diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted-inventory.json b/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted-inventory.json new file mode 100644 index 0000000000000000000000000000000000000000..6926ef1c22ed56457101c37cd70e0fe0d1656f0c --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted-inventory.json @@ -0,0 +1,242 @@ +{ + "directory_roots": [ + "pypika/tests" + ], + "files": { + "pypika/tests/__init__.py": { + "bytes": 58, + "mode": 420, + "sha256": "7d41f44b87688bdf162e6d5cbe7b517cfba468f96eaa421f02718c17eb486a18" + }, + "pypika/tests/clickhouse/__init__.py": { + "bytes": 0, + "mode": 420, + "sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "pypika/tests/clickhouse/test_array.py": { + "bytes": 2942, + "mode": 420, + "sha256": "0f0a5b4c3daf3ddce2944b6119795e80d50b74e4687ef2e34399e5d21d3d48ae" + }, + "pypika/tests/clickhouse/test_condition.py": { + "bytes": 2533, + "mode": 420, + "sha256": "c666976d082b1d12cd57e791d1a525183246335efad96a369b58871a6f1e4fa1" + }, + "pypika/tests/clickhouse/test_dates_and_times.py": { + "bytes": 2508, + "mode": 420, + "sha256": "cb8ea84363e35ad0a00b52a8ec20cb38f2348f4cba28d026a4c32c14fd1fc56f" + }, + "pypika/tests/clickhouse/test_nullable_arg.py": { + "bytes": 672, + "mode": 420, + "sha256": "883c5161ebeb09544ce124d20a096d248bd12a0404ad77c84637be75d6738529" + }, + "pypika/tests/clickhouse/test_search_string.py": { + "bytes": 1189, + "mode": 420, + "sha256": "d5f0ed6a51cf550bdd4b261fa2e98084184dd1cbb08f5dbb8b91278b4c8f3bfd" + }, + "pypika/tests/clickhouse/test_type_conversion.py": { + "bytes": 4445, + "mode": 420, + "sha256": "7e6045b64433a8947346cfb34ac30279349f7a2e2081a2815212c8cb7d0235ab" + }, + "pypika/tests/dialects/__init__.py": { + "bytes": 0, + "mode": 420, + "sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "pypika/tests/dialects/test_clickhouse.py": { + "bytes": 5747, + "mode": 420, + "sha256": "2272538d6eeb6dfb01f9803eed328b4cd4efc8d255b6a8ab3c4e25bee74d73fa" + }, + "pypika/tests/dialects/test_mssql.py": { + "bytes": 3152, + "mode": 420, + "sha256": "0cd9b2ee6498caa9fa75a51ead30803057fb23deb2ac706d396d88329e0e91d7" + }, + "pypika/tests/dialects/test_mysql.py": { + "bytes": 2984, + "mode": 420, + "sha256": "a5f4550dd14bf4820e5d85cf06b6c7c79286e41d2d3c794f639579d20fffab92" + }, + "pypika/tests/dialects/test_oracle.py": { + "bytes": 1906, + "mode": 420, + "sha256": "67f80eb40cc9b4dabcbad355e8be6d83c54a64cbee809182ef57fa9f48d2ebc6" + }, + "pypika/tests/dialects/test_postgresql.py": { + "bytes": 9532, + "mode": 420, + "sha256": "548ee7267ca87c9e1ae82ca89a4e5bd96c7392a55cc07996f2b105f911ffa6cf" + }, + "pypika/tests/dialects/test_snowflake.py": { + "bytes": 2159, + "mode": 420, + "sha256": "e567b9dab0a5366bd11a0ef162c3a3bb492280b78bc4b397a23070563dc84468" + }, + "pypika/tests/dialects/test_sqllite.py": { + "bytes": 1243, + "mode": 420, + "sha256": "118fed7e575415f276bda390a119080bd6a767aee3d9c953e11a8c219f0f017c" + }, + "pypika/tests/dialects/test_vertica.py": { + "bytes": 3578, + "mode": 420, + "sha256": "33a027e6735ca03b7afd11394905c4193e48a15dda3efbe47cdcd85fcabf840c" + }, + "pypika/tests/test_aggregate.py": { + "bytes": 3946, + "mode": 420, + "sha256": "5b0fb549de3bb50ad88ae1d75824f12f7ab4a5f1102b06a70c7b2ebae33bea6d" + }, + "pypika/tests/test_analytic_queries.py": { + "bytes": 20611, + "mode": 420, + "sha256": "8546b7a296c8e212c349c4baff95f93934b3120f74625b3945ade3b438e3a3ed" + }, + "pypika/tests/test_create.py": { + "bytes": 9088, + "mode": 420, + "sha256": "6c57302da52ca1044be0afdafe677d5de245e44873dff1386c9a1ccb2625cc82" + }, + "pypika/tests/test_criterions.py": { + "bytes": 32014, + "mode": 420, + "sha256": "78539ccca82f9a02fad0f5a39041ac343e3a142ce52368cd4f6ada489c52516a" + }, + "pypika/tests/test_custom_functions.py": { + "bytes": 1710, + "mode": 420, + "sha256": "bfa18bc328a3577965db7cc75eb94439f0cfd95a3775d9b1cc8af1062bb202cb" + }, + "pypika/tests/test_data_types.py": { + "bytes": 403, + "mode": 420, + "sha256": "c1be6ecc621a80dd91d35b1427bdfc8b1b33bd926515198e626d6fb5e1878c8b" + }, + "pypika/tests/test_date_math.py": { + "bytes": 5544, + "mode": 420, + "sha256": "85aa54efe54fe19639f2dc2a5750647e3337ac2681768bc3fe327841f1634d9e" + }, + "pypika/tests/test_deletes.py": { + "bytes": 3204, + "mode": 420, + "sha256": "ccde6df760d76d5d499ce828f6b0e2ad3eebcb2a5553c1890f481b9160b8d51a" + }, + "pypika/tests/test_drop.py": { + "bytes": 1556, + "mode": 420, + "sha256": "a13dffa59ef8657398d5498c18977bfd702635e336ea9966b1a86137afca7926" + }, + "pypika/tests/test_formats.py": { + "bytes": 1948, + "mode": 420, + "sha256": "240458a404bb119322778893b94a12be0f98f914acd701d2b4be73eb9be96f75" + }, + "pypika/tests/test_functions.py": { + "bytes": 32769, + "mode": 420, + "sha256": "3ceaac7791bd27e50f44e1b4a1451d1e09afe6a8011052caea838e5124582154" + }, + "pypika/tests/test_groupby_modifiers.py": { + "bytes": 5227, + "mode": 420, + "sha256": "9db4497660f08e3352a9a02c34889ad1cd6bab3aebaeaa485e84390ad71c84c5" + }, + "pypika/tests/test_immutability.py": { + "bytes": 3954, + "mode": 420, + "sha256": "af537ced19f7274951cc91697eae748ef6c9cd20a8d8e492d93dc85b06f8fb50" + }, + "pypika/tests/test_inserts.py": { + "bytes": 32549, + "mode": 420, + "sha256": "652e9f7f0f425e9acc0f70e2851ae29310b378262ea30369ea0113ef428f210f" + }, + "pypika/tests/test_internals.py": { + "bytes": 828, + "mode": 420, + "sha256": "4374c2632563346d00ca4de6af397a022ef3f5022e808c8711a3f207a3a21609" + }, + "pypika/tests/test_joins.py": { + "bytes": 43895, + "mode": 420, + "sha256": "53f224815c10393382443f020cb20e313420764495a8fd30f7ea2f34fd52935d" + }, + "pypika/tests/test_negation.py": { + "bytes": 763, + "mode": 420, + "sha256": "6be105e8f39b32fb23e6ac7c7158232ee78111455d4f35638c8af60781138c79" + }, + "pypika/tests/test_parameter.py": { + "bytes": 7382, + "mode": 420, + "sha256": "aaf2a3e79c8267bdc60e218445bc2a2254b97cf37b643a44d6f1a8141cbb5104" + }, + "pypika/tests/test_pseudocolumns.py": { + "bytes": 1609, + "mode": 420, + "sha256": "b7c69f7aca41323c0e14a6a9e58697399cd7860610f07291afc6e8af26079ca2" + }, + "pypika/tests/test_query.py": { + "bytes": 9025, + "mode": 420, + "sha256": "2da9d717673912a84e86e6c0d3955dbd8f2fa7b41b7ed9a6f78089dfa28f9444" + }, + "pypika/tests/test_selects.py": { + "bytes": 50757, + "mode": 420, + "sha256": "5ac1b7ad3248d64b1e3865a72c763873514ae5cd6e03356b913e531c0c336986" + }, + "pypika/tests/test_tables.py": { + "bytes": 6568, + "mode": 420, + "sha256": "384c8e843ba56374ee92cd7b7e2fd3f89247b899e23cd9e1f6663d751ad5d884" + }, + "pypika/tests/test_terms.py": { + "bytes": 3215, + "mode": 420, + "sha256": "8598513180ddcd28cc61582618d85bd570280978b07603044dae81b2eb099f77" + }, + "pypika/tests/test_tuples.py": { + "bytes": 6033, + "mode": 420, + "sha256": "863942196a93e8939be0d03c49cfeb42a35503ad42f9f3d6c730260112811087" + }, + "pypika/tests/test_updates.py": { + "bytes": 5689, + "mode": 420, + "sha256": "0f0f2521bb8d1f5d782f8fabaea5fd1d82090cde045ba87fad65770db6c75d2f" + }, + "pypika/tests/test_utils.py": { + "bytes": 834, + "mode": 420, + "sha256": "5db6e90df5daaa70b9f35f1243db69908da1f27887f63466fc27ce20c7e14892" + }, + "pyproject.toml": { + "bytes": 390, + "mode": 420, + "sha256": "037fedacd5be5d078f398265ff97e1677e25214ad8839d17073a439695ee7a91" + }, + "setup.cfg": { + "bytes": 317, + "mode": 420, + "sha256": "c84a31de586e8385e741127b004fc1f19ebae6463cdf0b3f243991db35cdeaea" + }, + "setup.py": { + "bytes": 2638, + "mode": 420, + "sha256": "f8bad274588a22e65764d8cf9fb2be5aa6fcfaf3bf861d71e5f751105898845a" + }, + "tox.ini": { + "bytes": 257, + "mode": 420, + "sha256": "c2d7205d0ac93e9c9e80dc5d24f0a826a6781f587a33ea722ea621f9e2ccd0ea" + } + } +} diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/__init__.py b/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..86d8a68101915c27b95484243dd81d55f7dba356 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/__init__.py @@ -0,0 +1,2 @@ +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/clickhouse/__init__.py b/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/clickhouse/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/clickhouse/test_array.py b/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/clickhouse/test_array.py new file mode 100644 index 0000000000000000000000000000000000000000..469705a9ff3c8fe9cc7f02c44a9812521eeb67f4 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/clickhouse/test_array.py @@ -0,0 +1,104 @@ +import unittest + +from parameterized import parameterized + +from pypika import Field +from pypika.clickhouse.array import ( + Array, + Empty, + HasAny, + Length, + NotEmpty, +) +from pypika.clickhouse.type_conversion import ( + ToFixedString, + ToInt64, +) + + +class TestArray(unittest.TestCase): + @parameterized.expand( + [ + ( + "['ridley', 'scott', 'jimi', 'hendrix']", + Array(["ridley", "scott", "jimi", "hendrix"]), + ), + ( + "[1, 2, 3, 4]", + Array([1, 2, 3, 4]), + ), + ( + "[toInt64('1'),toInt64('2'),toInt64('3'),toInt64('4')]", + Array(["1", "2", "3", "4"], ToInt64), + ), + ( + "[toFixedString('mogwai',10),toFixedString('mono',10),toFixedString('bonobo',10)] arr", + Array(["mogwai", "mono", "bonobo"], ToFixedString, {"length": 10}).as_('arr'), + ), + ] + ) + def test_get_sql(self, expected: str, array: Array): + self.assertEqual(expected, array.get_sql()) + + +class TestHasAny(unittest.TestCase): + @parameterized.expand( + [ + ( + 'hasAny("mental_abilities","physical_abilities")', + HasAny(Field("mental_abilities"), Field("physical_abilities")), + ), + ("hasAny([1, 2, 3, 4],[3])", HasAny(Array([1, 2, 3, 4]), Array([3]))), + ( + "hasAny(\"bands\",[toFixedString('port-royal',20),toFixedString('hammock',20)])", + HasAny( + Field("bands"), + Array(["port-royal", "hammock"], ToFixedString, {"length": 20}), + ), + ), + ] + ) + def test_get_sql(self, expected: str, func: HasAny): + self.assertEqual(expected, func.get_sql()) + + +class TestLength(unittest.TestCase): + @parameterized.expand( + [ + ( + 'length("tags")', + Length(Field("tags")), + ), + ("length([1, 2, 3])", Length(Array([1, 2, 3]))), + ] + ) + def test_get_sql(self, expected: str, func: Length): + self.assertEqual(expected, func.get_sql()) + + +class TestEmpty(unittest.TestCase): + @parameterized.expand( + [ + ( + 'empty("tags")', + Empty(Field("tags")), + ), + ("empty([1, 2, 3])", Empty(Array([1, 2, 3]))), + ] + ) + def test_get_sql(self, expected: str, func: Empty): + self.assertEqual(expected, func.get_sql()) + + +class TestNotEmpty(unittest.TestCase): + @parameterized.expand( + [ + ( + 'notEmpty("tags")', + NotEmpty(Field("tags")), + ), + ("notEmpty([1, 2, 3])", NotEmpty(Array([1, 2, 3]))), + ] + ) + def test_get_sql(self, expected: str, func: NotEmpty): + self.assertEqual(expected, func.get_sql()) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/clickhouse/test_condition.py b/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/clickhouse/test_condition.py new file mode 100644 index 0000000000000000000000000000000000000000..145baeb7753dd9cbefbd6f272bd672ae5730b0c0 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/clickhouse/test_condition.py @@ -0,0 +1,72 @@ +import unittest + +from parameterized import parameterized + +from pypika import Field +from pypika.clickhouse.condition import If, MultiIf +from pypika.clickhouse.type_conversion import ToFixedString + + +class TestIfCondition(unittest.TestCase): + @parameterized.expand( + [ + ( + If( + Field("filmmaker").isnull(), + ToFixedString("Tarantino", 20), + Field("filmmaker"), + ), + "if(filmmaker IS NULL,toFixedString('Tarantino',20),filmmaker)", + ), + ( + If( + Field("created") == Field("updated"), + ToFixedString("yes", 3), + ToFixedString("no", 3), + ), + "if(created=updated,toFixedString('yes',3),toFixedString('no',3))", + ), + ] + ) + def test_get_sql(self, func, expected): + self.assertEqual(func.get_sql(), expected) + + +class TestMultiIfCondition(unittest.TestCase): + @parameterized.expand( + [ + ( + MultiIf( + Field("filmmaker").isnull(), + ToFixedString("Tarantino", 20), + Field("filmmaker") == ToFixedString("undefined", 20), + ToFixedString("Tarantino", 20), + Field("filmmaker"), + ), + "multiIf(filmmaker IS NULL," + "toFixedString('Tarantino',20)," + "filmmaker=toFixedString('undefined',20)," + "toFixedString('Tarantino',20),filmmaker)", + ), + ( + MultiIf( + Field("color") == ToFixedString("black", 20), + ToFixedString("dark", 20), + Field("color") == ToFixedString("grey", 20), + ToFixedString("dark", 20), + Field("color") == ToFixedString("white", 20), + ToFixedString("light", 20), + ToFixedString("undefined", 20), + ), + "multiIf(color=toFixedString('black',20)," + "toFixedString('dark',20)," + "color=toFixedString('grey',20)," + "toFixedString('dark',20)," + "color=toFixedString('white',20)," + "toFixedString('light',20)," + "toFixedString('undefined',20))", + ), + ] + ) + def test_get_sql(self, func, expected): + self.assertEqual(func.get_sql(), expected) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/clickhouse/test_dates_and_times.py b/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/clickhouse/test_dates_and_times.py new file mode 100644 index 0000000000000000000000000000000000000000..135dd7f112131776d76748e15eead1eb81752b59 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/clickhouse/test_dates_and_times.py @@ -0,0 +1,70 @@ +import unittest + +from parameterized import parameterized + +from pypika import Field +from pypika.clickhouse.dates_and_times import ( + AddDays, + AddHours, + AddMinutes, + AddMonths, + AddQuarters, + AddSeconds, + AddWeeks, + AddYears, + FormatDateTime, + SubtractDays, + SubtractHours, + SubtractMinutes, + SubtractMonths, + SubtractQuarters, + SubtractSeconds, + SubtractWeeks, + SubtractYears, + ToYYYYMM, +) + + +class TestFormatDateTime(unittest.TestCase): + @parameterized.expand( + [ + (FormatDateTime(Field("created"), "%V"), "formatDateTime(created,'%V')"), + ( + FormatDateTime(Field("created"), "%Y-%m-%d"), + "formatDateTime(created,'%Y-%m-%d')", + ), + ] + ) + def test_get_sql(self, func, expected): + self.assertEqual(func.get_sql(), expected) + + +class TestAddSubtractDt(unittest.TestCase): + @parameterized.expand( + [ + (AddYears(Field("created"), 1), "addYears(created,1)"), + (AddMonths(Field("created"), 2), "addMonths(created,2)"), + (AddWeeks(Field("created"), 3), "addWeeks(created,3)"), + (AddDays(Field("created"), 4), "addDays(created,4)"), + (AddHours(Field("created"), 5), "addHours(created,5)"), + (AddMinutes(Field("created"), 6), "addMinutes(created,6)"), + (AddSeconds(Field("created"), 7), "addSeconds(created,7)"), + (AddQuarters(Field("created"), 8), "addQuarters(created,8)"), + (SubtractYears(Field("created"), 9), "subtractYears(created,9)"), + (SubtractMonths(Field("created"), 10), "subtractMonths(created,10)"), + (SubtractWeeks(Field("created"), 11), "subtractWeeks(created,11)"), + (SubtractDays(Field("created"), 12), "subtractDays(created,12)"), + (SubtractHours(Field("created"), 13), "subtractHours(created,13)"), + (SubtractHours(Field("created"), 13), "subtractHours(created,13)"), + (SubtractMinutes(Field("created"), 14), "subtractMinutes(created,14)"), + (SubtractSeconds(Field("created"), 15), "subtractSeconds(created,15)"), + (SubtractQuarters(Field("created"), 16), "subtractQuarters(created,16)"), + ] + ) + def test_get_sql(self, func, expected): + self.assertEqual(func.get_sql(), expected) + + +class TestToYYYYMM(unittest.TestCase): + def test_get_sql(self): + self.assertEqual(ToYYYYMM(Field("created").get_sql()), "toYYYYMM(created)") diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/clickhouse/test_nullable_arg.py b/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/clickhouse/test_nullable_arg.py new file mode 100644 index 0000000000000000000000000000000000000000..3c6c86207a4d0206b5c0ba80b77fac4cc257fa17 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/clickhouse/test_nullable_arg.py @@ -0,0 +1,24 @@ +import unittest + +from parameterized import parameterized + +from pypika import Field +from pypika.clickhouse.nullable_arg import IfNull +from pypika.clickhouse.type_conversion import ToFixedString + + +class TestSearchString(unittest.TestCase): + @parameterized.expand( + [ + ( + IfNull(Field("name"), Field("login")), + "ifNull(name,login)", + ), + ( + IfNull(Field("builder"), ToFixedString("pypika", 100)), + "ifNull(builder,toFixedString('pypika',100))", + ), + ] + ) + def test_get_sql(self, func, expected): + self.assertEqual(func.get_sql(), expected) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/clickhouse/test_search_string.py b/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/clickhouse/test_search_string.py new file mode 100644 index 0000000000000000000000000000000000000000..9778eb32e47d4370c0bfe36dcd875903666d30b6 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/clickhouse/test_search_string.py @@ -0,0 +1,41 @@ +import unittest + +from parameterized import parameterized + +from pypika import Field +from pypika.clickhouse.search_string import ( + Match, + Like, + NotLike, + MultiSearchAny, + MultiMatchAny, +) + + +class TestSearchString(unittest.TestCase): + @parameterized.expand( + [ + (Match(Field("name"), "twheys"), "match(toString(\"name\"),'twheys')"), + (Like(Field("name"), "twheys"), "like(toString(\"name\"),'twheys')"), + (NotLike(Field("name"), "twheys"), "notLike(toString(\"name\"),'twheys')"), + ] + ) + def test_search_string(self, func, expected): + self.assertEqual(func, expected) + + +class TestMultiSearch(unittest.TestCase): + @parameterized.expand( + [ + ( + MultiSearchAny(Field("name"), ["sarah", "connor"]), + "multiSearchAny(toString(\"name\"),['sarah','connor'])", + ), + ( + MultiMatchAny(Field("name"), ["sarah", "connor"]), + "multiMatchAny(toString(\"name\"),['sarah','connor'])", + ), + ] + ) + def test_multi_search_string(self, func, expected): + self.assertEqual(func.get_sql(), expected) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/clickhouse/test_type_conversion.py b/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/clickhouse/test_type_conversion.py new file mode 100644 index 0000000000000000000000000000000000000000..9692e17bee901e2629db9a5c77111e145358e8eb --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/clickhouse/test_type_conversion.py @@ -0,0 +1,176 @@ +import unittest + +from parameterized import parameterized + +from pypika import ClickHouseQuery, Field, Table +from pypika.clickhouse.type_conversion import ( + ToDate, + ToDateTime, + ToFixedString, + ToFloat32, + ToFloat64, + ToInt16, + ToInt32, + ToInt64, + ToInt8, + ToString, + ToUInt16, + ToUInt32, + ToUInt64, + ToUInt8, +) + + +class TestBasicTypeConverters(unittest.TestCase): + @parameterized.expand( + [ + ( + 'toString("field_name")', + ToString(Field("field_name")), + ), + ( + 'toInt8("field_name")', + ToInt8(Field("field_name")), + ), + ( + 'toInt16("field_name")', + ToInt16(Field("field_name")), + ), + ( + 'toInt32("field_name")', + ToInt32(Field("field_name")), + ), + ( + 'toInt64("field_name")', + ToInt64(Field("field_name")), + ), + ( + 'toUInt8("field_name")', + ToUInt8(Field("field_name")), + ), + ( + 'toUInt16("field_name")', + ToUInt16(Field("field_name")), + ), + ( + 'toUInt32("field_name")', + ToUInt32(Field("field_name")), + ), + ( + 'toUInt64("field_name")', + ToUInt64(Field("field_name")), + ), + ( + 'toFloat32("field_name")', + ToFloat32(Field("field_name")), + ), + ( + 'toFloat64("field_name")', + ToFloat64(Field("field_name")), + ), + ( + 'toFloat64("field_name")', + ToFloat64(Field("field_name")), + ), + ( + 'toDate("field_name")', + ToDate(Field("field_name")), + ), + ( + 'toDateTime("field_name")', + ToDateTime(Field("field_name")), + ), + ( + 'toFixedString("field_name",100)', + ToFixedString(Field("field_name"), 100), + ), + ] + ) + def test_basic_types_field(self, expected, func): + self.assertEqual(func, expected) + + @parameterized.expand( + [ + ( + "toString('100')", + ToString("100"), + ), + ( + "toInt8('100')", + ToInt8("100"), + ), + ( + "toInt16('100')", + ToInt16("100"), + ), + ( + "toInt32('100')", + ToInt32("100"), + ), + ( + "toInt64('100')", + ToInt64("100"), + ), + ( + "toUInt8('100')", + ToUInt8("100"), + ), + ( + "toUInt16('100')", + ToUInt16("100"), + ), + ( + "toUInt32('100')", + ToUInt32("100"), + ), + ( + "toUInt64('100')", + ToUInt64("100"), + ), + ( + "toFloat32('100')", + ToFloat32("100"), + ), + ( + "toFloat64('100')", + ToFloat64("100"), + ), + ( + "toFloat64('100')", + ToFloat64("100"), + ), + ( + "toDate('100')", + ToDate("100"), + ), + ( + "toDateTime('100')", + ToDateTime("100"), + ), + ( + "toFixedString('100',100)", + ToFixedString("100", 100), + ), + ] + ) + def test_basic_types_value(self, expected, func): + self.assertEqual(func, expected) + + +class TestToFixedString(unittest.TestCase): + def test_get_sql_with_table(self): + table = Table("example") + query = ( + ClickHouseQuery.from_(table) + .select( + table.name, + ) + .where( + table.name == ToFixedString("name", 50), + ) + ) + + self.assertEqual( + 'SELECT "name" FROM "example" WHERE "name"=toFixedString(\'name\',50)', + query.get_sql(), + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/dialects/__init__.py b/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/dialects/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/dialects/test_clickhouse.py b/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/dialects/test_clickhouse.py new file mode 100644 index 0000000000000000000000000000000000000000..f319c4627bd25d7004894181906a284b8b1c64cf --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/dialects/test_clickhouse.py @@ -0,0 +1,146 @@ +from unittest import TestCase + +from pypika import ( + ClickHouseQuery, + Database, + Table, +) + + +class ClickHouseQueryTests(TestCase): + def test_use_AS_keyword_for_alias(self): + t = Table('abc') + query = ClickHouseQuery.from_(t).select(t.foo.as_('f1'), t.bar.as_('f2')) + self.assertEqual(str(query), 'SELECT "foo" AS "f1","bar" AS "f2" FROM "abc"') + + def test_use_SAMPLE_keyword(self): + t = Table('abc') + query = ClickHouseQuery.from_(t).select(t.foo).sample(10) + self.assertEqual(str(query), 'SELECT "foo" FROM "abc" SAMPLE 10') + + def test_use_SAMPLE_with_offset_keyword(self): + t = Table('abc') + query = ClickHouseQuery.from_(t).select(t.foo).sample(10, 5) + self.assertEqual(str(query), 'SELECT "foo" FROM "abc" SAMPLE 10 OFFSET 5') + + def test_use_FINAL_keyword(self): + t = Table('abc') + query = ClickHouseQuery.from_(t).select(t.foo).final() + self.assertEqual(str(query), 'SELECT "foo" FROM "abc" FINAL') + + +class ClickHouseDeleteTests(TestCase): + table_abc = Table("abc") + + def test_omit_where(self): + q = ClickHouseQuery.from_("abc").delete() + + self.assertEqual('ALTER TABLE "abc" DELETE', str(q)) + + def test_omit_where__table_schema(self): + q = ClickHouseQuery.from_(Table("abc", "schema1")).delete() + + self.assertEqual('ALTER TABLE "schema1"."abc" DELETE', str(q)) + + def test_where_field_equals(self): + q1 = ClickHouseQuery.from_(self.table_abc).where(self.table_abc.foo == self.table_abc.bar).delete() + q2 = ClickHouseQuery.from_(self.table_abc).where(self.table_abc.foo.eq(self.table_abc.bar)).delete() + + self.assertEqual('ALTER TABLE "abc" DELETE WHERE "foo"="bar"', str(q1)) + self.assertEqual('ALTER TABLE "abc" DELETE WHERE "foo"="bar"', str(q2)) + + +class ClickHouseUpdateTests(TestCase): + table_abc = Table("abc") + + def test_update(self): + q = ClickHouseQuery.update(self.table_abc).where(self.table_abc.foo == 0).set("foo", "bar") + + self.assertEqual('ALTER TABLE "abc" UPDATE "foo"=\'bar\' WHERE "foo"=0', str(q)) + + +class ClickHouseDropQuery(TestCase): + table_abc = Table("abc") + database_xyz = Database("mydb") + cluster_name = "mycluster" + + def test_drop_database(self): + q1 = ClickHouseQuery.drop_database(self.database_xyz) + q2 = ClickHouseQuery.drop_database(self.database_xyz).on_cluster(self.cluster_name) + q3 = ClickHouseQuery.drop_database(self.database_xyz).if_exists().on_cluster(self.cluster_name) + + self.assertEqual('DROP DATABASE "mydb"', str(q1)) + self.assertEqual('DROP DATABASE "mydb" ON CLUSTER "mycluster"', str(q2)) + self.assertEqual('DROP DATABASE IF EXISTS "mydb" ON CLUSTER "mycluster"', str(q3)) + + def test_drop_table(self): + q1 = ClickHouseQuery.drop_table(self.table_abc) + q2 = ClickHouseQuery.drop_table(self.table_abc).on_cluster(self.cluster_name) + q3 = ClickHouseQuery.drop_table(self.table_abc).if_exists().on_cluster(self.cluster_name) + + self.assertEqual('DROP TABLE "abc"', str(q1)) + self.assertEqual('DROP TABLE "abc" ON CLUSTER "mycluster"', str(q2)) + self.assertEqual('DROP TABLE IF EXISTS "abc" ON CLUSTER "mycluster"', str(q3)) + + def test_drop_dictionary(self): + q1 = ClickHouseQuery.drop_dictionary("dict") + q2 = ClickHouseQuery.drop_dictionary("dict").on_cluster(self.cluster_name) + q3 = ClickHouseQuery.drop_dictionary("dict").if_exists().on_cluster(self.cluster_name) + + self.assertEqual('DROP DICTIONARY "dict"', str(q1)) + self.assertEqual('DROP DICTIONARY "dict"', str(q2)) # NO CLUSTER + self.assertEqual('DROP DICTIONARY IF EXISTS "dict"', str(q3)) # NO CLUSTER + + def test_drop_other(self): + q1 = ClickHouseQuery.drop_quota("myquota") + q2 = ClickHouseQuery.drop_user("myuser") + q3 = ClickHouseQuery.drop_view("myview") + + self.assertEqual('DROP QUOTA "myquota"', str(q1)) + self.assertEqual('DROP USER "myuser"', str(q2)) + self.assertEqual('DROP VIEW "myview"', str(q3)) + + +class DistinctOnTests(TestCase): + table_abc = Table("abc") + + def test_distinct_on(self): + q = ClickHouseQuery.from_(self.table_abc).distinct_on("lname", self.table_abc.fname).select("lname", "id") + + self.assertEqual('''SELECT DISTINCT ON("lname","fname") "lname","id" FROM "abc"''', str(q)) + + +class LimitByTests(TestCase): + table_abc = Table("abc") + + def test_limit_by(self): + q = ClickHouseQuery.from_(self.table_abc).limit_by(1, "a", self.table_abc.b).select("a", "b", "c") + + self.assertEqual('''SELECT "a","b","c" FROM "abc" LIMIT 1 BY ("a","b")''', str(q)) + + def test_limit_offset_by(self): + q = ClickHouseQuery.from_(self.table_abc).limit_offset_by(1, 2, "a", self.table_abc.b).select("a", "b", "c") + + self.assertEqual('''SELECT "a","b","c" FROM "abc" LIMIT 1 OFFSET 2 BY ("a","b")''', str(q)) + + def test_limit_offset0_by(self): + q = ClickHouseQuery.from_(self.table_abc).limit_offset_by(1, 0, "a", self.table_abc.b).select("a", "b", "c") + + self.assertEqual('''SELECT "a","b","c" FROM "abc" LIMIT 1 BY ("a","b")''', str(q)) + + def test_rename_table(self): + table_join = Table("join") + + q = ( + ClickHouseQuery.from_(self.table_abc) + .join(table_join) + .using("a") + .limit_by(1, self.table_abc.a, table_join.a) + .select(self.table_abc.b, table_join.b) + ) + q = q.replace_table(self.table_abc, Table("xyz")) + + self.assertEqual( + '''SELECT "xyz"."b","join"."b" FROM "xyz" JOIN "join" USING ("a") LIMIT 1 BY ("xyz"."a","join"."a")''', + str(q), + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/dialects/test_mssql.py b/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/dialects/test_mssql.py new file mode 100644 index 0000000000000000000000000000000000000000..7cf53b228f413a8c7cd3e414fef5522a82f99b29 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/dialects/test_mssql.py @@ -0,0 +1,81 @@ +import unittest + +from pypika import Table +from pypika.analytics import Count +from pypika.dialects import MSSQLQuery +from pypika.utils import QueryException + + +class SelectTests(unittest.TestCase): + def test_normal_select(self): + q = MSSQLQuery.from_("abc").select("def") + + self.assertEqual('SELECT "def" FROM "abc"', str(q)) + + def test_distinct_select(self): + q = MSSQLQuery.from_("abc").select("def").distinct() + + self.assertEqual('SELECT DISTINCT "def" FROM "abc"', str(q)) + + def test_top_distinct_select(self): + q = MSSQLQuery.from_("abc").select("def").top(10).distinct() + + self.assertEqual('SELECT DISTINCT TOP (10) "def" FROM "abc"', str(q)) + + def test_top_select(self): + q = MSSQLQuery.from_("abc").select("def").top(10) + + self.assertEqual('SELECT TOP (10) "def" FROM "abc"', str(q)) + + def test_top_with_ties_select(self): + q = MSSQLQuery.from_("abc").select("def").top(10, with_ties=True) + + self.assertEqual('SELECT TOP (10) WITH TIES "def" FROM "abc"', str(q)) + + def test_top_percent_select(self): + q = MSSQLQuery.from_("abc").select("def").top(10, percent=True) + + self.assertEqual('SELECT TOP (10) PERCENT "def" FROM "abc"', str(q)) + + def test_top_percent_invalid_range(self): + for invalid_top in [-1, 101]: + with self.assertRaisesRegex( + QueryException, "TOP value must be between 0 and 100 when `percent` is specified" + ): + MSSQLQuery.from_("abc").select("def").top(invalid_top, percent=True) + + def test_top_select_non_int(self): + with self.assertRaisesRegex(QueryException, "TOP value must be an integer"): + MSSQLQuery.from_("abc").select("def").top("a") + + def test_limit(self): + q = MSSQLQuery.from_("abc").select("def").orderby("def").limit(10) + + self.assertEqual('SELECT "def" FROM "abc" ORDER BY "def" OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY', str(q)) + + def test_offset(self): + q = MSSQLQuery.from_("abc").select("def").orderby("def").offset(10) + + self.assertEqual('SELECT "def" FROM "abc" ORDER BY "def" OFFSET 10 ROWS', str(q)) + + def test_limit_with_offset(self): + q = MSSQLQuery.from_("abc").select("def").orderby("def").limit(10).offset(10) + + self.assertEqual('SELECT "def" FROM "abc" ORDER BY "def" OFFSET 10 ROWS FETCH NEXT 10 ROWS ONLY', str(q)) + + def test_groupby_alias_False_does_not_group_by_alias_with_standard_query(self): + t = Table('table1') + col = t.abc.as_('a') + q = MSSQLQuery.from_(t).select(col, Count('*')).groupby(col) + + self.assertEqual('SELECT "abc" "a",COUNT(\'*\') FROM "table1" GROUP BY "abc"', str(q)) + + def test_groupby_alias_False_does_not_group_by_alias_when_subqueries_are_present(self): + t = Table('table1') + subquery = MSSQLQuery.from_(t).select(t.abc) + col = subquery.abc.as_('a') + q = MSSQLQuery.from_(subquery).select(col, Count('*')).groupby(col) + + self.assertEqual( + 'SELECT "sq0"."abc" "a",COUNT(\'*\') FROM (SELECT "abc" FROM "table1") "sq0" GROUP BY "sq0"."abc"', str(q) + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/dialects/test_mysql.py b/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/dialects/test_mysql.py new file mode 100644 index 0000000000000000000000000000000000000000..619d064adcdf8b5ff9ecd054fa4ab00eff1d69b3 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/dialects/test_mysql.py @@ -0,0 +1,91 @@ +import unittest + +from pypika import MySQLQuery, QueryException, Table, Column + + +class SelectTests(unittest.TestCase): + table_abc = Table("abc") + + def test_normal_select(self): + q = MySQLQuery.from_("abc").select("def") + + self.assertEqual("SELECT `def` FROM `abc`", str(q)) + + def test_distinct_select(self): + q = MySQLQuery.from_("abc").select("def").distinct() + + self.assertEqual("SELECT DISTINCT `def` FROM `abc`", str(q)) + + def test_modifier_select(self): + q = MySQLQuery.from_("abc").select("def").select("ghi").modifier("SQL_CALC_FOUND_ROWS") + + self.assertEqual("SELECT SQL_CALC_FOUND_ROWS `def`,`ghi` FROM `abc`", str(q)) + + def test_multiple_modifier_select(self): + q = MySQLQuery.from_("abc").select("def").modifier("HIGH_PRIORITY").modifier("SQL_CALC_FOUND_ROWS") + + self.assertEqual("SELECT HIGH_PRIORITY SQL_CALC_FOUND_ROWS `def` FROM `abc`", str(q)) + + +class UpdateTests(unittest.TestCase): + table_abc = Table("abc") + + def test_update(self): + q = MySQLQuery.into("abc").insert(1, [1, "a", True]) + + self.assertEqual("INSERT INTO `abc` VALUES (1,[1,'a',true])", str(q)) + + def test_on_duplicate_key_ignore_update(self): + q = MySQLQuery.into("abc").insert(1, [1, "a", True]).on_duplicate_key_ignore() + + self.assertEqual("INSERT INTO `abc` VALUES (1,[1,'a',true]) ON DUPLICATE KEY IGNORE", str(q)) + + def test_on_duplicate_key_update_update(self): + q = MySQLQuery.into("abc").insert(1, [1, "a", True]).on_duplicate_key_update(self.table_abc.a, 'b') + + self.assertEqual("INSERT INTO `abc` VALUES (1,[1,'a',true]) ON DUPLICATE KEY UPDATE `a`='b'", str(q)) + + def test_conflict_handlers_update(self): + with self.assertRaises(QueryException): + ( + MySQLQuery.into("abc") + .insert(1, [1, "a", True]) + .on_duplicate_key_ignore() + .on_duplicate_key_update(self.table_abc.a, 'b') + ) + + +class LoadCSVTests(unittest.TestCase): + table_abc = Table("abc") + + def test_load_from_file(self): + q1 = MySQLQuery.load("/path/to/file").into("abc") + + q2 = MySQLQuery.load("/path/to/file").into(self.table_abc) + + self.assertEqual( + "LOAD DATA LOCAL INFILE '/path/to/file' INTO TABLE `abc` FIELDS TERMINATED BY ','", + str(q1), + ) + self.assertEqual( + "LOAD DATA LOCAL INFILE '/path/to/file' INTO TABLE `abc` FIELDS TERMINATED BY ','", + str(q2), + ) + + +class TableTests(unittest.TestCase): + table_abc = Table("abc") + + def test_create_table(self): + q = MySQLQuery.create_table(self.table_abc).columns(Column("id", "INT")) + self.assertEqual( + 'CREATE TABLE `abc` (`id` INT)', + str(q), + ) + + def test_drop_table(self): + q = MySQLQuery.drop_table(self.table_abc) + self.assertEqual( + 'DROP TABLE `abc`', + str(q), + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/dialects/test_oracle.py b/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/dialects/test_oracle.py new file mode 100644 index 0000000000000000000000000000000000000000..21b54f16fd5d3518b5c767d3605068637898a73f --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/dialects/test_oracle.py @@ -0,0 +1,51 @@ +import unittest + +from pypika import OracleQuery, Table +from pypika.analytics import Count + + +class SelectTests(unittest.TestCase): + def test_groupby_alias_False_does_not_group_by_alias_with_standard_query(self): + t = Table('table1') + col = t.abc.as_('a') + q = OracleQuery.from_(t).select(col, Count('*')).groupby(col) + + self.assertEqual('SELECT abc a,COUNT(\'*\') FROM table1 GROUP BY abc', str(q)) + + def test_groupby_alias_False_does_not_group_by_alias_when_subqueries_are_present(self): + t = Table('table1') + subquery = OracleQuery.from_(t).select(t.abc) + col = subquery.abc.as_('a') + q = OracleQuery.from_(subquery).select(col, Count('*')).groupby(col) + + self.assertEqual('SELECT sq0.abc a,COUNT(\'*\') FROM (SELECT abc FROM table1) sq0 GROUP BY sq0.abc', str(q)) + + def test_limit_query(self): + t = Table('table1') + limit = 5 + q = OracleQuery.from_(t).select(t.test).limit(limit) + + self.assertEqual(f'SELECT test FROM table1 FETCH NEXT {limit} ROWS ONLY', str(q)) + + def test_offset_query(self): + t = Table('table1') + offset = 5 + q = OracleQuery.from_(t).select(t.test).offset(offset) + + self.assertEqual(f'SELECT test FROM table1 OFFSET {offset} ROWS', str(q)) + + def test_limit_offset_query(self): + t = Table('table1') + limit = 5 + offset = 5 + q = OracleQuery.from_(t).select(t.test).limit(limit).offset(offset) + + self.assertEqual(f'SELECT test FROM table1 OFFSET {offset} ROWS FETCH NEXT {limit} ROWS ONLY', str(q)) + + def test_fetch_next_method_deprecated(self): + with self.assertWarns(DeprecationWarning): + t = Table('table1') + limit = 5 + q = OracleQuery.from_(t).select(t.test).fetch_next(limit) + + self.assertEqual(f'SELECT test FROM table1 FETCH NEXT {limit} ROWS ONLY', str(q)) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/dialects/test_postgresql.py b/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/dialects/test_postgresql.py new file mode 100644 index 0000000000000000000000000000000000000000..437eed03e120485ed2a357a4c2d92426f1466e14 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/dialects/test_postgresql.py @@ -0,0 +1,262 @@ +import unittest +from collections import OrderedDict + +from pypika import ( + Array, + Field, + JSON, + QueryException, + Table, +) +from pypika.dialects import PostgreSQLQuery + + +class InsertTests(unittest.TestCase): + table_abc = Table("abc") + + def test_array_keyword(self): + q = PostgreSQLQuery.into(self.table_abc).insert(1, [1, "a", True]) + + self.assertEqual("INSERT INTO \"abc\" VALUES (1,ARRAY[1,'a',true])", str(q)) + + +class JSONObjectTests(unittest.TestCase): + def test_alias_set_correctly(self): + table = Table('jsonb_table') + q = PostgreSQLQuery.from_('abc').select(table.value.get_text_value('a').as_('name')) + + self.assertEqual('''SELECT "value"->>'a' "name" FROM "abc"''', str(q)) + + def test_json_value_from_dict(self): + q = PostgreSQLQuery.select(JSON({"a": "foo"})) + + self.assertEqual('SELECT \'{"a":"foo"}\'', str(q)) + + def test_json_value_from_array_num(self): + q = PostgreSQLQuery.select(JSON([1, 2, 3])) + + self.assertEqual("SELECT '[1,2,3]'", str(q)) + + def test_json_value_from_array_str(self): + q = PostgreSQLQuery.select(JSON(["a", "b", "c"])) + + self.assertEqual('SELECT \'["a","b","c"]\'', str(q)) + + def test_json_value_from_dict_recursive(self): + q = PostgreSQLQuery.select(JSON({"a": "z", "b": {"c": "foo"}, "d": 1})) + + # gotta split this one up to avoid the indeterminate order + sql = str(q) + start, end = 9, -2 + self.assertEqual("SELECT '{}'", sql[:start] + sql[end:]) + + members_set = set(sql[start:end].split(",")) + self.assertSetEqual({'"a":"z"', '"b":{"c":"foo"}', '"d":1'}, members_set) + + +class JSONOperatorsTests(unittest.TestCase): + # reference https://www.postgresql.org/docs/9.5/functions-json.html + table_abc = Table("abc") + + def test_get_json_value_by_key(self): + q = PostgreSQLQuery.from_(self.table_abc).select("*").where(self.table_abc.json.get_json_value("dates")) + + self.assertEqual('SELECT * FROM "abc" WHERE "json"->\'dates\'', str(q)) + + def test_get_json_value_by_index(self): + q = PostgreSQLQuery.from_(self.table_abc).select("*").where(self.table_abc.json.get_json_value(1)) + + self.assertEqual('SELECT * FROM "abc" WHERE "json"->1', str(q)) + + def test_get_text_value_by_key(self): + q = PostgreSQLQuery.from_(self.table_abc).select("*").where(self.table_abc.json.get_text_value("dates")) + + self.assertEqual('SELECT * FROM "abc" WHERE "json"->>\'dates\'', str(q)) + + def test_get_text_value_by_index(self): + q = PostgreSQLQuery.from_(self.table_abc).select("*").where(self.table_abc.json.get_text_value(1)) + + self.assertEqual('SELECT * FROM "abc" WHERE "json"->>1', str(q)) + + def test_get_path_json_value(self): + q = PostgreSQLQuery.from_(self.table_abc).select("*").where(self.table_abc.json.get_path_json_value("{a,b}")) + + self.assertEqual('SELECT * FROM "abc" WHERE "json"#>\'{a,b}\'', str(q)) + + def test_get_path_text_value(self): + q = PostgreSQLQuery.from_(self.table_abc).select("*").where(self.table_abc.json.get_path_text_value("{a,b}")) + + self.assertEqual('SELECT * FROM "abc" WHERE "json"#>>\'{a,b}\'', str(q)) + + +class JSONBOperatorsTests(unittest.TestCase): + # reference https://www.postgresql.org/docs/9.5/functions-json.html + table_abc = Table("abc") + + def test_json_contains_for_json(self): + q = PostgreSQLQuery.select(JSON({"a": 1, "b": 2}).contains({"a": 1})) + + # gotta split this one up to avoid the indeterminate order + sql = str(q) + start, end = 9, -13 + self.assertEqual("SELECT '{}'@>'{\"a\":1}'", sql[:start] + sql[end:]) + + members_set = set(sql[start:end].split(",")) + self.assertSetEqual({'"a":1', '"b":2'}, members_set) + + def test_json_contains_for_field(self): + q = ( + PostgreSQLQuery.from_(self.table_abc) + .select("*") + .where(self.table_abc.json.contains({"dates": "2018-07-10 - 2018-07-17"})) + ) + + self.assertEqual( + "SELECT * " 'FROM "abc" ' 'WHERE "json"@>\'{"dates":"2018-07-10 - 2018-07-17"}\'', + str(q), + ) + + def test_json_contained_by_using_str_arg(self): + q = ( + PostgreSQLQuery.from_(self.table_abc) + .select("*") + .where( + self.table_abc.json.contained_by( + OrderedDict( + [ + ("dates", "2018-07-10 - 2018-07-17"), + ("imported", "8"), + ] + ) + ) + ) + ) + self.assertEqual( + 'SELECT * FROM "abc" ' 'WHERE "json"<@\'{"dates":"2018-07-10 - 2018-07-17","imported":"8"}\'', + str(q), + ) + + def test_json_contained_by_using_list_arg(self): + q = ( + PostgreSQLQuery.from_(self.table_abc) + .select("*") + .where(self.table_abc.json.contained_by(["One", "Two", "Three"])) + ) + + self.assertEqual('SELECT * FROM "abc" WHERE "json"<@\'["One","Two","Three"]\'', str(q)) + + def test_json_contained_by_with_complex_criterion(self): + q = ( + PostgreSQLQuery.from_(self.table_abc) + .select("*") + .where(self.table_abc.json.contained_by(["One", "Two", "Three"]) & (self.table_abc.id == 26)) + ) + + self.assertEqual( + 'SELECT * FROM "abc" WHERE "json"<@\'["One","Two","Three"]\' AND "id"=26', + str(q), + ) + + def test_json_has_key(self): + q = PostgreSQLQuery.from_(self.table_abc).select("*").where(self.table_abc.json.has_key("dates")) + + self.assertEqual('SELECT * FROM "abc" WHERE "json"?\'dates\'', str(q)) + + def test_json_has_keys(self): + q = PostgreSQLQuery.from_(self.table_abc).select("*").where(self.table_abc.json.has_keys(["dates", "imported"])) + + self.assertEqual("SELECT * FROM \"abc\" WHERE \"json\"?&ARRAY['dates','imported']", str(q)) + + def test_json_has_any_keys(self): + q = ( + PostgreSQLQuery.from_(self.table_abc) + .select("*") + .where(self.table_abc.json.has_any_keys(["dates", "imported"])) + ) + + self.assertEqual("SELECT * FROM \"abc\" WHERE \"json\"?|ARRAY['dates','imported']", str(q)) + + def test_subnet_contains_inet(self): + q = ( + PostgreSQLQuery.from_(self.table_abc) + .select(self.table_abc.a.lshift(2)) + .where(self.table_abc.cidr >> "1.1.1.1") + ) + + self.assertEqual("SELECT \"a\"<<2 FROM \"abc\" WHERE \"cidr\">>'1.1.1.1'", str(q)) + + +class DistinctOnTests(unittest.TestCase): + table_abc = Table("abc") + + def test_distinct_on(self): + q = PostgreSQLQuery.from_(self.table_abc).distinct_on("lname", self.table_abc.fname).select("lname", "id") + + self.assertEqual('''SELECT DISTINCT ON("lname","fname") "lname","id" FROM "abc"''', str(q)) + + +class ArrayTests(unittest.TestCase): + def test_array_syntax(self): + tb = Table("tb") + q = PostgreSQLQuery.from_(tb).select(Array(1, "a", ["b", 2, 3])) + + self.assertEqual(str(q), "SELECT ARRAY[1,'a',ARRAY['b',2,3]] FROM \"tb\"") + + def test_render_alias_in_array_sql(self): + tb = Table("tb") + + q = PostgreSQLQuery.from_(tb).select(Array(tb.col).as_("different_name")) + self.assertEqual(str(q), 'SELECT ARRAY["col"] "different_name" FROM "tb"') + + +class ReturningClauseTests(unittest.TestCase): + @classmethod + def setUpClass(cls) -> None: + super().setUpClass() + cls.table_abc = Table('abc') + + def test_returning_from_missing_table_raises_queryexception(self): + field_from_diff_table = Field('xyz', table=Table('other')) + + with self.assertRaisesRegex(QueryException, "You can't return from other tables"): + ( + PostgreSQLQuery.from_(self.table_abc) + .where(self.table_abc.foo == self.table_abc.bar) + .delete() + .returning(field_from_diff_table) + ) + + def test_queryexception_if_returning_used_on_invalid_query(self): + with self.assertRaisesRegex(QueryException, "Returning can't be used in this query"): + PostgreSQLQuery.from_(self.table_abc).select('abc').returning('abc') + + def test_no_queryexception_if_returning_used_on_valid_query_type(self): + # No exceptions for insert, update and delete queries + with self.subTest('DELETE'): + PostgreSQLQuery.from_(self.table_abc).where(self.table_abc.foo == self.table_abc.bar).delete().returning( + "id" + ) + with self.subTest('UPDATE'): + PostgreSQLQuery.update(self.table_abc).where(self.table_abc.foo == 0).set("foo", "bar").returning("id") + with self.subTest('INSERT'): + PostgreSQLQuery.into(self.table_abc).insert('abc').returning('abc') + + def test_return_field_from_join_table(self): + new_table = Table('xyz') + q = ( + PostgreSQLQuery.update(self.table_abc) + .join(new_table) + .on(new_table.id == self.table_abc.xyz) + .where(self.table_abc.foo == 0) + .set("foo", "bar") + .returning(new_table.a) + ) + + self.assertEqual( + 'UPDATE "abc" ' + 'JOIN "xyz" ON "xyz"."id"="abc"."xyz" ' + 'SET "foo"=\'bar\' ' + 'WHERE "abc"."foo"=0 ' + 'RETURNING "xyz"."a"', + str(q), + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/dialects/test_snowflake.py b/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/dialects/test_snowflake.py new file mode 100644 index 0000000000000000000000000000000000000000..5ac08b2d8b8b5496ed6f3510acf4be1ec7893405 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/dialects/test_snowflake.py @@ -0,0 +1,58 @@ +import unittest + +from pypika import ( + Tables, + functions as fn, + Column, +) +from pypika.dialects import SnowflakeQuery + + +class QuoteTests(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_use_double_quotes_on_alias_but_not_on_terms(self): + q = SnowflakeQuery.from_(self.table_abc).select(self.table_abc.a.as_("bar")) + + self.assertEqual('SELECT a "bar" FROM abc', q.get_sql(with_namespace=True)) + + def test_use_double_quotes_on_alias_but_not_on_terms_with_joins(self): + foo = self.table_abc.as_("foo") + bar = self.table_efg.as_("bar") + + q = SnowflakeQuery.from_(foo).join(bar).on(foo.fk == bar.id).select(foo.a, bar.b) + + self.assertEqual( + "SELECT foo.a,bar.b " 'FROM abc "foo" ' 'JOIN efg "bar" ' "ON foo.fk=bar.id", + q.get_sql(with_namespace=True), + ) + + def test_use_double_quotes_on_alias_but_not_on_terms(self): + idx = self.table_abc.index.as_("idx") + val = fn.Sum(self.table_abc.value).as_("val") + q = SnowflakeQuery.from_(self.table_abc).select(idx, val).groupby(idx).orderby(idx) + + self.assertEqual( + 'SELECT index "idx",SUM(value) "val" ' "FROM abc " 'GROUP BY "idx" ' 'ORDER BY "idx"', + q.get_sql(with_namespace=True), + ) + + def test_dont_use_double_quotes_on_joining_queries(self): + foo = self.table_abc + bar = self.table_efg + q1 = SnowflakeQuery.from_(foo).select(foo.b) + q2 = SnowflakeQuery.from_(bar).select(bar.b) + q = SnowflakeQuery.from_(q1).join(q2).on(q1.b == q2.b).select("*") + + self.assertEqual( + "SELECT * " 'FROM (SELECT b FROM abc) sq0 ' 'JOIN (SELECT b FROM efg) sq1 ' "ON sq0.b=sq1.b", + q.get_sql(), + ) + + def test_dont_use_double_quotes_on_create_queries(self): + q = SnowflakeQuery.create_table(self.table_abc).columns(Column("id", "INT")) + self.assertEqual("CREATE TABLE abc (id INT)", q.get_sql()) + + def test_dont_use_double_quotes_on_drop_queries(self): + q = SnowflakeQuery.drop_table(self.table_abc) + self.assertEqual("DROP TABLE abc", q.get_sql()) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/dialects/test_sqllite.py b/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/dialects/test_sqllite.py new file mode 100644 index 0000000000000000000000000000000000000000..104a7235b6ea2d46fd365989f68c5d081eb20076 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/dialects/test_sqllite.py @@ -0,0 +1,35 @@ +import unittest + +from pypika import Table +from pypika.dialects import SQLLiteQuery + + +class SelectTests(unittest.TestCase): + table_abc = Table("abc") + + def test_bool_true_as_one(self): + q = SQLLiteQuery.from_("abc").select(True) + + self.assertEqual('SELECT 1 FROM "abc"', str(q)) + + def test_bool_false_as_zero(self): + q = SQLLiteQuery.from_("abc").select(False) + + self.assertEqual('SELECT 0 FROM "abc"', str(q)) + + +class ReplaceTests(unittest.TestCase): + def test_normal_replace(self): + query = SQLLiteQuery.into("abc").replace("v1", "v2", "v3") + expected_output = "REPLACE INTO \"abc\" VALUES ('v1','v2','v3')" + self.assertEqual(expected_output, str(query)) + + def test_replace_subquery(self): + query = SQLLiteQuery.into("abc").replace(SQLLiteQuery.from_("def").select("f1", "f2")) + expected_output = 'REPLACE INTO "abc" VALUES ((SELECT "f1","f2" FROM "def"))' + self.assertEqual(expected_output, str(query)) + + def test_insert_or_replace(self): + query = SQLLiteQuery.into("abc").insert_or_replace("v1", "v2", "v3") + expected_output = "INSERT OR REPLACE INTO \"abc\" VALUES ('v1','v2','v3')" + self.assertEqual(expected_output, str(query)) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/dialects/test_vertica.py b/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/dialects/test_vertica.py new file mode 100644 index 0000000000000000000000000000000000000000..61985bfc244fcd663e7d8a904b4645901f3abdfc --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/dialects/test_vertica.py @@ -0,0 +1,93 @@ +import unittest + +from pypika import Columns, Table, Tables, VerticaQuery + + +class VerticaQueryTests(unittest.TestCase): + table_abc = Table("abc") + + def test_select_query_with_hint(self): + q = VerticaQuery.from_("abc").select("*").hint("test_hint") + + self.assertEqual('SELECT /*+label(test_hint)*/ * FROM "abc"', str(q)) + + def test_insert_query_with_hint(self): + query = VerticaQuery.into(self.table_abc).insert(1).hint("test_hint") + + self.assertEqual('INSERT /*+label(test_hint)*/ INTO "abc" VALUES (1)', str(query)) + + def test_update_query_with_hint(self): + q = VerticaQuery.update(self.table_abc).set("foo", "bar").hint("test_hint") + + self.assertEqual('UPDATE /*+label(test_hint)*/ "abc" SET "foo"=\'bar\'', str(q)) + + def test_delete_query_with_hint(self): + q = VerticaQuery.from_("abc").delete().hint("test_hint") + + self.assertEqual('DELETE /*+label(test_hint)*/ FROM "abc"', str(q)) + + +class CopyCSVTests(unittest.TestCase): + table_abc = Table("abc") + + def test_copy_from_file(self): + with self.subTest("with table as string"): + q = VerticaQuery.from_file("/path/to/file").copy_("abc") + + self.assertEqual( + "COPY \"abc\" FROM LOCAL '/path/to/file' PARSER fcsvparser(header=false)", + str(q), + ) + + with self.subTest("with table"): + q = VerticaQuery.from_file("/path/to/file").copy_(self.table_abc) + + self.assertEqual( + "COPY \"abc\" FROM LOCAL '/path/to/file' PARSER fcsvparser(header=false)", + str(q), + ) + + +class CreateTemporaryTableTests(unittest.TestCase): + new_table, existing_table = Tables("abc", "efg") + foo, bar = Columns(("a", "INT"), ("b", "VARCHAR(100)")) + select = VerticaQuery.from_(existing_table).select(existing_table.foo, existing_table.bar) + + def test_create_local_temporary_table(self): + with self.subTest("with columns"): + q = VerticaQuery.create_table(self.new_table).temporary().local().columns(self.foo, self.bar) + + self.assertEqual('CREATE LOCAL TEMPORARY TABLE "abc" ("a" INT,"b" VARCHAR(100))', str(q)) + + with self.subTest("with select"): + q = VerticaQuery.create_table(self.new_table).temporary().local().as_select(self.select) + + self.assertEqual( + 'CREATE LOCAL TEMPORARY TABLE "abc" AS (SELECT "foo","bar" FROM "efg")', + str(q), + ) + + def test_create_local_table_without_temporary_raises_error(self): + with self.assertRaises(AttributeError): + VerticaQuery.create_table(self.new_table).local() + + def test_create_temporary_table_preserve_rows(self): + with self.subTest("with columns"): + q = VerticaQuery.create_table(self.new_table).temporary().preserve_rows().columns(self.foo, self.bar) + + self.assertEqual( + 'CREATE TEMPORARY TABLE "abc" ("a" INT,"b" VARCHAR(100)) ON COMMIT PRESERVE ROWS', + str(q), + ) + + with self.subTest("with select"): + q = VerticaQuery.create_table(self.new_table).temporary().preserve_rows().as_select(self.select) + + self.assertEqual( + 'CREATE TEMPORARY TABLE "abc" ON COMMIT PRESERVE ROWS AS (SELECT "foo","bar" FROM "efg")', + str(q), + ) + + def test_create_table_preserve_rows_without_temporary_raises_error(self): + with self.assertRaises(AttributeError): + VerticaQuery.create_table(self.new_table).preserve_rows() diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/test_aggregate.py b/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/test_aggregate.py new file mode 100644 index 0000000000000000000000000000000000000000..1c627d8e9c2d65410c67cf2c39974949b0720a0e --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/test_aggregate.py @@ -0,0 +1,122 @@ +import unittest + +from pypika import ( + Case, + Field, + Table, + functions as fn, +) +from pypika.terms import ( + Negative, + ValueWrapper, +) + + +class IsAggregateTests(unittest.TestCase): + def test__field_is_not_aggregate(self): + v = Field("foo") + self.assertFalse(v.is_aggregate) + + def test__constant_is_aggregate_none(self): + v = ValueWrapper(100) + self.assertIsNone(v.is_aggregate) + + def test__constant_arithmetic_is_aggregate_none(self): + v = ValueWrapper(100) + ValueWrapper(100) + self.assertIsNone(v.is_aggregate) + + def test__field_arithmetic_is_not_aggregate(self): + v = Field("foo") + Field("bar") + self.assertFalse(v.is_aggregate) + + def test__field_arithmetic_constant_is_not_aggregate(self): + v = Field("foo") + 1 + self.assertFalse(v.is_aggregate) + + def test__agg_func_is_aggregate(self): + v = fn.Sum(Field("foo")) + self.assertTrue(v.is_aggregate) + + def test__negative_agg_func_is_aggregate(self): + v = Negative(fn.Sum(Field("foo"))) + self.assertTrue(v.is_aggregate) + + def test__agg_func_arithmetic_is_aggregate(self): + v = fn.Sum(Field("foo")) / fn.Sum(Field("foo")) + self.assertTrue(v.is_aggregate) + + def test__mixed_func_arithmetic_is_not_aggregate(self): + v = Field("foo") / fn.Sum(Field("foo")) + self.assertFalse(v.is_aggregate) + + def test__func_arithmetic_constant_is_not_aggregate(self): + v = 1 / fn.Sum(Field("foo")) + self.assertTrue(v.is_aggregate) + + def test__agg_case_criterion_is_aggregate(self): + v = Case().when(fn.Sum(Field("foo")) > 666, 'More than 666').else_('Less than 666') + + self.assertTrue(v.is_aggregate) + + def test__agg_case_is_aggregate(self): + v = ( + Case() + .when(Field("foo") == 1, fn.Sum(Field("bar"))) + .when(Field("foo") == 2, fn.Sum(Field("fiz"))) + .else_(fn.Sum(Field("fiz"))) + ) + + self.assertTrue(v.is_aggregate) + + def test__mixed_case_is_not_aggregate(self): + v = Case().when(Field("foo") == 1, fn.Sum(Field("bar"))).when(Field("foo") == 2, Field("fiz")) + + self.assertFalse(v.is_aggregate) + + def test__case_mixed_else_is_not_aggregate(self): + v = ( + Case() + .when(Field("foo") == 1, fn.Sum(Field("bar"))) + .when(Field("foo") == 2, fn.Sum(Field("fiz"))) + .else_(Field("fiz")) + ) + + self.assertFalse(v.is_aggregate) + + def test__case_mixed_constant_is_not_aggregate(self): + v = Case().when(Field("foo") == 1, fn.Sum(Field("bar"))).when(Field("foo") == 2, fn.Sum(Field("fiz"))).else_(1) + + self.assertTrue(v.is_aggregate) + + def test__case_with_field_is_not_aggregate(self): + v = Case().when(Field("foo") == 1, 1).when(Field("foo") == 2, 2).else_(3) + + self.assertFalse(v.is_aggregate) + + def test__case_with_single_aggregate_field_in_one_criterion_is_aggregate(self): + v = Case().when(Field("foo") == 1, 1).when(fn.Sum(Field("foo")) == 2, 2).else_(3) + + self.assertTrue(v.is_aggregate) + + def test__non_aggregate_function_with_aggregated_arg(self): + t = Table("abc") + expr = fn.Sqrt(fn.Sum(t.a)) + + self.assertTrue(expr.is_aggregate) + + def test_complicated(self): + t = Table("abc") + is_placebo = t.campaign_extra_info == "placebo" + + pixel_mobile_search = Case().when(is_placebo, t.action_fb_pixel_search + t.action_fb_mobile_search) + unique_impressions = Case().when(is_placebo, t.unique_impressions) + + v = fn.Sum(pixel_mobile_search) / fn.Sum(unique_impressions) - 1.96 * fn.Sqrt( + 1 + / fn.Sum(unique_impressions) + * fn.Sum(pixel_mobile_search) + / fn.Sum(unique_impressions) + * (1 - fn.Sum(pixel_mobile_search) / fn.Sum(unique_impressions)) + ) + + self.assertTrue(v.is_aggregate) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/test_analytic_queries.py b/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/test_analytic_queries.py new file mode 100644 index 0000000000000000000000000000000000000000..6a35ab854b30e3b0f91e633b3349706a22e0a2fd --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/test_analytic_queries.py @@ -0,0 +1,610 @@ +import unittest + +from pypika import Criterion, JoinType, Order, Query, Tables, analytics as an +from pypika.analytics import Lag, Lead + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + + +class RankTests(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_rank(self): + expr = an.Rank().over(self.table_abc.foo).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " "RANK() " 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_dense_rank(self): + expr = an.DenseRank().over(self.table_abc.foo).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " "DENSE_RANK() " 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_row_number(self): + expr = an.RowNumber().over(self.table_abc.foo).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " "ROW_NUMBER() " 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_rank_with_alias(self): + expr = an.Rank().over(self.table_abc.foo).orderby(self.table_abc.date).as_("rank") + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " "RANK() " 'OVER(PARTITION BY "foo" ORDER BY "date") "rank" ' 'FROM "abc"', + str(q), + ) + + def test_multiple_partitions(self): + expr = an.Rank().orderby(self.table_abc.date).over(self.table_abc.foo, self.table_abc.bar) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " "RANK() " 'OVER(PARTITION BY "foo","bar" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_ntile_no_partition_or_order_invalid_sql(self): + expr = an.NTile(5) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual("SELECT " "NTILE(5) " 'FROM "abc"', str(q)) + + def test_ntile_with_partition(self): + expr = an.NTile(5).over(self.table_abc.foo) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual("SELECT " "NTILE(5) " 'OVER(PARTITION BY "foo") ' 'FROM "abc"', str(q)) + + def test_ntile_with_order(self): + expr = an.NTile(5).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual("SELECT " "NTILE(5) " 'OVER(ORDER BY "date") ' 'FROM "abc"', str(q)) + + def test_ntile_with_partition_and_order(self): + expr = an.NTile(5).over(self.table_abc.foo).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " "NTILE(5) " 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_first_value(self): + expr = an.FirstValue(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'FIRST_VALUE("fizz") ' 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_first_value_ignore_nulls(self): + expr = an.FirstValue(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).ignore_nulls() + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'FIRST_VALUE("fizz" IGNORE NULLS) ' 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_first_value_ignore_nulls_first(self): + expr = an.FirstValue(self.table_abc.fizz).ignore_nulls().over(self.table_abc.foo).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'FIRST_VALUE("fizz" IGNORE NULLS) ' 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_first_value_multi_argument(self): + expr = ( + an.FirstValue(self.table_abc.fizz, self.table_abc.buzz) + .over(self.table_abc.foo) + .orderby(self.table_abc.date) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'FIRST_VALUE("fizz","buzz") ' 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_last_value(self): + expr = an.LastValue(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'LAST_VALUE("fizz") ' 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_filter(self): + expr = ( + an.LastValue(self.table_abc.fizz) + .filter(Criterion.all([self.table_abc.bar == True])) + .over(self.table_abc.foo) + .orderby(self.table_abc.date) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'LAST_VALUE("fizz") ' + 'FILTER(WHERE "bar"=true) ' + 'OVER(PARTITION BY "foo" ORDER BY "date") ' + 'FROM "abc"', + str(q), + ) + + def test_filter_quote_table_in_filter(self): + expr = ( + an.LastValue(self.table_efg.fizz) + .filter(self.table_efg.filed.eq('yes')) + .over(self.table_efg.foo) + .orderby(self.table_efg.date) + ) + + q = ( + Query.from_(self.table_abc) + .inner_join(self.table_efg) + .on(self.table_abc.id.eq(self.table_efg.id)) + .select(expr) + ) + + self.assertEqual( + 'SELECT ' + 'LAST_VALUE("efg"."fizz") ' + 'FILTER(WHERE "efg"."filed"=\'yes\') ' + 'OVER(PARTITION BY "efg"."foo" ORDER BY "efg"."date") ' + 'FROM "abc" ' + 'JOIN "efg" ON "abc"."id"="efg"."id"', + str(q), + ) + + def test_orderby_asc(self): + expr = an.LastValue(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date, order=Order.asc) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'LAST_VALUE("fizz") ' 'OVER(PARTITION BY "foo" ORDER BY "date" ASC) ' 'FROM "abc"', + str(q), + ) + + def test_orderby_desc(self): + expr = an.LastValue(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date, order=Order.desc) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'LAST_VALUE("fizz") ' 'OVER(PARTITION BY "foo" ORDER BY "date" DESC) ' 'FROM "abc"', + str(q), + ) + + def test_last_value_multi_argument(self): + expr = ( + an.LastValue(self.table_abc.fizz, self.table_abc.buzz).over(self.table_abc.foo).orderby(self.table_abc.date) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'LAST_VALUE("fizz","buzz") ' 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_last_value_ignore_nulls(self): + expr = an.LastValue(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).ignore_nulls() + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'LAST_VALUE("fizz" IGNORE NULLS) ' 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_median(self): + expr = an.Median(self.table_abc.fizz).over(self.table_abc.foo, self.table_abc.bar).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'MEDIAN("fizz") ' 'OVER(PARTITION BY "foo","bar" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_avg(self): + expr = an.Avg(self.table_abc.fizz).over(self.table_abc.foo, self.table_abc.bar).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'AVG("fizz") ' 'OVER(PARTITION BY "foo","bar" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_stddev(self): + expr = an.StdDev(self.table_abc.fizz).over(self.table_abc.foo, self.table_abc.bar).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'STDDEV("fizz") ' 'OVER(PARTITION BY "foo","bar" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_stddev_pop(self): + expr = ( + an.StdDevPop(self.table_abc.fizz).over(self.table_abc.foo, self.table_abc.bar).orderby(self.table_abc.date) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'STDDEV_POP("fizz") ' 'OVER(PARTITION BY "foo","bar" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_stddev_samp(self): + expr = ( + an.StdDevSamp(self.table_abc.fizz).over(self.table_abc.foo, self.table_abc.bar).orderby(self.table_abc.date) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'STDDEV_SAMP("fizz") ' 'OVER(PARTITION BY "foo","bar" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_variance(self): + expr = ( + an.Variance(self.table_abc.fizz).over(self.table_abc.foo, self.table_abc.bar).orderby(self.table_abc.date) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'VARIANCE("fizz") ' 'OVER(PARTITION BY "foo","bar" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_var_pop(self): + expr = an.VarPop(self.table_abc.fizz).over(self.table_abc.foo, self.table_abc.bar).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'VAR_POP("fizz") ' 'OVER(PARTITION BY "foo","bar" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_var_samp(self): + expr = an.VarSamp(self.table_abc.fizz).over(self.table_abc.foo, self.table_abc.bar).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'VAR_SAMP("fizz") ' 'OVER(PARTITION BY "foo","bar" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_table_prefixes_used_in_analytic_functions(self): + expr = an.Rank().over(self.table_abc.foo).orderby(self.table_efg.date) + + query = ( + Query.from_(self.table_abc) + .join(self.table_efg, how=JoinType.left) + .on(self.table_abc.foo == self.table_efg.bar) + .select("*", expr) + ) + + self.assertEqual( + 'SELECT *,RANK() OVER(PARTITION BY "abc"."foo" ORDER BY "efg"."date") ' + 'FROM "abc" LEFT JOIN "efg" ON "abc"."foo"="efg"."bar"', + str(query), + ) + + def test_sum_rows_unbounded_preceeding(self): + expr = an.Sum(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).rows(an.Preceding()) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'SUM("fizz") ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "ROWS UNBOUNDED PRECEDING" + ") " + 'FROM "abc"', + str(q), + ) + + def test_max_rows_x_preceeding(self): + expr = an.Max(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).rows(an.Preceding(5)) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'MAX("fizz") ' "OVER(" 'PARTITION BY "foo" ORDER BY "date" ' "ROWS 5 PRECEDING" ") " 'FROM "abc"', + str(q), + ) + + def test_min_rows_current_row(self): + expr = an.Min(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).rows(an.CURRENT_ROW) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'MIN("fizz") ' "OVER(" 'PARTITION BY "foo" ORDER BY "date" ' "ROWS CURRENT ROW" ") " 'FROM "abc"', + str(q), + ) + + def test_varpop_range_unbounded_preceeding(self): + expr = ( + an.VarPop(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).range(an.Preceding()) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'VAR_POP("fizz") ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "RANGE UNBOUNDED PRECEDING" + ") " + 'FROM "abc"', + str(q), + ) + + def test_max_range_x_preceeding(self): + expr = an.Max(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).range(an.Preceding(5)) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'MAX("fizz") ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "RANGE 5 PRECEDING" + ") " + 'FROM "abc"', + str(q), + ) + + def test_min_range_current_row(self): + expr = an.Min(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).range(an.CURRENT_ROW) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'MIN("fizz") ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "RANGE CURRENT ROW" + ") " + 'FROM "abc"', + str(q), + ) + + def test_variance_rows_between_unbounded_preceeding_unbounded_following(self): + expr = ( + an.Variance(self.table_abc.fizz) + .over(self.table_abc.foo) + .orderby(self.table_abc.date) + .rows(an.Preceding(), an.Following()) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'VARIANCE("fizz") ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING" + ") " + 'FROM "abc"', + str(q), + ) + + def test_first_value_range_between_x_preceeding_unbounded_following(self): + expr = ( + an.FirstValue(self.table_abc.fizz) + .over(self.table_abc.foo) + .orderby(self.table_abc.date) + .range(an.Preceding(3), an.Following()) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'FIRST_VALUE("fizz") ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "RANGE BETWEEN 3 PRECEDING AND UNBOUNDED FOLLOWING" + ") " + 'FROM "abc"', + str(q), + ) + + def test_varpop_rows_between_unbounded_preceeding_x_following(self): + expr = ( + an.VarPop(self.table_abc.fizz) + .over(self.table_abc.foo) + .orderby(self.table_abc.date) + .rows(an.Preceding(), an.Following(6)) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'VAR_POP("fizz") ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "ROWS BETWEEN UNBOUNDED PRECEDING AND 6 FOLLOWING" + ") " + 'FROM "abc"', + str(q), + ) + + def test_count_range_between_unbounded_preceeding_current_row(self): + expr = ( + an.Count(self.table_abc.fizz) + .over(self.table_abc.foo) + .orderby(self.table_abc.date) + .range(an.Preceding(), an.CURRENT_ROW) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'COUNT("fizz") ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW" + ") " + 'FROM "abc"', + str(q), + ) + + def test_last_value_rows_between_current_row_unbounded_following(self): + expr = ( + an.LastValue(self.table_abc.fizz) + .over(self.table_abc.foo) + .orderby(self.table_abc.date) + .rows(an.CURRENT_ROW, an.Following()) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'LAST_VALUE("fizz") ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING" + ") " + 'FROM "abc"', + str(q), + ) + + def test_last_value_rows_between_current_row_unbounded_following_ignore_nulls(self): + expr = ( + an.LastValue(self.table_abc.fizz) + .over(self.table_abc.foo) + .orderby(self.table_abc.date) + .ignore_nulls() + .rows(an.CURRENT_ROW, an.Following(8)) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'LAST_VALUE("fizz" IGNORE NULLS) ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "ROWS BETWEEN CURRENT ROW AND 8 FOLLOWING" + ") " + 'FROM "abc"', + str(q), + ) + + def test_empty_over(self): + query = Query.from_(self.table_abc).select(an.Sum(self.table_abc.fizz).over()) + + self.assertEqual("SELECT " 'SUM("fizz") OVER() ' 'FROM "abc"', str(query)) + + def test_rows_called_twice_raises_attribute_error(self): + with self.assertRaises(AttributeError): + an.Sum(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).rows(an.Preceding()).rows( + an.Preceding() + ) + + def test_range_called_twice_raises_attribute_error(self): + with self.assertRaises(AttributeError): + an.Sum(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).range( + an.Preceding() + ).range(an.Preceding()) + + def test_rows_then_range_raises_attribute_error(self): + with self.assertRaises(AttributeError): + an.Sum(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).rows( + an.Preceding() + ).range(an.Preceding()) + + def test_range_then_rows_raises_attribute_error(self): + with self.assertRaises(AttributeError): + an.Sum(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).range( + an.Preceding() + ).rows(an.Preceding()) + + def test_lag_generates_correct_sql(self): + with self.subTest('without partition by'): + q = Query.from_(self.table_abc).select( + Lag(self.table_abc.date, 1, '2000-01-01').orderby(self.table_abc.date) + ) + + self.assertEqual('SELECT LAG("date",1,\'2000-01-01\') OVER(ORDER BY "date") FROM "abc"', str(q)) + + with self.subTest('with partition by'): + q = Query.from_(self.table_abc).select( + Lag(self.table_abc.date, 1, '2000-01-01').over(self.table_abc.foo).orderby(self.table_abc.date) + ) + + self.assertEqual( + 'SELECT LAG("date",1,\'2000-01-01\') OVER(PARTITION BY "foo" ORDER BY "date") FROM "abc"', str(q) + ) + + def test_lead_generates_correct_sql(self): + with self.subTest('without partition by'): + q = Query.from_(self.table_abc).select( + Lead(self.table_abc.date, 1, '2000-01-01').orderby(self.table_abc.date) + ) + + self.assertEqual('SELECT LEAD("date",1,\'2000-01-01\') OVER(ORDER BY "date") FROM "abc"', str(q)) + + with self.subTest('with partition by'): + q = Query.from_(self.table_abc).select( + Lead(self.table_abc.date, 1, '2000-01-01').over(self.table_abc.foo).orderby(self.table_abc.date) + ) + + self.assertEqual( + 'SELECT LEAD("date",1,\'2000-01-01\') OVER(PARTITION BY "foo" ORDER BY "date") FROM "abc"', str(q) + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/test_create.py b/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/test_create.py new file mode 100644 index 0000000000000000000000000000000000000000..325076544e3824b0d07f82f2378b88218b910dde --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/test_create.py @@ -0,0 +1,210 @@ +import unittest + +from pypika import Column, Columns, Query, Tables, Table +from pypika.terms import ValueWrapper, Index +from pypika.enums import ReferenceOption + + +class CreateTableTests(unittest.TestCase): + new_table, existing_table = Tables("abc", "efg") + foo, bar = Columns(("a", "INT"), ("b", "VARCHAR(100)")) + + def test_create_table_with_columns(self): + with self.subTest("with nullable"): + a = Column("a", "INT", True) + b = Column("b", "VARCHAR(100)", False) + q = Query.create_table(self.new_table).columns(a, b) + + self.assertEqual('CREATE TABLE "abc" ("a" INT NULL,"b" VARCHAR(100) NOT NULL)', str(q)) + + with self.subTest("with defaults"): + a = Column("a", "INT", default=ValueWrapper(42)) + b = Column("b", "VARCHAR(100)", default=ValueWrapper("foo")) + q = Query.create_table(self.new_table).columns(a, b) + + self.assertEqual('CREATE TABLE "abc" ("a" INT DEFAULT 42,"b" VARCHAR(100) DEFAULT \'foo\')', str(q)) + + with self.subTest("with unwrapped defaults"): + a = Column("a", "INT", default=42) + b = Column("b", "VARCHAR(100)", default="foo") + q = Query.create_table(self.new_table).columns(a, b) + + self.assertEqual('CREATE TABLE "abc" ("a" INT DEFAULT 42,"b" VARCHAR(100) DEFAULT \'foo\')', str(q)) + + with self.subTest("with period for"): + a = Column("id", "INT") + b = Column("valid_from", "DATETIME") + c = Column("valid_to", "DATETIME") + q = Query.create_table(self.new_table).columns(a, b, c).period_for('valid_period', b, c) + + self.assertEqual( + 'CREATE TABLE "abc" (' + '"id" INT,' + '"valid_from" DATETIME,' + '"valid_to" DATETIME,' + 'PERIOD FOR "valid_period" ("valid_from","valid_to"))', + str(q), + ) + + with self.subTest("without temporary keyword"): + q = Query.create_table(self.new_table).columns(self.foo, self.bar) + + self.assertEqual('CREATE TABLE "abc" ("a" INT,"b" VARCHAR(100))', str(q)) + + with self.subTest("with temporary keyword"): + q = Query.create_table(self.new_table).temporary().columns(self.foo, self.bar) + + self.assertEqual('CREATE TEMPORARY TABLE "abc" ("a" INT,"b" VARCHAR(100))', str(q)) + + with self.subTest("with primary key"): + q = Query.create_table(self.new_table).columns(self.foo, self.bar).primary_key(self.foo, self.bar) + + self.assertEqual('CREATE TABLE "abc" ("a" INT,"b" VARCHAR(100),PRIMARY KEY ("a","b"))', str(q)) + + with self.subTest("with simple foreign key"): + cref, dref = Columns(("c", "INT"), ("d", "VARCHAR(100)")) + q = ( + Query.create_table(self.new_table) + .columns(self.foo, self.bar) + .foreign_key([self.foo, self.bar], self.existing_table, [cref, dref]) + ) + + self.assertEqual( + 'CREATE TABLE "abc" (' + '"a" INT,' + '"b" VARCHAR(100),' + 'FOREIGN KEY ("a","b") REFERENCES "efg" ("c","d"))', + str(q), + ) + + with self.subTest("with foreign key reference options"): + cref, dref = Columns(("c", "INT"), ("d", "VARCHAR(100)")) + q = ( + Query.create_table(self.new_table) + .columns(self.foo, self.bar) + .foreign_key( + [self.foo, self.bar], + self.existing_table, + [cref, dref], + on_delete=ReferenceOption.cascade, + on_update=ReferenceOption.restrict, + ) + ) + + self.assertEqual( + 'CREATE TABLE "abc" (' + '"a" INT,' + '"b" VARCHAR(100),' + 'FOREIGN KEY ("a","b") REFERENCES "efg" ("c","d") ON DELETE CASCADE ON UPDATE RESTRICT)', + str(q), + ) + + with self.subTest("with unique keys"): + q = ( + Query.create_table(self.new_table) + .columns(self.foo, self.bar) + .unique(self.foo, self.bar) + .unique(self.foo) + ) + + self.assertEqual('CREATE TABLE "abc" ("a" INT,"b" VARCHAR(100),UNIQUE ("a","b"),UNIQUE ("a"))', str(q)) + + with self.subTest("with system versioning"): + q = Query.create_table(self.new_table).columns(self.foo, self.bar).with_system_versioning() + + self.assertEqual('CREATE TABLE "abc" ("a" INT,"b" VARCHAR(100)) WITH SYSTEM VERSIONING', str(q)) + + with self.subTest("with unlogged keyword"): + q = Query.create_table(self.new_table).unlogged().columns(self.foo, self.bar) + + self.assertEqual('CREATE UNLOGGED TABLE "abc" ("a" INT,"b" VARCHAR(100))', str(q)) + + with self.subTest("with if not exists keyword"): + q = Query.create_table(self.new_table).if_not_exists().columns(self.foo, self.bar) + + self.assertEqual('CREATE TABLE IF NOT EXISTS "abc" ("a" INT,"b" VARCHAR(100))', str(q)) + + def test_create_table_with_select(self): + select = Query.from_(self.existing_table).select(self.existing_table.foo, self.existing_table.bar) + + with self.subTest("without temporary keyword"): + q = Query.create_table(self.new_table).as_select(select) + + self.assertEqual('CREATE TABLE "abc" AS (SELECT "foo","bar" FROM "efg")', str(q)) + + with self.subTest("with temporary keyword"): + q = Query.create_table(self.new_table).temporary().as_select(select) + + self.assertEqual( + 'CREATE TEMPORARY TABLE "abc" AS (SELECT "foo","bar" FROM "efg")', + str(q), + ) + + def test_create_table_without_columns_or_select_empty(self): + q = Query.create_table(self.new_table) + + self.assertEqual("", str(q)) + + def test_create_table_with_select_and_columns_fails(self): + select = Query.from_(self.existing_table).select(self.existing_table.foo, self.existing_table.bar) + + with self.subTest("for columns before as_select"): + with self.assertRaises(AttributeError): + Query.create_table(self.new_table).columns(self.foo, self.bar).as_select(select) + + with self.subTest("for as_select before columns"): + with self.assertRaises(AttributeError): + Query.create_table(self.new_table).as_select(select).columns(self.foo, self.bar) + + with self.subTest("repeated foreign key"): + with self.assertRaises(AttributeError): + Query.create_table(self.new_table).foreign_key([self.foo], self.existing_table, [self.bar]).foreign_key( + [self.foo], self.existing_table, [self.bar] + ) + + def test_create_table_as_select_not_query_raises_error(self): + with self.assertRaises(TypeError): + Query.create_table(self.new_table).as_select("abc") + + +class CreateIndexTests(unittest.TestCase): + new_index = Index("abc") + new_table = Table("my_table") + columns = (new_table.a, new_table.b) + where = new_table.a > 1 + + def test_create_index_simple(self) -> None: + q = Query.create_index(self.new_index).on(self.new_table).columns(*self.columns) + self.assertEqual( + f'CREATE INDEX "{self.new_index.name}" ON "{self.new_table.get_table_name()}"({", ".join([c.name for c in self.columns])})', + q.get_sql(), + ) + + def test_create_index_where(self) -> None: + q = Query.create_index(self.new_index).on(self.new_table).columns(*self.columns).where(self.where) + self.assertEqual( + f'CREATE INDEX "{self.new_index.name}" ON "{self.new_table.get_table_name()}"({", ".join([c.name for c in self.columns])}) WHERE {self.where.get_sql()}', + q.get_sql(), + ) + + def test_create_index_unique(self) -> None: + q = Query.create_index(self.new_index).on(self.new_table).columns(*self.columns).unique() + self.assertEqual( + f'CREATE UNIQUE INDEX "{self.new_index.name}" ON "{self.new_table.get_table_name()}"({", ".join([c.name for c in self.columns])})', + q.get_sql(), + ) + + def test_create_index_if_not_exists(self) -> None: + q = Query.create_index(self.new_index).on(self.new_table).columns(*self.columns).if_not_exists() + self.assertEqual( + f'CREATE INDEX IF NOT EXISTS "{self.new_index.name}" ON "{self.new_table.get_table_name()}"({", ".join([c.name for c in self.columns])})', + q.get_sql(), + ) + + def test_create_index_without_columns_raises_error(self) -> None: + with self.assertRaises(AttributeError): + Query.create_index(self.new_index).on(self.new_table).get_sql() + + def test_create_index_without_table_raises_error(self) -> None: + with self.assertRaises(AttributeError): + Query.create_index(self.new_index).columns(*self.columns).get_sql() diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/test_criterions.py b/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/test_criterions.py new file mode 100644 index 0000000000000000000000000000000000000000..fca2ceeeb18db88e34ebc38776f644fdcda67e93 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/test_criterions.py @@ -0,0 +1,873 @@ +import unittest +from datetime import ( + date, + datetime, +) + +from pypika import ( + Criterion, + EmptyCriterion, + Field, + Table, + functions as fn, +) +from pypika.queries import QueryBuilder +from pypika.terms import ExistsCriterion, Mod + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + + +class CriterionTests(unittest.TestCase): + t = Table("test", alias="crit") + + def test__criterion_with_alias(self): + c1 = (Field("foo") == Field("bar")).as_("criterion") + + self.assertEqual('"foo"="bar"', str(c1)) + self.assertEqual('"foo"="bar" "criterion"', c1.get_sql(with_alias=True, quote_char='"', alias_quote_char='"')) + + def test__criterion_eq_number(self): + c1 = Field("foo") == 1 + c2 = Field("foo", table=self.t).eq(0) + c3 = Field("foo", table=self.t) == -1 + + self.assertEqual('"foo"=1', str(c1)) + self.assertEqual('"crit"."foo"=0', str(c2)) + self.assertEqual('"crit"."foo"=-1', str(c3)) + + def test__criterion_eq_decimal(self): + c1 = Field("foo") == 1.0 + c2 = Field("foo", table=self.t).eq(0.5) + + self.assertEqual('"foo"=1.0', str(c1)) + self.assertEqual('"crit"."foo"=0.5', str(c2)) + + def test__criterion_eq_bool(self): + c1 = Field("foo") == True + c2 = Field("foo", table=self.t).eq(True) + c3 = Field("foo") == False + c4 = Field("foo", table=self.t).eq(False) + + self.assertEqual('"foo"=true', str(c1)) + self.assertEqual('"crit"."foo"=true', str(c2)) + self.assertEqual('"foo"=false', str(c3)) + self.assertEqual('"crit"."foo"=false', str(c4)) + + def test__criterion_eq_str(self): + c1 = Field("foo") == "abc" + c2 = Field("foo", table=self.t).eq("abc") + + self.assertEqual("\"foo\"='abc'", str(c1)) + self.assertEqual('"crit"."foo"=\'abc\'', str(c2)) + + def test__criterion_eq_date(self): + c1 = Field("foo") == date(2000, 1, 1) + c2 = Field("foo", table=self.t).eq(date(2000, 1, 1)) + + self.assertEqual("\"foo\"='2000-01-01'", str(c1)) + self.assertEqual('"crit"."foo"=\'2000-01-01\'', str(c2)) + + def test__criterion_eq_datetime(self): + c1 = Field("foo") == datetime(2000, 1, 1, 12, 30, 55) + c2 = Field("foo", table=self.t).eq(datetime(2000, 1, 1, 12, 30, 55)) + + self.assertEqual("\"foo\"='2000-01-01T12:30:55'", str(c1)) + self.assertEqual('"crit"."foo"=\'2000-01-01T12:30:55\'', str(c2)) + + def test__criterion_eq_right(self): + c1 = 1 == Field("foo") + c2 = -1 == Field("foo", table=self.t) + + self.assertEqual('"foo"=1', str(c1)) + self.assertEqual('"crit"."foo"=-1', str(c2)) + + def test__criterion_is_null(self): + c1 = Field("foo").isnull() + c2 = Field("foo", table=self.t).isnull() + + self.assertEqual('"foo" IS NULL', str(c1)) + self.assertEqual('"crit"."foo" IS NULL', str(c2)) + + def test__criterion_is_null_with_alias(self): + c1 = Field("foo").isnull().as_('alias') + c2 = Field("foo", table=self.t).isnull().as_('alias') + + self.assertEqual('"foo" IS NULL "alias"', str(c1)) + self.assertEqual('"crit"."foo" IS NULL "alias"', str(c2)) + + def test__criterion_ne_number(self): + c1 = Field("foo") != 1 + c2 = Field("foo", table=self.t).ne(0) + c3 = Field("foo") != -1 + + self.assertEqual('"foo"<>1', str(c1)) + self.assertEqual('"crit"."foo"<>0', str(c2)) + self.assertEqual('"foo"<>-1', str(c3)) + + def test__criterion_ne_str(self): + c1 = Field("foo") != "abc" + c2 = Field("foo", table=self.t).ne("abc") + + self.assertEqual("\"foo\"<>'abc'", str(c1)) + self.assertEqual('"crit"."foo"<>\'abc\'', str(c2)) + + def test__criterion_ne_date(self): + c1 = Field("foo") != date(2000, 1, 1) + c2 = Field("foo", table=self.t).ne(date(2000, 1, 1)) + + self.assertEqual("\"foo\"<>'2000-01-01'", str(c1)) + self.assertEqual('"crit"."foo"<>\'2000-01-01\'', str(c2)) + + def test__criterion_ne_datetime(self): + c1 = Field("foo") != datetime(2000, 1, 1, 12, 30, 55) + c2 = Field("foo", table=self.t).ne(datetime(2000, 1, 1, 12, 30, 55)) + + self.assertEqual("\"foo\"<>'2000-01-01T12:30:55'", str(c1)) + self.assertEqual('"crit"."foo"<>\'2000-01-01T12:30:55\'', str(c2)) + + def test__criterion_ne_right(self): + c1 = 1 != Field("foo") + c2 = -1 != Field("foo", table=self.t) + + self.assertEqual('"foo"<>1', str(c1)) + self.assertEqual('"crit"."foo"<>-1', str(c2)) + + def test__criterion_lt_number(self): + c1 = Field("foo") < 1 + c2 = Field("foo", table=self.t).lt(0) + c3 = Field("foo") < -1 + + self.assertEqual('"foo"<1', str(c1)) + self.assertEqual('"crit"."foo"<0', str(c2)) + self.assertEqual('"foo"<-1', str(c3)) + + def test__criterion_lt_date(self): + c1 = Field("foo") < date(2000, 1, 1) + c2 = Field("foo", table=self.t).lt(date(2000, 1, 1)) + + self.assertEqual("\"foo\"<'2000-01-01'", str(c1)) + self.assertEqual('"crit"."foo"<\'2000-01-01\'', str(c2)) + + def test__criterion_lt_datetime(self): + c1 = Field("foo") < datetime(2000, 1, 1, 12, 30, 55) + c2 = Field("foo", table=self.t).lt(datetime(2000, 1, 1, 12, 30, 55)) + + self.assertEqual("\"foo\"<'2000-01-01T12:30:55'", str(c1)) + self.assertEqual('"crit"."foo"<\'2000-01-01T12:30:55\'', str(c2)) + + def test__criterion_lt_right(self): + c1 = 1 > Field("foo") + c2 = -1 > Field("foo", table=self.t) + + self.assertEqual('"foo"<1', str(c1)) + self.assertEqual('"crit"."foo"<-1', str(c2)) + + def test__criterion_gt_number(self): + c1 = Field("foo") > 1 + c2 = Field("foo", table=self.t).gt(0) + c3 = Field("foo") > -1 + + self.assertEqual('"foo">1', str(c1)) + self.assertEqual('"crit"."foo">0', str(c2)) + self.assertEqual('"foo">-1', str(c3)) + + def test__criterion_gt_date(self): + c1 = Field("foo") > date(2000, 1, 1) + c2 = Field("foo", table=self.t).gt(date(2000, 1, 1)) + + self.assertEqual("\"foo\">'2000-01-01'", str(c1)) + self.assertEqual('"crit"."foo">\'2000-01-01\'', str(c2)) + + def test__criterion_gt_datetime(self): + c1 = Field("foo") > datetime(2000, 1, 1, 12, 30, 55) + c2 = Field("foo", table=self.t).gt(datetime(2000, 1, 1, 12, 30, 55)) + + self.assertEqual("\"foo\">'2000-01-01T12:30:55'", str(c1)) + self.assertEqual('"crit"."foo">\'2000-01-01T12:30:55\'', str(c2)) + + def test__criterion_gt_right(self): + c1 = 1 < Field("foo") + c2 = -1 < Field("foo", table=self.t) + + self.assertEqual('"foo">1', str(c1)) + self.assertEqual('"crit"."foo">-1', str(c2)) + + def test__criterion_lte_number(self): + c1 = Field("foo") <= 1 + c2 = Field("foo", table=self.t).lte(0) + c3 = Field("foo") <= -1 + + self.assertEqual('"foo"<=1', str(c1)) + self.assertEqual('"crit"."foo"<=0', str(c2)) + self.assertEqual('"foo"<=-1', str(c3)) + + def test__criterion_lte_date(self): + c1 = Field("foo") <= date(2000, 1, 1) + c2 = Field("foo", table=self.t).lte(date(2000, 1, 1)) + + self.assertEqual("\"foo\"<='2000-01-01'", str(c1)) + self.assertEqual('"crit"."foo"<=\'2000-01-01\'', str(c2)) + + def test__criterion_lte_datetime(self): + c1 = Field("foo") <= datetime(2000, 1, 1, 12, 30, 55) + c2 = Field("foo", table=self.t).lte(datetime(2000, 1, 1, 12, 30, 55)) + + self.assertEqual("\"foo\"<='2000-01-01T12:30:55'", str(c1)) + self.assertEqual('"crit"."foo"<=\'2000-01-01T12:30:55\'', str(c2)) + + def test__criterion_lte_right(self): + c1 = 1 >= Field("foo") + c2 = -1 >= Field("foo", table=self.t) + + self.assertEqual('"foo"<=1', str(c1)) + self.assertEqual('"crit"."foo"<=-1', str(c2)) + + def test__criterion_gte_number(self): + c1 = Field("foo") >= 1 + c2 = Field("foo", table=self.t).gte(0) + c3 = Field("foo") >= -1 + + self.assertEqual('"foo">=1', str(c1)) + self.assertEqual('"crit"."foo">=0', str(c2)) + self.assertEqual('"foo">=-1', str(c3)) + + def test__criterion_gte_date(self): + c1 = Field("foo") >= date(2000, 1, 1) + c2 = Field("foo", table=self.t).gte(date(2000, 1, 1)) + + self.assertEqual("\"foo\">='2000-01-01'", str(c1)) + self.assertEqual('"crit"."foo">=\'2000-01-01\'', str(c2)) + + def test__criterion_gte_datetime(self): + c1 = Field("foo") >= datetime(2000, 1, 1, 12, 30, 55) + c2 = Field("foo", table=self.t).gte(datetime(2000, 1, 1, 12, 30, 55)) + + self.assertEqual("\"foo\">='2000-01-01T12:30:55'", str(c1)) + self.assertEqual('"crit"."foo">=\'2000-01-01T12:30:55\'', str(c2)) + + def test__criterion_gte_right(self): + c1 = 1 <= Field("foo") + c2 = -1 <= Field("foo", table=self.t) + + self.assertEqual('"foo">=1', str(c1)) + self.assertEqual('"crit"."foo">=-1', str(c2)) + + def test__criterion_bitwise_and(self): + c1 = Field("foo").bitwiseand(2) + c2 = Field("foo", table=self.t).bitwiseand(10) == 2 + + self.assertEqual('("foo" & 2)', str(c1)) + self.assertEqual('("crit"."foo" & 10)=2', str(c2)) + + def test__criterion_bitwise_and_with_alias(self): + c1 = Field("foo").bitwiseand(2).as_('alias') + + self.assertEqual('("foo" & 2) "alias"', str(c1)) + + def test__bitwise_and_in_where_clause(self): + q = QueryBuilder().from_('items').select('abc').where(Field("foo").bitwiseand(1) == 1) + + self.assertEqual('SELECT "abc" FROM "items" WHERE ("foo" & 1)=1', str(q)) + + +class NotTests(unittest.TestCase): + table_abc, table_efg = Table("abc", alias="cx0"), Table("efg", alias="cx1") + + def test_negate(self): + c1 = Field("foo") >= 1 + c2 = c1.negate() + + self.assertEqual('"foo">=1', str(c1)) + self.assertEqual('NOT "foo">=1', str(c2)) + + def test_variable_access(self): + c1 = Field("foo").negate() + + self.assertEqual(c1.is_aggregate, False) + + def test_chained_function(self): + field1 = Field("foo").negate() + field2 = field1.eq("bar") + + self.assertEqual('NOT "foo"', str(field1)) + self.assertEqual("NOT \"foo\"='bar'", str(field2)) + self.assertIsNot(field1, field2) + + def test_not_null(self): + c1 = Field("foo").notnull() + c2 = Field("foo", table=self.table_abc).notnull() + + self.assertEqual('NOT "foo" IS NULL', str(c1)) + self.assertEqual('NOT "cx0"."foo" IS NULL', str(c2)) + + def test_is_not_null(self): + c1 = Field("foo").isnotnull() + c2 = Field("foo", table=self.table_abc).isnotnull() + + self.assertEqual('"foo" IS NOT NULL', str(c1)) + self.assertEqual('"cx0"."foo" IS NOT NULL', str(c2)) + + def test_not_null_with_alias(self): + c1 = Field("foo").notnull().as_("something") + c2 = Field("foo", table=self.table_abc).notnull().as_("something") + + self.assertEqual('NOT "foo" IS NULL "something"', str(c1)) + self.assertEqual('NOT "cx0"."foo" IS NULL "something"', str(c2)) + + def test_notnullcriterion_replace_table(self): + f = self.table_abc.foo.notnull().replace_table(self.table_abc, self.table_efg) + + self.assertEqual('NOT "cx1"."foo" IS NULL', str(f)) + + def test_not_with_or_criterion(self): + self.assertEqual('NOT ("foo" OR "bar")', str(~(Field("foo") | Field("bar")))) + + def test_not_with_and_criterion(self): + self.assertEqual('NOT ("foo" AND "bar")', str(~(Field("foo") & Field("bar")))) + + def test_not_with_complex_criterion(self): + self.assertEqual( + 'NOT ("foo" AND "bar" AND "fizz" AND "buzz")', + str(~(Field("foo") & Field("bar") & Field("fizz") & Field("buzz"))), + ) + + +class BetweenTests(unittest.TestCase): + t = Table("abc", alias="btw") + + def test__between_number(self): + c1 = Field("foo").between(0, 1) + c2 = Field("foo", table=self.t).between(0, 1) + c3 = Field("foo")[0:1] + + self.assertEqual('"foo" BETWEEN 0 AND 1', str(c1)) + self.assertEqual('"btw"."foo" BETWEEN 0 AND 1', str(c2)) + self.assertEqual('"foo" BETWEEN 0 AND 1', str(c3)) + + def test__between_with_alias(self): + c1 = Field("foo").between(0, 1).as_('alias') + c2 = Field("foo", table=self.t).between(0, 1).as_('alias') + c3 = Field("foo")[0:1].as_('alias') + + self.assertEqual('"foo" BETWEEN 0 AND 1 "alias"', str(c1)) + self.assertEqual('"btw"."foo" BETWEEN 0 AND 1 "alias"', str(c2)) + self.assertEqual('"foo" BETWEEN 0 AND 1 "alias"', str(c3)) + + def test__between_date(self): + c1 = Field("foo").between(date(2000, 1, 1), date(2000, 12, 31)) + c2 = Field("foo", table=self.t).between(date(2000, 1, 1), date(2000, 12, 31)) + c3 = Field("foo")[date(2000, 1, 1) : date(2000, 12, 31)] + + self.assertEqual("\"foo\" BETWEEN '2000-01-01' AND '2000-12-31'", str(c1)) + self.assertEqual("\"btw\".\"foo\" BETWEEN '2000-01-01' AND '2000-12-31'", str(c2)) + self.assertEqual("\"foo\" BETWEEN '2000-01-01' AND '2000-12-31'", str(c3)) + + def test__between_datetime(self): + c1 = Field("foo").between(datetime(2000, 1, 1, 0, 0, 0), datetime(2000, 12, 31, 23, 59, 59)) + c2 = Field("foo", table=self.t).between(datetime(2000, 1, 1, 0, 0, 0), datetime(2000, 12, 31, 23, 59, 59)) + c3 = Field("foo")[datetime(2000, 1, 1, 0, 0, 0) : datetime(2000, 12, 31, 23, 59, 59)] + + self.assertEqual("\"foo\" BETWEEN '2000-01-01T00:00:00' AND '2000-12-31T23:59:59'", str(c1)) + self.assertEqual( + "\"btw\".\"foo\" BETWEEN '2000-01-01T00:00:00' AND '2000-12-31T23:59:59'", + str(c2), + ) + self.assertEqual("\"foo\" BETWEEN '2000-01-01T00:00:00' AND '2000-12-31T23:59:59'", str(c3)) + + def test__function_between(self): + c1 = fn.Coalesce(Field("foo"), 0)[0:1] + c2 = fn.Coalesce(Field("foo", table=self.t), 0)[0:1] + + self.assertEqual('COALESCE("foo",0) BETWEEN 0 AND 1', str(c1)) + self.assertEqual('COALESCE("btw"."foo",0) BETWEEN 0 AND 1', str(c2)) + + def test_get_item_only_works_with_slice(self): + with self.assertRaises(TypeError): + Field("foo")[0] + + with self.assertRaises(TypeError): + Field("foo")[date(2000, 1, 1)] + + with self.assertRaises(TypeError): + Field("foo")[datetime(2000, 1, 1, 0, 0, 0)] + + +class IsInTests(unittest.TestCase): + t = Table("abc", alias="isin") + + def test__in_number(self): + c1 = Field("foo").isin([0, 1]) + c2 = Field("foo", table=self.t).isin([0, 1]) + + self.assertEqual('"foo" IN (0,1)', str(c1)) + self.assertEqual('"isin"."foo" IN (0,1)', str(c2)) + + def test__in_number_with_alias(self): + c1 = Field("foo").isin([0, 1]).as_('alias') + c2 = Field("foo", table=self.t).isin([0, 1]).as_('alias') + + self.assertEqual('"foo" IN (0,1) "alias"', str(c1)) + self.assertEqual('"isin"."foo" IN (0,1) "alias"', str(c2)) + + def test__in_character(self): + c1 = Field("foo").isin(["a", "b"]) + c2 = Field("foo", table=self.t).isin(["a", "b"]) + + self.assertEqual("\"foo\" IN ('a','b')", str(c1)) + self.assertEqual("\"isin\".\"foo\" IN ('a','b')", str(c2)) + + def test__in_date(self): + c1 = Field("foo").isin([date(2000, 1, 1), date(2000, 12, 31)]) + c2 = Field("foo", table=self.t).isin([date(2000, 1, 1), date(2000, 12, 31)]) + + self.assertEqual("\"foo\" IN ('2000-01-01','2000-12-31')", str(c1)) + self.assertEqual("\"isin\".\"foo\" IN ('2000-01-01','2000-12-31')", str(c2)) + + def test__in_datetime(self): + c1 = Field("foo").isin([datetime(2000, 1, 1, 0, 0, 0), datetime(2000, 12, 31, 23, 59, 59)]) + c2 = Field("foo", table=self.t).isin([datetime(2000, 1, 1, 0, 0, 0), datetime(2000, 12, 31, 23, 59, 59)]) + + self.assertEqual("\"foo\" IN ('2000-01-01T00:00:00','2000-12-31T23:59:59')", str(c1)) + self.assertEqual("\"isin\".\"foo\" IN ('2000-01-01T00:00:00','2000-12-31T23:59:59')", str(c2)) + + def test__function_isin(self): + c1 = fn.Coalesce(Field("foo"), 0).isin([0, 1]) + c2 = fn.Coalesce(Field("foo", table=self.t), 0).isin([0, 1]) + + self.assertEqual('COALESCE("foo",0) IN (0,1)', str(c1)) + self.assertEqual('COALESCE("isin"."foo",0) IN (0,1)', str(c2)) + + for t in (list, tuple, set, frozenset): + c_type = fn.Coalesce(Field("foo"), 0).isin(t([0, 1])) + self.assertEqual('COALESCE("foo",0) IN (0,1)', str(c_type)) + + self.assertRaises(AttributeError, lambda: str(fn.Coalesce(Field("foo"), 0).isin('SHOULD_FAIL'))) + + def test__in_unicode(self): + c1 = Field("foo").isin([u"a", u"b"]) + c2 = Field("foo", table=self.t).isin([u"a", u"b"]) + + self.assertEqual("\"foo\" IN ('a','b')", str(c1)) + self.assertEqual("\"isin\".\"foo\" IN ('a','b')", str(c2)) + + +class ArithmeticExpressionTests(unittest.TestCase): + def test__lshift(self): + c1 = Field("foo").lshift("1") + c2 = Field("foo").lshift("2") + + self.assertEqual("\"foo\"<<'1'", str(c1)) + self.assertEqual("\"foo\"<<'2'", str(c2)) + + def test__rshift(self): + c1 = Field("foo").rshift("1") + c2 = Field("foo").rshift("2") + + self.assertEqual("\"foo\">>'1'", str(c1)) + self.assertEqual("\"foo\">>'2'", str(c2)) + + +class NotInTests(unittest.TestCase): + t = Table("abc", alias="notin") + + def test__notin_number(self): + c1 = Field("foo").notin([0, 1]) + c2 = Field("foo", table=self.t).notin([0, 1]) + + self.assertEqual('"foo" NOT IN (0,1)', str(c1)) + self.assertEqual('"notin"."foo" NOT IN (0,1)', str(c2)) + + def test__notin_number_with_alias(self): + c1 = Field("foo").notin([0, 1]).as_('alias') + c2 = Field("foo", table=self.t).notin([0, 1]).as_('alias') + + self.assertEqual('"foo" NOT IN (0,1) "alias"', str(c1)) + self.assertEqual('"notin"."foo" NOT IN (0,1) "alias"', str(c2)) + + def test__notin_character(self): + c1 = Field("foo").notin(["a", "b"]) + c2 = Field("foo", table=self.t).notin(["a", "b"]) + + self.assertEqual("\"foo\" NOT IN ('a','b')", str(c1)) + self.assertEqual("\"notin\".\"foo\" NOT IN ('a','b')", str(c2)) + + def test__notin_date(self): + c1 = Field("foo").notin([date(2000, 1, 1), date(2000, 12, 31)]) + c2 = Field("foo", table=self.t).notin([date(2000, 1, 1), date(2000, 12, 31)]) + + self.assertEqual("\"foo\" NOT IN ('2000-01-01','2000-12-31')", str(c1)) + self.assertEqual("\"notin\".\"foo\" NOT IN ('2000-01-01','2000-12-31')", str(c2)) + + def test__notin_datetime(self): + c1 = Field("foo").notin([datetime(2000, 1, 1, 0, 0, 0), datetime(2000, 12, 31, 23, 59, 59)]) + c2 = Field("foo", table=self.t).notin([datetime(2000, 1, 1, 0, 0, 0), datetime(2000, 12, 31, 23, 59, 59)]) + + self.assertEqual("\"foo\" NOT IN ('2000-01-01T00:00:00','2000-12-31T23:59:59')", str(c1)) + self.assertEqual( + "\"notin\".\"foo\" NOT IN ('2000-01-01T00:00:00','2000-12-31T23:59:59')", + str(c2), + ) + + def test__function_notin(self): + c1 = fn.Coalesce(Field("foo"), 0).notin([0, 1]) + c2 = fn.Coalesce(Field("foo", table=self.t), 0).notin([0, 1]) + + self.assertEqual('COALESCE("foo",0) NOT IN (0,1)', str(c1)) + self.assertEqual('COALESCE("notin"."foo",0) NOT IN (0,1)', str(c2)) + + +class LikeTests(unittest.TestCase): + t = Table("abc", alias="like") + + def test_like_starts_with(self): + c1 = Field("foo").like("ab%") + c2 = Field("foo", table=self.t).like("ab%") + + self.assertEqual("\"foo\" LIKE 'ab%'", str(c1)) + self.assertEqual('"like"."foo" LIKE \'ab%\'', str(c2)) + + def test_like_contains(self): + c1 = Field("foo").like("%ab%") + c2 = Field("foo", table=self.t).like("%ab%") + + self.assertEqual("\"foo\" LIKE '%ab%'", str(c1)) + self.assertEqual('"like"."foo" LIKE \'%ab%\'', str(c2)) + + def test_like_ends_with(self): + c1 = Field("foo").like("%ab") + c2 = Field("foo", table=self.t).like("%ab") + + self.assertEqual("\"foo\" LIKE '%ab'", str(c1)) + self.assertEqual('"like"."foo" LIKE \'%ab\'', str(c2)) + + def test_like_n_chars_long(self): + c1 = Field("foo").like("___") + c2 = Field("foo", table=self.t).like("___") + + self.assertEqual("\"foo\" LIKE '___'", str(c1)) + self.assertEqual('"like"."foo" LIKE \'___\'', str(c2)) + + def test_like_single_chars_and_various_chars(self): + c1 = Field("foo").like("a_b%c") + c2 = Field("foo", table=self.t).like("a_b%c") + + self.assertEqual("\"foo\" LIKE 'a_b%c'", str(c1)) + self.assertEqual('"like"."foo" LIKE \'a_b%c\'', str(c2)) + + def test_not_like_single_chars_and_various_chars(self): + c1 = Field("foo").not_like("a_b%c") + c2 = Field("foo", table=self.t).not_like("a_b%c") + + self.assertEqual("\"foo\" NOT LIKE 'a_b%c'", str(c1)) + self.assertEqual('"like"."foo" NOT LIKE \'a_b%c\'', str(c2)) + + def test_ilike_starts_with(self): + c1 = Field("foo").ilike("ab%") + c2 = Field("foo", table=self.t).ilike("ab%") + + self.assertEqual("\"foo\" ILIKE 'ab%'", str(c1)) + self.assertEqual('"like"."foo" ILIKE \'ab%\'', str(c2)) + + def test_ilike_contains(self): + c1 = Field("foo").ilike("%ab%") + c2 = Field("foo", table=self.t).ilike("%ab%") + + self.assertEqual("\"foo\" ILIKE '%ab%'", str(c1)) + self.assertEqual('"like"."foo" ILIKE \'%ab%\'', str(c2)) + + def test_ilike_ends_with(self): + c1 = Field("foo").ilike("%ab") + c2 = Field("foo", table=self.t).ilike("%ab") + + self.assertEqual("\"foo\" ILIKE '%ab'", str(c1)) + self.assertEqual('"like"."foo" ILIKE \'%ab\'', str(c2)) + + def test_ilike_n_chars_long(self): + c1 = Field("foo").ilike("___") + c2 = Field("foo", table=self.t).ilike("___") + + self.assertEqual("\"foo\" ILIKE '___'", str(c1)) + self.assertEqual('"like"."foo" ILIKE \'___\'', str(c2)) + + def test_ilike_single_chars_and_various_chars(self): + c1 = Field("foo").ilike("a_b%c") + c2 = Field("foo", table=self.t).ilike("a_b%c") + + self.assertEqual("\"foo\" ILIKE 'a_b%c'", str(c1)) + self.assertEqual('"like"."foo" ILIKE \'a_b%c\'', str(c2)) + + def test_not_ilike_single_chars_and_various_chars(self): + c1 = Field("foo").not_ilike("a_b%c") + c2 = Field("foo", table=self.t).not_ilike("a_b%c") + + self.assertEqual("\"foo\" NOT ILIKE 'a_b%c'", str(c1)) + self.assertEqual('"like"."foo" NOT ILIKE \'a_b%c\'', str(c2)) + + def test_rlike_escape_chars(self): + c1 = Field("foo").rlike("\\\\d+$") + c2 = Field("foo", table=self.t).rlike("\\\\d+$") + + self.assertEqual("\"foo\" RLIKE '\\\\d+$'", str(c1)) + self.assertEqual('"like"."foo" RLIKE \'\\\\d+$\'', str(c2)) + + def test_glob_single_chars_and_various_chars(self): + c1 = Field("foo").glob("a_b*") + c2 = Field("foo", table=self.t).glob("a_b*") + + self.assertEqual("\"foo\" GLOB 'a_b*'", str(c1)) + self.assertEqual('"like"."foo" GLOB \'a_b*\'', str(c2)) + + +class ExistsCriterionTests(unittest.TestCase): + t2 = Table("abc", alias="t2") + q2 = QueryBuilder().from_(t2).select(t2.field2) + + def test_exists(self): + t1 = Table("def", alias="t1") + q1 = QueryBuilder().from_(t1).where(ExistsCriterion(self.q2)).select(t1.field1) + + self.assertEqual( + 'SELECT "t1"."field1" FROM "def" "t1" WHERE EXISTS (SELECT "t2"."field2" FROM "abc" "t2")', str(q1) + ) + + def test_not_exists(self): + t1 = Table("def", alias="t1") + q1 = QueryBuilder().from_(t1).where(ExistsCriterion(self.q2).negate()).select(t1.field1) + + self.assertEqual( + 'SELECT "t1"."field1" FROM "def" "t1" WHERE NOT EXISTS (SELECT "t2"."field2" FROM "abc" "t2")', str(q1) + ) + + +class ComplexCriterionTests(unittest.TestCase): + table_abc, table_efg = Table("abc", alias="cx0"), Table("efg", alias="cx1") + + def test_and(self): + c1 = (Field("foo") == 1) & (Field("bar") == 2) + c2 = (Field("foo", table=self.table_abc) == 1) & (Field("bar", table=self.table_efg) == 2) + + self.assertEqual('"foo"=1 AND "bar"=2', str(c1)) + self.assertEqual('"cx0"."foo"=1 AND "cx1"."bar"=2', str(c2)) + + def test_or(self): + c1 = (Field("foo") == 1) | (Field("bar") == 2) + c2 = (Field("foo", table=self.table_abc) == 1) | (Field("bar", table=self.table_efg) == 2) + + self.assertEqual('"foo"=1 OR "bar"=2', str(c1)) + self.assertEqual('"cx0"."foo"=1 OR "cx1"."bar"=2', str(c2)) + + def test_xor(self): + c1 = (Field("foo") == 1) ^ (Field("bar") == 2) + c2 = (Field("foo", table=self.table_abc) == 1) ^ (Field("bar", table=self.table_efg) == 2) + + self.assertEqual('"foo"=1 XOR "bar"=2', str(c1)) + self.assertEqual('"cx0"."foo"=1 XOR "cx1"."bar"=2', str(c2)) + + def test_function_and(self): + c1 = fn.IsNull(Field("foo")) & (Field("bar") == 2) + + self.assertEqual('ISNULL("foo") AND "bar"=2', str(c1)) + + def test_function_or(self): + c1 = fn.IsNull(Field("foo")) | (Field("bar") == 2) + + self.assertEqual('ISNULL("foo") OR "bar"=2', str(c1)) + + def test_function_xor(self): + c1 = fn.IsNull(Field("foo")) ^ (Field("bar") == 2) + + self.assertEqual('ISNULL("foo") XOR "bar"=2', str(c1)) + + def test__nested__and(self): + c = (Field("foo") == 1) & (Field("bar") == 2) & (Field("buz") == 3) + + self.assertEqual('"foo"=1 AND "bar"=2 AND "buz"=3', str(c)) + + def test__nested__or(self): + c = (Field("foo") == 1) | (Field("bar") == 2) | (Field("buz") == 3) + + self.assertEqual('"foo"=1 OR "bar"=2 OR "buz"=3', str(c)) + + def test__nested__mixed(self): + c = ((Field("foo") == 1) & (Field("bar") == 2)) | (Field("buz") == 3) + + self.assertEqual('("foo"=1 AND "bar"=2) OR "buz"=3', str(c)) + + def test__between_and_isin(self): + c = Field("foo").isin([1, 2, 3]) & Field("bar").between(0, 1) + + self.assertEqual('"foo" IN (1,2,3) AND "bar" BETWEEN 0 AND 1', str(c)) + + def test__between_and_field(self): + c1 = Field("foo").between(0, 1) + c2 = Field("bool_field") + + self.assertEqual('"foo" BETWEEN 0 AND 1 AND "bool_field"', str(c1 & c2)) + self.assertEqual('"bool_field" AND "foo" BETWEEN 0 AND 1', str(c2 & c1)) + + +class FieldsAsCriterionTests(unittest.TestCase): + def test__field_and_field(self): + c1 = Field("a") + c2 = Field("b") + + self.assertEqual('"a" AND "b"', str(c1 & c2)) + + def test__field_or_field(self): + c1 = Field("a") + c2 = Field("b") + + self.assertEqual('"a" OR "b"', str(c1 | c2)) + + def test__field_xor_field(self): + c1 = Field("a") + c2 = Field("b") + + self.assertEqual('"a" XOR "b"', str(c1 ^ c2)) + + +class CriterionOperationsTests(unittest.TestCase): + table_abc, table_efg = Table("abc", alias="cx0"), Table("efg", alias="cx1") + + def test_field_replace_table(self): + f = self.table_abc.foo.replace_table(self.table_abc, self.table_efg) + + self.assertEqual('"cx1"."foo"', str(f)) + + def test_arithmeticfunction_replace_table(self): + f = (self.table_abc.foo + self.table_abc.bar).replace_table(self.table_abc, self.table_efg) + + self.assertEqual('"cx1"."foo"+"cx1"."bar"', str(f)) + + def test_criterion_replace_table(self): + f = (self.table_abc.foo < self.table_abc.bar).replace_table(self.table_abc, self.table_efg) + + self.assertEqual('"cx1"."foo"<"cx1"."bar"', str(f)) + + def test_complexcriterion_replace_table(self): + f = (self.table_abc.foo < self.table_abc.bar) & (self.table_abc.fiz > self.table_abc.buz) + f = f.replace_table(self.table_abc, self.table_efg) + + self.assertEqual('"cx1"."foo"<"cx1"."bar" AND "cx1"."fiz">"cx1"."buz"', str(f)) + + def test_function_with_only_fields_replace_table(self): + f = fn.Sum(self.table_abc.foo).replace_table(self.table_abc, self.table_efg) + + self.assertEqual('SUM("cx1"."foo")', str(f)) + + def test_function_with_values_and_fields_replace_table(self): + f = Mod(self.table_abc.foo, 2).replace_table(self.table_abc, self.table_efg) + + self.assertEqual('MOD("cx1"."foo",2)', str(f)) + + def test_betweencriterion_replace_table(self): + f = self.table_abc.foo[0:1].replace_table(self.table_abc, self.table_efg) + + self.assertEqual('"cx1"."foo" BETWEEN 0 AND 1', str(f)) + + def test_nullcriterion_replace_table(self): + f = self.table_abc.foo.isnull().replace_table(self.table_abc, self.table_efg) + + self.assertEqual('"cx1"."foo" IS NULL', str(f)) + + +class AnyTests(unittest.TestCase): + def test_zero_args_returns_empty_criterion(self): + crit = Criterion.any() + self.assertIsInstance(crit, EmptyCriterion) + + def test_single_arg_returns_self(self): + f = Field("a") + crit = Criterion.any([f]) + self.assertEqual(str(f), str(crit)) + + def test_multiple_args_returned_in_chain_of_ors(self): + crit = Criterion.any([Field("a"), Field("b"), Field("c"), Field("d")]) + self.assertEqual(str(crit), '"a" OR "b" OR "c" OR "d"') + + def test_with_generator(self): + crit = Criterion.any(Field(letter) for letter in "abcd") + self.assertEqual(str(crit), '"a" OR "b" OR "c" OR "d"') + + +class EmptyCriterionTests(unittest.TestCase): + def test_fields_(self): + empty_criterion = EmptyCriterion() + + self.assertEqual(len(empty_criterion.fields_()), 0) + + def test_empty_criterion_on_the_left(self): + t = Table("test1") + q = EmptyCriterion() & t.f1 == "v1" + + self.assertEqual( + '"test1"."f1"=\'v1\'', + q.get_sql(with_namespace=True), + ) + + def test_empty_criterion_on_the_right(self): + t = Table("test1") + q = (t.f1 == "v1") & EmptyCriterion() + + self.assertEqual( + '"test1"."f1"=\'v1\'', + q.get_sql(with_namespace=True), + ) + + def test_invertion_of_the_empty_criterion(self): + t = Table("test1") + q = (t.f1 == "v1") & ~EmptyCriterion() + + self.assertEqual( + '"test1"."f1"=\'v1\'', + q.get_sql(with_namespace=True), + ) + + def test_different_operations_with_empty_criterion(self): + t = Table("test1") + q1 = (t.f1 == "v1") & EmptyCriterion() + q2 = (t.f1 == "v1") | EmptyCriterion() + q3 = (t.f1 == "v1") ^ EmptyCriterion() + + expected_sql = '"test1"."f1"=\'v1\'' + self.assertEqual( + expected_sql, + q1.get_sql(with_namespace=True), + ) + self.assertEqual( + expected_sql, + q2.get_sql(with_namespace=True), + ) + self.assertEqual( + expected_sql, + q3.get_sql(with_namespace=True), + ) + + def test_more_than_one_empty_criterions(self): + t = Table("test1") + q = EmptyCriterion() & ~(EmptyCriterion() | EmptyCriterion()) & (t.f1 == "v1") & ~EmptyCriterion() + + self.assertEqual( + '"test1"."f1"=\'v1\'', + q.get_sql(with_namespace=True), + ) + + +class AllTests(unittest.TestCase): + def test_zero_args_returns_empty_criterion(self): + crit = Criterion.all() + self.assertIsInstance(crit, EmptyCriterion) + + def test_single_arg_returns_self(self): + f = Field("a") + crit = Criterion.all([f]) + self.assertEqual(str(f), str(crit)) + + def test_multiple_args_returned_in_chain_of_ors(self): + crit = Criterion.all([Field("a"), Field("b"), Field("c"), Field("d")]) + self.assertEqual(str(crit), '"a" AND "b" AND "c" AND "d"') + + def test_with_generator(self): + crit = Criterion.all(Field(letter) for letter in "abcd") + self.assertEqual(str(crit), '"a" AND "b" AND "c" AND "d"') diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/test_custom_functions.py b/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/test_custom_functions.py new file mode 100644 index 0000000000000000000000000000000000000000..60ffd3cd8e6191e3fc782dac003c41bfb7a78528 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/test_custom_functions.py @@ -0,0 +1,49 @@ +import unittest + +from pypika import CustomFunction, FunctionException, Query, Table + +__author__ = "Airton Zanon" +__email__ = "me@airton.dev" + + +class TestUnitCustomFunction(unittest.TestCase): + def test_should_fail_with_wrong_arguments(self): + DateDiff = CustomFunction("DATE_DIFF", ["interval", "start_date", "end_date"]) + + with self.assertRaises(FunctionException): + DateDiff("foo") + + def test_should_return_function_with_arguments(self): + DateDiff = CustomFunction("DATE_DIFF", ["interval", "start_date", "end_date"]) + + self.assertEqual( + "DATE_DIFF('day','start_date','end_date')", + str(DateDiff("day", "start_date", "end_date")), + ) + + def test_should_return_function_with_no_arguments(self): + CurrentDate = CustomFunction("CURRENT_DATE") + + self.assertEqual("CURRENT_DATE()", str(CurrentDate())) + + +class TestFunctionalCustomFunction(unittest.TestCase): + def test_should_use_custom_function_on_select(self): + service = Table("service") + + DateDiff = CustomFunction("DATE_DIFF", ["interval", "start_date", "end_date"]) + + q = Query.from_(service).select(DateDiff("day", service.created_date, service.updated_date)) + + self.assertEqual( + 'SELECT DATE_DIFF(\'day\',"created_date","updated_date") FROM "service"', + str(q), + ) + + def test_should_fail_use_custom_function_on_select_with_wrong_arguments(self): + service = Table("service") + + DateDiff = CustomFunction("DATE_DIFF", ["interval", "start_date", "end_date"]) + + with self.assertRaises(FunctionException): + Query.from_(service).select(DateDiff("day", service.created_date)) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/test_data_types.py b/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/test_data_types.py new file mode 100644 index 0000000000000000000000000000000000000000..52fb4487fe7be3ae28a4e9eb08628fba89dc0f79 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/test_data_types.py @@ -0,0 +1,15 @@ +import unittest +import uuid + +from pypika.terms import ValueWrapper + + +class StringTests(unittest.TestCase): + def test_inline_string_concatentation(self): + self.assertEqual("'it''s'", ValueWrapper("it's").get_sql()) + + +class UuidTests(unittest.TestCase): + def test_uuid_string_generation(self): + id = uuid.uuid4() + self.assertEqual("'{}'".format(id), ValueWrapper(id).get_sql()) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/test_date_math.py b/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/test_date_math.py new file mode 100644 index 0000000000000000000000000000000000000000..38db8ef2f8e812a97c6980a7ec6b9a3909d804fb --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/test_date_math.py @@ -0,0 +1,179 @@ +import unittest + +from pypika import ( + Field as F, + Interval, +) +from pypika.enums import Dialects + +dt = F("dt") + + +class AddIntervalTests(unittest.TestCase): + def test_add_microsecond(self): + c = dt + Interval(microseconds=1) + + self.assertEqual("\"dt\"+INTERVAL '1 MICROSECOND'", str(c)) + + def test_add_second(self): + c = dt + Interval(seconds=1) + + self.assertEqual("\"dt\"+INTERVAL '1 SECOND'", str(c)) + + def test_add_minute(self): + c = dt + Interval(minutes=1) + + self.assertEqual("\"dt\"+INTERVAL '1 MINUTE'", str(c)) + + def test_add_day(self): + c = dt + Interval(days=1) + + self.assertEqual("\"dt\"+INTERVAL '1 DAY'", str(c)) + + def test_add_week(self): + c = dt + Interval(weeks=1) + + self.assertEqual("\"dt\"+INTERVAL '1 WEEK'", str(c)) + + def test_add_month(self): + c = dt + Interval(months=1) + + self.assertEqual("\"dt\"+INTERVAL '1 MONTH'", str(c)) + + def test_add_quarter(self): + c = dt + Interval(quarters=1) + + self.assertEqual("\"dt\"+INTERVAL '1 QUARTER'", str(c)) + + def test_add_year(self): + c = dt + Interval(years=1) + + self.assertEqual("\"dt\"+INTERVAL '1 YEAR'", str(c)) + + def test_add_default(self): + c = dt + Interval(days=0) + + self.assertEqual("\"dt\"+INTERVAL '0 DAY'", str(c)) + + +class AddIntervalMultipleUnitsTests(unittest.TestCase): + def test_add_second_microsecond(self): + c = dt + Interval(seconds=1, microseconds=1) + + self.assertEqual("\"dt\"+INTERVAL '1.1 SECOND_MICROSECOND'", str(c)) + + def test_add_minute_microsecond(self): + c = dt + Interval(minutes=1, microseconds=1) + + self.assertEqual("\"dt\"+INTERVAL '1:0.1 MINUTE_MICROSECOND'", str(c)) + + def test_add_minute_second(self): + c = dt + Interval(minutes=1, seconds=1) + + self.assertEqual("\"dt\"+INTERVAL '1:1 MINUTE_SECOND'", str(c)) + + def test_add_hour_microsecond(self): + c = dt + Interval(hours=1, microseconds=1) + + self.assertEqual("\"dt\"+INTERVAL '1:0:0.1 HOUR_MICROSECOND'", str(c)) + + def test_add_hour_second(self): + c = dt + Interval(hours=1, seconds=1) + + self.assertEqual("\"dt\"+INTERVAL '1:0:1 HOUR_SECOND'", str(c)) + + def test_add_hour_minute(self): + c = dt + Interval(hours=1, minutes=1) + + self.assertEqual("\"dt\"+INTERVAL '1:1 HOUR_MINUTE'", str(c)) + + def test_add_day_microsecond(self): + c = dt + Interval(days=1, microseconds=1) + + self.assertEqual("\"dt\"+INTERVAL '1 0:0:0.1 DAY_MICROSECOND'", str(c)) + + def test_add_day_second(self): + c = dt + Interval(days=1, seconds=1) + + self.assertEqual("\"dt\"+INTERVAL '1 0:0:1 DAY_SECOND'", str(c)) + + def test_add_day_minute(self): + c = dt + Interval(days=1, minutes=1) + + self.assertEqual("\"dt\"+INTERVAL '1 0:1 DAY_MINUTE'", str(c)) + + def test_add_day_hour(self): + c = dt + Interval(days=1, hours=1) + + self.assertEqual("\"dt\"+INTERVAL '1 1 DAY_HOUR'", str(c)) + + def test_add_year_month(self): + c = dt + Interval(years=1, months=1) + + self.assertEqual("\"dt\"+INTERVAL '1-1 YEAR_MONTH'", str(c)) + + def test_add_value_right(self): + c = Interval(microseconds=1) - dt + + self.assertEqual("INTERVAL '1 MICROSECOND'-\"dt\"", str(c)) + + def test_add_value_complex_expressions(self): + c = dt + Interval(quarters=1) + Interval(weeks=1) + + self.assertEqual("\"dt\"+INTERVAL '1 QUARTER'+INTERVAL '1 WEEK'", str(c)) + + +class DialectIntervalTests(unittest.TestCase): + def test_mysql_dialect_uses_single_quotes_around_expression_in_an_interval(self): + c = Interval(days=1).get_sql(dialect=Dialects.MYSQL) + self.assertEqual("INTERVAL '1' DAY", c) + + def test_oracle_dialect_uses_single_quotes_around_expression_in_an_interval(self): + c = Interval(days=1).get_sql(dialect=Dialects.ORACLE) + self.assertEqual("INTERVAL '1' DAY", c) + + def test_vertica_dialect_uses_single_quotes_around_interval(self): + c = Interval(days=1).get_sql(dialect=Dialects.VERTICA) + self.assertEqual("INTERVAL '1 DAY'", c) + + def test_redshift_dialect_uses_single_quotes_around_interval(self): + c = Interval(days=1).get_sql(dialect=Dialects.REDSHIFT) + self.assertEqual("INTERVAL '1 DAY'", c) + + def test_postgresql_dialect_uses_single_quotes_around_interval(self): + c = Interval(days=1).get_sql(dialect=Dialects.POSTGRESQL) + self.assertEqual("INTERVAL '1 DAY'", c) + + +class TestNegativeIntervals(unittest.TestCase): + def test_day(self): + c = Interval(days=-1).get_sql() + self.assertEqual("INTERVAL '-1 DAY'", c) + + def test_week(self): + c = Interval(weeks=-1).get_sql() + self.assertEqual("INTERVAL '-1 WEEK'", c) + + def test_month(self): + c = Interval(months=-1).get_sql() + self.assertEqual("INTERVAL '-1 MONTH'", c) + + def test_year(self): + c = Interval(years=-1).get_sql() + self.assertEqual("INTERVAL '-1 YEAR'", c) + + def test_year_month(self): + c = Interval(years=-1, months=-4).get_sql() + self.assertEqual("INTERVAL '-1-4 YEAR_MONTH'", c) + + +class TruncateTrailingZerosTests(unittest.TestCase): + def test_do_not_truncate_integer_values(self): + i = Interval(seconds=10) + + self.assertEqual("INTERVAL '10 SECOND'", str(i)) + + def test_do_not_truncate_months_between_years_and_datys(self): + i = Interval(years=10, days=10) + + self.assertEqual("INTERVAL '10-0-10 YEAR_DAY'", str(i)) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/test_deletes.py b/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/test_deletes.py new file mode 100644 index 0000000000000000000000000000000000000000..09df93f5331b845b0c3aed628bf1c4a3ec6b0f02 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/test_deletes.py @@ -0,0 +1,97 @@ +import unittest + +from pypika import PostgreSQLQuery, Query, SYSTEM_TIME, Table + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + +from pypika.terms import Star + + +class DeleteTests(unittest.TestCase): + @classmethod + def setUpClass(cls) -> None: + super().setUpClass() + cls.table_abc = Table("abc") + + def test_omit_where(self): + q = Query.from_("abc").delete() + + self.assertEqual('DELETE FROM "abc"', str(q)) + + def test_omit_where__table_schema(self): + q = Query.from_(Table("abc", "schema1")).delete() + + self.assertEqual('DELETE FROM "schema1"."abc"', str(q)) + + def test_where_field_equals(self): + q1 = Query.from_(self.table_abc).where(self.table_abc.foo == self.table_abc.bar).delete() + q2 = Query.from_(self.table_abc).where(self.table_abc.foo.eq(self.table_abc.bar)).delete() + + self.assertEqual('DELETE FROM "abc" WHERE "foo"="bar"', str(q1)) + self.assertEqual('DELETE FROM "abc" WHERE "foo"="bar"', str(q2)) + + def test_for_portion(self): + with self.subTest("with system time"): + q = Query.from_(self.table_abc.for_portion(SYSTEM_TIME.from_to('2020-01-01', '2020-02-01'))).delete() + + self.assertEqual( + 'DELETE FROM "abc" FOR PORTION OF SYSTEM_TIME FROM \'2020-01-01\' TO \'2020-02-01\'', str(q) + ) + + with self.subTest("with column"): + q = Query.from_( + self.table_abc.for_portion(self.table_abc.valid_period.from_to('2020-01-01', '2020-02-01')) + ).delete() + + self.assertEqual( + 'DELETE FROM "abc" FOR PORTION OF "valid_period" FROM \'2020-01-01\' TO \'2020-02-01\'', str(q) + ) + + +class PostgresDeleteTests(unittest.TestCase): + @classmethod + def setUpClass(cls) -> None: + super().setUpClass() + cls.table_abc = Table("abc") + + def test_delete_returning(self): + q1 = ( + PostgreSQLQuery.from_(self.table_abc) + .where(self.table_abc.foo == self.table_abc.bar) + .delete() + .returning(self.table_abc.id) + ) + + self.assertEqual('DELETE FROM "abc" WHERE "foo"="bar" RETURNING "id"', str(q1)) + + def test_delete_returning_str(self): + q1 = ( + PostgreSQLQuery.from_(self.table_abc) + .where(self.table_abc.foo == self.table_abc.bar) + .delete() + .returning("id") + ) + + self.assertEqual('DELETE FROM "abc" WHERE "foo"="bar" RETURNING "id"', str(q1)) + + def test_delete_returning_star(self): + q1 = ( + PostgreSQLQuery.from_(self.table_abc) + .where(self.table_abc.foo == self.table_abc.bar) + .delete() + .returning(Star()) + ) + + self.assertEqual('DELETE FROM "abc" WHERE "foo"="bar" RETURNING *', str(q1)) + + def test_delete_using(self): + table_trash = Table('trash') + q1 = ( + PostgreSQLQuery.from_(self.table_abc) + .using(table_trash) + .where(self.table_abc.id == table_trash.abc_id) + .delete() + ) + + self.assertEqual('DELETE FROM "abc" USING "trash" WHERE "abc"."id"="trash"."abc_id"', str(q1)) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/test_drop.py b/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/test_drop.py new file mode 100644 index 0000000000000000000000000000000000000000..265ae7350d2054549731f9a8c4379fdac95dc580 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/test_drop.py @@ -0,0 +1,49 @@ +import unittest + +from pypika import ( + Columns, + Database, + Query, + Tables, +) + + +class DropTableTests(unittest.TestCase): + database_xyz = Database("mydb") + new_table, existing_table = Tables("abc", "efg") + foo, bar = Columns(("a", "INT"), ("b", "VARCHAR(100)")) + + def test_drop_database(self): + q1 = Query.drop_database(self.database_xyz) + q2 = Query.drop_database(self.database_xyz).if_exists() + + self.assertEqual('DROP DATABASE "mydb"', str(q1)) + self.assertEqual('DROP DATABASE IF EXISTS "mydb"', str(q2)) + + def test_drop_table(self): + q1 = Query.drop_table(self.new_table) + q2 = Query.drop_table(self.new_table).if_exists() + + self.assertEqual('DROP TABLE "abc"', str(q1)) + self.assertEqual('DROP TABLE IF EXISTS "abc"', str(q2)) + + def test_drop_user(self): + q1 = Query.drop_user("myuser") + q2 = Query.drop_user("myuser").if_exists() + + self.assertEqual('DROP USER "myuser"', str(q1)) + self.assertEqual('DROP USER IF EXISTS "myuser"', str(q2)) + + def test_drop_view(self): + q1 = Query.drop_view("myview") + q2 = Query.drop_view("myview").if_exists() + + self.assertEqual('DROP VIEW "myview"', str(q1)) + self.assertEqual('DROP VIEW IF EXISTS "myview"', str(q2)) + + def test_drop_index(self): + q1 = Query.drop_index("myindex") + q2 = Query.drop_index("myindex").if_exists() + + self.assertEqual('DROP INDEX "myindex"', str(q1)) + self.assertEqual('DROP INDEX IF EXISTS "myindex"', str(q2)) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/test_formats.py b/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/test_formats.py new file mode 100644 index 0000000000000000000000000000000000000000..6a442757c6659a215661e03f1ca9c3771d394d96 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/test_formats.py @@ -0,0 +1,68 @@ +import unittest + +from pypika import Query, Tables, functions as fn + + +class QuoteTests(unittest.TestCase): + maxDiff = None + + table_abc, table_efg = Tables("abc", "efg") + + def setUp(self): + subquery1 = ( + Query.from_(self.table_abc) + .select( + self.table_abc.foo, + fn.Sum(self.table_abc.fizz + self.table_abc.buzz).as_("fizzbuzz"), + ) + .groupby(self.table_abc.foo) + ) + + subquery2 = Query.from_(self.table_efg).select( + self.table_efg.foo.as_("foo_two"), + self.table_efg.bar, + ) + + self.query = ( + Query.from_(subquery1) + .select(subquery1.foo, subquery1.fizzbuzz) + .join(subquery2) + .on(subquery1.foo == subquery2.foo_two) + .select(subquery2.foo_two, subquery2.bar) + ) + + def test_replace_quote_char_in_complex_query(self): + self.assertEqual( + "SELECT " + "`sq0`.`foo`,`sq0`.`fizzbuzz`," + "`sq1`.`foo_two`,`sq1`.`bar` " + "FROM (" + "SELECT " + "`foo`,SUM(`fizz`+`buzz`) `fizzbuzz` " + "FROM `abc` " + "GROUP BY `foo`" + ") `sq0` JOIN (" + "SELECT " + "`foo` `foo_two`,`bar` " + "FROM `efg`" + ") `sq1` ON `sq0`.`foo`=`sq1`.`foo_two`", + self.query.get_sql(quote_char="`"), + ) + + def test_no_quote_char_in_complex_query(self): + self.assertEqual( + "SELECT " + "sq0.foo,sq0.fizzbuzz," + "sq1.foo_two,sq1.bar " + "FROM (" + "SELECT " + "foo,SUM(fizz+buzz) fizzbuzz " + "FROM abc " + "GROUP BY foo" + ") sq0 JOIN (" + "SELECT " + "foo foo_two,bar " + "FROM efg" + ") sq1 ON sq0.foo=sq1.foo_two", + self.query.get_sql(quote_char=None), + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/test_functions.py b/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/test_functions.py new file mode 100644 index 0000000000000000000000000000000000000000..f526966eefc554ec68d0e15fb69de7d69f1604c3 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/test_functions.py @@ -0,0 +1,847 @@ +import unittest + +from pypika import ( + Case, + CaseException, + DatePart, + Field as F, + Query, + Query as Q, + Schema, + Table as T, + VerticaQuery, + functions as fn, +) +from pypika.enums import Dialects, SqlTypes + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + + +class FunctionTests(unittest.TestCase): + def test_dialect_propagation(self): + func = fn.Function("func", ["a"], ["b"]) + self.assertEqual("func(ARRAY['a'],ARRAY['b'])", func.get_sql(dialect=Dialects.POSTGRESQL)) + + def test_is_aggregate_None_for_non_aggregate_function_or_function_with_no_aggregate_functions(self): + self.assertIsNone(fn.Coalesce('a', 0).is_aggregate) + self.assertIsNone(fn.Coalesce(fn.NullIf('a', 0), 0).is_aggregate) + + def test_is_aggregate_True_for_aggregate_function_or_function_with_aggregate_functions(self): + self.assertTrue(fn.Sum('a').is_aggregate) + self.assertTrue(fn.Coalesce(fn.Avg('a'), 0).is_aggregate) + self.assertTrue(fn.Coalesce(fn.NullIf(fn.Sum('a'), 0), 0).is_aggregate) + + +class SchemaTests(unittest.TestCase): + def test_schema_no_schema_in_sql_when_none_set(self): + func = fn.Function("my_proc", 1, 2, 3) + + self.assertEqual("my_proc(1,2,3)", func.get_sql(quote_char='"')) + + def test_schema_included_in_function_sql(self): + a = Schema("a") + func = fn.Function("my_proc", 1, 2, 3, schema=a) + + self.assertEqual('"a".my_proc(1,2,3)', func.get_sql(quote_char='"')) + + +class ArithmeticTests(unittest.TestCase): + t = T("abc") + + def test__addition__fields(self): + q1 = Q.from_("abc").select(F("a") + F("b")) + q2 = Q.from_(self.t).select(self.t.a + self.t.b) + + self.assertEqual('SELECT "a"+"b" FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"+"b" FROM "abc"', str(q2)) + + def test__addition__number(self): + q1 = Q.from_("abc").select(F("a") + 1) + q2 = Q.from_(self.t).select(self.t.a + 1) + + self.assertEqual('SELECT "a"+1 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"+1 FROM "abc"', str(q2)) + + def test__addition__decimal(self): + q1 = Q.from_("abc").select(F("a") + 1.0) + q2 = Q.from_(self.t).select(self.t.a + 1.0) + + self.assertEqual('SELECT "a"+1.0 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"+1.0 FROM "abc"', str(q2)) + + def test__addition__right(self): + q1 = Q.from_("abc").select(1 + F("a")) + q2 = Q.from_(self.t).select(1 + self.t.a) + + self.assertEqual('SELECT 1+"a" FROM "abc"', str(q1)) + self.assertEqual('SELECT 1+"a" FROM "abc"', str(q2)) + + def test__subtraction__fields(self): + q1 = Q.from_("abc").select(F("a") - F("b")) + q2 = Q.from_(self.t).select(self.t.a - self.t.b) + + self.assertEqual('SELECT "a"-"b" FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"-"b" FROM "abc"', str(q2)) + + def test__subtraction__number(self): + q1 = Q.from_("abc").select(F("a") - 1) + q2 = Q.from_(self.t).select(self.t.a - 1) + + self.assertEqual('SELECT "a"-1 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"-1 FROM "abc"', str(q2)) + + def test__subtraction__decimal(self): + q1 = Q.from_("abc").select(F("a") - 1.0) + q2 = Q.from_(self.t).select(self.t.a - 1.0) + + self.assertEqual('SELECT "a"-1.0 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"-1.0 FROM "abc"', str(q2)) + + def test__subtraction__right(self): + q1 = Q.from_("abc").select(1 - F("a")) + q2 = Q.from_(self.t).select(1 - self.t.a) + + self.assertEqual('SELECT 1-"a" FROM "abc"', str(q1)) + self.assertEqual('SELECT 1-"a" FROM "abc"', str(q2)) + + def test__multiplication__fields(self): + q1 = Q.from_("abc").select(F("a") * F("b")) + q2 = Q.from_(self.t).select(self.t.a * self.t.b) + + self.assertEqual('SELECT "a"*"b" FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"*"b" FROM "abc"', str(q2)) + + def test__multiplication__number(self): + q1 = Q.from_("abc").select(F("a") * 1) + q2 = Q.from_(self.t).select(self.t.a * 1) + + self.assertEqual('SELECT "a"*1 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"*1 FROM "abc"', str(q2)) + + def test__multiplication__decimal(self): + q1 = Q.from_("abc").select(F("a") * 1.0) + q2 = Q.from_(self.t).select(self.t.a * 1.0) + + self.assertEqual('SELECT "a"*1.0 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"*1.0 FROM "abc"', str(q2)) + + def test__multiplication__right(self): + q1 = Q.from_("abc").select(1 * F("a")) + q2 = Q.from_(self.t).select(1 * self.t.a) + + self.assertEqual('SELECT 1*"a" FROM "abc"', str(q1)) + self.assertEqual('SELECT 1*"a" FROM "abc"', str(q2)) + + def test__division__fields(self): + q1 = Q.from_("abc").select(F("a") / F("b")) + q2 = Q.from_(self.t).select(self.t.a / self.t.b) + + self.assertEqual('SELECT "a"/"b" FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"/"b" FROM "abc"', str(q2)) + + def test__division__number(self): + q1 = Q.from_("abc").select(F("a") / 1) + q2 = Q.from_(self.t).select(self.t.a / 1) + + self.assertEqual('SELECT "a"/1 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"/1 FROM "abc"', str(q2)) + + def test__division__decimal(self): + q1 = Q.from_("abc").select(F("a") / 1.0) + q2 = Q.from_(self.t).select(self.t.a / 1.0) + + self.assertEqual('SELECT "a"/1.0 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"/1.0 FROM "abc"', str(q2)) + + def test__division__right(self): + q1 = Q.from_("abc").select(1 / F("a")) + q2 = Q.from_(self.t).select(1 / self.t.a) + + self.assertEqual('SELECT 1/"a" FROM "abc"', str(q1)) + self.assertEqual('SELECT 1/"a" FROM "abc"', str(q2)) + + def test__leftshift__fields(self): + q1 = Q.from_("abc").select(F("a") << F("b")) + q2 = Q.from_(self.t).select(self.t.a << self.t.b) + + self.assertEqual('SELECT "a"<<"b" FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"<<"b" FROM "abc"', str(q2)) + + def test__leftshift__number(self): + q1 = Q.from_("abc").select(F('a') << 2) + q2 = Q.from_(self.t).select(self.t.a << 2) + + self.assertEqual('SELECT "a"<<2 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"<<2 FROM "abc"', str(q2)) + + def test__leftshift__right(self): + q1 = Q.from_("abc").select(1 << F("a")) + q2 = Q.from_(self.t).select(1 << self.t.a) + + self.assertEqual('SELECT 1<<"a" FROM "abc"', str(q1)) + self.assertEqual('SELECT 1<<"a" FROM "abc"', str(q2)) + + def test__rightshift__fields(self): + q1 = Q.from_("abc").select(F("a") >> F("b")) + q2 = Q.from_(self.t).select(self.t.a >> self.t.b) + + self.assertEqual('SELECT "a">>"b" FROM "abc"', str(q1)) + self.assertEqual('SELECT "a">>"b" FROM "abc"', str(q2)) + + def test__rightshift__number(self): + q1 = Q.from_("abc").select(F('a') >> 2) + q2 = Q.from_(self.t).select(self.t.a >> 2) + + self.assertEqual('SELECT "a">>2 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a">>2 FROM "abc"', str(q2)) + + def test__rightshift__right(self): + q1 = Q.from_("abc").select(1 >> F("a")) + q2 = Q.from_(self.t).select(1 >> self.t.a) + + self.assertEqual('SELECT 1>>"a" FROM "abc"', str(q1)) + self.assertEqual('SELECT 1>>"a" FROM "abc"', str(q2)) + + def test__complex_op(self): + q1 = Q.from_("abc").select(2 + 1 / F("a") - 5) + q2 = Q.from_(self.t).select(2 + 1 / self.t.a - 5) + + self.assertEqual('SELECT 2+1/"a"-5 FROM "abc"', str(q1)) + self.assertEqual('SELECT 2+1/"a"-5 FROM "abc"', str(q2)) + + def test__complex_op_add_parentheses(self): + q1 = Q.from_("abc").select((F("a") + 1) + (F("b") - 5)) + q2 = Q.from_(self.t).select((self.t.a + 1) + (self.t.b - 5)) + q3 = Q.from_("abc").select((F("a") / 1) + (F("b") / 5)) + q4 = Q.from_(self.t).select((self.t.a / 1) + (self.t.b / 5)) + + self.assertEqual('SELECT "a"+1+"b"-5 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"+1+"b"-5 FROM "abc"', str(q2)) + self.assertEqual('SELECT "a"/1+"b"/5 FROM "abc"', str(q3)) + self.assertEqual('SELECT "a"/1+"b"/5 FROM "abc"', str(q4)) + + def test__complex_op_sub_parentheses(self): + q1 = Q.from_("abc").select((F("a") + 1) - (F("b") - 5)) + q2 = Q.from_(self.t).select((self.t.a + 1) - (self.t.b - 5)) + q3 = Q.from_("abc").select((F("a") / 1) - (F("b") / 5)) + q4 = Q.from_(self.t).select((self.t.a / 1) - (self.t.b / 5)) + + self.assertEqual('SELECT "a"+1-("b"-5) FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"+1-("b"-5) FROM "abc"', str(q2)) + self.assertEqual('SELECT "a"/1-"b"/5 FROM "abc"', str(q3)) + self.assertEqual('SELECT "a"/1-"b"/5 FROM "abc"', str(q4)) + + def test__complex_op_mul_parentheses(self): + q1 = Q.from_("abc").select((F("a") + 1) * (F("b") - 5)) + q2 = Q.from_(self.t).select((self.t.a + 1) * (self.t.b - 5)) + q3 = Q.from_("abc").select((F("a") / 1) * (F("b") - 5)) + q4 = Q.from_(self.t).select((self.t.a / 1) * (self.t.b - 5)) + q5 = Q.from_("abc").select((F("a") + 1) * (F("b") / 5)) + q6 = Q.from_(self.t).select((self.t.a + 1) * (self.t.b / 5)) + + self.assertEqual('SELECT ("a"+1)*("b"-5) FROM "abc"', str(q1)) + self.assertEqual('SELECT ("a"+1)*("b"-5) FROM "abc"', str(q2)) + self.assertEqual('SELECT "a"/1*("b"-5) FROM "abc"', str(q3)) + self.assertEqual('SELECT "a"/1*("b"-5) FROM "abc"', str(q4)) + self.assertEqual('SELECT ("a"+1)*"b"/5 FROM "abc"', str(q5)) + self.assertEqual('SELECT ("a"+1)*"b"/5 FROM "abc"', str(q6)) + + def test__complex_op_mul_no_parentheses(self): + q = Q.from_("abc").select(F("a") + 1 * F("b") - 5) + + self.assertEqual('SELECT "a"+1*"b"-5 FROM "abc"', str(q)) + + def test__complex_op_div_parentheses(self): + q1 = Q.from_("abc").select((F("a") + 1) / (F("b") - 5)) + q2 = Q.from_(self.t).select((self.t.a + 1) / (self.t.b - 5)) + q3 = Q.from_("abc").select((F("a") / 1) / (F("b") - 5)) + q4 = Q.from_(self.t).select((self.t.a / 1) / (self.t.b - 5)) + q5 = Q.from_("abc").select((F("a") + 1) / (F("b") * 5)) + q6 = Q.from_(self.t).select((self.t.a + 1) / (self.t.b * 5)) + + self.assertEqual('SELECT ("a"+1)/("b"-5) FROM "abc"', str(q1)) + self.assertEqual('SELECT ("a"+1)/("b"-5) FROM "abc"', str(q2)) + self.assertEqual('SELECT "a"/1/("b"-5) FROM "abc"', str(q3)) + self.assertEqual('SELECT "a"/1/("b"-5) FROM "abc"', str(q4)) + self.assertEqual('SELECT ("a"+1)/("b"*5) FROM "abc"', str(q5)) + self.assertEqual('SELECT ("a"+1)/("b"*5) FROM "abc"', str(q6)) + + def test__complex_op_div_no_parentheses(self): + q = Q.from_("abc").select(F("a") + 1 / F("b") - 5) + + self.assertEqual('SELECT "a"+1/"b"-5 FROM "abc"', str(q)) + + def test__complex_op_exponent_parentheses(self): + q1 = Q.from_("abc").select(F("a") / (F("b") ** 2)) + q2 = Q.from_(self.t).select(self.t.a / (self.t.b**2)) + q3 = Q.from_("abc").select(F("a") ** (F("b") / 2)) + q4 = Q.from_(self.t).select(self.t.a ** (self.t.b / 2)) + q5 = Q.from_("abc").select((F("a") ** F("b")) ** 2) + q6 = Q.from_(self.t).select((self.t.a**self.t.b) ** 2) + + self.assertEqual('SELECT "a"/POW("b",2) FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"/POW("b",2) FROM "abc"', str(q2)) + self.assertEqual('SELECT POW("a","b"/2) FROM "abc"', str(q3)) + self.assertEqual('SELECT POW("a","b"/2) FROM "abc"', str(q4)) + self.assertEqual('SELECT POW(POW("a","b"),2) FROM "abc"', str(q5)) + self.assertEqual('SELECT POW(POW("a","b"),2) FROM "abc"', str(q6)) + + def test__complex_op_exponent_no_parentheses(self): + q1 = Q.from_("abc").select(F("a") ** F("b") ** 2) + q2 = Q.from_(self.t).select(self.t.a**self.t.b**2) + q3 = Q.from_("abc").select(F("a") / F("b") ** 2) + q4 = Q.from_(self.t).select(self.t.a / self.t.b**2) + + self.assertEqual('SELECT POW("a",POW("b",2)) FROM "abc"', str(q1)) + self.assertEqual('SELECT POW("a",POW("b",2)) FROM "abc"', str(q2)) + self.assertEqual('SELECT "a"/POW("b",2) FROM "abc"', str(q3)) + self.assertEqual('SELECT "a"/POW("b",2) FROM "abc"', str(q4)) + + def test__complex_op_function_parentheses(self): + q1 = Q.from_("abc").select(F("a") / (fn.Sum(F("b")) / 2)) + q2 = Q.from_("abc").select(self.t.a / (fn.Sum(self.t.b) / 2)) + q3 = Q.from_("abc").select(fn.Sum(F("a") / (F("b") / 2))) + q4 = Q.from_("abc").select(fn.Sum(self.t.a / (self.t.b / 2))) + + self.assertEqual('SELECT "a"/(SUM("b")/2) FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"/(SUM("b")/2) FROM "abc"', str(q2)) + self.assertEqual('SELECT SUM("a"/("b"/2)) FROM "abc"', str(q3)) + self.assertEqual('SELECT SUM("a"/("b"/2)) FROM "abc"', str(q4)) + + def test__complex_op_modulus_parentheses(self): + q1 = Q.from_("abc").select(F("a") / (F("b") % 2)) + q2 = Q.from_(self.t).select(self.t.a / (self.t.b % 2)) + q3 = Q.from_("abc").select(F("a") % (F("b") / 2)) + q4 = Q.from_(self.t).select(self.t.a % (self.t.b / 2)) + q5 = Q.from_("abc").select(F("a") % (F("b") % 2)) + q6 = Q.from_("abc").select(self.t.a % (self.t.b % 2)) + + self.assertEqual('SELECT "a"/MOD("b",2) FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"/MOD("b",2) FROM "abc"', str(q2)) + self.assertEqual('SELECT MOD("a","b"/2) FROM "abc"', str(q3)) + self.assertEqual('SELECT MOD("a","b"/2) FROM "abc"', str(q4)) + self.assertEqual('SELECT MOD("a",MOD("b",2)) FROM "abc"', str(q5)) + self.assertEqual('SELECT MOD("a",MOD("b",2)) FROM "abc"', str(q6)) + + def test__complex_op_modulus_no_parentheses(self): + q1 = Q.from_("abc").select(F("a") % F("b") % 2) + q2 = Q.from_(self.t).select(self.t.a % self.t.b % 2) + q3 = Q.from_("abc").select(F("a") / F("b") % 2) + q4 = Q.from_(self.t).select(self.t.a / self.t.b % 2) + + self.assertEqual('SELECT MOD(MOD("a","b"),2) FROM "abc"', str(q1)) + self.assertEqual('SELECT MOD(MOD("a","b"),2) FROM "abc"', str(q2)) + self.assertEqual('SELECT MOD("a"/"b",2) FROM "abc"', str(q3)) + self.assertEqual('SELECT MOD("a"/"b",2) FROM "abc"', str(q4)) + + def test__complex_op_floor_parentheses(self): + q1 = Q.from_("abc").select(F("a") / (fn.Floor(F("b")) / 2)) + q2 = Q.from_("abc").select(self.t.a / (fn.Floor(self.t.b) / 2)) + q3 = Q.from_("abc").select(fn.Floor(F("a") / (F("b") / 2))) + q4 = Q.from_("abc").select(fn.Floor(self.t.a / (self.t.b / 2))) + + self.assertEqual('SELECT "a"/(FLOOR("b")/2) FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"/(FLOOR("b")/2) FROM "abc"', str(q2)) + self.assertEqual('SELECT FLOOR("a"/("b"/2)) FROM "abc"', str(q3)) + self.assertEqual('SELECT FLOOR("a"/("b"/2)) FROM "abc"', str(q4)) + + def test__complex_op_nested_parentheses(self): + q1 = Q.from_("abc").select(F("a") / (F("b") / ((F("c") / 2)))) + q2 = Q.from_("abc").select(self.t.a / (self.t.b / ((self.t.c / 2)))) + + self.assertEqual('SELECT "a"/("b"/("c"/2)) FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"/("b"/("c"/2)) FROM "abc"', str(q2)) + + def test__arithmetic_equality(self): + q1 = Q.from_("abc").select(F("a") / 2 == 2) + q2 = Q.from_(self.t).select(self.t.a / 2 == 2) + + self.assertEqual('SELECT "a"/2=2 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"/2=2 FROM "abc"', str(q2)) + + def test__arithmetic_with_function(self): + q1 = Q.from_("abc").select(fn.Sum(F("foo")) + 1) + q2 = Q.from_(self.t).select(fn.Sum(self.t.foo) + 1) + + self.assertEqual('SELECT SUM("foo")+1 FROM "abc"', str(q1)) + self.assertEqual('SELECT SUM("foo")+1 FROM "abc"', str(q2)) + + def test__exponent__number(self): + q1 = Q.from_("abc").select(F("a") ** 2) + q2 = Q.from_(self.t).select(self.t.a**2) + + self.assertEqual('SELECT POW("a",2) FROM "abc"', str(q1)) + self.assertEqual('SELECT POW("a",2) FROM "abc"', str(q2)) + + def test__exponent__decimal(self): + q1 = Q.from_("abc").select(F("a") ** 0.5) + q2 = Q.from_(self.t).select(self.t.a**0.5) + + self.assertEqual('SELECT POW("a",0.5) FROM "abc"', str(q1)) + self.assertEqual('SELECT POW("a",0.5) FROM "abc"', str(q2)) + + def test__modulus__number(self): + q1 = Q.from_("abc").select(F("a") % 2) + q2 = Q.from_(self.t).select(self.t.a % 2) + + self.assertEqual('SELECT MOD("a",2) FROM "abc"', str(q1)) + self.assertEqual('SELECT MOD("a",2) FROM "abc"', str(q2)) + + def test__floor(self): + q1 = Q.from_("abc").select(fn.Floor(F("foo"))) + q2 = Q.from_(self.t).select(fn.Floor(self.t.foo)) + + self.assertEqual('SELECT FLOOR("foo") FROM "abc"', str(q1)) + self.assertEqual('SELECT FLOOR("foo") FROM "abc"', str(q2)) + + +class AggregationTests(unittest.TestCase): + def test__count(self): + q = Q.from_("abc").select(fn.Count(F("foo"))) + + self.assertEqual('SELECT COUNT("foo") FROM "abc"', str(q)) + + def test__count__star(self): + q = Q.from_("abc").select(fn.Count("*")) + + self.assertEqual('SELECT COUNT(*) FROM "abc"', str(q)) + + def test__sum(self): + q = Q.from_("abc").select(fn.Sum(F("foo"))) + + self.assertEqual('SELECT SUM("foo") FROM "abc"', str(q)) + + def test__avg(self): + q = Q.from_("abc").select(fn.Avg(F("foo"))) + + self.assertEqual('SELECT AVG("foo") FROM "abc"', str(q)) + + def test__first(self): + q = Q.from_("abc").select(fn.First(F("foo"))) + + self.assertEqual('SELECT FIRST("foo") FROM "abc"', str(q)) + + def test__last(self): + q = Q.from_("abc").select(fn.Last(F("foo"))) + + self.assertEqual('SELECT LAST("foo") FROM "abc"', str(q)) + + def test__min(self): + q = Q.from_("abc").select(fn.Min(F("foo"))) + + self.assertEqual('SELECT MIN("foo") FROM "abc"', str(q)) + + def test__max(self): + q = Q.from_("abc").select(fn.Max(F("foo"))) + + self.assertEqual('SELECT MAX("foo") FROM "abc"', str(q)) + + def test__std(self): + q = Q.from_("abc").select(fn.Std(F("foo"))) + + self.assertEqual('SELECT STD("foo") FROM "abc"', str(q)) + + def test__stddev(self): + q = Q.from_("abc").select(fn.StdDev(F("foo"))) + + self.assertEqual('SELECT STDDEV("foo") FROM "abc"', str(q)) + + def test__approx_percentile(self): + q = Q.from_("abc").select(fn.ApproximatePercentile(F("foo"), 0.5)) + + self.assertEqual( + 'SELECT APPROXIMATE_PERCENTILE("foo" USING PARAMETERS percentile=0.5) FROM "abc"', + str(q), + ) + + def test__subquery_in_params_functions(self): + subquery = Query.from_('table').select('id') + func = fn.Function('func', 'id', subquery) + self.assertEqual("func('id',(SELECT id FROM table))", func.get_sql()) + + +class ConditionTests(unittest.TestCase): + def test__case__raw(self): + q = Q.from_("abc").select(Case().when(F("foo") == 1, "a")) + + self.assertEqual('SELECT CASE WHEN "foo"=1 THEN \'a\' END FROM "abc"', str(q)) + + def test__case__else(self): + q = Q.from_("abc").select(Case().when(F("foo") == 1, "a").else_("b")) + + self.assertEqual("SELECT CASE WHEN \"foo\"=1 THEN 'a' ELSE 'b' END FROM \"abc\"", str(q)) + + def test__case__field(self): + q = Q.from_("abc").select(Case().when(F("foo") == 1, F("bar")).else_(F("buz"))) + + self.assertEqual('SELECT CASE WHEN "foo"=1 THEN "bar" ELSE "buz" END FROM "abc"', str(q)) + + def test__case__multi(self): + q = Q.from_("abc").select(Case().when(F("foo") > 0, F("fiz")).when(F("bar") <= 0, F("buz")).else_(1)) + + self.assertEqual( + 'SELECT CASE WHEN "foo">0 THEN "fiz" WHEN "bar"<=0 THEN "buz" ELSE 1 END FROM "abc"', + str(q), + ) + + def test__case__no_cases(self): + with self.assertRaises(CaseException): + q = Q.from_("abc").select(Case()) + + str(q) + + +class StringTests(unittest.TestCase): + t = T("abc") + + def test__ascii__str(self): + q = Q.select(fn.Ascii("2")) + + self.assertEqual("SELECT ASCII('2')", str(q)) + + def test__ascii__int(self): + q = Q.select(fn.Ascii(2)) + + self.assertEqual("SELECT ASCII(2)", str(q)) + + def test__ascii__field(self): + q = Q.from_(self.t).select(fn.Ascii(self.t.foo)) + + self.assertEqual('SELECT ASCII("foo") FROM "abc"', str(q)) + + def test__bin__str(self): + q = Q.select(fn.Bin("2")) + + self.assertEqual("SELECT BIN('2')", str(q)) + + def test__bin__int(self): + q = Q.select(fn.Bin(2)) + + self.assertEqual("SELECT BIN(2)", str(q)) + + def test__bin__field(self): + q = Q.from_(self.t).select(fn.Bin(self.t.foo)) + + self.assertEqual('SELECT BIN("foo") FROM "abc"', str(q)) + + def test__concat__str(self): + q = Q.select(fn.Concat("p", "y", "q", "b")) + + self.assertEqual("SELECT CONCAT('p','y','q','b')", str(q)) + + def test__concat__field(self): + q = Q.from_(self.t).select(fn.Concat(self.t.foo, self.t.bar)) + + self.assertEqual('SELECT CONCAT("foo","bar") FROM "abc"', str(q)) + + def test__insert__str(self): + q = Q.select(fn.Insert("Quadratic", 3, 4, "What")) + + self.assertEqual("SELECT INSERT('Quadratic',3,4,'What')", str(q)) + + def test__insert__field(self): + q = Q.from_(self.t).select(fn.Insert(self.t.foo, 3, 4, self.t.bar)) + + self.assertEqual('SELECT INSERT("foo",3,4,"bar") FROM "abc"', str(q)) + + def test__lower__str(self): + q = Q.select(fn.Lower("ABC")) + + self.assertEqual("SELECT LOWER('ABC')", str(q)) + + def test__lower__field(self): + q = Q.from_(self.t).select(fn.Lower(self.t.foo)) + + self.assertEqual('SELECT LOWER("foo") FROM "abc"', str(q)) + + def test__length__str(self): + q = Q.select(fn.Length("ABC")) + + self.assertEqual("SELECT LENGTH('ABC')", str(q)) + + def test__length__field(self): + q = Q.from_(self.t).select(fn.Length(self.t.foo)) + + self.assertEqual('SELECT LENGTH("foo") FROM "abc"', str(q)) + + def test__substring(self): + q = Q.from_(self.t).select(fn.Substring(self.t.foo, 2, 6)) + + self.assertEqual('SELECT SUBSTRING("foo",2,6) FROM "abc"', str(q)) + + def test__replace__str(self): + q = Q.select(fn.Replace("ABC_DEF", "_", " ")) + self.assertEqual("SELECT REPLACE('ABC_DEF','_',' ')", str(q)) + + def test__replace__field(self): + q = Q.from_(self.t).select(fn.Replace(self.t.foobar, self.t.foo, self.t.bar)) + self.assertEqual('SELECT REPLACE("foobar","foo","bar") FROM "abc"', str(q)) + + +class SplitPartFunctionTests(unittest.TestCase): + t = T("abc") + + def test__split_part(self): + q = VerticaQuery.from_(self.t).select(fn.SplitPart(self.t.foo, "|", 3)) + + self.assertEqual('SELECT SPLIT_PART("foo",\'|\',3) FROM "abc"', str(q)) + + +class RegexpLikeFunctionTests(unittest.TestCase): + t = T("abc") + + def test__regexp_like(self): + q = VerticaQuery.from_(self.t).select(fn.RegexpLike(self.t.foo, "^a", "x")) + + self.assertEqual("SELECT REGEXP_LIKE(\"foo\",'^a','x') FROM \"abc\"", str(q)) + + +class CastTests(unittest.TestCase): + t = T("abc") + + def test__cast__as(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.UNSIGNED)) + + self.assertEqual('SELECT CAST("foo" AS UNSIGNED) FROM "abc"', str(q)) + + def test__cast__signed(self): + q1 = Q.from_(self.t).select(fn.Signed(self.t.foo)) + q2 = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.SIGNED)) + + self.assertEqual('SELECT CAST("foo" AS SIGNED) FROM "abc"', str(q1)) + self.assertEqual('SELECT CAST("foo" AS SIGNED) FROM "abc"', str(q2)) + + def test__cast__unsigned(self): + q1 = Q.from_(self.t).select(fn.Unsigned(self.t.foo)) + q2 = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.UNSIGNED)) + + self.assertEqual('SELECT CAST("foo" AS UNSIGNED) FROM "abc"', str(q1)) + self.assertEqual('SELECT CAST("foo" AS UNSIGNED) FROM "abc"', str(q2)) + + def test__cast__date(self): + q1 = Q.from_(self.t).select(fn.Date(self.t.foo)) + q2 = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.DATE)) + + self.assertEqual('SELECT DATE("foo") FROM "abc"', str(q1)) + self.assertEqual('SELECT CAST("foo" AS DATE) FROM "abc"', str(q2)) + + def test__cast__timestamp(self): + q1 = Q.from_(self.t).select(fn.Timestamp(self.t.foo)) + q2 = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.TIMESTAMP)) + + self.assertEqual('SELECT TIMESTAMP("foo") FROM "abc"', str(q1)) + self.assertEqual('SELECT CAST("foo" AS TIMESTAMP) FROM "abc"', str(q2)) + + def test__cast__char(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.CHAR)) + + self.assertEqual('SELECT CAST("foo" AS CHAR) FROM "abc"', str(q)) + + def test__cast__char_with_arg(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.VARCHAR(24))) + + self.assertEqual('SELECT CAST("foo" AS VARCHAR(24)) FROM "abc"', str(q)) + + def test__cast__varchar(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.VARCHAR)) + + self.assertEqual('SELECT CAST("foo" AS VARCHAR) FROM "abc"', str(q)) + + def test__cast__varchar_with_arg(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.VARCHAR(24))) + + self.assertEqual('SELECT CAST("foo" AS VARCHAR(24)) FROM "abc"', str(q)) + + def test__cast__long_varchar(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.LONG_VARCHAR)) + + self.assertEqual('SELECT CAST("foo" AS LONG VARCHAR) FROM "abc"', str(q)) + + def test__cast__long_varchar_with_arg(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.LONG_VARCHAR(24))) + + self.assertEqual('SELECT CAST("foo" AS LONG VARCHAR(24)) FROM "abc"', str(q)) + + def test__cast__binary(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.BINARY)) + + self.assertEqual('SELECT CAST("foo" AS BINARY) FROM "abc"', str(q)) + + def test__cast__binary_with_arg(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.BINARY(24))) + + self.assertEqual('SELECT CAST("foo" AS BINARY(24)) FROM "abc"', str(q)) + + def test__cast__varbinary(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.VARBINARY)) + + self.assertEqual('SELECT CAST("foo" AS VARBINARY) FROM "abc"', str(q)) + + def test__cast__varbinary_with_arg(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.VARBINARY(24))) + + self.assertEqual('SELECT CAST("foo" AS VARBINARY(24)) FROM "abc"', str(q)) + + def test__cast__long_varbinary(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.LONG_VARBINARY)) + + self.assertEqual('SELECT CAST("foo" AS LONG VARBINARY) FROM "abc"', str(q)) + + def test__cast__long_varbinary_with_arg(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.LONG_VARBINARY(24))) + + self.assertEqual('SELECT CAST("foo" AS LONG VARBINARY(24)) FROM "abc"', str(q)) + + def test__cast__boolean(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.BOOLEAN)) + + self.assertEqual('SELECT CAST("foo" AS BOOLEAN) FROM "abc"', str(q)) + + def test__cast__integer(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.INTEGER)) + + self.assertEqual('SELECT CAST("foo" AS INTEGER) FROM "abc"', str(q)) + + def test__cast__float(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.FLOAT)) + + self.assertEqual('SELECT CAST("foo" AS FLOAT) FROM "abc"', str(q)) + + def test__cast__numeric(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.NUMERIC)) + + self.assertEqual('SELECT CAST("foo" AS NUMERIC) FROM "abc"', str(q)) + + def test__tochar__(self): + q = Q.from_(self.t).select(fn.ToChar(self.t.foo, "SomeFormat")) + + self.assertEqual('SELECT TO_CHAR("foo",\'SomeFormat\') FROM "abc"', str(q)) + + +class DateFunctionsTests(unittest.TestCase): + dt = F("dt") + t = T("abc") + t2 = T("efg") + + def _test_extract_datepart(self, date_part): + q = Q.from_(self.t).select(fn.Extract(date_part, self.t.foo)) + + value = getattr(date_part, 'value', date_part) + self.assertEqual('SELECT EXTRACT(%s FROM "foo") FROM "abc"' % value, str(q)) + + def test_extract_microsecond(self): + self._test_extract_datepart(DatePart.microsecond) + self._test_extract_datepart(DatePart.microsecond.value) + + def test_extract_second(self): + self._test_extract_datepart(DatePart.second) + self._test_extract_datepart(DatePart.second.value) + + def test_extract_minute(self): + self._test_extract_datepart(DatePart.minute) + self._test_extract_datepart(DatePart.minute.value) + + def test_extract_hour(self): + self._test_extract_datepart(DatePart.hour) + self._test_extract_datepart(DatePart.hour.value) + + def test_extract_day(self): + self._test_extract_datepart(DatePart.day) + self._test_extract_datepart(DatePart.day.value) + + def test_extract_week(self): + self._test_extract_datepart(DatePart.week) + self._test_extract_datepart(DatePart.week.value) + + def test_extract_month(self): + self._test_extract_datepart(DatePart.month) + self._test_extract_datepart(DatePart.month.value) + + def test_extract_quarter(self): + self._test_extract_datepart(DatePart.quarter) + self._test_extract_datepart(DatePart.quarter.value) + + def test_extract_year(self): + self._test_extract_datepart(DatePart.year) + self._test_extract_datepart(DatePart.year.value) + + def test_extract_join(self): + q = Q.from_(self.t).join(self.t2).on(self.t.id == self.t2.t_id).select(fn.Extract(DatePart.year, self.t.foo)) + + self.assertEqual( + 'SELECT EXTRACT(YEAR FROM "abc"."foo") FROM "abc" ' 'JOIN "efg" ON "abc"."id"="efg"."t_id"', str(q) + ) + + def test_timestampadd(self): + a = fn.TimestampAdd("year", 1, "2017-10-01") + self.assertEqual(str(a), "TIMESTAMPADD(year,1,'2017-10-01')") + + def test_time_diff(self): + a = fn.TimeDiff("18:00:00", "10:00:00") + self.assertEqual(str(a), "TIMEDIFF('18:00:00','10:00:00')") + + def test_date_add(self): + a = fn.DateAdd("year", 1, "2017-10-01") + self.assertEqual(str(a), "DATE_ADD(year,1,'2017-10-01')") + + def test_now(self): + query = Query.select(fn.Now()) + + self.assertEqual("SELECT NOW()", str(query)) + + def test_utc_timestamp(self): + query = Query.select(fn.UtcTimestamp()) + + self.assertEqual("SELECT UTC_TIMESTAMP()", str(query)) + + def test_current_date(self): + query = Query.select(fn.CurDate()) + + self.assertEqual("SELECT CURRENT_DATE()", str(query)) + + def test_current_time(self): + query = Query.select(fn.CurTime()) + + self.assertEqual("SELECT CURRENT_TIME()", str(query)) + + def test_current_timestamp(self): + query = Query.select(fn.CurTimestamp()) + + self.assertEqual("SELECT CURRENT_TIMESTAMP", str(query)) + + def test_current_timestamp_with_alias(self): + query = Query.select(fn.CurTimestamp("ts")) + + self.assertEqual('SELECT CURRENT_TIMESTAMP "ts"', str(query)) + + def test_to_date(self): + q1 = fn.ToDate("2019-06-21", "yyyy-mm-dd") + q2 = Query.from_(self.t).select(fn.ToDate("2019-06-21", "yyyy-mm-dd")) + q3 = Query.from_(self.t).select(fn.ToDate(F("foo"), "yyyy-mm-dd")) + + self.assertEqual(str(q1), "TO_DATE('2019-06-21','yyyy-mm-dd')") + self.assertEqual(str(q2), "SELECT TO_DATE('2019-06-21','yyyy-mm-dd') FROM \"abc\"") + self.assertEqual(str(q3), 'SELECT TO_DATE("foo",\'yyyy-mm-dd\') FROM "abc"') + + +class NullFunctionsTests(unittest.TestCase): + def test_isnull(self): + q = Q.from_("abc").select(fn.IsNull(F("foo"))) + + self.assertEqual('SELECT ISNULL("foo") FROM "abc"', str(q)) + + def test_coalesce(self): + q = Q.from_("abc").select(fn.Coalesce(F("foo"), 0)) + + self.assertEqual('SELECT COALESCE("foo",0) FROM "abc"', str(q)) + + def test_nullif(self): + q = Q.from_("abc").select(fn.NullIf(F("foo"), 0)) + + self.assertEqual('SELECT NULLIF("foo",0) FROM "abc"', str(q)) + + def test_nvl(self): + q = Q.from_("abc").select(fn.NVL(F("foo"), 0)) + + self.assertEqual('SELECT NVL("foo",0) FROM "abc"', str(q)) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/test_groupby_modifiers.py b/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/test_groupby_modifiers.py new file mode 100644 index 0000000000000000000000000000000000000000..978834c2409f4b4800fedb9b1bb2538a31d0f31c --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/test_groupby_modifiers.py @@ -0,0 +1,168 @@ +import unittest + +from pypika import Query, Rollup, RollupException, Table, functions as fn + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + + +class RollupTests(unittest.TestCase): + table = Table("abc") + + def test_mysql_one_groupby(self): + q = ( + Query.from_(self.table) + .select(self.table.foo, fn.Sum(self.table.bar)) + .rollup(self.table.foo, vendor="mysql") + ) + + self.assertEqual('SELECT "foo",SUM("bar") FROM "abc" GROUP BY "foo" WITH ROLLUP', str(q)) + + def test_mysql_rollup_two_groupbys(self): + q = ( + Query.from_(self.table) + .select(self.table.foo, self.table.fiz, fn.Sum(self.table.bar)) + .rollup(self.table.foo, self.table.fiz, vendor="mysql") + ) + + self.assertEqual( + 'SELECT "foo","fiz",SUM("bar") FROM "abc" GROUP BY "foo","fiz" WITH ROLLUP', + str(q), + ) + + def test_no_rollup_before_groupby(self): + with self.assertRaises(RollupException): + Query.from_(self.table).select(self.table.foo, fn.Sum(self.table.bar)).rollup(vendor="mysql") + + def test_no_rollup_after_rollup_mysql(self): + with self.assertRaises(AttributeError): + Query.from_(self.table).select(self.table.foo, self.table.fiz, fn.Sum(self.table.bar)).rollup( + self.table.foo, vendor="mysql" + ).rollup(self.table.fiz, vendor="mysql") + + def test_verticaoracle_func_one_groupby(self): + q = Query.from_(self.table).select(self.table.foo, fn.Sum(self.table.bar)).groupby(Rollup(self.table.foo)) + + self.assertEqual('SELECT "foo",SUM("bar") FROM "abc" GROUP BY ROLLUP("foo")', str(q)) + + def test_verticaoracle_func_two_groupbys(self): + q = ( + Query.from_(self.table) + .select(self.table.foo, self.table.fiz, fn.Sum(self.table.bar)) + .groupby( + Rollup( + self.table.foo, + self.table.fiz, + ) + ) + ) + + self.assertEqual( + 'SELECT "foo","fiz",SUM("bar") FROM "abc" GROUP BY ROLLUP("foo","fiz")', + str(q), + ) + + def test_verticaoracle_func_partial(self): + q = ( + Query.from_(self.table) + .select(self.table.foo, self.table.fiz, self.table.buz, fn.Sum(self.table.bar)) + .groupby( + Rollup( + self.table.foo, + self.table.fiz, + ), + self.table.buz, + ) + ) + + self.assertEqual( + 'SELECT "foo","fiz","buz",SUM("bar") FROM "abc" GROUP BY ROLLUP("foo","fiz"),"buz"', + str(q), + ) + + def test_verticaoracle_from_groupbys(self): + q = Query.from_(self.table).select(self.table.foo, fn.Sum(self.table.bar)).rollup(self.table.foo) + + self.assertEqual('SELECT "foo",SUM("bar") FROM "abc" GROUP BY ROLLUP("foo")', str(q)) + + def test_verticaoracle_from_two_groupbys(self): + q = ( + Query.from_(self.table) + .select(self.table.foo, self.table.fiz, fn.Sum(self.table.bar)) + .rollup( + self.table.foo, + self.table.fiz, + ) + ) + + self.assertEqual( + 'SELECT "foo","fiz",SUM("bar") FROM "abc" GROUP BY ROLLUP("foo","fiz")', + str(q), + ) + + def test_verticaoracle_from_parameters(self): + q = ( + Query.from_(self.table) + .select(self.table.foo, self.table.fiz, fn.Sum(self.table.bar)) + .groupby( + self.table.foo, + ) + .rollup( + self.table.fiz, + ) + ) + + self.assertEqual( + 'SELECT "foo","fiz",SUM("bar") FROM "abc" GROUP BY "foo",ROLLUP("fiz")', + str(q), + ) + + def test_verticaoracle_multiple_rollups(self): + q = ( + Query.from_(self.table) + .select(self.table.foo, self.table.fiz, fn.Sum(self.table.bar)) + .rollup( + self.table.foo, + ) + .rollup( + self.table.fiz, + ) + ) + + self.assertEqual( + 'SELECT "foo","fiz",SUM("bar") FROM "abc" GROUP BY ROLLUP("foo","fiz")', + str(q), + ) + + def test_verticaoracle_rollups_with_parity(self): + q = ( + Query.from_(self.table) + .select( + self.table.buz, + ) + .rollup( + [self.table.foo, self.table.bar], + self.table.fiz, + ) + ) + + self.assertEqual('SELECT "buz" FROM "abc" GROUP BY ROLLUP(("foo","bar"),"fiz")', str(q)) + + def test_verticaoracle_rollups_with_multiple_rollups_and_parity(self): + q = ( + Query.from_(self.table) + .select( + self.table.buz, + ) + .rollup( + [self.table.foo, self.table.bar], + ) + .rollup( + [self.table.fiz, self.table.buz], + ) + ) + + self.assertEqual( + 'SELECT "buz" FROM "abc" GROUP BY ROLLUP(("foo","bar"),("fiz","buz"))', + str(q), + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/test_immutability.py b/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/test_immutability.py new file mode 100644 index 0000000000000000000000000000000000000000..ee539bfa1e9c4509b929e7a86a03f098dd923515 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/test_immutability.py @@ -0,0 +1,99 @@ +import unittest + +from pypika import ( + AliasedQuery, + Query, + Tables, +) + + +class ImmutabilityTests(unittest.TestCase): + table_a, table_b, table_c = Tables("a", "b", "c") + + def test_select_returns_new_query_instance(self): + query_a = Query.from_(self.table_a).select(self.table_a.foo) + query_b = query_a.select(self.table_a.bar) + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_groupby_returns_new_query_instance(self): + query_a = Query.from_(self.table_a).select(self.table_a.foo).groupby(self.table_a.foo) + query_b = query_a.groupby(self.table_a.bar) + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_orderby_return_new_query_instance(self): + query_a = Query.from_(self.table_a).select(self.table_a.foo).orderby(self.table_a.foo) + query_b = query_a.orderby(self.table_a.bar) + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_join_return_new_query_instance(self): + base = Query.from_(self.table_a).select(self.table_a.foo) + query_a = base.join(self.table_b).on(self.table_a.foo == self.table_b.bar).select(self.table_b.bar) + query_b = query_a.join(self.table_c).on(self.table_a.foo == self.table_c.baz).select(self.table_c.baz) + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_use_index_return_new_query_instance(self): + query_a = Query.from_(self.table_a).select(self.table_a.foo).use_index('idx1') + query_b = query_a.use_index('idx2') + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_force_index_return_new_query_instance(self): + query_a = Query.from_(self.table_a).select(self.table_a.foo).force_index('idx1') + query_b = query_a.force_index('idx2') + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_with_return_new_query_instance(self): + alias_1 = Query.from_(self.table_a).select(self.table_a.foo) + alias_2 = Query.from_(self.table_b).select(self.table_b.bar) + query_a = Query.from_(AliasedQuery('a1')).select('foo').with_(alias_1, 'a1') + query_b = query_a.with_(alias_2, 'a2') + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_insert_into_return_new_query_instance(self): + query_a = Query.into(self.table_a).insert('foo1') + query_b = query_a.insert('foo2') + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_replace_into_return_new_query_instance(self): + query_a = Query.into(self.table_a).replace('foo') + query_b = query_a.replace('bar') + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_update_set_return_new_query_instance(self): + query_a = Query.update(self.table_a).set(self.table_a.foo, 'foo') + query_b = query_a.set(self.table_a.bar, 'bar') + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_queries_after_join(self): + query1 = Query.from_(self.table_a).select(self.table_a.foo) + query2 = query1.join(self.table_b).on(self.table_a.foo == self.table_b.bar).select(self.table_b.buz) + + self.assertEqual('SELECT "foo" FROM "a"', str(query1)) + self.assertEqual( + 'SELECT "a"."foo","b"."buz" FROM "a" JOIN "b" ON "a"."foo"="b"."bar"', + str(query2), + ) + + def test_immutable_kwarg_on_query_builder_disables_immutability(self): + query0 = Query.from_(self.table_a, immutable=False) + query1 = query0.select(self.table_a.foo) + self.assertIs(query0, query1) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/test_inserts.py b/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/test_inserts.py new file mode 100644 index 0000000000000000000000000000000000000000..f86efd7a76dc498a69b61c6353951695f1933a61 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/test_inserts.py @@ -0,0 +1,885 @@ +import unittest + +from pypika import ( + AliasedQuery, + Case, + Field as F, + MySQLQuery, + PostgreSQLQuery, + Query, + Table, + Tables, + functions as fn, +) +from pypika.functions import ( + Avg, + Cast, +) +from pypika.terms import Values +from pypika.utils import QueryException + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + + +class InsertIntoTests(unittest.TestCase): + table_abc = Table("abc") + + def test_insert_one_column(self): + query = Query.into(self.table_abc).insert(1) + + self.assertEqual('INSERT INTO "abc" VALUES (1)', str(query)) + + def test_insert_one_column_single_element_array(self): + query = Query.into(self.table_abc).insert((1,)) + + self.assertEqual('INSERT INTO "abc" VALUES (1)', str(query)) + + def test_insert_one_column_multi_element_array(self): + query = Query.into(self.table_abc).insert((1,), (2,)) + + self.assertEqual('INSERT INTO "abc" VALUES (1),(2)', str(query)) + + def test_insert_single_row_with_array_value(self): + query = Query.into(self.table_abc).insert(1, ["a", "b", "c"]) + + self.assertEqual("INSERT INTO \"abc\" VALUES (1,['a','b','c'])", str(query)) + + def test_insert_multiple_rows_with_array_value(self): + query = Query.into(self.table_abc).insert( + (1, ["a", "b", "c"]), + (2, ["c", "d", "e"]), + ) + + self.assertEqual( + 'INSERT INTO "abc" ' "VALUES (1,['a','b','c']),(2,['c','d','e'])", + str(query), + ) + + def test_insert_all_columns(self): + query = Query.into(self.table_abc).insert(1, "a", True) + + self.assertEqual("INSERT INTO \"abc\" VALUES (1,'a',true)", str(query)) + + def test_insert_all_columns_single_element(self): + query = Query.into(self.table_abc).insert((1, "a", True)) + + self.assertEqual("INSERT INTO \"abc\" VALUES (1,'a',true)", str(query)) + + def test_insert_all_columns_multi_rows(self): + query = Query.into(self.table_abc).insert((1, "a", True), (2, "b", False)) + + self.assertEqual("INSERT INTO \"abc\" VALUES (1,'a',true),(2,'b',false)", str(query)) + + def test_insert_all_columns_multi_rows_chained(self): + query = Query.into(self.table_abc).insert(1, "a", True).insert(2, "b", False) + + self.assertEqual("INSERT INTO \"abc\" VALUES (1,'a',true),(2,'b',false)", str(query)) + + def test_insert_all_columns_multi_rows_chained_mixed(self): + query = Query.into(self.table_abc).insert((1, "a", True), (2, "b", False)).insert(3, "c", True) + + self.assertEqual( + 'INSERT INTO "abc" VALUES ' "(1,'a',true),(2,'b',false)," "(3,'c',true)", + str(query), + ) + + def test_insert_all_columns_multi_rows_chained_multiple_rows(self): + query = ( + Query.into(self.table_abc).insert((1, "a", True), (2, "b", False)).insert((3, "c", True), (4, "d", False)) + ) + + self.assertEqual( + 'INSERT INTO "abc" VALUES ' "(1,'a',true),(2,'b',false)," "(3,'c',true),(4,'d',false)", + str(query), + ) + + def test_insert_selected_columns(self): + query = ( + Query.into(self.table_abc) + .columns(self.table_abc.foo, self.table_abc.bar, self.table_abc.buz) + .insert(1, "a", True) + ) + + self.assertEqual('INSERT INTO "abc" ("foo","bar","buz") VALUES (1,\'a\',true)', str(query)) + + def test_insert_empty_columns(self): + query = Query.into(self.table_abc).columns().insert(1, "a", True) + + self.assertEqual('INSERT INTO "abc" VALUES (1,\'a\',true)', str(query)) + + def test_insert_selected_columns_type_list(self): + query = ( + Query.into(self.table_abc) + .columns([self.table_abc.foo, self.table_abc.bar, self.table_abc.buz]) + .insert(1, "a", True) + ) + + self.assertEqual('INSERT INTO "abc" ("foo","bar","buz") VALUES (1,\'a\',true)', str(query)) + + def test_insert_empty_columns_type_list(self): + query = Query.into(self.table_abc).columns([]).insert(1, "a", True) + + self.assertEqual('INSERT INTO "abc" VALUES (1,\'a\',true)', str(query)) + + def test_insert_selected_columns_type_tuple(self): + query = ( + Query.into(self.table_abc) + .columns((self.table_abc.foo, self.table_abc.bar, self.table_abc.buz)) + .insert(1, "a", True) + ) + + self.assertEqual('INSERT INTO "abc" ("foo","bar","buz") VALUES (1,\'a\',true)', str(query)) + + def test_insert_empty_columns_type_tuple(self): + query = Query.into(self.table_abc).columns(()).insert(1, "a", True) + + self.assertEqual('INSERT INTO "abc" VALUES (1,\'a\',true)', str(query)) + + def test_insert_none_skipped(self): + query = Query.into(self.table_abc).insert() + + self.assertEqual("", str(query)) + + def test_insert_ignore(self): + query = Query.into(self.table_abc).insert(1).ignore() + + self.assertEqual('INSERT IGNORE INTO "abc" VALUES (1)', str(query)) + + def test_insert_null(self): + query = Query.into(self.table_abc).insert(None) + + self.assertEqual('INSERT INTO "abc" VALUES (NULL)', str(query)) + + def test_insert_column_using_table_alias(self): + q = self.table_abc.insert(1) + self.assertEqual('INSERT INTO "abc" VALUES (1)', str(q)) + + def test_insert_column_using_alias_with_chain(self): + q = self.table_abc.insert(1, "a", True).insert(2, "b", False) + self.assertEqual("INSERT INTO \"abc\" VALUES (1,'a',true),(2,'b',false)", str(q)) + + def test_insert_with_statement(self): + sub_query = Query().select(self.table_abc.id).from_(self.table_abc) + aliased = AliasedQuery('sub_qs') + + q = Query().with_(sub_query, 'sub_qs').into(self.table_abc).select(aliased.id).from_(aliased) + self.assertEqual( + 'WITH sub_qs AS (SELECT "id" FROM "abc") INSERT INTO "abc" SELECT "sub_qs"."id" FROM sub_qs', str(q) + ) + + +class PostgresInsertIntoOnConflictTests(unittest.TestCase): + table_abc = Table("abc") + + def test_insert_on_conflict_do_nothing_field(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).on_conflict(self.table_abc.id).do_nothing() + + self.assertEqual('INSERT INTO "abc" VALUES (1) ON CONFLICT ("id") DO NOTHING', str(query)) + + def test_insert_on_conflict_do_nothing_multiple_fields(self): + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1) + .on_conflict(self.table_abc.id, self.table_abc.sub_id) + .do_nothing() + ) + + self.assertEqual('INSERT INTO "abc" VALUES (1) ON CONFLICT ("id", "sub_id") DO NOTHING', str(query)) + + def test_insert_on_conflict_do_nothing_field_str(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).on_conflict("id").do_nothing() + + self.assertEqual('INSERT INTO "abc" VALUES (1) ON CONFLICT ("id") DO NOTHING', str(query)) + + def test_insert_on_conflict_do_nothing_multiple_fields_str(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).on_conflict("id", "sub_id").do_nothing() + + self.assertEqual('INSERT INTO "abc" VALUES (1) ON CONFLICT ("id", "sub_id") DO NOTHING', str(query)) + + def test_insert_on_conflict_do_nothing_mixed_fields(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).on_conflict("id", self.table_abc.sub_id).do_nothing() + + self.assertEqual('INSERT INTO "abc" VALUES (1) ON CONFLICT ("id", "sub_id") DO NOTHING', str(query)) + + def test_insert_on_conflict_do_update_field(self): + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict(self.table_abc.id) + .do_update(self.table_abc.name, "m") + ) + + self.assertEqual( + "INSERT INTO \"abc\" VALUES (1,'m') ON CONFLICT (\"id\") DO UPDATE SET \"name\"='m'", + str(query), + ) + + def test_insert_on_conflict_do_update_multiple_fields(self): + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict(self.table_abc.id, self.table_abc.sub_id) + .do_update(self.table_abc.name, "m") + ) + + self.assertEqual( + "INSERT INTO \"abc\" VALUES (1,'m') ON CONFLICT (\"id\", \"sub_id\") DO UPDATE SET \"name\"='m'", + str(query), + ) + + def test_insert_on_conflict_do_update_field_str(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1, "m").on_conflict("id").do_update("name", "m") + + self.assertEqual( + "INSERT INTO \"abc\" VALUES (1,'m') ON CONFLICT (\"id\") DO UPDATE SET \"name\"='m'", + str(query), + ) + + def test_insert_on_conflict_do_update_multiple_fields_str(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1, "m").on_conflict("id", "sub_id").do_update("name", "m") + + self.assertEqual( + "INSERT INTO \"abc\" VALUES (1,'m') ON CONFLICT (\"id\", \"sub_id\") DO UPDATE SET \"name\"='m'", + str(query), + ) + + def test_insert_on_conflict_do_update_multiple_mixed_fields(self): + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict("id", self.table_abc.sub_id) + .do_update("name", "m") + ) + + self.assertEqual( + "INSERT INTO \"abc\" VALUES (1,'m') ON CONFLICT (\"id\", \"sub_id\") DO UPDATE SET \"name\"='m'", + str(query), + ) + + def test_insert_on_conflict_no_handler(self): + with self.assertRaises(QueryException): + query = str(PostgreSQLQuery.into(self.table_abc).insert(1).on_conflict(self.table_abc.id)) + + def test_insert_on_conflict_two_handlers_do_nothing(self): + with self.assertRaises(QueryException): + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1) + .on_conflict("id") + .do_nothing() + .do_update(self.table_abc.name, "m") + ) + + def test_insert_on_conflict_two_handlers_do_update(self): + with self.assertRaises(QueryException): + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1) + .on_conflict(self.table_abc.id) + .do_update(self.table_abc.name, "m") + .do_nothing() + ) + + def test_non_insert_on_conflict_do_nothing(self): + with self.assertRaises(QueryException): + query = PostgreSQLQuery.update(self.table_abc).set("foo", "bar").on_conflict("id").do_nothing() + + def test_non_insert_on_conflict_do_update(self): + with self.assertRaises(QueryException): + query = ( + PostgreSQLQuery.update(self.table_abc).set("foo", "bar").on_conflict("id").do_update(["name"], ["m"]) + ) + + def test_insert_on_fieldless_conflict_do_nothing(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).on_conflict(None).do_nothing() + + self.assertEqual('INSERT INTO "abc" VALUES (1) ON CONFLICT DO NOTHING', str(query)) + + def test_insert_on_fieldless_conflict_do_update_field(self): + with self.assertRaises(QueryException): + query = str( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict(None) + .do_update(self.table_abc.name, "m") + ) + + def test_on_conflict_from_subquery(self): + table_bcd = Table('bcd') + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(self.table_abc.fname, self.table_abc.lname) + .select(table_bcd.fname, table_bcd.lname) + .from_(table_bcd) + .on_conflict(self.table_abc.id, self.table_abc.sub_id) + .do_update(self.table_abc.fname, 1) + .do_update(self.table_abc.lname, table_bcd.lname) + .do_update( + self.table_abc.cname, + Case().when(self.table_abc.cname.eq('cname'), 'new_name').else_(self.table_abc.cname), + ) + ) + + self.assertEqual( + 'INSERT INTO "abc" VALUES ("fname","lname") ' + 'ON CONFLICT ("id", "sub_id") ' + 'DO UPDATE SET "fname"=1,"lname"="bcd"."lname",' + '"cname"=CASE WHEN "abc"."cname"=\'cname\' THEN \'new_name\' ELSE "abc"."cname" END', + str(query), + ) + + def test_on_conflict_where_empty_conflict_fields_do_nothing(self): + with self.assertRaises(QueryException): + ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict() + .where(self.table_abc.abc.eq(0)) + .where(self.table_abc.cde.eq(0)) + .do_nothing() + ) + + def test_on_conflict_where_conflict_fields_do_nothing(self): + qs = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict('id') + .where(self.table_abc.abc.eq(0)) + .where(self.table_abc.cde.eq(0)) + .do_nothing() + ) + self.assertEqual( + '''INSERT INTO "abc" VALUES (1,'m') ON CONFLICT ("id") WHERE "abc"=0 AND "cde"=0 DO NOTHING''', str(qs) + ) + + def test_on_conflict_where_empty_conflict_fields_do_update(self): + with self.assertRaises(QueryException): + ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict() + .where(self.table_abc.abc.eq(0)) + .where(self.table_abc.cde.eq(0)) + .do_update('field', 'val') + ) + + def test_on_conflict_where_conflict_fields_do_update(self): + qs = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict('id') + .where(self.table_abc.abc.eq(0)) + .where(self.table_abc.cde.eq(0)) + .do_update('field', 'val') + ) + self.assertEqual( + '''INSERT INTO "abc" VALUES (1,'m') ON CONFLICT ("id") WHERE "abc"=0 AND "cde"=0 ''' + '''DO UPDATE SET "field"='val\'''', + str(qs), + ) + + def test_where_and_on_conflict_where(self): + table_bcd = Table('bcd') + + qs = ( + PostgreSQLQuery.into(self.table_abc) + .select(table_bcd.abc) + .from_(table_bcd) + .where(table_bcd.abc.eq('1')) + .on_conflict('id') + .where(self.table_abc.abc.eq(0)) + .where(self.table_abc.cde.eq(0)) + .do_update('field', 'val') + ) + + self.assertEqual( + 'INSERT INTO "abc" SELECT "abc" FROM "bcd" WHERE "abc"=\'1\' ' + 'ON CONFLICT ("id") WHERE "abc"=0 AND "cde"=0 DO UPDATE SET "field"=\'val\'', + str(qs), + ) + + def test_on_conflict_do_nothing_where(self): + with self.assertRaises(QueryException): + ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict() + .do_nothing() + .where(self.table_abc.abc.eq(1)) + ) + + def test_empty_on_conflict_do_update_where(self): + with self.assertRaises(QueryException): + ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict() + .do_update('abc', 1) + .where(self.table_abc.abc.eq(1)) + ) + + def test_on_conflict_do_update_where(self): + qs = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict("id") + .do_update('abc', 1) + .where(self.table_abc.abc.eq(1)) + ) + self.assertEqual( + 'INSERT INTO "abc" VALUES (1,\'m\') ON CONFLICT ("id") DO UPDATE SET "abc"=1 WHERE "abc"."abc"=1', str(qs) + ) + + def test_on_conflict_do_update_with_excluded_where(self): + qs = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict("id") + .do_update('abc') + .where(self.table_abc.abc.eq(1)) + ) + self.assertEqual( + 'INSERT INTO "abc" VALUES (1,\'m\') ON CONFLICT ("id") DO UPDATE SET "abc"=EXCLUDED."abc" WHERE ' + '"abc"."abc"=1', + str(qs), + ) + + def test_on_conflict_where_complex(self): + table_bcd = Table('bcd') + + qs = ( + PostgreSQLQuery.into(self.table_abc) + .select(table_bcd.abc) + .from_(table_bcd) + .where(table_bcd.abc.eq('1')) + .on_conflict('id') + .where(self.table_abc.abc.eq(0)) + .where(self.table_abc.cde.eq(0)) + .do_update('field', 'val') + .where(self.table_abc.id.eq(2)) + .where(self.table_abc.sub_id.eq(3)) + ) + self.assertEqual( + 'INSERT INTO "abc" SELECT "abc" FROM "bcd" WHERE "abc"=\'1\' ' + 'ON CONFLICT ("id") WHERE "abc"=0 AND "cde"=0 ' + 'DO UPDATE SET "field"=\'val\' WHERE "abc"."id"=2 AND "abc"."sub_id"=3', + str(qs), + ) + + +class PostgresInsertIntoReturningTests(unittest.TestCase): + table_abc = Table("abc") + + def test_insert_returning_one_field(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).returning(self.table_abc.id) + + self.assertEqual('INSERT INTO "abc" VALUES (1) RETURNING "id"', str(query)) + + def test_insert_returning_one_field_str(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).returning("id") + + self.assertEqual('INSERT INTO "abc" VALUES (1) RETURNING "id"', str(query)) + + def test_insert_returning_all_fields(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).returning(self.table_abc.star) + + self.assertEqual('INSERT INTO "abc" VALUES (1) RETURNING *', str(query)) + + def test_insert_returning_all_fields_and_arithmetics(self): + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1) + .returning(self.table_abc.star, self.table_abc.f1 + self.table_abc.f2) + ) + + self.assertEqual('INSERT INTO "abc" VALUES (1) RETURNING *,"f1"+"f2"', str(query)) + + def test_insert_all_columns_multi_rows_chained_returning_star(self): + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "a", True) + .insert(2, "b", False) + .returning(self.table_abc.star) + ) + + self.assertEqual( + "INSERT INTO \"abc\" VALUES (1,'a',true),(2,'b',false) RETURNING *", + str(query), + ) + + def test_insert_all_columns_multi_rows_chained_returning_star_and_id(self): + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "a", True) + .insert(2, "b", False) + .returning( + self.table_abc.name, + self.table_abc.star, + self.table_abc.id, + ) + ) + + self.assertEqual( + "INSERT INTO \"abc\" VALUES (1,'a',true),(2,'b',false) RETURNING *", + str(query), + ) + + def test_insert_all_columns_multi_rows_chained_returning_star_str(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1, "a", True).insert(2, "b", False).returning("*") + + self.assertEqual( + "INSERT INTO \"abc\" VALUES (1,'a',true),(2,'b',false) RETURNING *", + str(query), + ) + + def test_insert_all_columns_single_element_arrays(self): + query = PostgreSQLQuery.into(self.table_abc).insert((1, "a", True)).returning(self.table_abc.star) + + self.assertEqual("INSERT INTO \"abc\" VALUES (1,'a',true) RETURNING *", str(query)) + + def test_insert_returning_null(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).returning(None) + + self.assertEqual('INSERT INTO "abc" VALUES (1) RETURNING NULL', str(query)) + + def test_insert_returning_tuple(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).returning((1, 2, 3)) + + self.assertEqual('INSERT INTO "abc" VALUES (1) RETURNING (1,2,3)', str(query)) + + def test_insert_returning_arithmetics(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).returning(self.table_abc.f1 + self.table_abc.f2) + + self.assertEqual('INSERT INTO "abc" VALUES (1) RETURNING "f1"+"f2"', str(query)) + + def test_insert_returning_functions(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).returning(Cast(self.table_abc.f1, "int")) + + self.assertEqual('INSERT INTO "abc" VALUES (1) RETURNING CAST("f1" AS INT)', str(query)) + + def test_insert_returning_aggregate(self): + with self.assertRaises(QueryException): + PostgreSQLQuery.into(self.table_abc).insert(1).returning(Avg(self.table_abc.views)) + + def test_insert_returning_from_other_table(self): + table_cba = Table("cba") + with self.assertRaises(QueryException): + PostgreSQLQuery.into(self.table_abc).insert(1).returning(table_cba.id) + + +class InsertIntoOnDuplicateTests(unittest.TestCase): + table_abc = Table("abc") + + def test_insert_one_column(self): + query = ( + MySQLQuery.into(self.table_abc).insert(1).on_duplicate_key_update(self.table_abc.foo, self.table_abc.foo) + ) + self.assertEqual( + "INSERT INTO `abc` VALUES (1) ON DUPLICATE KEY UPDATE `foo`=`foo`", + str(query), + ) + + def test_insert_one_column_using_values(self): + query = ( + MySQLQuery.into(self.table_abc) + .insert(1) + .on_duplicate_key_update(self.table_abc.foo, Values(self.table_abc.foo)) + ) + self.assertEqual( + "INSERT INTO `abc` VALUES (1) ON DUPLICATE KEY UPDATE `foo`=VALUES(`foo`)", + str(query), + ) + + def test_insert_one_column_single_element_array(self): + query = ( + MySQLQuery.into(self.table_abc).insert((1,)).on_duplicate_key_update(self.table_abc.foo, self.table_abc.foo) + ) + + self.assertEqual( + "INSERT INTO `abc` VALUES (1) ON DUPLICATE KEY UPDATE `foo`=`foo`", + str(query), + ) + + def test_insert_one_column_multi_element_array(self): + query = ( + MySQLQuery.into(self.table_abc) + .insert((1,), (2,)) + .on_duplicate_key_update(self.table_abc.foo, self.table_abc.foo) + ) + + self.assertEqual( + "INSERT INTO `abc` VALUES (1),(2) ON DUPLICATE KEY UPDATE `foo`=`foo`", + str(query), + ) + + def test_insert_multiple_columns_on_duplicate_update_one_with_same_value(self): + query = ( + MySQLQuery.into(self.table_abc) + .insert(1, "a") + .on_duplicate_key_update(self.table_abc.bar, Values(self.table_abc.bar)) + ) + + self.assertEqual( + "INSERT INTO `abc` VALUES (1,'a') ON DUPLICATE KEY UPDATE `bar`=VALUES(`bar`)", + str(query), + ) + + def test_insert_multiple_columns_on_duplicate_update_one_with_different_value(self): + query = MySQLQuery.into(self.table_abc).insert(1, "a").on_duplicate_key_update(self.table_abc.bar, "b") + + self.assertEqual( + "INSERT INTO `abc` VALUES (1,'a') ON DUPLICATE KEY UPDATE `bar`='b'", + str(query), + ) + + def test_insert_multiple_columns_on_duplicate_update_one_with_expression(self): + query = ( + MySQLQuery.into(self.table_abc).insert(1, 2).on_duplicate_key_update(self.table_abc.bar, 4 + F("bar")) + ) # todo sql expression? not python + + self.assertEqual( + "INSERT INTO `abc` VALUES (1,2) ON DUPLICATE KEY UPDATE `bar`=4+`bar`", + str(query), + ) + + def test_insert_multiple_columns_on_duplicate_update_one_with_expression_using_original_field_value( + self, + ): + query = ( + MySQLQuery.into(self.table_abc) + .insert(1, "a") + .on_duplicate_key_update(self.table_abc.bar, fn.Concat(self.table_abc.bar, "update")) + ) + + self.assertEqual( + "INSERT INTO `abc` VALUES (1,'a') ON DUPLICATE KEY UPDATE `bar`=CONCAT(`bar`,'update')", + str(query), + ) + + def test_insert_multiple_columns_on_duplicate_update_one_with_expression_using_values( + self, + ): + query = ( + MySQLQuery.into(self.table_abc) + .insert(1, "a") + .on_duplicate_key_update(self.table_abc.bar, fn.Concat(Values(self.table_abc.bar), "update")) + ) + + self.assertEqual( + "INSERT INTO `abc` VALUES (1,'a') ON DUPLICATE KEY UPDATE `bar`=CONCAT(VALUES(`bar`),'update')", + str(query), + ) + + def test_insert_multiple_columns_on_duplicate_update_multiple(self): + query = ( + MySQLQuery.into(self.table_abc) + .insert(1, "a", "b") + .on_duplicate_key_update(self.table_abc.bar, "b") + .on_duplicate_key_update(self.table_abc.baz, "c") + ) + + self.assertEqual( + "INSERT INTO `abc` VALUES (1,'a','b') ON DUPLICATE KEY UPDATE `bar`='b',`baz`='c'", + str(query), + ) + + def test_insert_multi_rows_chained_mixed_on_duplicate_update_multiple(self): + query = ( + MySQLQuery.into(self.table_abc) + .insert((1, "a", True), (2, "b", False)) + .insert(3, "c", True) + .on_duplicate_key_update(self.table_abc.foo, self.table_abc.foo) + .on_duplicate_key_update(self.table_abc.bar, Values(self.table_abc.bar)) + ) + + self.assertEqual( + "INSERT INTO `abc` VALUES (1,'a',true),(2,'b',false),(3,'c',true) " + "ON DUPLICATE KEY UPDATE `foo`=`foo`,`bar`=VALUES(`bar`)", + str(query), + ) + + def test_insert_selected_columns_on_duplicate_update_one(self): + query = ( + MySQLQuery.into(self.table_abc) + .columns(self.table_abc.foo, self.table_abc.bar, self.table_abc.baz) + .insert(1, "a", True) + .on_duplicate_key_update(self.table_abc.baz, False) + ) + + self.assertEqual( + "INSERT INTO `abc` (`foo`,`bar`,`baz`) VALUES (1,'a',true) ON DUPLICATE KEY UPDATE `baz`=false", + str(query), + ) + + def test_insert_selected_columns_on_duplicate_update_multiple(self): + query = ( + MySQLQuery.into(self.table_abc) + .columns(self.table_abc.foo, self.table_abc.bar, self.table_abc.baz) + .insert(1, "a", True) + .on_duplicate_key_update(self.table_abc.baz, False) + .on_duplicate_key_update(self.table_abc.bar, Values(self.table_abc.bar)) + ) + + self.assertEqual( + "INSERT INTO `abc` (`foo`,`bar`,`baz`) VALUES (1,'a',true) " + "ON DUPLICATE KEY UPDATE `baz`=false,`bar`=VALUES(`bar`)", + str(query), + ) + + def test_insert_none_skipped(self): + query = MySQLQuery.into(self.table_abc).insert().on_duplicate_key_update(self.table_abc.baz, False) + + self.assertEqual("", str(query)) + + def test_insert_ignore(self): + query = MySQLQuery.into(self.table_abc).insert(1).ignore().on_duplicate_key_update(self.table_abc.baz, False) + + self.assertEqual( + "INSERT IGNORE INTO `abc` VALUES (1) ON DUPLICATE KEY UPDATE `baz`=false", + str(query), + ) + + +class InsertSelectFromTests(unittest.TestCase): + table_abc, table_efg, table_hij = Tables("abc", "efg", "hij") + + def test_insert_star(self): + query = Query.into(self.table_abc).from_(self.table_efg).select("*") + + self.assertEqual('INSERT INTO "abc" SELECT * FROM "efg"', str(query)) + + def test_insert_ignore_star(self): + query = Query.into(self.table_abc).from_(self.table_efg).select("*").ignore() + + self.assertEqual('INSERT IGNORE INTO "abc" SELECT * FROM "efg"', str(query)) + + def test_insert_from_columns(self): + query = ( + Query.into(self.table_abc) + .from_(self.table_efg) + .select(self.table_efg.fiz, self.table_efg.buz, self.table_efg.baz) + ) + + self.assertEqual('INSERT INTO "abc" ' 'SELECT "fiz","buz","baz" FROM "efg"', str(query)) + + def test_insert_columns_from_star(self): + query = ( + Query.into(self.table_abc) + .columns( + self.table_abc.foo, + self.table_abc.bar, + self.table_abc.buz, + ) + .from_(self.table_efg) + .select("*") + ) + + self.assertEqual('INSERT INTO "abc" ("foo","bar","buz") ' 'SELECT * FROM "efg"', str(query)) + + def test_insert_columns_from_columns(self): + query = ( + Query.into(self.table_abc) + .columns(self.table_abc.foo, self.table_abc.bar, self.table_abc.buz) + .from_(self.table_efg) + .select(self.table_efg.fiz, self.table_efg.buz, self.table_efg.baz) + ) + + self.assertEqual( + 'INSERT INTO "abc" ("foo","bar","buz") ' 'SELECT "fiz","buz","baz" FROM "efg"', + str(query), + ) + + def test_insert_columns_from_columns_with_join(self): + query = ( + Query.into(self.table_abc) + .columns( + self.table_abc.c1, + self.table_abc.c2, + self.table_abc.c3, + self.table_abc.c4, + ) + .from_(self.table_efg) + .select(self.table_efg.foo, self.table_efg.bar) + .join(self.table_hij) + .on(self.table_efg.id == self.table_hij.abc_id) + .select(self.table_hij.fiz, self.table_hij.buz) + ) + + self.assertEqual( + 'INSERT INTO "abc" ("c1","c2","c3","c4") ' + 'SELECT "efg"."foo","efg"."bar","hij"."fiz","hij"."buz" FROM "efg" ' + 'JOIN "hij" ON "efg"."id"="hij"."abc_id"', + str(query), + ) + + +class InsertSubqueryTests(unittest.TestCase): + def test_insert_subquery_wrapped_in_brackets(self): + purchase_order_item, part = Tables("purchase_order_item", "part") + + q = ( + Query.into(purchase_order_item) + .columns(purchase_order_item.id_part, purchase_order_item.id_customer) + .insert( + Query.from_(part).select(part.part_id).where(part.part_number == "FOOBAR"), + 12345, + ) + ) + + self.assertEqual( + 'INSERT INTO "purchase_order_item" ' + '("id_part","id_customer") ' + "VALUES " + '((SELECT "part_id" FROM "part" WHERE "part_number"=\'FOOBAR\'),12345)', + str(q), + ) + + +class SelectIntoTests(unittest.TestCase): + table_abc, table_efg, table_hij = Tables("abc", "efg", "hij") + + def test_select_star_into(self): + query = Query.from_(self.table_abc).select("*").into(self.table_efg) + + self.assertEqual('SELECT * INTO "efg" FROM "abc"', str(query)) + + def test_select_columns_into(self): + query = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, self.table_abc.bar, self.table_abc.buz) + .into(self.table_efg) + ) + + self.assertEqual('SELECT "foo","bar","buz" INTO "efg" FROM "abc"', str(query)) + + def test_select_columns_into_with_join(self): + query = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, self.table_abc.bar) + .join(self.table_hij) + .on(self.table_abc.id == self.table_hij.abc_id) + .select(self.table_hij.fiz, self.table_hij.buz) + .into(self.table_efg) + ) + + self.assertEqual( + 'SELECT "abc"."foo","abc"."bar","hij"."fiz","hij"."buz" ' + 'INTO "efg" FROM "abc" ' + 'JOIN "hij" ON "abc"."id"="hij"."abc_id"', + str(query), + ) + + +class ReplaceTests(unittest.TestCase): + table_abc, table_def = Tables("abc", "efg") + + def test_replace_simple(self): + query = Query.into(self.table_abc).replace("v1", "v2", "v3") + expected_output = "REPLACE INTO \"abc\" VALUES ('v1','v2','v3')" + self.assertEqual(str(query), expected_output) + + def test_replace_subquery(self): + query = Query.into(self.table_abc).replace(Query.from_(self.table_def).select("f1", "f2")) + expected_output = 'REPLACE INTO "abc" VALUES ((SELECT "f1","f2" FROM "efg"))' + self.assertEqual(str(query), expected_output) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/test_internals.py b/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/test_internals.py new file mode 100644 index 0000000000000000000000000000000000000000..921e381ba8613d4a83cc53bd60d111d9547e2c1f --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/test_internals.py @@ -0,0 +1,35 @@ +import unittest + +from pypika import ( + Case, + Field, + Table, +) +from pypika.terms import Star + + +class TablesTests(unittest.TestCase): + def test__criterion_replace_table_with_value(self): + table = Table("a") + + c = (Field("foo") > 1).replace_table(None, table) + self.assertEqual(c.left, table) + self.assertEqual(c.tables_, {table}) + + def test__case_tables(self): + table = Table("a") + + c = Case().when(table.a == 1, 2 * table.a) + self.assertIsInstance(c.tables_, set) + self.assertSetEqual(c.tables_, {table}) + + def test__star_tables(self): + star = Star() + + self.assertEqual(star.tables_, set()) + + def test__table_star_tables(self): + table = Table("a") + star = Star(table=table) + + self.assertEqual(star.tables_, {table}) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/test_joins.py b/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/test_joins.py new file mode 100644 index 0000000000000000000000000000000000000000..03142d583921edbe966e0ae191d254e7b8bf46ba --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/test_joins.py @@ -0,0 +1,1168 @@ +import unittest + +from pypika import ( + Field, + Interval, + JoinException, + JoinType, + MySQLQuery, + Query, + SetOperationException, + Table, + Tables, + functions as fn, + SYSTEM_TIME, +) + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + + +class SelectQueryJoinTests(unittest.TestCase): + table0, table1, hij = Tables("abc", "efg", "hij") + + def test_default_join_type(self): + query = Query.from_(self.table0).join(self.table1).on(self.table0.foo == self.table1.bar).select("*") + + self.assertEqual('SELECT * FROM "abc" JOIN "efg" ON "abc"."foo"="efg"."bar"', str(query)) + + def test_inner_join(self): + expected = 'SELECT * FROM "abc" JOIN "efg" ON "abc"."foo"="efg"."bar"' + + with self.subTest("join with enum"): + query = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.inner) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + self.assertEqual(expected, str(query)) + + with self.subTest("join function"): + query = Query.from_(self.table0).inner_join(self.table1).on(self.table0.foo == self.table1.bar).select("*") + self.assertEqual(expected, str(query)) + + def test_left_join(self): + expected = 'SELECT * FROM "abc" LEFT JOIN "efg" ON "abc"."foo"="efg"."bar"' + + with self.subTest("join with enum"): + query = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.left) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + + self.assertEqual(expected, str(query)) + + with self.subTest("join function"): + query = Query.from_(self.table0).left_join(self.table1).on(self.table0.foo == self.table1.bar).select("*") + self.assertEqual(expected, str(query)) + + def test_right_join(self): + expected = 'SELECT * FROM "abc" RIGHT JOIN "efg" ON "abc"."foo"="efg"."bar"' + + with self.subTest("join with enum"): + query = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.right) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + + self.assertEqual(expected, str(query)) + + with self.subTest("join function"): + query = Query.from_(self.table0).right_join(self.table1).on(self.table0.foo == self.table1.bar).select("*") + self.assertEqual(expected, str(query)) + + def test_hash_join(self): + expected = 'SELECT * FROM "abc" HASH JOIN "efg" ON "abc"."foo"="efg"."bar"' + + with self.subTest("join with enum"): + query = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.hash) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + + self.assertEqual(expected, str(query)) + + with self.subTest("join function"): + query = Query.from_(self.table0).hash_join(self.table1).on(self.table0.foo == self.table1.bar).select("*") + self.assertEqual(expected, str(query)) + + def test_outer_join(self): + expected = 'SELECT * FROM "abc" FULL OUTER JOIN "efg" ON "abc"."foo"="efg"."bar"' + + with self.subTest("join with enum"): + query = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.outer) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + + self.assertEqual(expected, str(query)) + + with self.subTest("join function"): + query = Query.from_(self.table0).outer_join(self.table1).on(self.table0.foo == self.table1.bar).select("*") + self.assertEqual(expected, str(query)) + + def test_cross_join(self): + expected = 'SELECT * FROM "abc" CROSS JOIN "efg" ON "abc"."foo"="efg"."bar"' + + with self.subTest("join with enum"): + query = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.cross) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + + self.assertEqual(expected, str(query)) + + with self.subTest("join function"): + query = Query.from_(self.table0).cross_join(self.table1).on(self.table0.foo == self.table1.bar).select("*") + self.assertEqual(expected, str(query)) + + def test_left_outer_join(self): + expected = 'SELECT * FROM "abc" LEFT OUTER JOIN "efg" ON "abc"."foo"="efg"."bar"' + with self.subTest("join with enum"): + query = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.left_outer) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + + self.assertEqual(expected, str(query)) + + with self.subTest("join function"): + query = ( + Query.from_(self.table0).left_outer_join(self.table1).on(self.table0.foo == self.table1.bar).select("*") + ) + + self.assertEqual(expected, str(query)) + + def test_right_outer_join(self): + expected = 'SELECT * FROM "abc" RIGHT OUTER JOIN "efg" ON "abc"."foo"="efg"."bar"' + with self.subTest("join with enum"): + query = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.right_outer) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + + self.assertEqual(expected, str(query)) + + with self.subTest("join function"): + query = ( + Query.from_(self.table0) + .right_outer_join(self.table1) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + + self.assertEqual(expected, str(query)) + + def test_full_outer_join(self): + expected = 'SELECT * FROM "abc" FULL OUTER JOIN "efg" ON "abc"."foo"="efg"."bar"' + + with self.subTest("join with enum"): + query = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.full_outer) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + + self.assertEqual(expected, str(query)) + + with self.subTest("join function"): + query = ( + Query.from_(self.table0).full_outer_join(self.table1).on(self.table0.foo == self.table1.bar).select("*") + ) + + self.assertEqual(expected, str(query)) + + def test_join_on_field_single(self): + query = Query.from_(self.table0).join(self.table1).on_field("foo").select("*") + self.assertEqual('SELECT * FROM "abc" JOIN "efg" ON "abc"."foo"="efg"."foo"', str(query)) + + def test_join_on_field_multi(self): + query = Query.from_(self.table0).join(self.table1).on_field("foo", "bar").select("*") + self.assertEqual( + 'SELECT * FROM "abc" JOIN "efg" ON "abc"."foo"="efg"."foo" ' 'AND "abc"."bar"="efg"."bar"', + str(query), + ) + + def test_join_on_field_multi_with_extra_join(self): + query = ( + Query.from_(self.table0) + .join(self.hij) + .on_field("buzz") + .join(self.table1) + .on_field("foo", "bar") + .select("*") + ) + + self.assertEqual( + 'SELECT * FROM "abc" JOIN "hij" ON "abc"."buzz"="hij"."buzz" ' + 'JOIN "efg" ON "abc"."foo"="efg"."foo" AND "abc"."bar"="efg"."bar"', + str(query), + ) + + def test_join_using_string_field_name(self): + query = Query.from_(self.table0).join(self.table1).using("id").select("*") + + self.assertEqual('SELECT * FROM "abc" JOIN "efg" USING ("id")', str(query)) + + def test_join_using_multiple_fields(self): + query = Query.from_(self.table0).join(self.table1).using("foo", "bar").select("*") + + self.assertEqual('SELECT * FROM "abc" JOIN "efg" USING ("foo","bar")', str(query)) + + def test_join_using_with_quote_char(self): + query = Query.from_(self.table0).join(self.table1).using("foo", "bar").select("*") + + self.assertEqual("SELECT * FROM abc JOIN efg USING (foo,bar)", query.get_sql(quote_char="")) + + def test_join_using_without_fields_raises_exception(self): + with self.assertRaises(JoinException): + Query.from_(self.table0).join(self.table1).using() + + def test_join_on_field_without_fields_raises_exception(self): + with self.assertRaises(JoinException): + Query.from_(self.table0).join(self.table1).on_field() + + def test_join_arithmetic_field(self): + q = ( + Query.from_(self.table0) + .join(self.table1) + .on(self.table0.dt == (self.table1.dt - Interval(weeks=1))) + .select("*") + ) + + self.assertEqual( + 'SELECT * FROM "abc" ' 'JOIN "efg" ON "abc"."dt"="efg"."dt"-INTERVAL \'1 WEEK\'', + str(q), + ) + + def test_join_with_arithmetic_function_in_select(self): + q = ( + Query.from_( + self.table0, + ) + .join(self.table1) + .on(self.table0.dt == (self.table1.dt - Interval(weeks=1))) + .select(self.table0.fiz - self.table0.buz, self.table1.star) + ) + + self.assertEqual( + 'SELECT "abc"."fiz"-"abc"."buz","efg".* FROM "abc" ' + 'JOIN "efg" ON "abc"."dt"="efg"."dt"-INTERVAL \'1 WEEK\'', + str(q), + ) + + def test_join_on_complex_criteria(self): + q = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.right) + .on((self.table0.foo == self.table1.fiz) & (self.table0.bar == self.table1.buz)) + .select("*") + ) + + self.assertEqual( + 'SELECT * FROM "abc" ' 'RIGHT JOIN "efg" ON "abc"."foo"="efg"."fiz" AND "abc"."bar"="efg"."buz"', + str(q), + ) + + def test_join_on_subquery_criteria(self): + table_a, table_b, table_c = Tables("a", "b", "c") + subquery = Query.from_(table_c).select("id").limit(1) + query = ( + Query.from_(table_a).select("*").join(table_b).on((table_a.b_id == table_b.id) & (table_b.c_id == subquery)) + ) + + self.assertEqual( + "SELECT * " 'FROM "a" ' 'JOIN "b" ON "a"."b_id"="b"."id" AND "b"."c_id"=' '(SELECT "id" FROM "c" LIMIT 1)', + str(query), + ) + + def test_use_different_table_objects_for_same_table(self): + table = Table("t") + q = Query.from_(table).select("*").where(Field("id", table=table) == 1) + + self.assertEqual('SELECT * FROM "t" WHERE "id"=1', str(q)) + + def test_join_second_table_in_from_clause(self): + table_a, table_b, table_c = Tables("a", "b", "c") + q = Query.from_(table_a).from_(table_b).select("*").join(table_c).on(table_b.c_id == table_c.id) + + self.assertEqual("SELECT * " 'FROM "a","b" ' 'JOIN "c" ON "b"."c_id"="c"."id"', str(q)) + + def test_cross_join_on_table(self): + table_a, table_b = Tables("a", "b") + q = Query.from_(table_a).join(table_b).cross().select("*") + + self.assertEqual('SELECT * FROM "a" CROSS JOIN "b"', str(q)) + + def test_cross_join_on_subquery(self): + table_a, table_b = Tables("a", "b") + q_a = Query.from_(table_a).select("*") + q_b = Query.from_(table_b).select("*").join(q_a).cross().select("*") + + self.assertEqual('SELECT * FROM "b" CROSS JOIN (SELECT * FROM "a") "sq0"', str(q_b)) + + def test_join_on_collate(self): + table_a, table_b = Tables("a", "b") + + q1 = ( + Query.from_(table_a) + .select(table_b.ouch) + .join(table_b) + .on(table_a.foo == table_b.boo, collate="utf8_general_ci") + ) + q2 = Query.from_(table_a).select(table_b.ouch).join(table_b).on(table_a.foo == table_b.boo) + + self.assertEqual( + 'SELECT "b"."ouch" FROM "a" JOIN "b" ON "a"."foo"="b"."boo" COLLATE utf8_general_ci', + str(q1), + ) + self.assertEqual('SELECT "b"."ouch" FROM "a" JOIN "b" ON "a"."foo"="b"."boo"', str(q2)) + + def test_temporal_join(self): + t0 = self.table0.for_(SYSTEM_TIME.as_of('2020-01-01')) + t1 = self.table1.for_(SYSTEM_TIME.as_of('2020-01-01')) + query = Query.from_(t0).join(t1).on(t0.foo == t1.bar).select("*") + + self.assertEqual( + 'SELECT * FROM "abc" FOR SYSTEM_TIME AS OF \'2020-01-01\' ' + 'JOIN "efg" FOR SYSTEM_TIME AS OF \'2020-01-01\' ' + 'ON "abc"."foo"="efg"."bar"', + str(query), + ) + + +class JoinBehaviorTests(unittest.TestCase): + table_abc, table_efg, table_hij, table_klm = Tables("abc", "efg", "hij", "klm") + + def test_select__ordered_select_clauses(self): + q = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .select( + self.table_abc.baz, + self.table_efg.buz, + self.table_abc.fiz, + self.table_efg.bam, + ) + ) + + self.assertEqual( + 'SELECT "abc"."baz","efg"."buz","abc"."fiz","efg"."bam" FROM "abc" ' + 'JOIN "efg" ON "abc"."foo"="efg"."bar"', + str(q), + ) + + def test_select__star_for_table(self): + q = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .join(self.table_hij) + .on(self.table_abc.buz == self.table_hij.bam) + .select(self.table_abc.star) + .select(self.table_efg.star) + .select(self.table_hij.star) + ) + + self.assertEqual( + 'SELECT "abc".*,"efg".*,"hij".* FROM "abc" ' + 'JOIN "efg" ON "abc"."foo"="efg"."bar" ' + 'JOIN "hij" ON "abc"."buz"="hij"."bam"', + str(q), + ) + + def test_select__star_for_table__replacement(self): + q = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .join(self.table_hij) + .on(self.table_abc.buz == self.table_hij.bam) + .select(self.table_abc.foo, self.table_efg.bar, self.table_hij.bam) + .select(self.table_abc.star, self.table_efg.star, self.table_hij.star) + ) + + self.assertEqual( + 'SELECT "abc".*,"efg".*,"hij".* FROM "abc" ' + 'JOIN "efg" ON "abc"."foo"="efg"."bar" ' + 'JOIN "hij" ON "abc"."buz"="hij"."bam"', + str(q), + ) + + def test_select_fields_with_where(self): + q = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .join(self.table_hij) + .on(self.table_abc.buz == self.table_hij.bam) + .select(self.table_abc.foo, self.table_efg.bar, self.table_hij.bam) + .where(self.table_abc.foo > 1) + .where(self.table_efg.bar != 2) + ) + + self.assertEqual( + 'SELECT "abc"."foo","efg"."bar","hij"."bam" FROM "abc" ' + 'JOIN "efg" ON "abc"."foo"="efg"."bar" ' + 'JOIN "hij" ON "abc"."buz"="hij"."bam" ' + 'WHERE "abc"."foo">1 AND "efg"."bar"<>2', + str(q), + ) + + def test_require_condition(self): + with self.assertRaises(JoinException): + Query.from_(self.table_abc).join(self.table_efg).on(None) + + def test_require_condition_with_both_tables(self): + with self.assertRaises(JoinException): + Query.from_(self.table_abc).join(self.table_efg).on(self.table_abc.foo == self.table_hij.bar) + + with self.assertRaises(JoinException): + Query.from_(self.table_abc).join(self.table_efg).on(self.table_hij.foo == self.table_efg.bar) + + with self.assertRaises(JoinException): + Query.from_(self.table_abc).join(self.table_efg).on(self.table_hij.foo == self.table_klm.bar) + + def test_join_same_table(self): + table1 = Table("abc") + table2 = Table("abc") + q = Query.from_(table1).join(table2).on(table1.foo == table2.bar).select(table1.foo, table2.buz) + + self.assertEqual( + 'SELECT "abc"."foo","abc2"."buz" FROM "abc" ' 'JOIN "abc" "abc2" ON "abc"."foo"="abc2"."bar"', + str(q), + ) + + def test_join_same_table_with_prefixes(self): + table1 = Table("abc").as_("x") + table2 = Table("abc").as_("y") + q = Query.from_(table1).join(table2).on(table1.foo == table2.bar).select(table1.foo, table2.buz) + + self.assertEqual( + 'SELECT "x"."foo","y"."buz" FROM "abc" "x" ' 'JOIN "abc" "y" ON "x"."foo"="y"."bar"', + str(q), + ) + + def test_join_table_twice(self): + table1, table2 = Table("efg").as_("efg1"), Table("efg").as_("efg2") + q = ( + Query.from_(self.table_abc) + .join(table1) + .on(self.table_abc.foo == table1.bar) + .join(table2) + .on(self.table_abc.foo == table2.bam) + .select(self.table_abc.foo, table1.fiz, table2.buz) + ) + + self.assertEqual( + 'SELECT "abc"."foo","efg1"."fiz","efg2"."buz" FROM "abc" ' + 'JOIN "efg" "efg1" ON "abc"."foo"="efg1"."bar" ' + 'JOIN "efg" "efg2" ON "abc"."foo"="efg2"."bam"', + str(q), + ) + + def test_select__fields_after_table_star(self): + q = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .select(self.table_abc.star, self.table_efg.bar) + .select(self.table_abc.foo) + ) + + self.assertEqual( + 'SELECT "abc".*,"efg"."bar" FROM "abc" JOIN "efg" ON "abc"."foo"="efg"."bar"', + str(q), + ) + + def test_fail_when_joining_unknown_type(self): + with self.assertRaises(ValueError): + Query.from_(self.table_abc).join("this is a string") + + def test_immutable__tables(self): + query1 = Query.from_(self.table_abc).select(self.table_abc.foo) + query2 = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .select(self.table_abc.foo, self.table_efg.buz) + ) + + self.assertEqual( + 'SELECT "abc"."foo","efg"."buz" FROM "abc" ' 'JOIN "efg" ON "abc"."foo"="efg"."bar"', + str(query2), + ) + self.assertEqual('SELECT "foo" FROM "abc"', str(query1)) + + def test_select_field_from_missing_table(self): + """ + Previously we validated the select field was a member of a table + in the query (e.g. FROM clause or a JOIN). However this made + correlated subqueries awkward to write (subqueries which refer + to their parent table. So the validation was removed. + + None of the following raise an error. Previously raised JoinException + """ + Query.from_(self.table_abc).select(self.table_efg.foo) + + Query.from_(self.table_abc).where(self.table_efg.foo == 0) + + Query.from_(self.table_abc).where(fn.Sum(self.table_efg.foo) == 0) + + Query.from_(self.table_abc).select(fn.Sum(self.table_abc.bar * 2) + fn.Sum(self.table_efg.foo * 2)) + + Query.from_(self.table_abc).groupby(self.table_efg.foo) + + Query.from_(self.table_abc).groupby(self.table_abc.foo).having(self.table_efg.bar) + + subquery = ( + Query.from_(self.table_efg).select(self.table_efg.id).where(self.table_efg.abc_id == self.table_abc.id) + ) + query = Query.from_(self.table_abc).select(subquery.as_("efg_id").limit(1)) + self.assertEqual( + 'SELECT (SELECT "efg"."id" FROM "efg" WHERE "efg"."abc_id"="abc"."id" LIMIT 1) "efg_id" FROM "abc"', + str(query), + ) + + def test_ignore_table_references(self): + query = Query.from_(Table("abc")).select(Table("abc").foo) + + self.assertEqual('SELECT "foo" FROM "abc"', str(query)) + + def test_prefixes_added_to_groupby(self): + test_query = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .select(self.table_abc.foo, fn.Sum(self.table_efg.buz)) + .groupby(self.table_abc.foo) + ) + + self.assertEqual( + 'SELECT "abc"."foo",SUM("efg"."buz") FROM "abc" ' + 'JOIN "efg" ON "abc"."foo"="efg"."bar" ' + 'GROUP BY "abc"."foo"', + str(test_query), + ) + + def test_prefixes_added_to_orderby(self): + test_query = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .select(self.table_abc.foo, self.table_efg.buz) + .orderby(self.table_abc.foo) + ) + + self.assertEqual( + 'SELECT "abc"."foo","efg"."buz" FROM "abc" ' + 'JOIN "efg" ON "abc"."foo"="efg"."bar" ' + 'ORDER BY "abc"."foo"', + str(test_query), + ) + + def test_prefixes_added_to_function_in_orderby(self): + test_query = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .select(self.table_abc.foo, self.table_efg.buz) + .orderby(fn.Date(self.table_abc.foo)) + ) + + self.assertEqual( + 'SELECT "abc"."foo","efg"."buz" FROM "abc" ' + 'JOIN "efg" ON "abc"."foo"="efg"."bar" ' + 'ORDER BY DATE("abc"."foo")', + str(test_query), + ) + + def test_join_from_join(self): + test_query = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.efg_id == self.table_efg.id) + .join(self.table_hij) + .on(self.table_efg.hij_id == self.table_hij.id) + .select(self.table_abc.foo, self.table_efg.bar, self.table_hij.fizz) + ) + + self.assertEqual( + 'SELECT "abc"."foo","efg"."bar","hij"."fizz" FROM "abc" ' + 'JOIN "efg" ON "abc"."efg_id"="efg"."id" ' + 'JOIN "hij" ON "efg"."hij_id"="hij"."id"', + str(test_query), + ) + + def test_join_query_without_alias(self): + subquery = Query.from_(self.table_efg).select( + self.table_efg.base_id.as_("x"), self.table_efg.fizz, self.table_efg.buzz + ) + + test_query = ( + Query.from_(self.table_abc) + .join(subquery) + .on(subquery.x == self.table_abc.id) + .select(self.table_abc.foo, subquery.fizz, subquery.buzz) + ) + + self.assertEqual( + 'SELECT "abc"."foo","sq0"."fizz","sq0"."buzz" ' + 'FROM "abc" JOIN (' + 'SELECT "base_id" "x","fizz","buzz" FROM "efg"' + ') "sq0" ' + 'ON "sq0"."x"="abc"."id"', + str(test_query), + ) + + def test_join_query_with_column_alias(self): + subquery = ( + Query.from_(self.table_efg) + .select( + self.table_efg.base_id.as_("x"), + self.table_efg.fizz, + self.table_efg.buzz, + ) + .as_("subq") + ) + + test_query = ( + Query.from_(self.table_abc) + .join(subquery) + .on(subquery.x == self.table_abc.id) + .select(self.table_abc.foo, subquery.fizz, subquery.buzz) + ) + + self.assertEqual( + 'SELECT "abc"."foo","subq"."fizz","subq"."buzz" ' + 'FROM "abc" JOIN (' + 'SELECT "base_id" "x","fizz","buzz" FROM "efg"' + ') "subq" ' + 'ON "subq"."x"="abc"."id"', + str(test_query), + ) + + def test_join_query_with_table_alias(self): + xxx = self.table_efg.as_("xxx") + subquery = Query.from_(xxx).select(xxx.base_id, xxx.fizz, xxx.buzz).as_("subq") + + test_query = ( + Query.from_(self.table_abc) + .join(subquery) + .on(subquery.x == self.table_abc.id) + .select(self.table_abc.foo, subquery.fizz, subquery.buzz) + ) + + self.assertEqual( + 'SELECT "abc"."foo","subq"."fizz","subq"."buzz" ' + 'FROM "abc" JOIN (' + 'SELECT "xxx"."base_id","xxx"."fizz","xxx"."buzz" FROM "efg" "xxx"' + ') "subq" ' + 'ON "subq"."x"="abc"."id"', + str(test_query), + ) + + def test_join_query_with_setoperation(self): + subquery = Query.from_(self.table_abc).select("*").union(Query.from_(self.table_abc).select("*")).as_("subq") + + test_query = ( + Query.from_(self.table_abc).join(subquery).on(subquery.x == self.table_abc.id).select(self.table_abc.foo) + ) + + self.assertEqual( + 'SELECT "abc"."foo" FROM "abc" ' + 'JOIN ' + '((SELECT * FROM "abc") ' + 'UNION ' + '(SELECT * FROM "abc")) "subq" ' + 'ON "subq"."x"="abc"."id"', + str(test_query), + ) + + +class UnionTests(unittest.TestCase): + table1, table2 = Tables("abc", "efg") + + def test_union(self): + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + + self.assertEqual( + '(SELECT "foo" FROM "abc") UNION (SELECT "bar" FROM "efg")', + str(query1 + query2), + ) + self.assertEqual( + '(SELECT "foo" FROM "abc") UNION (SELECT "bar" FROM "efg")', + str(query1.union(query2)), + ) + + def test_union_multiple(self): + table3, table4 = Tables("hij", "lmn") + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + query3 = Query.from_(table3).select(table3.baz) + query4 = Query.from_(table4).select(table4.faz) + + self.assertEqual( + '(SELECT "foo" FROM "abc") UNION ' + '(SELECT "bar" FROM "efg") UNION ' + '(SELECT "baz" FROM "hij") UNION ' + '(SELECT "faz" FROM "lmn")', + str(query1 + query2 + query3 + query4), + ) + self.assertEqual( + '(SELECT "foo" FROM "abc") UNION ' + '(SELECT "bar" FROM "efg") UNION ' + '(SELECT "baz" FROM "hij") UNION ' + '(SELECT "faz" FROM "lmn")', + str(query1.union(query2).union(query3).union(query4)), + ) + + def test_union_all(self): + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + + self.assertEqual( + '(SELECT "foo" FROM "abc") UNION ALL (SELECT "bar" FROM "efg")', + str(query1 * query2), + ) + self.assertEqual( + '(SELECT "foo" FROM "abc") UNION ALL (SELECT "bar" FROM "efg")', + str(query1.union_all(query2)), + ) + + def test_union_all_multiple(self): + table3, table4 = Tables("hij", "lmn") + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + query3 = Query.from_(table3).select(table3.baz) + query4 = Query.from_(table4).select(table4.faz) + + self.assertEqual( + '(SELECT "foo" FROM "abc") UNION ALL ' + '(SELECT "bar" FROM "efg") UNION ALL ' + '(SELECT "baz" FROM "hij") UNION ALL ' + '(SELECT "faz" FROM "lmn")', + str(query1 * query2 * query3 * query4), + ) + self.assertEqual( + '(SELECT "foo" FROM "abc") UNION ALL ' + '(SELECT "bar" FROM "efg") UNION ALL ' + '(SELECT "baz" FROM "hij") UNION ALL ' + '(SELECT "faz" FROM "lmn")', + str(query1.union_all(query2).union_all(query3).union_all(query4)), + ) + + def test_union_with_order_by(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + union_query = str((query1 + query2).orderby(query1.field("a"))) + union_all_query = str((query1 * query2).orderby(query1.field("a"))) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "UNION " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "a"', + union_query, + ) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "UNION ALL " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "a"', + union_all_query, + ) + + def test_union_with_order_by_use_union_query_field(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + union_query = query1 + query2 + union_query = str(union_query.orderby(union_query.field("a"))) + union_all_query = query1 * query2 + union_all_query = str(union_all_query.orderby(union_all_query.field("a"))) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "UNION " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "a"', + union_query, + ) + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "UNION ALL " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "a"', + union_all_query, + ) + + def test_union_with_order_by_with_aliases(self): + query1 = Query.from_(self.table1.as_("a")).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2.as_("b")).select(self.table2.bar.as_("a")) + + union_all_query = str((query1 * query2).orderby(query1.field("a"))) + union_query = str((query1 + query2).orderby(query1.field("a"))) + self.assertEqual( + '(SELECT "foo" "a" FROM "abc" "a")' " UNION ALL " '(SELECT "bar" "a" FROM "efg" "b")' ' ORDER BY "a"', + union_all_query, + ) + self.assertEqual( + '(SELECT "foo" "a" FROM "abc" "a")' " UNION " '(SELECT "bar" "a" FROM "efg" "b")' ' ORDER BY "a"', + union_query, + ) + + def test_union_with_order_by_use_union_query_field_with_aliases(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + union_query = (query1 + query2).as_("x") + union_query = union_query.orderby(union_query.field("a")) + union_all_query = (query1 * query2).as_("x") + union_all_query = union_all_query.orderby(union_all_query.field("a")) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "UNION " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "x"."a"', + str(union_query), + ) + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "UNION ALL " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "x"."a"', + str(union_all_query), + ) + + def test_require_equal_number_of_fields(self): + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.fiz, self.table2.buz) + + with self.assertRaises(SetOperationException): + str(query1 + query2) + + def test_mysql_query_wraps_unioned_queries(self): + query1 = MySQLQuery.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + + self.assertEqual( + "(SELECT `foo` FROM `abc`) UNION (SELECT `bar` FROM `efg`)", + str(query1 + query2), + ) + + def test_union_as_subquery(self): + abc, efg = Tables("abc", "efg") + hij = Query.from_(abc).select(abc.t).union(Query.from_(efg).select(efg.t)) + q = Query.from_(hij).select(fn.Avg(hij.t)) + + self.assertEqual( + 'SELECT AVG("sq0"."t") FROM ((SELECT "t" FROM "abc") UNION (SELECT "t" FROM "efg")) "sq0"', + str(q), + ) + + def test_union_with_no_quote_char(self): + abc, efg = Tables("abc", "efg") + hij = Query.from_(abc).select(abc.t).union(Query.from_(efg).select(efg.t)) + q = Query.from_(hij).select(fn.Avg(hij.t)) + + self.assertEqual( + "SELECT AVG(sq0.t) FROM ((SELECT t FROM abc) UNION (SELECT t FROM efg)) sq0", + q.get_sql(quote_char=None), + ) + + +class InsertQueryJoinTests(unittest.TestCase): + def test_join_table_on_insert_query(self): + a, b, c = Tables("a", "b", "c") + q = Query.into(c).from_(a).join(b).on(a.fkey_id == b.id).where(b.foo == 1).select("a.*", "b.*") + + self.assertEqual( + 'INSERT INTO "c" ' + 'SELECT "a"."a.*","a"."b.*" ' + 'FROM "a" JOIN "b" ' + 'ON "a"."fkey_id"="b"."id" ' + 'WHERE "b"."foo"=1', + str(q), + ) + + +class UpdateQueryJoinTests(unittest.TestCase): + def test_join_table_on_update_query(self): + a, b = Tables("a", "b") + q = Query.update(a).join(b).on(a.fkey_id == b.id).where(b.foo == 1).set("adwords_batch_job_id", 1) + + self.assertEqual( + 'UPDATE "a" ' 'JOIN "b" ' 'ON "a"."fkey_id"="b"."id" ' 'SET "adwords_batch_job_id"=1 ' 'WHERE "b"."foo"=1', + str(q), + ) + + +class IntersectTests(unittest.TestCase): + table1, table2 = Tables("abc", "efg") + + def test_intersect(self): + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + + self.assertEqual( + '(SELECT "foo" FROM "abc") INTERSECT (SELECT "bar" FROM "efg")', + str(query1.intersect(query2)), + ) + + def test_intersect_multiple(self): + table3, table4 = Tables("hij", "lmn") + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + query3 = Query.from_(table3).select(table3.baz) + query4 = Query.from_(table4).select(table4.faz) + + self.assertEqual( + '(SELECT "foo" FROM "abc") INTERSECT ' + '(SELECT "bar" FROM "efg") INTERSECT ' + '(SELECT "baz" FROM "hij") INTERSECT ' + '(SELECT "faz" FROM "lmn")', + str(query1.intersect(query2).intersect(query3).intersect(query4)), + ) + + def test_intersect_with_order_by(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + intersect_query = str((query1.intersect(query2)).orderby(query1.field("a"))) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "INTERSECT " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "a"', + intersect_query, + ) + + def test_intersect_with_limit(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + intersect_query = str((query1.intersect(query2)).limit(10)) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "INTERSECT " '(SELECT "bar" "a" FROM "efg") ' 'LIMIT 10', + intersect_query, + ) + + def test_intersect_with_offset(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + intersect_query = str((query1.intersect(query2)).offset(10)) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "INTERSECT " '(SELECT "bar" "a" FROM "efg") ' 'OFFSET 10', + intersect_query, + ) + + def test_require_equal_number_of_fields_intersect(self): + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.fiz, self.table2.buz) + + with self.assertRaises(SetOperationException): + str(query1.intersect(query2)) + + def test_mysql_query_wraps_intersected_queries(self): + query1 = MySQLQuery.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + + self.assertEqual( + "(SELECT `foo` FROM `abc`) INTERSECT (SELECT `bar` FROM `efg`)", + str(query1.intersect(query2)), + ) + + def test_intersect_as_subquery(self): + abc, efg = Tables("abc", "efg") + hij = Query.from_(abc).select(abc.t).intersect(Query.from_(efg).select(efg.t)) + q = Query.from_(hij).select(fn.Avg(hij.t)) + + self.assertEqual( + 'SELECT AVG("sq0"."t") FROM ((SELECT "t" FROM "abc") INTERSECT (SELECT "t" FROM "efg")) "sq0"', + str(q), + ) + + def test_intersect_with_no_quote_char(self): + abc, efg = Tables("abc", "efg") + hij = Query.from_(abc).select(abc.t).intersect(Query.from_(efg).select(efg.t)) + q = Query.from_(hij).select(fn.Avg(hij.t)) + + self.assertEqual( + "SELECT AVG(sq0.t) FROM ((SELECT t FROM abc) INTERSECT (SELECT t FROM efg)) sq0", + q.get_sql(quote_char=None), + ) + + +class MinusTests(unittest.TestCase): + table1, table2 = Tables("abc", "efg") + + def test_minus(self): + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + + self.assertEqual('(SELECT "foo" FROM "abc") MINUS (SELECT "bar" FROM "efg")', str(query1.minus(query2))) + + self.assertEqual( + '(SELECT "foo" FROM "abc") MINUS (SELECT "bar" FROM "efg")', + str(query1 - query2), + ) + + def test_minus_multiple(self): + table3, table4 = Tables("hij", "lmn") + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + query3 = Query.from_(table3).select(table3.baz) + query4 = Query.from_(table4).select(table4.faz) + + self.assertEqual( + '(SELECT "foo" FROM "abc") MINUS ' + '(SELECT "bar" FROM "efg") MINUS ' + '(SELECT "baz" FROM "hij") MINUS ' + '(SELECT "faz" FROM "lmn")', + str(query1 - query2 - query3 - query4), + ) + + self.assertEqual( + '(SELECT "foo" FROM "abc") MINUS ' + '(SELECT "bar" FROM "efg") MINUS ' + '(SELECT "baz" FROM "hij") MINUS ' + '(SELECT "faz" FROM "lmn")', + str(query1.minus(query2).minus(query3).minus(query4)), + ) + + def test_minus_with_order_by(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + minus_query = str(query1.minus(query2).orderby(query1.field("a"))) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "MINUS " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "a"', minus_query + ) + + def test_minus_query_with_order_by_use_minus_query_field(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + minus_query = query1.minus(query2) + minus_query = str(minus_query.orderby(minus_query.field("b"))) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "MINUS " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "b"', + minus_query, + ) + + def test_require_equal_number_of_fields(self): + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.fiz, self.table2.buz) + + with self.assertRaises(SetOperationException): + str(query1.minus(query2)) + + def test_mysql_query_wraps_minus_queries(self): + query1 = MySQLQuery.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + + self.assertEqual( + "(SELECT `foo` FROM `abc`) MINUS (SELECT `bar` FROM `efg`)", + str(query1 - query2), + ) + + def test_minus_as_subquery(self): + abc, efg = Tables("abc", "efg") + hij = Query.from_(abc).select(abc.t).minus(Query.from_(efg).select(efg.t)) + q = Query.from_(hij).select(fn.Avg(hij.t)) + + self.assertEqual( + 'SELECT AVG("sq0"."t") FROM ((SELECT "t" FROM "abc") MINUS (SELECT "t" FROM "efg")) "sq0"', + str(q), + ) + + def test_minus_with_no_quote_char(self): + abc, efg = Tables("abc", "efg") + hij = Query.from_(abc).select(abc.t).minus(Query.from_(efg).select(efg.t)) + q = Query.from_(hij).select(fn.Avg(hij.t)) + + self.assertEqual( + "SELECT AVG(sq0.t) FROM ((SELECT t FROM abc) MINUS (SELECT t FROM efg)) sq0", + q.get_sql(quote_char=None), + ) + + +class ExceptOfTests(unittest.TestCase): + table1, table2 = Tables("abc", "efg") + + def test_except(self): + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + + self.assertEqual('(SELECT "foo" FROM "abc") EXCEPT (SELECT "bar" FROM "efg")', str(query1.except_of(query2))) + + def test_except_multiple(self): + table3, table4 = Tables("hij", "lmn") + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + query3 = Query.from_(table3).select(table3.baz) + query4 = Query.from_(table4).select(table4.faz) + + self.assertEqual( + '(SELECT "foo" FROM "abc") EXCEPT ' + '(SELECT "bar" FROM "efg") EXCEPT ' + '(SELECT "baz" FROM "hij") EXCEPT ' + '(SELECT "faz" FROM "lmn")', + str(query1.except_of(query2).except_of(query3).except_of(query4)), + ) + + def test_except_with_order_by(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + except_query = str(query1.except_of(query2).orderby(query1.field("a"))) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "EXCEPT " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "a"', except_query + ) + + def test_except_query_with_order_by_use_minus_query_field(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + except_query = query1.except_of(query2) + except_query = str(except_query.orderby(except_query.field("b"))) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "EXCEPT " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "b"', + except_query, + ) + + def test_require_equal_number_of_fields_except_of(self): + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.fiz, self.table2.buz) + + with self.assertRaises(SetOperationException): + str(query1.except_of(query2)) + + def test_except_as_subquery(self): + abc, efg = Tables("abc", "efg") + hij = Query.from_(abc).select(abc.t).except_of(Query.from_(efg).select(efg.t)) + q = Query.from_(hij).select(fn.Avg(hij.t)) + + self.assertEqual( + 'SELECT AVG("sq0"."t") FROM ((SELECT "t" FROM "abc") EXCEPT (SELECT "t" FROM "efg")) "sq0"', + str(q), + ) + + def test_except_with_no_quote_char(self): + abc, efg = Tables("abc", "efg") + hij = Query.from_(abc).select(abc.t).except_of(Query.from_(efg).select(efg.t)) + q = Query.from_(hij).select(fn.Avg(hij.t)) + + self.assertEqual( + "SELECT AVG(sq0.t) FROM ((SELECT t FROM abc) EXCEPT (SELECT t FROM efg)) sq0", + q.get_sql(quote_char=None), + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/test_negation.py b/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/test_negation.py new file mode 100644 index 0000000000000000000000000000000000000000..9f4db83b560dbc8546ce6d384b781dfccefd319d --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/test_negation.py @@ -0,0 +1,31 @@ +import unittest + +from pypika import ( + Tables, + functions as fn, +) +from pypika.terms import ValueWrapper + + +class NegationTests(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_negate_wrapped_float(self): + q = -ValueWrapper(1.0) + + self.assertEqual("-1.0", q.get_sql()) + + def test_negate_wrapped_int(self): + q = -ValueWrapper(1) + + self.assertEqual("-1", q.get_sql()) + + def test_negate_field(self): + q = -self.table_abc.foo + + self.assertEqual('-"abc"."foo"', q.get_sql(with_namespace=True, quote_char='"')) + + def test_negate_function(self): + q = -fn.Sum(self.table_abc.foo) + + self.assertEqual('-SUM("abc"."foo")', q.get_sql(with_namespace=True, quote_char='"')) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/test_parameter.py b/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/test_parameter.py new file mode 100644 index 0000000000000000000000000000000000000000..c11e9afcd9624abb0a7313306eda34ebcf4c99ba --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/test_parameter.py @@ -0,0 +1,206 @@ +import unittest +from datetime import date + +from pypika import ( + FormatParameter, + NamedParameter, + NumericParameter, + Parameter, + PyformatParameter, + QmarkParameter, + Query, + Tables, +) +from pypika.terms import ListParameter, ParameterValueWrapper + + +class ParametrizedTests(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_param_insert(self): + q = Query.into(self.table_abc).columns("a", "b", "c").insert(Parameter("?"), Parameter("?"), Parameter("?")) + + self.assertEqual('INSERT INTO "abc" ("a","b","c") VALUES (?,?,?)', q.get_sql()) + + def test_param_select_join(self): + q = ( + Query.from_(self.table_abc) + .select("*") + .where(self.table_abc.category == Parameter("%s")) + .join(self.table_efg) + .on(self.table_abc.id == self.table_efg.abc_id) + .where(self.table_efg.date >= Parameter("%s")) + .limit(10) + ) + + self.assertEqual( + 'SELECT * FROM "abc" JOIN "efg" ON "abc"."id"="efg"."abc_id" WHERE "abc"."category"=%s AND "efg"."date">=%s LIMIT 10', + q.get_sql(), + ) + + def test_param_select_subquery(self): + q = ( + Query.from_(self.table_abc) + .select("*") + .where(self.table_abc.category == Parameter("&1")) + .where( + self.table_abc.id.isin( + Query.from_(self.table_efg) + .select(self.table_efg.abc_id) + .where(self.table_efg.date >= Parameter("&2")) + ) + ) + .limit(10) + ) + + self.assertEqual( + 'SELECT * FROM "abc" WHERE "category"=&1 AND "id" IN (SELECT "abc_id" FROM "efg" WHERE "date">=&2) LIMIT 10', + q.get_sql(), + ) + + def test_join(self): + subquery = ( + Query.from_(self.table_efg) + .select(self.table_efg.fiz, self.table_efg.buz) + .where(self.table_efg.buz == Parameter(":buz")) + ) + + q = ( + Query.from_(self.table_abc) + .join(subquery) + .on(self.table_abc.bar == subquery.buz) + .select(self.table_abc.foo, subquery.fiz) + .where(self.table_abc.bar == Parameter(":bar")) + ) + + self.assertEqual( + 'SELECT "abc"."foo","sq0"."fiz" FROM "abc" JOIN (SELECT "fiz","buz" FROM "efg" WHERE "buz"=:buz)' + ' "sq0" ON "abc"."bar"="sq0"."buz" WHERE "abc"."bar"=:bar', + q.get_sql(), + ) + + def test_qmark_parameter(self): + self.assertEqual('?', QmarkParameter().get_sql()) + + def test_numeric_parameter(self): + self.assertEqual(':14', NumericParameter('14').get_sql()) + self.assertEqual(':15', NumericParameter(15).get_sql()) + + def test_named_parameter(self): + self.assertEqual(':buz', NamedParameter('buz').get_sql()) + + def test_format_parameter(self): + self.assertEqual('%s', FormatParameter().get_sql()) + + def test_pyformat_parameter(self): + self.assertEqual('%(buz)s', PyformatParameter('buz').get_sql()) + + +class ParametrizedTestsWithValues(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_param_insert(self): + q = Query.into(self.table_abc).columns("a", "b", "c").insert(1, 2.2, 'foo') + + parameter = QmarkParameter() + sql = q.get_sql(parameter=parameter) + self.assertEqual('INSERT INTO "abc" ("a","b","c") VALUES (?,?,?)', sql) + self.assertEqual([1, 2.2, 'foo'], parameter.get_parameters()) + + def test_param_select_join(self): + q = ( + Query.from_(self.table_abc) + .select("*") + .where(self.table_abc.category == 'foobar') + .join(self.table_efg) + .on(self.table_abc.id == self.table_efg.abc_id) + .where(self.table_efg.date >= date(2024, 2, 22)) + .limit(10) + ) + + parameter = FormatParameter() + sql = q.get_sql(parameter=parameter) + self.assertEqual( + 'SELECT * FROM "abc" JOIN "efg" ON "abc"."id"="efg"."abc_id" WHERE "abc"."category"=%s AND "efg"."date">=%s LIMIT 10', + sql, + ) + self.assertEqual(['foobar', '2024-02-22'], parameter.get_parameters()) + + def test_param_select_subquery(self): + q = ( + Query.from_(self.table_abc) + .select("*") + .where(self.table_abc.category == 'foobar') + .where( + self.table_abc.id.isin( + Query.from_(self.table_efg) + .select(self.table_efg.abc_id) + .where(self.table_efg.date >= date(2024, 2, 22)) + ) + ) + .limit(10) + ) + + parameter = ListParameter(placeholder=lambda idx: f'&{idx+1}') + sql = q.get_sql(parameter=parameter) + self.assertEqual( + 'SELECT * FROM "abc" WHERE "category"=&1 AND "id" IN (SELECT "abc_id" FROM "efg" WHERE "date">=&2) LIMIT 10', + sql, + ) + self.assertEqual(['foobar', '2024-02-22'], parameter.get_parameters()) + + def test_join(self): + subquery = ( + Query.from_(self.table_efg) + .select(self.table_efg.fiz, self.table_efg.buz) + .where(self.table_efg.buz == 'buz') + ) + + q = ( + Query.from_(self.table_abc) + .join(subquery) + .on(self.table_abc.bar == subquery.buz) + .select(self.table_abc.foo, subquery.fiz) + .where(self.table_abc.bar == 'bar') + ) + + parameter = NamedParameter() + sql = q.get_sql(parameter=parameter) + self.assertEqual( + 'SELECT "abc"."foo","sq0"."fiz" FROM "abc" JOIN (SELECT "fiz","buz" FROM "efg" WHERE "buz"=:param1)' + ' "sq0" ON "abc"."bar"="sq0"."buz" WHERE "abc"."bar"=:param2', + sql, + ) + self.assertEqual({'param1': 'buz', 'param2': 'bar'}, parameter.get_parameters()) + + def test_join_with_parameter_value_wrapper(self): + subquery = ( + Query.from_(self.table_efg) + .select(self.table_efg.fiz, self.table_efg.buz) + .where(self.table_efg.buz == ParameterValueWrapper(Parameter(':buz'), 'buz')) + ) + + q = ( + Query.from_(self.table_abc) + .join(subquery) + .on(self.table_abc.bar == subquery.buz) + .select(self.table_abc.foo, subquery.fiz) + .where(self.table_abc.bar == ParameterValueWrapper(NamedParameter('bar'), 'bar')) + ) + + parameter = NamedParameter() + sql = q.get_sql(parameter=parameter) + self.assertEqual( + 'SELECT "abc"."foo","sq0"."fiz" FROM "abc" JOIN (SELECT "fiz","buz" FROM "efg" WHERE "buz"=:buz)' + ' "sq0" ON "abc"."bar"="sq0"."buz" WHERE "abc"."bar"=:bar', + sql, + ) + self.assertEqual({':buz': 'buz', 'bar': 'bar'}, parameter.get_parameters()) + + def test_pyformat_parameter(self): + q = Query.into(self.table_abc).columns("a", "b", "c").insert(1, 2.2, 'foo') + + parameter = PyformatParameter() + sql = q.get_sql(parameter=parameter) + self.assertEqual('INSERT INTO "abc" ("a","b","c") VALUES (%(param1)s,%(param2)s,%(param3)s)', sql) + self.assertEqual({"param1": 1, "param2": 2.2, "param3": "foo"}, parameter.get_parameters()) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/test_pseudocolumns.py b/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/test_pseudocolumns.py new file mode 100644 index 0000000000000000000000000000000000000000..6a25c70269b2ccc98ac3870ac64a43c8a32ddbe9 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/test_pseudocolumns.py @@ -0,0 +1,51 @@ +import unittest + +from pypika import Query, Table +from pypika.pseudocolumns import ( + ColumnValue, + ObjectID, + ObjectValue, + RowID, + RowNum, + SysDate, +) +from pypika.terms import PseudoColumn + + +class PseudoColumnsTest(unittest.TestCase): + @classmethod + def setUpClass(cls): + super(PseudoColumnsTest, cls).setUpClass() + cls.table1 = Table("table1") + + def test_column_value(self): + self.assertEqual("COLUMN_VALUE", ColumnValue) + + def test_object_id(self): + self.assertEqual("OBJECT_ID", ObjectID) + + def test_object_value(self): + self.assertEqual("OBJECT_VALUE", ObjectValue) + + def test_row_id(self): + self.assertEqual("ROWID", RowID) + + def test_row_num(self): + self.assertEqual("ROWNUM", RowNum) + + def test_sys_date(self): + self.assertEqual("SYSDATE", SysDate) + + def test_can_be_used_in_a_select_statement(self): + query = Query.from_(self.table1).where(self.table1.is_active == 1).select(PseudoColumn("abcde")) + + self.assertEqual(str(query), 'SELECT abcde FROM "table1" WHERE "is_active"=1') + + def test_can_be_used_in_a_where_clause(self): + query = Query.from_(self.table1).where(PseudoColumn("abcde") > 1).select(self.table1.is_active) + + self.assertEqual(str(query), 'SELECT "is_active" FROM "table1" WHERE abcde>1') + + def test_can_be_used_in_orderby(self): + query = Query.from_(self.table1).select(self.table1.abcde.as_("some_name")).orderby(PseudoColumn("some_name")) + self.assertEqual(str(query), 'SELECT "abcde" "some_name" FROM "table1" ORDER BY some_name') diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/test_query.py b/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/test_query.py new file mode 100644 index 0000000000000000000000000000000000000000..ae8dc01599a6a562b591ce15391bfe9b5c87e0f9 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/test_query.py @@ -0,0 +1,242 @@ +import unittest + +from pypika import Case, Query, Tables, Tuple, functions, Field +from pypika.dialects import ( + ClickHouseQuery, + ClickHouseQueryBuilder, + MSSQLQuery, + MSSQLQueryBuilder, + MySQLLoadQueryBuilder, + MySQLQuery, + MySQLQueryBuilder, + OracleQuery, + OracleQueryBuilder, + PostgreSQLQuery, + PostgreSQLQueryBuilder, + RedShiftQueryBuilder, + RedshiftQuery, + SQLLiteQuery, + SQLLiteQueryBuilder, + SnowflakeQuery, + SnowflakeQueryBuilder, + VerticaCopyQueryBuilder, + VerticaCreateQueryBuilder, + VerticaQuery, + VerticaQueryBuilder, +) +from pypika.queries import CreateQueryBuilder, DropQueryBuilder, QueryBuilder + + +class QueryTablesTests(unittest.TestCase): + table_a, table_b, table_c, table_d = Tables("a", "b", "c", "d") + + def test_replace_table(self): + query = Query.from_(self.table_a).select(self.table_a.time) + query = query.replace_table(self.table_a, self.table_b) + + self.assertEqual('SELECT "time" FROM "b"', str(query)) + + def test_replace_only_specified_table(self): + query = Query.from_(self.table_a).select(self.table_a.time) + query = query.replace_table(self.table_b, self.table_c) + + self.assertEqual('SELECT "time" FROM "a"', str(query)) + + def test_replace_insert_table(self): + query = Query.into(self.table_a).insert(1) + query = query.replace_table(self.table_a, self.table_b) + + self.assertEqual('INSERT INTO "b" VALUES (1)', str(query)) + + def test_replace_insert_table_current_table_not_match(self): + query = Query.into(self.table_a).insert(1) + query = query.replace_table(self.table_c, self.table_b) + + self.assertEqual('INSERT INTO "a" VALUES (1)', str(query)) + + def test_replace_update_table(self): + query = Query.update(self.table_a).set("foo", "bar") + query = query.replace_table(self.table_a, self.table_b) + + self.assertEqual('UPDATE "b" SET "foo"=\'bar\'', str(query)) + + def test_replace_update_table_current_table_not_match(self): + query = Query.update(self.table_a).set("foo", "bar") + query = query.replace_table(self.table_c, self.table_b) + + self.assertEqual('UPDATE "a" SET "foo"=\'bar\'', str(query)) + + def test_replace_delete_table(self): + query = Query.from_(self.table_a).delete() + query = query.replace_table(self.table_a, self.table_b) + + self.assertEqual('DELETE FROM "b"', str(query)) + + def test_replace_join_tables(self): + query = ( + Query.from_(self.table_a) + .join(self.table_b) + .on(self.table_a.customer_id == self.table_b.id) + .join(self.table_c) + .on(self.table_b.seller_id == self.table_c.id) + .select(self.table_a.star) + ) + query = query.replace_table(self.table_a, self.table_d) + + self.assertEqual( + 'SELECT "d".* ' + 'FROM "d" ' + 'JOIN "b" ON "d"."customer_id"="b"."id" ' + 'JOIN "c" ON "b"."seller_id"="c"."id"', + str(query), + ) + + def test_replace_filter_tables(self): + query = Query.from_(self.table_a).select(self.table_a.name).where(self.table_a.name == "Mustermann") + query = query.replace_table(self.table_a, self.table_b) + + self.assertEqual('SELECT "name" FROM "b" WHERE "name"=\'Mustermann\'', str(query)) + + def test_replace_having_table(self): + query = ( + Query.from_(self.table_a) + .select(functions.Sum(self.table_a.revenue)) + .groupby(self.table_a.customer) + .having(functions.Sum(self.table_a.revenue) >= 1000) + ) + query = query.replace_table(self.table_a, self.table_b) + + self.assertEqual( + 'SELECT SUM("revenue") ' 'FROM "b" ' 'GROUP BY "customer" ' 'HAVING SUM("revenue")>=1000', + str(query), + ) + + def test_replace_case_table(self): + query = Query.from_(self.table_a).select( + Case() + .when(self.table_a.fname == "Tom", "It was Tom") + .when(self.table_a.fname == "John", "It was John") + .else_("It was someone else.") + .as_("who_was_it") + ) + query = query.replace_table(self.table_a, self.table_b) + + self.assertEqual( + "SELECT CASE " + "WHEN \"fname\"='Tom' THEN 'It was Tom' " + "WHEN \"fname\"='John' THEN 'It was John' " + "ELSE 'It was someone else.' END \"who_was_it\" " + 'FROM "b"', + str(query), + ) + + def test_replace_orderby_table(self): + query = Query.from_(self.table_a).select(self.table_a.customer).orderby(self.table_a.customer) + query = query.replace_table(self.table_a, self.table_b) + + self.assertEqual('SELECT "customer" FROM "b" ORDER BY "customer"', str(query)) + + def test_replace_tuple_table(self): + query = ( + Query.from_(self.table_a) + .select(self.table_a.cost, self.table_a.revenue) + .where((self.table_a.cost, self.table_a.revenue) == Tuple(1, 2)) + ) + + query = query.replace_table(self.table_a, self.table_b) + + # Order is reversed due to lack of right equals method + self.assertEqual( + 'SELECT "cost","revenue" FROM "b" WHERE (1,2)=("cost","revenue")', + str(query), + ) + + def test_is_joined(self): + q = Query.from_(self.table_a).join(self.table_b).on(self.table_a.foo == self.table_b.boo) + + self.assertTrue(q.is_joined(self.table_b)) + self.assertFalse(q.is_joined(self.table_c)) + + +class QueryBuilderTests(unittest.TestCase): + def test_query_builders_have_reference_to_correct_query_class(self): + with self.subTest('QueryBuilder'): + self.assertEqual(Query, QueryBuilder.QUERY_CLS) + + with self.subTest('DropQueryBuilder'): + self.assertEqual(Query, DropQueryBuilder.QUERY_CLS) + + with self.subTest('CreateQueryBuilder'): + self.assertEqual(Query, CreateQueryBuilder.QUERY_CLS) + + with self.subTest('MySQLQueryBuilder'): + self.assertEqual(MySQLQuery, MySQLQueryBuilder.QUERY_CLS) + + with self.subTest('MySQLLoadQueryBuilder'): + self.assertEqual(MySQLQuery, MySQLLoadQueryBuilder.QUERY_CLS) + + with self.subTest('VerticaQueryBuilder'): + self.assertEqual(VerticaQuery, VerticaQueryBuilder.QUERY_CLS) + + with self.subTest('VerticaCreateQueryBuilder'): + self.assertEqual(VerticaQuery, VerticaCreateQueryBuilder.QUERY_CLS) + + with self.subTest('VerticaCopyQueryBuilder'): + self.assertEqual(VerticaQuery, VerticaCopyQueryBuilder.QUERY_CLS) + + with self.subTest('PostgreSQLQueryBuilder'): + self.assertEqual(PostgreSQLQuery, PostgreSQLQueryBuilder.QUERY_CLS) + + with self.subTest('MSSQLQueryBuilder'): + self.assertEqual(MSSQLQuery, MSSQLQueryBuilder.QUERY_CLS) + + with self.subTest('SnowflakeQueryBuilder'): + self.assertEqual(SnowflakeQuery, SnowflakeQueryBuilder.QUERY_CLS) + + with self.subTest('ClickHouseQueryBuilder'): + self.assertEqual(ClickHouseQuery, ClickHouseQueryBuilder.QUERY_CLS) + + with self.subTest('RedShiftQueryBuilder'): + self.assertEqual(RedshiftQuery, RedShiftQueryBuilder.QUERY_CLS) + + with self.subTest('SQLLiteQueryBuilder'): + self.assertEqual(SQLLiteQuery, SQLLiteQueryBuilder.QUERY_CLS) + + with self.subTest('OracleQueryBuilder'): + self.assertEqual(OracleQuery, OracleQueryBuilder.QUERY_CLS) + + def test_pipe(self) -> None: + base_query = Query.from_("test") + + def select(query: QueryBuilder) -> QueryBuilder: + return query.select("test1", "test2") + + def count_group(query: QueryBuilder, *groups) -> QueryBuilder: + return query.groupby(*groups).select(*groups, functions.Count("*")) + + for func, args, kwargs, expected_str in [ + (select, [], {}, 'SELECT "test1","test2" FROM "test"'), + ( + count_group, + ["test1", "test2"], + {}, + 'SELECT "test1","test2",COUNT(*) FROM "test" GROUP BY "test1","test2"', + ), + (count_group, ["test1"], {}, 'SELECT "test1",COUNT(*) FROM "test" GROUP BY "test1"'), + ]: + result_str = str(base_query.pipe(func, *args, **kwargs)) + self.assertEqual(result_str, str(func(base_query, *args, **kwargs))) + self.assertEqual(result_str, expected_str) + + def where_clause(query: QueryBuilder, num_days: int) -> QueryBuilder: + return query.where(Field("date") > functions.Now() - num_days) + + result_str = str(base_query.pipe(select).pipe(where_clause, num_days=1)) + self.assertEqual( + result_str, + str(select(where_clause(base_query, num_days=1))), + ) + self.assertEqual( + result_str, + 'SELECT "test1","test2" FROM "test" WHERE "date">NOW()-1', + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/test_selects.py b/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/test_selects.py new file mode 100644 index 0000000000000000000000000000000000000000..1ce04937492e655db362b7e2a0a6856abf22a48f --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/test_selects.py @@ -0,0 +1,1331 @@ +import unittest +from datetime import date +from enum import Enum + +from pypika import ( + AliasedQuery, + Case, + ClickHouseQuery, + EmptyCriterion, + Field as F, + Index, + MSSQLQuery, + MySQLQuery, + NullValue, + OracleQuery, + Order, + PostgreSQLQuery, + Query, + QueryException, + RedshiftQuery, + SQLLiteQuery, + Table, + Tables, + VerticaQuery, + functions as fn, + SYSTEM_TIME, +) +from pypika.terms import ValueWrapper + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + + +class SelectTests(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_empty_query(self): + q = Query.from_("abc") + + self.assertEqual("", str(q)) + + def test_select_no_from(self): + q = Query.select(1) + + self.assertEqual("SELECT 1", str(q)) + + def test_select_no_with_alias_from(self): + q = Query.select(ValueWrapper(1, "test")) + + self.assertEqual('SELECT 1 "test"', str(q)) + + def test_select_no_from_with_field_raises_exception(self): + with self.assertRaises(QueryException): + Query.select("asdf") + + def test_select__star(self): + q = Query.from_("abc").select("*") + + self.assertEqual('SELECT * FROM "abc"', str(q)) + + def test_select__table_schema(self): + q = Query.from_(Table("abc", "schema1")).select("*") + + self.assertEqual('SELECT * FROM "schema1"."abc"', str(q)) + + def test_select__table_schema_with_multiple_levels_as_tuple(self): + q = Query.from_(Table("abc", ("schema1", "schema2"))).select("*") + + self.assertEqual('SELECT * FROM "schema1"."schema2"."abc"', str(q)) + + def test_select__table_schema_with_multiple_levels_as_list(self): + q = Query.from_(Table("abc", ["schema1", "schema2"])).select("*") + + self.assertEqual('SELECT * FROM "schema1"."schema2"."abc"', str(q)) + + def test_select__star__replacement(self): + q = Query.from_("abc").select("foo").select("*") + + self.assertEqual('SELECT * FROM "abc"', str(q)) + + def test_select__distinct__single(self): + q = Query.from_("abc").select("foo").distinct() + + self.assertEqual('SELECT DISTINCT "foo" FROM "abc"', str(q)) + + def test_select__distinct__multi(self): + q = Query.from_("abc").select("foo", "bar").distinct() + + self.assertEqual('SELECT DISTINCT "foo","bar" FROM "abc"', str(q)) + + def test_select__column__single__str(self): + q = Query.from_("abc").select("foo") + + self.assertEqual('SELECT "foo" FROM "abc"', str(q)) + + def test_select__column__single__alias__str(self): + q = Query.from_(self.table_abc).select(self.table_abc.foo.as_("bar")) + + self.assertEqual('SELECT "foo" "bar" FROM "abc"', str(q)) + + def test_select__column__single__table_alias__str(self): + q = Query.from_(self.table_abc.as_("fizzbuzz")).select(self.table_abc.foo.as_("bar")) + + self.assertEqual('SELECT "foo" "bar" FROM "abc" "fizzbuzz"', str(q)) + + def test_select__column__single__field(self): + t = Table("abc") + q = Query.from_(t).select(t.foo) + + self.assertEqual('SELECT "foo" FROM "abc"', str(q)) + + def test_select__columns__multi__str(self): + q1 = Query.from_("abc").select("foo", "bar") + q2 = Query.from_("abc").select("foo").select("bar") + + self.assertEqual('SELECT "foo","bar" FROM "abc"', str(q1)) + self.assertEqual('SELECT "foo","bar" FROM "abc"', str(q2)) + + def test_select__columns__multi__field(self): + q1 = Query.from_(self.table_abc).select(self.table_abc.foo, self.table_abc.bar) + q2 = Query.from_(self.table_abc).select(self.table_abc.foo).select(self.table_abc.bar) + + self.assertEqual('SELECT "foo","bar" FROM "abc"', str(q1)) + self.assertEqual('SELECT "foo","bar" FROM "abc"', str(q2)) + + def test_select__multiple_tables(self): + q = Query.from_(self.table_abc).select(self.table_abc.foo).from_(self.table_efg).select(self.table_efg.bar) + + self.assertEqual('SELECT "abc"."foo","efg"."bar" FROM "abc","efg"', str(q)) + + def test_select__subquery(self): + subquery = Query.from_(self.table_abc).select("*") + q = Query.from_(subquery).select(subquery.foo, subquery.bar) + + self.assertEqual('SELECT "sq0"."foo","sq0"."bar" ' 'FROM (SELECT * FROM "abc") "sq0"', str(q)) + + def test_select__multiple_subqueries(self): + subquery0 = Query.from_(self.table_abc).select("foo") + subquery1 = Query.from_(self.table_efg).select("bar") + q = Query.from_(subquery0).from_(subquery1).select(subquery0.foo, subquery1.bar) + + self.assertEqual( + 'SELECT "sq0"."foo","sq1"."bar" ' 'FROM (SELECT "foo" FROM "abc") "sq0",' '(SELECT "bar" FROM "efg") "sq1"', + str(q), + ) + + def test_select__nested_subquery(self): + subquery0 = Query.from_(self.table_abc).select("*") + subquery1 = Query.from_(subquery0).select(subquery0.foo, subquery0.bar) + subquery2 = Query.from_(subquery1).select(subquery1.foo) + + q = Query.from_(subquery2).select(subquery2.foo) + + self.assertEqual( + 'SELECT "sq2"."foo" ' + 'FROM (SELECT "sq1"."foo" ' + 'FROM (SELECT "sq0"."foo","sq0"."bar" ' + 'FROM (SELECT * FROM "abc") "sq0") "sq1") "sq2"', + str(q), + ) + + def test_select__no_table(self): + q = Query.select(1, 2, 3) + + self.assertEqual("SELECT 1,2,3", str(q)) + + def test_select_then_add_table(self): + q = Query.select(1).select(2, 3).from_("abc").select("foo") + + self.assertEqual('SELECT 1,2,3,"foo" FROM "abc"', str(q)) + + def test_select_with_limit(self): + q1 = Query.from_("abc").select("foo")[:10] + + self.assertEqual('SELECT "foo" FROM "abc" LIMIT 10', str(q1)) + + def test_select_with_limit_zero(self): + with self.subTest('using python slice'): + q1 = Query.from_("abc").select("foo")[:0] + self.assertEqual('SELECT "foo" FROM "abc" LIMIT 0', str(q1)) + + with self.subTest('using limit method'): + q2 = Query.from_("abc").select("foo").limit(0) + self.assertEqual('SELECT "foo" FROM "abc" LIMIT 0', str(q2)) + + def test_select_with_limit__func(self): + q1 = Query.from_("abc").select("foo").limit(10) + + self.assertEqual('SELECT "foo" FROM "abc" LIMIT 10', str(q1)) + + def test_select_with_offset(self): + q1 = Query.from_("abc").select("foo")[10:] + + self.assertEqual('SELECT "foo" FROM "abc" OFFSET 10', str(q1)) + + def test_select_with_offset__func(self): + q1 = Query.from_("abc").select("foo").offset(10) + + self.assertEqual('SELECT "foo" FROM "abc" OFFSET 10', str(q1)) + + def test_select_with_limit_and_offset(self): + q1 = Query.from_("abc").select("foo")[10:10] + + self.assertEqual('SELECT "foo" FROM "abc" LIMIT 10 OFFSET 10', str(q1)) + + def test_select_with_force_index(self): + q = Query.from_("abc").select("foo").force_index("egg") + + self.assertEqual('SELECT "foo" FROM "abc" FORCE INDEX ("egg")', str(q)) + + def test_select_with_force_index_with_index_object(self): + index = Index("egg") + q = Query.from_("abc").select("foo").force_index(index) + + self.assertEqual('SELECT "foo" FROM "abc" FORCE INDEX ("egg")', str(q)) + + def test_select_with_force_index_multiple_indexes(self): + q = Query.from_("abc").select("foo").force_index("egg", "bacon") + + self.assertEqual('SELECT "foo" FROM "abc" FORCE INDEX ("egg","bacon")', str(q)) + + def test_select_with_force_index_multiple_calls(self): + q = ( + Query.from_("abc") + .select("foo") + .force_index( + "egg", + ) + .force_index("spam") + ) + + self.assertEqual('SELECT "foo" FROM "abc" FORCE INDEX ("egg","spam")', str(q)) + + def test_select_with_use_index(self): + q = Query.from_("abc").select("foo").use_index("egg") + + self.assertEqual('SELECT "foo" FROM "abc" USE INDEX ("egg")', str(q)) + + def test_select_with_use_index_with_index_object(self): + index = Index("egg") + q = Query.from_("abc").select("foo").use_index(index) + + self.assertEqual('SELECT "foo" FROM "abc" USE INDEX ("egg")', str(q)) + + def test_select_with_use_index_multiple_indexes(self): + q = Query.from_("abc").select("foo").use_index("egg", "bacon") + + self.assertEqual('SELECT "foo" FROM "abc" USE INDEX ("egg","bacon")', str(q)) + + def test_select_with_use_index_multiple_calls(self): + q = ( + Query.from_("abc") + .select("foo") + .use_index( + "egg", + ) + .use_index("spam") + ) + + self.assertEqual('SELECT "foo" FROM "abc" USE INDEX ("egg","spam")', str(q)) + + def test_mysql_query_uses_backtick_quote_chars(self): + q = MySQLQuery.from_("abc").select("foo", "bar") + + self.assertEqual("SELECT `foo`,`bar` FROM `abc`", str(q)) + + def test_vertica_query_uses_double_quote_chars(self): + q = VerticaQuery.from_("abc").select("foo", "bar") + + self.assertEqual('SELECT "foo","bar" FROM "abc"', str(q)) + + def test_mssql_query_uses_double_quote_chars(self): + q = MSSQLQuery.from_("abc").select("foo", "bar") + + self.assertEqual('SELECT "foo","bar" FROM "abc"', str(q)) + + def test_oracle_query_uses_no_quote_chars(self): + q = OracleQuery.from_("abc").select("foo", "bar") + + self.assertEqual('SELECT foo,bar FROM abc', str(q)) + + def test_postgresql_query_uses_double_quote_chars(self): + q = PostgreSQLQuery.from_("abc").select("foo", "bar") + + self.assertEqual('SELECT "foo","bar" FROM "abc"', str(q)) + + def test_redshift_query_uses_double_quote_chars(self): + q = RedshiftQuery.from_("abc").select("foo", "bar") + + self.assertEqual('SELECT "foo","bar" FROM "abc"', str(q)) + + def test_table_select_alias(self): + q = self.table_abc.select(1) + + self.assertEqual('SELECT 1 FROM "abc"', str(q)) + self.assertEqual(q, Query.from_("abc").select(1)) + + def test_table_select_alias_with_offset_and_limit(self): + self.assertEqual(self.table_abc.select("foo")[10:10], Query.from_("abc").select("foo")[10:10]) + self.assertEqual( + self.table_abc.select(self.table_abc.foo)[10:10], + Query.from_("abc").select("foo")[10:10], + ) + + def test_temporal_select(self): + t = Table("abc") + + with self.subTest("with system time as of"): + q = Query.from_(t.for_(SYSTEM_TIME.as_of('2020-01-01'))).select("*") + + self.assertEqual('SELECT * FROM "abc" FOR SYSTEM_TIME AS OF \'2020-01-01\'', str(q)) + + with self.subTest("with system time between"): + q = Query.from_(t.for_(SYSTEM_TIME.between('2020-01-01', '2020-02-01'))).select("*") + + self.assertEqual('SELECT * FROM "abc" FOR SYSTEM_TIME BETWEEN \'2020-01-01\' AND \'2020-02-01\'', str(q)) + + with self.subTest("with system time from to"): + q = Query.from_(t.for_(SYSTEM_TIME.from_to('2020-01-01', '2020-02-01'))).select("*") + + self.assertEqual('SELECT * FROM "abc" FOR SYSTEM_TIME FROM \'2020-01-01\' TO \'2020-02-01\'', str(q)) + + with self.subTest("with ALL"): + q = Query.from_(t.for_(SYSTEM_TIME.all_())).select("*") + + self.assertEqual('SELECT * FROM "abc" FOR SYSTEM_TIME ALL', str(q)) + + with self.subTest("with period between"): + q = Query.from_(t.for_(t.valid_period.between('2020-01-01', '2020-02-01'))).select("*") + + self.assertEqual('SELECT * FROM "abc" FOR "valid_period" BETWEEN \'2020-01-01\' AND \'2020-02-01\'', str(q)) + + with self.subTest("with period from to"): + q = Query.from_(t.for_(t.valid_period.from_to('2020-01-01', '2020-02-01'))).select("*") + + self.assertEqual('SELECT * FROM "abc" FOR "valid_period" FROM \'2020-01-01\' TO \'2020-02-01\'', str(q)) + + with self.subTest("with ALL"): + q = Query.from_(t.for_(t.valid_period.all_())).select("*") + + self.assertEqual('SELECT * FROM "abc" FOR "valid_period" ALL', str(q)) + + +class MyEnum(Enum): + STR = "foo" + INT = 0 + BOOL = True + DATE = date(2020, 2, 2) + NONE = None + + +class WhereTests(unittest.TestCase): + t = Table("abc") + t2 = Table("cba") + + def test_where_enum(self): + q1 = Query.from_(self.t).select("*").where(self.t.foo == MyEnum.STR) + q2 = Query.from_(self.t).select("*").where(self.t.foo == MyEnum.INT) + q3 = Query.from_(self.t).select("*").where(self.t.foo == MyEnum.BOOL) + q4 = Query.from_(self.t).select("*").where(self.t.foo == MyEnum.DATE) + q5 = Query.from_(self.t).select("*").where(self.t.foo == MyEnum.NONE) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo"=\'foo\'', str(q1)) + self.assertEqual('SELECT * FROM "abc" WHERE "foo"=0', str(q2)) + self.assertEqual('SELECT * FROM "abc" WHERE "foo"=true', str(q3)) + self.assertEqual('SELECT * FROM "abc" WHERE "foo"=\'2020-02-02\'', str(q4)) + self.assertEqual('SELECT * FROM "abc" WHERE "foo"=null', str(q5)) + + def test_where_field_equals(self): + q1 = Query.from_(self.t).select("*").where(self.t.foo == self.t.bar) + q2 = Query.from_(self.t).select("*").where(self.t.foo.eq(self.t.bar)) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo"="bar"', str(q1)) + self.assertEqual('SELECT * FROM "abc" WHERE "foo"="bar"', str(q2)) + q = self.t.select("*").where(self.t.foo == self.t.bar) + self.assertEqual(q, q1) + + def test_where_field_equals_for_update(self): + q = Query.from_(self.t).select("*").where(self.t.foo == self.t.bar).for_update() + self.assertEqual('SELECT * FROM "abc" WHERE "foo"="bar" FOR UPDATE', str(q)) + + def test_where_field_equals_for_update_nowait(self): + for query_cls in [ + MySQLQuery, + PostgreSQLQuery, + ]: + quote_char = query_cls._builder().QUOTE_CHAR if isinstance(query_cls._builder().QUOTE_CHAR, str) else '"' + q = query_cls.from_(self.t).select("*").where(self.t.foo == self.t.bar).for_update(nowait=True) + self.assertEqual( + 'SELECT * ' + 'FROM {quote_char}abc{quote_char} ' + 'WHERE {quote_char}foo{quote_char}={quote_char}bar{quote_char} ' + 'FOR UPDATE NOWAIT'.format( + quote_char=quote_char, + ), + str(q), + ) + + def test_where_field_equals_for_update_skip_locked(self): + for query_cls in [ + MySQLQuery, + PostgreSQLQuery, + ]: + quote_char = query_cls._builder().QUOTE_CHAR if isinstance(query_cls._builder().QUOTE_CHAR, str) else '"' + q = query_cls.from_(self.t).select("*").where(self.t.foo == self.t.bar).for_update(skip_locked=True) + self.assertEqual( + 'SELECT * ' + 'FROM {quote_char}abc{quote_char} ' + 'WHERE {quote_char}foo{quote_char}={quote_char}bar{quote_char} ' + 'FOR UPDATE SKIP LOCKED'.format( + quote_char=quote_char, + ), + str(q), + ) + + def test_where_field_equals_for_update_of(self): + for query_cls in [ + MySQLQuery, + PostgreSQLQuery, + ]: + quote_char = query_cls._builder().QUOTE_CHAR if isinstance(query_cls._builder().QUOTE_CHAR, str) else '"' + q = query_cls.from_(self.t).select("*").where(self.t.foo == self.t.bar).for_update(of=("abc",)) + self.assertEqual( + 'SELECT * ' + 'FROM {quote_char}abc{quote_char} ' + 'WHERE {quote_char}foo{quote_char}={quote_char}bar{quote_char} ' + 'FOR UPDATE OF {quote_char}abc{quote_char}'.format( + quote_char=quote_char, + ), + str(q), + ) + + def test_where_field_equals_for_update_of_multiple_tables(self): + for query_cls in [ + MySQLQuery, + PostgreSQLQuery, + ]: + q = ( + query_cls.from_(self.t) + .join(self.t2) + .on(self.t.id == self.t2.abc_id) + .select("*") + .where(self.t.foo == self.t.bar) + .for_update(of=("abc", "cba")) + ) + quote_char = query_cls._builder().QUOTE_CHAR if isinstance(query_cls._builder().QUOTE_CHAR, str) else '"' + self.assertIn( + str(q), + [ + 'SELECT * ' + 'FROM {quote_char}abc{quote_char} ' + 'JOIN {quote_char}cba{quote_char} ' + 'ON {quote_char}abc{quote_char}.{quote_char}id{quote_char}=' + '{quote_char}cba{quote_char}.{quote_char}abc_id{quote_char} ' + 'WHERE {quote_char}abc{quote_char}.{quote_char}foo{quote_char}=' + '{quote_char}abc{quote_char}.{quote_char}bar{quote_char} ' + 'FOR UPDATE OF {quote_char}cba{quote_char}, {quote_char}abc{quote_char}'.format( + quote_char=quote_char, + ), + 'SELECT * ' + 'FROM {quote_char}abc{quote_char} ' + 'JOIN {quote_char}cba{quote_char} ' + 'ON {quote_char}abc{quote_char}.{quote_char}id{quote_char}=' + '{quote_char}cba{quote_char}.{quote_char}abc_id{quote_char} ' + 'WHERE {quote_char}abc{quote_char}.{quote_char}foo{quote_char}=' + '{quote_char}abc{quote_char}.{quote_char}bar{quote_char} ' + 'FOR UPDATE OF {quote_char}abc{quote_char}, {quote_char}cba{quote_char}'.format( + quote_char=quote_char, + ), + ], + ) + + def test_where_field_equals_for_update_of_nowait(self): + for query_cls in [ + MySQLQuery, + PostgreSQLQuery, + ]: + q = query_cls.from_(self.t).select("*").where(self.t.foo == self.t.bar).for_update(of=("abc",), nowait=True) + quote_char = query_cls._builder().QUOTE_CHAR if isinstance(query_cls._builder().QUOTE_CHAR, str) else '"' + self.assertEqual( + 'SELECT * ' + 'FROM {quote_char}abc{quote_char} ' + 'WHERE {quote_char}foo{quote_char}={quote_char}bar{quote_char} ' + 'FOR UPDATE OF {quote_char}abc{quote_char} NOWAIT'.format( + quote_char=quote_char, + ), + str(q), + ) + + def test_where_field_equals_for_update_of_skip_locked(self): + for query_cls in [ + MySQLQuery, + PostgreSQLQuery, + ]: + q = ( + query_cls.from_(self.t) + .select("*") + .where(self.t.foo == self.t.bar) + .for_update(of=("abc",), skip_locked=True) + ) + quote_char = query_cls._builder().QUOTE_CHAR if isinstance(query_cls._builder().QUOTE_CHAR, str) else '"' + self.assertEqual( + 'SELECT * ' + 'FROM {quote_char}abc{quote_char} ' + 'WHERE {quote_char}foo{quote_char}={quote_char}bar{quote_char} ' + 'FOR UPDATE OF {quote_char}abc{quote_char} SKIP LOCKED'.format( + quote_char=quote_char, + ), + str(q), + ) + + def test_where_field_equals_for_update_skip_locked_and_of(self): + for query_cls in [ + MySQLQuery, + PostgreSQLQuery, + ]: + q = ( + query_cls.from_(self.t) + .select("*") + .where(self.t.foo == self.t.bar) + .for_update(nowait=False, skip_locked=True, of=("abc",)) + ) + quote_char = query_cls._builder().QUOTE_CHAR if isinstance(query_cls._builder().QUOTE_CHAR, str) else '"' + self.assertEqual( + 'SELECT * ' + 'FROM {quote_char}abc{quote_char} ' + 'WHERE {quote_char}foo{quote_char}={quote_char}bar{quote_char} ' + 'FOR UPDATE OF {quote_char}abc{quote_char} SKIP LOCKED'.format( + quote_char=quote_char, + ), + str(q), + ) + + def test_where_field_equals_where(self): + q = Query.from_(self.t).select("*").where(self.t.foo == 1).where(self.t.bar == self.t.baz) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo"=1 AND "bar"="baz"', str(q)) + + def test_where_field_equals_where_not(self): + q = Query.from_(self.t).select("*").where((self.t.foo == 1).negate()).where(self.t.bar == self.t.baz) + + self.assertEqual('SELECT * FROM "abc" WHERE NOT "foo"=1 AND "bar"="baz"', str(q)) + + def test_where_field_equals_where_two_not(self): + q = Query.from_(self.t).select("*").where((self.t.foo == 1).negate()).where((self.t.bar == self.t.baz).negate()) + + self.assertEqual('SELECT * FROM "abc" WHERE NOT "foo"=1 AND NOT "bar"="baz"', str(q)) + + def test_where_single_quote(self): + q1 = Query.from_(self.t).select("*").where(self.t.foo == "bar'foo") + + self.assertEqual("SELECT * FROM \"abc\" WHERE \"foo\"='bar''foo'", str(q1)) + + def test_where_field_equals_and(self): + q = Query.from_(self.t).select("*").where((self.t.foo == 1) & (self.t.bar == self.t.baz)) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo"=1 AND "bar"="baz"', str(q)) + + def test_where_field_equals_or(self): + q = Query.from_(self.t).select("*").where((self.t.foo == 1) | (self.t.bar == self.t.baz)) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo"=1 OR "bar"="baz"', str(q)) + + def test_where_nested_conditions(self): + q = Query.from_(self.t).select("*").where((self.t.foo == 1) | (self.t.bar == self.t.baz)).where(self.t.baz == 0) + + self.assertEqual('SELECT * FROM "abc" WHERE ("foo"=1 OR "bar"="baz") AND "baz"=0', str(q)) + + def test_where_field_starts_with(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.like("ab%")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" LIKE \'ab%\'', str(q)) + + def test_where_field_contains(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.like("%fg%")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" LIKE \'%fg%\'', str(q)) + + def test_where_field_ends_with(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.like("%yz")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" LIKE \'%yz\'', str(q)) + + def test_where_field_is_n_chars_long(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.like("___")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" LIKE \'___\'', str(q)) + + def test_where_field_does_not_start_with(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.not_like("ab%")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" NOT LIKE \'ab%\'', str(q)) + + def test_where_field_does_not_contain(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.not_like("%fg%")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" NOT LIKE \'%fg%\'', str(q)) + + def test_where_field_does_not_end_with(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.not_like("%yz")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" NOT LIKE \'%yz\'', str(q)) + + def test_where_field_is_not_n_chars_long(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.not_like("___")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" NOT LIKE \'___\'', str(q)) + + def test_where_field_matches_regex(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.regex(r"^b")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" REGEX \'^b\'', str(q)) + + def test_where_field_matches_regexp(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.regexp(r"^b")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" REGEXP \'^b\'', str(q)) + + def test_where_field_matches_rlike(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.rlike(r"^b")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" RLIKE \'^b\'', str(q)) + + def test_ignore_empty_criterion_where(self): + q1 = Query.from_(self.t).select("*").where(EmptyCriterion()) + + self.assertEqual('SELECT * FROM "abc"', str(q1)) + + def test_ignore_empty_criterion_having(self): + q1 = Query.from_(self.t).select("*").having(EmptyCriterion()) + + self.assertEqual('SELECT * FROM "abc"', str(q1)) + + def test_select_with_force_index_and_where(self): + q = Query.from_("abc").select("foo").where(self.t.foo == self.t.bar).force_index("egg") + + self.assertEqual('SELECT "foo" FROM "abc" FORCE INDEX ("egg") WHERE "foo"="bar"', str(q)) + + def test_where_with_multiple_wheres_using_and_case(self): + case_stmt = Case().when(self.t.foo == 'bar', 1).else_(0) + query = Query.from_(self.t).select(case_stmt).where(case_stmt & self.t.blah.isin(['test'])) + + self.assertEqual( + 'SELECT CASE WHEN "foo"=\'bar\' THEN 1 ELSE 0 END FROM "abc" WHERE CASE WHEN "foo"=\'bar\' THEN 1 ELSE 0 ' + 'END AND "blah" IN (\'test\')', + str(query), + ) + + def test_where_with_multiple_wheres_using_or_case(self): + case_stmt = Case().when(self.t.foo == 'bar', 1).else_(0) + query = Query.from_(self.t).select(case_stmt).where(case_stmt | self.t.blah.isin(['test'])) + + self.assertEqual( + 'SELECT CASE WHEN "foo"=\'bar\' THEN 1 ELSE 0 END FROM "abc" WHERE CASE WHEN "foo"=\'bar\' THEN 1 ELSE 0 ' + 'END OR "blah" IN (\'test\')', + str(query), + ) + + +class PreWhereTests(WhereTests): + t = Table("abc") + + def test_prewhere_field_equals(self): + q1 = Query.from_(self.t).select("*").prewhere(self.t.foo == self.t.bar) + q2 = Query.from_(self.t).select("*").prewhere(self.t.foo.eq(self.t.bar)) + + self.assertEqual('SELECT * FROM "abc" PREWHERE "foo"="bar"', str(q1)) + self.assertEqual('SELECT * FROM "abc" PREWHERE "foo"="bar"', str(q2)) + + def test_where_and_prewhere(self): + q = Query.from_(self.t).select("*").prewhere(self.t.foo == self.t.bar).where(self.t.foo == self.t.bar) + + self.assertEqual('SELECT * FROM "abc" PREWHERE "foo"="bar" WHERE "foo"="bar"', str(q)) + + +class GroupByTests(unittest.TestCase): + t = Table("abc") + maxDiff = None + + def test_groupby__single(self): + q = Query.from_(self.t).groupby(self.t.foo).select(self.t.foo) + + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo"', str(q)) + + def test_groupby__multi(self): + q = Query.from_(self.t).groupby(self.t.foo, self.t.bar).select(self.t.foo, self.t.bar) + + self.assertEqual('SELECT "foo","bar" FROM "abc" GROUP BY "foo","bar"', str(q)) + + def test_groupby__count_star(self): + q = Query.from_(self.t).groupby(self.t.foo).select(self.t.foo, fn.Count("*")) + + self.assertEqual('SELECT "foo",COUNT(*) FROM "abc" GROUP BY "foo"', str(q)) + + def test_groupby__count_field(self): + q = Query.from_(self.t).groupby(self.t.foo).select(self.t.foo, fn.Count(self.t.bar)) + + self.assertEqual('SELECT "foo",COUNT("bar") FROM "abc" GROUP BY "foo"', str(q)) + + def test_groupby__count_distinct(self): + q = Query.from_(self.t).groupby(self.t.foo).select(self.t.foo, fn.Count("*").distinct()) + + self.assertEqual('SELECT "foo",COUNT(DISTINCT *) FROM "abc" GROUP BY "foo"', str(q)) + + def test_groupby__sum_distinct(self): + q = Query.from_(self.t).groupby(self.t.foo).select(self.t.foo, fn.Sum(self.t.bar).distinct()) + + self.assertEqual('SELECT "foo",SUM(DISTINCT "bar") FROM "abc" GROUP BY "foo"', str(q)) + + def test_groupby__sum_filter(self): + q = ( + Query.from_(self.t) + .groupby(self.t.foo) + .select(self.t.foo, fn.Sum(self.t.bar).filter(self.t.id.eq(1) & self.t.cid.gt(2))) + ) + + self.assertEqual('SELECT "foo",SUM("bar") FILTER(WHERE "id"=1 AND "cid">2) FROM "abc" GROUP BY "foo"', str(q)) + + def test_groupby__str(self): + q = Query.from_("abc").groupby("foo").select("foo", fn.Count("*").distinct()) + + self.assertEqual('SELECT "foo",COUNT(DISTINCT *) FROM "abc" GROUP BY "foo"', str(q)) + + def test_groupby__int(self): + q = Query.from_("abc").groupby(1).select("foo", fn.Count("*").distinct()) + + self.assertEqual('SELECT "foo",COUNT(DISTINCT *) FROM "abc" GROUP BY 1', str(q)) + + def test_groupby__alias(self): + bar = self.t.bar.as_("bar01") + q = Query.from_(self.t).select(fn.Sum(self.t.foo), bar).groupby(bar) + + self.assertEqual('SELECT SUM("foo"),"bar" "bar01" FROM "abc" GROUP BY "bar01"', str(q)) + + def test_groupby__no_alias(self): + bar = self.t.bar.as_("bar01") + q = Query.from_(self.t).select(fn.Sum(self.t.foo), bar).groupby(bar) + + self.assertEqual( + 'SELECT SUM("foo"),"bar" "bar01" FROM "abc" GROUP BY "bar"', + q.get_sql(groupby_alias=False), + ) + + def test_groupby__no_alias_mssql(self): + bar = self.t.bar.as_("bar01") + q = MSSQLQuery.from_(self.t).select(fn.Sum(self.t.foo), bar).groupby(bar) + + self.assertEqual('SELECT SUM("foo"),"bar" "bar01" FROM "abc" GROUP BY "bar"', str(q)) + + def test_groupby__no_alias_oracle(self): + bar = self.t.bar.as_("bar01") + q = OracleQuery.from_(self.t).select(fn.Sum(self.t.foo), bar).groupby(bar) + + self.assertEqual('SELECT SUM(foo),bar bar01 FROM abc GROUP BY bar', str(q)) + + def test_groupby__alias_platforms(self): + bar = self.t.bar.as_("bar01") + + for query_cls in [ + MySQLQuery, + VerticaQuery, + PostgreSQLQuery, + RedshiftQuery, + ClickHouseQuery, + SQLLiteQuery, + ]: + q = query_cls.from_(self.t).select(fn.Sum(self.t.foo), bar).groupby(bar) + + quote_char = query_cls._builder().QUOTE_CHAR if isinstance(query_cls._builder().QUOTE_CHAR, str) else '"' + + self.assertEqual( + "SELECT " + "SUM({quote_char}foo{quote_char})," + "{quote_char}bar{quote_char}{as_keyword}{quote_char}bar01{quote_char} " + "FROM {quote_char}abc{quote_char} " + "GROUP BY {quote_char}bar01{quote_char}".format( + as_keyword=' AS ' if query_cls is ClickHouseQuery else ' ', quote_char=quote_char + ), + str(q), + ) + + def test_groupby__alias_with_join(self): + table1 = Table("table1", alias="t1") + bar = table1.bar.as_("bar01") + q = Query.from_(self.t).join(table1).on(self.t.id == table1.t_ref).select(fn.Sum(self.t.foo), bar).groupby(bar) + + self.assertEqual( + 'SELECT SUM("abc"."foo"),"t1"."bar" "bar01" FROM "abc" ' + 'JOIN "table1" "t1" ON "abc"."id"="t1"."t_ref" ' + 'GROUP BY "bar01"', + str(q), + ) + + def test_groupby_with_case_uses_the_alias(self): + q = ( + Query.from_(self.t) + .select( + fn.Sum(self.t.foo).as_("bar"), + Case().when(self.t.fname == "Tom", "It was Tom").else_("It was someone else.").as_("who_was_it"), + ) + .groupby(Case().when(self.t.fname == "Tom", "It was Tom").else_("It was someone else.").as_("who_was_it")) + ) + + self.assertEqual( + 'SELECT SUM("foo") "bar",' + "CASE WHEN \"fname\"='Tom' THEN 'It was Tom' " + "ELSE 'It was someone else.' END \"who_was_it\" " + 'FROM "abc" ' + 'GROUP BY "who_was_it"', + str(q), + ) + + def test_mysql_query_uses_backtick_quote_chars(self): + q = MySQLQuery.from_(self.t).groupby(self.t.foo).select(self.t.foo) + + self.assertEqual("SELECT `foo` FROM `abc` GROUP BY `foo`", str(q)) + + def test_vertica_query_uses_double_quote_chars(self): + q = VerticaQuery.from_(self.t).groupby(self.t.foo).select(self.t.foo) + + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo"', str(q)) + + def test_mssql_query_uses_double_quote_chars(self): + q = MSSQLQuery.from_(self.t).groupby(self.t.foo).select(self.t.foo) + + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo"', str(q)) + + def test_oracle_query_uses_no_quote_chars(self): + q = OracleQuery.from_(self.t).groupby(self.t.foo).select(self.t.foo) + + self.assertEqual('SELECT foo FROM abc GROUP BY foo', str(q)) + + def test_postgres_query_uses_double_quote_chars(self): + q = PostgreSQLQuery.from_(self.t).groupby(self.t.foo).select(self.t.foo) + + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo"', str(q)) + + def test_redshift_query_uses_double_quote_chars(self): + q = RedshiftQuery.from_(self.t).groupby(self.t.foo).select(self.t.foo) + + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo"', str(q)) + + def test_group_by__single_with_totals(self): + q = Query.from_(self.t).groupby(self.t.foo).select(self.t.foo).with_totals() + + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo" WITH TOTALS', str(q)) + + def test_groupby__multi_with_totals(self): + q = Query.from_(self.t).groupby(self.t.foo, self.t.bar).select(self.t.foo, self.t.bar).with_totals() + + self.assertEqual('SELECT "foo","bar" FROM "abc" GROUP BY "foo","bar" WITH TOTALS', str(q)) + + +class HavingTests(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_having_greater_than(self): + q = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, fn.Sum(self.table_abc.bar)) + .groupby(self.table_abc.foo) + .having(fn.Sum(self.table_abc.bar) > 1) + ) + + self.assertEqual( + 'SELECT "foo",SUM("bar") FROM "abc" GROUP BY "foo" HAVING SUM("bar")>1', + str(q), + ) + + def test_having_and(self): + q = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, fn.Sum(self.table_abc.bar)) + .groupby(self.table_abc.foo) + .having((fn.Sum(self.table_abc.bar) > 1) & (fn.Sum(self.table_abc.bar) < 100)) + ) + + self.assertEqual( + 'SELECT "foo",SUM("bar") FROM "abc" GROUP BY "foo" HAVING SUM("bar")>1 AND SUM("bar")<100', + str(q), + ) + + def test_having_join_and_equality(self): + q = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.foo) + .select(self.table_abc.foo, fn.Sum(self.table_efg.bar), self.table_abc.buz) + .groupby(self.table_abc.foo) + .having(self.table_abc.buz == "fiz") + .having(fn.Sum(self.table_efg.bar) > 100) + ) + + self.assertEqual( + 'SELECT "abc"."foo",SUM("efg"."bar"),"abc"."buz" FROM "abc" ' + 'JOIN "efg" ON "abc"."foo"="efg"."foo" ' + 'GROUP BY "abc"."foo" ' + 'HAVING "abc"."buz"=\'fiz\' AND SUM("efg"."bar")>100', + str(q), + ) + + def test_mysql_query_uses_backtick_quote_chars(self): + q = ( + MySQLQuery.from_(self.table_abc) + .select(self.table_abc.foo) + .groupby(self.table_abc.foo) + .having(self.table_abc.buz == "fiz") + ) + self.assertEqual("SELECT `foo` FROM `abc` GROUP BY `foo` HAVING `buz`='fiz'", str(q)) + + def test_vertica_query_uses_double_quote_chars(self): + q = ( + VerticaQuery.from_(self.table_abc) + .select(self.table_abc.foo) + .groupby(self.table_abc.foo) + .having(self.table_abc.buz == "fiz") + ) + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo" HAVING "buz"=\'fiz\'', str(q)) + + def test_mssql_query_uses_double_quote_chars(self): + q = ( + MSSQLQuery.from_(self.table_abc) + .select(self.table_abc.foo) + .groupby(self.table_abc.foo) + .having(self.table_abc.buz == "fiz") + ) + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo" HAVING "buz"=\'fiz\'', str(q)) + + def test_oracle_query_uses_no_quote_chars(self): + q = ( + OracleQuery.from_(self.table_abc) + .select(self.table_abc.foo) + .groupby(self.table_abc.foo) + .having(self.table_abc.buz == "fiz") + ) + self.assertEqual('SELECT foo FROM abc GROUP BY foo HAVING buz=\'fiz\'', str(q)) + + def test_postgres_query_uses_double_quote_chars(self): + q = ( + PostgreSQLQuery.from_(self.table_abc) + .select(self.table_abc.foo) + .groupby(self.table_abc.foo) + .having(self.table_abc.buz == "fiz") + ) + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo" HAVING "buz"=\'fiz\'', str(q)) + + def test_redshift_query_uses_double_quote_chars(self): + q = ( + RedshiftQuery.from_(self.table_abc) + .select(self.table_abc.foo) + .groupby(self.table_abc.foo) + .having(self.table_abc.buz == "fiz") + ) + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo" HAVING "buz"=\'fiz\'', str(q)) + + +class OrderByTests(unittest.TestCase): + t = Table("abc") + + def test_orderby_single_field(self): + q = Query.from_(self.t).orderby(self.t.foo).select(self.t.foo) + + self.assertEqual('SELECT "foo" FROM "abc" ORDER BY "foo"', str(q)) + + def test_orderby_multi_fields(self): + q = Query.from_(self.t).orderby(self.t.foo, self.t.bar).select(self.t.foo, self.t.bar) + + self.assertEqual('SELECT "foo","bar" FROM "abc" ORDER BY "foo","bar"', str(q)) + + def test_orderby_single_str(self): + q = Query.from_("abc").orderby("foo").select("foo") + + self.assertEqual('SELECT "foo" FROM "abc" ORDER BY "foo"', str(q)) + + def test_orderby_asc(self): + q = Query.from_(self.t).orderby(self.t.foo, order=Order.asc).select(self.t.foo) + + self.assertEqual('SELECT "foo" FROM "abc" ORDER BY "foo" ASC', str(q)) + + def test_orderby_desc(self): + q = Query.from_(self.t).orderby(self.t.foo, order=Order.desc).select(self.t.foo) + + self.assertEqual('SELECT "foo" FROM "abc" ORDER BY "foo" DESC', str(q)) + + def test_orderby_no_alias(self): + bar = self.t.bar.as_("bar01") + q = Query.from_(self.t).select(fn.Sum(self.t.foo), bar).orderby(bar) + + self.assertEqual( + 'SELECT SUM("foo"),"bar" "bar01" FROM "abc" ORDER BY "bar"', + q.get_sql(orderby_alias=False), + ) + + def test_orderby_alias(self): + bar = self.t.bar.as_("bar01") + q = Query.from_(self.t).select(fn.Sum(self.t.foo), bar).orderby(bar) + + self.assertEqual('SELECT SUM("foo"),"bar" "bar01" FROM "abc" ORDER BY "bar01"', q.get_sql()) + + +class AliasTests(unittest.TestCase): + t = Table("abc") + + def test_table_field(self): + q = Query.from_(self.t).select(self.t.foo.as_("bar")) + + self.assertEqual('SELECT "foo" "bar" FROM "abc"', str(q)) + + def test_table_field__multi(self): + q = Query.from_(self.t).select(self.t.foo.as_("bar"), self.t.fiz.as_("buz")) + + self.assertEqual('SELECT "foo" "bar","fiz" "buz" FROM "abc"', str(q)) + + def test_arithmetic_function(self): + q = Query.from_(self.t).select((self.t.foo + self.t.bar).as_("biz")) + + self.assertEqual('SELECT "foo"+"bar" "biz" FROM "abc"', str(q)) + + def test_functions_using_as(self): + q = Query.from_(self.t).select(fn.Count("*").as_("foo")) + + self.assertEqual('SELECT COUNT(*) "foo" FROM "abc"', str(q)) + + def test_functions_using_constructor_param(self): + q = Query.from_(self.t).select(fn.Count("*", alias="foo")) + + self.assertEqual('SELECT COUNT(*) "foo" FROM "abc"', str(q)) + + def test_function_using_as_nested(self): + """ + We don't show aliases of fields that are arguments of a function. + """ + q = Query.from_(self.t).select(fn.Sqrt(fn.Count("*").as_("foo")).as_("bar")) + + self.assertEqual('SELECT SQRT(COUNT(*)) "bar" FROM "abc"', str(q)) + + def test_functions_using_constructor_param_nested(self): + """ + We don't show aliases of fields that are arguments of a function. + """ + q = Query.from_(self.t).select(fn.Sqrt(fn.Count("*", alias="foo"), alias="bar")) + + self.assertEqual('SELECT SQRT(COUNT(*)) "bar" FROM "abc"', str(q)) + + def test_ignored_in_where(self): + q = Query.from_(self.t).select(self.t.foo).where(self.t.foo.as_("bar") == 1) + + self.assertEqual('SELECT "foo" FROM "abc" WHERE "foo"=1', str(q)) + + def test_ignored_in_groupby(self): + q = Query.from_(self.t).select(self.t.foo).groupby(self.t.foo.as_("bar")) + + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo"', str(q)) + + def test_ignored_in_orderby(self): + q = Query.from_(self.t).select(self.t.foo).orderby(self.t.foo.as_("bar")) + + self.assertEqual('SELECT "foo" FROM "abc" ORDER BY "foo"', str(q)) + + def test_ignored_in_criterion(self): + c = self.t.foo.as_("bar") == 1 + + self.assertEqual('"foo"=1', str(c)) + + def test_ignored_in_criterion_comparison(self): + c = self.t.foo.as_("bar") == self.t.fiz.as_("buz") + + self.assertEqual('"foo"="fiz"', str(c)) + + def test_ignored_in_field_inside_case(self): + q = Query.from_(self.t).select(Case().when(self.t.foo == 1, "a").else_(self.t.bar.as_('"buz"'))) + + self.assertEqual('SELECT CASE WHEN "foo"=1 THEN \'a\' ELSE "bar" END FROM "abc"', str(q)) + + def test_case_using_as(self): + q = Query.from_(self.t).select(Case().when(self.t.foo == 1, "a").else_("b").as_("bar")) + + self.assertEqual( + 'SELECT CASE WHEN "foo"=1 THEN \'a\' ELSE \'b\' END "bar" FROM "abc"', + str(q), + ) + + def test_case_using_constructor_param(self): + q = Query.from_(self.t).select(Case(alias="bar").when(self.t.foo == 1, "a").else_("b")) + + self.assertEqual( + 'SELECT CASE WHEN "foo"=1 THEN \'a\' ELSE \'b\' END "bar" FROM "abc"', + str(q), + ) + + def test_select__multiple_tables(self): + table_abc, table_efg = Table("abc", alias="q0"), Table("efg", alias="q1") + + q = Query.from_(table_abc).select(table_abc.foo).from_(table_efg).select(table_efg.bar) + + self.assertEqual('SELECT "q0"."foo","q1"."bar" FROM "abc" "q0","efg" "q1"', str(q)) + + def test_use_aliases_in_groupby_and_orderby(self): + table_abc = Table("abc", alias="q0") + + my_foo = table_abc.foo.as_("my_foo") + q = Query.from_(table_abc).select(my_foo, table_abc.bar).groupby(my_foo).orderby(my_foo) + + self.assertEqual( + 'SELECT "q0"."foo" "my_foo","q0"."bar" ' 'FROM "abc" "q0" ' 'GROUP BY "my_foo" ' 'ORDER BY "my_foo"', + str(q), + ) + + def test_table_with_schema_and_alias(self): + table = Table("abc", schema="schema", alias="alias") + self.assertEqual('"schema"."abc" "alias"', str(table)) + + def test_null_value_with_alias(self): + q = Query.select(NullValue().as_("abcdef")) + + self.assertEqual('SELECT NULL "abcdef"', str(q)) + + +class SubqueryTests(unittest.TestCase): + maxDiff = None + + table_abc, table_efg, table_hij = Tables("abc", "efg", "hij") + + def test_where__in(self): + q = ( + Query.from_(self.table_abc) + .select("*") + .where( + self.table_abc.foo.isin( + Query.from_(self.table_efg).select(self.table_efg.foo).where(self.table_efg.bar == 0) + ) + ) + ) + + self.assertEqual( + 'SELECT * FROM "abc" WHERE "foo" IN (SELECT "foo" FROM "efg" WHERE "bar"=0)', + str(q), + ) + + def test_where__in_nested(self): + q = Query.from_(self.table_abc).select("*").where(self.table_abc.foo).isin(self.table_efg.select("*")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" IN (SELECT * FROM "efg")', str(q)) + + def test_join(self): + subquery = Query.from_("efg").select("fiz", "buz").where(F("buz") == 0) + + q = ( + Query.from_(self.table_abc) + .join(subquery) + .on(self.table_abc.bar == subquery.buz) + .select(self.table_abc.foo, subquery.fiz) + ) + + self.assertEqual( + 'SELECT "abc"."foo","sq0"."fiz" FROM "abc" ' + 'JOIN (SELECT "fiz","buz" FROM "efg" WHERE "buz"=0) "sq0" ' + 'ON "abc"."bar"="sq0"."buz"', + str(q), + ) + + def test_select_subquery(self): + subq = Query.from_(self.table_efg).select("fizzbuzz").where(self.table_efg.id == 1) + + q = Query.from_(self.table_abc).select("foo", "bar").select(subq) + + self.assertEqual( + 'SELECT "foo","bar",(SELECT "fizzbuzz" FROM "efg" WHERE "id"=1) ' 'FROM "abc"', + str(q), + ) + + def test_select_subquery_with_alias(self): + subq = Query.from_(self.table_efg).select("fizzbuzz").where(self.table_efg.id == 1) + + q = Query.from_(self.table_abc).select("foo", "bar").select(subq.as_("sq")) + + self.assertEqual( + 'SELECT "foo","bar",(SELECT "fizzbuzz" FROM "efg" WHERE "id"=1) "sq" ' 'FROM "abc"', + str(q), + ) + + def test_where__equality(self): + subquery = Query.from_("efg").select("fiz").where(F("buz") == 0) + query = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, self.table_abc.bar) + .where(self.table_abc.bar == subquery) + ) + + self.assertEqual( + 'SELECT "foo","bar" FROM "abc" ' 'WHERE "bar"=(SELECT "fiz" FROM "efg" WHERE "buz"=0)', + str(query), + ) + + def test_select_from_nested_query(self): + subquery = Query.from_(self.table_abc).select( + self.table_abc.foo, + self.table_abc.bar, + (self.table_abc.fizz + self.table_abc.buzz).as_("fizzbuzz"), + ) + + query = Query.from_(subquery).select(subquery.foo, subquery.bar, subquery.fizzbuzz) + + self.assertEqual( + 'SELECT "sq0"."foo","sq0"."bar","sq0"."fizzbuzz" ' + "FROM (" + 'SELECT "foo","bar","fizz"+"buzz" "fizzbuzz" ' + 'FROM "abc"' + ') "sq0"', + str(query), + ) + + def test_select_from_nested_query_with_join(self): + subquery1 = ( + Query.from_(self.table_abc) + .select( + self.table_abc.foo, + fn.Sum(self.table_abc.fizz + self.table_abc.buzz).as_("fizzbuzz"), + ) + .groupby(self.table_abc.foo) + ) + + subquery2 = Query.from_(self.table_efg).select( + self.table_efg.foo.as_("foo_two"), + self.table_efg.bar, + ) + + query = ( + Query.from_(subquery1) + .select(subquery1.foo, subquery1.fizzbuzz) + .join(subquery2) + .on(subquery1.foo == subquery2.foo_two) + .select(subquery2.foo_two, subquery2.bar) + ) + + self.assertEqual( + "SELECT " + '"sq0"."foo","sq0"."fizzbuzz",' + '"sq1"."foo_two","sq1"."bar" ' + "FROM (" + "SELECT " + '"foo",SUM("fizz"+"buzz") "fizzbuzz" ' + 'FROM "abc" ' + 'GROUP BY "foo"' + ') "sq0" JOIN (' + "SELECT " + '"foo" "foo_two","bar" ' + 'FROM "efg"' + ') "sq1" ON "sq0"."foo"="sq1"."foo_two"', + str(query), + ) + + def test_from_subquery_without_alias(self): + subquery = Query.from_(self.table_efg).select( + self.table_efg.base_id.as_("x"), self.table_efg.fizz, self.table_efg.buzz + ) + + test_query = Query.from_(subquery).select(subquery.x, subquery.fizz, subquery.buzz) + + self.assertEqual( + 'SELECT "sq0"."x","sq0"."fizz","sq0"."buzz" ' + "FROM (" + 'SELECT "base_id" "x","fizz","buzz" FROM "efg"' + ') "sq0"', + str(test_query), + ) + + def test_join_query_with_alias(self): + subquery = ( + Query.from_(self.table_efg) + .select( + self.table_efg.base_id.as_("x"), + self.table_efg.fizz, + self.table_efg.buzz, + ) + .as_("subq") + ) + + test_query = Query.from_(subquery).select(subquery.x, subquery.fizz, subquery.buzz) + + self.assertEqual( + 'SELECT "subq"."x","subq"."fizz","subq"."buzz" ' + "FROM (" + 'SELECT "base_id" "x","fizz","buzz" FROM "efg"' + ') "subq"', + str(test_query), + ) + + def test_with(self): + sub_query = Query.from_(self.table_efg).select("fizz") + test_query = Query.with_(sub_query, "an_alias").from_(AliasedQuery("an_alias")).select("*") + + self.assertEqual( + 'WITH an_alias AS (SELECT "fizz" FROM "efg") SELECT * FROM an_alias', + str(test_query), + ) + + def test_join_with_with(self): + sub_query = Query.from_(self.table_efg).select("fizz") + test_query = ( + Query.with_(sub_query, "an_alias") + .from_(self.table_abc) + .join(AliasedQuery("an_alias")) + .on(AliasedQuery("an_alias").fizz == self.table_abc.buzz) + .select("*") + ) + self.assertEqual( + 'WITH an_alias AS (SELECT "fizz" FROM "efg") ' + 'SELECT * FROM "abc" JOIN an_alias ON "an_alias"."fizz"="abc"."buzz"', + str(test_query), + ) + + def test_select_from_with_returning(self): + sub_query = PostgreSQLQuery.into(self.table_abc).insert(1).returning('*') + test_query = Query.with_(sub_query, "an_alias").from_(AliasedQuery("an_alias")).select("*") + self.assertEqual( + 'WITH an_alias AS (INSERT INTO "abc" VALUES (1) RETURNING *) SELECT * FROM an_alias', str(test_query) + ) + + +class QuoteTests(unittest.TestCase): + def test_extraneous_quotes(self): + t1 = Table("table1", alias="t1") + t2 = Table("table2", alias="t2") + + query = Query.from_(t1).join(t2).on(t1.Value.between(t2.start, t2.end)).select(t1.value) + + self.assertEqual( + "SELECT t1.value FROM table1 t1 " "JOIN table2 t2 ON t1.Value " "BETWEEN t2.start AND t2.end", + query.get_sql(quote_char=None), + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/test_tables.py b/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/test_tables.py new file mode 100644 index 0000000000000000000000000000000000000000..f43e740915f642d29ce7497c36e3b68f01311016 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/test_tables.py @@ -0,0 +1,186 @@ +# from pypika.terms import ValueWrapper, SystemTimeValue +import unittest + +from pypika import Database, Dialects, Schema, SQLLiteQuery, Table, Tables, Query, SYSTEM_TIME + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + + +class TableStructureTests(unittest.TestCase): + def test_table_sql(self): + table = Table("test_table") + + self.assertEqual('"test_table"', str(table)) + + def test_table_with_alias(self): + table = Table("test_table").as_("my_table") + + self.assertEqual('"test_table" "my_table"', table.get_sql(with_alias=True, quote_char='"')) + + def test_schema_table_attr(self): + table = Schema("x_schema").test_table + + self.assertEqual('"x_schema"."test_table"', str(table)) + + def test_table_with_schema_arg(self): + table = Table("test_table", schema=Schema("x_schema")) + + self.assertEqual('"x_schema"."test_table"', str(table)) + + def test_database_schema_table_attr(self): + table = Database("x_db").x_schema.test_table + + self.assertEqual('"x_db"."x_schema"."test_table"', str(table)) + + def test_table_with_schema_and_schema_parent_arg(self): + table = Table("test_table", schema=Schema("x_schema", parent=Database("x_db"))) + + self.assertEqual('"x_db"."x_schema"."test_table"', str(table)) + + def test_table_for_system_time_sql(self): + with self.subTest("with between criterion"): + table = Table("test_table").for_(SYSTEM_TIME.between('2020-01-01', '2020-02-01')) + + self.assertEqual('"test_table" FOR SYSTEM_TIME BETWEEN \'2020-01-01\' AND \'2020-02-01\'', str(table)) + + with self.subTest("with as of criterion"): + table = Table("test_table").for_(SYSTEM_TIME.as_of('2020-01-01')) + + self.assertEqual('"test_table" FOR SYSTEM_TIME AS OF \'2020-01-01\'', str(table)) + + with self.subTest("with from to criterion"): + table = Table("test_table").for_(SYSTEM_TIME.from_to('2020-01-01', '2020-02-01')) + + self.assertEqual('"test_table" FOR SYSTEM_TIME FROM \'2020-01-01\' TO \'2020-02-01\'', str(table)) + + def test_table_for_period_sql(self): + with self.subTest("with between criterion"): + table = Table("test_table") + table = table.for_(table.valid_period.between('2020-01-01', '2020-02-01')) + + self.assertEqual('"test_table" FOR "valid_period" BETWEEN \'2020-01-01\' AND \'2020-02-01\'', str(table)) + + with self.subTest("with as of criterion"): + table = Table("test_table") + table = table.for_(table.valid_period.as_of('2020-01-01')) + + self.assertEqual('"test_table" FOR "valid_period" AS OF \'2020-01-01\'', str(table)) + + with self.subTest("with from to criterion"): + table = Table("test_table") + table = table.for_(table.valid_period.from_to('2020-01-01', '2020-02-01')) + + self.assertEqual('"test_table" FOR "valid_period" FROM \'2020-01-01\' TO \'2020-02-01\'', str(table)) + + +class TableEqualityTests(unittest.TestCase): + def test_tables_equal_by_name(self): + t1 = Table("t") + t2 = Table("t") + + self.assertEqual(t1, t2) + + def test_tables_equal_by_schema_and_name(self): + t1 = Table("t", schema="a") + t2 = Table("t", schema="a") + + self.assertEqual(t1, t2) + + def test_tables_equal_by_schema_and_name_using_schema(self): + a = Schema("a") + t1 = Table("t", schema=a) + t2 = Table("t", schema=a) + + self.assertEqual(t1, t2) + + def test_tables_equal_by_schema_and_name_using_schema_with_parent(self): + parent = Schema("parent") + a = Schema("a", parent=parent) + t1 = Table("t", schema=a) + t2 = Table("t", schema=a) + + self.assertEqual(t1, t2) + + def test_tables_not_equal_by_schema_and_name_using_schema_with_different_parents( + self, + ): + parent = Schema("parent") + a = Schema("a", parent=parent) + t1 = Table("t", schema=a) + t2 = Table("t", schema=Schema("a")) + + self.assertNotEqual(t1, t2) + + def test_tables_not_equal_with_different_schemas(self): + t1 = Table("t", schema="a") + t2 = Table("t", schema="b") + + self.assertNotEqual(t1, t2) + + def test_tables_not_equal_with_different_names(self): + t1 = Table("t", schema="a") + t2 = Table("q", schema="a") + + self.assertNotEqual(t1, t2) + + def test_many_tables_with_alias(self): + tables_data = [("table1", "t1"), ("table2", "t2"), ("table3", "t3")] + tables = Tables(*tables_data) + for el in tables: + self.assertIsNotNone(el.alias) + + def test_many_tables_without_alias(self): + tables_data = ["table1", "table2", "table3"] + tables = Tables(*tables_data) + for el in tables: + self.assertIsNone(el.alias) + + def test_many_tables_with_or_not_alias(self): + tables_data = [("table1", "t1"), ("table2"), "table3"] + tables = Tables(*tables_data) + for i in range(len(tables)): + if isinstance(tables_data[i], tuple): + self.assertIsNotNone(tables[i].alias) + else: + self.assertIsNone(tables[i].alias) + + +class TableDialectTests(unittest.TestCase): + def test_table_with_default_query_cls(self): + table = Table("abc") + q = table.select("1") + self.assertIs(q.dialect, None) + + def test_table_with_dialect_query_cls(self): + table = Table("abc", query_cls=SQLLiteQuery) + q = table.select("1") + self.assertIs(q.dialect, Dialects.SQLLITE) + + def test_table_factory_with_default_query_cls(self): + table = Query.Table("abc") + q = table.select("1") + self.assertIs(q.dialect, None) + + def test_table_factory_with_dialect_query_cls(self): + table = SQLLiteQuery.Table("abc") + q = table.select("1") + self.assertIs(q.dialect, Dialects.SQLLITE) + + def test_make_tables_factory_with_default_query_cls(self): + t1, t2 = Query.Tables("abc", "def") + q1 = t1.select("1") + q2 = t2.select("2") + self.assertIs(q1.dialect, None) + self.assertIs(q2.dialect, None) + + def test_make_tables_factory_with_dialect_query_cls(self): + t1, t2 = SQLLiteQuery.Tables("abc", "def") + q1 = t1.select("1") + q2 = t2.select("2") + self.assertIs(q1.dialect, Dialects.SQLLITE) + self.assertIs(q2.dialect, Dialects.SQLLITE) + + def test_table_with_bad_query_cls(self): + with self.assertRaises(TypeError): + Table("abc", query_cls=object) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/test_terms.py b/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/test_terms.py new file mode 100644 index 0000000000000000000000000000000000000000..4c7590dfce129bac97a3f30de99b596cc746c893 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/test_terms.py @@ -0,0 +1,82 @@ +from unittest import TestCase + +from pypika import Query, Table, Field +from pypika.terms import AtTimezone + + +class FieldAliasTests(TestCase): + t = Table("test", alias="crit") + + def test_when_alias_specified(self): + c1 = Field("foo", alias="bar") + self.assertEqual('bar', str(c1.alias)) + + c1 = Field("foo").as_("bar") + self.assertEqual('bar', str(c1.alias)) + + +class FieldInitTests(TestCase): + def test_init_with_str_table(self): + test_table_name = "test_table" + field = Field(name="name", table=test_table_name) + self.assertEqual(field.table, Table(name=test_table_name)) + + +class FieldHashingTests(TestCase): + def test_tabled_eq_fields_equally_hashed(self): + client_name1 = Field(name="name", table=Table("clients")) + client_name2 = Field(name="name", table=Table("clients")) + self.assertTrue(hash(client_name1) == hash(client_name2)) + + def test_tabled_ne_fields_differently_hashed(self): + customer_name = Field(name="name", table=Table("customers")) + client_name = Field(name="name", table=Table("clients")) + self.assertTrue(hash(customer_name) != hash(client_name)) + + def test_non_tabled_aliased_eq_fields_equally_hashed(self): + self.assertTrue(hash(Field(name="A", alias="my_a")) == hash(Field(name="A", alias="my_a"))) + + def test_non_tabled_aliased_ne_fields_differently_hashed(self): + self.assertTrue(hash(Field(name="A", alias="my_a1")) != hash(Field(name="A", alias="my_a2"))) + + def test_non_tabled_eq_fields_equally_hashed(self): + self.assertTrue(hash(Field(name="A")) == hash(Field(name="A"))) + + def test_non_tabled_ne_fields_differently_hashed(self): + self.assertTrue(hash(Field(name="A")) != hash(Field(name="B"))) + + +class AtTimezoneTests(TestCase): + def test_when_interval_not_specified(self): + query = Query.from_("customers").select(AtTimezone("date", "US/Eastern")) + self.assertEqual('SELECT "date" AT TIME ZONE \'US/Eastern\' FROM "customers"', str(query)) + + def test_when_interval_specified(self): + query = Query.from_("customers").select(AtTimezone("date", "-06:00", interval=True)) + self.assertEqual( + 'SELECT "date" AT TIME ZONE INTERVAL \'-06:00\' FROM "customers"', + str(query), + ) + + def test_when_alias_specified(self): + query = Query.from_("customers").select(AtTimezone("date", "US/Eastern", alias="alias1")) + self.assertEqual( + 'SELECT "date" AT TIME ZONE \'US/Eastern\' "alias1" FROM "customers"', + str(query), + ) + + def test_passes_kwargs_to_field_get_sql(self): + customers = Table("customers") + accounts = Table("accounts") + query = ( + Query.from_(customers) + .join(accounts) + .on(customers.account_id == accounts.account_id) + .select(AtTimezone(customers.date, "US/Eastern", alias="alias1")) + ) + + self.assertEqual( + 'SELECT "customers"."date" AT TIME ZONE \'US/Eastern\' "alias1" ' + 'FROM "customers" JOIN "accounts" ON "customers"."account_id"="accounts"."account_id"', + query.get_sql(with_namespace=True), + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/test_tuples.py b/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/test_tuples.py new file mode 100644 index 0000000000000000000000000000000000000000..c8ebc8e41b0115777f8b3c8cb01c04e62f13ee18 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/test_tuples.py @@ -0,0 +1,162 @@ +import unittest + +from pypika import ( + Array, + Bracket, + Query, + PostgreSQLQuery, + Table, + Tables, + Tuple, +) +from pypika.functions import Coalesce, NullIf, Sum +from pypika.terms import Field + + +class TupleTests(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_tuple_equality_tuple_on_both(self): + q = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, self.table_abc.bar) + .where(Tuple(self.table_abc.foo, self.table_abc.bar) == Tuple(1, 2)) + ) + + self.assertEqual('SELECT "foo","bar" FROM "abc" ' 'WHERE ("foo","bar")=(1,2)', str(q)) + + def test_tuple_equality_tuple_on_left(self): + q = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, self.table_abc.bar) + .where(Tuple(self.table_abc.foo, self.table_abc.bar) == (1, 2)) + ) + + self.assertEqual('SELECT "foo","bar" FROM "abc" ' 'WHERE ("foo","bar")=(1,2)', str(q)) + + def test_tuple_equality_tuple_on_right(self): + q = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, self.table_abc.bar) + .where((self.table_abc.foo, self.table_abc.bar) == Tuple(1, 2)) + ) + + # Order is reversed due to lack of right equals method + self.assertEqual('SELECT "foo","bar" FROM "abc" ' 'WHERE (1,2)=("foo","bar")', str(q)) + + def test_tuple_in_using_python_tuples(self): + q = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, self.table_abc.bar) + .where(Tuple(self.table_abc.foo, self.table_abc.bar).isin([(1, 1), (2, 2), (3, 3)])) + ) + + self.assertEqual( + 'SELECT "foo","bar" FROM "abc" ' 'WHERE ("foo","bar") IN ((1,1),(2,2),(3,3))', + str(q), + ) + + def test_tuple_in_using_pypika_tuples(self): + q = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, self.table_abc.bar) + .where(Tuple(self.table_abc.foo, self.table_abc.bar).isin([Tuple(1, 1), Tuple(2, 2), Tuple(3, 3)])) + ) + + self.assertEqual( + 'SELECT "foo","bar" FROM "abc" ' 'WHERE ("foo","bar") IN ((1,1),(2,2),(3,3))', + str(q), + ) + + def test_tuple_in_using_mixed_tuples(self): + q = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, self.table_abc.bar) + .where(Tuple(self.table_abc.foo, self.table_abc.bar).isin([(1, 1), Tuple(2, 2), (3, 3)])) + ) + + self.assertEqual( + 'SELECT "foo","bar" FROM "abc" ' 'WHERE ("foo","bar") IN ((1,1),(2,2),(3,3))', + str(q), + ) + + def test_tuples_in_join(self): + query = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .select("*") + .where(Tuple(self.table_abc.foo, self.table_efg.bar).isin([(1, 1), Tuple(2, 2), (3, 3)])) + ) + + self.assertEqual( + 'SELECT * FROM "abc" JOIN "efg" ON "abc"."foo"="efg"."bar" ' + 'WHERE ("abc"."foo","efg"."bar") IN ((1,1),(2,2),(3,3))', + str(query), + ) + + def test_render_alias_in_array_sql(self): + tb = Table("tb") + + q = Query.from_(tb).select(Tuple(tb.col).as_("different_name")) + self.assertEqual(str(q), 'SELECT ("col") "different_name" FROM "tb"') + + def test_tuple_is_aggregate(self): + with self.subTest('None if single argument returns None for is_aggregate'): + self.assertEqual(None, Tuple(0).is_aggregate) + self.assertEqual(None, Tuple(Coalesce('col')).is_aggregate) + + with self.subTest('None if multiple arguments all return None for is_aggregate'): + self.assertEqual(None, Tuple(0, 'a').is_aggregate) + self.assertEqual(None, Tuple(Coalesce('col'), NullIf('col2', 0)).is_aggregate) + + with self.subTest('True if single argument returns True for is_aggregate'): + self.assertEqual(True, Tuple(Sum('col')).is_aggregate) + + with self.subTest('True if multiple arguments return True for is_aggregate'): + self.assertEqual(True, Tuple(Sum('col'), Sum('col2')).is_aggregate) + + with self.subTest('True when mix of arguments returning None and True for is_aggregate'): + self.assertEqual(True, Tuple(Coalesce('col'), Coalesce('col2', 0), Sum('col3')).is_aggregate) + + with self.subTest('False when one of the arguments returns False for is_aggregate'): + self.assertEqual(False, Tuple(Field('col1'), Sum('col2')).is_aggregate) + + +class ArrayTests(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_array_general(self): + query = Query.from_(self.table_abc).select(Array(1, "a", ["b", 2, 3])) + + self.assertEqual("SELECT [1,'a',['b',2,3]] FROM \"abc\"", str(query)) + + def test_empty_psql_array(self): + query = PostgreSQLQuery.from_(self.table_abc).select(Array()) + + self.assertEqual("SELECT '{}' FROM \"abc\"", str(query)) + + def test_psql_array_general(self): + query = PostgreSQLQuery.from_(self.table_abc).select(Array(1, Array(2, 2, 2), 3)) + + self.assertEqual("SELECT ARRAY[1,ARRAY[2,2,2],3] FROM \"abc\"", str(query)) + + def test_render_alias_in_array_sql(self): + tb = Table("tb") + + q = Query.from_(tb).select(Array(tb.col).as_("different_name")) + self.assertEqual(str(q), 'SELECT ["col"] "different_name" FROM "tb"') + + +class BracketTests(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_arithmetic_with_brackets(self): + q = Query.from_(self.table_abc).select(Bracket(self.table_abc.foo / 2) / 2) + + self.assertEqual('SELECT ("foo"/2)/2 FROM "abc"', str(q)) + + def test_arithmetic_with_brackets_and_alias(self): + q = Query.from_(self.table_abc).select(Bracket(self.table_abc.foo / 2).as_("alias")) + + self.assertEqual('SELECT ("foo"/2) "alias" FROM "abc"', str(q)) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/test_updates.py b/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/test_updates.py new file mode 100644 index 0000000000000000000000000000000000000000..fb9d714dbcb8213b4bda04bf7b8dd9b2419410ec --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/test_updates.py @@ -0,0 +1,162 @@ +import unittest + +from pypika import AliasedQuery, PostgreSQLQuery, Query, SQLLiteQuery, SYSTEM_TIME, Table + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + +from pypika.terms import Star + + +class UpdateTests(unittest.TestCase): + table_abc = Table("abc") + table_def = Table("def") + + def test_empty_query(self): + q = Query.update("abc") + + self.assertEqual("", str(q)) + + def test_omit_where(self): + q = Query.update(self.table_abc).set("foo", "bar") + + self.assertEqual('UPDATE "abc" SET "foo"=\'bar\'', str(q)) + + def test_single_quote_escape_in_set(self): + q = Query.update(self.table_abc).set("foo", "bar'foo") + + self.assertEqual("UPDATE \"abc\" SET \"foo\"='bar''foo'", str(q)) + + def test_update__table_schema(self): + table = Table("abc", "schema1") + q = Query.update(table).set(table.foo, 1).where(table.foo == 0) + + self.assertEqual('UPDATE "schema1"."abc" SET "foo"=1 WHERE "foo"=0', str(q)) + + def test_update_with_none(self): + q = Query.update("abc").set("foo", None) + self.assertEqual('UPDATE "abc" SET "foo"=null', str(q)) + + def test_update_with_join(self): + q = ( + Query.update(self.table_abc) + .join(self.table_def) + .on(self.table_def.abc_id == self.table_abc.id) + .set(self.table_abc.lname, self.table_def.lname) + ) + self.assertEqual( + 'UPDATE "abc" JOIN "def" ON "def"."abc_id"="abc"."id" SET "lname"="def"."lname"', + str(q), + ) + + def test_update_with_limit(self): + q = Query.update(self.table_abc).set(self.table_abc.lname, "test").limit(1) + self.assertEqual('UPDATE "abc" SET "lname"=\'test\' LIMIT 1', str(q)) + + def test_update_from(self): + from_table = Table('from_table') + + q = Query.update(self.table_abc).set(self.table_abc.lname, from_table.long_name).from_(from_table) + self.assertEqual('UPDATE "abc" SET "lname"="from_table"."long_name" FROM "from_table"', str(q)) + + def test_update_from_with_where(self): + from_table = Table('from_table') + + q = ( + Query.update(self.table_abc) + .set(self.table_abc.lname, from_table.long_name) + .from_(from_table) + .where(self.table_abc.fname.eq(from_table.full_name)) + ) + self.assertEqual( + 'UPDATE "abc" SET "lname"="from_table"."long_name" FROM "from_table" ' + 'WHERE "abc"."fname"="from_table"."full_name"', + str(q), + ) + + def test_update_with_statement(self): + table_efg = Table('efg') + + sub_query = Query.from_(table_efg).select("fizz") + an_alias = AliasedQuery("an_alias") + + q = ( + Query.with_(sub_query, "an_alias") + .update(self.table_abc) + .from_(an_alias) + .set(self.table_abc.lname, an_alias.long_name) + .where(self.table_abc.comp.eq(an_alias.alias_comp)) + ) + self.assertEqual( + 'WITH an_alias AS (SELECT "fizz" FROM "efg") ' + 'UPDATE "abc" SET "lname"="an_alias"."long_name" FROM an_alias ' + 'WHERE "abc"."comp"="an_alias"."alias_comp"', + str(q), + ) + + def test_for_portion(self): + with self.subTest("with system time"): + q = Query.update(self.table_abc.for_portion(SYSTEM_TIME.from_to('2020-01-01', '2020-02-01'))).set( + "foo", "bar" + ) + + self.assertEqual( + 'UPDATE "abc" FOR PORTION OF SYSTEM_TIME FROM \'2020-01-01\' TO \'2020-02-01\' SET "foo"=\'bar\'', + str(q), + ) + + with self.subTest("with column"): + q = Query.update( + self.table_abc.for_portion(self.table_abc.valid_period.from_to('2020-01-01', '2020-02-01')) + ).set("foo", "bar") + + self.assertEqual( + 'UPDATE "abc" FOR PORTION OF "valid_period" FROM \'2020-01-01\' TO \'2020-02-01\' SET "foo"=\'bar\'', + str(q), + ) + + +class PostgresUpdateTests(unittest.TestCase): + table_abc = Table("abc") + + def test_update_returning_str(self): + q = PostgreSQLQuery.update(self.table_abc).where(self.table_abc.foo == 0).set("foo", "bar").returning("id") + + self.assertEqual('UPDATE "abc" SET "foo"=\'bar\' WHERE "foo"=0 RETURNING "abc"."id"', str(q)) + + def test_update_returning(self): + q = ( + PostgreSQLQuery.update(self.table_abc) + .where(self.table_abc.foo == 0) + .set("foo", "bar") + .returning(self.table_abc.id) + ) + + self.assertEqual('UPDATE "abc" SET "foo"=\'bar\' WHERE "foo"=0 RETURNING "abc"."id"', str(q)) + + def test_update_returning_from_different_tables(self): + table_bcd = Table('bcd') + + q = ( + PostgreSQLQuery.update(self.table_abc) + .from_(table_bcd) + .set(self.table_abc.lname, table_bcd.long_name) + .returning(self.table_abc.id, table_bcd.fname) + ) + self.assertEqual( + 'UPDATE "abc" SET "lname"="bcd"."long_name" FROM "bcd" RETURNING "abc"."id","bcd"."fname"', str(q) + ) + + def test_update_returning_star(self): + q = PostgreSQLQuery.update(self.table_abc).where(self.table_abc.foo == 0).set("foo", "bar").returning(Star()) + + self.assertEqual('UPDATE "abc" SET "foo"=\'bar\' WHERE "foo"=0 RETURNING *', str(q)) + + +class SQLLiteUpdateTests(unittest.TestCase): + table_abc = Table("abc") + + def test_update_with_bool(self): + q = SQLLiteQuery.update(self.table_abc).set(self.table_abc.foo, True) + + self.assertEqual('UPDATE "abc" SET "foo"=1', str(q)) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/test_utils.py b/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/test_utils.py new file mode 100644 index 0000000000000000000000000000000000000000..bb9a9b1c68fe8671989f7c49f9db90e389d06f59 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pypika/tests/test_utils.py @@ -0,0 +1,24 @@ +import unittest + +from pypika import utils + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + + +class ImmutabilityTests(unittest.TestCase): + def test_raise_attribute_error_for_deepcopy(self): + with self.assertRaises(AttributeError): + utils.raise_attribute_for_copy("Test", "__deepcopy__") + + def test_raise_attribute_error_for_getstate(self): + with self.assertRaises(AttributeError): + utils.raise_attribute_for_copy("Test", "__getstate__") + + def test_raise_attribute_error_for_setstate(self): + with self.assertRaises(AttributeError): + utils.raise_attribute_for_copy("Test", "__setstate__") + + def test_raise_attribute_error_for_getnewargs(self): + with self.assertRaises(AttributeError): + utils.raise_attribute_for_copy("Test", "__getnewargs__") diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pyproject.toml b/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pyproject.toml new file mode 100644 index 0000000000000000000000000000000000000000..dcc56baede23e3571b336625e695c466ab833a56 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/pyproject.toml @@ -0,0 +1,22 @@ +[tool.black] +line-length = 120 +skip-string-normalization = true +target-version = ['py38', 'py39', 'py310', 'py311'] +force-exclude = ''' +( + /( + \.eggs # exclude a few common directories in the + | \.git # root of the project + | \.hg + | \.mypy_cache + | \.tox + | \.venv + | _build + | buck-out + | build + | dist + | docs + )/ + | setup.py +) +''' diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/setup.cfg b/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/setup.cfg new file mode 100644 index 0000000000000000000000000000000000000000..46084aaf2ca9e95b2f9bb7680e432e637fc3ed90 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/setup.cfg @@ -0,0 +1,16 @@ +[bumpversion] +current_version = 0.48.9 +commit = True +tag = True + +[bumpversion:file:pypika/__init__.py] +search = __version__ = "{current_version}" +replace = __version__ = "{new_version}" + +[bdist_wheel] +universal = 1 + +[flake8] +exclude = docs, .git, __pycache__ +max-line-length = 120 +per-file-ignores = __init__.py:F401 diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/setup.py b/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/setup.py new file mode 100644 index 0000000000000000000000000000000000000000..41cce7d742df3e33e8d76f267d77df486f69249a --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/setup.py @@ -0,0 +1,81 @@ +import ast + +from setuptools import setup + + +def readme(): + with open('README.rst', 'rb') as f: + return f.read().decode('UTF-8') + + +def version(): + path = 'pypika/__init__.py' + with open(path, 'r') as file: + t = compile(file.read(), path, 'exec', ast.PyCF_ONLY_AST) + for node in (n for n in t.body if isinstance(n, ast.Assign)): + if len(node.targets) == 1: + name = node.targets[0] + if isinstance(name, ast.Name) and name.id in ('__version__', '__version_info__', 'VERSION'): + v = node.value + if isinstance(v, ast.Str): + return v.s + + if isinstance(v, ast.Tuple): + r = [] + for e in v.elts: + if isinstance(e, ast.Str): + r.append(e.s) + elif isinstance(e, ast.Num): + r.append(str(e.n)) + return '.'.join(r) + + +setup( + # Application name: + name="PyPika", + + # Version number: + version=version(), + + # Application author details: + author="Timothy Heys", + author_email="theys@kayak.com", + + # License + license='Apache License Version 2.0', + + # Packages + packages=["pypika", "pypika.clickhouse"], + + # Include additional files into the package + package_data={"pypika": ["py.typed"]}, + include_package_data=True, + + install_requires=[], + + # Details + url="https://github.com/kayak/pypika", + + description="A SQL query builder API for Python", + long_description=readme(), + + classifiers=[ + 'License :: OSI Approved :: Apache Software License', + 'Development Status :: 5 - Production/Stable', + 'Intended Audience :: Developers', + 'Programming Language :: Python :: 3', + 'Programming Language :: PL/SQL', + 'Topic :: Software Development :: Libraries :: Python Modules', + 'Topic :: Scientific/Engineering :: Information Analysis', + 'Topic :: Scientific/Engineering :: Mathematics', + 'Operating System :: POSIX', + 'Operating System :: MacOS :: MacOS X', + 'Operating System :: Microsoft :: Windows', + ], + keywords=('pypika python query builder querybuilder sql mysql postgres psql oracle vertica aggregated ' + 'relational database rdbms business analytics bi data science analysis pandas ' + 'orm object mapper'), + + # Dependent packages (distributions) + test_suite="pypika.tests", +) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/tox.ini b/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/tox.ini new file mode 100644 index 0000000000000000000000000000000000000000..2f0e6893243b1ca2ead6a12825e9014dc66364ce --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/tests/trusted/tox.ini @@ -0,0 +1,16 @@ +[tox] +envlist = py38,py39,py310,py311,pypy3 + +[testenv] +description = testing against {basepython} +deps = -r requirements-dev.txt +commands = + coverage run + coverage xml + +[gh-actions] +python = + 3.8: py38 + 3.9: py39 + 3.10: py310 + 3.11: py311 diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/validation/canaries/first-hunk-only.sh b/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/validation/canaries/first-hunk-only.sh new file mode 100644 index 0000000000000000000000000000000000000000..db738672f28e40d90ff5839750f9fba61750ab43 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/validation/canaries/first-hunk-only.sh @@ -0,0 +1,23 @@ +#!/bin/bash +set -Eeuo pipefail +cd /testbed/repo +cat > /tmp/openenv-reference.diff <<'OPENENV_PARTIAL' +diff --git a/pypika/clickhouse/array.py b/pypika/clickhouse/array.py +index 21d2148b4bb0389126619823d5f1f2a780b24c80..67929f1664e8a3d63d5b1a83cdf66ae590c53ce4 100644 +--- a/pypika/clickhouse/array.py ++++ b/pypika/clickhouse/array.py +@@ -85,10 +85,10 @@ + class Empty(_AbstractArrayFunction): + @classmethod + def clickhouse_function(cls) -> str: +- return "Empty" ++ return "empty" + + + class Length(_AbstractArrayFunction): + @classmethod + def clickhouse_function(cls) -> str: +- return "count" ++ return "length" +OPENENV_PARTIAL +/usr/bin/git -c core.hooksPath=/dev/null -c core.fsmonitor=false apply --whitespace=nowarn /tmp/openenv-reference.diff diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/validation/canaries/original-bug.sh b/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/validation/canaries/original-bug.sh new file mode 100644 index 0000000000000000000000000000000000000000..927547df786c86ab3bb5eeb917a31e0fa1895f8b --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/validation/canaries/original-bug.sh @@ -0,0 +1,3 @@ +#!/bin/bash +set -Eeuo pipefail +: diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/validation/openenv.json b/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/validation/openenv.json new file mode 100644 index 0000000000000000000000000000000000000000..a13b3c577df494f6c894584d2b608ab051ebc44f --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__44udpu9o/validation/openenv.json @@ -0,0 +1,27 @@ +{ + "canaries": "validation/canaries", + "profile": "harbor-semantic-v1", + "requires_credentials": false, + "resources": { + "cpu": 2, + "disk_mb": 16384, + "episode_timeout_s": 1800, + "memory_mb": 8192 + }, + "reward": { + "floor_margin": 0.1, + "oracle_tolerance": 0, + "range": [ + 0, + 1 + ] + }, + "reward_key": "reward", + "types": { + "tags": [ + "swe", + "python", + "mutation-repair" + ] + } +} diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/LICENSE.source b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/LICENSE.source new file mode 100644 index 0000000000000000000000000000000000000000..9c8f3ea0871e0bfe81da0fa6e7c1d7d156dc380e --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/LICENSE.source @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. \ No newline at end of file diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/adapter.json b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/adapter.json new file mode 100644 index 0000000000000000000000000000000000000000..31c40e98c872a80c0d49ecf769f357171765fa34 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/adapter.json @@ -0,0 +1,135 @@ +{ + "canary_selection": "Fixed first provided gold hunk only when at least2hunks exist; strict subset, never reward-selected. Single-hunk task original-bug canary is explicitly NOP-equivalent and adds no signal beyond floor_gap.", + "collector_sha256": "352e555112f2de8a1393f939903e4971c9ace0e944843762b707a725c5c72481", + "dependency_installation_pinned": false, + "dependency_setup_sha256": "ed8673d02878e91c7ae0b51b9178d6a15792b79c6992f800c14a941d95242392", + "gold_patch_sha256": "3672c31c3989ee8e031268fb8637ab05f027f0f540dfb14d46d70290eb11da29", + "hostile_code_isolation_established": false, + "known_wrong_semantic_implementations": 0, + "native_inventory_sha256": "f8e4b9b9d71848a0e5381d9d040b40a33c84f16bae601c84ed0a0f3dff7074a5", + "new_files_deletions_and_executable_modes_supported": true, + "official_profile": { + "eval_sets": [], + "profile_class": "Pypika1c9646f0", + "profile_lines": [ + 736, + 739 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "upstream_repo": "kayak/pypika" + }, + "original_bug_canary_nop_equivalent": true, + "original_bug_runtime_wrongness_established": false, + "partial_repair_canary": true, + "partial_repair_sha256": "459630b1292b204fbddfd52a7840853ec037061e776a843ab0654bfd16a05e9b", + "partial_repair_wrongness_established": false, + "positive_approval_policy": "All original strict presence/identity/no-skip/no-error/exit checks retained", + "private_checker_sha256": "f0a641064b725415e23a0221bb53c90446d7efcb7f9ece5ede93a220d18dd9e7", + "private_checker_version": "matched-failure-precedence-v2", + "provided_original_bug_control": true, + "repo_url": "https://github.com/swesmith/kayak__pypika.1c9646f0.git", + "runtime_image": null, + "runtime_ready": false, + "runtime_recipe": { + "dependency_installation_pinned": false, + "official_install_cmds": [ + "python -m pip install -e ." + ], + "official_pytest_argv": [ + "pytest", + "--disable-warnings", + "--color=no", + "--tb=no", + "--verbose" + ], + "official_test_command": "source /opt/miniconda3/bin/activate; conda activate testbed; pytest --disable-warnings --color=no --tb=no --verbose", + "operator_test_runner_prerequisites": [ + "python -m pip install pytest==8.4.2" + ], + "operator_test_runner_reason": "The official profile invokes pytest, but the common tools runtime does not provide it; pinned separately from source-native project requirements.", + "panel_normalization": "Override project addopts only to execute the exact frozen native panels; add JUnit output, preserve official pytest options and all selectors.", + "python_version": "3.10", + "source_bound_test_dependency_cmds": [ + "python -m pip install parameterized==0.7.0" + ], + "test_dependency_source_sha256": { + "requirements-dev.txt": "10f4ba7b19a73950d28fd7403d7e1d1b1fe2ccc4f49516974f47199d2965f23d", + "setup.py": "f8bad274588a22e65764d8cf9fb2be5aa6fcfaf3bf861d71e5f751105898845a", + "tox.ini": "c2d7205d0ac93e9c9e80dc5d24f0a826a6781f587a33ea722ea621f9e2ccd0ea" + } + }, + "runtime_resource_review_required": false, + "schema": "python-git-patch-jobs-v1", + "source_base_commit": "99d75158b583a09e5ececd35cd34434333891b4e", + "source_completion_sha256": "1b13f8eb2e187083b24685745fc3baac193003f89a0c062e7e3cf37351ad0314", + "source_index_sha256": "e856874b9410fce9f3bfea52c8c482e84b3e43942d87517f8b55f0034bd40f6f", + "source_pr_url": null, + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:kayak__pypika.1c9646f0.combine_module__9lguwrtp", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "6a742f12bfa386994289ec8b75824663d8ee4b15", + "instruction_sha256": "4436415fb11227783fa942df8cbda0d0457fee39317eaf2b34167e3f10b6505a", + "is_fork": true, + "learner_path": "tasks/29738fa7e9c9b474ac0f655e/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "actual_upstream_url": "https://raw.githubusercontent.com/kayak/pypika/1c9646f0a019a167c32b649b6f5e6423c5ba2c9b/LICENSE.txt", + "reviewed": true, + "sha256": "c5accbbd8546e94c34aed24afe689a617627d18eed5a6c48277e48db57c23851", + "spdx": "Apache-2.0", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/kayak__pypika.1c9646f0/99d75158b583a09e5ececd35cd34434333891b4e/LICENSE.txt" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "patch_sha256": "ddaa8ae3604c51b91242aaace3a255b354eedac3a450beaa22388ba8b58f6fa3", + "provenance_path": "tasks/29738fa7e9c9b474ac0f655e/source-proof.json", + "repository_lineage": [ + "swesmith/kayak__pypika.1c9646f0", + "kayak/pypika" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "99d75158b583a09e5ececd35cd34434333891b4e", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "19f4e0bcfc7008f30945795dee7958402a48fd9e", + "source_kind": "mutation", + "source_repo": "swesmith/kayak__pypika.1c9646f0", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "kayak__pypika.1c9646f0.combine_module__9lguwrtp", + "task_sha256": "183c48cd0a4916d3df9342b0eed3c6dcc419af25fe6db0a8d3dc0952c4d96d20", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "kayak/pypika", + "usage": "quarantine_only" + }, + "source_repo": "swesmith/kayak__pypika.1c9646f0", + "symlink_submodule_changes_supported": false, + "task_id": "kayak__pypika.1c9646f0.combine_module__9lguwrtp", + "transfer": "index-independent-worktree-to-Git-binary-patch", + "transfer_path": "/testbed/submission.patch", + "upstream_repo": "kayak/pypika" +} diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/dependency-setup.sh b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/dependency-setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e1a28db070ebf088cec3ef817cf2dc8715091ac2 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/dependency-setup.sh @@ -0,0 +1,9 @@ +#!/bin/bash +set -Eeuo pipefail +source /opt/miniconda3/bin/activate +conda activate testbed +cd /testbed/repo +python -c 'import sys; assert sys.version_info[:2] == (3, 10)' +python -m pip install pytest==8.4.2 +python -m pip install -e . +python -m pip install parameterized==0.7.0 diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/environment/Dockerfile b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..a59b58c2ea8217c78c1e39b4678f93c8c0023bcd --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/environment/Dockerfile @@ -0,0 +1,3 @@ +# Runtime is selected only by an independently qualified immutable amd64 receipt. +FROM ubuntu:22.04 +RUN false diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/instruction.md b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..33839d5140618593e7c4caa6d1618a83552b4a90 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/instruction.md @@ -0,0 +1,36 @@ +ClickHouse functions generating incorrect SQL syntax + +#### Description + +Several ClickHouse-specific functions are producing malformed SQL output. The generated queries contain syntax errors that prevent them from executing properly. + +#### Steps/Code to Reproduce + +```python +from pypika.clickhouse import MultiSearchAny, ToFixedString +from pypika import Field + +# MultiSearchAny generates incorrect function name and syntax +field = Field('text') +patterns = ['hello', 'world'] +search = MultiSearchAny(field, patterns) +print(search.get_sql()) +# Expected: multiSearchAny(text,['hello','world']) +# Actual: singleSearchAll(text,{patterns}) + +# ToFixedString generates incorrect parameter order and values +field = Field('name') +fixed_str = ToFixedString(field, 10) +print(fixed_str.get_sql()) +# Expected: toFixedString(name,10) +# Actual: toFixedString(11,name) +``` + +The issues affect multiple ClickHouse functions including: +- MultiSearchAny/MultiMatchAny using wrong function names +- ToFixedString with incorrect parameter order and length calculation +- Search string functions with malformed SQL formatting + +## Environment + +The repository is at `/testbed/repo`. Its dependencies, including pytest, are installed in the `testbed` conda environment, which comes first on PATH. If `python -m pytest` reports that pytest is missing, use the full interpreter path: `/opt/miniconda3/envs/testbed/bin/python -m pytest `. Don't install packages: the tests need nothing else, and the sandbox may have no network access. diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/metadata.json b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/metadata.json new file mode 100644 index 0000000000000000000000000000000000000000..c2b76718a7dc2042f3e2d605bc6538fa02dec61c --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/metadata.json @@ -0,0 +1,1276 @@ +{ + "all_runtime_and_training_flags": false, + "official_profile": { + "eval_sets": [], + "profile_class": "Pypika1c9646f0", + "profile_lines": [ + 736, + 739 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "upstream_repo": "kayak/pypika" + }, + "source_healthy_reference_proof": { + "FAIL_TO_PASS": [ + "pypika/tests/clickhouse/test_array.py::TestArray::test_get_sql_3__toFixedString_mogwai_10_toFixedString_mono_10_toFixedString_bonobo_10_arr", + "pypika/tests/clickhouse/test_array.py::TestHasAny::test_get_sql_2_hasAny_bands_toFixedString_port_royal_20_toFixedString_hammock_20_", + "pypika/tests/clickhouse/test_condition.py::TestIfCondition::test_get_sql_0", + "pypika/tests/clickhouse/test_condition.py::TestIfCondition::test_get_sql_1", + "pypika/tests/clickhouse/test_condition.py::TestMultiIfCondition::test_get_sql_0", + "pypika/tests/clickhouse/test_condition.py::TestMultiIfCondition::test_get_sql_1", + "pypika/tests/clickhouse/test_nullable_arg.py::TestSearchString::test_get_sql_1", + "pypika/tests/clickhouse/test_search_string.py::TestMultiSearch::test_multi_search_string_0", + "pypika/tests/clickhouse/test_search_string.py::TestMultiSearch::test_multi_search_string_1", + "pypika/tests/clickhouse/test_type_conversion.py::TestToFixedString::test_get_sql_with_table" + ], + "PASS_TO_PASS": [ + "pypika/tests/clickhouse/test_array.py::TestArray::test_get_sql_0__ridley_scott_jimi_hendrix_", + "pypika/tests/clickhouse/test_array.py::TestArray::test_get_sql_1__1_2_3_4_", + "pypika/tests/clickhouse/test_array.py::TestArray::test_get_sql_2__toInt64_1_toInt64_2_toInt64_3_toInt64_4_", + "pypika/tests/clickhouse/test_array.py::TestHasAny::test_get_sql_0_hasAny_mental_abilities_physical_abilities_", + "pypika/tests/clickhouse/test_array.py::TestHasAny::test_get_sql_1_hasAny_1_2_3_4_3_", + "pypika/tests/clickhouse/test_array.py::TestLength::test_get_sql_0_length_tags_", + "pypika/tests/clickhouse/test_array.py::TestLength::test_get_sql_1_length_1_2_3_", + "pypika/tests/clickhouse/test_array.py::TestEmpty::test_get_sql_0_empty_tags_", + "pypika/tests/clickhouse/test_array.py::TestEmpty::test_get_sql_1_empty_1_2_3_", + "pypika/tests/clickhouse/test_array.py::TestNotEmpty::test_get_sql_0_notEmpty_tags_", + "pypika/tests/clickhouse/test_array.py::TestNotEmpty::test_get_sql_1_notEmpty_1_2_3_", + "pypika/tests/clickhouse/test_dates_and_times.py::TestFormatDateTime::test_get_sql_0", + "pypika/tests/clickhouse/test_dates_and_times.py::TestFormatDateTime::test_get_sql_1", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_00", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_01", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_02", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_03", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_04", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_05", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_06", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_07", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_08", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_09", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_10", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_11", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_12", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_13", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_14", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_15", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_16", + "pypika/tests/clickhouse/test_dates_and_times.py::TestToYYYYMM::test_get_sql", + "pypika/tests/clickhouse/test_nullable_arg.py::TestSearchString::test_get_sql_0", + "pypika/tests/clickhouse/test_search_string.py::TestSearchString::test_search_string_0", + "pypika/tests/clickhouse/test_search_string.py::TestSearchString::test_search_string_1", + "pypika/tests/clickhouse/test_search_string.py::TestSearchString::test_search_string_2", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_00_toString_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_01_toInt8_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_02_toInt16_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_03_toInt32_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_04_toInt64_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_05_toUInt8_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_06_toUInt16_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_07_toUInt32_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_08_toUInt64_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_09_toFloat32_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_10_toFloat64_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_11_toFloat64_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_12_toDate_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_13_toDateTime_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_14_toFixedString_field_name_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_00_toString_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_01_toInt8_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_02_toInt16_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_03_toInt32_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_04_toInt64_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_05_toUInt8_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_06_toUInt16_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_07_toUInt32_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_08_toUInt64_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_09_toFloat32_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_10_toFloat64_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_11_toFloat64_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_12_toDate_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_13_toDateTime_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_14_toFixedString_100_100_", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseQueryTests::test_use_AS_keyword_for_alias", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseQueryTests::test_use_FINAL_keyword", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseQueryTests::test_use_SAMPLE_keyword", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseQueryTests::test_use_SAMPLE_with_offset_keyword", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDeleteTests::test_omit_where", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDeleteTests::test_omit_where__table_schema", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDeleteTests::test_where_field_equals", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseUpdateTests::test_update", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDropQuery::test_drop_database", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDropQuery::test_drop_dictionary", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDropQuery::test_drop_other", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDropQuery::test_drop_table", + "pypika/tests/dialects/test_clickhouse.py::DistinctOnTests::test_distinct_on", + "pypika/tests/dialects/test_clickhouse.py::LimitByTests::test_limit_by", + "pypika/tests/dialects/test_clickhouse.py::LimitByTests::test_limit_offset0_by", + "pypika/tests/dialects/test_clickhouse.py::LimitByTests::test_limit_offset_by", + "pypika/tests/dialects/test_clickhouse.py::LimitByTests::test_rename_table", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_distinct_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_groupby_alias_False_does_not_group_by_alias_when_subqueries_are_present", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_groupby_alias_False_does_not_group_by_alias_with_standard_query", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_limit", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_limit_with_offset", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_normal_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_offset", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_distinct_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_percent_invalid_range", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_percent_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_select_non_int", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_with_ties_select", + "pypika/tests/dialects/test_mysql.py::SelectTests::test_distinct_select", + "pypika/tests/dialects/test_mysql.py::SelectTests::test_modifier_select", + "pypika/tests/dialects/test_mysql.py::SelectTests::test_multiple_modifier_select", + "pypika/tests/dialects/test_mysql.py::SelectTests::test_normal_select", + "pypika/tests/dialects/test_mysql.py::UpdateTests::test_conflict_handlers_update", + "pypika/tests/dialects/test_mysql.py::UpdateTests::test_on_duplicate_key_ignore_update", + "pypika/tests/dialects/test_mysql.py::UpdateTests::test_on_duplicate_key_update_update", + "pypika/tests/dialects/test_mysql.py::UpdateTests::test_update", + "pypika/tests/dialects/test_mysql.py::LoadCSVTests::test_load_from_file", + "pypika/tests/dialects/test_mysql.py::TableTests::test_create_table", + "pypika/tests/dialects/test_mysql.py::TableTests::test_drop_table", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_fetch_next_method_deprecated", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_groupby_alias_False_does_not_group_by_alias_when_subqueries_are_present", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_groupby_alias_False_does_not_group_by_alias_with_standard_query", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_limit_offset_query", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_limit_query", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_offset_query", + "pypika/tests/dialects/test_postgresql.py::InsertTests::test_array_keyword", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_alias_set_correctly", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_json_value_from_array_num", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_json_value_from_array_str", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_json_value_from_dict", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_json_value_from_dict_recursive", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_json_value_by_index", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_json_value_by_key", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_path_json_value", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_path_text_value", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_text_value_by_index", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_text_value_by_key", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contained_by_using_list_arg", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contained_by_using_str_arg", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contained_by_with_complex_criterion", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contains_for_field", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contains_for_json", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_has_any_keys", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_has_key", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_has_keys", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_subnet_contains_inet", + "pypika/tests/dialects/test_postgresql.py::DistinctOnTests::test_distinct_on", + "pypika/tests/dialects/test_postgresql.py::ArrayTests::test_array_syntax", + "pypika/tests/dialects/test_postgresql.py::ArrayTests::test_render_alias_in_array_sql", + "pypika/tests/dialects/test_postgresql.py::ReturningClauseTests::test_no_queryexception_if_returning_used_on_valid_query_type", + "pypika/tests/dialects/test_postgresql.py::ReturningClauseTests::test_queryexception_if_returning_used_on_invalid_query", + "pypika/tests/dialects/test_postgresql.py::ReturningClauseTests::test_return_field_from_join_table", + "pypika/tests/dialects/test_postgresql.py::ReturningClauseTests::test_returning_from_missing_table_raises_queryexception", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_dont_use_double_quotes_on_create_queries", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_dont_use_double_quotes_on_drop_queries", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_dont_use_double_quotes_on_joining_queries", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_use_double_quotes_on_alias_but_not_on_terms", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_use_double_quotes_on_alias_but_not_on_terms_with_joins", + "pypika/tests/dialects/test_sqllite.py::SelectTests::test_bool_false_as_zero", + "pypika/tests/dialects/test_sqllite.py::SelectTests::test_bool_true_as_one", + "pypika/tests/dialects/test_sqllite.py::ReplaceTests::test_insert_or_replace", + "pypika/tests/dialects/test_sqllite.py::ReplaceTests::test_normal_replace", + "pypika/tests/dialects/test_sqllite.py::ReplaceTests::test_replace_subquery", + "pypika/tests/dialects/test_vertica.py::VerticaQueryTests::test_delete_query_with_hint", + "pypika/tests/dialects/test_vertica.py::VerticaQueryTests::test_insert_query_with_hint", + "pypika/tests/dialects/test_vertica.py::VerticaQueryTests::test_select_query_with_hint", + "pypika/tests/dialects/test_vertica.py::VerticaQueryTests::test_update_query_with_hint", + "pypika/tests/dialects/test_vertica.py::CopyCSVTests::test_copy_from_file", + "pypika/tests/dialects/test_vertica.py::CreateTemporaryTableTests::test_create_local_table_without_temporary_raises_error", + "pypika/tests/dialects/test_vertica.py::CreateTemporaryTableTests::test_create_local_temporary_table", + "pypika/tests/dialects/test_vertica.py::CreateTemporaryTableTests::test_create_table_preserve_rows_without_temporary_raises_error", + "pypika/tests/dialects/test_vertica.py::CreateTemporaryTableTests::test_create_temporary_table_preserve_rows", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__agg_case_criterion_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__agg_case_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__agg_func_arithmetic_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__agg_func_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__case_mixed_constant_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__case_mixed_else_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__case_with_field_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__case_with_single_aggregate_field_in_one_criterion_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__constant_arithmetic_is_aggregate_none", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__constant_is_aggregate_none", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__field_arithmetic_constant_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__field_arithmetic_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__field_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__func_arithmetic_constant_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__mixed_case_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__mixed_func_arithmetic_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__negative_agg_func_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__non_aggregate_function_with_aggregated_arg", + "pypika/tests/test_aggregate.py::IsAggregateTests::test_complicated", + "pypika/tests/test_analytic_queries.py::RankTests::test_avg", + "pypika/tests/test_analytic_queries.py::RankTests::test_count_range_between_unbounded_preceeding_current_row", + "pypika/tests/test_analytic_queries.py::RankTests::test_dense_rank", + "pypika/tests/test_analytic_queries.py::RankTests::test_empty_over", + "pypika/tests/test_analytic_queries.py::RankTests::test_filter", + "pypika/tests/test_analytic_queries.py::RankTests::test_filter_quote_table_in_filter", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value_ignore_nulls", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value_ignore_nulls_first", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value_multi_argument", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value_range_between_x_preceeding_unbounded_following", + "pypika/tests/test_analytic_queries.py::RankTests::test_lag_generates_correct_sql", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value_ignore_nulls", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value_multi_argument", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value_rows_between_current_row_unbounded_following", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value_rows_between_current_row_unbounded_following_ignore_nulls", + "pypika/tests/test_analytic_queries.py::RankTests::test_lead_generates_correct_sql", + "pypika/tests/test_analytic_queries.py::RankTests::test_max_range_x_preceeding", + "pypika/tests/test_analytic_queries.py::RankTests::test_max_rows_x_preceeding", + "pypika/tests/test_analytic_queries.py::RankTests::test_median", + "pypika/tests/test_analytic_queries.py::RankTests::test_min_range_current_row", + "pypika/tests/test_analytic_queries.py::RankTests::test_min_rows_current_row", + "pypika/tests/test_analytic_queries.py::RankTests::test_multiple_partitions", + "pypika/tests/test_analytic_queries.py::RankTests::test_ntile_no_partition_or_order_invalid_sql", + "pypika/tests/test_analytic_queries.py::RankTests::test_ntile_with_order", + "pypika/tests/test_analytic_queries.py::RankTests::test_ntile_with_partition", + "pypika/tests/test_analytic_queries.py::RankTests::test_ntile_with_partition_and_order", + "pypika/tests/test_analytic_queries.py::RankTests::test_orderby_asc", + "pypika/tests/test_analytic_queries.py::RankTests::test_orderby_desc", + "pypika/tests/test_analytic_queries.py::RankTests::test_range_called_twice_raises_attribute_error", + "pypika/tests/test_analytic_queries.py::RankTests::test_range_then_rows_raises_attribute_error", + "pypika/tests/test_analytic_queries.py::RankTests::test_rank", + "pypika/tests/test_analytic_queries.py::RankTests::test_rank_with_alias", + "pypika/tests/test_analytic_queries.py::RankTests::test_row_number", + "pypika/tests/test_analytic_queries.py::RankTests::test_rows_called_twice_raises_attribute_error", + "pypika/tests/test_analytic_queries.py::RankTests::test_rows_then_range_raises_attribute_error", + "pypika/tests/test_analytic_queries.py::RankTests::test_stddev", + "pypika/tests/test_analytic_queries.py::RankTests::test_stddev_pop", + "pypika/tests/test_analytic_queries.py::RankTests::test_stddev_samp", + "pypika/tests/test_analytic_queries.py::RankTests::test_sum_rows_unbounded_preceeding", + "pypika/tests/test_analytic_queries.py::RankTests::test_table_prefixes_used_in_analytic_functions", + "pypika/tests/test_analytic_queries.py::RankTests::test_var_pop", + "pypika/tests/test_analytic_queries.py::RankTests::test_var_samp", + "pypika/tests/test_analytic_queries.py::RankTests::test_variance", + "pypika/tests/test_analytic_queries.py::RankTests::test_variance_rows_between_unbounded_preceeding_unbounded_following", + "pypika/tests/test_analytic_queries.py::RankTests::test_varpop_range_unbounded_preceeding", + "pypika/tests/test_analytic_queries.py::RankTests::test_varpop_rows_between_unbounded_preceeding_x_following", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_as_select_not_query_raises_error", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_with_columns", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_with_select", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_with_select_and_columns_fails", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_without_columns_or_select_empty", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_if_not_exists", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_simple", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_unique", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_where", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_without_columns_raises_error", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_without_table_raises_error", + "pypika/tests/test_criterions.py::CriterionTests::test__bitwise_and_in_where_clause", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_bitwise_and", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_bitwise_and_with_alias", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_bool", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_decimal", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_str", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gt_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gt_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gt_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gt_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gte_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gte_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gte_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gte_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_is_null", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_is_null_with_alias", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lt_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lt_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lt_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lt_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lte_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lte_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lte_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lte_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_str", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_with_alias", + "pypika/tests/test_criterions.py::NotTests::test_chained_function", + "pypika/tests/test_criterions.py::NotTests::test_is_not_null", + "pypika/tests/test_criterions.py::NotTests::test_negate", + "pypika/tests/test_criterions.py::NotTests::test_not_null", + "pypika/tests/test_criterions.py::NotTests::test_not_null_with_alias", + "pypika/tests/test_criterions.py::NotTests::test_not_with_and_criterion", + "pypika/tests/test_criterions.py::NotTests::test_not_with_complex_criterion", + "pypika/tests/test_criterions.py::NotTests::test_not_with_or_criterion", + "pypika/tests/test_criterions.py::NotTests::test_notnullcriterion_replace_table", + "pypika/tests/test_criterions.py::NotTests::test_variable_access", + "pypika/tests/test_criterions.py::BetweenTests::test__between_date", + "pypika/tests/test_criterions.py::BetweenTests::test__between_datetime", + "pypika/tests/test_criterions.py::BetweenTests::test__between_number", + "pypika/tests/test_criterions.py::BetweenTests::test__between_with_alias", + "pypika/tests/test_criterions.py::BetweenTests::test__function_between", + "pypika/tests/test_criterions.py::BetweenTests::test_get_item_only_works_with_slice", + "pypika/tests/test_criterions.py::IsInTests::test__function_isin", + "pypika/tests/test_criterions.py::IsInTests::test__in_character", + "pypika/tests/test_criterions.py::IsInTests::test__in_date", + "pypika/tests/test_criterions.py::IsInTests::test__in_datetime", + "pypika/tests/test_criterions.py::IsInTests::test__in_number", + "pypika/tests/test_criterions.py::IsInTests::test__in_number_with_alias", + "pypika/tests/test_criterions.py::IsInTests::test__in_unicode", + "pypika/tests/test_criterions.py::ArithmeticExpressionTests::test__lshift", + "pypika/tests/test_criterions.py::ArithmeticExpressionTests::test__rshift", + "pypika/tests/test_criterions.py::NotInTests::test__function_notin", + "pypika/tests/test_criterions.py::NotInTests::test__notin_character", + "pypika/tests/test_criterions.py::NotInTests::test__notin_date", + "pypika/tests/test_criterions.py::NotInTests::test__notin_datetime", + "pypika/tests/test_criterions.py::NotInTests::test__notin_number", + "pypika/tests/test_criterions.py::NotInTests::test__notin_number_with_alias", + "pypika/tests/test_criterions.py::LikeTests::test_glob_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_contains", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_ends_with", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_n_chars_long", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_starts_with", + "pypika/tests/test_criterions.py::LikeTests::test_like_contains", + "pypika/tests/test_criterions.py::LikeTests::test_like_ends_with", + "pypika/tests/test_criterions.py::LikeTests::test_like_n_chars_long", + "pypika/tests/test_criterions.py::LikeTests::test_like_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_like_starts_with", + "pypika/tests/test_criterions.py::LikeTests::test_not_ilike_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_not_like_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_rlike_escape_chars", + "pypika/tests/test_criterions.py::ExistsCriterionTests::test_exists", + "pypika/tests/test_criterions.py::ExistsCriterionTests::test_not_exists", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__between_and_field", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__between_and_isin", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__nested__and", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__nested__mixed", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__nested__or", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_and", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_function_and", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_function_or", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_function_xor", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_or", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_xor", + "pypika/tests/test_criterions.py::FieldsAsCriterionTests::test__field_and_field", + "pypika/tests/test_criterions.py::FieldsAsCriterionTests::test__field_or_field", + "pypika/tests/test_criterions.py::FieldsAsCriterionTests::test__field_xor_field", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_arithmeticfunction_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_betweencriterion_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_complexcriterion_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_criterion_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_field_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_function_with_only_fields_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_function_with_values_and_fields_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_nullcriterion_replace_table", + "pypika/tests/test_criterions.py::AnyTests::test_multiple_args_returned_in_chain_of_ors", + "pypika/tests/test_criterions.py::AnyTests::test_single_arg_returns_self", + "pypika/tests/test_criterions.py::AnyTests::test_with_generator", + "pypika/tests/test_criterions.py::AnyTests::test_zero_args_returns_empty_criterion", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_different_operations_with_empty_criterion", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_empty_criterion_on_the_left", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_empty_criterion_on_the_right", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_fields_", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_invertion_of_the_empty_criterion", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_more_than_one_empty_criterions", + "pypika/tests/test_criterions.py::AllTests::test_multiple_args_returned_in_chain_of_ors", + "pypika/tests/test_criterions.py::AllTests::test_single_arg_returns_self", + "pypika/tests/test_criterions.py::AllTests::test_with_generator", + "pypika/tests/test_criterions.py::AllTests::test_zero_args_returns_empty_criterion", + "pypika/tests/test_custom_functions.py::TestUnitCustomFunction::test_should_fail_with_wrong_arguments", + "pypika/tests/test_custom_functions.py::TestUnitCustomFunction::test_should_return_function_with_arguments", + "pypika/tests/test_custom_functions.py::TestUnitCustomFunction::test_should_return_function_with_no_arguments", + "pypika/tests/test_custom_functions.py::TestFunctionalCustomFunction::test_should_fail_use_custom_function_on_select_with_wrong_arguments", + "pypika/tests/test_custom_functions.py::TestFunctionalCustomFunction::test_should_use_custom_function_on_select", + "pypika/tests/test_data_types.py::StringTests::test_inline_string_concatentation", + "pypika/tests/test_data_types.py::UuidTests::test_uuid_string_generation", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_day", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_default", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_microsecond", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_minute", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_month", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_quarter", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_second", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_week", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_year", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_day_hour", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_day_microsecond", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_day_minute", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_day_second", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_hour_microsecond", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_hour_minute", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_hour_second", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_minute_microsecond", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_minute_second", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_second_microsecond", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_value_complex_expressions", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_value_right", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_year_month", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_mysql_dialect_uses_single_quotes_around_expression_in_an_interval", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_oracle_dialect_uses_single_quotes_around_expression_in_an_interval", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_postgresql_dialect_uses_single_quotes_around_interval", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_redshift_dialect_uses_single_quotes_around_interval", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_vertica_dialect_uses_single_quotes_around_interval", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_day", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_month", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_week", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_year", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_year_month", + "pypika/tests/test_date_math.py::TruncateTrailingZerosTests::test_do_not_truncate_integer_values", + "pypika/tests/test_date_math.py::TruncateTrailingZerosTests::test_do_not_truncate_months_between_years_and_datys", + "pypika/tests/test_deletes.py::DeleteTests::test_for_portion", + "pypika/tests/test_deletes.py::DeleteTests::test_omit_where", + "pypika/tests/test_deletes.py::DeleteTests::test_omit_where__table_schema", + "pypika/tests/test_deletes.py::DeleteTests::test_where_field_equals", + "pypika/tests/test_deletes.py::PostgresDeleteTests::test_delete_returning", + "pypika/tests/test_deletes.py::PostgresDeleteTests::test_delete_returning_star", + "pypika/tests/test_deletes.py::PostgresDeleteTests::test_delete_returning_str", + "pypika/tests/test_deletes.py::PostgresDeleteTests::test_delete_using", + "pypika/tests/test_drop.py::DropTableTests::test_drop_database", + "pypika/tests/test_drop.py::DropTableTests::test_drop_index", + "pypika/tests/test_drop.py::DropTableTests::test_drop_table", + "pypika/tests/test_drop.py::DropTableTests::test_drop_user", + "pypika/tests/test_drop.py::DropTableTests::test_drop_view", + "pypika/tests/test_formats.py::QuoteTests::test_no_quote_char_in_complex_query", + "pypika/tests/test_formats.py::QuoteTests::test_replace_quote_char_in_complex_query", + "pypika/tests/test_functions.py::FunctionTests::test_dialect_propagation", + "pypika/tests/test_functions.py::FunctionTests::test_is_aggregate_None_for_non_aggregate_function_or_function_with_no_aggregate_functions", + "pypika/tests/test_functions.py::FunctionTests::test_is_aggregate_True_for_aggregate_function_or_function_with_aggregate_functions", + "pypika/tests/test_functions.py::SchemaTests::test_schema_included_in_function_sql", + "pypika/tests/test_functions.py::SchemaTests::test_schema_no_schema_in_sql_when_none_set", + "pypika/tests/test_functions.py::ArithmeticTests::test__addition__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__addition__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__addition__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__addition__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__arithmetic_equality", + "pypika/tests/test_functions.py::ArithmeticTests::test__arithmetic_with_function", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_add_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_div_no_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_div_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_exponent_no_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_exponent_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_floor_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_function_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_modulus_no_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_modulus_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_mul_no_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_mul_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_nested_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_sub_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__division__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__division__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__division__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__division__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__exponent__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__exponent__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__floor", + "pypika/tests/test_functions.py::ArithmeticTests::test__leftshift__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__leftshift__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__leftshift__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__modulus__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__multiplication__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__multiplication__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__multiplication__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__multiplication__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__rightshift__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__rightshift__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__rightshift__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__subtraction__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__subtraction__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__subtraction__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__subtraction__right", + "pypika/tests/test_functions.py::AggregationTests::test__approx_percentile", + "pypika/tests/test_functions.py::AggregationTests::test__avg", + "pypika/tests/test_functions.py::AggregationTests::test__count", + "pypika/tests/test_functions.py::AggregationTests::test__count__star", + "pypika/tests/test_functions.py::AggregationTests::test__first", + "pypika/tests/test_functions.py::AggregationTests::test__last", + "pypika/tests/test_functions.py::AggregationTests::test__max", + "pypika/tests/test_functions.py::AggregationTests::test__min", + "pypika/tests/test_functions.py::AggregationTests::test__std", + "pypika/tests/test_functions.py::AggregationTests::test__stddev", + "pypika/tests/test_functions.py::AggregationTests::test__subquery_in_params_functions", + "pypika/tests/test_functions.py::AggregationTests::test__sum", + "pypika/tests/test_functions.py::ConditionTests::test__case__else", + "pypika/tests/test_functions.py::ConditionTests::test__case__field", + "pypika/tests/test_functions.py::ConditionTests::test__case__multi", + "pypika/tests/test_functions.py::ConditionTests::test__case__no_cases", + "pypika/tests/test_functions.py::ConditionTests::test__case__raw", + "pypika/tests/test_functions.py::StringTests::test__ascii__field", + "pypika/tests/test_functions.py::StringTests::test__ascii__int", + "pypika/tests/test_functions.py::StringTests::test__ascii__str", + "pypika/tests/test_functions.py::StringTests::test__bin__field", + "pypika/tests/test_functions.py::StringTests::test__bin__int", + "pypika/tests/test_functions.py::StringTests::test__bin__str", + "pypika/tests/test_functions.py::StringTests::test__concat__field", + "pypika/tests/test_functions.py::StringTests::test__concat__str", + "pypika/tests/test_functions.py::StringTests::test__insert__field", + "pypika/tests/test_functions.py::StringTests::test__insert__str", + "pypika/tests/test_functions.py::StringTests::test__length__field", + "pypika/tests/test_functions.py::StringTests::test__length__str", + "pypika/tests/test_functions.py::StringTests::test__lower__field", + "pypika/tests/test_functions.py::StringTests::test__lower__str", + "pypika/tests/test_functions.py::StringTests::test__replace__field", + "pypika/tests/test_functions.py::StringTests::test__replace__str", + "pypika/tests/test_functions.py::StringTests::test__substring", + "pypika/tests/test_functions.py::SplitPartFunctionTests::test__split_part", + "pypika/tests/test_functions.py::RegexpLikeFunctionTests::test__regexp_like", + "pypika/tests/test_functions.py::CastTests::test__cast__as", + "pypika/tests/test_functions.py::CastTests::test__cast__binary", + "pypika/tests/test_functions.py::CastTests::test__cast__binary_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__boolean", + "pypika/tests/test_functions.py::CastTests::test__cast__char", + "pypika/tests/test_functions.py::CastTests::test__cast__char_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__date", + "pypika/tests/test_functions.py::CastTests::test__cast__float", + "pypika/tests/test_functions.py::CastTests::test__cast__integer", + "pypika/tests/test_functions.py::CastTests::test__cast__long_varbinary", + "pypika/tests/test_functions.py::CastTests::test__cast__long_varbinary_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__long_varchar", + "pypika/tests/test_functions.py::CastTests::test__cast__long_varchar_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__numeric", + "pypika/tests/test_functions.py::CastTests::test__cast__signed", + "pypika/tests/test_functions.py::CastTests::test__cast__timestamp", + "pypika/tests/test_functions.py::CastTests::test__cast__unsigned", + "pypika/tests/test_functions.py::CastTests::test__cast__varbinary", + "pypika/tests/test_functions.py::CastTests::test__cast__varbinary_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__varchar", + "pypika/tests/test_functions.py::CastTests::test__cast__varchar_with_arg", + "pypika/tests/test_functions.py::CastTests::test__tochar__", + "pypika/tests/test_functions.py::DateFunctionsTests::test_current_date", + "pypika/tests/test_functions.py::DateFunctionsTests::test_current_time", + "pypika/tests/test_functions.py::DateFunctionsTests::test_current_timestamp", + "pypika/tests/test_functions.py::DateFunctionsTests::test_current_timestamp_with_alias", + "pypika/tests/test_functions.py::DateFunctionsTests::test_date_add", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_day", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_hour", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_join", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_microsecond", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_minute", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_month", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_quarter", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_second", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_week", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_year", + "pypika/tests/test_functions.py::DateFunctionsTests::test_now", + "pypika/tests/test_functions.py::DateFunctionsTests::test_time_diff", + "pypika/tests/test_functions.py::DateFunctionsTests::test_timestampadd", + "pypika/tests/test_functions.py::DateFunctionsTests::test_to_date", + "pypika/tests/test_functions.py::DateFunctionsTests::test_utc_timestamp", + "pypika/tests/test_functions.py::NullFunctionsTests::test_coalesce", + "pypika/tests/test_functions.py::NullFunctionsTests::test_isnull", + "pypika/tests/test_functions.py::NullFunctionsTests::test_nullif", + "pypika/tests/test_functions.py::NullFunctionsTests::test_nvl", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_mysql_one_groupby", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_mysql_rollup_two_groupbys", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_no_rollup_after_rollup_mysql", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_no_rollup_before_groupby", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_from_groupbys", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_from_parameters", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_from_two_groupbys", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_func_one_groupby", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_func_partial", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_func_two_groupbys", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_multiple_rollups", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_rollups_with_multiple_rollups_and_parity", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_rollups_with_parity", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_force_index_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_groupby_returns_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_immutable_kwarg_on_query_builder_disables_immutability", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_insert_into_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_join_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_orderby_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_queries_after_join", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_replace_into_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_select_returns_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_update_set_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_use_index_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_with_return_new_query_instance", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_multi_rows", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_multi_rows_chained", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_multi_rows_chained_mixed", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_multi_rows_chained_multiple_rows", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_single_element", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_column_using_alias_with_chain", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_column_using_table_alias", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_empty_columns", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_empty_columns_type_list", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_empty_columns_type_tuple", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_ignore", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_multiple_rows_with_array_value", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_none_skipped", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_null", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_one_column", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_one_column_multi_element_array", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_one_column_single_element_array", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_selected_columns", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_selected_columns_type_list", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_selected_columns_type_tuple", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_single_row_with_array_value", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_with_statement", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_empty_on_conflict_do_update_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_field", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_field_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_mixed_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_multiple_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_multiple_fields_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_field", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_field_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_multiple_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_multiple_fields_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_multiple_mixed_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_no_handler", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_two_handlers_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_two_handlers_do_update", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_fieldless_conflict_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_fieldless_conflict_do_update_field", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_non_insert_on_conflict_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_non_insert_on_conflict_do_update", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_do_nothing_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_do_update_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_do_update_with_excluded_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_from_subquery", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_complex", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_conflict_fields_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_conflict_fields_do_update", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_empty_conflict_fields_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_empty_conflict_fields_do_update", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_where_and_on_conflict_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_all_columns_multi_rows_chained_returning_star", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_all_columns_multi_rows_chained_returning_star_and_id", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_all_columns_multi_rows_chained_returning_star_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_all_columns_single_element_arrays", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_aggregate", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_all_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_all_fields_and_arithmetics", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_arithmetics", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_from_other_table", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_functions", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_null", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_one_field", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_one_field_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_tuple", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_ignore", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multi_rows_chained_mixed_on_duplicate_update_multiple", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_multiple", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_different_value", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_expression", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_expression_using_original_field_value", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_expression_using_values", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_same_value", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_none_skipped", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_one_column", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_one_column_multi_element_array", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_one_column_single_element_array", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_one_column_using_values", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_selected_columns_on_duplicate_update_multiple", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_selected_columns_on_duplicate_update_one", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_columns_from_columns", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_columns_from_columns_with_join", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_columns_from_star", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_from_columns", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_ignore_star", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_star", + "pypika/tests/test_inserts.py::InsertSubqueryTests::test_insert_subquery_wrapped_in_brackets", + "pypika/tests/test_inserts.py::SelectIntoTests::test_select_columns_into", + "pypika/tests/test_inserts.py::SelectIntoTests::test_select_columns_into_with_join", + "pypika/tests/test_inserts.py::SelectIntoTests::test_select_star_into", + "pypika/tests/test_inserts.py::ReplaceTests::test_replace_simple", + "pypika/tests/test_inserts.py::ReplaceTests::test_replace_subquery", + "pypika/tests/test_internals.py::TablesTests::test__case_tables", + "pypika/tests/test_internals.py::TablesTests::test__criterion_replace_table_with_value", + "pypika/tests/test_internals.py::TablesTests::test__star_tables", + "pypika/tests/test_internals.py::TablesTests::test__table_star_tables", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_cross_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_cross_join_on_subquery", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_cross_join_on_table", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_default_join_type", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_full_outer_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_hash_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_inner_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_arithmetic_field", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_collate", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_complex_criteria", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_field_multi", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_field_multi_with_extra_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_field_single", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_field_without_fields_raises_exception", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_subquery_criteria", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_second_table_in_from_clause", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_using_multiple_fields", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_using_string_field_name", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_using_with_quote_char", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_using_without_fields_raises_exception", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_with_arithmetic_function_in_select", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_left_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_left_outer_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_outer_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_right_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_right_outer_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_temporal_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_use_different_table_objects_for_same_table", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_fail_when_joining_unknown_type", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_ignore_table_references", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_immutable__tables", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_from_join", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_query_with_column_alias", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_query_with_setoperation", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_query_with_table_alias", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_query_without_alias", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_same_table", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_same_table_with_prefixes", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_table_twice", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_prefixes_added_to_function_in_orderby", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_prefixes_added_to_groupby", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_prefixes_added_to_orderby", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_require_condition", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_require_condition_with_both_tables", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select__fields_after_table_star", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select__ordered_select_clauses", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select__star_for_table", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select__star_for_table__replacement", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select_field_from_missing_table", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select_fields_with_where", + "pypika/tests/test_joins.py::UnionTests::test_mysql_query_wraps_unioned_queries", + "pypika/tests/test_joins.py::UnionTests::test_require_equal_number_of_fields", + "pypika/tests/test_joins.py::UnionTests::test_union", + "pypika/tests/test_joins.py::UnionTests::test_union_all", + "pypika/tests/test_joins.py::UnionTests::test_union_all_multiple", + "pypika/tests/test_joins.py::UnionTests::test_union_as_subquery", + "pypika/tests/test_joins.py::UnionTests::test_union_multiple", + "pypika/tests/test_joins.py::UnionTests::test_union_with_no_quote_char", + "pypika/tests/test_joins.py::UnionTests::test_union_with_order_by", + "pypika/tests/test_joins.py::UnionTests::test_union_with_order_by_use_union_query_field", + "pypika/tests/test_joins.py::UnionTests::test_union_with_order_by_use_union_query_field_with_aliases", + "pypika/tests/test_joins.py::UnionTests::test_union_with_order_by_with_aliases", + "pypika/tests/test_joins.py::InsertQueryJoinTests::test_join_table_on_insert_query", + "pypika/tests/test_joins.py::UpdateQueryJoinTests::test_join_table_on_update_query", + "pypika/tests/test_joins.py::IntersectTests::test_intersect", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_as_subquery", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_multiple", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_with_limit", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_with_no_quote_char", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_with_offset", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_with_order_by", + "pypika/tests/test_joins.py::IntersectTests::test_mysql_query_wraps_intersected_queries", + "pypika/tests/test_joins.py::IntersectTests::test_require_equal_number_of_fields_intersect", + "pypika/tests/test_joins.py::MinusTests::test_minus", + "pypika/tests/test_joins.py::MinusTests::test_minus_as_subquery", + "pypika/tests/test_joins.py::MinusTests::test_minus_multiple", + "pypika/tests/test_joins.py::MinusTests::test_minus_query_with_order_by_use_minus_query_field", + "pypika/tests/test_joins.py::MinusTests::test_minus_with_no_quote_char", + "pypika/tests/test_joins.py::MinusTests::test_minus_with_order_by", + "pypika/tests/test_joins.py::MinusTests::test_mysql_query_wraps_minus_queries", + "pypika/tests/test_joins.py::MinusTests::test_require_equal_number_of_fields", + "pypika/tests/test_joins.py::ExceptOfTests::test_except", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_as_subquery", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_multiple", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_query_with_order_by_use_minus_query_field", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_with_no_quote_char", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_with_order_by", + "pypika/tests/test_joins.py::ExceptOfTests::test_require_equal_number_of_fields_except_of", + "pypika/tests/test_negation.py::NegationTests::test_negate_field", + "pypika/tests/test_negation.py::NegationTests::test_negate_function", + "pypika/tests/test_negation.py::NegationTests::test_negate_wrapped_float", + "pypika/tests/test_negation.py::NegationTests::test_negate_wrapped_int", + "pypika/tests/test_parameter.py::ParametrizedTests::test_format_parameter", + "pypika/tests/test_parameter.py::ParametrizedTests::test_join", + "pypika/tests/test_parameter.py::ParametrizedTests::test_named_parameter", + "pypika/tests/test_parameter.py::ParametrizedTests::test_numeric_parameter", + "pypika/tests/test_parameter.py::ParametrizedTests::test_param_insert", + "pypika/tests/test_parameter.py::ParametrizedTests::test_param_select_join", + "pypika/tests/test_parameter.py::ParametrizedTests::test_param_select_subquery", + "pypika/tests/test_parameter.py::ParametrizedTests::test_pyformat_parameter", + "pypika/tests/test_parameter.py::ParametrizedTests::test_qmark_parameter", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_join", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_join_with_parameter_value_wrapper", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_param_insert", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_param_select_join", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_param_select_subquery", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_pyformat_parameter", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_can_be_used_in_a_select_statement", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_can_be_used_in_a_where_clause", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_can_be_used_in_orderby", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_column_value", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_object_id", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_object_value", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_row_id", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_row_num", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_sys_date", + "pypika/tests/test_query.py::QueryTablesTests::test_is_joined", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_case_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_delete_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_filter_tables", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_having_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_insert_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_insert_table_current_table_not_match", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_join_tables", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_only_specified_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_orderby_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_tuple_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_update_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_update_table_current_table_not_match", + "pypika/tests/test_query.py::QueryBuilderTests::test_pipe", + "pypika/tests/test_query.py::QueryBuilderTests::test_query_builders_have_reference_to_correct_query_class", + "pypika/tests/test_selects.py::SelectTests::test_empty_query", + "pypika/tests/test_selects.py::SelectTests::test_mssql_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_mysql_query_uses_backtick_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_oracle_query_uses_no_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_postgresql_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_redshift_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_select__column__single__alias__str", + "pypika/tests/test_selects.py::SelectTests::test_select__column__single__field", + "pypika/tests/test_selects.py::SelectTests::test_select__column__single__str", + "pypika/tests/test_selects.py::SelectTests::test_select__column__single__table_alias__str", + "pypika/tests/test_selects.py::SelectTests::test_select__columns__multi__field", + "pypika/tests/test_selects.py::SelectTests::test_select__columns__multi__str", + "pypika/tests/test_selects.py::SelectTests::test_select__distinct__multi", + "pypika/tests/test_selects.py::SelectTests::test_select__distinct__single", + "pypika/tests/test_selects.py::SelectTests::test_select__multiple_subqueries", + "pypika/tests/test_selects.py::SelectTests::test_select__multiple_tables", + "pypika/tests/test_selects.py::SelectTests::test_select__nested_subquery", + "pypika/tests/test_selects.py::SelectTests::test_select__no_table", + "pypika/tests/test_selects.py::SelectTests::test_select__star", + "pypika/tests/test_selects.py::SelectTests::test_select__star__replacement", + "pypika/tests/test_selects.py::SelectTests::test_select__subquery", + "pypika/tests/test_selects.py::SelectTests::test_select__table_schema", + "pypika/tests/test_selects.py::SelectTests::test_select__table_schema_with_multiple_levels_as_list", + "pypika/tests/test_selects.py::SelectTests::test_select__table_schema_with_multiple_levels_as_tuple", + "pypika/tests/test_selects.py::SelectTests::test_select_no_from", + "pypika/tests/test_selects.py::SelectTests::test_select_no_from_with_field_raises_exception", + "pypika/tests/test_selects.py::SelectTests::test_select_no_with_alias_from", + "pypika/tests/test_selects.py::SelectTests::test_select_then_add_table", + "pypika/tests/test_selects.py::SelectTests::test_select_with_force_index", + "pypika/tests/test_selects.py::SelectTests::test_select_with_force_index_multiple_calls", + "pypika/tests/test_selects.py::SelectTests::test_select_with_force_index_multiple_indexes", + "pypika/tests/test_selects.py::SelectTests::test_select_with_force_index_with_index_object", + "pypika/tests/test_selects.py::SelectTests::test_select_with_limit", + "pypika/tests/test_selects.py::SelectTests::test_select_with_limit__func", + "pypika/tests/test_selects.py::SelectTests::test_select_with_limit_and_offset", + "pypika/tests/test_selects.py::SelectTests::test_select_with_limit_zero", + "pypika/tests/test_selects.py::SelectTests::test_select_with_offset", + "pypika/tests/test_selects.py::SelectTests::test_select_with_offset__func", + "pypika/tests/test_selects.py::SelectTests::test_select_with_use_index", + "pypika/tests/test_selects.py::SelectTests::test_select_with_use_index_multiple_calls", + "pypika/tests/test_selects.py::SelectTests::test_select_with_use_index_multiple_indexes", + "pypika/tests/test_selects.py::SelectTests::test_select_with_use_index_with_index_object", + "pypika/tests/test_selects.py::SelectTests::test_table_select_alias", + "pypika/tests/test_selects.py::SelectTests::test_table_select_alias_with_offset_and_limit", + "pypika/tests/test_selects.py::SelectTests::test_temporal_select", + "pypika/tests/test_selects.py::SelectTests::test_vertica_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::WhereTests::test_ignore_empty_criterion_having", + "pypika/tests/test_selects.py::WhereTests::test_ignore_empty_criterion_where", + "pypika/tests/test_selects.py::WhereTests::test_select_with_force_index_and_where", + "pypika/tests/test_selects.py::WhereTests::test_where_enum", + "pypika/tests/test_selects.py::WhereTests::test_where_field_contains", + "pypika/tests/test_selects.py::WhereTests::test_where_field_does_not_contain", + "pypika/tests/test_selects.py::WhereTests::test_where_field_does_not_end_with", + "pypika/tests/test_selects.py::WhereTests::test_where_field_does_not_start_with", + "pypika/tests/test_selects.py::WhereTests::test_where_field_ends_with", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_and", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_nowait", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_of", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_of_multiple_tables", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_of_nowait", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_of_skip_locked", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_skip_locked", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_skip_locked_and_of", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_or", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_where", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_where_not", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_where_two_not", + "pypika/tests/test_selects.py::WhereTests::test_where_field_is_n_chars_long", + "pypika/tests/test_selects.py::WhereTests::test_where_field_is_not_n_chars_long", + "pypika/tests/test_selects.py::WhereTests::test_where_field_matches_regex", + "pypika/tests/test_selects.py::WhereTests::test_where_field_matches_regexp", + "pypika/tests/test_selects.py::WhereTests::test_where_field_matches_rlike", + "pypika/tests/test_selects.py::WhereTests::test_where_field_starts_with", + "pypika/tests/test_selects.py::WhereTests::test_where_nested_conditions", + "pypika/tests/test_selects.py::WhereTests::test_where_single_quote", + "pypika/tests/test_selects.py::WhereTests::test_where_with_multiple_wheres_using_and_case", + "pypika/tests/test_selects.py::WhereTests::test_where_with_multiple_wheres_using_or_case", + "pypika/tests/test_selects.py::PreWhereTests::test_ignore_empty_criterion_having", + "pypika/tests/test_selects.py::PreWhereTests::test_ignore_empty_criterion_where", + "pypika/tests/test_selects.py::PreWhereTests::test_prewhere_field_equals", + "pypika/tests/test_selects.py::PreWhereTests::test_select_with_force_index_and_where", + "pypika/tests/test_selects.py::PreWhereTests::test_where_and_prewhere", + "pypika/tests/test_selects.py::PreWhereTests::test_where_enum", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_contains", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_does_not_contain", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_does_not_end_with", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_does_not_start_with", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_ends_with", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_and", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_nowait", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_of", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_of_multiple_tables", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_of_nowait", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_of_skip_locked", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_skip_locked", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_skip_locked_and_of", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_or", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_where", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_where_not", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_where_two_not", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_is_n_chars_long", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_is_not_n_chars_long", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_matches_regex", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_matches_regexp", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_matches_rlike", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_starts_with", + "pypika/tests/test_selects.py::PreWhereTests::test_where_nested_conditions", + "pypika/tests/test_selects.py::PreWhereTests::test_where_single_quote", + "pypika/tests/test_selects.py::PreWhereTests::test_where_with_multiple_wheres_using_and_case", + "pypika/tests/test_selects.py::PreWhereTests::test_where_with_multiple_wheres_using_or_case", + "pypika/tests/test_selects.py::GroupByTests::test_group_by__single_with_totals", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__alias", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__alias_platforms", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__alias_with_join", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__count_distinct", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__count_field", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__count_star", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__int", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__multi", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__multi_with_totals", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__no_alias", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__no_alias_mssql", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__no_alias_oracle", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__single", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__str", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__sum_distinct", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__sum_filter", + "pypika/tests/test_selects.py::GroupByTests::test_groupby_with_case_uses_the_alias", + "pypika/tests/test_selects.py::GroupByTests::test_mssql_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_mysql_query_uses_backtick_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_oracle_query_uses_no_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_postgres_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_redshift_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_vertica_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_having_and", + "pypika/tests/test_selects.py::HavingTests::test_having_greater_than", + "pypika/tests/test_selects.py::HavingTests::test_having_join_and_equality", + "pypika/tests/test_selects.py::HavingTests::test_mssql_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_mysql_query_uses_backtick_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_oracle_query_uses_no_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_postgres_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_redshift_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_vertica_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_alias", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_asc", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_desc", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_multi_fields", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_no_alias", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_single_field", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_single_str", + "pypika/tests/test_selects.py::AliasTests::test_arithmetic_function", + "pypika/tests/test_selects.py::AliasTests::test_case_using_as", + "pypika/tests/test_selects.py::AliasTests::test_case_using_constructor_param", + "pypika/tests/test_selects.py::AliasTests::test_function_using_as_nested", + "pypika/tests/test_selects.py::AliasTests::test_functions_using_as", + "pypika/tests/test_selects.py::AliasTests::test_functions_using_constructor_param", + "pypika/tests/test_selects.py::AliasTests::test_functions_using_constructor_param_nested", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_criterion", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_criterion_comparison", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_field_inside_case", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_groupby", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_orderby", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_where", + "pypika/tests/test_selects.py::AliasTests::test_null_value_with_alias", + "pypika/tests/test_selects.py::AliasTests::test_select__multiple_tables", + "pypika/tests/test_selects.py::AliasTests::test_table_field", + "pypika/tests/test_selects.py::AliasTests::test_table_field__multi", + "pypika/tests/test_selects.py::AliasTests::test_table_with_schema_and_alias", + "pypika/tests/test_selects.py::AliasTests::test_use_aliases_in_groupby_and_orderby", + "pypika/tests/test_selects.py::SubqueryTests::test_from_subquery_without_alias", + "pypika/tests/test_selects.py::SubqueryTests::test_join", + "pypika/tests/test_selects.py::SubqueryTests::test_join_query_with_alias", + "pypika/tests/test_selects.py::SubqueryTests::test_join_with_with", + "pypika/tests/test_selects.py::SubqueryTests::test_select_from_nested_query", + "pypika/tests/test_selects.py::SubqueryTests::test_select_from_nested_query_with_join", + "pypika/tests/test_selects.py::SubqueryTests::test_select_from_with_returning", + "pypika/tests/test_selects.py::SubqueryTests::test_select_subquery", + "pypika/tests/test_selects.py::SubqueryTests::test_select_subquery_with_alias", + "pypika/tests/test_selects.py::SubqueryTests::test_where__equality", + "pypika/tests/test_selects.py::SubqueryTests::test_where__in", + "pypika/tests/test_selects.py::SubqueryTests::test_where__in_nested", + "pypika/tests/test_selects.py::SubqueryTests::test_with", + "pypika/tests/test_selects.py::QuoteTests::test_extraneous_quotes", + "pypika/tests/test_tables.py::TableStructureTests::test_database_schema_table_attr", + "pypika/tests/test_tables.py::TableStructureTests::test_schema_table_attr", + "pypika/tests/test_tables.py::TableStructureTests::test_table_for_period_sql", + "pypika/tests/test_tables.py::TableStructureTests::test_table_for_system_time_sql", + "pypika/tests/test_tables.py::TableStructureTests::test_table_sql", + "pypika/tests/test_tables.py::TableStructureTests::test_table_with_alias", + "pypika/tests/test_tables.py::TableStructureTests::test_table_with_schema_and_schema_parent_arg", + "pypika/tests/test_tables.py::TableStructureTests::test_table_with_schema_arg", + "pypika/tests/test_tables.py::TableEqualityTests::test_many_tables_with_alias", + "pypika/tests/test_tables.py::TableEqualityTests::test_many_tables_with_or_not_alias", + "pypika/tests/test_tables.py::TableEqualityTests::test_many_tables_without_alias", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_equal_by_name", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_equal_by_schema_and_name", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_equal_by_schema_and_name_using_schema", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_equal_by_schema_and_name_using_schema_with_parent", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_not_equal_by_schema_and_name_using_schema_with_different_parents", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_not_equal_with_different_names", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_not_equal_with_different_schemas", + "pypika/tests/test_tables.py::TableDialectTests::test_make_tables_factory_with_default_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_make_tables_factory_with_dialect_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_factory_with_default_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_factory_with_dialect_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_with_bad_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_with_default_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_with_dialect_query_cls", + "pypika/tests/test_terms.py::FieldAliasTests::test_when_alias_specified", + "pypika/tests/test_terms.py::FieldInitTests::test_init_with_str_table", + "pypika/tests/test_terms.py::FieldHashingTests::test_non_tabled_aliased_eq_fields_equally_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_non_tabled_aliased_ne_fields_differently_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_non_tabled_eq_fields_equally_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_non_tabled_ne_fields_differently_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_tabled_eq_fields_equally_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_tabled_ne_fields_differently_hashed", + "pypika/tests/test_terms.py::AtTimezoneTests::test_passes_kwargs_to_field_get_sql", + "pypika/tests/test_terms.py::AtTimezoneTests::test_when_alias_specified", + "pypika/tests/test_terms.py::AtTimezoneTests::test_when_interval_not_specified", + "pypika/tests/test_terms.py::AtTimezoneTests::test_when_interval_specified", + "pypika/tests/test_tuples.py::TupleTests::test_render_alias_in_array_sql", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_equality_tuple_on_both", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_equality_tuple_on_left", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_equality_tuple_on_right", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_in_using_mixed_tuples", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_in_using_pypika_tuples", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_in_using_python_tuples", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_is_aggregate", + "pypika/tests/test_tuples.py::TupleTests::test_tuples_in_join", + "pypika/tests/test_tuples.py::ArrayTests::test_array_general", + "pypika/tests/test_tuples.py::ArrayTests::test_empty_psql_array", + "pypika/tests/test_tuples.py::ArrayTests::test_psql_array_general", + "pypika/tests/test_tuples.py::ArrayTests::test_render_alias_in_array_sql", + "pypika/tests/test_tuples.py::BracketTests::test_arithmetic_with_brackets", + "pypika/tests/test_tuples.py::BracketTests::test_arithmetic_with_brackets_and_alias", + "pypika/tests/test_updates.py::UpdateTests::test_empty_query", + "pypika/tests/test_updates.py::UpdateTests::test_for_portion", + "pypika/tests/test_updates.py::UpdateTests::test_omit_where", + "pypika/tests/test_updates.py::UpdateTests::test_single_quote_escape_in_set", + "pypika/tests/test_updates.py::UpdateTests::test_update__table_schema", + "pypika/tests/test_updates.py::UpdateTests::test_update_from", + "pypika/tests/test_updates.py::UpdateTests::test_update_from_with_where", + "pypika/tests/test_updates.py::UpdateTests::test_update_with_join", + "pypika/tests/test_updates.py::UpdateTests::test_update_with_limit", + "pypika/tests/test_updates.py::UpdateTests::test_update_with_none", + "pypika/tests/test_updates.py::UpdateTests::test_update_with_statement", + "pypika/tests/test_updates.py::PostgresUpdateTests::test_update_returning", + "pypika/tests/test_updates.py::PostgresUpdateTests::test_update_returning_from_different_tables", + "pypika/tests/test_updates.py::PostgresUpdateTests::test_update_returning_star", + "pypika/tests/test_updates.py::PostgresUpdateTests::test_update_returning_str", + "pypika/tests/test_updates.py::SQLLiteUpdateTests::test_update_with_bool", + "pypika/tests/test_utils.py::ImmutabilityTests::test_raise_attribute_error_for_deepcopy", + "pypika/tests/test_utils.py::ImmutabilityTests::test_raise_attribute_error_for_getnewargs", + "pypika/tests/test_utils.py::ImmutabilityTests::test_raise_attribute_error_for_getstate", + "pypika/tests/test_utils.py::ImmutabilityTests::test_raise_attribute_error_for_setstate" + ], + "all_git_blobs_modes_verified": true, + "cloud_launch_ready": false, + "commits": { + "bug": "19f4e0bcfc7008f30945795dee7958402a48fd9e", + "healthy": "6a742f12bfa386994289ec8b75824663d8ee4b15", + "learner": "99d75158b583a09e5ececd35cd34434333891b4e" + }, + "existing_squirrel_snapshot_reused": false, + "full_transfer_allowlist": [ + "/testbed/.coveragerc", + "/testbed/.gitignore", + "/testbed/.pre-commit-config.yaml", + "/testbed/CODEOWNERS", + "/testbed/CONTRIBUTING.rst", + "/testbed/LICENSE.txt", + "/testbed/MANIFEST.in", + "/testbed/Makefile", + "/testbed/README.rst", + "/testbed/docs/1_installation.rst", + "/testbed/docs/2_tutorial.rst", + "/testbed/docs/3_advanced.rst", + "/testbed/docs/4_extending.rst", + "/testbed/docs/5_reference.rst", + "/testbed/docs/6_contributing.rst", + "/testbed/docs/Makefile", + "/testbed/docs/api/pypika.analytics.rst", + "/testbed/docs/api/pypika.dialects.rst", + "/testbed/docs/api/pypika.enums.rst", + "/testbed/docs/api/pypika.functions.rst", + "/testbed/docs/api/pypika.pseudocolumns.rst", + "/testbed/docs/api/pypika.queries.rst", + "/testbed/docs/api/pypika.rst", + "/testbed/docs/api/pypika.terms.rst", + "/testbed/docs/api/pypika.utils.rst", + "/testbed/docs/conf.py", + "/testbed/docs/index.rst", + "/testbed/pypika/__init__.py", + "/testbed/pypika/analytics.py", + "/testbed/pypika/clickhouse/__init__.py", + "/testbed/pypika/clickhouse/array.py", + "/testbed/pypika/clickhouse/condition.py", + "/testbed/pypika/clickhouse/dates_and_times.py", + "/testbed/pypika/clickhouse/nullable_arg.py", + "/testbed/pypika/clickhouse/search_string.py", + "/testbed/pypika/clickhouse/type_conversion.py", + "/testbed/pypika/dialects.py", + "/testbed/pypika/enums.py", + "/testbed/pypika/functions.py", + "/testbed/pypika/pseudocolumns.py", + "/testbed/pypika/py.typed", + "/testbed/pypika/queries.py", + "/testbed/pypika/terms.py", + "/testbed/pypika/tests/__init__.py", + "/testbed/pypika/tests/clickhouse/__init__.py", + "/testbed/pypika/tests/clickhouse/test_dates_and_times.py", + "/testbed/pypika/tests/dialects/__init__.py", + "/testbed/pypika/tests/dialects/test_clickhouse.py", + "/testbed/pypika/tests/dialects/test_mssql.py", + "/testbed/pypika/tests/dialects/test_mysql.py", + "/testbed/pypika/tests/dialects/test_oracle.py", + "/testbed/pypika/tests/dialects/test_postgresql.py", + "/testbed/pypika/tests/dialects/test_snowflake.py", + "/testbed/pypika/tests/dialects/test_sqllite.py", + "/testbed/pypika/tests/dialects/test_vertica.py", + "/testbed/pypika/tests/test_aggregate.py", + "/testbed/pypika/tests/test_analytic_queries.py", + "/testbed/pypika/tests/test_create.py", + "/testbed/pypika/tests/test_criterions.py", + "/testbed/pypika/tests/test_custom_functions.py", + "/testbed/pypika/tests/test_data_types.py", + "/testbed/pypika/tests/test_date_math.py", + "/testbed/pypika/tests/test_deletes.py", + "/testbed/pypika/tests/test_drop.py", + "/testbed/pypika/tests/test_formats.py", + "/testbed/pypika/tests/test_functions.py", + "/testbed/pypika/tests/test_groupby_modifiers.py", + "/testbed/pypika/tests/test_immutability.py", + "/testbed/pypika/tests/test_inserts.py", + "/testbed/pypika/tests/test_internals.py", + "/testbed/pypika/tests/test_joins.py", + "/testbed/pypika/tests/test_negation.py", + "/testbed/pypika/tests/test_parameter.py", + "/testbed/pypika/tests/test_pseudocolumns.py", + "/testbed/pypika/tests/test_query.py", + "/testbed/pypika/tests/test_selects.py", + "/testbed/pypika/tests/test_tables.py", + "/testbed/pypika/tests/test_terms.py", + "/testbed/pypika/tests/test_tuples.py", + "/testbed/pypika/tests/test_updates.py", + "/testbed/pypika/tests/test_utils.py", + "/testbed/pypika/utils.py", + "/testbed/pyproject.toml", + "/testbed/requirements-dev.txt", + "/testbed/setup.cfg", + "/testbed/setup.py", + "/testbed/tox.ini" + ], + "healthy_stage_meaning": "Direct parent of the mutation; no source or test execution has been performed", + "mutation_matches_dataset_and_git_blobs": true, + "official_profile": { + "eval_sets": [], + "profile_class": "Pypika1c9646f0", + "profile_lines": [ + 736, + 739 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "upstream_repo": "kayak/pypika" + }, + "original_source_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "private_test_paths": [ + "pypika/tests/clickhouse/test_array.py", + "pypika/tests/clickhouse/test_condition.py", + "pypika/tests/clickhouse/test_nullable_arg.py", + "pypika/tests/clickhouse/test_search_string.py", + "pypika/tests/clickhouse/test_type_conversion.py" + ], + "private_tests_unchanged": true, + "profile_mapping_basis": "Explicit upstream repo and full commit fields parsed from pinned official Python profile AST, not basename inference", + "qwen_calibrated": false, + "runtime_qualified": false, + "source_paths": [ + "pypika/clickhouse/search_string.py", + "pypika/clickhouse/type_conversion.py" + ], + "source_repo": "swesmith/kayak__pypika.1c9646f0", + "source_stages_bytes": 1885167, + "task_id": "kayak__pypika.1c9646f0.combine_module__9lguwrtp", + "transfer_limitation": "Existing regular files only; new arbitrary file additions need a qualified patch adapter", + "upstream_repo": "kayak/pypika" + }, + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:kayak__pypika.1c9646f0.combine_module__9lguwrtp", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "6a742f12bfa386994289ec8b75824663d8ee4b15", + "instruction_sha256": "4436415fb11227783fa942df8cbda0d0457fee39317eaf2b34167e3f10b6505a", + "is_fork": true, + "learner_path": "tasks/29738fa7e9c9b474ac0f655e/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "actual_upstream_url": "https://raw.githubusercontent.com/kayak/pypika/1c9646f0a019a167c32b649b6f5e6423c5ba2c9b/LICENSE.txt", + "reviewed": true, + "sha256": "c5accbbd8546e94c34aed24afe689a617627d18eed5a6c48277e48db57c23851", + "spdx": "Apache-2.0", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/kayak__pypika.1c9646f0/99d75158b583a09e5ececd35cd34434333891b4e/LICENSE.txt" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "patch_sha256": "ddaa8ae3604c51b91242aaace3a255b354eedac3a450beaa22388ba8b58f6fa3", + "provenance_path": "tasks/29738fa7e9c9b474ac0f655e/source-proof.json", + "repository_lineage": [ + "swesmith/kayak__pypika.1c9646f0", + "kayak/pypika" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "99d75158b583a09e5ececd35cd34434333891b4e", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "19f4e0bcfc7008f30945795dee7958402a48fd9e", + "source_kind": "mutation", + "source_repo": "swesmith/kayak__pypika.1c9646f0", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "kayak__pypika.1c9646f0.combine_module__9lguwrtp", + "task_sha256": "183c48cd0a4916d3df9342b0eed3c6dcc419af25fe6db0a8d3dc0952c4d96d20", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "kayak/pypika", + "usage": "quarantine_only" + }, + "task_kind": "original-source-mutation" +} diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/provenance.json b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/provenance.json new file mode 100644 index 0000000000000000000000000000000000000000..e8fb9a777078ac504f6772ae93421801771d946d --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/provenance.json @@ -0,0 +1,88 @@ +{ + "generated_reference": false, + "healthy_reference_delta_sha256": "3672c31c3989ee8e031268fb8637ab05f027f0f540dfb14d46d70290eb11da29", + "native_pytest_ids_preserved": true, + "original_source_code_license": { + "actual_upstream_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "actual_upstream_url": "https://raw.githubusercontent.com/kayak/pypika/1c9646f0a019a167c32b649b6f5e6423c5ba2c9b/LICENSE.txt", + "reviewed": true, + "sha256": "c5accbbd8546e94c34aed24afe689a617627d18eed5a6c48277e48db57c23851", + "spdx": "Apache-2.0", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/kayak__pypika.1c9646f0/99d75158b583a09e5ececd35cd34434333891b4e/LICENSE.txt" + }, + "provided_reference": true, + "qwen_calibrated": false, + "runtime_qualified": false, + "source_completion_sha256": "1b13f8eb2e187083b24685745fc3baac193003f89a0c062e7e3cf37351ad0314", + "source_index_sha256": "e856874b9410fce9f3bfea52c8c482e84b3e43942d87517f8b55f0034bd40f6f", + "source_proof_sha256": "6c5ab9813f9f6d313c12d3e93f2ae11968d56b4076f934c2414447076e52166b", + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:kayak__pypika.1c9646f0.combine_module__9lguwrtp", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "6a742f12bfa386994289ec8b75824663d8ee4b15", + "instruction_sha256": "4436415fb11227783fa942df8cbda0d0457fee39317eaf2b34167e3f10b6505a", + "is_fork": true, + "learner_path": "tasks/29738fa7e9c9b474ac0f655e/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "actual_upstream_url": "https://raw.githubusercontent.com/kayak/pypika/1c9646f0a019a167c32b649b6f5e6423c5ba2c9b/LICENSE.txt", + "reviewed": true, + "sha256": "c5accbbd8546e94c34aed24afe689a617627d18eed5a6c48277e48db57c23851", + "spdx": "Apache-2.0", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/kayak__pypika.1c9646f0/99d75158b583a09e5ececd35cd34434333891b4e/LICENSE.txt" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "patch_sha256": "ddaa8ae3604c51b91242aaace3a255b354eedac3a450beaa22388ba8b58f6fa3", + "provenance_path": "tasks/29738fa7e9c9b474ac0f655e/source-proof.json", + "repository_lineage": [ + "swesmith/kayak__pypika.1c9646f0", + "kayak/pypika" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "99d75158b583a09e5ececd35cd34434333891b4e", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "19f4e0bcfc7008f30945795dee7958402a48fd9e", + "source_kind": "mutation", + "source_repo": "swesmith/kayak__pypika.1c9646f0", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "kayak__pypika.1c9646f0.combine_module__9lguwrtp", + "task_sha256": "183c48cd0a4916d3df9342b0eed3c6dcc419af25fe6db0a8d3dc0952c4d96d20", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "kayak/pypika", + "usage": "quarantine_only" + }, + "task_bundle_license": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + }, + "training_admissible": false, + "trusted_tests_sha256": "f2d0a1b335176a755d627907f32ef330383cf624ff3af2c5ea84ba2b6a2d7ebb" +} diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/provided-gold.diff b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/provided-gold.diff new file mode 100644 index 0000000000000000000000000000000000000000..4cf4f73fcd12942ce966cd572c5cefb6147a413a --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/provided-gold.diff @@ -0,0 +1,67 @@ +diff --git a/pypika/clickhouse/search_string.py b/pypika/clickhouse/search_string.py +index 6fadbced1008bb922ef4d74873b8180191f95c9f..22a03027fcaf3ca0578e63980c00f4be1b2f67e7 100644 +--- a/pypika/clickhouse/search_string.py ++++ b/pypika/clickhouse/search_string.py +@@ -51,9 +51,9 @@ + + class _AbstractMultiSearchString(Function, metaclass=abc.ABCMeta): + def __init__(self, name, patterns: list, alias: str = None): +- super(_AbstractMultiSearchString, self).__init__(self, name, alias=alias) ++ super(_AbstractMultiSearchString, self).__init__(self.clickhouse_function(), name, alias=alias) + +- self._patterns = patterns[::-1] ++ self._patterns = patterns + + @classmethod + @abc.abstractmethod +@@ -64,13 +64,13 @@ + args = [] + for p in self.args: + if hasattr(p, "get_sql"): +- args.append('toString("{arg}")'.format(arg=p.get_sql(with_alias=True, **kwargs))) ++ args.append('toString("{arg}")'.format(arg=p.get_sql(with_alias=False, **kwargs))) + else: + args.append(str(p)) + +- sql = "{name}({args},{{patterns}})".format( ++ sql = "{name}({args},[{patterns}])".format( + name=self.name, +- args=";".join(args), ++ args=",".join(args), + patterns=",".join(["'%s'" % i for i in self._patterns]), + ) + return format_alias_sql(sql, self.alias, **kwargs) +@@ -79,10 +79,10 @@ + class MultiSearchAny(_AbstractMultiSearchString): + @classmethod + def clickhouse_function(cls) -> str: +- return "singleSearchAll" ++ return "multiSearchAny" + + + class MultiMatchAny(_AbstractMultiSearchString): + @classmethod + def clickhouse_function(cls) -> str: +- return "multiMatchAll" ++ return "multiMatchAny" +diff --git a/pypika/clickhouse/type_conversion.py b/pypika/clickhouse/type_conversion.py +index ee28252228f5b43310805950fd5e0702fc489e93..80229b7e755dfb25bba5c4e65828a5d3cf42d988 100644 +--- a/pypika/clickhouse/type_conversion.py ++++ b/pypika/clickhouse/type_conversion.py +@@ -20,12 +20,12 @@ + self.args = () + + def get_sql(self, with_alias=False, with_namespace=False, quote_char=None, dialect=None, **kwargs): +- sql = "{name}({length},{field})".format( ++ sql = "{name}({field},{length})".format( + name=self.name, +- field=str(self._field) if isinstance(self._field, Field) else self._field, +- length=self._length + 1, ++ field=self._field if isinstance(self._field, Field) else "'%s'" % str(self._field), ++ length=self._length, + ) +- return format_alias_sql(sql, None, **kwargs) ++ return format_alias_sql(sql, self.alias, **kwargs) + + + class ToInt8(Function): diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/solution/solve.sh b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..0582770ebc3536879487a1fd95db1afe7196a9c6 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/solution/solve.sh @@ -0,0 +1,73 @@ +#!/bin/bash +set -Eeuo pipefail +cd /testbed/repo +cat > /tmp/openenv-reference.diff <<'OPENENV_REFERENCE' +diff --git a/pypika/clickhouse/search_string.py b/pypika/clickhouse/search_string.py +index 6fadbced1008bb922ef4d74873b8180191f95c9f..22a03027fcaf3ca0578e63980c00f4be1b2f67e7 100644 +--- a/pypika/clickhouse/search_string.py ++++ b/pypika/clickhouse/search_string.py +@@ -51,9 +51,9 @@ + + class _AbstractMultiSearchString(Function, metaclass=abc.ABCMeta): + def __init__(self, name, patterns: list, alias: str = None): +- super(_AbstractMultiSearchString, self).__init__(self, name, alias=alias) ++ super(_AbstractMultiSearchString, self).__init__(self.clickhouse_function(), name, alias=alias) + +- self._patterns = patterns[::-1] ++ self._patterns = patterns + + @classmethod + @abc.abstractmethod +@@ -64,13 +64,13 @@ + args = [] + for p in self.args: + if hasattr(p, "get_sql"): +- args.append('toString("{arg}")'.format(arg=p.get_sql(with_alias=True, **kwargs))) ++ args.append('toString("{arg}")'.format(arg=p.get_sql(with_alias=False, **kwargs))) + else: + args.append(str(p)) + +- sql = "{name}({args},{{patterns}})".format( ++ sql = "{name}({args},[{patterns}])".format( + name=self.name, +- args=";".join(args), ++ args=",".join(args), + patterns=",".join(["'%s'" % i for i in self._patterns]), + ) + return format_alias_sql(sql, self.alias, **kwargs) +@@ -79,10 +79,10 @@ + class MultiSearchAny(_AbstractMultiSearchString): + @classmethod + def clickhouse_function(cls) -> str: +- return "singleSearchAll" ++ return "multiSearchAny" + + + class MultiMatchAny(_AbstractMultiSearchString): + @classmethod + def clickhouse_function(cls) -> str: +- return "multiMatchAll" ++ return "multiMatchAny" +diff --git a/pypika/clickhouse/type_conversion.py b/pypika/clickhouse/type_conversion.py +index ee28252228f5b43310805950fd5e0702fc489e93..80229b7e755dfb25bba5c4e65828a5d3cf42d988 100644 +--- a/pypika/clickhouse/type_conversion.py ++++ b/pypika/clickhouse/type_conversion.py +@@ -20,12 +20,12 @@ + self.args = () + + def get_sql(self, with_alias=False, with_namespace=False, quote_char=None, dialect=None, **kwargs): +- sql = "{name}({length},{field})".format( ++ sql = "{name}({field},{length})".format( + name=self.name, +- field=str(self._field) if isinstance(self._field, Field) else self._field, +- length=self._length + 1, ++ field=self._field if isinstance(self._field, Field) else "'%s'" % str(self._field), ++ length=self._length, + ) +- return format_alias_sql(sql, None, **kwargs) ++ return format_alias_sql(sql, self.alias, **kwargs) + + + class ToInt8(Function): +OPENENV_REFERENCE +/usr/bin/git -c core.hooksPath=/dev/null -c core.fsmonitor=false apply --whitespace=nowarn /tmp/openenv-reference.diff diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/task.toml b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..57c9636ecd417e52441d94273992a89f10dd5619 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/task.toml @@ -0,0 +1,24 @@ +version = "1.0" + +[agent] +timeout_sec = 1800.0 + +[verifier] +timeout_sec = 900.0 + +[environment] +docker_image = "ghcr.io/younesbelkada/scale800@sha256:2e1bc5f96fb72d95cbc7a191c58149def366990cf83ed1f7c0af5ea7f36331ab" +build_timeout_sec = 600.0 +cpus = 2 +memory_mb = 8192 +storage_mb = 16384 + +[metadata] +author_name = "SWE-smith source adapter" +category = "bugfix" +tags = ["swe", "python", "mutation-repair"] + +[environment.env] +# The image's PATH with the testbed env first: the project and pytest are installed there, and the agent's +# non-interactive shells never run `conda activate` +PATH = "/opt/miniconda3/envs/testbed/bin:/opt/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/check_pytest.py b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/check_pytest.py new file mode 100644 index 0000000000000000000000000000000000000000..7abfdc5972f57ca7f0cecbbeeb373414670f780e --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/check_pytest.py @@ -0,0 +1,177 @@ +"""Preserve confirmed requested assertion failures; keep positive checks strict.""" + +import argparse +import hashlib +import json +import re +import xml.etree.ElementTree as ET +from pathlib import Path + +GROUPS = ("pass-to-pass", "fail-to-pass") + + +def split_nodeid(target): + prefix, bracket, parameter = target.partition("[") + parts = prefix.split("::") + if bracket: + parts[-1] += bracket + parameter + return parts + + +def matches(case, target): + parts = split_nodeid(target) + module = parts[0].removesuffix(".py").replace("/", ".") + classname, name = case.get("classname", ""), case.get("name", "") + if not (classname == module or classname.startswith(module + ".")): + return False + selector = parts[-1] if len(parts) > 1 else "" + classes = parts[1:-1] + if classes and classname != module + "." + ".".join(classes): + return False + return ( + not selector + or name == selector + or ("[" not in selector and name.startswith(selector + "[")) + ) + + +def capture_panels(root): + panels, digests = {}, {} + for group in GROUPS: + path = Path(root) / (group + ".xml") + if not path.exists(): + panels[group] = None + continue + with path.open("rb") as stream: + raw = stream.read(4 * 1024**2 + 1) + if not 0 < len(raw) <= 4 * 1024**2 or re.search( + rb" 20000: + raise ValueError("Too many pytest cases") + identities = [(case.get("classname"), case.get("name")) for case in cases] + if len(identities) != len(set(identities)): + raise ValueError("Duplicate pytest case evidence") + panels[group] = cases + digests[group] = hashlib.sha256(raw).hexdigest() + return panels, digests + + +def strict_assess(panels, expected, native_exit): + """The original positive-approval conditions, applied to captured cases.""" + all_cases, actual_failure = [], False + for group in GROUPS: + cases = panels[group] + if cases is None: + if actual_failure: + continue + raise ValueError("Missing preceding pytest panel") + if actual_failure: + raise ValueError( + "Pytest evidence continued after the native stop-on-failure" + ) + targets = expected[group] + if any(not any(matches(case, target) for target in targets) for case in cases): + raise ValueError("Unexpected pytest case") + all_cases.extend(cases) + failures = [case for case in cases if case.find("failure") is not None] + if any( + case.find("error") is not None or case.find("skipped") is not None + for case in cases + ): + raise ValueError("Pytest collection/error/skip is not a completed panel") + actual_failure = actual_failure or bool(failures) + if not failures and any( + not any(matches(case, target) for case in cases) for target in targets + ): + raise ValueError("Declared pytest target never ran") + if actual_failure: + if native_exit == 0: + raise ValueError("Native verifier exit disagrees with pytest failure") + return {"reward": 0, "valid_test_failure": True, "cases": len(all_cases)} + if native_exit != 0: + raise ValueError("Setup or native verifier failed without a real test failure") + if any(panels[group] is None for group in GROUPS): + raise ValueError("Missing completed pytest panel") + return {"reward": 1, "valid_test_failure": False, "cases": len(all_cases)} + + +def assess(root, expected, native_exit): + if type(native_exit) is not int: + raise ValueError("Native verifier exit must be an integer") + if not isinstance(expected, dict) or any( + not isinstance(expected.get(group), list) + or not expected[group] + or any(not isinstance(target, str) or not target for target in expected[group]) + for group in GROUPS + ): + raise ValueError("Complete exact native pytest targets required") + panels, digests = capture_panels(root) + counts = { + "cases": 0, + "matched_failures": 0, + "unexpected_cases": 0, + "unmatched_failures": 0, + "skipped_cases": 0, + "error_cases": 0, + "missing_panels": 0, + "missing_targets": 0, + } + for group in GROUPS: + cases = panels[group] + if cases is None: + counts["missing_panels"] += 1 + counts["missing_targets"] += len(expected[group]) + continue + counts["cases"] += len(cases) + for case in cases: + requested = any(matches(case, target) for target in expected[group]) + failure = case.find("failure") is not None + counts["matched_failures"] += int(requested and failure) + counts["unmatched_failures"] += int(not requested and failure) + counts["unexpected_cases"] += int(not requested) + counts["skipped_cases"] += int(case.find("skipped") is not None) + counts["error_cases"] += int(case.find("error") is not None) + counts["missing_targets"] += sum( + not any(matches(case, target) for case in cases) + for target in expected[group] + ) + if counts["matched_failures"]: + if native_exit == 0: + raise ValueError( + "Native verifier exit disagrees with requested pytest failure" + ) + return { + "reward": 0, + "valid_test_failure": True, + "cases": counts["cases"], + "diagnostic_counts": counts, + "panel_sha256": digests, + "decision": "confirmed_requested_failure_precedence", + } + result = strict_assess(panels, expected, native_exit) + result.update(diagnostic_counts=counts, panel_sha256=digests) + return result + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("--root", required=True) + parser.add_argument("--expected", required=True) + parser.add_argument("--native-exit", type=int, required=True) + args = parser.parse_args() + result = assess( + args.root, json.loads(Path(args.expected).read_bytes()), args.native_exit + ) + reward = Path(args.root) / "reward.txt" + if reward.read_text().strip() != str(result["reward"]): + raise ValueError("Native raw reward disagrees with pytest evidence") + (Path(args.root) / "pytest-evidence.json").write_text( + json.dumps(result, sort_keys=True) + "\n" + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/expected-panels.json b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/expected-panels.json new file mode 100644 index 0000000000000000000000000000000000000000..7647ecc5a95119d10003ffba047c09a8ddb189a7 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/expected-panels.json @@ -0,0 +1,1067 @@ +{ + "fail-to-pass": [ + "pypika/tests/clickhouse/test_array.py::TestArray::test_get_sql_3__toFixedString_mogwai_10_toFixedString_mono_10_toFixedString_bonobo_10_arr", + "pypika/tests/clickhouse/test_array.py::TestHasAny::test_get_sql_2_hasAny_bands_toFixedString_port_royal_20_toFixedString_hammock_20_", + "pypika/tests/clickhouse/test_condition.py::TestIfCondition::test_get_sql_0", + "pypika/tests/clickhouse/test_condition.py::TestIfCondition::test_get_sql_1", + "pypika/tests/clickhouse/test_condition.py::TestMultiIfCondition::test_get_sql_0", + "pypika/tests/clickhouse/test_condition.py::TestMultiIfCondition::test_get_sql_1", + "pypika/tests/clickhouse/test_nullable_arg.py::TestSearchString::test_get_sql_1", + "pypika/tests/clickhouse/test_search_string.py::TestMultiSearch::test_multi_search_string_0", + "pypika/tests/clickhouse/test_search_string.py::TestMultiSearch::test_multi_search_string_1", + "pypika/tests/clickhouse/test_type_conversion.py::TestToFixedString::test_get_sql_with_table" + ], + "pass-to-pass": [ + "pypika/tests/clickhouse/test_array.py::TestArray::test_get_sql_0__ridley_scott_jimi_hendrix_", + "pypika/tests/clickhouse/test_array.py::TestArray::test_get_sql_1__1_2_3_4_", + "pypika/tests/clickhouse/test_array.py::TestArray::test_get_sql_2__toInt64_1_toInt64_2_toInt64_3_toInt64_4_", + "pypika/tests/clickhouse/test_array.py::TestHasAny::test_get_sql_0_hasAny_mental_abilities_physical_abilities_", + "pypika/tests/clickhouse/test_array.py::TestHasAny::test_get_sql_1_hasAny_1_2_3_4_3_", + "pypika/tests/clickhouse/test_array.py::TestLength::test_get_sql_0_length_tags_", + "pypika/tests/clickhouse/test_array.py::TestLength::test_get_sql_1_length_1_2_3_", + "pypika/tests/clickhouse/test_array.py::TestEmpty::test_get_sql_0_empty_tags_", + "pypika/tests/clickhouse/test_array.py::TestEmpty::test_get_sql_1_empty_1_2_3_", + "pypika/tests/clickhouse/test_array.py::TestNotEmpty::test_get_sql_0_notEmpty_tags_", + "pypika/tests/clickhouse/test_array.py::TestNotEmpty::test_get_sql_1_notEmpty_1_2_3_", + "pypika/tests/clickhouse/test_dates_and_times.py::TestFormatDateTime::test_get_sql_0", + "pypika/tests/clickhouse/test_dates_and_times.py::TestFormatDateTime::test_get_sql_1", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_00", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_01", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_02", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_03", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_04", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_05", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_06", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_07", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_08", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_09", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_10", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_11", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_12", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_13", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_14", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_15", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_16", + "pypika/tests/clickhouse/test_dates_and_times.py::TestToYYYYMM::test_get_sql", + "pypika/tests/clickhouse/test_nullable_arg.py::TestSearchString::test_get_sql_0", + "pypika/tests/clickhouse/test_search_string.py::TestSearchString::test_search_string_0", + "pypika/tests/clickhouse/test_search_string.py::TestSearchString::test_search_string_1", + "pypika/tests/clickhouse/test_search_string.py::TestSearchString::test_search_string_2", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_00_toString_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_01_toInt8_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_02_toInt16_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_03_toInt32_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_04_toInt64_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_05_toUInt8_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_06_toUInt16_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_07_toUInt32_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_08_toUInt64_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_09_toFloat32_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_10_toFloat64_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_11_toFloat64_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_12_toDate_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_13_toDateTime_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_14_toFixedString_field_name_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_00_toString_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_01_toInt8_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_02_toInt16_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_03_toInt32_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_04_toInt64_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_05_toUInt8_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_06_toUInt16_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_07_toUInt32_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_08_toUInt64_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_09_toFloat32_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_10_toFloat64_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_11_toFloat64_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_12_toDate_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_13_toDateTime_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_14_toFixedString_100_100_", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseQueryTests::test_use_AS_keyword_for_alias", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseQueryTests::test_use_FINAL_keyword", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseQueryTests::test_use_SAMPLE_keyword", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseQueryTests::test_use_SAMPLE_with_offset_keyword", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDeleteTests::test_omit_where", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDeleteTests::test_omit_where__table_schema", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDeleteTests::test_where_field_equals", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseUpdateTests::test_update", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDropQuery::test_drop_database", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDropQuery::test_drop_dictionary", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDropQuery::test_drop_other", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDropQuery::test_drop_table", + "pypika/tests/dialects/test_clickhouse.py::DistinctOnTests::test_distinct_on", + "pypika/tests/dialects/test_clickhouse.py::LimitByTests::test_limit_by", + "pypika/tests/dialects/test_clickhouse.py::LimitByTests::test_limit_offset0_by", + "pypika/tests/dialects/test_clickhouse.py::LimitByTests::test_limit_offset_by", + "pypika/tests/dialects/test_clickhouse.py::LimitByTests::test_rename_table", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_distinct_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_groupby_alias_False_does_not_group_by_alias_when_subqueries_are_present", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_groupby_alias_False_does_not_group_by_alias_with_standard_query", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_limit", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_limit_with_offset", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_normal_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_offset", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_distinct_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_percent_invalid_range", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_percent_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_select_non_int", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_with_ties_select", + "pypika/tests/dialects/test_mysql.py::SelectTests::test_distinct_select", + "pypika/tests/dialects/test_mysql.py::SelectTests::test_modifier_select", + "pypika/tests/dialects/test_mysql.py::SelectTests::test_multiple_modifier_select", + "pypika/tests/dialects/test_mysql.py::SelectTests::test_normal_select", + "pypika/tests/dialects/test_mysql.py::UpdateTests::test_conflict_handlers_update", + "pypika/tests/dialects/test_mysql.py::UpdateTests::test_on_duplicate_key_ignore_update", + "pypika/tests/dialects/test_mysql.py::UpdateTests::test_on_duplicate_key_update_update", + "pypika/tests/dialects/test_mysql.py::UpdateTests::test_update", + "pypika/tests/dialects/test_mysql.py::LoadCSVTests::test_load_from_file", + "pypika/tests/dialects/test_mysql.py::TableTests::test_create_table", + "pypika/tests/dialects/test_mysql.py::TableTests::test_drop_table", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_fetch_next_method_deprecated", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_groupby_alias_False_does_not_group_by_alias_when_subqueries_are_present", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_groupby_alias_False_does_not_group_by_alias_with_standard_query", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_limit_offset_query", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_limit_query", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_offset_query", + "pypika/tests/dialects/test_postgresql.py::InsertTests::test_array_keyword", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_alias_set_correctly", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_json_value_from_array_num", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_json_value_from_array_str", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_json_value_from_dict", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_json_value_from_dict_recursive", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_json_value_by_index", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_json_value_by_key", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_path_json_value", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_path_text_value", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_text_value_by_index", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_text_value_by_key", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contained_by_using_list_arg", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contained_by_using_str_arg", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contained_by_with_complex_criterion", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contains_for_field", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contains_for_json", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_has_any_keys", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_has_key", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_has_keys", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_subnet_contains_inet", + "pypika/tests/dialects/test_postgresql.py::DistinctOnTests::test_distinct_on", + "pypika/tests/dialects/test_postgresql.py::ArrayTests::test_array_syntax", + "pypika/tests/dialects/test_postgresql.py::ArrayTests::test_render_alias_in_array_sql", + "pypika/tests/dialects/test_postgresql.py::ReturningClauseTests::test_no_queryexception_if_returning_used_on_valid_query_type", + "pypika/tests/dialects/test_postgresql.py::ReturningClauseTests::test_queryexception_if_returning_used_on_invalid_query", + "pypika/tests/dialects/test_postgresql.py::ReturningClauseTests::test_return_field_from_join_table", + "pypika/tests/dialects/test_postgresql.py::ReturningClauseTests::test_returning_from_missing_table_raises_queryexception", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_dont_use_double_quotes_on_create_queries", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_dont_use_double_quotes_on_drop_queries", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_dont_use_double_quotes_on_joining_queries", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_use_double_quotes_on_alias_but_not_on_terms", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_use_double_quotes_on_alias_but_not_on_terms_with_joins", + "pypika/tests/dialects/test_sqllite.py::SelectTests::test_bool_false_as_zero", + "pypika/tests/dialects/test_sqllite.py::SelectTests::test_bool_true_as_one", + "pypika/tests/dialects/test_sqllite.py::ReplaceTests::test_insert_or_replace", + "pypika/tests/dialects/test_sqllite.py::ReplaceTests::test_normal_replace", + "pypika/tests/dialects/test_sqllite.py::ReplaceTests::test_replace_subquery", + "pypika/tests/dialects/test_vertica.py::VerticaQueryTests::test_delete_query_with_hint", + "pypika/tests/dialects/test_vertica.py::VerticaQueryTests::test_insert_query_with_hint", + "pypika/tests/dialects/test_vertica.py::VerticaQueryTests::test_select_query_with_hint", + "pypika/tests/dialects/test_vertica.py::VerticaQueryTests::test_update_query_with_hint", + "pypika/tests/dialects/test_vertica.py::CopyCSVTests::test_copy_from_file", + "pypika/tests/dialects/test_vertica.py::CreateTemporaryTableTests::test_create_local_table_without_temporary_raises_error", + "pypika/tests/dialects/test_vertica.py::CreateTemporaryTableTests::test_create_local_temporary_table", + "pypika/tests/dialects/test_vertica.py::CreateTemporaryTableTests::test_create_table_preserve_rows_without_temporary_raises_error", + "pypika/tests/dialects/test_vertica.py::CreateTemporaryTableTests::test_create_temporary_table_preserve_rows", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__agg_case_criterion_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__agg_case_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__agg_func_arithmetic_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__agg_func_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__case_mixed_constant_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__case_mixed_else_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__case_with_field_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__case_with_single_aggregate_field_in_one_criterion_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__constant_arithmetic_is_aggregate_none", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__constant_is_aggregate_none", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__field_arithmetic_constant_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__field_arithmetic_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__field_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__func_arithmetic_constant_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__mixed_case_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__mixed_func_arithmetic_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__negative_agg_func_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__non_aggregate_function_with_aggregated_arg", + "pypika/tests/test_aggregate.py::IsAggregateTests::test_complicated", + "pypika/tests/test_analytic_queries.py::RankTests::test_avg", + "pypika/tests/test_analytic_queries.py::RankTests::test_count_range_between_unbounded_preceeding_current_row", + "pypika/tests/test_analytic_queries.py::RankTests::test_dense_rank", + "pypika/tests/test_analytic_queries.py::RankTests::test_empty_over", + "pypika/tests/test_analytic_queries.py::RankTests::test_filter", + "pypika/tests/test_analytic_queries.py::RankTests::test_filter_quote_table_in_filter", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value_ignore_nulls", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value_ignore_nulls_first", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value_multi_argument", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value_range_between_x_preceeding_unbounded_following", + "pypika/tests/test_analytic_queries.py::RankTests::test_lag_generates_correct_sql", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value_ignore_nulls", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value_multi_argument", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value_rows_between_current_row_unbounded_following", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value_rows_between_current_row_unbounded_following_ignore_nulls", + "pypika/tests/test_analytic_queries.py::RankTests::test_lead_generates_correct_sql", + "pypika/tests/test_analytic_queries.py::RankTests::test_max_range_x_preceeding", + "pypika/tests/test_analytic_queries.py::RankTests::test_max_rows_x_preceeding", + "pypika/tests/test_analytic_queries.py::RankTests::test_median", + "pypika/tests/test_analytic_queries.py::RankTests::test_min_range_current_row", + "pypika/tests/test_analytic_queries.py::RankTests::test_min_rows_current_row", + "pypika/tests/test_analytic_queries.py::RankTests::test_multiple_partitions", + "pypika/tests/test_analytic_queries.py::RankTests::test_ntile_no_partition_or_order_invalid_sql", + "pypika/tests/test_analytic_queries.py::RankTests::test_ntile_with_order", + "pypika/tests/test_analytic_queries.py::RankTests::test_ntile_with_partition", + "pypika/tests/test_analytic_queries.py::RankTests::test_ntile_with_partition_and_order", + "pypika/tests/test_analytic_queries.py::RankTests::test_orderby_asc", + "pypika/tests/test_analytic_queries.py::RankTests::test_orderby_desc", + "pypika/tests/test_analytic_queries.py::RankTests::test_range_called_twice_raises_attribute_error", + "pypika/tests/test_analytic_queries.py::RankTests::test_range_then_rows_raises_attribute_error", + "pypika/tests/test_analytic_queries.py::RankTests::test_rank", + "pypika/tests/test_analytic_queries.py::RankTests::test_rank_with_alias", + "pypika/tests/test_analytic_queries.py::RankTests::test_row_number", + "pypika/tests/test_analytic_queries.py::RankTests::test_rows_called_twice_raises_attribute_error", + "pypika/tests/test_analytic_queries.py::RankTests::test_rows_then_range_raises_attribute_error", + "pypika/tests/test_analytic_queries.py::RankTests::test_stddev", + "pypika/tests/test_analytic_queries.py::RankTests::test_stddev_pop", + "pypika/tests/test_analytic_queries.py::RankTests::test_stddev_samp", + "pypika/tests/test_analytic_queries.py::RankTests::test_sum_rows_unbounded_preceeding", + "pypika/tests/test_analytic_queries.py::RankTests::test_table_prefixes_used_in_analytic_functions", + "pypika/tests/test_analytic_queries.py::RankTests::test_var_pop", + "pypika/tests/test_analytic_queries.py::RankTests::test_var_samp", + "pypika/tests/test_analytic_queries.py::RankTests::test_variance", + "pypika/tests/test_analytic_queries.py::RankTests::test_variance_rows_between_unbounded_preceeding_unbounded_following", + "pypika/tests/test_analytic_queries.py::RankTests::test_varpop_range_unbounded_preceeding", + "pypika/tests/test_analytic_queries.py::RankTests::test_varpop_rows_between_unbounded_preceeding_x_following", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_as_select_not_query_raises_error", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_with_columns", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_with_select", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_with_select_and_columns_fails", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_without_columns_or_select_empty", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_if_not_exists", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_simple", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_unique", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_where", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_without_columns_raises_error", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_without_table_raises_error", + "pypika/tests/test_criterions.py::CriterionTests::test__bitwise_and_in_where_clause", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_bitwise_and", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_bitwise_and_with_alias", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_bool", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_decimal", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_str", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gt_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gt_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gt_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gt_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gte_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gte_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gte_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gte_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_is_null", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_is_null_with_alias", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lt_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lt_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lt_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lt_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lte_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lte_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lte_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lte_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_str", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_with_alias", + "pypika/tests/test_criterions.py::NotTests::test_chained_function", + "pypika/tests/test_criterions.py::NotTests::test_is_not_null", + "pypika/tests/test_criterions.py::NotTests::test_negate", + "pypika/tests/test_criterions.py::NotTests::test_not_null", + "pypika/tests/test_criterions.py::NotTests::test_not_null_with_alias", + "pypika/tests/test_criterions.py::NotTests::test_not_with_and_criterion", + "pypika/tests/test_criterions.py::NotTests::test_not_with_complex_criterion", + "pypika/tests/test_criterions.py::NotTests::test_not_with_or_criterion", + "pypika/tests/test_criterions.py::NotTests::test_notnullcriterion_replace_table", + "pypika/tests/test_criterions.py::NotTests::test_variable_access", + "pypika/tests/test_criterions.py::BetweenTests::test__between_date", + "pypika/tests/test_criterions.py::BetweenTests::test__between_datetime", + "pypika/tests/test_criterions.py::BetweenTests::test__between_number", + "pypika/tests/test_criterions.py::BetweenTests::test__between_with_alias", + "pypika/tests/test_criterions.py::BetweenTests::test__function_between", + "pypika/tests/test_criterions.py::BetweenTests::test_get_item_only_works_with_slice", + "pypika/tests/test_criterions.py::IsInTests::test__function_isin", + "pypika/tests/test_criterions.py::IsInTests::test__in_character", + "pypika/tests/test_criterions.py::IsInTests::test__in_date", + "pypika/tests/test_criterions.py::IsInTests::test__in_datetime", + "pypika/tests/test_criterions.py::IsInTests::test__in_number", + "pypika/tests/test_criterions.py::IsInTests::test__in_number_with_alias", + "pypika/tests/test_criterions.py::IsInTests::test__in_unicode", + "pypika/tests/test_criterions.py::ArithmeticExpressionTests::test__lshift", + "pypika/tests/test_criterions.py::ArithmeticExpressionTests::test__rshift", + "pypika/tests/test_criterions.py::NotInTests::test__function_notin", + "pypika/tests/test_criterions.py::NotInTests::test__notin_character", + "pypika/tests/test_criterions.py::NotInTests::test__notin_date", + "pypika/tests/test_criterions.py::NotInTests::test__notin_datetime", + "pypika/tests/test_criterions.py::NotInTests::test__notin_number", + "pypika/tests/test_criterions.py::NotInTests::test__notin_number_with_alias", + "pypika/tests/test_criterions.py::LikeTests::test_glob_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_contains", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_ends_with", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_n_chars_long", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_starts_with", + "pypika/tests/test_criterions.py::LikeTests::test_like_contains", + "pypika/tests/test_criterions.py::LikeTests::test_like_ends_with", + "pypika/tests/test_criterions.py::LikeTests::test_like_n_chars_long", + "pypika/tests/test_criterions.py::LikeTests::test_like_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_like_starts_with", + "pypika/tests/test_criterions.py::LikeTests::test_not_ilike_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_not_like_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_rlike_escape_chars", + "pypika/tests/test_criterions.py::ExistsCriterionTests::test_exists", + "pypika/tests/test_criterions.py::ExistsCriterionTests::test_not_exists", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__between_and_field", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__between_and_isin", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__nested__and", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__nested__mixed", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__nested__or", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_and", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_function_and", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_function_or", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_function_xor", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_or", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_xor", + "pypika/tests/test_criterions.py::FieldsAsCriterionTests::test__field_and_field", + "pypika/tests/test_criterions.py::FieldsAsCriterionTests::test__field_or_field", + "pypika/tests/test_criterions.py::FieldsAsCriterionTests::test__field_xor_field", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_arithmeticfunction_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_betweencriterion_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_complexcriterion_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_criterion_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_field_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_function_with_only_fields_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_function_with_values_and_fields_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_nullcriterion_replace_table", + "pypika/tests/test_criterions.py::AnyTests::test_multiple_args_returned_in_chain_of_ors", + "pypika/tests/test_criterions.py::AnyTests::test_single_arg_returns_self", + "pypika/tests/test_criterions.py::AnyTests::test_with_generator", + "pypika/tests/test_criterions.py::AnyTests::test_zero_args_returns_empty_criterion", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_different_operations_with_empty_criterion", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_empty_criterion_on_the_left", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_empty_criterion_on_the_right", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_fields_", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_invertion_of_the_empty_criterion", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_more_than_one_empty_criterions", + "pypika/tests/test_criterions.py::AllTests::test_multiple_args_returned_in_chain_of_ors", + "pypika/tests/test_criterions.py::AllTests::test_single_arg_returns_self", + "pypika/tests/test_criterions.py::AllTests::test_with_generator", + "pypika/tests/test_criterions.py::AllTests::test_zero_args_returns_empty_criterion", + "pypika/tests/test_custom_functions.py::TestUnitCustomFunction::test_should_fail_with_wrong_arguments", + "pypika/tests/test_custom_functions.py::TestUnitCustomFunction::test_should_return_function_with_arguments", + "pypika/tests/test_custom_functions.py::TestUnitCustomFunction::test_should_return_function_with_no_arguments", + "pypika/tests/test_custom_functions.py::TestFunctionalCustomFunction::test_should_fail_use_custom_function_on_select_with_wrong_arguments", + "pypika/tests/test_custom_functions.py::TestFunctionalCustomFunction::test_should_use_custom_function_on_select", + "pypika/tests/test_data_types.py::StringTests::test_inline_string_concatentation", + "pypika/tests/test_data_types.py::UuidTests::test_uuid_string_generation", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_day", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_default", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_microsecond", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_minute", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_month", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_quarter", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_second", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_week", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_year", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_day_hour", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_day_microsecond", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_day_minute", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_day_second", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_hour_microsecond", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_hour_minute", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_hour_second", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_minute_microsecond", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_minute_second", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_second_microsecond", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_value_complex_expressions", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_value_right", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_year_month", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_mysql_dialect_uses_single_quotes_around_expression_in_an_interval", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_oracle_dialect_uses_single_quotes_around_expression_in_an_interval", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_postgresql_dialect_uses_single_quotes_around_interval", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_redshift_dialect_uses_single_quotes_around_interval", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_vertica_dialect_uses_single_quotes_around_interval", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_day", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_month", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_week", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_year", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_year_month", + "pypika/tests/test_date_math.py::TruncateTrailingZerosTests::test_do_not_truncate_integer_values", + "pypika/tests/test_date_math.py::TruncateTrailingZerosTests::test_do_not_truncate_months_between_years_and_datys", + "pypika/tests/test_deletes.py::DeleteTests::test_for_portion", + "pypika/tests/test_deletes.py::DeleteTests::test_omit_where", + "pypika/tests/test_deletes.py::DeleteTests::test_omit_where__table_schema", + "pypika/tests/test_deletes.py::DeleteTests::test_where_field_equals", + "pypika/tests/test_deletes.py::PostgresDeleteTests::test_delete_returning", + "pypika/tests/test_deletes.py::PostgresDeleteTests::test_delete_returning_star", + "pypika/tests/test_deletes.py::PostgresDeleteTests::test_delete_returning_str", + "pypika/tests/test_deletes.py::PostgresDeleteTests::test_delete_using", + "pypika/tests/test_drop.py::DropTableTests::test_drop_database", + "pypika/tests/test_drop.py::DropTableTests::test_drop_index", + "pypika/tests/test_drop.py::DropTableTests::test_drop_table", + "pypika/tests/test_drop.py::DropTableTests::test_drop_user", + "pypika/tests/test_drop.py::DropTableTests::test_drop_view", + "pypika/tests/test_formats.py::QuoteTests::test_no_quote_char_in_complex_query", + "pypika/tests/test_formats.py::QuoteTests::test_replace_quote_char_in_complex_query", + "pypika/tests/test_functions.py::FunctionTests::test_dialect_propagation", + "pypika/tests/test_functions.py::FunctionTests::test_is_aggregate_None_for_non_aggregate_function_or_function_with_no_aggregate_functions", + "pypika/tests/test_functions.py::FunctionTests::test_is_aggregate_True_for_aggregate_function_or_function_with_aggregate_functions", + "pypika/tests/test_functions.py::SchemaTests::test_schema_included_in_function_sql", + "pypika/tests/test_functions.py::SchemaTests::test_schema_no_schema_in_sql_when_none_set", + "pypika/tests/test_functions.py::ArithmeticTests::test__addition__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__addition__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__addition__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__addition__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__arithmetic_equality", + "pypika/tests/test_functions.py::ArithmeticTests::test__arithmetic_with_function", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_add_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_div_no_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_div_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_exponent_no_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_exponent_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_floor_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_function_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_modulus_no_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_modulus_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_mul_no_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_mul_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_nested_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_sub_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__division__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__division__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__division__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__division__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__exponent__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__exponent__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__floor", + "pypika/tests/test_functions.py::ArithmeticTests::test__leftshift__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__leftshift__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__leftshift__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__modulus__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__multiplication__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__multiplication__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__multiplication__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__multiplication__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__rightshift__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__rightshift__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__rightshift__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__subtraction__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__subtraction__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__subtraction__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__subtraction__right", + "pypika/tests/test_functions.py::AggregationTests::test__approx_percentile", + "pypika/tests/test_functions.py::AggregationTests::test__avg", + "pypika/tests/test_functions.py::AggregationTests::test__count", + "pypika/tests/test_functions.py::AggregationTests::test__count__star", + "pypika/tests/test_functions.py::AggregationTests::test__first", + "pypika/tests/test_functions.py::AggregationTests::test__last", + "pypika/tests/test_functions.py::AggregationTests::test__max", + "pypika/tests/test_functions.py::AggregationTests::test__min", + "pypika/tests/test_functions.py::AggregationTests::test__std", + "pypika/tests/test_functions.py::AggregationTests::test__stddev", + "pypika/tests/test_functions.py::AggregationTests::test__subquery_in_params_functions", + "pypika/tests/test_functions.py::AggregationTests::test__sum", + "pypika/tests/test_functions.py::ConditionTests::test__case__else", + "pypika/tests/test_functions.py::ConditionTests::test__case__field", + "pypika/tests/test_functions.py::ConditionTests::test__case__multi", + "pypika/tests/test_functions.py::ConditionTests::test__case__no_cases", + "pypika/tests/test_functions.py::ConditionTests::test__case__raw", + "pypika/tests/test_functions.py::StringTests::test__ascii__field", + "pypika/tests/test_functions.py::StringTests::test__ascii__int", + "pypika/tests/test_functions.py::StringTests::test__ascii__str", + "pypika/tests/test_functions.py::StringTests::test__bin__field", + "pypika/tests/test_functions.py::StringTests::test__bin__int", + "pypika/tests/test_functions.py::StringTests::test__bin__str", + "pypika/tests/test_functions.py::StringTests::test__concat__field", + "pypika/tests/test_functions.py::StringTests::test__concat__str", + "pypika/tests/test_functions.py::StringTests::test__insert__field", + "pypika/tests/test_functions.py::StringTests::test__insert__str", + "pypika/tests/test_functions.py::StringTests::test__length__field", + "pypika/tests/test_functions.py::StringTests::test__length__str", + "pypika/tests/test_functions.py::StringTests::test__lower__field", + "pypika/tests/test_functions.py::StringTests::test__lower__str", + "pypika/tests/test_functions.py::StringTests::test__replace__field", + "pypika/tests/test_functions.py::StringTests::test__replace__str", + "pypika/tests/test_functions.py::StringTests::test__substring", + "pypika/tests/test_functions.py::SplitPartFunctionTests::test__split_part", + "pypika/tests/test_functions.py::RegexpLikeFunctionTests::test__regexp_like", + "pypika/tests/test_functions.py::CastTests::test__cast__as", + "pypika/tests/test_functions.py::CastTests::test__cast__binary", + "pypika/tests/test_functions.py::CastTests::test__cast__binary_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__boolean", + "pypika/tests/test_functions.py::CastTests::test__cast__char", + "pypika/tests/test_functions.py::CastTests::test__cast__char_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__date", + "pypika/tests/test_functions.py::CastTests::test__cast__float", + "pypika/tests/test_functions.py::CastTests::test__cast__integer", + "pypika/tests/test_functions.py::CastTests::test__cast__long_varbinary", + "pypika/tests/test_functions.py::CastTests::test__cast__long_varbinary_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__long_varchar", + "pypika/tests/test_functions.py::CastTests::test__cast__long_varchar_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__numeric", + "pypika/tests/test_functions.py::CastTests::test__cast__signed", + "pypika/tests/test_functions.py::CastTests::test__cast__timestamp", + "pypika/tests/test_functions.py::CastTests::test__cast__unsigned", + "pypika/tests/test_functions.py::CastTests::test__cast__varbinary", + "pypika/tests/test_functions.py::CastTests::test__cast__varbinary_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__varchar", + "pypika/tests/test_functions.py::CastTests::test__cast__varchar_with_arg", + "pypika/tests/test_functions.py::CastTests::test__tochar__", + "pypika/tests/test_functions.py::DateFunctionsTests::test_current_date", + "pypika/tests/test_functions.py::DateFunctionsTests::test_current_time", + "pypika/tests/test_functions.py::DateFunctionsTests::test_current_timestamp", + "pypika/tests/test_functions.py::DateFunctionsTests::test_current_timestamp_with_alias", + "pypika/tests/test_functions.py::DateFunctionsTests::test_date_add", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_day", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_hour", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_join", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_microsecond", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_minute", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_month", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_quarter", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_second", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_week", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_year", + "pypika/tests/test_functions.py::DateFunctionsTests::test_now", + "pypika/tests/test_functions.py::DateFunctionsTests::test_time_diff", + "pypika/tests/test_functions.py::DateFunctionsTests::test_timestampadd", + "pypika/tests/test_functions.py::DateFunctionsTests::test_to_date", + "pypika/tests/test_functions.py::DateFunctionsTests::test_utc_timestamp", + "pypika/tests/test_functions.py::NullFunctionsTests::test_coalesce", + "pypika/tests/test_functions.py::NullFunctionsTests::test_isnull", + "pypika/tests/test_functions.py::NullFunctionsTests::test_nullif", + "pypika/tests/test_functions.py::NullFunctionsTests::test_nvl", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_mysql_one_groupby", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_mysql_rollup_two_groupbys", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_no_rollup_after_rollup_mysql", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_no_rollup_before_groupby", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_from_groupbys", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_from_parameters", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_from_two_groupbys", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_func_one_groupby", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_func_partial", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_func_two_groupbys", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_multiple_rollups", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_rollups_with_multiple_rollups_and_parity", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_rollups_with_parity", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_force_index_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_groupby_returns_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_immutable_kwarg_on_query_builder_disables_immutability", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_insert_into_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_join_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_orderby_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_queries_after_join", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_replace_into_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_select_returns_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_update_set_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_use_index_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_with_return_new_query_instance", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_multi_rows", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_multi_rows_chained", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_multi_rows_chained_mixed", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_multi_rows_chained_multiple_rows", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_single_element", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_column_using_alias_with_chain", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_column_using_table_alias", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_empty_columns", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_empty_columns_type_list", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_empty_columns_type_tuple", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_ignore", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_multiple_rows_with_array_value", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_none_skipped", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_null", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_one_column", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_one_column_multi_element_array", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_one_column_single_element_array", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_selected_columns", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_selected_columns_type_list", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_selected_columns_type_tuple", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_single_row_with_array_value", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_with_statement", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_empty_on_conflict_do_update_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_field", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_field_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_mixed_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_multiple_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_multiple_fields_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_field", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_field_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_multiple_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_multiple_fields_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_multiple_mixed_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_no_handler", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_two_handlers_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_two_handlers_do_update", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_fieldless_conflict_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_fieldless_conflict_do_update_field", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_non_insert_on_conflict_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_non_insert_on_conflict_do_update", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_do_nothing_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_do_update_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_do_update_with_excluded_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_from_subquery", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_complex", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_conflict_fields_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_conflict_fields_do_update", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_empty_conflict_fields_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_empty_conflict_fields_do_update", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_where_and_on_conflict_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_all_columns_multi_rows_chained_returning_star", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_all_columns_multi_rows_chained_returning_star_and_id", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_all_columns_multi_rows_chained_returning_star_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_all_columns_single_element_arrays", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_aggregate", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_all_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_all_fields_and_arithmetics", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_arithmetics", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_from_other_table", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_functions", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_null", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_one_field", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_one_field_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_tuple", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_ignore", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multi_rows_chained_mixed_on_duplicate_update_multiple", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_multiple", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_different_value", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_expression", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_expression_using_original_field_value", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_expression_using_values", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_same_value", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_none_skipped", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_one_column", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_one_column_multi_element_array", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_one_column_single_element_array", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_one_column_using_values", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_selected_columns_on_duplicate_update_multiple", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_selected_columns_on_duplicate_update_one", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_columns_from_columns", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_columns_from_columns_with_join", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_columns_from_star", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_from_columns", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_ignore_star", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_star", + "pypika/tests/test_inserts.py::InsertSubqueryTests::test_insert_subquery_wrapped_in_brackets", + "pypika/tests/test_inserts.py::SelectIntoTests::test_select_columns_into", + "pypika/tests/test_inserts.py::SelectIntoTests::test_select_columns_into_with_join", + "pypika/tests/test_inserts.py::SelectIntoTests::test_select_star_into", + "pypika/tests/test_inserts.py::ReplaceTests::test_replace_simple", + "pypika/tests/test_inserts.py::ReplaceTests::test_replace_subquery", + "pypika/tests/test_internals.py::TablesTests::test__case_tables", + "pypika/tests/test_internals.py::TablesTests::test__criterion_replace_table_with_value", + "pypika/tests/test_internals.py::TablesTests::test__star_tables", + "pypika/tests/test_internals.py::TablesTests::test__table_star_tables", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_cross_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_cross_join_on_subquery", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_cross_join_on_table", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_default_join_type", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_full_outer_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_hash_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_inner_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_arithmetic_field", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_collate", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_complex_criteria", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_field_multi", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_field_multi_with_extra_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_field_single", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_field_without_fields_raises_exception", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_subquery_criteria", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_second_table_in_from_clause", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_using_multiple_fields", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_using_string_field_name", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_using_with_quote_char", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_using_without_fields_raises_exception", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_with_arithmetic_function_in_select", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_left_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_left_outer_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_outer_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_right_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_right_outer_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_temporal_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_use_different_table_objects_for_same_table", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_fail_when_joining_unknown_type", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_ignore_table_references", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_immutable__tables", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_from_join", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_query_with_column_alias", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_query_with_setoperation", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_query_with_table_alias", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_query_without_alias", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_same_table", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_same_table_with_prefixes", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_table_twice", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_prefixes_added_to_function_in_orderby", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_prefixes_added_to_groupby", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_prefixes_added_to_orderby", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_require_condition", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_require_condition_with_both_tables", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select__fields_after_table_star", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select__ordered_select_clauses", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select__star_for_table", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select__star_for_table__replacement", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select_field_from_missing_table", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select_fields_with_where", + "pypika/tests/test_joins.py::UnionTests::test_mysql_query_wraps_unioned_queries", + "pypika/tests/test_joins.py::UnionTests::test_require_equal_number_of_fields", + "pypika/tests/test_joins.py::UnionTests::test_union", + "pypika/tests/test_joins.py::UnionTests::test_union_all", + "pypika/tests/test_joins.py::UnionTests::test_union_all_multiple", + "pypika/tests/test_joins.py::UnionTests::test_union_as_subquery", + "pypika/tests/test_joins.py::UnionTests::test_union_multiple", + "pypika/tests/test_joins.py::UnionTests::test_union_with_no_quote_char", + "pypika/tests/test_joins.py::UnionTests::test_union_with_order_by", + "pypika/tests/test_joins.py::UnionTests::test_union_with_order_by_use_union_query_field", + "pypika/tests/test_joins.py::UnionTests::test_union_with_order_by_use_union_query_field_with_aliases", + "pypika/tests/test_joins.py::UnionTests::test_union_with_order_by_with_aliases", + "pypika/tests/test_joins.py::InsertQueryJoinTests::test_join_table_on_insert_query", + "pypika/tests/test_joins.py::UpdateQueryJoinTests::test_join_table_on_update_query", + "pypika/tests/test_joins.py::IntersectTests::test_intersect", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_as_subquery", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_multiple", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_with_limit", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_with_no_quote_char", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_with_offset", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_with_order_by", + "pypika/tests/test_joins.py::IntersectTests::test_mysql_query_wraps_intersected_queries", + "pypika/tests/test_joins.py::IntersectTests::test_require_equal_number_of_fields_intersect", + "pypika/tests/test_joins.py::MinusTests::test_minus", + "pypika/tests/test_joins.py::MinusTests::test_minus_as_subquery", + "pypika/tests/test_joins.py::MinusTests::test_minus_multiple", + "pypika/tests/test_joins.py::MinusTests::test_minus_query_with_order_by_use_minus_query_field", + "pypika/tests/test_joins.py::MinusTests::test_minus_with_no_quote_char", + "pypika/tests/test_joins.py::MinusTests::test_minus_with_order_by", + "pypika/tests/test_joins.py::MinusTests::test_mysql_query_wraps_minus_queries", + "pypika/tests/test_joins.py::MinusTests::test_require_equal_number_of_fields", + "pypika/tests/test_joins.py::ExceptOfTests::test_except", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_as_subquery", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_multiple", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_query_with_order_by_use_minus_query_field", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_with_no_quote_char", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_with_order_by", + "pypika/tests/test_joins.py::ExceptOfTests::test_require_equal_number_of_fields_except_of", + "pypika/tests/test_negation.py::NegationTests::test_negate_field", + "pypika/tests/test_negation.py::NegationTests::test_negate_function", + "pypika/tests/test_negation.py::NegationTests::test_negate_wrapped_float", + "pypika/tests/test_negation.py::NegationTests::test_negate_wrapped_int", + "pypika/tests/test_parameter.py::ParametrizedTests::test_format_parameter", + "pypika/tests/test_parameter.py::ParametrizedTests::test_join", + "pypika/tests/test_parameter.py::ParametrizedTests::test_named_parameter", + "pypika/tests/test_parameter.py::ParametrizedTests::test_numeric_parameter", + "pypika/tests/test_parameter.py::ParametrizedTests::test_param_insert", + "pypika/tests/test_parameter.py::ParametrizedTests::test_param_select_join", + "pypika/tests/test_parameter.py::ParametrizedTests::test_param_select_subquery", + "pypika/tests/test_parameter.py::ParametrizedTests::test_pyformat_parameter", + "pypika/tests/test_parameter.py::ParametrizedTests::test_qmark_parameter", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_join", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_join_with_parameter_value_wrapper", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_param_insert", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_param_select_join", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_param_select_subquery", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_pyformat_parameter", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_can_be_used_in_a_select_statement", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_can_be_used_in_a_where_clause", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_can_be_used_in_orderby", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_column_value", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_object_id", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_object_value", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_row_id", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_row_num", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_sys_date", + "pypika/tests/test_query.py::QueryTablesTests::test_is_joined", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_case_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_delete_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_filter_tables", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_having_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_insert_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_insert_table_current_table_not_match", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_join_tables", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_only_specified_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_orderby_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_tuple_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_update_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_update_table_current_table_not_match", + "pypika/tests/test_query.py::QueryBuilderTests::test_pipe", + "pypika/tests/test_query.py::QueryBuilderTests::test_query_builders_have_reference_to_correct_query_class", + "pypika/tests/test_selects.py::SelectTests::test_empty_query", + "pypika/tests/test_selects.py::SelectTests::test_mssql_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_mysql_query_uses_backtick_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_oracle_query_uses_no_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_postgresql_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_redshift_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_select__column__single__alias__str", + "pypika/tests/test_selects.py::SelectTests::test_select__column__single__field", + "pypika/tests/test_selects.py::SelectTests::test_select__column__single__str", + "pypika/tests/test_selects.py::SelectTests::test_select__column__single__table_alias__str", + "pypika/tests/test_selects.py::SelectTests::test_select__columns__multi__field", + "pypika/tests/test_selects.py::SelectTests::test_select__columns__multi__str", + "pypika/tests/test_selects.py::SelectTests::test_select__distinct__multi", + "pypika/tests/test_selects.py::SelectTests::test_select__distinct__single", + "pypika/tests/test_selects.py::SelectTests::test_select__multiple_subqueries", + "pypika/tests/test_selects.py::SelectTests::test_select__multiple_tables", + "pypika/tests/test_selects.py::SelectTests::test_select__nested_subquery", + "pypika/tests/test_selects.py::SelectTests::test_select__no_table", + "pypika/tests/test_selects.py::SelectTests::test_select__star", + "pypika/tests/test_selects.py::SelectTests::test_select__star__replacement", + "pypika/tests/test_selects.py::SelectTests::test_select__subquery", + "pypika/tests/test_selects.py::SelectTests::test_select__table_schema", + "pypika/tests/test_selects.py::SelectTests::test_select__table_schema_with_multiple_levels_as_list", + "pypika/tests/test_selects.py::SelectTests::test_select__table_schema_with_multiple_levels_as_tuple", + "pypika/tests/test_selects.py::SelectTests::test_select_no_from", + "pypika/tests/test_selects.py::SelectTests::test_select_no_from_with_field_raises_exception", + "pypika/tests/test_selects.py::SelectTests::test_select_no_with_alias_from", + "pypika/tests/test_selects.py::SelectTests::test_select_then_add_table", + "pypika/tests/test_selects.py::SelectTests::test_select_with_force_index", + "pypika/tests/test_selects.py::SelectTests::test_select_with_force_index_multiple_calls", + "pypika/tests/test_selects.py::SelectTests::test_select_with_force_index_multiple_indexes", + "pypika/tests/test_selects.py::SelectTests::test_select_with_force_index_with_index_object", + "pypika/tests/test_selects.py::SelectTests::test_select_with_limit", + "pypika/tests/test_selects.py::SelectTests::test_select_with_limit__func", + "pypika/tests/test_selects.py::SelectTests::test_select_with_limit_and_offset", + "pypika/tests/test_selects.py::SelectTests::test_select_with_limit_zero", + "pypika/tests/test_selects.py::SelectTests::test_select_with_offset", + "pypika/tests/test_selects.py::SelectTests::test_select_with_offset__func", + "pypika/tests/test_selects.py::SelectTests::test_select_with_use_index", + "pypika/tests/test_selects.py::SelectTests::test_select_with_use_index_multiple_calls", + "pypika/tests/test_selects.py::SelectTests::test_select_with_use_index_multiple_indexes", + "pypika/tests/test_selects.py::SelectTests::test_select_with_use_index_with_index_object", + "pypika/tests/test_selects.py::SelectTests::test_table_select_alias", + "pypika/tests/test_selects.py::SelectTests::test_table_select_alias_with_offset_and_limit", + "pypika/tests/test_selects.py::SelectTests::test_temporal_select", + "pypika/tests/test_selects.py::SelectTests::test_vertica_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::WhereTests::test_ignore_empty_criterion_having", + "pypika/tests/test_selects.py::WhereTests::test_ignore_empty_criterion_where", + "pypika/tests/test_selects.py::WhereTests::test_select_with_force_index_and_where", + "pypika/tests/test_selects.py::WhereTests::test_where_enum", + "pypika/tests/test_selects.py::WhereTests::test_where_field_contains", + "pypika/tests/test_selects.py::WhereTests::test_where_field_does_not_contain", + "pypika/tests/test_selects.py::WhereTests::test_where_field_does_not_end_with", + "pypika/tests/test_selects.py::WhereTests::test_where_field_does_not_start_with", + "pypika/tests/test_selects.py::WhereTests::test_where_field_ends_with", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_and", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_nowait", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_of", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_of_multiple_tables", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_of_nowait", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_of_skip_locked", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_skip_locked", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_skip_locked_and_of", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_or", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_where", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_where_not", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_where_two_not", + "pypika/tests/test_selects.py::WhereTests::test_where_field_is_n_chars_long", + "pypika/tests/test_selects.py::WhereTests::test_where_field_is_not_n_chars_long", + "pypika/tests/test_selects.py::WhereTests::test_where_field_matches_regex", + "pypika/tests/test_selects.py::WhereTests::test_where_field_matches_regexp", + "pypika/tests/test_selects.py::WhereTests::test_where_field_matches_rlike", + "pypika/tests/test_selects.py::WhereTests::test_where_field_starts_with", + "pypika/tests/test_selects.py::WhereTests::test_where_nested_conditions", + "pypika/tests/test_selects.py::WhereTests::test_where_single_quote", + "pypika/tests/test_selects.py::WhereTests::test_where_with_multiple_wheres_using_and_case", + "pypika/tests/test_selects.py::WhereTests::test_where_with_multiple_wheres_using_or_case", + "pypika/tests/test_selects.py::PreWhereTests::test_ignore_empty_criterion_having", + "pypika/tests/test_selects.py::PreWhereTests::test_ignore_empty_criterion_where", + "pypika/tests/test_selects.py::PreWhereTests::test_prewhere_field_equals", + "pypika/tests/test_selects.py::PreWhereTests::test_select_with_force_index_and_where", + "pypika/tests/test_selects.py::PreWhereTests::test_where_and_prewhere", + "pypika/tests/test_selects.py::PreWhereTests::test_where_enum", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_contains", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_does_not_contain", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_does_not_end_with", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_does_not_start_with", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_ends_with", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_and", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_nowait", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_of", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_of_multiple_tables", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_of_nowait", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_of_skip_locked", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_skip_locked", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_skip_locked_and_of", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_or", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_where", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_where_not", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_where_two_not", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_is_n_chars_long", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_is_not_n_chars_long", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_matches_regex", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_matches_regexp", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_matches_rlike", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_starts_with", + "pypika/tests/test_selects.py::PreWhereTests::test_where_nested_conditions", + "pypika/tests/test_selects.py::PreWhereTests::test_where_single_quote", + "pypika/tests/test_selects.py::PreWhereTests::test_where_with_multiple_wheres_using_and_case", + "pypika/tests/test_selects.py::PreWhereTests::test_where_with_multiple_wheres_using_or_case", + "pypika/tests/test_selects.py::GroupByTests::test_group_by__single_with_totals", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__alias", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__alias_platforms", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__alias_with_join", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__count_distinct", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__count_field", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__count_star", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__int", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__multi", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__multi_with_totals", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__no_alias", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__no_alias_mssql", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__no_alias_oracle", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__single", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__str", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__sum_distinct", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__sum_filter", + "pypika/tests/test_selects.py::GroupByTests::test_groupby_with_case_uses_the_alias", + "pypika/tests/test_selects.py::GroupByTests::test_mssql_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_mysql_query_uses_backtick_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_oracle_query_uses_no_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_postgres_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_redshift_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_vertica_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_having_and", + "pypika/tests/test_selects.py::HavingTests::test_having_greater_than", + "pypika/tests/test_selects.py::HavingTests::test_having_join_and_equality", + "pypika/tests/test_selects.py::HavingTests::test_mssql_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_mysql_query_uses_backtick_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_oracle_query_uses_no_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_postgres_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_redshift_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_vertica_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_alias", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_asc", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_desc", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_multi_fields", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_no_alias", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_single_field", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_single_str", + "pypika/tests/test_selects.py::AliasTests::test_arithmetic_function", + "pypika/tests/test_selects.py::AliasTests::test_case_using_as", + "pypika/tests/test_selects.py::AliasTests::test_case_using_constructor_param", + "pypika/tests/test_selects.py::AliasTests::test_function_using_as_nested", + "pypika/tests/test_selects.py::AliasTests::test_functions_using_as", + "pypika/tests/test_selects.py::AliasTests::test_functions_using_constructor_param", + "pypika/tests/test_selects.py::AliasTests::test_functions_using_constructor_param_nested", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_criterion", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_criterion_comparison", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_field_inside_case", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_groupby", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_orderby", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_where", + "pypika/tests/test_selects.py::AliasTests::test_null_value_with_alias", + "pypika/tests/test_selects.py::AliasTests::test_select__multiple_tables", + "pypika/tests/test_selects.py::AliasTests::test_table_field", + "pypika/tests/test_selects.py::AliasTests::test_table_field__multi", + "pypika/tests/test_selects.py::AliasTests::test_table_with_schema_and_alias", + "pypika/tests/test_selects.py::AliasTests::test_use_aliases_in_groupby_and_orderby", + "pypika/tests/test_selects.py::SubqueryTests::test_from_subquery_without_alias", + "pypika/tests/test_selects.py::SubqueryTests::test_join", + "pypika/tests/test_selects.py::SubqueryTests::test_join_query_with_alias", + "pypika/tests/test_selects.py::SubqueryTests::test_join_with_with", + "pypika/tests/test_selects.py::SubqueryTests::test_select_from_nested_query", + "pypika/tests/test_selects.py::SubqueryTests::test_select_from_nested_query_with_join", + "pypika/tests/test_selects.py::SubqueryTests::test_select_from_with_returning", + "pypika/tests/test_selects.py::SubqueryTests::test_select_subquery", + "pypika/tests/test_selects.py::SubqueryTests::test_select_subquery_with_alias", + "pypika/tests/test_selects.py::SubqueryTests::test_where__equality", + "pypika/tests/test_selects.py::SubqueryTests::test_where__in", + "pypika/tests/test_selects.py::SubqueryTests::test_where__in_nested", + "pypika/tests/test_selects.py::SubqueryTests::test_with", + "pypika/tests/test_selects.py::QuoteTests::test_extraneous_quotes", + "pypika/tests/test_tables.py::TableStructureTests::test_database_schema_table_attr", + "pypika/tests/test_tables.py::TableStructureTests::test_schema_table_attr", + "pypika/tests/test_tables.py::TableStructureTests::test_table_for_period_sql", + "pypika/tests/test_tables.py::TableStructureTests::test_table_for_system_time_sql", + "pypika/tests/test_tables.py::TableStructureTests::test_table_sql", + "pypika/tests/test_tables.py::TableStructureTests::test_table_with_alias", + "pypika/tests/test_tables.py::TableStructureTests::test_table_with_schema_and_schema_parent_arg", + "pypika/tests/test_tables.py::TableStructureTests::test_table_with_schema_arg", + "pypika/tests/test_tables.py::TableEqualityTests::test_many_tables_with_alias", + "pypika/tests/test_tables.py::TableEqualityTests::test_many_tables_with_or_not_alias", + "pypika/tests/test_tables.py::TableEqualityTests::test_many_tables_without_alias", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_equal_by_name", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_equal_by_schema_and_name", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_equal_by_schema_and_name_using_schema", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_equal_by_schema_and_name_using_schema_with_parent", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_not_equal_by_schema_and_name_using_schema_with_different_parents", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_not_equal_with_different_names", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_not_equal_with_different_schemas", + "pypika/tests/test_tables.py::TableDialectTests::test_make_tables_factory_with_default_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_make_tables_factory_with_dialect_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_factory_with_default_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_factory_with_dialect_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_with_bad_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_with_default_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_with_dialect_query_cls", + "pypika/tests/test_terms.py::FieldAliasTests::test_when_alias_specified", + "pypika/tests/test_terms.py::FieldInitTests::test_init_with_str_table", + "pypika/tests/test_terms.py::FieldHashingTests::test_non_tabled_aliased_eq_fields_equally_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_non_tabled_aliased_ne_fields_differently_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_non_tabled_eq_fields_equally_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_non_tabled_ne_fields_differently_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_tabled_eq_fields_equally_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_tabled_ne_fields_differently_hashed", + "pypika/tests/test_terms.py::AtTimezoneTests::test_passes_kwargs_to_field_get_sql", + "pypika/tests/test_terms.py::AtTimezoneTests::test_when_alias_specified", + "pypika/tests/test_terms.py::AtTimezoneTests::test_when_interval_not_specified", + "pypika/tests/test_terms.py::AtTimezoneTests::test_when_interval_specified", + "pypika/tests/test_tuples.py::TupleTests::test_render_alias_in_array_sql", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_equality_tuple_on_both", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_equality_tuple_on_left", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_equality_tuple_on_right", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_in_using_mixed_tuples", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_in_using_pypika_tuples", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_in_using_python_tuples", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_is_aggregate", + "pypika/tests/test_tuples.py::TupleTests::test_tuples_in_join", + "pypika/tests/test_tuples.py::ArrayTests::test_array_general", + "pypika/tests/test_tuples.py::ArrayTests::test_empty_psql_array", + "pypika/tests/test_tuples.py::ArrayTests::test_psql_array_general", + "pypika/tests/test_tuples.py::ArrayTests::test_render_alias_in_array_sql", + "pypika/tests/test_tuples.py::BracketTests::test_arithmetic_with_brackets", + "pypika/tests/test_tuples.py::BracketTests::test_arithmetic_with_brackets_and_alias", + "pypika/tests/test_updates.py::UpdateTests::test_empty_query", + "pypika/tests/test_updates.py::UpdateTests::test_for_portion", + "pypika/tests/test_updates.py::UpdateTests::test_omit_where", + "pypika/tests/test_updates.py::UpdateTests::test_single_quote_escape_in_set", + "pypika/tests/test_updates.py::UpdateTests::test_update__table_schema", + "pypika/tests/test_updates.py::UpdateTests::test_update_from", + "pypika/tests/test_updates.py::UpdateTests::test_update_from_with_where", + "pypika/tests/test_updates.py::UpdateTests::test_update_with_join", + "pypika/tests/test_updates.py::UpdateTests::test_update_with_limit", + "pypika/tests/test_updates.py::UpdateTests::test_update_with_none", + "pypika/tests/test_updates.py::UpdateTests::test_update_with_statement", + "pypika/tests/test_updates.py::PostgresUpdateTests::test_update_returning", + "pypika/tests/test_updates.py::PostgresUpdateTests::test_update_returning_from_different_tables", + "pypika/tests/test_updates.py::PostgresUpdateTests::test_update_returning_star", + "pypika/tests/test_updates.py::PostgresUpdateTests::test_update_returning_str", + "pypika/tests/test_updates.py::SQLLiteUpdateTests::test_update_with_bool", + "pypika/tests/test_utils.py::ImmutabilityTests::test_raise_attribute_error_for_deepcopy", + "pypika/tests/test_utils.py::ImmutabilityTests::test_raise_attribute_error_for_getnewargs", + "pypika/tests/test_utils.py::ImmutabilityTests::test_raise_attribute_error_for_getstate", + "pypika/tests/test_utils.py::ImmutabilityTests::test_raise_attribute_error_for_setstate" + ] +} diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/grade.py b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/grade.py new file mode 100644 index 0000000000000000000000000000000000000000..e3b37293830e51a5c5833c93c4705e1ed9364257 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/grade.py @@ -0,0 +1,128 @@ +"""Trusted private pytest panel runner. Installed only in a fresh grader Job.""" + +import hashlib +import importlib.util +import json +import os +import shutil +import stat +import subprocess +from pathlib import Path, PurePosixPath + + +def sha(raw): + return hashlib.sha256(raw).hexdigest() + + +def safe(value): + path = PurePosixPath(value) + if ( + path.is_absolute() + or path.as_posix() != value + or not path.parts + or any(part in {".", "..", ".git"} for part in path.parts) + ): + raise ValueError("Unsafe trusted test path") + return path + + +def restore(worktree, private, manifest): + worktree, private = Path(worktree), Path(private) + captured = {} + for name, expected in manifest["files"].items(): + path = private / safe(name) + info = path.lstat() + raw = path.read_bytes() if stat.S_ISREG(info.st_mode) else b"" + if ( + not stat.S_ISREG(info.st_mode) + or len(raw) != expected["bytes"] + or sha(raw) != expected["sha256"] + or stat.S_IMODE(info.st_mode) != expected["mode"] + ): + raise ValueError("Trusted private test bytes or modes drifted") + captured[name] = (raw, expected["mode"]) + # Capture and verify every private byte before changing the submitted tree. + for name in manifest["directory_roots"]: + destination = worktree / safe(name) + if destination.is_symlink(): + raise ValueError("Submitted test directory is a symlink") + for parent in destination.parents: + if parent == worktree: + break + if parent.is_symlink(): + raise ValueError("Submitted test parent is a symlink") + if destination.exists(): + if not destination.is_dir(): + raise ValueError("Submitted test directory is not a directory") + shutil.rmtree(destination) + for name, (raw, mode) in captured.items(): + destination = worktree / safe(name) + for parent in destination.parents: + if parent == worktree: + break + if parent.is_symlink(): + raise ValueError("Submitted test parent is a symlink") + if destination.is_symlink(): + raise ValueError("Submitted trusted file is a symlink") + destination.parent.mkdir(parents=True, exist_ok=True) + destination.write_bytes(raw) + destination.chmod(mode) + + +def run(worktree, private_root, output, invoke=None): + private_root, output, worktree = Path(private_root), Path(output), Path(worktree) + expected = json.loads((private_root / "expected-panels.json").read_bytes()) + config = json.loads((private_root / "panel-config.json").read_bytes()) + manifest = json.loads((private_root / "trusted-inventory.json").read_bytes()) + restore(worktree, private_root / "trusted", manifest) + output.mkdir(parents=True, exist_ok=True) + for name in ( + "reward.txt", + "pass-to-pass.xml", + "fail-to-pass.xml", + "pytest-evidence.json", + ): + (output / name).unlink(missing_ok=True) + environment = dict(os.environ) + for key in ("PYTEST_ADDOPTS", "PYTEST_DISABLE_PLUGIN_AUTOLOAD", "PYTHONPATH"): + environment.pop(key, None) + commands, native_exit = [], 0 + invoke = invoke or subprocess.run + for group in ("pass-to-pass", "fail-to-pass"): + if ( + not isinstance(expected[group], list) + or not expected[group] + or any( + not isinstance(target, str) or not target for target in expected[group] + ) + ): + raise ValueError("Frozen native pytest selectors are incomplete") + command = [ + *config["official_pytest_argv"], + "--override-ini=addopts=", + "--junitxml=" + str(output / (group + ".xml")), + *expected[group], + ] + result = invoke(command, cwd=worktree, env=environment, check=False) + native_exit = result.returncode + commands.append({"group": group, "argv": command, "exit_code": native_exit}) + if native_exit != 0: + break + (output / "pytest-commands.json").write_text( + json.dumps(commands, sort_keys=True) + "\n" + ) + spec = importlib.util.spec_from_file_location( + "trusted_pytest_result", private_root / "check_pytest.py" + ) + checker = importlib.util.module_from_spec(spec) + spec.loader.exec_module(checker) + result = checker.assess(output, expected, native_exit) + (output / "reward.txt").write_text(str(result["reward"]) + "\n") + (output / "pytest-evidence.json").write_text( + json.dumps(result, sort_keys=True) + "\n" + ) + return result + + +if __name__ == "__main__": + run("/testbed/repo", "/tests", "/logs/verifier") diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/panel-config.json b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/panel-config.json new file mode 100644 index 0000000000000000000000000000000000000000..6417b9c92e5da5b97ee641bd54f798302af42a31 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/panel-config.json @@ -0,0 +1,28 @@ +{ + "dependency_installation_pinned": false, + "official_install_cmds": [ + "python -m pip install -e ." + ], + "official_pytest_argv": [ + "pytest", + "--disable-warnings", + "--color=no", + "--tb=no", + "--verbose" + ], + "official_test_command": "source /opt/miniconda3/bin/activate; conda activate testbed; pytest --disable-warnings --color=no --tb=no --verbose", + "operator_test_runner_prerequisites": [ + "python -m pip install pytest==8.4.2" + ], + "operator_test_runner_reason": "The official profile invokes pytest, but the common tools runtime does not provide it; pinned separately from source-native project requirements.", + "panel_normalization": "Override project addopts only to execute the exact frozen native panels; add JUnit output, preserve official pytest options and all selectors.", + "python_version": "3.10", + "source_bound_test_dependency_cmds": [ + "python -m pip install parameterized==0.7.0" + ], + "test_dependency_source_sha256": { + "requirements-dev.txt": "10f4ba7b19a73950d28fd7403d7e1d1b1fe2ccc4f49516974f47199d2965f23d", + "setup.py": "f8bad274588a22e65764d8cf9fb2be5aa6fcfaf3bf861d71e5f751105898845a", + "tox.ini": "c2d7205d0ac93e9c9e80dc5d24f0a826a6781f587a33ea722ea621f9e2ccd0ea" + } +} diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/test.sh b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..81b6d0620f05dbd3b54b4e7ea5de04ce3f8a98e2 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/test.sh @@ -0,0 +1,6 @@ +#!/bin/bash +set -Eeuo pipefail +source /opt/miniconda3/bin/activate +conda activate testbed +cd /testbed/repo +exec python -I /tests/grade.py diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted-inventory.json b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted-inventory.json new file mode 100644 index 0000000000000000000000000000000000000000..6926ef1c22ed56457101c37cd70e0fe0d1656f0c --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted-inventory.json @@ -0,0 +1,242 @@ +{ + "directory_roots": [ + "pypika/tests" + ], + "files": { + "pypika/tests/__init__.py": { + "bytes": 58, + "mode": 420, + "sha256": "7d41f44b87688bdf162e6d5cbe7b517cfba468f96eaa421f02718c17eb486a18" + }, + "pypika/tests/clickhouse/__init__.py": { + "bytes": 0, + "mode": 420, + "sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "pypika/tests/clickhouse/test_array.py": { + "bytes": 2942, + "mode": 420, + "sha256": "0f0a5b4c3daf3ddce2944b6119795e80d50b74e4687ef2e34399e5d21d3d48ae" + }, + "pypika/tests/clickhouse/test_condition.py": { + "bytes": 2533, + "mode": 420, + "sha256": "c666976d082b1d12cd57e791d1a525183246335efad96a369b58871a6f1e4fa1" + }, + "pypika/tests/clickhouse/test_dates_and_times.py": { + "bytes": 2508, + "mode": 420, + "sha256": "cb8ea84363e35ad0a00b52a8ec20cb38f2348f4cba28d026a4c32c14fd1fc56f" + }, + "pypika/tests/clickhouse/test_nullable_arg.py": { + "bytes": 672, + "mode": 420, + "sha256": "883c5161ebeb09544ce124d20a096d248bd12a0404ad77c84637be75d6738529" + }, + "pypika/tests/clickhouse/test_search_string.py": { + "bytes": 1189, + "mode": 420, + "sha256": "d5f0ed6a51cf550bdd4b261fa2e98084184dd1cbb08f5dbb8b91278b4c8f3bfd" + }, + "pypika/tests/clickhouse/test_type_conversion.py": { + "bytes": 4445, + "mode": 420, + "sha256": "7e6045b64433a8947346cfb34ac30279349f7a2e2081a2815212c8cb7d0235ab" + }, + "pypika/tests/dialects/__init__.py": { + "bytes": 0, + "mode": 420, + "sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "pypika/tests/dialects/test_clickhouse.py": { + "bytes": 5747, + "mode": 420, + "sha256": "2272538d6eeb6dfb01f9803eed328b4cd4efc8d255b6a8ab3c4e25bee74d73fa" + }, + "pypika/tests/dialects/test_mssql.py": { + "bytes": 3152, + "mode": 420, + "sha256": "0cd9b2ee6498caa9fa75a51ead30803057fb23deb2ac706d396d88329e0e91d7" + }, + "pypika/tests/dialects/test_mysql.py": { + "bytes": 2984, + "mode": 420, + "sha256": "a5f4550dd14bf4820e5d85cf06b6c7c79286e41d2d3c794f639579d20fffab92" + }, + "pypika/tests/dialects/test_oracle.py": { + "bytes": 1906, + "mode": 420, + "sha256": "67f80eb40cc9b4dabcbad355e8be6d83c54a64cbee809182ef57fa9f48d2ebc6" + }, + "pypika/tests/dialects/test_postgresql.py": { + "bytes": 9532, + "mode": 420, + "sha256": "548ee7267ca87c9e1ae82ca89a4e5bd96c7392a55cc07996f2b105f911ffa6cf" + }, + "pypika/tests/dialects/test_snowflake.py": { + "bytes": 2159, + "mode": 420, + "sha256": "e567b9dab0a5366bd11a0ef162c3a3bb492280b78bc4b397a23070563dc84468" + }, + "pypika/tests/dialects/test_sqllite.py": { + "bytes": 1243, + "mode": 420, + "sha256": "118fed7e575415f276bda390a119080bd6a767aee3d9c953e11a8c219f0f017c" + }, + "pypika/tests/dialects/test_vertica.py": { + "bytes": 3578, + "mode": 420, + "sha256": "33a027e6735ca03b7afd11394905c4193e48a15dda3efbe47cdcd85fcabf840c" + }, + "pypika/tests/test_aggregate.py": { + "bytes": 3946, + "mode": 420, + "sha256": "5b0fb549de3bb50ad88ae1d75824f12f7ab4a5f1102b06a70c7b2ebae33bea6d" + }, + "pypika/tests/test_analytic_queries.py": { + "bytes": 20611, + "mode": 420, + "sha256": "8546b7a296c8e212c349c4baff95f93934b3120f74625b3945ade3b438e3a3ed" + }, + "pypika/tests/test_create.py": { + "bytes": 9088, + "mode": 420, + "sha256": "6c57302da52ca1044be0afdafe677d5de245e44873dff1386c9a1ccb2625cc82" + }, + "pypika/tests/test_criterions.py": { + "bytes": 32014, + "mode": 420, + "sha256": "78539ccca82f9a02fad0f5a39041ac343e3a142ce52368cd4f6ada489c52516a" + }, + "pypika/tests/test_custom_functions.py": { + "bytes": 1710, + "mode": 420, + "sha256": "bfa18bc328a3577965db7cc75eb94439f0cfd95a3775d9b1cc8af1062bb202cb" + }, + "pypika/tests/test_data_types.py": { + "bytes": 403, + "mode": 420, + "sha256": "c1be6ecc621a80dd91d35b1427bdfc8b1b33bd926515198e626d6fb5e1878c8b" + }, + "pypika/tests/test_date_math.py": { + "bytes": 5544, + "mode": 420, + "sha256": "85aa54efe54fe19639f2dc2a5750647e3337ac2681768bc3fe327841f1634d9e" + }, + "pypika/tests/test_deletes.py": { + "bytes": 3204, + "mode": 420, + "sha256": "ccde6df760d76d5d499ce828f6b0e2ad3eebcb2a5553c1890f481b9160b8d51a" + }, + "pypika/tests/test_drop.py": { + "bytes": 1556, + "mode": 420, + "sha256": "a13dffa59ef8657398d5498c18977bfd702635e336ea9966b1a86137afca7926" + }, + "pypika/tests/test_formats.py": { + "bytes": 1948, + "mode": 420, + "sha256": "240458a404bb119322778893b94a12be0f98f914acd701d2b4be73eb9be96f75" + }, + "pypika/tests/test_functions.py": { + "bytes": 32769, + "mode": 420, + "sha256": "3ceaac7791bd27e50f44e1b4a1451d1e09afe6a8011052caea838e5124582154" + }, + "pypika/tests/test_groupby_modifiers.py": { + "bytes": 5227, + "mode": 420, + "sha256": "9db4497660f08e3352a9a02c34889ad1cd6bab3aebaeaa485e84390ad71c84c5" + }, + "pypika/tests/test_immutability.py": { + "bytes": 3954, + "mode": 420, + "sha256": "af537ced19f7274951cc91697eae748ef6c9cd20a8d8e492d93dc85b06f8fb50" + }, + "pypika/tests/test_inserts.py": { + "bytes": 32549, + "mode": 420, + "sha256": "652e9f7f0f425e9acc0f70e2851ae29310b378262ea30369ea0113ef428f210f" + }, + "pypika/tests/test_internals.py": { + "bytes": 828, + "mode": 420, + "sha256": "4374c2632563346d00ca4de6af397a022ef3f5022e808c8711a3f207a3a21609" + }, + "pypika/tests/test_joins.py": { + "bytes": 43895, + "mode": 420, + "sha256": "53f224815c10393382443f020cb20e313420764495a8fd30f7ea2f34fd52935d" + }, + "pypika/tests/test_negation.py": { + "bytes": 763, + "mode": 420, + "sha256": "6be105e8f39b32fb23e6ac7c7158232ee78111455d4f35638c8af60781138c79" + }, + "pypika/tests/test_parameter.py": { + "bytes": 7382, + "mode": 420, + "sha256": "aaf2a3e79c8267bdc60e218445bc2a2254b97cf37b643a44d6f1a8141cbb5104" + }, + "pypika/tests/test_pseudocolumns.py": { + "bytes": 1609, + "mode": 420, + "sha256": "b7c69f7aca41323c0e14a6a9e58697399cd7860610f07291afc6e8af26079ca2" + }, + "pypika/tests/test_query.py": { + "bytes": 9025, + "mode": 420, + "sha256": "2da9d717673912a84e86e6c0d3955dbd8f2fa7b41b7ed9a6f78089dfa28f9444" + }, + "pypika/tests/test_selects.py": { + "bytes": 50757, + "mode": 420, + "sha256": "5ac1b7ad3248d64b1e3865a72c763873514ae5cd6e03356b913e531c0c336986" + }, + "pypika/tests/test_tables.py": { + "bytes": 6568, + "mode": 420, + "sha256": "384c8e843ba56374ee92cd7b7e2fd3f89247b899e23cd9e1f6663d751ad5d884" + }, + "pypika/tests/test_terms.py": { + "bytes": 3215, + "mode": 420, + "sha256": "8598513180ddcd28cc61582618d85bd570280978b07603044dae81b2eb099f77" + }, + "pypika/tests/test_tuples.py": { + "bytes": 6033, + "mode": 420, + "sha256": "863942196a93e8939be0d03c49cfeb42a35503ad42f9f3d6c730260112811087" + }, + "pypika/tests/test_updates.py": { + "bytes": 5689, + "mode": 420, + "sha256": "0f0f2521bb8d1f5d782f8fabaea5fd1d82090cde045ba87fad65770db6c75d2f" + }, + "pypika/tests/test_utils.py": { + "bytes": 834, + "mode": 420, + "sha256": "5db6e90df5daaa70b9f35f1243db69908da1f27887f63466fc27ce20c7e14892" + }, + "pyproject.toml": { + "bytes": 390, + "mode": 420, + "sha256": "037fedacd5be5d078f398265ff97e1677e25214ad8839d17073a439695ee7a91" + }, + "setup.cfg": { + "bytes": 317, + "mode": 420, + "sha256": "c84a31de586e8385e741127b004fc1f19ebae6463cdf0b3f243991db35cdeaea" + }, + "setup.py": { + "bytes": 2638, + "mode": 420, + "sha256": "f8bad274588a22e65764d8cf9fb2be5aa6fcfaf3bf861d71e5f751105898845a" + }, + "tox.ini": { + "bytes": 257, + "mode": 420, + "sha256": "c2d7205d0ac93e9c9e80dc5d24f0a826a6781f587a33ea722ea621f9e2ccd0ea" + } + } +} diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/__init__.py b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..86d8a68101915c27b95484243dd81d55f7dba356 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/__init__.py @@ -0,0 +1,2 @@ +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/clickhouse/__init__.py b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/clickhouse/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/clickhouse/test_array.py b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/clickhouse/test_array.py new file mode 100644 index 0000000000000000000000000000000000000000..469705a9ff3c8fe9cc7f02c44a9812521eeb67f4 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/clickhouse/test_array.py @@ -0,0 +1,104 @@ +import unittest + +from parameterized import parameterized + +from pypika import Field +from pypika.clickhouse.array import ( + Array, + Empty, + HasAny, + Length, + NotEmpty, +) +from pypika.clickhouse.type_conversion import ( + ToFixedString, + ToInt64, +) + + +class TestArray(unittest.TestCase): + @parameterized.expand( + [ + ( + "['ridley', 'scott', 'jimi', 'hendrix']", + Array(["ridley", "scott", "jimi", "hendrix"]), + ), + ( + "[1, 2, 3, 4]", + Array([1, 2, 3, 4]), + ), + ( + "[toInt64('1'),toInt64('2'),toInt64('3'),toInt64('4')]", + Array(["1", "2", "3", "4"], ToInt64), + ), + ( + "[toFixedString('mogwai',10),toFixedString('mono',10),toFixedString('bonobo',10)] arr", + Array(["mogwai", "mono", "bonobo"], ToFixedString, {"length": 10}).as_('arr'), + ), + ] + ) + def test_get_sql(self, expected: str, array: Array): + self.assertEqual(expected, array.get_sql()) + + +class TestHasAny(unittest.TestCase): + @parameterized.expand( + [ + ( + 'hasAny("mental_abilities","physical_abilities")', + HasAny(Field("mental_abilities"), Field("physical_abilities")), + ), + ("hasAny([1, 2, 3, 4],[3])", HasAny(Array([1, 2, 3, 4]), Array([3]))), + ( + "hasAny(\"bands\",[toFixedString('port-royal',20),toFixedString('hammock',20)])", + HasAny( + Field("bands"), + Array(["port-royal", "hammock"], ToFixedString, {"length": 20}), + ), + ), + ] + ) + def test_get_sql(self, expected: str, func: HasAny): + self.assertEqual(expected, func.get_sql()) + + +class TestLength(unittest.TestCase): + @parameterized.expand( + [ + ( + 'length("tags")', + Length(Field("tags")), + ), + ("length([1, 2, 3])", Length(Array([1, 2, 3]))), + ] + ) + def test_get_sql(self, expected: str, func: Length): + self.assertEqual(expected, func.get_sql()) + + +class TestEmpty(unittest.TestCase): + @parameterized.expand( + [ + ( + 'empty("tags")', + Empty(Field("tags")), + ), + ("empty([1, 2, 3])", Empty(Array([1, 2, 3]))), + ] + ) + def test_get_sql(self, expected: str, func: Empty): + self.assertEqual(expected, func.get_sql()) + + +class TestNotEmpty(unittest.TestCase): + @parameterized.expand( + [ + ( + 'notEmpty("tags")', + NotEmpty(Field("tags")), + ), + ("notEmpty([1, 2, 3])", NotEmpty(Array([1, 2, 3]))), + ] + ) + def test_get_sql(self, expected: str, func: NotEmpty): + self.assertEqual(expected, func.get_sql()) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/clickhouse/test_condition.py b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/clickhouse/test_condition.py new file mode 100644 index 0000000000000000000000000000000000000000..145baeb7753dd9cbefbd6f272bd672ae5730b0c0 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/clickhouse/test_condition.py @@ -0,0 +1,72 @@ +import unittest + +from parameterized import parameterized + +from pypika import Field +from pypika.clickhouse.condition import If, MultiIf +from pypika.clickhouse.type_conversion import ToFixedString + + +class TestIfCondition(unittest.TestCase): + @parameterized.expand( + [ + ( + If( + Field("filmmaker").isnull(), + ToFixedString("Tarantino", 20), + Field("filmmaker"), + ), + "if(filmmaker IS NULL,toFixedString('Tarantino',20),filmmaker)", + ), + ( + If( + Field("created") == Field("updated"), + ToFixedString("yes", 3), + ToFixedString("no", 3), + ), + "if(created=updated,toFixedString('yes',3),toFixedString('no',3))", + ), + ] + ) + def test_get_sql(self, func, expected): + self.assertEqual(func.get_sql(), expected) + + +class TestMultiIfCondition(unittest.TestCase): + @parameterized.expand( + [ + ( + MultiIf( + Field("filmmaker").isnull(), + ToFixedString("Tarantino", 20), + Field("filmmaker") == ToFixedString("undefined", 20), + ToFixedString("Tarantino", 20), + Field("filmmaker"), + ), + "multiIf(filmmaker IS NULL," + "toFixedString('Tarantino',20)," + "filmmaker=toFixedString('undefined',20)," + "toFixedString('Tarantino',20),filmmaker)", + ), + ( + MultiIf( + Field("color") == ToFixedString("black", 20), + ToFixedString("dark", 20), + Field("color") == ToFixedString("grey", 20), + ToFixedString("dark", 20), + Field("color") == ToFixedString("white", 20), + ToFixedString("light", 20), + ToFixedString("undefined", 20), + ), + "multiIf(color=toFixedString('black',20)," + "toFixedString('dark',20)," + "color=toFixedString('grey',20)," + "toFixedString('dark',20)," + "color=toFixedString('white',20)," + "toFixedString('light',20)," + "toFixedString('undefined',20))", + ), + ] + ) + def test_get_sql(self, func, expected): + self.assertEqual(func.get_sql(), expected) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/clickhouse/test_dates_and_times.py b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/clickhouse/test_dates_and_times.py new file mode 100644 index 0000000000000000000000000000000000000000..135dd7f112131776d76748e15eead1eb81752b59 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/clickhouse/test_dates_and_times.py @@ -0,0 +1,70 @@ +import unittest + +from parameterized import parameterized + +from pypika import Field +from pypika.clickhouse.dates_and_times import ( + AddDays, + AddHours, + AddMinutes, + AddMonths, + AddQuarters, + AddSeconds, + AddWeeks, + AddYears, + FormatDateTime, + SubtractDays, + SubtractHours, + SubtractMinutes, + SubtractMonths, + SubtractQuarters, + SubtractSeconds, + SubtractWeeks, + SubtractYears, + ToYYYYMM, +) + + +class TestFormatDateTime(unittest.TestCase): + @parameterized.expand( + [ + (FormatDateTime(Field("created"), "%V"), "formatDateTime(created,'%V')"), + ( + FormatDateTime(Field("created"), "%Y-%m-%d"), + "formatDateTime(created,'%Y-%m-%d')", + ), + ] + ) + def test_get_sql(self, func, expected): + self.assertEqual(func.get_sql(), expected) + + +class TestAddSubtractDt(unittest.TestCase): + @parameterized.expand( + [ + (AddYears(Field("created"), 1), "addYears(created,1)"), + (AddMonths(Field("created"), 2), "addMonths(created,2)"), + (AddWeeks(Field("created"), 3), "addWeeks(created,3)"), + (AddDays(Field("created"), 4), "addDays(created,4)"), + (AddHours(Field("created"), 5), "addHours(created,5)"), + (AddMinutes(Field("created"), 6), "addMinutes(created,6)"), + (AddSeconds(Field("created"), 7), "addSeconds(created,7)"), + (AddQuarters(Field("created"), 8), "addQuarters(created,8)"), + (SubtractYears(Field("created"), 9), "subtractYears(created,9)"), + (SubtractMonths(Field("created"), 10), "subtractMonths(created,10)"), + (SubtractWeeks(Field("created"), 11), "subtractWeeks(created,11)"), + (SubtractDays(Field("created"), 12), "subtractDays(created,12)"), + (SubtractHours(Field("created"), 13), "subtractHours(created,13)"), + (SubtractHours(Field("created"), 13), "subtractHours(created,13)"), + (SubtractMinutes(Field("created"), 14), "subtractMinutes(created,14)"), + (SubtractSeconds(Field("created"), 15), "subtractSeconds(created,15)"), + (SubtractQuarters(Field("created"), 16), "subtractQuarters(created,16)"), + ] + ) + def test_get_sql(self, func, expected): + self.assertEqual(func.get_sql(), expected) + + +class TestToYYYYMM(unittest.TestCase): + def test_get_sql(self): + self.assertEqual(ToYYYYMM(Field("created").get_sql()), "toYYYYMM(created)") diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/clickhouse/test_nullable_arg.py b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/clickhouse/test_nullable_arg.py new file mode 100644 index 0000000000000000000000000000000000000000..3c6c86207a4d0206b5c0ba80b77fac4cc257fa17 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/clickhouse/test_nullable_arg.py @@ -0,0 +1,24 @@ +import unittest + +from parameterized import parameterized + +from pypika import Field +from pypika.clickhouse.nullable_arg import IfNull +from pypika.clickhouse.type_conversion import ToFixedString + + +class TestSearchString(unittest.TestCase): + @parameterized.expand( + [ + ( + IfNull(Field("name"), Field("login")), + "ifNull(name,login)", + ), + ( + IfNull(Field("builder"), ToFixedString("pypika", 100)), + "ifNull(builder,toFixedString('pypika',100))", + ), + ] + ) + def test_get_sql(self, func, expected): + self.assertEqual(func.get_sql(), expected) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/clickhouse/test_search_string.py b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/clickhouse/test_search_string.py new file mode 100644 index 0000000000000000000000000000000000000000..9778eb32e47d4370c0bfe36dcd875903666d30b6 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/clickhouse/test_search_string.py @@ -0,0 +1,41 @@ +import unittest + +from parameterized import parameterized + +from pypika import Field +from pypika.clickhouse.search_string import ( + Match, + Like, + NotLike, + MultiSearchAny, + MultiMatchAny, +) + + +class TestSearchString(unittest.TestCase): + @parameterized.expand( + [ + (Match(Field("name"), "twheys"), "match(toString(\"name\"),'twheys')"), + (Like(Field("name"), "twheys"), "like(toString(\"name\"),'twheys')"), + (NotLike(Field("name"), "twheys"), "notLike(toString(\"name\"),'twheys')"), + ] + ) + def test_search_string(self, func, expected): + self.assertEqual(func, expected) + + +class TestMultiSearch(unittest.TestCase): + @parameterized.expand( + [ + ( + MultiSearchAny(Field("name"), ["sarah", "connor"]), + "multiSearchAny(toString(\"name\"),['sarah','connor'])", + ), + ( + MultiMatchAny(Field("name"), ["sarah", "connor"]), + "multiMatchAny(toString(\"name\"),['sarah','connor'])", + ), + ] + ) + def test_multi_search_string(self, func, expected): + self.assertEqual(func.get_sql(), expected) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/clickhouse/test_type_conversion.py b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/clickhouse/test_type_conversion.py new file mode 100644 index 0000000000000000000000000000000000000000..9692e17bee901e2629db9a5c77111e145358e8eb --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/clickhouse/test_type_conversion.py @@ -0,0 +1,176 @@ +import unittest + +from parameterized import parameterized + +from pypika import ClickHouseQuery, Field, Table +from pypika.clickhouse.type_conversion import ( + ToDate, + ToDateTime, + ToFixedString, + ToFloat32, + ToFloat64, + ToInt16, + ToInt32, + ToInt64, + ToInt8, + ToString, + ToUInt16, + ToUInt32, + ToUInt64, + ToUInt8, +) + + +class TestBasicTypeConverters(unittest.TestCase): + @parameterized.expand( + [ + ( + 'toString("field_name")', + ToString(Field("field_name")), + ), + ( + 'toInt8("field_name")', + ToInt8(Field("field_name")), + ), + ( + 'toInt16("field_name")', + ToInt16(Field("field_name")), + ), + ( + 'toInt32("field_name")', + ToInt32(Field("field_name")), + ), + ( + 'toInt64("field_name")', + ToInt64(Field("field_name")), + ), + ( + 'toUInt8("field_name")', + ToUInt8(Field("field_name")), + ), + ( + 'toUInt16("field_name")', + ToUInt16(Field("field_name")), + ), + ( + 'toUInt32("field_name")', + ToUInt32(Field("field_name")), + ), + ( + 'toUInt64("field_name")', + ToUInt64(Field("field_name")), + ), + ( + 'toFloat32("field_name")', + ToFloat32(Field("field_name")), + ), + ( + 'toFloat64("field_name")', + ToFloat64(Field("field_name")), + ), + ( + 'toFloat64("field_name")', + ToFloat64(Field("field_name")), + ), + ( + 'toDate("field_name")', + ToDate(Field("field_name")), + ), + ( + 'toDateTime("field_name")', + ToDateTime(Field("field_name")), + ), + ( + 'toFixedString("field_name",100)', + ToFixedString(Field("field_name"), 100), + ), + ] + ) + def test_basic_types_field(self, expected, func): + self.assertEqual(func, expected) + + @parameterized.expand( + [ + ( + "toString('100')", + ToString("100"), + ), + ( + "toInt8('100')", + ToInt8("100"), + ), + ( + "toInt16('100')", + ToInt16("100"), + ), + ( + "toInt32('100')", + ToInt32("100"), + ), + ( + "toInt64('100')", + ToInt64("100"), + ), + ( + "toUInt8('100')", + ToUInt8("100"), + ), + ( + "toUInt16('100')", + ToUInt16("100"), + ), + ( + "toUInt32('100')", + ToUInt32("100"), + ), + ( + "toUInt64('100')", + ToUInt64("100"), + ), + ( + "toFloat32('100')", + ToFloat32("100"), + ), + ( + "toFloat64('100')", + ToFloat64("100"), + ), + ( + "toFloat64('100')", + ToFloat64("100"), + ), + ( + "toDate('100')", + ToDate("100"), + ), + ( + "toDateTime('100')", + ToDateTime("100"), + ), + ( + "toFixedString('100',100)", + ToFixedString("100", 100), + ), + ] + ) + def test_basic_types_value(self, expected, func): + self.assertEqual(func, expected) + + +class TestToFixedString(unittest.TestCase): + def test_get_sql_with_table(self): + table = Table("example") + query = ( + ClickHouseQuery.from_(table) + .select( + table.name, + ) + .where( + table.name == ToFixedString("name", 50), + ) + ) + + self.assertEqual( + 'SELECT "name" FROM "example" WHERE "name"=toFixedString(\'name\',50)', + query.get_sql(), + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/dialects/__init__.py b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/dialects/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/dialects/test_clickhouse.py b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/dialects/test_clickhouse.py new file mode 100644 index 0000000000000000000000000000000000000000..f319c4627bd25d7004894181906a284b8b1c64cf --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/dialects/test_clickhouse.py @@ -0,0 +1,146 @@ +from unittest import TestCase + +from pypika import ( + ClickHouseQuery, + Database, + Table, +) + + +class ClickHouseQueryTests(TestCase): + def test_use_AS_keyword_for_alias(self): + t = Table('abc') + query = ClickHouseQuery.from_(t).select(t.foo.as_('f1'), t.bar.as_('f2')) + self.assertEqual(str(query), 'SELECT "foo" AS "f1","bar" AS "f2" FROM "abc"') + + def test_use_SAMPLE_keyword(self): + t = Table('abc') + query = ClickHouseQuery.from_(t).select(t.foo).sample(10) + self.assertEqual(str(query), 'SELECT "foo" FROM "abc" SAMPLE 10') + + def test_use_SAMPLE_with_offset_keyword(self): + t = Table('abc') + query = ClickHouseQuery.from_(t).select(t.foo).sample(10, 5) + self.assertEqual(str(query), 'SELECT "foo" FROM "abc" SAMPLE 10 OFFSET 5') + + def test_use_FINAL_keyword(self): + t = Table('abc') + query = ClickHouseQuery.from_(t).select(t.foo).final() + self.assertEqual(str(query), 'SELECT "foo" FROM "abc" FINAL') + + +class ClickHouseDeleteTests(TestCase): + table_abc = Table("abc") + + def test_omit_where(self): + q = ClickHouseQuery.from_("abc").delete() + + self.assertEqual('ALTER TABLE "abc" DELETE', str(q)) + + def test_omit_where__table_schema(self): + q = ClickHouseQuery.from_(Table("abc", "schema1")).delete() + + self.assertEqual('ALTER TABLE "schema1"."abc" DELETE', str(q)) + + def test_where_field_equals(self): + q1 = ClickHouseQuery.from_(self.table_abc).where(self.table_abc.foo == self.table_abc.bar).delete() + q2 = ClickHouseQuery.from_(self.table_abc).where(self.table_abc.foo.eq(self.table_abc.bar)).delete() + + self.assertEqual('ALTER TABLE "abc" DELETE WHERE "foo"="bar"', str(q1)) + self.assertEqual('ALTER TABLE "abc" DELETE WHERE "foo"="bar"', str(q2)) + + +class ClickHouseUpdateTests(TestCase): + table_abc = Table("abc") + + def test_update(self): + q = ClickHouseQuery.update(self.table_abc).where(self.table_abc.foo == 0).set("foo", "bar") + + self.assertEqual('ALTER TABLE "abc" UPDATE "foo"=\'bar\' WHERE "foo"=0', str(q)) + + +class ClickHouseDropQuery(TestCase): + table_abc = Table("abc") + database_xyz = Database("mydb") + cluster_name = "mycluster" + + def test_drop_database(self): + q1 = ClickHouseQuery.drop_database(self.database_xyz) + q2 = ClickHouseQuery.drop_database(self.database_xyz).on_cluster(self.cluster_name) + q3 = ClickHouseQuery.drop_database(self.database_xyz).if_exists().on_cluster(self.cluster_name) + + self.assertEqual('DROP DATABASE "mydb"', str(q1)) + self.assertEqual('DROP DATABASE "mydb" ON CLUSTER "mycluster"', str(q2)) + self.assertEqual('DROP DATABASE IF EXISTS "mydb" ON CLUSTER "mycluster"', str(q3)) + + def test_drop_table(self): + q1 = ClickHouseQuery.drop_table(self.table_abc) + q2 = ClickHouseQuery.drop_table(self.table_abc).on_cluster(self.cluster_name) + q3 = ClickHouseQuery.drop_table(self.table_abc).if_exists().on_cluster(self.cluster_name) + + self.assertEqual('DROP TABLE "abc"', str(q1)) + self.assertEqual('DROP TABLE "abc" ON CLUSTER "mycluster"', str(q2)) + self.assertEqual('DROP TABLE IF EXISTS "abc" ON CLUSTER "mycluster"', str(q3)) + + def test_drop_dictionary(self): + q1 = ClickHouseQuery.drop_dictionary("dict") + q2 = ClickHouseQuery.drop_dictionary("dict").on_cluster(self.cluster_name) + q3 = ClickHouseQuery.drop_dictionary("dict").if_exists().on_cluster(self.cluster_name) + + self.assertEqual('DROP DICTIONARY "dict"', str(q1)) + self.assertEqual('DROP DICTIONARY "dict"', str(q2)) # NO CLUSTER + self.assertEqual('DROP DICTIONARY IF EXISTS "dict"', str(q3)) # NO CLUSTER + + def test_drop_other(self): + q1 = ClickHouseQuery.drop_quota("myquota") + q2 = ClickHouseQuery.drop_user("myuser") + q3 = ClickHouseQuery.drop_view("myview") + + self.assertEqual('DROP QUOTA "myquota"', str(q1)) + self.assertEqual('DROP USER "myuser"', str(q2)) + self.assertEqual('DROP VIEW "myview"', str(q3)) + + +class DistinctOnTests(TestCase): + table_abc = Table("abc") + + def test_distinct_on(self): + q = ClickHouseQuery.from_(self.table_abc).distinct_on("lname", self.table_abc.fname).select("lname", "id") + + self.assertEqual('''SELECT DISTINCT ON("lname","fname") "lname","id" FROM "abc"''', str(q)) + + +class LimitByTests(TestCase): + table_abc = Table("abc") + + def test_limit_by(self): + q = ClickHouseQuery.from_(self.table_abc).limit_by(1, "a", self.table_abc.b).select("a", "b", "c") + + self.assertEqual('''SELECT "a","b","c" FROM "abc" LIMIT 1 BY ("a","b")''', str(q)) + + def test_limit_offset_by(self): + q = ClickHouseQuery.from_(self.table_abc).limit_offset_by(1, 2, "a", self.table_abc.b).select("a", "b", "c") + + self.assertEqual('''SELECT "a","b","c" FROM "abc" LIMIT 1 OFFSET 2 BY ("a","b")''', str(q)) + + def test_limit_offset0_by(self): + q = ClickHouseQuery.from_(self.table_abc).limit_offset_by(1, 0, "a", self.table_abc.b).select("a", "b", "c") + + self.assertEqual('''SELECT "a","b","c" FROM "abc" LIMIT 1 BY ("a","b")''', str(q)) + + def test_rename_table(self): + table_join = Table("join") + + q = ( + ClickHouseQuery.from_(self.table_abc) + .join(table_join) + .using("a") + .limit_by(1, self.table_abc.a, table_join.a) + .select(self.table_abc.b, table_join.b) + ) + q = q.replace_table(self.table_abc, Table("xyz")) + + self.assertEqual( + '''SELECT "xyz"."b","join"."b" FROM "xyz" JOIN "join" USING ("a") LIMIT 1 BY ("xyz"."a","join"."a")''', + str(q), + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/dialects/test_mssql.py b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/dialects/test_mssql.py new file mode 100644 index 0000000000000000000000000000000000000000..7cf53b228f413a8c7cd3e414fef5522a82f99b29 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/dialects/test_mssql.py @@ -0,0 +1,81 @@ +import unittest + +from pypika import Table +from pypika.analytics import Count +from pypika.dialects import MSSQLQuery +from pypika.utils import QueryException + + +class SelectTests(unittest.TestCase): + def test_normal_select(self): + q = MSSQLQuery.from_("abc").select("def") + + self.assertEqual('SELECT "def" FROM "abc"', str(q)) + + def test_distinct_select(self): + q = MSSQLQuery.from_("abc").select("def").distinct() + + self.assertEqual('SELECT DISTINCT "def" FROM "abc"', str(q)) + + def test_top_distinct_select(self): + q = MSSQLQuery.from_("abc").select("def").top(10).distinct() + + self.assertEqual('SELECT DISTINCT TOP (10) "def" FROM "abc"', str(q)) + + def test_top_select(self): + q = MSSQLQuery.from_("abc").select("def").top(10) + + self.assertEqual('SELECT TOP (10) "def" FROM "abc"', str(q)) + + def test_top_with_ties_select(self): + q = MSSQLQuery.from_("abc").select("def").top(10, with_ties=True) + + self.assertEqual('SELECT TOP (10) WITH TIES "def" FROM "abc"', str(q)) + + def test_top_percent_select(self): + q = MSSQLQuery.from_("abc").select("def").top(10, percent=True) + + self.assertEqual('SELECT TOP (10) PERCENT "def" FROM "abc"', str(q)) + + def test_top_percent_invalid_range(self): + for invalid_top in [-1, 101]: + with self.assertRaisesRegex( + QueryException, "TOP value must be between 0 and 100 when `percent` is specified" + ): + MSSQLQuery.from_("abc").select("def").top(invalid_top, percent=True) + + def test_top_select_non_int(self): + with self.assertRaisesRegex(QueryException, "TOP value must be an integer"): + MSSQLQuery.from_("abc").select("def").top("a") + + def test_limit(self): + q = MSSQLQuery.from_("abc").select("def").orderby("def").limit(10) + + self.assertEqual('SELECT "def" FROM "abc" ORDER BY "def" OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY', str(q)) + + def test_offset(self): + q = MSSQLQuery.from_("abc").select("def").orderby("def").offset(10) + + self.assertEqual('SELECT "def" FROM "abc" ORDER BY "def" OFFSET 10 ROWS', str(q)) + + def test_limit_with_offset(self): + q = MSSQLQuery.from_("abc").select("def").orderby("def").limit(10).offset(10) + + self.assertEqual('SELECT "def" FROM "abc" ORDER BY "def" OFFSET 10 ROWS FETCH NEXT 10 ROWS ONLY', str(q)) + + def test_groupby_alias_False_does_not_group_by_alias_with_standard_query(self): + t = Table('table1') + col = t.abc.as_('a') + q = MSSQLQuery.from_(t).select(col, Count('*')).groupby(col) + + self.assertEqual('SELECT "abc" "a",COUNT(\'*\') FROM "table1" GROUP BY "abc"', str(q)) + + def test_groupby_alias_False_does_not_group_by_alias_when_subqueries_are_present(self): + t = Table('table1') + subquery = MSSQLQuery.from_(t).select(t.abc) + col = subquery.abc.as_('a') + q = MSSQLQuery.from_(subquery).select(col, Count('*')).groupby(col) + + self.assertEqual( + 'SELECT "sq0"."abc" "a",COUNT(\'*\') FROM (SELECT "abc" FROM "table1") "sq0" GROUP BY "sq0"."abc"', str(q) + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/dialects/test_mysql.py b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/dialects/test_mysql.py new file mode 100644 index 0000000000000000000000000000000000000000..619d064adcdf8b5ff9ecd054fa4ab00eff1d69b3 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/dialects/test_mysql.py @@ -0,0 +1,91 @@ +import unittest + +from pypika import MySQLQuery, QueryException, Table, Column + + +class SelectTests(unittest.TestCase): + table_abc = Table("abc") + + def test_normal_select(self): + q = MySQLQuery.from_("abc").select("def") + + self.assertEqual("SELECT `def` FROM `abc`", str(q)) + + def test_distinct_select(self): + q = MySQLQuery.from_("abc").select("def").distinct() + + self.assertEqual("SELECT DISTINCT `def` FROM `abc`", str(q)) + + def test_modifier_select(self): + q = MySQLQuery.from_("abc").select("def").select("ghi").modifier("SQL_CALC_FOUND_ROWS") + + self.assertEqual("SELECT SQL_CALC_FOUND_ROWS `def`,`ghi` FROM `abc`", str(q)) + + def test_multiple_modifier_select(self): + q = MySQLQuery.from_("abc").select("def").modifier("HIGH_PRIORITY").modifier("SQL_CALC_FOUND_ROWS") + + self.assertEqual("SELECT HIGH_PRIORITY SQL_CALC_FOUND_ROWS `def` FROM `abc`", str(q)) + + +class UpdateTests(unittest.TestCase): + table_abc = Table("abc") + + def test_update(self): + q = MySQLQuery.into("abc").insert(1, [1, "a", True]) + + self.assertEqual("INSERT INTO `abc` VALUES (1,[1,'a',true])", str(q)) + + def test_on_duplicate_key_ignore_update(self): + q = MySQLQuery.into("abc").insert(1, [1, "a", True]).on_duplicate_key_ignore() + + self.assertEqual("INSERT INTO `abc` VALUES (1,[1,'a',true]) ON DUPLICATE KEY IGNORE", str(q)) + + def test_on_duplicate_key_update_update(self): + q = MySQLQuery.into("abc").insert(1, [1, "a", True]).on_duplicate_key_update(self.table_abc.a, 'b') + + self.assertEqual("INSERT INTO `abc` VALUES (1,[1,'a',true]) ON DUPLICATE KEY UPDATE `a`='b'", str(q)) + + def test_conflict_handlers_update(self): + with self.assertRaises(QueryException): + ( + MySQLQuery.into("abc") + .insert(1, [1, "a", True]) + .on_duplicate_key_ignore() + .on_duplicate_key_update(self.table_abc.a, 'b') + ) + + +class LoadCSVTests(unittest.TestCase): + table_abc = Table("abc") + + def test_load_from_file(self): + q1 = MySQLQuery.load("/path/to/file").into("abc") + + q2 = MySQLQuery.load("/path/to/file").into(self.table_abc) + + self.assertEqual( + "LOAD DATA LOCAL INFILE '/path/to/file' INTO TABLE `abc` FIELDS TERMINATED BY ','", + str(q1), + ) + self.assertEqual( + "LOAD DATA LOCAL INFILE '/path/to/file' INTO TABLE `abc` FIELDS TERMINATED BY ','", + str(q2), + ) + + +class TableTests(unittest.TestCase): + table_abc = Table("abc") + + def test_create_table(self): + q = MySQLQuery.create_table(self.table_abc).columns(Column("id", "INT")) + self.assertEqual( + 'CREATE TABLE `abc` (`id` INT)', + str(q), + ) + + def test_drop_table(self): + q = MySQLQuery.drop_table(self.table_abc) + self.assertEqual( + 'DROP TABLE `abc`', + str(q), + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/dialects/test_oracle.py b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/dialects/test_oracle.py new file mode 100644 index 0000000000000000000000000000000000000000..21b54f16fd5d3518b5c767d3605068637898a73f --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/dialects/test_oracle.py @@ -0,0 +1,51 @@ +import unittest + +from pypika import OracleQuery, Table +from pypika.analytics import Count + + +class SelectTests(unittest.TestCase): + def test_groupby_alias_False_does_not_group_by_alias_with_standard_query(self): + t = Table('table1') + col = t.abc.as_('a') + q = OracleQuery.from_(t).select(col, Count('*')).groupby(col) + + self.assertEqual('SELECT abc a,COUNT(\'*\') FROM table1 GROUP BY abc', str(q)) + + def test_groupby_alias_False_does_not_group_by_alias_when_subqueries_are_present(self): + t = Table('table1') + subquery = OracleQuery.from_(t).select(t.abc) + col = subquery.abc.as_('a') + q = OracleQuery.from_(subquery).select(col, Count('*')).groupby(col) + + self.assertEqual('SELECT sq0.abc a,COUNT(\'*\') FROM (SELECT abc FROM table1) sq0 GROUP BY sq0.abc', str(q)) + + def test_limit_query(self): + t = Table('table1') + limit = 5 + q = OracleQuery.from_(t).select(t.test).limit(limit) + + self.assertEqual(f'SELECT test FROM table1 FETCH NEXT {limit} ROWS ONLY', str(q)) + + def test_offset_query(self): + t = Table('table1') + offset = 5 + q = OracleQuery.from_(t).select(t.test).offset(offset) + + self.assertEqual(f'SELECT test FROM table1 OFFSET {offset} ROWS', str(q)) + + def test_limit_offset_query(self): + t = Table('table1') + limit = 5 + offset = 5 + q = OracleQuery.from_(t).select(t.test).limit(limit).offset(offset) + + self.assertEqual(f'SELECT test FROM table1 OFFSET {offset} ROWS FETCH NEXT {limit} ROWS ONLY', str(q)) + + def test_fetch_next_method_deprecated(self): + with self.assertWarns(DeprecationWarning): + t = Table('table1') + limit = 5 + q = OracleQuery.from_(t).select(t.test).fetch_next(limit) + + self.assertEqual(f'SELECT test FROM table1 FETCH NEXT {limit} ROWS ONLY', str(q)) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/dialects/test_postgresql.py b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/dialects/test_postgresql.py new file mode 100644 index 0000000000000000000000000000000000000000..437eed03e120485ed2a357a4c2d92426f1466e14 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/dialects/test_postgresql.py @@ -0,0 +1,262 @@ +import unittest +from collections import OrderedDict + +from pypika import ( + Array, + Field, + JSON, + QueryException, + Table, +) +from pypika.dialects import PostgreSQLQuery + + +class InsertTests(unittest.TestCase): + table_abc = Table("abc") + + def test_array_keyword(self): + q = PostgreSQLQuery.into(self.table_abc).insert(1, [1, "a", True]) + + self.assertEqual("INSERT INTO \"abc\" VALUES (1,ARRAY[1,'a',true])", str(q)) + + +class JSONObjectTests(unittest.TestCase): + def test_alias_set_correctly(self): + table = Table('jsonb_table') + q = PostgreSQLQuery.from_('abc').select(table.value.get_text_value('a').as_('name')) + + self.assertEqual('''SELECT "value"->>'a' "name" FROM "abc"''', str(q)) + + def test_json_value_from_dict(self): + q = PostgreSQLQuery.select(JSON({"a": "foo"})) + + self.assertEqual('SELECT \'{"a":"foo"}\'', str(q)) + + def test_json_value_from_array_num(self): + q = PostgreSQLQuery.select(JSON([1, 2, 3])) + + self.assertEqual("SELECT '[1,2,3]'", str(q)) + + def test_json_value_from_array_str(self): + q = PostgreSQLQuery.select(JSON(["a", "b", "c"])) + + self.assertEqual('SELECT \'["a","b","c"]\'', str(q)) + + def test_json_value_from_dict_recursive(self): + q = PostgreSQLQuery.select(JSON({"a": "z", "b": {"c": "foo"}, "d": 1})) + + # gotta split this one up to avoid the indeterminate order + sql = str(q) + start, end = 9, -2 + self.assertEqual("SELECT '{}'", sql[:start] + sql[end:]) + + members_set = set(sql[start:end].split(",")) + self.assertSetEqual({'"a":"z"', '"b":{"c":"foo"}', '"d":1'}, members_set) + + +class JSONOperatorsTests(unittest.TestCase): + # reference https://www.postgresql.org/docs/9.5/functions-json.html + table_abc = Table("abc") + + def test_get_json_value_by_key(self): + q = PostgreSQLQuery.from_(self.table_abc).select("*").where(self.table_abc.json.get_json_value("dates")) + + self.assertEqual('SELECT * FROM "abc" WHERE "json"->\'dates\'', str(q)) + + def test_get_json_value_by_index(self): + q = PostgreSQLQuery.from_(self.table_abc).select("*").where(self.table_abc.json.get_json_value(1)) + + self.assertEqual('SELECT * FROM "abc" WHERE "json"->1', str(q)) + + def test_get_text_value_by_key(self): + q = PostgreSQLQuery.from_(self.table_abc).select("*").where(self.table_abc.json.get_text_value("dates")) + + self.assertEqual('SELECT * FROM "abc" WHERE "json"->>\'dates\'', str(q)) + + def test_get_text_value_by_index(self): + q = PostgreSQLQuery.from_(self.table_abc).select("*").where(self.table_abc.json.get_text_value(1)) + + self.assertEqual('SELECT * FROM "abc" WHERE "json"->>1', str(q)) + + def test_get_path_json_value(self): + q = PostgreSQLQuery.from_(self.table_abc).select("*").where(self.table_abc.json.get_path_json_value("{a,b}")) + + self.assertEqual('SELECT * FROM "abc" WHERE "json"#>\'{a,b}\'', str(q)) + + def test_get_path_text_value(self): + q = PostgreSQLQuery.from_(self.table_abc).select("*").where(self.table_abc.json.get_path_text_value("{a,b}")) + + self.assertEqual('SELECT * FROM "abc" WHERE "json"#>>\'{a,b}\'', str(q)) + + +class JSONBOperatorsTests(unittest.TestCase): + # reference https://www.postgresql.org/docs/9.5/functions-json.html + table_abc = Table("abc") + + def test_json_contains_for_json(self): + q = PostgreSQLQuery.select(JSON({"a": 1, "b": 2}).contains({"a": 1})) + + # gotta split this one up to avoid the indeterminate order + sql = str(q) + start, end = 9, -13 + self.assertEqual("SELECT '{}'@>'{\"a\":1}'", sql[:start] + sql[end:]) + + members_set = set(sql[start:end].split(",")) + self.assertSetEqual({'"a":1', '"b":2'}, members_set) + + def test_json_contains_for_field(self): + q = ( + PostgreSQLQuery.from_(self.table_abc) + .select("*") + .where(self.table_abc.json.contains({"dates": "2018-07-10 - 2018-07-17"})) + ) + + self.assertEqual( + "SELECT * " 'FROM "abc" ' 'WHERE "json"@>\'{"dates":"2018-07-10 - 2018-07-17"}\'', + str(q), + ) + + def test_json_contained_by_using_str_arg(self): + q = ( + PostgreSQLQuery.from_(self.table_abc) + .select("*") + .where( + self.table_abc.json.contained_by( + OrderedDict( + [ + ("dates", "2018-07-10 - 2018-07-17"), + ("imported", "8"), + ] + ) + ) + ) + ) + self.assertEqual( + 'SELECT * FROM "abc" ' 'WHERE "json"<@\'{"dates":"2018-07-10 - 2018-07-17","imported":"8"}\'', + str(q), + ) + + def test_json_contained_by_using_list_arg(self): + q = ( + PostgreSQLQuery.from_(self.table_abc) + .select("*") + .where(self.table_abc.json.contained_by(["One", "Two", "Three"])) + ) + + self.assertEqual('SELECT * FROM "abc" WHERE "json"<@\'["One","Two","Three"]\'', str(q)) + + def test_json_contained_by_with_complex_criterion(self): + q = ( + PostgreSQLQuery.from_(self.table_abc) + .select("*") + .where(self.table_abc.json.contained_by(["One", "Two", "Three"]) & (self.table_abc.id == 26)) + ) + + self.assertEqual( + 'SELECT * FROM "abc" WHERE "json"<@\'["One","Two","Three"]\' AND "id"=26', + str(q), + ) + + def test_json_has_key(self): + q = PostgreSQLQuery.from_(self.table_abc).select("*").where(self.table_abc.json.has_key("dates")) + + self.assertEqual('SELECT * FROM "abc" WHERE "json"?\'dates\'', str(q)) + + def test_json_has_keys(self): + q = PostgreSQLQuery.from_(self.table_abc).select("*").where(self.table_abc.json.has_keys(["dates", "imported"])) + + self.assertEqual("SELECT * FROM \"abc\" WHERE \"json\"?&ARRAY['dates','imported']", str(q)) + + def test_json_has_any_keys(self): + q = ( + PostgreSQLQuery.from_(self.table_abc) + .select("*") + .where(self.table_abc.json.has_any_keys(["dates", "imported"])) + ) + + self.assertEqual("SELECT * FROM \"abc\" WHERE \"json\"?|ARRAY['dates','imported']", str(q)) + + def test_subnet_contains_inet(self): + q = ( + PostgreSQLQuery.from_(self.table_abc) + .select(self.table_abc.a.lshift(2)) + .where(self.table_abc.cidr >> "1.1.1.1") + ) + + self.assertEqual("SELECT \"a\"<<2 FROM \"abc\" WHERE \"cidr\">>'1.1.1.1'", str(q)) + + +class DistinctOnTests(unittest.TestCase): + table_abc = Table("abc") + + def test_distinct_on(self): + q = PostgreSQLQuery.from_(self.table_abc).distinct_on("lname", self.table_abc.fname).select("lname", "id") + + self.assertEqual('''SELECT DISTINCT ON("lname","fname") "lname","id" FROM "abc"''', str(q)) + + +class ArrayTests(unittest.TestCase): + def test_array_syntax(self): + tb = Table("tb") + q = PostgreSQLQuery.from_(tb).select(Array(1, "a", ["b", 2, 3])) + + self.assertEqual(str(q), "SELECT ARRAY[1,'a',ARRAY['b',2,3]] FROM \"tb\"") + + def test_render_alias_in_array_sql(self): + tb = Table("tb") + + q = PostgreSQLQuery.from_(tb).select(Array(tb.col).as_("different_name")) + self.assertEqual(str(q), 'SELECT ARRAY["col"] "different_name" FROM "tb"') + + +class ReturningClauseTests(unittest.TestCase): + @classmethod + def setUpClass(cls) -> None: + super().setUpClass() + cls.table_abc = Table('abc') + + def test_returning_from_missing_table_raises_queryexception(self): + field_from_diff_table = Field('xyz', table=Table('other')) + + with self.assertRaisesRegex(QueryException, "You can't return from other tables"): + ( + PostgreSQLQuery.from_(self.table_abc) + .where(self.table_abc.foo == self.table_abc.bar) + .delete() + .returning(field_from_diff_table) + ) + + def test_queryexception_if_returning_used_on_invalid_query(self): + with self.assertRaisesRegex(QueryException, "Returning can't be used in this query"): + PostgreSQLQuery.from_(self.table_abc).select('abc').returning('abc') + + def test_no_queryexception_if_returning_used_on_valid_query_type(self): + # No exceptions for insert, update and delete queries + with self.subTest('DELETE'): + PostgreSQLQuery.from_(self.table_abc).where(self.table_abc.foo == self.table_abc.bar).delete().returning( + "id" + ) + with self.subTest('UPDATE'): + PostgreSQLQuery.update(self.table_abc).where(self.table_abc.foo == 0).set("foo", "bar").returning("id") + with self.subTest('INSERT'): + PostgreSQLQuery.into(self.table_abc).insert('abc').returning('abc') + + def test_return_field_from_join_table(self): + new_table = Table('xyz') + q = ( + PostgreSQLQuery.update(self.table_abc) + .join(new_table) + .on(new_table.id == self.table_abc.xyz) + .where(self.table_abc.foo == 0) + .set("foo", "bar") + .returning(new_table.a) + ) + + self.assertEqual( + 'UPDATE "abc" ' + 'JOIN "xyz" ON "xyz"."id"="abc"."xyz" ' + 'SET "foo"=\'bar\' ' + 'WHERE "abc"."foo"=0 ' + 'RETURNING "xyz"."a"', + str(q), + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/dialects/test_snowflake.py b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/dialects/test_snowflake.py new file mode 100644 index 0000000000000000000000000000000000000000..5ac08b2d8b8b5496ed6f3510acf4be1ec7893405 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/dialects/test_snowflake.py @@ -0,0 +1,58 @@ +import unittest + +from pypika import ( + Tables, + functions as fn, + Column, +) +from pypika.dialects import SnowflakeQuery + + +class QuoteTests(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_use_double_quotes_on_alias_but_not_on_terms(self): + q = SnowflakeQuery.from_(self.table_abc).select(self.table_abc.a.as_("bar")) + + self.assertEqual('SELECT a "bar" FROM abc', q.get_sql(with_namespace=True)) + + def test_use_double_quotes_on_alias_but_not_on_terms_with_joins(self): + foo = self.table_abc.as_("foo") + bar = self.table_efg.as_("bar") + + q = SnowflakeQuery.from_(foo).join(bar).on(foo.fk == bar.id).select(foo.a, bar.b) + + self.assertEqual( + "SELECT foo.a,bar.b " 'FROM abc "foo" ' 'JOIN efg "bar" ' "ON foo.fk=bar.id", + q.get_sql(with_namespace=True), + ) + + def test_use_double_quotes_on_alias_but_not_on_terms(self): + idx = self.table_abc.index.as_("idx") + val = fn.Sum(self.table_abc.value).as_("val") + q = SnowflakeQuery.from_(self.table_abc).select(idx, val).groupby(idx).orderby(idx) + + self.assertEqual( + 'SELECT index "idx",SUM(value) "val" ' "FROM abc " 'GROUP BY "idx" ' 'ORDER BY "idx"', + q.get_sql(with_namespace=True), + ) + + def test_dont_use_double_quotes_on_joining_queries(self): + foo = self.table_abc + bar = self.table_efg + q1 = SnowflakeQuery.from_(foo).select(foo.b) + q2 = SnowflakeQuery.from_(bar).select(bar.b) + q = SnowflakeQuery.from_(q1).join(q2).on(q1.b == q2.b).select("*") + + self.assertEqual( + "SELECT * " 'FROM (SELECT b FROM abc) sq0 ' 'JOIN (SELECT b FROM efg) sq1 ' "ON sq0.b=sq1.b", + q.get_sql(), + ) + + def test_dont_use_double_quotes_on_create_queries(self): + q = SnowflakeQuery.create_table(self.table_abc).columns(Column("id", "INT")) + self.assertEqual("CREATE TABLE abc (id INT)", q.get_sql()) + + def test_dont_use_double_quotes_on_drop_queries(self): + q = SnowflakeQuery.drop_table(self.table_abc) + self.assertEqual("DROP TABLE abc", q.get_sql()) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/dialects/test_sqllite.py b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/dialects/test_sqllite.py new file mode 100644 index 0000000000000000000000000000000000000000..104a7235b6ea2d46fd365989f68c5d081eb20076 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/dialects/test_sqllite.py @@ -0,0 +1,35 @@ +import unittest + +from pypika import Table +from pypika.dialects import SQLLiteQuery + + +class SelectTests(unittest.TestCase): + table_abc = Table("abc") + + def test_bool_true_as_one(self): + q = SQLLiteQuery.from_("abc").select(True) + + self.assertEqual('SELECT 1 FROM "abc"', str(q)) + + def test_bool_false_as_zero(self): + q = SQLLiteQuery.from_("abc").select(False) + + self.assertEqual('SELECT 0 FROM "abc"', str(q)) + + +class ReplaceTests(unittest.TestCase): + def test_normal_replace(self): + query = SQLLiteQuery.into("abc").replace("v1", "v2", "v3") + expected_output = "REPLACE INTO \"abc\" VALUES ('v1','v2','v3')" + self.assertEqual(expected_output, str(query)) + + def test_replace_subquery(self): + query = SQLLiteQuery.into("abc").replace(SQLLiteQuery.from_("def").select("f1", "f2")) + expected_output = 'REPLACE INTO "abc" VALUES ((SELECT "f1","f2" FROM "def"))' + self.assertEqual(expected_output, str(query)) + + def test_insert_or_replace(self): + query = SQLLiteQuery.into("abc").insert_or_replace("v1", "v2", "v3") + expected_output = "INSERT OR REPLACE INTO \"abc\" VALUES ('v1','v2','v3')" + self.assertEqual(expected_output, str(query)) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/dialects/test_vertica.py b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/dialects/test_vertica.py new file mode 100644 index 0000000000000000000000000000000000000000..61985bfc244fcd663e7d8a904b4645901f3abdfc --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/dialects/test_vertica.py @@ -0,0 +1,93 @@ +import unittest + +from pypika import Columns, Table, Tables, VerticaQuery + + +class VerticaQueryTests(unittest.TestCase): + table_abc = Table("abc") + + def test_select_query_with_hint(self): + q = VerticaQuery.from_("abc").select("*").hint("test_hint") + + self.assertEqual('SELECT /*+label(test_hint)*/ * FROM "abc"', str(q)) + + def test_insert_query_with_hint(self): + query = VerticaQuery.into(self.table_abc).insert(1).hint("test_hint") + + self.assertEqual('INSERT /*+label(test_hint)*/ INTO "abc" VALUES (1)', str(query)) + + def test_update_query_with_hint(self): + q = VerticaQuery.update(self.table_abc).set("foo", "bar").hint("test_hint") + + self.assertEqual('UPDATE /*+label(test_hint)*/ "abc" SET "foo"=\'bar\'', str(q)) + + def test_delete_query_with_hint(self): + q = VerticaQuery.from_("abc").delete().hint("test_hint") + + self.assertEqual('DELETE /*+label(test_hint)*/ FROM "abc"', str(q)) + + +class CopyCSVTests(unittest.TestCase): + table_abc = Table("abc") + + def test_copy_from_file(self): + with self.subTest("with table as string"): + q = VerticaQuery.from_file("/path/to/file").copy_("abc") + + self.assertEqual( + "COPY \"abc\" FROM LOCAL '/path/to/file' PARSER fcsvparser(header=false)", + str(q), + ) + + with self.subTest("with table"): + q = VerticaQuery.from_file("/path/to/file").copy_(self.table_abc) + + self.assertEqual( + "COPY \"abc\" FROM LOCAL '/path/to/file' PARSER fcsvparser(header=false)", + str(q), + ) + + +class CreateTemporaryTableTests(unittest.TestCase): + new_table, existing_table = Tables("abc", "efg") + foo, bar = Columns(("a", "INT"), ("b", "VARCHAR(100)")) + select = VerticaQuery.from_(existing_table).select(existing_table.foo, existing_table.bar) + + def test_create_local_temporary_table(self): + with self.subTest("with columns"): + q = VerticaQuery.create_table(self.new_table).temporary().local().columns(self.foo, self.bar) + + self.assertEqual('CREATE LOCAL TEMPORARY TABLE "abc" ("a" INT,"b" VARCHAR(100))', str(q)) + + with self.subTest("with select"): + q = VerticaQuery.create_table(self.new_table).temporary().local().as_select(self.select) + + self.assertEqual( + 'CREATE LOCAL TEMPORARY TABLE "abc" AS (SELECT "foo","bar" FROM "efg")', + str(q), + ) + + def test_create_local_table_without_temporary_raises_error(self): + with self.assertRaises(AttributeError): + VerticaQuery.create_table(self.new_table).local() + + def test_create_temporary_table_preserve_rows(self): + with self.subTest("with columns"): + q = VerticaQuery.create_table(self.new_table).temporary().preserve_rows().columns(self.foo, self.bar) + + self.assertEqual( + 'CREATE TEMPORARY TABLE "abc" ("a" INT,"b" VARCHAR(100)) ON COMMIT PRESERVE ROWS', + str(q), + ) + + with self.subTest("with select"): + q = VerticaQuery.create_table(self.new_table).temporary().preserve_rows().as_select(self.select) + + self.assertEqual( + 'CREATE TEMPORARY TABLE "abc" ON COMMIT PRESERVE ROWS AS (SELECT "foo","bar" FROM "efg")', + str(q), + ) + + def test_create_table_preserve_rows_without_temporary_raises_error(self): + with self.assertRaises(AttributeError): + VerticaQuery.create_table(self.new_table).preserve_rows() diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/test_aggregate.py b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/test_aggregate.py new file mode 100644 index 0000000000000000000000000000000000000000..1c627d8e9c2d65410c67cf2c39974949b0720a0e --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/test_aggregate.py @@ -0,0 +1,122 @@ +import unittest + +from pypika import ( + Case, + Field, + Table, + functions as fn, +) +from pypika.terms import ( + Negative, + ValueWrapper, +) + + +class IsAggregateTests(unittest.TestCase): + def test__field_is_not_aggregate(self): + v = Field("foo") + self.assertFalse(v.is_aggregate) + + def test__constant_is_aggregate_none(self): + v = ValueWrapper(100) + self.assertIsNone(v.is_aggregate) + + def test__constant_arithmetic_is_aggregate_none(self): + v = ValueWrapper(100) + ValueWrapper(100) + self.assertIsNone(v.is_aggregate) + + def test__field_arithmetic_is_not_aggregate(self): + v = Field("foo") + Field("bar") + self.assertFalse(v.is_aggregate) + + def test__field_arithmetic_constant_is_not_aggregate(self): + v = Field("foo") + 1 + self.assertFalse(v.is_aggregate) + + def test__agg_func_is_aggregate(self): + v = fn.Sum(Field("foo")) + self.assertTrue(v.is_aggregate) + + def test__negative_agg_func_is_aggregate(self): + v = Negative(fn.Sum(Field("foo"))) + self.assertTrue(v.is_aggregate) + + def test__agg_func_arithmetic_is_aggregate(self): + v = fn.Sum(Field("foo")) / fn.Sum(Field("foo")) + self.assertTrue(v.is_aggregate) + + def test__mixed_func_arithmetic_is_not_aggregate(self): + v = Field("foo") / fn.Sum(Field("foo")) + self.assertFalse(v.is_aggregate) + + def test__func_arithmetic_constant_is_not_aggregate(self): + v = 1 / fn.Sum(Field("foo")) + self.assertTrue(v.is_aggregate) + + def test__agg_case_criterion_is_aggregate(self): + v = Case().when(fn.Sum(Field("foo")) > 666, 'More than 666').else_('Less than 666') + + self.assertTrue(v.is_aggregate) + + def test__agg_case_is_aggregate(self): + v = ( + Case() + .when(Field("foo") == 1, fn.Sum(Field("bar"))) + .when(Field("foo") == 2, fn.Sum(Field("fiz"))) + .else_(fn.Sum(Field("fiz"))) + ) + + self.assertTrue(v.is_aggregate) + + def test__mixed_case_is_not_aggregate(self): + v = Case().when(Field("foo") == 1, fn.Sum(Field("bar"))).when(Field("foo") == 2, Field("fiz")) + + self.assertFalse(v.is_aggregate) + + def test__case_mixed_else_is_not_aggregate(self): + v = ( + Case() + .when(Field("foo") == 1, fn.Sum(Field("bar"))) + .when(Field("foo") == 2, fn.Sum(Field("fiz"))) + .else_(Field("fiz")) + ) + + self.assertFalse(v.is_aggregate) + + def test__case_mixed_constant_is_not_aggregate(self): + v = Case().when(Field("foo") == 1, fn.Sum(Field("bar"))).when(Field("foo") == 2, fn.Sum(Field("fiz"))).else_(1) + + self.assertTrue(v.is_aggregate) + + def test__case_with_field_is_not_aggregate(self): + v = Case().when(Field("foo") == 1, 1).when(Field("foo") == 2, 2).else_(3) + + self.assertFalse(v.is_aggregate) + + def test__case_with_single_aggregate_field_in_one_criterion_is_aggregate(self): + v = Case().when(Field("foo") == 1, 1).when(fn.Sum(Field("foo")) == 2, 2).else_(3) + + self.assertTrue(v.is_aggregate) + + def test__non_aggregate_function_with_aggregated_arg(self): + t = Table("abc") + expr = fn.Sqrt(fn.Sum(t.a)) + + self.assertTrue(expr.is_aggregate) + + def test_complicated(self): + t = Table("abc") + is_placebo = t.campaign_extra_info == "placebo" + + pixel_mobile_search = Case().when(is_placebo, t.action_fb_pixel_search + t.action_fb_mobile_search) + unique_impressions = Case().when(is_placebo, t.unique_impressions) + + v = fn.Sum(pixel_mobile_search) / fn.Sum(unique_impressions) - 1.96 * fn.Sqrt( + 1 + / fn.Sum(unique_impressions) + * fn.Sum(pixel_mobile_search) + / fn.Sum(unique_impressions) + * (1 - fn.Sum(pixel_mobile_search) / fn.Sum(unique_impressions)) + ) + + self.assertTrue(v.is_aggregate) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/test_analytic_queries.py b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/test_analytic_queries.py new file mode 100644 index 0000000000000000000000000000000000000000..6a35ab854b30e3b0f91e633b3349706a22e0a2fd --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/test_analytic_queries.py @@ -0,0 +1,610 @@ +import unittest + +from pypika import Criterion, JoinType, Order, Query, Tables, analytics as an +from pypika.analytics import Lag, Lead + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + + +class RankTests(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_rank(self): + expr = an.Rank().over(self.table_abc.foo).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " "RANK() " 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_dense_rank(self): + expr = an.DenseRank().over(self.table_abc.foo).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " "DENSE_RANK() " 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_row_number(self): + expr = an.RowNumber().over(self.table_abc.foo).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " "ROW_NUMBER() " 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_rank_with_alias(self): + expr = an.Rank().over(self.table_abc.foo).orderby(self.table_abc.date).as_("rank") + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " "RANK() " 'OVER(PARTITION BY "foo" ORDER BY "date") "rank" ' 'FROM "abc"', + str(q), + ) + + def test_multiple_partitions(self): + expr = an.Rank().orderby(self.table_abc.date).over(self.table_abc.foo, self.table_abc.bar) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " "RANK() " 'OVER(PARTITION BY "foo","bar" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_ntile_no_partition_or_order_invalid_sql(self): + expr = an.NTile(5) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual("SELECT " "NTILE(5) " 'FROM "abc"', str(q)) + + def test_ntile_with_partition(self): + expr = an.NTile(5).over(self.table_abc.foo) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual("SELECT " "NTILE(5) " 'OVER(PARTITION BY "foo") ' 'FROM "abc"', str(q)) + + def test_ntile_with_order(self): + expr = an.NTile(5).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual("SELECT " "NTILE(5) " 'OVER(ORDER BY "date") ' 'FROM "abc"', str(q)) + + def test_ntile_with_partition_and_order(self): + expr = an.NTile(5).over(self.table_abc.foo).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " "NTILE(5) " 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_first_value(self): + expr = an.FirstValue(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'FIRST_VALUE("fizz") ' 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_first_value_ignore_nulls(self): + expr = an.FirstValue(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).ignore_nulls() + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'FIRST_VALUE("fizz" IGNORE NULLS) ' 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_first_value_ignore_nulls_first(self): + expr = an.FirstValue(self.table_abc.fizz).ignore_nulls().over(self.table_abc.foo).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'FIRST_VALUE("fizz" IGNORE NULLS) ' 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_first_value_multi_argument(self): + expr = ( + an.FirstValue(self.table_abc.fizz, self.table_abc.buzz) + .over(self.table_abc.foo) + .orderby(self.table_abc.date) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'FIRST_VALUE("fizz","buzz") ' 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_last_value(self): + expr = an.LastValue(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'LAST_VALUE("fizz") ' 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_filter(self): + expr = ( + an.LastValue(self.table_abc.fizz) + .filter(Criterion.all([self.table_abc.bar == True])) + .over(self.table_abc.foo) + .orderby(self.table_abc.date) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'LAST_VALUE("fizz") ' + 'FILTER(WHERE "bar"=true) ' + 'OVER(PARTITION BY "foo" ORDER BY "date") ' + 'FROM "abc"', + str(q), + ) + + def test_filter_quote_table_in_filter(self): + expr = ( + an.LastValue(self.table_efg.fizz) + .filter(self.table_efg.filed.eq('yes')) + .over(self.table_efg.foo) + .orderby(self.table_efg.date) + ) + + q = ( + Query.from_(self.table_abc) + .inner_join(self.table_efg) + .on(self.table_abc.id.eq(self.table_efg.id)) + .select(expr) + ) + + self.assertEqual( + 'SELECT ' + 'LAST_VALUE("efg"."fizz") ' + 'FILTER(WHERE "efg"."filed"=\'yes\') ' + 'OVER(PARTITION BY "efg"."foo" ORDER BY "efg"."date") ' + 'FROM "abc" ' + 'JOIN "efg" ON "abc"."id"="efg"."id"', + str(q), + ) + + def test_orderby_asc(self): + expr = an.LastValue(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date, order=Order.asc) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'LAST_VALUE("fizz") ' 'OVER(PARTITION BY "foo" ORDER BY "date" ASC) ' 'FROM "abc"', + str(q), + ) + + def test_orderby_desc(self): + expr = an.LastValue(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date, order=Order.desc) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'LAST_VALUE("fizz") ' 'OVER(PARTITION BY "foo" ORDER BY "date" DESC) ' 'FROM "abc"', + str(q), + ) + + def test_last_value_multi_argument(self): + expr = ( + an.LastValue(self.table_abc.fizz, self.table_abc.buzz).over(self.table_abc.foo).orderby(self.table_abc.date) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'LAST_VALUE("fizz","buzz") ' 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_last_value_ignore_nulls(self): + expr = an.LastValue(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).ignore_nulls() + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'LAST_VALUE("fizz" IGNORE NULLS) ' 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_median(self): + expr = an.Median(self.table_abc.fizz).over(self.table_abc.foo, self.table_abc.bar).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'MEDIAN("fizz") ' 'OVER(PARTITION BY "foo","bar" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_avg(self): + expr = an.Avg(self.table_abc.fizz).over(self.table_abc.foo, self.table_abc.bar).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'AVG("fizz") ' 'OVER(PARTITION BY "foo","bar" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_stddev(self): + expr = an.StdDev(self.table_abc.fizz).over(self.table_abc.foo, self.table_abc.bar).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'STDDEV("fizz") ' 'OVER(PARTITION BY "foo","bar" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_stddev_pop(self): + expr = ( + an.StdDevPop(self.table_abc.fizz).over(self.table_abc.foo, self.table_abc.bar).orderby(self.table_abc.date) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'STDDEV_POP("fizz") ' 'OVER(PARTITION BY "foo","bar" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_stddev_samp(self): + expr = ( + an.StdDevSamp(self.table_abc.fizz).over(self.table_abc.foo, self.table_abc.bar).orderby(self.table_abc.date) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'STDDEV_SAMP("fizz") ' 'OVER(PARTITION BY "foo","bar" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_variance(self): + expr = ( + an.Variance(self.table_abc.fizz).over(self.table_abc.foo, self.table_abc.bar).orderby(self.table_abc.date) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'VARIANCE("fizz") ' 'OVER(PARTITION BY "foo","bar" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_var_pop(self): + expr = an.VarPop(self.table_abc.fizz).over(self.table_abc.foo, self.table_abc.bar).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'VAR_POP("fizz") ' 'OVER(PARTITION BY "foo","bar" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_var_samp(self): + expr = an.VarSamp(self.table_abc.fizz).over(self.table_abc.foo, self.table_abc.bar).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'VAR_SAMP("fizz") ' 'OVER(PARTITION BY "foo","bar" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_table_prefixes_used_in_analytic_functions(self): + expr = an.Rank().over(self.table_abc.foo).orderby(self.table_efg.date) + + query = ( + Query.from_(self.table_abc) + .join(self.table_efg, how=JoinType.left) + .on(self.table_abc.foo == self.table_efg.bar) + .select("*", expr) + ) + + self.assertEqual( + 'SELECT *,RANK() OVER(PARTITION BY "abc"."foo" ORDER BY "efg"."date") ' + 'FROM "abc" LEFT JOIN "efg" ON "abc"."foo"="efg"."bar"', + str(query), + ) + + def test_sum_rows_unbounded_preceeding(self): + expr = an.Sum(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).rows(an.Preceding()) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'SUM("fizz") ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "ROWS UNBOUNDED PRECEDING" + ") " + 'FROM "abc"', + str(q), + ) + + def test_max_rows_x_preceeding(self): + expr = an.Max(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).rows(an.Preceding(5)) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'MAX("fizz") ' "OVER(" 'PARTITION BY "foo" ORDER BY "date" ' "ROWS 5 PRECEDING" ") " 'FROM "abc"', + str(q), + ) + + def test_min_rows_current_row(self): + expr = an.Min(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).rows(an.CURRENT_ROW) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'MIN("fizz") ' "OVER(" 'PARTITION BY "foo" ORDER BY "date" ' "ROWS CURRENT ROW" ") " 'FROM "abc"', + str(q), + ) + + def test_varpop_range_unbounded_preceeding(self): + expr = ( + an.VarPop(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).range(an.Preceding()) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'VAR_POP("fizz") ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "RANGE UNBOUNDED PRECEDING" + ") " + 'FROM "abc"', + str(q), + ) + + def test_max_range_x_preceeding(self): + expr = an.Max(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).range(an.Preceding(5)) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'MAX("fizz") ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "RANGE 5 PRECEDING" + ") " + 'FROM "abc"', + str(q), + ) + + def test_min_range_current_row(self): + expr = an.Min(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).range(an.CURRENT_ROW) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'MIN("fizz") ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "RANGE CURRENT ROW" + ") " + 'FROM "abc"', + str(q), + ) + + def test_variance_rows_between_unbounded_preceeding_unbounded_following(self): + expr = ( + an.Variance(self.table_abc.fizz) + .over(self.table_abc.foo) + .orderby(self.table_abc.date) + .rows(an.Preceding(), an.Following()) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'VARIANCE("fizz") ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING" + ") " + 'FROM "abc"', + str(q), + ) + + def test_first_value_range_between_x_preceeding_unbounded_following(self): + expr = ( + an.FirstValue(self.table_abc.fizz) + .over(self.table_abc.foo) + .orderby(self.table_abc.date) + .range(an.Preceding(3), an.Following()) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'FIRST_VALUE("fizz") ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "RANGE BETWEEN 3 PRECEDING AND UNBOUNDED FOLLOWING" + ") " + 'FROM "abc"', + str(q), + ) + + def test_varpop_rows_between_unbounded_preceeding_x_following(self): + expr = ( + an.VarPop(self.table_abc.fizz) + .over(self.table_abc.foo) + .orderby(self.table_abc.date) + .rows(an.Preceding(), an.Following(6)) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'VAR_POP("fizz") ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "ROWS BETWEEN UNBOUNDED PRECEDING AND 6 FOLLOWING" + ") " + 'FROM "abc"', + str(q), + ) + + def test_count_range_between_unbounded_preceeding_current_row(self): + expr = ( + an.Count(self.table_abc.fizz) + .over(self.table_abc.foo) + .orderby(self.table_abc.date) + .range(an.Preceding(), an.CURRENT_ROW) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'COUNT("fizz") ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW" + ") " + 'FROM "abc"', + str(q), + ) + + def test_last_value_rows_between_current_row_unbounded_following(self): + expr = ( + an.LastValue(self.table_abc.fizz) + .over(self.table_abc.foo) + .orderby(self.table_abc.date) + .rows(an.CURRENT_ROW, an.Following()) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'LAST_VALUE("fizz") ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING" + ") " + 'FROM "abc"', + str(q), + ) + + def test_last_value_rows_between_current_row_unbounded_following_ignore_nulls(self): + expr = ( + an.LastValue(self.table_abc.fizz) + .over(self.table_abc.foo) + .orderby(self.table_abc.date) + .ignore_nulls() + .rows(an.CURRENT_ROW, an.Following(8)) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'LAST_VALUE("fizz" IGNORE NULLS) ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "ROWS BETWEEN CURRENT ROW AND 8 FOLLOWING" + ") " + 'FROM "abc"', + str(q), + ) + + def test_empty_over(self): + query = Query.from_(self.table_abc).select(an.Sum(self.table_abc.fizz).over()) + + self.assertEqual("SELECT " 'SUM("fizz") OVER() ' 'FROM "abc"', str(query)) + + def test_rows_called_twice_raises_attribute_error(self): + with self.assertRaises(AttributeError): + an.Sum(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).rows(an.Preceding()).rows( + an.Preceding() + ) + + def test_range_called_twice_raises_attribute_error(self): + with self.assertRaises(AttributeError): + an.Sum(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).range( + an.Preceding() + ).range(an.Preceding()) + + def test_rows_then_range_raises_attribute_error(self): + with self.assertRaises(AttributeError): + an.Sum(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).rows( + an.Preceding() + ).range(an.Preceding()) + + def test_range_then_rows_raises_attribute_error(self): + with self.assertRaises(AttributeError): + an.Sum(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).range( + an.Preceding() + ).rows(an.Preceding()) + + def test_lag_generates_correct_sql(self): + with self.subTest('without partition by'): + q = Query.from_(self.table_abc).select( + Lag(self.table_abc.date, 1, '2000-01-01').orderby(self.table_abc.date) + ) + + self.assertEqual('SELECT LAG("date",1,\'2000-01-01\') OVER(ORDER BY "date") FROM "abc"', str(q)) + + with self.subTest('with partition by'): + q = Query.from_(self.table_abc).select( + Lag(self.table_abc.date, 1, '2000-01-01').over(self.table_abc.foo).orderby(self.table_abc.date) + ) + + self.assertEqual( + 'SELECT LAG("date",1,\'2000-01-01\') OVER(PARTITION BY "foo" ORDER BY "date") FROM "abc"', str(q) + ) + + def test_lead_generates_correct_sql(self): + with self.subTest('without partition by'): + q = Query.from_(self.table_abc).select( + Lead(self.table_abc.date, 1, '2000-01-01').orderby(self.table_abc.date) + ) + + self.assertEqual('SELECT LEAD("date",1,\'2000-01-01\') OVER(ORDER BY "date") FROM "abc"', str(q)) + + with self.subTest('with partition by'): + q = Query.from_(self.table_abc).select( + Lead(self.table_abc.date, 1, '2000-01-01').over(self.table_abc.foo).orderby(self.table_abc.date) + ) + + self.assertEqual( + 'SELECT LEAD("date",1,\'2000-01-01\') OVER(PARTITION BY "foo" ORDER BY "date") FROM "abc"', str(q) + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/test_create.py b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/test_create.py new file mode 100644 index 0000000000000000000000000000000000000000..325076544e3824b0d07f82f2378b88218b910dde --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/test_create.py @@ -0,0 +1,210 @@ +import unittest + +from pypika import Column, Columns, Query, Tables, Table +from pypika.terms import ValueWrapper, Index +from pypika.enums import ReferenceOption + + +class CreateTableTests(unittest.TestCase): + new_table, existing_table = Tables("abc", "efg") + foo, bar = Columns(("a", "INT"), ("b", "VARCHAR(100)")) + + def test_create_table_with_columns(self): + with self.subTest("with nullable"): + a = Column("a", "INT", True) + b = Column("b", "VARCHAR(100)", False) + q = Query.create_table(self.new_table).columns(a, b) + + self.assertEqual('CREATE TABLE "abc" ("a" INT NULL,"b" VARCHAR(100) NOT NULL)', str(q)) + + with self.subTest("with defaults"): + a = Column("a", "INT", default=ValueWrapper(42)) + b = Column("b", "VARCHAR(100)", default=ValueWrapper("foo")) + q = Query.create_table(self.new_table).columns(a, b) + + self.assertEqual('CREATE TABLE "abc" ("a" INT DEFAULT 42,"b" VARCHAR(100) DEFAULT \'foo\')', str(q)) + + with self.subTest("with unwrapped defaults"): + a = Column("a", "INT", default=42) + b = Column("b", "VARCHAR(100)", default="foo") + q = Query.create_table(self.new_table).columns(a, b) + + self.assertEqual('CREATE TABLE "abc" ("a" INT DEFAULT 42,"b" VARCHAR(100) DEFAULT \'foo\')', str(q)) + + with self.subTest("with period for"): + a = Column("id", "INT") + b = Column("valid_from", "DATETIME") + c = Column("valid_to", "DATETIME") + q = Query.create_table(self.new_table).columns(a, b, c).period_for('valid_period', b, c) + + self.assertEqual( + 'CREATE TABLE "abc" (' + '"id" INT,' + '"valid_from" DATETIME,' + '"valid_to" DATETIME,' + 'PERIOD FOR "valid_period" ("valid_from","valid_to"))', + str(q), + ) + + with self.subTest("without temporary keyword"): + q = Query.create_table(self.new_table).columns(self.foo, self.bar) + + self.assertEqual('CREATE TABLE "abc" ("a" INT,"b" VARCHAR(100))', str(q)) + + with self.subTest("with temporary keyword"): + q = Query.create_table(self.new_table).temporary().columns(self.foo, self.bar) + + self.assertEqual('CREATE TEMPORARY TABLE "abc" ("a" INT,"b" VARCHAR(100))', str(q)) + + with self.subTest("with primary key"): + q = Query.create_table(self.new_table).columns(self.foo, self.bar).primary_key(self.foo, self.bar) + + self.assertEqual('CREATE TABLE "abc" ("a" INT,"b" VARCHAR(100),PRIMARY KEY ("a","b"))', str(q)) + + with self.subTest("with simple foreign key"): + cref, dref = Columns(("c", "INT"), ("d", "VARCHAR(100)")) + q = ( + Query.create_table(self.new_table) + .columns(self.foo, self.bar) + .foreign_key([self.foo, self.bar], self.existing_table, [cref, dref]) + ) + + self.assertEqual( + 'CREATE TABLE "abc" (' + '"a" INT,' + '"b" VARCHAR(100),' + 'FOREIGN KEY ("a","b") REFERENCES "efg" ("c","d"))', + str(q), + ) + + with self.subTest("with foreign key reference options"): + cref, dref = Columns(("c", "INT"), ("d", "VARCHAR(100)")) + q = ( + Query.create_table(self.new_table) + .columns(self.foo, self.bar) + .foreign_key( + [self.foo, self.bar], + self.existing_table, + [cref, dref], + on_delete=ReferenceOption.cascade, + on_update=ReferenceOption.restrict, + ) + ) + + self.assertEqual( + 'CREATE TABLE "abc" (' + '"a" INT,' + '"b" VARCHAR(100),' + 'FOREIGN KEY ("a","b") REFERENCES "efg" ("c","d") ON DELETE CASCADE ON UPDATE RESTRICT)', + str(q), + ) + + with self.subTest("with unique keys"): + q = ( + Query.create_table(self.new_table) + .columns(self.foo, self.bar) + .unique(self.foo, self.bar) + .unique(self.foo) + ) + + self.assertEqual('CREATE TABLE "abc" ("a" INT,"b" VARCHAR(100),UNIQUE ("a","b"),UNIQUE ("a"))', str(q)) + + with self.subTest("with system versioning"): + q = Query.create_table(self.new_table).columns(self.foo, self.bar).with_system_versioning() + + self.assertEqual('CREATE TABLE "abc" ("a" INT,"b" VARCHAR(100)) WITH SYSTEM VERSIONING', str(q)) + + with self.subTest("with unlogged keyword"): + q = Query.create_table(self.new_table).unlogged().columns(self.foo, self.bar) + + self.assertEqual('CREATE UNLOGGED TABLE "abc" ("a" INT,"b" VARCHAR(100))', str(q)) + + with self.subTest("with if not exists keyword"): + q = Query.create_table(self.new_table).if_not_exists().columns(self.foo, self.bar) + + self.assertEqual('CREATE TABLE IF NOT EXISTS "abc" ("a" INT,"b" VARCHAR(100))', str(q)) + + def test_create_table_with_select(self): + select = Query.from_(self.existing_table).select(self.existing_table.foo, self.existing_table.bar) + + with self.subTest("without temporary keyword"): + q = Query.create_table(self.new_table).as_select(select) + + self.assertEqual('CREATE TABLE "abc" AS (SELECT "foo","bar" FROM "efg")', str(q)) + + with self.subTest("with temporary keyword"): + q = Query.create_table(self.new_table).temporary().as_select(select) + + self.assertEqual( + 'CREATE TEMPORARY TABLE "abc" AS (SELECT "foo","bar" FROM "efg")', + str(q), + ) + + def test_create_table_without_columns_or_select_empty(self): + q = Query.create_table(self.new_table) + + self.assertEqual("", str(q)) + + def test_create_table_with_select_and_columns_fails(self): + select = Query.from_(self.existing_table).select(self.existing_table.foo, self.existing_table.bar) + + with self.subTest("for columns before as_select"): + with self.assertRaises(AttributeError): + Query.create_table(self.new_table).columns(self.foo, self.bar).as_select(select) + + with self.subTest("for as_select before columns"): + with self.assertRaises(AttributeError): + Query.create_table(self.new_table).as_select(select).columns(self.foo, self.bar) + + with self.subTest("repeated foreign key"): + with self.assertRaises(AttributeError): + Query.create_table(self.new_table).foreign_key([self.foo], self.existing_table, [self.bar]).foreign_key( + [self.foo], self.existing_table, [self.bar] + ) + + def test_create_table_as_select_not_query_raises_error(self): + with self.assertRaises(TypeError): + Query.create_table(self.new_table).as_select("abc") + + +class CreateIndexTests(unittest.TestCase): + new_index = Index("abc") + new_table = Table("my_table") + columns = (new_table.a, new_table.b) + where = new_table.a > 1 + + def test_create_index_simple(self) -> None: + q = Query.create_index(self.new_index).on(self.new_table).columns(*self.columns) + self.assertEqual( + f'CREATE INDEX "{self.new_index.name}" ON "{self.new_table.get_table_name()}"({", ".join([c.name for c in self.columns])})', + q.get_sql(), + ) + + def test_create_index_where(self) -> None: + q = Query.create_index(self.new_index).on(self.new_table).columns(*self.columns).where(self.where) + self.assertEqual( + f'CREATE INDEX "{self.new_index.name}" ON "{self.new_table.get_table_name()}"({", ".join([c.name for c in self.columns])}) WHERE {self.where.get_sql()}', + q.get_sql(), + ) + + def test_create_index_unique(self) -> None: + q = Query.create_index(self.new_index).on(self.new_table).columns(*self.columns).unique() + self.assertEqual( + f'CREATE UNIQUE INDEX "{self.new_index.name}" ON "{self.new_table.get_table_name()}"({", ".join([c.name for c in self.columns])})', + q.get_sql(), + ) + + def test_create_index_if_not_exists(self) -> None: + q = Query.create_index(self.new_index).on(self.new_table).columns(*self.columns).if_not_exists() + self.assertEqual( + f'CREATE INDEX IF NOT EXISTS "{self.new_index.name}" ON "{self.new_table.get_table_name()}"({", ".join([c.name for c in self.columns])})', + q.get_sql(), + ) + + def test_create_index_without_columns_raises_error(self) -> None: + with self.assertRaises(AttributeError): + Query.create_index(self.new_index).on(self.new_table).get_sql() + + def test_create_index_without_table_raises_error(self) -> None: + with self.assertRaises(AttributeError): + Query.create_index(self.new_index).columns(*self.columns).get_sql() diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/test_criterions.py b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/test_criterions.py new file mode 100644 index 0000000000000000000000000000000000000000..fca2ceeeb18db88e34ebc38776f644fdcda67e93 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/test_criterions.py @@ -0,0 +1,873 @@ +import unittest +from datetime import ( + date, + datetime, +) + +from pypika import ( + Criterion, + EmptyCriterion, + Field, + Table, + functions as fn, +) +from pypika.queries import QueryBuilder +from pypika.terms import ExistsCriterion, Mod + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + + +class CriterionTests(unittest.TestCase): + t = Table("test", alias="crit") + + def test__criterion_with_alias(self): + c1 = (Field("foo") == Field("bar")).as_("criterion") + + self.assertEqual('"foo"="bar"', str(c1)) + self.assertEqual('"foo"="bar" "criterion"', c1.get_sql(with_alias=True, quote_char='"', alias_quote_char='"')) + + def test__criterion_eq_number(self): + c1 = Field("foo") == 1 + c2 = Field("foo", table=self.t).eq(0) + c3 = Field("foo", table=self.t) == -1 + + self.assertEqual('"foo"=1', str(c1)) + self.assertEqual('"crit"."foo"=0', str(c2)) + self.assertEqual('"crit"."foo"=-1', str(c3)) + + def test__criterion_eq_decimal(self): + c1 = Field("foo") == 1.0 + c2 = Field("foo", table=self.t).eq(0.5) + + self.assertEqual('"foo"=1.0', str(c1)) + self.assertEqual('"crit"."foo"=0.5', str(c2)) + + def test__criterion_eq_bool(self): + c1 = Field("foo") == True + c2 = Field("foo", table=self.t).eq(True) + c3 = Field("foo") == False + c4 = Field("foo", table=self.t).eq(False) + + self.assertEqual('"foo"=true', str(c1)) + self.assertEqual('"crit"."foo"=true', str(c2)) + self.assertEqual('"foo"=false', str(c3)) + self.assertEqual('"crit"."foo"=false', str(c4)) + + def test__criterion_eq_str(self): + c1 = Field("foo") == "abc" + c2 = Field("foo", table=self.t).eq("abc") + + self.assertEqual("\"foo\"='abc'", str(c1)) + self.assertEqual('"crit"."foo"=\'abc\'', str(c2)) + + def test__criterion_eq_date(self): + c1 = Field("foo") == date(2000, 1, 1) + c2 = Field("foo", table=self.t).eq(date(2000, 1, 1)) + + self.assertEqual("\"foo\"='2000-01-01'", str(c1)) + self.assertEqual('"crit"."foo"=\'2000-01-01\'', str(c2)) + + def test__criterion_eq_datetime(self): + c1 = Field("foo") == datetime(2000, 1, 1, 12, 30, 55) + c2 = Field("foo", table=self.t).eq(datetime(2000, 1, 1, 12, 30, 55)) + + self.assertEqual("\"foo\"='2000-01-01T12:30:55'", str(c1)) + self.assertEqual('"crit"."foo"=\'2000-01-01T12:30:55\'', str(c2)) + + def test__criterion_eq_right(self): + c1 = 1 == Field("foo") + c2 = -1 == Field("foo", table=self.t) + + self.assertEqual('"foo"=1', str(c1)) + self.assertEqual('"crit"."foo"=-1', str(c2)) + + def test__criterion_is_null(self): + c1 = Field("foo").isnull() + c2 = Field("foo", table=self.t).isnull() + + self.assertEqual('"foo" IS NULL', str(c1)) + self.assertEqual('"crit"."foo" IS NULL', str(c2)) + + def test__criterion_is_null_with_alias(self): + c1 = Field("foo").isnull().as_('alias') + c2 = Field("foo", table=self.t).isnull().as_('alias') + + self.assertEqual('"foo" IS NULL "alias"', str(c1)) + self.assertEqual('"crit"."foo" IS NULL "alias"', str(c2)) + + def test__criterion_ne_number(self): + c1 = Field("foo") != 1 + c2 = Field("foo", table=self.t).ne(0) + c3 = Field("foo") != -1 + + self.assertEqual('"foo"<>1', str(c1)) + self.assertEqual('"crit"."foo"<>0', str(c2)) + self.assertEqual('"foo"<>-1', str(c3)) + + def test__criterion_ne_str(self): + c1 = Field("foo") != "abc" + c2 = Field("foo", table=self.t).ne("abc") + + self.assertEqual("\"foo\"<>'abc'", str(c1)) + self.assertEqual('"crit"."foo"<>\'abc\'', str(c2)) + + def test__criterion_ne_date(self): + c1 = Field("foo") != date(2000, 1, 1) + c2 = Field("foo", table=self.t).ne(date(2000, 1, 1)) + + self.assertEqual("\"foo\"<>'2000-01-01'", str(c1)) + self.assertEqual('"crit"."foo"<>\'2000-01-01\'', str(c2)) + + def test__criterion_ne_datetime(self): + c1 = Field("foo") != datetime(2000, 1, 1, 12, 30, 55) + c2 = Field("foo", table=self.t).ne(datetime(2000, 1, 1, 12, 30, 55)) + + self.assertEqual("\"foo\"<>'2000-01-01T12:30:55'", str(c1)) + self.assertEqual('"crit"."foo"<>\'2000-01-01T12:30:55\'', str(c2)) + + def test__criterion_ne_right(self): + c1 = 1 != Field("foo") + c2 = -1 != Field("foo", table=self.t) + + self.assertEqual('"foo"<>1', str(c1)) + self.assertEqual('"crit"."foo"<>-1', str(c2)) + + def test__criterion_lt_number(self): + c1 = Field("foo") < 1 + c2 = Field("foo", table=self.t).lt(0) + c3 = Field("foo") < -1 + + self.assertEqual('"foo"<1', str(c1)) + self.assertEqual('"crit"."foo"<0', str(c2)) + self.assertEqual('"foo"<-1', str(c3)) + + def test__criterion_lt_date(self): + c1 = Field("foo") < date(2000, 1, 1) + c2 = Field("foo", table=self.t).lt(date(2000, 1, 1)) + + self.assertEqual("\"foo\"<'2000-01-01'", str(c1)) + self.assertEqual('"crit"."foo"<\'2000-01-01\'', str(c2)) + + def test__criterion_lt_datetime(self): + c1 = Field("foo") < datetime(2000, 1, 1, 12, 30, 55) + c2 = Field("foo", table=self.t).lt(datetime(2000, 1, 1, 12, 30, 55)) + + self.assertEqual("\"foo\"<'2000-01-01T12:30:55'", str(c1)) + self.assertEqual('"crit"."foo"<\'2000-01-01T12:30:55\'', str(c2)) + + def test__criterion_lt_right(self): + c1 = 1 > Field("foo") + c2 = -1 > Field("foo", table=self.t) + + self.assertEqual('"foo"<1', str(c1)) + self.assertEqual('"crit"."foo"<-1', str(c2)) + + def test__criterion_gt_number(self): + c1 = Field("foo") > 1 + c2 = Field("foo", table=self.t).gt(0) + c3 = Field("foo") > -1 + + self.assertEqual('"foo">1', str(c1)) + self.assertEqual('"crit"."foo">0', str(c2)) + self.assertEqual('"foo">-1', str(c3)) + + def test__criterion_gt_date(self): + c1 = Field("foo") > date(2000, 1, 1) + c2 = Field("foo", table=self.t).gt(date(2000, 1, 1)) + + self.assertEqual("\"foo\">'2000-01-01'", str(c1)) + self.assertEqual('"crit"."foo">\'2000-01-01\'', str(c2)) + + def test__criterion_gt_datetime(self): + c1 = Field("foo") > datetime(2000, 1, 1, 12, 30, 55) + c2 = Field("foo", table=self.t).gt(datetime(2000, 1, 1, 12, 30, 55)) + + self.assertEqual("\"foo\">'2000-01-01T12:30:55'", str(c1)) + self.assertEqual('"crit"."foo">\'2000-01-01T12:30:55\'', str(c2)) + + def test__criterion_gt_right(self): + c1 = 1 < Field("foo") + c2 = -1 < Field("foo", table=self.t) + + self.assertEqual('"foo">1', str(c1)) + self.assertEqual('"crit"."foo">-1', str(c2)) + + def test__criterion_lte_number(self): + c1 = Field("foo") <= 1 + c2 = Field("foo", table=self.t).lte(0) + c3 = Field("foo") <= -1 + + self.assertEqual('"foo"<=1', str(c1)) + self.assertEqual('"crit"."foo"<=0', str(c2)) + self.assertEqual('"foo"<=-1', str(c3)) + + def test__criterion_lte_date(self): + c1 = Field("foo") <= date(2000, 1, 1) + c2 = Field("foo", table=self.t).lte(date(2000, 1, 1)) + + self.assertEqual("\"foo\"<='2000-01-01'", str(c1)) + self.assertEqual('"crit"."foo"<=\'2000-01-01\'', str(c2)) + + def test__criterion_lte_datetime(self): + c1 = Field("foo") <= datetime(2000, 1, 1, 12, 30, 55) + c2 = Field("foo", table=self.t).lte(datetime(2000, 1, 1, 12, 30, 55)) + + self.assertEqual("\"foo\"<='2000-01-01T12:30:55'", str(c1)) + self.assertEqual('"crit"."foo"<=\'2000-01-01T12:30:55\'', str(c2)) + + def test__criterion_lte_right(self): + c1 = 1 >= Field("foo") + c2 = -1 >= Field("foo", table=self.t) + + self.assertEqual('"foo"<=1', str(c1)) + self.assertEqual('"crit"."foo"<=-1', str(c2)) + + def test__criterion_gte_number(self): + c1 = Field("foo") >= 1 + c2 = Field("foo", table=self.t).gte(0) + c3 = Field("foo") >= -1 + + self.assertEqual('"foo">=1', str(c1)) + self.assertEqual('"crit"."foo">=0', str(c2)) + self.assertEqual('"foo">=-1', str(c3)) + + def test__criterion_gte_date(self): + c1 = Field("foo") >= date(2000, 1, 1) + c2 = Field("foo", table=self.t).gte(date(2000, 1, 1)) + + self.assertEqual("\"foo\">='2000-01-01'", str(c1)) + self.assertEqual('"crit"."foo">=\'2000-01-01\'', str(c2)) + + def test__criterion_gte_datetime(self): + c1 = Field("foo") >= datetime(2000, 1, 1, 12, 30, 55) + c2 = Field("foo", table=self.t).gte(datetime(2000, 1, 1, 12, 30, 55)) + + self.assertEqual("\"foo\">='2000-01-01T12:30:55'", str(c1)) + self.assertEqual('"crit"."foo">=\'2000-01-01T12:30:55\'', str(c2)) + + def test__criterion_gte_right(self): + c1 = 1 <= Field("foo") + c2 = -1 <= Field("foo", table=self.t) + + self.assertEqual('"foo">=1', str(c1)) + self.assertEqual('"crit"."foo">=-1', str(c2)) + + def test__criterion_bitwise_and(self): + c1 = Field("foo").bitwiseand(2) + c2 = Field("foo", table=self.t).bitwiseand(10) == 2 + + self.assertEqual('("foo" & 2)', str(c1)) + self.assertEqual('("crit"."foo" & 10)=2', str(c2)) + + def test__criterion_bitwise_and_with_alias(self): + c1 = Field("foo").bitwiseand(2).as_('alias') + + self.assertEqual('("foo" & 2) "alias"', str(c1)) + + def test__bitwise_and_in_where_clause(self): + q = QueryBuilder().from_('items').select('abc').where(Field("foo").bitwiseand(1) == 1) + + self.assertEqual('SELECT "abc" FROM "items" WHERE ("foo" & 1)=1', str(q)) + + +class NotTests(unittest.TestCase): + table_abc, table_efg = Table("abc", alias="cx0"), Table("efg", alias="cx1") + + def test_negate(self): + c1 = Field("foo") >= 1 + c2 = c1.negate() + + self.assertEqual('"foo">=1', str(c1)) + self.assertEqual('NOT "foo">=1', str(c2)) + + def test_variable_access(self): + c1 = Field("foo").negate() + + self.assertEqual(c1.is_aggregate, False) + + def test_chained_function(self): + field1 = Field("foo").negate() + field2 = field1.eq("bar") + + self.assertEqual('NOT "foo"', str(field1)) + self.assertEqual("NOT \"foo\"='bar'", str(field2)) + self.assertIsNot(field1, field2) + + def test_not_null(self): + c1 = Field("foo").notnull() + c2 = Field("foo", table=self.table_abc).notnull() + + self.assertEqual('NOT "foo" IS NULL', str(c1)) + self.assertEqual('NOT "cx0"."foo" IS NULL', str(c2)) + + def test_is_not_null(self): + c1 = Field("foo").isnotnull() + c2 = Field("foo", table=self.table_abc).isnotnull() + + self.assertEqual('"foo" IS NOT NULL', str(c1)) + self.assertEqual('"cx0"."foo" IS NOT NULL', str(c2)) + + def test_not_null_with_alias(self): + c1 = Field("foo").notnull().as_("something") + c2 = Field("foo", table=self.table_abc).notnull().as_("something") + + self.assertEqual('NOT "foo" IS NULL "something"', str(c1)) + self.assertEqual('NOT "cx0"."foo" IS NULL "something"', str(c2)) + + def test_notnullcriterion_replace_table(self): + f = self.table_abc.foo.notnull().replace_table(self.table_abc, self.table_efg) + + self.assertEqual('NOT "cx1"."foo" IS NULL', str(f)) + + def test_not_with_or_criterion(self): + self.assertEqual('NOT ("foo" OR "bar")', str(~(Field("foo") | Field("bar")))) + + def test_not_with_and_criterion(self): + self.assertEqual('NOT ("foo" AND "bar")', str(~(Field("foo") & Field("bar")))) + + def test_not_with_complex_criterion(self): + self.assertEqual( + 'NOT ("foo" AND "bar" AND "fizz" AND "buzz")', + str(~(Field("foo") & Field("bar") & Field("fizz") & Field("buzz"))), + ) + + +class BetweenTests(unittest.TestCase): + t = Table("abc", alias="btw") + + def test__between_number(self): + c1 = Field("foo").between(0, 1) + c2 = Field("foo", table=self.t).between(0, 1) + c3 = Field("foo")[0:1] + + self.assertEqual('"foo" BETWEEN 0 AND 1', str(c1)) + self.assertEqual('"btw"."foo" BETWEEN 0 AND 1', str(c2)) + self.assertEqual('"foo" BETWEEN 0 AND 1', str(c3)) + + def test__between_with_alias(self): + c1 = Field("foo").between(0, 1).as_('alias') + c2 = Field("foo", table=self.t).between(0, 1).as_('alias') + c3 = Field("foo")[0:1].as_('alias') + + self.assertEqual('"foo" BETWEEN 0 AND 1 "alias"', str(c1)) + self.assertEqual('"btw"."foo" BETWEEN 0 AND 1 "alias"', str(c2)) + self.assertEqual('"foo" BETWEEN 0 AND 1 "alias"', str(c3)) + + def test__between_date(self): + c1 = Field("foo").between(date(2000, 1, 1), date(2000, 12, 31)) + c2 = Field("foo", table=self.t).between(date(2000, 1, 1), date(2000, 12, 31)) + c3 = Field("foo")[date(2000, 1, 1) : date(2000, 12, 31)] + + self.assertEqual("\"foo\" BETWEEN '2000-01-01' AND '2000-12-31'", str(c1)) + self.assertEqual("\"btw\".\"foo\" BETWEEN '2000-01-01' AND '2000-12-31'", str(c2)) + self.assertEqual("\"foo\" BETWEEN '2000-01-01' AND '2000-12-31'", str(c3)) + + def test__between_datetime(self): + c1 = Field("foo").between(datetime(2000, 1, 1, 0, 0, 0), datetime(2000, 12, 31, 23, 59, 59)) + c2 = Field("foo", table=self.t).between(datetime(2000, 1, 1, 0, 0, 0), datetime(2000, 12, 31, 23, 59, 59)) + c3 = Field("foo")[datetime(2000, 1, 1, 0, 0, 0) : datetime(2000, 12, 31, 23, 59, 59)] + + self.assertEqual("\"foo\" BETWEEN '2000-01-01T00:00:00' AND '2000-12-31T23:59:59'", str(c1)) + self.assertEqual( + "\"btw\".\"foo\" BETWEEN '2000-01-01T00:00:00' AND '2000-12-31T23:59:59'", + str(c2), + ) + self.assertEqual("\"foo\" BETWEEN '2000-01-01T00:00:00' AND '2000-12-31T23:59:59'", str(c3)) + + def test__function_between(self): + c1 = fn.Coalesce(Field("foo"), 0)[0:1] + c2 = fn.Coalesce(Field("foo", table=self.t), 0)[0:1] + + self.assertEqual('COALESCE("foo",0) BETWEEN 0 AND 1', str(c1)) + self.assertEqual('COALESCE("btw"."foo",0) BETWEEN 0 AND 1', str(c2)) + + def test_get_item_only_works_with_slice(self): + with self.assertRaises(TypeError): + Field("foo")[0] + + with self.assertRaises(TypeError): + Field("foo")[date(2000, 1, 1)] + + with self.assertRaises(TypeError): + Field("foo")[datetime(2000, 1, 1, 0, 0, 0)] + + +class IsInTests(unittest.TestCase): + t = Table("abc", alias="isin") + + def test__in_number(self): + c1 = Field("foo").isin([0, 1]) + c2 = Field("foo", table=self.t).isin([0, 1]) + + self.assertEqual('"foo" IN (0,1)', str(c1)) + self.assertEqual('"isin"."foo" IN (0,1)', str(c2)) + + def test__in_number_with_alias(self): + c1 = Field("foo").isin([0, 1]).as_('alias') + c2 = Field("foo", table=self.t).isin([0, 1]).as_('alias') + + self.assertEqual('"foo" IN (0,1) "alias"', str(c1)) + self.assertEqual('"isin"."foo" IN (0,1) "alias"', str(c2)) + + def test__in_character(self): + c1 = Field("foo").isin(["a", "b"]) + c2 = Field("foo", table=self.t).isin(["a", "b"]) + + self.assertEqual("\"foo\" IN ('a','b')", str(c1)) + self.assertEqual("\"isin\".\"foo\" IN ('a','b')", str(c2)) + + def test__in_date(self): + c1 = Field("foo").isin([date(2000, 1, 1), date(2000, 12, 31)]) + c2 = Field("foo", table=self.t).isin([date(2000, 1, 1), date(2000, 12, 31)]) + + self.assertEqual("\"foo\" IN ('2000-01-01','2000-12-31')", str(c1)) + self.assertEqual("\"isin\".\"foo\" IN ('2000-01-01','2000-12-31')", str(c2)) + + def test__in_datetime(self): + c1 = Field("foo").isin([datetime(2000, 1, 1, 0, 0, 0), datetime(2000, 12, 31, 23, 59, 59)]) + c2 = Field("foo", table=self.t).isin([datetime(2000, 1, 1, 0, 0, 0), datetime(2000, 12, 31, 23, 59, 59)]) + + self.assertEqual("\"foo\" IN ('2000-01-01T00:00:00','2000-12-31T23:59:59')", str(c1)) + self.assertEqual("\"isin\".\"foo\" IN ('2000-01-01T00:00:00','2000-12-31T23:59:59')", str(c2)) + + def test__function_isin(self): + c1 = fn.Coalesce(Field("foo"), 0).isin([0, 1]) + c2 = fn.Coalesce(Field("foo", table=self.t), 0).isin([0, 1]) + + self.assertEqual('COALESCE("foo",0) IN (0,1)', str(c1)) + self.assertEqual('COALESCE("isin"."foo",0) IN (0,1)', str(c2)) + + for t in (list, tuple, set, frozenset): + c_type = fn.Coalesce(Field("foo"), 0).isin(t([0, 1])) + self.assertEqual('COALESCE("foo",0) IN (0,1)', str(c_type)) + + self.assertRaises(AttributeError, lambda: str(fn.Coalesce(Field("foo"), 0).isin('SHOULD_FAIL'))) + + def test__in_unicode(self): + c1 = Field("foo").isin([u"a", u"b"]) + c2 = Field("foo", table=self.t).isin([u"a", u"b"]) + + self.assertEqual("\"foo\" IN ('a','b')", str(c1)) + self.assertEqual("\"isin\".\"foo\" IN ('a','b')", str(c2)) + + +class ArithmeticExpressionTests(unittest.TestCase): + def test__lshift(self): + c1 = Field("foo").lshift("1") + c2 = Field("foo").lshift("2") + + self.assertEqual("\"foo\"<<'1'", str(c1)) + self.assertEqual("\"foo\"<<'2'", str(c2)) + + def test__rshift(self): + c1 = Field("foo").rshift("1") + c2 = Field("foo").rshift("2") + + self.assertEqual("\"foo\">>'1'", str(c1)) + self.assertEqual("\"foo\">>'2'", str(c2)) + + +class NotInTests(unittest.TestCase): + t = Table("abc", alias="notin") + + def test__notin_number(self): + c1 = Field("foo").notin([0, 1]) + c2 = Field("foo", table=self.t).notin([0, 1]) + + self.assertEqual('"foo" NOT IN (0,1)', str(c1)) + self.assertEqual('"notin"."foo" NOT IN (0,1)', str(c2)) + + def test__notin_number_with_alias(self): + c1 = Field("foo").notin([0, 1]).as_('alias') + c2 = Field("foo", table=self.t).notin([0, 1]).as_('alias') + + self.assertEqual('"foo" NOT IN (0,1) "alias"', str(c1)) + self.assertEqual('"notin"."foo" NOT IN (0,1) "alias"', str(c2)) + + def test__notin_character(self): + c1 = Field("foo").notin(["a", "b"]) + c2 = Field("foo", table=self.t).notin(["a", "b"]) + + self.assertEqual("\"foo\" NOT IN ('a','b')", str(c1)) + self.assertEqual("\"notin\".\"foo\" NOT IN ('a','b')", str(c2)) + + def test__notin_date(self): + c1 = Field("foo").notin([date(2000, 1, 1), date(2000, 12, 31)]) + c2 = Field("foo", table=self.t).notin([date(2000, 1, 1), date(2000, 12, 31)]) + + self.assertEqual("\"foo\" NOT IN ('2000-01-01','2000-12-31')", str(c1)) + self.assertEqual("\"notin\".\"foo\" NOT IN ('2000-01-01','2000-12-31')", str(c2)) + + def test__notin_datetime(self): + c1 = Field("foo").notin([datetime(2000, 1, 1, 0, 0, 0), datetime(2000, 12, 31, 23, 59, 59)]) + c2 = Field("foo", table=self.t).notin([datetime(2000, 1, 1, 0, 0, 0), datetime(2000, 12, 31, 23, 59, 59)]) + + self.assertEqual("\"foo\" NOT IN ('2000-01-01T00:00:00','2000-12-31T23:59:59')", str(c1)) + self.assertEqual( + "\"notin\".\"foo\" NOT IN ('2000-01-01T00:00:00','2000-12-31T23:59:59')", + str(c2), + ) + + def test__function_notin(self): + c1 = fn.Coalesce(Field("foo"), 0).notin([0, 1]) + c2 = fn.Coalesce(Field("foo", table=self.t), 0).notin([0, 1]) + + self.assertEqual('COALESCE("foo",0) NOT IN (0,1)', str(c1)) + self.assertEqual('COALESCE("notin"."foo",0) NOT IN (0,1)', str(c2)) + + +class LikeTests(unittest.TestCase): + t = Table("abc", alias="like") + + def test_like_starts_with(self): + c1 = Field("foo").like("ab%") + c2 = Field("foo", table=self.t).like("ab%") + + self.assertEqual("\"foo\" LIKE 'ab%'", str(c1)) + self.assertEqual('"like"."foo" LIKE \'ab%\'', str(c2)) + + def test_like_contains(self): + c1 = Field("foo").like("%ab%") + c2 = Field("foo", table=self.t).like("%ab%") + + self.assertEqual("\"foo\" LIKE '%ab%'", str(c1)) + self.assertEqual('"like"."foo" LIKE \'%ab%\'', str(c2)) + + def test_like_ends_with(self): + c1 = Field("foo").like("%ab") + c2 = Field("foo", table=self.t).like("%ab") + + self.assertEqual("\"foo\" LIKE '%ab'", str(c1)) + self.assertEqual('"like"."foo" LIKE \'%ab\'', str(c2)) + + def test_like_n_chars_long(self): + c1 = Field("foo").like("___") + c2 = Field("foo", table=self.t).like("___") + + self.assertEqual("\"foo\" LIKE '___'", str(c1)) + self.assertEqual('"like"."foo" LIKE \'___\'', str(c2)) + + def test_like_single_chars_and_various_chars(self): + c1 = Field("foo").like("a_b%c") + c2 = Field("foo", table=self.t).like("a_b%c") + + self.assertEqual("\"foo\" LIKE 'a_b%c'", str(c1)) + self.assertEqual('"like"."foo" LIKE \'a_b%c\'', str(c2)) + + def test_not_like_single_chars_and_various_chars(self): + c1 = Field("foo").not_like("a_b%c") + c2 = Field("foo", table=self.t).not_like("a_b%c") + + self.assertEqual("\"foo\" NOT LIKE 'a_b%c'", str(c1)) + self.assertEqual('"like"."foo" NOT LIKE \'a_b%c\'', str(c2)) + + def test_ilike_starts_with(self): + c1 = Field("foo").ilike("ab%") + c2 = Field("foo", table=self.t).ilike("ab%") + + self.assertEqual("\"foo\" ILIKE 'ab%'", str(c1)) + self.assertEqual('"like"."foo" ILIKE \'ab%\'', str(c2)) + + def test_ilike_contains(self): + c1 = Field("foo").ilike("%ab%") + c2 = Field("foo", table=self.t).ilike("%ab%") + + self.assertEqual("\"foo\" ILIKE '%ab%'", str(c1)) + self.assertEqual('"like"."foo" ILIKE \'%ab%\'', str(c2)) + + def test_ilike_ends_with(self): + c1 = Field("foo").ilike("%ab") + c2 = Field("foo", table=self.t).ilike("%ab") + + self.assertEqual("\"foo\" ILIKE '%ab'", str(c1)) + self.assertEqual('"like"."foo" ILIKE \'%ab\'', str(c2)) + + def test_ilike_n_chars_long(self): + c1 = Field("foo").ilike("___") + c2 = Field("foo", table=self.t).ilike("___") + + self.assertEqual("\"foo\" ILIKE '___'", str(c1)) + self.assertEqual('"like"."foo" ILIKE \'___\'', str(c2)) + + def test_ilike_single_chars_and_various_chars(self): + c1 = Field("foo").ilike("a_b%c") + c2 = Field("foo", table=self.t).ilike("a_b%c") + + self.assertEqual("\"foo\" ILIKE 'a_b%c'", str(c1)) + self.assertEqual('"like"."foo" ILIKE \'a_b%c\'', str(c2)) + + def test_not_ilike_single_chars_and_various_chars(self): + c1 = Field("foo").not_ilike("a_b%c") + c2 = Field("foo", table=self.t).not_ilike("a_b%c") + + self.assertEqual("\"foo\" NOT ILIKE 'a_b%c'", str(c1)) + self.assertEqual('"like"."foo" NOT ILIKE \'a_b%c\'', str(c2)) + + def test_rlike_escape_chars(self): + c1 = Field("foo").rlike("\\\\d+$") + c2 = Field("foo", table=self.t).rlike("\\\\d+$") + + self.assertEqual("\"foo\" RLIKE '\\\\d+$'", str(c1)) + self.assertEqual('"like"."foo" RLIKE \'\\\\d+$\'', str(c2)) + + def test_glob_single_chars_and_various_chars(self): + c1 = Field("foo").glob("a_b*") + c2 = Field("foo", table=self.t).glob("a_b*") + + self.assertEqual("\"foo\" GLOB 'a_b*'", str(c1)) + self.assertEqual('"like"."foo" GLOB \'a_b*\'', str(c2)) + + +class ExistsCriterionTests(unittest.TestCase): + t2 = Table("abc", alias="t2") + q2 = QueryBuilder().from_(t2).select(t2.field2) + + def test_exists(self): + t1 = Table("def", alias="t1") + q1 = QueryBuilder().from_(t1).where(ExistsCriterion(self.q2)).select(t1.field1) + + self.assertEqual( + 'SELECT "t1"."field1" FROM "def" "t1" WHERE EXISTS (SELECT "t2"."field2" FROM "abc" "t2")', str(q1) + ) + + def test_not_exists(self): + t1 = Table("def", alias="t1") + q1 = QueryBuilder().from_(t1).where(ExistsCriterion(self.q2).negate()).select(t1.field1) + + self.assertEqual( + 'SELECT "t1"."field1" FROM "def" "t1" WHERE NOT EXISTS (SELECT "t2"."field2" FROM "abc" "t2")', str(q1) + ) + + +class ComplexCriterionTests(unittest.TestCase): + table_abc, table_efg = Table("abc", alias="cx0"), Table("efg", alias="cx1") + + def test_and(self): + c1 = (Field("foo") == 1) & (Field("bar") == 2) + c2 = (Field("foo", table=self.table_abc) == 1) & (Field("bar", table=self.table_efg) == 2) + + self.assertEqual('"foo"=1 AND "bar"=2', str(c1)) + self.assertEqual('"cx0"."foo"=1 AND "cx1"."bar"=2', str(c2)) + + def test_or(self): + c1 = (Field("foo") == 1) | (Field("bar") == 2) + c2 = (Field("foo", table=self.table_abc) == 1) | (Field("bar", table=self.table_efg) == 2) + + self.assertEqual('"foo"=1 OR "bar"=2', str(c1)) + self.assertEqual('"cx0"."foo"=1 OR "cx1"."bar"=2', str(c2)) + + def test_xor(self): + c1 = (Field("foo") == 1) ^ (Field("bar") == 2) + c2 = (Field("foo", table=self.table_abc) == 1) ^ (Field("bar", table=self.table_efg) == 2) + + self.assertEqual('"foo"=1 XOR "bar"=2', str(c1)) + self.assertEqual('"cx0"."foo"=1 XOR "cx1"."bar"=2', str(c2)) + + def test_function_and(self): + c1 = fn.IsNull(Field("foo")) & (Field("bar") == 2) + + self.assertEqual('ISNULL("foo") AND "bar"=2', str(c1)) + + def test_function_or(self): + c1 = fn.IsNull(Field("foo")) | (Field("bar") == 2) + + self.assertEqual('ISNULL("foo") OR "bar"=2', str(c1)) + + def test_function_xor(self): + c1 = fn.IsNull(Field("foo")) ^ (Field("bar") == 2) + + self.assertEqual('ISNULL("foo") XOR "bar"=2', str(c1)) + + def test__nested__and(self): + c = (Field("foo") == 1) & (Field("bar") == 2) & (Field("buz") == 3) + + self.assertEqual('"foo"=1 AND "bar"=2 AND "buz"=3', str(c)) + + def test__nested__or(self): + c = (Field("foo") == 1) | (Field("bar") == 2) | (Field("buz") == 3) + + self.assertEqual('"foo"=1 OR "bar"=2 OR "buz"=3', str(c)) + + def test__nested__mixed(self): + c = ((Field("foo") == 1) & (Field("bar") == 2)) | (Field("buz") == 3) + + self.assertEqual('("foo"=1 AND "bar"=2) OR "buz"=3', str(c)) + + def test__between_and_isin(self): + c = Field("foo").isin([1, 2, 3]) & Field("bar").between(0, 1) + + self.assertEqual('"foo" IN (1,2,3) AND "bar" BETWEEN 0 AND 1', str(c)) + + def test__between_and_field(self): + c1 = Field("foo").between(0, 1) + c2 = Field("bool_field") + + self.assertEqual('"foo" BETWEEN 0 AND 1 AND "bool_field"', str(c1 & c2)) + self.assertEqual('"bool_field" AND "foo" BETWEEN 0 AND 1', str(c2 & c1)) + + +class FieldsAsCriterionTests(unittest.TestCase): + def test__field_and_field(self): + c1 = Field("a") + c2 = Field("b") + + self.assertEqual('"a" AND "b"', str(c1 & c2)) + + def test__field_or_field(self): + c1 = Field("a") + c2 = Field("b") + + self.assertEqual('"a" OR "b"', str(c1 | c2)) + + def test__field_xor_field(self): + c1 = Field("a") + c2 = Field("b") + + self.assertEqual('"a" XOR "b"', str(c1 ^ c2)) + + +class CriterionOperationsTests(unittest.TestCase): + table_abc, table_efg = Table("abc", alias="cx0"), Table("efg", alias="cx1") + + def test_field_replace_table(self): + f = self.table_abc.foo.replace_table(self.table_abc, self.table_efg) + + self.assertEqual('"cx1"."foo"', str(f)) + + def test_arithmeticfunction_replace_table(self): + f = (self.table_abc.foo + self.table_abc.bar).replace_table(self.table_abc, self.table_efg) + + self.assertEqual('"cx1"."foo"+"cx1"."bar"', str(f)) + + def test_criterion_replace_table(self): + f = (self.table_abc.foo < self.table_abc.bar).replace_table(self.table_abc, self.table_efg) + + self.assertEqual('"cx1"."foo"<"cx1"."bar"', str(f)) + + def test_complexcriterion_replace_table(self): + f = (self.table_abc.foo < self.table_abc.bar) & (self.table_abc.fiz > self.table_abc.buz) + f = f.replace_table(self.table_abc, self.table_efg) + + self.assertEqual('"cx1"."foo"<"cx1"."bar" AND "cx1"."fiz">"cx1"."buz"', str(f)) + + def test_function_with_only_fields_replace_table(self): + f = fn.Sum(self.table_abc.foo).replace_table(self.table_abc, self.table_efg) + + self.assertEqual('SUM("cx1"."foo")', str(f)) + + def test_function_with_values_and_fields_replace_table(self): + f = Mod(self.table_abc.foo, 2).replace_table(self.table_abc, self.table_efg) + + self.assertEqual('MOD("cx1"."foo",2)', str(f)) + + def test_betweencriterion_replace_table(self): + f = self.table_abc.foo[0:1].replace_table(self.table_abc, self.table_efg) + + self.assertEqual('"cx1"."foo" BETWEEN 0 AND 1', str(f)) + + def test_nullcriterion_replace_table(self): + f = self.table_abc.foo.isnull().replace_table(self.table_abc, self.table_efg) + + self.assertEqual('"cx1"."foo" IS NULL', str(f)) + + +class AnyTests(unittest.TestCase): + def test_zero_args_returns_empty_criterion(self): + crit = Criterion.any() + self.assertIsInstance(crit, EmptyCriterion) + + def test_single_arg_returns_self(self): + f = Field("a") + crit = Criterion.any([f]) + self.assertEqual(str(f), str(crit)) + + def test_multiple_args_returned_in_chain_of_ors(self): + crit = Criterion.any([Field("a"), Field("b"), Field("c"), Field("d")]) + self.assertEqual(str(crit), '"a" OR "b" OR "c" OR "d"') + + def test_with_generator(self): + crit = Criterion.any(Field(letter) for letter in "abcd") + self.assertEqual(str(crit), '"a" OR "b" OR "c" OR "d"') + + +class EmptyCriterionTests(unittest.TestCase): + def test_fields_(self): + empty_criterion = EmptyCriterion() + + self.assertEqual(len(empty_criterion.fields_()), 0) + + def test_empty_criterion_on_the_left(self): + t = Table("test1") + q = EmptyCriterion() & t.f1 == "v1" + + self.assertEqual( + '"test1"."f1"=\'v1\'', + q.get_sql(with_namespace=True), + ) + + def test_empty_criterion_on_the_right(self): + t = Table("test1") + q = (t.f1 == "v1") & EmptyCriterion() + + self.assertEqual( + '"test1"."f1"=\'v1\'', + q.get_sql(with_namespace=True), + ) + + def test_invertion_of_the_empty_criterion(self): + t = Table("test1") + q = (t.f1 == "v1") & ~EmptyCriterion() + + self.assertEqual( + '"test1"."f1"=\'v1\'', + q.get_sql(with_namespace=True), + ) + + def test_different_operations_with_empty_criterion(self): + t = Table("test1") + q1 = (t.f1 == "v1") & EmptyCriterion() + q2 = (t.f1 == "v1") | EmptyCriterion() + q3 = (t.f1 == "v1") ^ EmptyCriterion() + + expected_sql = '"test1"."f1"=\'v1\'' + self.assertEqual( + expected_sql, + q1.get_sql(with_namespace=True), + ) + self.assertEqual( + expected_sql, + q2.get_sql(with_namespace=True), + ) + self.assertEqual( + expected_sql, + q3.get_sql(with_namespace=True), + ) + + def test_more_than_one_empty_criterions(self): + t = Table("test1") + q = EmptyCriterion() & ~(EmptyCriterion() | EmptyCriterion()) & (t.f1 == "v1") & ~EmptyCriterion() + + self.assertEqual( + '"test1"."f1"=\'v1\'', + q.get_sql(with_namespace=True), + ) + + +class AllTests(unittest.TestCase): + def test_zero_args_returns_empty_criterion(self): + crit = Criterion.all() + self.assertIsInstance(crit, EmptyCriterion) + + def test_single_arg_returns_self(self): + f = Field("a") + crit = Criterion.all([f]) + self.assertEqual(str(f), str(crit)) + + def test_multiple_args_returned_in_chain_of_ors(self): + crit = Criterion.all([Field("a"), Field("b"), Field("c"), Field("d")]) + self.assertEqual(str(crit), '"a" AND "b" AND "c" AND "d"') + + def test_with_generator(self): + crit = Criterion.all(Field(letter) for letter in "abcd") + self.assertEqual(str(crit), '"a" AND "b" AND "c" AND "d"') diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/test_custom_functions.py b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/test_custom_functions.py new file mode 100644 index 0000000000000000000000000000000000000000..60ffd3cd8e6191e3fc782dac003c41bfb7a78528 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/test_custom_functions.py @@ -0,0 +1,49 @@ +import unittest + +from pypika import CustomFunction, FunctionException, Query, Table + +__author__ = "Airton Zanon" +__email__ = "me@airton.dev" + + +class TestUnitCustomFunction(unittest.TestCase): + def test_should_fail_with_wrong_arguments(self): + DateDiff = CustomFunction("DATE_DIFF", ["interval", "start_date", "end_date"]) + + with self.assertRaises(FunctionException): + DateDiff("foo") + + def test_should_return_function_with_arguments(self): + DateDiff = CustomFunction("DATE_DIFF", ["interval", "start_date", "end_date"]) + + self.assertEqual( + "DATE_DIFF('day','start_date','end_date')", + str(DateDiff("day", "start_date", "end_date")), + ) + + def test_should_return_function_with_no_arguments(self): + CurrentDate = CustomFunction("CURRENT_DATE") + + self.assertEqual("CURRENT_DATE()", str(CurrentDate())) + + +class TestFunctionalCustomFunction(unittest.TestCase): + def test_should_use_custom_function_on_select(self): + service = Table("service") + + DateDiff = CustomFunction("DATE_DIFF", ["interval", "start_date", "end_date"]) + + q = Query.from_(service).select(DateDiff("day", service.created_date, service.updated_date)) + + self.assertEqual( + 'SELECT DATE_DIFF(\'day\',"created_date","updated_date") FROM "service"', + str(q), + ) + + def test_should_fail_use_custom_function_on_select_with_wrong_arguments(self): + service = Table("service") + + DateDiff = CustomFunction("DATE_DIFF", ["interval", "start_date", "end_date"]) + + with self.assertRaises(FunctionException): + Query.from_(service).select(DateDiff("day", service.created_date)) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/test_data_types.py b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/test_data_types.py new file mode 100644 index 0000000000000000000000000000000000000000..52fb4487fe7be3ae28a4e9eb08628fba89dc0f79 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/test_data_types.py @@ -0,0 +1,15 @@ +import unittest +import uuid + +from pypika.terms import ValueWrapper + + +class StringTests(unittest.TestCase): + def test_inline_string_concatentation(self): + self.assertEqual("'it''s'", ValueWrapper("it's").get_sql()) + + +class UuidTests(unittest.TestCase): + def test_uuid_string_generation(self): + id = uuid.uuid4() + self.assertEqual("'{}'".format(id), ValueWrapper(id).get_sql()) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/test_date_math.py b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/test_date_math.py new file mode 100644 index 0000000000000000000000000000000000000000..38db8ef2f8e812a97c6980a7ec6b9a3909d804fb --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/test_date_math.py @@ -0,0 +1,179 @@ +import unittest + +from pypika import ( + Field as F, + Interval, +) +from pypika.enums import Dialects + +dt = F("dt") + + +class AddIntervalTests(unittest.TestCase): + def test_add_microsecond(self): + c = dt + Interval(microseconds=1) + + self.assertEqual("\"dt\"+INTERVAL '1 MICROSECOND'", str(c)) + + def test_add_second(self): + c = dt + Interval(seconds=1) + + self.assertEqual("\"dt\"+INTERVAL '1 SECOND'", str(c)) + + def test_add_minute(self): + c = dt + Interval(minutes=1) + + self.assertEqual("\"dt\"+INTERVAL '1 MINUTE'", str(c)) + + def test_add_day(self): + c = dt + Interval(days=1) + + self.assertEqual("\"dt\"+INTERVAL '1 DAY'", str(c)) + + def test_add_week(self): + c = dt + Interval(weeks=1) + + self.assertEqual("\"dt\"+INTERVAL '1 WEEK'", str(c)) + + def test_add_month(self): + c = dt + Interval(months=1) + + self.assertEqual("\"dt\"+INTERVAL '1 MONTH'", str(c)) + + def test_add_quarter(self): + c = dt + Interval(quarters=1) + + self.assertEqual("\"dt\"+INTERVAL '1 QUARTER'", str(c)) + + def test_add_year(self): + c = dt + Interval(years=1) + + self.assertEqual("\"dt\"+INTERVAL '1 YEAR'", str(c)) + + def test_add_default(self): + c = dt + Interval(days=0) + + self.assertEqual("\"dt\"+INTERVAL '0 DAY'", str(c)) + + +class AddIntervalMultipleUnitsTests(unittest.TestCase): + def test_add_second_microsecond(self): + c = dt + Interval(seconds=1, microseconds=1) + + self.assertEqual("\"dt\"+INTERVAL '1.1 SECOND_MICROSECOND'", str(c)) + + def test_add_minute_microsecond(self): + c = dt + Interval(minutes=1, microseconds=1) + + self.assertEqual("\"dt\"+INTERVAL '1:0.1 MINUTE_MICROSECOND'", str(c)) + + def test_add_minute_second(self): + c = dt + Interval(minutes=1, seconds=1) + + self.assertEqual("\"dt\"+INTERVAL '1:1 MINUTE_SECOND'", str(c)) + + def test_add_hour_microsecond(self): + c = dt + Interval(hours=1, microseconds=1) + + self.assertEqual("\"dt\"+INTERVAL '1:0:0.1 HOUR_MICROSECOND'", str(c)) + + def test_add_hour_second(self): + c = dt + Interval(hours=1, seconds=1) + + self.assertEqual("\"dt\"+INTERVAL '1:0:1 HOUR_SECOND'", str(c)) + + def test_add_hour_minute(self): + c = dt + Interval(hours=1, minutes=1) + + self.assertEqual("\"dt\"+INTERVAL '1:1 HOUR_MINUTE'", str(c)) + + def test_add_day_microsecond(self): + c = dt + Interval(days=1, microseconds=1) + + self.assertEqual("\"dt\"+INTERVAL '1 0:0:0.1 DAY_MICROSECOND'", str(c)) + + def test_add_day_second(self): + c = dt + Interval(days=1, seconds=1) + + self.assertEqual("\"dt\"+INTERVAL '1 0:0:1 DAY_SECOND'", str(c)) + + def test_add_day_minute(self): + c = dt + Interval(days=1, minutes=1) + + self.assertEqual("\"dt\"+INTERVAL '1 0:1 DAY_MINUTE'", str(c)) + + def test_add_day_hour(self): + c = dt + Interval(days=1, hours=1) + + self.assertEqual("\"dt\"+INTERVAL '1 1 DAY_HOUR'", str(c)) + + def test_add_year_month(self): + c = dt + Interval(years=1, months=1) + + self.assertEqual("\"dt\"+INTERVAL '1-1 YEAR_MONTH'", str(c)) + + def test_add_value_right(self): + c = Interval(microseconds=1) - dt + + self.assertEqual("INTERVAL '1 MICROSECOND'-\"dt\"", str(c)) + + def test_add_value_complex_expressions(self): + c = dt + Interval(quarters=1) + Interval(weeks=1) + + self.assertEqual("\"dt\"+INTERVAL '1 QUARTER'+INTERVAL '1 WEEK'", str(c)) + + +class DialectIntervalTests(unittest.TestCase): + def test_mysql_dialect_uses_single_quotes_around_expression_in_an_interval(self): + c = Interval(days=1).get_sql(dialect=Dialects.MYSQL) + self.assertEqual("INTERVAL '1' DAY", c) + + def test_oracle_dialect_uses_single_quotes_around_expression_in_an_interval(self): + c = Interval(days=1).get_sql(dialect=Dialects.ORACLE) + self.assertEqual("INTERVAL '1' DAY", c) + + def test_vertica_dialect_uses_single_quotes_around_interval(self): + c = Interval(days=1).get_sql(dialect=Dialects.VERTICA) + self.assertEqual("INTERVAL '1 DAY'", c) + + def test_redshift_dialect_uses_single_quotes_around_interval(self): + c = Interval(days=1).get_sql(dialect=Dialects.REDSHIFT) + self.assertEqual("INTERVAL '1 DAY'", c) + + def test_postgresql_dialect_uses_single_quotes_around_interval(self): + c = Interval(days=1).get_sql(dialect=Dialects.POSTGRESQL) + self.assertEqual("INTERVAL '1 DAY'", c) + + +class TestNegativeIntervals(unittest.TestCase): + def test_day(self): + c = Interval(days=-1).get_sql() + self.assertEqual("INTERVAL '-1 DAY'", c) + + def test_week(self): + c = Interval(weeks=-1).get_sql() + self.assertEqual("INTERVAL '-1 WEEK'", c) + + def test_month(self): + c = Interval(months=-1).get_sql() + self.assertEqual("INTERVAL '-1 MONTH'", c) + + def test_year(self): + c = Interval(years=-1).get_sql() + self.assertEqual("INTERVAL '-1 YEAR'", c) + + def test_year_month(self): + c = Interval(years=-1, months=-4).get_sql() + self.assertEqual("INTERVAL '-1-4 YEAR_MONTH'", c) + + +class TruncateTrailingZerosTests(unittest.TestCase): + def test_do_not_truncate_integer_values(self): + i = Interval(seconds=10) + + self.assertEqual("INTERVAL '10 SECOND'", str(i)) + + def test_do_not_truncate_months_between_years_and_datys(self): + i = Interval(years=10, days=10) + + self.assertEqual("INTERVAL '10-0-10 YEAR_DAY'", str(i)) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/test_deletes.py b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/test_deletes.py new file mode 100644 index 0000000000000000000000000000000000000000..09df93f5331b845b0c3aed628bf1c4a3ec6b0f02 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/test_deletes.py @@ -0,0 +1,97 @@ +import unittest + +from pypika import PostgreSQLQuery, Query, SYSTEM_TIME, Table + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + +from pypika.terms import Star + + +class DeleteTests(unittest.TestCase): + @classmethod + def setUpClass(cls) -> None: + super().setUpClass() + cls.table_abc = Table("abc") + + def test_omit_where(self): + q = Query.from_("abc").delete() + + self.assertEqual('DELETE FROM "abc"', str(q)) + + def test_omit_where__table_schema(self): + q = Query.from_(Table("abc", "schema1")).delete() + + self.assertEqual('DELETE FROM "schema1"."abc"', str(q)) + + def test_where_field_equals(self): + q1 = Query.from_(self.table_abc).where(self.table_abc.foo == self.table_abc.bar).delete() + q2 = Query.from_(self.table_abc).where(self.table_abc.foo.eq(self.table_abc.bar)).delete() + + self.assertEqual('DELETE FROM "abc" WHERE "foo"="bar"', str(q1)) + self.assertEqual('DELETE FROM "abc" WHERE "foo"="bar"', str(q2)) + + def test_for_portion(self): + with self.subTest("with system time"): + q = Query.from_(self.table_abc.for_portion(SYSTEM_TIME.from_to('2020-01-01', '2020-02-01'))).delete() + + self.assertEqual( + 'DELETE FROM "abc" FOR PORTION OF SYSTEM_TIME FROM \'2020-01-01\' TO \'2020-02-01\'', str(q) + ) + + with self.subTest("with column"): + q = Query.from_( + self.table_abc.for_portion(self.table_abc.valid_period.from_to('2020-01-01', '2020-02-01')) + ).delete() + + self.assertEqual( + 'DELETE FROM "abc" FOR PORTION OF "valid_period" FROM \'2020-01-01\' TO \'2020-02-01\'', str(q) + ) + + +class PostgresDeleteTests(unittest.TestCase): + @classmethod + def setUpClass(cls) -> None: + super().setUpClass() + cls.table_abc = Table("abc") + + def test_delete_returning(self): + q1 = ( + PostgreSQLQuery.from_(self.table_abc) + .where(self.table_abc.foo == self.table_abc.bar) + .delete() + .returning(self.table_abc.id) + ) + + self.assertEqual('DELETE FROM "abc" WHERE "foo"="bar" RETURNING "id"', str(q1)) + + def test_delete_returning_str(self): + q1 = ( + PostgreSQLQuery.from_(self.table_abc) + .where(self.table_abc.foo == self.table_abc.bar) + .delete() + .returning("id") + ) + + self.assertEqual('DELETE FROM "abc" WHERE "foo"="bar" RETURNING "id"', str(q1)) + + def test_delete_returning_star(self): + q1 = ( + PostgreSQLQuery.from_(self.table_abc) + .where(self.table_abc.foo == self.table_abc.bar) + .delete() + .returning(Star()) + ) + + self.assertEqual('DELETE FROM "abc" WHERE "foo"="bar" RETURNING *', str(q1)) + + def test_delete_using(self): + table_trash = Table('trash') + q1 = ( + PostgreSQLQuery.from_(self.table_abc) + .using(table_trash) + .where(self.table_abc.id == table_trash.abc_id) + .delete() + ) + + self.assertEqual('DELETE FROM "abc" USING "trash" WHERE "abc"."id"="trash"."abc_id"', str(q1)) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/test_drop.py b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/test_drop.py new file mode 100644 index 0000000000000000000000000000000000000000..265ae7350d2054549731f9a8c4379fdac95dc580 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/test_drop.py @@ -0,0 +1,49 @@ +import unittest + +from pypika import ( + Columns, + Database, + Query, + Tables, +) + + +class DropTableTests(unittest.TestCase): + database_xyz = Database("mydb") + new_table, existing_table = Tables("abc", "efg") + foo, bar = Columns(("a", "INT"), ("b", "VARCHAR(100)")) + + def test_drop_database(self): + q1 = Query.drop_database(self.database_xyz) + q2 = Query.drop_database(self.database_xyz).if_exists() + + self.assertEqual('DROP DATABASE "mydb"', str(q1)) + self.assertEqual('DROP DATABASE IF EXISTS "mydb"', str(q2)) + + def test_drop_table(self): + q1 = Query.drop_table(self.new_table) + q2 = Query.drop_table(self.new_table).if_exists() + + self.assertEqual('DROP TABLE "abc"', str(q1)) + self.assertEqual('DROP TABLE IF EXISTS "abc"', str(q2)) + + def test_drop_user(self): + q1 = Query.drop_user("myuser") + q2 = Query.drop_user("myuser").if_exists() + + self.assertEqual('DROP USER "myuser"', str(q1)) + self.assertEqual('DROP USER IF EXISTS "myuser"', str(q2)) + + def test_drop_view(self): + q1 = Query.drop_view("myview") + q2 = Query.drop_view("myview").if_exists() + + self.assertEqual('DROP VIEW "myview"', str(q1)) + self.assertEqual('DROP VIEW IF EXISTS "myview"', str(q2)) + + def test_drop_index(self): + q1 = Query.drop_index("myindex") + q2 = Query.drop_index("myindex").if_exists() + + self.assertEqual('DROP INDEX "myindex"', str(q1)) + self.assertEqual('DROP INDEX IF EXISTS "myindex"', str(q2)) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/test_formats.py b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/test_formats.py new file mode 100644 index 0000000000000000000000000000000000000000..6a442757c6659a215661e03f1ca9c3771d394d96 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/test_formats.py @@ -0,0 +1,68 @@ +import unittest + +from pypika import Query, Tables, functions as fn + + +class QuoteTests(unittest.TestCase): + maxDiff = None + + table_abc, table_efg = Tables("abc", "efg") + + def setUp(self): + subquery1 = ( + Query.from_(self.table_abc) + .select( + self.table_abc.foo, + fn.Sum(self.table_abc.fizz + self.table_abc.buzz).as_("fizzbuzz"), + ) + .groupby(self.table_abc.foo) + ) + + subquery2 = Query.from_(self.table_efg).select( + self.table_efg.foo.as_("foo_two"), + self.table_efg.bar, + ) + + self.query = ( + Query.from_(subquery1) + .select(subquery1.foo, subquery1.fizzbuzz) + .join(subquery2) + .on(subquery1.foo == subquery2.foo_two) + .select(subquery2.foo_two, subquery2.bar) + ) + + def test_replace_quote_char_in_complex_query(self): + self.assertEqual( + "SELECT " + "`sq0`.`foo`,`sq0`.`fizzbuzz`," + "`sq1`.`foo_two`,`sq1`.`bar` " + "FROM (" + "SELECT " + "`foo`,SUM(`fizz`+`buzz`) `fizzbuzz` " + "FROM `abc` " + "GROUP BY `foo`" + ") `sq0` JOIN (" + "SELECT " + "`foo` `foo_two`,`bar` " + "FROM `efg`" + ") `sq1` ON `sq0`.`foo`=`sq1`.`foo_two`", + self.query.get_sql(quote_char="`"), + ) + + def test_no_quote_char_in_complex_query(self): + self.assertEqual( + "SELECT " + "sq0.foo,sq0.fizzbuzz," + "sq1.foo_two,sq1.bar " + "FROM (" + "SELECT " + "foo,SUM(fizz+buzz) fizzbuzz " + "FROM abc " + "GROUP BY foo" + ") sq0 JOIN (" + "SELECT " + "foo foo_two,bar " + "FROM efg" + ") sq1 ON sq0.foo=sq1.foo_two", + self.query.get_sql(quote_char=None), + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/test_functions.py b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/test_functions.py new file mode 100644 index 0000000000000000000000000000000000000000..f526966eefc554ec68d0e15fb69de7d69f1604c3 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/test_functions.py @@ -0,0 +1,847 @@ +import unittest + +from pypika import ( + Case, + CaseException, + DatePart, + Field as F, + Query, + Query as Q, + Schema, + Table as T, + VerticaQuery, + functions as fn, +) +from pypika.enums import Dialects, SqlTypes + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + + +class FunctionTests(unittest.TestCase): + def test_dialect_propagation(self): + func = fn.Function("func", ["a"], ["b"]) + self.assertEqual("func(ARRAY['a'],ARRAY['b'])", func.get_sql(dialect=Dialects.POSTGRESQL)) + + def test_is_aggregate_None_for_non_aggregate_function_or_function_with_no_aggregate_functions(self): + self.assertIsNone(fn.Coalesce('a', 0).is_aggregate) + self.assertIsNone(fn.Coalesce(fn.NullIf('a', 0), 0).is_aggregate) + + def test_is_aggregate_True_for_aggregate_function_or_function_with_aggregate_functions(self): + self.assertTrue(fn.Sum('a').is_aggregate) + self.assertTrue(fn.Coalesce(fn.Avg('a'), 0).is_aggregate) + self.assertTrue(fn.Coalesce(fn.NullIf(fn.Sum('a'), 0), 0).is_aggregate) + + +class SchemaTests(unittest.TestCase): + def test_schema_no_schema_in_sql_when_none_set(self): + func = fn.Function("my_proc", 1, 2, 3) + + self.assertEqual("my_proc(1,2,3)", func.get_sql(quote_char='"')) + + def test_schema_included_in_function_sql(self): + a = Schema("a") + func = fn.Function("my_proc", 1, 2, 3, schema=a) + + self.assertEqual('"a".my_proc(1,2,3)', func.get_sql(quote_char='"')) + + +class ArithmeticTests(unittest.TestCase): + t = T("abc") + + def test__addition__fields(self): + q1 = Q.from_("abc").select(F("a") + F("b")) + q2 = Q.from_(self.t).select(self.t.a + self.t.b) + + self.assertEqual('SELECT "a"+"b" FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"+"b" FROM "abc"', str(q2)) + + def test__addition__number(self): + q1 = Q.from_("abc").select(F("a") + 1) + q2 = Q.from_(self.t).select(self.t.a + 1) + + self.assertEqual('SELECT "a"+1 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"+1 FROM "abc"', str(q2)) + + def test__addition__decimal(self): + q1 = Q.from_("abc").select(F("a") + 1.0) + q2 = Q.from_(self.t).select(self.t.a + 1.0) + + self.assertEqual('SELECT "a"+1.0 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"+1.0 FROM "abc"', str(q2)) + + def test__addition__right(self): + q1 = Q.from_("abc").select(1 + F("a")) + q2 = Q.from_(self.t).select(1 + self.t.a) + + self.assertEqual('SELECT 1+"a" FROM "abc"', str(q1)) + self.assertEqual('SELECT 1+"a" FROM "abc"', str(q2)) + + def test__subtraction__fields(self): + q1 = Q.from_("abc").select(F("a") - F("b")) + q2 = Q.from_(self.t).select(self.t.a - self.t.b) + + self.assertEqual('SELECT "a"-"b" FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"-"b" FROM "abc"', str(q2)) + + def test__subtraction__number(self): + q1 = Q.from_("abc").select(F("a") - 1) + q2 = Q.from_(self.t).select(self.t.a - 1) + + self.assertEqual('SELECT "a"-1 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"-1 FROM "abc"', str(q2)) + + def test__subtraction__decimal(self): + q1 = Q.from_("abc").select(F("a") - 1.0) + q2 = Q.from_(self.t).select(self.t.a - 1.0) + + self.assertEqual('SELECT "a"-1.0 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"-1.0 FROM "abc"', str(q2)) + + def test__subtraction__right(self): + q1 = Q.from_("abc").select(1 - F("a")) + q2 = Q.from_(self.t).select(1 - self.t.a) + + self.assertEqual('SELECT 1-"a" FROM "abc"', str(q1)) + self.assertEqual('SELECT 1-"a" FROM "abc"', str(q2)) + + def test__multiplication__fields(self): + q1 = Q.from_("abc").select(F("a") * F("b")) + q2 = Q.from_(self.t).select(self.t.a * self.t.b) + + self.assertEqual('SELECT "a"*"b" FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"*"b" FROM "abc"', str(q2)) + + def test__multiplication__number(self): + q1 = Q.from_("abc").select(F("a") * 1) + q2 = Q.from_(self.t).select(self.t.a * 1) + + self.assertEqual('SELECT "a"*1 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"*1 FROM "abc"', str(q2)) + + def test__multiplication__decimal(self): + q1 = Q.from_("abc").select(F("a") * 1.0) + q2 = Q.from_(self.t).select(self.t.a * 1.0) + + self.assertEqual('SELECT "a"*1.0 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"*1.0 FROM "abc"', str(q2)) + + def test__multiplication__right(self): + q1 = Q.from_("abc").select(1 * F("a")) + q2 = Q.from_(self.t).select(1 * self.t.a) + + self.assertEqual('SELECT 1*"a" FROM "abc"', str(q1)) + self.assertEqual('SELECT 1*"a" FROM "abc"', str(q2)) + + def test__division__fields(self): + q1 = Q.from_("abc").select(F("a") / F("b")) + q2 = Q.from_(self.t).select(self.t.a / self.t.b) + + self.assertEqual('SELECT "a"/"b" FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"/"b" FROM "abc"', str(q2)) + + def test__division__number(self): + q1 = Q.from_("abc").select(F("a") / 1) + q2 = Q.from_(self.t).select(self.t.a / 1) + + self.assertEqual('SELECT "a"/1 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"/1 FROM "abc"', str(q2)) + + def test__division__decimal(self): + q1 = Q.from_("abc").select(F("a") / 1.0) + q2 = Q.from_(self.t).select(self.t.a / 1.0) + + self.assertEqual('SELECT "a"/1.0 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"/1.0 FROM "abc"', str(q2)) + + def test__division__right(self): + q1 = Q.from_("abc").select(1 / F("a")) + q2 = Q.from_(self.t).select(1 / self.t.a) + + self.assertEqual('SELECT 1/"a" FROM "abc"', str(q1)) + self.assertEqual('SELECT 1/"a" FROM "abc"', str(q2)) + + def test__leftshift__fields(self): + q1 = Q.from_("abc").select(F("a") << F("b")) + q2 = Q.from_(self.t).select(self.t.a << self.t.b) + + self.assertEqual('SELECT "a"<<"b" FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"<<"b" FROM "abc"', str(q2)) + + def test__leftshift__number(self): + q1 = Q.from_("abc").select(F('a') << 2) + q2 = Q.from_(self.t).select(self.t.a << 2) + + self.assertEqual('SELECT "a"<<2 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"<<2 FROM "abc"', str(q2)) + + def test__leftshift__right(self): + q1 = Q.from_("abc").select(1 << F("a")) + q2 = Q.from_(self.t).select(1 << self.t.a) + + self.assertEqual('SELECT 1<<"a" FROM "abc"', str(q1)) + self.assertEqual('SELECT 1<<"a" FROM "abc"', str(q2)) + + def test__rightshift__fields(self): + q1 = Q.from_("abc").select(F("a") >> F("b")) + q2 = Q.from_(self.t).select(self.t.a >> self.t.b) + + self.assertEqual('SELECT "a">>"b" FROM "abc"', str(q1)) + self.assertEqual('SELECT "a">>"b" FROM "abc"', str(q2)) + + def test__rightshift__number(self): + q1 = Q.from_("abc").select(F('a') >> 2) + q2 = Q.from_(self.t).select(self.t.a >> 2) + + self.assertEqual('SELECT "a">>2 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a">>2 FROM "abc"', str(q2)) + + def test__rightshift__right(self): + q1 = Q.from_("abc").select(1 >> F("a")) + q2 = Q.from_(self.t).select(1 >> self.t.a) + + self.assertEqual('SELECT 1>>"a" FROM "abc"', str(q1)) + self.assertEqual('SELECT 1>>"a" FROM "abc"', str(q2)) + + def test__complex_op(self): + q1 = Q.from_("abc").select(2 + 1 / F("a") - 5) + q2 = Q.from_(self.t).select(2 + 1 / self.t.a - 5) + + self.assertEqual('SELECT 2+1/"a"-5 FROM "abc"', str(q1)) + self.assertEqual('SELECT 2+1/"a"-5 FROM "abc"', str(q2)) + + def test__complex_op_add_parentheses(self): + q1 = Q.from_("abc").select((F("a") + 1) + (F("b") - 5)) + q2 = Q.from_(self.t).select((self.t.a + 1) + (self.t.b - 5)) + q3 = Q.from_("abc").select((F("a") / 1) + (F("b") / 5)) + q4 = Q.from_(self.t).select((self.t.a / 1) + (self.t.b / 5)) + + self.assertEqual('SELECT "a"+1+"b"-5 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"+1+"b"-5 FROM "abc"', str(q2)) + self.assertEqual('SELECT "a"/1+"b"/5 FROM "abc"', str(q3)) + self.assertEqual('SELECT "a"/1+"b"/5 FROM "abc"', str(q4)) + + def test__complex_op_sub_parentheses(self): + q1 = Q.from_("abc").select((F("a") + 1) - (F("b") - 5)) + q2 = Q.from_(self.t).select((self.t.a + 1) - (self.t.b - 5)) + q3 = Q.from_("abc").select((F("a") / 1) - (F("b") / 5)) + q4 = Q.from_(self.t).select((self.t.a / 1) - (self.t.b / 5)) + + self.assertEqual('SELECT "a"+1-("b"-5) FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"+1-("b"-5) FROM "abc"', str(q2)) + self.assertEqual('SELECT "a"/1-"b"/5 FROM "abc"', str(q3)) + self.assertEqual('SELECT "a"/1-"b"/5 FROM "abc"', str(q4)) + + def test__complex_op_mul_parentheses(self): + q1 = Q.from_("abc").select((F("a") + 1) * (F("b") - 5)) + q2 = Q.from_(self.t).select((self.t.a + 1) * (self.t.b - 5)) + q3 = Q.from_("abc").select((F("a") / 1) * (F("b") - 5)) + q4 = Q.from_(self.t).select((self.t.a / 1) * (self.t.b - 5)) + q5 = Q.from_("abc").select((F("a") + 1) * (F("b") / 5)) + q6 = Q.from_(self.t).select((self.t.a + 1) * (self.t.b / 5)) + + self.assertEqual('SELECT ("a"+1)*("b"-5) FROM "abc"', str(q1)) + self.assertEqual('SELECT ("a"+1)*("b"-5) FROM "abc"', str(q2)) + self.assertEqual('SELECT "a"/1*("b"-5) FROM "abc"', str(q3)) + self.assertEqual('SELECT "a"/1*("b"-5) FROM "abc"', str(q4)) + self.assertEqual('SELECT ("a"+1)*"b"/5 FROM "abc"', str(q5)) + self.assertEqual('SELECT ("a"+1)*"b"/5 FROM "abc"', str(q6)) + + def test__complex_op_mul_no_parentheses(self): + q = Q.from_("abc").select(F("a") + 1 * F("b") - 5) + + self.assertEqual('SELECT "a"+1*"b"-5 FROM "abc"', str(q)) + + def test__complex_op_div_parentheses(self): + q1 = Q.from_("abc").select((F("a") + 1) / (F("b") - 5)) + q2 = Q.from_(self.t).select((self.t.a + 1) / (self.t.b - 5)) + q3 = Q.from_("abc").select((F("a") / 1) / (F("b") - 5)) + q4 = Q.from_(self.t).select((self.t.a / 1) / (self.t.b - 5)) + q5 = Q.from_("abc").select((F("a") + 1) / (F("b") * 5)) + q6 = Q.from_(self.t).select((self.t.a + 1) / (self.t.b * 5)) + + self.assertEqual('SELECT ("a"+1)/("b"-5) FROM "abc"', str(q1)) + self.assertEqual('SELECT ("a"+1)/("b"-5) FROM "abc"', str(q2)) + self.assertEqual('SELECT "a"/1/("b"-5) FROM "abc"', str(q3)) + self.assertEqual('SELECT "a"/1/("b"-5) FROM "abc"', str(q4)) + self.assertEqual('SELECT ("a"+1)/("b"*5) FROM "abc"', str(q5)) + self.assertEqual('SELECT ("a"+1)/("b"*5) FROM "abc"', str(q6)) + + def test__complex_op_div_no_parentheses(self): + q = Q.from_("abc").select(F("a") + 1 / F("b") - 5) + + self.assertEqual('SELECT "a"+1/"b"-5 FROM "abc"', str(q)) + + def test__complex_op_exponent_parentheses(self): + q1 = Q.from_("abc").select(F("a") / (F("b") ** 2)) + q2 = Q.from_(self.t).select(self.t.a / (self.t.b**2)) + q3 = Q.from_("abc").select(F("a") ** (F("b") / 2)) + q4 = Q.from_(self.t).select(self.t.a ** (self.t.b / 2)) + q5 = Q.from_("abc").select((F("a") ** F("b")) ** 2) + q6 = Q.from_(self.t).select((self.t.a**self.t.b) ** 2) + + self.assertEqual('SELECT "a"/POW("b",2) FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"/POW("b",2) FROM "abc"', str(q2)) + self.assertEqual('SELECT POW("a","b"/2) FROM "abc"', str(q3)) + self.assertEqual('SELECT POW("a","b"/2) FROM "abc"', str(q4)) + self.assertEqual('SELECT POW(POW("a","b"),2) FROM "abc"', str(q5)) + self.assertEqual('SELECT POW(POW("a","b"),2) FROM "abc"', str(q6)) + + def test__complex_op_exponent_no_parentheses(self): + q1 = Q.from_("abc").select(F("a") ** F("b") ** 2) + q2 = Q.from_(self.t).select(self.t.a**self.t.b**2) + q3 = Q.from_("abc").select(F("a") / F("b") ** 2) + q4 = Q.from_(self.t).select(self.t.a / self.t.b**2) + + self.assertEqual('SELECT POW("a",POW("b",2)) FROM "abc"', str(q1)) + self.assertEqual('SELECT POW("a",POW("b",2)) FROM "abc"', str(q2)) + self.assertEqual('SELECT "a"/POW("b",2) FROM "abc"', str(q3)) + self.assertEqual('SELECT "a"/POW("b",2) FROM "abc"', str(q4)) + + def test__complex_op_function_parentheses(self): + q1 = Q.from_("abc").select(F("a") / (fn.Sum(F("b")) / 2)) + q2 = Q.from_("abc").select(self.t.a / (fn.Sum(self.t.b) / 2)) + q3 = Q.from_("abc").select(fn.Sum(F("a") / (F("b") / 2))) + q4 = Q.from_("abc").select(fn.Sum(self.t.a / (self.t.b / 2))) + + self.assertEqual('SELECT "a"/(SUM("b")/2) FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"/(SUM("b")/2) FROM "abc"', str(q2)) + self.assertEqual('SELECT SUM("a"/("b"/2)) FROM "abc"', str(q3)) + self.assertEqual('SELECT SUM("a"/("b"/2)) FROM "abc"', str(q4)) + + def test__complex_op_modulus_parentheses(self): + q1 = Q.from_("abc").select(F("a") / (F("b") % 2)) + q2 = Q.from_(self.t).select(self.t.a / (self.t.b % 2)) + q3 = Q.from_("abc").select(F("a") % (F("b") / 2)) + q4 = Q.from_(self.t).select(self.t.a % (self.t.b / 2)) + q5 = Q.from_("abc").select(F("a") % (F("b") % 2)) + q6 = Q.from_("abc").select(self.t.a % (self.t.b % 2)) + + self.assertEqual('SELECT "a"/MOD("b",2) FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"/MOD("b",2) FROM "abc"', str(q2)) + self.assertEqual('SELECT MOD("a","b"/2) FROM "abc"', str(q3)) + self.assertEqual('SELECT MOD("a","b"/2) FROM "abc"', str(q4)) + self.assertEqual('SELECT MOD("a",MOD("b",2)) FROM "abc"', str(q5)) + self.assertEqual('SELECT MOD("a",MOD("b",2)) FROM "abc"', str(q6)) + + def test__complex_op_modulus_no_parentheses(self): + q1 = Q.from_("abc").select(F("a") % F("b") % 2) + q2 = Q.from_(self.t).select(self.t.a % self.t.b % 2) + q3 = Q.from_("abc").select(F("a") / F("b") % 2) + q4 = Q.from_(self.t).select(self.t.a / self.t.b % 2) + + self.assertEqual('SELECT MOD(MOD("a","b"),2) FROM "abc"', str(q1)) + self.assertEqual('SELECT MOD(MOD("a","b"),2) FROM "abc"', str(q2)) + self.assertEqual('SELECT MOD("a"/"b",2) FROM "abc"', str(q3)) + self.assertEqual('SELECT MOD("a"/"b",2) FROM "abc"', str(q4)) + + def test__complex_op_floor_parentheses(self): + q1 = Q.from_("abc").select(F("a") / (fn.Floor(F("b")) / 2)) + q2 = Q.from_("abc").select(self.t.a / (fn.Floor(self.t.b) / 2)) + q3 = Q.from_("abc").select(fn.Floor(F("a") / (F("b") / 2))) + q4 = Q.from_("abc").select(fn.Floor(self.t.a / (self.t.b / 2))) + + self.assertEqual('SELECT "a"/(FLOOR("b")/2) FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"/(FLOOR("b")/2) FROM "abc"', str(q2)) + self.assertEqual('SELECT FLOOR("a"/("b"/2)) FROM "abc"', str(q3)) + self.assertEqual('SELECT FLOOR("a"/("b"/2)) FROM "abc"', str(q4)) + + def test__complex_op_nested_parentheses(self): + q1 = Q.from_("abc").select(F("a") / (F("b") / ((F("c") / 2)))) + q2 = Q.from_("abc").select(self.t.a / (self.t.b / ((self.t.c / 2)))) + + self.assertEqual('SELECT "a"/("b"/("c"/2)) FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"/("b"/("c"/2)) FROM "abc"', str(q2)) + + def test__arithmetic_equality(self): + q1 = Q.from_("abc").select(F("a") / 2 == 2) + q2 = Q.from_(self.t).select(self.t.a / 2 == 2) + + self.assertEqual('SELECT "a"/2=2 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"/2=2 FROM "abc"', str(q2)) + + def test__arithmetic_with_function(self): + q1 = Q.from_("abc").select(fn.Sum(F("foo")) + 1) + q2 = Q.from_(self.t).select(fn.Sum(self.t.foo) + 1) + + self.assertEqual('SELECT SUM("foo")+1 FROM "abc"', str(q1)) + self.assertEqual('SELECT SUM("foo")+1 FROM "abc"', str(q2)) + + def test__exponent__number(self): + q1 = Q.from_("abc").select(F("a") ** 2) + q2 = Q.from_(self.t).select(self.t.a**2) + + self.assertEqual('SELECT POW("a",2) FROM "abc"', str(q1)) + self.assertEqual('SELECT POW("a",2) FROM "abc"', str(q2)) + + def test__exponent__decimal(self): + q1 = Q.from_("abc").select(F("a") ** 0.5) + q2 = Q.from_(self.t).select(self.t.a**0.5) + + self.assertEqual('SELECT POW("a",0.5) FROM "abc"', str(q1)) + self.assertEqual('SELECT POW("a",0.5) FROM "abc"', str(q2)) + + def test__modulus__number(self): + q1 = Q.from_("abc").select(F("a") % 2) + q2 = Q.from_(self.t).select(self.t.a % 2) + + self.assertEqual('SELECT MOD("a",2) FROM "abc"', str(q1)) + self.assertEqual('SELECT MOD("a",2) FROM "abc"', str(q2)) + + def test__floor(self): + q1 = Q.from_("abc").select(fn.Floor(F("foo"))) + q2 = Q.from_(self.t).select(fn.Floor(self.t.foo)) + + self.assertEqual('SELECT FLOOR("foo") FROM "abc"', str(q1)) + self.assertEqual('SELECT FLOOR("foo") FROM "abc"', str(q2)) + + +class AggregationTests(unittest.TestCase): + def test__count(self): + q = Q.from_("abc").select(fn.Count(F("foo"))) + + self.assertEqual('SELECT COUNT("foo") FROM "abc"', str(q)) + + def test__count__star(self): + q = Q.from_("abc").select(fn.Count("*")) + + self.assertEqual('SELECT COUNT(*) FROM "abc"', str(q)) + + def test__sum(self): + q = Q.from_("abc").select(fn.Sum(F("foo"))) + + self.assertEqual('SELECT SUM("foo") FROM "abc"', str(q)) + + def test__avg(self): + q = Q.from_("abc").select(fn.Avg(F("foo"))) + + self.assertEqual('SELECT AVG("foo") FROM "abc"', str(q)) + + def test__first(self): + q = Q.from_("abc").select(fn.First(F("foo"))) + + self.assertEqual('SELECT FIRST("foo") FROM "abc"', str(q)) + + def test__last(self): + q = Q.from_("abc").select(fn.Last(F("foo"))) + + self.assertEqual('SELECT LAST("foo") FROM "abc"', str(q)) + + def test__min(self): + q = Q.from_("abc").select(fn.Min(F("foo"))) + + self.assertEqual('SELECT MIN("foo") FROM "abc"', str(q)) + + def test__max(self): + q = Q.from_("abc").select(fn.Max(F("foo"))) + + self.assertEqual('SELECT MAX("foo") FROM "abc"', str(q)) + + def test__std(self): + q = Q.from_("abc").select(fn.Std(F("foo"))) + + self.assertEqual('SELECT STD("foo") FROM "abc"', str(q)) + + def test__stddev(self): + q = Q.from_("abc").select(fn.StdDev(F("foo"))) + + self.assertEqual('SELECT STDDEV("foo") FROM "abc"', str(q)) + + def test__approx_percentile(self): + q = Q.from_("abc").select(fn.ApproximatePercentile(F("foo"), 0.5)) + + self.assertEqual( + 'SELECT APPROXIMATE_PERCENTILE("foo" USING PARAMETERS percentile=0.5) FROM "abc"', + str(q), + ) + + def test__subquery_in_params_functions(self): + subquery = Query.from_('table').select('id') + func = fn.Function('func', 'id', subquery) + self.assertEqual("func('id',(SELECT id FROM table))", func.get_sql()) + + +class ConditionTests(unittest.TestCase): + def test__case__raw(self): + q = Q.from_("abc").select(Case().when(F("foo") == 1, "a")) + + self.assertEqual('SELECT CASE WHEN "foo"=1 THEN \'a\' END FROM "abc"', str(q)) + + def test__case__else(self): + q = Q.from_("abc").select(Case().when(F("foo") == 1, "a").else_("b")) + + self.assertEqual("SELECT CASE WHEN \"foo\"=1 THEN 'a' ELSE 'b' END FROM \"abc\"", str(q)) + + def test__case__field(self): + q = Q.from_("abc").select(Case().when(F("foo") == 1, F("bar")).else_(F("buz"))) + + self.assertEqual('SELECT CASE WHEN "foo"=1 THEN "bar" ELSE "buz" END FROM "abc"', str(q)) + + def test__case__multi(self): + q = Q.from_("abc").select(Case().when(F("foo") > 0, F("fiz")).when(F("bar") <= 0, F("buz")).else_(1)) + + self.assertEqual( + 'SELECT CASE WHEN "foo">0 THEN "fiz" WHEN "bar"<=0 THEN "buz" ELSE 1 END FROM "abc"', + str(q), + ) + + def test__case__no_cases(self): + with self.assertRaises(CaseException): + q = Q.from_("abc").select(Case()) + + str(q) + + +class StringTests(unittest.TestCase): + t = T("abc") + + def test__ascii__str(self): + q = Q.select(fn.Ascii("2")) + + self.assertEqual("SELECT ASCII('2')", str(q)) + + def test__ascii__int(self): + q = Q.select(fn.Ascii(2)) + + self.assertEqual("SELECT ASCII(2)", str(q)) + + def test__ascii__field(self): + q = Q.from_(self.t).select(fn.Ascii(self.t.foo)) + + self.assertEqual('SELECT ASCII("foo") FROM "abc"', str(q)) + + def test__bin__str(self): + q = Q.select(fn.Bin("2")) + + self.assertEqual("SELECT BIN('2')", str(q)) + + def test__bin__int(self): + q = Q.select(fn.Bin(2)) + + self.assertEqual("SELECT BIN(2)", str(q)) + + def test__bin__field(self): + q = Q.from_(self.t).select(fn.Bin(self.t.foo)) + + self.assertEqual('SELECT BIN("foo") FROM "abc"', str(q)) + + def test__concat__str(self): + q = Q.select(fn.Concat("p", "y", "q", "b")) + + self.assertEqual("SELECT CONCAT('p','y','q','b')", str(q)) + + def test__concat__field(self): + q = Q.from_(self.t).select(fn.Concat(self.t.foo, self.t.bar)) + + self.assertEqual('SELECT CONCAT("foo","bar") FROM "abc"', str(q)) + + def test__insert__str(self): + q = Q.select(fn.Insert("Quadratic", 3, 4, "What")) + + self.assertEqual("SELECT INSERT('Quadratic',3,4,'What')", str(q)) + + def test__insert__field(self): + q = Q.from_(self.t).select(fn.Insert(self.t.foo, 3, 4, self.t.bar)) + + self.assertEqual('SELECT INSERT("foo",3,4,"bar") FROM "abc"', str(q)) + + def test__lower__str(self): + q = Q.select(fn.Lower("ABC")) + + self.assertEqual("SELECT LOWER('ABC')", str(q)) + + def test__lower__field(self): + q = Q.from_(self.t).select(fn.Lower(self.t.foo)) + + self.assertEqual('SELECT LOWER("foo") FROM "abc"', str(q)) + + def test__length__str(self): + q = Q.select(fn.Length("ABC")) + + self.assertEqual("SELECT LENGTH('ABC')", str(q)) + + def test__length__field(self): + q = Q.from_(self.t).select(fn.Length(self.t.foo)) + + self.assertEqual('SELECT LENGTH("foo") FROM "abc"', str(q)) + + def test__substring(self): + q = Q.from_(self.t).select(fn.Substring(self.t.foo, 2, 6)) + + self.assertEqual('SELECT SUBSTRING("foo",2,6) FROM "abc"', str(q)) + + def test__replace__str(self): + q = Q.select(fn.Replace("ABC_DEF", "_", " ")) + self.assertEqual("SELECT REPLACE('ABC_DEF','_',' ')", str(q)) + + def test__replace__field(self): + q = Q.from_(self.t).select(fn.Replace(self.t.foobar, self.t.foo, self.t.bar)) + self.assertEqual('SELECT REPLACE("foobar","foo","bar") FROM "abc"', str(q)) + + +class SplitPartFunctionTests(unittest.TestCase): + t = T("abc") + + def test__split_part(self): + q = VerticaQuery.from_(self.t).select(fn.SplitPart(self.t.foo, "|", 3)) + + self.assertEqual('SELECT SPLIT_PART("foo",\'|\',3) FROM "abc"', str(q)) + + +class RegexpLikeFunctionTests(unittest.TestCase): + t = T("abc") + + def test__regexp_like(self): + q = VerticaQuery.from_(self.t).select(fn.RegexpLike(self.t.foo, "^a", "x")) + + self.assertEqual("SELECT REGEXP_LIKE(\"foo\",'^a','x') FROM \"abc\"", str(q)) + + +class CastTests(unittest.TestCase): + t = T("abc") + + def test__cast__as(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.UNSIGNED)) + + self.assertEqual('SELECT CAST("foo" AS UNSIGNED) FROM "abc"', str(q)) + + def test__cast__signed(self): + q1 = Q.from_(self.t).select(fn.Signed(self.t.foo)) + q2 = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.SIGNED)) + + self.assertEqual('SELECT CAST("foo" AS SIGNED) FROM "abc"', str(q1)) + self.assertEqual('SELECT CAST("foo" AS SIGNED) FROM "abc"', str(q2)) + + def test__cast__unsigned(self): + q1 = Q.from_(self.t).select(fn.Unsigned(self.t.foo)) + q2 = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.UNSIGNED)) + + self.assertEqual('SELECT CAST("foo" AS UNSIGNED) FROM "abc"', str(q1)) + self.assertEqual('SELECT CAST("foo" AS UNSIGNED) FROM "abc"', str(q2)) + + def test__cast__date(self): + q1 = Q.from_(self.t).select(fn.Date(self.t.foo)) + q2 = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.DATE)) + + self.assertEqual('SELECT DATE("foo") FROM "abc"', str(q1)) + self.assertEqual('SELECT CAST("foo" AS DATE) FROM "abc"', str(q2)) + + def test__cast__timestamp(self): + q1 = Q.from_(self.t).select(fn.Timestamp(self.t.foo)) + q2 = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.TIMESTAMP)) + + self.assertEqual('SELECT TIMESTAMP("foo") FROM "abc"', str(q1)) + self.assertEqual('SELECT CAST("foo" AS TIMESTAMP) FROM "abc"', str(q2)) + + def test__cast__char(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.CHAR)) + + self.assertEqual('SELECT CAST("foo" AS CHAR) FROM "abc"', str(q)) + + def test__cast__char_with_arg(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.VARCHAR(24))) + + self.assertEqual('SELECT CAST("foo" AS VARCHAR(24)) FROM "abc"', str(q)) + + def test__cast__varchar(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.VARCHAR)) + + self.assertEqual('SELECT CAST("foo" AS VARCHAR) FROM "abc"', str(q)) + + def test__cast__varchar_with_arg(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.VARCHAR(24))) + + self.assertEqual('SELECT CAST("foo" AS VARCHAR(24)) FROM "abc"', str(q)) + + def test__cast__long_varchar(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.LONG_VARCHAR)) + + self.assertEqual('SELECT CAST("foo" AS LONG VARCHAR) FROM "abc"', str(q)) + + def test__cast__long_varchar_with_arg(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.LONG_VARCHAR(24))) + + self.assertEqual('SELECT CAST("foo" AS LONG VARCHAR(24)) FROM "abc"', str(q)) + + def test__cast__binary(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.BINARY)) + + self.assertEqual('SELECT CAST("foo" AS BINARY) FROM "abc"', str(q)) + + def test__cast__binary_with_arg(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.BINARY(24))) + + self.assertEqual('SELECT CAST("foo" AS BINARY(24)) FROM "abc"', str(q)) + + def test__cast__varbinary(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.VARBINARY)) + + self.assertEqual('SELECT CAST("foo" AS VARBINARY) FROM "abc"', str(q)) + + def test__cast__varbinary_with_arg(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.VARBINARY(24))) + + self.assertEqual('SELECT CAST("foo" AS VARBINARY(24)) FROM "abc"', str(q)) + + def test__cast__long_varbinary(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.LONG_VARBINARY)) + + self.assertEqual('SELECT CAST("foo" AS LONG VARBINARY) FROM "abc"', str(q)) + + def test__cast__long_varbinary_with_arg(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.LONG_VARBINARY(24))) + + self.assertEqual('SELECT CAST("foo" AS LONG VARBINARY(24)) FROM "abc"', str(q)) + + def test__cast__boolean(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.BOOLEAN)) + + self.assertEqual('SELECT CAST("foo" AS BOOLEAN) FROM "abc"', str(q)) + + def test__cast__integer(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.INTEGER)) + + self.assertEqual('SELECT CAST("foo" AS INTEGER) FROM "abc"', str(q)) + + def test__cast__float(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.FLOAT)) + + self.assertEqual('SELECT CAST("foo" AS FLOAT) FROM "abc"', str(q)) + + def test__cast__numeric(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.NUMERIC)) + + self.assertEqual('SELECT CAST("foo" AS NUMERIC) FROM "abc"', str(q)) + + def test__tochar__(self): + q = Q.from_(self.t).select(fn.ToChar(self.t.foo, "SomeFormat")) + + self.assertEqual('SELECT TO_CHAR("foo",\'SomeFormat\') FROM "abc"', str(q)) + + +class DateFunctionsTests(unittest.TestCase): + dt = F("dt") + t = T("abc") + t2 = T("efg") + + def _test_extract_datepart(self, date_part): + q = Q.from_(self.t).select(fn.Extract(date_part, self.t.foo)) + + value = getattr(date_part, 'value', date_part) + self.assertEqual('SELECT EXTRACT(%s FROM "foo") FROM "abc"' % value, str(q)) + + def test_extract_microsecond(self): + self._test_extract_datepart(DatePart.microsecond) + self._test_extract_datepart(DatePart.microsecond.value) + + def test_extract_second(self): + self._test_extract_datepart(DatePart.second) + self._test_extract_datepart(DatePart.second.value) + + def test_extract_minute(self): + self._test_extract_datepart(DatePart.minute) + self._test_extract_datepart(DatePart.minute.value) + + def test_extract_hour(self): + self._test_extract_datepart(DatePart.hour) + self._test_extract_datepart(DatePart.hour.value) + + def test_extract_day(self): + self._test_extract_datepart(DatePart.day) + self._test_extract_datepart(DatePart.day.value) + + def test_extract_week(self): + self._test_extract_datepart(DatePart.week) + self._test_extract_datepart(DatePart.week.value) + + def test_extract_month(self): + self._test_extract_datepart(DatePart.month) + self._test_extract_datepart(DatePart.month.value) + + def test_extract_quarter(self): + self._test_extract_datepart(DatePart.quarter) + self._test_extract_datepart(DatePart.quarter.value) + + def test_extract_year(self): + self._test_extract_datepart(DatePart.year) + self._test_extract_datepart(DatePart.year.value) + + def test_extract_join(self): + q = Q.from_(self.t).join(self.t2).on(self.t.id == self.t2.t_id).select(fn.Extract(DatePart.year, self.t.foo)) + + self.assertEqual( + 'SELECT EXTRACT(YEAR FROM "abc"."foo") FROM "abc" ' 'JOIN "efg" ON "abc"."id"="efg"."t_id"', str(q) + ) + + def test_timestampadd(self): + a = fn.TimestampAdd("year", 1, "2017-10-01") + self.assertEqual(str(a), "TIMESTAMPADD(year,1,'2017-10-01')") + + def test_time_diff(self): + a = fn.TimeDiff("18:00:00", "10:00:00") + self.assertEqual(str(a), "TIMEDIFF('18:00:00','10:00:00')") + + def test_date_add(self): + a = fn.DateAdd("year", 1, "2017-10-01") + self.assertEqual(str(a), "DATE_ADD(year,1,'2017-10-01')") + + def test_now(self): + query = Query.select(fn.Now()) + + self.assertEqual("SELECT NOW()", str(query)) + + def test_utc_timestamp(self): + query = Query.select(fn.UtcTimestamp()) + + self.assertEqual("SELECT UTC_TIMESTAMP()", str(query)) + + def test_current_date(self): + query = Query.select(fn.CurDate()) + + self.assertEqual("SELECT CURRENT_DATE()", str(query)) + + def test_current_time(self): + query = Query.select(fn.CurTime()) + + self.assertEqual("SELECT CURRENT_TIME()", str(query)) + + def test_current_timestamp(self): + query = Query.select(fn.CurTimestamp()) + + self.assertEqual("SELECT CURRENT_TIMESTAMP", str(query)) + + def test_current_timestamp_with_alias(self): + query = Query.select(fn.CurTimestamp("ts")) + + self.assertEqual('SELECT CURRENT_TIMESTAMP "ts"', str(query)) + + def test_to_date(self): + q1 = fn.ToDate("2019-06-21", "yyyy-mm-dd") + q2 = Query.from_(self.t).select(fn.ToDate("2019-06-21", "yyyy-mm-dd")) + q3 = Query.from_(self.t).select(fn.ToDate(F("foo"), "yyyy-mm-dd")) + + self.assertEqual(str(q1), "TO_DATE('2019-06-21','yyyy-mm-dd')") + self.assertEqual(str(q2), "SELECT TO_DATE('2019-06-21','yyyy-mm-dd') FROM \"abc\"") + self.assertEqual(str(q3), 'SELECT TO_DATE("foo",\'yyyy-mm-dd\') FROM "abc"') + + +class NullFunctionsTests(unittest.TestCase): + def test_isnull(self): + q = Q.from_("abc").select(fn.IsNull(F("foo"))) + + self.assertEqual('SELECT ISNULL("foo") FROM "abc"', str(q)) + + def test_coalesce(self): + q = Q.from_("abc").select(fn.Coalesce(F("foo"), 0)) + + self.assertEqual('SELECT COALESCE("foo",0) FROM "abc"', str(q)) + + def test_nullif(self): + q = Q.from_("abc").select(fn.NullIf(F("foo"), 0)) + + self.assertEqual('SELECT NULLIF("foo",0) FROM "abc"', str(q)) + + def test_nvl(self): + q = Q.from_("abc").select(fn.NVL(F("foo"), 0)) + + self.assertEqual('SELECT NVL("foo",0) FROM "abc"', str(q)) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/test_groupby_modifiers.py b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/test_groupby_modifiers.py new file mode 100644 index 0000000000000000000000000000000000000000..978834c2409f4b4800fedb9b1bb2538a31d0f31c --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/test_groupby_modifiers.py @@ -0,0 +1,168 @@ +import unittest + +from pypika import Query, Rollup, RollupException, Table, functions as fn + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + + +class RollupTests(unittest.TestCase): + table = Table("abc") + + def test_mysql_one_groupby(self): + q = ( + Query.from_(self.table) + .select(self.table.foo, fn.Sum(self.table.bar)) + .rollup(self.table.foo, vendor="mysql") + ) + + self.assertEqual('SELECT "foo",SUM("bar") FROM "abc" GROUP BY "foo" WITH ROLLUP', str(q)) + + def test_mysql_rollup_two_groupbys(self): + q = ( + Query.from_(self.table) + .select(self.table.foo, self.table.fiz, fn.Sum(self.table.bar)) + .rollup(self.table.foo, self.table.fiz, vendor="mysql") + ) + + self.assertEqual( + 'SELECT "foo","fiz",SUM("bar") FROM "abc" GROUP BY "foo","fiz" WITH ROLLUP', + str(q), + ) + + def test_no_rollup_before_groupby(self): + with self.assertRaises(RollupException): + Query.from_(self.table).select(self.table.foo, fn.Sum(self.table.bar)).rollup(vendor="mysql") + + def test_no_rollup_after_rollup_mysql(self): + with self.assertRaises(AttributeError): + Query.from_(self.table).select(self.table.foo, self.table.fiz, fn.Sum(self.table.bar)).rollup( + self.table.foo, vendor="mysql" + ).rollup(self.table.fiz, vendor="mysql") + + def test_verticaoracle_func_one_groupby(self): + q = Query.from_(self.table).select(self.table.foo, fn.Sum(self.table.bar)).groupby(Rollup(self.table.foo)) + + self.assertEqual('SELECT "foo",SUM("bar") FROM "abc" GROUP BY ROLLUP("foo")', str(q)) + + def test_verticaoracle_func_two_groupbys(self): + q = ( + Query.from_(self.table) + .select(self.table.foo, self.table.fiz, fn.Sum(self.table.bar)) + .groupby( + Rollup( + self.table.foo, + self.table.fiz, + ) + ) + ) + + self.assertEqual( + 'SELECT "foo","fiz",SUM("bar") FROM "abc" GROUP BY ROLLUP("foo","fiz")', + str(q), + ) + + def test_verticaoracle_func_partial(self): + q = ( + Query.from_(self.table) + .select(self.table.foo, self.table.fiz, self.table.buz, fn.Sum(self.table.bar)) + .groupby( + Rollup( + self.table.foo, + self.table.fiz, + ), + self.table.buz, + ) + ) + + self.assertEqual( + 'SELECT "foo","fiz","buz",SUM("bar") FROM "abc" GROUP BY ROLLUP("foo","fiz"),"buz"', + str(q), + ) + + def test_verticaoracle_from_groupbys(self): + q = Query.from_(self.table).select(self.table.foo, fn.Sum(self.table.bar)).rollup(self.table.foo) + + self.assertEqual('SELECT "foo",SUM("bar") FROM "abc" GROUP BY ROLLUP("foo")', str(q)) + + def test_verticaoracle_from_two_groupbys(self): + q = ( + Query.from_(self.table) + .select(self.table.foo, self.table.fiz, fn.Sum(self.table.bar)) + .rollup( + self.table.foo, + self.table.fiz, + ) + ) + + self.assertEqual( + 'SELECT "foo","fiz",SUM("bar") FROM "abc" GROUP BY ROLLUP("foo","fiz")', + str(q), + ) + + def test_verticaoracle_from_parameters(self): + q = ( + Query.from_(self.table) + .select(self.table.foo, self.table.fiz, fn.Sum(self.table.bar)) + .groupby( + self.table.foo, + ) + .rollup( + self.table.fiz, + ) + ) + + self.assertEqual( + 'SELECT "foo","fiz",SUM("bar") FROM "abc" GROUP BY "foo",ROLLUP("fiz")', + str(q), + ) + + def test_verticaoracle_multiple_rollups(self): + q = ( + Query.from_(self.table) + .select(self.table.foo, self.table.fiz, fn.Sum(self.table.bar)) + .rollup( + self.table.foo, + ) + .rollup( + self.table.fiz, + ) + ) + + self.assertEqual( + 'SELECT "foo","fiz",SUM("bar") FROM "abc" GROUP BY ROLLUP("foo","fiz")', + str(q), + ) + + def test_verticaoracle_rollups_with_parity(self): + q = ( + Query.from_(self.table) + .select( + self.table.buz, + ) + .rollup( + [self.table.foo, self.table.bar], + self.table.fiz, + ) + ) + + self.assertEqual('SELECT "buz" FROM "abc" GROUP BY ROLLUP(("foo","bar"),"fiz")', str(q)) + + def test_verticaoracle_rollups_with_multiple_rollups_and_parity(self): + q = ( + Query.from_(self.table) + .select( + self.table.buz, + ) + .rollup( + [self.table.foo, self.table.bar], + ) + .rollup( + [self.table.fiz, self.table.buz], + ) + ) + + self.assertEqual( + 'SELECT "buz" FROM "abc" GROUP BY ROLLUP(("foo","bar"),("fiz","buz"))', + str(q), + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/test_immutability.py b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/test_immutability.py new file mode 100644 index 0000000000000000000000000000000000000000..ee539bfa1e9c4509b929e7a86a03f098dd923515 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/test_immutability.py @@ -0,0 +1,99 @@ +import unittest + +from pypika import ( + AliasedQuery, + Query, + Tables, +) + + +class ImmutabilityTests(unittest.TestCase): + table_a, table_b, table_c = Tables("a", "b", "c") + + def test_select_returns_new_query_instance(self): + query_a = Query.from_(self.table_a).select(self.table_a.foo) + query_b = query_a.select(self.table_a.bar) + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_groupby_returns_new_query_instance(self): + query_a = Query.from_(self.table_a).select(self.table_a.foo).groupby(self.table_a.foo) + query_b = query_a.groupby(self.table_a.bar) + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_orderby_return_new_query_instance(self): + query_a = Query.from_(self.table_a).select(self.table_a.foo).orderby(self.table_a.foo) + query_b = query_a.orderby(self.table_a.bar) + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_join_return_new_query_instance(self): + base = Query.from_(self.table_a).select(self.table_a.foo) + query_a = base.join(self.table_b).on(self.table_a.foo == self.table_b.bar).select(self.table_b.bar) + query_b = query_a.join(self.table_c).on(self.table_a.foo == self.table_c.baz).select(self.table_c.baz) + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_use_index_return_new_query_instance(self): + query_a = Query.from_(self.table_a).select(self.table_a.foo).use_index('idx1') + query_b = query_a.use_index('idx2') + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_force_index_return_new_query_instance(self): + query_a = Query.from_(self.table_a).select(self.table_a.foo).force_index('idx1') + query_b = query_a.force_index('idx2') + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_with_return_new_query_instance(self): + alias_1 = Query.from_(self.table_a).select(self.table_a.foo) + alias_2 = Query.from_(self.table_b).select(self.table_b.bar) + query_a = Query.from_(AliasedQuery('a1')).select('foo').with_(alias_1, 'a1') + query_b = query_a.with_(alias_2, 'a2') + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_insert_into_return_new_query_instance(self): + query_a = Query.into(self.table_a).insert('foo1') + query_b = query_a.insert('foo2') + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_replace_into_return_new_query_instance(self): + query_a = Query.into(self.table_a).replace('foo') + query_b = query_a.replace('bar') + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_update_set_return_new_query_instance(self): + query_a = Query.update(self.table_a).set(self.table_a.foo, 'foo') + query_b = query_a.set(self.table_a.bar, 'bar') + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_queries_after_join(self): + query1 = Query.from_(self.table_a).select(self.table_a.foo) + query2 = query1.join(self.table_b).on(self.table_a.foo == self.table_b.bar).select(self.table_b.buz) + + self.assertEqual('SELECT "foo" FROM "a"', str(query1)) + self.assertEqual( + 'SELECT "a"."foo","b"."buz" FROM "a" JOIN "b" ON "a"."foo"="b"."bar"', + str(query2), + ) + + def test_immutable_kwarg_on_query_builder_disables_immutability(self): + query0 = Query.from_(self.table_a, immutable=False) + query1 = query0.select(self.table_a.foo) + self.assertIs(query0, query1) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/test_inserts.py b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/test_inserts.py new file mode 100644 index 0000000000000000000000000000000000000000..f86efd7a76dc498a69b61c6353951695f1933a61 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/test_inserts.py @@ -0,0 +1,885 @@ +import unittest + +from pypika import ( + AliasedQuery, + Case, + Field as F, + MySQLQuery, + PostgreSQLQuery, + Query, + Table, + Tables, + functions as fn, +) +from pypika.functions import ( + Avg, + Cast, +) +from pypika.terms import Values +from pypika.utils import QueryException + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + + +class InsertIntoTests(unittest.TestCase): + table_abc = Table("abc") + + def test_insert_one_column(self): + query = Query.into(self.table_abc).insert(1) + + self.assertEqual('INSERT INTO "abc" VALUES (1)', str(query)) + + def test_insert_one_column_single_element_array(self): + query = Query.into(self.table_abc).insert((1,)) + + self.assertEqual('INSERT INTO "abc" VALUES (1)', str(query)) + + def test_insert_one_column_multi_element_array(self): + query = Query.into(self.table_abc).insert((1,), (2,)) + + self.assertEqual('INSERT INTO "abc" VALUES (1),(2)', str(query)) + + def test_insert_single_row_with_array_value(self): + query = Query.into(self.table_abc).insert(1, ["a", "b", "c"]) + + self.assertEqual("INSERT INTO \"abc\" VALUES (1,['a','b','c'])", str(query)) + + def test_insert_multiple_rows_with_array_value(self): + query = Query.into(self.table_abc).insert( + (1, ["a", "b", "c"]), + (2, ["c", "d", "e"]), + ) + + self.assertEqual( + 'INSERT INTO "abc" ' "VALUES (1,['a','b','c']),(2,['c','d','e'])", + str(query), + ) + + def test_insert_all_columns(self): + query = Query.into(self.table_abc).insert(1, "a", True) + + self.assertEqual("INSERT INTO \"abc\" VALUES (1,'a',true)", str(query)) + + def test_insert_all_columns_single_element(self): + query = Query.into(self.table_abc).insert((1, "a", True)) + + self.assertEqual("INSERT INTO \"abc\" VALUES (1,'a',true)", str(query)) + + def test_insert_all_columns_multi_rows(self): + query = Query.into(self.table_abc).insert((1, "a", True), (2, "b", False)) + + self.assertEqual("INSERT INTO \"abc\" VALUES (1,'a',true),(2,'b',false)", str(query)) + + def test_insert_all_columns_multi_rows_chained(self): + query = Query.into(self.table_abc).insert(1, "a", True).insert(2, "b", False) + + self.assertEqual("INSERT INTO \"abc\" VALUES (1,'a',true),(2,'b',false)", str(query)) + + def test_insert_all_columns_multi_rows_chained_mixed(self): + query = Query.into(self.table_abc).insert((1, "a", True), (2, "b", False)).insert(3, "c", True) + + self.assertEqual( + 'INSERT INTO "abc" VALUES ' "(1,'a',true),(2,'b',false)," "(3,'c',true)", + str(query), + ) + + def test_insert_all_columns_multi_rows_chained_multiple_rows(self): + query = ( + Query.into(self.table_abc).insert((1, "a", True), (2, "b", False)).insert((3, "c", True), (4, "d", False)) + ) + + self.assertEqual( + 'INSERT INTO "abc" VALUES ' "(1,'a',true),(2,'b',false)," "(3,'c',true),(4,'d',false)", + str(query), + ) + + def test_insert_selected_columns(self): + query = ( + Query.into(self.table_abc) + .columns(self.table_abc.foo, self.table_abc.bar, self.table_abc.buz) + .insert(1, "a", True) + ) + + self.assertEqual('INSERT INTO "abc" ("foo","bar","buz") VALUES (1,\'a\',true)', str(query)) + + def test_insert_empty_columns(self): + query = Query.into(self.table_abc).columns().insert(1, "a", True) + + self.assertEqual('INSERT INTO "abc" VALUES (1,\'a\',true)', str(query)) + + def test_insert_selected_columns_type_list(self): + query = ( + Query.into(self.table_abc) + .columns([self.table_abc.foo, self.table_abc.bar, self.table_abc.buz]) + .insert(1, "a", True) + ) + + self.assertEqual('INSERT INTO "abc" ("foo","bar","buz") VALUES (1,\'a\',true)', str(query)) + + def test_insert_empty_columns_type_list(self): + query = Query.into(self.table_abc).columns([]).insert(1, "a", True) + + self.assertEqual('INSERT INTO "abc" VALUES (1,\'a\',true)', str(query)) + + def test_insert_selected_columns_type_tuple(self): + query = ( + Query.into(self.table_abc) + .columns((self.table_abc.foo, self.table_abc.bar, self.table_abc.buz)) + .insert(1, "a", True) + ) + + self.assertEqual('INSERT INTO "abc" ("foo","bar","buz") VALUES (1,\'a\',true)', str(query)) + + def test_insert_empty_columns_type_tuple(self): + query = Query.into(self.table_abc).columns(()).insert(1, "a", True) + + self.assertEqual('INSERT INTO "abc" VALUES (1,\'a\',true)', str(query)) + + def test_insert_none_skipped(self): + query = Query.into(self.table_abc).insert() + + self.assertEqual("", str(query)) + + def test_insert_ignore(self): + query = Query.into(self.table_abc).insert(1).ignore() + + self.assertEqual('INSERT IGNORE INTO "abc" VALUES (1)', str(query)) + + def test_insert_null(self): + query = Query.into(self.table_abc).insert(None) + + self.assertEqual('INSERT INTO "abc" VALUES (NULL)', str(query)) + + def test_insert_column_using_table_alias(self): + q = self.table_abc.insert(1) + self.assertEqual('INSERT INTO "abc" VALUES (1)', str(q)) + + def test_insert_column_using_alias_with_chain(self): + q = self.table_abc.insert(1, "a", True).insert(2, "b", False) + self.assertEqual("INSERT INTO \"abc\" VALUES (1,'a',true),(2,'b',false)", str(q)) + + def test_insert_with_statement(self): + sub_query = Query().select(self.table_abc.id).from_(self.table_abc) + aliased = AliasedQuery('sub_qs') + + q = Query().with_(sub_query, 'sub_qs').into(self.table_abc).select(aliased.id).from_(aliased) + self.assertEqual( + 'WITH sub_qs AS (SELECT "id" FROM "abc") INSERT INTO "abc" SELECT "sub_qs"."id" FROM sub_qs', str(q) + ) + + +class PostgresInsertIntoOnConflictTests(unittest.TestCase): + table_abc = Table("abc") + + def test_insert_on_conflict_do_nothing_field(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).on_conflict(self.table_abc.id).do_nothing() + + self.assertEqual('INSERT INTO "abc" VALUES (1) ON CONFLICT ("id") DO NOTHING', str(query)) + + def test_insert_on_conflict_do_nothing_multiple_fields(self): + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1) + .on_conflict(self.table_abc.id, self.table_abc.sub_id) + .do_nothing() + ) + + self.assertEqual('INSERT INTO "abc" VALUES (1) ON CONFLICT ("id", "sub_id") DO NOTHING', str(query)) + + def test_insert_on_conflict_do_nothing_field_str(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).on_conflict("id").do_nothing() + + self.assertEqual('INSERT INTO "abc" VALUES (1) ON CONFLICT ("id") DO NOTHING', str(query)) + + def test_insert_on_conflict_do_nothing_multiple_fields_str(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).on_conflict("id", "sub_id").do_nothing() + + self.assertEqual('INSERT INTO "abc" VALUES (1) ON CONFLICT ("id", "sub_id") DO NOTHING', str(query)) + + def test_insert_on_conflict_do_nothing_mixed_fields(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).on_conflict("id", self.table_abc.sub_id).do_nothing() + + self.assertEqual('INSERT INTO "abc" VALUES (1) ON CONFLICT ("id", "sub_id") DO NOTHING', str(query)) + + def test_insert_on_conflict_do_update_field(self): + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict(self.table_abc.id) + .do_update(self.table_abc.name, "m") + ) + + self.assertEqual( + "INSERT INTO \"abc\" VALUES (1,'m') ON CONFLICT (\"id\") DO UPDATE SET \"name\"='m'", + str(query), + ) + + def test_insert_on_conflict_do_update_multiple_fields(self): + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict(self.table_abc.id, self.table_abc.sub_id) + .do_update(self.table_abc.name, "m") + ) + + self.assertEqual( + "INSERT INTO \"abc\" VALUES (1,'m') ON CONFLICT (\"id\", \"sub_id\") DO UPDATE SET \"name\"='m'", + str(query), + ) + + def test_insert_on_conflict_do_update_field_str(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1, "m").on_conflict("id").do_update("name", "m") + + self.assertEqual( + "INSERT INTO \"abc\" VALUES (1,'m') ON CONFLICT (\"id\") DO UPDATE SET \"name\"='m'", + str(query), + ) + + def test_insert_on_conflict_do_update_multiple_fields_str(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1, "m").on_conflict("id", "sub_id").do_update("name", "m") + + self.assertEqual( + "INSERT INTO \"abc\" VALUES (1,'m') ON CONFLICT (\"id\", \"sub_id\") DO UPDATE SET \"name\"='m'", + str(query), + ) + + def test_insert_on_conflict_do_update_multiple_mixed_fields(self): + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict("id", self.table_abc.sub_id) + .do_update("name", "m") + ) + + self.assertEqual( + "INSERT INTO \"abc\" VALUES (1,'m') ON CONFLICT (\"id\", \"sub_id\") DO UPDATE SET \"name\"='m'", + str(query), + ) + + def test_insert_on_conflict_no_handler(self): + with self.assertRaises(QueryException): + query = str(PostgreSQLQuery.into(self.table_abc).insert(1).on_conflict(self.table_abc.id)) + + def test_insert_on_conflict_two_handlers_do_nothing(self): + with self.assertRaises(QueryException): + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1) + .on_conflict("id") + .do_nothing() + .do_update(self.table_abc.name, "m") + ) + + def test_insert_on_conflict_two_handlers_do_update(self): + with self.assertRaises(QueryException): + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1) + .on_conflict(self.table_abc.id) + .do_update(self.table_abc.name, "m") + .do_nothing() + ) + + def test_non_insert_on_conflict_do_nothing(self): + with self.assertRaises(QueryException): + query = PostgreSQLQuery.update(self.table_abc).set("foo", "bar").on_conflict("id").do_nothing() + + def test_non_insert_on_conflict_do_update(self): + with self.assertRaises(QueryException): + query = ( + PostgreSQLQuery.update(self.table_abc).set("foo", "bar").on_conflict("id").do_update(["name"], ["m"]) + ) + + def test_insert_on_fieldless_conflict_do_nothing(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).on_conflict(None).do_nothing() + + self.assertEqual('INSERT INTO "abc" VALUES (1) ON CONFLICT DO NOTHING', str(query)) + + def test_insert_on_fieldless_conflict_do_update_field(self): + with self.assertRaises(QueryException): + query = str( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict(None) + .do_update(self.table_abc.name, "m") + ) + + def test_on_conflict_from_subquery(self): + table_bcd = Table('bcd') + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(self.table_abc.fname, self.table_abc.lname) + .select(table_bcd.fname, table_bcd.lname) + .from_(table_bcd) + .on_conflict(self.table_abc.id, self.table_abc.sub_id) + .do_update(self.table_abc.fname, 1) + .do_update(self.table_abc.lname, table_bcd.lname) + .do_update( + self.table_abc.cname, + Case().when(self.table_abc.cname.eq('cname'), 'new_name').else_(self.table_abc.cname), + ) + ) + + self.assertEqual( + 'INSERT INTO "abc" VALUES ("fname","lname") ' + 'ON CONFLICT ("id", "sub_id") ' + 'DO UPDATE SET "fname"=1,"lname"="bcd"."lname",' + '"cname"=CASE WHEN "abc"."cname"=\'cname\' THEN \'new_name\' ELSE "abc"."cname" END', + str(query), + ) + + def test_on_conflict_where_empty_conflict_fields_do_nothing(self): + with self.assertRaises(QueryException): + ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict() + .where(self.table_abc.abc.eq(0)) + .where(self.table_abc.cde.eq(0)) + .do_nothing() + ) + + def test_on_conflict_where_conflict_fields_do_nothing(self): + qs = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict('id') + .where(self.table_abc.abc.eq(0)) + .where(self.table_abc.cde.eq(0)) + .do_nothing() + ) + self.assertEqual( + '''INSERT INTO "abc" VALUES (1,'m') ON CONFLICT ("id") WHERE "abc"=0 AND "cde"=0 DO NOTHING''', str(qs) + ) + + def test_on_conflict_where_empty_conflict_fields_do_update(self): + with self.assertRaises(QueryException): + ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict() + .where(self.table_abc.abc.eq(0)) + .where(self.table_abc.cde.eq(0)) + .do_update('field', 'val') + ) + + def test_on_conflict_where_conflict_fields_do_update(self): + qs = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict('id') + .where(self.table_abc.abc.eq(0)) + .where(self.table_abc.cde.eq(0)) + .do_update('field', 'val') + ) + self.assertEqual( + '''INSERT INTO "abc" VALUES (1,'m') ON CONFLICT ("id") WHERE "abc"=0 AND "cde"=0 ''' + '''DO UPDATE SET "field"='val\'''', + str(qs), + ) + + def test_where_and_on_conflict_where(self): + table_bcd = Table('bcd') + + qs = ( + PostgreSQLQuery.into(self.table_abc) + .select(table_bcd.abc) + .from_(table_bcd) + .where(table_bcd.abc.eq('1')) + .on_conflict('id') + .where(self.table_abc.abc.eq(0)) + .where(self.table_abc.cde.eq(0)) + .do_update('field', 'val') + ) + + self.assertEqual( + 'INSERT INTO "abc" SELECT "abc" FROM "bcd" WHERE "abc"=\'1\' ' + 'ON CONFLICT ("id") WHERE "abc"=0 AND "cde"=0 DO UPDATE SET "field"=\'val\'', + str(qs), + ) + + def test_on_conflict_do_nothing_where(self): + with self.assertRaises(QueryException): + ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict() + .do_nothing() + .where(self.table_abc.abc.eq(1)) + ) + + def test_empty_on_conflict_do_update_where(self): + with self.assertRaises(QueryException): + ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict() + .do_update('abc', 1) + .where(self.table_abc.abc.eq(1)) + ) + + def test_on_conflict_do_update_where(self): + qs = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict("id") + .do_update('abc', 1) + .where(self.table_abc.abc.eq(1)) + ) + self.assertEqual( + 'INSERT INTO "abc" VALUES (1,\'m\') ON CONFLICT ("id") DO UPDATE SET "abc"=1 WHERE "abc"."abc"=1', str(qs) + ) + + def test_on_conflict_do_update_with_excluded_where(self): + qs = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict("id") + .do_update('abc') + .where(self.table_abc.abc.eq(1)) + ) + self.assertEqual( + 'INSERT INTO "abc" VALUES (1,\'m\') ON CONFLICT ("id") DO UPDATE SET "abc"=EXCLUDED."abc" WHERE ' + '"abc"."abc"=1', + str(qs), + ) + + def test_on_conflict_where_complex(self): + table_bcd = Table('bcd') + + qs = ( + PostgreSQLQuery.into(self.table_abc) + .select(table_bcd.abc) + .from_(table_bcd) + .where(table_bcd.abc.eq('1')) + .on_conflict('id') + .where(self.table_abc.abc.eq(0)) + .where(self.table_abc.cde.eq(0)) + .do_update('field', 'val') + .where(self.table_abc.id.eq(2)) + .where(self.table_abc.sub_id.eq(3)) + ) + self.assertEqual( + 'INSERT INTO "abc" SELECT "abc" FROM "bcd" WHERE "abc"=\'1\' ' + 'ON CONFLICT ("id") WHERE "abc"=0 AND "cde"=0 ' + 'DO UPDATE SET "field"=\'val\' WHERE "abc"."id"=2 AND "abc"."sub_id"=3', + str(qs), + ) + + +class PostgresInsertIntoReturningTests(unittest.TestCase): + table_abc = Table("abc") + + def test_insert_returning_one_field(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).returning(self.table_abc.id) + + self.assertEqual('INSERT INTO "abc" VALUES (1) RETURNING "id"', str(query)) + + def test_insert_returning_one_field_str(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).returning("id") + + self.assertEqual('INSERT INTO "abc" VALUES (1) RETURNING "id"', str(query)) + + def test_insert_returning_all_fields(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).returning(self.table_abc.star) + + self.assertEqual('INSERT INTO "abc" VALUES (1) RETURNING *', str(query)) + + def test_insert_returning_all_fields_and_arithmetics(self): + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1) + .returning(self.table_abc.star, self.table_abc.f1 + self.table_abc.f2) + ) + + self.assertEqual('INSERT INTO "abc" VALUES (1) RETURNING *,"f1"+"f2"', str(query)) + + def test_insert_all_columns_multi_rows_chained_returning_star(self): + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "a", True) + .insert(2, "b", False) + .returning(self.table_abc.star) + ) + + self.assertEqual( + "INSERT INTO \"abc\" VALUES (1,'a',true),(2,'b',false) RETURNING *", + str(query), + ) + + def test_insert_all_columns_multi_rows_chained_returning_star_and_id(self): + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "a", True) + .insert(2, "b", False) + .returning( + self.table_abc.name, + self.table_abc.star, + self.table_abc.id, + ) + ) + + self.assertEqual( + "INSERT INTO \"abc\" VALUES (1,'a',true),(2,'b',false) RETURNING *", + str(query), + ) + + def test_insert_all_columns_multi_rows_chained_returning_star_str(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1, "a", True).insert(2, "b", False).returning("*") + + self.assertEqual( + "INSERT INTO \"abc\" VALUES (1,'a',true),(2,'b',false) RETURNING *", + str(query), + ) + + def test_insert_all_columns_single_element_arrays(self): + query = PostgreSQLQuery.into(self.table_abc).insert((1, "a", True)).returning(self.table_abc.star) + + self.assertEqual("INSERT INTO \"abc\" VALUES (1,'a',true) RETURNING *", str(query)) + + def test_insert_returning_null(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).returning(None) + + self.assertEqual('INSERT INTO "abc" VALUES (1) RETURNING NULL', str(query)) + + def test_insert_returning_tuple(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).returning((1, 2, 3)) + + self.assertEqual('INSERT INTO "abc" VALUES (1) RETURNING (1,2,3)', str(query)) + + def test_insert_returning_arithmetics(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).returning(self.table_abc.f1 + self.table_abc.f2) + + self.assertEqual('INSERT INTO "abc" VALUES (1) RETURNING "f1"+"f2"', str(query)) + + def test_insert_returning_functions(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).returning(Cast(self.table_abc.f1, "int")) + + self.assertEqual('INSERT INTO "abc" VALUES (1) RETURNING CAST("f1" AS INT)', str(query)) + + def test_insert_returning_aggregate(self): + with self.assertRaises(QueryException): + PostgreSQLQuery.into(self.table_abc).insert(1).returning(Avg(self.table_abc.views)) + + def test_insert_returning_from_other_table(self): + table_cba = Table("cba") + with self.assertRaises(QueryException): + PostgreSQLQuery.into(self.table_abc).insert(1).returning(table_cba.id) + + +class InsertIntoOnDuplicateTests(unittest.TestCase): + table_abc = Table("abc") + + def test_insert_one_column(self): + query = ( + MySQLQuery.into(self.table_abc).insert(1).on_duplicate_key_update(self.table_abc.foo, self.table_abc.foo) + ) + self.assertEqual( + "INSERT INTO `abc` VALUES (1) ON DUPLICATE KEY UPDATE `foo`=`foo`", + str(query), + ) + + def test_insert_one_column_using_values(self): + query = ( + MySQLQuery.into(self.table_abc) + .insert(1) + .on_duplicate_key_update(self.table_abc.foo, Values(self.table_abc.foo)) + ) + self.assertEqual( + "INSERT INTO `abc` VALUES (1) ON DUPLICATE KEY UPDATE `foo`=VALUES(`foo`)", + str(query), + ) + + def test_insert_one_column_single_element_array(self): + query = ( + MySQLQuery.into(self.table_abc).insert((1,)).on_duplicate_key_update(self.table_abc.foo, self.table_abc.foo) + ) + + self.assertEqual( + "INSERT INTO `abc` VALUES (1) ON DUPLICATE KEY UPDATE `foo`=`foo`", + str(query), + ) + + def test_insert_one_column_multi_element_array(self): + query = ( + MySQLQuery.into(self.table_abc) + .insert((1,), (2,)) + .on_duplicate_key_update(self.table_abc.foo, self.table_abc.foo) + ) + + self.assertEqual( + "INSERT INTO `abc` VALUES (1),(2) ON DUPLICATE KEY UPDATE `foo`=`foo`", + str(query), + ) + + def test_insert_multiple_columns_on_duplicate_update_one_with_same_value(self): + query = ( + MySQLQuery.into(self.table_abc) + .insert(1, "a") + .on_duplicate_key_update(self.table_abc.bar, Values(self.table_abc.bar)) + ) + + self.assertEqual( + "INSERT INTO `abc` VALUES (1,'a') ON DUPLICATE KEY UPDATE `bar`=VALUES(`bar`)", + str(query), + ) + + def test_insert_multiple_columns_on_duplicate_update_one_with_different_value(self): + query = MySQLQuery.into(self.table_abc).insert(1, "a").on_duplicate_key_update(self.table_abc.bar, "b") + + self.assertEqual( + "INSERT INTO `abc` VALUES (1,'a') ON DUPLICATE KEY UPDATE `bar`='b'", + str(query), + ) + + def test_insert_multiple_columns_on_duplicate_update_one_with_expression(self): + query = ( + MySQLQuery.into(self.table_abc).insert(1, 2).on_duplicate_key_update(self.table_abc.bar, 4 + F("bar")) + ) # todo sql expression? not python + + self.assertEqual( + "INSERT INTO `abc` VALUES (1,2) ON DUPLICATE KEY UPDATE `bar`=4+`bar`", + str(query), + ) + + def test_insert_multiple_columns_on_duplicate_update_one_with_expression_using_original_field_value( + self, + ): + query = ( + MySQLQuery.into(self.table_abc) + .insert(1, "a") + .on_duplicate_key_update(self.table_abc.bar, fn.Concat(self.table_abc.bar, "update")) + ) + + self.assertEqual( + "INSERT INTO `abc` VALUES (1,'a') ON DUPLICATE KEY UPDATE `bar`=CONCAT(`bar`,'update')", + str(query), + ) + + def test_insert_multiple_columns_on_duplicate_update_one_with_expression_using_values( + self, + ): + query = ( + MySQLQuery.into(self.table_abc) + .insert(1, "a") + .on_duplicate_key_update(self.table_abc.bar, fn.Concat(Values(self.table_abc.bar), "update")) + ) + + self.assertEqual( + "INSERT INTO `abc` VALUES (1,'a') ON DUPLICATE KEY UPDATE `bar`=CONCAT(VALUES(`bar`),'update')", + str(query), + ) + + def test_insert_multiple_columns_on_duplicate_update_multiple(self): + query = ( + MySQLQuery.into(self.table_abc) + .insert(1, "a", "b") + .on_duplicate_key_update(self.table_abc.bar, "b") + .on_duplicate_key_update(self.table_abc.baz, "c") + ) + + self.assertEqual( + "INSERT INTO `abc` VALUES (1,'a','b') ON DUPLICATE KEY UPDATE `bar`='b',`baz`='c'", + str(query), + ) + + def test_insert_multi_rows_chained_mixed_on_duplicate_update_multiple(self): + query = ( + MySQLQuery.into(self.table_abc) + .insert((1, "a", True), (2, "b", False)) + .insert(3, "c", True) + .on_duplicate_key_update(self.table_abc.foo, self.table_abc.foo) + .on_duplicate_key_update(self.table_abc.bar, Values(self.table_abc.bar)) + ) + + self.assertEqual( + "INSERT INTO `abc` VALUES (1,'a',true),(2,'b',false),(3,'c',true) " + "ON DUPLICATE KEY UPDATE `foo`=`foo`,`bar`=VALUES(`bar`)", + str(query), + ) + + def test_insert_selected_columns_on_duplicate_update_one(self): + query = ( + MySQLQuery.into(self.table_abc) + .columns(self.table_abc.foo, self.table_abc.bar, self.table_abc.baz) + .insert(1, "a", True) + .on_duplicate_key_update(self.table_abc.baz, False) + ) + + self.assertEqual( + "INSERT INTO `abc` (`foo`,`bar`,`baz`) VALUES (1,'a',true) ON DUPLICATE KEY UPDATE `baz`=false", + str(query), + ) + + def test_insert_selected_columns_on_duplicate_update_multiple(self): + query = ( + MySQLQuery.into(self.table_abc) + .columns(self.table_abc.foo, self.table_abc.bar, self.table_abc.baz) + .insert(1, "a", True) + .on_duplicate_key_update(self.table_abc.baz, False) + .on_duplicate_key_update(self.table_abc.bar, Values(self.table_abc.bar)) + ) + + self.assertEqual( + "INSERT INTO `abc` (`foo`,`bar`,`baz`) VALUES (1,'a',true) " + "ON DUPLICATE KEY UPDATE `baz`=false,`bar`=VALUES(`bar`)", + str(query), + ) + + def test_insert_none_skipped(self): + query = MySQLQuery.into(self.table_abc).insert().on_duplicate_key_update(self.table_abc.baz, False) + + self.assertEqual("", str(query)) + + def test_insert_ignore(self): + query = MySQLQuery.into(self.table_abc).insert(1).ignore().on_duplicate_key_update(self.table_abc.baz, False) + + self.assertEqual( + "INSERT IGNORE INTO `abc` VALUES (1) ON DUPLICATE KEY UPDATE `baz`=false", + str(query), + ) + + +class InsertSelectFromTests(unittest.TestCase): + table_abc, table_efg, table_hij = Tables("abc", "efg", "hij") + + def test_insert_star(self): + query = Query.into(self.table_abc).from_(self.table_efg).select("*") + + self.assertEqual('INSERT INTO "abc" SELECT * FROM "efg"', str(query)) + + def test_insert_ignore_star(self): + query = Query.into(self.table_abc).from_(self.table_efg).select("*").ignore() + + self.assertEqual('INSERT IGNORE INTO "abc" SELECT * FROM "efg"', str(query)) + + def test_insert_from_columns(self): + query = ( + Query.into(self.table_abc) + .from_(self.table_efg) + .select(self.table_efg.fiz, self.table_efg.buz, self.table_efg.baz) + ) + + self.assertEqual('INSERT INTO "abc" ' 'SELECT "fiz","buz","baz" FROM "efg"', str(query)) + + def test_insert_columns_from_star(self): + query = ( + Query.into(self.table_abc) + .columns( + self.table_abc.foo, + self.table_abc.bar, + self.table_abc.buz, + ) + .from_(self.table_efg) + .select("*") + ) + + self.assertEqual('INSERT INTO "abc" ("foo","bar","buz") ' 'SELECT * FROM "efg"', str(query)) + + def test_insert_columns_from_columns(self): + query = ( + Query.into(self.table_abc) + .columns(self.table_abc.foo, self.table_abc.bar, self.table_abc.buz) + .from_(self.table_efg) + .select(self.table_efg.fiz, self.table_efg.buz, self.table_efg.baz) + ) + + self.assertEqual( + 'INSERT INTO "abc" ("foo","bar","buz") ' 'SELECT "fiz","buz","baz" FROM "efg"', + str(query), + ) + + def test_insert_columns_from_columns_with_join(self): + query = ( + Query.into(self.table_abc) + .columns( + self.table_abc.c1, + self.table_abc.c2, + self.table_abc.c3, + self.table_abc.c4, + ) + .from_(self.table_efg) + .select(self.table_efg.foo, self.table_efg.bar) + .join(self.table_hij) + .on(self.table_efg.id == self.table_hij.abc_id) + .select(self.table_hij.fiz, self.table_hij.buz) + ) + + self.assertEqual( + 'INSERT INTO "abc" ("c1","c2","c3","c4") ' + 'SELECT "efg"."foo","efg"."bar","hij"."fiz","hij"."buz" FROM "efg" ' + 'JOIN "hij" ON "efg"."id"="hij"."abc_id"', + str(query), + ) + + +class InsertSubqueryTests(unittest.TestCase): + def test_insert_subquery_wrapped_in_brackets(self): + purchase_order_item, part = Tables("purchase_order_item", "part") + + q = ( + Query.into(purchase_order_item) + .columns(purchase_order_item.id_part, purchase_order_item.id_customer) + .insert( + Query.from_(part).select(part.part_id).where(part.part_number == "FOOBAR"), + 12345, + ) + ) + + self.assertEqual( + 'INSERT INTO "purchase_order_item" ' + '("id_part","id_customer") ' + "VALUES " + '((SELECT "part_id" FROM "part" WHERE "part_number"=\'FOOBAR\'),12345)', + str(q), + ) + + +class SelectIntoTests(unittest.TestCase): + table_abc, table_efg, table_hij = Tables("abc", "efg", "hij") + + def test_select_star_into(self): + query = Query.from_(self.table_abc).select("*").into(self.table_efg) + + self.assertEqual('SELECT * INTO "efg" FROM "abc"', str(query)) + + def test_select_columns_into(self): + query = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, self.table_abc.bar, self.table_abc.buz) + .into(self.table_efg) + ) + + self.assertEqual('SELECT "foo","bar","buz" INTO "efg" FROM "abc"', str(query)) + + def test_select_columns_into_with_join(self): + query = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, self.table_abc.bar) + .join(self.table_hij) + .on(self.table_abc.id == self.table_hij.abc_id) + .select(self.table_hij.fiz, self.table_hij.buz) + .into(self.table_efg) + ) + + self.assertEqual( + 'SELECT "abc"."foo","abc"."bar","hij"."fiz","hij"."buz" ' + 'INTO "efg" FROM "abc" ' + 'JOIN "hij" ON "abc"."id"="hij"."abc_id"', + str(query), + ) + + +class ReplaceTests(unittest.TestCase): + table_abc, table_def = Tables("abc", "efg") + + def test_replace_simple(self): + query = Query.into(self.table_abc).replace("v1", "v2", "v3") + expected_output = "REPLACE INTO \"abc\" VALUES ('v1','v2','v3')" + self.assertEqual(str(query), expected_output) + + def test_replace_subquery(self): + query = Query.into(self.table_abc).replace(Query.from_(self.table_def).select("f1", "f2")) + expected_output = 'REPLACE INTO "abc" VALUES ((SELECT "f1","f2" FROM "efg"))' + self.assertEqual(str(query), expected_output) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/test_internals.py b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/test_internals.py new file mode 100644 index 0000000000000000000000000000000000000000..921e381ba8613d4a83cc53bd60d111d9547e2c1f --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/test_internals.py @@ -0,0 +1,35 @@ +import unittest + +from pypika import ( + Case, + Field, + Table, +) +from pypika.terms import Star + + +class TablesTests(unittest.TestCase): + def test__criterion_replace_table_with_value(self): + table = Table("a") + + c = (Field("foo") > 1).replace_table(None, table) + self.assertEqual(c.left, table) + self.assertEqual(c.tables_, {table}) + + def test__case_tables(self): + table = Table("a") + + c = Case().when(table.a == 1, 2 * table.a) + self.assertIsInstance(c.tables_, set) + self.assertSetEqual(c.tables_, {table}) + + def test__star_tables(self): + star = Star() + + self.assertEqual(star.tables_, set()) + + def test__table_star_tables(self): + table = Table("a") + star = Star(table=table) + + self.assertEqual(star.tables_, {table}) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/test_joins.py b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/test_joins.py new file mode 100644 index 0000000000000000000000000000000000000000..03142d583921edbe966e0ae191d254e7b8bf46ba --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/test_joins.py @@ -0,0 +1,1168 @@ +import unittest + +from pypika import ( + Field, + Interval, + JoinException, + JoinType, + MySQLQuery, + Query, + SetOperationException, + Table, + Tables, + functions as fn, + SYSTEM_TIME, +) + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + + +class SelectQueryJoinTests(unittest.TestCase): + table0, table1, hij = Tables("abc", "efg", "hij") + + def test_default_join_type(self): + query = Query.from_(self.table0).join(self.table1).on(self.table0.foo == self.table1.bar).select("*") + + self.assertEqual('SELECT * FROM "abc" JOIN "efg" ON "abc"."foo"="efg"."bar"', str(query)) + + def test_inner_join(self): + expected = 'SELECT * FROM "abc" JOIN "efg" ON "abc"."foo"="efg"."bar"' + + with self.subTest("join with enum"): + query = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.inner) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + self.assertEqual(expected, str(query)) + + with self.subTest("join function"): + query = Query.from_(self.table0).inner_join(self.table1).on(self.table0.foo == self.table1.bar).select("*") + self.assertEqual(expected, str(query)) + + def test_left_join(self): + expected = 'SELECT * FROM "abc" LEFT JOIN "efg" ON "abc"."foo"="efg"."bar"' + + with self.subTest("join with enum"): + query = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.left) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + + self.assertEqual(expected, str(query)) + + with self.subTest("join function"): + query = Query.from_(self.table0).left_join(self.table1).on(self.table0.foo == self.table1.bar).select("*") + self.assertEqual(expected, str(query)) + + def test_right_join(self): + expected = 'SELECT * FROM "abc" RIGHT JOIN "efg" ON "abc"."foo"="efg"."bar"' + + with self.subTest("join with enum"): + query = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.right) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + + self.assertEqual(expected, str(query)) + + with self.subTest("join function"): + query = Query.from_(self.table0).right_join(self.table1).on(self.table0.foo == self.table1.bar).select("*") + self.assertEqual(expected, str(query)) + + def test_hash_join(self): + expected = 'SELECT * FROM "abc" HASH JOIN "efg" ON "abc"."foo"="efg"."bar"' + + with self.subTest("join with enum"): + query = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.hash) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + + self.assertEqual(expected, str(query)) + + with self.subTest("join function"): + query = Query.from_(self.table0).hash_join(self.table1).on(self.table0.foo == self.table1.bar).select("*") + self.assertEqual(expected, str(query)) + + def test_outer_join(self): + expected = 'SELECT * FROM "abc" FULL OUTER JOIN "efg" ON "abc"."foo"="efg"."bar"' + + with self.subTest("join with enum"): + query = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.outer) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + + self.assertEqual(expected, str(query)) + + with self.subTest("join function"): + query = Query.from_(self.table0).outer_join(self.table1).on(self.table0.foo == self.table1.bar).select("*") + self.assertEqual(expected, str(query)) + + def test_cross_join(self): + expected = 'SELECT * FROM "abc" CROSS JOIN "efg" ON "abc"."foo"="efg"."bar"' + + with self.subTest("join with enum"): + query = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.cross) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + + self.assertEqual(expected, str(query)) + + with self.subTest("join function"): + query = Query.from_(self.table0).cross_join(self.table1).on(self.table0.foo == self.table1.bar).select("*") + self.assertEqual(expected, str(query)) + + def test_left_outer_join(self): + expected = 'SELECT * FROM "abc" LEFT OUTER JOIN "efg" ON "abc"."foo"="efg"."bar"' + with self.subTest("join with enum"): + query = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.left_outer) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + + self.assertEqual(expected, str(query)) + + with self.subTest("join function"): + query = ( + Query.from_(self.table0).left_outer_join(self.table1).on(self.table0.foo == self.table1.bar).select("*") + ) + + self.assertEqual(expected, str(query)) + + def test_right_outer_join(self): + expected = 'SELECT * FROM "abc" RIGHT OUTER JOIN "efg" ON "abc"."foo"="efg"."bar"' + with self.subTest("join with enum"): + query = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.right_outer) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + + self.assertEqual(expected, str(query)) + + with self.subTest("join function"): + query = ( + Query.from_(self.table0) + .right_outer_join(self.table1) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + + self.assertEqual(expected, str(query)) + + def test_full_outer_join(self): + expected = 'SELECT * FROM "abc" FULL OUTER JOIN "efg" ON "abc"."foo"="efg"."bar"' + + with self.subTest("join with enum"): + query = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.full_outer) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + + self.assertEqual(expected, str(query)) + + with self.subTest("join function"): + query = ( + Query.from_(self.table0).full_outer_join(self.table1).on(self.table0.foo == self.table1.bar).select("*") + ) + + self.assertEqual(expected, str(query)) + + def test_join_on_field_single(self): + query = Query.from_(self.table0).join(self.table1).on_field("foo").select("*") + self.assertEqual('SELECT * FROM "abc" JOIN "efg" ON "abc"."foo"="efg"."foo"', str(query)) + + def test_join_on_field_multi(self): + query = Query.from_(self.table0).join(self.table1).on_field("foo", "bar").select("*") + self.assertEqual( + 'SELECT * FROM "abc" JOIN "efg" ON "abc"."foo"="efg"."foo" ' 'AND "abc"."bar"="efg"."bar"', + str(query), + ) + + def test_join_on_field_multi_with_extra_join(self): + query = ( + Query.from_(self.table0) + .join(self.hij) + .on_field("buzz") + .join(self.table1) + .on_field("foo", "bar") + .select("*") + ) + + self.assertEqual( + 'SELECT * FROM "abc" JOIN "hij" ON "abc"."buzz"="hij"."buzz" ' + 'JOIN "efg" ON "abc"."foo"="efg"."foo" AND "abc"."bar"="efg"."bar"', + str(query), + ) + + def test_join_using_string_field_name(self): + query = Query.from_(self.table0).join(self.table1).using("id").select("*") + + self.assertEqual('SELECT * FROM "abc" JOIN "efg" USING ("id")', str(query)) + + def test_join_using_multiple_fields(self): + query = Query.from_(self.table0).join(self.table1).using("foo", "bar").select("*") + + self.assertEqual('SELECT * FROM "abc" JOIN "efg" USING ("foo","bar")', str(query)) + + def test_join_using_with_quote_char(self): + query = Query.from_(self.table0).join(self.table1).using("foo", "bar").select("*") + + self.assertEqual("SELECT * FROM abc JOIN efg USING (foo,bar)", query.get_sql(quote_char="")) + + def test_join_using_without_fields_raises_exception(self): + with self.assertRaises(JoinException): + Query.from_(self.table0).join(self.table1).using() + + def test_join_on_field_without_fields_raises_exception(self): + with self.assertRaises(JoinException): + Query.from_(self.table0).join(self.table1).on_field() + + def test_join_arithmetic_field(self): + q = ( + Query.from_(self.table0) + .join(self.table1) + .on(self.table0.dt == (self.table1.dt - Interval(weeks=1))) + .select("*") + ) + + self.assertEqual( + 'SELECT * FROM "abc" ' 'JOIN "efg" ON "abc"."dt"="efg"."dt"-INTERVAL \'1 WEEK\'', + str(q), + ) + + def test_join_with_arithmetic_function_in_select(self): + q = ( + Query.from_( + self.table0, + ) + .join(self.table1) + .on(self.table0.dt == (self.table1.dt - Interval(weeks=1))) + .select(self.table0.fiz - self.table0.buz, self.table1.star) + ) + + self.assertEqual( + 'SELECT "abc"."fiz"-"abc"."buz","efg".* FROM "abc" ' + 'JOIN "efg" ON "abc"."dt"="efg"."dt"-INTERVAL \'1 WEEK\'', + str(q), + ) + + def test_join_on_complex_criteria(self): + q = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.right) + .on((self.table0.foo == self.table1.fiz) & (self.table0.bar == self.table1.buz)) + .select("*") + ) + + self.assertEqual( + 'SELECT * FROM "abc" ' 'RIGHT JOIN "efg" ON "abc"."foo"="efg"."fiz" AND "abc"."bar"="efg"."buz"', + str(q), + ) + + def test_join_on_subquery_criteria(self): + table_a, table_b, table_c = Tables("a", "b", "c") + subquery = Query.from_(table_c).select("id").limit(1) + query = ( + Query.from_(table_a).select("*").join(table_b).on((table_a.b_id == table_b.id) & (table_b.c_id == subquery)) + ) + + self.assertEqual( + "SELECT * " 'FROM "a" ' 'JOIN "b" ON "a"."b_id"="b"."id" AND "b"."c_id"=' '(SELECT "id" FROM "c" LIMIT 1)', + str(query), + ) + + def test_use_different_table_objects_for_same_table(self): + table = Table("t") + q = Query.from_(table).select("*").where(Field("id", table=table) == 1) + + self.assertEqual('SELECT * FROM "t" WHERE "id"=1', str(q)) + + def test_join_second_table_in_from_clause(self): + table_a, table_b, table_c = Tables("a", "b", "c") + q = Query.from_(table_a).from_(table_b).select("*").join(table_c).on(table_b.c_id == table_c.id) + + self.assertEqual("SELECT * " 'FROM "a","b" ' 'JOIN "c" ON "b"."c_id"="c"."id"', str(q)) + + def test_cross_join_on_table(self): + table_a, table_b = Tables("a", "b") + q = Query.from_(table_a).join(table_b).cross().select("*") + + self.assertEqual('SELECT * FROM "a" CROSS JOIN "b"', str(q)) + + def test_cross_join_on_subquery(self): + table_a, table_b = Tables("a", "b") + q_a = Query.from_(table_a).select("*") + q_b = Query.from_(table_b).select("*").join(q_a).cross().select("*") + + self.assertEqual('SELECT * FROM "b" CROSS JOIN (SELECT * FROM "a") "sq0"', str(q_b)) + + def test_join_on_collate(self): + table_a, table_b = Tables("a", "b") + + q1 = ( + Query.from_(table_a) + .select(table_b.ouch) + .join(table_b) + .on(table_a.foo == table_b.boo, collate="utf8_general_ci") + ) + q2 = Query.from_(table_a).select(table_b.ouch).join(table_b).on(table_a.foo == table_b.boo) + + self.assertEqual( + 'SELECT "b"."ouch" FROM "a" JOIN "b" ON "a"."foo"="b"."boo" COLLATE utf8_general_ci', + str(q1), + ) + self.assertEqual('SELECT "b"."ouch" FROM "a" JOIN "b" ON "a"."foo"="b"."boo"', str(q2)) + + def test_temporal_join(self): + t0 = self.table0.for_(SYSTEM_TIME.as_of('2020-01-01')) + t1 = self.table1.for_(SYSTEM_TIME.as_of('2020-01-01')) + query = Query.from_(t0).join(t1).on(t0.foo == t1.bar).select("*") + + self.assertEqual( + 'SELECT * FROM "abc" FOR SYSTEM_TIME AS OF \'2020-01-01\' ' + 'JOIN "efg" FOR SYSTEM_TIME AS OF \'2020-01-01\' ' + 'ON "abc"."foo"="efg"."bar"', + str(query), + ) + + +class JoinBehaviorTests(unittest.TestCase): + table_abc, table_efg, table_hij, table_klm = Tables("abc", "efg", "hij", "klm") + + def test_select__ordered_select_clauses(self): + q = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .select( + self.table_abc.baz, + self.table_efg.buz, + self.table_abc.fiz, + self.table_efg.bam, + ) + ) + + self.assertEqual( + 'SELECT "abc"."baz","efg"."buz","abc"."fiz","efg"."bam" FROM "abc" ' + 'JOIN "efg" ON "abc"."foo"="efg"."bar"', + str(q), + ) + + def test_select__star_for_table(self): + q = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .join(self.table_hij) + .on(self.table_abc.buz == self.table_hij.bam) + .select(self.table_abc.star) + .select(self.table_efg.star) + .select(self.table_hij.star) + ) + + self.assertEqual( + 'SELECT "abc".*,"efg".*,"hij".* FROM "abc" ' + 'JOIN "efg" ON "abc"."foo"="efg"."bar" ' + 'JOIN "hij" ON "abc"."buz"="hij"."bam"', + str(q), + ) + + def test_select__star_for_table__replacement(self): + q = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .join(self.table_hij) + .on(self.table_abc.buz == self.table_hij.bam) + .select(self.table_abc.foo, self.table_efg.bar, self.table_hij.bam) + .select(self.table_abc.star, self.table_efg.star, self.table_hij.star) + ) + + self.assertEqual( + 'SELECT "abc".*,"efg".*,"hij".* FROM "abc" ' + 'JOIN "efg" ON "abc"."foo"="efg"."bar" ' + 'JOIN "hij" ON "abc"."buz"="hij"."bam"', + str(q), + ) + + def test_select_fields_with_where(self): + q = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .join(self.table_hij) + .on(self.table_abc.buz == self.table_hij.bam) + .select(self.table_abc.foo, self.table_efg.bar, self.table_hij.bam) + .where(self.table_abc.foo > 1) + .where(self.table_efg.bar != 2) + ) + + self.assertEqual( + 'SELECT "abc"."foo","efg"."bar","hij"."bam" FROM "abc" ' + 'JOIN "efg" ON "abc"."foo"="efg"."bar" ' + 'JOIN "hij" ON "abc"."buz"="hij"."bam" ' + 'WHERE "abc"."foo">1 AND "efg"."bar"<>2', + str(q), + ) + + def test_require_condition(self): + with self.assertRaises(JoinException): + Query.from_(self.table_abc).join(self.table_efg).on(None) + + def test_require_condition_with_both_tables(self): + with self.assertRaises(JoinException): + Query.from_(self.table_abc).join(self.table_efg).on(self.table_abc.foo == self.table_hij.bar) + + with self.assertRaises(JoinException): + Query.from_(self.table_abc).join(self.table_efg).on(self.table_hij.foo == self.table_efg.bar) + + with self.assertRaises(JoinException): + Query.from_(self.table_abc).join(self.table_efg).on(self.table_hij.foo == self.table_klm.bar) + + def test_join_same_table(self): + table1 = Table("abc") + table2 = Table("abc") + q = Query.from_(table1).join(table2).on(table1.foo == table2.bar).select(table1.foo, table2.buz) + + self.assertEqual( + 'SELECT "abc"."foo","abc2"."buz" FROM "abc" ' 'JOIN "abc" "abc2" ON "abc"."foo"="abc2"."bar"', + str(q), + ) + + def test_join_same_table_with_prefixes(self): + table1 = Table("abc").as_("x") + table2 = Table("abc").as_("y") + q = Query.from_(table1).join(table2).on(table1.foo == table2.bar).select(table1.foo, table2.buz) + + self.assertEqual( + 'SELECT "x"."foo","y"."buz" FROM "abc" "x" ' 'JOIN "abc" "y" ON "x"."foo"="y"."bar"', + str(q), + ) + + def test_join_table_twice(self): + table1, table2 = Table("efg").as_("efg1"), Table("efg").as_("efg2") + q = ( + Query.from_(self.table_abc) + .join(table1) + .on(self.table_abc.foo == table1.bar) + .join(table2) + .on(self.table_abc.foo == table2.bam) + .select(self.table_abc.foo, table1.fiz, table2.buz) + ) + + self.assertEqual( + 'SELECT "abc"."foo","efg1"."fiz","efg2"."buz" FROM "abc" ' + 'JOIN "efg" "efg1" ON "abc"."foo"="efg1"."bar" ' + 'JOIN "efg" "efg2" ON "abc"."foo"="efg2"."bam"', + str(q), + ) + + def test_select__fields_after_table_star(self): + q = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .select(self.table_abc.star, self.table_efg.bar) + .select(self.table_abc.foo) + ) + + self.assertEqual( + 'SELECT "abc".*,"efg"."bar" FROM "abc" JOIN "efg" ON "abc"."foo"="efg"."bar"', + str(q), + ) + + def test_fail_when_joining_unknown_type(self): + with self.assertRaises(ValueError): + Query.from_(self.table_abc).join("this is a string") + + def test_immutable__tables(self): + query1 = Query.from_(self.table_abc).select(self.table_abc.foo) + query2 = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .select(self.table_abc.foo, self.table_efg.buz) + ) + + self.assertEqual( + 'SELECT "abc"."foo","efg"."buz" FROM "abc" ' 'JOIN "efg" ON "abc"."foo"="efg"."bar"', + str(query2), + ) + self.assertEqual('SELECT "foo" FROM "abc"', str(query1)) + + def test_select_field_from_missing_table(self): + """ + Previously we validated the select field was a member of a table + in the query (e.g. FROM clause or a JOIN). However this made + correlated subqueries awkward to write (subqueries which refer + to their parent table. So the validation was removed. + + None of the following raise an error. Previously raised JoinException + """ + Query.from_(self.table_abc).select(self.table_efg.foo) + + Query.from_(self.table_abc).where(self.table_efg.foo == 0) + + Query.from_(self.table_abc).where(fn.Sum(self.table_efg.foo) == 0) + + Query.from_(self.table_abc).select(fn.Sum(self.table_abc.bar * 2) + fn.Sum(self.table_efg.foo * 2)) + + Query.from_(self.table_abc).groupby(self.table_efg.foo) + + Query.from_(self.table_abc).groupby(self.table_abc.foo).having(self.table_efg.bar) + + subquery = ( + Query.from_(self.table_efg).select(self.table_efg.id).where(self.table_efg.abc_id == self.table_abc.id) + ) + query = Query.from_(self.table_abc).select(subquery.as_("efg_id").limit(1)) + self.assertEqual( + 'SELECT (SELECT "efg"."id" FROM "efg" WHERE "efg"."abc_id"="abc"."id" LIMIT 1) "efg_id" FROM "abc"', + str(query), + ) + + def test_ignore_table_references(self): + query = Query.from_(Table("abc")).select(Table("abc").foo) + + self.assertEqual('SELECT "foo" FROM "abc"', str(query)) + + def test_prefixes_added_to_groupby(self): + test_query = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .select(self.table_abc.foo, fn.Sum(self.table_efg.buz)) + .groupby(self.table_abc.foo) + ) + + self.assertEqual( + 'SELECT "abc"."foo",SUM("efg"."buz") FROM "abc" ' + 'JOIN "efg" ON "abc"."foo"="efg"."bar" ' + 'GROUP BY "abc"."foo"', + str(test_query), + ) + + def test_prefixes_added_to_orderby(self): + test_query = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .select(self.table_abc.foo, self.table_efg.buz) + .orderby(self.table_abc.foo) + ) + + self.assertEqual( + 'SELECT "abc"."foo","efg"."buz" FROM "abc" ' + 'JOIN "efg" ON "abc"."foo"="efg"."bar" ' + 'ORDER BY "abc"."foo"', + str(test_query), + ) + + def test_prefixes_added_to_function_in_orderby(self): + test_query = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .select(self.table_abc.foo, self.table_efg.buz) + .orderby(fn.Date(self.table_abc.foo)) + ) + + self.assertEqual( + 'SELECT "abc"."foo","efg"."buz" FROM "abc" ' + 'JOIN "efg" ON "abc"."foo"="efg"."bar" ' + 'ORDER BY DATE("abc"."foo")', + str(test_query), + ) + + def test_join_from_join(self): + test_query = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.efg_id == self.table_efg.id) + .join(self.table_hij) + .on(self.table_efg.hij_id == self.table_hij.id) + .select(self.table_abc.foo, self.table_efg.bar, self.table_hij.fizz) + ) + + self.assertEqual( + 'SELECT "abc"."foo","efg"."bar","hij"."fizz" FROM "abc" ' + 'JOIN "efg" ON "abc"."efg_id"="efg"."id" ' + 'JOIN "hij" ON "efg"."hij_id"="hij"."id"', + str(test_query), + ) + + def test_join_query_without_alias(self): + subquery = Query.from_(self.table_efg).select( + self.table_efg.base_id.as_("x"), self.table_efg.fizz, self.table_efg.buzz + ) + + test_query = ( + Query.from_(self.table_abc) + .join(subquery) + .on(subquery.x == self.table_abc.id) + .select(self.table_abc.foo, subquery.fizz, subquery.buzz) + ) + + self.assertEqual( + 'SELECT "abc"."foo","sq0"."fizz","sq0"."buzz" ' + 'FROM "abc" JOIN (' + 'SELECT "base_id" "x","fizz","buzz" FROM "efg"' + ') "sq0" ' + 'ON "sq0"."x"="abc"."id"', + str(test_query), + ) + + def test_join_query_with_column_alias(self): + subquery = ( + Query.from_(self.table_efg) + .select( + self.table_efg.base_id.as_("x"), + self.table_efg.fizz, + self.table_efg.buzz, + ) + .as_("subq") + ) + + test_query = ( + Query.from_(self.table_abc) + .join(subquery) + .on(subquery.x == self.table_abc.id) + .select(self.table_abc.foo, subquery.fizz, subquery.buzz) + ) + + self.assertEqual( + 'SELECT "abc"."foo","subq"."fizz","subq"."buzz" ' + 'FROM "abc" JOIN (' + 'SELECT "base_id" "x","fizz","buzz" FROM "efg"' + ') "subq" ' + 'ON "subq"."x"="abc"."id"', + str(test_query), + ) + + def test_join_query_with_table_alias(self): + xxx = self.table_efg.as_("xxx") + subquery = Query.from_(xxx).select(xxx.base_id, xxx.fizz, xxx.buzz).as_("subq") + + test_query = ( + Query.from_(self.table_abc) + .join(subquery) + .on(subquery.x == self.table_abc.id) + .select(self.table_abc.foo, subquery.fizz, subquery.buzz) + ) + + self.assertEqual( + 'SELECT "abc"."foo","subq"."fizz","subq"."buzz" ' + 'FROM "abc" JOIN (' + 'SELECT "xxx"."base_id","xxx"."fizz","xxx"."buzz" FROM "efg" "xxx"' + ') "subq" ' + 'ON "subq"."x"="abc"."id"', + str(test_query), + ) + + def test_join_query_with_setoperation(self): + subquery = Query.from_(self.table_abc).select("*").union(Query.from_(self.table_abc).select("*")).as_("subq") + + test_query = ( + Query.from_(self.table_abc).join(subquery).on(subquery.x == self.table_abc.id).select(self.table_abc.foo) + ) + + self.assertEqual( + 'SELECT "abc"."foo" FROM "abc" ' + 'JOIN ' + '((SELECT * FROM "abc") ' + 'UNION ' + '(SELECT * FROM "abc")) "subq" ' + 'ON "subq"."x"="abc"."id"', + str(test_query), + ) + + +class UnionTests(unittest.TestCase): + table1, table2 = Tables("abc", "efg") + + def test_union(self): + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + + self.assertEqual( + '(SELECT "foo" FROM "abc") UNION (SELECT "bar" FROM "efg")', + str(query1 + query2), + ) + self.assertEqual( + '(SELECT "foo" FROM "abc") UNION (SELECT "bar" FROM "efg")', + str(query1.union(query2)), + ) + + def test_union_multiple(self): + table3, table4 = Tables("hij", "lmn") + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + query3 = Query.from_(table3).select(table3.baz) + query4 = Query.from_(table4).select(table4.faz) + + self.assertEqual( + '(SELECT "foo" FROM "abc") UNION ' + '(SELECT "bar" FROM "efg") UNION ' + '(SELECT "baz" FROM "hij") UNION ' + '(SELECT "faz" FROM "lmn")', + str(query1 + query2 + query3 + query4), + ) + self.assertEqual( + '(SELECT "foo" FROM "abc") UNION ' + '(SELECT "bar" FROM "efg") UNION ' + '(SELECT "baz" FROM "hij") UNION ' + '(SELECT "faz" FROM "lmn")', + str(query1.union(query2).union(query3).union(query4)), + ) + + def test_union_all(self): + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + + self.assertEqual( + '(SELECT "foo" FROM "abc") UNION ALL (SELECT "bar" FROM "efg")', + str(query1 * query2), + ) + self.assertEqual( + '(SELECT "foo" FROM "abc") UNION ALL (SELECT "bar" FROM "efg")', + str(query1.union_all(query2)), + ) + + def test_union_all_multiple(self): + table3, table4 = Tables("hij", "lmn") + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + query3 = Query.from_(table3).select(table3.baz) + query4 = Query.from_(table4).select(table4.faz) + + self.assertEqual( + '(SELECT "foo" FROM "abc") UNION ALL ' + '(SELECT "bar" FROM "efg") UNION ALL ' + '(SELECT "baz" FROM "hij") UNION ALL ' + '(SELECT "faz" FROM "lmn")', + str(query1 * query2 * query3 * query4), + ) + self.assertEqual( + '(SELECT "foo" FROM "abc") UNION ALL ' + '(SELECT "bar" FROM "efg") UNION ALL ' + '(SELECT "baz" FROM "hij") UNION ALL ' + '(SELECT "faz" FROM "lmn")', + str(query1.union_all(query2).union_all(query3).union_all(query4)), + ) + + def test_union_with_order_by(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + union_query = str((query1 + query2).orderby(query1.field("a"))) + union_all_query = str((query1 * query2).orderby(query1.field("a"))) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "UNION " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "a"', + union_query, + ) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "UNION ALL " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "a"', + union_all_query, + ) + + def test_union_with_order_by_use_union_query_field(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + union_query = query1 + query2 + union_query = str(union_query.orderby(union_query.field("a"))) + union_all_query = query1 * query2 + union_all_query = str(union_all_query.orderby(union_all_query.field("a"))) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "UNION " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "a"', + union_query, + ) + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "UNION ALL " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "a"', + union_all_query, + ) + + def test_union_with_order_by_with_aliases(self): + query1 = Query.from_(self.table1.as_("a")).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2.as_("b")).select(self.table2.bar.as_("a")) + + union_all_query = str((query1 * query2).orderby(query1.field("a"))) + union_query = str((query1 + query2).orderby(query1.field("a"))) + self.assertEqual( + '(SELECT "foo" "a" FROM "abc" "a")' " UNION ALL " '(SELECT "bar" "a" FROM "efg" "b")' ' ORDER BY "a"', + union_all_query, + ) + self.assertEqual( + '(SELECT "foo" "a" FROM "abc" "a")' " UNION " '(SELECT "bar" "a" FROM "efg" "b")' ' ORDER BY "a"', + union_query, + ) + + def test_union_with_order_by_use_union_query_field_with_aliases(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + union_query = (query1 + query2).as_("x") + union_query = union_query.orderby(union_query.field("a")) + union_all_query = (query1 * query2).as_("x") + union_all_query = union_all_query.orderby(union_all_query.field("a")) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "UNION " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "x"."a"', + str(union_query), + ) + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "UNION ALL " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "x"."a"', + str(union_all_query), + ) + + def test_require_equal_number_of_fields(self): + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.fiz, self.table2.buz) + + with self.assertRaises(SetOperationException): + str(query1 + query2) + + def test_mysql_query_wraps_unioned_queries(self): + query1 = MySQLQuery.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + + self.assertEqual( + "(SELECT `foo` FROM `abc`) UNION (SELECT `bar` FROM `efg`)", + str(query1 + query2), + ) + + def test_union_as_subquery(self): + abc, efg = Tables("abc", "efg") + hij = Query.from_(abc).select(abc.t).union(Query.from_(efg).select(efg.t)) + q = Query.from_(hij).select(fn.Avg(hij.t)) + + self.assertEqual( + 'SELECT AVG("sq0"."t") FROM ((SELECT "t" FROM "abc") UNION (SELECT "t" FROM "efg")) "sq0"', + str(q), + ) + + def test_union_with_no_quote_char(self): + abc, efg = Tables("abc", "efg") + hij = Query.from_(abc).select(abc.t).union(Query.from_(efg).select(efg.t)) + q = Query.from_(hij).select(fn.Avg(hij.t)) + + self.assertEqual( + "SELECT AVG(sq0.t) FROM ((SELECT t FROM abc) UNION (SELECT t FROM efg)) sq0", + q.get_sql(quote_char=None), + ) + + +class InsertQueryJoinTests(unittest.TestCase): + def test_join_table_on_insert_query(self): + a, b, c = Tables("a", "b", "c") + q = Query.into(c).from_(a).join(b).on(a.fkey_id == b.id).where(b.foo == 1).select("a.*", "b.*") + + self.assertEqual( + 'INSERT INTO "c" ' + 'SELECT "a"."a.*","a"."b.*" ' + 'FROM "a" JOIN "b" ' + 'ON "a"."fkey_id"="b"."id" ' + 'WHERE "b"."foo"=1', + str(q), + ) + + +class UpdateQueryJoinTests(unittest.TestCase): + def test_join_table_on_update_query(self): + a, b = Tables("a", "b") + q = Query.update(a).join(b).on(a.fkey_id == b.id).where(b.foo == 1).set("adwords_batch_job_id", 1) + + self.assertEqual( + 'UPDATE "a" ' 'JOIN "b" ' 'ON "a"."fkey_id"="b"."id" ' 'SET "adwords_batch_job_id"=1 ' 'WHERE "b"."foo"=1', + str(q), + ) + + +class IntersectTests(unittest.TestCase): + table1, table2 = Tables("abc", "efg") + + def test_intersect(self): + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + + self.assertEqual( + '(SELECT "foo" FROM "abc") INTERSECT (SELECT "bar" FROM "efg")', + str(query1.intersect(query2)), + ) + + def test_intersect_multiple(self): + table3, table4 = Tables("hij", "lmn") + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + query3 = Query.from_(table3).select(table3.baz) + query4 = Query.from_(table4).select(table4.faz) + + self.assertEqual( + '(SELECT "foo" FROM "abc") INTERSECT ' + '(SELECT "bar" FROM "efg") INTERSECT ' + '(SELECT "baz" FROM "hij") INTERSECT ' + '(SELECT "faz" FROM "lmn")', + str(query1.intersect(query2).intersect(query3).intersect(query4)), + ) + + def test_intersect_with_order_by(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + intersect_query = str((query1.intersect(query2)).orderby(query1.field("a"))) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "INTERSECT " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "a"', + intersect_query, + ) + + def test_intersect_with_limit(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + intersect_query = str((query1.intersect(query2)).limit(10)) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "INTERSECT " '(SELECT "bar" "a" FROM "efg") ' 'LIMIT 10', + intersect_query, + ) + + def test_intersect_with_offset(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + intersect_query = str((query1.intersect(query2)).offset(10)) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "INTERSECT " '(SELECT "bar" "a" FROM "efg") ' 'OFFSET 10', + intersect_query, + ) + + def test_require_equal_number_of_fields_intersect(self): + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.fiz, self.table2.buz) + + with self.assertRaises(SetOperationException): + str(query1.intersect(query2)) + + def test_mysql_query_wraps_intersected_queries(self): + query1 = MySQLQuery.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + + self.assertEqual( + "(SELECT `foo` FROM `abc`) INTERSECT (SELECT `bar` FROM `efg`)", + str(query1.intersect(query2)), + ) + + def test_intersect_as_subquery(self): + abc, efg = Tables("abc", "efg") + hij = Query.from_(abc).select(abc.t).intersect(Query.from_(efg).select(efg.t)) + q = Query.from_(hij).select(fn.Avg(hij.t)) + + self.assertEqual( + 'SELECT AVG("sq0"."t") FROM ((SELECT "t" FROM "abc") INTERSECT (SELECT "t" FROM "efg")) "sq0"', + str(q), + ) + + def test_intersect_with_no_quote_char(self): + abc, efg = Tables("abc", "efg") + hij = Query.from_(abc).select(abc.t).intersect(Query.from_(efg).select(efg.t)) + q = Query.from_(hij).select(fn.Avg(hij.t)) + + self.assertEqual( + "SELECT AVG(sq0.t) FROM ((SELECT t FROM abc) INTERSECT (SELECT t FROM efg)) sq0", + q.get_sql(quote_char=None), + ) + + +class MinusTests(unittest.TestCase): + table1, table2 = Tables("abc", "efg") + + def test_minus(self): + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + + self.assertEqual('(SELECT "foo" FROM "abc") MINUS (SELECT "bar" FROM "efg")', str(query1.minus(query2))) + + self.assertEqual( + '(SELECT "foo" FROM "abc") MINUS (SELECT "bar" FROM "efg")', + str(query1 - query2), + ) + + def test_minus_multiple(self): + table3, table4 = Tables("hij", "lmn") + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + query3 = Query.from_(table3).select(table3.baz) + query4 = Query.from_(table4).select(table4.faz) + + self.assertEqual( + '(SELECT "foo" FROM "abc") MINUS ' + '(SELECT "bar" FROM "efg") MINUS ' + '(SELECT "baz" FROM "hij") MINUS ' + '(SELECT "faz" FROM "lmn")', + str(query1 - query2 - query3 - query4), + ) + + self.assertEqual( + '(SELECT "foo" FROM "abc") MINUS ' + '(SELECT "bar" FROM "efg") MINUS ' + '(SELECT "baz" FROM "hij") MINUS ' + '(SELECT "faz" FROM "lmn")', + str(query1.minus(query2).minus(query3).minus(query4)), + ) + + def test_minus_with_order_by(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + minus_query = str(query1.minus(query2).orderby(query1.field("a"))) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "MINUS " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "a"', minus_query + ) + + def test_minus_query_with_order_by_use_minus_query_field(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + minus_query = query1.minus(query2) + minus_query = str(minus_query.orderby(minus_query.field("b"))) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "MINUS " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "b"', + minus_query, + ) + + def test_require_equal_number_of_fields(self): + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.fiz, self.table2.buz) + + with self.assertRaises(SetOperationException): + str(query1.minus(query2)) + + def test_mysql_query_wraps_minus_queries(self): + query1 = MySQLQuery.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + + self.assertEqual( + "(SELECT `foo` FROM `abc`) MINUS (SELECT `bar` FROM `efg`)", + str(query1 - query2), + ) + + def test_minus_as_subquery(self): + abc, efg = Tables("abc", "efg") + hij = Query.from_(abc).select(abc.t).minus(Query.from_(efg).select(efg.t)) + q = Query.from_(hij).select(fn.Avg(hij.t)) + + self.assertEqual( + 'SELECT AVG("sq0"."t") FROM ((SELECT "t" FROM "abc") MINUS (SELECT "t" FROM "efg")) "sq0"', + str(q), + ) + + def test_minus_with_no_quote_char(self): + abc, efg = Tables("abc", "efg") + hij = Query.from_(abc).select(abc.t).minus(Query.from_(efg).select(efg.t)) + q = Query.from_(hij).select(fn.Avg(hij.t)) + + self.assertEqual( + "SELECT AVG(sq0.t) FROM ((SELECT t FROM abc) MINUS (SELECT t FROM efg)) sq0", + q.get_sql(quote_char=None), + ) + + +class ExceptOfTests(unittest.TestCase): + table1, table2 = Tables("abc", "efg") + + def test_except(self): + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + + self.assertEqual('(SELECT "foo" FROM "abc") EXCEPT (SELECT "bar" FROM "efg")', str(query1.except_of(query2))) + + def test_except_multiple(self): + table3, table4 = Tables("hij", "lmn") + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + query3 = Query.from_(table3).select(table3.baz) + query4 = Query.from_(table4).select(table4.faz) + + self.assertEqual( + '(SELECT "foo" FROM "abc") EXCEPT ' + '(SELECT "bar" FROM "efg") EXCEPT ' + '(SELECT "baz" FROM "hij") EXCEPT ' + '(SELECT "faz" FROM "lmn")', + str(query1.except_of(query2).except_of(query3).except_of(query4)), + ) + + def test_except_with_order_by(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + except_query = str(query1.except_of(query2).orderby(query1.field("a"))) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "EXCEPT " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "a"', except_query + ) + + def test_except_query_with_order_by_use_minus_query_field(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + except_query = query1.except_of(query2) + except_query = str(except_query.orderby(except_query.field("b"))) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "EXCEPT " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "b"', + except_query, + ) + + def test_require_equal_number_of_fields_except_of(self): + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.fiz, self.table2.buz) + + with self.assertRaises(SetOperationException): + str(query1.except_of(query2)) + + def test_except_as_subquery(self): + abc, efg = Tables("abc", "efg") + hij = Query.from_(abc).select(abc.t).except_of(Query.from_(efg).select(efg.t)) + q = Query.from_(hij).select(fn.Avg(hij.t)) + + self.assertEqual( + 'SELECT AVG("sq0"."t") FROM ((SELECT "t" FROM "abc") EXCEPT (SELECT "t" FROM "efg")) "sq0"', + str(q), + ) + + def test_except_with_no_quote_char(self): + abc, efg = Tables("abc", "efg") + hij = Query.from_(abc).select(abc.t).except_of(Query.from_(efg).select(efg.t)) + q = Query.from_(hij).select(fn.Avg(hij.t)) + + self.assertEqual( + "SELECT AVG(sq0.t) FROM ((SELECT t FROM abc) EXCEPT (SELECT t FROM efg)) sq0", + q.get_sql(quote_char=None), + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/test_negation.py b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/test_negation.py new file mode 100644 index 0000000000000000000000000000000000000000..9f4db83b560dbc8546ce6d384b781dfccefd319d --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/test_negation.py @@ -0,0 +1,31 @@ +import unittest + +from pypika import ( + Tables, + functions as fn, +) +from pypika.terms import ValueWrapper + + +class NegationTests(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_negate_wrapped_float(self): + q = -ValueWrapper(1.0) + + self.assertEqual("-1.0", q.get_sql()) + + def test_negate_wrapped_int(self): + q = -ValueWrapper(1) + + self.assertEqual("-1", q.get_sql()) + + def test_negate_field(self): + q = -self.table_abc.foo + + self.assertEqual('-"abc"."foo"', q.get_sql(with_namespace=True, quote_char='"')) + + def test_negate_function(self): + q = -fn.Sum(self.table_abc.foo) + + self.assertEqual('-SUM("abc"."foo")', q.get_sql(with_namespace=True, quote_char='"')) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/test_parameter.py b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/test_parameter.py new file mode 100644 index 0000000000000000000000000000000000000000..c11e9afcd9624abb0a7313306eda34ebcf4c99ba --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/test_parameter.py @@ -0,0 +1,206 @@ +import unittest +from datetime import date + +from pypika import ( + FormatParameter, + NamedParameter, + NumericParameter, + Parameter, + PyformatParameter, + QmarkParameter, + Query, + Tables, +) +from pypika.terms import ListParameter, ParameterValueWrapper + + +class ParametrizedTests(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_param_insert(self): + q = Query.into(self.table_abc).columns("a", "b", "c").insert(Parameter("?"), Parameter("?"), Parameter("?")) + + self.assertEqual('INSERT INTO "abc" ("a","b","c") VALUES (?,?,?)', q.get_sql()) + + def test_param_select_join(self): + q = ( + Query.from_(self.table_abc) + .select("*") + .where(self.table_abc.category == Parameter("%s")) + .join(self.table_efg) + .on(self.table_abc.id == self.table_efg.abc_id) + .where(self.table_efg.date >= Parameter("%s")) + .limit(10) + ) + + self.assertEqual( + 'SELECT * FROM "abc" JOIN "efg" ON "abc"."id"="efg"."abc_id" WHERE "abc"."category"=%s AND "efg"."date">=%s LIMIT 10', + q.get_sql(), + ) + + def test_param_select_subquery(self): + q = ( + Query.from_(self.table_abc) + .select("*") + .where(self.table_abc.category == Parameter("&1")) + .where( + self.table_abc.id.isin( + Query.from_(self.table_efg) + .select(self.table_efg.abc_id) + .where(self.table_efg.date >= Parameter("&2")) + ) + ) + .limit(10) + ) + + self.assertEqual( + 'SELECT * FROM "abc" WHERE "category"=&1 AND "id" IN (SELECT "abc_id" FROM "efg" WHERE "date">=&2) LIMIT 10', + q.get_sql(), + ) + + def test_join(self): + subquery = ( + Query.from_(self.table_efg) + .select(self.table_efg.fiz, self.table_efg.buz) + .where(self.table_efg.buz == Parameter(":buz")) + ) + + q = ( + Query.from_(self.table_abc) + .join(subquery) + .on(self.table_abc.bar == subquery.buz) + .select(self.table_abc.foo, subquery.fiz) + .where(self.table_abc.bar == Parameter(":bar")) + ) + + self.assertEqual( + 'SELECT "abc"."foo","sq0"."fiz" FROM "abc" JOIN (SELECT "fiz","buz" FROM "efg" WHERE "buz"=:buz)' + ' "sq0" ON "abc"."bar"="sq0"."buz" WHERE "abc"."bar"=:bar', + q.get_sql(), + ) + + def test_qmark_parameter(self): + self.assertEqual('?', QmarkParameter().get_sql()) + + def test_numeric_parameter(self): + self.assertEqual(':14', NumericParameter('14').get_sql()) + self.assertEqual(':15', NumericParameter(15).get_sql()) + + def test_named_parameter(self): + self.assertEqual(':buz', NamedParameter('buz').get_sql()) + + def test_format_parameter(self): + self.assertEqual('%s', FormatParameter().get_sql()) + + def test_pyformat_parameter(self): + self.assertEqual('%(buz)s', PyformatParameter('buz').get_sql()) + + +class ParametrizedTestsWithValues(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_param_insert(self): + q = Query.into(self.table_abc).columns("a", "b", "c").insert(1, 2.2, 'foo') + + parameter = QmarkParameter() + sql = q.get_sql(parameter=parameter) + self.assertEqual('INSERT INTO "abc" ("a","b","c") VALUES (?,?,?)', sql) + self.assertEqual([1, 2.2, 'foo'], parameter.get_parameters()) + + def test_param_select_join(self): + q = ( + Query.from_(self.table_abc) + .select("*") + .where(self.table_abc.category == 'foobar') + .join(self.table_efg) + .on(self.table_abc.id == self.table_efg.abc_id) + .where(self.table_efg.date >= date(2024, 2, 22)) + .limit(10) + ) + + parameter = FormatParameter() + sql = q.get_sql(parameter=parameter) + self.assertEqual( + 'SELECT * FROM "abc" JOIN "efg" ON "abc"."id"="efg"."abc_id" WHERE "abc"."category"=%s AND "efg"."date">=%s LIMIT 10', + sql, + ) + self.assertEqual(['foobar', '2024-02-22'], parameter.get_parameters()) + + def test_param_select_subquery(self): + q = ( + Query.from_(self.table_abc) + .select("*") + .where(self.table_abc.category == 'foobar') + .where( + self.table_abc.id.isin( + Query.from_(self.table_efg) + .select(self.table_efg.abc_id) + .where(self.table_efg.date >= date(2024, 2, 22)) + ) + ) + .limit(10) + ) + + parameter = ListParameter(placeholder=lambda idx: f'&{idx+1}') + sql = q.get_sql(parameter=parameter) + self.assertEqual( + 'SELECT * FROM "abc" WHERE "category"=&1 AND "id" IN (SELECT "abc_id" FROM "efg" WHERE "date">=&2) LIMIT 10', + sql, + ) + self.assertEqual(['foobar', '2024-02-22'], parameter.get_parameters()) + + def test_join(self): + subquery = ( + Query.from_(self.table_efg) + .select(self.table_efg.fiz, self.table_efg.buz) + .where(self.table_efg.buz == 'buz') + ) + + q = ( + Query.from_(self.table_abc) + .join(subquery) + .on(self.table_abc.bar == subquery.buz) + .select(self.table_abc.foo, subquery.fiz) + .where(self.table_abc.bar == 'bar') + ) + + parameter = NamedParameter() + sql = q.get_sql(parameter=parameter) + self.assertEqual( + 'SELECT "abc"."foo","sq0"."fiz" FROM "abc" JOIN (SELECT "fiz","buz" FROM "efg" WHERE "buz"=:param1)' + ' "sq0" ON "abc"."bar"="sq0"."buz" WHERE "abc"."bar"=:param2', + sql, + ) + self.assertEqual({'param1': 'buz', 'param2': 'bar'}, parameter.get_parameters()) + + def test_join_with_parameter_value_wrapper(self): + subquery = ( + Query.from_(self.table_efg) + .select(self.table_efg.fiz, self.table_efg.buz) + .where(self.table_efg.buz == ParameterValueWrapper(Parameter(':buz'), 'buz')) + ) + + q = ( + Query.from_(self.table_abc) + .join(subquery) + .on(self.table_abc.bar == subquery.buz) + .select(self.table_abc.foo, subquery.fiz) + .where(self.table_abc.bar == ParameterValueWrapper(NamedParameter('bar'), 'bar')) + ) + + parameter = NamedParameter() + sql = q.get_sql(parameter=parameter) + self.assertEqual( + 'SELECT "abc"."foo","sq0"."fiz" FROM "abc" JOIN (SELECT "fiz","buz" FROM "efg" WHERE "buz"=:buz)' + ' "sq0" ON "abc"."bar"="sq0"."buz" WHERE "abc"."bar"=:bar', + sql, + ) + self.assertEqual({':buz': 'buz', 'bar': 'bar'}, parameter.get_parameters()) + + def test_pyformat_parameter(self): + q = Query.into(self.table_abc).columns("a", "b", "c").insert(1, 2.2, 'foo') + + parameter = PyformatParameter() + sql = q.get_sql(parameter=parameter) + self.assertEqual('INSERT INTO "abc" ("a","b","c") VALUES (%(param1)s,%(param2)s,%(param3)s)', sql) + self.assertEqual({"param1": 1, "param2": 2.2, "param3": "foo"}, parameter.get_parameters()) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/test_pseudocolumns.py b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/test_pseudocolumns.py new file mode 100644 index 0000000000000000000000000000000000000000..6a25c70269b2ccc98ac3870ac64a43c8a32ddbe9 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/test_pseudocolumns.py @@ -0,0 +1,51 @@ +import unittest + +from pypika import Query, Table +from pypika.pseudocolumns import ( + ColumnValue, + ObjectID, + ObjectValue, + RowID, + RowNum, + SysDate, +) +from pypika.terms import PseudoColumn + + +class PseudoColumnsTest(unittest.TestCase): + @classmethod + def setUpClass(cls): + super(PseudoColumnsTest, cls).setUpClass() + cls.table1 = Table("table1") + + def test_column_value(self): + self.assertEqual("COLUMN_VALUE", ColumnValue) + + def test_object_id(self): + self.assertEqual("OBJECT_ID", ObjectID) + + def test_object_value(self): + self.assertEqual("OBJECT_VALUE", ObjectValue) + + def test_row_id(self): + self.assertEqual("ROWID", RowID) + + def test_row_num(self): + self.assertEqual("ROWNUM", RowNum) + + def test_sys_date(self): + self.assertEqual("SYSDATE", SysDate) + + def test_can_be_used_in_a_select_statement(self): + query = Query.from_(self.table1).where(self.table1.is_active == 1).select(PseudoColumn("abcde")) + + self.assertEqual(str(query), 'SELECT abcde FROM "table1" WHERE "is_active"=1') + + def test_can_be_used_in_a_where_clause(self): + query = Query.from_(self.table1).where(PseudoColumn("abcde") > 1).select(self.table1.is_active) + + self.assertEqual(str(query), 'SELECT "is_active" FROM "table1" WHERE abcde>1') + + def test_can_be_used_in_orderby(self): + query = Query.from_(self.table1).select(self.table1.abcde.as_("some_name")).orderby(PseudoColumn("some_name")) + self.assertEqual(str(query), 'SELECT "abcde" "some_name" FROM "table1" ORDER BY some_name') diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/test_query.py b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/test_query.py new file mode 100644 index 0000000000000000000000000000000000000000..ae8dc01599a6a562b591ce15391bfe9b5c87e0f9 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/test_query.py @@ -0,0 +1,242 @@ +import unittest + +from pypika import Case, Query, Tables, Tuple, functions, Field +from pypika.dialects import ( + ClickHouseQuery, + ClickHouseQueryBuilder, + MSSQLQuery, + MSSQLQueryBuilder, + MySQLLoadQueryBuilder, + MySQLQuery, + MySQLQueryBuilder, + OracleQuery, + OracleQueryBuilder, + PostgreSQLQuery, + PostgreSQLQueryBuilder, + RedShiftQueryBuilder, + RedshiftQuery, + SQLLiteQuery, + SQLLiteQueryBuilder, + SnowflakeQuery, + SnowflakeQueryBuilder, + VerticaCopyQueryBuilder, + VerticaCreateQueryBuilder, + VerticaQuery, + VerticaQueryBuilder, +) +from pypika.queries import CreateQueryBuilder, DropQueryBuilder, QueryBuilder + + +class QueryTablesTests(unittest.TestCase): + table_a, table_b, table_c, table_d = Tables("a", "b", "c", "d") + + def test_replace_table(self): + query = Query.from_(self.table_a).select(self.table_a.time) + query = query.replace_table(self.table_a, self.table_b) + + self.assertEqual('SELECT "time" FROM "b"', str(query)) + + def test_replace_only_specified_table(self): + query = Query.from_(self.table_a).select(self.table_a.time) + query = query.replace_table(self.table_b, self.table_c) + + self.assertEqual('SELECT "time" FROM "a"', str(query)) + + def test_replace_insert_table(self): + query = Query.into(self.table_a).insert(1) + query = query.replace_table(self.table_a, self.table_b) + + self.assertEqual('INSERT INTO "b" VALUES (1)', str(query)) + + def test_replace_insert_table_current_table_not_match(self): + query = Query.into(self.table_a).insert(1) + query = query.replace_table(self.table_c, self.table_b) + + self.assertEqual('INSERT INTO "a" VALUES (1)', str(query)) + + def test_replace_update_table(self): + query = Query.update(self.table_a).set("foo", "bar") + query = query.replace_table(self.table_a, self.table_b) + + self.assertEqual('UPDATE "b" SET "foo"=\'bar\'', str(query)) + + def test_replace_update_table_current_table_not_match(self): + query = Query.update(self.table_a).set("foo", "bar") + query = query.replace_table(self.table_c, self.table_b) + + self.assertEqual('UPDATE "a" SET "foo"=\'bar\'', str(query)) + + def test_replace_delete_table(self): + query = Query.from_(self.table_a).delete() + query = query.replace_table(self.table_a, self.table_b) + + self.assertEqual('DELETE FROM "b"', str(query)) + + def test_replace_join_tables(self): + query = ( + Query.from_(self.table_a) + .join(self.table_b) + .on(self.table_a.customer_id == self.table_b.id) + .join(self.table_c) + .on(self.table_b.seller_id == self.table_c.id) + .select(self.table_a.star) + ) + query = query.replace_table(self.table_a, self.table_d) + + self.assertEqual( + 'SELECT "d".* ' + 'FROM "d" ' + 'JOIN "b" ON "d"."customer_id"="b"."id" ' + 'JOIN "c" ON "b"."seller_id"="c"."id"', + str(query), + ) + + def test_replace_filter_tables(self): + query = Query.from_(self.table_a).select(self.table_a.name).where(self.table_a.name == "Mustermann") + query = query.replace_table(self.table_a, self.table_b) + + self.assertEqual('SELECT "name" FROM "b" WHERE "name"=\'Mustermann\'', str(query)) + + def test_replace_having_table(self): + query = ( + Query.from_(self.table_a) + .select(functions.Sum(self.table_a.revenue)) + .groupby(self.table_a.customer) + .having(functions.Sum(self.table_a.revenue) >= 1000) + ) + query = query.replace_table(self.table_a, self.table_b) + + self.assertEqual( + 'SELECT SUM("revenue") ' 'FROM "b" ' 'GROUP BY "customer" ' 'HAVING SUM("revenue")>=1000', + str(query), + ) + + def test_replace_case_table(self): + query = Query.from_(self.table_a).select( + Case() + .when(self.table_a.fname == "Tom", "It was Tom") + .when(self.table_a.fname == "John", "It was John") + .else_("It was someone else.") + .as_("who_was_it") + ) + query = query.replace_table(self.table_a, self.table_b) + + self.assertEqual( + "SELECT CASE " + "WHEN \"fname\"='Tom' THEN 'It was Tom' " + "WHEN \"fname\"='John' THEN 'It was John' " + "ELSE 'It was someone else.' END \"who_was_it\" " + 'FROM "b"', + str(query), + ) + + def test_replace_orderby_table(self): + query = Query.from_(self.table_a).select(self.table_a.customer).orderby(self.table_a.customer) + query = query.replace_table(self.table_a, self.table_b) + + self.assertEqual('SELECT "customer" FROM "b" ORDER BY "customer"', str(query)) + + def test_replace_tuple_table(self): + query = ( + Query.from_(self.table_a) + .select(self.table_a.cost, self.table_a.revenue) + .where((self.table_a.cost, self.table_a.revenue) == Tuple(1, 2)) + ) + + query = query.replace_table(self.table_a, self.table_b) + + # Order is reversed due to lack of right equals method + self.assertEqual( + 'SELECT "cost","revenue" FROM "b" WHERE (1,2)=("cost","revenue")', + str(query), + ) + + def test_is_joined(self): + q = Query.from_(self.table_a).join(self.table_b).on(self.table_a.foo == self.table_b.boo) + + self.assertTrue(q.is_joined(self.table_b)) + self.assertFalse(q.is_joined(self.table_c)) + + +class QueryBuilderTests(unittest.TestCase): + def test_query_builders_have_reference_to_correct_query_class(self): + with self.subTest('QueryBuilder'): + self.assertEqual(Query, QueryBuilder.QUERY_CLS) + + with self.subTest('DropQueryBuilder'): + self.assertEqual(Query, DropQueryBuilder.QUERY_CLS) + + with self.subTest('CreateQueryBuilder'): + self.assertEqual(Query, CreateQueryBuilder.QUERY_CLS) + + with self.subTest('MySQLQueryBuilder'): + self.assertEqual(MySQLQuery, MySQLQueryBuilder.QUERY_CLS) + + with self.subTest('MySQLLoadQueryBuilder'): + self.assertEqual(MySQLQuery, MySQLLoadQueryBuilder.QUERY_CLS) + + with self.subTest('VerticaQueryBuilder'): + self.assertEqual(VerticaQuery, VerticaQueryBuilder.QUERY_CLS) + + with self.subTest('VerticaCreateQueryBuilder'): + self.assertEqual(VerticaQuery, VerticaCreateQueryBuilder.QUERY_CLS) + + with self.subTest('VerticaCopyQueryBuilder'): + self.assertEqual(VerticaQuery, VerticaCopyQueryBuilder.QUERY_CLS) + + with self.subTest('PostgreSQLQueryBuilder'): + self.assertEqual(PostgreSQLQuery, PostgreSQLQueryBuilder.QUERY_CLS) + + with self.subTest('MSSQLQueryBuilder'): + self.assertEqual(MSSQLQuery, MSSQLQueryBuilder.QUERY_CLS) + + with self.subTest('SnowflakeQueryBuilder'): + self.assertEqual(SnowflakeQuery, SnowflakeQueryBuilder.QUERY_CLS) + + with self.subTest('ClickHouseQueryBuilder'): + self.assertEqual(ClickHouseQuery, ClickHouseQueryBuilder.QUERY_CLS) + + with self.subTest('RedShiftQueryBuilder'): + self.assertEqual(RedshiftQuery, RedShiftQueryBuilder.QUERY_CLS) + + with self.subTest('SQLLiteQueryBuilder'): + self.assertEqual(SQLLiteQuery, SQLLiteQueryBuilder.QUERY_CLS) + + with self.subTest('OracleQueryBuilder'): + self.assertEqual(OracleQuery, OracleQueryBuilder.QUERY_CLS) + + def test_pipe(self) -> None: + base_query = Query.from_("test") + + def select(query: QueryBuilder) -> QueryBuilder: + return query.select("test1", "test2") + + def count_group(query: QueryBuilder, *groups) -> QueryBuilder: + return query.groupby(*groups).select(*groups, functions.Count("*")) + + for func, args, kwargs, expected_str in [ + (select, [], {}, 'SELECT "test1","test2" FROM "test"'), + ( + count_group, + ["test1", "test2"], + {}, + 'SELECT "test1","test2",COUNT(*) FROM "test" GROUP BY "test1","test2"', + ), + (count_group, ["test1"], {}, 'SELECT "test1",COUNT(*) FROM "test" GROUP BY "test1"'), + ]: + result_str = str(base_query.pipe(func, *args, **kwargs)) + self.assertEqual(result_str, str(func(base_query, *args, **kwargs))) + self.assertEqual(result_str, expected_str) + + def where_clause(query: QueryBuilder, num_days: int) -> QueryBuilder: + return query.where(Field("date") > functions.Now() - num_days) + + result_str = str(base_query.pipe(select).pipe(where_clause, num_days=1)) + self.assertEqual( + result_str, + str(select(where_clause(base_query, num_days=1))), + ) + self.assertEqual( + result_str, + 'SELECT "test1","test2" FROM "test" WHERE "date">NOW()-1', + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/test_selects.py b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/test_selects.py new file mode 100644 index 0000000000000000000000000000000000000000..1ce04937492e655db362b7e2a0a6856abf22a48f --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/test_selects.py @@ -0,0 +1,1331 @@ +import unittest +from datetime import date +from enum import Enum + +from pypika import ( + AliasedQuery, + Case, + ClickHouseQuery, + EmptyCriterion, + Field as F, + Index, + MSSQLQuery, + MySQLQuery, + NullValue, + OracleQuery, + Order, + PostgreSQLQuery, + Query, + QueryException, + RedshiftQuery, + SQLLiteQuery, + Table, + Tables, + VerticaQuery, + functions as fn, + SYSTEM_TIME, +) +from pypika.terms import ValueWrapper + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + + +class SelectTests(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_empty_query(self): + q = Query.from_("abc") + + self.assertEqual("", str(q)) + + def test_select_no_from(self): + q = Query.select(1) + + self.assertEqual("SELECT 1", str(q)) + + def test_select_no_with_alias_from(self): + q = Query.select(ValueWrapper(1, "test")) + + self.assertEqual('SELECT 1 "test"', str(q)) + + def test_select_no_from_with_field_raises_exception(self): + with self.assertRaises(QueryException): + Query.select("asdf") + + def test_select__star(self): + q = Query.from_("abc").select("*") + + self.assertEqual('SELECT * FROM "abc"', str(q)) + + def test_select__table_schema(self): + q = Query.from_(Table("abc", "schema1")).select("*") + + self.assertEqual('SELECT * FROM "schema1"."abc"', str(q)) + + def test_select__table_schema_with_multiple_levels_as_tuple(self): + q = Query.from_(Table("abc", ("schema1", "schema2"))).select("*") + + self.assertEqual('SELECT * FROM "schema1"."schema2"."abc"', str(q)) + + def test_select__table_schema_with_multiple_levels_as_list(self): + q = Query.from_(Table("abc", ["schema1", "schema2"])).select("*") + + self.assertEqual('SELECT * FROM "schema1"."schema2"."abc"', str(q)) + + def test_select__star__replacement(self): + q = Query.from_("abc").select("foo").select("*") + + self.assertEqual('SELECT * FROM "abc"', str(q)) + + def test_select__distinct__single(self): + q = Query.from_("abc").select("foo").distinct() + + self.assertEqual('SELECT DISTINCT "foo" FROM "abc"', str(q)) + + def test_select__distinct__multi(self): + q = Query.from_("abc").select("foo", "bar").distinct() + + self.assertEqual('SELECT DISTINCT "foo","bar" FROM "abc"', str(q)) + + def test_select__column__single__str(self): + q = Query.from_("abc").select("foo") + + self.assertEqual('SELECT "foo" FROM "abc"', str(q)) + + def test_select__column__single__alias__str(self): + q = Query.from_(self.table_abc).select(self.table_abc.foo.as_("bar")) + + self.assertEqual('SELECT "foo" "bar" FROM "abc"', str(q)) + + def test_select__column__single__table_alias__str(self): + q = Query.from_(self.table_abc.as_("fizzbuzz")).select(self.table_abc.foo.as_("bar")) + + self.assertEqual('SELECT "foo" "bar" FROM "abc" "fizzbuzz"', str(q)) + + def test_select__column__single__field(self): + t = Table("abc") + q = Query.from_(t).select(t.foo) + + self.assertEqual('SELECT "foo" FROM "abc"', str(q)) + + def test_select__columns__multi__str(self): + q1 = Query.from_("abc").select("foo", "bar") + q2 = Query.from_("abc").select("foo").select("bar") + + self.assertEqual('SELECT "foo","bar" FROM "abc"', str(q1)) + self.assertEqual('SELECT "foo","bar" FROM "abc"', str(q2)) + + def test_select__columns__multi__field(self): + q1 = Query.from_(self.table_abc).select(self.table_abc.foo, self.table_abc.bar) + q2 = Query.from_(self.table_abc).select(self.table_abc.foo).select(self.table_abc.bar) + + self.assertEqual('SELECT "foo","bar" FROM "abc"', str(q1)) + self.assertEqual('SELECT "foo","bar" FROM "abc"', str(q2)) + + def test_select__multiple_tables(self): + q = Query.from_(self.table_abc).select(self.table_abc.foo).from_(self.table_efg).select(self.table_efg.bar) + + self.assertEqual('SELECT "abc"."foo","efg"."bar" FROM "abc","efg"', str(q)) + + def test_select__subquery(self): + subquery = Query.from_(self.table_abc).select("*") + q = Query.from_(subquery).select(subquery.foo, subquery.bar) + + self.assertEqual('SELECT "sq0"."foo","sq0"."bar" ' 'FROM (SELECT * FROM "abc") "sq0"', str(q)) + + def test_select__multiple_subqueries(self): + subquery0 = Query.from_(self.table_abc).select("foo") + subquery1 = Query.from_(self.table_efg).select("bar") + q = Query.from_(subquery0).from_(subquery1).select(subquery0.foo, subquery1.bar) + + self.assertEqual( + 'SELECT "sq0"."foo","sq1"."bar" ' 'FROM (SELECT "foo" FROM "abc") "sq0",' '(SELECT "bar" FROM "efg") "sq1"', + str(q), + ) + + def test_select__nested_subquery(self): + subquery0 = Query.from_(self.table_abc).select("*") + subquery1 = Query.from_(subquery0).select(subquery0.foo, subquery0.bar) + subquery2 = Query.from_(subquery1).select(subquery1.foo) + + q = Query.from_(subquery2).select(subquery2.foo) + + self.assertEqual( + 'SELECT "sq2"."foo" ' + 'FROM (SELECT "sq1"."foo" ' + 'FROM (SELECT "sq0"."foo","sq0"."bar" ' + 'FROM (SELECT * FROM "abc") "sq0") "sq1") "sq2"', + str(q), + ) + + def test_select__no_table(self): + q = Query.select(1, 2, 3) + + self.assertEqual("SELECT 1,2,3", str(q)) + + def test_select_then_add_table(self): + q = Query.select(1).select(2, 3).from_("abc").select("foo") + + self.assertEqual('SELECT 1,2,3,"foo" FROM "abc"', str(q)) + + def test_select_with_limit(self): + q1 = Query.from_("abc").select("foo")[:10] + + self.assertEqual('SELECT "foo" FROM "abc" LIMIT 10', str(q1)) + + def test_select_with_limit_zero(self): + with self.subTest('using python slice'): + q1 = Query.from_("abc").select("foo")[:0] + self.assertEqual('SELECT "foo" FROM "abc" LIMIT 0', str(q1)) + + with self.subTest('using limit method'): + q2 = Query.from_("abc").select("foo").limit(0) + self.assertEqual('SELECT "foo" FROM "abc" LIMIT 0', str(q2)) + + def test_select_with_limit__func(self): + q1 = Query.from_("abc").select("foo").limit(10) + + self.assertEqual('SELECT "foo" FROM "abc" LIMIT 10', str(q1)) + + def test_select_with_offset(self): + q1 = Query.from_("abc").select("foo")[10:] + + self.assertEqual('SELECT "foo" FROM "abc" OFFSET 10', str(q1)) + + def test_select_with_offset__func(self): + q1 = Query.from_("abc").select("foo").offset(10) + + self.assertEqual('SELECT "foo" FROM "abc" OFFSET 10', str(q1)) + + def test_select_with_limit_and_offset(self): + q1 = Query.from_("abc").select("foo")[10:10] + + self.assertEqual('SELECT "foo" FROM "abc" LIMIT 10 OFFSET 10', str(q1)) + + def test_select_with_force_index(self): + q = Query.from_("abc").select("foo").force_index("egg") + + self.assertEqual('SELECT "foo" FROM "abc" FORCE INDEX ("egg")', str(q)) + + def test_select_with_force_index_with_index_object(self): + index = Index("egg") + q = Query.from_("abc").select("foo").force_index(index) + + self.assertEqual('SELECT "foo" FROM "abc" FORCE INDEX ("egg")', str(q)) + + def test_select_with_force_index_multiple_indexes(self): + q = Query.from_("abc").select("foo").force_index("egg", "bacon") + + self.assertEqual('SELECT "foo" FROM "abc" FORCE INDEX ("egg","bacon")', str(q)) + + def test_select_with_force_index_multiple_calls(self): + q = ( + Query.from_("abc") + .select("foo") + .force_index( + "egg", + ) + .force_index("spam") + ) + + self.assertEqual('SELECT "foo" FROM "abc" FORCE INDEX ("egg","spam")', str(q)) + + def test_select_with_use_index(self): + q = Query.from_("abc").select("foo").use_index("egg") + + self.assertEqual('SELECT "foo" FROM "abc" USE INDEX ("egg")', str(q)) + + def test_select_with_use_index_with_index_object(self): + index = Index("egg") + q = Query.from_("abc").select("foo").use_index(index) + + self.assertEqual('SELECT "foo" FROM "abc" USE INDEX ("egg")', str(q)) + + def test_select_with_use_index_multiple_indexes(self): + q = Query.from_("abc").select("foo").use_index("egg", "bacon") + + self.assertEqual('SELECT "foo" FROM "abc" USE INDEX ("egg","bacon")', str(q)) + + def test_select_with_use_index_multiple_calls(self): + q = ( + Query.from_("abc") + .select("foo") + .use_index( + "egg", + ) + .use_index("spam") + ) + + self.assertEqual('SELECT "foo" FROM "abc" USE INDEX ("egg","spam")', str(q)) + + def test_mysql_query_uses_backtick_quote_chars(self): + q = MySQLQuery.from_("abc").select("foo", "bar") + + self.assertEqual("SELECT `foo`,`bar` FROM `abc`", str(q)) + + def test_vertica_query_uses_double_quote_chars(self): + q = VerticaQuery.from_("abc").select("foo", "bar") + + self.assertEqual('SELECT "foo","bar" FROM "abc"', str(q)) + + def test_mssql_query_uses_double_quote_chars(self): + q = MSSQLQuery.from_("abc").select("foo", "bar") + + self.assertEqual('SELECT "foo","bar" FROM "abc"', str(q)) + + def test_oracle_query_uses_no_quote_chars(self): + q = OracleQuery.from_("abc").select("foo", "bar") + + self.assertEqual('SELECT foo,bar FROM abc', str(q)) + + def test_postgresql_query_uses_double_quote_chars(self): + q = PostgreSQLQuery.from_("abc").select("foo", "bar") + + self.assertEqual('SELECT "foo","bar" FROM "abc"', str(q)) + + def test_redshift_query_uses_double_quote_chars(self): + q = RedshiftQuery.from_("abc").select("foo", "bar") + + self.assertEqual('SELECT "foo","bar" FROM "abc"', str(q)) + + def test_table_select_alias(self): + q = self.table_abc.select(1) + + self.assertEqual('SELECT 1 FROM "abc"', str(q)) + self.assertEqual(q, Query.from_("abc").select(1)) + + def test_table_select_alias_with_offset_and_limit(self): + self.assertEqual(self.table_abc.select("foo")[10:10], Query.from_("abc").select("foo")[10:10]) + self.assertEqual( + self.table_abc.select(self.table_abc.foo)[10:10], + Query.from_("abc").select("foo")[10:10], + ) + + def test_temporal_select(self): + t = Table("abc") + + with self.subTest("with system time as of"): + q = Query.from_(t.for_(SYSTEM_TIME.as_of('2020-01-01'))).select("*") + + self.assertEqual('SELECT * FROM "abc" FOR SYSTEM_TIME AS OF \'2020-01-01\'', str(q)) + + with self.subTest("with system time between"): + q = Query.from_(t.for_(SYSTEM_TIME.between('2020-01-01', '2020-02-01'))).select("*") + + self.assertEqual('SELECT * FROM "abc" FOR SYSTEM_TIME BETWEEN \'2020-01-01\' AND \'2020-02-01\'', str(q)) + + with self.subTest("with system time from to"): + q = Query.from_(t.for_(SYSTEM_TIME.from_to('2020-01-01', '2020-02-01'))).select("*") + + self.assertEqual('SELECT * FROM "abc" FOR SYSTEM_TIME FROM \'2020-01-01\' TO \'2020-02-01\'', str(q)) + + with self.subTest("with ALL"): + q = Query.from_(t.for_(SYSTEM_TIME.all_())).select("*") + + self.assertEqual('SELECT * FROM "abc" FOR SYSTEM_TIME ALL', str(q)) + + with self.subTest("with period between"): + q = Query.from_(t.for_(t.valid_period.between('2020-01-01', '2020-02-01'))).select("*") + + self.assertEqual('SELECT * FROM "abc" FOR "valid_period" BETWEEN \'2020-01-01\' AND \'2020-02-01\'', str(q)) + + with self.subTest("with period from to"): + q = Query.from_(t.for_(t.valid_period.from_to('2020-01-01', '2020-02-01'))).select("*") + + self.assertEqual('SELECT * FROM "abc" FOR "valid_period" FROM \'2020-01-01\' TO \'2020-02-01\'', str(q)) + + with self.subTest("with ALL"): + q = Query.from_(t.for_(t.valid_period.all_())).select("*") + + self.assertEqual('SELECT * FROM "abc" FOR "valid_period" ALL', str(q)) + + +class MyEnum(Enum): + STR = "foo" + INT = 0 + BOOL = True + DATE = date(2020, 2, 2) + NONE = None + + +class WhereTests(unittest.TestCase): + t = Table("abc") + t2 = Table("cba") + + def test_where_enum(self): + q1 = Query.from_(self.t).select("*").where(self.t.foo == MyEnum.STR) + q2 = Query.from_(self.t).select("*").where(self.t.foo == MyEnum.INT) + q3 = Query.from_(self.t).select("*").where(self.t.foo == MyEnum.BOOL) + q4 = Query.from_(self.t).select("*").where(self.t.foo == MyEnum.DATE) + q5 = Query.from_(self.t).select("*").where(self.t.foo == MyEnum.NONE) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo"=\'foo\'', str(q1)) + self.assertEqual('SELECT * FROM "abc" WHERE "foo"=0', str(q2)) + self.assertEqual('SELECT * FROM "abc" WHERE "foo"=true', str(q3)) + self.assertEqual('SELECT * FROM "abc" WHERE "foo"=\'2020-02-02\'', str(q4)) + self.assertEqual('SELECT * FROM "abc" WHERE "foo"=null', str(q5)) + + def test_where_field_equals(self): + q1 = Query.from_(self.t).select("*").where(self.t.foo == self.t.bar) + q2 = Query.from_(self.t).select("*").where(self.t.foo.eq(self.t.bar)) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo"="bar"', str(q1)) + self.assertEqual('SELECT * FROM "abc" WHERE "foo"="bar"', str(q2)) + q = self.t.select("*").where(self.t.foo == self.t.bar) + self.assertEqual(q, q1) + + def test_where_field_equals_for_update(self): + q = Query.from_(self.t).select("*").where(self.t.foo == self.t.bar).for_update() + self.assertEqual('SELECT * FROM "abc" WHERE "foo"="bar" FOR UPDATE', str(q)) + + def test_where_field_equals_for_update_nowait(self): + for query_cls in [ + MySQLQuery, + PostgreSQLQuery, + ]: + quote_char = query_cls._builder().QUOTE_CHAR if isinstance(query_cls._builder().QUOTE_CHAR, str) else '"' + q = query_cls.from_(self.t).select("*").where(self.t.foo == self.t.bar).for_update(nowait=True) + self.assertEqual( + 'SELECT * ' + 'FROM {quote_char}abc{quote_char} ' + 'WHERE {quote_char}foo{quote_char}={quote_char}bar{quote_char} ' + 'FOR UPDATE NOWAIT'.format( + quote_char=quote_char, + ), + str(q), + ) + + def test_where_field_equals_for_update_skip_locked(self): + for query_cls in [ + MySQLQuery, + PostgreSQLQuery, + ]: + quote_char = query_cls._builder().QUOTE_CHAR if isinstance(query_cls._builder().QUOTE_CHAR, str) else '"' + q = query_cls.from_(self.t).select("*").where(self.t.foo == self.t.bar).for_update(skip_locked=True) + self.assertEqual( + 'SELECT * ' + 'FROM {quote_char}abc{quote_char} ' + 'WHERE {quote_char}foo{quote_char}={quote_char}bar{quote_char} ' + 'FOR UPDATE SKIP LOCKED'.format( + quote_char=quote_char, + ), + str(q), + ) + + def test_where_field_equals_for_update_of(self): + for query_cls in [ + MySQLQuery, + PostgreSQLQuery, + ]: + quote_char = query_cls._builder().QUOTE_CHAR if isinstance(query_cls._builder().QUOTE_CHAR, str) else '"' + q = query_cls.from_(self.t).select("*").where(self.t.foo == self.t.bar).for_update(of=("abc",)) + self.assertEqual( + 'SELECT * ' + 'FROM {quote_char}abc{quote_char} ' + 'WHERE {quote_char}foo{quote_char}={quote_char}bar{quote_char} ' + 'FOR UPDATE OF {quote_char}abc{quote_char}'.format( + quote_char=quote_char, + ), + str(q), + ) + + def test_where_field_equals_for_update_of_multiple_tables(self): + for query_cls in [ + MySQLQuery, + PostgreSQLQuery, + ]: + q = ( + query_cls.from_(self.t) + .join(self.t2) + .on(self.t.id == self.t2.abc_id) + .select("*") + .where(self.t.foo == self.t.bar) + .for_update(of=("abc", "cba")) + ) + quote_char = query_cls._builder().QUOTE_CHAR if isinstance(query_cls._builder().QUOTE_CHAR, str) else '"' + self.assertIn( + str(q), + [ + 'SELECT * ' + 'FROM {quote_char}abc{quote_char} ' + 'JOIN {quote_char}cba{quote_char} ' + 'ON {quote_char}abc{quote_char}.{quote_char}id{quote_char}=' + '{quote_char}cba{quote_char}.{quote_char}abc_id{quote_char} ' + 'WHERE {quote_char}abc{quote_char}.{quote_char}foo{quote_char}=' + '{quote_char}abc{quote_char}.{quote_char}bar{quote_char} ' + 'FOR UPDATE OF {quote_char}cba{quote_char}, {quote_char}abc{quote_char}'.format( + quote_char=quote_char, + ), + 'SELECT * ' + 'FROM {quote_char}abc{quote_char} ' + 'JOIN {quote_char}cba{quote_char} ' + 'ON {quote_char}abc{quote_char}.{quote_char}id{quote_char}=' + '{quote_char}cba{quote_char}.{quote_char}abc_id{quote_char} ' + 'WHERE {quote_char}abc{quote_char}.{quote_char}foo{quote_char}=' + '{quote_char}abc{quote_char}.{quote_char}bar{quote_char} ' + 'FOR UPDATE OF {quote_char}abc{quote_char}, {quote_char}cba{quote_char}'.format( + quote_char=quote_char, + ), + ], + ) + + def test_where_field_equals_for_update_of_nowait(self): + for query_cls in [ + MySQLQuery, + PostgreSQLQuery, + ]: + q = query_cls.from_(self.t).select("*").where(self.t.foo == self.t.bar).for_update(of=("abc",), nowait=True) + quote_char = query_cls._builder().QUOTE_CHAR if isinstance(query_cls._builder().QUOTE_CHAR, str) else '"' + self.assertEqual( + 'SELECT * ' + 'FROM {quote_char}abc{quote_char} ' + 'WHERE {quote_char}foo{quote_char}={quote_char}bar{quote_char} ' + 'FOR UPDATE OF {quote_char}abc{quote_char} NOWAIT'.format( + quote_char=quote_char, + ), + str(q), + ) + + def test_where_field_equals_for_update_of_skip_locked(self): + for query_cls in [ + MySQLQuery, + PostgreSQLQuery, + ]: + q = ( + query_cls.from_(self.t) + .select("*") + .where(self.t.foo == self.t.bar) + .for_update(of=("abc",), skip_locked=True) + ) + quote_char = query_cls._builder().QUOTE_CHAR if isinstance(query_cls._builder().QUOTE_CHAR, str) else '"' + self.assertEqual( + 'SELECT * ' + 'FROM {quote_char}abc{quote_char} ' + 'WHERE {quote_char}foo{quote_char}={quote_char}bar{quote_char} ' + 'FOR UPDATE OF {quote_char}abc{quote_char} SKIP LOCKED'.format( + quote_char=quote_char, + ), + str(q), + ) + + def test_where_field_equals_for_update_skip_locked_and_of(self): + for query_cls in [ + MySQLQuery, + PostgreSQLQuery, + ]: + q = ( + query_cls.from_(self.t) + .select("*") + .where(self.t.foo == self.t.bar) + .for_update(nowait=False, skip_locked=True, of=("abc",)) + ) + quote_char = query_cls._builder().QUOTE_CHAR if isinstance(query_cls._builder().QUOTE_CHAR, str) else '"' + self.assertEqual( + 'SELECT * ' + 'FROM {quote_char}abc{quote_char} ' + 'WHERE {quote_char}foo{quote_char}={quote_char}bar{quote_char} ' + 'FOR UPDATE OF {quote_char}abc{quote_char} SKIP LOCKED'.format( + quote_char=quote_char, + ), + str(q), + ) + + def test_where_field_equals_where(self): + q = Query.from_(self.t).select("*").where(self.t.foo == 1).where(self.t.bar == self.t.baz) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo"=1 AND "bar"="baz"', str(q)) + + def test_where_field_equals_where_not(self): + q = Query.from_(self.t).select("*").where((self.t.foo == 1).negate()).where(self.t.bar == self.t.baz) + + self.assertEqual('SELECT * FROM "abc" WHERE NOT "foo"=1 AND "bar"="baz"', str(q)) + + def test_where_field_equals_where_two_not(self): + q = Query.from_(self.t).select("*").where((self.t.foo == 1).negate()).where((self.t.bar == self.t.baz).negate()) + + self.assertEqual('SELECT * FROM "abc" WHERE NOT "foo"=1 AND NOT "bar"="baz"', str(q)) + + def test_where_single_quote(self): + q1 = Query.from_(self.t).select("*").where(self.t.foo == "bar'foo") + + self.assertEqual("SELECT * FROM \"abc\" WHERE \"foo\"='bar''foo'", str(q1)) + + def test_where_field_equals_and(self): + q = Query.from_(self.t).select("*").where((self.t.foo == 1) & (self.t.bar == self.t.baz)) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo"=1 AND "bar"="baz"', str(q)) + + def test_where_field_equals_or(self): + q = Query.from_(self.t).select("*").where((self.t.foo == 1) | (self.t.bar == self.t.baz)) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo"=1 OR "bar"="baz"', str(q)) + + def test_where_nested_conditions(self): + q = Query.from_(self.t).select("*").where((self.t.foo == 1) | (self.t.bar == self.t.baz)).where(self.t.baz == 0) + + self.assertEqual('SELECT * FROM "abc" WHERE ("foo"=1 OR "bar"="baz") AND "baz"=0', str(q)) + + def test_where_field_starts_with(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.like("ab%")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" LIKE \'ab%\'', str(q)) + + def test_where_field_contains(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.like("%fg%")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" LIKE \'%fg%\'', str(q)) + + def test_where_field_ends_with(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.like("%yz")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" LIKE \'%yz\'', str(q)) + + def test_where_field_is_n_chars_long(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.like("___")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" LIKE \'___\'', str(q)) + + def test_where_field_does_not_start_with(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.not_like("ab%")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" NOT LIKE \'ab%\'', str(q)) + + def test_where_field_does_not_contain(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.not_like("%fg%")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" NOT LIKE \'%fg%\'', str(q)) + + def test_where_field_does_not_end_with(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.not_like("%yz")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" NOT LIKE \'%yz\'', str(q)) + + def test_where_field_is_not_n_chars_long(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.not_like("___")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" NOT LIKE \'___\'', str(q)) + + def test_where_field_matches_regex(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.regex(r"^b")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" REGEX \'^b\'', str(q)) + + def test_where_field_matches_regexp(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.regexp(r"^b")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" REGEXP \'^b\'', str(q)) + + def test_where_field_matches_rlike(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.rlike(r"^b")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" RLIKE \'^b\'', str(q)) + + def test_ignore_empty_criterion_where(self): + q1 = Query.from_(self.t).select("*").where(EmptyCriterion()) + + self.assertEqual('SELECT * FROM "abc"', str(q1)) + + def test_ignore_empty_criterion_having(self): + q1 = Query.from_(self.t).select("*").having(EmptyCriterion()) + + self.assertEqual('SELECT * FROM "abc"', str(q1)) + + def test_select_with_force_index_and_where(self): + q = Query.from_("abc").select("foo").where(self.t.foo == self.t.bar).force_index("egg") + + self.assertEqual('SELECT "foo" FROM "abc" FORCE INDEX ("egg") WHERE "foo"="bar"', str(q)) + + def test_where_with_multiple_wheres_using_and_case(self): + case_stmt = Case().when(self.t.foo == 'bar', 1).else_(0) + query = Query.from_(self.t).select(case_stmt).where(case_stmt & self.t.blah.isin(['test'])) + + self.assertEqual( + 'SELECT CASE WHEN "foo"=\'bar\' THEN 1 ELSE 0 END FROM "abc" WHERE CASE WHEN "foo"=\'bar\' THEN 1 ELSE 0 ' + 'END AND "blah" IN (\'test\')', + str(query), + ) + + def test_where_with_multiple_wheres_using_or_case(self): + case_stmt = Case().when(self.t.foo == 'bar', 1).else_(0) + query = Query.from_(self.t).select(case_stmt).where(case_stmt | self.t.blah.isin(['test'])) + + self.assertEqual( + 'SELECT CASE WHEN "foo"=\'bar\' THEN 1 ELSE 0 END FROM "abc" WHERE CASE WHEN "foo"=\'bar\' THEN 1 ELSE 0 ' + 'END OR "blah" IN (\'test\')', + str(query), + ) + + +class PreWhereTests(WhereTests): + t = Table("abc") + + def test_prewhere_field_equals(self): + q1 = Query.from_(self.t).select("*").prewhere(self.t.foo == self.t.bar) + q2 = Query.from_(self.t).select("*").prewhere(self.t.foo.eq(self.t.bar)) + + self.assertEqual('SELECT * FROM "abc" PREWHERE "foo"="bar"', str(q1)) + self.assertEqual('SELECT * FROM "abc" PREWHERE "foo"="bar"', str(q2)) + + def test_where_and_prewhere(self): + q = Query.from_(self.t).select("*").prewhere(self.t.foo == self.t.bar).where(self.t.foo == self.t.bar) + + self.assertEqual('SELECT * FROM "abc" PREWHERE "foo"="bar" WHERE "foo"="bar"', str(q)) + + +class GroupByTests(unittest.TestCase): + t = Table("abc") + maxDiff = None + + def test_groupby__single(self): + q = Query.from_(self.t).groupby(self.t.foo).select(self.t.foo) + + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo"', str(q)) + + def test_groupby__multi(self): + q = Query.from_(self.t).groupby(self.t.foo, self.t.bar).select(self.t.foo, self.t.bar) + + self.assertEqual('SELECT "foo","bar" FROM "abc" GROUP BY "foo","bar"', str(q)) + + def test_groupby__count_star(self): + q = Query.from_(self.t).groupby(self.t.foo).select(self.t.foo, fn.Count("*")) + + self.assertEqual('SELECT "foo",COUNT(*) FROM "abc" GROUP BY "foo"', str(q)) + + def test_groupby__count_field(self): + q = Query.from_(self.t).groupby(self.t.foo).select(self.t.foo, fn.Count(self.t.bar)) + + self.assertEqual('SELECT "foo",COUNT("bar") FROM "abc" GROUP BY "foo"', str(q)) + + def test_groupby__count_distinct(self): + q = Query.from_(self.t).groupby(self.t.foo).select(self.t.foo, fn.Count("*").distinct()) + + self.assertEqual('SELECT "foo",COUNT(DISTINCT *) FROM "abc" GROUP BY "foo"', str(q)) + + def test_groupby__sum_distinct(self): + q = Query.from_(self.t).groupby(self.t.foo).select(self.t.foo, fn.Sum(self.t.bar).distinct()) + + self.assertEqual('SELECT "foo",SUM(DISTINCT "bar") FROM "abc" GROUP BY "foo"', str(q)) + + def test_groupby__sum_filter(self): + q = ( + Query.from_(self.t) + .groupby(self.t.foo) + .select(self.t.foo, fn.Sum(self.t.bar).filter(self.t.id.eq(1) & self.t.cid.gt(2))) + ) + + self.assertEqual('SELECT "foo",SUM("bar") FILTER(WHERE "id"=1 AND "cid">2) FROM "abc" GROUP BY "foo"', str(q)) + + def test_groupby__str(self): + q = Query.from_("abc").groupby("foo").select("foo", fn.Count("*").distinct()) + + self.assertEqual('SELECT "foo",COUNT(DISTINCT *) FROM "abc" GROUP BY "foo"', str(q)) + + def test_groupby__int(self): + q = Query.from_("abc").groupby(1).select("foo", fn.Count("*").distinct()) + + self.assertEqual('SELECT "foo",COUNT(DISTINCT *) FROM "abc" GROUP BY 1', str(q)) + + def test_groupby__alias(self): + bar = self.t.bar.as_("bar01") + q = Query.from_(self.t).select(fn.Sum(self.t.foo), bar).groupby(bar) + + self.assertEqual('SELECT SUM("foo"),"bar" "bar01" FROM "abc" GROUP BY "bar01"', str(q)) + + def test_groupby__no_alias(self): + bar = self.t.bar.as_("bar01") + q = Query.from_(self.t).select(fn.Sum(self.t.foo), bar).groupby(bar) + + self.assertEqual( + 'SELECT SUM("foo"),"bar" "bar01" FROM "abc" GROUP BY "bar"', + q.get_sql(groupby_alias=False), + ) + + def test_groupby__no_alias_mssql(self): + bar = self.t.bar.as_("bar01") + q = MSSQLQuery.from_(self.t).select(fn.Sum(self.t.foo), bar).groupby(bar) + + self.assertEqual('SELECT SUM("foo"),"bar" "bar01" FROM "abc" GROUP BY "bar"', str(q)) + + def test_groupby__no_alias_oracle(self): + bar = self.t.bar.as_("bar01") + q = OracleQuery.from_(self.t).select(fn.Sum(self.t.foo), bar).groupby(bar) + + self.assertEqual('SELECT SUM(foo),bar bar01 FROM abc GROUP BY bar', str(q)) + + def test_groupby__alias_platforms(self): + bar = self.t.bar.as_("bar01") + + for query_cls in [ + MySQLQuery, + VerticaQuery, + PostgreSQLQuery, + RedshiftQuery, + ClickHouseQuery, + SQLLiteQuery, + ]: + q = query_cls.from_(self.t).select(fn.Sum(self.t.foo), bar).groupby(bar) + + quote_char = query_cls._builder().QUOTE_CHAR if isinstance(query_cls._builder().QUOTE_CHAR, str) else '"' + + self.assertEqual( + "SELECT " + "SUM({quote_char}foo{quote_char})," + "{quote_char}bar{quote_char}{as_keyword}{quote_char}bar01{quote_char} " + "FROM {quote_char}abc{quote_char} " + "GROUP BY {quote_char}bar01{quote_char}".format( + as_keyword=' AS ' if query_cls is ClickHouseQuery else ' ', quote_char=quote_char + ), + str(q), + ) + + def test_groupby__alias_with_join(self): + table1 = Table("table1", alias="t1") + bar = table1.bar.as_("bar01") + q = Query.from_(self.t).join(table1).on(self.t.id == table1.t_ref).select(fn.Sum(self.t.foo), bar).groupby(bar) + + self.assertEqual( + 'SELECT SUM("abc"."foo"),"t1"."bar" "bar01" FROM "abc" ' + 'JOIN "table1" "t1" ON "abc"."id"="t1"."t_ref" ' + 'GROUP BY "bar01"', + str(q), + ) + + def test_groupby_with_case_uses_the_alias(self): + q = ( + Query.from_(self.t) + .select( + fn.Sum(self.t.foo).as_("bar"), + Case().when(self.t.fname == "Tom", "It was Tom").else_("It was someone else.").as_("who_was_it"), + ) + .groupby(Case().when(self.t.fname == "Tom", "It was Tom").else_("It was someone else.").as_("who_was_it")) + ) + + self.assertEqual( + 'SELECT SUM("foo") "bar",' + "CASE WHEN \"fname\"='Tom' THEN 'It was Tom' " + "ELSE 'It was someone else.' END \"who_was_it\" " + 'FROM "abc" ' + 'GROUP BY "who_was_it"', + str(q), + ) + + def test_mysql_query_uses_backtick_quote_chars(self): + q = MySQLQuery.from_(self.t).groupby(self.t.foo).select(self.t.foo) + + self.assertEqual("SELECT `foo` FROM `abc` GROUP BY `foo`", str(q)) + + def test_vertica_query_uses_double_quote_chars(self): + q = VerticaQuery.from_(self.t).groupby(self.t.foo).select(self.t.foo) + + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo"', str(q)) + + def test_mssql_query_uses_double_quote_chars(self): + q = MSSQLQuery.from_(self.t).groupby(self.t.foo).select(self.t.foo) + + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo"', str(q)) + + def test_oracle_query_uses_no_quote_chars(self): + q = OracleQuery.from_(self.t).groupby(self.t.foo).select(self.t.foo) + + self.assertEqual('SELECT foo FROM abc GROUP BY foo', str(q)) + + def test_postgres_query_uses_double_quote_chars(self): + q = PostgreSQLQuery.from_(self.t).groupby(self.t.foo).select(self.t.foo) + + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo"', str(q)) + + def test_redshift_query_uses_double_quote_chars(self): + q = RedshiftQuery.from_(self.t).groupby(self.t.foo).select(self.t.foo) + + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo"', str(q)) + + def test_group_by__single_with_totals(self): + q = Query.from_(self.t).groupby(self.t.foo).select(self.t.foo).with_totals() + + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo" WITH TOTALS', str(q)) + + def test_groupby__multi_with_totals(self): + q = Query.from_(self.t).groupby(self.t.foo, self.t.bar).select(self.t.foo, self.t.bar).with_totals() + + self.assertEqual('SELECT "foo","bar" FROM "abc" GROUP BY "foo","bar" WITH TOTALS', str(q)) + + +class HavingTests(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_having_greater_than(self): + q = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, fn.Sum(self.table_abc.bar)) + .groupby(self.table_abc.foo) + .having(fn.Sum(self.table_abc.bar) > 1) + ) + + self.assertEqual( + 'SELECT "foo",SUM("bar") FROM "abc" GROUP BY "foo" HAVING SUM("bar")>1', + str(q), + ) + + def test_having_and(self): + q = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, fn.Sum(self.table_abc.bar)) + .groupby(self.table_abc.foo) + .having((fn.Sum(self.table_abc.bar) > 1) & (fn.Sum(self.table_abc.bar) < 100)) + ) + + self.assertEqual( + 'SELECT "foo",SUM("bar") FROM "abc" GROUP BY "foo" HAVING SUM("bar")>1 AND SUM("bar")<100', + str(q), + ) + + def test_having_join_and_equality(self): + q = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.foo) + .select(self.table_abc.foo, fn.Sum(self.table_efg.bar), self.table_abc.buz) + .groupby(self.table_abc.foo) + .having(self.table_abc.buz == "fiz") + .having(fn.Sum(self.table_efg.bar) > 100) + ) + + self.assertEqual( + 'SELECT "abc"."foo",SUM("efg"."bar"),"abc"."buz" FROM "abc" ' + 'JOIN "efg" ON "abc"."foo"="efg"."foo" ' + 'GROUP BY "abc"."foo" ' + 'HAVING "abc"."buz"=\'fiz\' AND SUM("efg"."bar")>100', + str(q), + ) + + def test_mysql_query_uses_backtick_quote_chars(self): + q = ( + MySQLQuery.from_(self.table_abc) + .select(self.table_abc.foo) + .groupby(self.table_abc.foo) + .having(self.table_abc.buz == "fiz") + ) + self.assertEqual("SELECT `foo` FROM `abc` GROUP BY `foo` HAVING `buz`='fiz'", str(q)) + + def test_vertica_query_uses_double_quote_chars(self): + q = ( + VerticaQuery.from_(self.table_abc) + .select(self.table_abc.foo) + .groupby(self.table_abc.foo) + .having(self.table_abc.buz == "fiz") + ) + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo" HAVING "buz"=\'fiz\'', str(q)) + + def test_mssql_query_uses_double_quote_chars(self): + q = ( + MSSQLQuery.from_(self.table_abc) + .select(self.table_abc.foo) + .groupby(self.table_abc.foo) + .having(self.table_abc.buz == "fiz") + ) + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo" HAVING "buz"=\'fiz\'', str(q)) + + def test_oracle_query_uses_no_quote_chars(self): + q = ( + OracleQuery.from_(self.table_abc) + .select(self.table_abc.foo) + .groupby(self.table_abc.foo) + .having(self.table_abc.buz == "fiz") + ) + self.assertEqual('SELECT foo FROM abc GROUP BY foo HAVING buz=\'fiz\'', str(q)) + + def test_postgres_query_uses_double_quote_chars(self): + q = ( + PostgreSQLQuery.from_(self.table_abc) + .select(self.table_abc.foo) + .groupby(self.table_abc.foo) + .having(self.table_abc.buz == "fiz") + ) + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo" HAVING "buz"=\'fiz\'', str(q)) + + def test_redshift_query_uses_double_quote_chars(self): + q = ( + RedshiftQuery.from_(self.table_abc) + .select(self.table_abc.foo) + .groupby(self.table_abc.foo) + .having(self.table_abc.buz == "fiz") + ) + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo" HAVING "buz"=\'fiz\'', str(q)) + + +class OrderByTests(unittest.TestCase): + t = Table("abc") + + def test_orderby_single_field(self): + q = Query.from_(self.t).orderby(self.t.foo).select(self.t.foo) + + self.assertEqual('SELECT "foo" FROM "abc" ORDER BY "foo"', str(q)) + + def test_orderby_multi_fields(self): + q = Query.from_(self.t).orderby(self.t.foo, self.t.bar).select(self.t.foo, self.t.bar) + + self.assertEqual('SELECT "foo","bar" FROM "abc" ORDER BY "foo","bar"', str(q)) + + def test_orderby_single_str(self): + q = Query.from_("abc").orderby("foo").select("foo") + + self.assertEqual('SELECT "foo" FROM "abc" ORDER BY "foo"', str(q)) + + def test_orderby_asc(self): + q = Query.from_(self.t).orderby(self.t.foo, order=Order.asc).select(self.t.foo) + + self.assertEqual('SELECT "foo" FROM "abc" ORDER BY "foo" ASC', str(q)) + + def test_orderby_desc(self): + q = Query.from_(self.t).orderby(self.t.foo, order=Order.desc).select(self.t.foo) + + self.assertEqual('SELECT "foo" FROM "abc" ORDER BY "foo" DESC', str(q)) + + def test_orderby_no_alias(self): + bar = self.t.bar.as_("bar01") + q = Query.from_(self.t).select(fn.Sum(self.t.foo), bar).orderby(bar) + + self.assertEqual( + 'SELECT SUM("foo"),"bar" "bar01" FROM "abc" ORDER BY "bar"', + q.get_sql(orderby_alias=False), + ) + + def test_orderby_alias(self): + bar = self.t.bar.as_("bar01") + q = Query.from_(self.t).select(fn.Sum(self.t.foo), bar).orderby(bar) + + self.assertEqual('SELECT SUM("foo"),"bar" "bar01" FROM "abc" ORDER BY "bar01"', q.get_sql()) + + +class AliasTests(unittest.TestCase): + t = Table("abc") + + def test_table_field(self): + q = Query.from_(self.t).select(self.t.foo.as_("bar")) + + self.assertEqual('SELECT "foo" "bar" FROM "abc"', str(q)) + + def test_table_field__multi(self): + q = Query.from_(self.t).select(self.t.foo.as_("bar"), self.t.fiz.as_("buz")) + + self.assertEqual('SELECT "foo" "bar","fiz" "buz" FROM "abc"', str(q)) + + def test_arithmetic_function(self): + q = Query.from_(self.t).select((self.t.foo + self.t.bar).as_("biz")) + + self.assertEqual('SELECT "foo"+"bar" "biz" FROM "abc"', str(q)) + + def test_functions_using_as(self): + q = Query.from_(self.t).select(fn.Count("*").as_("foo")) + + self.assertEqual('SELECT COUNT(*) "foo" FROM "abc"', str(q)) + + def test_functions_using_constructor_param(self): + q = Query.from_(self.t).select(fn.Count("*", alias="foo")) + + self.assertEqual('SELECT COUNT(*) "foo" FROM "abc"', str(q)) + + def test_function_using_as_nested(self): + """ + We don't show aliases of fields that are arguments of a function. + """ + q = Query.from_(self.t).select(fn.Sqrt(fn.Count("*").as_("foo")).as_("bar")) + + self.assertEqual('SELECT SQRT(COUNT(*)) "bar" FROM "abc"', str(q)) + + def test_functions_using_constructor_param_nested(self): + """ + We don't show aliases of fields that are arguments of a function. + """ + q = Query.from_(self.t).select(fn.Sqrt(fn.Count("*", alias="foo"), alias="bar")) + + self.assertEqual('SELECT SQRT(COUNT(*)) "bar" FROM "abc"', str(q)) + + def test_ignored_in_where(self): + q = Query.from_(self.t).select(self.t.foo).where(self.t.foo.as_("bar") == 1) + + self.assertEqual('SELECT "foo" FROM "abc" WHERE "foo"=1', str(q)) + + def test_ignored_in_groupby(self): + q = Query.from_(self.t).select(self.t.foo).groupby(self.t.foo.as_("bar")) + + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo"', str(q)) + + def test_ignored_in_orderby(self): + q = Query.from_(self.t).select(self.t.foo).orderby(self.t.foo.as_("bar")) + + self.assertEqual('SELECT "foo" FROM "abc" ORDER BY "foo"', str(q)) + + def test_ignored_in_criterion(self): + c = self.t.foo.as_("bar") == 1 + + self.assertEqual('"foo"=1', str(c)) + + def test_ignored_in_criterion_comparison(self): + c = self.t.foo.as_("bar") == self.t.fiz.as_("buz") + + self.assertEqual('"foo"="fiz"', str(c)) + + def test_ignored_in_field_inside_case(self): + q = Query.from_(self.t).select(Case().when(self.t.foo == 1, "a").else_(self.t.bar.as_('"buz"'))) + + self.assertEqual('SELECT CASE WHEN "foo"=1 THEN \'a\' ELSE "bar" END FROM "abc"', str(q)) + + def test_case_using_as(self): + q = Query.from_(self.t).select(Case().when(self.t.foo == 1, "a").else_("b").as_("bar")) + + self.assertEqual( + 'SELECT CASE WHEN "foo"=1 THEN \'a\' ELSE \'b\' END "bar" FROM "abc"', + str(q), + ) + + def test_case_using_constructor_param(self): + q = Query.from_(self.t).select(Case(alias="bar").when(self.t.foo == 1, "a").else_("b")) + + self.assertEqual( + 'SELECT CASE WHEN "foo"=1 THEN \'a\' ELSE \'b\' END "bar" FROM "abc"', + str(q), + ) + + def test_select__multiple_tables(self): + table_abc, table_efg = Table("abc", alias="q0"), Table("efg", alias="q1") + + q = Query.from_(table_abc).select(table_abc.foo).from_(table_efg).select(table_efg.bar) + + self.assertEqual('SELECT "q0"."foo","q1"."bar" FROM "abc" "q0","efg" "q1"', str(q)) + + def test_use_aliases_in_groupby_and_orderby(self): + table_abc = Table("abc", alias="q0") + + my_foo = table_abc.foo.as_("my_foo") + q = Query.from_(table_abc).select(my_foo, table_abc.bar).groupby(my_foo).orderby(my_foo) + + self.assertEqual( + 'SELECT "q0"."foo" "my_foo","q0"."bar" ' 'FROM "abc" "q0" ' 'GROUP BY "my_foo" ' 'ORDER BY "my_foo"', + str(q), + ) + + def test_table_with_schema_and_alias(self): + table = Table("abc", schema="schema", alias="alias") + self.assertEqual('"schema"."abc" "alias"', str(table)) + + def test_null_value_with_alias(self): + q = Query.select(NullValue().as_("abcdef")) + + self.assertEqual('SELECT NULL "abcdef"', str(q)) + + +class SubqueryTests(unittest.TestCase): + maxDiff = None + + table_abc, table_efg, table_hij = Tables("abc", "efg", "hij") + + def test_where__in(self): + q = ( + Query.from_(self.table_abc) + .select("*") + .where( + self.table_abc.foo.isin( + Query.from_(self.table_efg).select(self.table_efg.foo).where(self.table_efg.bar == 0) + ) + ) + ) + + self.assertEqual( + 'SELECT * FROM "abc" WHERE "foo" IN (SELECT "foo" FROM "efg" WHERE "bar"=0)', + str(q), + ) + + def test_where__in_nested(self): + q = Query.from_(self.table_abc).select("*").where(self.table_abc.foo).isin(self.table_efg.select("*")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" IN (SELECT * FROM "efg")', str(q)) + + def test_join(self): + subquery = Query.from_("efg").select("fiz", "buz").where(F("buz") == 0) + + q = ( + Query.from_(self.table_abc) + .join(subquery) + .on(self.table_abc.bar == subquery.buz) + .select(self.table_abc.foo, subquery.fiz) + ) + + self.assertEqual( + 'SELECT "abc"."foo","sq0"."fiz" FROM "abc" ' + 'JOIN (SELECT "fiz","buz" FROM "efg" WHERE "buz"=0) "sq0" ' + 'ON "abc"."bar"="sq0"."buz"', + str(q), + ) + + def test_select_subquery(self): + subq = Query.from_(self.table_efg).select("fizzbuzz").where(self.table_efg.id == 1) + + q = Query.from_(self.table_abc).select("foo", "bar").select(subq) + + self.assertEqual( + 'SELECT "foo","bar",(SELECT "fizzbuzz" FROM "efg" WHERE "id"=1) ' 'FROM "abc"', + str(q), + ) + + def test_select_subquery_with_alias(self): + subq = Query.from_(self.table_efg).select("fizzbuzz").where(self.table_efg.id == 1) + + q = Query.from_(self.table_abc).select("foo", "bar").select(subq.as_("sq")) + + self.assertEqual( + 'SELECT "foo","bar",(SELECT "fizzbuzz" FROM "efg" WHERE "id"=1) "sq" ' 'FROM "abc"', + str(q), + ) + + def test_where__equality(self): + subquery = Query.from_("efg").select("fiz").where(F("buz") == 0) + query = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, self.table_abc.bar) + .where(self.table_abc.bar == subquery) + ) + + self.assertEqual( + 'SELECT "foo","bar" FROM "abc" ' 'WHERE "bar"=(SELECT "fiz" FROM "efg" WHERE "buz"=0)', + str(query), + ) + + def test_select_from_nested_query(self): + subquery = Query.from_(self.table_abc).select( + self.table_abc.foo, + self.table_abc.bar, + (self.table_abc.fizz + self.table_abc.buzz).as_("fizzbuzz"), + ) + + query = Query.from_(subquery).select(subquery.foo, subquery.bar, subquery.fizzbuzz) + + self.assertEqual( + 'SELECT "sq0"."foo","sq0"."bar","sq0"."fizzbuzz" ' + "FROM (" + 'SELECT "foo","bar","fizz"+"buzz" "fizzbuzz" ' + 'FROM "abc"' + ') "sq0"', + str(query), + ) + + def test_select_from_nested_query_with_join(self): + subquery1 = ( + Query.from_(self.table_abc) + .select( + self.table_abc.foo, + fn.Sum(self.table_abc.fizz + self.table_abc.buzz).as_("fizzbuzz"), + ) + .groupby(self.table_abc.foo) + ) + + subquery2 = Query.from_(self.table_efg).select( + self.table_efg.foo.as_("foo_two"), + self.table_efg.bar, + ) + + query = ( + Query.from_(subquery1) + .select(subquery1.foo, subquery1.fizzbuzz) + .join(subquery2) + .on(subquery1.foo == subquery2.foo_two) + .select(subquery2.foo_two, subquery2.bar) + ) + + self.assertEqual( + "SELECT " + '"sq0"."foo","sq0"."fizzbuzz",' + '"sq1"."foo_two","sq1"."bar" ' + "FROM (" + "SELECT " + '"foo",SUM("fizz"+"buzz") "fizzbuzz" ' + 'FROM "abc" ' + 'GROUP BY "foo"' + ') "sq0" JOIN (' + "SELECT " + '"foo" "foo_two","bar" ' + 'FROM "efg"' + ') "sq1" ON "sq0"."foo"="sq1"."foo_two"', + str(query), + ) + + def test_from_subquery_without_alias(self): + subquery = Query.from_(self.table_efg).select( + self.table_efg.base_id.as_("x"), self.table_efg.fizz, self.table_efg.buzz + ) + + test_query = Query.from_(subquery).select(subquery.x, subquery.fizz, subquery.buzz) + + self.assertEqual( + 'SELECT "sq0"."x","sq0"."fizz","sq0"."buzz" ' + "FROM (" + 'SELECT "base_id" "x","fizz","buzz" FROM "efg"' + ') "sq0"', + str(test_query), + ) + + def test_join_query_with_alias(self): + subquery = ( + Query.from_(self.table_efg) + .select( + self.table_efg.base_id.as_("x"), + self.table_efg.fizz, + self.table_efg.buzz, + ) + .as_("subq") + ) + + test_query = Query.from_(subquery).select(subquery.x, subquery.fizz, subquery.buzz) + + self.assertEqual( + 'SELECT "subq"."x","subq"."fizz","subq"."buzz" ' + "FROM (" + 'SELECT "base_id" "x","fizz","buzz" FROM "efg"' + ') "subq"', + str(test_query), + ) + + def test_with(self): + sub_query = Query.from_(self.table_efg).select("fizz") + test_query = Query.with_(sub_query, "an_alias").from_(AliasedQuery("an_alias")).select("*") + + self.assertEqual( + 'WITH an_alias AS (SELECT "fizz" FROM "efg") SELECT * FROM an_alias', + str(test_query), + ) + + def test_join_with_with(self): + sub_query = Query.from_(self.table_efg).select("fizz") + test_query = ( + Query.with_(sub_query, "an_alias") + .from_(self.table_abc) + .join(AliasedQuery("an_alias")) + .on(AliasedQuery("an_alias").fizz == self.table_abc.buzz) + .select("*") + ) + self.assertEqual( + 'WITH an_alias AS (SELECT "fizz" FROM "efg") ' + 'SELECT * FROM "abc" JOIN an_alias ON "an_alias"."fizz"="abc"."buzz"', + str(test_query), + ) + + def test_select_from_with_returning(self): + sub_query = PostgreSQLQuery.into(self.table_abc).insert(1).returning('*') + test_query = Query.with_(sub_query, "an_alias").from_(AliasedQuery("an_alias")).select("*") + self.assertEqual( + 'WITH an_alias AS (INSERT INTO "abc" VALUES (1) RETURNING *) SELECT * FROM an_alias', str(test_query) + ) + + +class QuoteTests(unittest.TestCase): + def test_extraneous_quotes(self): + t1 = Table("table1", alias="t1") + t2 = Table("table2", alias="t2") + + query = Query.from_(t1).join(t2).on(t1.Value.between(t2.start, t2.end)).select(t1.value) + + self.assertEqual( + "SELECT t1.value FROM table1 t1 " "JOIN table2 t2 ON t1.Value " "BETWEEN t2.start AND t2.end", + query.get_sql(quote_char=None), + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/test_tables.py b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/test_tables.py new file mode 100644 index 0000000000000000000000000000000000000000..f43e740915f642d29ce7497c36e3b68f01311016 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/test_tables.py @@ -0,0 +1,186 @@ +# from pypika.terms import ValueWrapper, SystemTimeValue +import unittest + +from pypika import Database, Dialects, Schema, SQLLiteQuery, Table, Tables, Query, SYSTEM_TIME + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + + +class TableStructureTests(unittest.TestCase): + def test_table_sql(self): + table = Table("test_table") + + self.assertEqual('"test_table"', str(table)) + + def test_table_with_alias(self): + table = Table("test_table").as_("my_table") + + self.assertEqual('"test_table" "my_table"', table.get_sql(with_alias=True, quote_char='"')) + + def test_schema_table_attr(self): + table = Schema("x_schema").test_table + + self.assertEqual('"x_schema"."test_table"', str(table)) + + def test_table_with_schema_arg(self): + table = Table("test_table", schema=Schema("x_schema")) + + self.assertEqual('"x_schema"."test_table"', str(table)) + + def test_database_schema_table_attr(self): + table = Database("x_db").x_schema.test_table + + self.assertEqual('"x_db"."x_schema"."test_table"', str(table)) + + def test_table_with_schema_and_schema_parent_arg(self): + table = Table("test_table", schema=Schema("x_schema", parent=Database("x_db"))) + + self.assertEqual('"x_db"."x_schema"."test_table"', str(table)) + + def test_table_for_system_time_sql(self): + with self.subTest("with between criterion"): + table = Table("test_table").for_(SYSTEM_TIME.between('2020-01-01', '2020-02-01')) + + self.assertEqual('"test_table" FOR SYSTEM_TIME BETWEEN \'2020-01-01\' AND \'2020-02-01\'', str(table)) + + with self.subTest("with as of criterion"): + table = Table("test_table").for_(SYSTEM_TIME.as_of('2020-01-01')) + + self.assertEqual('"test_table" FOR SYSTEM_TIME AS OF \'2020-01-01\'', str(table)) + + with self.subTest("with from to criterion"): + table = Table("test_table").for_(SYSTEM_TIME.from_to('2020-01-01', '2020-02-01')) + + self.assertEqual('"test_table" FOR SYSTEM_TIME FROM \'2020-01-01\' TO \'2020-02-01\'', str(table)) + + def test_table_for_period_sql(self): + with self.subTest("with between criterion"): + table = Table("test_table") + table = table.for_(table.valid_period.between('2020-01-01', '2020-02-01')) + + self.assertEqual('"test_table" FOR "valid_period" BETWEEN \'2020-01-01\' AND \'2020-02-01\'', str(table)) + + with self.subTest("with as of criterion"): + table = Table("test_table") + table = table.for_(table.valid_period.as_of('2020-01-01')) + + self.assertEqual('"test_table" FOR "valid_period" AS OF \'2020-01-01\'', str(table)) + + with self.subTest("with from to criterion"): + table = Table("test_table") + table = table.for_(table.valid_period.from_to('2020-01-01', '2020-02-01')) + + self.assertEqual('"test_table" FOR "valid_period" FROM \'2020-01-01\' TO \'2020-02-01\'', str(table)) + + +class TableEqualityTests(unittest.TestCase): + def test_tables_equal_by_name(self): + t1 = Table("t") + t2 = Table("t") + + self.assertEqual(t1, t2) + + def test_tables_equal_by_schema_and_name(self): + t1 = Table("t", schema="a") + t2 = Table("t", schema="a") + + self.assertEqual(t1, t2) + + def test_tables_equal_by_schema_and_name_using_schema(self): + a = Schema("a") + t1 = Table("t", schema=a) + t2 = Table("t", schema=a) + + self.assertEqual(t1, t2) + + def test_tables_equal_by_schema_and_name_using_schema_with_parent(self): + parent = Schema("parent") + a = Schema("a", parent=parent) + t1 = Table("t", schema=a) + t2 = Table("t", schema=a) + + self.assertEqual(t1, t2) + + def test_tables_not_equal_by_schema_and_name_using_schema_with_different_parents( + self, + ): + parent = Schema("parent") + a = Schema("a", parent=parent) + t1 = Table("t", schema=a) + t2 = Table("t", schema=Schema("a")) + + self.assertNotEqual(t1, t2) + + def test_tables_not_equal_with_different_schemas(self): + t1 = Table("t", schema="a") + t2 = Table("t", schema="b") + + self.assertNotEqual(t1, t2) + + def test_tables_not_equal_with_different_names(self): + t1 = Table("t", schema="a") + t2 = Table("q", schema="a") + + self.assertNotEqual(t1, t2) + + def test_many_tables_with_alias(self): + tables_data = [("table1", "t1"), ("table2", "t2"), ("table3", "t3")] + tables = Tables(*tables_data) + for el in tables: + self.assertIsNotNone(el.alias) + + def test_many_tables_without_alias(self): + tables_data = ["table1", "table2", "table3"] + tables = Tables(*tables_data) + for el in tables: + self.assertIsNone(el.alias) + + def test_many_tables_with_or_not_alias(self): + tables_data = [("table1", "t1"), ("table2"), "table3"] + tables = Tables(*tables_data) + for i in range(len(tables)): + if isinstance(tables_data[i], tuple): + self.assertIsNotNone(tables[i].alias) + else: + self.assertIsNone(tables[i].alias) + + +class TableDialectTests(unittest.TestCase): + def test_table_with_default_query_cls(self): + table = Table("abc") + q = table.select("1") + self.assertIs(q.dialect, None) + + def test_table_with_dialect_query_cls(self): + table = Table("abc", query_cls=SQLLiteQuery) + q = table.select("1") + self.assertIs(q.dialect, Dialects.SQLLITE) + + def test_table_factory_with_default_query_cls(self): + table = Query.Table("abc") + q = table.select("1") + self.assertIs(q.dialect, None) + + def test_table_factory_with_dialect_query_cls(self): + table = SQLLiteQuery.Table("abc") + q = table.select("1") + self.assertIs(q.dialect, Dialects.SQLLITE) + + def test_make_tables_factory_with_default_query_cls(self): + t1, t2 = Query.Tables("abc", "def") + q1 = t1.select("1") + q2 = t2.select("2") + self.assertIs(q1.dialect, None) + self.assertIs(q2.dialect, None) + + def test_make_tables_factory_with_dialect_query_cls(self): + t1, t2 = SQLLiteQuery.Tables("abc", "def") + q1 = t1.select("1") + q2 = t2.select("2") + self.assertIs(q1.dialect, Dialects.SQLLITE) + self.assertIs(q2.dialect, Dialects.SQLLITE) + + def test_table_with_bad_query_cls(self): + with self.assertRaises(TypeError): + Table("abc", query_cls=object) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/test_terms.py b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/test_terms.py new file mode 100644 index 0000000000000000000000000000000000000000..4c7590dfce129bac97a3f30de99b596cc746c893 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/test_terms.py @@ -0,0 +1,82 @@ +from unittest import TestCase + +from pypika import Query, Table, Field +from pypika.terms import AtTimezone + + +class FieldAliasTests(TestCase): + t = Table("test", alias="crit") + + def test_when_alias_specified(self): + c1 = Field("foo", alias="bar") + self.assertEqual('bar', str(c1.alias)) + + c1 = Field("foo").as_("bar") + self.assertEqual('bar', str(c1.alias)) + + +class FieldInitTests(TestCase): + def test_init_with_str_table(self): + test_table_name = "test_table" + field = Field(name="name", table=test_table_name) + self.assertEqual(field.table, Table(name=test_table_name)) + + +class FieldHashingTests(TestCase): + def test_tabled_eq_fields_equally_hashed(self): + client_name1 = Field(name="name", table=Table("clients")) + client_name2 = Field(name="name", table=Table("clients")) + self.assertTrue(hash(client_name1) == hash(client_name2)) + + def test_tabled_ne_fields_differently_hashed(self): + customer_name = Field(name="name", table=Table("customers")) + client_name = Field(name="name", table=Table("clients")) + self.assertTrue(hash(customer_name) != hash(client_name)) + + def test_non_tabled_aliased_eq_fields_equally_hashed(self): + self.assertTrue(hash(Field(name="A", alias="my_a")) == hash(Field(name="A", alias="my_a"))) + + def test_non_tabled_aliased_ne_fields_differently_hashed(self): + self.assertTrue(hash(Field(name="A", alias="my_a1")) != hash(Field(name="A", alias="my_a2"))) + + def test_non_tabled_eq_fields_equally_hashed(self): + self.assertTrue(hash(Field(name="A")) == hash(Field(name="A"))) + + def test_non_tabled_ne_fields_differently_hashed(self): + self.assertTrue(hash(Field(name="A")) != hash(Field(name="B"))) + + +class AtTimezoneTests(TestCase): + def test_when_interval_not_specified(self): + query = Query.from_("customers").select(AtTimezone("date", "US/Eastern")) + self.assertEqual('SELECT "date" AT TIME ZONE \'US/Eastern\' FROM "customers"', str(query)) + + def test_when_interval_specified(self): + query = Query.from_("customers").select(AtTimezone("date", "-06:00", interval=True)) + self.assertEqual( + 'SELECT "date" AT TIME ZONE INTERVAL \'-06:00\' FROM "customers"', + str(query), + ) + + def test_when_alias_specified(self): + query = Query.from_("customers").select(AtTimezone("date", "US/Eastern", alias="alias1")) + self.assertEqual( + 'SELECT "date" AT TIME ZONE \'US/Eastern\' "alias1" FROM "customers"', + str(query), + ) + + def test_passes_kwargs_to_field_get_sql(self): + customers = Table("customers") + accounts = Table("accounts") + query = ( + Query.from_(customers) + .join(accounts) + .on(customers.account_id == accounts.account_id) + .select(AtTimezone(customers.date, "US/Eastern", alias="alias1")) + ) + + self.assertEqual( + 'SELECT "customers"."date" AT TIME ZONE \'US/Eastern\' "alias1" ' + 'FROM "customers" JOIN "accounts" ON "customers"."account_id"="accounts"."account_id"', + query.get_sql(with_namespace=True), + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/test_tuples.py b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/test_tuples.py new file mode 100644 index 0000000000000000000000000000000000000000..c8ebc8e41b0115777f8b3c8cb01c04e62f13ee18 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/test_tuples.py @@ -0,0 +1,162 @@ +import unittest + +from pypika import ( + Array, + Bracket, + Query, + PostgreSQLQuery, + Table, + Tables, + Tuple, +) +from pypika.functions import Coalesce, NullIf, Sum +from pypika.terms import Field + + +class TupleTests(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_tuple_equality_tuple_on_both(self): + q = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, self.table_abc.bar) + .where(Tuple(self.table_abc.foo, self.table_abc.bar) == Tuple(1, 2)) + ) + + self.assertEqual('SELECT "foo","bar" FROM "abc" ' 'WHERE ("foo","bar")=(1,2)', str(q)) + + def test_tuple_equality_tuple_on_left(self): + q = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, self.table_abc.bar) + .where(Tuple(self.table_abc.foo, self.table_abc.bar) == (1, 2)) + ) + + self.assertEqual('SELECT "foo","bar" FROM "abc" ' 'WHERE ("foo","bar")=(1,2)', str(q)) + + def test_tuple_equality_tuple_on_right(self): + q = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, self.table_abc.bar) + .where((self.table_abc.foo, self.table_abc.bar) == Tuple(1, 2)) + ) + + # Order is reversed due to lack of right equals method + self.assertEqual('SELECT "foo","bar" FROM "abc" ' 'WHERE (1,2)=("foo","bar")', str(q)) + + def test_tuple_in_using_python_tuples(self): + q = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, self.table_abc.bar) + .where(Tuple(self.table_abc.foo, self.table_abc.bar).isin([(1, 1), (2, 2), (3, 3)])) + ) + + self.assertEqual( + 'SELECT "foo","bar" FROM "abc" ' 'WHERE ("foo","bar") IN ((1,1),(2,2),(3,3))', + str(q), + ) + + def test_tuple_in_using_pypika_tuples(self): + q = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, self.table_abc.bar) + .where(Tuple(self.table_abc.foo, self.table_abc.bar).isin([Tuple(1, 1), Tuple(2, 2), Tuple(3, 3)])) + ) + + self.assertEqual( + 'SELECT "foo","bar" FROM "abc" ' 'WHERE ("foo","bar") IN ((1,1),(2,2),(3,3))', + str(q), + ) + + def test_tuple_in_using_mixed_tuples(self): + q = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, self.table_abc.bar) + .where(Tuple(self.table_abc.foo, self.table_abc.bar).isin([(1, 1), Tuple(2, 2), (3, 3)])) + ) + + self.assertEqual( + 'SELECT "foo","bar" FROM "abc" ' 'WHERE ("foo","bar") IN ((1,1),(2,2),(3,3))', + str(q), + ) + + def test_tuples_in_join(self): + query = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .select("*") + .where(Tuple(self.table_abc.foo, self.table_efg.bar).isin([(1, 1), Tuple(2, 2), (3, 3)])) + ) + + self.assertEqual( + 'SELECT * FROM "abc" JOIN "efg" ON "abc"."foo"="efg"."bar" ' + 'WHERE ("abc"."foo","efg"."bar") IN ((1,1),(2,2),(3,3))', + str(query), + ) + + def test_render_alias_in_array_sql(self): + tb = Table("tb") + + q = Query.from_(tb).select(Tuple(tb.col).as_("different_name")) + self.assertEqual(str(q), 'SELECT ("col") "different_name" FROM "tb"') + + def test_tuple_is_aggregate(self): + with self.subTest('None if single argument returns None for is_aggregate'): + self.assertEqual(None, Tuple(0).is_aggregate) + self.assertEqual(None, Tuple(Coalesce('col')).is_aggregate) + + with self.subTest('None if multiple arguments all return None for is_aggregate'): + self.assertEqual(None, Tuple(0, 'a').is_aggregate) + self.assertEqual(None, Tuple(Coalesce('col'), NullIf('col2', 0)).is_aggregate) + + with self.subTest('True if single argument returns True for is_aggregate'): + self.assertEqual(True, Tuple(Sum('col')).is_aggregate) + + with self.subTest('True if multiple arguments return True for is_aggregate'): + self.assertEqual(True, Tuple(Sum('col'), Sum('col2')).is_aggregate) + + with self.subTest('True when mix of arguments returning None and True for is_aggregate'): + self.assertEqual(True, Tuple(Coalesce('col'), Coalesce('col2', 0), Sum('col3')).is_aggregate) + + with self.subTest('False when one of the arguments returns False for is_aggregate'): + self.assertEqual(False, Tuple(Field('col1'), Sum('col2')).is_aggregate) + + +class ArrayTests(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_array_general(self): + query = Query.from_(self.table_abc).select(Array(1, "a", ["b", 2, 3])) + + self.assertEqual("SELECT [1,'a',['b',2,3]] FROM \"abc\"", str(query)) + + def test_empty_psql_array(self): + query = PostgreSQLQuery.from_(self.table_abc).select(Array()) + + self.assertEqual("SELECT '{}' FROM \"abc\"", str(query)) + + def test_psql_array_general(self): + query = PostgreSQLQuery.from_(self.table_abc).select(Array(1, Array(2, 2, 2), 3)) + + self.assertEqual("SELECT ARRAY[1,ARRAY[2,2,2],3] FROM \"abc\"", str(query)) + + def test_render_alias_in_array_sql(self): + tb = Table("tb") + + q = Query.from_(tb).select(Array(tb.col).as_("different_name")) + self.assertEqual(str(q), 'SELECT ["col"] "different_name" FROM "tb"') + + +class BracketTests(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_arithmetic_with_brackets(self): + q = Query.from_(self.table_abc).select(Bracket(self.table_abc.foo / 2) / 2) + + self.assertEqual('SELECT ("foo"/2)/2 FROM "abc"', str(q)) + + def test_arithmetic_with_brackets_and_alias(self): + q = Query.from_(self.table_abc).select(Bracket(self.table_abc.foo / 2).as_("alias")) + + self.assertEqual('SELECT ("foo"/2) "alias" FROM "abc"', str(q)) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/test_updates.py b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/test_updates.py new file mode 100644 index 0000000000000000000000000000000000000000..fb9d714dbcb8213b4bda04bf7b8dd9b2419410ec --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/test_updates.py @@ -0,0 +1,162 @@ +import unittest + +from pypika import AliasedQuery, PostgreSQLQuery, Query, SQLLiteQuery, SYSTEM_TIME, Table + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + +from pypika.terms import Star + + +class UpdateTests(unittest.TestCase): + table_abc = Table("abc") + table_def = Table("def") + + def test_empty_query(self): + q = Query.update("abc") + + self.assertEqual("", str(q)) + + def test_omit_where(self): + q = Query.update(self.table_abc).set("foo", "bar") + + self.assertEqual('UPDATE "abc" SET "foo"=\'bar\'', str(q)) + + def test_single_quote_escape_in_set(self): + q = Query.update(self.table_abc).set("foo", "bar'foo") + + self.assertEqual("UPDATE \"abc\" SET \"foo\"='bar''foo'", str(q)) + + def test_update__table_schema(self): + table = Table("abc", "schema1") + q = Query.update(table).set(table.foo, 1).where(table.foo == 0) + + self.assertEqual('UPDATE "schema1"."abc" SET "foo"=1 WHERE "foo"=0', str(q)) + + def test_update_with_none(self): + q = Query.update("abc").set("foo", None) + self.assertEqual('UPDATE "abc" SET "foo"=null', str(q)) + + def test_update_with_join(self): + q = ( + Query.update(self.table_abc) + .join(self.table_def) + .on(self.table_def.abc_id == self.table_abc.id) + .set(self.table_abc.lname, self.table_def.lname) + ) + self.assertEqual( + 'UPDATE "abc" JOIN "def" ON "def"."abc_id"="abc"."id" SET "lname"="def"."lname"', + str(q), + ) + + def test_update_with_limit(self): + q = Query.update(self.table_abc).set(self.table_abc.lname, "test").limit(1) + self.assertEqual('UPDATE "abc" SET "lname"=\'test\' LIMIT 1', str(q)) + + def test_update_from(self): + from_table = Table('from_table') + + q = Query.update(self.table_abc).set(self.table_abc.lname, from_table.long_name).from_(from_table) + self.assertEqual('UPDATE "abc" SET "lname"="from_table"."long_name" FROM "from_table"', str(q)) + + def test_update_from_with_where(self): + from_table = Table('from_table') + + q = ( + Query.update(self.table_abc) + .set(self.table_abc.lname, from_table.long_name) + .from_(from_table) + .where(self.table_abc.fname.eq(from_table.full_name)) + ) + self.assertEqual( + 'UPDATE "abc" SET "lname"="from_table"."long_name" FROM "from_table" ' + 'WHERE "abc"."fname"="from_table"."full_name"', + str(q), + ) + + def test_update_with_statement(self): + table_efg = Table('efg') + + sub_query = Query.from_(table_efg).select("fizz") + an_alias = AliasedQuery("an_alias") + + q = ( + Query.with_(sub_query, "an_alias") + .update(self.table_abc) + .from_(an_alias) + .set(self.table_abc.lname, an_alias.long_name) + .where(self.table_abc.comp.eq(an_alias.alias_comp)) + ) + self.assertEqual( + 'WITH an_alias AS (SELECT "fizz" FROM "efg") ' + 'UPDATE "abc" SET "lname"="an_alias"."long_name" FROM an_alias ' + 'WHERE "abc"."comp"="an_alias"."alias_comp"', + str(q), + ) + + def test_for_portion(self): + with self.subTest("with system time"): + q = Query.update(self.table_abc.for_portion(SYSTEM_TIME.from_to('2020-01-01', '2020-02-01'))).set( + "foo", "bar" + ) + + self.assertEqual( + 'UPDATE "abc" FOR PORTION OF SYSTEM_TIME FROM \'2020-01-01\' TO \'2020-02-01\' SET "foo"=\'bar\'', + str(q), + ) + + with self.subTest("with column"): + q = Query.update( + self.table_abc.for_portion(self.table_abc.valid_period.from_to('2020-01-01', '2020-02-01')) + ).set("foo", "bar") + + self.assertEqual( + 'UPDATE "abc" FOR PORTION OF "valid_period" FROM \'2020-01-01\' TO \'2020-02-01\' SET "foo"=\'bar\'', + str(q), + ) + + +class PostgresUpdateTests(unittest.TestCase): + table_abc = Table("abc") + + def test_update_returning_str(self): + q = PostgreSQLQuery.update(self.table_abc).where(self.table_abc.foo == 0).set("foo", "bar").returning("id") + + self.assertEqual('UPDATE "abc" SET "foo"=\'bar\' WHERE "foo"=0 RETURNING "abc"."id"', str(q)) + + def test_update_returning(self): + q = ( + PostgreSQLQuery.update(self.table_abc) + .where(self.table_abc.foo == 0) + .set("foo", "bar") + .returning(self.table_abc.id) + ) + + self.assertEqual('UPDATE "abc" SET "foo"=\'bar\' WHERE "foo"=0 RETURNING "abc"."id"', str(q)) + + def test_update_returning_from_different_tables(self): + table_bcd = Table('bcd') + + q = ( + PostgreSQLQuery.update(self.table_abc) + .from_(table_bcd) + .set(self.table_abc.lname, table_bcd.long_name) + .returning(self.table_abc.id, table_bcd.fname) + ) + self.assertEqual( + 'UPDATE "abc" SET "lname"="bcd"."long_name" FROM "bcd" RETURNING "abc"."id","bcd"."fname"', str(q) + ) + + def test_update_returning_star(self): + q = PostgreSQLQuery.update(self.table_abc).where(self.table_abc.foo == 0).set("foo", "bar").returning(Star()) + + self.assertEqual('UPDATE "abc" SET "foo"=\'bar\' WHERE "foo"=0 RETURNING *', str(q)) + + +class SQLLiteUpdateTests(unittest.TestCase): + table_abc = Table("abc") + + def test_update_with_bool(self): + q = SQLLiteQuery.update(self.table_abc).set(self.table_abc.foo, True) + + self.assertEqual('UPDATE "abc" SET "foo"=1', str(q)) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/test_utils.py b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/test_utils.py new file mode 100644 index 0000000000000000000000000000000000000000..bb9a9b1c68fe8671989f7c49f9db90e389d06f59 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pypika/tests/test_utils.py @@ -0,0 +1,24 @@ +import unittest + +from pypika import utils + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + + +class ImmutabilityTests(unittest.TestCase): + def test_raise_attribute_error_for_deepcopy(self): + with self.assertRaises(AttributeError): + utils.raise_attribute_for_copy("Test", "__deepcopy__") + + def test_raise_attribute_error_for_getstate(self): + with self.assertRaises(AttributeError): + utils.raise_attribute_for_copy("Test", "__getstate__") + + def test_raise_attribute_error_for_setstate(self): + with self.assertRaises(AttributeError): + utils.raise_attribute_for_copy("Test", "__setstate__") + + def test_raise_attribute_error_for_getnewargs(self): + with self.assertRaises(AttributeError): + utils.raise_attribute_for_copy("Test", "__getnewargs__") diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pyproject.toml b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pyproject.toml new file mode 100644 index 0000000000000000000000000000000000000000..dcc56baede23e3571b336625e695c466ab833a56 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/pyproject.toml @@ -0,0 +1,22 @@ +[tool.black] +line-length = 120 +skip-string-normalization = true +target-version = ['py38', 'py39', 'py310', 'py311'] +force-exclude = ''' +( + /( + \.eggs # exclude a few common directories in the + | \.git # root of the project + | \.hg + | \.mypy_cache + | \.tox + | \.venv + | _build + | buck-out + | build + | dist + | docs + )/ + | setup.py +) +''' diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/setup.cfg b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/setup.cfg new file mode 100644 index 0000000000000000000000000000000000000000..46084aaf2ca9e95b2f9bb7680e432e637fc3ed90 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/setup.cfg @@ -0,0 +1,16 @@ +[bumpversion] +current_version = 0.48.9 +commit = True +tag = True + +[bumpversion:file:pypika/__init__.py] +search = __version__ = "{current_version}" +replace = __version__ = "{new_version}" + +[bdist_wheel] +universal = 1 + +[flake8] +exclude = docs, .git, __pycache__ +max-line-length = 120 +per-file-ignores = __init__.py:F401 diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/setup.py b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/setup.py new file mode 100644 index 0000000000000000000000000000000000000000..41cce7d742df3e33e8d76f267d77df486f69249a --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/setup.py @@ -0,0 +1,81 @@ +import ast + +from setuptools import setup + + +def readme(): + with open('README.rst', 'rb') as f: + return f.read().decode('UTF-8') + + +def version(): + path = 'pypika/__init__.py' + with open(path, 'r') as file: + t = compile(file.read(), path, 'exec', ast.PyCF_ONLY_AST) + for node in (n for n in t.body if isinstance(n, ast.Assign)): + if len(node.targets) == 1: + name = node.targets[0] + if isinstance(name, ast.Name) and name.id in ('__version__', '__version_info__', 'VERSION'): + v = node.value + if isinstance(v, ast.Str): + return v.s + + if isinstance(v, ast.Tuple): + r = [] + for e in v.elts: + if isinstance(e, ast.Str): + r.append(e.s) + elif isinstance(e, ast.Num): + r.append(str(e.n)) + return '.'.join(r) + + +setup( + # Application name: + name="PyPika", + + # Version number: + version=version(), + + # Application author details: + author="Timothy Heys", + author_email="theys@kayak.com", + + # License + license='Apache License Version 2.0', + + # Packages + packages=["pypika", "pypika.clickhouse"], + + # Include additional files into the package + package_data={"pypika": ["py.typed"]}, + include_package_data=True, + + install_requires=[], + + # Details + url="https://github.com/kayak/pypika", + + description="A SQL query builder API for Python", + long_description=readme(), + + classifiers=[ + 'License :: OSI Approved :: Apache Software License', + 'Development Status :: 5 - Production/Stable', + 'Intended Audience :: Developers', + 'Programming Language :: Python :: 3', + 'Programming Language :: PL/SQL', + 'Topic :: Software Development :: Libraries :: Python Modules', + 'Topic :: Scientific/Engineering :: Information Analysis', + 'Topic :: Scientific/Engineering :: Mathematics', + 'Operating System :: POSIX', + 'Operating System :: MacOS :: MacOS X', + 'Operating System :: Microsoft :: Windows', + ], + keywords=('pypika python query builder querybuilder sql mysql postgres psql oracle vertica aggregated ' + 'relational database rdbms business analytics bi data science analysis pandas ' + 'orm object mapper'), + + # Dependent packages (distributions) + test_suite="pypika.tests", +) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/tox.ini b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/tox.ini new file mode 100644 index 0000000000000000000000000000000000000000..2f0e6893243b1ca2ead6a12825e9014dc66364ce --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/tests/trusted/tox.ini @@ -0,0 +1,16 @@ +[tox] +envlist = py38,py39,py310,py311,pypy3 + +[testenv] +description = testing against {basepython} +deps = -r requirements-dev.txt +commands = + coverage run + coverage xml + +[gh-actions] +python = + 3.8: py38 + 3.9: py39 + 3.10: py310 + 3.11: py311 diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/validation/canaries/first-hunk-only.sh b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/validation/canaries/first-hunk-only.sh new file mode 100644 index 0000000000000000000000000000000000000000..32a7c4efba37030c487016663a54050dcf20e46f --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/validation/canaries/first-hunk-only.sh @@ -0,0 +1,22 @@ +#!/bin/bash +set -Eeuo pipefail +cd /testbed/repo +cat > /tmp/openenv-reference.diff <<'OPENENV_PARTIAL' +diff --git a/pypika/clickhouse/search_string.py b/pypika/clickhouse/search_string.py +index 6fadbced1008bb922ef4d74873b8180191f95c9f..22a03027fcaf3ca0578e63980c00f4be1b2f67e7 100644 +--- a/pypika/clickhouse/search_string.py ++++ b/pypika/clickhouse/search_string.py +@@ -51,9 +51,9 @@ + + class _AbstractMultiSearchString(Function, metaclass=abc.ABCMeta): + def __init__(self, name, patterns: list, alias: str = None): +- super(_AbstractMultiSearchString, self).__init__(self, name, alias=alias) ++ super(_AbstractMultiSearchString, self).__init__(self.clickhouse_function(), name, alias=alias) + +- self._patterns = patterns[::-1] ++ self._patterns = patterns + + @classmethod + @abc.abstractmethod +OPENENV_PARTIAL +/usr/bin/git -c core.hooksPath=/dev/null -c core.fsmonitor=false apply --whitespace=nowarn /tmp/openenv-reference.diff diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/validation/canaries/original-bug.sh b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/validation/canaries/original-bug.sh new file mode 100644 index 0000000000000000000000000000000000000000..927547df786c86ab3bb5eeb917a31e0fa1895f8b --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/validation/canaries/original-bug.sh @@ -0,0 +1,3 @@ +#!/bin/bash +set -Eeuo pipefail +: diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/validation/openenv.json b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/validation/openenv.json new file mode 100644 index 0000000000000000000000000000000000000000..a13b3c577df494f6c894584d2b608ab051ebc44f --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__9lguwrtp/validation/openenv.json @@ -0,0 +1,27 @@ +{ + "canaries": "validation/canaries", + "profile": "harbor-semantic-v1", + "requires_credentials": false, + "resources": { + "cpu": 2, + "disk_mb": 16384, + "episode_timeout_s": 1800, + "memory_mb": 8192 + }, + "reward": { + "floor_margin": 0.1, + "oracle_tolerance": 0, + "range": [ + 0, + 1 + ] + }, + "reward_key": "reward", + "types": { + "tags": [ + "swe", + "python", + "mutation-repair" + ] + } +} diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/LICENSE.source b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/LICENSE.source new file mode 100644 index 0000000000000000000000000000000000000000..9c8f3ea0871e0bfe81da0fa6e7c1d7d156dc380e --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/LICENSE.source @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. \ No newline at end of file diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/adapter.json b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/adapter.json new file mode 100644 index 0000000000000000000000000000000000000000..72741102f2319171bec0bd336a38be41ffc5a8be --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/adapter.json @@ -0,0 +1,135 @@ +{ + "canary_selection": "Fixed first provided gold hunk only when at least2hunks exist; strict subset, never reward-selected. Single-hunk task original-bug canary is explicitly NOP-equivalent and adds no signal beyond floor_gap.", + "collector_sha256": "352e555112f2de8a1393f939903e4971c9ace0e944843762b707a725c5c72481", + "dependency_installation_pinned": false, + "dependency_setup_sha256": "ed8673d02878e91c7ae0b51b9178d6a15792b79c6992f800c14a941d95242392", + "gold_patch_sha256": "4002260d0cefb6481fa51bb2fc851979934dc9ed6acd7b0328beaf11c86a7b33", + "hostile_code_isolation_established": false, + "known_wrong_semantic_implementations": 0, + "native_inventory_sha256": "0cf396401277c712494ccd813932cdffe1f2fa5089e56a69a7aa0830a3de82b4", + "new_files_deletions_and_executable_modes_supported": true, + "official_profile": { + "eval_sets": [], + "profile_class": "Pypika1c9646f0", + "profile_lines": [ + 736, + 739 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "upstream_repo": "kayak/pypika" + }, + "original_bug_canary_nop_equivalent": true, + "original_bug_runtime_wrongness_established": false, + "partial_repair_canary": true, + "partial_repair_sha256": "bbe18377cedd73cd62ece0a20e76b8dadc6c6acc80a77b4c796a58562ac3b373", + "partial_repair_wrongness_established": false, + "positive_approval_policy": "All original strict presence/identity/no-skip/no-error/exit checks retained", + "private_checker_sha256": "f0a641064b725415e23a0221bb53c90446d7efcb7f9ece5ede93a220d18dd9e7", + "private_checker_version": "matched-failure-precedence-v2", + "provided_original_bug_control": true, + "repo_url": "https://github.com/swesmith/kayak__pypika.1c9646f0.git", + "runtime_image": null, + "runtime_ready": false, + "runtime_recipe": { + "dependency_installation_pinned": false, + "official_install_cmds": [ + "python -m pip install -e ." + ], + "official_pytest_argv": [ + "pytest", + "--disable-warnings", + "--color=no", + "--tb=no", + "--verbose" + ], + "official_test_command": "source /opt/miniconda3/bin/activate; conda activate testbed; pytest --disable-warnings --color=no --tb=no --verbose", + "operator_test_runner_prerequisites": [ + "python -m pip install pytest==8.4.2" + ], + "operator_test_runner_reason": "The official profile invokes pytest, but the common tools runtime does not provide it; pinned separately from source-native project requirements.", + "panel_normalization": "Override project addopts only to execute the exact frozen native panels; add JUnit output, preserve official pytest options and all selectors.", + "python_version": "3.10", + "source_bound_test_dependency_cmds": [ + "python -m pip install parameterized==0.7.0" + ], + "test_dependency_source_sha256": { + "requirements-dev.txt": "10f4ba7b19a73950d28fd7403d7e1d1b1fe2ccc4f49516974f47199d2965f23d", + "setup.py": "f8bad274588a22e65764d8cf9fb2be5aa6fcfaf3bf861d71e5f751105898845a", + "tox.ini": "c2d7205d0ac93e9c9e80dc5d24f0a826a6781f587a33ea722ea621f9e2ccd0ea" + } + }, + "runtime_resource_review_required": false, + "schema": "python-git-patch-jobs-v1", + "source_base_commit": "e3bf2d032fde8913105fb8a570fb062c62ec6292", + "source_completion_sha256": "2fdfd68871c98bdf555f2ee2ee0cf4f80cf2b7bbdfe4f7ed9ae516389b7e36a9", + "source_index_sha256": "e856874b9410fce9f3bfea52c8c482e84b3e43942d87517f8b55f0034bd40f6f", + "source_pr_url": null, + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:kayak__pypika.1c9646f0.combine_module__ahdnka55", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "6a742f12bfa386994289ec8b75824663d8ee4b15", + "instruction_sha256": "0f431895660b7afac9b6e276f50390fe4dafe5764497a31576bfebd211e6e505", + "is_fork": true, + "learner_path": "tasks/2452fac346ef9d98f8514d9a/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "actual_upstream_url": "https://raw.githubusercontent.com/kayak/pypika/1c9646f0a019a167c32b649b6f5e6423c5ba2c9b/LICENSE.txt", + "reviewed": true, + "sha256": "c5accbbd8546e94c34aed24afe689a617627d18eed5a6c48277e48db57c23851", + "spdx": "Apache-2.0", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/kayak__pypika.1c9646f0/e3bf2d032fde8913105fb8a570fb062c62ec6292/LICENSE.txt" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "patch_sha256": "fcaa27f3bdbed02fe49b3107220eabe1df141be815fc9df9a398aa57dbd84224", + "provenance_path": "tasks/2452fac346ef9d98f8514d9a/source-proof.json", + "repository_lineage": [ + "swesmith/kayak__pypika.1c9646f0", + "kayak/pypika" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "e3bf2d032fde8913105fb8a570fb062c62ec6292", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "cb6e228b45d8ac80bc16a7b1d97fd8269778c233", + "source_kind": "mutation", + "source_repo": "swesmith/kayak__pypika.1c9646f0", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "kayak__pypika.1c9646f0.combine_module__ahdnka55", + "task_sha256": "77bae1d1f202f63a510f39cc58937cad494f1d30660cd83e66205d6dae8d9bec", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "kayak/pypika", + "usage": "quarantine_only" + }, + "source_repo": "swesmith/kayak__pypika.1c9646f0", + "symlink_submodule_changes_supported": false, + "task_id": "kayak__pypika.1c9646f0.combine_module__ahdnka55", + "transfer": "index-independent-worktree-to-Git-binary-patch", + "transfer_path": "/testbed/submission.patch", + "upstream_repo": "kayak/pypika" +} diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/dependency-setup.sh b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/dependency-setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e1a28db070ebf088cec3ef817cf2dc8715091ac2 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/dependency-setup.sh @@ -0,0 +1,9 @@ +#!/bin/bash +set -Eeuo pipefail +source /opt/miniconda3/bin/activate +conda activate testbed +cd /testbed/repo +python -c 'import sys; assert sys.version_info[:2] == (3, 10)' +python -m pip install pytest==8.4.2 +python -m pip install -e . +python -m pip install parameterized==0.7.0 diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/environment/Dockerfile b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..a59b58c2ea8217c78c1e39b4678f93c8c0023bcd --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/environment/Dockerfile @@ -0,0 +1,3 @@ +# Runtime is selected only by an independently qualified immutable amd64 receipt. +FROM ubuntu:22.04 +RUN false diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/instruction.md b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..8ea4447fb439b302c5fcc37f5f02cb4cd65d3734 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/instruction.md @@ -0,0 +1,39 @@ +ClickHouse functions generating incorrect SQL output + +#### Description + +Several ClickHouse functions are producing incorrect SQL output. The `If`, `MultiIf`, `IfNull`, `MultiSearchAny`, and `MultiMatchAny` functions appear to be generating malformed or incorrect SQL statements. + +#### Steps/Code to Reproduce + +```python +from pypika.clickhouse import If, MultiIf, IfNull, MultiSearchAny, MultiMatchAny +from pypika import Field + +# Test If function +field = Field('test_field') +if_condition = If(field > 5, 'high', 'low') +print("If SQL:", if_condition.get_sql()) + +# Test MultiIf function +multi_if = MultiIf(field > 10, 'very_high', field > 5, 'high', 'low') +print("MultiIf SQL:", multi_if.get_sql()) + +# Test IfNull function +if_null = IfNull(field, 'default_value') +print("IfNull SQL:", if_null.get_sql()) + +# Test MultiSearchAny function +multi_search = MultiSearchAny('text_field', ['pattern1', 'pattern2']) +print("MultiSearchAny SQL:", multi_search.get_sql()) + +# Test MultiMatchAny function +multi_match = MultiMatchAny('text_field', ['regex1', 'regex2']) +print("MultiMatchAny SQL:", multi_match.get_sql()) +``` + +The functions are not generating the expected ClickHouse SQL syntax. For example, `If` should generate `if(condition, then_value, else_value)` but appears to be generating something else entirely. + +## Environment + +The repository is at `/testbed/repo`. Its dependencies, including pytest, are installed in the `testbed` conda environment, which comes first on PATH. If `python -m pytest` reports that pytest is missing, use the full interpreter path: `/opt/miniconda3/envs/testbed/bin/python -m pytest `. Don't install packages: the tests need nothing else, and the sandbox may have no network access. diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/metadata.json b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/metadata.json new file mode 100644 index 0000000000000000000000000000000000000000..5e1bdc8933df1fd3232c60d3d4161155b16ec818 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/metadata.json @@ -0,0 +1,1277 @@ +{ + "all_runtime_and_training_flags": false, + "official_profile": { + "eval_sets": [], + "profile_class": "Pypika1c9646f0", + "profile_lines": [ + 736, + 739 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "upstream_repo": "kayak/pypika" + }, + "source_healthy_reference_proof": { + "FAIL_TO_PASS": [ + "pypika/tests/clickhouse/test_condition.py::TestIfCondition::test_get_sql_0", + "pypika/tests/clickhouse/test_condition.py::TestIfCondition::test_get_sql_1", + "pypika/tests/clickhouse/test_condition.py::TestMultiIfCondition::test_get_sql_0", + "pypika/tests/clickhouse/test_condition.py::TestMultiIfCondition::test_get_sql_1", + "pypika/tests/clickhouse/test_nullable_arg.py::TestSearchString::test_get_sql_0", + "pypika/tests/clickhouse/test_nullable_arg.py::TestSearchString::test_get_sql_1", + "pypika/tests/clickhouse/test_search_string.py::TestMultiSearch::test_multi_search_string_0", + "pypika/tests/clickhouse/test_search_string.py::TestMultiSearch::test_multi_search_string_1" + ], + "PASS_TO_PASS": [ + "pypika/tests/clickhouse/test_array.py::TestArray::test_get_sql_0__ridley_scott_jimi_hendrix_", + "pypika/tests/clickhouse/test_array.py::TestArray::test_get_sql_1__1_2_3_4_", + "pypika/tests/clickhouse/test_array.py::TestArray::test_get_sql_2__toInt64_1_toInt64_2_toInt64_3_toInt64_4_", + "pypika/tests/clickhouse/test_array.py::TestArray::test_get_sql_3__toFixedString_mogwai_10_toFixedString_mono_10_toFixedString_bonobo_10_arr", + "pypika/tests/clickhouse/test_array.py::TestHasAny::test_get_sql_0_hasAny_mental_abilities_physical_abilities_", + "pypika/tests/clickhouse/test_array.py::TestHasAny::test_get_sql_1_hasAny_1_2_3_4_3_", + "pypika/tests/clickhouse/test_array.py::TestHasAny::test_get_sql_2_hasAny_bands_toFixedString_port_royal_20_toFixedString_hammock_20_", + "pypika/tests/clickhouse/test_array.py::TestLength::test_get_sql_0_length_tags_", + "pypika/tests/clickhouse/test_array.py::TestLength::test_get_sql_1_length_1_2_3_", + "pypika/tests/clickhouse/test_array.py::TestEmpty::test_get_sql_0_empty_tags_", + "pypika/tests/clickhouse/test_array.py::TestEmpty::test_get_sql_1_empty_1_2_3_", + "pypika/tests/clickhouse/test_array.py::TestNotEmpty::test_get_sql_0_notEmpty_tags_", + "pypika/tests/clickhouse/test_array.py::TestNotEmpty::test_get_sql_1_notEmpty_1_2_3_", + "pypika/tests/clickhouse/test_dates_and_times.py::TestFormatDateTime::test_get_sql_0", + "pypika/tests/clickhouse/test_dates_and_times.py::TestFormatDateTime::test_get_sql_1", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_00", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_01", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_02", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_03", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_04", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_05", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_06", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_07", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_08", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_09", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_10", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_11", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_12", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_13", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_14", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_15", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_16", + "pypika/tests/clickhouse/test_dates_and_times.py::TestToYYYYMM::test_get_sql", + "pypika/tests/clickhouse/test_search_string.py::TestSearchString::test_search_string_0", + "pypika/tests/clickhouse/test_search_string.py::TestSearchString::test_search_string_1", + "pypika/tests/clickhouse/test_search_string.py::TestSearchString::test_search_string_2", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_00_toString_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_01_toInt8_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_02_toInt16_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_03_toInt32_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_04_toInt64_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_05_toUInt8_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_06_toUInt16_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_07_toUInt32_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_08_toUInt64_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_09_toFloat32_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_10_toFloat64_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_11_toFloat64_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_12_toDate_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_13_toDateTime_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_14_toFixedString_field_name_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_00_toString_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_01_toInt8_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_02_toInt16_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_03_toInt32_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_04_toInt64_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_05_toUInt8_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_06_toUInt16_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_07_toUInt32_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_08_toUInt64_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_09_toFloat32_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_10_toFloat64_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_11_toFloat64_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_12_toDate_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_13_toDateTime_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_14_toFixedString_100_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestToFixedString::test_get_sql_with_table", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseQueryTests::test_use_AS_keyword_for_alias", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseQueryTests::test_use_FINAL_keyword", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseQueryTests::test_use_SAMPLE_keyword", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseQueryTests::test_use_SAMPLE_with_offset_keyword", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDeleteTests::test_omit_where", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDeleteTests::test_omit_where__table_schema", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDeleteTests::test_where_field_equals", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseUpdateTests::test_update", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDropQuery::test_drop_database", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDropQuery::test_drop_dictionary", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDropQuery::test_drop_other", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDropQuery::test_drop_table", + "pypika/tests/dialects/test_clickhouse.py::DistinctOnTests::test_distinct_on", + "pypika/tests/dialects/test_clickhouse.py::LimitByTests::test_limit_by", + "pypika/tests/dialects/test_clickhouse.py::LimitByTests::test_limit_offset0_by", + "pypika/tests/dialects/test_clickhouse.py::LimitByTests::test_limit_offset_by", + "pypika/tests/dialects/test_clickhouse.py::LimitByTests::test_rename_table", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_distinct_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_groupby_alias_False_does_not_group_by_alias_when_subqueries_are_present", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_groupby_alias_False_does_not_group_by_alias_with_standard_query", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_limit", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_limit_with_offset", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_normal_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_offset", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_distinct_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_percent_invalid_range", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_percent_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_select_non_int", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_with_ties_select", + "pypika/tests/dialects/test_mysql.py::SelectTests::test_distinct_select", + "pypika/tests/dialects/test_mysql.py::SelectTests::test_modifier_select", + "pypika/tests/dialects/test_mysql.py::SelectTests::test_multiple_modifier_select", + "pypika/tests/dialects/test_mysql.py::SelectTests::test_normal_select", + "pypika/tests/dialects/test_mysql.py::UpdateTests::test_conflict_handlers_update", + "pypika/tests/dialects/test_mysql.py::UpdateTests::test_on_duplicate_key_ignore_update", + "pypika/tests/dialects/test_mysql.py::UpdateTests::test_on_duplicate_key_update_update", + "pypika/tests/dialects/test_mysql.py::UpdateTests::test_update", + "pypika/tests/dialects/test_mysql.py::LoadCSVTests::test_load_from_file", + "pypika/tests/dialects/test_mysql.py::TableTests::test_create_table", + "pypika/tests/dialects/test_mysql.py::TableTests::test_drop_table", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_fetch_next_method_deprecated", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_groupby_alias_False_does_not_group_by_alias_when_subqueries_are_present", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_groupby_alias_False_does_not_group_by_alias_with_standard_query", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_limit_offset_query", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_limit_query", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_offset_query", + "pypika/tests/dialects/test_postgresql.py::InsertTests::test_array_keyword", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_alias_set_correctly", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_json_value_from_array_num", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_json_value_from_array_str", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_json_value_from_dict", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_json_value_from_dict_recursive", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_json_value_by_index", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_json_value_by_key", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_path_json_value", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_path_text_value", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_text_value_by_index", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_text_value_by_key", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contained_by_using_list_arg", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contained_by_using_str_arg", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contained_by_with_complex_criterion", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contains_for_field", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contains_for_json", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_has_any_keys", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_has_key", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_has_keys", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_subnet_contains_inet", + "pypika/tests/dialects/test_postgresql.py::DistinctOnTests::test_distinct_on", + "pypika/tests/dialects/test_postgresql.py::ArrayTests::test_array_syntax", + "pypika/tests/dialects/test_postgresql.py::ArrayTests::test_render_alias_in_array_sql", + "pypika/tests/dialects/test_postgresql.py::ReturningClauseTests::test_no_queryexception_if_returning_used_on_valid_query_type", + "pypika/tests/dialects/test_postgresql.py::ReturningClauseTests::test_queryexception_if_returning_used_on_invalid_query", + "pypika/tests/dialects/test_postgresql.py::ReturningClauseTests::test_return_field_from_join_table", + "pypika/tests/dialects/test_postgresql.py::ReturningClauseTests::test_returning_from_missing_table_raises_queryexception", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_dont_use_double_quotes_on_create_queries", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_dont_use_double_quotes_on_drop_queries", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_dont_use_double_quotes_on_joining_queries", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_use_double_quotes_on_alias_but_not_on_terms", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_use_double_quotes_on_alias_but_not_on_terms_with_joins", + "pypika/tests/dialects/test_sqllite.py::SelectTests::test_bool_false_as_zero", + "pypika/tests/dialects/test_sqllite.py::SelectTests::test_bool_true_as_one", + "pypika/tests/dialects/test_sqllite.py::ReplaceTests::test_insert_or_replace", + "pypika/tests/dialects/test_sqllite.py::ReplaceTests::test_normal_replace", + "pypika/tests/dialects/test_sqllite.py::ReplaceTests::test_replace_subquery", + "pypika/tests/dialects/test_vertica.py::VerticaQueryTests::test_delete_query_with_hint", + "pypika/tests/dialects/test_vertica.py::VerticaQueryTests::test_insert_query_with_hint", + "pypika/tests/dialects/test_vertica.py::VerticaQueryTests::test_select_query_with_hint", + "pypika/tests/dialects/test_vertica.py::VerticaQueryTests::test_update_query_with_hint", + "pypika/tests/dialects/test_vertica.py::CopyCSVTests::test_copy_from_file", + "pypika/tests/dialects/test_vertica.py::CreateTemporaryTableTests::test_create_local_table_without_temporary_raises_error", + "pypika/tests/dialects/test_vertica.py::CreateTemporaryTableTests::test_create_local_temporary_table", + "pypika/tests/dialects/test_vertica.py::CreateTemporaryTableTests::test_create_table_preserve_rows_without_temporary_raises_error", + "pypika/tests/dialects/test_vertica.py::CreateTemporaryTableTests::test_create_temporary_table_preserve_rows", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__agg_case_criterion_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__agg_case_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__agg_func_arithmetic_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__agg_func_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__case_mixed_constant_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__case_mixed_else_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__case_with_field_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__case_with_single_aggregate_field_in_one_criterion_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__constant_arithmetic_is_aggregate_none", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__constant_is_aggregate_none", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__field_arithmetic_constant_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__field_arithmetic_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__field_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__func_arithmetic_constant_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__mixed_case_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__mixed_func_arithmetic_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__negative_agg_func_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__non_aggregate_function_with_aggregated_arg", + "pypika/tests/test_aggregate.py::IsAggregateTests::test_complicated", + "pypika/tests/test_analytic_queries.py::RankTests::test_avg", + "pypika/tests/test_analytic_queries.py::RankTests::test_count_range_between_unbounded_preceeding_current_row", + "pypika/tests/test_analytic_queries.py::RankTests::test_dense_rank", + "pypika/tests/test_analytic_queries.py::RankTests::test_empty_over", + "pypika/tests/test_analytic_queries.py::RankTests::test_filter", + "pypika/tests/test_analytic_queries.py::RankTests::test_filter_quote_table_in_filter", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value_ignore_nulls", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value_ignore_nulls_first", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value_multi_argument", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value_range_between_x_preceeding_unbounded_following", + "pypika/tests/test_analytic_queries.py::RankTests::test_lag_generates_correct_sql", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value_ignore_nulls", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value_multi_argument", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value_rows_between_current_row_unbounded_following", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value_rows_between_current_row_unbounded_following_ignore_nulls", + "pypika/tests/test_analytic_queries.py::RankTests::test_lead_generates_correct_sql", + "pypika/tests/test_analytic_queries.py::RankTests::test_max_range_x_preceeding", + "pypika/tests/test_analytic_queries.py::RankTests::test_max_rows_x_preceeding", + "pypika/tests/test_analytic_queries.py::RankTests::test_median", + "pypika/tests/test_analytic_queries.py::RankTests::test_min_range_current_row", + "pypika/tests/test_analytic_queries.py::RankTests::test_min_rows_current_row", + "pypika/tests/test_analytic_queries.py::RankTests::test_multiple_partitions", + "pypika/tests/test_analytic_queries.py::RankTests::test_ntile_no_partition_or_order_invalid_sql", + "pypika/tests/test_analytic_queries.py::RankTests::test_ntile_with_order", + "pypika/tests/test_analytic_queries.py::RankTests::test_ntile_with_partition", + "pypika/tests/test_analytic_queries.py::RankTests::test_ntile_with_partition_and_order", + "pypika/tests/test_analytic_queries.py::RankTests::test_orderby_asc", + "pypika/tests/test_analytic_queries.py::RankTests::test_orderby_desc", + "pypika/tests/test_analytic_queries.py::RankTests::test_range_called_twice_raises_attribute_error", + "pypika/tests/test_analytic_queries.py::RankTests::test_range_then_rows_raises_attribute_error", + "pypika/tests/test_analytic_queries.py::RankTests::test_rank", + "pypika/tests/test_analytic_queries.py::RankTests::test_rank_with_alias", + "pypika/tests/test_analytic_queries.py::RankTests::test_row_number", + "pypika/tests/test_analytic_queries.py::RankTests::test_rows_called_twice_raises_attribute_error", + "pypika/tests/test_analytic_queries.py::RankTests::test_rows_then_range_raises_attribute_error", + "pypika/tests/test_analytic_queries.py::RankTests::test_stddev", + "pypika/tests/test_analytic_queries.py::RankTests::test_stddev_pop", + "pypika/tests/test_analytic_queries.py::RankTests::test_stddev_samp", + "pypika/tests/test_analytic_queries.py::RankTests::test_sum_rows_unbounded_preceeding", + "pypika/tests/test_analytic_queries.py::RankTests::test_table_prefixes_used_in_analytic_functions", + "pypika/tests/test_analytic_queries.py::RankTests::test_var_pop", + "pypika/tests/test_analytic_queries.py::RankTests::test_var_samp", + "pypika/tests/test_analytic_queries.py::RankTests::test_variance", + "pypika/tests/test_analytic_queries.py::RankTests::test_variance_rows_between_unbounded_preceeding_unbounded_following", + "pypika/tests/test_analytic_queries.py::RankTests::test_varpop_range_unbounded_preceeding", + "pypika/tests/test_analytic_queries.py::RankTests::test_varpop_rows_between_unbounded_preceeding_x_following", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_as_select_not_query_raises_error", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_with_columns", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_with_select", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_with_select_and_columns_fails", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_without_columns_or_select_empty", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_if_not_exists", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_simple", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_unique", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_where", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_without_columns_raises_error", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_without_table_raises_error", + "pypika/tests/test_criterions.py::CriterionTests::test__bitwise_and_in_where_clause", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_bitwise_and", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_bitwise_and_with_alias", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_bool", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_decimal", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_str", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gt_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gt_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gt_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gt_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gte_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gte_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gte_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gte_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_is_null", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_is_null_with_alias", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lt_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lt_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lt_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lt_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lte_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lte_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lte_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lte_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_str", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_with_alias", + "pypika/tests/test_criterions.py::NotTests::test_chained_function", + "pypika/tests/test_criterions.py::NotTests::test_is_not_null", + "pypika/tests/test_criterions.py::NotTests::test_negate", + "pypika/tests/test_criterions.py::NotTests::test_not_null", + "pypika/tests/test_criterions.py::NotTests::test_not_null_with_alias", + "pypika/tests/test_criterions.py::NotTests::test_not_with_and_criterion", + "pypika/tests/test_criterions.py::NotTests::test_not_with_complex_criterion", + "pypika/tests/test_criterions.py::NotTests::test_not_with_or_criterion", + "pypika/tests/test_criterions.py::NotTests::test_notnullcriterion_replace_table", + "pypika/tests/test_criterions.py::NotTests::test_variable_access", + "pypika/tests/test_criterions.py::BetweenTests::test__between_date", + "pypika/tests/test_criterions.py::BetweenTests::test__between_datetime", + "pypika/tests/test_criterions.py::BetweenTests::test__between_number", + "pypika/tests/test_criterions.py::BetweenTests::test__between_with_alias", + "pypika/tests/test_criterions.py::BetweenTests::test__function_between", + "pypika/tests/test_criterions.py::BetweenTests::test_get_item_only_works_with_slice", + "pypika/tests/test_criterions.py::IsInTests::test__function_isin", + "pypika/tests/test_criterions.py::IsInTests::test__in_character", + "pypika/tests/test_criterions.py::IsInTests::test__in_date", + "pypika/tests/test_criterions.py::IsInTests::test__in_datetime", + "pypika/tests/test_criterions.py::IsInTests::test__in_number", + "pypika/tests/test_criterions.py::IsInTests::test__in_number_with_alias", + "pypika/tests/test_criterions.py::IsInTests::test__in_unicode", + "pypika/tests/test_criterions.py::ArithmeticExpressionTests::test__lshift", + "pypika/tests/test_criterions.py::ArithmeticExpressionTests::test__rshift", + "pypika/tests/test_criterions.py::NotInTests::test__function_notin", + "pypika/tests/test_criterions.py::NotInTests::test__notin_character", + "pypika/tests/test_criterions.py::NotInTests::test__notin_date", + "pypika/tests/test_criterions.py::NotInTests::test__notin_datetime", + "pypika/tests/test_criterions.py::NotInTests::test__notin_number", + "pypika/tests/test_criterions.py::NotInTests::test__notin_number_with_alias", + "pypika/tests/test_criterions.py::LikeTests::test_glob_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_contains", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_ends_with", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_n_chars_long", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_starts_with", + "pypika/tests/test_criterions.py::LikeTests::test_like_contains", + "pypika/tests/test_criterions.py::LikeTests::test_like_ends_with", + "pypika/tests/test_criterions.py::LikeTests::test_like_n_chars_long", + "pypika/tests/test_criterions.py::LikeTests::test_like_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_like_starts_with", + "pypika/tests/test_criterions.py::LikeTests::test_not_ilike_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_not_like_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_rlike_escape_chars", + "pypika/tests/test_criterions.py::ExistsCriterionTests::test_exists", + "pypika/tests/test_criterions.py::ExistsCriterionTests::test_not_exists", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__between_and_field", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__between_and_isin", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__nested__and", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__nested__mixed", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__nested__or", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_and", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_function_and", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_function_or", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_function_xor", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_or", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_xor", + "pypika/tests/test_criterions.py::FieldsAsCriterionTests::test__field_and_field", + "pypika/tests/test_criterions.py::FieldsAsCriterionTests::test__field_or_field", + "pypika/tests/test_criterions.py::FieldsAsCriterionTests::test__field_xor_field", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_arithmeticfunction_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_betweencriterion_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_complexcriterion_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_criterion_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_field_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_function_with_only_fields_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_function_with_values_and_fields_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_nullcriterion_replace_table", + "pypika/tests/test_criterions.py::AnyTests::test_multiple_args_returned_in_chain_of_ors", + "pypika/tests/test_criterions.py::AnyTests::test_single_arg_returns_self", + "pypika/tests/test_criterions.py::AnyTests::test_with_generator", + "pypika/tests/test_criterions.py::AnyTests::test_zero_args_returns_empty_criterion", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_different_operations_with_empty_criterion", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_empty_criterion_on_the_left", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_empty_criterion_on_the_right", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_fields_", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_invertion_of_the_empty_criterion", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_more_than_one_empty_criterions", + "pypika/tests/test_criterions.py::AllTests::test_multiple_args_returned_in_chain_of_ors", + "pypika/tests/test_criterions.py::AllTests::test_single_arg_returns_self", + "pypika/tests/test_criterions.py::AllTests::test_with_generator", + "pypika/tests/test_criterions.py::AllTests::test_zero_args_returns_empty_criterion", + "pypika/tests/test_custom_functions.py::TestUnitCustomFunction::test_should_fail_with_wrong_arguments", + "pypika/tests/test_custom_functions.py::TestUnitCustomFunction::test_should_return_function_with_arguments", + "pypika/tests/test_custom_functions.py::TestUnitCustomFunction::test_should_return_function_with_no_arguments", + "pypika/tests/test_custom_functions.py::TestFunctionalCustomFunction::test_should_fail_use_custom_function_on_select_with_wrong_arguments", + "pypika/tests/test_custom_functions.py::TestFunctionalCustomFunction::test_should_use_custom_function_on_select", + "pypika/tests/test_data_types.py::StringTests::test_inline_string_concatentation", + "pypika/tests/test_data_types.py::UuidTests::test_uuid_string_generation", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_day", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_default", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_microsecond", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_minute", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_month", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_quarter", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_second", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_week", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_year", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_day_hour", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_day_microsecond", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_day_minute", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_day_second", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_hour_microsecond", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_hour_minute", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_hour_second", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_minute_microsecond", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_minute_second", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_second_microsecond", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_value_complex_expressions", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_value_right", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_year_month", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_mysql_dialect_uses_single_quotes_around_expression_in_an_interval", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_oracle_dialect_uses_single_quotes_around_expression_in_an_interval", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_postgresql_dialect_uses_single_quotes_around_interval", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_redshift_dialect_uses_single_quotes_around_interval", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_vertica_dialect_uses_single_quotes_around_interval", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_day", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_month", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_week", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_year", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_year_month", + "pypika/tests/test_date_math.py::TruncateTrailingZerosTests::test_do_not_truncate_integer_values", + "pypika/tests/test_date_math.py::TruncateTrailingZerosTests::test_do_not_truncate_months_between_years_and_datys", + "pypika/tests/test_deletes.py::DeleteTests::test_for_portion", + "pypika/tests/test_deletes.py::DeleteTests::test_omit_where", + "pypika/tests/test_deletes.py::DeleteTests::test_omit_where__table_schema", + "pypika/tests/test_deletes.py::DeleteTests::test_where_field_equals", + "pypika/tests/test_deletes.py::PostgresDeleteTests::test_delete_returning", + "pypika/tests/test_deletes.py::PostgresDeleteTests::test_delete_returning_star", + "pypika/tests/test_deletes.py::PostgresDeleteTests::test_delete_returning_str", + "pypika/tests/test_deletes.py::PostgresDeleteTests::test_delete_using", + "pypika/tests/test_drop.py::DropTableTests::test_drop_database", + "pypika/tests/test_drop.py::DropTableTests::test_drop_index", + "pypika/tests/test_drop.py::DropTableTests::test_drop_table", + "pypika/tests/test_drop.py::DropTableTests::test_drop_user", + "pypika/tests/test_drop.py::DropTableTests::test_drop_view", + "pypika/tests/test_formats.py::QuoteTests::test_no_quote_char_in_complex_query", + "pypika/tests/test_formats.py::QuoteTests::test_replace_quote_char_in_complex_query", + "pypika/tests/test_functions.py::FunctionTests::test_dialect_propagation", + "pypika/tests/test_functions.py::FunctionTests::test_is_aggregate_None_for_non_aggregate_function_or_function_with_no_aggregate_functions", + "pypika/tests/test_functions.py::FunctionTests::test_is_aggregate_True_for_aggregate_function_or_function_with_aggregate_functions", + "pypika/tests/test_functions.py::SchemaTests::test_schema_included_in_function_sql", + "pypika/tests/test_functions.py::SchemaTests::test_schema_no_schema_in_sql_when_none_set", + "pypika/tests/test_functions.py::ArithmeticTests::test__addition__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__addition__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__addition__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__addition__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__arithmetic_equality", + "pypika/tests/test_functions.py::ArithmeticTests::test__arithmetic_with_function", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_add_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_div_no_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_div_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_exponent_no_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_exponent_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_floor_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_function_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_modulus_no_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_modulus_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_mul_no_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_mul_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_nested_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_sub_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__division__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__division__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__division__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__division__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__exponent__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__exponent__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__floor", + "pypika/tests/test_functions.py::ArithmeticTests::test__leftshift__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__leftshift__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__leftshift__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__modulus__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__multiplication__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__multiplication__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__multiplication__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__multiplication__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__rightshift__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__rightshift__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__rightshift__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__subtraction__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__subtraction__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__subtraction__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__subtraction__right", + "pypika/tests/test_functions.py::AggregationTests::test__approx_percentile", + "pypika/tests/test_functions.py::AggregationTests::test__avg", + "pypika/tests/test_functions.py::AggregationTests::test__count", + "pypika/tests/test_functions.py::AggregationTests::test__count__star", + "pypika/tests/test_functions.py::AggregationTests::test__first", + "pypika/tests/test_functions.py::AggregationTests::test__last", + "pypika/tests/test_functions.py::AggregationTests::test__max", + "pypika/tests/test_functions.py::AggregationTests::test__min", + "pypika/tests/test_functions.py::AggregationTests::test__std", + "pypika/tests/test_functions.py::AggregationTests::test__stddev", + "pypika/tests/test_functions.py::AggregationTests::test__subquery_in_params_functions", + "pypika/tests/test_functions.py::AggregationTests::test__sum", + "pypika/tests/test_functions.py::ConditionTests::test__case__else", + "pypika/tests/test_functions.py::ConditionTests::test__case__field", + "pypika/tests/test_functions.py::ConditionTests::test__case__multi", + "pypika/tests/test_functions.py::ConditionTests::test__case__no_cases", + "pypika/tests/test_functions.py::ConditionTests::test__case__raw", + "pypika/tests/test_functions.py::StringTests::test__ascii__field", + "pypika/tests/test_functions.py::StringTests::test__ascii__int", + "pypika/tests/test_functions.py::StringTests::test__ascii__str", + "pypika/tests/test_functions.py::StringTests::test__bin__field", + "pypika/tests/test_functions.py::StringTests::test__bin__int", + "pypika/tests/test_functions.py::StringTests::test__bin__str", + "pypika/tests/test_functions.py::StringTests::test__concat__field", + "pypika/tests/test_functions.py::StringTests::test__concat__str", + "pypika/tests/test_functions.py::StringTests::test__insert__field", + "pypika/tests/test_functions.py::StringTests::test__insert__str", + "pypika/tests/test_functions.py::StringTests::test__length__field", + "pypika/tests/test_functions.py::StringTests::test__length__str", + "pypika/tests/test_functions.py::StringTests::test__lower__field", + "pypika/tests/test_functions.py::StringTests::test__lower__str", + "pypika/tests/test_functions.py::StringTests::test__replace__field", + "pypika/tests/test_functions.py::StringTests::test__replace__str", + "pypika/tests/test_functions.py::StringTests::test__substring", + "pypika/tests/test_functions.py::SplitPartFunctionTests::test__split_part", + "pypika/tests/test_functions.py::RegexpLikeFunctionTests::test__regexp_like", + "pypika/tests/test_functions.py::CastTests::test__cast__as", + "pypika/tests/test_functions.py::CastTests::test__cast__binary", + "pypika/tests/test_functions.py::CastTests::test__cast__binary_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__boolean", + "pypika/tests/test_functions.py::CastTests::test__cast__char", + "pypika/tests/test_functions.py::CastTests::test__cast__char_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__date", + "pypika/tests/test_functions.py::CastTests::test__cast__float", + "pypika/tests/test_functions.py::CastTests::test__cast__integer", + "pypika/tests/test_functions.py::CastTests::test__cast__long_varbinary", + "pypika/tests/test_functions.py::CastTests::test__cast__long_varbinary_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__long_varchar", + "pypika/tests/test_functions.py::CastTests::test__cast__long_varchar_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__numeric", + "pypika/tests/test_functions.py::CastTests::test__cast__signed", + "pypika/tests/test_functions.py::CastTests::test__cast__timestamp", + "pypika/tests/test_functions.py::CastTests::test__cast__unsigned", + "pypika/tests/test_functions.py::CastTests::test__cast__varbinary", + "pypika/tests/test_functions.py::CastTests::test__cast__varbinary_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__varchar", + "pypika/tests/test_functions.py::CastTests::test__cast__varchar_with_arg", + "pypika/tests/test_functions.py::CastTests::test__tochar__", + "pypika/tests/test_functions.py::DateFunctionsTests::test_current_date", + "pypika/tests/test_functions.py::DateFunctionsTests::test_current_time", + "pypika/tests/test_functions.py::DateFunctionsTests::test_current_timestamp", + "pypika/tests/test_functions.py::DateFunctionsTests::test_current_timestamp_with_alias", + "pypika/tests/test_functions.py::DateFunctionsTests::test_date_add", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_day", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_hour", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_join", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_microsecond", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_minute", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_month", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_quarter", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_second", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_week", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_year", + "pypika/tests/test_functions.py::DateFunctionsTests::test_now", + "pypika/tests/test_functions.py::DateFunctionsTests::test_time_diff", + "pypika/tests/test_functions.py::DateFunctionsTests::test_timestampadd", + "pypika/tests/test_functions.py::DateFunctionsTests::test_to_date", + "pypika/tests/test_functions.py::DateFunctionsTests::test_utc_timestamp", + "pypika/tests/test_functions.py::NullFunctionsTests::test_coalesce", + "pypika/tests/test_functions.py::NullFunctionsTests::test_isnull", + "pypika/tests/test_functions.py::NullFunctionsTests::test_nullif", + "pypika/tests/test_functions.py::NullFunctionsTests::test_nvl", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_mysql_one_groupby", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_mysql_rollup_two_groupbys", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_no_rollup_after_rollup_mysql", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_no_rollup_before_groupby", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_from_groupbys", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_from_parameters", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_from_two_groupbys", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_func_one_groupby", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_func_partial", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_func_two_groupbys", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_multiple_rollups", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_rollups_with_multiple_rollups_and_parity", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_rollups_with_parity", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_force_index_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_groupby_returns_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_immutable_kwarg_on_query_builder_disables_immutability", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_insert_into_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_join_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_orderby_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_queries_after_join", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_replace_into_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_select_returns_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_update_set_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_use_index_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_with_return_new_query_instance", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_multi_rows", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_multi_rows_chained", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_multi_rows_chained_mixed", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_multi_rows_chained_multiple_rows", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_single_element", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_column_using_alias_with_chain", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_column_using_table_alias", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_empty_columns", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_empty_columns_type_list", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_empty_columns_type_tuple", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_ignore", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_multiple_rows_with_array_value", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_none_skipped", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_null", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_one_column", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_one_column_multi_element_array", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_one_column_single_element_array", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_selected_columns", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_selected_columns_type_list", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_selected_columns_type_tuple", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_single_row_with_array_value", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_with_statement", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_empty_on_conflict_do_update_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_field", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_field_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_mixed_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_multiple_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_multiple_fields_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_field", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_field_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_multiple_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_multiple_fields_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_multiple_mixed_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_no_handler", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_two_handlers_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_two_handlers_do_update", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_fieldless_conflict_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_fieldless_conflict_do_update_field", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_non_insert_on_conflict_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_non_insert_on_conflict_do_update", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_do_nothing_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_do_update_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_do_update_with_excluded_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_from_subquery", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_complex", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_conflict_fields_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_conflict_fields_do_update", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_empty_conflict_fields_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_empty_conflict_fields_do_update", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_where_and_on_conflict_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_all_columns_multi_rows_chained_returning_star", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_all_columns_multi_rows_chained_returning_star_and_id", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_all_columns_multi_rows_chained_returning_star_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_all_columns_single_element_arrays", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_aggregate", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_all_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_all_fields_and_arithmetics", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_arithmetics", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_from_other_table", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_functions", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_null", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_one_field", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_one_field_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_tuple", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_ignore", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multi_rows_chained_mixed_on_duplicate_update_multiple", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_multiple", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_different_value", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_expression", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_expression_using_original_field_value", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_expression_using_values", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_same_value", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_none_skipped", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_one_column", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_one_column_multi_element_array", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_one_column_single_element_array", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_one_column_using_values", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_selected_columns_on_duplicate_update_multiple", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_selected_columns_on_duplicate_update_one", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_columns_from_columns", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_columns_from_columns_with_join", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_columns_from_star", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_from_columns", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_ignore_star", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_star", + "pypika/tests/test_inserts.py::InsertSubqueryTests::test_insert_subquery_wrapped_in_brackets", + "pypika/tests/test_inserts.py::SelectIntoTests::test_select_columns_into", + "pypika/tests/test_inserts.py::SelectIntoTests::test_select_columns_into_with_join", + "pypika/tests/test_inserts.py::SelectIntoTests::test_select_star_into", + "pypika/tests/test_inserts.py::ReplaceTests::test_replace_simple", + "pypika/tests/test_inserts.py::ReplaceTests::test_replace_subquery", + "pypika/tests/test_internals.py::TablesTests::test__case_tables", + "pypika/tests/test_internals.py::TablesTests::test__criterion_replace_table_with_value", + "pypika/tests/test_internals.py::TablesTests::test__star_tables", + "pypika/tests/test_internals.py::TablesTests::test__table_star_tables", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_cross_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_cross_join_on_subquery", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_cross_join_on_table", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_default_join_type", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_full_outer_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_hash_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_inner_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_arithmetic_field", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_collate", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_complex_criteria", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_field_multi", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_field_multi_with_extra_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_field_single", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_field_without_fields_raises_exception", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_subquery_criteria", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_second_table_in_from_clause", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_using_multiple_fields", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_using_string_field_name", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_using_with_quote_char", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_using_without_fields_raises_exception", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_with_arithmetic_function_in_select", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_left_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_left_outer_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_outer_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_right_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_right_outer_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_temporal_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_use_different_table_objects_for_same_table", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_fail_when_joining_unknown_type", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_ignore_table_references", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_immutable__tables", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_from_join", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_query_with_column_alias", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_query_with_setoperation", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_query_with_table_alias", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_query_without_alias", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_same_table", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_same_table_with_prefixes", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_table_twice", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_prefixes_added_to_function_in_orderby", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_prefixes_added_to_groupby", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_prefixes_added_to_orderby", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_require_condition", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_require_condition_with_both_tables", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select__fields_after_table_star", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select__ordered_select_clauses", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select__star_for_table", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select__star_for_table__replacement", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select_field_from_missing_table", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select_fields_with_where", + "pypika/tests/test_joins.py::UnionTests::test_mysql_query_wraps_unioned_queries", + "pypika/tests/test_joins.py::UnionTests::test_require_equal_number_of_fields", + "pypika/tests/test_joins.py::UnionTests::test_union", + "pypika/tests/test_joins.py::UnionTests::test_union_all", + "pypika/tests/test_joins.py::UnionTests::test_union_all_multiple", + "pypika/tests/test_joins.py::UnionTests::test_union_as_subquery", + "pypika/tests/test_joins.py::UnionTests::test_union_multiple", + "pypika/tests/test_joins.py::UnionTests::test_union_with_no_quote_char", + "pypika/tests/test_joins.py::UnionTests::test_union_with_order_by", + "pypika/tests/test_joins.py::UnionTests::test_union_with_order_by_use_union_query_field", + "pypika/tests/test_joins.py::UnionTests::test_union_with_order_by_use_union_query_field_with_aliases", + "pypika/tests/test_joins.py::UnionTests::test_union_with_order_by_with_aliases", + "pypika/tests/test_joins.py::InsertQueryJoinTests::test_join_table_on_insert_query", + "pypika/tests/test_joins.py::UpdateQueryJoinTests::test_join_table_on_update_query", + "pypika/tests/test_joins.py::IntersectTests::test_intersect", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_as_subquery", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_multiple", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_with_limit", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_with_no_quote_char", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_with_offset", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_with_order_by", + "pypika/tests/test_joins.py::IntersectTests::test_mysql_query_wraps_intersected_queries", + "pypika/tests/test_joins.py::IntersectTests::test_require_equal_number_of_fields_intersect", + "pypika/tests/test_joins.py::MinusTests::test_minus", + "pypika/tests/test_joins.py::MinusTests::test_minus_as_subquery", + "pypika/tests/test_joins.py::MinusTests::test_minus_multiple", + "pypika/tests/test_joins.py::MinusTests::test_minus_query_with_order_by_use_minus_query_field", + "pypika/tests/test_joins.py::MinusTests::test_minus_with_no_quote_char", + "pypika/tests/test_joins.py::MinusTests::test_minus_with_order_by", + "pypika/tests/test_joins.py::MinusTests::test_mysql_query_wraps_minus_queries", + "pypika/tests/test_joins.py::MinusTests::test_require_equal_number_of_fields", + "pypika/tests/test_joins.py::ExceptOfTests::test_except", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_as_subquery", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_multiple", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_query_with_order_by_use_minus_query_field", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_with_no_quote_char", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_with_order_by", + "pypika/tests/test_joins.py::ExceptOfTests::test_require_equal_number_of_fields_except_of", + "pypika/tests/test_negation.py::NegationTests::test_negate_field", + "pypika/tests/test_negation.py::NegationTests::test_negate_function", + "pypika/tests/test_negation.py::NegationTests::test_negate_wrapped_float", + "pypika/tests/test_negation.py::NegationTests::test_negate_wrapped_int", + "pypika/tests/test_parameter.py::ParametrizedTests::test_format_parameter", + "pypika/tests/test_parameter.py::ParametrizedTests::test_join", + "pypika/tests/test_parameter.py::ParametrizedTests::test_named_parameter", + "pypika/tests/test_parameter.py::ParametrizedTests::test_numeric_parameter", + "pypika/tests/test_parameter.py::ParametrizedTests::test_param_insert", + "pypika/tests/test_parameter.py::ParametrizedTests::test_param_select_join", + "pypika/tests/test_parameter.py::ParametrizedTests::test_param_select_subquery", + "pypika/tests/test_parameter.py::ParametrizedTests::test_pyformat_parameter", + "pypika/tests/test_parameter.py::ParametrizedTests::test_qmark_parameter", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_join", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_join_with_parameter_value_wrapper", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_param_insert", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_param_select_join", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_param_select_subquery", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_pyformat_parameter", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_can_be_used_in_a_select_statement", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_can_be_used_in_a_where_clause", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_can_be_used_in_orderby", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_column_value", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_object_id", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_object_value", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_row_id", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_row_num", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_sys_date", + "pypika/tests/test_query.py::QueryTablesTests::test_is_joined", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_case_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_delete_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_filter_tables", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_having_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_insert_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_insert_table_current_table_not_match", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_join_tables", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_only_specified_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_orderby_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_tuple_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_update_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_update_table_current_table_not_match", + "pypika/tests/test_query.py::QueryBuilderTests::test_pipe", + "pypika/tests/test_query.py::QueryBuilderTests::test_query_builders_have_reference_to_correct_query_class", + "pypika/tests/test_selects.py::SelectTests::test_empty_query", + "pypika/tests/test_selects.py::SelectTests::test_mssql_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_mysql_query_uses_backtick_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_oracle_query_uses_no_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_postgresql_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_redshift_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_select__column__single__alias__str", + "pypika/tests/test_selects.py::SelectTests::test_select__column__single__field", + "pypika/tests/test_selects.py::SelectTests::test_select__column__single__str", + "pypika/tests/test_selects.py::SelectTests::test_select__column__single__table_alias__str", + "pypika/tests/test_selects.py::SelectTests::test_select__columns__multi__field", + "pypika/tests/test_selects.py::SelectTests::test_select__columns__multi__str", + "pypika/tests/test_selects.py::SelectTests::test_select__distinct__multi", + "pypika/tests/test_selects.py::SelectTests::test_select__distinct__single", + "pypika/tests/test_selects.py::SelectTests::test_select__multiple_subqueries", + "pypika/tests/test_selects.py::SelectTests::test_select__multiple_tables", + "pypika/tests/test_selects.py::SelectTests::test_select__nested_subquery", + "pypika/tests/test_selects.py::SelectTests::test_select__no_table", + "pypika/tests/test_selects.py::SelectTests::test_select__star", + "pypika/tests/test_selects.py::SelectTests::test_select__star__replacement", + "pypika/tests/test_selects.py::SelectTests::test_select__subquery", + "pypika/tests/test_selects.py::SelectTests::test_select__table_schema", + "pypika/tests/test_selects.py::SelectTests::test_select__table_schema_with_multiple_levels_as_list", + "pypika/tests/test_selects.py::SelectTests::test_select__table_schema_with_multiple_levels_as_tuple", + "pypika/tests/test_selects.py::SelectTests::test_select_no_from", + "pypika/tests/test_selects.py::SelectTests::test_select_no_from_with_field_raises_exception", + "pypika/tests/test_selects.py::SelectTests::test_select_no_with_alias_from", + "pypika/tests/test_selects.py::SelectTests::test_select_then_add_table", + "pypika/tests/test_selects.py::SelectTests::test_select_with_force_index", + "pypika/tests/test_selects.py::SelectTests::test_select_with_force_index_multiple_calls", + "pypika/tests/test_selects.py::SelectTests::test_select_with_force_index_multiple_indexes", + "pypika/tests/test_selects.py::SelectTests::test_select_with_force_index_with_index_object", + "pypika/tests/test_selects.py::SelectTests::test_select_with_limit", + "pypika/tests/test_selects.py::SelectTests::test_select_with_limit__func", + "pypika/tests/test_selects.py::SelectTests::test_select_with_limit_and_offset", + "pypika/tests/test_selects.py::SelectTests::test_select_with_limit_zero", + "pypika/tests/test_selects.py::SelectTests::test_select_with_offset", + "pypika/tests/test_selects.py::SelectTests::test_select_with_offset__func", + "pypika/tests/test_selects.py::SelectTests::test_select_with_use_index", + "pypika/tests/test_selects.py::SelectTests::test_select_with_use_index_multiple_calls", + "pypika/tests/test_selects.py::SelectTests::test_select_with_use_index_multiple_indexes", + "pypika/tests/test_selects.py::SelectTests::test_select_with_use_index_with_index_object", + "pypika/tests/test_selects.py::SelectTests::test_table_select_alias", + "pypika/tests/test_selects.py::SelectTests::test_table_select_alias_with_offset_and_limit", + "pypika/tests/test_selects.py::SelectTests::test_temporal_select", + "pypika/tests/test_selects.py::SelectTests::test_vertica_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::WhereTests::test_ignore_empty_criterion_having", + "pypika/tests/test_selects.py::WhereTests::test_ignore_empty_criterion_where", + "pypika/tests/test_selects.py::WhereTests::test_select_with_force_index_and_where", + "pypika/tests/test_selects.py::WhereTests::test_where_enum", + "pypika/tests/test_selects.py::WhereTests::test_where_field_contains", + "pypika/tests/test_selects.py::WhereTests::test_where_field_does_not_contain", + "pypika/tests/test_selects.py::WhereTests::test_where_field_does_not_end_with", + "pypika/tests/test_selects.py::WhereTests::test_where_field_does_not_start_with", + "pypika/tests/test_selects.py::WhereTests::test_where_field_ends_with", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_and", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_nowait", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_of", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_of_multiple_tables", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_of_nowait", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_of_skip_locked", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_skip_locked", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_skip_locked_and_of", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_or", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_where", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_where_not", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_where_two_not", + "pypika/tests/test_selects.py::WhereTests::test_where_field_is_n_chars_long", + "pypika/tests/test_selects.py::WhereTests::test_where_field_is_not_n_chars_long", + "pypika/tests/test_selects.py::WhereTests::test_where_field_matches_regex", + "pypika/tests/test_selects.py::WhereTests::test_where_field_matches_regexp", + "pypika/tests/test_selects.py::WhereTests::test_where_field_matches_rlike", + "pypika/tests/test_selects.py::WhereTests::test_where_field_starts_with", + "pypika/tests/test_selects.py::WhereTests::test_where_nested_conditions", + "pypika/tests/test_selects.py::WhereTests::test_where_single_quote", + "pypika/tests/test_selects.py::WhereTests::test_where_with_multiple_wheres_using_and_case", + "pypika/tests/test_selects.py::WhereTests::test_where_with_multiple_wheres_using_or_case", + "pypika/tests/test_selects.py::PreWhereTests::test_ignore_empty_criterion_having", + "pypika/tests/test_selects.py::PreWhereTests::test_ignore_empty_criterion_where", + "pypika/tests/test_selects.py::PreWhereTests::test_prewhere_field_equals", + "pypika/tests/test_selects.py::PreWhereTests::test_select_with_force_index_and_where", + "pypika/tests/test_selects.py::PreWhereTests::test_where_and_prewhere", + "pypika/tests/test_selects.py::PreWhereTests::test_where_enum", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_contains", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_does_not_contain", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_does_not_end_with", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_does_not_start_with", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_ends_with", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_and", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_nowait", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_of", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_of_multiple_tables", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_of_nowait", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_of_skip_locked", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_skip_locked", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_skip_locked_and_of", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_or", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_where", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_where_not", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_where_two_not", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_is_n_chars_long", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_is_not_n_chars_long", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_matches_regex", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_matches_regexp", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_matches_rlike", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_starts_with", + "pypika/tests/test_selects.py::PreWhereTests::test_where_nested_conditions", + "pypika/tests/test_selects.py::PreWhereTests::test_where_single_quote", + "pypika/tests/test_selects.py::PreWhereTests::test_where_with_multiple_wheres_using_and_case", + "pypika/tests/test_selects.py::PreWhereTests::test_where_with_multiple_wheres_using_or_case", + "pypika/tests/test_selects.py::GroupByTests::test_group_by__single_with_totals", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__alias", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__alias_platforms", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__alias_with_join", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__count_distinct", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__count_field", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__count_star", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__int", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__multi", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__multi_with_totals", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__no_alias", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__no_alias_mssql", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__no_alias_oracle", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__single", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__str", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__sum_distinct", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__sum_filter", + "pypika/tests/test_selects.py::GroupByTests::test_groupby_with_case_uses_the_alias", + "pypika/tests/test_selects.py::GroupByTests::test_mssql_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_mysql_query_uses_backtick_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_oracle_query_uses_no_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_postgres_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_redshift_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_vertica_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_having_and", + "pypika/tests/test_selects.py::HavingTests::test_having_greater_than", + "pypika/tests/test_selects.py::HavingTests::test_having_join_and_equality", + "pypika/tests/test_selects.py::HavingTests::test_mssql_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_mysql_query_uses_backtick_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_oracle_query_uses_no_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_postgres_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_redshift_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_vertica_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_alias", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_asc", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_desc", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_multi_fields", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_no_alias", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_single_field", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_single_str", + "pypika/tests/test_selects.py::AliasTests::test_arithmetic_function", + "pypika/tests/test_selects.py::AliasTests::test_case_using_as", + "pypika/tests/test_selects.py::AliasTests::test_case_using_constructor_param", + "pypika/tests/test_selects.py::AliasTests::test_function_using_as_nested", + "pypika/tests/test_selects.py::AliasTests::test_functions_using_as", + "pypika/tests/test_selects.py::AliasTests::test_functions_using_constructor_param", + "pypika/tests/test_selects.py::AliasTests::test_functions_using_constructor_param_nested", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_criterion", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_criterion_comparison", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_field_inside_case", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_groupby", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_orderby", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_where", + "pypika/tests/test_selects.py::AliasTests::test_null_value_with_alias", + "pypika/tests/test_selects.py::AliasTests::test_select__multiple_tables", + "pypika/tests/test_selects.py::AliasTests::test_table_field", + "pypika/tests/test_selects.py::AliasTests::test_table_field__multi", + "pypika/tests/test_selects.py::AliasTests::test_table_with_schema_and_alias", + "pypika/tests/test_selects.py::AliasTests::test_use_aliases_in_groupby_and_orderby", + "pypika/tests/test_selects.py::SubqueryTests::test_from_subquery_without_alias", + "pypika/tests/test_selects.py::SubqueryTests::test_join", + "pypika/tests/test_selects.py::SubqueryTests::test_join_query_with_alias", + "pypika/tests/test_selects.py::SubqueryTests::test_join_with_with", + "pypika/tests/test_selects.py::SubqueryTests::test_select_from_nested_query", + "pypika/tests/test_selects.py::SubqueryTests::test_select_from_nested_query_with_join", + "pypika/tests/test_selects.py::SubqueryTests::test_select_from_with_returning", + "pypika/tests/test_selects.py::SubqueryTests::test_select_subquery", + "pypika/tests/test_selects.py::SubqueryTests::test_select_subquery_with_alias", + "pypika/tests/test_selects.py::SubqueryTests::test_where__equality", + "pypika/tests/test_selects.py::SubqueryTests::test_where__in", + "pypika/tests/test_selects.py::SubqueryTests::test_where__in_nested", + "pypika/tests/test_selects.py::SubqueryTests::test_with", + "pypika/tests/test_selects.py::QuoteTests::test_extraneous_quotes", + "pypika/tests/test_tables.py::TableStructureTests::test_database_schema_table_attr", + "pypika/tests/test_tables.py::TableStructureTests::test_schema_table_attr", + "pypika/tests/test_tables.py::TableStructureTests::test_table_for_period_sql", + "pypika/tests/test_tables.py::TableStructureTests::test_table_for_system_time_sql", + "pypika/tests/test_tables.py::TableStructureTests::test_table_sql", + "pypika/tests/test_tables.py::TableStructureTests::test_table_with_alias", + "pypika/tests/test_tables.py::TableStructureTests::test_table_with_schema_and_schema_parent_arg", + "pypika/tests/test_tables.py::TableStructureTests::test_table_with_schema_arg", + "pypika/tests/test_tables.py::TableEqualityTests::test_many_tables_with_alias", + "pypika/tests/test_tables.py::TableEqualityTests::test_many_tables_with_or_not_alias", + "pypika/tests/test_tables.py::TableEqualityTests::test_many_tables_without_alias", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_equal_by_name", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_equal_by_schema_and_name", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_equal_by_schema_and_name_using_schema", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_equal_by_schema_and_name_using_schema_with_parent", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_not_equal_by_schema_and_name_using_schema_with_different_parents", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_not_equal_with_different_names", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_not_equal_with_different_schemas", + "pypika/tests/test_tables.py::TableDialectTests::test_make_tables_factory_with_default_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_make_tables_factory_with_dialect_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_factory_with_default_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_factory_with_dialect_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_with_bad_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_with_default_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_with_dialect_query_cls", + "pypika/tests/test_terms.py::FieldAliasTests::test_when_alias_specified", + "pypika/tests/test_terms.py::FieldInitTests::test_init_with_str_table", + "pypika/tests/test_terms.py::FieldHashingTests::test_non_tabled_aliased_eq_fields_equally_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_non_tabled_aliased_ne_fields_differently_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_non_tabled_eq_fields_equally_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_non_tabled_ne_fields_differently_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_tabled_eq_fields_equally_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_tabled_ne_fields_differently_hashed", + "pypika/tests/test_terms.py::AtTimezoneTests::test_passes_kwargs_to_field_get_sql", + "pypika/tests/test_terms.py::AtTimezoneTests::test_when_alias_specified", + "pypika/tests/test_terms.py::AtTimezoneTests::test_when_interval_not_specified", + "pypika/tests/test_terms.py::AtTimezoneTests::test_when_interval_specified", + "pypika/tests/test_tuples.py::TupleTests::test_render_alias_in_array_sql", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_equality_tuple_on_both", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_equality_tuple_on_left", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_equality_tuple_on_right", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_in_using_mixed_tuples", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_in_using_pypika_tuples", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_in_using_python_tuples", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_is_aggregate", + "pypika/tests/test_tuples.py::TupleTests::test_tuples_in_join", + "pypika/tests/test_tuples.py::ArrayTests::test_array_general", + "pypika/tests/test_tuples.py::ArrayTests::test_empty_psql_array", + "pypika/tests/test_tuples.py::ArrayTests::test_psql_array_general", + "pypika/tests/test_tuples.py::ArrayTests::test_render_alias_in_array_sql", + "pypika/tests/test_tuples.py::BracketTests::test_arithmetic_with_brackets", + "pypika/tests/test_tuples.py::BracketTests::test_arithmetic_with_brackets_and_alias", + "pypika/tests/test_updates.py::UpdateTests::test_empty_query", + "pypika/tests/test_updates.py::UpdateTests::test_for_portion", + "pypika/tests/test_updates.py::UpdateTests::test_omit_where", + "pypika/tests/test_updates.py::UpdateTests::test_single_quote_escape_in_set", + "pypika/tests/test_updates.py::UpdateTests::test_update__table_schema", + "pypika/tests/test_updates.py::UpdateTests::test_update_from", + "pypika/tests/test_updates.py::UpdateTests::test_update_from_with_where", + "pypika/tests/test_updates.py::UpdateTests::test_update_with_join", + "pypika/tests/test_updates.py::UpdateTests::test_update_with_limit", + "pypika/tests/test_updates.py::UpdateTests::test_update_with_none", + "pypika/tests/test_updates.py::UpdateTests::test_update_with_statement", + "pypika/tests/test_updates.py::PostgresUpdateTests::test_update_returning", + "pypika/tests/test_updates.py::PostgresUpdateTests::test_update_returning_from_different_tables", + "pypika/tests/test_updates.py::PostgresUpdateTests::test_update_returning_star", + "pypika/tests/test_updates.py::PostgresUpdateTests::test_update_returning_str", + "pypika/tests/test_updates.py::SQLLiteUpdateTests::test_update_with_bool", + "pypika/tests/test_utils.py::ImmutabilityTests::test_raise_attribute_error_for_deepcopy", + "pypika/tests/test_utils.py::ImmutabilityTests::test_raise_attribute_error_for_getnewargs", + "pypika/tests/test_utils.py::ImmutabilityTests::test_raise_attribute_error_for_getstate", + "pypika/tests/test_utils.py::ImmutabilityTests::test_raise_attribute_error_for_setstate" + ], + "all_git_blobs_modes_verified": true, + "cloud_launch_ready": false, + "commits": { + "bug": "cb6e228b45d8ac80bc16a7b1d97fd8269778c233", + "healthy": "6a742f12bfa386994289ec8b75824663d8ee4b15", + "learner": "e3bf2d032fde8913105fb8a570fb062c62ec6292" + }, + "existing_squirrel_snapshot_reused": false, + "full_transfer_allowlist": [ + "/testbed/.coveragerc", + "/testbed/.gitignore", + "/testbed/.pre-commit-config.yaml", + "/testbed/CODEOWNERS", + "/testbed/CONTRIBUTING.rst", + "/testbed/LICENSE.txt", + "/testbed/MANIFEST.in", + "/testbed/Makefile", + "/testbed/README.rst", + "/testbed/docs/1_installation.rst", + "/testbed/docs/2_tutorial.rst", + "/testbed/docs/3_advanced.rst", + "/testbed/docs/4_extending.rst", + "/testbed/docs/5_reference.rst", + "/testbed/docs/6_contributing.rst", + "/testbed/docs/Makefile", + "/testbed/docs/api/pypika.analytics.rst", + "/testbed/docs/api/pypika.dialects.rst", + "/testbed/docs/api/pypika.enums.rst", + "/testbed/docs/api/pypika.functions.rst", + "/testbed/docs/api/pypika.pseudocolumns.rst", + "/testbed/docs/api/pypika.queries.rst", + "/testbed/docs/api/pypika.rst", + "/testbed/docs/api/pypika.terms.rst", + "/testbed/docs/api/pypika.utils.rst", + "/testbed/docs/conf.py", + "/testbed/docs/index.rst", + "/testbed/pypika/__init__.py", + "/testbed/pypika/analytics.py", + "/testbed/pypika/clickhouse/__init__.py", + "/testbed/pypika/clickhouse/array.py", + "/testbed/pypika/clickhouse/condition.py", + "/testbed/pypika/clickhouse/dates_and_times.py", + "/testbed/pypika/clickhouse/nullable_arg.py", + "/testbed/pypika/clickhouse/search_string.py", + "/testbed/pypika/clickhouse/type_conversion.py", + "/testbed/pypika/dialects.py", + "/testbed/pypika/enums.py", + "/testbed/pypika/functions.py", + "/testbed/pypika/pseudocolumns.py", + "/testbed/pypika/py.typed", + "/testbed/pypika/queries.py", + "/testbed/pypika/terms.py", + "/testbed/pypika/tests/__init__.py", + "/testbed/pypika/tests/clickhouse/__init__.py", + "/testbed/pypika/tests/clickhouse/test_array.py", + "/testbed/pypika/tests/clickhouse/test_dates_and_times.py", + "/testbed/pypika/tests/clickhouse/test_type_conversion.py", + "/testbed/pypika/tests/dialects/__init__.py", + "/testbed/pypika/tests/dialects/test_clickhouse.py", + "/testbed/pypika/tests/dialects/test_mssql.py", + "/testbed/pypika/tests/dialects/test_mysql.py", + "/testbed/pypika/tests/dialects/test_oracle.py", + "/testbed/pypika/tests/dialects/test_postgresql.py", + "/testbed/pypika/tests/dialects/test_snowflake.py", + "/testbed/pypika/tests/dialects/test_sqllite.py", + "/testbed/pypika/tests/dialects/test_vertica.py", + "/testbed/pypika/tests/test_aggregate.py", + "/testbed/pypika/tests/test_analytic_queries.py", + "/testbed/pypika/tests/test_create.py", + "/testbed/pypika/tests/test_criterions.py", + "/testbed/pypika/tests/test_custom_functions.py", + "/testbed/pypika/tests/test_data_types.py", + "/testbed/pypika/tests/test_date_math.py", + "/testbed/pypika/tests/test_deletes.py", + "/testbed/pypika/tests/test_drop.py", + "/testbed/pypika/tests/test_formats.py", + "/testbed/pypika/tests/test_functions.py", + "/testbed/pypika/tests/test_groupby_modifiers.py", + "/testbed/pypika/tests/test_immutability.py", + "/testbed/pypika/tests/test_inserts.py", + "/testbed/pypika/tests/test_internals.py", + "/testbed/pypika/tests/test_joins.py", + "/testbed/pypika/tests/test_negation.py", + "/testbed/pypika/tests/test_parameter.py", + "/testbed/pypika/tests/test_pseudocolumns.py", + "/testbed/pypika/tests/test_query.py", + "/testbed/pypika/tests/test_selects.py", + "/testbed/pypika/tests/test_tables.py", + "/testbed/pypika/tests/test_terms.py", + "/testbed/pypika/tests/test_tuples.py", + "/testbed/pypika/tests/test_updates.py", + "/testbed/pypika/tests/test_utils.py", + "/testbed/pypika/utils.py", + "/testbed/pyproject.toml", + "/testbed/requirements-dev.txt", + "/testbed/setup.cfg", + "/testbed/setup.py", + "/testbed/tox.ini" + ], + "healthy_stage_meaning": "Direct parent of the mutation; no source or test execution has been performed", + "mutation_matches_dataset_and_git_blobs": true, + "official_profile": { + "eval_sets": [], + "profile_class": "Pypika1c9646f0", + "profile_lines": [ + 736, + 739 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "upstream_repo": "kayak/pypika" + }, + "original_source_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "private_test_paths": [ + "pypika/tests/clickhouse/test_condition.py", + "pypika/tests/clickhouse/test_nullable_arg.py", + "pypika/tests/clickhouse/test_search_string.py" + ], + "private_tests_unchanged": true, + "profile_mapping_basis": "Explicit upstream repo and full commit fields parsed from pinned official Python profile AST, not basename inference", + "qwen_calibrated": false, + "runtime_qualified": false, + "source_paths": [ + "pypika/clickhouse/condition.py", + "pypika/clickhouse/nullable_arg.py", + "pypika/clickhouse/search_string.py" + ], + "source_repo": "swesmith/kayak__pypika.1c9646f0", + "source_stages_bytes": 1892616, + "task_id": "kayak__pypika.1c9646f0.combine_module__ahdnka55", + "transfer_limitation": "Existing regular files only; new arbitrary file additions need a qualified patch adapter", + "upstream_repo": "kayak/pypika" + }, + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:kayak__pypika.1c9646f0.combine_module__ahdnka55", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "6a742f12bfa386994289ec8b75824663d8ee4b15", + "instruction_sha256": "0f431895660b7afac9b6e276f50390fe4dafe5764497a31576bfebd211e6e505", + "is_fork": true, + "learner_path": "tasks/2452fac346ef9d98f8514d9a/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "actual_upstream_url": "https://raw.githubusercontent.com/kayak/pypika/1c9646f0a019a167c32b649b6f5e6423c5ba2c9b/LICENSE.txt", + "reviewed": true, + "sha256": "c5accbbd8546e94c34aed24afe689a617627d18eed5a6c48277e48db57c23851", + "spdx": "Apache-2.0", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/kayak__pypika.1c9646f0/e3bf2d032fde8913105fb8a570fb062c62ec6292/LICENSE.txt" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "patch_sha256": "fcaa27f3bdbed02fe49b3107220eabe1df141be815fc9df9a398aa57dbd84224", + "provenance_path": "tasks/2452fac346ef9d98f8514d9a/source-proof.json", + "repository_lineage": [ + "swesmith/kayak__pypika.1c9646f0", + "kayak/pypika" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "e3bf2d032fde8913105fb8a570fb062c62ec6292", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "cb6e228b45d8ac80bc16a7b1d97fd8269778c233", + "source_kind": "mutation", + "source_repo": "swesmith/kayak__pypika.1c9646f0", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "kayak__pypika.1c9646f0.combine_module__ahdnka55", + "task_sha256": "77bae1d1f202f63a510f39cc58937cad494f1d30660cd83e66205d6dae8d9bec", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "kayak/pypika", + "usage": "quarantine_only" + }, + "task_kind": "original-source-mutation" +} diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/provenance.json b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/provenance.json new file mode 100644 index 0000000000000000000000000000000000000000..d59cdc0a31af662c1c7653b7eb9e5d0ed5277b05 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/provenance.json @@ -0,0 +1,88 @@ +{ + "generated_reference": false, + "healthy_reference_delta_sha256": "4002260d0cefb6481fa51bb2fc851979934dc9ed6acd7b0328beaf11c86a7b33", + "native_pytest_ids_preserved": true, + "original_source_code_license": { + "actual_upstream_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "actual_upstream_url": "https://raw.githubusercontent.com/kayak/pypika/1c9646f0a019a167c32b649b6f5e6423c5ba2c9b/LICENSE.txt", + "reviewed": true, + "sha256": "c5accbbd8546e94c34aed24afe689a617627d18eed5a6c48277e48db57c23851", + "spdx": "Apache-2.0", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/kayak__pypika.1c9646f0/e3bf2d032fde8913105fb8a570fb062c62ec6292/LICENSE.txt" + }, + "provided_reference": true, + "qwen_calibrated": false, + "runtime_qualified": false, + "source_completion_sha256": "2fdfd68871c98bdf555f2ee2ee0cf4f80cf2b7bbdfe4f7ed9ae516389b7e36a9", + "source_index_sha256": "e856874b9410fce9f3bfea52c8c482e84b3e43942d87517f8b55f0034bd40f6f", + "source_proof_sha256": "ef37e43c27d36f9971a66b7aff2c93a8dceeb859cd306766ac5bbfd49db7511f", + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:kayak__pypika.1c9646f0.combine_module__ahdnka55", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "6a742f12bfa386994289ec8b75824663d8ee4b15", + "instruction_sha256": "0f431895660b7afac9b6e276f50390fe4dafe5764497a31576bfebd211e6e505", + "is_fork": true, + "learner_path": "tasks/2452fac346ef9d98f8514d9a/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "actual_upstream_url": "https://raw.githubusercontent.com/kayak/pypika/1c9646f0a019a167c32b649b6f5e6423c5ba2c9b/LICENSE.txt", + "reviewed": true, + "sha256": "c5accbbd8546e94c34aed24afe689a617627d18eed5a6c48277e48db57c23851", + "spdx": "Apache-2.0", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/kayak__pypika.1c9646f0/e3bf2d032fde8913105fb8a570fb062c62ec6292/LICENSE.txt" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "patch_sha256": "fcaa27f3bdbed02fe49b3107220eabe1df141be815fc9df9a398aa57dbd84224", + "provenance_path": "tasks/2452fac346ef9d98f8514d9a/source-proof.json", + "repository_lineage": [ + "swesmith/kayak__pypika.1c9646f0", + "kayak/pypika" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "e3bf2d032fde8913105fb8a570fb062c62ec6292", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "cb6e228b45d8ac80bc16a7b1d97fd8269778c233", + "source_kind": "mutation", + "source_repo": "swesmith/kayak__pypika.1c9646f0", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "kayak__pypika.1c9646f0.combine_module__ahdnka55", + "task_sha256": "77bae1d1f202f63a510f39cc58937cad494f1d30660cd83e66205d6dae8d9bec", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "kayak/pypika", + "usage": "quarantine_only" + }, + "task_bundle_license": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + }, + "training_admissible": false, + "trusted_tests_sha256": "f2d0a1b335176a755d627907f32ef330383cf624ff3af2c5ea84ba2b6a2d7ebb" +} diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/provided-gold.diff b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/provided-gold.diff new file mode 100644 index 0000000000000000000000000000000000000000..1a9e99a0e2460d9a6a0d1fc507ad71747c2e09be --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/provided-gold.diff @@ -0,0 +1,72 @@ +diff --git a/pypika/clickhouse/condition.py b/pypika/clickhouse/condition.py +index 46e2a0b8303c07f1d6b6d77b7f6d131ad3d8da3a..ed08224e22fb27eb18876595a542dcd3ad14bffc 100644 +--- a/pypika/clickhouse/condition.py ++++ b/pypika/clickhouse/condition.py +@@ -3,9 +3,9 @@ + + class If(Function): + def __init__(self, *conditions, **kwargs): +- super().__init__("switch", *reversed(conditions), **kwargs) ++ super().__init__("if", *conditions, **kwargs) + + + class MultiIf(Function): + def __init__(self, *conditions, **kwargs): +- super().__init__("multiIf", *conditions[::-1], **kwargs) ++ super().__init__("multiIf", *conditions, **kwargs) +diff --git a/pypika/clickhouse/nullable_arg.py b/pypika/clickhouse/nullable_arg.py +index 14f7b0f07fc2a03b93391dd57a15b28a5b2a7bf7..a3f23fe53af3174a33b002f6965e2d1ca06d2790 100644 +--- a/pypika/clickhouse/nullable_arg.py ++++ b/pypika/clickhouse/nullable_arg.py +@@ -3,4 +3,4 @@ + + class IfNull(Function): + def __init__(self, term, alt, **kwargs): +- super().__init__("ifNull", alt, term, **kwargs) ++ super().__init__("ifNull", term, alt, **kwargs) +diff --git a/pypika/clickhouse/search_string.py b/pypika/clickhouse/search_string.py +index 6fadbced1008bb922ef4d74873b8180191f95c9f..22a03027fcaf3ca0578e63980c00f4be1b2f67e7 100644 +--- a/pypika/clickhouse/search_string.py ++++ b/pypika/clickhouse/search_string.py +@@ -51,9 +51,9 @@ + + class _AbstractMultiSearchString(Function, metaclass=abc.ABCMeta): + def __init__(self, name, patterns: list, alias: str = None): +- super(_AbstractMultiSearchString, self).__init__(self, name, alias=alias) ++ super(_AbstractMultiSearchString, self).__init__(self.clickhouse_function(), name, alias=alias) + +- self._patterns = patterns[::-1] ++ self._patterns = patterns + + @classmethod + @abc.abstractmethod +@@ -64,13 +64,13 @@ + args = [] + for p in self.args: + if hasattr(p, "get_sql"): +- args.append('toString("{arg}")'.format(arg=p.get_sql(with_alias=True, **kwargs))) ++ args.append('toString("{arg}")'.format(arg=p.get_sql(with_alias=False, **kwargs))) + else: + args.append(str(p)) + +- sql = "{name}({args},{{patterns}})".format( ++ sql = "{name}({args},[{patterns}])".format( + name=self.name, +- args=";".join(args), ++ args=",".join(args), + patterns=",".join(["'%s'" % i for i in self._patterns]), + ) + return format_alias_sql(sql, self.alias, **kwargs) +@@ -79,10 +79,10 @@ + class MultiSearchAny(_AbstractMultiSearchString): + @classmethod + def clickhouse_function(cls) -> str: +- return "singleSearchAll" ++ return "multiSearchAny" + + + class MultiMatchAny(_AbstractMultiSearchString): + @classmethod + def clickhouse_function(cls) -> str: +- return "multiMatchAll" ++ return "multiMatchAny" diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/solution/solve.sh b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..6598b050617e8a328dad89fa418bc231d9063705 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/solution/solve.sh @@ -0,0 +1,78 @@ +#!/bin/bash +set -Eeuo pipefail +cd /testbed/repo +cat > /tmp/openenv-reference.diff <<'OPENENV_REFERENCE' +diff --git a/pypika/clickhouse/condition.py b/pypika/clickhouse/condition.py +index 46e2a0b8303c07f1d6b6d77b7f6d131ad3d8da3a..ed08224e22fb27eb18876595a542dcd3ad14bffc 100644 +--- a/pypika/clickhouse/condition.py ++++ b/pypika/clickhouse/condition.py +@@ -3,9 +3,9 @@ + + class If(Function): + def __init__(self, *conditions, **kwargs): +- super().__init__("switch", *reversed(conditions), **kwargs) ++ super().__init__("if", *conditions, **kwargs) + + + class MultiIf(Function): + def __init__(self, *conditions, **kwargs): +- super().__init__("multiIf", *conditions[::-1], **kwargs) ++ super().__init__("multiIf", *conditions, **kwargs) +diff --git a/pypika/clickhouse/nullable_arg.py b/pypika/clickhouse/nullable_arg.py +index 14f7b0f07fc2a03b93391dd57a15b28a5b2a7bf7..a3f23fe53af3174a33b002f6965e2d1ca06d2790 100644 +--- a/pypika/clickhouse/nullable_arg.py ++++ b/pypika/clickhouse/nullable_arg.py +@@ -3,4 +3,4 @@ + + class IfNull(Function): + def __init__(self, term, alt, **kwargs): +- super().__init__("ifNull", alt, term, **kwargs) ++ super().__init__("ifNull", term, alt, **kwargs) +diff --git a/pypika/clickhouse/search_string.py b/pypika/clickhouse/search_string.py +index 6fadbced1008bb922ef4d74873b8180191f95c9f..22a03027fcaf3ca0578e63980c00f4be1b2f67e7 100644 +--- a/pypika/clickhouse/search_string.py ++++ b/pypika/clickhouse/search_string.py +@@ -51,9 +51,9 @@ + + class _AbstractMultiSearchString(Function, metaclass=abc.ABCMeta): + def __init__(self, name, patterns: list, alias: str = None): +- super(_AbstractMultiSearchString, self).__init__(self, name, alias=alias) ++ super(_AbstractMultiSearchString, self).__init__(self.clickhouse_function(), name, alias=alias) + +- self._patterns = patterns[::-1] ++ self._patterns = patterns + + @classmethod + @abc.abstractmethod +@@ -64,13 +64,13 @@ + args = [] + for p in self.args: + if hasattr(p, "get_sql"): +- args.append('toString("{arg}")'.format(arg=p.get_sql(with_alias=True, **kwargs))) ++ args.append('toString("{arg}")'.format(arg=p.get_sql(with_alias=False, **kwargs))) + else: + args.append(str(p)) + +- sql = "{name}({args},{{patterns}})".format( ++ sql = "{name}({args},[{patterns}])".format( + name=self.name, +- args=";".join(args), ++ args=",".join(args), + patterns=",".join(["'%s'" % i for i in self._patterns]), + ) + return format_alias_sql(sql, self.alias, **kwargs) +@@ -79,10 +79,10 @@ + class MultiSearchAny(_AbstractMultiSearchString): + @classmethod + def clickhouse_function(cls) -> str: +- return "singleSearchAll" ++ return "multiSearchAny" + + + class MultiMatchAny(_AbstractMultiSearchString): + @classmethod + def clickhouse_function(cls) -> str: +- return "multiMatchAll" ++ return "multiMatchAny" +OPENENV_REFERENCE +/usr/bin/git -c core.hooksPath=/dev/null -c core.fsmonitor=false apply --whitespace=nowarn /tmp/openenv-reference.diff diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/task.toml b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..50438eac07ae76bdd1520290c0970e38fc21c88e --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/task.toml @@ -0,0 +1,24 @@ +version = "1.0" + +[agent] +timeout_sec = 1800.0 + +[verifier] +timeout_sec = 900.0 + +[environment] +docker_image = "ghcr.io/younesbelkada/scale800@sha256:6459942080751be0e13b909f76d149630678d6cde8134dd2ac2e2e54632c654d" +build_timeout_sec = 600.0 +cpus = 2 +memory_mb = 8192 +storage_mb = 16384 + +[metadata] +author_name = "SWE-smith source adapter" +category = "bugfix" +tags = ["swe", "python", "mutation-repair"] + +[environment.env] +# The image's PATH with the testbed env first: the project and pytest are installed there, and the agent's +# non-interactive shells never run `conda activate` +PATH = "/opt/miniconda3/envs/testbed/bin:/opt/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/check_pytest.py b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/check_pytest.py new file mode 100644 index 0000000000000000000000000000000000000000..7abfdc5972f57ca7f0cecbbeeb373414670f780e --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/check_pytest.py @@ -0,0 +1,177 @@ +"""Preserve confirmed requested assertion failures; keep positive checks strict.""" + +import argparse +import hashlib +import json +import re +import xml.etree.ElementTree as ET +from pathlib import Path + +GROUPS = ("pass-to-pass", "fail-to-pass") + + +def split_nodeid(target): + prefix, bracket, parameter = target.partition("[") + parts = prefix.split("::") + if bracket: + parts[-1] += bracket + parameter + return parts + + +def matches(case, target): + parts = split_nodeid(target) + module = parts[0].removesuffix(".py").replace("/", ".") + classname, name = case.get("classname", ""), case.get("name", "") + if not (classname == module or classname.startswith(module + ".")): + return False + selector = parts[-1] if len(parts) > 1 else "" + classes = parts[1:-1] + if classes and classname != module + "." + ".".join(classes): + return False + return ( + not selector + or name == selector + or ("[" not in selector and name.startswith(selector + "[")) + ) + + +def capture_panels(root): + panels, digests = {}, {} + for group in GROUPS: + path = Path(root) / (group + ".xml") + if not path.exists(): + panels[group] = None + continue + with path.open("rb") as stream: + raw = stream.read(4 * 1024**2 + 1) + if not 0 < len(raw) <= 4 * 1024**2 or re.search( + rb" 20000: + raise ValueError("Too many pytest cases") + identities = [(case.get("classname"), case.get("name")) for case in cases] + if len(identities) != len(set(identities)): + raise ValueError("Duplicate pytest case evidence") + panels[group] = cases + digests[group] = hashlib.sha256(raw).hexdigest() + return panels, digests + + +def strict_assess(panels, expected, native_exit): + """The original positive-approval conditions, applied to captured cases.""" + all_cases, actual_failure = [], False + for group in GROUPS: + cases = panels[group] + if cases is None: + if actual_failure: + continue + raise ValueError("Missing preceding pytest panel") + if actual_failure: + raise ValueError( + "Pytest evidence continued after the native stop-on-failure" + ) + targets = expected[group] + if any(not any(matches(case, target) for target in targets) for case in cases): + raise ValueError("Unexpected pytest case") + all_cases.extend(cases) + failures = [case for case in cases if case.find("failure") is not None] + if any( + case.find("error") is not None or case.find("skipped") is not None + for case in cases + ): + raise ValueError("Pytest collection/error/skip is not a completed panel") + actual_failure = actual_failure or bool(failures) + if not failures and any( + not any(matches(case, target) for case in cases) for target in targets + ): + raise ValueError("Declared pytest target never ran") + if actual_failure: + if native_exit == 0: + raise ValueError("Native verifier exit disagrees with pytest failure") + return {"reward": 0, "valid_test_failure": True, "cases": len(all_cases)} + if native_exit != 0: + raise ValueError("Setup or native verifier failed without a real test failure") + if any(panels[group] is None for group in GROUPS): + raise ValueError("Missing completed pytest panel") + return {"reward": 1, "valid_test_failure": False, "cases": len(all_cases)} + + +def assess(root, expected, native_exit): + if type(native_exit) is not int: + raise ValueError("Native verifier exit must be an integer") + if not isinstance(expected, dict) or any( + not isinstance(expected.get(group), list) + or not expected[group] + or any(not isinstance(target, str) or not target for target in expected[group]) + for group in GROUPS + ): + raise ValueError("Complete exact native pytest targets required") + panels, digests = capture_panels(root) + counts = { + "cases": 0, + "matched_failures": 0, + "unexpected_cases": 0, + "unmatched_failures": 0, + "skipped_cases": 0, + "error_cases": 0, + "missing_panels": 0, + "missing_targets": 0, + } + for group in GROUPS: + cases = panels[group] + if cases is None: + counts["missing_panels"] += 1 + counts["missing_targets"] += len(expected[group]) + continue + counts["cases"] += len(cases) + for case in cases: + requested = any(matches(case, target) for target in expected[group]) + failure = case.find("failure") is not None + counts["matched_failures"] += int(requested and failure) + counts["unmatched_failures"] += int(not requested and failure) + counts["unexpected_cases"] += int(not requested) + counts["skipped_cases"] += int(case.find("skipped") is not None) + counts["error_cases"] += int(case.find("error") is not None) + counts["missing_targets"] += sum( + not any(matches(case, target) for case in cases) + for target in expected[group] + ) + if counts["matched_failures"]: + if native_exit == 0: + raise ValueError( + "Native verifier exit disagrees with requested pytest failure" + ) + return { + "reward": 0, + "valid_test_failure": True, + "cases": counts["cases"], + "diagnostic_counts": counts, + "panel_sha256": digests, + "decision": "confirmed_requested_failure_precedence", + } + result = strict_assess(panels, expected, native_exit) + result.update(diagnostic_counts=counts, panel_sha256=digests) + return result + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("--root", required=True) + parser.add_argument("--expected", required=True) + parser.add_argument("--native-exit", type=int, required=True) + args = parser.parse_args() + result = assess( + args.root, json.loads(Path(args.expected).read_bytes()), args.native_exit + ) + reward = Path(args.root) / "reward.txt" + if reward.read_text().strip() != str(result["reward"]): + raise ValueError("Native raw reward disagrees with pytest evidence") + (Path(args.root) / "pytest-evidence.json").write_text( + json.dumps(result, sort_keys=True) + "\n" + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/expected-panels.json b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/expected-panels.json new file mode 100644 index 0000000000000000000000000000000000000000..74ea415071857657df28ad8c86ffce20c7f1285f --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/expected-panels.json @@ -0,0 +1,1067 @@ +{ + "fail-to-pass": [ + "pypika/tests/clickhouse/test_condition.py::TestIfCondition::test_get_sql_0", + "pypika/tests/clickhouse/test_condition.py::TestIfCondition::test_get_sql_1", + "pypika/tests/clickhouse/test_condition.py::TestMultiIfCondition::test_get_sql_0", + "pypika/tests/clickhouse/test_condition.py::TestMultiIfCondition::test_get_sql_1", + "pypika/tests/clickhouse/test_nullable_arg.py::TestSearchString::test_get_sql_0", + "pypika/tests/clickhouse/test_nullable_arg.py::TestSearchString::test_get_sql_1", + "pypika/tests/clickhouse/test_search_string.py::TestMultiSearch::test_multi_search_string_0", + "pypika/tests/clickhouse/test_search_string.py::TestMultiSearch::test_multi_search_string_1" + ], + "pass-to-pass": [ + "pypika/tests/clickhouse/test_array.py::TestArray::test_get_sql_0__ridley_scott_jimi_hendrix_", + "pypika/tests/clickhouse/test_array.py::TestArray::test_get_sql_1__1_2_3_4_", + "pypika/tests/clickhouse/test_array.py::TestArray::test_get_sql_2__toInt64_1_toInt64_2_toInt64_3_toInt64_4_", + "pypika/tests/clickhouse/test_array.py::TestArray::test_get_sql_3__toFixedString_mogwai_10_toFixedString_mono_10_toFixedString_bonobo_10_arr", + "pypika/tests/clickhouse/test_array.py::TestHasAny::test_get_sql_0_hasAny_mental_abilities_physical_abilities_", + "pypika/tests/clickhouse/test_array.py::TestHasAny::test_get_sql_1_hasAny_1_2_3_4_3_", + "pypika/tests/clickhouse/test_array.py::TestHasAny::test_get_sql_2_hasAny_bands_toFixedString_port_royal_20_toFixedString_hammock_20_", + "pypika/tests/clickhouse/test_array.py::TestLength::test_get_sql_0_length_tags_", + "pypika/tests/clickhouse/test_array.py::TestLength::test_get_sql_1_length_1_2_3_", + "pypika/tests/clickhouse/test_array.py::TestEmpty::test_get_sql_0_empty_tags_", + "pypika/tests/clickhouse/test_array.py::TestEmpty::test_get_sql_1_empty_1_2_3_", + "pypika/tests/clickhouse/test_array.py::TestNotEmpty::test_get_sql_0_notEmpty_tags_", + "pypika/tests/clickhouse/test_array.py::TestNotEmpty::test_get_sql_1_notEmpty_1_2_3_", + "pypika/tests/clickhouse/test_dates_and_times.py::TestFormatDateTime::test_get_sql_0", + "pypika/tests/clickhouse/test_dates_and_times.py::TestFormatDateTime::test_get_sql_1", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_00", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_01", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_02", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_03", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_04", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_05", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_06", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_07", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_08", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_09", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_10", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_11", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_12", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_13", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_14", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_15", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_16", + "pypika/tests/clickhouse/test_dates_and_times.py::TestToYYYYMM::test_get_sql", + "pypika/tests/clickhouse/test_search_string.py::TestSearchString::test_search_string_0", + "pypika/tests/clickhouse/test_search_string.py::TestSearchString::test_search_string_1", + "pypika/tests/clickhouse/test_search_string.py::TestSearchString::test_search_string_2", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_00_toString_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_01_toInt8_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_02_toInt16_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_03_toInt32_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_04_toInt64_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_05_toUInt8_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_06_toUInt16_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_07_toUInt32_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_08_toUInt64_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_09_toFloat32_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_10_toFloat64_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_11_toFloat64_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_12_toDate_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_13_toDateTime_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_14_toFixedString_field_name_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_00_toString_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_01_toInt8_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_02_toInt16_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_03_toInt32_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_04_toInt64_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_05_toUInt8_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_06_toUInt16_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_07_toUInt32_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_08_toUInt64_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_09_toFloat32_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_10_toFloat64_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_11_toFloat64_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_12_toDate_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_13_toDateTime_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_14_toFixedString_100_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestToFixedString::test_get_sql_with_table", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseQueryTests::test_use_AS_keyword_for_alias", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseQueryTests::test_use_FINAL_keyword", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseQueryTests::test_use_SAMPLE_keyword", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseQueryTests::test_use_SAMPLE_with_offset_keyword", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDeleteTests::test_omit_where", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDeleteTests::test_omit_where__table_schema", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDeleteTests::test_where_field_equals", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseUpdateTests::test_update", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDropQuery::test_drop_database", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDropQuery::test_drop_dictionary", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDropQuery::test_drop_other", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDropQuery::test_drop_table", + "pypika/tests/dialects/test_clickhouse.py::DistinctOnTests::test_distinct_on", + "pypika/tests/dialects/test_clickhouse.py::LimitByTests::test_limit_by", + "pypika/tests/dialects/test_clickhouse.py::LimitByTests::test_limit_offset0_by", + "pypika/tests/dialects/test_clickhouse.py::LimitByTests::test_limit_offset_by", + "pypika/tests/dialects/test_clickhouse.py::LimitByTests::test_rename_table", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_distinct_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_groupby_alias_False_does_not_group_by_alias_when_subqueries_are_present", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_groupby_alias_False_does_not_group_by_alias_with_standard_query", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_limit", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_limit_with_offset", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_normal_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_offset", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_distinct_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_percent_invalid_range", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_percent_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_select_non_int", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_with_ties_select", + "pypika/tests/dialects/test_mysql.py::SelectTests::test_distinct_select", + "pypika/tests/dialects/test_mysql.py::SelectTests::test_modifier_select", + "pypika/tests/dialects/test_mysql.py::SelectTests::test_multiple_modifier_select", + "pypika/tests/dialects/test_mysql.py::SelectTests::test_normal_select", + "pypika/tests/dialects/test_mysql.py::UpdateTests::test_conflict_handlers_update", + "pypika/tests/dialects/test_mysql.py::UpdateTests::test_on_duplicate_key_ignore_update", + "pypika/tests/dialects/test_mysql.py::UpdateTests::test_on_duplicate_key_update_update", + "pypika/tests/dialects/test_mysql.py::UpdateTests::test_update", + "pypika/tests/dialects/test_mysql.py::LoadCSVTests::test_load_from_file", + "pypika/tests/dialects/test_mysql.py::TableTests::test_create_table", + "pypika/tests/dialects/test_mysql.py::TableTests::test_drop_table", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_fetch_next_method_deprecated", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_groupby_alias_False_does_not_group_by_alias_when_subqueries_are_present", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_groupby_alias_False_does_not_group_by_alias_with_standard_query", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_limit_offset_query", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_limit_query", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_offset_query", + "pypika/tests/dialects/test_postgresql.py::InsertTests::test_array_keyword", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_alias_set_correctly", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_json_value_from_array_num", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_json_value_from_array_str", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_json_value_from_dict", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_json_value_from_dict_recursive", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_json_value_by_index", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_json_value_by_key", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_path_json_value", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_path_text_value", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_text_value_by_index", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_text_value_by_key", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contained_by_using_list_arg", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contained_by_using_str_arg", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contained_by_with_complex_criterion", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contains_for_field", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contains_for_json", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_has_any_keys", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_has_key", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_has_keys", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_subnet_contains_inet", + "pypika/tests/dialects/test_postgresql.py::DistinctOnTests::test_distinct_on", + "pypika/tests/dialects/test_postgresql.py::ArrayTests::test_array_syntax", + "pypika/tests/dialects/test_postgresql.py::ArrayTests::test_render_alias_in_array_sql", + "pypika/tests/dialects/test_postgresql.py::ReturningClauseTests::test_no_queryexception_if_returning_used_on_valid_query_type", + "pypika/tests/dialects/test_postgresql.py::ReturningClauseTests::test_queryexception_if_returning_used_on_invalid_query", + "pypika/tests/dialects/test_postgresql.py::ReturningClauseTests::test_return_field_from_join_table", + "pypika/tests/dialects/test_postgresql.py::ReturningClauseTests::test_returning_from_missing_table_raises_queryexception", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_dont_use_double_quotes_on_create_queries", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_dont_use_double_quotes_on_drop_queries", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_dont_use_double_quotes_on_joining_queries", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_use_double_quotes_on_alias_but_not_on_terms", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_use_double_quotes_on_alias_but_not_on_terms_with_joins", + "pypika/tests/dialects/test_sqllite.py::SelectTests::test_bool_false_as_zero", + "pypika/tests/dialects/test_sqllite.py::SelectTests::test_bool_true_as_one", + "pypika/tests/dialects/test_sqllite.py::ReplaceTests::test_insert_or_replace", + "pypika/tests/dialects/test_sqllite.py::ReplaceTests::test_normal_replace", + "pypika/tests/dialects/test_sqllite.py::ReplaceTests::test_replace_subquery", + "pypika/tests/dialects/test_vertica.py::VerticaQueryTests::test_delete_query_with_hint", + "pypika/tests/dialects/test_vertica.py::VerticaQueryTests::test_insert_query_with_hint", + "pypika/tests/dialects/test_vertica.py::VerticaQueryTests::test_select_query_with_hint", + "pypika/tests/dialects/test_vertica.py::VerticaQueryTests::test_update_query_with_hint", + "pypika/tests/dialects/test_vertica.py::CopyCSVTests::test_copy_from_file", + "pypika/tests/dialects/test_vertica.py::CreateTemporaryTableTests::test_create_local_table_without_temporary_raises_error", + "pypika/tests/dialects/test_vertica.py::CreateTemporaryTableTests::test_create_local_temporary_table", + "pypika/tests/dialects/test_vertica.py::CreateTemporaryTableTests::test_create_table_preserve_rows_without_temporary_raises_error", + "pypika/tests/dialects/test_vertica.py::CreateTemporaryTableTests::test_create_temporary_table_preserve_rows", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__agg_case_criterion_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__agg_case_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__agg_func_arithmetic_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__agg_func_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__case_mixed_constant_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__case_mixed_else_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__case_with_field_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__case_with_single_aggregate_field_in_one_criterion_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__constant_arithmetic_is_aggregate_none", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__constant_is_aggregate_none", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__field_arithmetic_constant_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__field_arithmetic_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__field_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__func_arithmetic_constant_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__mixed_case_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__mixed_func_arithmetic_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__negative_agg_func_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__non_aggregate_function_with_aggregated_arg", + "pypika/tests/test_aggregate.py::IsAggregateTests::test_complicated", + "pypika/tests/test_analytic_queries.py::RankTests::test_avg", + "pypika/tests/test_analytic_queries.py::RankTests::test_count_range_between_unbounded_preceeding_current_row", + "pypika/tests/test_analytic_queries.py::RankTests::test_dense_rank", + "pypika/tests/test_analytic_queries.py::RankTests::test_empty_over", + "pypika/tests/test_analytic_queries.py::RankTests::test_filter", + "pypika/tests/test_analytic_queries.py::RankTests::test_filter_quote_table_in_filter", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value_ignore_nulls", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value_ignore_nulls_first", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value_multi_argument", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value_range_between_x_preceeding_unbounded_following", + "pypika/tests/test_analytic_queries.py::RankTests::test_lag_generates_correct_sql", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value_ignore_nulls", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value_multi_argument", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value_rows_between_current_row_unbounded_following", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value_rows_between_current_row_unbounded_following_ignore_nulls", + "pypika/tests/test_analytic_queries.py::RankTests::test_lead_generates_correct_sql", + "pypika/tests/test_analytic_queries.py::RankTests::test_max_range_x_preceeding", + "pypika/tests/test_analytic_queries.py::RankTests::test_max_rows_x_preceeding", + "pypika/tests/test_analytic_queries.py::RankTests::test_median", + "pypika/tests/test_analytic_queries.py::RankTests::test_min_range_current_row", + "pypika/tests/test_analytic_queries.py::RankTests::test_min_rows_current_row", + "pypika/tests/test_analytic_queries.py::RankTests::test_multiple_partitions", + "pypika/tests/test_analytic_queries.py::RankTests::test_ntile_no_partition_or_order_invalid_sql", + "pypika/tests/test_analytic_queries.py::RankTests::test_ntile_with_order", + "pypika/tests/test_analytic_queries.py::RankTests::test_ntile_with_partition", + "pypika/tests/test_analytic_queries.py::RankTests::test_ntile_with_partition_and_order", + "pypika/tests/test_analytic_queries.py::RankTests::test_orderby_asc", + "pypika/tests/test_analytic_queries.py::RankTests::test_orderby_desc", + "pypika/tests/test_analytic_queries.py::RankTests::test_range_called_twice_raises_attribute_error", + "pypika/tests/test_analytic_queries.py::RankTests::test_range_then_rows_raises_attribute_error", + "pypika/tests/test_analytic_queries.py::RankTests::test_rank", + "pypika/tests/test_analytic_queries.py::RankTests::test_rank_with_alias", + "pypika/tests/test_analytic_queries.py::RankTests::test_row_number", + "pypika/tests/test_analytic_queries.py::RankTests::test_rows_called_twice_raises_attribute_error", + "pypika/tests/test_analytic_queries.py::RankTests::test_rows_then_range_raises_attribute_error", + "pypika/tests/test_analytic_queries.py::RankTests::test_stddev", + "pypika/tests/test_analytic_queries.py::RankTests::test_stddev_pop", + "pypika/tests/test_analytic_queries.py::RankTests::test_stddev_samp", + "pypika/tests/test_analytic_queries.py::RankTests::test_sum_rows_unbounded_preceeding", + "pypika/tests/test_analytic_queries.py::RankTests::test_table_prefixes_used_in_analytic_functions", + "pypika/tests/test_analytic_queries.py::RankTests::test_var_pop", + "pypika/tests/test_analytic_queries.py::RankTests::test_var_samp", + "pypika/tests/test_analytic_queries.py::RankTests::test_variance", + "pypika/tests/test_analytic_queries.py::RankTests::test_variance_rows_between_unbounded_preceeding_unbounded_following", + "pypika/tests/test_analytic_queries.py::RankTests::test_varpop_range_unbounded_preceeding", + "pypika/tests/test_analytic_queries.py::RankTests::test_varpop_rows_between_unbounded_preceeding_x_following", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_as_select_not_query_raises_error", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_with_columns", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_with_select", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_with_select_and_columns_fails", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_without_columns_or_select_empty", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_if_not_exists", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_simple", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_unique", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_where", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_without_columns_raises_error", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_without_table_raises_error", + "pypika/tests/test_criterions.py::CriterionTests::test__bitwise_and_in_where_clause", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_bitwise_and", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_bitwise_and_with_alias", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_bool", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_decimal", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_str", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gt_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gt_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gt_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gt_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gte_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gte_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gte_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gte_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_is_null", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_is_null_with_alias", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lt_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lt_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lt_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lt_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lte_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lte_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lte_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lte_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_str", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_with_alias", + "pypika/tests/test_criterions.py::NotTests::test_chained_function", + "pypika/tests/test_criterions.py::NotTests::test_is_not_null", + "pypika/tests/test_criterions.py::NotTests::test_negate", + "pypika/tests/test_criterions.py::NotTests::test_not_null", + "pypika/tests/test_criterions.py::NotTests::test_not_null_with_alias", + "pypika/tests/test_criterions.py::NotTests::test_not_with_and_criterion", + "pypika/tests/test_criterions.py::NotTests::test_not_with_complex_criterion", + "pypika/tests/test_criterions.py::NotTests::test_not_with_or_criterion", + "pypika/tests/test_criterions.py::NotTests::test_notnullcriterion_replace_table", + "pypika/tests/test_criterions.py::NotTests::test_variable_access", + "pypika/tests/test_criterions.py::BetweenTests::test__between_date", + "pypika/tests/test_criterions.py::BetweenTests::test__between_datetime", + "pypika/tests/test_criterions.py::BetweenTests::test__between_number", + "pypika/tests/test_criterions.py::BetweenTests::test__between_with_alias", + "pypika/tests/test_criterions.py::BetweenTests::test__function_between", + "pypika/tests/test_criterions.py::BetweenTests::test_get_item_only_works_with_slice", + "pypika/tests/test_criterions.py::IsInTests::test__function_isin", + "pypika/tests/test_criterions.py::IsInTests::test__in_character", + "pypika/tests/test_criterions.py::IsInTests::test__in_date", + "pypika/tests/test_criterions.py::IsInTests::test__in_datetime", + "pypika/tests/test_criterions.py::IsInTests::test__in_number", + "pypika/tests/test_criterions.py::IsInTests::test__in_number_with_alias", + "pypika/tests/test_criterions.py::IsInTests::test__in_unicode", + "pypika/tests/test_criterions.py::ArithmeticExpressionTests::test__lshift", + "pypika/tests/test_criterions.py::ArithmeticExpressionTests::test__rshift", + "pypika/tests/test_criterions.py::NotInTests::test__function_notin", + "pypika/tests/test_criterions.py::NotInTests::test__notin_character", + "pypika/tests/test_criterions.py::NotInTests::test__notin_date", + "pypika/tests/test_criterions.py::NotInTests::test__notin_datetime", + "pypika/tests/test_criterions.py::NotInTests::test__notin_number", + "pypika/tests/test_criterions.py::NotInTests::test__notin_number_with_alias", + "pypika/tests/test_criterions.py::LikeTests::test_glob_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_contains", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_ends_with", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_n_chars_long", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_starts_with", + "pypika/tests/test_criterions.py::LikeTests::test_like_contains", + "pypika/tests/test_criterions.py::LikeTests::test_like_ends_with", + "pypika/tests/test_criterions.py::LikeTests::test_like_n_chars_long", + "pypika/tests/test_criterions.py::LikeTests::test_like_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_like_starts_with", + "pypika/tests/test_criterions.py::LikeTests::test_not_ilike_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_not_like_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_rlike_escape_chars", + "pypika/tests/test_criterions.py::ExistsCriterionTests::test_exists", + "pypika/tests/test_criterions.py::ExistsCriterionTests::test_not_exists", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__between_and_field", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__between_and_isin", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__nested__and", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__nested__mixed", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__nested__or", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_and", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_function_and", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_function_or", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_function_xor", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_or", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_xor", + "pypika/tests/test_criterions.py::FieldsAsCriterionTests::test__field_and_field", + "pypika/tests/test_criterions.py::FieldsAsCriterionTests::test__field_or_field", + "pypika/tests/test_criterions.py::FieldsAsCriterionTests::test__field_xor_field", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_arithmeticfunction_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_betweencriterion_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_complexcriterion_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_criterion_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_field_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_function_with_only_fields_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_function_with_values_and_fields_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_nullcriterion_replace_table", + "pypika/tests/test_criterions.py::AnyTests::test_multiple_args_returned_in_chain_of_ors", + "pypika/tests/test_criterions.py::AnyTests::test_single_arg_returns_self", + "pypika/tests/test_criterions.py::AnyTests::test_with_generator", + "pypika/tests/test_criterions.py::AnyTests::test_zero_args_returns_empty_criterion", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_different_operations_with_empty_criterion", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_empty_criterion_on_the_left", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_empty_criterion_on_the_right", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_fields_", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_invertion_of_the_empty_criterion", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_more_than_one_empty_criterions", + "pypika/tests/test_criterions.py::AllTests::test_multiple_args_returned_in_chain_of_ors", + "pypika/tests/test_criterions.py::AllTests::test_single_arg_returns_self", + "pypika/tests/test_criterions.py::AllTests::test_with_generator", + "pypika/tests/test_criterions.py::AllTests::test_zero_args_returns_empty_criterion", + "pypika/tests/test_custom_functions.py::TestUnitCustomFunction::test_should_fail_with_wrong_arguments", + "pypika/tests/test_custom_functions.py::TestUnitCustomFunction::test_should_return_function_with_arguments", + "pypika/tests/test_custom_functions.py::TestUnitCustomFunction::test_should_return_function_with_no_arguments", + "pypika/tests/test_custom_functions.py::TestFunctionalCustomFunction::test_should_fail_use_custom_function_on_select_with_wrong_arguments", + "pypika/tests/test_custom_functions.py::TestFunctionalCustomFunction::test_should_use_custom_function_on_select", + "pypika/tests/test_data_types.py::StringTests::test_inline_string_concatentation", + "pypika/tests/test_data_types.py::UuidTests::test_uuid_string_generation", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_day", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_default", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_microsecond", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_minute", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_month", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_quarter", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_second", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_week", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_year", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_day_hour", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_day_microsecond", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_day_minute", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_day_second", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_hour_microsecond", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_hour_minute", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_hour_second", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_minute_microsecond", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_minute_second", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_second_microsecond", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_value_complex_expressions", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_value_right", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_year_month", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_mysql_dialect_uses_single_quotes_around_expression_in_an_interval", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_oracle_dialect_uses_single_quotes_around_expression_in_an_interval", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_postgresql_dialect_uses_single_quotes_around_interval", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_redshift_dialect_uses_single_quotes_around_interval", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_vertica_dialect_uses_single_quotes_around_interval", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_day", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_month", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_week", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_year", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_year_month", + "pypika/tests/test_date_math.py::TruncateTrailingZerosTests::test_do_not_truncate_integer_values", + "pypika/tests/test_date_math.py::TruncateTrailingZerosTests::test_do_not_truncate_months_between_years_and_datys", + "pypika/tests/test_deletes.py::DeleteTests::test_for_portion", + "pypika/tests/test_deletes.py::DeleteTests::test_omit_where", + "pypika/tests/test_deletes.py::DeleteTests::test_omit_where__table_schema", + "pypika/tests/test_deletes.py::DeleteTests::test_where_field_equals", + "pypika/tests/test_deletes.py::PostgresDeleteTests::test_delete_returning", + "pypika/tests/test_deletes.py::PostgresDeleteTests::test_delete_returning_star", + "pypika/tests/test_deletes.py::PostgresDeleteTests::test_delete_returning_str", + "pypika/tests/test_deletes.py::PostgresDeleteTests::test_delete_using", + "pypika/tests/test_drop.py::DropTableTests::test_drop_database", + "pypika/tests/test_drop.py::DropTableTests::test_drop_index", + "pypika/tests/test_drop.py::DropTableTests::test_drop_table", + "pypika/tests/test_drop.py::DropTableTests::test_drop_user", + "pypika/tests/test_drop.py::DropTableTests::test_drop_view", + "pypika/tests/test_formats.py::QuoteTests::test_no_quote_char_in_complex_query", + "pypika/tests/test_formats.py::QuoteTests::test_replace_quote_char_in_complex_query", + "pypika/tests/test_functions.py::FunctionTests::test_dialect_propagation", + "pypika/tests/test_functions.py::FunctionTests::test_is_aggregate_None_for_non_aggregate_function_or_function_with_no_aggregate_functions", + "pypika/tests/test_functions.py::FunctionTests::test_is_aggregate_True_for_aggregate_function_or_function_with_aggregate_functions", + "pypika/tests/test_functions.py::SchemaTests::test_schema_included_in_function_sql", + "pypika/tests/test_functions.py::SchemaTests::test_schema_no_schema_in_sql_when_none_set", + "pypika/tests/test_functions.py::ArithmeticTests::test__addition__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__addition__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__addition__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__addition__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__arithmetic_equality", + "pypika/tests/test_functions.py::ArithmeticTests::test__arithmetic_with_function", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_add_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_div_no_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_div_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_exponent_no_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_exponent_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_floor_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_function_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_modulus_no_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_modulus_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_mul_no_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_mul_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_nested_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_sub_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__division__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__division__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__division__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__division__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__exponent__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__exponent__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__floor", + "pypika/tests/test_functions.py::ArithmeticTests::test__leftshift__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__leftshift__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__leftshift__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__modulus__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__multiplication__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__multiplication__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__multiplication__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__multiplication__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__rightshift__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__rightshift__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__rightshift__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__subtraction__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__subtraction__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__subtraction__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__subtraction__right", + "pypika/tests/test_functions.py::AggregationTests::test__approx_percentile", + "pypika/tests/test_functions.py::AggregationTests::test__avg", + "pypika/tests/test_functions.py::AggregationTests::test__count", + "pypika/tests/test_functions.py::AggregationTests::test__count__star", + "pypika/tests/test_functions.py::AggregationTests::test__first", + "pypika/tests/test_functions.py::AggregationTests::test__last", + "pypika/tests/test_functions.py::AggregationTests::test__max", + "pypika/tests/test_functions.py::AggregationTests::test__min", + "pypika/tests/test_functions.py::AggregationTests::test__std", + "pypika/tests/test_functions.py::AggregationTests::test__stddev", + "pypika/tests/test_functions.py::AggregationTests::test__subquery_in_params_functions", + "pypika/tests/test_functions.py::AggregationTests::test__sum", + "pypika/tests/test_functions.py::ConditionTests::test__case__else", + "pypika/tests/test_functions.py::ConditionTests::test__case__field", + "pypika/tests/test_functions.py::ConditionTests::test__case__multi", + "pypika/tests/test_functions.py::ConditionTests::test__case__no_cases", + "pypika/tests/test_functions.py::ConditionTests::test__case__raw", + "pypika/tests/test_functions.py::StringTests::test__ascii__field", + "pypika/tests/test_functions.py::StringTests::test__ascii__int", + "pypika/tests/test_functions.py::StringTests::test__ascii__str", + "pypika/tests/test_functions.py::StringTests::test__bin__field", + "pypika/tests/test_functions.py::StringTests::test__bin__int", + "pypika/tests/test_functions.py::StringTests::test__bin__str", + "pypika/tests/test_functions.py::StringTests::test__concat__field", + "pypika/tests/test_functions.py::StringTests::test__concat__str", + "pypika/tests/test_functions.py::StringTests::test__insert__field", + "pypika/tests/test_functions.py::StringTests::test__insert__str", + "pypika/tests/test_functions.py::StringTests::test__length__field", + "pypika/tests/test_functions.py::StringTests::test__length__str", + "pypika/tests/test_functions.py::StringTests::test__lower__field", + "pypika/tests/test_functions.py::StringTests::test__lower__str", + "pypika/tests/test_functions.py::StringTests::test__replace__field", + "pypika/tests/test_functions.py::StringTests::test__replace__str", + "pypika/tests/test_functions.py::StringTests::test__substring", + "pypika/tests/test_functions.py::SplitPartFunctionTests::test__split_part", + "pypika/tests/test_functions.py::RegexpLikeFunctionTests::test__regexp_like", + "pypika/tests/test_functions.py::CastTests::test__cast__as", + "pypika/tests/test_functions.py::CastTests::test__cast__binary", + "pypika/tests/test_functions.py::CastTests::test__cast__binary_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__boolean", + "pypika/tests/test_functions.py::CastTests::test__cast__char", + "pypika/tests/test_functions.py::CastTests::test__cast__char_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__date", + "pypika/tests/test_functions.py::CastTests::test__cast__float", + "pypika/tests/test_functions.py::CastTests::test__cast__integer", + "pypika/tests/test_functions.py::CastTests::test__cast__long_varbinary", + "pypika/tests/test_functions.py::CastTests::test__cast__long_varbinary_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__long_varchar", + "pypika/tests/test_functions.py::CastTests::test__cast__long_varchar_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__numeric", + "pypika/tests/test_functions.py::CastTests::test__cast__signed", + "pypika/tests/test_functions.py::CastTests::test__cast__timestamp", + "pypika/tests/test_functions.py::CastTests::test__cast__unsigned", + "pypika/tests/test_functions.py::CastTests::test__cast__varbinary", + "pypika/tests/test_functions.py::CastTests::test__cast__varbinary_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__varchar", + "pypika/tests/test_functions.py::CastTests::test__cast__varchar_with_arg", + "pypika/tests/test_functions.py::CastTests::test__tochar__", + "pypika/tests/test_functions.py::DateFunctionsTests::test_current_date", + "pypika/tests/test_functions.py::DateFunctionsTests::test_current_time", + "pypika/tests/test_functions.py::DateFunctionsTests::test_current_timestamp", + "pypika/tests/test_functions.py::DateFunctionsTests::test_current_timestamp_with_alias", + "pypika/tests/test_functions.py::DateFunctionsTests::test_date_add", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_day", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_hour", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_join", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_microsecond", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_minute", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_month", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_quarter", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_second", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_week", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_year", + "pypika/tests/test_functions.py::DateFunctionsTests::test_now", + "pypika/tests/test_functions.py::DateFunctionsTests::test_time_diff", + "pypika/tests/test_functions.py::DateFunctionsTests::test_timestampadd", + "pypika/tests/test_functions.py::DateFunctionsTests::test_to_date", + "pypika/tests/test_functions.py::DateFunctionsTests::test_utc_timestamp", + "pypika/tests/test_functions.py::NullFunctionsTests::test_coalesce", + "pypika/tests/test_functions.py::NullFunctionsTests::test_isnull", + "pypika/tests/test_functions.py::NullFunctionsTests::test_nullif", + "pypika/tests/test_functions.py::NullFunctionsTests::test_nvl", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_mysql_one_groupby", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_mysql_rollup_two_groupbys", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_no_rollup_after_rollup_mysql", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_no_rollup_before_groupby", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_from_groupbys", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_from_parameters", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_from_two_groupbys", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_func_one_groupby", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_func_partial", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_func_two_groupbys", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_multiple_rollups", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_rollups_with_multiple_rollups_and_parity", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_rollups_with_parity", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_force_index_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_groupby_returns_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_immutable_kwarg_on_query_builder_disables_immutability", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_insert_into_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_join_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_orderby_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_queries_after_join", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_replace_into_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_select_returns_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_update_set_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_use_index_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_with_return_new_query_instance", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_multi_rows", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_multi_rows_chained", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_multi_rows_chained_mixed", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_multi_rows_chained_multiple_rows", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_single_element", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_column_using_alias_with_chain", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_column_using_table_alias", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_empty_columns", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_empty_columns_type_list", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_empty_columns_type_tuple", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_ignore", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_multiple_rows_with_array_value", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_none_skipped", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_null", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_one_column", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_one_column_multi_element_array", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_one_column_single_element_array", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_selected_columns", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_selected_columns_type_list", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_selected_columns_type_tuple", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_single_row_with_array_value", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_with_statement", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_empty_on_conflict_do_update_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_field", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_field_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_mixed_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_multiple_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_multiple_fields_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_field", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_field_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_multiple_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_multiple_fields_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_multiple_mixed_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_no_handler", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_two_handlers_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_two_handlers_do_update", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_fieldless_conflict_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_fieldless_conflict_do_update_field", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_non_insert_on_conflict_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_non_insert_on_conflict_do_update", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_do_nothing_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_do_update_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_do_update_with_excluded_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_from_subquery", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_complex", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_conflict_fields_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_conflict_fields_do_update", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_empty_conflict_fields_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_empty_conflict_fields_do_update", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_where_and_on_conflict_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_all_columns_multi_rows_chained_returning_star", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_all_columns_multi_rows_chained_returning_star_and_id", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_all_columns_multi_rows_chained_returning_star_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_all_columns_single_element_arrays", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_aggregate", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_all_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_all_fields_and_arithmetics", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_arithmetics", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_from_other_table", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_functions", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_null", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_one_field", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_one_field_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_tuple", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_ignore", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multi_rows_chained_mixed_on_duplicate_update_multiple", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_multiple", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_different_value", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_expression", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_expression_using_original_field_value", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_expression_using_values", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_same_value", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_none_skipped", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_one_column", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_one_column_multi_element_array", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_one_column_single_element_array", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_one_column_using_values", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_selected_columns_on_duplicate_update_multiple", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_selected_columns_on_duplicate_update_one", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_columns_from_columns", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_columns_from_columns_with_join", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_columns_from_star", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_from_columns", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_ignore_star", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_star", + "pypika/tests/test_inserts.py::InsertSubqueryTests::test_insert_subquery_wrapped_in_brackets", + "pypika/tests/test_inserts.py::SelectIntoTests::test_select_columns_into", + "pypika/tests/test_inserts.py::SelectIntoTests::test_select_columns_into_with_join", + "pypika/tests/test_inserts.py::SelectIntoTests::test_select_star_into", + "pypika/tests/test_inserts.py::ReplaceTests::test_replace_simple", + "pypika/tests/test_inserts.py::ReplaceTests::test_replace_subquery", + "pypika/tests/test_internals.py::TablesTests::test__case_tables", + "pypika/tests/test_internals.py::TablesTests::test__criterion_replace_table_with_value", + "pypika/tests/test_internals.py::TablesTests::test__star_tables", + "pypika/tests/test_internals.py::TablesTests::test__table_star_tables", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_cross_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_cross_join_on_subquery", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_cross_join_on_table", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_default_join_type", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_full_outer_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_hash_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_inner_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_arithmetic_field", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_collate", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_complex_criteria", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_field_multi", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_field_multi_with_extra_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_field_single", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_field_without_fields_raises_exception", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_subquery_criteria", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_second_table_in_from_clause", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_using_multiple_fields", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_using_string_field_name", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_using_with_quote_char", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_using_without_fields_raises_exception", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_with_arithmetic_function_in_select", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_left_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_left_outer_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_outer_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_right_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_right_outer_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_temporal_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_use_different_table_objects_for_same_table", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_fail_when_joining_unknown_type", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_ignore_table_references", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_immutable__tables", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_from_join", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_query_with_column_alias", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_query_with_setoperation", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_query_with_table_alias", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_query_without_alias", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_same_table", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_same_table_with_prefixes", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_table_twice", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_prefixes_added_to_function_in_orderby", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_prefixes_added_to_groupby", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_prefixes_added_to_orderby", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_require_condition", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_require_condition_with_both_tables", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select__fields_after_table_star", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select__ordered_select_clauses", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select__star_for_table", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select__star_for_table__replacement", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select_field_from_missing_table", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select_fields_with_where", + "pypika/tests/test_joins.py::UnionTests::test_mysql_query_wraps_unioned_queries", + "pypika/tests/test_joins.py::UnionTests::test_require_equal_number_of_fields", + "pypika/tests/test_joins.py::UnionTests::test_union", + "pypika/tests/test_joins.py::UnionTests::test_union_all", + "pypika/tests/test_joins.py::UnionTests::test_union_all_multiple", + "pypika/tests/test_joins.py::UnionTests::test_union_as_subquery", + "pypika/tests/test_joins.py::UnionTests::test_union_multiple", + "pypika/tests/test_joins.py::UnionTests::test_union_with_no_quote_char", + "pypika/tests/test_joins.py::UnionTests::test_union_with_order_by", + "pypika/tests/test_joins.py::UnionTests::test_union_with_order_by_use_union_query_field", + "pypika/tests/test_joins.py::UnionTests::test_union_with_order_by_use_union_query_field_with_aliases", + "pypika/tests/test_joins.py::UnionTests::test_union_with_order_by_with_aliases", + "pypika/tests/test_joins.py::InsertQueryJoinTests::test_join_table_on_insert_query", + "pypika/tests/test_joins.py::UpdateQueryJoinTests::test_join_table_on_update_query", + "pypika/tests/test_joins.py::IntersectTests::test_intersect", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_as_subquery", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_multiple", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_with_limit", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_with_no_quote_char", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_with_offset", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_with_order_by", + "pypika/tests/test_joins.py::IntersectTests::test_mysql_query_wraps_intersected_queries", + "pypika/tests/test_joins.py::IntersectTests::test_require_equal_number_of_fields_intersect", + "pypika/tests/test_joins.py::MinusTests::test_minus", + "pypika/tests/test_joins.py::MinusTests::test_minus_as_subquery", + "pypika/tests/test_joins.py::MinusTests::test_minus_multiple", + "pypika/tests/test_joins.py::MinusTests::test_minus_query_with_order_by_use_minus_query_field", + "pypika/tests/test_joins.py::MinusTests::test_minus_with_no_quote_char", + "pypika/tests/test_joins.py::MinusTests::test_minus_with_order_by", + "pypika/tests/test_joins.py::MinusTests::test_mysql_query_wraps_minus_queries", + "pypika/tests/test_joins.py::MinusTests::test_require_equal_number_of_fields", + "pypika/tests/test_joins.py::ExceptOfTests::test_except", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_as_subquery", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_multiple", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_query_with_order_by_use_minus_query_field", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_with_no_quote_char", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_with_order_by", + "pypika/tests/test_joins.py::ExceptOfTests::test_require_equal_number_of_fields_except_of", + "pypika/tests/test_negation.py::NegationTests::test_negate_field", + "pypika/tests/test_negation.py::NegationTests::test_negate_function", + "pypika/tests/test_negation.py::NegationTests::test_negate_wrapped_float", + "pypika/tests/test_negation.py::NegationTests::test_negate_wrapped_int", + "pypika/tests/test_parameter.py::ParametrizedTests::test_format_parameter", + "pypika/tests/test_parameter.py::ParametrizedTests::test_join", + "pypika/tests/test_parameter.py::ParametrizedTests::test_named_parameter", + "pypika/tests/test_parameter.py::ParametrizedTests::test_numeric_parameter", + "pypika/tests/test_parameter.py::ParametrizedTests::test_param_insert", + "pypika/tests/test_parameter.py::ParametrizedTests::test_param_select_join", + "pypika/tests/test_parameter.py::ParametrizedTests::test_param_select_subquery", + "pypika/tests/test_parameter.py::ParametrizedTests::test_pyformat_parameter", + "pypika/tests/test_parameter.py::ParametrizedTests::test_qmark_parameter", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_join", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_join_with_parameter_value_wrapper", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_param_insert", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_param_select_join", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_param_select_subquery", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_pyformat_parameter", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_can_be_used_in_a_select_statement", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_can_be_used_in_a_where_clause", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_can_be_used_in_orderby", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_column_value", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_object_id", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_object_value", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_row_id", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_row_num", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_sys_date", + "pypika/tests/test_query.py::QueryTablesTests::test_is_joined", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_case_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_delete_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_filter_tables", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_having_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_insert_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_insert_table_current_table_not_match", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_join_tables", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_only_specified_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_orderby_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_tuple_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_update_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_update_table_current_table_not_match", + "pypika/tests/test_query.py::QueryBuilderTests::test_pipe", + "pypika/tests/test_query.py::QueryBuilderTests::test_query_builders_have_reference_to_correct_query_class", + "pypika/tests/test_selects.py::SelectTests::test_empty_query", + "pypika/tests/test_selects.py::SelectTests::test_mssql_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_mysql_query_uses_backtick_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_oracle_query_uses_no_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_postgresql_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_redshift_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_select__column__single__alias__str", + "pypika/tests/test_selects.py::SelectTests::test_select__column__single__field", + "pypika/tests/test_selects.py::SelectTests::test_select__column__single__str", + "pypika/tests/test_selects.py::SelectTests::test_select__column__single__table_alias__str", + "pypika/tests/test_selects.py::SelectTests::test_select__columns__multi__field", + "pypika/tests/test_selects.py::SelectTests::test_select__columns__multi__str", + "pypika/tests/test_selects.py::SelectTests::test_select__distinct__multi", + "pypika/tests/test_selects.py::SelectTests::test_select__distinct__single", + "pypika/tests/test_selects.py::SelectTests::test_select__multiple_subqueries", + "pypika/tests/test_selects.py::SelectTests::test_select__multiple_tables", + "pypika/tests/test_selects.py::SelectTests::test_select__nested_subquery", + "pypika/tests/test_selects.py::SelectTests::test_select__no_table", + "pypika/tests/test_selects.py::SelectTests::test_select__star", + "pypika/tests/test_selects.py::SelectTests::test_select__star__replacement", + "pypika/tests/test_selects.py::SelectTests::test_select__subquery", + "pypika/tests/test_selects.py::SelectTests::test_select__table_schema", + "pypika/tests/test_selects.py::SelectTests::test_select__table_schema_with_multiple_levels_as_list", + "pypika/tests/test_selects.py::SelectTests::test_select__table_schema_with_multiple_levels_as_tuple", + "pypika/tests/test_selects.py::SelectTests::test_select_no_from", + "pypika/tests/test_selects.py::SelectTests::test_select_no_from_with_field_raises_exception", + "pypika/tests/test_selects.py::SelectTests::test_select_no_with_alias_from", + "pypika/tests/test_selects.py::SelectTests::test_select_then_add_table", + "pypika/tests/test_selects.py::SelectTests::test_select_with_force_index", + "pypika/tests/test_selects.py::SelectTests::test_select_with_force_index_multiple_calls", + "pypika/tests/test_selects.py::SelectTests::test_select_with_force_index_multiple_indexes", + "pypika/tests/test_selects.py::SelectTests::test_select_with_force_index_with_index_object", + "pypika/tests/test_selects.py::SelectTests::test_select_with_limit", + "pypika/tests/test_selects.py::SelectTests::test_select_with_limit__func", + "pypika/tests/test_selects.py::SelectTests::test_select_with_limit_and_offset", + "pypika/tests/test_selects.py::SelectTests::test_select_with_limit_zero", + "pypika/tests/test_selects.py::SelectTests::test_select_with_offset", + "pypika/tests/test_selects.py::SelectTests::test_select_with_offset__func", + "pypika/tests/test_selects.py::SelectTests::test_select_with_use_index", + "pypika/tests/test_selects.py::SelectTests::test_select_with_use_index_multiple_calls", + "pypika/tests/test_selects.py::SelectTests::test_select_with_use_index_multiple_indexes", + "pypika/tests/test_selects.py::SelectTests::test_select_with_use_index_with_index_object", + "pypika/tests/test_selects.py::SelectTests::test_table_select_alias", + "pypika/tests/test_selects.py::SelectTests::test_table_select_alias_with_offset_and_limit", + "pypika/tests/test_selects.py::SelectTests::test_temporal_select", + "pypika/tests/test_selects.py::SelectTests::test_vertica_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::WhereTests::test_ignore_empty_criterion_having", + "pypika/tests/test_selects.py::WhereTests::test_ignore_empty_criterion_where", + "pypika/tests/test_selects.py::WhereTests::test_select_with_force_index_and_where", + "pypika/tests/test_selects.py::WhereTests::test_where_enum", + "pypika/tests/test_selects.py::WhereTests::test_where_field_contains", + "pypika/tests/test_selects.py::WhereTests::test_where_field_does_not_contain", + "pypika/tests/test_selects.py::WhereTests::test_where_field_does_not_end_with", + "pypika/tests/test_selects.py::WhereTests::test_where_field_does_not_start_with", + "pypika/tests/test_selects.py::WhereTests::test_where_field_ends_with", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_and", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_nowait", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_of", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_of_multiple_tables", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_of_nowait", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_of_skip_locked", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_skip_locked", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_skip_locked_and_of", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_or", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_where", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_where_not", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_where_two_not", + "pypika/tests/test_selects.py::WhereTests::test_where_field_is_n_chars_long", + "pypika/tests/test_selects.py::WhereTests::test_where_field_is_not_n_chars_long", + "pypika/tests/test_selects.py::WhereTests::test_where_field_matches_regex", + "pypika/tests/test_selects.py::WhereTests::test_where_field_matches_regexp", + "pypika/tests/test_selects.py::WhereTests::test_where_field_matches_rlike", + "pypika/tests/test_selects.py::WhereTests::test_where_field_starts_with", + "pypika/tests/test_selects.py::WhereTests::test_where_nested_conditions", + "pypika/tests/test_selects.py::WhereTests::test_where_single_quote", + "pypika/tests/test_selects.py::WhereTests::test_where_with_multiple_wheres_using_and_case", + "pypika/tests/test_selects.py::WhereTests::test_where_with_multiple_wheres_using_or_case", + "pypika/tests/test_selects.py::PreWhereTests::test_ignore_empty_criterion_having", + "pypika/tests/test_selects.py::PreWhereTests::test_ignore_empty_criterion_where", + "pypika/tests/test_selects.py::PreWhereTests::test_prewhere_field_equals", + "pypika/tests/test_selects.py::PreWhereTests::test_select_with_force_index_and_where", + "pypika/tests/test_selects.py::PreWhereTests::test_where_and_prewhere", + "pypika/tests/test_selects.py::PreWhereTests::test_where_enum", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_contains", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_does_not_contain", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_does_not_end_with", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_does_not_start_with", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_ends_with", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_and", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_nowait", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_of", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_of_multiple_tables", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_of_nowait", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_of_skip_locked", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_skip_locked", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_skip_locked_and_of", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_or", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_where", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_where_not", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_where_two_not", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_is_n_chars_long", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_is_not_n_chars_long", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_matches_regex", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_matches_regexp", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_matches_rlike", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_starts_with", + "pypika/tests/test_selects.py::PreWhereTests::test_where_nested_conditions", + "pypika/tests/test_selects.py::PreWhereTests::test_where_single_quote", + "pypika/tests/test_selects.py::PreWhereTests::test_where_with_multiple_wheres_using_and_case", + "pypika/tests/test_selects.py::PreWhereTests::test_where_with_multiple_wheres_using_or_case", + "pypika/tests/test_selects.py::GroupByTests::test_group_by__single_with_totals", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__alias", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__alias_platforms", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__alias_with_join", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__count_distinct", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__count_field", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__count_star", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__int", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__multi", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__multi_with_totals", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__no_alias", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__no_alias_mssql", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__no_alias_oracle", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__single", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__str", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__sum_distinct", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__sum_filter", + "pypika/tests/test_selects.py::GroupByTests::test_groupby_with_case_uses_the_alias", + "pypika/tests/test_selects.py::GroupByTests::test_mssql_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_mysql_query_uses_backtick_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_oracle_query_uses_no_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_postgres_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_redshift_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_vertica_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_having_and", + "pypika/tests/test_selects.py::HavingTests::test_having_greater_than", + "pypika/tests/test_selects.py::HavingTests::test_having_join_and_equality", + "pypika/tests/test_selects.py::HavingTests::test_mssql_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_mysql_query_uses_backtick_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_oracle_query_uses_no_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_postgres_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_redshift_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_vertica_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_alias", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_asc", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_desc", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_multi_fields", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_no_alias", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_single_field", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_single_str", + "pypika/tests/test_selects.py::AliasTests::test_arithmetic_function", + "pypika/tests/test_selects.py::AliasTests::test_case_using_as", + "pypika/tests/test_selects.py::AliasTests::test_case_using_constructor_param", + "pypika/tests/test_selects.py::AliasTests::test_function_using_as_nested", + "pypika/tests/test_selects.py::AliasTests::test_functions_using_as", + "pypika/tests/test_selects.py::AliasTests::test_functions_using_constructor_param", + "pypika/tests/test_selects.py::AliasTests::test_functions_using_constructor_param_nested", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_criterion", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_criterion_comparison", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_field_inside_case", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_groupby", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_orderby", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_where", + "pypika/tests/test_selects.py::AliasTests::test_null_value_with_alias", + "pypika/tests/test_selects.py::AliasTests::test_select__multiple_tables", + "pypika/tests/test_selects.py::AliasTests::test_table_field", + "pypika/tests/test_selects.py::AliasTests::test_table_field__multi", + "pypika/tests/test_selects.py::AliasTests::test_table_with_schema_and_alias", + "pypika/tests/test_selects.py::AliasTests::test_use_aliases_in_groupby_and_orderby", + "pypika/tests/test_selects.py::SubqueryTests::test_from_subquery_without_alias", + "pypika/tests/test_selects.py::SubqueryTests::test_join", + "pypika/tests/test_selects.py::SubqueryTests::test_join_query_with_alias", + "pypika/tests/test_selects.py::SubqueryTests::test_join_with_with", + "pypika/tests/test_selects.py::SubqueryTests::test_select_from_nested_query", + "pypika/tests/test_selects.py::SubqueryTests::test_select_from_nested_query_with_join", + "pypika/tests/test_selects.py::SubqueryTests::test_select_from_with_returning", + "pypika/tests/test_selects.py::SubqueryTests::test_select_subquery", + "pypika/tests/test_selects.py::SubqueryTests::test_select_subquery_with_alias", + "pypika/tests/test_selects.py::SubqueryTests::test_where__equality", + "pypika/tests/test_selects.py::SubqueryTests::test_where__in", + "pypika/tests/test_selects.py::SubqueryTests::test_where__in_nested", + "pypika/tests/test_selects.py::SubqueryTests::test_with", + "pypika/tests/test_selects.py::QuoteTests::test_extraneous_quotes", + "pypika/tests/test_tables.py::TableStructureTests::test_database_schema_table_attr", + "pypika/tests/test_tables.py::TableStructureTests::test_schema_table_attr", + "pypika/tests/test_tables.py::TableStructureTests::test_table_for_period_sql", + "pypika/tests/test_tables.py::TableStructureTests::test_table_for_system_time_sql", + "pypika/tests/test_tables.py::TableStructureTests::test_table_sql", + "pypika/tests/test_tables.py::TableStructureTests::test_table_with_alias", + "pypika/tests/test_tables.py::TableStructureTests::test_table_with_schema_and_schema_parent_arg", + "pypika/tests/test_tables.py::TableStructureTests::test_table_with_schema_arg", + "pypika/tests/test_tables.py::TableEqualityTests::test_many_tables_with_alias", + "pypika/tests/test_tables.py::TableEqualityTests::test_many_tables_with_or_not_alias", + "pypika/tests/test_tables.py::TableEqualityTests::test_many_tables_without_alias", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_equal_by_name", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_equal_by_schema_and_name", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_equal_by_schema_and_name_using_schema", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_equal_by_schema_and_name_using_schema_with_parent", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_not_equal_by_schema_and_name_using_schema_with_different_parents", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_not_equal_with_different_names", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_not_equal_with_different_schemas", + "pypika/tests/test_tables.py::TableDialectTests::test_make_tables_factory_with_default_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_make_tables_factory_with_dialect_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_factory_with_default_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_factory_with_dialect_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_with_bad_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_with_default_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_with_dialect_query_cls", + "pypika/tests/test_terms.py::FieldAliasTests::test_when_alias_specified", + "pypika/tests/test_terms.py::FieldInitTests::test_init_with_str_table", + "pypika/tests/test_terms.py::FieldHashingTests::test_non_tabled_aliased_eq_fields_equally_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_non_tabled_aliased_ne_fields_differently_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_non_tabled_eq_fields_equally_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_non_tabled_ne_fields_differently_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_tabled_eq_fields_equally_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_tabled_ne_fields_differently_hashed", + "pypika/tests/test_terms.py::AtTimezoneTests::test_passes_kwargs_to_field_get_sql", + "pypika/tests/test_terms.py::AtTimezoneTests::test_when_alias_specified", + "pypika/tests/test_terms.py::AtTimezoneTests::test_when_interval_not_specified", + "pypika/tests/test_terms.py::AtTimezoneTests::test_when_interval_specified", + "pypika/tests/test_tuples.py::TupleTests::test_render_alias_in_array_sql", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_equality_tuple_on_both", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_equality_tuple_on_left", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_equality_tuple_on_right", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_in_using_mixed_tuples", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_in_using_pypika_tuples", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_in_using_python_tuples", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_is_aggregate", + "pypika/tests/test_tuples.py::TupleTests::test_tuples_in_join", + "pypika/tests/test_tuples.py::ArrayTests::test_array_general", + "pypika/tests/test_tuples.py::ArrayTests::test_empty_psql_array", + "pypika/tests/test_tuples.py::ArrayTests::test_psql_array_general", + "pypika/tests/test_tuples.py::ArrayTests::test_render_alias_in_array_sql", + "pypika/tests/test_tuples.py::BracketTests::test_arithmetic_with_brackets", + "pypika/tests/test_tuples.py::BracketTests::test_arithmetic_with_brackets_and_alias", + "pypika/tests/test_updates.py::UpdateTests::test_empty_query", + "pypika/tests/test_updates.py::UpdateTests::test_for_portion", + "pypika/tests/test_updates.py::UpdateTests::test_omit_where", + "pypika/tests/test_updates.py::UpdateTests::test_single_quote_escape_in_set", + "pypika/tests/test_updates.py::UpdateTests::test_update__table_schema", + "pypika/tests/test_updates.py::UpdateTests::test_update_from", + "pypika/tests/test_updates.py::UpdateTests::test_update_from_with_where", + "pypika/tests/test_updates.py::UpdateTests::test_update_with_join", + "pypika/tests/test_updates.py::UpdateTests::test_update_with_limit", + "pypika/tests/test_updates.py::UpdateTests::test_update_with_none", + "pypika/tests/test_updates.py::UpdateTests::test_update_with_statement", + "pypika/tests/test_updates.py::PostgresUpdateTests::test_update_returning", + "pypika/tests/test_updates.py::PostgresUpdateTests::test_update_returning_from_different_tables", + "pypika/tests/test_updates.py::PostgresUpdateTests::test_update_returning_star", + "pypika/tests/test_updates.py::PostgresUpdateTests::test_update_returning_str", + "pypika/tests/test_updates.py::SQLLiteUpdateTests::test_update_with_bool", + "pypika/tests/test_utils.py::ImmutabilityTests::test_raise_attribute_error_for_deepcopy", + "pypika/tests/test_utils.py::ImmutabilityTests::test_raise_attribute_error_for_getnewargs", + "pypika/tests/test_utils.py::ImmutabilityTests::test_raise_attribute_error_for_getstate", + "pypika/tests/test_utils.py::ImmutabilityTests::test_raise_attribute_error_for_setstate" + ] +} diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/grade.py b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/grade.py new file mode 100644 index 0000000000000000000000000000000000000000..e3b37293830e51a5c5833c93c4705e1ed9364257 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/grade.py @@ -0,0 +1,128 @@ +"""Trusted private pytest panel runner. Installed only in a fresh grader Job.""" + +import hashlib +import importlib.util +import json +import os +import shutil +import stat +import subprocess +from pathlib import Path, PurePosixPath + + +def sha(raw): + return hashlib.sha256(raw).hexdigest() + + +def safe(value): + path = PurePosixPath(value) + if ( + path.is_absolute() + or path.as_posix() != value + or not path.parts + or any(part in {".", "..", ".git"} for part in path.parts) + ): + raise ValueError("Unsafe trusted test path") + return path + + +def restore(worktree, private, manifest): + worktree, private = Path(worktree), Path(private) + captured = {} + for name, expected in manifest["files"].items(): + path = private / safe(name) + info = path.lstat() + raw = path.read_bytes() if stat.S_ISREG(info.st_mode) else b"" + if ( + not stat.S_ISREG(info.st_mode) + or len(raw) != expected["bytes"] + or sha(raw) != expected["sha256"] + or stat.S_IMODE(info.st_mode) != expected["mode"] + ): + raise ValueError("Trusted private test bytes or modes drifted") + captured[name] = (raw, expected["mode"]) + # Capture and verify every private byte before changing the submitted tree. + for name in manifest["directory_roots"]: + destination = worktree / safe(name) + if destination.is_symlink(): + raise ValueError("Submitted test directory is a symlink") + for parent in destination.parents: + if parent == worktree: + break + if parent.is_symlink(): + raise ValueError("Submitted test parent is a symlink") + if destination.exists(): + if not destination.is_dir(): + raise ValueError("Submitted test directory is not a directory") + shutil.rmtree(destination) + for name, (raw, mode) in captured.items(): + destination = worktree / safe(name) + for parent in destination.parents: + if parent == worktree: + break + if parent.is_symlink(): + raise ValueError("Submitted test parent is a symlink") + if destination.is_symlink(): + raise ValueError("Submitted trusted file is a symlink") + destination.parent.mkdir(parents=True, exist_ok=True) + destination.write_bytes(raw) + destination.chmod(mode) + + +def run(worktree, private_root, output, invoke=None): + private_root, output, worktree = Path(private_root), Path(output), Path(worktree) + expected = json.loads((private_root / "expected-panels.json").read_bytes()) + config = json.loads((private_root / "panel-config.json").read_bytes()) + manifest = json.loads((private_root / "trusted-inventory.json").read_bytes()) + restore(worktree, private_root / "trusted", manifest) + output.mkdir(parents=True, exist_ok=True) + for name in ( + "reward.txt", + "pass-to-pass.xml", + "fail-to-pass.xml", + "pytest-evidence.json", + ): + (output / name).unlink(missing_ok=True) + environment = dict(os.environ) + for key in ("PYTEST_ADDOPTS", "PYTEST_DISABLE_PLUGIN_AUTOLOAD", "PYTHONPATH"): + environment.pop(key, None) + commands, native_exit = [], 0 + invoke = invoke or subprocess.run + for group in ("pass-to-pass", "fail-to-pass"): + if ( + not isinstance(expected[group], list) + or not expected[group] + or any( + not isinstance(target, str) or not target for target in expected[group] + ) + ): + raise ValueError("Frozen native pytest selectors are incomplete") + command = [ + *config["official_pytest_argv"], + "--override-ini=addopts=", + "--junitxml=" + str(output / (group + ".xml")), + *expected[group], + ] + result = invoke(command, cwd=worktree, env=environment, check=False) + native_exit = result.returncode + commands.append({"group": group, "argv": command, "exit_code": native_exit}) + if native_exit != 0: + break + (output / "pytest-commands.json").write_text( + json.dumps(commands, sort_keys=True) + "\n" + ) + spec = importlib.util.spec_from_file_location( + "trusted_pytest_result", private_root / "check_pytest.py" + ) + checker = importlib.util.module_from_spec(spec) + spec.loader.exec_module(checker) + result = checker.assess(output, expected, native_exit) + (output / "reward.txt").write_text(str(result["reward"]) + "\n") + (output / "pytest-evidence.json").write_text( + json.dumps(result, sort_keys=True) + "\n" + ) + return result + + +if __name__ == "__main__": + run("/testbed/repo", "/tests", "/logs/verifier") diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/panel-config.json b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/panel-config.json new file mode 100644 index 0000000000000000000000000000000000000000..6417b9c92e5da5b97ee641bd54f798302af42a31 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/panel-config.json @@ -0,0 +1,28 @@ +{ + "dependency_installation_pinned": false, + "official_install_cmds": [ + "python -m pip install -e ." + ], + "official_pytest_argv": [ + "pytest", + "--disable-warnings", + "--color=no", + "--tb=no", + "--verbose" + ], + "official_test_command": "source /opt/miniconda3/bin/activate; conda activate testbed; pytest --disable-warnings --color=no --tb=no --verbose", + "operator_test_runner_prerequisites": [ + "python -m pip install pytest==8.4.2" + ], + "operator_test_runner_reason": "The official profile invokes pytest, but the common tools runtime does not provide it; pinned separately from source-native project requirements.", + "panel_normalization": "Override project addopts only to execute the exact frozen native panels; add JUnit output, preserve official pytest options and all selectors.", + "python_version": "3.10", + "source_bound_test_dependency_cmds": [ + "python -m pip install parameterized==0.7.0" + ], + "test_dependency_source_sha256": { + "requirements-dev.txt": "10f4ba7b19a73950d28fd7403d7e1d1b1fe2ccc4f49516974f47199d2965f23d", + "setup.py": "f8bad274588a22e65764d8cf9fb2be5aa6fcfaf3bf861d71e5f751105898845a", + "tox.ini": "c2d7205d0ac93e9c9e80dc5d24f0a826a6781f587a33ea722ea621f9e2ccd0ea" + } +} diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/test.sh b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..81b6d0620f05dbd3b54b4e7ea5de04ce3f8a98e2 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/test.sh @@ -0,0 +1,6 @@ +#!/bin/bash +set -Eeuo pipefail +source /opt/miniconda3/bin/activate +conda activate testbed +cd /testbed/repo +exec python -I /tests/grade.py diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted-inventory.json b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted-inventory.json new file mode 100644 index 0000000000000000000000000000000000000000..6926ef1c22ed56457101c37cd70e0fe0d1656f0c --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted-inventory.json @@ -0,0 +1,242 @@ +{ + "directory_roots": [ + "pypika/tests" + ], + "files": { + "pypika/tests/__init__.py": { + "bytes": 58, + "mode": 420, + "sha256": "7d41f44b87688bdf162e6d5cbe7b517cfba468f96eaa421f02718c17eb486a18" + }, + "pypika/tests/clickhouse/__init__.py": { + "bytes": 0, + "mode": 420, + "sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "pypika/tests/clickhouse/test_array.py": { + "bytes": 2942, + "mode": 420, + "sha256": "0f0a5b4c3daf3ddce2944b6119795e80d50b74e4687ef2e34399e5d21d3d48ae" + }, + "pypika/tests/clickhouse/test_condition.py": { + "bytes": 2533, + "mode": 420, + "sha256": "c666976d082b1d12cd57e791d1a525183246335efad96a369b58871a6f1e4fa1" + }, + "pypika/tests/clickhouse/test_dates_and_times.py": { + "bytes": 2508, + "mode": 420, + "sha256": "cb8ea84363e35ad0a00b52a8ec20cb38f2348f4cba28d026a4c32c14fd1fc56f" + }, + "pypika/tests/clickhouse/test_nullable_arg.py": { + "bytes": 672, + "mode": 420, + "sha256": "883c5161ebeb09544ce124d20a096d248bd12a0404ad77c84637be75d6738529" + }, + "pypika/tests/clickhouse/test_search_string.py": { + "bytes": 1189, + "mode": 420, + "sha256": "d5f0ed6a51cf550bdd4b261fa2e98084184dd1cbb08f5dbb8b91278b4c8f3bfd" + }, + "pypika/tests/clickhouse/test_type_conversion.py": { + "bytes": 4445, + "mode": 420, + "sha256": "7e6045b64433a8947346cfb34ac30279349f7a2e2081a2815212c8cb7d0235ab" + }, + "pypika/tests/dialects/__init__.py": { + "bytes": 0, + "mode": 420, + "sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "pypika/tests/dialects/test_clickhouse.py": { + "bytes": 5747, + "mode": 420, + "sha256": "2272538d6eeb6dfb01f9803eed328b4cd4efc8d255b6a8ab3c4e25bee74d73fa" + }, + "pypika/tests/dialects/test_mssql.py": { + "bytes": 3152, + "mode": 420, + "sha256": "0cd9b2ee6498caa9fa75a51ead30803057fb23deb2ac706d396d88329e0e91d7" + }, + "pypika/tests/dialects/test_mysql.py": { + "bytes": 2984, + "mode": 420, + "sha256": "a5f4550dd14bf4820e5d85cf06b6c7c79286e41d2d3c794f639579d20fffab92" + }, + "pypika/tests/dialects/test_oracle.py": { + "bytes": 1906, + "mode": 420, + "sha256": "67f80eb40cc9b4dabcbad355e8be6d83c54a64cbee809182ef57fa9f48d2ebc6" + }, + "pypika/tests/dialects/test_postgresql.py": { + "bytes": 9532, + "mode": 420, + "sha256": "548ee7267ca87c9e1ae82ca89a4e5bd96c7392a55cc07996f2b105f911ffa6cf" + }, + "pypika/tests/dialects/test_snowflake.py": { + "bytes": 2159, + "mode": 420, + "sha256": "e567b9dab0a5366bd11a0ef162c3a3bb492280b78bc4b397a23070563dc84468" + }, + "pypika/tests/dialects/test_sqllite.py": { + "bytes": 1243, + "mode": 420, + "sha256": "118fed7e575415f276bda390a119080bd6a767aee3d9c953e11a8c219f0f017c" + }, + "pypika/tests/dialects/test_vertica.py": { + "bytes": 3578, + "mode": 420, + "sha256": "33a027e6735ca03b7afd11394905c4193e48a15dda3efbe47cdcd85fcabf840c" + }, + "pypika/tests/test_aggregate.py": { + "bytes": 3946, + "mode": 420, + "sha256": "5b0fb549de3bb50ad88ae1d75824f12f7ab4a5f1102b06a70c7b2ebae33bea6d" + }, + "pypika/tests/test_analytic_queries.py": { + "bytes": 20611, + "mode": 420, + "sha256": "8546b7a296c8e212c349c4baff95f93934b3120f74625b3945ade3b438e3a3ed" + }, + "pypika/tests/test_create.py": { + "bytes": 9088, + "mode": 420, + "sha256": "6c57302da52ca1044be0afdafe677d5de245e44873dff1386c9a1ccb2625cc82" + }, + "pypika/tests/test_criterions.py": { + "bytes": 32014, + "mode": 420, + "sha256": "78539ccca82f9a02fad0f5a39041ac343e3a142ce52368cd4f6ada489c52516a" + }, + "pypika/tests/test_custom_functions.py": { + "bytes": 1710, + "mode": 420, + "sha256": "bfa18bc328a3577965db7cc75eb94439f0cfd95a3775d9b1cc8af1062bb202cb" + }, + "pypika/tests/test_data_types.py": { + "bytes": 403, + "mode": 420, + "sha256": "c1be6ecc621a80dd91d35b1427bdfc8b1b33bd926515198e626d6fb5e1878c8b" + }, + "pypika/tests/test_date_math.py": { + "bytes": 5544, + "mode": 420, + "sha256": "85aa54efe54fe19639f2dc2a5750647e3337ac2681768bc3fe327841f1634d9e" + }, + "pypika/tests/test_deletes.py": { + "bytes": 3204, + "mode": 420, + "sha256": "ccde6df760d76d5d499ce828f6b0e2ad3eebcb2a5553c1890f481b9160b8d51a" + }, + "pypika/tests/test_drop.py": { + "bytes": 1556, + "mode": 420, + "sha256": "a13dffa59ef8657398d5498c18977bfd702635e336ea9966b1a86137afca7926" + }, + "pypika/tests/test_formats.py": { + "bytes": 1948, + "mode": 420, + "sha256": "240458a404bb119322778893b94a12be0f98f914acd701d2b4be73eb9be96f75" + }, + "pypika/tests/test_functions.py": { + "bytes": 32769, + "mode": 420, + "sha256": "3ceaac7791bd27e50f44e1b4a1451d1e09afe6a8011052caea838e5124582154" + }, + "pypika/tests/test_groupby_modifiers.py": { + "bytes": 5227, + "mode": 420, + "sha256": "9db4497660f08e3352a9a02c34889ad1cd6bab3aebaeaa485e84390ad71c84c5" + }, + "pypika/tests/test_immutability.py": { + "bytes": 3954, + "mode": 420, + "sha256": "af537ced19f7274951cc91697eae748ef6c9cd20a8d8e492d93dc85b06f8fb50" + }, + "pypika/tests/test_inserts.py": { + "bytes": 32549, + "mode": 420, + "sha256": "652e9f7f0f425e9acc0f70e2851ae29310b378262ea30369ea0113ef428f210f" + }, + "pypika/tests/test_internals.py": { + "bytes": 828, + "mode": 420, + "sha256": "4374c2632563346d00ca4de6af397a022ef3f5022e808c8711a3f207a3a21609" + }, + "pypika/tests/test_joins.py": { + "bytes": 43895, + "mode": 420, + "sha256": "53f224815c10393382443f020cb20e313420764495a8fd30f7ea2f34fd52935d" + }, + "pypika/tests/test_negation.py": { + "bytes": 763, + "mode": 420, + "sha256": "6be105e8f39b32fb23e6ac7c7158232ee78111455d4f35638c8af60781138c79" + }, + "pypika/tests/test_parameter.py": { + "bytes": 7382, + "mode": 420, + "sha256": "aaf2a3e79c8267bdc60e218445bc2a2254b97cf37b643a44d6f1a8141cbb5104" + }, + "pypika/tests/test_pseudocolumns.py": { + "bytes": 1609, + "mode": 420, + "sha256": "b7c69f7aca41323c0e14a6a9e58697399cd7860610f07291afc6e8af26079ca2" + }, + "pypika/tests/test_query.py": { + "bytes": 9025, + "mode": 420, + "sha256": "2da9d717673912a84e86e6c0d3955dbd8f2fa7b41b7ed9a6f78089dfa28f9444" + }, + "pypika/tests/test_selects.py": { + "bytes": 50757, + "mode": 420, + "sha256": "5ac1b7ad3248d64b1e3865a72c763873514ae5cd6e03356b913e531c0c336986" + }, + "pypika/tests/test_tables.py": { + "bytes": 6568, + "mode": 420, + "sha256": "384c8e843ba56374ee92cd7b7e2fd3f89247b899e23cd9e1f6663d751ad5d884" + }, + "pypika/tests/test_terms.py": { + "bytes": 3215, + "mode": 420, + "sha256": "8598513180ddcd28cc61582618d85bd570280978b07603044dae81b2eb099f77" + }, + "pypika/tests/test_tuples.py": { + "bytes": 6033, + "mode": 420, + "sha256": "863942196a93e8939be0d03c49cfeb42a35503ad42f9f3d6c730260112811087" + }, + "pypika/tests/test_updates.py": { + "bytes": 5689, + "mode": 420, + "sha256": "0f0f2521bb8d1f5d782f8fabaea5fd1d82090cde045ba87fad65770db6c75d2f" + }, + "pypika/tests/test_utils.py": { + "bytes": 834, + "mode": 420, + "sha256": "5db6e90df5daaa70b9f35f1243db69908da1f27887f63466fc27ce20c7e14892" + }, + "pyproject.toml": { + "bytes": 390, + "mode": 420, + "sha256": "037fedacd5be5d078f398265ff97e1677e25214ad8839d17073a439695ee7a91" + }, + "setup.cfg": { + "bytes": 317, + "mode": 420, + "sha256": "c84a31de586e8385e741127b004fc1f19ebae6463cdf0b3f243991db35cdeaea" + }, + "setup.py": { + "bytes": 2638, + "mode": 420, + "sha256": "f8bad274588a22e65764d8cf9fb2be5aa6fcfaf3bf861d71e5f751105898845a" + }, + "tox.ini": { + "bytes": 257, + "mode": 420, + "sha256": "c2d7205d0ac93e9c9e80dc5d24f0a826a6781f587a33ea722ea621f9e2ccd0ea" + } + } +} diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/__init__.py b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..86d8a68101915c27b95484243dd81d55f7dba356 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/__init__.py @@ -0,0 +1,2 @@ +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/clickhouse/__init__.py b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/clickhouse/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/clickhouse/test_array.py b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/clickhouse/test_array.py new file mode 100644 index 0000000000000000000000000000000000000000..469705a9ff3c8fe9cc7f02c44a9812521eeb67f4 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/clickhouse/test_array.py @@ -0,0 +1,104 @@ +import unittest + +from parameterized import parameterized + +from pypika import Field +from pypika.clickhouse.array import ( + Array, + Empty, + HasAny, + Length, + NotEmpty, +) +from pypika.clickhouse.type_conversion import ( + ToFixedString, + ToInt64, +) + + +class TestArray(unittest.TestCase): + @parameterized.expand( + [ + ( + "['ridley', 'scott', 'jimi', 'hendrix']", + Array(["ridley", "scott", "jimi", "hendrix"]), + ), + ( + "[1, 2, 3, 4]", + Array([1, 2, 3, 4]), + ), + ( + "[toInt64('1'),toInt64('2'),toInt64('3'),toInt64('4')]", + Array(["1", "2", "3", "4"], ToInt64), + ), + ( + "[toFixedString('mogwai',10),toFixedString('mono',10),toFixedString('bonobo',10)] arr", + Array(["mogwai", "mono", "bonobo"], ToFixedString, {"length": 10}).as_('arr'), + ), + ] + ) + def test_get_sql(self, expected: str, array: Array): + self.assertEqual(expected, array.get_sql()) + + +class TestHasAny(unittest.TestCase): + @parameterized.expand( + [ + ( + 'hasAny("mental_abilities","physical_abilities")', + HasAny(Field("mental_abilities"), Field("physical_abilities")), + ), + ("hasAny([1, 2, 3, 4],[3])", HasAny(Array([1, 2, 3, 4]), Array([3]))), + ( + "hasAny(\"bands\",[toFixedString('port-royal',20),toFixedString('hammock',20)])", + HasAny( + Field("bands"), + Array(["port-royal", "hammock"], ToFixedString, {"length": 20}), + ), + ), + ] + ) + def test_get_sql(self, expected: str, func: HasAny): + self.assertEqual(expected, func.get_sql()) + + +class TestLength(unittest.TestCase): + @parameterized.expand( + [ + ( + 'length("tags")', + Length(Field("tags")), + ), + ("length([1, 2, 3])", Length(Array([1, 2, 3]))), + ] + ) + def test_get_sql(self, expected: str, func: Length): + self.assertEqual(expected, func.get_sql()) + + +class TestEmpty(unittest.TestCase): + @parameterized.expand( + [ + ( + 'empty("tags")', + Empty(Field("tags")), + ), + ("empty([1, 2, 3])", Empty(Array([1, 2, 3]))), + ] + ) + def test_get_sql(self, expected: str, func: Empty): + self.assertEqual(expected, func.get_sql()) + + +class TestNotEmpty(unittest.TestCase): + @parameterized.expand( + [ + ( + 'notEmpty("tags")', + NotEmpty(Field("tags")), + ), + ("notEmpty([1, 2, 3])", NotEmpty(Array([1, 2, 3]))), + ] + ) + def test_get_sql(self, expected: str, func: NotEmpty): + self.assertEqual(expected, func.get_sql()) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/clickhouse/test_condition.py b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/clickhouse/test_condition.py new file mode 100644 index 0000000000000000000000000000000000000000..145baeb7753dd9cbefbd6f272bd672ae5730b0c0 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/clickhouse/test_condition.py @@ -0,0 +1,72 @@ +import unittest + +from parameterized import parameterized + +from pypika import Field +from pypika.clickhouse.condition import If, MultiIf +from pypika.clickhouse.type_conversion import ToFixedString + + +class TestIfCondition(unittest.TestCase): + @parameterized.expand( + [ + ( + If( + Field("filmmaker").isnull(), + ToFixedString("Tarantino", 20), + Field("filmmaker"), + ), + "if(filmmaker IS NULL,toFixedString('Tarantino',20),filmmaker)", + ), + ( + If( + Field("created") == Field("updated"), + ToFixedString("yes", 3), + ToFixedString("no", 3), + ), + "if(created=updated,toFixedString('yes',3),toFixedString('no',3))", + ), + ] + ) + def test_get_sql(self, func, expected): + self.assertEqual(func.get_sql(), expected) + + +class TestMultiIfCondition(unittest.TestCase): + @parameterized.expand( + [ + ( + MultiIf( + Field("filmmaker").isnull(), + ToFixedString("Tarantino", 20), + Field("filmmaker") == ToFixedString("undefined", 20), + ToFixedString("Tarantino", 20), + Field("filmmaker"), + ), + "multiIf(filmmaker IS NULL," + "toFixedString('Tarantino',20)," + "filmmaker=toFixedString('undefined',20)," + "toFixedString('Tarantino',20),filmmaker)", + ), + ( + MultiIf( + Field("color") == ToFixedString("black", 20), + ToFixedString("dark", 20), + Field("color") == ToFixedString("grey", 20), + ToFixedString("dark", 20), + Field("color") == ToFixedString("white", 20), + ToFixedString("light", 20), + ToFixedString("undefined", 20), + ), + "multiIf(color=toFixedString('black',20)," + "toFixedString('dark',20)," + "color=toFixedString('grey',20)," + "toFixedString('dark',20)," + "color=toFixedString('white',20)," + "toFixedString('light',20)," + "toFixedString('undefined',20))", + ), + ] + ) + def test_get_sql(self, func, expected): + self.assertEqual(func.get_sql(), expected) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/clickhouse/test_dates_and_times.py b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/clickhouse/test_dates_and_times.py new file mode 100644 index 0000000000000000000000000000000000000000..135dd7f112131776d76748e15eead1eb81752b59 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/clickhouse/test_dates_and_times.py @@ -0,0 +1,70 @@ +import unittest + +from parameterized import parameterized + +from pypika import Field +from pypika.clickhouse.dates_and_times import ( + AddDays, + AddHours, + AddMinutes, + AddMonths, + AddQuarters, + AddSeconds, + AddWeeks, + AddYears, + FormatDateTime, + SubtractDays, + SubtractHours, + SubtractMinutes, + SubtractMonths, + SubtractQuarters, + SubtractSeconds, + SubtractWeeks, + SubtractYears, + ToYYYYMM, +) + + +class TestFormatDateTime(unittest.TestCase): + @parameterized.expand( + [ + (FormatDateTime(Field("created"), "%V"), "formatDateTime(created,'%V')"), + ( + FormatDateTime(Field("created"), "%Y-%m-%d"), + "formatDateTime(created,'%Y-%m-%d')", + ), + ] + ) + def test_get_sql(self, func, expected): + self.assertEqual(func.get_sql(), expected) + + +class TestAddSubtractDt(unittest.TestCase): + @parameterized.expand( + [ + (AddYears(Field("created"), 1), "addYears(created,1)"), + (AddMonths(Field("created"), 2), "addMonths(created,2)"), + (AddWeeks(Field("created"), 3), "addWeeks(created,3)"), + (AddDays(Field("created"), 4), "addDays(created,4)"), + (AddHours(Field("created"), 5), "addHours(created,5)"), + (AddMinutes(Field("created"), 6), "addMinutes(created,6)"), + (AddSeconds(Field("created"), 7), "addSeconds(created,7)"), + (AddQuarters(Field("created"), 8), "addQuarters(created,8)"), + (SubtractYears(Field("created"), 9), "subtractYears(created,9)"), + (SubtractMonths(Field("created"), 10), "subtractMonths(created,10)"), + (SubtractWeeks(Field("created"), 11), "subtractWeeks(created,11)"), + (SubtractDays(Field("created"), 12), "subtractDays(created,12)"), + (SubtractHours(Field("created"), 13), "subtractHours(created,13)"), + (SubtractHours(Field("created"), 13), "subtractHours(created,13)"), + (SubtractMinutes(Field("created"), 14), "subtractMinutes(created,14)"), + (SubtractSeconds(Field("created"), 15), "subtractSeconds(created,15)"), + (SubtractQuarters(Field("created"), 16), "subtractQuarters(created,16)"), + ] + ) + def test_get_sql(self, func, expected): + self.assertEqual(func.get_sql(), expected) + + +class TestToYYYYMM(unittest.TestCase): + def test_get_sql(self): + self.assertEqual(ToYYYYMM(Field("created").get_sql()), "toYYYYMM(created)") diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/clickhouse/test_nullable_arg.py b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/clickhouse/test_nullable_arg.py new file mode 100644 index 0000000000000000000000000000000000000000..3c6c86207a4d0206b5c0ba80b77fac4cc257fa17 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/clickhouse/test_nullable_arg.py @@ -0,0 +1,24 @@ +import unittest + +from parameterized import parameterized + +from pypika import Field +from pypika.clickhouse.nullable_arg import IfNull +from pypika.clickhouse.type_conversion import ToFixedString + + +class TestSearchString(unittest.TestCase): + @parameterized.expand( + [ + ( + IfNull(Field("name"), Field("login")), + "ifNull(name,login)", + ), + ( + IfNull(Field("builder"), ToFixedString("pypika", 100)), + "ifNull(builder,toFixedString('pypika',100))", + ), + ] + ) + def test_get_sql(self, func, expected): + self.assertEqual(func.get_sql(), expected) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/clickhouse/test_search_string.py b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/clickhouse/test_search_string.py new file mode 100644 index 0000000000000000000000000000000000000000..9778eb32e47d4370c0bfe36dcd875903666d30b6 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/clickhouse/test_search_string.py @@ -0,0 +1,41 @@ +import unittest + +from parameterized import parameterized + +from pypika import Field +from pypika.clickhouse.search_string import ( + Match, + Like, + NotLike, + MultiSearchAny, + MultiMatchAny, +) + + +class TestSearchString(unittest.TestCase): + @parameterized.expand( + [ + (Match(Field("name"), "twheys"), "match(toString(\"name\"),'twheys')"), + (Like(Field("name"), "twheys"), "like(toString(\"name\"),'twheys')"), + (NotLike(Field("name"), "twheys"), "notLike(toString(\"name\"),'twheys')"), + ] + ) + def test_search_string(self, func, expected): + self.assertEqual(func, expected) + + +class TestMultiSearch(unittest.TestCase): + @parameterized.expand( + [ + ( + MultiSearchAny(Field("name"), ["sarah", "connor"]), + "multiSearchAny(toString(\"name\"),['sarah','connor'])", + ), + ( + MultiMatchAny(Field("name"), ["sarah", "connor"]), + "multiMatchAny(toString(\"name\"),['sarah','connor'])", + ), + ] + ) + def test_multi_search_string(self, func, expected): + self.assertEqual(func.get_sql(), expected) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/clickhouse/test_type_conversion.py b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/clickhouse/test_type_conversion.py new file mode 100644 index 0000000000000000000000000000000000000000..9692e17bee901e2629db9a5c77111e145358e8eb --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/clickhouse/test_type_conversion.py @@ -0,0 +1,176 @@ +import unittest + +from parameterized import parameterized + +from pypika import ClickHouseQuery, Field, Table +from pypika.clickhouse.type_conversion import ( + ToDate, + ToDateTime, + ToFixedString, + ToFloat32, + ToFloat64, + ToInt16, + ToInt32, + ToInt64, + ToInt8, + ToString, + ToUInt16, + ToUInt32, + ToUInt64, + ToUInt8, +) + + +class TestBasicTypeConverters(unittest.TestCase): + @parameterized.expand( + [ + ( + 'toString("field_name")', + ToString(Field("field_name")), + ), + ( + 'toInt8("field_name")', + ToInt8(Field("field_name")), + ), + ( + 'toInt16("field_name")', + ToInt16(Field("field_name")), + ), + ( + 'toInt32("field_name")', + ToInt32(Field("field_name")), + ), + ( + 'toInt64("field_name")', + ToInt64(Field("field_name")), + ), + ( + 'toUInt8("field_name")', + ToUInt8(Field("field_name")), + ), + ( + 'toUInt16("field_name")', + ToUInt16(Field("field_name")), + ), + ( + 'toUInt32("field_name")', + ToUInt32(Field("field_name")), + ), + ( + 'toUInt64("field_name")', + ToUInt64(Field("field_name")), + ), + ( + 'toFloat32("field_name")', + ToFloat32(Field("field_name")), + ), + ( + 'toFloat64("field_name")', + ToFloat64(Field("field_name")), + ), + ( + 'toFloat64("field_name")', + ToFloat64(Field("field_name")), + ), + ( + 'toDate("field_name")', + ToDate(Field("field_name")), + ), + ( + 'toDateTime("field_name")', + ToDateTime(Field("field_name")), + ), + ( + 'toFixedString("field_name",100)', + ToFixedString(Field("field_name"), 100), + ), + ] + ) + def test_basic_types_field(self, expected, func): + self.assertEqual(func, expected) + + @parameterized.expand( + [ + ( + "toString('100')", + ToString("100"), + ), + ( + "toInt8('100')", + ToInt8("100"), + ), + ( + "toInt16('100')", + ToInt16("100"), + ), + ( + "toInt32('100')", + ToInt32("100"), + ), + ( + "toInt64('100')", + ToInt64("100"), + ), + ( + "toUInt8('100')", + ToUInt8("100"), + ), + ( + "toUInt16('100')", + ToUInt16("100"), + ), + ( + "toUInt32('100')", + ToUInt32("100"), + ), + ( + "toUInt64('100')", + ToUInt64("100"), + ), + ( + "toFloat32('100')", + ToFloat32("100"), + ), + ( + "toFloat64('100')", + ToFloat64("100"), + ), + ( + "toFloat64('100')", + ToFloat64("100"), + ), + ( + "toDate('100')", + ToDate("100"), + ), + ( + "toDateTime('100')", + ToDateTime("100"), + ), + ( + "toFixedString('100',100)", + ToFixedString("100", 100), + ), + ] + ) + def test_basic_types_value(self, expected, func): + self.assertEqual(func, expected) + + +class TestToFixedString(unittest.TestCase): + def test_get_sql_with_table(self): + table = Table("example") + query = ( + ClickHouseQuery.from_(table) + .select( + table.name, + ) + .where( + table.name == ToFixedString("name", 50), + ) + ) + + self.assertEqual( + 'SELECT "name" FROM "example" WHERE "name"=toFixedString(\'name\',50)', + query.get_sql(), + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/dialects/__init__.py b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/dialects/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/dialects/test_clickhouse.py b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/dialects/test_clickhouse.py new file mode 100644 index 0000000000000000000000000000000000000000..f319c4627bd25d7004894181906a284b8b1c64cf --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/dialects/test_clickhouse.py @@ -0,0 +1,146 @@ +from unittest import TestCase + +from pypika import ( + ClickHouseQuery, + Database, + Table, +) + + +class ClickHouseQueryTests(TestCase): + def test_use_AS_keyword_for_alias(self): + t = Table('abc') + query = ClickHouseQuery.from_(t).select(t.foo.as_('f1'), t.bar.as_('f2')) + self.assertEqual(str(query), 'SELECT "foo" AS "f1","bar" AS "f2" FROM "abc"') + + def test_use_SAMPLE_keyword(self): + t = Table('abc') + query = ClickHouseQuery.from_(t).select(t.foo).sample(10) + self.assertEqual(str(query), 'SELECT "foo" FROM "abc" SAMPLE 10') + + def test_use_SAMPLE_with_offset_keyword(self): + t = Table('abc') + query = ClickHouseQuery.from_(t).select(t.foo).sample(10, 5) + self.assertEqual(str(query), 'SELECT "foo" FROM "abc" SAMPLE 10 OFFSET 5') + + def test_use_FINAL_keyword(self): + t = Table('abc') + query = ClickHouseQuery.from_(t).select(t.foo).final() + self.assertEqual(str(query), 'SELECT "foo" FROM "abc" FINAL') + + +class ClickHouseDeleteTests(TestCase): + table_abc = Table("abc") + + def test_omit_where(self): + q = ClickHouseQuery.from_("abc").delete() + + self.assertEqual('ALTER TABLE "abc" DELETE', str(q)) + + def test_omit_where__table_schema(self): + q = ClickHouseQuery.from_(Table("abc", "schema1")).delete() + + self.assertEqual('ALTER TABLE "schema1"."abc" DELETE', str(q)) + + def test_where_field_equals(self): + q1 = ClickHouseQuery.from_(self.table_abc).where(self.table_abc.foo == self.table_abc.bar).delete() + q2 = ClickHouseQuery.from_(self.table_abc).where(self.table_abc.foo.eq(self.table_abc.bar)).delete() + + self.assertEqual('ALTER TABLE "abc" DELETE WHERE "foo"="bar"', str(q1)) + self.assertEqual('ALTER TABLE "abc" DELETE WHERE "foo"="bar"', str(q2)) + + +class ClickHouseUpdateTests(TestCase): + table_abc = Table("abc") + + def test_update(self): + q = ClickHouseQuery.update(self.table_abc).where(self.table_abc.foo == 0).set("foo", "bar") + + self.assertEqual('ALTER TABLE "abc" UPDATE "foo"=\'bar\' WHERE "foo"=0', str(q)) + + +class ClickHouseDropQuery(TestCase): + table_abc = Table("abc") + database_xyz = Database("mydb") + cluster_name = "mycluster" + + def test_drop_database(self): + q1 = ClickHouseQuery.drop_database(self.database_xyz) + q2 = ClickHouseQuery.drop_database(self.database_xyz).on_cluster(self.cluster_name) + q3 = ClickHouseQuery.drop_database(self.database_xyz).if_exists().on_cluster(self.cluster_name) + + self.assertEqual('DROP DATABASE "mydb"', str(q1)) + self.assertEqual('DROP DATABASE "mydb" ON CLUSTER "mycluster"', str(q2)) + self.assertEqual('DROP DATABASE IF EXISTS "mydb" ON CLUSTER "mycluster"', str(q3)) + + def test_drop_table(self): + q1 = ClickHouseQuery.drop_table(self.table_abc) + q2 = ClickHouseQuery.drop_table(self.table_abc).on_cluster(self.cluster_name) + q3 = ClickHouseQuery.drop_table(self.table_abc).if_exists().on_cluster(self.cluster_name) + + self.assertEqual('DROP TABLE "abc"', str(q1)) + self.assertEqual('DROP TABLE "abc" ON CLUSTER "mycluster"', str(q2)) + self.assertEqual('DROP TABLE IF EXISTS "abc" ON CLUSTER "mycluster"', str(q3)) + + def test_drop_dictionary(self): + q1 = ClickHouseQuery.drop_dictionary("dict") + q2 = ClickHouseQuery.drop_dictionary("dict").on_cluster(self.cluster_name) + q3 = ClickHouseQuery.drop_dictionary("dict").if_exists().on_cluster(self.cluster_name) + + self.assertEqual('DROP DICTIONARY "dict"', str(q1)) + self.assertEqual('DROP DICTIONARY "dict"', str(q2)) # NO CLUSTER + self.assertEqual('DROP DICTIONARY IF EXISTS "dict"', str(q3)) # NO CLUSTER + + def test_drop_other(self): + q1 = ClickHouseQuery.drop_quota("myquota") + q2 = ClickHouseQuery.drop_user("myuser") + q3 = ClickHouseQuery.drop_view("myview") + + self.assertEqual('DROP QUOTA "myquota"', str(q1)) + self.assertEqual('DROP USER "myuser"', str(q2)) + self.assertEqual('DROP VIEW "myview"', str(q3)) + + +class DistinctOnTests(TestCase): + table_abc = Table("abc") + + def test_distinct_on(self): + q = ClickHouseQuery.from_(self.table_abc).distinct_on("lname", self.table_abc.fname).select("lname", "id") + + self.assertEqual('''SELECT DISTINCT ON("lname","fname") "lname","id" FROM "abc"''', str(q)) + + +class LimitByTests(TestCase): + table_abc = Table("abc") + + def test_limit_by(self): + q = ClickHouseQuery.from_(self.table_abc).limit_by(1, "a", self.table_abc.b).select("a", "b", "c") + + self.assertEqual('''SELECT "a","b","c" FROM "abc" LIMIT 1 BY ("a","b")''', str(q)) + + def test_limit_offset_by(self): + q = ClickHouseQuery.from_(self.table_abc).limit_offset_by(1, 2, "a", self.table_abc.b).select("a", "b", "c") + + self.assertEqual('''SELECT "a","b","c" FROM "abc" LIMIT 1 OFFSET 2 BY ("a","b")''', str(q)) + + def test_limit_offset0_by(self): + q = ClickHouseQuery.from_(self.table_abc).limit_offset_by(1, 0, "a", self.table_abc.b).select("a", "b", "c") + + self.assertEqual('''SELECT "a","b","c" FROM "abc" LIMIT 1 BY ("a","b")''', str(q)) + + def test_rename_table(self): + table_join = Table("join") + + q = ( + ClickHouseQuery.from_(self.table_abc) + .join(table_join) + .using("a") + .limit_by(1, self.table_abc.a, table_join.a) + .select(self.table_abc.b, table_join.b) + ) + q = q.replace_table(self.table_abc, Table("xyz")) + + self.assertEqual( + '''SELECT "xyz"."b","join"."b" FROM "xyz" JOIN "join" USING ("a") LIMIT 1 BY ("xyz"."a","join"."a")''', + str(q), + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/dialects/test_mssql.py b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/dialects/test_mssql.py new file mode 100644 index 0000000000000000000000000000000000000000..7cf53b228f413a8c7cd3e414fef5522a82f99b29 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/dialects/test_mssql.py @@ -0,0 +1,81 @@ +import unittest + +from pypika import Table +from pypika.analytics import Count +from pypika.dialects import MSSQLQuery +from pypika.utils import QueryException + + +class SelectTests(unittest.TestCase): + def test_normal_select(self): + q = MSSQLQuery.from_("abc").select("def") + + self.assertEqual('SELECT "def" FROM "abc"', str(q)) + + def test_distinct_select(self): + q = MSSQLQuery.from_("abc").select("def").distinct() + + self.assertEqual('SELECT DISTINCT "def" FROM "abc"', str(q)) + + def test_top_distinct_select(self): + q = MSSQLQuery.from_("abc").select("def").top(10).distinct() + + self.assertEqual('SELECT DISTINCT TOP (10) "def" FROM "abc"', str(q)) + + def test_top_select(self): + q = MSSQLQuery.from_("abc").select("def").top(10) + + self.assertEqual('SELECT TOP (10) "def" FROM "abc"', str(q)) + + def test_top_with_ties_select(self): + q = MSSQLQuery.from_("abc").select("def").top(10, with_ties=True) + + self.assertEqual('SELECT TOP (10) WITH TIES "def" FROM "abc"', str(q)) + + def test_top_percent_select(self): + q = MSSQLQuery.from_("abc").select("def").top(10, percent=True) + + self.assertEqual('SELECT TOP (10) PERCENT "def" FROM "abc"', str(q)) + + def test_top_percent_invalid_range(self): + for invalid_top in [-1, 101]: + with self.assertRaisesRegex( + QueryException, "TOP value must be between 0 and 100 when `percent` is specified" + ): + MSSQLQuery.from_("abc").select("def").top(invalid_top, percent=True) + + def test_top_select_non_int(self): + with self.assertRaisesRegex(QueryException, "TOP value must be an integer"): + MSSQLQuery.from_("abc").select("def").top("a") + + def test_limit(self): + q = MSSQLQuery.from_("abc").select("def").orderby("def").limit(10) + + self.assertEqual('SELECT "def" FROM "abc" ORDER BY "def" OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY', str(q)) + + def test_offset(self): + q = MSSQLQuery.from_("abc").select("def").orderby("def").offset(10) + + self.assertEqual('SELECT "def" FROM "abc" ORDER BY "def" OFFSET 10 ROWS', str(q)) + + def test_limit_with_offset(self): + q = MSSQLQuery.from_("abc").select("def").orderby("def").limit(10).offset(10) + + self.assertEqual('SELECT "def" FROM "abc" ORDER BY "def" OFFSET 10 ROWS FETCH NEXT 10 ROWS ONLY', str(q)) + + def test_groupby_alias_False_does_not_group_by_alias_with_standard_query(self): + t = Table('table1') + col = t.abc.as_('a') + q = MSSQLQuery.from_(t).select(col, Count('*')).groupby(col) + + self.assertEqual('SELECT "abc" "a",COUNT(\'*\') FROM "table1" GROUP BY "abc"', str(q)) + + def test_groupby_alias_False_does_not_group_by_alias_when_subqueries_are_present(self): + t = Table('table1') + subquery = MSSQLQuery.from_(t).select(t.abc) + col = subquery.abc.as_('a') + q = MSSQLQuery.from_(subquery).select(col, Count('*')).groupby(col) + + self.assertEqual( + 'SELECT "sq0"."abc" "a",COUNT(\'*\') FROM (SELECT "abc" FROM "table1") "sq0" GROUP BY "sq0"."abc"', str(q) + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/dialects/test_mysql.py b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/dialects/test_mysql.py new file mode 100644 index 0000000000000000000000000000000000000000..619d064adcdf8b5ff9ecd054fa4ab00eff1d69b3 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/dialects/test_mysql.py @@ -0,0 +1,91 @@ +import unittest + +from pypika import MySQLQuery, QueryException, Table, Column + + +class SelectTests(unittest.TestCase): + table_abc = Table("abc") + + def test_normal_select(self): + q = MySQLQuery.from_("abc").select("def") + + self.assertEqual("SELECT `def` FROM `abc`", str(q)) + + def test_distinct_select(self): + q = MySQLQuery.from_("abc").select("def").distinct() + + self.assertEqual("SELECT DISTINCT `def` FROM `abc`", str(q)) + + def test_modifier_select(self): + q = MySQLQuery.from_("abc").select("def").select("ghi").modifier("SQL_CALC_FOUND_ROWS") + + self.assertEqual("SELECT SQL_CALC_FOUND_ROWS `def`,`ghi` FROM `abc`", str(q)) + + def test_multiple_modifier_select(self): + q = MySQLQuery.from_("abc").select("def").modifier("HIGH_PRIORITY").modifier("SQL_CALC_FOUND_ROWS") + + self.assertEqual("SELECT HIGH_PRIORITY SQL_CALC_FOUND_ROWS `def` FROM `abc`", str(q)) + + +class UpdateTests(unittest.TestCase): + table_abc = Table("abc") + + def test_update(self): + q = MySQLQuery.into("abc").insert(1, [1, "a", True]) + + self.assertEqual("INSERT INTO `abc` VALUES (1,[1,'a',true])", str(q)) + + def test_on_duplicate_key_ignore_update(self): + q = MySQLQuery.into("abc").insert(1, [1, "a", True]).on_duplicate_key_ignore() + + self.assertEqual("INSERT INTO `abc` VALUES (1,[1,'a',true]) ON DUPLICATE KEY IGNORE", str(q)) + + def test_on_duplicate_key_update_update(self): + q = MySQLQuery.into("abc").insert(1, [1, "a", True]).on_duplicate_key_update(self.table_abc.a, 'b') + + self.assertEqual("INSERT INTO `abc` VALUES (1,[1,'a',true]) ON DUPLICATE KEY UPDATE `a`='b'", str(q)) + + def test_conflict_handlers_update(self): + with self.assertRaises(QueryException): + ( + MySQLQuery.into("abc") + .insert(1, [1, "a", True]) + .on_duplicate_key_ignore() + .on_duplicate_key_update(self.table_abc.a, 'b') + ) + + +class LoadCSVTests(unittest.TestCase): + table_abc = Table("abc") + + def test_load_from_file(self): + q1 = MySQLQuery.load("/path/to/file").into("abc") + + q2 = MySQLQuery.load("/path/to/file").into(self.table_abc) + + self.assertEqual( + "LOAD DATA LOCAL INFILE '/path/to/file' INTO TABLE `abc` FIELDS TERMINATED BY ','", + str(q1), + ) + self.assertEqual( + "LOAD DATA LOCAL INFILE '/path/to/file' INTO TABLE `abc` FIELDS TERMINATED BY ','", + str(q2), + ) + + +class TableTests(unittest.TestCase): + table_abc = Table("abc") + + def test_create_table(self): + q = MySQLQuery.create_table(self.table_abc).columns(Column("id", "INT")) + self.assertEqual( + 'CREATE TABLE `abc` (`id` INT)', + str(q), + ) + + def test_drop_table(self): + q = MySQLQuery.drop_table(self.table_abc) + self.assertEqual( + 'DROP TABLE `abc`', + str(q), + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/dialects/test_oracle.py b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/dialects/test_oracle.py new file mode 100644 index 0000000000000000000000000000000000000000..21b54f16fd5d3518b5c767d3605068637898a73f --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/dialects/test_oracle.py @@ -0,0 +1,51 @@ +import unittest + +from pypika import OracleQuery, Table +from pypika.analytics import Count + + +class SelectTests(unittest.TestCase): + def test_groupby_alias_False_does_not_group_by_alias_with_standard_query(self): + t = Table('table1') + col = t.abc.as_('a') + q = OracleQuery.from_(t).select(col, Count('*')).groupby(col) + + self.assertEqual('SELECT abc a,COUNT(\'*\') FROM table1 GROUP BY abc', str(q)) + + def test_groupby_alias_False_does_not_group_by_alias_when_subqueries_are_present(self): + t = Table('table1') + subquery = OracleQuery.from_(t).select(t.abc) + col = subquery.abc.as_('a') + q = OracleQuery.from_(subquery).select(col, Count('*')).groupby(col) + + self.assertEqual('SELECT sq0.abc a,COUNT(\'*\') FROM (SELECT abc FROM table1) sq0 GROUP BY sq0.abc', str(q)) + + def test_limit_query(self): + t = Table('table1') + limit = 5 + q = OracleQuery.from_(t).select(t.test).limit(limit) + + self.assertEqual(f'SELECT test FROM table1 FETCH NEXT {limit} ROWS ONLY', str(q)) + + def test_offset_query(self): + t = Table('table1') + offset = 5 + q = OracleQuery.from_(t).select(t.test).offset(offset) + + self.assertEqual(f'SELECT test FROM table1 OFFSET {offset} ROWS', str(q)) + + def test_limit_offset_query(self): + t = Table('table1') + limit = 5 + offset = 5 + q = OracleQuery.from_(t).select(t.test).limit(limit).offset(offset) + + self.assertEqual(f'SELECT test FROM table1 OFFSET {offset} ROWS FETCH NEXT {limit} ROWS ONLY', str(q)) + + def test_fetch_next_method_deprecated(self): + with self.assertWarns(DeprecationWarning): + t = Table('table1') + limit = 5 + q = OracleQuery.from_(t).select(t.test).fetch_next(limit) + + self.assertEqual(f'SELECT test FROM table1 FETCH NEXT {limit} ROWS ONLY', str(q)) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/dialects/test_postgresql.py b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/dialects/test_postgresql.py new file mode 100644 index 0000000000000000000000000000000000000000..437eed03e120485ed2a357a4c2d92426f1466e14 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/dialects/test_postgresql.py @@ -0,0 +1,262 @@ +import unittest +from collections import OrderedDict + +from pypika import ( + Array, + Field, + JSON, + QueryException, + Table, +) +from pypika.dialects import PostgreSQLQuery + + +class InsertTests(unittest.TestCase): + table_abc = Table("abc") + + def test_array_keyword(self): + q = PostgreSQLQuery.into(self.table_abc).insert(1, [1, "a", True]) + + self.assertEqual("INSERT INTO \"abc\" VALUES (1,ARRAY[1,'a',true])", str(q)) + + +class JSONObjectTests(unittest.TestCase): + def test_alias_set_correctly(self): + table = Table('jsonb_table') + q = PostgreSQLQuery.from_('abc').select(table.value.get_text_value('a').as_('name')) + + self.assertEqual('''SELECT "value"->>'a' "name" FROM "abc"''', str(q)) + + def test_json_value_from_dict(self): + q = PostgreSQLQuery.select(JSON({"a": "foo"})) + + self.assertEqual('SELECT \'{"a":"foo"}\'', str(q)) + + def test_json_value_from_array_num(self): + q = PostgreSQLQuery.select(JSON([1, 2, 3])) + + self.assertEqual("SELECT '[1,2,3]'", str(q)) + + def test_json_value_from_array_str(self): + q = PostgreSQLQuery.select(JSON(["a", "b", "c"])) + + self.assertEqual('SELECT \'["a","b","c"]\'', str(q)) + + def test_json_value_from_dict_recursive(self): + q = PostgreSQLQuery.select(JSON({"a": "z", "b": {"c": "foo"}, "d": 1})) + + # gotta split this one up to avoid the indeterminate order + sql = str(q) + start, end = 9, -2 + self.assertEqual("SELECT '{}'", sql[:start] + sql[end:]) + + members_set = set(sql[start:end].split(",")) + self.assertSetEqual({'"a":"z"', '"b":{"c":"foo"}', '"d":1'}, members_set) + + +class JSONOperatorsTests(unittest.TestCase): + # reference https://www.postgresql.org/docs/9.5/functions-json.html + table_abc = Table("abc") + + def test_get_json_value_by_key(self): + q = PostgreSQLQuery.from_(self.table_abc).select("*").where(self.table_abc.json.get_json_value("dates")) + + self.assertEqual('SELECT * FROM "abc" WHERE "json"->\'dates\'', str(q)) + + def test_get_json_value_by_index(self): + q = PostgreSQLQuery.from_(self.table_abc).select("*").where(self.table_abc.json.get_json_value(1)) + + self.assertEqual('SELECT * FROM "abc" WHERE "json"->1', str(q)) + + def test_get_text_value_by_key(self): + q = PostgreSQLQuery.from_(self.table_abc).select("*").where(self.table_abc.json.get_text_value("dates")) + + self.assertEqual('SELECT * FROM "abc" WHERE "json"->>\'dates\'', str(q)) + + def test_get_text_value_by_index(self): + q = PostgreSQLQuery.from_(self.table_abc).select("*").where(self.table_abc.json.get_text_value(1)) + + self.assertEqual('SELECT * FROM "abc" WHERE "json"->>1', str(q)) + + def test_get_path_json_value(self): + q = PostgreSQLQuery.from_(self.table_abc).select("*").where(self.table_abc.json.get_path_json_value("{a,b}")) + + self.assertEqual('SELECT * FROM "abc" WHERE "json"#>\'{a,b}\'', str(q)) + + def test_get_path_text_value(self): + q = PostgreSQLQuery.from_(self.table_abc).select("*").where(self.table_abc.json.get_path_text_value("{a,b}")) + + self.assertEqual('SELECT * FROM "abc" WHERE "json"#>>\'{a,b}\'', str(q)) + + +class JSONBOperatorsTests(unittest.TestCase): + # reference https://www.postgresql.org/docs/9.5/functions-json.html + table_abc = Table("abc") + + def test_json_contains_for_json(self): + q = PostgreSQLQuery.select(JSON({"a": 1, "b": 2}).contains({"a": 1})) + + # gotta split this one up to avoid the indeterminate order + sql = str(q) + start, end = 9, -13 + self.assertEqual("SELECT '{}'@>'{\"a\":1}'", sql[:start] + sql[end:]) + + members_set = set(sql[start:end].split(",")) + self.assertSetEqual({'"a":1', '"b":2'}, members_set) + + def test_json_contains_for_field(self): + q = ( + PostgreSQLQuery.from_(self.table_abc) + .select("*") + .where(self.table_abc.json.contains({"dates": "2018-07-10 - 2018-07-17"})) + ) + + self.assertEqual( + "SELECT * " 'FROM "abc" ' 'WHERE "json"@>\'{"dates":"2018-07-10 - 2018-07-17"}\'', + str(q), + ) + + def test_json_contained_by_using_str_arg(self): + q = ( + PostgreSQLQuery.from_(self.table_abc) + .select("*") + .where( + self.table_abc.json.contained_by( + OrderedDict( + [ + ("dates", "2018-07-10 - 2018-07-17"), + ("imported", "8"), + ] + ) + ) + ) + ) + self.assertEqual( + 'SELECT * FROM "abc" ' 'WHERE "json"<@\'{"dates":"2018-07-10 - 2018-07-17","imported":"8"}\'', + str(q), + ) + + def test_json_contained_by_using_list_arg(self): + q = ( + PostgreSQLQuery.from_(self.table_abc) + .select("*") + .where(self.table_abc.json.contained_by(["One", "Two", "Three"])) + ) + + self.assertEqual('SELECT * FROM "abc" WHERE "json"<@\'["One","Two","Three"]\'', str(q)) + + def test_json_contained_by_with_complex_criterion(self): + q = ( + PostgreSQLQuery.from_(self.table_abc) + .select("*") + .where(self.table_abc.json.contained_by(["One", "Two", "Three"]) & (self.table_abc.id == 26)) + ) + + self.assertEqual( + 'SELECT * FROM "abc" WHERE "json"<@\'["One","Two","Three"]\' AND "id"=26', + str(q), + ) + + def test_json_has_key(self): + q = PostgreSQLQuery.from_(self.table_abc).select("*").where(self.table_abc.json.has_key("dates")) + + self.assertEqual('SELECT * FROM "abc" WHERE "json"?\'dates\'', str(q)) + + def test_json_has_keys(self): + q = PostgreSQLQuery.from_(self.table_abc).select("*").where(self.table_abc.json.has_keys(["dates", "imported"])) + + self.assertEqual("SELECT * FROM \"abc\" WHERE \"json\"?&ARRAY['dates','imported']", str(q)) + + def test_json_has_any_keys(self): + q = ( + PostgreSQLQuery.from_(self.table_abc) + .select("*") + .where(self.table_abc.json.has_any_keys(["dates", "imported"])) + ) + + self.assertEqual("SELECT * FROM \"abc\" WHERE \"json\"?|ARRAY['dates','imported']", str(q)) + + def test_subnet_contains_inet(self): + q = ( + PostgreSQLQuery.from_(self.table_abc) + .select(self.table_abc.a.lshift(2)) + .where(self.table_abc.cidr >> "1.1.1.1") + ) + + self.assertEqual("SELECT \"a\"<<2 FROM \"abc\" WHERE \"cidr\">>'1.1.1.1'", str(q)) + + +class DistinctOnTests(unittest.TestCase): + table_abc = Table("abc") + + def test_distinct_on(self): + q = PostgreSQLQuery.from_(self.table_abc).distinct_on("lname", self.table_abc.fname).select("lname", "id") + + self.assertEqual('''SELECT DISTINCT ON("lname","fname") "lname","id" FROM "abc"''', str(q)) + + +class ArrayTests(unittest.TestCase): + def test_array_syntax(self): + tb = Table("tb") + q = PostgreSQLQuery.from_(tb).select(Array(1, "a", ["b", 2, 3])) + + self.assertEqual(str(q), "SELECT ARRAY[1,'a',ARRAY['b',2,3]] FROM \"tb\"") + + def test_render_alias_in_array_sql(self): + tb = Table("tb") + + q = PostgreSQLQuery.from_(tb).select(Array(tb.col).as_("different_name")) + self.assertEqual(str(q), 'SELECT ARRAY["col"] "different_name" FROM "tb"') + + +class ReturningClauseTests(unittest.TestCase): + @classmethod + def setUpClass(cls) -> None: + super().setUpClass() + cls.table_abc = Table('abc') + + def test_returning_from_missing_table_raises_queryexception(self): + field_from_diff_table = Field('xyz', table=Table('other')) + + with self.assertRaisesRegex(QueryException, "You can't return from other tables"): + ( + PostgreSQLQuery.from_(self.table_abc) + .where(self.table_abc.foo == self.table_abc.bar) + .delete() + .returning(field_from_diff_table) + ) + + def test_queryexception_if_returning_used_on_invalid_query(self): + with self.assertRaisesRegex(QueryException, "Returning can't be used in this query"): + PostgreSQLQuery.from_(self.table_abc).select('abc').returning('abc') + + def test_no_queryexception_if_returning_used_on_valid_query_type(self): + # No exceptions for insert, update and delete queries + with self.subTest('DELETE'): + PostgreSQLQuery.from_(self.table_abc).where(self.table_abc.foo == self.table_abc.bar).delete().returning( + "id" + ) + with self.subTest('UPDATE'): + PostgreSQLQuery.update(self.table_abc).where(self.table_abc.foo == 0).set("foo", "bar").returning("id") + with self.subTest('INSERT'): + PostgreSQLQuery.into(self.table_abc).insert('abc').returning('abc') + + def test_return_field_from_join_table(self): + new_table = Table('xyz') + q = ( + PostgreSQLQuery.update(self.table_abc) + .join(new_table) + .on(new_table.id == self.table_abc.xyz) + .where(self.table_abc.foo == 0) + .set("foo", "bar") + .returning(new_table.a) + ) + + self.assertEqual( + 'UPDATE "abc" ' + 'JOIN "xyz" ON "xyz"."id"="abc"."xyz" ' + 'SET "foo"=\'bar\' ' + 'WHERE "abc"."foo"=0 ' + 'RETURNING "xyz"."a"', + str(q), + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/dialects/test_snowflake.py b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/dialects/test_snowflake.py new file mode 100644 index 0000000000000000000000000000000000000000..5ac08b2d8b8b5496ed6f3510acf4be1ec7893405 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/dialects/test_snowflake.py @@ -0,0 +1,58 @@ +import unittest + +from pypika import ( + Tables, + functions as fn, + Column, +) +from pypika.dialects import SnowflakeQuery + + +class QuoteTests(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_use_double_quotes_on_alias_but_not_on_terms(self): + q = SnowflakeQuery.from_(self.table_abc).select(self.table_abc.a.as_("bar")) + + self.assertEqual('SELECT a "bar" FROM abc', q.get_sql(with_namespace=True)) + + def test_use_double_quotes_on_alias_but_not_on_terms_with_joins(self): + foo = self.table_abc.as_("foo") + bar = self.table_efg.as_("bar") + + q = SnowflakeQuery.from_(foo).join(bar).on(foo.fk == bar.id).select(foo.a, bar.b) + + self.assertEqual( + "SELECT foo.a,bar.b " 'FROM abc "foo" ' 'JOIN efg "bar" ' "ON foo.fk=bar.id", + q.get_sql(with_namespace=True), + ) + + def test_use_double_quotes_on_alias_but_not_on_terms(self): + idx = self.table_abc.index.as_("idx") + val = fn.Sum(self.table_abc.value).as_("val") + q = SnowflakeQuery.from_(self.table_abc).select(idx, val).groupby(idx).orderby(idx) + + self.assertEqual( + 'SELECT index "idx",SUM(value) "val" ' "FROM abc " 'GROUP BY "idx" ' 'ORDER BY "idx"', + q.get_sql(with_namespace=True), + ) + + def test_dont_use_double_quotes_on_joining_queries(self): + foo = self.table_abc + bar = self.table_efg + q1 = SnowflakeQuery.from_(foo).select(foo.b) + q2 = SnowflakeQuery.from_(bar).select(bar.b) + q = SnowflakeQuery.from_(q1).join(q2).on(q1.b == q2.b).select("*") + + self.assertEqual( + "SELECT * " 'FROM (SELECT b FROM abc) sq0 ' 'JOIN (SELECT b FROM efg) sq1 ' "ON sq0.b=sq1.b", + q.get_sql(), + ) + + def test_dont_use_double_quotes_on_create_queries(self): + q = SnowflakeQuery.create_table(self.table_abc).columns(Column("id", "INT")) + self.assertEqual("CREATE TABLE abc (id INT)", q.get_sql()) + + def test_dont_use_double_quotes_on_drop_queries(self): + q = SnowflakeQuery.drop_table(self.table_abc) + self.assertEqual("DROP TABLE abc", q.get_sql()) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/dialects/test_sqllite.py b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/dialects/test_sqllite.py new file mode 100644 index 0000000000000000000000000000000000000000..104a7235b6ea2d46fd365989f68c5d081eb20076 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/dialects/test_sqllite.py @@ -0,0 +1,35 @@ +import unittest + +from pypika import Table +from pypika.dialects import SQLLiteQuery + + +class SelectTests(unittest.TestCase): + table_abc = Table("abc") + + def test_bool_true_as_one(self): + q = SQLLiteQuery.from_("abc").select(True) + + self.assertEqual('SELECT 1 FROM "abc"', str(q)) + + def test_bool_false_as_zero(self): + q = SQLLiteQuery.from_("abc").select(False) + + self.assertEqual('SELECT 0 FROM "abc"', str(q)) + + +class ReplaceTests(unittest.TestCase): + def test_normal_replace(self): + query = SQLLiteQuery.into("abc").replace("v1", "v2", "v3") + expected_output = "REPLACE INTO \"abc\" VALUES ('v1','v2','v3')" + self.assertEqual(expected_output, str(query)) + + def test_replace_subquery(self): + query = SQLLiteQuery.into("abc").replace(SQLLiteQuery.from_("def").select("f1", "f2")) + expected_output = 'REPLACE INTO "abc" VALUES ((SELECT "f1","f2" FROM "def"))' + self.assertEqual(expected_output, str(query)) + + def test_insert_or_replace(self): + query = SQLLiteQuery.into("abc").insert_or_replace("v1", "v2", "v3") + expected_output = "INSERT OR REPLACE INTO \"abc\" VALUES ('v1','v2','v3')" + self.assertEqual(expected_output, str(query)) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/dialects/test_vertica.py b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/dialects/test_vertica.py new file mode 100644 index 0000000000000000000000000000000000000000..61985bfc244fcd663e7d8a904b4645901f3abdfc --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/dialects/test_vertica.py @@ -0,0 +1,93 @@ +import unittest + +from pypika import Columns, Table, Tables, VerticaQuery + + +class VerticaQueryTests(unittest.TestCase): + table_abc = Table("abc") + + def test_select_query_with_hint(self): + q = VerticaQuery.from_("abc").select("*").hint("test_hint") + + self.assertEqual('SELECT /*+label(test_hint)*/ * FROM "abc"', str(q)) + + def test_insert_query_with_hint(self): + query = VerticaQuery.into(self.table_abc).insert(1).hint("test_hint") + + self.assertEqual('INSERT /*+label(test_hint)*/ INTO "abc" VALUES (1)', str(query)) + + def test_update_query_with_hint(self): + q = VerticaQuery.update(self.table_abc).set("foo", "bar").hint("test_hint") + + self.assertEqual('UPDATE /*+label(test_hint)*/ "abc" SET "foo"=\'bar\'', str(q)) + + def test_delete_query_with_hint(self): + q = VerticaQuery.from_("abc").delete().hint("test_hint") + + self.assertEqual('DELETE /*+label(test_hint)*/ FROM "abc"', str(q)) + + +class CopyCSVTests(unittest.TestCase): + table_abc = Table("abc") + + def test_copy_from_file(self): + with self.subTest("with table as string"): + q = VerticaQuery.from_file("/path/to/file").copy_("abc") + + self.assertEqual( + "COPY \"abc\" FROM LOCAL '/path/to/file' PARSER fcsvparser(header=false)", + str(q), + ) + + with self.subTest("with table"): + q = VerticaQuery.from_file("/path/to/file").copy_(self.table_abc) + + self.assertEqual( + "COPY \"abc\" FROM LOCAL '/path/to/file' PARSER fcsvparser(header=false)", + str(q), + ) + + +class CreateTemporaryTableTests(unittest.TestCase): + new_table, existing_table = Tables("abc", "efg") + foo, bar = Columns(("a", "INT"), ("b", "VARCHAR(100)")) + select = VerticaQuery.from_(existing_table).select(existing_table.foo, existing_table.bar) + + def test_create_local_temporary_table(self): + with self.subTest("with columns"): + q = VerticaQuery.create_table(self.new_table).temporary().local().columns(self.foo, self.bar) + + self.assertEqual('CREATE LOCAL TEMPORARY TABLE "abc" ("a" INT,"b" VARCHAR(100))', str(q)) + + with self.subTest("with select"): + q = VerticaQuery.create_table(self.new_table).temporary().local().as_select(self.select) + + self.assertEqual( + 'CREATE LOCAL TEMPORARY TABLE "abc" AS (SELECT "foo","bar" FROM "efg")', + str(q), + ) + + def test_create_local_table_without_temporary_raises_error(self): + with self.assertRaises(AttributeError): + VerticaQuery.create_table(self.new_table).local() + + def test_create_temporary_table_preserve_rows(self): + with self.subTest("with columns"): + q = VerticaQuery.create_table(self.new_table).temporary().preserve_rows().columns(self.foo, self.bar) + + self.assertEqual( + 'CREATE TEMPORARY TABLE "abc" ("a" INT,"b" VARCHAR(100)) ON COMMIT PRESERVE ROWS', + str(q), + ) + + with self.subTest("with select"): + q = VerticaQuery.create_table(self.new_table).temporary().preserve_rows().as_select(self.select) + + self.assertEqual( + 'CREATE TEMPORARY TABLE "abc" ON COMMIT PRESERVE ROWS AS (SELECT "foo","bar" FROM "efg")', + str(q), + ) + + def test_create_table_preserve_rows_without_temporary_raises_error(self): + with self.assertRaises(AttributeError): + VerticaQuery.create_table(self.new_table).preserve_rows() diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/test_aggregate.py b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/test_aggregate.py new file mode 100644 index 0000000000000000000000000000000000000000..1c627d8e9c2d65410c67cf2c39974949b0720a0e --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/test_aggregate.py @@ -0,0 +1,122 @@ +import unittest + +from pypika import ( + Case, + Field, + Table, + functions as fn, +) +from pypika.terms import ( + Negative, + ValueWrapper, +) + + +class IsAggregateTests(unittest.TestCase): + def test__field_is_not_aggregate(self): + v = Field("foo") + self.assertFalse(v.is_aggregate) + + def test__constant_is_aggregate_none(self): + v = ValueWrapper(100) + self.assertIsNone(v.is_aggregate) + + def test__constant_arithmetic_is_aggregate_none(self): + v = ValueWrapper(100) + ValueWrapper(100) + self.assertIsNone(v.is_aggregate) + + def test__field_arithmetic_is_not_aggregate(self): + v = Field("foo") + Field("bar") + self.assertFalse(v.is_aggregate) + + def test__field_arithmetic_constant_is_not_aggregate(self): + v = Field("foo") + 1 + self.assertFalse(v.is_aggregate) + + def test__agg_func_is_aggregate(self): + v = fn.Sum(Field("foo")) + self.assertTrue(v.is_aggregate) + + def test__negative_agg_func_is_aggregate(self): + v = Negative(fn.Sum(Field("foo"))) + self.assertTrue(v.is_aggregate) + + def test__agg_func_arithmetic_is_aggregate(self): + v = fn.Sum(Field("foo")) / fn.Sum(Field("foo")) + self.assertTrue(v.is_aggregate) + + def test__mixed_func_arithmetic_is_not_aggregate(self): + v = Field("foo") / fn.Sum(Field("foo")) + self.assertFalse(v.is_aggregate) + + def test__func_arithmetic_constant_is_not_aggregate(self): + v = 1 / fn.Sum(Field("foo")) + self.assertTrue(v.is_aggregate) + + def test__agg_case_criterion_is_aggregate(self): + v = Case().when(fn.Sum(Field("foo")) > 666, 'More than 666').else_('Less than 666') + + self.assertTrue(v.is_aggregate) + + def test__agg_case_is_aggregate(self): + v = ( + Case() + .when(Field("foo") == 1, fn.Sum(Field("bar"))) + .when(Field("foo") == 2, fn.Sum(Field("fiz"))) + .else_(fn.Sum(Field("fiz"))) + ) + + self.assertTrue(v.is_aggregate) + + def test__mixed_case_is_not_aggregate(self): + v = Case().when(Field("foo") == 1, fn.Sum(Field("bar"))).when(Field("foo") == 2, Field("fiz")) + + self.assertFalse(v.is_aggregate) + + def test__case_mixed_else_is_not_aggregate(self): + v = ( + Case() + .when(Field("foo") == 1, fn.Sum(Field("bar"))) + .when(Field("foo") == 2, fn.Sum(Field("fiz"))) + .else_(Field("fiz")) + ) + + self.assertFalse(v.is_aggregate) + + def test__case_mixed_constant_is_not_aggregate(self): + v = Case().when(Field("foo") == 1, fn.Sum(Field("bar"))).when(Field("foo") == 2, fn.Sum(Field("fiz"))).else_(1) + + self.assertTrue(v.is_aggregate) + + def test__case_with_field_is_not_aggregate(self): + v = Case().when(Field("foo") == 1, 1).when(Field("foo") == 2, 2).else_(3) + + self.assertFalse(v.is_aggregate) + + def test__case_with_single_aggregate_field_in_one_criterion_is_aggregate(self): + v = Case().when(Field("foo") == 1, 1).when(fn.Sum(Field("foo")) == 2, 2).else_(3) + + self.assertTrue(v.is_aggregate) + + def test__non_aggregate_function_with_aggregated_arg(self): + t = Table("abc") + expr = fn.Sqrt(fn.Sum(t.a)) + + self.assertTrue(expr.is_aggregate) + + def test_complicated(self): + t = Table("abc") + is_placebo = t.campaign_extra_info == "placebo" + + pixel_mobile_search = Case().when(is_placebo, t.action_fb_pixel_search + t.action_fb_mobile_search) + unique_impressions = Case().when(is_placebo, t.unique_impressions) + + v = fn.Sum(pixel_mobile_search) / fn.Sum(unique_impressions) - 1.96 * fn.Sqrt( + 1 + / fn.Sum(unique_impressions) + * fn.Sum(pixel_mobile_search) + / fn.Sum(unique_impressions) + * (1 - fn.Sum(pixel_mobile_search) / fn.Sum(unique_impressions)) + ) + + self.assertTrue(v.is_aggregate) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/test_analytic_queries.py b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/test_analytic_queries.py new file mode 100644 index 0000000000000000000000000000000000000000..6a35ab854b30e3b0f91e633b3349706a22e0a2fd --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/test_analytic_queries.py @@ -0,0 +1,610 @@ +import unittest + +from pypika import Criterion, JoinType, Order, Query, Tables, analytics as an +from pypika.analytics import Lag, Lead + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + + +class RankTests(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_rank(self): + expr = an.Rank().over(self.table_abc.foo).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " "RANK() " 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_dense_rank(self): + expr = an.DenseRank().over(self.table_abc.foo).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " "DENSE_RANK() " 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_row_number(self): + expr = an.RowNumber().over(self.table_abc.foo).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " "ROW_NUMBER() " 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_rank_with_alias(self): + expr = an.Rank().over(self.table_abc.foo).orderby(self.table_abc.date).as_("rank") + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " "RANK() " 'OVER(PARTITION BY "foo" ORDER BY "date") "rank" ' 'FROM "abc"', + str(q), + ) + + def test_multiple_partitions(self): + expr = an.Rank().orderby(self.table_abc.date).over(self.table_abc.foo, self.table_abc.bar) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " "RANK() " 'OVER(PARTITION BY "foo","bar" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_ntile_no_partition_or_order_invalid_sql(self): + expr = an.NTile(5) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual("SELECT " "NTILE(5) " 'FROM "abc"', str(q)) + + def test_ntile_with_partition(self): + expr = an.NTile(5).over(self.table_abc.foo) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual("SELECT " "NTILE(5) " 'OVER(PARTITION BY "foo") ' 'FROM "abc"', str(q)) + + def test_ntile_with_order(self): + expr = an.NTile(5).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual("SELECT " "NTILE(5) " 'OVER(ORDER BY "date") ' 'FROM "abc"', str(q)) + + def test_ntile_with_partition_and_order(self): + expr = an.NTile(5).over(self.table_abc.foo).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " "NTILE(5) " 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_first_value(self): + expr = an.FirstValue(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'FIRST_VALUE("fizz") ' 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_first_value_ignore_nulls(self): + expr = an.FirstValue(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).ignore_nulls() + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'FIRST_VALUE("fizz" IGNORE NULLS) ' 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_first_value_ignore_nulls_first(self): + expr = an.FirstValue(self.table_abc.fizz).ignore_nulls().over(self.table_abc.foo).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'FIRST_VALUE("fizz" IGNORE NULLS) ' 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_first_value_multi_argument(self): + expr = ( + an.FirstValue(self.table_abc.fizz, self.table_abc.buzz) + .over(self.table_abc.foo) + .orderby(self.table_abc.date) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'FIRST_VALUE("fizz","buzz") ' 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_last_value(self): + expr = an.LastValue(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'LAST_VALUE("fizz") ' 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_filter(self): + expr = ( + an.LastValue(self.table_abc.fizz) + .filter(Criterion.all([self.table_abc.bar == True])) + .over(self.table_abc.foo) + .orderby(self.table_abc.date) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'LAST_VALUE("fizz") ' + 'FILTER(WHERE "bar"=true) ' + 'OVER(PARTITION BY "foo" ORDER BY "date") ' + 'FROM "abc"', + str(q), + ) + + def test_filter_quote_table_in_filter(self): + expr = ( + an.LastValue(self.table_efg.fizz) + .filter(self.table_efg.filed.eq('yes')) + .over(self.table_efg.foo) + .orderby(self.table_efg.date) + ) + + q = ( + Query.from_(self.table_abc) + .inner_join(self.table_efg) + .on(self.table_abc.id.eq(self.table_efg.id)) + .select(expr) + ) + + self.assertEqual( + 'SELECT ' + 'LAST_VALUE("efg"."fizz") ' + 'FILTER(WHERE "efg"."filed"=\'yes\') ' + 'OVER(PARTITION BY "efg"."foo" ORDER BY "efg"."date") ' + 'FROM "abc" ' + 'JOIN "efg" ON "abc"."id"="efg"."id"', + str(q), + ) + + def test_orderby_asc(self): + expr = an.LastValue(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date, order=Order.asc) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'LAST_VALUE("fizz") ' 'OVER(PARTITION BY "foo" ORDER BY "date" ASC) ' 'FROM "abc"', + str(q), + ) + + def test_orderby_desc(self): + expr = an.LastValue(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date, order=Order.desc) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'LAST_VALUE("fizz") ' 'OVER(PARTITION BY "foo" ORDER BY "date" DESC) ' 'FROM "abc"', + str(q), + ) + + def test_last_value_multi_argument(self): + expr = ( + an.LastValue(self.table_abc.fizz, self.table_abc.buzz).over(self.table_abc.foo).orderby(self.table_abc.date) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'LAST_VALUE("fizz","buzz") ' 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_last_value_ignore_nulls(self): + expr = an.LastValue(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).ignore_nulls() + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'LAST_VALUE("fizz" IGNORE NULLS) ' 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_median(self): + expr = an.Median(self.table_abc.fizz).over(self.table_abc.foo, self.table_abc.bar).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'MEDIAN("fizz") ' 'OVER(PARTITION BY "foo","bar" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_avg(self): + expr = an.Avg(self.table_abc.fizz).over(self.table_abc.foo, self.table_abc.bar).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'AVG("fizz") ' 'OVER(PARTITION BY "foo","bar" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_stddev(self): + expr = an.StdDev(self.table_abc.fizz).over(self.table_abc.foo, self.table_abc.bar).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'STDDEV("fizz") ' 'OVER(PARTITION BY "foo","bar" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_stddev_pop(self): + expr = ( + an.StdDevPop(self.table_abc.fizz).over(self.table_abc.foo, self.table_abc.bar).orderby(self.table_abc.date) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'STDDEV_POP("fizz") ' 'OVER(PARTITION BY "foo","bar" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_stddev_samp(self): + expr = ( + an.StdDevSamp(self.table_abc.fizz).over(self.table_abc.foo, self.table_abc.bar).orderby(self.table_abc.date) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'STDDEV_SAMP("fizz") ' 'OVER(PARTITION BY "foo","bar" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_variance(self): + expr = ( + an.Variance(self.table_abc.fizz).over(self.table_abc.foo, self.table_abc.bar).orderby(self.table_abc.date) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'VARIANCE("fizz") ' 'OVER(PARTITION BY "foo","bar" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_var_pop(self): + expr = an.VarPop(self.table_abc.fizz).over(self.table_abc.foo, self.table_abc.bar).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'VAR_POP("fizz") ' 'OVER(PARTITION BY "foo","bar" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_var_samp(self): + expr = an.VarSamp(self.table_abc.fizz).over(self.table_abc.foo, self.table_abc.bar).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'VAR_SAMP("fizz") ' 'OVER(PARTITION BY "foo","bar" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_table_prefixes_used_in_analytic_functions(self): + expr = an.Rank().over(self.table_abc.foo).orderby(self.table_efg.date) + + query = ( + Query.from_(self.table_abc) + .join(self.table_efg, how=JoinType.left) + .on(self.table_abc.foo == self.table_efg.bar) + .select("*", expr) + ) + + self.assertEqual( + 'SELECT *,RANK() OVER(PARTITION BY "abc"."foo" ORDER BY "efg"."date") ' + 'FROM "abc" LEFT JOIN "efg" ON "abc"."foo"="efg"."bar"', + str(query), + ) + + def test_sum_rows_unbounded_preceeding(self): + expr = an.Sum(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).rows(an.Preceding()) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'SUM("fizz") ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "ROWS UNBOUNDED PRECEDING" + ") " + 'FROM "abc"', + str(q), + ) + + def test_max_rows_x_preceeding(self): + expr = an.Max(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).rows(an.Preceding(5)) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'MAX("fizz") ' "OVER(" 'PARTITION BY "foo" ORDER BY "date" ' "ROWS 5 PRECEDING" ") " 'FROM "abc"', + str(q), + ) + + def test_min_rows_current_row(self): + expr = an.Min(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).rows(an.CURRENT_ROW) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'MIN("fizz") ' "OVER(" 'PARTITION BY "foo" ORDER BY "date" ' "ROWS CURRENT ROW" ") " 'FROM "abc"', + str(q), + ) + + def test_varpop_range_unbounded_preceeding(self): + expr = ( + an.VarPop(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).range(an.Preceding()) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'VAR_POP("fizz") ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "RANGE UNBOUNDED PRECEDING" + ") " + 'FROM "abc"', + str(q), + ) + + def test_max_range_x_preceeding(self): + expr = an.Max(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).range(an.Preceding(5)) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'MAX("fizz") ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "RANGE 5 PRECEDING" + ") " + 'FROM "abc"', + str(q), + ) + + def test_min_range_current_row(self): + expr = an.Min(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).range(an.CURRENT_ROW) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'MIN("fizz") ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "RANGE CURRENT ROW" + ") " + 'FROM "abc"', + str(q), + ) + + def test_variance_rows_between_unbounded_preceeding_unbounded_following(self): + expr = ( + an.Variance(self.table_abc.fizz) + .over(self.table_abc.foo) + .orderby(self.table_abc.date) + .rows(an.Preceding(), an.Following()) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'VARIANCE("fizz") ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING" + ") " + 'FROM "abc"', + str(q), + ) + + def test_first_value_range_between_x_preceeding_unbounded_following(self): + expr = ( + an.FirstValue(self.table_abc.fizz) + .over(self.table_abc.foo) + .orderby(self.table_abc.date) + .range(an.Preceding(3), an.Following()) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'FIRST_VALUE("fizz") ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "RANGE BETWEEN 3 PRECEDING AND UNBOUNDED FOLLOWING" + ") " + 'FROM "abc"', + str(q), + ) + + def test_varpop_rows_between_unbounded_preceeding_x_following(self): + expr = ( + an.VarPop(self.table_abc.fizz) + .over(self.table_abc.foo) + .orderby(self.table_abc.date) + .rows(an.Preceding(), an.Following(6)) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'VAR_POP("fizz") ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "ROWS BETWEEN UNBOUNDED PRECEDING AND 6 FOLLOWING" + ") " + 'FROM "abc"', + str(q), + ) + + def test_count_range_between_unbounded_preceeding_current_row(self): + expr = ( + an.Count(self.table_abc.fizz) + .over(self.table_abc.foo) + .orderby(self.table_abc.date) + .range(an.Preceding(), an.CURRENT_ROW) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'COUNT("fizz") ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW" + ") " + 'FROM "abc"', + str(q), + ) + + def test_last_value_rows_between_current_row_unbounded_following(self): + expr = ( + an.LastValue(self.table_abc.fizz) + .over(self.table_abc.foo) + .orderby(self.table_abc.date) + .rows(an.CURRENT_ROW, an.Following()) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'LAST_VALUE("fizz") ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING" + ") " + 'FROM "abc"', + str(q), + ) + + def test_last_value_rows_between_current_row_unbounded_following_ignore_nulls(self): + expr = ( + an.LastValue(self.table_abc.fizz) + .over(self.table_abc.foo) + .orderby(self.table_abc.date) + .ignore_nulls() + .rows(an.CURRENT_ROW, an.Following(8)) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'LAST_VALUE("fizz" IGNORE NULLS) ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "ROWS BETWEEN CURRENT ROW AND 8 FOLLOWING" + ") " + 'FROM "abc"', + str(q), + ) + + def test_empty_over(self): + query = Query.from_(self.table_abc).select(an.Sum(self.table_abc.fizz).over()) + + self.assertEqual("SELECT " 'SUM("fizz") OVER() ' 'FROM "abc"', str(query)) + + def test_rows_called_twice_raises_attribute_error(self): + with self.assertRaises(AttributeError): + an.Sum(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).rows(an.Preceding()).rows( + an.Preceding() + ) + + def test_range_called_twice_raises_attribute_error(self): + with self.assertRaises(AttributeError): + an.Sum(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).range( + an.Preceding() + ).range(an.Preceding()) + + def test_rows_then_range_raises_attribute_error(self): + with self.assertRaises(AttributeError): + an.Sum(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).rows( + an.Preceding() + ).range(an.Preceding()) + + def test_range_then_rows_raises_attribute_error(self): + with self.assertRaises(AttributeError): + an.Sum(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).range( + an.Preceding() + ).rows(an.Preceding()) + + def test_lag_generates_correct_sql(self): + with self.subTest('without partition by'): + q = Query.from_(self.table_abc).select( + Lag(self.table_abc.date, 1, '2000-01-01').orderby(self.table_abc.date) + ) + + self.assertEqual('SELECT LAG("date",1,\'2000-01-01\') OVER(ORDER BY "date") FROM "abc"', str(q)) + + with self.subTest('with partition by'): + q = Query.from_(self.table_abc).select( + Lag(self.table_abc.date, 1, '2000-01-01').over(self.table_abc.foo).orderby(self.table_abc.date) + ) + + self.assertEqual( + 'SELECT LAG("date",1,\'2000-01-01\') OVER(PARTITION BY "foo" ORDER BY "date") FROM "abc"', str(q) + ) + + def test_lead_generates_correct_sql(self): + with self.subTest('without partition by'): + q = Query.from_(self.table_abc).select( + Lead(self.table_abc.date, 1, '2000-01-01').orderby(self.table_abc.date) + ) + + self.assertEqual('SELECT LEAD("date",1,\'2000-01-01\') OVER(ORDER BY "date") FROM "abc"', str(q)) + + with self.subTest('with partition by'): + q = Query.from_(self.table_abc).select( + Lead(self.table_abc.date, 1, '2000-01-01').over(self.table_abc.foo).orderby(self.table_abc.date) + ) + + self.assertEqual( + 'SELECT LEAD("date",1,\'2000-01-01\') OVER(PARTITION BY "foo" ORDER BY "date") FROM "abc"', str(q) + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/test_create.py b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/test_create.py new file mode 100644 index 0000000000000000000000000000000000000000..325076544e3824b0d07f82f2378b88218b910dde --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/test_create.py @@ -0,0 +1,210 @@ +import unittest + +from pypika import Column, Columns, Query, Tables, Table +from pypika.terms import ValueWrapper, Index +from pypika.enums import ReferenceOption + + +class CreateTableTests(unittest.TestCase): + new_table, existing_table = Tables("abc", "efg") + foo, bar = Columns(("a", "INT"), ("b", "VARCHAR(100)")) + + def test_create_table_with_columns(self): + with self.subTest("with nullable"): + a = Column("a", "INT", True) + b = Column("b", "VARCHAR(100)", False) + q = Query.create_table(self.new_table).columns(a, b) + + self.assertEqual('CREATE TABLE "abc" ("a" INT NULL,"b" VARCHAR(100) NOT NULL)', str(q)) + + with self.subTest("with defaults"): + a = Column("a", "INT", default=ValueWrapper(42)) + b = Column("b", "VARCHAR(100)", default=ValueWrapper("foo")) + q = Query.create_table(self.new_table).columns(a, b) + + self.assertEqual('CREATE TABLE "abc" ("a" INT DEFAULT 42,"b" VARCHAR(100) DEFAULT \'foo\')', str(q)) + + with self.subTest("with unwrapped defaults"): + a = Column("a", "INT", default=42) + b = Column("b", "VARCHAR(100)", default="foo") + q = Query.create_table(self.new_table).columns(a, b) + + self.assertEqual('CREATE TABLE "abc" ("a" INT DEFAULT 42,"b" VARCHAR(100) DEFAULT \'foo\')', str(q)) + + with self.subTest("with period for"): + a = Column("id", "INT") + b = Column("valid_from", "DATETIME") + c = Column("valid_to", "DATETIME") + q = Query.create_table(self.new_table).columns(a, b, c).period_for('valid_period', b, c) + + self.assertEqual( + 'CREATE TABLE "abc" (' + '"id" INT,' + '"valid_from" DATETIME,' + '"valid_to" DATETIME,' + 'PERIOD FOR "valid_period" ("valid_from","valid_to"))', + str(q), + ) + + with self.subTest("without temporary keyword"): + q = Query.create_table(self.new_table).columns(self.foo, self.bar) + + self.assertEqual('CREATE TABLE "abc" ("a" INT,"b" VARCHAR(100))', str(q)) + + with self.subTest("with temporary keyword"): + q = Query.create_table(self.new_table).temporary().columns(self.foo, self.bar) + + self.assertEqual('CREATE TEMPORARY TABLE "abc" ("a" INT,"b" VARCHAR(100))', str(q)) + + with self.subTest("with primary key"): + q = Query.create_table(self.new_table).columns(self.foo, self.bar).primary_key(self.foo, self.bar) + + self.assertEqual('CREATE TABLE "abc" ("a" INT,"b" VARCHAR(100),PRIMARY KEY ("a","b"))', str(q)) + + with self.subTest("with simple foreign key"): + cref, dref = Columns(("c", "INT"), ("d", "VARCHAR(100)")) + q = ( + Query.create_table(self.new_table) + .columns(self.foo, self.bar) + .foreign_key([self.foo, self.bar], self.existing_table, [cref, dref]) + ) + + self.assertEqual( + 'CREATE TABLE "abc" (' + '"a" INT,' + '"b" VARCHAR(100),' + 'FOREIGN KEY ("a","b") REFERENCES "efg" ("c","d"))', + str(q), + ) + + with self.subTest("with foreign key reference options"): + cref, dref = Columns(("c", "INT"), ("d", "VARCHAR(100)")) + q = ( + Query.create_table(self.new_table) + .columns(self.foo, self.bar) + .foreign_key( + [self.foo, self.bar], + self.existing_table, + [cref, dref], + on_delete=ReferenceOption.cascade, + on_update=ReferenceOption.restrict, + ) + ) + + self.assertEqual( + 'CREATE TABLE "abc" (' + '"a" INT,' + '"b" VARCHAR(100),' + 'FOREIGN KEY ("a","b") REFERENCES "efg" ("c","d") ON DELETE CASCADE ON UPDATE RESTRICT)', + str(q), + ) + + with self.subTest("with unique keys"): + q = ( + Query.create_table(self.new_table) + .columns(self.foo, self.bar) + .unique(self.foo, self.bar) + .unique(self.foo) + ) + + self.assertEqual('CREATE TABLE "abc" ("a" INT,"b" VARCHAR(100),UNIQUE ("a","b"),UNIQUE ("a"))', str(q)) + + with self.subTest("with system versioning"): + q = Query.create_table(self.new_table).columns(self.foo, self.bar).with_system_versioning() + + self.assertEqual('CREATE TABLE "abc" ("a" INT,"b" VARCHAR(100)) WITH SYSTEM VERSIONING', str(q)) + + with self.subTest("with unlogged keyword"): + q = Query.create_table(self.new_table).unlogged().columns(self.foo, self.bar) + + self.assertEqual('CREATE UNLOGGED TABLE "abc" ("a" INT,"b" VARCHAR(100))', str(q)) + + with self.subTest("with if not exists keyword"): + q = Query.create_table(self.new_table).if_not_exists().columns(self.foo, self.bar) + + self.assertEqual('CREATE TABLE IF NOT EXISTS "abc" ("a" INT,"b" VARCHAR(100))', str(q)) + + def test_create_table_with_select(self): + select = Query.from_(self.existing_table).select(self.existing_table.foo, self.existing_table.bar) + + with self.subTest("without temporary keyword"): + q = Query.create_table(self.new_table).as_select(select) + + self.assertEqual('CREATE TABLE "abc" AS (SELECT "foo","bar" FROM "efg")', str(q)) + + with self.subTest("with temporary keyword"): + q = Query.create_table(self.new_table).temporary().as_select(select) + + self.assertEqual( + 'CREATE TEMPORARY TABLE "abc" AS (SELECT "foo","bar" FROM "efg")', + str(q), + ) + + def test_create_table_without_columns_or_select_empty(self): + q = Query.create_table(self.new_table) + + self.assertEqual("", str(q)) + + def test_create_table_with_select_and_columns_fails(self): + select = Query.from_(self.existing_table).select(self.existing_table.foo, self.existing_table.bar) + + with self.subTest("for columns before as_select"): + with self.assertRaises(AttributeError): + Query.create_table(self.new_table).columns(self.foo, self.bar).as_select(select) + + with self.subTest("for as_select before columns"): + with self.assertRaises(AttributeError): + Query.create_table(self.new_table).as_select(select).columns(self.foo, self.bar) + + with self.subTest("repeated foreign key"): + with self.assertRaises(AttributeError): + Query.create_table(self.new_table).foreign_key([self.foo], self.existing_table, [self.bar]).foreign_key( + [self.foo], self.existing_table, [self.bar] + ) + + def test_create_table_as_select_not_query_raises_error(self): + with self.assertRaises(TypeError): + Query.create_table(self.new_table).as_select("abc") + + +class CreateIndexTests(unittest.TestCase): + new_index = Index("abc") + new_table = Table("my_table") + columns = (new_table.a, new_table.b) + where = new_table.a > 1 + + def test_create_index_simple(self) -> None: + q = Query.create_index(self.new_index).on(self.new_table).columns(*self.columns) + self.assertEqual( + f'CREATE INDEX "{self.new_index.name}" ON "{self.new_table.get_table_name()}"({", ".join([c.name for c in self.columns])})', + q.get_sql(), + ) + + def test_create_index_where(self) -> None: + q = Query.create_index(self.new_index).on(self.new_table).columns(*self.columns).where(self.where) + self.assertEqual( + f'CREATE INDEX "{self.new_index.name}" ON "{self.new_table.get_table_name()}"({", ".join([c.name for c in self.columns])}) WHERE {self.where.get_sql()}', + q.get_sql(), + ) + + def test_create_index_unique(self) -> None: + q = Query.create_index(self.new_index).on(self.new_table).columns(*self.columns).unique() + self.assertEqual( + f'CREATE UNIQUE INDEX "{self.new_index.name}" ON "{self.new_table.get_table_name()}"({", ".join([c.name for c in self.columns])})', + q.get_sql(), + ) + + def test_create_index_if_not_exists(self) -> None: + q = Query.create_index(self.new_index).on(self.new_table).columns(*self.columns).if_not_exists() + self.assertEqual( + f'CREATE INDEX IF NOT EXISTS "{self.new_index.name}" ON "{self.new_table.get_table_name()}"({", ".join([c.name for c in self.columns])})', + q.get_sql(), + ) + + def test_create_index_without_columns_raises_error(self) -> None: + with self.assertRaises(AttributeError): + Query.create_index(self.new_index).on(self.new_table).get_sql() + + def test_create_index_without_table_raises_error(self) -> None: + with self.assertRaises(AttributeError): + Query.create_index(self.new_index).columns(*self.columns).get_sql() diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/test_criterions.py b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/test_criterions.py new file mode 100644 index 0000000000000000000000000000000000000000..fca2ceeeb18db88e34ebc38776f644fdcda67e93 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/test_criterions.py @@ -0,0 +1,873 @@ +import unittest +from datetime import ( + date, + datetime, +) + +from pypika import ( + Criterion, + EmptyCriterion, + Field, + Table, + functions as fn, +) +from pypika.queries import QueryBuilder +from pypika.terms import ExistsCriterion, Mod + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + + +class CriterionTests(unittest.TestCase): + t = Table("test", alias="crit") + + def test__criterion_with_alias(self): + c1 = (Field("foo") == Field("bar")).as_("criterion") + + self.assertEqual('"foo"="bar"', str(c1)) + self.assertEqual('"foo"="bar" "criterion"', c1.get_sql(with_alias=True, quote_char='"', alias_quote_char='"')) + + def test__criterion_eq_number(self): + c1 = Field("foo") == 1 + c2 = Field("foo", table=self.t).eq(0) + c3 = Field("foo", table=self.t) == -1 + + self.assertEqual('"foo"=1', str(c1)) + self.assertEqual('"crit"."foo"=0', str(c2)) + self.assertEqual('"crit"."foo"=-1', str(c3)) + + def test__criterion_eq_decimal(self): + c1 = Field("foo") == 1.0 + c2 = Field("foo", table=self.t).eq(0.5) + + self.assertEqual('"foo"=1.0', str(c1)) + self.assertEqual('"crit"."foo"=0.5', str(c2)) + + def test__criterion_eq_bool(self): + c1 = Field("foo") == True + c2 = Field("foo", table=self.t).eq(True) + c3 = Field("foo") == False + c4 = Field("foo", table=self.t).eq(False) + + self.assertEqual('"foo"=true', str(c1)) + self.assertEqual('"crit"."foo"=true', str(c2)) + self.assertEqual('"foo"=false', str(c3)) + self.assertEqual('"crit"."foo"=false', str(c4)) + + def test__criterion_eq_str(self): + c1 = Field("foo") == "abc" + c2 = Field("foo", table=self.t).eq("abc") + + self.assertEqual("\"foo\"='abc'", str(c1)) + self.assertEqual('"crit"."foo"=\'abc\'', str(c2)) + + def test__criterion_eq_date(self): + c1 = Field("foo") == date(2000, 1, 1) + c2 = Field("foo", table=self.t).eq(date(2000, 1, 1)) + + self.assertEqual("\"foo\"='2000-01-01'", str(c1)) + self.assertEqual('"crit"."foo"=\'2000-01-01\'', str(c2)) + + def test__criterion_eq_datetime(self): + c1 = Field("foo") == datetime(2000, 1, 1, 12, 30, 55) + c2 = Field("foo", table=self.t).eq(datetime(2000, 1, 1, 12, 30, 55)) + + self.assertEqual("\"foo\"='2000-01-01T12:30:55'", str(c1)) + self.assertEqual('"crit"."foo"=\'2000-01-01T12:30:55\'', str(c2)) + + def test__criterion_eq_right(self): + c1 = 1 == Field("foo") + c2 = -1 == Field("foo", table=self.t) + + self.assertEqual('"foo"=1', str(c1)) + self.assertEqual('"crit"."foo"=-1', str(c2)) + + def test__criterion_is_null(self): + c1 = Field("foo").isnull() + c2 = Field("foo", table=self.t).isnull() + + self.assertEqual('"foo" IS NULL', str(c1)) + self.assertEqual('"crit"."foo" IS NULL', str(c2)) + + def test__criterion_is_null_with_alias(self): + c1 = Field("foo").isnull().as_('alias') + c2 = Field("foo", table=self.t).isnull().as_('alias') + + self.assertEqual('"foo" IS NULL "alias"', str(c1)) + self.assertEqual('"crit"."foo" IS NULL "alias"', str(c2)) + + def test__criterion_ne_number(self): + c1 = Field("foo") != 1 + c2 = Field("foo", table=self.t).ne(0) + c3 = Field("foo") != -1 + + self.assertEqual('"foo"<>1', str(c1)) + self.assertEqual('"crit"."foo"<>0', str(c2)) + self.assertEqual('"foo"<>-1', str(c3)) + + def test__criterion_ne_str(self): + c1 = Field("foo") != "abc" + c2 = Field("foo", table=self.t).ne("abc") + + self.assertEqual("\"foo\"<>'abc'", str(c1)) + self.assertEqual('"crit"."foo"<>\'abc\'', str(c2)) + + def test__criterion_ne_date(self): + c1 = Field("foo") != date(2000, 1, 1) + c2 = Field("foo", table=self.t).ne(date(2000, 1, 1)) + + self.assertEqual("\"foo\"<>'2000-01-01'", str(c1)) + self.assertEqual('"crit"."foo"<>\'2000-01-01\'', str(c2)) + + def test__criterion_ne_datetime(self): + c1 = Field("foo") != datetime(2000, 1, 1, 12, 30, 55) + c2 = Field("foo", table=self.t).ne(datetime(2000, 1, 1, 12, 30, 55)) + + self.assertEqual("\"foo\"<>'2000-01-01T12:30:55'", str(c1)) + self.assertEqual('"crit"."foo"<>\'2000-01-01T12:30:55\'', str(c2)) + + def test__criterion_ne_right(self): + c1 = 1 != Field("foo") + c2 = -1 != Field("foo", table=self.t) + + self.assertEqual('"foo"<>1', str(c1)) + self.assertEqual('"crit"."foo"<>-1', str(c2)) + + def test__criterion_lt_number(self): + c1 = Field("foo") < 1 + c2 = Field("foo", table=self.t).lt(0) + c3 = Field("foo") < -1 + + self.assertEqual('"foo"<1', str(c1)) + self.assertEqual('"crit"."foo"<0', str(c2)) + self.assertEqual('"foo"<-1', str(c3)) + + def test__criterion_lt_date(self): + c1 = Field("foo") < date(2000, 1, 1) + c2 = Field("foo", table=self.t).lt(date(2000, 1, 1)) + + self.assertEqual("\"foo\"<'2000-01-01'", str(c1)) + self.assertEqual('"crit"."foo"<\'2000-01-01\'', str(c2)) + + def test__criterion_lt_datetime(self): + c1 = Field("foo") < datetime(2000, 1, 1, 12, 30, 55) + c2 = Field("foo", table=self.t).lt(datetime(2000, 1, 1, 12, 30, 55)) + + self.assertEqual("\"foo\"<'2000-01-01T12:30:55'", str(c1)) + self.assertEqual('"crit"."foo"<\'2000-01-01T12:30:55\'', str(c2)) + + def test__criterion_lt_right(self): + c1 = 1 > Field("foo") + c2 = -1 > Field("foo", table=self.t) + + self.assertEqual('"foo"<1', str(c1)) + self.assertEqual('"crit"."foo"<-1', str(c2)) + + def test__criterion_gt_number(self): + c1 = Field("foo") > 1 + c2 = Field("foo", table=self.t).gt(0) + c3 = Field("foo") > -1 + + self.assertEqual('"foo">1', str(c1)) + self.assertEqual('"crit"."foo">0', str(c2)) + self.assertEqual('"foo">-1', str(c3)) + + def test__criterion_gt_date(self): + c1 = Field("foo") > date(2000, 1, 1) + c2 = Field("foo", table=self.t).gt(date(2000, 1, 1)) + + self.assertEqual("\"foo\">'2000-01-01'", str(c1)) + self.assertEqual('"crit"."foo">\'2000-01-01\'', str(c2)) + + def test__criterion_gt_datetime(self): + c1 = Field("foo") > datetime(2000, 1, 1, 12, 30, 55) + c2 = Field("foo", table=self.t).gt(datetime(2000, 1, 1, 12, 30, 55)) + + self.assertEqual("\"foo\">'2000-01-01T12:30:55'", str(c1)) + self.assertEqual('"crit"."foo">\'2000-01-01T12:30:55\'', str(c2)) + + def test__criterion_gt_right(self): + c1 = 1 < Field("foo") + c2 = -1 < Field("foo", table=self.t) + + self.assertEqual('"foo">1', str(c1)) + self.assertEqual('"crit"."foo">-1', str(c2)) + + def test__criterion_lte_number(self): + c1 = Field("foo") <= 1 + c2 = Field("foo", table=self.t).lte(0) + c3 = Field("foo") <= -1 + + self.assertEqual('"foo"<=1', str(c1)) + self.assertEqual('"crit"."foo"<=0', str(c2)) + self.assertEqual('"foo"<=-1', str(c3)) + + def test__criterion_lte_date(self): + c1 = Field("foo") <= date(2000, 1, 1) + c2 = Field("foo", table=self.t).lte(date(2000, 1, 1)) + + self.assertEqual("\"foo\"<='2000-01-01'", str(c1)) + self.assertEqual('"crit"."foo"<=\'2000-01-01\'', str(c2)) + + def test__criterion_lte_datetime(self): + c1 = Field("foo") <= datetime(2000, 1, 1, 12, 30, 55) + c2 = Field("foo", table=self.t).lte(datetime(2000, 1, 1, 12, 30, 55)) + + self.assertEqual("\"foo\"<='2000-01-01T12:30:55'", str(c1)) + self.assertEqual('"crit"."foo"<=\'2000-01-01T12:30:55\'', str(c2)) + + def test__criterion_lte_right(self): + c1 = 1 >= Field("foo") + c2 = -1 >= Field("foo", table=self.t) + + self.assertEqual('"foo"<=1', str(c1)) + self.assertEqual('"crit"."foo"<=-1', str(c2)) + + def test__criterion_gte_number(self): + c1 = Field("foo") >= 1 + c2 = Field("foo", table=self.t).gte(0) + c3 = Field("foo") >= -1 + + self.assertEqual('"foo">=1', str(c1)) + self.assertEqual('"crit"."foo">=0', str(c2)) + self.assertEqual('"foo">=-1', str(c3)) + + def test__criterion_gte_date(self): + c1 = Field("foo") >= date(2000, 1, 1) + c2 = Field("foo", table=self.t).gte(date(2000, 1, 1)) + + self.assertEqual("\"foo\">='2000-01-01'", str(c1)) + self.assertEqual('"crit"."foo">=\'2000-01-01\'', str(c2)) + + def test__criterion_gte_datetime(self): + c1 = Field("foo") >= datetime(2000, 1, 1, 12, 30, 55) + c2 = Field("foo", table=self.t).gte(datetime(2000, 1, 1, 12, 30, 55)) + + self.assertEqual("\"foo\">='2000-01-01T12:30:55'", str(c1)) + self.assertEqual('"crit"."foo">=\'2000-01-01T12:30:55\'', str(c2)) + + def test__criterion_gte_right(self): + c1 = 1 <= Field("foo") + c2 = -1 <= Field("foo", table=self.t) + + self.assertEqual('"foo">=1', str(c1)) + self.assertEqual('"crit"."foo">=-1', str(c2)) + + def test__criterion_bitwise_and(self): + c1 = Field("foo").bitwiseand(2) + c2 = Field("foo", table=self.t).bitwiseand(10) == 2 + + self.assertEqual('("foo" & 2)', str(c1)) + self.assertEqual('("crit"."foo" & 10)=2', str(c2)) + + def test__criterion_bitwise_and_with_alias(self): + c1 = Field("foo").bitwiseand(2).as_('alias') + + self.assertEqual('("foo" & 2) "alias"', str(c1)) + + def test__bitwise_and_in_where_clause(self): + q = QueryBuilder().from_('items').select('abc').where(Field("foo").bitwiseand(1) == 1) + + self.assertEqual('SELECT "abc" FROM "items" WHERE ("foo" & 1)=1', str(q)) + + +class NotTests(unittest.TestCase): + table_abc, table_efg = Table("abc", alias="cx0"), Table("efg", alias="cx1") + + def test_negate(self): + c1 = Field("foo") >= 1 + c2 = c1.negate() + + self.assertEqual('"foo">=1', str(c1)) + self.assertEqual('NOT "foo">=1', str(c2)) + + def test_variable_access(self): + c1 = Field("foo").negate() + + self.assertEqual(c1.is_aggregate, False) + + def test_chained_function(self): + field1 = Field("foo").negate() + field2 = field1.eq("bar") + + self.assertEqual('NOT "foo"', str(field1)) + self.assertEqual("NOT \"foo\"='bar'", str(field2)) + self.assertIsNot(field1, field2) + + def test_not_null(self): + c1 = Field("foo").notnull() + c2 = Field("foo", table=self.table_abc).notnull() + + self.assertEqual('NOT "foo" IS NULL', str(c1)) + self.assertEqual('NOT "cx0"."foo" IS NULL', str(c2)) + + def test_is_not_null(self): + c1 = Field("foo").isnotnull() + c2 = Field("foo", table=self.table_abc).isnotnull() + + self.assertEqual('"foo" IS NOT NULL', str(c1)) + self.assertEqual('"cx0"."foo" IS NOT NULL', str(c2)) + + def test_not_null_with_alias(self): + c1 = Field("foo").notnull().as_("something") + c2 = Field("foo", table=self.table_abc).notnull().as_("something") + + self.assertEqual('NOT "foo" IS NULL "something"', str(c1)) + self.assertEqual('NOT "cx0"."foo" IS NULL "something"', str(c2)) + + def test_notnullcriterion_replace_table(self): + f = self.table_abc.foo.notnull().replace_table(self.table_abc, self.table_efg) + + self.assertEqual('NOT "cx1"."foo" IS NULL', str(f)) + + def test_not_with_or_criterion(self): + self.assertEqual('NOT ("foo" OR "bar")', str(~(Field("foo") | Field("bar")))) + + def test_not_with_and_criterion(self): + self.assertEqual('NOT ("foo" AND "bar")', str(~(Field("foo") & Field("bar")))) + + def test_not_with_complex_criterion(self): + self.assertEqual( + 'NOT ("foo" AND "bar" AND "fizz" AND "buzz")', + str(~(Field("foo") & Field("bar") & Field("fizz") & Field("buzz"))), + ) + + +class BetweenTests(unittest.TestCase): + t = Table("abc", alias="btw") + + def test__between_number(self): + c1 = Field("foo").between(0, 1) + c2 = Field("foo", table=self.t).between(0, 1) + c3 = Field("foo")[0:1] + + self.assertEqual('"foo" BETWEEN 0 AND 1', str(c1)) + self.assertEqual('"btw"."foo" BETWEEN 0 AND 1', str(c2)) + self.assertEqual('"foo" BETWEEN 0 AND 1', str(c3)) + + def test__between_with_alias(self): + c1 = Field("foo").between(0, 1).as_('alias') + c2 = Field("foo", table=self.t).between(0, 1).as_('alias') + c3 = Field("foo")[0:1].as_('alias') + + self.assertEqual('"foo" BETWEEN 0 AND 1 "alias"', str(c1)) + self.assertEqual('"btw"."foo" BETWEEN 0 AND 1 "alias"', str(c2)) + self.assertEqual('"foo" BETWEEN 0 AND 1 "alias"', str(c3)) + + def test__between_date(self): + c1 = Field("foo").between(date(2000, 1, 1), date(2000, 12, 31)) + c2 = Field("foo", table=self.t).between(date(2000, 1, 1), date(2000, 12, 31)) + c3 = Field("foo")[date(2000, 1, 1) : date(2000, 12, 31)] + + self.assertEqual("\"foo\" BETWEEN '2000-01-01' AND '2000-12-31'", str(c1)) + self.assertEqual("\"btw\".\"foo\" BETWEEN '2000-01-01' AND '2000-12-31'", str(c2)) + self.assertEqual("\"foo\" BETWEEN '2000-01-01' AND '2000-12-31'", str(c3)) + + def test__between_datetime(self): + c1 = Field("foo").between(datetime(2000, 1, 1, 0, 0, 0), datetime(2000, 12, 31, 23, 59, 59)) + c2 = Field("foo", table=self.t).between(datetime(2000, 1, 1, 0, 0, 0), datetime(2000, 12, 31, 23, 59, 59)) + c3 = Field("foo")[datetime(2000, 1, 1, 0, 0, 0) : datetime(2000, 12, 31, 23, 59, 59)] + + self.assertEqual("\"foo\" BETWEEN '2000-01-01T00:00:00' AND '2000-12-31T23:59:59'", str(c1)) + self.assertEqual( + "\"btw\".\"foo\" BETWEEN '2000-01-01T00:00:00' AND '2000-12-31T23:59:59'", + str(c2), + ) + self.assertEqual("\"foo\" BETWEEN '2000-01-01T00:00:00' AND '2000-12-31T23:59:59'", str(c3)) + + def test__function_between(self): + c1 = fn.Coalesce(Field("foo"), 0)[0:1] + c2 = fn.Coalesce(Field("foo", table=self.t), 0)[0:1] + + self.assertEqual('COALESCE("foo",0) BETWEEN 0 AND 1', str(c1)) + self.assertEqual('COALESCE("btw"."foo",0) BETWEEN 0 AND 1', str(c2)) + + def test_get_item_only_works_with_slice(self): + with self.assertRaises(TypeError): + Field("foo")[0] + + with self.assertRaises(TypeError): + Field("foo")[date(2000, 1, 1)] + + with self.assertRaises(TypeError): + Field("foo")[datetime(2000, 1, 1, 0, 0, 0)] + + +class IsInTests(unittest.TestCase): + t = Table("abc", alias="isin") + + def test__in_number(self): + c1 = Field("foo").isin([0, 1]) + c2 = Field("foo", table=self.t).isin([0, 1]) + + self.assertEqual('"foo" IN (0,1)', str(c1)) + self.assertEqual('"isin"."foo" IN (0,1)', str(c2)) + + def test__in_number_with_alias(self): + c1 = Field("foo").isin([0, 1]).as_('alias') + c2 = Field("foo", table=self.t).isin([0, 1]).as_('alias') + + self.assertEqual('"foo" IN (0,1) "alias"', str(c1)) + self.assertEqual('"isin"."foo" IN (0,1) "alias"', str(c2)) + + def test__in_character(self): + c1 = Field("foo").isin(["a", "b"]) + c2 = Field("foo", table=self.t).isin(["a", "b"]) + + self.assertEqual("\"foo\" IN ('a','b')", str(c1)) + self.assertEqual("\"isin\".\"foo\" IN ('a','b')", str(c2)) + + def test__in_date(self): + c1 = Field("foo").isin([date(2000, 1, 1), date(2000, 12, 31)]) + c2 = Field("foo", table=self.t).isin([date(2000, 1, 1), date(2000, 12, 31)]) + + self.assertEqual("\"foo\" IN ('2000-01-01','2000-12-31')", str(c1)) + self.assertEqual("\"isin\".\"foo\" IN ('2000-01-01','2000-12-31')", str(c2)) + + def test__in_datetime(self): + c1 = Field("foo").isin([datetime(2000, 1, 1, 0, 0, 0), datetime(2000, 12, 31, 23, 59, 59)]) + c2 = Field("foo", table=self.t).isin([datetime(2000, 1, 1, 0, 0, 0), datetime(2000, 12, 31, 23, 59, 59)]) + + self.assertEqual("\"foo\" IN ('2000-01-01T00:00:00','2000-12-31T23:59:59')", str(c1)) + self.assertEqual("\"isin\".\"foo\" IN ('2000-01-01T00:00:00','2000-12-31T23:59:59')", str(c2)) + + def test__function_isin(self): + c1 = fn.Coalesce(Field("foo"), 0).isin([0, 1]) + c2 = fn.Coalesce(Field("foo", table=self.t), 0).isin([0, 1]) + + self.assertEqual('COALESCE("foo",0) IN (0,1)', str(c1)) + self.assertEqual('COALESCE("isin"."foo",0) IN (0,1)', str(c2)) + + for t in (list, tuple, set, frozenset): + c_type = fn.Coalesce(Field("foo"), 0).isin(t([0, 1])) + self.assertEqual('COALESCE("foo",0) IN (0,1)', str(c_type)) + + self.assertRaises(AttributeError, lambda: str(fn.Coalesce(Field("foo"), 0).isin('SHOULD_FAIL'))) + + def test__in_unicode(self): + c1 = Field("foo").isin([u"a", u"b"]) + c2 = Field("foo", table=self.t).isin([u"a", u"b"]) + + self.assertEqual("\"foo\" IN ('a','b')", str(c1)) + self.assertEqual("\"isin\".\"foo\" IN ('a','b')", str(c2)) + + +class ArithmeticExpressionTests(unittest.TestCase): + def test__lshift(self): + c1 = Field("foo").lshift("1") + c2 = Field("foo").lshift("2") + + self.assertEqual("\"foo\"<<'1'", str(c1)) + self.assertEqual("\"foo\"<<'2'", str(c2)) + + def test__rshift(self): + c1 = Field("foo").rshift("1") + c2 = Field("foo").rshift("2") + + self.assertEqual("\"foo\">>'1'", str(c1)) + self.assertEqual("\"foo\">>'2'", str(c2)) + + +class NotInTests(unittest.TestCase): + t = Table("abc", alias="notin") + + def test__notin_number(self): + c1 = Field("foo").notin([0, 1]) + c2 = Field("foo", table=self.t).notin([0, 1]) + + self.assertEqual('"foo" NOT IN (0,1)', str(c1)) + self.assertEqual('"notin"."foo" NOT IN (0,1)', str(c2)) + + def test__notin_number_with_alias(self): + c1 = Field("foo").notin([0, 1]).as_('alias') + c2 = Field("foo", table=self.t).notin([0, 1]).as_('alias') + + self.assertEqual('"foo" NOT IN (0,1) "alias"', str(c1)) + self.assertEqual('"notin"."foo" NOT IN (0,1) "alias"', str(c2)) + + def test__notin_character(self): + c1 = Field("foo").notin(["a", "b"]) + c2 = Field("foo", table=self.t).notin(["a", "b"]) + + self.assertEqual("\"foo\" NOT IN ('a','b')", str(c1)) + self.assertEqual("\"notin\".\"foo\" NOT IN ('a','b')", str(c2)) + + def test__notin_date(self): + c1 = Field("foo").notin([date(2000, 1, 1), date(2000, 12, 31)]) + c2 = Field("foo", table=self.t).notin([date(2000, 1, 1), date(2000, 12, 31)]) + + self.assertEqual("\"foo\" NOT IN ('2000-01-01','2000-12-31')", str(c1)) + self.assertEqual("\"notin\".\"foo\" NOT IN ('2000-01-01','2000-12-31')", str(c2)) + + def test__notin_datetime(self): + c1 = Field("foo").notin([datetime(2000, 1, 1, 0, 0, 0), datetime(2000, 12, 31, 23, 59, 59)]) + c2 = Field("foo", table=self.t).notin([datetime(2000, 1, 1, 0, 0, 0), datetime(2000, 12, 31, 23, 59, 59)]) + + self.assertEqual("\"foo\" NOT IN ('2000-01-01T00:00:00','2000-12-31T23:59:59')", str(c1)) + self.assertEqual( + "\"notin\".\"foo\" NOT IN ('2000-01-01T00:00:00','2000-12-31T23:59:59')", + str(c2), + ) + + def test__function_notin(self): + c1 = fn.Coalesce(Field("foo"), 0).notin([0, 1]) + c2 = fn.Coalesce(Field("foo", table=self.t), 0).notin([0, 1]) + + self.assertEqual('COALESCE("foo",0) NOT IN (0,1)', str(c1)) + self.assertEqual('COALESCE("notin"."foo",0) NOT IN (0,1)', str(c2)) + + +class LikeTests(unittest.TestCase): + t = Table("abc", alias="like") + + def test_like_starts_with(self): + c1 = Field("foo").like("ab%") + c2 = Field("foo", table=self.t).like("ab%") + + self.assertEqual("\"foo\" LIKE 'ab%'", str(c1)) + self.assertEqual('"like"."foo" LIKE \'ab%\'', str(c2)) + + def test_like_contains(self): + c1 = Field("foo").like("%ab%") + c2 = Field("foo", table=self.t).like("%ab%") + + self.assertEqual("\"foo\" LIKE '%ab%'", str(c1)) + self.assertEqual('"like"."foo" LIKE \'%ab%\'', str(c2)) + + def test_like_ends_with(self): + c1 = Field("foo").like("%ab") + c2 = Field("foo", table=self.t).like("%ab") + + self.assertEqual("\"foo\" LIKE '%ab'", str(c1)) + self.assertEqual('"like"."foo" LIKE \'%ab\'', str(c2)) + + def test_like_n_chars_long(self): + c1 = Field("foo").like("___") + c2 = Field("foo", table=self.t).like("___") + + self.assertEqual("\"foo\" LIKE '___'", str(c1)) + self.assertEqual('"like"."foo" LIKE \'___\'', str(c2)) + + def test_like_single_chars_and_various_chars(self): + c1 = Field("foo").like("a_b%c") + c2 = Field("foo", table=self.t).like("a_b%c") + + self.assertEqual("\"foo\" LIKE 'a_b%c'", str(c1)) + self.assertEqual('"like"."foo" LIKE \'a_b%c\'', str(c2)) + + def test_not_like_single_chars_and_various_chars(self): + c1 = Field("foo").not_like("a_b%c") + c2 = Field("foo", table=self.t).not_like("a_b%c") + + self.assertEqual("\"foo\" NOT LIKE 'a_b%c'", str(c1)) + self.assertEqual('"like"."foo" NOT LIKE \'a_b%c\'', str(c2)) + + def test_ilike_starts_with(self): + c1 = Field("foo").ilike("ab%") + c2 = Field("foo", table=self.t).ilike("ab%") + + self.assertEqual("\"foo\" ILIKE 'ab%'", str(c1)) + self.assertEqual('"like"."foo" ILIKE \'ab%\'', str(c2)) + + def test_ilike_contains(self): + c1 = Field("foo").ilike("%ab%") + c2 = Field("foo", table=self.t).ilike("%ab%") + + self.assertEqual("\"foo\" ILIKE '%ab%'", str(c1)) + self.assertEqual('"like"."foo" ILIKE \'%ab%\'', str(c2)) + + def test_ilike_ends_with(self): + c1 = Field("foo").ilike("%ab") + c2 = Field("foo", table=self.t).ilike("%ab") + + self.assertEqual("\"foo\" ILIKE '%ab'", str(c1)) + self.assertEqual('"like"."foo" ILIKE \'%ab\'', str(c2)) + + def test_ilike_n_chars_long(self): + c1 = Field("foo").ilike("___") + c2 = Field("foo", table=self.t).ilike("___") + + self.assertEqual("\"foo\" ILIKE '___'", str(c1)) + self.assertEqual('"like"."foo" ILIKE \'___\'', str(c2)) + + def test_ilike_single_chars_and_various_chars(self): + c1 = Field("foo").ilike("a_b%c") + c2 = Field("foo", table=self.t).ilike("a_b%c") + + self.assertEqual("\"foo\" ILIKE 'a_b%c'", str(c1)) + self.assertEqual('"like"."foo" ILIKE \'a_b%c\'', str(c2)) + + def test_not_ilike_single_chars_and_various_chars(self): + c1 = Field("foo").not_ilike("a_b%c") + c2 = Field("foo", table=self.t).not_ilike("a_b%c") + + self.assertEqual("\"foo\" NOT ILIKE 'a_b%c'", str(c1)) + self.assertEqual('"like"."foo" NOT ILIKE \'a_b%c\'', str(c2)) + + def test_rlike_escape_chars(self): + c1 = Field("foo").rlike("\\\\d+$") + c2 = Field("foo", table=self.t).rlike("\\\\d+$") + + self.assertEqual("\"foo\" RLIKE '\\\\d+$'", str(c1)) + self.assertEqual('"like"."foo" RLIKE \'\\\\d+$\'', str(c2)) + + def test_glob_single_chars_and_various_chars(self): + c1 = Field("foo").glob("a_b*") + c2 = Field("foo", table=self.t).glob("a_b*") + + self.assertEqual("\"foo\" GLOB 'a_b*'", str(c1)) + self.assertEqual('"like"."foo" GLOB \'a_b*\'', str(c2)) + + +class ExistsCriterionTests(unittest.TestCase): + t2 = Table("abc", alias="t2") + q2 = QueryBuilder().from_(t2).select(t2.field2) + + def test_exists(self): + t1 = Table("def", alias="t1") + q1 = QueryBuilder().from_(t1).where(ExistsCriterion(self.q2)).select(t1.field1) + + self.assertEqual( + 'SELECT "t1"."field1" FROM "def" "t1" WHERE EXISTS (SELECT "t2"."field2" FROM "abc" "t2")', str(q1) + ) + + def test_not_exists(self): + t1 = Table("def", alias="t1") + q1 = QueryBuilder().from_(t1).where(ExistsCriterion(self.q2).negate()).select(t1.field1) + + self.assertEqual( + 'SELECT "t1"."field1" FROM "def" "t1" WHERE NOT EXISTS (SELECT "t2"."field2" FROM "abc" "t2")', str(q1) + ) + + +class ComplexCriterionTests(unittest.TestCase): + table_abc, table_efg = Table("abc", alias="cx0"), Table("efg", alias="cx1") + + def test_and(self): + c1 = (Field("foo") == 1) & (Field("bar") == 2) + c2 = (Field("foo", table=self.table_abc) == 1) & (Field("bar", table=self.table_efg) == 2) + + self.assertEqual('"foo"=1 AND "bar"=2', str(c1)) + self.assertEqual('"cx0"."foo"=1 AND "cx1"."bar"=2', str(c2)) + + def test_or(self): + c1 = (Field("foo") == 1) | (Field("bar") == 2) + c2 = (Field("foo", table=self.table_abc) == 1) | (Field("bar", table=self.table_efg) == 2) + + self.assertEqual('"foo"=1 OR "bar"=2', str(c1)) + self.assertEqual('"cx0"."foo"=1 OR "cx1"."bar"=2', str(c2)) + + def test_xor(self): + c1 = (Field("foo") == 1) ^ (Field("bar") == 2) + c2 = (Field("foo", table=self.table_abc) == 1) ^ (Field("bar", table=self.table_efg) == 2) + + self.assertEqual('"foo"=1 XOR "bar"=2', str(c1)) + self.assertEqual('"cx0"."foo"=1 XOR "cx1"."bar"=2', str(c2)) + + def test_function_and(self): + c1 = fn.IsNull(Field("foo")) & (Field("bar") == 2) + + self.assertEqual('ISNULL("foo") AND "bar"=2', str(c1)) + + def test_function_or(self): + c1 = fn.IsNull(Field("foo")) | (Field("bar") == 2) + + self.assertEqual('ISNULL("foo") OR "bar"=2', str(c1)) + + def test_function_xor(self): + c1 = fn.IsNull(Field("foo")) ^ (Field("bar") == 2) + + self.assertEqual('ISNULL("foo") XOR "bar"=2', str(c1)) + + def test__nested__and(self): + c = (Field("foo") == 1) & (Field("bar") == 2) & (Field("buz") == 3) + + self.assertEqual('"foo"=1 AND "bar"=2 AND "buz"=3', str(c)) + + def test__nested__or(self): + c = (Field("foo") == 1) | (Field("bar") == 2) | (Field("buz") == 3) + + self.assertEqual('"foo"=1 OR "bar"=2 OR "buz"=3', str(c)) + + def test__nested__mixed(self): + c = ((Field("foo") == 1) & (Field("bar") == 2)) | (Field("buz") == 3) + + self.assertEqual('("foo"=1 AND "bar"=2) OR "buz"=3', str(c)) + + def test__between_and_isin(self): + c = Field("foo").isin([1, 2, 3]) & Field("bar").between(0, 1) + + self.assertEqual('"foo" IN (1,2,3) AND "bar" BETWEEN 0 AND 1', str(c)) + + def test__between_and_field(self): + c1 = Field("foo").between(0, 1) + c2 = Field("bool_field") + + self.assertEqual('"foo" BETWEEN 0 AND 1 AND "bool_field"', str(c1 & c2)) + self.assertEqual('"bool_field" AND "foo" BETWEEN 0 AND 1', str(c2 & c1)) + + +class FieldsAsCriterionTests(unittest.TestCase): + def test__field_and_field(self): + c1 = Field("a") + c2 = Field("b") + + self.assertEqual('"a" AND "b"', str(c1 & c2)) + + def test__field_or_field(self): + c1 = Field("a") + c2 = Field("b") + + self.assertEqual('"a" OR "b"', str(c1 | c2)) + + def test__field_xor_field(self): + c1 = Field("a") + c2 = Field("b") + + self.assertEqual('"a" XOR "b"', str(c1 ^ c2)) + + +class CriterionOperationsTests(unittest.TestCase): + table_abc, table_efg = Table("abc", alias="cx0"), Table("efg", alias="cx1") + + def test_field_replace_table(self): + f = self.table_abc.foo.replace_table(self.table_abc, self.table_efg) + + self.assertEqual('"cx1"."foo"', str(f)) + + def test_arithmeticfunction_replace_table(self): + f = (self.table_abc.foo + self.table_abc.bar).replace_table(self.table_abc, self.table_efg) + + self.assertEqual('"cx1"."foo"+"cx1"."bar"', str(f)) + + def test_criterion_replace_table(self): + f = (self.table_abc.foo < self.table_abc.bar).replace_table(self.table_abc, self.table_efg) + + self.assertEqual('"cx1"."foo"<"cx1"."bar"', str(f)) + + def test_complexcriterion_replace_table(self): + f = (self.table_abc.foo < self.table_abc.bar) & (self.table_abc.fiz > self.table_abc.buz) + f = f.replace_table(self.table_abc, self.table_efg) + + self.assertEqual('"cx1"."foo"<"cx1"."bar" AND "cx1"."fiz">"cx1"."buz"', str(f)) + + def test_function_with_only_fields_replace_table(self): + f = fn.Sum(self.table_abc.foo).replace_table(self.table_abc, self.table_efg) + + self.assertEqual('SUM("cx1"."foo")', str(f)) + + def test_function_with_values_and_fields_replace_table(self): + f = Mod(self.table_abc.foo, 2).replace_table(self.table_abc, self.table_efg) + + self.assertEqual('MOD("cx1"."foo",2)', str(f)) + + def test_betweencriterion_replace_table(self): + f = self.table_abc.foo[0:1].replace_table(self.table_abc, self.table_efg) + + self.assertEqual('"cx1"."foo" BETWEEN 0 AND 1', str(f)) + + def test_nullcriterion_replace_table(self): + f = self.table_abc.foo.isnull().replace_table(self.table_abc, self.table_efg) + + self.assertEqual('"cx1"."foo" IS NULL', str(f)) + + +class AnyTests(unittest.TestCase): + def test_zero_args_returns_empty_criterion(self): + crit = Criterion.any() + self.assertIsInstance(crit, EmptyCriterion) + + def test_single_arg_returns_self(self): + f = Field("a") + crit = Criterion.any([f]) + self.assertEqual(str(f), str(crit)) + + def test_multiple_args_returned_in_chain_of_ors(self): + crit = Criterion.any([Field("a"), Field("b"), Field("c"), Field("d")]) + self.assertEqual(str(crit), '"a" OR "b" OR "c" OR "d"') + + def test_with_generator(self): + crit = Criterion.any(Field(letter) for letter in "abcd") + self.assertEqual(str(crit), '"a" OR "b" OR "c" OR "d"') + + +class EmptyCriterionTests(unittest.TestCase): + def test_fields_(self): + empty_criterion = EmptyCriterion() + + self.assertEqual(len(empty_criterion.fields_()), 0) + + def test_empty_criterion_on_the_left(self): + t = Table("test1") + q = EmptyCriterion() & t.f1 == "v1" + + self.assertEqual( + '"test1"."f1"=\'v1\'', + q.get_sql(with_namespace=True), + ) + + def test_empty_criterion_on_the_right(self): + t = Table("test1") + q = (t.f1 == "v1") & EmptyCriterion() + + self.assertEqual( + '"test1"."f1"=\'v1\'', + q.get_sql(with_namespace=True), + ) + + def test_invertion_of_the_empty_criterion(self): + t = Table("test1") + q = (t.f1 == "v1") & ~EmptyCriterion() + + self.assertEqual( + '"test1"."f1"=\'v1\'', + q.get_sql(with_namespace=True), + ) + + def test_different_operations_with_empty_criterion(self): + t = Table("test1") + q1 = (t.f1 == "v1") & EmptyCriterion() + q2 = (t.f1 == "v1") | EmptyCriterion() + q3 = (t.f1 == "v1") ^ EmptyCriterion() + + expected_sql = '"test1"."f1"=\'v1\'' + self.assertEqual( + expected_sql, + q1.get_sql(with_namespace=True), + ) + self.assertEqual( + expected_sql, + q2.get_sql(with_namespace=True), + ) + self.assertEqual( + expected_sql, + q3.get_sql(with_namespace=True), + ) + + def test_more_than_one_empty_criterions(self): + t = Table("test1") + q = EmptyCriterion() & ~(EmptyCriterion() | EmptyCriterion()) & (t.f1 == "v1") & ~EmptyCriterion() + + self.assertEqual( + '"test1"."f1"=\'v1\'', + q.get_sql(with_namespace=True), + ) + + +class AllTests(unittest.TestCase): + def test_zero_args_returns_empty_criterion(self): + crit = Criterion.all() + self.assertIsInstance(crit, EmptyCriterion) + + def test_single_arg_returns_self(self): + f = Field("a") + crit = Criterion.all([f]) + self.assertEqual(str(f), str(crit)) + + def test_multiple_args_returned_in_chain_of_ors(self): + crit = Criterion.all([Field("a"), Field("b"), Field("c"), Field("d")]) + self.assertEqual(str(crit), '"a" AND "b" AND "c" AND "d"') + + def test_with_generator(self): + crit = Criterion.all(Field(letter) for letter in "abcd") + self.assertEqual(str(crit), '"a" AND "b" AND "c" AND "d"') diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/test_custom_functions.py b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/test_custom_functions.py new file mode 100644 index 0000000000000000000000000000000000000000..60ffd3cd8e6191e3fc782dac003c41bfb7a78528 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/test_custom_functions.py @@ -0,0 +1,49 @@ +import unittest + +from pypika import CustomFunction, FunctionException, Query, Table + +__author__ = "Airton Zanon" +__email__ = "me@airton.dev" + + +class TestUnitCustomFunction(unittest.TestCase): + def test_should_fail_with_wrong_arguments(self): + DateDiff = CustomFunction("DATE_DIFF", ["interval", "start_date", "end_date"]) + + with self.assertRaises(FunctionException): + DateDiff("foo") + + def test_should_return_function_with_arguments(self): + DateDiff = CustomFunction("DATE_DIFF", ["interval", "start_date", "end_date"]) + + self.assertEqual( + "DATE_DIFF('day','start_date','end_date')", + str(DateDiff("day", "start_date", "end_date")), + ) + + def test_should_return_function_with_no_arguments(self): + CurrentDate = CustomFunction("CURRENT_DATE") + + self.assertEqual("CURRENT_DATE()", str(CurrentDate())) + + +class TestFunctionalCustomFunction(unittest.TestCase): + def test_should_use_custom_function_on_select(self): + service = Table("service") + + DateDiff = CustomFunction("DATE_DIFF", ["interval", "start_date", "end_date"]) + + q = Query.from_(service).select(DateDiff("day", service.created_date, service.updated_date)) + + self.assertEqual( + 'SELECT DATE_DIFF(\'day\',"created_date","updated_date") FROM "service"', + str(q), + ) + + def test_should_fail_use_custom_function_on_select_with_wrong_arguments(self): + service = Table("service") + + DateDiff = CustomFunction("DATE_DIFF", ["interval", "start_date", "end_date"]) + + with self.assertRaises(FunctionException): + Query.from_(service).select(DateDiff("day", service.created_date)) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/test_data_types.py b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/test_data_types.py new file mode 100644 index 0000000000000000000000000000000000000000..52fb4487fe7be3ae28a4e9eb08628fba89dc0f79 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/test_data_types.py @@ -0,0 +1,15 @@ +import unittest +import uuid + +from pypika.terms import ValueWrapper + + +class StringTests(unittest.TestCase): + def test_inline_string_concatentation(self): + self.assertEqual("'it''s'", ValueWrapper("it's").get_sql()) + + +class UuidTests(unittest.TestCase): + def test_uuid_string_generation(self): + id = uuid.uuid4() + self.assertEqual("'{}'".format(id), ValueWrapper(id).get_sql()) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/test_date_math.py b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/test_date_math.py new file mode 100644 index 0000000000000000000000000000000000000000..38db8ef2f8e812a97c6980a7ec6b9a3909d804fb --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/test_date_math.py @@ -0,0 +1,179 @@ +import unittest + +from pypika import ( + Field as F, + Interval, +) +from pypika.enums import Dialects + +dt = F("dt") + + +class AddIntervalTests(unittest.TestCase): + def test_add_microsecond(self): + c = dt + Interval(microseconds=1) + + self.assertEqual("\"dt\"+INTERVAL '1 MICROSECOND'", str(c)) + + def test_add_second(self): + c = dt + Interval(seconds=1) + + self.assertEqual("\"dt\"+INTERVAL '1 SECOND'", str(c)) + + def test_add_minute(self): + c = dt + Interval(minutes=1) + + self.assertEqual("\"dt\"+INTERVAL '1 MINUTE'", str(c)) + + def test_add_day(self): + c = dt + Interval(days=1) + + self.assertEqual("\"dt\"+INTERVAL '1 DAY'", str(c)) + + def test_add_week(self): + c = dt + Interval(weeks=1) + + self.assertEqual("\"dt\"+INTERVAL '1 WEEK'", str(c)) + + def test_add_month(self): + c = dt + Interval(months=1) + + self.assertEqual("\"dt\"+INTERVAL '1 MONTH'", str(c)) + + def test_add_quarter(self): + c = dt + Interval(quarters=1) + + self.assertEqual("\"dt\"+INTERVAL '1 QUARTER'", str(c)) + + def test_add_year(self): + c = dt + Interval(years=1) + + self.assertEqual("\"dt\"+INTERVAL '1 YEAR'", str(c)) + + def test_add_default(self): + c = dt + Interval(days=0) + + self.assertEqual("\"dt\"+INTERVAL '0 DAY'", str(c)) + + +class AddIntervalMultipleUnitsTests(unittest.TestCase): + def test_add_second_microsecond(self): + c = dt + Interval(seconds=1, microseconds=1) + + self.assertEqual("\"dt\"+INTERVAL '1.1 SECOND_MICROSECOND'", str(c)) + + def test_add_minute_microsecond(self): + c = dt + Interval(minutes=1, microseconds=1) + + self.assertEqual("\"dt\"+INTERVAL '1:0.1 MINUTE_MICROSECOND'", str(c)) + + def test_add_minute_second(self): + c = dt + Interval(minutes=1, seconds=1) + + self.assertEqual("\"dt\"+INTERVAL '1:1 MINUTE_SECOND'", str(c)) + + def test_add_hour_microsecond(self): + c = dt + Interval(hours=1, microseconds=1) + + self.assertEqual("\"dt\"+INTERVAL '1:0:0.1 HOUR_MICROSECOND'", str(c)) + + def test_add_hour_second(self): + c = dt + Interval(hours=1, seconds=1) + + self.assertEqual("\"dt\"+INTERVAL '1:0:1 HOUR_SECOND'", str(c)) + + def test_add_hour_minute(self): + c = dt + Interval(hours=1, minutes=1) + + self.assertEqual("\"dt\"+INTERVAL '1:1 HOUR_MINUTE'", str(c)) + + def test_add_day_microsecond(self): + c = dt + Interval(days=1, microseconds=1) + + self.assertEqual("\"dt\"+INTERVAL '1 0:0:0.1 DAY_MICROSECOND'", str(c)) + + def test_add_day_second(self): + c = dt + Interval(days=1, seconds=1) + + self.assertEqual("\"dt\"+INTERVAL '1 0:0:1 DAY_SECOND'", str(c)) + + def test_add_day_minute(self): + c = dt + Interval(days=1, minutes=1) + + self.assertEqual("\"dt\"+INTERVAL '1 0:1 DAY_MINUTE'", str(c)) + + def test_add_day_hour(self): + c = dt + Interval(days=1, hours=1) + + self.assertEqual("\"dt\"+INTERVAL '1 1 DAY_HOUR'", str(c)) + + def test_add_year_month(self): + c = dt + Interval(years=1, months=1) + + self.assertEqual("\"dt\"+INTERVAL '1-1 YEAR_MONTH'", str(c)) + + def test_add_value_right(self): + c = Interval(microseconds=1) - dt + + self.assertEqual("INTERVAL '1 MICROSECOND'-\"dt\"", str(c)) + + def test_add_value_complex_expressions(self): + c = dt + Interval(quarters=1) + Interval(weeks=1) + + self.assertEqual("\"dt\"+INTERVAL '1 QUARTER'+INTERVAL '1 WEEK'", str(c)) + + +class DialectIntervalTests(unittest.TestCase): + def test_mysql_dialect_uses_single_quotes_around_expression_in_an_interval(self): + c = Interval(days=1).get_sql(dialect=Dialects.MYSQL) + self.assertEqual("INTERVAL '1' DAY", c) + + def test_oracle_dialect_uses_single_quotes_around_expression_in_an_interval(self): + c = Interval(days=1).get_sql(dialect=Dialects.ORACLE) + self.assertEqual("INTERVAL '1' DAY", c) + + def test_vertica_dialect_uses_single_quotes_around_interval(self): + c = Interval(days=1).get_sql(dialect=Dialects.VERTICA) + self.assertEqual("INTERVAL '1 DAY'", c) + + def test_redshift_dialect_uses_single_quotes_around_interval(self): + c = Interval(days=1).get_sql(dialect=Dialects.REDSHIFT) + self.assertEqual("INTERVAL '1 DAY'", c) + + def test_postgresql_dialect_uses_single_quotes_around_interval(self): + c = Interval(days=1).get_sql(dialect=Dialects.POSTGRESQL) + self.assertEqual("INTERVAL '1 DAY'", c) + + +class TestNegativeIntervals(unittest.TestCase): + def test_day(self): + c = Interval(days=-1).get_sql() + self.assertEqual("INTERVAL '-1 DAY'", c) + + def test_week(self): + c = Interval(weeks=-1).get_sql() + self.assertEqual("INTERVAL '-1 WEEK'", c) + + def test_month(self): + c = Interval(months=-1).get_sql() + self.assertEqual("INTERVAL '-1 MONTH'", c) + + def test_year(self): + c = Interval(years=-1).get_sql() + self.assertEqual("INTERVAL '-1 YEAR'", c) + + def test_year_month(self): + c = Interval(years=-1, months=-4).get_sql() + self.assertEqual("INTERVAL '-1-4 YEAR_MONTH'", c) + + +class TruncateTrailingZerosTests(unittest.TestCase): + def test_do_not_truncate_integer_values(self): + i = Interval(seconds=10) + + self.assertEqual("INTERVAL '10 SECOND'", str(i)) + + def test_do_not_truncate_months_between_years_and_datys(self): + i = Interval(years=10, days=10) + + self.assertEqual("INTERVAL '10-0-10 YEAR_DAY'", str(i)) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/test_deletes.py b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/test_deletes.py new file mode 100644 index 0000000000000000000000000000000000000000..09df93f5331b845b0c3aed628bf1c4a3ec6b0f02 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/test_deletes.py @@ -0,0 +1,97 @@ +import unittest + +from pypika import PostgreSQLQuery, Query, SYSTEM_TIME, Table + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + +from pypika.terms import Star + + +class DeleteTests(unittest.TestCase): + @classmethod + def setUpClass(cls) -> None: + super().setUpClass() + cls.table_abc = Table("abc") + + def test_omit_where(self): + q = Query.from_("abc").delete() + + self.assertEqual('DELETE FROM "abc"', str(q)) + + def test_omit_where__table_schema(self): + q = Query.from_(Table("abc", "schema1")).delete() + + self.assertEqual('DELETE FROM "schema1"."abc"', str(q)) + + def test_where_field_equals(self): + q1 = Query.from_(self.table_abc).where(self.table_abc.foo == self.table_abc.bar).delete() + q2 = Query.from_(self.table_abc).where(self.table_abc.foo.eq(self.table_abc.bar)).delete() + + self.assertEqual('DELETE FROM "abc" WHERE "foo"="bar"', str(q1)) + self.assertEqual('DELETE FROM "abc" WHERE "foo"="bar"', str(q2)) + + def test_for_portion(self): + with self.subTest("with system time"): + q = Query.from_(self.table_abc.for_portion(SYSTEM_TIME.from_to('2020-01-01', '2020-02-01'))).delete() + + self.assertEqual( + 'DELETE FROM "abc" FOR PORTION OF SYSTEM_TIME FROM \'2020-01-01\' TO \'2020-02-01\'', str(q) + ) + + with self.subTest("with column"): + q = Query.from_( + self.table_abc.for_portion(self.table_abc.valid_period.from_to('2020-01-01', '2020-02-01')) + ).delete() + + self.assertEqual( + 'DELETE FROM "abc" FOR PORTION OF "valid_period" FROM \'2020-01-01\' TO \'2020-02-01\'', str(q) + ) + + +class PostgresDeleteTests(unittest.TestCase): + @classmethod + def setUpClass(cls) -> None: + super().setUpClass() + cls.table_abc = Table("abc") + + def test_delete_returning(self): + q1 = ( + PostgreSQLQuery.from_(self.table_abc) + .where(self.table_abc.foo == self.table_abc.bar) + .delete() + .returning(self.table_abc.id) + ) + + self.assertEqual('DELETE FROM "abc" WHERE "foo"="bar" RETURNING "id"', str(q1)) + + def test_delete_returning_str(self): + q1 = ( + PostgreSQLQuery.from_(self.table_abc) + .where(self.table_abc.foo == self.table_abc.bar) + .delete() + .returning("id") + ) + + self.assertEqual('DELETE FROM "abc" WHERE "foo"="bar" RETURNING "id"', str(q1)) + + def test_delete_returning_star(self): + q1 = ( + PostgreSQLQuery.from_(self.table_abc) + .where(self.table_abc.foo == self.table_abc.bar) + .delete() + .returning(Star()) + ) + + self.assertEqual('DELETE FROM "abc" WHERE "foo"="bar" RETURNING *', str(q1)) + + def test_delete_using(self): + table_trash = Table('trash') + q1 = ( + PostgreSQLQuery.from_(self.table_abc) + .using(table_trash) + .where(self.table_abc.id == table_trash.abc_id) + .delete() + ) + + self.assertEqual('DELETE FROM "abc" USING "trash" WHERE "abc"."id"="trash"."abc_id"', str(q1)) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/test_drop.py b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/test_drop.py new file mode 100644 index 0000000000000000000000000000000000000000..265ae7350d2054549731f9a8c4379fdac95dc580 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/test_drop.py @@ -0,0 +1,49 @@ +import unittest + +from pypika import ( + Columns, + Database, + Query, + Tables, +) + + +class DropTableTests(unittest.TestCase): + database_xyz = Database("mydb") + new_table, existing_table = Tables("abc", "efg") + foo, bar = Columns(("a", "INT"), ("b", "VARCHAR(100)")) + + def test_drop_database(self): + q1 = Query.drop_database(self.database_xyz) + q2 = Query.drop_database(self.database_xyz).if_exists() + + self.assertEqual('DROP DATABASE "mydb"', str(q1)) + self.assertEqual('DROP DATABASE IF EXISTS "mydb"', str(q2)) + + def test_drop_table(self): + q1 = Query.drop_table(self.new_table) + q2 = Query.drop_table(self.new_table).if_exists() + + self.assertEqual('DROP TABLE "abc"', str(q1)) + self.assertEqual('DROP TABLE IF EXISTS "abc"', str(q2)) + + def test_drop_user(self): + q1 = Query.drop_user("myuser") + q2 = Query.drop_user("myuser").if_exists() + + self.assertEqual('DROP USER "myuser"', str(q1)) + self.assertEqual('DROP USER IF EXISTS "myuser"', str(q2)) + + def test_drop_view(self): + q1 = Query.drop_view("myview") + q2 = Query.drop_view("myview").if_exists() + + self.assertEqual('DROP VIEW "myview"', str(q1)) + self.assertEqual('DROP VIEW IF EXISTS "myview"', str(q2)) + + def test_drop_index(self): + q1 = Query.drop_index("myindex") + q2 = Query.drop_index("myindex").if_exists() + + self.assertEqual('DROP INDEX "myindex"', str(q1)) + self.assertEqual('DROP INDEX IF EXISTS "myindex"', str(q2)) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/test_formats.py b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/test_formats.py new file mode 100644 index 0000000000000000000000000000000000000000..6a442757c6659a215661e03f1ca9c3771d394d96 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/test_formats.py @@ -0,0 +1,68 @@ +import unittest + +from pypika import Query, Tables, functions as fn + + +class QuoteTests(unittest.TestCase): + maxDiff = None + + table_abc, table_efg = Tables("abc", "efg") + + def setUp(self): + subquery1 = ( + Query.from_(self.table_abc) + .select( + self.table_abc.foo, + fn.Sum(self.table_abc.fizz + self.table_abc.buzz).as_("fizzbuzz"), + ) + .groupby(self.table_abc.foo) + ) + + subquery2 = Query.from_(self.table_efg).select( + self.table_efg.foo.as_("foo_two"), + self.table_efg.bar, + ) + + self.query = ( + Query.from_(subquery1) + .select(subquery1.foo, subquery1.fizzbuzz) + .join(subquery2) + .on(subquery1.foo == subquery2.foo_two) + .select(subquery2.foo_two, subquery2.bar) + ) + + def test_replace_quote_char_in_complex_query(self): + self.assertEqual( + "SELECT " + "`sq0`.`foo`,`sq0`.`fizzbuzz`," + "`sq1`.`foo_two`,`sq1`.`bar` " + "FROM (" + "SELECT " + "`foo`,SUM(`fizz`+`buzz`) `fizzbuzz` " + "FROM `abc` " + "GROUP BY `foo`" + ") `sq0` JOIN (" + "SELECT " + "`foo` `foo_two`,`bar` " + "FROM `efg`" + ") `sq1` ON `sq0`.`foo`=`sq1`.`foo_two`", + self.query.get_sql(quote_char="`"), + ) + + def test_no_quote_char_in_complex_query(self): + self.assertEqual( + "SELECT " + "sq0.foo,sq0.fizzbuzz," + "sq1.foo_two,sq1.bar " + "FROM (" + "SELECT " + "foo,SUM(fizz+buzz) fizzbuzz " + "FROM abc " + "GROUP BY foo" + ") sq0 JOIN (" + "SELECT " + "foo foo_two,bar " + "FROM efg" + ") sq1 ON sq0.foo=sq1.foo_two", + self.query.get_sql(quote_char=None), + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/test_functions.py b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/test_functions.py new file mode 100644 index 0000000000000000000000000000000000000000..f526966eefc554ec68d0e15fb69de7d69f1604c3 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/test_functions.py @@ -0,0 +1,847 @@ +import unittest + +from pypika import ( + Case, + CaseException, + DatePart, + Field as F, + Query, + Query as Q, + Schema, + Table as T, + VerticaQuery, + functions as fn, +) +from pypika.enums import Dialects, SqlTypes + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + + +class FunctionTests(unittest.TestCase): + def test_dialect_propagation(self): + func = fn.Function("func", ["a"], ["b"]) + self.assertEqual("func(ARRAY['a'],ARRAY['b'])", func.get_sql(dialect=Dialects.POSTGRESQL)) + + def test_is_aggregate_None_for_non_aggregate_function_or_function_with_no_aggregate_functions(self): + self.assertIsNone(fn.Coalesce('a', 0).is_aggregate) + self.assertIsNone(fn.Coalesce(fn.NullIf('a', 0), 0).is_aggregate) + + def test_is_aggregate_True_for_aggregate_function_or_function_with_aggregate_functions(self): + self.assertTrue(fn.Sum('a').is_aggregate) + self.assertTrue(fn.Coalesce(fn.Avg('a'), 0).is_aggregate) + self.assertTrue(fn.Coalesce(fn.NullIf(fn.Sum('a'), 0), 0).is_aggregate) + + +class SchemaTests(unittest.TestCase): + def test_schema_no_schema_in_sql_when_none_set(self): + func = fn.Function("my_proc", 1, 2, 3) + + self.assertEqual("my_proc(1,2,3)", func.get_sql(quote_char='"')) + + def test_schema_included_in_function_sql(self): + a = Schema("a") + func = fn.Function("my_proc", 1, 2, 3, schema=a) + + self.assertEqual('"a".my_proc(1,2,3)', func.get_sql(quote_char='"')) + + +class ArithmeticTests(unittest.TestCase): + t = T("abc") + + def test__addition__fields(self): + q1 = Q.from_("abc").select(F("a") + F("b")) + q2 = Q.from_(self.t).select(self.t.a + self.t.b) + + self.assertEqual('SELECT "a"+"b" FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"+"b" FROM "abc"', str(q2)) + + def test__addition__number(self): + q1 = Q.from_("abc").select(F("a") + 1) + q2 = Q.from_(self.t).select(self.t.a + 1) + + self.assertEqual('SELECT "a"+1 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"+1 FROM "abc"', str(q2)) + + def test__addition__decimal(self): + q1 = Q.from_("abc").select(F("a") + 1.0) + q2 = Q.from_(self.t).select(self.t.a + 1.0) + + self.assertEqual('SELECT "a"+1.0 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"+1.0 FROM "abc"', str(q2)) + + def test__addition__right(self): + q1 = Q.from_("abc").select(1 + F("a")) + q2 = Q.from_(self.t).select(1 + self.t.a) + + self.assertEqual('SELECT 1+"a" FROM "abc"', str(q1)) + self.assertEqual('SELECT 1+"a" FROM "abc"', str(q2)) + + def test__subtraction__fields(self): + q1 = Q.from_("abc").select(F("a") - F("b")) + q2 = Q.from_(self.t).select(self.t.a - self.t.b) + + self.assertEqual('SELECT "a"-"b" FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"-"b" FROM "abc"', str(q2)) + + def test__subtraction__number(self): + q1 = Q.from_("abc").select(F("a") - 1) + q2 = Q.from_(self.t).select(self.t.a - 1) + + self.assertEqual('SELECT "a"-1 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"-1 FROM "abc"', str(q2)) + + def test__subtraction__decimal(self): + q1 = Q.from_("abc").select(F("a") - 1.0) + q2 = Q.from_(self.t).select(self.t.a - 1.0) + + self.assertEqual('SELECT "a"-1.0 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"-1.0 FROM "abc"', str(q2)) + + def test__subtraction__right(self): + q1 = Q.from_("abc").select(1 - F("a")) + q2 = Q.from_(self.t).select(1 - self.t.a) + + self.assertEqual('SELECT 1-"a" FROM "abc"', str(q1)) + self.assertEqual('SELECT 1-"a" FROM "abc"', str(q2)) + + def test__multiplication__fields(self): + q1 = Q.from_("abc").select(F("a") * F("b")) + q2 = Q.from_(self.t).select(self.t.a * self.t.b) + + self.assertEqual('SELECT "a"*"b" FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"*"b" FROM "abc"', str(q2)) + + def test__multiplication__number(self): + q1 = Q.from_("abc").select(F("a") * 1) + q2 = Q.from_(self.t).select(self.t.a * 1) + + self.assertEqual('SELECT "a"*1 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"*1 FROM "abc"', str(q2)) + + def test__multiplication__decimal(self): + q1 = Q.from_("abc").select(F("a") * 1.0) + q2 = Q.from_(self.t).select(self.t.a * 1.0) + + self.assertEqual('SELECT "a"*1.0 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"*1.0 FROM "abc"', str(q2)) + + def test__multiplication__right(self): + q1 = Q.from_("abc").select(1 * F("a")) + q2 = Q.from_(self.t).select(1 * self.t.a) + + self.assertEqual('SELECT 1*"a" FROM "abc"', str(q1)) + self.assertEqual('SELECT 1*"a" FROM "abc"', str(q2)) + + def test__division__fields(self): + q1 = Q.from_("abc").select(F("a") / F("b")) + q2 = Q.from_(self.t).select(self.t.a / self.t.b) + + self.assertEqual('SELECT "a"/"b" FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"/"b" FROM "abc"', str(q2)) + + def test__division__number(self): + q1 = Q.from_("abc").select(F("a") / 1) + q2 = Q.from_(self.t).select(self.t.a / 1) + + self.assertEqual('SELECT "a"/1 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"/1 FROM "abc"', str(q2)) + + def test__division__decimal(self): + q1 = Q.from_("abc").select(F("a") / 1.0) + q2 = Q.from_(self.t).select(self.t.a / 1.0) + + self.assertEqual('SELECT "a"/1.0 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"/1.0 FROM "abc"', str(q2)) + + def test__division__right(self): + q1 = Q.from_("abc").select(1 / F("a")) + q2 = Q.from_(self.t).select(1 / self.t.a) + + self.assertEqual('SELECT 1/"a" FROM "abc"', str(q1)) + self.assertEqual('SELECT 1/"a" FROM "abc"', str(q2)) + + def test__leftshift__fields(self): + q1 = Q.from_("abc").select(F("a") << F("b")) + q2 = Q.from_(self.t).select(self.t.a << self.t.b) + + self.assertEqual('SELECT "a"<<"b" FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"<<"b" FROM "abc"', str(q2)) + + def test__leftshift__number(self): + q1 = Q.from_("abc").select(F('a') << 2) + q2 = Q.from_(self.t).select(self.t.a << 2) + + self.assertEqual('SELECT "a"<<2 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"<<2 FROM "abc"', str(q2)) + + def test__leftshift__right(self): + q1 = Q.from_("abc").select(1 << F("a")) + q2 = Q.from_(self.t).select(1 << self.t.a) + + self.assertEqual('SELECT 1<<"a" FROM "abc"', str(q1)) + self.assertEqual('SELECT 1<<"a" FROM "abc"', str(q2)) + + def test__rightshift__fields(self): + q1 = Q.from_("abc").select(F("a") >> F("b")) + q2 = Q.from_(self.t).select(self.t.a >> self.t.b) + + self.assertEqual('SELECT "a">>"b" FROM "abc"', str(q1)) + self.assertEqual('SELECT "a">>"b" FROM "abc"', str(q2)) + + def test__rightshift__number(self): + q1 = Q.from_("abc").select(F('a') >> 2) + q2 = Q.from_(self.t).select(self.t.a >> 2) + + self.assertEqual('SELECT "a">>2 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a">>2 FROM "abc"', str(q2)) + + def test__rightshift__right(self): + q1 = Q.from_("abc").select(1 >> F("a")) + q2 = Q.from_(self.t).select(1 >> self.t.a) + + self.assertEqual('SELECT 1>>"a" FROM "abc"', str(q1)) + self.assertEqual('SELECT 1>>"a" FROM "abc"', str(q2)) + + def test__complex_op(self): + q1 = Q.from_("abc").select(2 + 1 / F("a") - 5) + q2 = Q.from_(self.t).select(2 + 1 / self.t.a - 5) + + self.assertEqual('SELECT 2+1/"a"-5 FROM "abc"', str(q1)) + self.assertEqual('SELECT 2+1/"a"-5 FROM "abc"', str(q2)) + + def test__complex_op_add_parentheses(self): + q1 = Q.from_("abc").select((F("a") + 1) + (F("b") - 5)) + q2 = Q.from_(self.t).select((self.t.a + 1) + (self.t.b - 5)) + q3 = Q.from_("abc").select((F("a") / 1) + (F("b") / 5)) + q4 = Q.from_(self.t).select((self.t.a / 1) + (self.t.b / 5)) + + self.assertEqual('SELECT "a"+1+"b"-5 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"+1+"b"-5 FROM "abc"', str(q2)) + self.assertEqual('SELECT "a"/1+"b"/5 FROM "abc"', str(q3)) + self.assertEqual('SELECT "a"/1+"b"/5 FROM "abc"', str(q4)) + + def test__complex_op_sub_parentheses(self): + q1 = Q.from_("abc").select((F("a") + 1) - (F("b") - 5)) + q2 = Q.from_(self.t).select((self.t.a + 1) - (self.t.b - 5)) + q3 = Q.from_("abc").select((F("a") / 1) - (F("b") / 5)) + q4 = Q.from_(self.t).select((self.t.a / 1) - (self.t.b / 5)) + + self.assertEqual('SELECT "a"+1-("b"-5) FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"+1-("b"-5) FROM "abc"', str(q2)) + self.assertEqual('SELECT "a"/1-"b"/5 FROM "abc"', str(q3)) + self.assertEqual('SELECT "a"/1-"b"/5 FROM "abc"', str(q4)) + + def test__complex_op_mul_parentheses(self): + q1 = Q.from_("abc").select((F("a") + 1) * (F("b") - 5)) + q2 = Q.from_(self.t).select((self.t.a + 1) * (self.t.b - 5)) + q3 = Q.from_("abc").select((F("a") / 1) * (F("b") - 5)) + q4 = Q.from_(self.t).select((self.t.a / 1) * (self.t.b - 5)) + q5 = Q.from_("abc").select((F("a") + 1) * (F("b") / 5)) + q6 = Q.from_(self.t).select((self.t.a + 1) * (self.t.b / 5)) + + self.assertEqual('SELECT ("a"+1)*("b"-5) FROM "abc"', str(q1)) + self.assertEqual('SELECT ("a"+1)*("b"-5) FROM "abc"', str(q2)) + self.assertEqual('SELECT "a"/1*("b"-5) FROM "abc"', str(q3)) + self.assertEqual('SELECT "a"/1*("b"-5) FROM "abc"', str(q4)) + self.assertEqual('SELECT ("a"+1)*"b"/5 FROM "abc"', str(q5)) + self.assertEqual('SELECT ("a"+1)*"b"/5 FROM "abc"', str(q6)) + + def test__complex_op_mul_no_parentheses(self): + q = Q.from_("abc").select(F("a") + 1 * F("b") - 5) + + self.assertEqual('SELECT "a"+1*"b"-5 FROM "abc"', str(q)) + + def test__complex_op_div_parentheses(self): + q1 = Q.from_("abc").select((F("a") + 1) / (F("b") - 5)) + q2 = Q.from_(self.t).select((self.t.a + 1) / (self.t.b - 5)) + q3 = Q.from_("abc").select((F("a") / 1) / (F("b") - 5)) + q4 = Q.from_(self.t).select((self.t.a / 1) / (self.t.b - 5)) + q5 = Q.from_("abc").select((F("a") + 1) / (F("b") * 5)) + q6 = Q.from_(self.t).select((self.t.a + 1) / (self.t.b * 5)) + + self.assertEqual('SELECT ("a"+1)/("b"-5) FROM "abc"', str(q1)) + self.assertEqual('SELECT ("a"+1)/("b"-5) FROM "abc"', str(q2)) + self.assertEqual('SELECT "a"/1/("b"-5) FROM "abc"', str(q3)) + self.assertEqual('SELECT "a"/1/("b"-5) FROM "abc"', str(q4)) + self.assertEqual('SELECT ("a"+1)/("b"*5) FROM "abc"', str(q5)) + self.assertEqual('SELECT ("a"+1)/("b"*5) FROM "abc"', str(q6)) + + def test__complex_op_div_no_parentheses(self): + q = Q.from_("abc").select(F("a") + 1 / F("b") - 5) + + self.assertEqual('SELECT "a"+1/"b"-5 FROM "abc"', str(q)) + + def test__complex_op_exponent_parentheses(self): + q1 = Q.from_("abc").select(F("a") / (F("b") ** 2)) + q2 = Q.from_(self.t).select(self.t.a / (self.t.b**2)) + q3 = Q.from_("abc").select(F("a") ** (F("b") / 2)) + q4 = Q.from_(self.t).select(self.t.a ** (self.t.b / 2)) + q5 = Q.from_("abc").select((F("a") ** F("b")) ** 2) + q6 = Q.from_(self.t).select((self.t.a**self.t.b) ** 2) + + self.assertEqual('SELECT "a"/POW("b",2) FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"/POW("b",2) FROM "abc"', str(q2)) + self.assertEqual('SELECT POW("a","b"/2) FROM "abc"', str(q3)) + self.assertEqual('SELECT POW("a","b"/2) FROM "abc"', str(q4)) + self.assertEqual('SELECT POW(POW("a","b"),2) FROM "abc"', str(q5)) + self.assertEqual('SELECT POW(POW("a","b"),2) FROM "abc"', str(q6)) + + def test__complex_op_exponent_no_parentheses(self): + q1 = Q.from_("abc").select(F("a") ** F("b") ** 2) + q2 = Q.from_(self.t).select(self.t.a**self.t.b**2) + q3 = Q.from_("abc").select(F("a") / F("b") ** 2) + q4 = Q.from_(self.t).select(self.t.a / self.t.b**2) + + self.assertEqual('SELECT POW("a",POW("b",2)) FROM "abc"', str(q1)) + self.assertEqual('SELECT POW("a",POW("b",2)) FROM "abc"', str(q2)) + self.assertEqual('SELECT "a"/POW("b",2) FROM "abc"', str(q3)) + self.assertEqual('SELECT "a"/POW("b",2) FROM "abc"', str(q4)) + + def test__complex_op_function_parentheses(self): + q1 = Q.from_("abc").select(F("a") / (fn.Sum(F("b")) / 2)) + q2 = Q.from_("abc").select(self.t.a / (fn.Sum(self.t.b) / 2)) + q3 = Q.from_("abc").select(fn.Sum(F("a") / (F("b") / 2))) + q4 = Q.from_("abc").select(fn.Sum(self.t.a / (self.t.b / 2))) + + self.assertEqual('SELECT "a"/(SUM("b")/2) FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"/(SUM("b")/2) FROM "abc"', str(q2)) + self.assertEqual('SELECT SUM("a"/("b"/2)) FROM "abc"', str(q3)) + self.assertEqual('SELECT SUM("a"/("b"/2)) FROM "abc"', str(q4)) + + def test__complex_op_modulus_parentheses(self): + q1 = Q.from_("abc").select(F("a") / (F("b") % 2)) + q2 = Q.from_(self.t).select(self.t.a / (self.t.b % 2)) + q3 = Q.from_("abc").select(F("a") % (F("b") / 2)) + q4 = Q.from_(self.t).select(self.t.a % (self.t.b / 2)) + q5 = Q.from_("abc").select(F("a") % (F("b") % 2)) + q6 = Q.from_("abc").select(self.t.a % (self.t.b % 2)) + + self.assertEqual('SELECT "a"/MOD("b",2) FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"/MOD("b",2) FROM "abc"', str(q2)) + self.assertEqual('SELECT MOD("a","b"/2) FROM "abc"', str(q3)) + self.assertEqual('SELECT MOD("a","b"/2) FROM "abc"', str(q4)) + self.assertEqual('SELECT MOD("a",MOD("b",2)) FROM "abc"', str(q5)) + self.assertEqual('SELECT MOD("a",MOD("b",2)) FROM "abc"', str(q6)) + + def test__complex_op_modulus_no_parentheses(self): + q1 = Q.from_("abc").select(F("a") % F("b") % 2) + q2 = Q.from_(self.t).select(self.t.a % self.t.b % 2) + q3 = Q.from_("abc").select(F("a") / F("b") % 2) + q4 = Q.from_(self.t).select(self.t.a / self.t.b % 2) + + self.assertEqual('SELECT MOD(MOD("a","b"),2) FROM "abc"', str(q1)) + self.assertEqual('SELECT MOD(MOD("a","b"),2) FROM "abc"', str(q2)) + self.assertEqual('SELECT MOD("a"/"b",2) FROM "abc"', str(q3)) + self.assertEqual('SELECT MOD("a"/"b",2) FROM "abc"', str(q4)) + + def test__complex_op_floor_parentheses(self): + q1 = Q.from_("abc").select(F("a") / (fn.Floor(F("b")) / 2)) + q2 = Q.from_("abc").select(self.t.a / (fn.Floor(self.t.b) / 2)) + q3 = Q.from_("abc").select(fn.Floor(F("a") / (F("b") / 2))) + q4 = Q.from_("abc").select(fn.Floor(self.t.a / (self.t.b / 2))) + + self.assertEqual('SELECT "a"/(FLOOR("b")/2) FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"/(FLOOR("b")/2) FROM "abc"', str(q2)) + self.assertEqual('SELECT FLOOR("a"/("b"/2)) FROM "abc"', str(q3)) + self.assertEqual('SELECT FLOOR("a"/("b"/2)) FROM "abc"', str(q4)) + + def test__complex_op_nested_parentheses(self): + q1 = Q.from_("abc").select(F("a") / (F("b") / ((F("c") / 2)))) + q2 = Q.from_("abc").select(self.t.a / (self.t.b / ((self.t.c / 2)))) + + self.assertEqual('SELECT "a"/("b"/("c"/2)) FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"/("b"/("c"/2)) FROM "abc"', str(q2)) + + def test__arithmetic_equality(self): + q1 = Q.from_("abc").select(F("a") / 2 == 2) + q2 = Q.from_(self.t).select(self.t.a / 2 == 2) + + self.assertEqual('SELECT "a"/2=2 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"/2=2 FROM "abc"', str(q2)) + + def test__arithmetic_with_function(self): + q1 = Q.from_("abc").select(fn.Sum(F("foo")) + 1) + q2 = Q.from_(self.t).select(fn.Sum(self.t.foo) + 1) + + self.assertEqual('SELECT SUM("foo")+1 FROM "abc"', str(q1)) + self.assertEqual('SELECT SUM("foo")+1 FROM "abc"', str(q2)) + + def test__exponent__number(self): + q1 = Q.from_("abc").select(F("a") ** 2) + q2 = Q.from_(self.t).select(self.t.a**2) + + self.assertEqual('SELECT POW("a",2) FROM "abc"', str(q1)) + self.assertEqual('SELECT POW("a",2) FROM "abc"', str(q2)) + + def test__exponent__decimal(self): + q1 = Q.from_("abc").select(F("a") ** 0.5) + q2 = Q.from_(self.t).select(self.t.a**0.5) + + self.assertEqual('SELECT POW("a",0.5) FROM "abc"', str(q1)) + self.assertEqual('SELECT POW("a",0.5) FROM "abc"', str(q2)) + + def test__modulus__number(self): + q1 = Q.from_("abc").select(F("a") % 2) + q2 = Q.from_(self.t).select(self.t.a % 2) + + self.assertEqual('SELECT MOD("a",2) FROM "abc"', str(q1)) + self.assertEqual('SELECT MOD("a",2) FROM "abc"', str(q2)) + + def test__floor(self): + q1 = Q.from_("abc").select(fn.Floor(F("foo"))) + q2 = Q.from_(self.t).select(fn.Floor(self.t.foo)) + + self.assertEqual('SELECT FLOOR("foo") FROM "abc"', str(q1)) + self.assertEqual('SELECT FLOOR("foo") FROM "abc"', str(q2)) + + +class AggregationTests(unittest.TestCase): + def test__count(self): + q = Q.from_("abc").select(fn.Count(F("foo"))) + + self.assertEqual('SELECT COUNT("foo") FROM "abc"', str(q)) + + def test__count__star(self): + q = Q.from_("abc").select(fn.Count("*")) + + self.assertEqual('SELECT COUNT(*) FROM "abc"', str(q)) + + def test__sum(self): + q = Q.from_("abc").select(fn.Sum(F("foo"))) + + self.assertEqual('SELECT SUM("foo") FROM "abc"', str(q)) + + def test__avg(self): + q = Q.from_("abc").select(fn.Avg(F("foo"))) + + self.assertEqual('SELECT AVG("foo") FROM "abc"', str(q)) + + def test__first(self): + q = Q.from_("abc").select(fn.First(F("foo"))) + + self.assertEqual('SELECT FIRST("foo") FROM "abc"', str(q)) + + def test__last(self): + q = Q.from_("abc").select(fn.Last(F("foo"))) + + self.assertEqual('SELECT LAST("foo") FROM "abc"', str(q)) + + def test__min(self): + q = Q.from_("abc").select(fn.Min(F("foo"))) + + self.assertEqual('SELECT MIN("foo") FROM "abc"', str(q)) + + def test__max(self): + q = Q.from_("abc").select(fn.Max(F("foo"))) + + self.assertEqual('SELECT MAX("foo") FROM "abc"', str(q)) + + def test__std(self): + q = Q.from_("abc").select(fn.Std(F("foo"))) + + self.assertEqual('SELECT STD("foo") FROM "abc"', str(q)) + + def test__stddev(self): + q = Q.from_("abc").select(fn.StdDev(F("foo"))) + + self.assertEqual('SELECT STDDEV("foo") FROM "abc"', str(q)) + + def test__approx_percentile(self): + q = Q.from_("abc").select(fn.ApproximatePercentile(F("foo"), 0.5)) + + self.assertEqual( + 'SELECT APPROXIMATE_PERCENTILE("foo" USING PARAMETERS percentile=0.5) FROM "abc"', + str(q), + ) + + def test__subquery_in_params_functions(self): + subquery = Query.from_('table').select('id') + func = fn.Function('func', 'id', subquery) + self.assertEqual("func('id',(SELECT id FROM table))", func.get_sql()) + + +class ConditionTests(unittest.TestCase): + def test__case__raw(self): + q = Q.from_("abc").select(Case().when(F("foo") == 1, "a")) + + self.assertEqual('SELECT CASE WHEN "foo"=1 THEN \'a\' END FROM "abc"', str(q)) + + def test__case__else(self): + q = Q.from_("abc").select(Case().when(F("foo") == 1, "a").else_("b")) + + self.assertEqual("SELECT CASE WHEN \"foo\"=1 THEN 'a' ELSE 'b' END FROM \"abc\"", str(q)) + + def test__case__field(self): + q = Q.from_("abc").select(Case().when(F("foo") == 1, F("bar")).else_(F("buz"))) + + self.assertEqual('SELECT CASE WHEN "foo"=1 THEN "bar" ELSE "buz" END FROM "abc"', str(q)) + + def test__case__multi(self): + q = Q.from_("abc").select(Case().when(F("foo") > 0, F("fiz")).when(F("bar") <= 0, F("buz")).else_(1)) + + self.assertEqual( + 'SELECT CASE WHEN "foo">0 THEN "fiz" WHEN "bar"<=0 THEN "buz" ELSE 1 END FROM "abc"', + str(q), + ) + + def test__case__no_cases(self): + with self.assertRaises(CaseException): + q = Q.from_("abc").select(Case()) + + str(q) + + +class StringTests(unittest.TestCase): + t = T("abc") + + def test__ascii__str(self): + q = Q.select(fn.Ascii("2")) + + self.assertEqual("SELECT ASCII('2')", str(q)) + + def test__ascii__int(self): + q = Q.select(fn.Ascii(2)) + + self.assertEqual("SELECT ASCII(2)", str(q)) + + def test__ascii__field(self): + q = Q.from_(self.t).select(fn.Ascii(self.t.foo)) + + self.assertEqual('SELECT ASCII("foo") FROM "abc"', str(q)) + + def test__bin__str(self): + q = Q.select(fn.Bin("2")) + + self.assertEqual("SELECT BIN('2')", str(q)) + + def test__bin__int(self): + q = Q.select(fn.Bin(2)) + + self.assertEqual("SELECT BIN(2)", str(q)) + + def test__bin__field(self): + q = Q.from_(self.t).select(fn.Bin(self.t.foo)) + + self.assertEqual('SELECT BIN("foo") FROM "abc"', str(q)) + + def test__concat__str(self): + q = Q.select(fn.Concat("p", "y", "q", "b")) + + self.assertEqual("SELECT CONCAT('p','y','q','b')", str(q)) + + def test__concat__field(self): + q = Q.from_(self.t).select(fn.Concat(self.t.foo, self.t.bar)) + + self.assertEqual('SELECT CONCAT("foo","bar") FROM "abc"', str(q)) + + def test__insert__str(self): + q = Q.select(fn.Insert("Quadratic", 3, 4, "What")) + + self.assertEqual("SELECT INSERT('Quadratic',3,4,'What')", str(q)) + + def test__insert__field(self): + q = Q.from_(self.t).select(fn.Insert(self.t.foo, 3, 4, self.t.bar)) + + self.assertEqual('SELECT INSERT("foo",3,4,"bar") FROM "abc"', str(q)) + + def test__lower__str(self): + q = Q.select(fn.Lower("ABC")) + + self.assertEqual("SELECT LOWER('ABC')", str(q)) + + def test__lower__field(self): + q = Q.from_(self.t).select(fn.Lower(self.t.foo)) + + self.assertEqual('SELECT LOWER("foo") FROM "abc"', str(q)) + + def test__length__str(self): + q = Q.select(fn.Length("ABC")) + + self.assertEqual("SELECT LENGTH('ABC')", str(q)) + + def test__length__field(self): + q = Q.from_(self.t).select(fn.Length(self.t.foo)) + + self.assertEqual('SELECT LENGTH("foo") FROM "abc"', str(q)) + + def test__substring(self): + q = Q.from_(self.t).select(fn.Substring(self.t.foo, 2, 6)) + + self.assertEqual('SELECT SUBSTRING("foo",2,6) FROM "abc"', str(q)) + + def test__replace__str(self): + q = Q.select(fn.Replace("ABC_DEF", "_", " ")) + self.assertEqual("SELECT REPLACE('ABC_DEF','_',' ')", str(q)) + + def test__replace__field(self): + q = Q.from_(self.t).select(fn.Replace(self.t.foobar, self.t.foo, self.t.bar)) + self.assertEqual('SELECT REPLACE("foobar","foo","bar") FROM "abc"', str(q)) + + +class SplitPartFunctionTests(unittest.TestCase): + t = T("abc") + + def test__split_part(self): + q = VerticaQuery.from_(self.t).select(fn.SplitPart(self.t.foo, "|", 3)) + + self.assertEqual('SELECT SPLIT_PART("foo",\'|\',3) FROM "abc"', str(q)) + + +class RegexpLikeFunctionTests(unittest.TestCase): + t = T("abc") + + def test__regexp_like(self): + q = VerticaQuery.from_(self.t).select(fn.RegexpLike(self.t.foo, "^a", "x")) + + self.assertEqual("SELECT REGEXP_LIKE(\"foo\",'^a','x') FROM \"abc\"", str(q)) + + +class CastTests(unittest.TestCase): + t = T("abc") + + def test__cast__as(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.UNSIGNED)) + + self.assertEqual('SELECT CAST("foo" AS UNSIGNED) FROM "abc"', str(q)) + + def test__cast__signed(self): + q1 = Q.from_(self.t).select(fn.Signed(self.t.foo)) + q2 = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.SIGNED)) + + self.assertEqual('SELECT CAST("foo" AS SIGNED) FROM "abc"', str(q1)) + self.assertEqual('SELECT CAST("foo" AS SIGNED) FROM "abc"', str(q2)) + + def test__cast__unsigned(self): + q1 = Q.from_(self.t).select(fn.Unsigned(self.t.foo)) + q2 = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.UNSIGNED)) + + self.assertEqual('SELECT CAST("foo" AS UNSIGNED) FROM "abc"', str(q1)) + self.assertEqual('SELECT CAST("foo" AS UNSIGNED) FROM "abc"', str(q2)) + + def test__cast__date(self): + q1 = Q.from_(self.t).select(fn.Date(self.t.foo)) + q2 = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.DATE)) + + self.assertEqual('SELECT DATE("foo") FROM "abc"', str(q1)) + self.assertEqual('SELECT CAST("foo" AS DATE) FROM "abc"', str(q2)) + + def test__cast__timestamp(self): + q1 = Q.from_(self.t).select(fn.Timestamp(self.t.foo)) + q2 = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.TIMESTAMP)) + + self.assertEqual('SELECT TIMESTAMP("foo") FROM "abc"', str(q1)) + self.assertEqual('SELECT CAST("foo" AS TIMESTAMP) FROM "abc"', str(q2)) + + def test__cast__char(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.CHAR)) + + self.assertEqual('SELECT CAST("foo" AS CHAR) FROM "abc"', str(q)) + + def test__cast__char_with_arg(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.VARCHAR(24))) + + self.assertEqual('SELECT CAST("foo" AS VARCHAR(24)) FROM "abc"', str(q)) + + def test__cast__varchar(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.VARCHAR)) + + self.assertEqual('SELECT CAST("foo" AS VARCHAR) FROM "abc"', str(q)) + + def test__cast__varchar_with_arg(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.VARCHAR(24))) + + self.assertEqual('SELECT CAST("foo" AS VARCHAR(24)) FROM "abc"', str(q)) + + def test__cast__long_varchar(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.LONG_VARCHAR)) + + self.assertEqual('SELECT CAST("foo" AS LONG VARCHAR) FROM "abc"', str(q)) + + def test__cast__long_varchar_with_arg(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.LONG_VARCHAR(24))) + + self.assertEqual('SELECT CAST("foo" AS LONG VARCHAR(24)) FROM "abc"', str(q)) + + def test__cast__binary(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.BINARY)) + + self.assertEqual('SELECT CAST("foo" AS BINARY) FROM "abc"', str(q)) + + def test__cast__binary_with_arg(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.BINARY(24))) + + self.assertEqual('SELECT CAST("foo" AS BINARY(24)) FROM "abc"', str(q)) + + def test__cast__varbinary(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.VARBINARY)) + + self.assertEqual('SELECT CAST("foo" AS VARBINARY) FROM "abc"', str(q)) + + def test__cast__varbinary_with_arg(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.VARBINARY(24))) + + self.assertEqual('SELECT CAST("foo" AS VARBINARY(24)) FROM "abc"', str(q)) + + def test__cast__long_varbinary(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.LONG_VARBINARY)) + + self.assertEqual('SELECT CAST("foo" AS LONG VARBINARY) FROM "abc"', str(q)) + + def test__cast__long_varbinary_with_arg(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.LONG_VARBINARY(24))) + + self.assertEqual('SELECT CAST("foo" AS LONG VARBINARY(24)) FROM "abc"', str(q)) + + def test__cast__boolean(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.BOOLEAN)) + + self.assertEqual('SELECT CAST("foo" AS BOOLEAN) FROM "abc"', str(q)) + + def test__cast__integer(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.INTEGER)) + + self.assertEqual('SELECT CAST("foo" AS INTEGER) FROM "abc"', str(q)) + + def test__cast__float(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.FLOAT)) + + self.assertEqual('SELECT CAST("foo" AS FLOAT) FROM "abc"', str(q)) + + def test__cast__numeric(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.NUMERIC)) + + self.assertEqual('SELECT CAST("foo" AS NUMERIC) FROM "abc"', str(q)) + + def test__tochar__(self): + q = Q.from_(self.t).select(fn.ToChar(self.t.foo, "SomeFormat")) + + self.assertEqual('SELECT TO_CHAR("foo",\'SomeFormat\') FROM "abc"', str(q)) + + +class DateFunctionsTests(unittest.TestCase): + dt = F("dt") + t = T("abc") + t2 = T("efg") + + def _test_extract_datepart(self, date_part): + q = Q.from_(self.t).select(fn.Extract(date_part, self.t.foo)) + + value = getattr(date_part, 'value', date_part) + self.assertEqual('SELECT EXTRACT(%s FROM "foo") FROM "abc"' % value, str(q)) + + def test_extract_microsecond(self): + self._test_extract_datepart(DatePart.microsecond) + self._test_extract_datepart(DatePart.microsecond.value) + + def test_extract_second(self): + self._test_extract_datepart(DatePart.second) + self._test_extract_datepart(DatePart.second.value) + + def test_extract_minute(self): + self._test_extract_datepart(DatePart.minute) + self._test_extract_datepart(DatePart.minute.value) + + def test_extract_hour(self): + self._test_extract_datepart(DatePart.hour) + self._test_extract_datepart(DatePart.hour.value) + + def test_extract_day(self): + self._test_extract_datepart(DatePart.day) + self._test_extract_datepart(DatePart.day.value) + + def test_extract_week(self): + self._test_extract_datepart(DatePart.week) + self._test_extract_datepart(DatePart.week.value) + + def test_extract_month(self): + self._test_extract_datepart(DatePart.month) + self._test_extract_datepart(DatePart.month.value) + + def test_extract_quarter(self): + self._test_extract_datepart(DatePart.quarter) + self._test_extract_datepart(DatePart.quarter.value) + + def test_extract_year(self): + self._test_extract_datepart(DatePart.year) + self._test_extract_datepart(DatePart.year.value) + + def test_extract_join(self): + q = Q.from_(self.t).join(self.t2).on(self.t.id == self.t2.t_id).select(fn.Extract(DatePart.year, self.t.foo)) + + self.assertEqual( + 'SELECT EXTRACT(YEAR FROM "abc"."foo") FROM "abc" ' 'JOIN "efg" ON "abc"."id"="efg"."t_id"', str(q) + ) + + def test_timestampadd(self): + a = fn.TimestampAdd("year", 1, "2017-10-01") + self.assertEqual(str(a), "TIMESTAMPADD(year,1,'2017-10-01')") + + def test_time_diff(self): + a = fn.TimeDiff("18:00:00", "10:00:00") + self.assertEqual(str(a), "TIMEDIFF('18:00:00','10:00:00')") + + def test_date_add(self): + a = fn.DateAdd("year", 1, "2017-10-01") + self.assertEqual(str(a), "DATE_ADD(year,1,'2017-10-01')") + + def test_now(self): + query = Query.select(fn.Now()) + + self.assertEqual("SELECT NOW()", str(query)) + + def test_utc_timestamp(self): + query = Query.select(fn.UtcTimestamp()) + + self.assertEqual("SELECT UTC_TIMESTAMP()", str(query)) + + def test_current_date(self): + query = Query.select(fn.CurDate()) + + self.assertEqual("SELECT CURRENT_DATE()", str(query)) + + def test_current_time(self): + query = Query.select(fn.CurTime()) + + self.assertEqual("SELECT CURRENT_TIME()", str(query)) + + def test_current_timestamp(self): + query = Query.select(fn.CurTimestamp()) + + self.assertEqual("SELECT CURRENT_TIMESTAMP", str(query)) + + def test_current_timestamp_with_alias(self): + query = Query.select(fn.CurTimestamp("ts")) + + self.assertEqual('SELECT CURRENT_TIMESTAMP "ts"', str(query)) + + def test_to_date(self): + q1 = fn.ToDate("2019-06-21", "yyyy-mm-dd") + q2 = Query.from_(self.t).select(fn.ToDate("2019-06-21", "yyyy-mm-dd")) + q3 = Query.from_(self.t).select(fn.ToDate(F("foo"), "yyyy-mm-dd")) + + self.assertEqual(str(q1), "TO_DATE('2019-06-21','yyyy-mm-dd')") + self.assertEqual(str(q2), "SELECT TO_DATE('2019-06-21','yyyy-mm-dd') FROM \"abc\"") + self.assertEqual(str(q3), 'SELECT TO_DATE("foo",\'yyyy-mm-dd\') FROM "abc"') + + +class NullFunctionsTests(unittest.TestCase): + def test_isnull(self): + q = Q.from_("abc").select(fn.IsNull(F("foo"))) + + self.assertEqual('SELECT ISNULL("foo") FROM "abc"', str(q)) + + def test_coalesce(self): + q = Q.from_("abc").select(fn.Coalesce(F("foo"), 0)) + + self.assertEqual('SELECT COALESCE("foo",0) FROM "abc"', str(q)) + + def test_nullif(self): + q = Q.from_("abc").select(fn.NullIf(F("foo"), 0)) + + self.assertEqual('SELECT NULLIF("foo",0) FROM "abc"', str(q)) + + def test_nvl(self): + q = Q.from_("abc").select(fn.NVL(F("foo"), 0)) + + self.assertEqual('SELECT NVL("foo",0) FROM "abc"', str(q)) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/test_groupby_modifiers.py b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/test_groupby_modifiers.py new file mode 100644 index 0000000000000000000000000000000000000000..978834c2409f4b4800fedb9b1bb2538a31d0f31c --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/test_groupby_modifiers.py @@ -0,0 +1,168 @@ +import unittest + +from pypika import Query, Rollup, RollupException, Table, functions as fn + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + + +class RollupTests(unittest.TestCase): + table = Table("abc") + + def test_mysql_one_groupby(self): + q = ( + Query.from_(self.table) + .select(self.table.foo, fn.Sum(self.table.bar)) + .rollup(self.table.foo, vendor="mysql") + ) + + self.assertEqual('SELECT "foo",SUM("bar") FROM "abc" GROUP BY "foo" WITH ROLLUP', str(q)) + + def test_mysql_rollup_two_groupbys(self): + q = ( + Query.from_(self.table) + .select(self.table.foo, self.table.fiz, fn.Sum(self.table.bar)) + .rollup(self.table.foo, self.table.fiz, vendor="mysql") + ) + + self.assertEqual( + 'SELECT "foo","fiz",SUM("bar") FROM "abc" GROUP BY "foo","fiz" WITH ROLLUP', + str(q), + ) + + def test_no_rollup_before_groupby(self): + with self.assertRaises(RollupException): + Query.from_(self.table).select(self.table.foo, fn.Sum(self.table.bar)).rollup(vendor="mysql") + + def test_no_rollup_after_rollup_mysql(self): + with self.assertRaises(AttributeError): + Query.from_(self.table).select(self.table.foo, self.table.fiz, fn.Sum(self.table.bar)).rollup( + self.table.foo, vendor="mysql" + ).rollup(self.table.fiz, vendor="mysql") + + def test_verticaoracle_func_one_groupby(self): + q = Query.from_(self.table).select(self.table.foo, fn.Sum(self.table.bar)).groupby(Rollup(self.table.foo)) + + self.assertEqual('SELECT "foo",SUM("bar") FROM "abc" GROUP BY ROLLUP("foo")', str(q)) + + def test_verticaoracle_func_two_groupbys(self): + q = ( + Query.from_(self.table) + .select(self.table.foo, self.table.fiz, fn.Sum(self.table.bar)) + .groupby( + Rollup( + self.table.foo, + self.table.fiz, + ) + ) + ) + + self.assertEqual( + 'SELECT "foo","fiz",SUM("bar") FROM "abc" GROUP BY ROLLUP("foo","fiz")', + str(q), + ) + + def test_verticaoracle_func_partial(self): + q = ( + Query.from_(self.table) + .select(self.table.foo, self.table.fiz, self.table.buz, fn.Sum(self.table.bar)) + .groupby( + Rollup( + self.table.foo, + self.table.fiz, + ), + self.table.buz, + ) + ) + + self.assertEqual( + 'SELECT "foo","fiz","buz",SUM("bar") FROM "abc" GROUP BY ROLLUP("foo","fiz"),"buz"', + str(q), + ) + + def test_verticaoracle_from_groupbys(self): + q = Query.from_(self.table).select(self.table.foo, fn.Sum(self.table.bar)).rollup(self.table.foo) + + self.assertEqual('SELECT "foo",SUM("bar") FROM "abc" GROUP BY ROLLUP("foo")', str(q)) + + def test_verticaoracle_from_two_groupbys(self): + q = ( + Query.from_(self.table) + .select(self.table.foo, self.table.fiz, fn.Sum(self.table.bar)) + .rollup( + self.table.foo, + self.table.fiz, + ) + ) + + self.assertEqual( + 'SELECT "foo","fiz",SUM("bar") FROM "abc" GROUP BY ROLLUP("foo","fiz")', + str(q), + ) + + def test_verticaoracle_from_parameters(self): + q = ( + Query.from_(self.table) + .select(self.table.foo, self.table.fiz, fn.Sum(self.table.bar)) + .groupby( + self.table.foo, + ) + .rollup( + self.table.fiz, + ) + ) + + self.assertEqual( + 'SELECT "foo","fiz",SUM("bar") FROM "abc" GROUP BY "foo",ROLLUP("fiz")', + str(q), + ) + + def test_verticaoracle_multiple_rollups(self): + q = ( + Query.from_(self.table) + .select(self.table.foo, self.table.fiz, fn.Sum(self.table.bar)) + .rollup( + self.table.foo, + ) + .rollup( + self.table.fiz, + ) + ) + + self.assertEqual( + 'SELECT "foo","fiz",SUM("bar") FROM "abc" GROUP BY ROLLUP("foo","fiz")', + str(q), + ) + + def test_verticaoracle_rollups_with_parity(self): + q = ( + Query.from_(self.table) + .select( + self.table.buz, + ) + .rollup( + [self.table.foo, self.table.bar], + self.table.fiz, + ) + ) + + self.assertEqual('SELECT "buz" FROM "abc" GROUP BY ROLLUP(("foo","bar"),"fiz")', str(q)) + + def test_verticaoracle_rollups_with_multiple_rollups_and_parity(self): + q = ( + Query.from_(self.table) + .select( + self.table.buz, + ) + .rollup( + [self.table.foo, self.table.bar], + ) + .rollup( + [self.table.fiz, self.table.buz], + ) + ) + + self.assertEqual( + 'SELECT "buz" FROM "abc" GROUP BY ROLLUP(("foo","bar"),("fiz","buz"))', + str(q), + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/test_immutability.py b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/test_immutability.py new file mode 100644 index 0000000000000000000000000000000000000000..ee539bfa1e9c4509b929e7a86a03f098dd923515 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/test_immutability.py @@ -0,0 +1,99 @@ +import unittest + +from pypika import ( + AliasedQuery, + Query, + Tables, +) + + +class ImmutabilityTests(unittest.TestCase): + table_a, table_b, table_c = Tables("a", "b", "c") + + def test_select_returns_new_query_instance(self): + query_a = Query.from_(self.table_a).select(self.table_a.foo) + query_b = query_a.select(self.table_a.bar) + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_groupby_returns_new_query_instance(self): + query_a = Query.from_(self.table_a).select(self.table_a.foo).groupby(self.table_a.foo) + query_b = query_a.groupby(self.table_a.bar) + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_orderby_return_new_query_instance(self): + query_a = Query.from_(self.table_a).select(self.table_a.foo).orderby(self.table_a.foo) + query_b = query_a.orderby(self.table_a.bar) + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_join_return_new_query_instance(self): + base = Query.from_(self.table_a).select(self.table_a.foo) + query_a = base.join(self.table_b).on(self.table_a.foo == self.table_b.bar).select(self.table_b.bar) + query_b = query_a.join(self.table_c).on(self.table_a.foo == self.table_c.baz).select(self.table_c.baz) + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_use_index_return_new_query_instance(self): + query_a = Query.from_(self.table_a).select(self.table_a.foo).use_index('idx1') + query_b = query_a.use_index('idx2') + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_force_index_return_new_query_instance(self): + query_a = Query.from_(self.table_a).select(self.table_a.foo).force_index('idx1') + query_b = query_a.force_index('idx2') + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_with_return_new_query_instance(self): + alias_1 = Query.from_(self.table_a).select(self.table_a.foo) + alias_2 = Query.from_(self.table_b).select(self.table_b.bar) + query_a = Query.from_(AliasedQuery('a1')).select('foo').with_(alias_1, 'a1') + query_b = query_a.with_(alias_2, 'a2') + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_insert_into_return_new_query_instance(self): + query_a = Query.into(self.table_a).insert('foo1') + query_b = query_a.insert('foo2') + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_replace_into_return_new_query_instance(self): + query_a = Query.into(self.table_a).replace('foo') + query_b = query_a.replace('bar') + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_update_set_return_new_query_instance(self): + query_a = Query.update(self.table_a).set(self.table_a.foo, 'foo') + query_b = query_a.set(self.table_a.bar, 'bar') + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_queries_after_join(self): + query1 = Query.from_(self.table_a).select(self.table_a.foo) + query2 = query1.join(self.table_b).on(self.table_a.foo == self.table_b.bar).select(self.table_b.buz) + + self.assertEqual('SELECT "foo" FROM "a"', str(query1)) + self.assertEqual( + 'SELECT "a"."foo","b"."buz" FROM "a" JOIN "b" ON "a"."foo"="b"."bar"', + str(query2), + ) + + def test_immutable_kwarg_on_query_builder_disables_immutability(self): + query0 = Query.from_(self.table_a, immutable=False) + query1 = query0.select(self.table_a.foo) + self.assertIs(query0, query1) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/test_inserts.py b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/test_inserts.py new file mode 100644 index 0000000000000000000000000000000000000000..f86efd7a76dc498a69b61c6353951695f1933a61 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/test_inserts.py @@ -0,0 +1,885 @@ +import unittest + +from pypika import ( + AliasedQuery, + Case, + Field as F, + MySQLQuery, + PostgreSQLQuery, + Query, + Table, + Tables, + functions as fn, +) +from pypika.functions import ( + Avg, + Cast, +) +from pypika.terms import Values +from pypika.utils import QueryException + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + + +class InsertIntoTests(unittest.TestCase): + table_abc = Table("abc") + + def test_insert_one_column(self): + query = Query.into(self.table_abc).insert(1) + + self.assertEqual('INSERT INTO "abc" VALUES (1)', str(query)) + + def test_insert_one_column_single_element_array(self): + query = Query.into(self.table_abc).insert((1,)) + + self.assertEqual('INSERT INTO "abc" VALUES (1)', str(query)) + + def test_insert_one_column_multi_element_array(self): + query = Query.into(self.table_abc).insert((1,), (2,)) + + self.assertEqual('INSERT INTO "abc" VALUES (1),(2)', str(query)) + + def test_insert_single_row_with_array_value(self): + query = Query.into(self.table_abc).insert(1, ["a", "b", "c"]) + + self.assertEqual("INSERT INTO \"abc\" VALUES (1,['a','b','c'])", str(query)) + + def test_insert_multiple_rows_with_array_value(self): + query = Query.into(self.table_abc).insert( + (1, ["a", "b", "c"]), + (2, ["c", "d", "e"]), + ) + + self.assertEqual( + 'INSERT INTO "abc" ' "VALUES (1,['a','b','c']),(2,['c','d','e'])", + str(query), + ) + + def test_insert_all_columns(self): + query = Query.into(self.table_abc).insert(1, "a", True) + + self.assertEqual("INSERT INTO \"abc\" VALUES (1,'a',true)", str(query)) + + def test_insert_all_columns_single_element(self): + query = Query.into(self.table_abc).insert((1, "a", True)) + + self.assertEqual("INSERT INTO \"abc\" VALUES (1,'a',true)", str(query)) + + def test_insert_all_columns_multi_rows(self): + query = Query.into(self.table_abc).insert((1, "a", True), (2, "b", False)) + + self.assertEqual("INSERT INTO \"abc\" VALUES (1,'a',true),(2,'b',false)", str(query)) + + def test_insert_all_columns_multi_rows_chained(self): + query = Query.into(self.table_abc).insert(1, "a", True).insert(2, "b", False) + + self.assertEqual("INSERT INTO \"abc\" VALUES (1,'a',true),(2,'b',false)", str(query)) + + def test_insert_all_columns_multi_rows_chained_mixed(self): + query = Query.into(self.table_abc).insert((1, "a", True), (2, "b", False)).insert(3, "c", True) + + self.assertEqual( + 'INSERT INTO "abc" VALUES ' "(1,'a',true),(2,'b',false)," "(3,'c',true)", + str(query), + ) + + def test_insert_all_columns_multi_rows_chained_multiple_rows(self): + query = ( + Query.into(self.table_abc).insert((1, "a", True), (2, "b", False)).insert((3, "c", True), (4, "d", False)) + ) + + self.assertEqual( + 'INSERT INTO "abc" VALUES ' "(1,'a',true),(2,'b',false)," "(3,'c',true),(4,'d',false)", + str(query), + ) + + def test_insert_selected_columns(self): + query = ( + Query.into(self.table_abc) + .columns(self.table_abc.foo, self.table_abc.bar, self.table_abc.buz) + .insert(1, "a", True) + ) + + self.assertEqual('INSERT INTO "abc" ("foo","bar","buz") VALUES (1,\'a\',true)', str(query)) + + def test_insert_empty_columns(self): + query = Query.into(self.table_abc).columns().insert(1, "a", True) + + self.assertEqual('INSERT INTO "abc" VALUES (1,\'a\',true)', str(query)) + + def test_insert_selected_columns_type_list(self): + query = ( + Query.into(self.table_abc) + .columns([self.table_abc.foo, self.table_abc.bar, self.table_abc.buz]) + .insert(1, "a", True) + ) + + self.assertEqual('INSERT INTO "abc" ("foo","bar","buz") VALUES (1,\'a\',true)', str(query)) + + def test_insert_empty_columns_type_list(self): + query = Query.into(self.table_abc).columns([]).insert(1, "a", True) + + self.assertEqual('INSERT INTO "abc" VALUES (1,\'a\',true)', str(query)) + + def test_insert_selected_columns_type_tuple(self): + query = ( + Query.into(self.table_abc) + .columns((self.table_abc.foo, self.table_abc.bar, self.table_abc.buz)) + .insert(1, "a", True) + ) + + self.assertEqual('INSERT INTO "abc" ("foo","bar","buz") VALUES (1,\'a\',true)', str(query)) + + def test_insert_empty_columns_type_tuple(self): + query = Query.into(self.table_abc).columns(()).insert(1, "a", True) + + self.assertEqual('INSERT INTO "abc" VALUES (1,\'a\',true)', str(query)) + + def test_insert_none_skipped(self): + query = Query.into(self.table_abc).insert() + + self.assertEqual("", str(query)) + + def test_insert_ignore(self): + query = Query.into(self.table_abc).insert(1).ignore() + + self.assertEqual('INSERT IGNORE INTO "abc" VALUES (1)', str(query)) + + def test_insert_null(self): + query = Query.into(self.table_abc).insert(None) + + self.assertEqual('INSERT INTO "abc" VALUES (NULL)', str(query)) + + def test_insert_column_using_table_alias(self): + q = self.table_abc.insert(1) + self.assertEqual('INSERT INTO "abc" VALUES (1)', str(q)) + + def test_insert_column_using_alias_with_chain(self): + q = self.table_abc.insert(1, "a", True).insert(2, "b", False) + self.assertEqual("INSERT INTO \"abc\" VALUES (1,'a',true),(2,'b',false)", str(q)) + + def test_insert_with_statement(self): + sub_query = Query().select(self.table_abc.id).from_(self.table_abc) + aliased = AliasedQuery('sub_qs') + + q = Query().with_(sub_query, 'sub_qs').into(self.table_abc).select(aliased.id).from_(aliased) + self.assertEqual( + 'WITH sub_qs AS (SELECT "id" FROM "abc") INSERT INTO "abc" SELECT "sub_qs"."id" FROM sub_qs', str(q) + ) + + +class PostgresInsertIntoOnConflictTests(unittest.TestCase): + table_abc = Table("abc") + + def test_insert_on_conflict_do_nothing_field(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).on_conflict(self.table_abc.id).do_nothing() + + self.assertEqual('INSERT INTO "abc" VALUES (1) ON CONFLICT ("id") DO NOTHING', str(query)) + + def test_insert_on_conflict_do_nothing_multiple_fields(self): + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1) + .on_conflict(self.table_abc.id, self.table_abc.sub_id) + .do_nothing() + ) + + self.assertEqual('INSERT INTO "abc" VALUES (1) ON CONFLICT ("id", "sub_id") DO NOTHING', str(query)) + + def test_insert_on_conflict_do_nothing_field_str(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).on_conflict("id").do_nothing() + + self.assertEqual('INSERT INTO "abc" VALUES (1) ON CONFLICT ("id") DO NOTHING', str(query)) + + def test_insert_on_conflict_do_nothing_multiple_fields_str(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).on_conflict("id", "sub_id").do_nothing() + + self.assertEqual('INSERT INTO "abc" VALUES (1) ON CONFLICT ("id", "sub_id") DO NOTHING', str(query)) + + def test_insert_on_conflict_do_nothing_mixed_fields(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).on_conflict("id", self.table_abc.sub_id).do_nothing() + + self.assertEqual('INSERT INTO "abc" VALUES (1) ON CONFLICT ("id", "sub_id") DO NOTHING', str(query)) + + def test_insert_on_conflict_do_update_field(self): + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict(self.table_abc.id) + .do_update(self.table_abc.name, "m") + ) + + self.assertEqual( + "INSERT INTO \"abc\" VALUES (1,'m') ON CONFLICT (\"id\") DO UPDATE SET \"name\"='m'", + str(query), + ) + + def test_insert_on_conflict_do_update_multiple_fields(self): + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict(self.table_abc.id, self.table_abc.sub_id) + .do_update(self.table_abc.name, "m") + ) + + self.assertEqual( + "INSERT INTO \"abc\" VALUES (1,'m') ON CONFLICT (\"id\", \"sub_id\") DO UPDATE SET \"name\"='m'", + str(query), + ) + + def test_insert_on_conflict_do_update_field_str(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1, "m").on_conflict("id").do_update("name", "m") + + self.assertEqual( + "INSERT INTO \"abc\" VALUES (1,'m') ON CONFLICT (\"id\") DO UPDATE SET \"name\"='m'", + str(query), + ) + + def test_insert_on_conflict_do_update_multiple_fields_str(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1, "m").on_conflict("id", "sub_id").do_update("name", "m") + + self.assertEqual( + "INSERT INTO \"abc\" VALUES (1,'m') ON CONFLICT (\"id\", \"sub_id\") DO UPDATE SET \"name\"='m'", + str(query), + ) + + def test_insert_on_conflict_do_update_multiple_mixed_fields(self): + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict("id", self.table_abc.sub_id) + .do_update("name", "m") + ) + + self.assertEqual( + "INSERT INTO \"abc\" VALUES (1,'m') ON CONFLICT (\"id\", \"sub_id\") DO UPDATE SET \"name\"='m'", + str(query), + ) + + def test_insert_on_conflict_no_handler(self): + with self.assertRaises(QueryException): + query = str(PostgreSQLQuery.into(self.table_abc).insert(1).on_conflict(self.table_abc.id)) + + def test_insert_on_conflict_two_handlers_do_nothing(self): + with self.assertRaises(QueryException): + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1) + .on_conflict("id") + .do_nothing() + .do_update(self.table_abc.name, "m") + ) + + def test_insert_on_conflict_two_handlers_do_update(self): + with self.assertRaises(QueryException): + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1) + .on_conflict(self.table_abc.id) + .do_update(self.table_abc.name, "m") + .do_nothing() + ) + + def test_non_insert_on_conflict_do_nothing(self): + with self.assertRaises(QueryException): + query = PostgreSQLQuery.update(self.table_abc).set("foo", "bar").on_conflict("id").do_nothing() + + def test_non_insert_on_conflict_do_update(self): + with self.assertRaises(QueryException): + query = ( + PostgreSQLQuery.update(self.table_abc).set("foo", "bar").on_conflict("id").do_update(["name"], ["m"]) + ) + + def test_insert_on_fieldless_conflict_do_nothing(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).on_conflict(None).do_nothing() + + self.assertEqual('INSERT INTO "abc" VALUES (1) ON CONFLICT DO NOTHING', str(query)) + + def test_insert_on_fieldless_conflict_do_update_field(self): + with self.assertRaises(QueryException): + query = str( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict(None) + .do_update(self.table_abc.name, "m") + ) + + def test_on_conflict_from_subquery(self): + table_bcd = Table('bcd') + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(self.table_abc.fname, self.table_abc.lname) + .select(table_bcd.fname, table_bcd.lname) + .from_(table_bcd) + .on_conflict(self.table_abc.id, self.table_abc.sub_id) + .do_update(self.table_abc.fname, 1) + .do_update(self.table_abc.lname, table_bcd.lname) + .do_update( + self.table_abc.cname, + Case().when(self.table_abc.cname.eq('cname'), 'new_name').else_(self.table_abc.cname), + ) + ) + + self.assertEqual( + 'INSERT INTO "abc" VALUES ("fname","lname") ' + 'ON CONFLICT ("id", "sub_id") ' + 'DO UPDATE SET "fname"=1,"lname"="bcd"."lname",' + '"cname"=CASE WHEN "abc"."cname"=\'cname\' THEN \'new_name\' ELSE "abc"."cname" END', + str(query), + ) + + def test_on_conflict_where_empty_conflict_fields_do_nothing(self): + with self.assertRaises(QueryException): + ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict() + .where(self.table_abc.abc.eq(0)) + .where(self.table_abc.cde.eq(0)) + .do_nothing() + ) + + def test_on_conflict_where_conflict_fields_do_nothing(self): + qs = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict('id') + .where(self.table_abc.abc.eq(0)) + .where(self.table_abc.cde.eq(0)) + .do_nothing() + ) + self.assertEqual( + '''INSERT INTO "abc" VALUES (1,'m') ON CONFLICT ("id") WHERE "abc"=0 AND "cde"=0 DO NOTHING''', str(qs) + ) + + def test_on_conflict_where_empty_conflict_fields_do_update(self): + with self.assertRaises(QueryException): + ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict() + .where(self.table_abc.abc.eq(0)) + .where(self.table_abc.cde.eq(0)) + .do_update('field', 'val') + ) + + def test_on_conflict_where_conflict_fields_do_update(self): + qs = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict('id') + .where(self.table_abc.abc.eq(0)) + .where(self.table_abc.cde.eq(0)) + .do_update('field', 'val') + ) + self.assertEqual( + '''INSERT INTO "abc" VALUES (1,'m') ON CONFLICT ("id") WHERE "abc"=0 AND "cde"=0 ''' + '''DO UPDATE SET "field"='val\'''', + str(qs), + ) + + def test_where_and_on_conflict_where(self): + table_bcd = Table('bcd') + + qs = ( + PostgreSQLQuery.into(self.table_abc) + .select(table_bcd.abc) + .from_(table_bcd) + .where(table_bcd.abc.eq('1')) + .on_conflict('id') + .where(self.table_abc.abc.eq(0)) + .where(self.table_abc.cde.eq(0)) + .do_update('field', 'val') + ) + + self.assertEqual( + 'INSERT INTO "abc" SELECT "abc" FROM "bcd" WHERE "abc"=\'1\' ' + 'ON CONFLICT ("id") WHERE "abc"=0 AND "cde"=0 DO UPDATE SET "field"=\'val\'', + str(qs), + ) + + def test_on_conflict_do_nothing_where(self): + with self.assertRaises(QueryException): + ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict() + .do_nothing() + .where(self.table_abc.abc.eq(1)) + ) + + def test_empty_on_conflict_do_update_where(self): + with self.assertRaises(QueryException): + ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict() + .do_update('abc', 1) + .where(self.table_abc.abc.eq(1)) + ) + + def test_on_conflict_do_update_where(self): + qs = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict("id") + .do_update('abc', 1) + .where(self.table_abc.abc.eq(1)) + ) + self.assertEqual( + 'INSERT INTO "abc" VALUES (1,\'m\') ON CONFLICT ("id") DO UPDATE SET "abc"=1 WHERE "abc"."abc"=1', str(qs) + ) + + def test_on_conflict_do_update_with_excluded_where(self): + qs = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict("id") + .do_update('abc') + .where(self.table_abc.abc.eq(1)) + ) + self.assertEqual( + 'INSERT INTO "abc" VALUES (1,\'m\') ON CONFLICT ("id") DO UPDATE SET "abc"=EXCLUDED."abc" WHERE ' + '"abc"."abc"=1', + str(qs), + ) + + def test_on_conflict_where_complex(self): + table_bcd = Table('bcd') + + qs = ( + PostgreSQLQuery.into(self.table_abc) + .select(table_bcd.abc) + .from_(table_bcd) + .where(table_bcd.abc.eq('1')) + .on_conflict('id') + .where(self.table_abc.abc.eq(0)) + .where(self.table_abc.cde.eq(0)) + .do_update('field', 'val') + .where(self.table_abc.id.eq(2)) + .where(self.table_abc.sub_id.eq(3)) + ) + self.assertEqual( + 'INSERT INTO "abc" SELECT "abc" FROM "bcd" WHERE "abc"=\'1\' ' + 'ON CONFLICT ("id") WHERE "abc"=0 AND "cde"=0 ' + 'DO UPDATE SET "field"=\'val\' WHERE "abc"."id"=2 AND "abc"."sub_id"=3', + str(qs), + ) + + +class PostgresInsertIntoReturningTests(unittest.TestCase): + table_abc = Table("abc") + + def test_insert_returning_one_field(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).returning(self.table_abc.id) + + self.assertEqual('INSERT INTO "abc" VALUES (1) RETURNING "id"', str(query)) + + def test_insert_returning_one_field_str(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).returning("id") + + self.assertEqual('INSERT INTO "abc" VALUES (1) RETURNING "id"', str(query)) + + def test_insert_returning_all_fields(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).returning(self.table_abc.star) + + self.assertEqual('INSERT INTO "abc" VALUES (1) RETURNING *', str(query)) + + def test_insert_returning_all_fields_and_arithmetics(self): + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1) + .returning(self.table_abc.star, self.table_abc.f1 + self.table_abc.f2) + ) + + self.assertEqual('INSERT INTO "abc" VALUES (1) RETURNING *,"f1"+"f2"', str(query)) + + def test_insert_all_columns_multi_rows_chained_returning_star(self): + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "a", True) + .insert(2, "b", False) + .returning(self.table_abc.star) + ) + + self.assertEqual( + "INSERT INTO \"abc\" VALUES (1,'a',true),(2,'b',false) RETURNING *", + str(query), + ) + + def test_insert_all_columns_multi_rows_chained_returning_star_and_id(self): + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "a", True) + .insert(2, "b", False) + .returning( + self.table_abc.name, + self.table_abc.star, + self.table_abc.id, + ) + ) + + self.assertEqual( + "INSERT INTO \"abc\" VALUES (1,'a',true),(2,'b',false) RETURNING *", + str(query), + ) + + def test_insert_all_columns_multi_rows_chained_returning_star_str(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1, "a", True).insert(2, "b", False).returning("*") + + self.assertEqual( + "INSERT INTO \"abc\" VALUES (1,'a',true),(2,'b',false) RETURNING *", + str(query), + ) + + def test_insert_all_columns_single_element_arrays(self): + query = PostgreSQLQuery.into(self.table_abc).insert((1, "a", True)).returning(self.table_abc.star) + + self.assertEqual("INSERT INTO \"abc\" VALUES (1,'a',true) RETURNING *", str(query)) + + def test_insert_returning_null(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).returning(None) + + self.assertEqual('INSERT INTO "abc" VALUES (1) RETURNING NULL', str(query)) + + def test_insert_returning_tuple(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).returning((1, 2, 3)) + + self.assertEqual('INSERT INTO "abc" VALUES (1) RETURNING (1,2,3)', str(query)) + + def test_insert_returning_arithmetics(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).returning(self.table_abc.f1 + self.table_abc.f2) + + self.assertEqual('INSERT INTO "abc" VALUES (1) RETURNING "f1"+"f2"', str(query)) + + def test_insert_returning_functions(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).returning(Cast(self.table_abc.f1, "int")) + + self.assertEqual('INSERT INTO "abc" VALUES (1) RETURNING CAST("f1" AS INT)', str(query)) + + def test_insert_returning_aggregate(self): + with self.assertRaises(QueryException): + PostgreSQLQuery.into(self.table_abc).insert(1).returning(Avg(self.table_abc.views)) + + def test_insert_returning_from_other_table(self): + table_cba = Table("cba") + with self.assertRaises(QueryException): + PostgreSQLQuery.into(self.table_abc).insert(1).returning(table_cba.id) + + +class InsertIntoOnDuplicateTests(unittest.TestCase): + table_abc = Table("abc") + + def test_insert_one_column(self): + query = ( + MySQLQuery.into(self.table_abc).insert(1).on_duplicate_key_update(self.table_abc.foo, self.table_abc.foo) + ) + self.assertEqual( + "INSERT INTO `abc` VALUES (1) ON DUPLICATE KEY UPDATE `foo`=`foo`", + str(query), + ) + + def test_insert_one_column_using_values(self): + query = ( + MySQLQuery.into(self.table_abc) + .insert(1) + .on_duplicate_key_update(self.table_abc.foo, Values(self.table_abc.foo)) + ) + self.assertEqual( + "INSERT INTO `abc` VALUES (1) ON DUPLICATE KEY UPDATE `foo`=VALUES(`foo`)", + str(query), + ) + + def test_insert_one_column_single_element_array(self): + query = ( + MySQLQuery.into(self.table_abc).insert((1,)).on_duplicate_key_update(self.table_abc.foo, self.table_abc.foo) + ) + + self.assertEqual( + "INSERT INTO `abc` VALUES (1) ON DUPLICATE KEY UPDATE `foo`=`foo`", + str(query), + ) + + def test_insert_one_column_multi_element_array(self): + query = ( + MySQLQuery.into(self.table_abc) + .insert((1,), (2,)) + .on_duplicate_key_update(self.table_abc.foo, self.table_abc.foo) + ) + + self.assertEqual( + "INSERT INTO `abc` VALUES (1),(2) ON DUPLICATE KEY UPDATE `foo`=`foo`", + str(query), + ) + + def test_insert_multiple_columns_on_duplicate_update_one_with_same_value(self): + query = ( + MySQLQuery.into(self.table_abc) + .insert(1, "a") + .on_duplicate_key_update(self.table_abc.bar, Values(self.table_abc.bar)) + ) + + self.assertEqual( + "INSERT INTO `abc` VALUES (1,'a') ON DUPLICATE KEY UPDATE `bar`=VALUES(`bar`)", + str(query), + ) + + def test_insert_multiple_columns_on_duplicate_update_one_with_different_value(self): + query = MySQLQuery.into(self.table_abc).insert(1, "a").on_duplicate_key_update(self.table_abc.bar, "b") + + self.assertEqual( + "INSERT INTO `abc` VALUES (1,'a') ON DUPLICATE KEY UPDATE `bar`='b'", + str(query), + ) + + def test_insert_multiple_columns_on_duplicate_update_one_with_expression(self): + query = ( + MySQLQuery.into(self.table_abc).insert(1, 2).on_duplicate_key_update(self.table_abc.bar, 4 + F("bar")) + ) # todo sql expression? not python + + self.assertEqual( + "INSERT INTO `abc` VALUES (1,2) ON DUPLICATE KEY UPDATE `bar`=4+`bar`", + str(query), + ) + + def test_insert_multiple_columns_on_duplicate_update_one_with_expression_using_original_field_value( + self, + ): + query = ( + MySQLQuery.into(self.table_abc) + .insert(1, "a") + .on_duplicate_key_update(self.table_abc.bar, fn.Concat(self.table_abc.bar, "update")) + ) + + self.assertEqual( + "INSERT INTO `abc` VALUES (1,'a') ON DUPLICATE KEY UPDATE `bar`=CONCAT(`bar`,'update')", + str(query), + ) + + def test_insert_multiple_columns_on_duplicate_update_one_with_expression_using_values( + self, + ): + query = ( + MySQLQuery.into(self.table_abc) + .insert(1, "a") + .on_duplicate_key_update(self.table_abc.bar, fn.Concat(Values(self.table_abc.bar), "update")) + ) + + self.assertEqual( + "INSERT INTO `abc` VALUES (1,'a') ON DUPLICATE KEY UPDATE `bar`=CONCAT(VALUES(`bar`),'update')", + str(query), + ) + + def test_insert_multiple_columns_on_duplicate_update_multiple(self): + query = ( + MySQLQuery.into(self.table_abc) + .insert(1, "a", "b") + .on_duplicate_key_update(self.table_abc.bar, "b") + .on_duplicate_key_update(self.table_abc.baz, "c") + ) + + self.assertEqual( + "INSERT INTO `abc` VALUES (1,'a','b') ON DUPLICATE KEY UPDATE `bar`='b',`baz`='c'", + str(query), + ) + + def test_insert_multi_rows_chained_mixed_on_duplicate_update_multiple(self): + query = ( + MySQLQuery.into(self.table_abc) + .insert((1, "a", True), (2, "b", False)) + .insert(3, "c", True) + .on_duplicate_key_update(self.table_abc.foo, self.table_abc.foo) + .on_duplicate_key_update(self.table_abc.bar, Values(self.table_abc.bar)) + ) + + self.assertEqual( + "INSERT INTO `abc` VALUES (1,'a',true),(2,'b',false),(3,'c',true) " + "ON DUPLICATE KEY UPDATE `foo`=`foo`,`bar`=VALUES(`bar`)", + str(query), + ) + + def test_insert_selected_columns_on_duplicate_update_one(self): + query = ( + MySQLQuery.into(self.table_abc) + .columns(self.table_abc.foo, self.table_abc.bar, self.table_abc.baz) + .insert(1, "a", True) + .on_duplicate_key_update(self.table_abc.baz, False) + ) + + self.assertEqual( + "INSERT INTO `abc` (`foo`,`bar`,`baz`) VALUES (1,'a',true) ON DUPLICATE KEY UPDATE `baz`=false", + str(query), + ) + + def test_insert_selected_columns_on_duplicate_update_multiple(self): + query = ( + MySQLQuery.into(self.table_abc) + .columns(self.table_abc.foo, self.table_abc.bar, self.table_abc.baz) + .insert(1, "a", True) + .on_duplicate_key_update(self.table_abc.baz, False) + .on_duplicate_key_update(self.table_abc.bar, Values(self.table_abc.bar)) + ) + + self.assertEqual( + "INSERT INTO `abc` (`foo`,`bar`,`baz`) VALUES (1,'a',true) " + "ON DUPLICATE KEY UPDATE `baz`=false,`bar`=VALUES(`bar`)", + str(query), + ) + + def test_insert_none_skipped(self): + query = MySQLQuery.into(self.table_abc).insert().on_duplicate_key_update(self.table_abc.baz, False) + + self.assertEqual("", str(query)) + + def test_insert_ignore(self): + query = MySQLQuery.into(self.table_abc).insert(1).ignore().on_duplicate_key_update(self.table_abc.baz, False) + + self.assertEqual( + "INSERT IGNORE INTO `abc` VALUES (1) ON DUPLICATE KEY UPDATE `baz`=false", + str(query), + ) + + +class InsertSelectFromTests(unittest.TestCase): + table_abc, table_efg, table_hij = Tables("abc", "efg", "hij") + + def test_insert_star(self): + query = Query.into(self.table_abc).from_(self.table_efg).select("*") + + self.assertEqual('INSERT INTO "abc" SELECT * FROM "efg"', str(query)) + + def test_insert_ignore_star(self): + query = Query.into(self.table_abc).from_(self.table_efg).select("*").ignore() + + self.assertEqual('INSERT IGNORE INTO "abc" SELECT * FROM "efg"', str(query)) + + def test_insert_from_columns(self): + query = ( + Query.into(self.table_abc) + .from_(self.table_efg) + .select(self.table_efg.fiz, self.table_efg.buz, self.table_efg.baz) + ) + + self.assertEqual('INSERT INTO "abc" ' 'SELECT "fiz","buz","baz" FROM "efg"', str(query)) + + def test_insert_columns_from_star(self): + query = ( + Query.into(self.table_abc) + .columns( + self.table_abc.foo, + self.table_abc.bar, + self.table_abc.buz, + ) + .from_(self.table_efg) + .select("*") + ) + + self.assertEqual('INSERT INTO "abc" ("foo","bar","buz") ' 'SELECT * FROM "efg"', str(query)) + + def test_insert_columns_from_columns(self): + query = ( + Query.into(self.table_abc) + .columns(self.table_abc.foo, self.table_abc.bar, self.table_abc.buz) + .from_(self.table_efg) + .select(self.table_efg.fiz, self.table_efg.buz, self.table_efg.baz) + ) + + self.assertEqual( + 'INSERT INTO "abc" ("foo","bar","buz") ' 'SELECT "fiz","buz","baz" FROM "efg"', + str(query), + ) + + def test_insert_columns_from_columns_with_join(self): + query = ( + Query.into(self.table_abc) + .columns( + self.table_abc.c1, + self.table_abc.c2, + self.table_abc.c3, + self.table_abc.c4, + ) + .from_(self.table_efg) + .select(self.table_efg.foo, self.table_efg.bar) + .join(self.table_hij) + .on(self.table_efg.id == self.table_hij.abc_id) + .select(self.table_hij.fiz, self.table_hij.buz) + ) + + self.assertEqual( + 'INSERT INTO "abc" ("c1","c2","c3","c4") ' + 'SELECT "efg"."foo","efg"."bar","hij"."fiz","hij"."buz" FROM "efg" ' + 'JOIN "hij" ON "efg"."id"="hij"."abc_id"', + str(query), + ) + + +class InsertSubqueryTests(unittest.TestCase): + def test_insert_subquery_wrapped_in_brackets(self): + purchase_order_item, part = Tables("purchase_order_item", "part") + + q = ( + Query.into(purchase_order_item) + .columns(purchase_order_item.id_part, purchase_order_item.id_customer) + .insert( + Query.from_(part).select(part.part_id).where(part.part_number == "FOOBAR"), + 12345, + ) + ) + + self.assertEqual( + 'INSERT INTO "purchase_order_item" ' + '("id_part","id_customer") ' + "VALUES " + '((SELECT "part_id" FROM "part" WHERE "part_number"=\'FOOBAR\'),12345)', + str(q), + ) + + +class SelectIntoTests(unittest.TestCase): + table_abc, table_efg, table_hij = Tables("abc", "efg", "hij") + + def test_select_star_into(self): + query = Query.from_(self.table_abc).select("*").into(self.table_efg) + + self.assertEqual('SELECT * INTO "efg" FROM "abc"', str(query)) + + def test_select_columns_into(self): + query = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, self.table_abc.bar, self.table_abc.buz) + .into(self.table_efg) + ) + + self.assertEqual('SELECT "foo","bar","buz" INTO "efg" FROM "abc"', str(query)) + + def test_select_columns_into_with_join(self): + query = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, self.table_abc.bar) + .join(self.table_hij) + .on(self.table_abc.id == self.table_hij.abc_id) + .select(self.table_hij.fiz, self.table_hij.buz) + .into(self.table_efg) + ) + + self.assertEqual( + 'SELECT "abc"."foo","abc"."bar","hij"."fiz","hij"."buz" ' + 'INTO "efg" FROM "abc" ' + 'JOIN "hij" ON "abc"."id"="hij"."abc_id"', + str(query), + ) + + +class ReplaceTests(unittest.TestCase): + table_abc, table_def = Tables("abc", "efg") + + def test_replace_simple(self): + query = Query.into(self.table_abc).replace("v1", "v2", "v3") + expected_output = "REPLACE INTO \"abc\" VALUES ('v1','v2','v3')" + self.assertEqual(str(query), expected_output) + + def test_replace_subquery(self): + query = Query.into(self.table_abc).replace(Query.from_(self.table_def).select("f1", "f2")) + expected_output = 'REPLACE INTO "abc" VALUES ((SELECT "f1","f2" FROM "efg"))' + self.assertEqual(str(query), expected_output) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/test_internals.py b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/test_internals.py new file mode 100644 index 0000000000000000000000000000000000000000..921e381ba8613d4a83cc53bd60d111d9547e2c1f --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/test_internals.py @@ -0,0 +1,35 @@ +import unittest + +from pypika import ( + Case, + Field, + Table, +) +from pypika.terms import Star + + +class TablesTests(unittest.TestCase): + def test__criterion_replace_table_with_value(self): + table = Table("a") + + c = (Field("foo") > 1).replace_table(None, table) + self.assertEqual(c.left, table) + self.assertEqual(c.tables_, {table}) + + def test__case_tables(self): + table = Table("a") + + c = Case().when(table.a == 1, 2 * table.a) + self.assertIsInstance(c.tables_, set) + self.assertSetEqual(c.tables_, {table}) + + def test__star_tables(self): + star = Star() + + self.assertEqual(star.tables_, set()) + + def test__table_star_tables(self): + table = Table("a") + star = Star(table=table) + + self.assertEqual(star.tables_, {table}) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/test_joins.py b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/test_joins.py new file mode 100644 index 0000000000000000000000000000000000000000..03142d583921edbe966e0ae191d254e7b8bf46ba --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/test_joins.py @@ -0,0 +1,1168 @@ +import unittest + +from pypika import ( + Field, + Interval, + JoinException, + JoinType, + MySQLQuery, + Query, + SetOperationException, + Table, + Tables, + functions as fn, + SYSTEM_TIME, +) + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + + +class SelectQueryJoinTests(unittest.TestCase): + table0, table1, hij = Tables("abc", "efg", "hij") + + def test_default_join_type(self): + query = Query.from_(self.table0).join(self.table1).on(self.table0.foo == self.table1.bar).select("*") + + self.assertEqual('SELECT * FROM "abc" JOIN "efg" ON "abc"."foo"="efg"."bar"', str(query)) + + def test_inner_join(self): + expected = 'SELECT * FROM "abc" JOIN "efg" ON "abc"."foo"="efg"."bar"' + + with self.subTest("join with enum"): + query = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.inner) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + self.assertEqual(expected, str(query)) + + with self.subTest("join function"): + query = Query.from_(self.table0).inner_join(self.table1).on(self.table0.foo == self.table1.bar).select("*") + self.assertEqual(expected, str(query)) + + def test_left_join(self): + expected = 'SELECT * FROM "abc" LEFT JOIN "efg" ON "abc"."foo"="efg"."bar"' + + with self.subTest("join with enum"): + query = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.left) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + + self.assertEqual(expected, str(query)) + + with self.subTest("join function"): + query = Query.from_(self.table0).left_join(self.table1).on(self.table0.foo == self.table1.bar).select("*") + self.assertEqual(expected, str(query)) + + def test_right_join(self): + expected = 'SELECT * FROM "abc" RIGHT JOIN "efg" ON "abc"."foo"="efg"."bar"' + + with self.subTest("join with enum"): + query = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.right) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + + self.assertEqual(expected, str(query)) + + with self.subTest("join function"): + query = Query.from_(self.table0).right_join(self.table1).on(self.table0.foo == self.table1.bar).select("*") + self.assertEqual(expected, str(query)) + + def test_hash_join(self): + expected = 'SELECT * FROM "abc" HASH JOIN "efg" ON "abc"."foo"="efg"."bar"' + + with self.subTest("join with enum"): + query = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.hash) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + + self.assertEqual(expected, str(query)) + + with self.subTest("join function"): + query = Query.from_(self.table0).hash_join(self.table1).on(self.table0.foo == self.table1.bar).select("*") + self.assertEqual(expected, str(query)) + + def test_outer_join(self): + expected = 'SELECT * FROM "abc" FULL OUTER JOIN "efg" ON "abc"."foo"="efg"."bar"' + + with self.subTest("join with enum"): + query = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.outer) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + + self.assertEqual(expected, str(query)) + + with self.subTest("join function"): + query = Query.from_(self.table0).outer_join(self.table1).on(self.table0.foo == self.table1.bar).select("*") + self.assertEqual(expected, str(query)) + + def test_cross_join(self): + expected = 'SELECT * FROM "abc" CROSS JOIN "efg" ON "abc"."foo"="efg"."bar"' + + with self.subTest("join with enum"): + query = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.cross) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + + self.assertEqual(expected, str(query)) + + with self.subTest("join function"): + query = Query.from_(self.table0).cross_join(self.table1).on(self.table0.foo == self.table1.bar).select("*") + self.assertEqual(expected, str(query)) + + def test_left_outer_join(self): + expected = 'SELECT * FROM "abc" LEFT OUTER JOIN "efg" ON "abc"."foo"="efg"."bar"' + with self.subTest("join with enum"): + query = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.left_outer) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + + self.assertEqual(expected, str(query)) + + with self.subTest("join function"): + query = ( + Query.from_(self.table0).left_outer_join(self.table1).on(self.table0.foo == self.table1.bar).select("*") + ) + + self.assertEqual(expected, str(query)) + + def test_right_outer_join(self): + expected = 'SELECT * FROM "abc" RIGHT OUTER JOIN "efg" ON "abc"."foo"="efg"."bar"' + with self.subTest("join with enum"): + query = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.right_outer) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + + self.assertEqual(expected, str(query)) + + with self.subTest("join function"): + query = ( + Query.from_(self.table0) + .right_outer_join(self.table1) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + + self.assertEqual(expected, str(query)) + + def test_full_outer_join(self): + expected = 'SELECT * FROM "abc" FULL OUTER JOIN "efg" ON "abc"."foo"="efg"."bar"' + + with self.subTest("join with enum"): + query = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.full_outer) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + + self.assertEqual(expected, str(query)) + + with self.subTest("join function"): + query = ( + Query.from_(self.table0).full_outer_join(self.table1).on(self.table0.foo == self.table1.bar).select("*") + ) + + self.assertEqual(expected, str(query)) + + def test_join_on_field_single(self): + query = Query.from_(self.table0).join(self.table1).on_field("foo").select("*") + self.assertEqual('SELECT * FROM "abc" JOIN "efg" ON "abc"."foo"="efg"."foo"', str(query)) + + def test_join_on_field_multi(self): + query = Query.from_(self.table0).join(self.table1).on_field("foo", "bar").select("*") + self.assertEqual( + 'SELECT * FROM "abc" JOIN "efg" ON "abc"."foo"="efg"."foo" ' 'AND "abc"."bar"="efg"."bar"', + str(query), + ) + + def test_join_on_field_multi_with_extra_join(self): + query = ( + Query.from_(self.table0) + .join(self.hij) + .on_field("buzz") + .join(self.table1) + .on_field("foo", "bar") + .select("*") + ) + + self.assertEqual( + 'SELECT * FROM "abc" JOIN "hij" ON "abc"."buzz"="hij"."buzz" ' + 'JOIN "efg" ON "abc"."foo"="efg"."foo" AND "abc"."bar"="efg"."bar"', + str(query), + ) + + def test_join_using_string_field_name(self): + query = Query.from_(self.table0).join(self.table1).using("id").select("*") + + self.assertEqual('SELECT * FROM "abc" JOIN "efg" USING ("id")', str(query)) + + def test_join_using_multiple_fields(self): + query = Query.from_(self.table0).join(self.table1).using("foo", "bar").select("*") + + self.assertEqual('SELECT * FROM "abc" JOIN "efg" USING ("foo","bar")', str(query)) + + def test_join_using_with_quote_char(self): + query = Query.from_(self.table0).join(self.table1).using("foo", "bar").select("*") + + self.assertEqual("SELECT * FROM abc JOIN efg USING (foo,bar)", query.get_sql(quote_char="")) + + def test_join_using_without_fields_raises_exception(self): + with self.assertRaises(JoinException): + Query.from_(self.table0).join(self.table1).using() + + def test_join_on_field_without_fields_raises_exception(self): + with self.assertRaises(JoinException): + Query.from_(self.table0).join(self.table1).on_field() + + def test_join_arithmetic_field(self): + q = ( + Query.from_(self.table0) + .join(self.table1) + .on(self.table0.dt == (self.table1.dt - Interval(weeks=1))) + .select("*") + ) + + self.assertEqual( + 'SELECT * FROM "abc" ' 'JOIN "efg" ON "abc"."dt"="efg"."dt"-INTERVAL \'1 WEEK\'', + str(q), + ) + + def test_join_with_arithmetic_function_in_select(self): + q = ( + Query.from_( + self.table0, + ) + .join(self.table1) + .on(self.table0.dt == (self.table1.dt - Interval(weeks=1))) + .select(self.table0.fiz - self.table0.buz, self.table1.star) + ) + + self.assertEqual( + 'SELECT "abc"."fiz"-"abc"."buz","efg".* FROM "abc" ' + 'JOIN "efg" ON "abc"."dt"="efg"."dt"-INTERVAL \'1 WEEK\'', + str(q), + ) + + def test_join_on_complex_criteria(self): + q = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.right) + .on((self.table0.foo == self.table1.fiz) & (self.table0.bar == self.table1.buz)) + .select("*") + ) + + self.assertEqual( + 'SELECT * FROM "abc" ' 'RIGHT JOIN "efg" ON "abc"."foo"="efg"."fiz" AND "abc"."bar"="efg"."buz"', + str(q), + ) + + def test_join_on_subquery_criteria(self): + table_a, table_b, table_c = Tables("a", "b", "c") + subquery = Query.from_(table_c).select("id").limit(1) + query = ( + Query.from_(table_a).select("*").join(table_b).on((table_a.b_id == table_b.id) & (table_b.c_id == subquery)) + ) + + self.assertEqual( + "SELECT * " 'FROM "a" ' 'JOIN "b" ON "a"."b_id"="b"."id" AND "b"."c_id"=' '(SELECT "id" FROM "c" LIMIT 1)', + str(query), + ) + + def test_use_different_table_objects_for_same_table(self): + table = Table("t") + q = Query.from_(table).select("*").where(Field("id", table=table) == 1) + + self.assertEqual('SELECT * FROM "t" WHERE "id"=1', str(q)) + + def test_join_second_table_in_from_clause(self): + table_a, table_b, table_c = Tables("a", "b", "c") + q = Query.from_(table_a).from_(table_b).select("*").join(table_c).on(table_b.c_id == table_c.id) + + self.assertEqual("SELECT * " 'FROM "a","b" ' 'JOIN "c" ON "b"."c_id"="c"."id"', str(q)) + + def test_cross_join_on_table(self): + table_a, table_b = Tables("a", "b") + q = Query.from_(table_a).join(table_b).cross().select("*") + + self.assertEqual('SELECT * FROM "a" CROSS JOIN "b"', str(q)) + + def test_cross_join_on_subquery(self): + table_a, table_b = Tables("a", "b") + q_a = Query.from_(table_a).select("*") + q_b = Query.from_(table_b).select("*").join(q_a).cross().select("*") + + self.assertEqual('SELECT * FROM "b" CROSS JOIN (SELECT * FROM "a") "sq0"', str(q_b)) + + def test_join_on_collate(self): + table_a, table_b = Tables("a", "b") + + q1 = ( + Query.from_(table_a) + .select(table_b.ouch) + .join(table_b) + .on(table_a.foo == table_b.boo, collate="utf8_general_ci") + ) + q2 = Query.from_(table_a).select(table_b.ouch).join(table_b).on(table_a.foo == table_b.boo) + + self.assertEqual( + 'SELECT "b"."ouch" FROM "a" JOIN "b" ON "a"."foo"="b"."boo" COLLATE utf8_general_ci', + str(q1), + ) + self.assertEqual('SELECT "b"."ouch" FROM "a" JOIN "b" ON "a"."foo"="b"."boo"', str(q2)) + + def test_temporal_join(self): + t0 = self.table0.for_(SYSTEM_TIME.as_of('2020-01-01')) + t1 = self.table1.for_(SYSTEM_TIME.as_of('2020-01-01')) + query = Query.from_(t0).join(t1).on(t0.foo == t1.bar).select("*") + + self.assertEqual( + 'SELECT * FROM "abc" FOR SYSTEM_TIME AS OF \'2020-01-01\' ' + 'JOIN "efg" FOR SYSTEM_TIME AS OF \'2020-01-01\' ' + 'ON "abc"."foo"="efg"."bar"', + str(query), + ) + + +class JoinBehaviorTests(unittest.TestCase): + table_abc, table_efg, table_hij, table_klm = Tables("abc", "efg", "hij", "klm") + + def test_select__ordered_select_clauses(self): + q = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .select( + self.table_abc.baz, + self.table_efg.buz, + self.table_abc.fiz, + self.table_efg.bam, + ) + ) + + self.assertEqual( + 'SELECT "abc"."baz","efg"."buz","abc"."fiz","efg"."bam" FROM "abc" ' + 'JOIN "efg" ON "abc"."foo"="efg"."bar"', + str(q), + ) + + def test_select__star_for_table(self): + q = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .join(self.table_hij) + .on(self.table_abc.buz == self.table_hij.bam) + .select(self.table_abc.star) + .select(self.table_efg.star) + .select(self.table_hij.star) + ) + + self.assertEqual( + 'SELECT "abc".*,"efg".*,"hij".* FROM "abc" ' + 'JOIN "efg" ON "abc"."foo"="efg"."bar" ' + 'JOIN "hij" ON "abc"."buz"="hij"."bam"', + str(q), + ) + + def test_select__star_for_table__replacement(self): + q = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .join(self.table_hij) + .on(self.table_abc.buz == self.table_hij.bam) + .select(self.table_abc.foo, self.table_efg.bar, self.table_hij.bam) + .select(self.table_abc.star, self.table_efg.star, self.table_hij.star) + ) + + self.assertEqual( + 'SELECT "abc".*,"efg".*,"hij".* FROM "abc" ' + 'JOIN "efg" ON "abc"."foo"="efg"."bar" ' + 'JOIN "hij" ON "abc"."buz"="hij"."bam"', + str(q), + ) + + def test_select_fields_with_where(self): + q = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .join(self.table_hij) + .on(self.table_abc.buz == self.table_hij.bam) + .select(self.table_abc.foo, self.table_efg.bar, self.table_hij.bam) + .where(self.table_abc.foo > 1) + .where(self.table_efg.bar != 2) + ) + + self.assertEqual( + 'SELECT "abc"."foo","efg"."bar","hij"."bam" FROM "abc" ' + 'JOIN "efg" ON "abc"."foo"="efg"."bar" ' + 'JOIN "hij" ON "abc"."buz"="hij"."bam" ' + 'WHERE "abc"."foo">1 AND "efg"."bar"<>2', + str(q), + ) + + def test_require_condition(self): + with self.assertRaises(JoinException): + Query.from_(self.table_abc).join(self.table_efg).on(None) + + def test_require_condition_with_both_tables(self): + with self.assertRaises(JoinException): + Query.from_(self.table_abc).join(self.table_efg).on(self.table_abc.foo == self.table_hij.bar) + + with self.assertRaises(JoinException): + Query.from_(self.table_abc).join(self.table_efg).on(self.table_hij.foo == self.table_efg.bar) + + with self.assertRaises(JoinException): + Query.from_(self.table_abc).join(self.table_efg).on(self.table_hij.foo == self.table_klm.bar) + + def test_join_same_table(self): + table1 = Table("abc") + table2 = Table("abc") + q = Query.from_(table1).join(table2).on(table1.foo == table2.bar).select(table1.foo, table2.buz) + + self.assertEqual( + 'SELECT "abc"."foo","abc2"."buz" FROM "abc" ' 'JOIN "abc" "abc2" ON "abc"."foo"="abc2"."bar"', + str(q), + ) + + def test_join_same_table_with_prefixes(self): + table1 = Table("abc").as_("x") + table2 = Table("abc").as_("y") + q = Query.from_(table1).join(table2).on(table1.foo == table2.bar).select(table1.foo, table2.buz) + + self.assertEqual( + 'SELECT "x"."foo","y"."buz" FROM "abc" "x" ' 'JOIN "abc" "y" ON "x"."foo"="y"."bar"', + str(q), + ) + + def test_join_table_twice(self): + table1, table2 = Table("efg").as_("efg1"), Table("efg").as_("efg2") + q = ( + Query.from_(self.table_abc) + .join(table1) + .on(self.table_abc.foo == table1.bar) + .join(table2) + .on(self.table_abc.foo == table2.bam) + .select(self.table_abc.foo, table1.fiz, table2.buz) + ) + + self.assertEqual( + 'SELECT "abc"."foo","efg1"."fiz","efg2"."buz" FROM "abc" ' + 'JOIN "efg" "efg1" ON "abc"."foo"="efg1"."bar" ' + 'JOIN "efg" "efg2" ON "abc"."foo"="efg2"."bam"', + str(q), + ) + + def test_select__fields_after_table_star(self): + q = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .select(self.table_abc.star, self.table_efg.bar) + .select(self.table_abc.foo) + ) + + self.assertEqual( + 'SELECT "abc".*,"efg"."bar" FROM "abc" JOIN "efg" ON "abc"."foo"="efg"."bar"', + str(q), + ) + + def test_fail_when_joining_unknown_type(self): + with self.assertRaises(ValueError): + Query.from_(self.table_abc).join("this is a string") + + def test_immutable__tables(self): + query1 = Query.from_(self.table_abc).select(self.table_abc.foo) + query2 = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .select(self.table_abc.foo, self.table_efg.buz) + ) + + self.assertEqual( + 'SELECT "abc"."foo","efg"."buz" FROM "abc" ' 'JOIN "efg" ON "abc"."foo"="efg"."bar"', + str(query2), + ) + self.assertEqual('SELECT "foo" FROM "abc"', str(query1)) + + def test_select_field_from_missing_table(self): + """ + Previously we validated the select field was a member of a table + in the query (e.g. FROM clause or a JOIN). However this made + correlated subqueries awkward to write (subqueries which refer + to their parent table. So the validation was removed. + + None of the following raise an error. Previously raised JoinException + """ + Query.from_(self.table_abc).select(self.table_efg.foo) + + Query.from_(self.table_abc).where(self.table_efg.foo == 0) + + Query.from_(self.table_abc).where(fn.Sum(self.table_efg.foo) == 0) + + Query.from_(self.table_abc).select(fn.Sum(self.table_abc.bar * 2) + fn.Sum(self.table_efg.foo * 2)) + + Query.from_(self.table_abc).groupby(self.table_efg.foo) + + Query.from_(self.table_abc).groupby(self.table_abc.foo).having(self.table_efg.bar) + + subquery = ( + Query.from_(self.table_efg).select(self.table_efg.id).where(self.table_efg.abc_id == self.table_abc.id) + ) + query = Query.from_(self.table_abc).select(subquery.as_("efg_id").limit(1)) + self.assertEqual( + 'SELECT (SELECT "efg"."id" FROM "efg" WHERE "efg"."abc_id"="abc"."id" LIMIT 1) "efg_id" FROM "abc"', + str(query), + ) + + def test_ignore_table_references(self): + query = Query.from_(Table("abc")).select(Table("abc").foo) + + self.assertEqual('SELECT "foo" FROM "abc"', str(query)) + + def test_prefixes_added_to_groupby(self): + test_query = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .select(self.table_abc.foo, fn.Sum(self.table_efg.buz)) + .groupby(self.table_abc.foo) + ) + + self.assertEqual( + 'SELECT "abc"."foo",SUM("efg"."buz") FROM "abc" ' + 'JOIN "efg" ON "abc"."foo"="efg"."bar" ' + 'GROUP BY "abc"."foo"', + str(test_query), + ) + + def test_prefixes_added_to_orderby(self): + test_query = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .select(self.table_abc.foo, self.table_efg.buz) + .orderby(self.table_abc.foo) + ) + + self.assertEqual( + 'SELECT "abc"."foo","efg"."buz" FROM "abc" ' + 'JOIN "efg" ON "abc"."foo"="efg"."bar" ' + 'ORDER BY "abc"."foo"', + str(test_query), + ) + + def test_prefixes_added_to_function_in_orderby(self): + test_query = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .select(self.table_abc.foo, self.table_efg.buz) + .orderby(fn.Date(self.table_abc.foo)) + ) + + self.assertEqual( + 'SELECT "abc"."foo","efg"."buz" FROM "abc" ' + 'JOIN "efg" ON "abc"."foo"="efg"."bar" ' + 'ORDER BY DATE("abc"."foo")', + str(test_query), + ) + + def test_join_from_join(self): + test_query = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.efg_id == self.table_efg.id) + .join(self.table_hij) + .on(self.table_efg.hij_id == self.table_hij.id) + .select(self.table_abc.foo, self.table_efg.bar, self.table_hij.fizz) + ) + + self.assertEqual( + 'SELECT "abc"."foo","efg"."bar","hij"."fizz" FROM "abc" ' + 'JOIN "efg" ON "abc"."efg_id"="efg"."id" ' + 'JOIN "hij" ON "efg"."hij_id"="hij"."id"', + str(test_query), + ) + + def test_join_query_without_alias(self): + subquery = Query.from_(self.table_efg).select( + self.table_efg.base_id.as_("x"), self.table_efg.fizz, self.table_efg.buzz + ) + + test_query = ( + Query.from_(self.table_abc) + .join(subquery) + .on(subquery.x == self.table_abc.id) + .select(self.table_abc.foo, subquery.fizz, subquery.buzz) + ) + + self.assertEqual( + 'SELECT "abc"."foo","sq0"."fizz","sq0"."buzz" ' + 'FROM "abc" JOIN (' + 'SELECT "base_id" "x","fizz","buzz" FROM "efg"' + ') "sq0" ' + 'ON "sq0"."x"="abc"."id"', + str(test_query), + ) + + def test_join_query_with_column_alias(self): + subquery = ( + Query.from_(self.table_efg) + .select( + self.table_efg.base_id.as_("x"), + self.table_efg.fizz, + self.table_efg.buzz, + ) + .as_("subq") + ) + + test_query = ( + Query.from_(self.table_abc) + .join(subquery) + .on(subquery.x == self.table_abc.id) + .select(self.table_abc.foo, subquery.fizz, subquery.buzz) + ) + + self.assertEqual( + 'SELECT "abc"."foo","subq"."fizz","subq"."buzz" ' + 'FROM "abc" JOIN (' + 'SELECT "base_id" "x","fizz","buzz" FROM "efg"' + ') "subq" ' + 'ON "subq"."x"="abc"."id"', + str(test_query), + ) + + def test_join_query_with_table_alias(self): + xxx = self.table_efg.as_("xxx") + subquery = Query.from_(xxx).select(xxx.base_id, xxx.fizz, xxx.buzz).as_("subq") + + test_query = ( + Query.from_(self.table_abc) + .join(subquery) + .on(subquery.x == self.table_abc.id) + .select(self.table_abc.foo, subquery.fizz, subquery.buzz) + ) + + self.assertEqual( + 'SELECT "abc"."foo","subq"."fizz","subq"."buzz" ' + 'FROM "abc" JOIN (' + 'SELECT "xxx"."base_id","xxx"."fizz","xxx"."buzz" FROM "efg" "xxx"' + ') "subq" ' + 'ON "subq"."x"="abc"."id"', + str(test_query), + ) + + def test_join_query_with_setoperation(self): + subquery = Query.from_(self.table_abc).select("*").union(Query.from_(self.table_abc).select("*")).as_("subq") + + test_query = ( + Query.from_(self.table_abc).join(subquery).on(subquery.x == self.table_abc.id).select(self.table_abc.foo) + ) + + self.assertEqual( + 'SELECT "abc"."foo" FROM "abc" ' + 'JOIN ' + '((SELECT * FROM "abc") ' + 'UNION ' + '(SELECT * FROM "abc")) "subq" ' + 'ON "subq"."x"="abc"."id"', + str(test_query), + ) + + +class UnionTests(unittest.TestCase): + table1, table2 = Tables("abc", "efg") + + def test_union(self): + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + + self.assertEqual( + '(SELECT "foo" FROM "abc") UNION (SELECT "bar" FROM "efg")', + str(query1 + query2), + ) + self.assertEqual( + '(SELECT "foo" FROM "abc") UNION (SELECT "bar" FROM "efg")', + str(query1.union(query2)), + ) + + def test_union_multiple(self): + table3, table4 = Tables("hij", "lmn") + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + query3 = Query.from_(table3).select(table3.baz) + query4 = Query.from_(table4).select(table4.faz) + + self.assertEqual( + '(SELECT "foo" FROM "abc") UNION ' + '(SELECT "bar" FROM "efg") UNION ' + '(SELECT "baz" FROM "hij") UNION ' + '(SELECT "faz" FROM "lmn")', + str(query1 + query2 + query3 + query4), + ) + self.assertEqual( + '(SELECT "foo" FROM "abc") UNION ' + '(SELECT "bar" FROM "efg") UNION ' + '(SELECT "baz" FROM "hij") UNION ' + '(SELECT "faz" FROM "lmn")', + str(query1.union(query2).union(query3).union(query4)), + ) + + def test_union_all(self): + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + + self.assertEqual( + '(SELECT "foo" FROM "abc") UNION ALL (SELECT "bar" FROM "efg")', + str(query1 * query2), + ) + self.assertEqual( + '(SELECT "foo" FROM "abc") UNION ALL (SELECT "bar" FROM "efg")', + str(query1.union_all(query2)), + ) + + def test_union_all_multiple(self): + table3, table4 = Tables("hij", "lmn") + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + query3 = Query.from_(table3).select(table3.baz) + query4 = Query.from_(table4).select(table4.faz) + + self.assertEqual( + '(SELECT "foo" FROM "abc") UNION ALL ' + '(SELECT "bar" FROM "efg") UNION ALL ' + '(SELECT "baz" FROM "hij") UNION ALL ' + '(SELECT "faz" FROM "lmn")', + str(query1 * query2 * query3 * query4), + ) + self.assertEqual( + '(SELECT "foo" FROM "abc") UNION ALL ' + '(SELECT "bar" FROM "efg") UNION ALL ' + '(SELECT "baz" FROM "hij") UNION ALL ' + '(SELECT "faz" FROM "lmn")', + str(query1.union_all(query2).union_all(query3).union_all(query4)), + ) + + def test_union_with_order_by(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + union_query = str((query1 + query2).orderby(query1.field("a"))) + union_all_query = str((query1 * query2).orderby(query1.field("a"))) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "UNION " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "a"', + union_query, + ) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "UNION ALL " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "a"', + union_all_query, + ) + + def test_union_with_order_by_use_union_query_field(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + union_query = query1 + query2 + union_query = str(union_query.orderby(union_query.field("a"))) + union_all_query = query1 * query2 + union_all_query = str(union_all_query.orderby(union_all_query.field("a"))) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "UNION " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "a"', + union_query, + ) + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "UNION ALL " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "a"', + union_all_query, + ) + + def test_union_with_order_by_with_aliases(self): + query1 = Query.from_(self.table1.as_("a")).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2.as_("b")).select(self.table2.bar.as_("a")) + + union_all_query = str((query1 * query2).orderby(query1.field("a"))) + union_query = str((query1 + query2).orderby(query1.field("a"))) + self.assertEqual( + '(SELECT "foo" "a" FROM "abc" "a")' " UNION ALL " '(SELECT "bar" "a" FROM "efg" "b")' ' ORDER BY "a"', + union_all_query, + ) + self.assertEqual( + '(SELECT "foo" "a" FROM "abc" "a")' " UNION " '(SELECT "bar" "a" FROM "efg" "b")' ' ORDER BY "a"', + union_query, + ) + + def test_union_with_order_by_use_union_query_field_with_aliases(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + union_query = (query1 + query2).as_("x") + union_query = union_query.orderby(union_query.field("a")) + union_all_query = (query1 * query2).as_("x") + union_all_query = union_all_query.orderby(union_all_query.field("a")) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "UNION " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "x"."a"', + str(union_query), + ) + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "UNION ALL " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "x"."a"', + str(union_all_query), + ) + + def test_require_equal_number_of_fields(self): + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.fiz, self.table2.buz) + + with self.assertRaises(SetOperationException): + str(query1 + query2) + + def test_mysql_query_wraps_unioned_queries(self): + query1 = MySQLQuery.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + + self.assertEqual( + "(SELECT `foo` FROM `abc`) UNION (SELECT `bar` FROM `efg`)", + str(query1 + query2), + ) + + def test_union_as_subquery(self): + abc, efg = Tables("abc", "efg") + hij = Query.from_(abc).select(abc.t).union(Query.from_(efg).select(efg.t)) + q = Query.from_(hij).select(fn.Avg(hij.t)) + + self.assertEqual( + 'SELECT AVG("sq0"."t") FROM ((SELECT "t" FROM "abc") UNION (SELECT "t" FROM "efg")) "sq0"', + str(q), + ) + + def test_union_with_no_quote_char(self): + abc, efg = Tables("abc", "efg") + hij = Query.from_(abc).select(abc.t).union(Query.from_(efg).select(efg.t)) + q = Query.from_(hij).select(fn.Avg(hij.t)) + + self.assertEqual( + "SELECT AVG(sq0.t) FROM ((SELECT t FROM abc) UNION (SELECT t FROM efg)) sq0", + q.get_sql(quote_char=None), + ) + + +class InsertQueryJoinTests(unittest.TestCase): + def test_join_table_on_insert_query(self): + a, b, c = Tables("a", "b", "c") + q = Query.into(c).from_(a).join(b).on(a.fkey_id == b.id).where(b.foo == 1).select("a.*", "b.*") + + self.assertEqual( + 'INSERT INTO "c" ' + 'SELECT "a"."a.*","a"."b.*" ' + 'FROM "a" JOIN "b" ' + 'ON "a"."fkey_id"="b"."id" ' + 'WHERE "b"."foo"=1', + str(q), + ) + + +class UpdateQueryJoinTests(unittest.TestCase): + def test_join_table_on_update_query(self): + a, b = Tables("a", "b") + q = Query.update(a).join(b).on(a.fkey_id == b.id).where(b.foo == 1).set("adwords_batch_job_id", 1) + + self.assertEqual( + 'UPDATE "a" ' 'JOIN "b" ' 'ON "a"."fkey_id"="b"."id" ' 'SET "adwords_batch_job_id"=1 ' 'WHERE "b"."foo"=1', + str(q), + ) + + +class IntersectTests(unittest.TestCase): + table1, table2 = Tables("abc", "efg") + + def test_intersect(self): + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + + self.assertEqual( + '(SELECT "foo" FROM "abc") INTERSECT (SELECT "bar" FROM "efg")', + str(query1.intersect(query2)), + ) + + def test_intersect_multiple(self): + table3, table4 = Tables("hij", "lmn") + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + query3 = Query.from_(table3).select(table3.baz) + query4 = Query.from_(table4).select(table4.faz) + + self.assertEqual( + '(SELECT "foo" FROM "abc") INTERSECT ' + '(SELECT "bar" FROM "efg") INTERSECT ' + '(SELECT "baz" FROM "hij") INTERSECT ' + '(SELECT "faz" FROM "lmn")', + str(query1.intersect(query2).intersect(query3).intersect(query4)), + ) + + def test_intersect_with_order_by(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + intersect_query = str((query1.intersect(query2)).orderby(query1.field("a"))) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "INTERSECT " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "a"', + intersect_query, + ) + + def test_intersect_with_limit(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + intersect_query = str((query1.intersect(query2)).limit(10)) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "INTERSECT " '(SELECT "bar" "a" FROM "efg") ' 'LIMIT 10', + intersect_query, + ) + + def test_intersect_with_offset(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + intersect_query = str((query1.intersect(query2)).offset(10)) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "INTERSECT " '(SELECT "bar" "a" FROM "efg") ' 'OFFSET 10', + intersect_query, + ) + + def test_require_equal_number_of_fields_intersect(self): + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.fiz, self.table2.buz) + + with self.assertRaises(SetOperationException): + str(query1.intersect(query2)) + + def test_mysql_query_wraps_intersected_queries(self): + query1 = MySQLQuery.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + + self.assertEqual( + "(SELECT `foo` FROM `abc`) INTERSECT (SELECT `bar` FROM `efg`)", + str(query1.intersect(query2)), + ) + + def test_intersect_as_subquery(self): + abc, efg = Tables("abc", "efg") + hij = Query.from_(abc).select(abc.t).intersect(Query.from_(efg).select(efg.t)) + q = Query.from_(hij).select(fn.Avg(hij.t)) + + self.assertEqual( + 'SELECT AVG("sq0"."t") FROM ((SELECT "t" FROM "abc") INTERSECT (SELECT "t" FROM "efg")) "sq0"', + str(q), + ) + + def test_intersect_with_no_quote_char(self): + abc, efg = Tables("abc", "efg") + hij = Query.from_(abc).select(abc.t).intersect(Query.from_(efg).select(efg.t)) + q = Query.from_(hij).select(fn.Avg(hij.t)) + + self.assertEqual( + "SELECT AVG(sq0.t) FROM ((SELECT t FROM abc) INTERSECT (SELECT t FROM efg)) sq0", + q.get_sql(quote_char=None), + ) + + +class MinusTests(unittest.TestCase): + table1, table2 = Tables("abc", "efg") + + def test_minus(self): + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + + self.assertEqual('(SELECT "foo" FROM "abc") MINUS (SELECT "bar" FROM "efg")', str(query1.minus(query2))) + + self.assertEqual( + '(SELECT "foo" FROM "abc") MINUS (SELECT "bar" FROM "efg")', + str(query1 - query2), + ) + + def test_minus_multiple(self): + table3, table4 = Tables("hij", "lmn") + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + query3 = Query.from_(table3).select(table3.baz) + query4 = Query.from_(table4).select(table4.faz) + + self.assertEqual( + '(SELECT "foo" FROM "abc") MINUS ' + '(SELECT "bar" FROM "efg") MINUS ' + '(SELECT "baz" FROM "hij") MINUS ' + '(SELECT "faz" FROM "lmn")', + str(query1 - query2 - query3 - query4), + ) + + self.assertEqual( + '(SELECT "foo" FROM "abc") MINUS ' + '(SELECT "bar" FROM "efg") MINUS ' + '(SELECT "baz" FROM "hij") MINUS ' + '(SELECT "faz" FROM "lmn")', + str(query1.minus(query2).minus(query3).minus(query4)), + ) + + def test_minus_with_order_by(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + minus_query = str(query1.minus(query2).orderby(query1.field("a"))) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "MINUS " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "a"', minus_query + ) + + def test_minus_query_with_order_by_use_minus_query_field(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + minus_query = query1.minus(query2) + minus_query = str(minus_query.orderby(minus_query.field("b"))) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "MINUS " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "b"', + minus_query, + ) + + def test_require_equal_number_of_fields(self): + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.fiz, self.table2.buz) + + with self.assertRaises(SetOperationException): + str(query1.minus(query2)) + + def test_mysql_query_wraps_minus_queries(self): + query1 = MySQLQuery.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + + self.assertEqual( + "(SELECT `foo` FROM `abc`) MINUS (SELECT `bar` FROM `efg`)", + str(query1 - query2), + ) + + def test_minus_as_subquery(self): + abc, efg = Tables("abc", "efg") + hij = Query.from_(abc).select(abc.t).minus(Query.from_(efg).select(efg.t)) + q = Query.from_(hij).select(fn.Avg(hij.t)) + + self.assertEqual( + 'SELECT AVG("sq0"."t") FROM ((SELECT "t" FROM "abc") MINUS (SELECT "t" FROM "efg")) "sq0"', + str(q), + ) + + def test_minus_with_no_quote_char(self): + abc, efg = Tables("abc", "efg") + hij = Query.from_(abc).select(abc.t).minus(Query.from_(efg).select(efg.t)) + q = Query.from_(hij).select(fn.Avg(hij.t)) + + self.assertEqual( + "SELECT AVG(sq0.t) FROM ((SELECT t FROM abc) MINUS (SELECT t FROM efg)) sq0", + q.get_sql(quote_char=None), + ) + + +class ExceptOfTests(unittest.TestCase): + table1, table2 = Tables("abc", "efg") + + def test_except(self): + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + + self.assertEqual('(SELECT "foo" FROM "abc") EXCEPT (SELECT "bar" FROM "efg")', str(query1.except_of(query2))) + + def test_except_multiple(self): + table3, table4 = Tables("hij", "lmn") + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + query3 = Query.from_(table3).select(table3.baz) + query4 = Query.from_(table4).select(table4.faz) + + self.assertEqual( + '(SELECT "foo" FROM "abc") EXCEPT ' + '(SELECT "bar" FROM "efg") EXCEPT ' + '(SELECT "baz" FROM "hij") EXCEPT ' + '(SELECT "faz" FROM "lmn")', + str(query1.except_of(query2).except_of(query3).except_of(query4)), + ) + + def test_except_with_order_by(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + except_query = str(query1.except_of(query2).orderby(query1.field("a"))) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "EXCEPT " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "a"', except_query + ) + + def test_except_query_with_order_by_use_minus_query_field(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + except_query = query1.except_of(query2) + except_query = str(except_query.orderby(except_query.field("b"))) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "EXCEPT " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "b"', + except_query, + ) + + def test_require_equal_number_of_fields_except_of(self): + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.fiz, self.table2.buz) + + with self.assertRaises(SetOperationException): + str(query1.except_of(query2)) + + def test_except_as_subquery(self): + abc, efg = Tables("abc", "efg") + hij = Query.from_(abc).select(abc.t).except_of(Query.from_(efg).select(efg.t)) + q = Query.from_(hij).select(fn.Avg(hij.t)) + + self.assertEqual( + 'SELECT AVG("sq0"."t") FROM ((SELECT "t" FROM "abc") EXCEPT (SELECT "t" FROM "efg")) "sq0"', + str(q), + ) + + def test_except_with_no_quote_char(self): + abc, efg = Tables("abc", "efg") + hij = Query.from_(abc).select(abc.t).except_of(Query.from_(efg).select(efg.t)) + q = Query.from_(hij).select(fn.Avg(hij.t)) + + self.assertEqual( + "SELECT AVG(sq0.t) FROM ((SELECT t FROM abc) EXCEPT (SELECT t FROM efg)) sq0", + q.get_sql(quote_char=None), + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/test_negation.py b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/test_negation.py new file mode 100644 index 0000000000000000000000000000000000000000..9f4db83b560dbc8546ce6d384b781dfccefd319d --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/test_negation.py @@ -0,0 +1,31 @@ +import unittest + +from pypika import ( + Tables, + functions as fn, +) +from pypika.terms import ValueWrapper + + +class NegationTests(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_negate_wrapped_float(self): + q = -ValueWrapper(1.0) + + self.assertEqual("-1.0", q.get_sql()) + + def test_negate_wrapped_int(self): + q = -ValueWrapper(1) + + self.assertEqual("-1", q.get_sql()) + + def test_negate_field(self): + q = -self.table_abc.foo + + self.assertEqual('-"abc"."foo"', q.get_sql(with_namespace=True, quote_char='"')) + + def test_negate_function(self): + q = -fn.Sum(self.table_abc.foo) + + self.assertEqual('-SUM("abc"."foo")', q.get_sql(with_namespace=True, quote_char='"')) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/test_parameter.py b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/test_parameter.py new file mode 100644 index 0000000000000000000000000000000000000000..c11e9afcd9624abb0a7313306eda34ebcf4c99ba --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/test_parameter.py @@ -0,0 +1,206 @@ +import unittest +from datetime import date + +from pypika import ( + FormatParameter, + NamedParameter, + NumericParameter, + Parameter, + PyformatParameter, + QmarkParameter, + Query, + Tables, +) +from pypika.terms import ListParameter, ParameterValueWrapper + + +class ParametrizedTests(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_param_insert(self): + q = Query.into(self.table_abc).columns("a", "b", "c").insert(Parameter("?"), Parameter("?"), Parameter("?")) + + self.assertEqual('INSERT INTO "abc" ("a","b","c") VALUES (?,?,?)', q.get_sql()) + + def test_param_select_join(self): + q = ( + Query.from_(self.table_abc) + .select("*") + .where(self.table_abc.category == Parameter("%s")) + .join(self.table_efg) + .on(self.table_abc.id == self.table_efg.abc_id) + .where(self.table_efg.date >= Parameter("%s")) + .limit(10) + ) + + self.assertEqual( + 'SELECT * FROM "abc" JOIN "efg" ON "abc"."id"="efg"."abc_id" WHERE "abc"."category"=%s AND "efg"."date">=%s LIMIT 10', + q.get_sql(), + ) + + def test_param_select_subquery(self): + q = ( + Query.from_(self.table_abc) + .select("*") + .where(self.table_abc.category == Parameter("&1")) + .where( + self.table_abc.id.isin( + Query.from_(self.table_efg) + .select(self.table_efg.abc_id) + .where(self.table_efg.date >= Parameter("&2")) + ) + ) + .limit(10) + ) + + self.assertEqual( + 'SELECT * FROM "abc" WHERE "category"=&1 AND "id" IN (SELECT "abc_id" FROM "efg" WHERE "date">=&2) LIMIT 10', + q.get_sql(), + ) + + def test_join(self): + subquery = ( + Query.from_(self.table_efg) + .select(self.table_efg.fiz, self.table_efg.buz) + .where(self.table_efg.buz == Parameter(":buz")) + ) + + q = ( + Query.from_(self.table_abc) + .join(subquery) + .on(self.table_abc.bar == subquery.buz) + .select(self.table_abc.foo, subquery.fiz) + .where(self.table_abc.bar == Parameter(":bar")) + ) + + self.assertEqual( + 'SELECT "abc"."foo","sq0"."fiz" FROM "abc" JOIN (SELECT "fiz","buz" FROM "efg" WHERE "buz"=:buz)' + ' "sq0" ON "abc"."bar"="sq0"."buz" WHERE "abc"."bar"=:bar', + q.get_sql(), + ) + + def test_qmark_parameter(self): + self.assertEqual('?', QmarkParameter().get_sql()) + + def test_numeric_parameter(self): + self.assertEqual(':14', NumericParameter('14').get_sql()) + self.assertEqual(':15', NumericParameter(15).get_sql()) + + def test_named_parameter(self): + self.assertEqual(':buz', NamedParameter('buz').get_sql()) + + def test_format_parameter(self): + self.assertEqual('%s', FormatParameter().get_sql()) + + def test_pyformat_parameter(self): + self.assertEqual('%(buz)s', PyformatParameter('buz').get_sql()) + + +class ParametrizedTestsWithValues(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_param_insert(self): + q = Query.into(self.table_abc).columns("a", "b", "c").insert(1, 2.2, 'foo') + + parameter = QmarkParameter() + sql = q.get_sql(parameter=parameter) + self.assertEqual('INSERT INTO "abc" ("a","b","c") VALUES (?,?,?)', sql) + self.assertEqual([1, 2.2, 'foo'], parameter.get_parameters()) + + def test_param_select_join(self): + q = ( + Query.from_(self.table_abc) + .select("*") + .where(self.table_abc.category == 'foobar') + .join(self.table_efg) + .on(self.table_abc.id == self.table_efg.abc_id) + .where(self.table_efg.date >= date(2024, 2, 22)) + .limit(10) + ) + + parameter = FormatParameter() + sql = q.get_sql(parameter=parameter) + self.assertEqual( + 'SELECT * FROM "abc" JOIN "efg" ON "abc"."id"="efg"."abc_id" WHERE "abc"."category"=%s AND "efg"."date">=%s LIMIT 10', + sql, + ) + self.assertEqual(['foobar', '2024-02-22'], parameter.get_parameters()) + + def test_param_select_subquery(self): + q = ( + Query.from_(self.table_abc) + .select("*") + .where(self.table_abc.category == 'foobar') + .where( + self.table_abc.id.isin( + Query.from_(self.table_efg) + .select(self.table_efg.abc_id) + .where(self.table_efg.date >= date(2024, 2, 22)) + ) + ) + .limit(10) + ) + + parameter = ListParameter(placeholder=lambda idx: f'&{idx+1}') + sql = q.get_sql(parameter=parameter) + self.assertEqual( + 'SELECT * FROM "abc" WHERE "category"=&1 AND "id" IN (SELECT "abc_id" FROM "efg" WHERE "date">=&2) LIMIT 10', + sql, + ) + self.assertEqual(['foobar', '2024-02-22'], parameter.get_parameters()) + + def test_join(self): + subquery = ( + Query.from_(self.table_efg) + .select(self.table_efg.fiz, self.table_efg.buz) + .where(self.table_efg.buz == 'buz') + ) + + q = ( + Query.from_(self.table_abc) + .join(subquery) + .on(self.table_abc.bar == subquery.buz) + .select(self.table_abc.foo, subquery.fiz) + .where(self.table_abc.bar == 'bar') + ) + + parameter = NamedParameter() + sql = q.get_sql(parameter=parameter) + self.assertEqual( + 'SELECT "abc"."foo","sq0"."fiz" FROM "abc" JOIN (SELECT "fiz","buz" FROM "efg" WHERE "buz"=:param1)' + ' "sq0" ON "abc"."bar"="sq0"."buz" WHERE "abc"."bar"=:param2', + sql, + ) + self.assertEqual({'param1': 'buz', 'param2': 'bar'}, parameter.get_parameters()) + + def test_join_with_parameter_value_wrapper(self): + subquery = ( + Query.from_(self.table_efg) + .select(self.table_efg.fiz, self.table_efg.buz) + .where(self.table_efg.buz == ParameterValueWrapper(Parameter(':buz'), 'buz')) + ) + + q = ( + Query.from_(self.table_abc) + .join(subquery) + .on(self.table_abc.bar == subquery.buz) + .select(self.table_abc.foo, subquery.fiz) + .where(self.table_abc.bar == ParameterValueWrapper(NamedParameter('bar'), 'bar')) + ) + + parameter = NamedParameter() + sql = q.get_sql(parameter=parameter) + self.assertEqual( + 'SELECT "abc"."foo","sq0"."fiz" FROM "abc" JOIN (SELECT "fiz","buz" FROM "efg" WHERE "buz"=:buz)' + ' "sq0" ON "abc"."bar"="sq0"."buz" WHERE "abc"."bar"=:bar', + sql, + ) + self.assertEqual({':buz': 'buz', 'bar': 'bar'}, parameter.get_parameters()) + + def test_pyformat_parameter(self): + q = Query.into(self.table_abc).columns("a", "b", "c").insert(1, 2.2, 'foo') + + parameter = PyformatParameter() + sql = q.get_sql(parameter=parameter) + self.assertEqual('INSERT INTO "abc" ("a","b","c") VALUES (%(param1)s,%(param2)s,%(param3)s)', sql) + self.assertEqual({"param1": 1, "param2": 2.2, "param3": "foo"}, parameter.get_parameters()) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/test_pseudocolumns.py b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/test_pseudocolumns.py new file mode 100644 index 0000000000000000000000000000000000000000..6a25c70269b2ccc98ac3870ac64a43c8a32ddbe9 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/test_pseudocolumns.py @@ -0,0 +1,51 @@ +import unittest + +from pypika import Query, Table +from pypika.pseudocolumns import ( + ColumnValue, + ObjectID, + ObjectValue, + RowID, + RowNum, + SysDate, +) +from pypika.terms import PseudoColumn + + +class PseudoColumnsTest(unittest.TestCase): + @classmethod + def setUpClass(cls): + super(PseudoColumnsTest, cls).setUpClass() + cls.table1 = Table("table1") + + def test_column_value(self): + self.assertEqual("COLUMN_VALUE", ColumnValue) + + def test_object_id(self): + self.assertEqual("OBJECT_ID", ObjectID) + + def test_object_value(self): + self.assertEqual("OBJECT_VALUE", ObjectValue) + + def test_row_id(self): + self.assertEqual("ROWID", RowID) + + def test_row_num(self): + self.assertEqual("ROWNUM", RowNum) + + def test_sys_date(self): + self.assertEqual("SYSDATE", SysDate) + + def test_can_be_used_in_a_select_statement(self): + query = Query.from_(self.table1).where(self.table1.is_active == 1).select(PseudoColumn("abcde")) + + self.assertEqual(str(query), 'SELECT abcde FROM "table1" WHERE "is_active"=1') + + def test_can_be_used_in_a_where_clause(self): + query = Query.from_(self.table1).where(PseudoColumn("abcde") > 1).select(self.table1.is_active) + + self.assertEqual(str(query), 'SELECT "is_active" FROM "table1" WHERE abcde>1') + + def test_can_be_used_in_orderby(self): + query = Query.from_(self.table1).select(self.table1.abcde.as_("some_name")).orderby(PseudoColumn("some_name")) + self.assertEqual(str(query), 'SELECT "abcde" "some_name" FROM "table1" ORDER BY some_name') diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/test_query.py b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/test_query.py new file mode 100644 index 0000000000000000000000000000000000000000..ae8dc01599a6a562b591ce15391bfe9b5c87e0f9 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/test_query.py @@ -0,0 +1,242 @@ +import unittest + +from pypika import Case, Query, Tables, Tuple, functions, Field +from pypika.dialects import ( + ClickHouseQuery, + ClickHouseQueryBuilder, + MSSQLQuery, + MSSQLQueryBuilder, + MySQLLoadQueryBuilder, + MySQLQuery, + MySQLQueryBuilder, + OracleQuery, + OracleQueryBuilder, + PostgreSQLQuery, + PostgreSQLQueryBuilder, + RedShiftQueryBuilder, + RedshiftQuery, + SQLLiteQuery, + SQLLiteQueryBuilder, + SnowflakeQuery, + SnowflakeQueryBuilder, + VerticaCopyQueryBuilder, + VerticaCreateQueryBuilder, + VerticaQuery, + VerticaQueryBuilder, +) +from pypika.queries import CreateQueryBuilder, DropQueryBuilder, QueryBuilder + + +class QueryTablesTests(unittest.TestCase): + table_a, table_b, table_c, table_d = Tables("a", "b", "c", "d") + + def test_replace_table(self): + query = Query.from_(self.table_a).select(self.table_a.time) + query = query.replace_table(self.table_a, self.table_b) + + self.assertEqual('SELECT "time" FROM "b"', str(query)) + + def test_replace_only_specified_table(self): + query = Query.from_(self.table_a).select(self.table_a.time) + query = query.replace_table(self.table_b, self.table_c) + + self.assertEqual('SELECT "time" FROM "a"', str(query)) + + def test_replace_insert_table(self): + query = Query.into(self.table_a).insert(1) + query = query.replace_table(self.table_a, self.table_b) + + self.assertEqual('INSERT INTO "b" VALUES (1)', str(query)) + + def test_replace_insert_table_current_table_not_match(self): + query = Query.into(self.table_a).insert(1) + query = query.replace_table(self.table_c, self.table_b) + + self.assertEqual('INSERT INTO "a" VALUES (1)', str(query)) + + def test_replace_update_table(self): + query = Query.update(self.table_a).set("foo", "bar") + query = query.replace_table(self.table_a, self.table_b) + + self.assertEqual('UPDATE "b" SET "foo"=\'bar\'', str(query)) + + def test_replace_update_table_current_table_not_match(self): + query = Query.update(self.table_a).set("foo", "bar") + query = query.replace_table(self.table_c, self.table_b) + + self.assertEqual('UPDATE "a" SET "foo"=\'bar\'', str(query)) + + def test_replace_delete_table(self): + query = Query.from_(self.table_a).delete() + query = query.replace_table(self.table_a, self.table_b) + + self.assertEqual('DELETE FROM "b"', str(query)) + + def test_replace_join_tables(self): + query = ( + Query.from_(self.table_a) + .join(self.table_b) + .on(self.table_a.customer_id == self.table_b.id) + .join(self.table_c) + .on(self.table_b.seller_id == self.table_c.id) + .select(self.table_a.star) + ) + query = query.replace_table(self.table_a, self.table_d) + + self.assertEqual( + 'SELECT "d".* ' + 'FROM "d" ' + 'JOIN "b" ON "d"."customer_id"="b"."id" ' + 'JOIN "c" ON "b"."seller_id"="c"."id"', + str(query), + ) + + def test_replace_filter_tables(self): + query = Query.from_(self.table_a).select(self.table_a.name).where(self.table_a.name == "Mustermann") + query = query.replace_table(self.table_a, self.table_b) + + self.assertEqual('SELECT "name" FROM "b" WHERE "name"=\'Mustermann\'', str(query)) + + def test_replace_having_table(self): + query = ( + Query.from_(self.table_a) + .select(functions.Sum(self.table_a.revenue)) + .groupby(self.table_a.customer) + .having(functions.Sum(self.table_a.revenue) >= 1000) + ) + query = query.replace_table(self.table_a, self.table_b) + + self.assertEqual( + 'SELECT SUM("revenue") ' 'FROM "b" ' 'GROUP BY "customer" ' 'HAVING SUM("revenue")>=1000', + str(query), + ) + + def test_replace_case_table(self): + query = Query.from_(self.table_a).select( + Case() + .when(self.table_a.fname == "Tom", "It was Tom") + .when(self.table_a.fname == "John", "It was John") + .else_("It was someone else.") + .as_("who_was_it") + ) + query = query.replace_table(self.table_a, self.table_b) + + self.assertEqual( + "SELECT CASE " + "WHEN \"fname\"='Tom' THEN 'It was Tom' " + "WHEN \"fname\"='John' THEN 'It was John' " + "ELSE 'It was someone else.' END \"who_was_it\" " + 'FROM "b"', + str(query), + ) + + def test_replace_orderby_table(self): + query = Query.from_(self.table_a).select(self.table_a.customer).orderby(self.table_a.customer) + query = query.replace_table(self.table_a, self.table_b) + + self.assertEqual('SELECT "customer" FROM "b" ORDER BY "customer"', str(query)) + + def test_replace_tuple_table(self): + query = ( + Query.from_(self.table_a) + .select(self.table_a.cost, self.table_a.revenue) + .where((self.table_a.cost, self.table_a.revenue) == Tuple(1, 2)) + ) + + query = query.replace_table(self.table_a, self.table_b) + + # Order is reversed due to lack of right equals method + self.assertEqual( + 'SELECT "cost","revenue" FROM "b" WHERE (1,2)=("cost","revenue")', + str(query), + ) + + def test_is_joined(self): + q = Query.from_(self.table_a).join(self.table_b).on(self.table_a.foo == self.table_b.boo) + + self.assertTrue(q.is_joined(self.table_b)) + self.assertFalse(q.is_joined(self.table_c)) + + +class QueryBuilderTests(unittest.TestCase): + def test_query_builders_have_reference_to_correct_query_class(self): + with self.subTest('QueryBuilder'): + self.assertEqual(Query, QueryBuilder.QUERY_CLS) + + with self.subTest('DropQueryBuilder'): + self.assertEqual(Query, DropQueryBuilder.QUERY_CLS) + + with self.subTest('CreateQueryBuilder'): + self.assertEqual(Query, CreateQueryBuilder.QUERY_CLS) + + with self.subTest('MySQLQueryBuilder'): + self.assertEqual(MySQLQuery, MySQLQueryBuilder.QUERY_CLS) + + with self.subTest('MySQLLoadQueryBuilder'): + self.assertEqual(MySQLQuery, MySQLLoadQueryBuilder.QUERY_CLS) + + with self.subTest('VerticaQueryBuilder'): + self.assertEqual(VerticaQuery, VerticaQueryBuilder.QUERY_CLS) + + with self.subTest('VerticaCreateQueryBuilder'): + self.assertEqual(VerticaQuery, VerticaCreateQueryBuilder.QUERY_CLS) + + with self.subTest('VerticaCopyQueryBuilder'): + self.assertEqual(VerticaQuery, VerticaCopyQueryBuilder.QUERY_CLS) + + with self.subTest('PostgreSQLQueryBuilder'): + self.assertEqual(PostgreSQLQuery, PostgreSQLQueryBuilder.QUERY_CLS) + + with self.subTest('MSSQLQueryBuilder'): + self.assertEqual(MSSQLQuery, MSSQLQueryBuilder.QUERY_CLS) + + with self.subTest('SnowflakeQueryBuilder'): + self.assertEqual(SnowflakeQuery, SnowflakeQueryBuilder.QUERY_CLS) + + with self.subTest('ClickHouseQueryBuilder'): + self.assertEqual(ClickHouseQuery, ClickHouseQueryBuilder.QUERY_CLS) + + with self.subTest('RedShiftQueryBuilder'): + self.assertEqual(RedshiftQuery, RedShiftQueryBuilder.QUERY_CLS) + + with self.subTest('SQLLiteQueryBuilder'): + self.assertEqual(SQLLiteQuery, SQLLiteQueryBuilder.QUERY_CLS) + + with self.subTest('OracleQueryBuilder'): + self.assertEqual(OracleQuery, OracleQueryBuilder.QUERY_CLS) + + def test_pipe(self) -> None: + base_query = Query.from_("test") + + def select(query: QueryBuilder) -> QueryBuilder: + return query.select("test1", "test2") + + def count_group(query: QueryBuilder, *groups) -> QueryBuilder: + return query.groupby(*groups).select(*groups, functions.Count("*")) + + for func, args, kwargs, expected_str in [ + (select, [], {}, 'SELECT "test1","test2" FROM "test"'), + ( + count_group, + ["test1", "test2"], + {}, + 'SELECT "test1","test2",COUNT(*) FROM "test" GROUP BY "test1","test2"', + ), + (count_group, ["test1"], {}, 'SELECT "test1",COUNT(*) FROM "test" GROUP BY "test1"'), + ]: + result_str = str(base_query.pipe(func, *args, **kwargs)) + self.assertEqual(result_str, str(func(base_query, *args, **kwargs))) + self.assertEqual(result_str, expected_str) + + def where_clause(query: QueryBuilder, num_days: int) -> QueryBuilder: + return query.where(Field("date") > functions.Now() - num_days) + + result_str = str(base_query.pipe(select).pipe(where_clause, num_days=1)) + self.assertEqual( + result_str, + str(select(where_clause(base_query, num_days=1))), + ) + self.assertEqual( + result_str, + 'SELECT "test1","test2" FROM "test" WHERE "date">NOW()-1', + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/test_selects.py b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/test_selects.py new file mode 100644 index 0000000000000000000000000000000000000000..1ce04937492e655db362b7e2a0a6856abf22a48f --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/test_selects.py @@ -0,0 +1,1331 @@ +import unittest +from datetime import date +from enum import Enum + +from pypika import ( + AliasedQuery, + Case, + ClickHouseQuery, + EmptyCriterion, + Field as F, + Index, + MSSQLQuery, + MySQLQuery, + NullValue, + OracleQuery, + Order, + PostgreSQLQuery, + Query, + QueryException, + RedshiftQuery, + SQLLiteQuery, + Table, + Tables, + VerticaQuery, + functions as fn, + SYSTEM_TIME, +) +from pypika.terms import ValueWrapper + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + + +class SelectTests(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_empty_query(self): + q = Query.from_("abc") + + self.assertEqual("", str(q)) + + def test_select_no_from(self): + q = Query.select(1) + + self.assertEqual("SELECT 1", str(q)) + + def test_select_no_with_alias_from(self): + q = Query.select(ValueWrapper(1, "test")) + + self.assertEqual('SELECT 1 "test"', str(q)) + + def test_select_no_from_with_field_raises_exception(self): + with self.assertRaises(QueryException): + Query.select("asdf") + + def test_select__star(self): + q = Query.from_("abc").select("*") + + self.assertEqual('SELECT * FROM "abc"', str(q)) + + def test_select__table_schema(self): + q = Query.from_(Table("abc", "schema1")).select("*") + + self.assertEqual('SELECT * FROM "schema1"."abc"', str(q)) + + def test_select__table_schema_with_multiple_levels_as_tuple(self): + q = Query.from_(Table("abc", ("schema1", "schema2"))).select("*") + + self.assertEqual('SELECT * FROM "schema1"."schema2"."abc"', str(q)) + + def test_select__table_schema_with_multiple_levels_as_list(self): + q = Query.from_(Table("abc", ["schema1", "schema2"])).select("*") + + self.assertEqual('SELECT * FROM "schema1"."schema2"."abc"', str(q)) + + def test_select__star__replacement(self): + q = Query.from_("abc").select("foo").select("*") + + self.assertEqual('SELECT * FROM "abc"', str(q)) + + def test_select__distinct__single(self): + q = Query.from_("abc").select("foo").distinct() + + self.assertEqual('SELECT DISTINCT "foo" FROM "abc"', str(q)) + + def test_select__distinct__multi(self): + q = Query.from_("abc").select("foo", "bar").distinct() + + self.assertEqual('SELECT DISTINCT "foo","bar" FROM "abc"', str(q)) + + def test_select__column__single__str(self): + q = Query.from_("abc").select("foo") + + self.assertEqual('SELECT "foo" FROM "abc"', str(q)) + + def test_select__column__single__alias__str(self): + q = Query.from_(self.table_abc).select(self.table_abc.foo.as_("bar")) + + self.assertEqual('SELECT "foo" "bar" FROM "abc"', str(q)) + + def test_select__column__single__table_alias__str(self): + q = Query.from_(self.table_abc.as_("fizzbuzz")).select(self.table_abc.foo.as_("bar")) + + self.assertEqual('SELECT "foo" "bar" FROM "abc" "fizzbuzz"', str(q)) + + def test_select__column__single__field(self): + t = Table("abc") + q = Query.from_(t).select(t.foo) + + self.assertEqual('SELECT "foo" FROM "abc"', str(q)) + + def test_select__columns__multi__str(self): + q1 = Query.from_("abc").select("foo", "bar") + q2 = Query.from_("abc").select("foo").select("bar") + + self.assertEqual('SELECT "foo","bar" FROM "abc"', str(q1)) + self.assertEqual('SELECT "foo","bar" FROM "abc"', str(q2)) + + def test_select__columns__multi__field(self): + q1 = Query.from_(self.table_abc).select(self.table_abc.foo, self.table_abc.bar) + q2 = Query.from_(self.table_abc).select(self.table_abc.foo).select(self.table_abc.bar) + + self.assertEqual('SELECT "foo","bar" FROM "abc"', str(q1)) + self.assertEqual('SELECT "foo","bar" FROM "abc"', str(q2)) + + def test_select__multiple_tables(self): + q = Query.from_(self.table_abc).select(self.table_abc.foo).from_(self.table_efg).select(self.table_efg.bar) + + self.assertEqual('SELECT "abc"."foo","efg"."bar" FROM "abc","efg"', str(q)) + + def test_select__subquery(self): + subquery = Query.from_(self.table_abc).select("*") + q = Query.from_(subquery).select(subquery.foo, subquery.bar) + + self.assertEqual('SELECT "sq0"."foo","sq0"."bar" ' 'FROM (SELECT * FROM "abc") "sq0"', str(q)) + + def test_select__multiple_subqueries(self): + subquery0 = Query.from_(self.table_abc).select("foo") + subquery1 = Query.from_(self.table_efg).select("bar") + q = Query.from_(subquery0).from_(subquery1).select(subquery0.foo, subquery1.bar) + + self.assertEqual( + 'SELECT "sq0"."foo","sq1"."bar" ' 'FROM (SELECT "foo" FROM "abc") "sq0",' '(SELECT "bar" FROM "efg") "sq1"', + str(q), + ) + + def test_select__nested_subquery(self): + subquery0 = Query.from_(self.table_abc).select("*") + subquery1 = Query.from_(subquery0).select(subquery0.foo, subquery0.bar) + subquery2 = Query.from_(subquery1).select(subquery1.foo) + + q = Query.from_(subquery2).select(subquery2.foo) + + self.assertEqual( + 'SELECT "sq2"."foo" ' + 'FROM (SELECT "sq1"."foo" ' + 'FROM (SELECT "sq0"."foo","sq0"."bar" ' + 'FROM (SELECT * FROM "abc") "sq0") "sq1") "sq2"', + str(q), + ) + + def test_select__no_table(self): + q = Query.select(1, 2, 3) + + self.assertEqual("SELECT 1,2,3", str(q)) + + def test_select_then_add_table(self): + q = Query.select(1).select(2, 3).from_("abc").select("foo") + + self.assertEqual('SELECT 1,2,3,"foo" FROM "abc"', str(q)) + + def test_select_with_limit(self): + q1 = Query.from_("abc").select("foo")[:10] + + self.assertEqual('SELECT "foo" FROM "abc" LIMIT 10', str(q1)) + + def test_select_with_limit_zero(self): + with self.subTest('using python slice'): + q1 = Query.from_("abc").select("foo")[:0] + self.assertEqual('SELECT "foo" FROM "abc" LIMIT 0', str(q1)) + + with self.subTest('using limit method'): + q2 = Query.from_("abc").select("foo").limit(0) + self.assertEqual('SELECT "foo" FROM "abc" LIMIT 0', str(q2)) + + def test_select_with_limit__func(self): + q1 = Query.from_("abc").select("foo").limit(10) + + self.assertEqual('SELECT "foo" FROM "abc" LIMIT 10', str(q1)) + + def test_select_with_offset(self): + q1 = Query.from_("abc").select("foo")[10:] + + self.assertEqual('SELECT "foo" FROM "abc" OFFSET 10', str(q1)) + + def test_select_with_offset__func(self): + q1 = Query.from_("abc").select("foo").offset(10) + + self.assertEqual('SELECT "foo" FROM "abc" OFFSET 10', str(q1)) + + def test_select_with_limit_and_offset(self): + q1 = Query.from_("abc").select("foo")[10:10] + + self.assertEqual('SELECT "foo" FROM "abc" LIMIT 10 OFFSET 10', str(q1)) + + def test_select_with_force_index(self): + q = Query.from_("abc").select("foo").force_index("egg") + + self.assertEqual('SELECT "foo" FROM "abc" FORCE INDEX ("egg")', str(q)) + + def test_select_with_force_index_with_index_object(self): + index = Index("egg") + q = Query.from_("abc").select("foo").force_index(index) + + self.assertEqual('SELECT "foo" FROM "abc" FORCE INDEX ("egg")', str(q)) + + def test_select_with_force_index_multiple_indexes(self): + q = Query.from_("abc").select("foo").force_index("egg", "bacon") + + self.assertEqual('SELECT "foo" FROM "abc" FORCE INDEX ("egg","bacon")', str(q)) + + def test_select_with_force_index_multiple_calls(self): + q = ( + Query.from_("abc") + .select("foo") + .force_index( + "egg", + ) + .force_index("spam") + ) + + self.assertEqual('SELECT "foo" FROM "abc" FORCE INDEX ("egg","spam")', str(q)) + + def test_select_with_use_index(self): + q = Query.from_("abc").select("foo").use_index("egg") + + self.assertEqual('SELECT "foo" FROM "abc" USE INDEX ("egg")', str(q)) + + def test_select_with_use_index_with_index_object(self): + index = Index("egg") + q = Query.from_("abc").select("foo").use_index(index) + + self.assertEqual('SELECT "foo" FROM "abc" USE INDEX ("egg")', str(q)) + + def test_select_with_use_index_multiple_indexes(self): + q = Query.from_("abc").select("foo").use_index("egg", "bacon") + + self.assertEqual('SELECT "foo" FROM "abc" USE INDEX ("egg","bacon")', str(q)) + + def test_select_with_use_index_multiple_calls(self): + q = ( + Query.from_("abc") + .select("foo") + .use_index( + "egg", + ) + .use_index("spam") + ) + + self.assertEqual('SELECT "foo" FROM "abc" USE INDEX ("egg","spam")', str(q)) + + def test_mysql_query_uses_backtick_quote_chars(self): + q = MySQLQuery.from_("abc").select("foo", "bar") + + self.assertEqual("SELECT `foo`,`bar` FROM `abc`", str(q)) + + def test_vertica_query_uses_double_quote_chars(self): + q = VerticaQuery.from_("abc").select("foo", "bar") + + self.assertEqual('SELECT "foo","bar" FROM "abc"', str(q)) + + def test_mssql_query_uses_double_quote_chars(self): + q = MSSQLQuery.from_("abc").select("foo", "bar") + + self.assertEqual('SELECT "foo","bar" FROM "abc"', str(q)) + + def test_oracle_query_uses_no_quote_chars(self): + q = OracleQuery.from_("abc").select("foo", "bar") + + self.assertEqual('SELECT foo,bar FROM abc', str(q)) + + def test_postgresql_query_uses_double_quote_chars(self): + q = PostgreSQLQuery.from_("abc").select("foo", "bar") + + self.assertEqual('SELECT "foo","bar" FROM "abc"', str(q)) + + def test_redshift_query_uses_double_quote_chars(self): + q = RedshiftQuery.from_("abc").select("foo", "bar") + + self.assertEqual('SELECT "foo","bar" FROM "abc"', str(q)) + + def test_table_select_alias(self): + q = self.table_abc.select(1) + + self.assertEqual('SELECT 1 FROM "abc"', str(q)) + self.assertEqual(q, Query.from_("abc").select(1)) + + def test_table_select_alias_with_offset_and_limit(self): + self.assertEqual(self.table_abc.select("foo")[10:10], Query.from_("abc").select("foo")[10:10]) + self.assertEqual( + self.table_abc.select(self.table_abc.foo)[10:10], + Query.from_("abc").select("foo")[10:10], + ) + + def test_temporal_select(self): + t = Table("abc") + + with self.subTest("with system time as of"): + q = Query.from_(t.for_(SYSTEM_TIME.as_of('2020-01-01'))).select("*") + + self.assertEqual('SELECT * FROM "abc" FOR SYSTEM_TIME AS OF \'2020-01-01\'', str(q)) + + with self.subTest("with system time between"): + q = Query.from_(t.for_(SYSTEM_TIME.between('2020-01-01', '2020-02-01'))).select("*") + + self.assertEqual('SELECT * FROM "abc" FOR SYSTEM_TIME BETWEEN \'2020-01-01\' AND \'2020-02-01\'', str(q)) + + with self.subTest("with system time from to"): + q = Query.from_(t.for_(SYSTEM_TIME.from_to('2020-01-01', '2020-02-01'))).select("*") + + self.assertEqual('SELECT * FROM "abc" FOR SYSTEM_TIME FROM \'2020-01-01\' TO \'2020-02-01\'', str(q)) + + with self.subTest("with ALL"): + q = Query.from_(t.for_(SYSTEM_TIME.all_())).select("*") + + self.assertEqual('SELECT * FROM "abc" FOR SYSTEM_TIME ALL', str(q)) + + with self.subTest("with period between"): + q = Query.from_(t.for_(t.valid_period.between('2020-01-01', '2020-02-01'))).select("*") + + self.assertEqual('SELECT * FROM "abc" FOR "valid_period" BETWEEN \'2020-01-01\' AND \'2020-02-01\'', str(q)) + + with self.subTest("with period from to"): + q = Query.from_(t.for_(t.valid_period.from_to('2020-01-01', '2020-02-01'))).select("*") + + self.assertEqual('SELECT * FROM "abc" FOR "valid_period" FROM \'2020-01-01\' TO \'2020-02-01\'', str(q)) + + with self.subTest("with ALL"): + q = Query.from_(t.for_(t.valid_period.all_())).select("*") + + self.assertEqual('SELECT * FROM "abc" FOR "valid_period" ALL', str(q)) + + +class MyEnum(Enum): + STR = "foo" + INT = 0 + BOOL = True + DATE = date(2020, 2, 2) + NONE = None + + +class WhereTests(unittest.TestCase): + t = Table("abc") + t2 = Table("cba") + + def test_where_enum(self): + q1 = Query.from_(self.t).select("*").where(self.t.foo == MyEnum.STR) + q2 = Query.from_(self.t).select("*").where(self.t.foo == MyEnum.INT) + q3 = Query.from_(self.t).select("*").where(self.t.foo == MyEnum.BOOL) + q4 = Query.from_(self.t).select("*").where(self.t.foo == MyEnum.DATE) + q5 = Query.from_(self.t).select("*").where(self.t.foo == MyEnum.NONE) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo"=\'foo\'', str(q1)) + self.assertEqual('SELECT * FROM "abc" WHERE "foo"=0', str(q2)) + self.assertEqual('SELECT * FROM "abc" WHERE "foo"=true', str(q3)) + self.assertEqual('SELECT * FROM "abc" WHERE "foo"=\'2020-02-02\'', str(q4)) + self.assertEqual('SELECT * FROM "abc" WHERE "foo"=null', str(q5)) + + def test_where_field_equals(self): + q1 = Query.from_(self.t).select("*").where(self.t.foo == self.t.bar) + q2 = Query.from_(self.t).select("*").where(self.t.foo.eq(self.t.bar)) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo"="bar"', str(q1)) + self.assertEqual('SELECT * FROM "abc" WHERE "foo"="bar"', str(q2)) + q = self.t.select("*").where(self.t.foo == self.t.bar) + self.assertEqual(q, q1) + + def test_where_field_equals_for_update(self): + q = Query.from_(self.t).select("*").where(self.t.foo == self.t.bar).for_update() + self.assertEqual('SELECT * FROM "abc" WHERE "foo"="bar" FOR UPDATE', str(q)) + + def test_where_field_equals_for_update_nowait(self): + for query_cls in [ + MySQLQuery, + PostgreSQLQuery, + ]: + quote_char = query_cls._builder().QUOTE_CHAR if isinstance(query_cls._builder().QUOTE_CHAR, str) else '"' + q = query_cls.from_(self.t).select("*").where(self.t.foo == self.t.bar).for_update(nowait=True) + self.assertEqual( + 'SELECT * ' + 'FROM {quote_char}abc{quote_char} ' + 'WHERE {quote_char}foo{quote_char}={quote_char}bar{quote_char} ' + 'FOR UPDATE NOWAIT'.format( + quote_char=quote_char, + ), + str(q), + ) + + def test_where_field_equals_for_update_skip_locked(self): + for query_cls in [ + MySQLQuery, + PostgreSQLQuery, + ]: + quote_char = query_cls._builder().QUOTE_CHAR if isinstance(query_cls._builder().QUOTE_CHAR, str) else '"' + q = query_cls.from_(self.t).select("*").where(self.t.foo == self.t.bar).for_update(skip_locked=True) + self.assertEqual( + 'SELECT * ' + 'FROM {quote_char}abc{quote_char} ' + 'WHERE {quote_char}foo{quote_char}={quote_char}bar{quote_char} ' + 'FOR UPDATE SKIP LOCKED'.format( + quote_char=quote_char, + ), + str(q), + ) + + def test_where_field_equals_for_update_of(self): + for query_cls in [ + MySQLQuery, + PostgreSQLQuery, + ]: + quote_char = query_cls._builder().QUOTE_CHAR if isinstance(query_cls._builder().QUOTE_CHAR, str) else '"' + q = query_cls.from_(self.t).select("*").where(self.t.foo == self.t.bar).for_update(of=("abc",)) + self.assertEqual( + 'SELECT * ' + 'FROM {quote_char}abc{quote_char} ' + 'WHERE {quote_char}foo{quote_char}={quote_char}bar{quote_char} ' + 'FOR UPDATE OF {quote_char}abc{quote_char}'.format( + quote_char=quote_char, + ), + str(q), + ) + + def test_where_field_equals_for_update_of_multiple_tables(self): + for query_cls in [ + MySQLQuery, + PostgreSQLQuery, + ]: + q = ( + query_cls.from_(self.t) + .join(self.t2) + .on(self.t.id == self.t2.abc_id) + .select("*") + .where(self.t.foo == self.t.bar) + .for_update(of=("abc", "cba")) + ) + quote_char = query_cls._builder().QUOTE_CHAR if isinstance(query_cls._builder().QUOTE_CHAR, str) else '"' + self.assertIn( + str(q), + [ + 'SELECT * ' + 'FROM {quote_char}abc{quote_char} ' + 'JOIN {quote_char}cba{quote_char} ' + 'ON {quote_char}abc{quote_char}.{quote_char}id{quote_char}=' + '{quote_char}cba{quote_char}.{quote_char}abc_id{quote_char} ' + 'WHERE {quote_char}abc{quote_char}.{quote_char}foo{quote_char}=' + '{quote_char}abc{quote_char}.{quote_char}bar{quote_char} ' + 'FOR UPDATE OF {quote_char}cba{quote_char}, {quote_char}abc{quote_char}'.format( + quote_char=quote_char, + ), + 'SELECT * ' + 'FROM {quote_char}abc{quote_char} ' + 'JOIN {quote_char}cba{quote_char} ' + 'ON {quote_char}abc{quote_char}.{quote_char}id{quote_char}=' + '{quote_char}cba{quote_char}.{quote_char}abc_id{quote_char} ' + 'WHERE {quote_char}abc{quote_char}.{quote_char}foo{quote_char}=' + '{quote_char}abc{quote_char}.{quote_char}bar{quote_char} ' + 'FOR UPDATE OF {quote_char}abc{quote_char}, {quote_char}cba{quote_char}'.format( + quote_char=quote_char, + ), + ], + ) + + def test_where_field_equals_for_update_of_nowait(self): + for query_cls in [ + MySQLQuery, + PostgreSQLQuery, + ]: + q = query_cls.from_(self.t).select("*").where(self.t.foo == self.t.bar).for_update(of=("abc",), nowait=True) + quote_char = query_cls._builder().QUOTE_CHAR if isinstance(query_cls._builder().QUOTE_CHAR, str) else '"' + self.assertEqual( + 'SELECT * ' + 'FROM {quote_char}abc{quote_char} ' + 'WHERE {quote_char}foo{quote_char}={quote_char}bar{quote_char} ' + 'FOR UPDATE OF {quote_char}abc{quote_char} NOWAIT'.format( + quote_char=quote_char, + ), + str(q), + ) + + def test_where_field_equals_for_update_of_skip_locked(self): + for query_cls in [ + MySQLQuery, + PostgreSQLQuery, + ]: + q = ( + query_cls.from_(self.t) + .select("*") + .where(self.t.foo == self.t.bar) + .for_update(of=("abc",), skip_locked=True) + ) + quote_char = query_cls._builder().QUOTE_CHAR if isinstance(query_cls._builder().QUOTE_CHAR, str) else '"' + self.assertEqual( + 'SELECT * ' + 'FROM {quote_char}abc{quote_char} ' + 'WHERE {quote_char}foo{quote_char}={quote_char}bar{quote_char} ' + 'FOR UPDATE OF {quote_char}abc{quote_char} SKIP LOCKED'.format( + quote_char=quote_char, + ), + str(q), + ) + + def test_where_field_equals_for_update_skip_locked_and_of(self): + for query_cls in [ + MySQLQuery, + PostgreSQLQuery, + ]: + q = ( + query_cls.from_(self.t) + .select("*") + .where(self.t.foo == self.t.bar) + .for_update(nowait=False, skip_locked=True, of=("abc",)) + ) + quote_char = query_cls._builder().QUOTE_CHAR if isinstance(query_cls._builder().QUOTE_CHAR, str) else '"' + self.assertEqual( + 'SELECT * ' + 'FROM {quote_char}abc{quote_char} ' + 'WHERE {quote_char}foo{quote_char}={quote_char}bar{quote_char} ' + 'FOR UPDATE OF {quote_char}abc{quote_char} SKIP LOCKED'.format( + quote_char=quote_char, + ), + str(q), + ) + + def test_where_field_equals_where(self): + q = Query.from_(self.t).select("*").where(self.t.foo == 1).where(self.t.bar == self.t.baz) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo"=1 AND "bar"="baz"', str(q)) + + def test_where_field_equals_where_not(self): + q = Query.from_(self.t).select("*").where((self.t.foo == 1).negate()).where(self.t.bar == self.t.baz) + + self.assertEqual('SELECT * FROM "abc" WHERE NOT "foo"=1 AND "bar"="baz"', str(q)) + + def test_where_field_equals_where_two_not(self): + q = Query.from_(self.t).select("*").where((self.t.foo == 1).negate()).where((self.t.bar == self.t.baz).negate()) + + self.assertEqual('SELECT * FROM "abc" WHERE NOT "foo"=1 AND NOT "bar"="baz"', str(q)) + + def test_where_single_quote(self): + q1 = Query.from_(self.t).select("*").where(self.t.foo == "bar'foo") + + self.assertEqual("SELECT * FROM \"abc\" WHERE \"foo\"='bar''foo'", str(q1)) + + def test_where_field_equals_and(self): + q = Query.from_(self.t).select("*").where((self.t.foo == 1) & (self.t.bar == self.t.baz)) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo"=1 AND "bar"="baz"', str(q)) + + def test_where_field_equals_or(self): + q = Query.from_(self.t).select("*").where((self.t.foo == 1) | (self.t.bar == self.t.baz)) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo"=1 OR "bar"="baz"', str(q)) + + def test_where_nested_conditions(self): + q = Query.from_(self.t).select("*").where((self.t.foo == 1) | (self.t.bar == self.t.baz)).where(self.t.baz == 0) + + self.assertEqual('SELECT * FROM "abc" WHERE ("foo"=1 OR "bar"="baz") AND "baz"=0', str(q)) + + def test_where_field_starts_with(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.like("ab%")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" LIKE \'ab%\'', str(q)) + + def test_where_field_contains(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.like("%fg%")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" LIKE \'%fg%\'', str(q)) + + def test_where_field_ends_with(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.like("%yz")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" LIKE \'%yz\'', str(q)) + + def test_where_field_is_n_chars_long(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.like("___")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" LIKE \'___\'', str(q)) + + def test_where_field_does_not_start_with(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.not_like("ab%")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" NOT LIKE \'ab%\'', str(q)) + + def test_where_field_does_not_contain(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.not_like("%fg%")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" NOT LIKE \'%fg%\'', str(q)) + + def test_where_field_does_not_end_with(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.not_like("%yz")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" NOT LIKE \'%yz\'', str(q)) + + def test_where_field_is_not_n_chars_long(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.not_like("___")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" NOT LIKE \'___\'', str(q)) + + def test_where_field_matches_regex(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.regex(r"^b")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" REGEX \'^b\'', str(q)) + + def test_where_field_matches_regexp(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.regexp(r"^b")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" REGEXP \'^b\'', str(q)) + + def test_where_field_matches_rlike(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.rlike(r"^b")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" RLIKE \'^b\'', str(q)) + + def test_ignore_empty_criterion_where(self): + q1 = Query.from_(self.t).select("*").where(EmptyCriterion()) + + self.assertEqual('SELECT * FROM "abc"', str(q1)) + + def test_ignore_empty_criterion_having(self): + q1 = Query.from_(self.t).select("*").having(EmptyCriterion()) + + self.assertEqual('SELECT * FROM "abc"', str(q1)) + + def test_select_with_force_index_and_where(self): + q = Query.from_("abc").select("foo").where(self.t.foo == self.t.bar).force_index("egg") + + self.assertEqual('SELECT "foo" FROM "abc" FORCE INDEX ("egg") WHERE "foo"="bar"', str(q)) + + def test_where_with_multiple_wheres_using_and_case(self): + case_stmt = Case().when(self.t.foo == 'bar', 1).else_(0) + query = Query.from_(self.t).select(case_stmt).where(case_stmt & self.t.blah.isin(['test'])) + + self.assertEqual( + 'SELECT CASE WHEN "foo"=\'bar\' THEN 1 ELSE 0 END FROM "abc" WHERE CASE WHEN "foo"=\'bar\' THEN 1 ELSE 0 ' + 'END AND "blah" IN (\'test\')', + str(query), + ) + + def test_where_with_multiple_wheres_using_or_case(self): + case_stmt = Case().when(self.t.foo == 'bar', 1).else_(0) + query = Query.from_(self.t).select(case_stmt).where(case_stmt | self.t.blah.isin(['test'])) + + self.assertEqual( + 'SELECT CASE WHEN "foo"=\'bar\' THEN 1 ELSE 0 END FROM "abc" WHERE CASE WHEN "foo"=\'bar\' THEN 1 ELSE 0 ' + 'END OR "blah" IN (\'test\')', + str(query), + ) + + +class PreWhereTests(WhereTests): + t = Table("abc") + + def test_prewhere_field_equals(self): + q1 = Query.from_(self.t).select("*").prewhere(self.t.foo == self.t.bar) + q2 = Query.from_(self.t).select("*").prewhere(self.t.foo.eq(self.t.bar)) + + self.assertEqual('SELECT * FROM "abc" PREWHERE "foo"="bar"', str(q1)) + self.assertEqual('SELECT * FROM "abc" PREWHERE "foo"="bar"', str(q2)) + + def test_where_and_prewhere(self): + q = Query.from_(self.t).select("*").prewhere(self.t.foo == self.t.bar).where(self.t.foo == self.t.bar) + + self.assertEqual('SELECT * FROM "abc" PREWHERE "foo"="bar" WHERE "foo"="bar"', str(q)) + + +class GroupByTests(unittest.TestCase): + t = Table("abc") + maxDiff = None + + def test_groupby__single(self): + q = Query.from_(self.t).groupby(self.t.foo).select(self.t.foo) + + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo"', str(q)) + + def test_groupby__multi(self): + q = Query.from_(self.t).groupby(self.t.foo, self.t.bar).select(self.t.foo, self.t.bar) + + self.assertEqual('SELECT "foo","bar" FROM "abc" GROUP BY "foo","bar"', str(q)) + + def test_groupby__count_star(self): + q = Query.from_(self.t).groupby(self.t.foo).select(self.t.foo, fn.Count("*")) + + self.assertEqual('SELECT "foo",COUNT(*) FROM "abc" GROUP BY "foo"', str(q)) + + def test_groupby__count_field(self): + q = Query.from_(self.t).groupby(self.t.foo).select(self.t.foo, fn.Count(self.t.bar)) + + self.assertEqual('SELECT "foo",COUNT("bar") FROM "abc" GROUP BY "foo"', str(q)) + + def test_groupby__count_distinct(self): + q = Query.from_(self.t).groupby(self.t.foo).select(self.t.foo, fn.Count("*").distinct()) + + self.assertEqual('SELECT "foo",COUNT(DISTINCT *) FROM "abc" GROUP BY "foo"', str(q)) + + def test_groupby__sum_distinct(self): + q = Query.from_(self.t).groupby(self.t.foo).select(self.t.foo, fn.Sum(self.t.bar).distinct()) + + self.assertEqual('SELECT "foo",SUM(DISTINCT "bar") FROM "abc" GROUP BY "foo"', str(q)) + + def test_groupby__sum_filter(self): + q = ( + Query.from_(self.t) + .groupby(self.t.foo) + .select(self.t.foo, fn.Sum(self.t.bar).filter(self.t.id.eq(1) & self.t.cid.gt(2))) + ) + + self.assertEqual('SELECT "foo",SUM("bar") FILTER(WHERE "id"=1 AND "cid">2) FROM "abc" GROUP BY "foo"', str(q)) + + def test_groupby__str(self): + q = Query.from_("abc").groupby("foo").select("foo", fn.Count("*").distinct()) + + self.assertEqual('SELECT "foo",COUNT(DISTINCT *) FROM "abc" GROUP BY "foo"', str(q)) + + def test_groupby__int(self): + q = Query.from_("abc").groupby(1).select("foo", fn.Count("*").distinct()) + + self.assertEqual('SELECT "foo",COUNT(DISTINCT *) FROM "abc" GROUP BY 1', str(q)) + + def test_groupby__alias(self): + bar = self.t.bar.as_("bar01") + q = Query.from_(self.t).select(fn.Sum(self.t.foo), bar).groupby(bar) + + self.assertEqual('SELECT SUM("foo"),"bar" "bar01" FROM "abc" GROUP BY "bar01"', str(q)) + + def test_groupby__no_alias(self): + bar = self.t.bar.as_("bar01") + q = Query.from_(self.t).select(fn.Sum(self.t.foo), bar).groupby(bar) + + self.assertEqual( + 'SELECT SUM("foo"),"bar" "bar01" FROM "abc" GROUP BY "bar"', + q.get_sql(groupby_alias=False), + ) + + def test_groupby__no_alias_mssql(self): + bar = self.t.bar.as_("bar01") + q = MSSQLQuery.from_(self.t).select(fn.Sum(self.t.foo), bar).groupby(bar) + + self.assertEqual('SELECT SUM("foo"),"bar" "bar01" FROM "abc" GROUP BY "bar"', str(q)) + + def test_groupby__no_alias_oracle(self): + bar = self.t.bar.as_("bar01") + q = OracleQuery.from_(self.t).select(fn.Sum(self.t.foo), bar).groupby(bar) + + self.assertEqual('SELECT SUM(foo),bar bar01 FROM abc GROUP BY bar', str(q)) + + def test_groupby__alias_platforms(self): + bar = self.t.bar.as_("bar01") + + for query_cls in [ + MySQLQuery, + VerticaQuery, + PostgreSQLQuery, + RedshiftQuery, + ClickHouseQuery, + SQLLiteQuery, + ]: + q = query_cls.from_(self.t).select(fn.Sum(self.t.foo), bar).groupby(bar) + + quote_char = query_cls._builder().QUOTE_CHAR if isinstance(query_cls._builder().QUOTE_CHAR, str) else '"' + + self.assertEqual( + "SELECT " + "SUM({quote_char}foo{quote_char})," + "{quote_char}bar{quote_char}{as_keyword}{quote_char}bar01{quote_char} " + "FROM {quote_char}abc{quote_char} " + "GROUP BY {quote_char}bar01{quote_char}".format( + as_keyword=' AS ' if query_cls is ClickHouseQuery else ' ', quote_char=quote_char + ), + str(q), + ) + + def test_groupby__alias_with_join(self): + table1 = Table("table1", alias="t1") + bar = table1.bar.as_("bar01") + q = Query.from_(self.t).join(table1).on(self.t.id == table1.t_ref).select(fn.Sum(self.t.foo), bar).groupby(bar) + + self.assertEqual( + 'SELECT SUM("abc"."foo"),"t1"."bar" "bar01" FROM "abc" ' + 'JOIN "table1" "t1" ON "abc"."id"="t1"."t_ref" ' + 'GROUP BY "bar01"', + str(q), + ) + + def test_groupby_with_case_uses_the_alias(self): + q = ( + Query.from_(self.t) + .select( + fn.Sum(self.t.foo).as_("bar"), + Case().when(self.t.fname == "Tom", "It was Tom").else_("It was someone else.").as_("who_was_it"), + ) + .groupby(Case().when(self.t.fname == "Tom", "It was Tom").else_("It was someone else.").as_("who_was_it")) + ) + + self.assertEqual( + 'SELECT SUM("foo") "bar",' + "CASE WHEN \"fname\"='Tom' THEN 'It was Tom' " + "ELSE 'It was someone else.' END \"who_was_it\" " + 'FROM "abc" ' + 'GROUP BY "who_was_it"', + str(q), + ) + + def test_mysql_query_uses_backtick_quote_chars(self): + q = MySQLQuery.from_(self.t).groupby(self.t.foo).select(self.t.foo) + + self.assertEqual("SELECT `foo` FROM `abc` GROUP BY `foo`", str(q)) + + def test_vertica_query_uses_double_quote_chars(self): + q = VerticaQuery.from_(self.t).groupby(self.t.foo).select(self.t.foo) + + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo"', str(q)) + + def test_mssql_query_uses_double_quote_chars(self): + q = MSSQLQuery.from_(self.t).groupby(self.t.foo).select(self.t.foo) + + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo"', str(q)) + + def test_oracle_query_uses_no_quote_chars(self): + q = OracleQuery.from_(self.t).groupby(self.t.foo).select(self.t.foo) + + self.assertEqual('SELECT foo FROM abc GROUP BY foo', str(q)) + + def test_postgres_query_uses_double_quote_chars(self): + q = PostgreSQLQuery.from_(self.t).groupby(self.t.foo).select(self.t.foo) + + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo"', str(q)) + + def test_redshift_query_uses_double_quote_chars(self): + q = RedshiftQuery.from_(self.t).groupby(self.t.foo).select(self.t.foo) + + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo"', str(q)) + + def test_group_by__single_with_totals(self): + q = Query.from_(self.t).groupby(self.t.foo).select(self.t.foo).with_totals() + + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo" WITH TOTALS', str(q)) + + def test_groupby__multi_with_totals(self): + q = Query.from_(self.t).groupby(self.t.foo, self.t.bar).select(self.t.foo, self.t.bar).with_totals() + + self.assertEqual('SELECT "foo","bar" FROM "abc" GROUP BY "foo","bar" WITH TOTALS', str(q)) + + +class HavingTests(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_having_greater_than(self): + q = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, fn.Sum(self.table_abc.bar)) + .groupby(self.table_abc.foo) + .having(fn.Sum(self.table_abc.bar) > 1) + ) + + self.assertEqual( + 'SELECT "foo",SUM("bar") FROM "abc" GROUP BY "foo" HAVING SUM("bar")>1', + str(q), + ) + + def test_having_and(self): + q = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, fn.Sum(self.table_abc.bar)) + .groupby(self.table_abc.foo) + .having((fn.Sum(self.table_abc.bar) > 1) & (fn.Sum(self.table_abc.bar) < 100)) + ) + + self.assertEqual( + 'SELECT "foo",SUM("bar") FROM "abc" GROUP BY "foo" HAVING SUM("bar")>1 AND SUM("bar")<100', + str(q), + ) + + def test_having_join_and_equality(self): + q = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.foo) + .select(self.table_abc.foo, fn.Sum(self.table_efg.bar), self.table_abc.buz) + .groupby(self.table_abc.foo) + .having(self.table_abc.buz == "fiz") + .having(fn.Sum(self.table_efg.bar) > 100) + ) + + self.assertEqual( + 'SELECT "abc"."foo",SUM("efg"."bar"),"abc"."buz" FROM "abc" ' + 'JOIN "efg" ON "abc"."foo"="efg"."foo" ' + 'GROUP BY "abc"."foo" ' + 'HAVING "abc"."buz"=\'fiz\' AND SUM("efg"."bar")>100', + str(q), + ) + + def test_mysql_query_uses_backtick_quote_chars(self): + q = ( + MySQLQuery.from_(self.table_abc) + .select(self.table_abc.foo) + .groupby(self.table_abc.foo) + .having(self.table_abc.buz == "fiz") + ) + self.assertEqual("SELECT `foo` FROM `abc` GROUP BY `foo` HAVING `buz`='fiz'", str(q)) + + def test_vertica_query_uses_double_quote_chars(self): + q = ( + VerticaQuery.from_(self.table_abc) + .select(self.table_abc.foo) + .groupby(self.table_abc.foo) + .having(self.table_abc.buz == "fiz") + ) + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo" HAVING "buz"=\'fiz\'', str(q)) + + def test_mssql_query_uses_double_quote_chars(self): + q = ( + MSSQLQuery.from_(self.table_abc) + .select(self.table_abc.foo) + .groupby(self.table_abc.foo) + .having(self.table_abc.buz == "fiz") + ) + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo" HAVING "buz"=\'fiz\'', str(q)) + + def test_oracle_query_uses_no_quote_chars(self): + q = ( + OracleQuery.from_(self.table_abc) + .select(self.table_abc.foo) + .groupby(self.table_abc.foo) + .having(self.table_abc.buz == "fiz") + ) + self.assertEqual('SELECT foo FROM abc GROUP BY foo HAVING buz=\'fiz\'', str(q)) + + def test_postgres_query_uses_double_quote_chars(self): + q = ( + PostgreSQLQuery.from_(self.table_abc) + .select(self.table_abc.foo) + .groupby(self.table_abc.foo) + .having(self.table_abc.buz == "fiz") + ) + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo" HAVING "buz"=\'fiz\'', str(q)) + + def test_redshift_query_uses_double_quote_chars(self): + q = ( + RedshiftQuery.from_(self.table_abc) + .select(self.table_abc.foo) + .groupby(self.table_abc.foo) + .having(self.table_abc.buz == "fiz") + ) + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo" HAVING "buz"=\'fiz\'', str(q)) + + +class OrderByTests(unittest.TestCase): + t = Table("abc") + + def test_orderby_single_field(self): + q = Query.from_(self.t).orderby(self.t.foo).select(self.t.foo) + + self.assertEqual('SELECT "foo" FROM "abc" ORDER BY "foo"', str(q)) + + def test_orderby_multi_fields(self): + q = Query.from_(self.t).orderby(self.t.foo, self.t.bar).select(self.t.foo, self.t.bar) + + self.assertEqual('SELECT "foo","bar" FROM "abc" ORDER BY "foo","bar"', str(q)) + + def test_orderby_single_str(self): + q = Query.from_("abc").orderby("foo").select("foo") + + self.assertEqual('SELECT "foo" FROM "abc" ORDER BY "foo"', str(q)) + + def test_orderby_asc(self): + q = Query.from_(self.t).orderby(self.t.foo, order=Order.asc).select(self.t.foo) + + self.assertEqual('SELECT "foo" FROM "abc" ORDER BY "foo" ASC', str(q)) + + def test_orderby_desc(self): + q = Query.from_(self.t).orderby(self.t.foo, order=Order.desc).select(self.t.foo) + + self.assertEqual('SELECT "foo" FROM "abc" ORDER BY "foo" DESC', str(q)) + + def test_orderby_no_alias(self): + bar = self.t.bar.as_("bar01") + q = Query.from_(self.t).select(fn.Sum(self.t.foo), bar).orderby(bar) + + self.assertEqual( + 'SELECT SUM("foo"),"bar" "bar01" FROM "abc" ORDER BY "bar"', + q.get_sql(orderby_alias=False), + ) + + def test_orderby_alias(self): + bar = self.t.bar.as_("bar01") + q = Query.from_(self.t).select(fn.Sum(self.t.foo), bar).orderby(bar) + + self.assertEqual('SELECT SUM("foo"),"bar" "bar01" FROM "abc" ORDER BY "bar01"', q.get_sql()) + + +class AliasTests(unittest.TestCase): + t = Table("abc") + + def test_table_field(self): + q = Query.from_(self.t).select(self.t.foo.as_("bar")) + + self.assertEqual('SELECT "foo" "bar" FROM "abc"', str(q)) + + def test_table_field__multi(self): + q = Query.from_(self.t).select(self.t.foo.as_("bar"), self.t.fiz.as_("buz")) + + self.assertEqual('SELECT "foo" "bar","fiz" "buz" FROM "abc"', str(q)) + + def test_arithmetic_function(self): + q = Query.from_(self.t).select((self.t.foo + self.t.bar).as_("biz")) + + self.assertEqual('SELECT "foo"+"bar" "biz" FROM "abc"', str(q)) + + def test_functions_using_as(self): + q = Query.from_(self.t).select(fn.Count("*").as_("foo")) + + self.assertEqual('SELECT COUNT(*) "foo" FROM "abc"', str(q)) + + def test_functions_using_constructor_param(self): + q = Query.from_(self.t).select(fn.Count("*", alias="foo")) + + self.assertEqual('SELECT COUNT(*) "foo" FROM "abc"', str(q)) + + def test_function_using_as_nested(self): + """ + We don't show aliases of fields that are arguments of a function. + """ + q = Query.from_(self.t).select(fn.Sqrt(fn.Count("*").as_("foo")).as_("bar")) + + self.assertEqual('SELECT SQRT(COUNT(*)) "bar" FROM "abc"', str(q)) + + def test_functions_using_constructor_param_nested(self): + """ + We don't show aliases of fields that are arguments of a function. + """ + q = Query.from_(self.t).select(fn.Sqrt(fn.Count("*", alias="foo"), alias="bar")) + + self.assertEqual('SELECT SQRT(COUNT(*)) "bar" FROM "abc"', str(q)) + + def test_ignored_in_where(self): + q = Query.from_(self.t).select(self.t.foo).where(self.t.foo.as_("bar") == 1) + + self.assertEqual('SELECT "foo" FROM "abc" WHERE "foo"=1', str(q)) + + def test_ignored_in_groupby(self): + q = Query.from_(self.t).select(self.t.foo).groupby(self.t.foo.as_("bar")) + + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo"', str(q)) + + def test_ignored_in_orderby(self): + q = Query.from_(self.t).select(self.t.foo).orderby(self.t.foo.as_("bar")) + + self.assertEqual('SELECT "foo" FROM "abc" ORDER BY "foo"', str(q)) + + def test_ignored_in_criterion(self): + c = self.t.foo.as_("bar") == 1 + + self.assertEqual('"foo"=1', str(c)) + + def test_ignored_in_criterion_comparison(self): + c = self.t.foo.as_("bar") == self.t.fiz.as_("buz") + + self.assertEqual('"foo"="fiz"', str(c)) + + def test_ignored_in_field_inside_case(self): + q = Query.from_(self.t).select(Case().when(self.t.foo == 1, "a").else_(self.t.bar.as_('"buz"'))) + + self.assertEqual('SELECT CASE WHEN "foo"=1 THEN \'a\' ELSE "bar" END FROM "abc"', str(q)) + + def test_case_using_as(self): + q = Query.from_(self.t).select(Case().when(self.t.foo == 1, "a").else_("b").as_("bar")) + + self.assertEqual( + 'SELECT CASE WHEN "foo"=1 THEN \'a\' ELSE \'b\' END "bar" FROM "abc"', + str(q), + ) + + def test_case_using_constructor_param(self): + q = Query.from_(self.t).select(Case(alias="bar").when(self.t.foo == 1, "a").else_("b")) + + self.assertEqual( + 'SELECT CASE WHEN "foo"=1 THEN \'a\' ELSE \'b\' END "bar" FROM "abc"', + str(q), + ) + + def test_select__multiple_tables(self): + table_abc, table_efg = Table("abc", alias="q0"), Table("efg", alias="q1") + + q = Query.from_(table_abc).select(table_abc.foo).from_(table_efg).select(table_efg.bar) + + self.assertEqual('SELECT "q0"."foo","q1"."bar" FROM "abc" "q0","efg" "q1"', str(q)) + + def test_use_aliases_in_groupby_and_orderby(self): + table_abc = Table("abc", alias="q0") + + my_foo = table_abc.foo.as_("my_foo") + q = Query.from_(table_abc).select(my_foo, table_abc.bar).groupby(my_foo).orderby(my_foo) + + self.assertEqual( + 'SELECT "q0"."foo" "my_foo","q0"."bar" ' 'FROM "abc" "q0" ' 'GROUP BY "my_foo" ' 'ORDER BY "my_foo"', + str(q), + ) + + def test_table_with_schema_and_alias(self): + table = Table("abc", schema="schema", alias="alias") + self.assertEqual('"schema"."abc" "alias"', str(table)) + + def test_null_value_with_alias(self): + q = Query.select(NullValue().as_("abcdef")) + + self.assertEqual('SELECT NULL "abcdef"', str(q)) + + +class SubqueryTests(unittest.TestCase): + maxDiff = None + + table_abc, table_efg, table_hij = Tables("abc", "efg", "hij") + + def test_where__in(self): + q = ( + Query.from_(self.table_abc) + .select("*") + .where( + self.table_abc.foo.isin( + Query.from_(self.table_efg).select(self.table_efg.foo).where(self.table_efg.bar == 0) + ) + ) + ) + + self.assertEqual( + 'SELECT * FROM "abc" WHERE "foo" IN (SELECT "foo" FROM "efg" WHERE "bar"=0)', + str(q), + ) + + def test_where__in_nested(self): + q = Query.from_(self.table_abc).select("*").where(self.table_abc.foo).isin(self.table_efg.select("*")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" IN (SELECT * FROM "efg")', str(q)) + + def test_join(self): + subquery = Query.from_("efg").select("fiz", "buz").where(F("buz") == 0) + + q = ( + Query.from_(self.table_abc) + .join(subquery) + .on(self.table_abc.bar == subquery.buz) + .select(self.table_abc.foo, subquery.fiz) + ) + + self.assertEqual( + 'SELECT "abc"."foo","sq0"."fiz" FROM "abc" ' + 'JOIN (SELECT "fiz","buz" FROM "efg" WHERE "buz"=0) "sq0" ' + 'ON "abc"."bar"="sq0"."buz"', + str(q), + ) + + def test_select_subquery(self): + subq = Query.from_(self.table_efg).select("fizzbuzz").where(self.table_efg.id == 1) + + q = Query.from_(self.table_abc).select("foo", "bar").select(subq) + + self.assertEqual( + 'SELECT "foo","bar",(SELECT "fizzbuzz" FROM "efg" WHERE "id"=1) ' 'FROM "abc"', + str(q), + ) + + def test_select_subquery_with_alias(self): + subq = Query.from_(self.table_efg).select("fizzbuzz").where(self.table_efg.id == 1) + + q = Query.from_(self.table_abc).select("foo", "bar").select(subq.as_("sq")) + + self.assertEqual( + 'SELECT "foo","bar",(SELECT "fizzbuzz" FROM "efg" WHERE "id"=1) "sq" ' 'FROM "abc"', + str(q), + ) + + def test_where__equality(self): + subquery = Query.from_("efg").select("fiz").where(F("buz") == 0) + query = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, self.table_abc.bar) + .where(self.table_abc.bar == subquery) + ) + + self.assertEqual( + 'SELECT "foo","bar" FROM "abc" ' 'WHERE "bar"=(SELECT "fiz" FROM "efg" WHERE "buz"=0)', + str(query), + ) + + def test_select_from_nested_query(self): + subquery = Query.from_(self.table_abc).select( + self.table_abc.foo, + self.table_abc.bar, + (self.table_abc.fizz + self.table_abc.buzz).as_("fizzbuzz"), + ) + + query = Query.from_(subquery).select(subquery.foo, subquery.bar, subquery.fizzbuzz) + + self.assertEqual( + 'SELECT "sq0"."foo","sq0"."bar","sq0"."fizzbuzz" ' + "FROM (" + 'SELECT "foo","bar","fizz"+"buzz" "fizzbuzz" ' + 'FROM "abc"' + ') "sq0"', + str(query), + ) + + def test_select_from_nested_query_with_join(self): + subquery1 = ( + Query.from_(self.table_abc) + .select( + self.table_abc.foo, + fn.Sum(self.table_abc.fizz + self.table_abc.buzz).as_("fizzbuzz"), + ) + .groupby(self.table_abc.foo) + ) + + subquery2 = Query.from_(self.table_efg).select( + self.table_efg.foo.as_("foo_two"), + self.table_efg.bar, + ) + + query = ( + Query.from_(subquery1) + .select(subquery1.foo, subquery1.fizzbuzz) + .join(subquery2) + .on(subquery1.foo == subquery2.foo_two) + .select(subquery2.foo_two, subquery2.bar) + ) + + self.assertEqual( + "SELECT " + '"sq0"."foo","sq0"."fizzbuzz",' + '"sq1"."foo_two","sq1"."bar" ' + "FROM (" + "SELECT " + '"foo",SUM("fizz"+"buzz") "fizzbuzz" ' + 'FROM "abc" ' + 'GROUP BY "foo"' + ') "sq0" JOIN (' + "SELECT " + '"foo" "foo_two","bar" ' + 'FROM "efg"' + ') "sq1" ON "sq0"."foo"="sq1"."foo_two"', + str(query), + ) + + def test_from_subquery_without_alias(self): + subquery = Query.from_(self.table_efg).select( + self.table_efg.base_id.as_("x"), self.table_efg.fizz, self.table_efg.buzz + ) + + test_query = Query.from_(subquery).select(subquery.x, subquery.fizz, subquery.buzz) + + self.assertEqual( + 'SELECT "sq0"."x","sq0"."fizz","sq0"."buzz" ' + "FROM (" + 'SELECT "base_id" "x","fizz","buzz" FROM "efg"' + ') "sq0"', + str(test_query), + ) + + def test_join_query_with_alias(self): + subquery = ( + Query.from_(self.table_efg) + .select( + self.table_efg.base_id.as_("x"), + self.table_efg.fizz, + self.table_efg.buzz, + ) + .as_("subq") + ) + + test_query = Query.from_(subquery).select(subquery.x, subquery.fizz, subquery.buzz) + + self.assertEqual( + 'SELECT "subq"."x","subq"."fizz","subq"."buzz" ' + "FROM (" + 'SELECT "base_id" "x","fizz","buzz" FROM "efg"' + ') "subq"', + str(test_query), + ) + + def test_with(self): + sub_query = Query.from_(self.table_efg).select("fizz") + test_query = Query.with_(sub_query, "an_alias").from_(AliasedQuery("an_alias")).select("*") + + self.assertEqual( + 'WITH an_alias AS (SELECT "fizz" FROM "efg") SELECT * FROM an_alias', + str(test_query), + ) + + def test_join_with_with(self): + sub_query = Query.from_(self.table_efg).select("fizz") + test_query = ( + Query.with_(sub_query, "an_alias") + .from_(self.table_abc) + .join(AliasedQuery("an_alias")) + .on(AliasedQuery("an_alias").fizz == self.table_abc.buzz) + .select("*") + ) + self.assertEqual( + 'WITH an_alias AS (SELECT "fizz" FROM "efg") ' + 'SELECT * FROM "abc" JOIN an_alias ON "an_alias"."fizz"="abc"."buzz"', + str(test_query), + ) + + def test_select_from_with_returning(self): + sub_query = PostgreSQLQuery.into(self.table_abc).insert(1).returning('*') + test_query = Query.with_(sub_query, "an_alias").from_(AliasedQuery("an_alias")).select("*") + self.assertEqual( + 'WITH an_alias AS (INSERT INTO "abc" VALUES (1) RETURNING *) SELECT * FROM an_alias', str(test_query) + ) + + +class QuoteTests(unittest.TestCase): + def test_extraneous_quotes(self): + t1 = Table("table1", alias="t1") + t2 = Table("table2", alias="t2") + + query = Query.from_(t1).join(t2).on(t1.Value.between(t2.start, t2.end)).select(t1.value) + + self.assertEqual( + "SELECT t1.value FROM table1 t1 " "JOIN table2 t2 ON t1.Value " "BETWEEN t2.start AND t2.end", + query.get_sql(quote_char=None), + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/test_tables.py b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/test_tables.py new file mode 100644 index 0000000000000000000000000000000000000000..f43e740915f642d29ce7497c36e3b68f01311016 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/test_tables.py @@ -0,0 +1,186 @@ +# from pypika.terms import ValueWrapper, SystemTimeValue +import unittest + +from pypika import Database, Dialects, Schema, SQLLiteQuery, Table, Tables, Query, SYSTEM_TIME + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + + +class TableStructureTests(unittest.TestCase): + def test_table_sql(self): + table = Table("test_table") + + self.assertEqual('"test_table"', str(table)) + + def test_table_with_alias(self): + table = Table("test_table").as_("my_table") + + self.assertEqual('"test_table" "my_table"', table.get_sql(with_alias=True, quote_char='"')) + + def test_schema_table_attr(self): + table = Schema("x_schema").test_table + + self.assertEqual('"x_schema"."test_table"', str(table)) + + def test_table_with_schema_arg(self): + table = Table("test_table", schema=Schema("x_schema")) + + self.assertEqual('"x_schema"."test_table"', str(table)) + + def test_database_schema_table_attr(self): + table = Database("x_db").x_schema.test_table + + self.assertEqual('"x_db"."x_schema"."test_table"', str(table)) + + def test_table_with_schema_and_schema_parent_arg(self): + table = Table("test_table", schema=Schema("x_schema", parent=Database("x_db"))) + + self.assertEqual('"x_db"."x_schema"."test_table"', str(table)) + + def test_table_for_system_time_sql(self): + with self.subTest("with between criterion"): + table = Table("test_table").for_(SYSTEM_TIME.between('2020-01-01', '2020-02-01')) + + self.assertEqual('"test_table" FOR SYSTEM_TIME BETWEEN \'2020-01-01\' AND \'2020-02-01\'', str(table)) + + with self.subTest("with as of criterion"): + table = Table("test_table").for_(SYSTEM_TIME.as_of('2020-01-01')) + + self.assertEqual('"test_table" FOR SYSTEM_TIME AS OF \'2020-01-01\'', str(table)) + + with self.subTest("with from to criterion"): + table = Table("test_table").for_(SYSTEM_TIME.from_to('2020-01-01', '2020-02-01')) + + self.assertEqual('"test_table" FOR SYSTEM_TIME FROM \'2020-01-01\' TO \'2020-02-01\'', str(table)) + + def test_table_for_period_sql(self): + with self.subTest("with between criterion"): + table = Table("test_table") + table = table.for_(table.valid_period.between('2020-01-01', '2020-02-01')) + + self.assertEqual('"test_table" FOR "valid_period" BETWEEN \'2020-01-01\' AND \'2020-02-01\'', str(table)) + + with self.subTest("with as of criterion"): + table = Table("test_table") + table = table.for_(table.valid_period.as_of('2020-01-01')) + + self.assertEqual('"test_table" FOR "valid_period" AS OF \'2020-01-01\'', str(table)) + + with self.subTest("with from to criterion"): + table = Table("test_table") + table = table.for_(table.valid_period.from_to('2020-01-01', '2020-02-01')) + + self.assertEqual('"test_table" FOR "valid_period" FROM \'2020-01-01\' TO \'2020-02-01\'', str(table)) + + +class TableEqualityTests(unittest.TestCase): + def test_tables_equal_by_name(self): + t1 = Table("t") + t2 = Table("t") + + self.assertEqual(t1, t2) + + def test_tables_equal_by_schema_and_name(self): + t1 = Table("t", schema="a") + t2 = Table("t", schema="a") + + self.assertEqual(t1, t2) + + def test_tables_equal_by_schema_and_name_using_schema(self): + a = Schema("a") + t1 = Table("t", schema=a) + t2 = Table("t", schema=a) + + self.assertEqual(t1, t2) + + def test_tables_equal_by_schema_and_name_using_schema_with_parent(self): + parent = Schema("parent") + a = Schema("a", parent=parent) + t1 = Table("t", schema=a) + t2 = Table("t", schema=a) + + self.assertEqual(t1, t2) + + def test_tables_not_equal_by_schema_and_name_using_schema_with_different_parents( + self, + ): + parent = Schema("parent") + a = Schema("a", parent=parent) + t1 = Table("t", schema=a) + t2 = Table("t", schema=Schema("a")) + + self.assertNotEqual(t1, t2) + + def test_tables_not_equal_with_different_schemas(self): + t1 = Table("t", schema="a") + t2 = Table("t", schema="b") + + self.assertNotEqual(t1, t2) + + def test_tables_not_equal_with_different_names(self): + t1 = Table("t", schema="a") + t2 = Table("q", schema="a") + + self.assertNotEqual(t1, t2) + + def test_many_tables_with_alias(self): + tables_data = [("table1", "t1"), ("table2", "t2"), ("table3", "t3")] + tables = Tables(*tables_data) + for el in tables: + self.assertIsNotNone(el.alias) + + def test_many_tables_without_alias(self): + tables_data = ["table1", "table2", "table3"] + tables = Tables(*tables_data) + for el in tables: + self.assertIsNone(el.alias) + + def test_many_tables_with_or_not_alias(self): + tables_data = [("table1", "t1"), ("table2"), "table3"] + tables = Tables(*tables_data) + for i in range(len(tables)): + if isinstance(tables_data[i], tuple): + self.assertIsNotNone(tables[i].alias) + else: + self.assertIsNone(tables[i].alias) + + +class TableDialectTests(unittest.TestCase): + def test_table_with_default_query_cls(self): + table = Table("abc") + q = table.select("1") + self.assertIs(q.dialect, None) + + def test_table_with_dialect_query_cls(self): + table = Table("abc", query_cls=SQLLiteQuery) + q = table.select("1") + self.assertIs(q.dialect, Dialects.SQLLITE) + + def test_table_factory_with_default_query_cls(self): + table = Query.Table("abc") + q = table.select("1") + self.assertIs(q.dialect, None) + + def test_table_factory_with_dialect_query_cls(self): + table = SQLLiteQuery.Table("abc") + q = table.select("1") + self.assertIs(q.dialect, Dialects.SQLLITE) + + def test_make_tables_factory_with_default_query_cls(self): + t1, t2 = Query.Tables("abc", "def") + q1 = t1.select("1") + q2 = t2.select("2") + self.assertIs(q1.dialect, None) + self.assertIs(q2.dialect, None) + + def test_make_tables_factory_with_dialect_query_cls(self): + t1, t2 = SQLLiteQuery.Tables("abc", "def") + q1 = t1.select("1") + q2 = t2.select("2") + self.assertIs(q1.dialect, Dialects.SQLLITE) + self.assertIs(q2.dialect, Dialects.SQLLITE) + + def test_table_with_bad_query_cls(self): + with self.assertRaises(TypeError): + Table("abc", query_cls=object) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/test_terms.py b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/test_terms.py new file mode 100644 index 0000000000000000000000000000000000000000..4c7590dfce129bac97a3f30de99b596cc746c893 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/test_terms.py @@ -0,0 +1,82 @@ +from unittest import TestCase + +from pypika import Query, Table, Field +from pypika.terms import AtTimezone + + +class FieldAliasTests(TestCase): + t = Table("test", alias="crit") + + def test_when_alias_specified(self): + c1 = Field("foo", alias="bar") + self.assertEqual('bar', str(c1.alias)) + + c1 = Field("foo").as_("bar") + self.assertEqual('bar', str(c1.alias)) + + +class FieldInitTests(TestCase): + def test_init_with_str_table(self): + test_table_name = "test_table" + field = Field(name="name", table=test_table_name) + self.assertEqual(field.table, Table(name=test_table_name)) + + +class FieldHashingTests(TestCase): + def test_tabled_eq_fields_equally_hashed(self): + client_name1 = Field(name="name", table=Table("clients")) + client_name2 = Field(name="name", table=Table("clients")) + self.assertTrue(hash(client_name1) == hash(client_name2)) + + def test_tabled_ne_fields_differently_hashed(self): + customer_name = Field(name="name", table=Table("customers")) + client_name = Field(name="name", table=Table("clients")) + self.assertTrue(hash(customer_name) != hash(client_name)) + + def test_non_tabled_aliased_eq_fields_equally_hashed(self): + self.assertTrue(hash(Field(name="A", alias="my_a")) == hash(Field(name="A", alias="my_a"))) + + def test_non_tabled_aliased_ne_fields_differently_hashed(self): + self.assertTrue(hash(Field(name="A", alias="my_a1")) != hash(Field(name="A", alias="my_a2"))) + + def test_non_tabled_eq_fields_equally_hashed(self): + self.assertTrue(hash(Field(name="A")) == hash(Field(name="A"))) + + def test_non_tabled_ne_fields_differently_hashed(self): + self.assertTrue(hash(Field(name="A")) != hash(Field(name="B"))) + + +class AtTimezoneTests(TestCase): + def test_when_interval_not_specified(self): + query = Query.from_("customers").select(AtTimezone("date", "US/Eastern")) + self.assertEqual('SELECT "date" AT TIME ZONE \'US/Eastern\' FROM "customers"', str(query)) + + def test_when_interval_specified(self): + query = Query.from_("customers").select(AtTimezone("date", "-06:00", interval=True)) + self.assertEqual( + 'SELECT "date" AT TIME ZONE INTERVAL \'-06:00\' FROM "customers"', + str(query), + ) + + def test_when_alias_specified(self): + query = Query.from_("customers").select(AtTimezone("date", "US/Eastern", alias="alias1")) + self.assertEqual( + 'SELECT "date" AT TIME ZONE \'US/Eastern\' "alias1" FROM "customers"', + str(query), + ) + + def test_passes_kwargs_to_field_get_sql(self): + customers = Table("customers") + accounts = Table("accounts") + query = ( + Query.from_(customers) + .join(accounts) + .on(customers.account_id == accounts.account_id) + .select(AtTimezone(customers.date, "US/Eastern", alias="alias1")) + ) + + self.assertEqual( + 'SELECT "customers"."date" AT TIME ZONE \'US/Eastern\' "alias1" ' + 'FROM "customers" JOIN "accounts" ON "customers"."account_id"="accounts"."account_id"', + query.get_sql(with_namespace=True), + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/test_tuples.py b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/test_tuples.py new file mode 100644 index 0000000000000000000000000000000000000000..c8ebc8e41b0115777f8b3c8cb01c04e62f13ee18 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/test_tuples.py @@ -0,0 +1,162 @@ +import unittest + +from pypika import ( + Array, + Bracket, + Query, + PostgreSQLQuery, + Table, + Tables, + Tuple, +) +from pypika.functions import Coalesce, NullIf, Sum +from pypika.terms import Field + + +class TupleTests(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_tuple_equality_tuple_on_both(self): + q = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, self.table_abc.bar) + .where(Tuple(self.table_abc.foo, self.table_abc.bar) == Tuple(1, 2)) + ) + + self.assertEqual('SELECT "foo","bar" FROM "abc" ' 'WHERE ("foo","bar")=(1,2)', str(q)) + + def test_tuple_equality_tuple_on_left(self): + q = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, self.table_abc.bar) + .where(Tuple(self.table_abc.foo, self.table_abc.bar) == (1, 2)) + ) + + self.assertEqual('SELECT "foo","bar" FROM "abc" ' 'WHERE ("foo","bar")=(1,2)', str(q)) + + def test_tuple_equality_tuple_on_right(self): + q = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, self.table_abc.bar) + .where((self.table_abc.foo, self.table_abc.bar) == Tuple(1, 2)) + ) + + # Order is reversed due to lack of right equals method + self.assertEqual('SELECT "foo","bar" FROM "abc" ' 'WHERE (1,2)=("foo","bar")', str(q)) + + def test_tuple_in_using_python_tuples(self): + q = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, self.table_abc.bar) + .where(Tuple(self.table_abc.foo, self.table_abc.bar).isin([(1, 1), (2, 2), (3, 3)])) + ) + + self.assertEqual( + 'SELECT "foo","bar" FROM "abc" ' 'WHERE ("foo","bar") IN ((1,1),(2,2),(3,3))', + str(q), + ) + + def test_tuple_in_using_pypika_tuples(self): + q = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, self.table_abc.bar) + .where(Tuple(self.table_abc.foo, self.table_abc.bar).isin([Tuple(1, 1), Tuple(2, 2), Tuple(3, 3)])) + ) + + self.assertEqual( + 'SELECT "foo","bar" FROM "abc" ' 'WHERE ("foo","bar") IN ((1,1),(2,2),(3,3))', + str(q), + ) + + def test_tuple_in_using_mixed_tuples(self): + q = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, self.table_abc.bar) + .where(Tuple(self.table_abc.foo, self.table_abc.bar).isin([(1, 1), Tuple(2, 2), (3, 3)])) + ) + + self.assertEqual( + 'SELECT "foo","bar" FROM "abc" ' 'WHERE ("foo","bar") IN ((1,1),(2,2),(3,3))', + str(q), + ) + + def test_tuples_in_join(self): + query = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .select("*") + .where(Tuple(self.table_abc.foo, self.table_efg.bar).isin([(1, 1), Tuple(2, 2), (3, 3)])) + ) + + self.assertEqual( + 'SELECT * FROM "abc" JOIN "efg" ON "abc"."foo"="efg"."bar" ' + 'WHERE ("abc"."foo","efg"."bar") IN ((1,1),(2,2),(3,3))', + str(query), + ) + + def test_render_alias_in_array_sql(self): + tb = Table("tb") + + q = Query.from_(tb).select(Tuple(tb.col).as_("different_name")) + self.assertEqual(str(q), 'SELECT ("col") "different_name" FROM "tb"') + + def test_tuple_is_aggregate(self): + with self.subTest('None if single argument returns None for is_aggregate'): + self.assertEqual(None, Tuple(0).is_aggregate) + self.assertEqual(None, Tuple(Coalesce('col')).is_aggregate) + + with self.subTest('None if multiple arguments all return None for is_aggregate'): + self.assertEqual(None, Tuple(0, 'a').is_aggregate) + self.assertEqual(None, Tuple(Coalesce('col'), NullIf('col2', 0)).is_aggregate) + + with self.subTest('True if single argument returns True for is_aggregate'): + self.assertEqual(True, Tuple(Sum('col')).is_aggregate) + + with self.subTest('True if multiple arguments return True for is_aggregate'): + self.assertEqual(True, Tuple(Sum('col'), Sum('col2')).is_aggregate) + + with self.subTest('True when mix of arguments returning None and True for is_aggregate'): + self.assertEqual(True, Tuple(Coalesce('col'), Coalesce('col2', 0), Sum('col3')).is_aggregate) + + with self.subTest('False when one of the arguments returns False for is_aggregate'): + self.assertEqual(False, Tuple(Field('col1'), Sum('col2')).is_aggregate) + + +class ArrayTests(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_array_general(self): + query = Query.from_(self.table_abc).select(Array(1, "a", ["b", 2, 3])) + + self.assertEqual("SELECT [1,'a',['b',2,3]] FROM \"abc\"", str(query)) + + def test_empty_psql_array(self): + query = PostgreSQLQuery.from_(self.table_abc).select(Array()) + + self.assertEqual("SELECT '{}' FROM \"abc\"", str(query)) + + def test_psql_array_general(self): + query = PostgreSQLQuery.from_(self.table_abc).select(Array(1, Array(2, 2, 2), 3)) + + self.assertEqual("SELECT ARRAY[1,ARRAY[2,2,2],3] FROM \"abc\"", str(query)) + + def test_render_alias_in_array_sql(self): + tb = Table("tb") + + q = Query.from_(tb).select(Array(tb.col).as_("different_name")) + self.assertEqual(str(q), 'SELECT ["col"] "different_name" FROM "tb"') + + +class BracketTests(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_arithmetic_with_brackets(self): + q = Query.from_(self.table_abc).select(Bracket(self.table_abc.foo / 2) / 2) + + self.assertEqual('SELECT ("foo"/2)/2 FROM "abc"', str(q)) + + def test_arithmetic_with_brackets_and_alias(self): + q = Query.from_(self.table_abc).select(Bracket(self.table_abc.foo / 2).as_("alias")) + + self.assertEqual('SELECT ("foo"/2) "alias" FROM "abc"', str(q)) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/test_updates.py b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/test_updates.py new file mode 100644 index 0000000000000000000000000000000000000000..fb9d714dbcb8213b4bda04bf7b8dd9b2419410ec --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/test_updates.py @@ -0,0 +1,162 @@ +import unittest + +from pypika import AliasedQuery, PostgreSQLQuery, Query, SQLLiteQuery, SYSTEM_TIME, Table + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + +from pypika.terms import Star + + +class UpdateTests(unittest.TestCase): + table_abc = Table("abc") + table_def = Table("def") + + def test_empty_query(self): + q = Query.update("abc") + + self.assertEqual("", str(q)) + + def test_omit_where(self): + q = Query.update(self.table_abc).set("foo", "bar") + + self.assertEqual('UPDATE "abc" SET "foo"=\'bar\'', str(q)) + + def test_single_quote_escape_in_set(self): + q = Query.update(self.table_abc).set("foo", "bar'foo") + + self.assertEqual("UPDATE \"abc\" SET \"foo\"='bar''foo'", str(q)) + + def test_update__table_schema(self): + table = Table("abc", "schema1") + q = Query.update(table).set(table.foo, 1).where(table.foo == 0) + + self.assertEqual('UPDATE "schema1"."abc" SET "foo"=1 WHERE "foo"=0', str(q)) + + def test_update_with_none(self): + q = Query.update("abc").set("foo", None) + self.assertEqual('UPDATE "abc" SET "foo"=null', str(q)) + + def test_update_with_join(self): + q = ( + Query.update(self.table_abc) + .join(self.table_def) + .on(self.table_def.abc_id == self.table_abc.id) + .set(self.table_abc.lname, self.table_def.lname) + ) + self.assertEqual( + 'UPDATE "abc" JOIN "def" ON "def"."abc_id"="abc"."id" SET "lname"="def"."lname"', + str(q), + ) + + def test_update_with_limit(self): + q = Query.update(self.table_abc).set(self.table_abc.lname, "test").limit(1) + self.assertEqual('UPDATE "abc" SET "lname"=\'test\' LIMIT 1', str(q)) + + def test_update_from(self): + from_table = Table('from_table') + + q = Query.update(self.table_abc).set(self.table_abc.lname, from_table.long_name).from_(from_table) + self.assertEqual('UPDATE "abc" SET "lname"="from_table"."long_name" FROM "from_table"', str(q)) + + def test_update_from_with_where(self): + from_table = Table('from_table') + + q = ( + Query.update(self.table_abc) + .set(self.table_abc.lname, from_table.long_name) + .from_(from_table) + .where(self.table_abc.fname.eq(from_table.full_name)) + ) + self.assertEqual( + 'UPDATE "abc" SET "lname"="from_table"."long_name" FROM "from_table" ' + 'WHERE "abc"."fname"="from_table"."full_name"', + str(q), + ) + + def test_update_with_statement(self): + table_efg = Table('efg') + + sub_query = Query.from_(table_efg).select("fizz") + an_alias = AliasedQuery("an_alias") + + q = ( + Query.with_(sub_query, "an_alias") + .update(self.table_abc) + .from_(an_alias) + .set(self.table_abc.lname, an_alias.long_name) + .where(self.table_abc.comp.eq(an_alias.alias_comp)) + ) + self.assertEqual( + 'WITH an_alias AS (SELECT "fizz" FROM "efg") ' + 'UPDATE "abc" SET "lname"="an_alias"."long_name" FROM an_alias ' + 'WHERE "abc"."comp"="an_alias"."alias_comp"', + str(q), + ) + + def test_for_portion(self): + with self.subTest("with system time"): + q = Query.update(self.table_abc.for_portion(SYSTEM_TIME.from_to('2020-01-01', '2020-02-01'))).set( + "foo", "bar" + ) + + self.assertEqual( + 'UPDATE "abc" FOR PORTION OF SYSTEM_TIME FROM \'2020-01-01\' TO \'2020-02-01\' SET "foo"=\'bar\'', + str(q), + ) + + with self.subTest("with column"): + q = Query.update( + self.table_abc.for_portion(self.table_abc.valid_period.from_to('2020-01-01', '2020-02-01')) + ).set("foo", "bar") + + self.assertEqual( + 'UPDATE "abc" FOR PORTION OF "valid_period" FROM \'2020-01-01\' TO \'2020-02-01\' SET "foo"=\'bar\'', + str(q), + ) + + +class PostgresUpdateTests(unittest.TestCase): + table_abc = Table("abc") + + def test_update_returning_str(self): + q = PostgreSQLQuery.update(self.table_abc).where(self.table_abc.foo == 0).set("foo", "bar").returning("id") + + self.assertEqual('UPDATE "abc" SET "foo"=\'bar\' WHERE "foo"=0 RETURNING "abc"."id"', str(q)) + + def test_update_returning(self): + q = ( + PostgreSQLQuery.update(self.table_abc) + .where(self.table_abc.foo == 0) + .set("foo", "bar") + .returning(self.table_abc.id) + ) + + self.assertEqual('UPDATE "abc" SET "foo"=\'bar\' WHERE "foo"=0 RETURNING "abc"."id"', str(q)) + + def test_update_returning_from_different_tables(self): + table_bcd = Table('bcd') + + q = ( + PostgreSQLQuery.update(self.table_abc) + .from_(table_bcd) + .set(self.table_abc.lname, table_bcd.long_name) + .returning(self.table_abc.id, table_bcd.fname) + ) + self.assertEqual( + 'UPDATE "abc" SET "lname"="bcd"."long_name" FROM "bcd" RETURNING "abc"."id","bcd"."fname"', str(q) + ) + + def test_update_returning_star(self): + q = PostgreSQLQuery.update(self.table_abc).where(self.table_abc.foo == 0).set("foo", "bar").returning(Star()) + + self.assertEqual('UPDATE "abc" SET "foo"=\'bar\' WHERE "foo"=0 RETURNING *', str(q)) + + +class SQLLiteUpdateTests(unittest.TestCase): + table_abc = Table("abc") + + def test_update_with_bool(self): + q = SQLLiteQuery.update(self.table_abc).set(self.table_abc.foo, True) + + self.assertEqual('UPDATE "abc" SET "foo"=1', str(q)) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/test_utils.py b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/test_utils.py new file mode 100644 index 0000000000000000000000000000000000000000..bb9a9b1c68fe8671989f7c49f9db90e389d06f59 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pypika/tests/test_utils.py @@ -0,0 +1,24 @@ +import unittest + +from pypika import utils + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + + +class ImmutabilityTests(unittest.TestCase): + def test_raise_attribute_error_for_deepcopy(self): + with self.assertRaises(AttributeError): + utils.raise_attribute_for_copy("Test", "__deepcopy__") + + def test_raise_attribute_error_for_getstate(self): + with self.assertRaises(AttributeError): + utils.raise_attribute_for_copy("Test", "__getstate__") + + def test_raise_attribute_error_for_setstate(self): + with self.assertRaises(AttributeError): + utils.raise_attribute_for_copy("Test", "__setstate__") + + def test_raise_attribute_error_for_getnewargs(self): + with self.assertRaises(AttributeError): + utils.raise_attribute_for_copy("Test", "__getnewargs__") diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pyproject.toml b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pyproject.toml new file mode 100644 index 0000000000000000000000000000000000000000..dcc56baede23e3571b336625e695c466ab833a56 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/pyproject.toml @@ -0,0 +1,22 @@ +[tool.black] +line-length = 120 +skip-string-normalization = true +target-version = ['py38', 'py39', 'py310', 'py311'] +force-exclude = ''' +( + /( + \.eggs # exclude a few common directories in the + | \.git # root of the project + | \.hg + | \.mypy_cache + | \.tox + | \.venv + | _build + | buck-out + | build + | dist + | docs + )/ + | setup.py +) +''' diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/setup.cfg b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/setup.cfg new file mode 100644 index 0000000000000000000000000000000000000000..46084aaf2ca9e95b2f9bb7680e432e637fc3ed90 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/setup.cfg @@ -0,0 +1,16 @@ +[bumpversion] +current_version = 0.48.9 +commit = True +tag = True + +[bumpversion:file:pypika/__init__.py] +search = __version__ = "{current_version}" +replace = __version__ = "{new_version}" + +[bdist_wheel] +universal = 1 + +[flake8] +exclude = docs, .git, __pycache__ +max-line-length = 120 +per-file-ignores = __init__.py:F401 diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/setup.py b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/setup.py new file mode 100644 index 0000000000000000000000000000000000000000..41cce7d742df3e33e8d76f267d77df486f69249a --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/setup.py @@ -0,0 +1,81 @@ +import ast + +from setuptools import setup + + +def readme(): + with open('README.rst', 'rb') as f: + return f.read().decode('UTF-8') + + +def version(): + path = 'pypika/__init__.py' + with open(path, 'r') as file: + t = compile(file.read(), path, 'exec', ast.PyCF_ONLY_AST) + for node in (n for n in t.body if isinstance(n, ast.Assign)): + if len(node.targets) == 1: + name = node.targets[0] + if isinstance(name, ast.Name) and name.id in ('__version__', '__version_info__', 'VERSION'): + v = node.value + if isinstance(v, ast.Str): + return v.s + + if isinstance(v, ast.Tuple): + r = [] + for e in v.elts: + if isinstance(e, ast.Str): + r.append(e.s) + elif isinstance(e, ast.Num): + r.append(str(e.n)) + return '.'.join(r) + + +setup( + # Application name: + name="PyPika", + + # Version number: + version=version(), + + # Application author details: + author="Timothy Heys", + author_email="theys@kayak.com", + + # License + license='Apache License Version 2.0', + + # Packages + packages=["pypika", "pypika.clickhouse"], + + # Include additional files into the package + package_data={"pypika": ["py.typed"]}, + include_package_data=True, + + install_requires=[], + + # Details + url="https://github.com/kayak/pypika", + + description="A SQL query builder API for Python", + long_description=readme(), + + classifiers=[ + 'License :: OSI Approved :: Apache Software License', + 'Development Status :: 5 - Production/Stable', + 'Intended Audience :: Developers', + 'Programming Language :: Python :: 3', + 'Programming Language :: PL/SQL', + 'Topic :: Software Development :: Libraries :: Python Modules', + 'Topic :: Scientific/Engineering :: Information Analysis', + 'Topic :: Scientific/Engineering :: Mathematics', + 'Operating System :: POSIX', + 'Operating System :: MacOS :: MacOS X', + 'Operating System :: Microsoft :: Windows', + ], + keywords=('pypika python query builder querybuilder sql mysql postgres psql oracle vertica aggregated ' + 'relational database rdbms business analytics bi data science analysis pandas ' + 'orm object mapper'), + + # Dependent packages (distributions) + test_suite="pypika.tests", +) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/tox.ini b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/tox.ini new file mode 100644 index 0000000000000000000000000000000000000000..2f0e6893243b1ca2ead6a12825e9014dc66364ce --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/tests/trusted/tox.ini @@ -0,0 +1,16 @@ +[tox] +envlist = py38,py39,py310,py311,pypy3 + +[testenv] +description = testing against {basepython} +deps = -r requirements-dev.txt +commands = + coverage run + coverage xml + +[gh-actions] +python = + 3.8: py38 + 3.9: py39 + 3.10: py310 + 3.11: py311 diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/validation/canaries/first-hunk-only.sh b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/validation/canaries/first-hunk-only.sh new file mode 100644 index 0000000000000000000000000000000000000000..0991a6c5a73fbed6cdb285c483993318c438c723 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/validation/canaries/first-hunk-only.sh @@ -0,0 +1,22 @@ +#!/bin/bash +set -Eeuo pipefail +cd /testbed/repo +cat > /tmp/openenv-reference.diff <<'OPENENV_PARTIAL' +diff --git a/pypika/clickhouse/condition.py b/pypika/clickhouse/condition.py +index 46e2a0b8303c07f1d6b6d77b7f6d131ad3d8da3a..ed08224e22fb27eb18876595a542dcd3ad14bffc 100644 +--- a/pypika/clickhouse/condition.py ++++ b/pypika/clickhouse/condition.py +@@ -3,9 +3,9 @@ + + class If(Function): + def __init__(self, *conditions, **kwargs): +- super().__init__("switch", *reversed(conditions), **kwargs) ++ super().__init__("if", *conditions, **kwargs) + + + class MultiIf(Function): + def __init__(self, *conditions, **kwargs): +- super().__init__("multiIf", *conditions[::-1], **kwargs) ++ super().__init__("multiIf", *conditions, **kwargs) +OPENENV_PARTIAL +/usr/bin/git -c core.hooksPath=/dev/null -c core.fsmonitor=false apply --whitespace=nowarn /tmp/openenv-reference.diff diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/validation/canaries/original-bug.sh b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/validation/canaries/original-bug.sh new file mode 100644 index 0000000000000000000000000000000000000000..927547df786c86ab3bb5eeb917a31e0fa1895f8b --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/validation/canaries/original-bug.sh @@ -0,0 +1,3 @@ +#!/bin/bash +set -Eeuo pipefail +: diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/validation/openenv.json b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/validation/openenv.json new file mode 100644 index 0000000000000000000000000000000000000000..a13b3c577df494f6c894584d2b608ab051ebc44f --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__ahdnka55/validation/openenv.json @@ -0,0 +1,27 @@ +{ + "canaries": "validation/canaries", + "profile": "harbor-semantic-v1", + "requires_credentials": false, + "resources": { + "cpu": 2, + "disk_mb": 16384, + "episode_timeout_s": 1800, + "memory_mb": 8192 + }, + "reward": { + "floor_margin": 0.1, + "oracle_tolerance": 0, + "range": [ + 0, + 1 + ] + }, + "reward_key": "reward", + "types": { + "tags": [ + "swe", + "python", + "mutation-repair" + ] + } +} diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/LICENSE.source b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/LICENSE.source new file mode 100644 index 0000000000000000000000000000000000000000..9c8f3ea0871e0bfe81da0fa6e7c1d7d156dc380e --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/LICENSE.source @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. \ No newline at end of file diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/adapter.json b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/adapter.json new file mode 100644 index 0000000000000000000000000000000000000000..0dfd35ed02258016235bcdbde83487432ab1cdc2 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/adapter.json @@ -0,0 +1,135 @@ +{ + "canary_selection": "Fixed first provided gold hunk only when at least2hunks exist; strict subset, never reward-selected. Single-hunk task original-bug canary is explicitly NOP-equivalent and adds no signal beyond floor_gap.", + "collector_sha256": "352e555112f2de8a1393f939903e4971c9ace0e944843762b707a725c5c72481", + "dependency_installation_pinned": false, + "dependency_setup_sha256": "ed8673d02878e91c7ae0b51b9178d6a15792b79c6992f800c14a941d95242392", + "gold_patch_sha256": "4a212463e9e1f1dcc2f0b11b52fba56ee3952848ab5db0a2dea6a734cf2ea492", + "hostile_code_isolation_established": false, + "known_wrong_semantic_implementations": 0, + "native_inventory_sha256": "278ce1f3216b6826235bb141f79254b8047e3a7e049973cb93834a0aa054a44f", + "new_files_deletions_and_executable_modes_supported": true, + "official_profile": { + "eval_sets": [], + "profile_class": "Pypika1c9646f0", + "profile_lines": [ + 736, + 739 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "upstream_repo": "kayak/pypika" + }, + "original_bug_canary_nop_equivalent": true, + "original_bug_runtime_wrongness_established": false, + "partial_repair_canary": true, + "partial_repair_sha256": "0865e1ec349bd40283f359e00476deec94083a38fd01601c19f8b85d980e6708", + "partial_repair_wrongness_established": false, + "positive_approval_policy": "All original strict presence/identity/no-skip/no-error/exit checks retained", + "private_checker_sha256": "f0a641064b725415e23a0221bb53c90446d7efcb7f9ece5ede93a220d18dd9e7", + "private_checker_version": "matched-failure-precedence-v2", + "provided_original_bug_control": true, + "repo_url": "https://github.com/swesmith/kayak__pypika.1c9646f0.git", + "runtime_image": null, + "runtime_ready": false, + "runtime_recipe": { + "dependency_installation_pinned": false, + "official_install_cmds": [ + "python -m pip install -e ." + ], + "official_pytest_argv": [ + "pytest", + "--disable-warnings", + "--color=no", + "--tb=no", + "--verbose" + ], + "official_test_command": "source /opt/miniconda3/bin/activate; conda activate testbed; pytest --disable-warnings --color=no --tb=no --verbose", + "operator_test_runner_prerequisites": [ + "python -m pip install pytest==8.4.2" + ], + "operator_test_runner_reason": "The official profile invokes pytest, but the common tools runtime does not provide it; pinned separately from source-native project requirements.", + "panel_normalization": "Override project addopts only to execute the exact frozen native panels; add JUnit output, preserve official pytest options and all selectors.", + "python_version": "3.10", + "source_bound_test_dependency_cmds": [ + "python -m pip install parameterized==0.7.0" + ], + "test_dependency_source_sha256": { + "requirements-dev.txt": "10f4ba7b19a73950d28fd7403d7e1d1b1fe2ccc4f49516974f47199d2965f23d", + "setup.py": "f8bad274588a22e65764d8cf9fb2be5aa6fcfaf3bf861d71e5f751105898845a", + "tox.ini": "c2d7205d0ac93e9c9e80dc5d24f0a826a6781f587a33ea722ea621f9e2ccd0ea" + } + }, + "runtime_resource_review_required": false, + "schema": "python-git-patch-jobs-v1", + "source_base_commit": "2ee40ceddd23390bdae58631011aaa291503f59e", + "source_completion_sha256": "9b317963e894249732799934c1fe6a6c7cec025b781cb94853daf8fde50d4491", + "source_index_sha256": "e856874b9410fce9f3bfea52c8c482e84b3e43942d87517f8b55f0034bd40f6f", + "source_pr_url": null, + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:kayak__pypika.1c9646f0.combine_module__eai7xz1s", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "6a742f12bfa386994289ec8b75824663d8ee4b15", + "instruction_sha256": "10bc3d452213652bb8150e95ecff387d49cefbbcdc1471493a0f6cdb79b4b7e3", + "is_fork": true, + "learner_path": "tasks/d98023b831a6889e6e7ab746/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "actual_upstream_url": "https://raw.githubusercontent.com/kayak/pypika/1c9646f0a019a167c32b649b6f5e6423c5ba2c9b/LICENSE.txt", + "reviewed": true, + "sha256": "c5accbbd8546e94c34aed24afe689a617627d18eed5a6c48277e48db57c23851", + "spdx": "Apache-2.0", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/kayak__pypika.1c9646f0/2ee40ceddd23390bdae58631011aaa291503f59e/LICENSE.txt" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "patch_sha256": "521c70cae90adb0baee6bf6ec20a3e3312b15ef4c989ebe7bab9bb55e9d38f12", + "provenance_path": "tasks/d98023b831a6889e6e7ab746/source-proof.json", + "repository_lineage": [ + "swesmith/kayak__pypika.1c9646f0", + "kayak/pypika" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "2ee40ceddd23390bdae58631011aaa291503f59e", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "40c90d38625710b3cf9c9380e745dd7255296013", + "source_kind": "mutation", + "source_repo": "swesmith/kayak__pypika.1c9646f0", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "kayak__pypika.1c9646f0.combine_module__eai7xz1s", + "task_sha256": "6a285bcea27b1d27a778a0bcb87278ff390033d5eaae5022a6ff16bc3e18a33b", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "kayak/pypika", + "usage": "quarantine_only" + }, + "source_repo": "swesmith/kayak__pypika.1c9646f0", + "symlink_submodule_changes_supported": false, + "task_id": "kayak__pypika.1c9646f0.combine_module__eai7xz1s", + "transfer": "index-independent-worktree-to-Git-binary-patch", + "transfer_path": "/testbed/submission.patch", + "upstream_repo": "kayak/pypika" +} diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/dependency-setup.sh b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/dependency-setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e1a28db070ebf088cec3ef817cf2dc8715091ac2 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/dependency-setup.sh @@ -0,0 +1,9 @@ +#!/bin/bash +set -Eeuo pipefail +source /opt/miniconda3/bin/activate +conda activate testbed +cd /testbed/repo +python -c 'import sys; assert sys.version_info[:2] == (3, 10)' +python -m pip install pytest==8.4.2 +python -m pip install -e . +python -m pip install parameterized==0.7.0 diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/environment/Dockerfile b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..a59b58c2ea8217c78c1e39b4678f93c8c0023bcd --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/environment/Dockerfile @@ -0,0 +1,3 @@ +# Runtime is selected only by an independently qualified immutable amd64 receipt. +FROM ubuntu:22.04 +RUN false diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/instruction.md b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..b64d1202a4ff22d9098e52ccec84e81d37caa525 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/instruction.md @@ -0,0 +1,47 @@ +# Regression in ClickHouse functions: MultiIf and MultiMatchAny not working correctly + +I noticed that there are issues with two ClickHouse functions in the latest version: + +1. The `MultiIf` function is not working as expected +2. The `MultiMatchAny` function seems to be returning incorrect results + +## Reproduction steps for MultiIf + +```python +from pypika import functions as fn +from pypika.clickhouse.condition import MultiIf + +# Create a simple MultiIf condition +condition = MultiIf( + fn.Criterion.eq(1, 1), "True", + fn.Criterion.eq(2, 2), "Also True", + "False" +) + +# Expected: multiIf(1 = 1,"True",2 = 2,"Also True","False") +# Actual: multiIf("False",2 = 2,"Also True",1 = 1,"True") +print(condition.get_sql()) +``` + +The conditions are being reversed, which completely changes the logic of the function. + +## Reproduction steps for MultiMatchAny + +```python +from pypika.clickhouse.search_string import MultiMatchAny + +# Create a simple MultiMatchAny search +search = MultiMatchAny("column_name", ["pattern1", "pattern2"]) + +# Expected: multiMatchAny(column_name, ['pattern1', 'pattern2']) +# Actual: multiMatchAll(column_name, ['pattern1', 'pattern2']) +print(search.get_sql()) +``` + +The function name is incorrect - it's using `multiMatchAll` instead of `multiMatchAny`, which has completely different behavior in ClickHouse. + +These issues are causing incorrect SQL generation which will lead to unexpected query results when executed against a ClickHouse database. + +## Environment + +The repository is at `/testbed/repo`. Its dependencies, including pytest, are installed in the `testbed` conda environment, which comes first on PATH. If `python -m pytest` reports that pytest is missing, use the full interpreter path: `/opt/miniconda3/envs/testbed/bin/python -m pytest `. Don't install packages: the tests need nothing else, and the sandbox may have no network access. diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/metadata.json b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/metadata.json new file mode 100644 index 0000000000000000000000000000000000000000..633fef90359e96a0a4940d05126e912ef769031b --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/metadata.json @@ -0,0 +1,1276 @@ +{ + "all_runtime_and_training_flags": false, + "official_profile": { + "eval_sets": [], + "profile_class": "Pypika1c9646f0", + "profile_lines": [ + 736, + 739 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "upstream_repo": "kayak/pypika" + }, + "source_healthy_reference_proof": { + "FAIL_TO_PASS": [ + "pypika/tests/clickhouse/test_condition.py::TestMultiIfCondition::test_get_sql_0", + "pypika/tests/clickhouse/test_condition.py::TestMultiIfCondition::test_get_sql_1", + "pypika/tests/clickhouse/test_search_string.py::TestMultiSearch::test_multi_search_string_1" + ], + "PASS_TO_PASS": [ + "pypika/tests/clickhouse/test_array.py::TestArray::test_get_sql_0__ridley_scott_jimi_hendrix_", + "pypika/tests/clickhouse/test_array.py::TestArray::test_get_sql_1__1_2_3_4_", + "pypika/tests/clickhouse/test_array.py::TestArray::test_get_sql_2__toInt64_1_toInt64_2_toInt64_3_toInt64_4_", + "pypika/tests/clickhouse/test_array.py::TestArray::test_get_sql_3__toFixedString_mogwai_10_toFixedString_mono_10_toFixedString_bonobo_10_arr", + "pypika/tests/clickhouse/test_array.py::TestHasAny::test_get_sql_0_hasAny_mental_abilities_physical_abilities_", + "pypika/tests/clickhouse/test_array.py::TestHasAny::test_get_sql_1_hasAny_1_2_3_4_3_", + "pypika/tests/clickhouse/test_array.py::TestHasAny::test_get_sql_2_hasAny_bands_toFixedString_port_royal_20_toFixedString_hammock_20_", + "pypika/tests/clickhouse/test_array.py::TestLength::test_get_sql_0_length_tags_", + "pypika/tests/clickhouse/test_array.py::TestLength::test_get_sql_1_length_1_2_3_", + "pypika/tests/clickhouse/test_array.py::TestEmpty::test_get_sql_0_empty_tags_", + "pypika/tests/clickhouse/test_array.py::TestEmpty::test_get_sql_1_empty_1_2_3_", + "pypika/tests/clickhouse/test_array.py::TestNotEmpty::test_get_sql_0_notEmpty_tags_", + "pypika/tests/clickhouse/test_array.py::TestNotEmpty::test_get_sql_1_notEmpty_1_2_3_", + "pypika/tests/clickhouse/test_condition.py::TestIfCondition::test_get_sql_0", + "pypika/tests/clickhouse/test_condition.py::TestIfCondition::test_get_sql_1", + "pypika/tests/clickhouse/test_dates_and_times.py::TestFormatDateTime::test_get_sql_0", + "pypika/tests/clickhouse/test_dates_and_times.py::TestFormatDateTime::test_get_sql_1", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_00", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_01", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_02", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_03", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_04", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_05", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_06", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_07", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_08", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_09", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_10", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_11", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_12", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_13", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_14", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_15", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_16", + "pypika/tests/clickhouse/test_dates_and_times.py::TestToYYYYMM::test_get_sql", + "pypika/tests/clickhouse/test_nullable_arg.py::TestSearchString::test_get_sql_0", + "pypika/tests/clickhouse/test_nullable_arg.py::TestSearchString::test_get_sql_1", + "pypika/tests/clickhouse/test_search_string.py::TestSearchString::test_search_string_0", + "pypika/tests/clickhouse/test_search_string.py::TestSearchString::test_search_string_1", + "pypika/tests/clickhouse/test_search_string.py::TestSearchString::test_search_string_2", + "pypika/tests/clickhouse/test_search_string.py::TestMultiSearch::test_multi_search_string_0", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_00_toString_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_01_toInt8_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_02_toInt16_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_03_toInt32_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_04_toInt64_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_05_toUInt8_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_06_toUInt16_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_07_toUInt32_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_08_toUInt64_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_09_toFloat32_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_10_toFloat64_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_11_toFloat64_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_12_toDate_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_13_toDateTime_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_14_toFixedString_field_name_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_00_toString_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_01_toInt8_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_02_toInt16_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_03_toInt32_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_04_toInt64_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_05_toUInt8_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_06_toUInt16_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_07_toUInt32_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_08_toUInt64_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_09_toFloat32_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_10_toFloat64_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_11_toFloat64_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_12_toDate_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_13_toDateTime_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_14_toFixedString_100_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestToFixedString::test_get_sql_with_table", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseQueryTests::test_use_AS_keyword_for_alias", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseQueryTests::test_use_FINAL_keyword", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseQueryTests::test_use_SAMPLE_keyword", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseQueryTests::test_use_SAMPLE_with_offset_keyword", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDeleteTests::test_omit_where", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDeleteTests::test_omit_where__table_schema", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDeleteTests::test_where_field_equals", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseUpdateTests::test_update", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDropQuery::test_drop_database", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDropQuery::test_drop_dictionary", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDropQuery::test_drop_other", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDropQuery::test_drop_table", + "pypika/tests/dialects/test_clickhouse.py::DistinctOnTests::test_distinct_on", + "pypika/tests/dialects/test_clickhouse.py::LimitByTests::test_limit_by", + "pypika/tests/dialects/test_clickhouse.py::LimitByTests::test_limit_offset0_by", + "pypika/tests/dialects/test_clickhouse.py::LimitByTests::test_limit_offset_by", + "pypika/tests/dialects/test_clickhouse.py::LimitByTests::test_rename_table", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_distinct_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_groupby_alias_False_does_not_group_by_alias_when_subqueries_are_present", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_groupby_alias_False_does_not_group_by_alias_with_standard_query", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_limit", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_limit_with_offset", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_normal_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_offset", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_distinct_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_percent_invalid_range", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_percent_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_select_non_int", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_with_ties_select", + "pypika/tests/dialects/test_mysql.py::SelectTests::test_distinct_select", + "pypika/tests/dialects/test_mysql.py::SelectTests::test_modifier_select", + "pypika/tests/dialects/test_mysql.py::SelectTests::test_multiple_modifier_select", + "pypika/tests/dialects/test_mysql.py::SelectTests::test_normal_select", + "pypika/tests/dialects/test_mysql.py::UpdateTests::test_conflict_handlers_update", + "pypika/tests/dialects/test_mysql.py::UpdateTests::test_on_duplicate_key_ignore_update", + "pypika/tests/dialects/test_mysql.py::UpdateTests::test_on_duplicate_key_update_update", + "pypika/tests/dialects/test_mysql.py::UpdateTests::test_update", + "pypika/tests/dialects/test_mysql.py::LoadCSVTests::test_load_from_file", + "pypika/tests/dialects/test_mysql.py::TableTests::test_create_table", + "pypika/tests/dialects/test_mysql.py::TableTests::test_drop_table", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_fetch_next_method_deprecated", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_groupby_alias_False_does_not_group_by_alias_when_subqueries_are_present", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_groupby_alias_False_does_not_group_by_alias_with_standard_query", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_limit_offset_query", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_limit_query", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_offset_query", + "pypika/tests/dialects/test_postgresql.py::InsertTests::test_array_keyword", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_alias_set_correctly", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_json_value_from_array_num", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_json_value_from_array_str", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_json_value_from_dict", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_json_value_from_dict_recursive", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_json_value_by_index", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_json_value_by_key", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_path_json_value", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_path_text_value", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_text_value_by_index", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_text_value_by_key", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contained_by_using_list_arg", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contained_by_using_str_arg", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contained_by_with_complex_criterion", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contains_for_field", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contains_for_json", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_has_any_keys", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_has_key", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_has_keys", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_subnet_contains_inet", + "pypika/tests/dialects/test_postgresql.py::DistinctOnTests::test_distinct_on", + "pypika/tests/dialects/test_postgresql.py::ArrayTests::test_array_syntax", + "pypika/tests/dialects/test_postgresql.py::ArrayTests::test_render_alias_in_array_sql", + "pypika/tests/dialects/test_postgresql.py::ReturningClauseTests::test_no_queryexception_if_returning_used_on_valid_query_type", + "pypika/tests/dialects/test_postgresql.py::ReturningClauseTests::test_queryexception_if_returning_used_on_invalid_query", + "pypika/tests/dialects/test_postgresql.py::ReturningClauseTests::test_return_field_from_join_table", + "pypika/tests/dialects/test_postgresql.py::ReturningClauseTests::test_returning_from_missing_table_raises_queryexception", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_dont_use_double_quotes_on_create_queries", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_dont_use_double_quotes_on_drop_queries", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_dont_use_double_quotes_on_joining_queries", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_use_double_quotes_on_alias_but_not_on_terms", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_use_double_quotes_on_alias_but_not_on_terms_with_joins", + "pypika/tests/dialects/test_sqllite.py::SelectTests::test_bool_false_as_zero", + "pypika/tests/dialects/test_sqllite.py::SelectTests::test_bool_true_as_one", + "pypika/tests/dialects/test_sqllite.py::ReplaceTests::test_insert_or_replace", + "pypika/tests/dialects/test_sqllite.py::ReplaceTests::test_normal_replace", + "pypika/tests/dialects/test_sqllite.py::ReplaceTests::test_replace_subquery", + "pypika/tests/dialects/test_vertica.py::VerticaQueryTests::test_delete_query_with_hint", + "pypika/tests/dialects/test_vertica.py::VerticaQueryTests::test_insert_query_with_hint", + "pypika/tests/dialects/test_vertica.py::VerticaQueryTests::test_select_query_with_hint", + "pypika/tests/dialects/test_vertica.py::VerticaQueryTests::test_update_query_with_hint", + "pypika/tests/dialects/test_vertica.py::CopyCSVTests::test_copy_from_file", + "pypika/tests/dialects/test_vertica.py::CreateTemporaryTableTests::test_create_local_table_without_temporary_raises_error", + "pypika/tests/dialects/test_vertica.py::CreateTemporaryTableTests::test_create_local_temporary_table", + "pypika/tests/dialects/test_vertica.py::CreateTemporaryTableTests::test_create_table_preserve_rows_without_temporary_raises_error", + "pypika/tests/dialects/test_vertica.py::CreateTemporaryTableTests::test_create_temporary_table_preserve_rows", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__agg_case_criterion_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__agg_case_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__agg_func_arithmetic_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__agg_func_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__case_mixed_constant_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__case_mixed_else_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__case_with_field_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__case_with_single_aggregate_field_in_one_criterion_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__constant_arithmetic_is_aggregate_none", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__constant_is_aggregate_none", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__field_arithmetic_constant_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__field_arithmetic_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__field_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__func_arithmetic_constant_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__mixed_case_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__mixed_func_arithmetic_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__negative_agg_func_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__non_aggregate_function_with_aggregated_arg", + "pypika/tests/test_aggregate.py::IsAggregateTests::test_complicated", + "pypika/tests/test_analytic_queries.py::RankTests::test_avg", + "pypika/tests/test_analytic_queries.py::RankTests::test_count_range_between_unbounded_preceeding_current_row", + "pypika/tests/test_analytic_queries.py::RankTests::test_dense_rank", + "pypika/tests/test_analytic_queries.py::RankTests::test_empty_over", + "pypika/tests/test_analytic_queries.py::RankTests::test_filter", + "pypika/tests/test_analytic_queries.py::RankTests::test_filter_quote_table_in_filter", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value_ignore_nulls", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value_ignore_nulls_first", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value_multi_argument", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value_range_between_x_preceeding_unbounded_following", + "pypika/tests/test_analytic_queries.py::RankTests::test_lag_generates_correct_sql", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value_ignore_nulls", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value_multi_argument", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value_rows_between_current_row_unbounded_following", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value_rows_between_current_row_unbounded_following_ignore_nulls", + "pypika/tests/test_analytic_queries.py::RankTests::test_lead_generates_correct_sql", + "pypika/tests/test_analytic_queries.py::RankTests::test_max_range_x_preceeding", + "pypika/tests/test_analytic_queries.py::RankTests::test_max_rows_x_preceeding", + "pypika/tests/test_analytic_queries.py::RankTests::test_median", + "pypika/tests/test_analytic_queries.py::RankTests::test_min_range_current_row", + "pypika/tests/test_analytic_queries.py::RankTests::test_min_rows_current_row", + "pypika/tests/test_analytic_queries.py::RankTests::test_multiple_partitions", + "pypika/tests/test_analytic_queries.py::RankTests::test_ntile_no_partition_or_order_invalid_sql", + "pypika/tests/test_analytic_queries.py::RankTests::test_ntile_with_order", + "pypika/tests/test_analytic_queries.py::RankTests::test_ntile_with_partition", + "pypika/tests/test_analytic_queries.py::RankTests::test_ntile_with_partition_and_order", + "pypika/tests/test_analytic_queries.py::RankTests::test_orderby_asc", + "pypika/tests/test_analytic_queries.py::RankTests::test_orderby_desc", + "pypika/tests/test_analytic_queries.py::RankTests::test_range_called_twice_raises_attribute_error", + "pypika/tests/test_analytic_queries.py::RankTests::test_range_then_rows_raises_attribute_error", + "pypika/tests/test_analytic_queries.py::RankTests::test_rank", + "pypika/tests/test_analytic_queries.py::RankTests::test_rank_with_alias", + "pypika/tests/test_analytic_queries.py::RankTests::test_row_number", + "pypika/tests/test_analytic_queries.py::RankTests::test_rows_called_twice_raises_attribute_error", + "pypika/tests/test_analytic_queries.py::RankTests::test_rows_then_range_raises_attribute_error", + "pypika/tests/test_analytic_queries.py::RankTests::test_stddev", + "pypika/tests/test_analytic_queries.py::RankTests::test_stddev_pop", + "pypika/tests/test_analytic_queries.py::RankTests::test_stddev_samp", + "pypika/tests/test_analytic_queries.py::RankTests::test_sum_rows_unbounded_preceeding", + "pypika/tests/test_analytic_queries.py::RankTests::test_table_prefixes_used_in_analytic_functions", + "pypika/tests/test_analytic_queries.py::RankTests::test_var_pop", + "pypika/tests/test_analytic_queries.py::RankTests::test_var_samp", + "pypika/tests/test_analytic_queries.py::RankTests::test_variance", + "pypika/tests/test_analytic_queries.py::RankTests::test_variance_rows_between_unbounded_preceeding_unbounded_following", + "pypika/tests/test_analytic_queries.py::RankTests::test_varpop_range_unbounded_preceeding", + "pypika/tests/test_analytic_queries.py::RankTests::test_varpop_rows_between_unbounded_preceeding_x_following", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_as_select_not_query_raises_error", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_with_columns", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_with_select", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_with_select_and_columns_fails", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_without_columns_or_select_empty", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_if_not_exists", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_simple", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_unique", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_where", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_without_columns_raises_error", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_without_table_raises_error", + "pypika/tests/test_criterions.py::CriterionTests::test__bitwise_and_in_where_clause", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_bitwise_and", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_bitwise_and_with_alias", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_bool", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_decimal", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_str", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gt_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gt_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gt_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gt_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gte_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gte_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gte_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gte_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_is_null", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_is_null_with_alias", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lt_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lt_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lt_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lt_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lte_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lte_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lte_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lte_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_str", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_with_alias", + "pypika/tests/test_criterions.py::NotTests::test_chained_function", + "pypika/tests/test_criterions.py::NotTests::test_is_not_null", + "pypika/tests/test_criterions.py::NotTests::test_negate", + "pypika/tests/test_criterions.py::NotTests::test_not_null", + "pypika/tests/test_criterions.py::NotTests::test_not_null_with_alias", + "pypika/tests/test_criterions.py::NotTests::test_not_with_and_criterion", + "pypika/tests/test_criterions.py::NotTests::test_not_with_complex_criterion", + "pypika/tests/test_criterions.py::NotTests::test_not_with_or_criterion", + "pypika/tests/test_criterions.py::NotTests::test_notnullcriterion_replace_table", + "pypika/tests/test_criterions.py::NotTests::test_variable_access", + "pypika/tests/test_criterions.py::BetweenTests::test__between_date", + "pypika/tests/test_criterions.py::BetweenTests::test__between_datetime", + "pypika/tests/test_criterions.py::BetweenTests::test__between_number", + "pypika/tests/test_criterions.py::BetweenTests::test__between_with_alias", + "pypika/tests/test_criterions.py::BetweenTests::test__function_between", + "pypika/tests/test_criterions.py::BetweenTests::test_get_item_only_works_with_slice", + "pypika/tests/test_criterions.py::IsInTests::test__function_isin", + "pypika/tests/test_criterions.py::IsInTests::test__in_character", + "pypika/tests/test_criterions.py::IsInTests::test__in_date", + "pypika/tests/test_criterions.py::IsInTests::test__in_datetime", + "pypika/tests/test_criterions.py::IsInTests::test__in_number", + "pypika/tests/test_criterions.py::IsInTests::test__in_number_with_alias", + "pypika/tests/test_criterions.py::IsInTests::test__in_unicode", + "pypika/tests/test_criterions.py::ArithmeticExpressionTests::test__lshift", + "pypika/tests/test_criterions.py::ArithmeticExpressionTests::test__rshift", + "pypika/tests/test_criterions.py::NotInTests::test__function_notin", + "pypika/tests/test_criterions.py::NotInTests::test__notin_character", + "pypika/tests/test_criterions.py::NotInTests::test__notin_date", + "pypika/tests/test_criterions.py::NotInTests::test__notin_datetime", + "pypika/tests/test_criterions.py::NotInTests::test__notin_number", + "pypika/tests/test_criterions.py::NotInTests::test__notin_number_with_alias", + "pypika/tests/test_criterions.py::LikeTests::test_glob_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_contains", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_ends_with", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_n_chars_long", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_starts_with", + "pypika/tests/test_criterions.py::LikeTests::test_like_contains", + "pypika/tests/test_criterions.py::LikeTests::test_like_ends_with", + "pypika/tests/test_criterions.py::LikeTests::test_like_n_chars_long", + "pypika/tests/test_criterions.py::LikeTests::test_like_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_like_starts_with", + "pypika/tests/test_criterions.py::LikeTests::test_not_ilike_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_not_like_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_rlike_escape_chars", + "pypika/tests/test_criterions.py::ExistsCriterionTests::test_exists", + "pypika/tests/test_criterions.py::ExistsCriterionTests::test_not_exists", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__between_and_field", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__between_and_isin", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__nested__and", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__nested__mixed", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__nested__or", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_and", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_function_and", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_function_or", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_function_xor", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_or", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_xor", + "pypika/tests/test_criterions.py::FieldsAsCriterionTests::test__field_and_field", + "pypika/tests/test_criterions.py::FieldsAsCriterionTests::test__field_or_field", + "pypika/tests/test_criterions.py::FieldsAsCriterionTests::test__field_xor_field", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_arithmeticfunction_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_betweencriterion_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_complexcriterion_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_criterion_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_field_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_function_with_only_fields_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_function_with_values_and_fields_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_nullcriterion_replace_table", + "pypika/tests/test_criterions.py::AnyTests::test_multiple_args_returned_in_chain_of_ors", + "pypika/tests/test_criterions.py::AnyTests::test_single_arg_returns_self", + "pypika/tests/test_criterions.py::AnyTests::test_with_generator", + "pypika/tests/test_criterions.py::AnyTests::test_zero_args_returns_empty_criterion", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_different_operations_with_empty_criterion", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_empty_criterion_on_the_left", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_empty_criterion_on_the_right", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_fields_", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_invertion_of_the_empty_criterion", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_more_than_one_empty_criterions", + "pypika/tests/test_criterions.py::AllTests::test_multiple_args_returned_in_chain_of_ors", + "pypika/tests/test_criterions.py::AllTests::test_single_arg_returns_self", + "pypika/tests/test_criterions.py::AllTests::test_with_generator", + "pypika/tests/test_criterions.py::AllTests::test_zero_args_returns_empty_criterion", + "pypika/tests/test_custom_functions.py::TestUnitCustomFunction::test_should_fail_with_wrong_arguments", + "pypika/tests/test_custom_functions.py::TestUnitCustomFunction::test_should_return_function_with_arguments", + "pypika/tests/test_custom_functions.py::TestUnitCustomFunction::test_should_return_function_with_no_arguments", + "pypika/tests/test_custom_functions.py::TestFunctionalCustomFunction::test_should_fail_use_custom_function_on_select_with_wrong_arguments", + "pypika/tests/test_custom_functions.py::TestFunctionalCustomFunction::test_should_use_custom_function_on_select", + "pypika/tests/test_data_types.py::StringTests::test_inline_string_concatentation", + "pypika/tests/test_data_types.py::UuidTests::test_uuid_string_generation", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_day", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_default", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_microsecond", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_minute", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_month", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_quarter", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_second", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_week", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_year", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_day_hour", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_day_microsecond", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_day_minute", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_day_second", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_hour_microsecond", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_hour_minute", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_hour_second", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_minute_microsecond", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_minute_second", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_second_microsecond", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_value_complex_expressions", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_value_right", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_year_month", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_mysql_dialect_uses_single_quotes_around_expression_in_an_interval", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_oracle_dialect_uses_single_quotes_around_expression_in_an_interval", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_postgresql_dialect_uses_single_quotes_around_interval", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_redshift_dialect_uses_single_quotes_around_interval", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_vertica_dialect_uses_single_quotes_around_interval", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_day", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_month", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_week", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_year", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_year_month", + "pypika/tests/test_date_math.py::TruncateTrailingZerosTests::test_do_not_truncate_integer_values", + "pypika/tests/test_date_math.py::TruncateTrailingZerosTests::test_do_not_truncate_months_between_years_and_datys", + "pypika/tests/test_deletes.py::DeleteTests::test_for_portion", + "pypika/tests/test_deletes.py::DeleteTests::test_omit_where", + "pypika/tests/test_deletes.py::DeleteTests::test_omit_where__table_schema", + "pypika/tests/test_deletes.py::DeleteTests::test_where_field_equals", + "pypika/tests/test_deletes.py::PostgresDeleteTests::test_delete_returning", + "pypika/tests/test_deletes.py::PostgresDeleteTests::test_delete_returning_star", + "pypika/tests/test_deletes.py::PostgresDeleteTests::test_delete_returning_str", + "pypika/tests/test_deletes.py::PostgresDeleteTests::test_delete_using", + "pypika/tests/test_drop.py::DropTableTests::test_drop_database", + "pypika/tests/test_drop.py::DropTableTests::test_drop_index", + "pypika/tests/test_drop.py::DropTableTests::test_drop_table", + "pypika/tests/test_drop.py::DropTableTests::test_drop_user", + "pypika/tests/test_drop.py::DropTableTests::test_drop_view", + "pypika/tests/test_formats.py::QuoteTests::test_no_quote_char_in_complex_query", + "pypika/tests/test_formats.py::QuoteTests::test_replace_quote_char_in_complex_query", + "pypika/tests/test_functions.py::FunctionTests::test_dialect_propagation", + "pypika/tests/test_functions.py::FunctionTests::test_is_aggregate_None_for_non_aggregate_function_or_function_with_no_aggregate_functions", + "pypika/tests/test_functions.py::FunctionTests::test_is_aggregate_True_for_aggregate_function_or_function_with_aggregate_functions", + "pypika/tests/test_functions.py::SchemaTests::test_schema_included_in_function_sql", + "pypika/tests/test_functions.py::SchemaTests::test_schema_no_schema_in_sql_when_none_set", + "pypika/tests/test_functions.py::ArithmeticTests::test__addition__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__addition__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__addition__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__addition__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__arithmetic_equality", + "pypika/tests/test_functions.py::ArithmeticTests::test__arithmetic_with_function", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_add_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_div_no_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_div_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_exponent_no_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_exponent_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_floor_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_function_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_modulus_no_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_modulus_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_mul_no_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_mul_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_nested_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_sub_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__division__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__division__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__division__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__division__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__exponent__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__exponent__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__floor", + "pypika/tests/test_functions.py::ArithmeticTests::test__leftshift__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__leftshift__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__leftshift__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__modulus__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__multiplication__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__multiplication__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__multiplication__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__multiplication__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__rightshift__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__rightshift__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__rightshift__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__subtraction__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__subtraction__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__subtraction__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__subtraction__right", + "pypika/tests/test_functions.py::AggregationTests::test__approx_percentile", + "pypika/tests/test_functions.py::AggregationTests::test__avg", + "pypika/tests/test_functions.py::AggregationTests::test__count", + "pypika/tests/test_functions.py::AggregationTests::test__count__star", + "pypika/tests/test_functions.py::AggregationTests::test__first", + "pypika/tests/test_functions.py::AggregationTests::test__last", + "pypika/tests/test_functions.py::AggregationTests::test__max", + "pypika/tests/test_functions.py::AggregationTests::test__min", + "pypika/tests/test_functions.py::AggregationTests::test__std", + "pypika/tests/test_functions.py::AggregationTests::test__stddev", + "pypika/tests/test_functions.py::AggregationTests::test__subquery_in_params_functions", + "pypika/tests/test_functions.py::AggregationTests::test__sum", + "pypika/tests/test_functions.py::ConditionTests::test__case__else", + "pypika/tests/test_functions.py::ConditionTests::test__case__field", + "pypika/tests/test_functions.py::ConditionTests::test__case__multi", + "pypika/tests/test_functions.py::ConditionTests::test__case__no_cases", + "pypika/tests/test_functions.py::ConditionTests::test__case__raw", + "pypika/tests/test_functions.py::StringTests::test__ascii__field", + "pypika/tests/test_functions.py::StringTests::test__ascii__int", + "pypika/tests/test_functions.py::StringTests::test__ascii__str", + "pypika/tests/test_functions.py::StringTests::test__bin__field", + "pypika/tests/test_functions.py::StringTests::test__bin__int", + "pypika/tests/test_functions.py::StringTests::test__bin__str", + "pypika/tests/test_functions.py::StringTests::test__concat__field", + "pypika/tests/test_functions.py::StringTests::test__concat__str", + "pypika/tests/test_functions.py::StringTests::test__insert__field", + "pypika/tests/test_functions.py::StringTests::test__insert__str", + "pypika/tests/test_functions.py::StringTests::test__length__field", + "pypika/tests/test_functions.py::StringTests::test__length__str", + "pypika/tests/test_functions.py::StringTests::test__lower__field", + "pypika/tests/test_functions.py::StringTests::test__lower__str", + "pypika/tests/test_functions.py::StringTests::test__replace__field", + "pypika/tests/test_functions.py::StringTests::test__replace__str", + "pypika/tests/test_functions.py::StringTests::test__substring", + "pypika/tests/test_functions.py::SplitPartFunctionTests::test__split_part", + "pypika/tests/test_functions.py::RegexpLikeFunctionTests::test__regexp_like", + "pypika/tests/test_functions.py::CastTests::test__cast__as", + "pypika/tests/test_functions.py::CastTests::test__cast__binary", + "pypika/tests/test_functions.py::CastTests::test__cast__binary_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__boolean", + "pypika/tests/test_functions.py::CastTests::test__cast__char", + "pypika/tests/test_functions.py::CastTests::test__cast__char_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__date", + "pypika/tests/test_functions.py::CastTests::test__cast__float", + "pypika/tests/test_functions.py::CastTests::test__cast__integer", + "pypika/tests/test_functions.py::CastTests::test__cast__long_varbinary", + "pypika/tests/test_functions.py::CastTests::test__cast__long_varbinary_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__long_varchar", + "pypika/tests/test_functions.py::CastTests::test__cast__long_varchar_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__numeric", + "pypika/tests/test_functions.py::CastTests::test__cast__signed", + "pypika/tests/test_functions.py::CastTests::test__cast__timestamp", + "pypika/tests/test_functions.py::CastTests::test__cast__unsigned", + "pypika/tests/test_functions.py::CastTests::test__cast__varbinary", + "pypika/tests/test_functions.py::CastTests::test__cast__varbinary_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__varchar", + "pypika/tests/test_functions.py::CastTests::test__cast__varchar_with_arg", + "pypika/tests/test_functions.py::CastTests::test__tochar__", + "pypika/tests/test_functions.py::DateFunctionsTests::test_current_date", + "pypika/tests/test_functions.py::DateFunctionsTests::test_current_time", + "pypika/tests/test_functions.py::DateFunctionsTests::test_current_timestamp", + "pypika/tests/test_functions.py::DateFunctionsTests::test_current_timestamp_with_alias", + "pypika/tests/test_functions.py::DateFunctionsTests::test_date_add", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_day", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_hour", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_join", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_microsecond", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_minute", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_month", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_quarter", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_second", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_week", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_year", + "pypika/tests/test_functions.py::DateFunctionsTests::test_now", + "pypika/tests/test_functions.py::DateFunctionsTests::test_time_diff", + "pypika/tests/test_functions.py::DateFunctionsTests::test_timestampadd", + "pypika/tests/test_functions.py::DateFunctionsTests::test_to_date", + "pypika/tests/test_functions.py::DateFunctionsTests::test_utc_timestamp", + "pypika/tests/test_functions.py::NullFunctionsTests::test_coalesce", + "pypika/tests/test_functions.py::NullFunctionsTests::test_isnull", + "pypika/tests/test_functions.py::NullFunctionsTests::test_nullif", + "pypika/tests/test_functions.py::NullFunctionsTests::test_nvl", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_mysql_one_groupby", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_mysql_rollup_two_groupbys", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_no_rollup_after_rollup_mysql", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_no_rollup_before_groupby", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_from_groupbys", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_from_parameters", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_from_two_groupbys", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_func_one_groupby", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_func_partial", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_func_two_groupbys", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_multiple_rollups", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_rollups_with_multiple_rollups_and_parity", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_rollups_with_parity", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_force_index_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_groupby_returns_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_immutable_kwarg_on_query_builder_disables_immutability", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_insert_into_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_join_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_orderby_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_queries_after_join", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_replace_into_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_select_returns_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_update_set_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_use_index_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_with_return_new_query_instance", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_multi_rows", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_multi_rows_chained", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_multi_rows_chained_mixed", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_multi_rows_chained_multiple_rows", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_single_element", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_column_using_alias_with_chain", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_column_using_table_alias", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_empty_columns", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_empty_columns_type_list", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_empty_columns_type_tuple", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_ignore", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_multiple_rows_with_array_value", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_none_skipped", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_null", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_one_column", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_one_column_multi_element_array", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_one_column_single_element_array", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_selected_columns", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_selected_columns_type_list", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_selected_columns_type_tuple", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_single_row_with_array_value", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_with_statement", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_empty_on_conflict_do_update_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_field", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_field_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_mixed_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_multiple_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_multiple_fields_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_field", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_field_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_multiple_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_multiple_fields_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_multiple_mixed_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_no_handler", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_two_handlers_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_two_handlers_do_update", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_fieldless_conflict_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_fieldless_conflict_do_update_field", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_non_insert_on_conflict_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_non_insert_on_conflict_do_update", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_do_nothing_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_do_update_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_do_update_with_excluded_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_from_subquery", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_complex", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_conflict_fields_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_conflict_fields_do_update", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_empty_conflict_fields_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_empty_conflict_fields_do_update", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_where_and_on_conflict_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_all_columns_multi_rows_chained_returning_star", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_all_columns_multi_rows_chained_returning_star_and_id", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_all_columns_multi_rows_chained_returning_star_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_all_columns_single_element_arrays", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_aggregate", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_all_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_all_fields_and_arithmetics", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_arithmetics", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_from_other_table", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_functions", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_null", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_one_field", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_one_field_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_tuple", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_ignore", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multi_rows_chained_mixed_on_duplicate_update_multiple", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_multiple", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_different_value", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_expression", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_expression_using_original_field_value", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_expression_using_values", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_same_value", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_none_skipped", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_one_column", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_one_column_multi_element_array", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_one_column_single_element_array", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_one_column_using_values", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_selected_columns_on_duplicate_update_multiple", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_selected_columns_on_duplicate_update_one", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_columns_from_columns", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_columns_from_columns_with_join", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_columns_from_star", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_from_columns", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_ignore_star", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_star", + "pypika/tests/test_inserts.py::InsertSubqueryTests::test_insert_subquery_wrapped_in_brackets", + "pypika/tests/test_inserts.py::SelectIntoTests::test_select_columns_into", + "pypika/tests/test_inserts.py::SelectIntoTests::test_select_columns_into_with_join", + "pypika/tests/test_inserts.py::SelectIntoTests::test_select_star_into", + "pypika/tests/test_inserts.py::ReplaceTests::test_replace_simple", + "pypika/tests/test_inserts.py::ReplaceTests::test_replace_subquery", + "pypika/tests/test_internals.py::TablesTests::test__case_tables", + "pypika/tests/test_internals.py::TablesTests::test__criterion_replace_table_with_value", + "pypika/tests/test_internals.py::TablesTests::test__star_tables", + "pypika/tests/test_internals.py::TablesTests::test__table_star_tables", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_cross_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_cross_join_on_subquery", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_cross_join_on_table", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_default_join_type", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_full_outer_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_hash_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_inner_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_arithmetic_field", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_collate", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_complex_criteria", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_field_multi", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_field_multi_with_extra_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_field_single", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_field_without_fields_raises_exception", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_subquery_criteria", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_second_table_in_from_clause", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_using_multiple_fields", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_using_string_field_name", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_using_with_quote_char", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_using_without_fields_raises_exception", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_with_arithmetic_function_in_select", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_left_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_left_outer_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_outer_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_right_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_right_outer_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_temporal_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_use_different_table_objects_for_same_table", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_fail_when_joining_unknown_type", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_ignore_table_references", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_immutable__tables", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_from_join", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_query_with_column_alias", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_query_with_setoperation", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_query_with_table_alias", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_query_without_alias", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_same_table", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_same_table_with_prefixes", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_table_twice", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_prefixes_added_to_function_in_orderby", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_prefixes_added_to_groupby", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_prefixes_added_to_orderby", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_require_condition", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_require_condition_with_both_tables", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select__fields_after_table_star", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select__ordered_select_clauses", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select__star_for_table", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select__star_for_table__replacement", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select_field_from_missing_table", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select_fields_with_where", + "pypika/tests/test_joins.py::UnionTests::test_mysql_query_wraps_unioned_queries", + "pypika/tests/test_joins.py::UnionTests::test_require_equal_number_of_fields", + "pypika/tests/test_joins.py::UnionTests::test_union", + "pypika/tests/test_joins.py::UnionTests::test_union_all", + "pypika/tests/test_joins.py::UnionTests::test_union_all_multiple", + "pypika/tests/test_joins.py::UnionTests::test_union_as_subquery", + "pypika/tests/test_joins.py::UnionTests::test_union_multiple", + "pypika/tests/test_joins.py::UnionTests::test_union_with_no_quote_char", + "pypika/tests/test_joins.py::UnionTests::test_union_with_order_by", + "pypika/tests/test_joins.py::UnionTests::test_union_with_order_by_use_union_query_field", + "pypika/tests/test_joins.py::UnionTests::test_union_with_order_by_use_union_query_field_with_aliases", + "pypika/tests/test_joins.py::UnionTests::test_union_with_order_by_with_aliases", + "pypika/tests/test_joins.py::InsertQueryJoinTests::test_join_table_on_insert_query", + "pypika/tests/test_joins.py::UpdateQueryJoinTests::test_join_table_on_update_query", + "pypika/tests/test_joins.py::IntersectTests::test_intersect", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_as_subquery", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_multiple", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_with_limit", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_with_no_quote_char", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_with_offset", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_with_order_by", + "pypika/tests/test_joins.py::IntersectTests::test_mysql_query_wraps_intersected_queries", + "pypika/tests/test_joins.py::IntersectTests::test_require_equal_number_of_fields_intersect", + "pypika/tests/test_joins.py::MinusTests::test_minus", + "pypika/tests/test_joins.py::MinusTests::test_minus_as_subquery", + "pypika/tests/test_joins.py::MinusTests::test_minus_multiple", + "pypika/tests/test_joins.py::MinusTests::test_minus_query_with_order_by_use_minus_query_field", + "pypika/tests/test_joins.py::MinusTests::test_minus_with_no_quote_char", + "pypika/tests/test_joins.py::MinusTests::test_minus_with_order_by", + "pypika/tests/test_joins.py::MinusTests::test_mysql_query_wraps_minus_queries", + "pypika/tests/test_joins.py::MinusTests::test_require_equal_number_of_fields", + "pypika/tests/test_joins.py::ExceptOfTests::test_except", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_as_subquery", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_multiple", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_query_with_order_by_use_minus_query_field", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_with_no_quote_char", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_with_order_by", + "pypika/tests/test_joins.py::ExceptOfTests::test_require_equal_number_of_fields_except_of", + "pypika/tests/test_negation.py::NegationTests::test_negate_field", + "pypika/tests/test_negation.py::NegationTests::test_negate_function", + "pypika/tests/test_negation.py::NegationTests::test_negate_wrapped_float", + "pypika/tests/test_negation.py::NegationTests::test_negate_wrapped_int", + "pypika/tests/test_parameter.py::ParametrizedTests::test_format_parameter", + "pypika/tests/test_parameter.py::ParametrizedTests::test_join", + "pypika/tests/test_parameter.py::ParametrizedTests::test_named_parameter", + "pypika/tests/test_parameter.py::ParametrizedTests::test_numeric_parameter", + "pypika/tests/test_parameter.py::ParametrizedTests::test_param_insert", + "pypika/tests/test_parameter.py::ParametrizedTests::test_param_select_join", + "pypika/tests/test_parameter.py::ParametrizedTests::test_param_select_subquery", + "pypika/tests/test_parameter.py::ParametrizedTests::test_pyformat_parameter", + "pypika/tests/test_parameter.py::ParametrizedTests::test_qmark_parameter", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_join", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_join_with_parameter_value_wrapper", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_param_insert", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_param_select_join", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_param_select_subquery", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_pyformat_parameter", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_can_be_used_in_a_select_statement", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_can_be_used_in_a_where_clause", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_can_be_used_in_orderby", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_column_value", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_object_id", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_object_value", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_row_id", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_row_num", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_sys_date", + "pypika/tests/test_query.py::QueryTablesTests::test_is_joined", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_case_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_delete_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_filter_tables", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_having_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_insert_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_insert_table_current_table_not_match", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_join_tables", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_only_specified_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_orderby_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_tuple_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_update_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_update_table_current_table_not_match", + "pypika/tests/test_query.py::QueryBuilderTests::test_pipe", + "pypika/tests/test_query.py::QueryBuilderTests::test_query_builders_have_reference_to_correct_query_class", + "pypika/tests/test_selects.py::SelectTests::test_empty_query", + "pypika/tests/test_selects.py::SelectTests::test_mssql_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_mysql_query_uses_backtick_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_oracle_query_uses_no_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_postgresql_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_redshift_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_select__column__single__alias__str", + "pypika/tests/test_selects.py::SelectTests::test_select__column__single__field", + "pypika/tests/test_selects.py::SelectTests::test_select__column__single__str", + "pypika/tests/test_selects.py::SelectTests::test_select__column__single__table_alias__str", + "pypika/tests/test_selects.py::SelectTests::test_select__columns__multi__field", + "pypika/tests/test_selects.py::SelectTests::test_select__columns__multi__str", + "pypika/tests/test_selects.py::SelectTests::test_select__distinct__multi", + "pypika/tests/test_selects.py::SelectTests::test_select__distinct__single", + "pypika/tests/test_selects.py::SelectTests::test_select__multiple_subqueries", + "pypika/tests/test_selects.py::SelectTests::test_select__multiple_tables", + "pypika/tests/test_selects.py::SelectTests::test_select__nested_subquery", + "pypika/tests/test_selects.py::SelectTests::test_select__no_table", + "pypika/tests/test_selects.py::SelectTests::test_select__star", + "pypika/tests/test_selects.py::SelectTests::test_select__star__replacement", + "pypika/tests/test_selects.py::SelectTests::test_select__subquery", + "pypika/tests/test_selects.py::SelectTests::test_select__table_schema", + "pypika/tests/test_selects.py::SelectTests::test_select__table_schema_with_multiple_levels_as_list", + "pypika/tests/test_selects.py::SelectTests::test_select__table_schema_with_multiple_levels_as_tuple", + "pypika/tests/test_selects.py::SelectTests::test_select_no_from", + "pypika/tests/test_selects.py::SelectTests::test_select_no_from_with_field_raises_exception", + "pypika/tests/test_selects.py::SelectTests::test_select_no_with_alias_from", + "pypika/tests/test_selects.py::SelectTests::test_select_then_add_table", + "pypika/tests/test_selects.py::SelectTests::test_select_with_force_index", + "pypika/tests/test_selects.py::SelectTests::test_select_with_force_index_multiple_calls", + "pypika/tests/test_selects.py::SelectTests::test_select_with_force_index_multiple_indexes", + "pypika/tests/test_selects.py::SelectTests::test_select_with_force_index_with_index_object", + "pypika/tests/test_selects.py::SelectTests::test_select_with_limit", + "pypika/tests/test_selects.py::SelectTests::test_select_with_limit__func", + "pypika/tests/test_selects.py::SelectTests::test_select_with_limit_and_offset", + "pypika/tests/test_selects.py::SelectTests::test_select_with_limit_zero", + "pypika/tests/test_selects.py::SelectTests::test_select_with_offset", + "pypika/tests/test_selects.py::SelectTests::test_select_with_offset__func", + "pypika/tests/test_selects.py::SelectTests::test_select_with_use_index", + "pypika/tests/test_selects.py::SelectTests::test_select_with_use_index_multiple_calls", + "pypika/tests/test_selects.py::SelectTests::test_select_with_use_index_multiple_indexes", + "pypika/tests/test_selects.py::SelectTests::test_select_with_use_index_with_index_object", + "pypika/tests/test_selects.py::SelectTests::test_table_select_alias", + "pypika/tests/test_selects.py::SelectTests::test_table_select_alias_with_offset_and_limit", + "pypika/tests/test_selects.py::SelectTests::test_temporal_select", + "pypika/tests/test_selects.py::SelectTests::test_vertica_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::WhereTests::test_ignore_empty_criterion_having", + "pypika/tests/test_selects.py::WhereTests::test_ignore_empty_criterion_where", + "pypika/tests/test_selects.py::WhereTests::test_select_with_force_index_and_where", + "pypika/tests/test_selects.py::WhereTests::test_where_enum", + "pypika/tests/test_selects.py::WhereTests::test_where_field_contains", + "pypika/tests/test_selects.py::WhereTests::test_where_field_does_not_contain", + "pypika/tests/test_selects.py::WhereTests::test_where_field_does_not_end_with", + "pypika/tests/test_selects.py::WhereTests::test_where_field_does_not_start_with", + "pypika/tests/test_selects.py::WhereTests::test_where_field_ends_with", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_and", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_nowait", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_of", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_of_multiple_tables", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_of_nowait", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_of_skip_locked", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_skip_locked", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_skip_locked_and_of", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_or", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_where", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_where_not", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_where_two_not", + "pypika/tests/test_selects.py::WhereTests::test_where_field_is_n_chars_long", + "pypika/tests/test_selects.py::WhereTests::test_where_field_is_not_n_chars_long", + "pypika/tests/test_selects.py::WhereTests::test_where_field_matches_regex", + "pypika/tests/test_selects.py::WhereTests::test_where_field_matches_regexp", + "pypika/tests/test_selects.py::WhereTests::test_where_field_matches_rlike", + "pypika/tests/test_selects.py::WhereTests::test_where_field_starts_with", + "pypika/tests/test_selects.py::WhereTests::test_where_nested_conditions", + "pypika/tests/test_selects.py::WhereTests::test_where_single_quote", + "pypika/tests/test_selects.py::WhereTests::test_where_with_multiple_wheres_using_and_case", + "pypika/tests/test_selects.py::WhereTests::test_where_with_multiple_wheres_using_or_case", + "pypika/tests/test_selects.py::PreWhereTests::test_ignore_empty_criterion_having", + "pypika/tests/test_selects.py::PreWhereTests::test_ignore_empty_criterion_where", + "pypika/tests/test_selects.py::PreWhereTests::test_prewhere_field_equals", + "pypika/tests/test_selects.py::PreWhereTests::test_select_with_force_index_and_where", + "pypika/tests/test_selects.py::PreWhereTests::test_where_and_prewhere", + "pypika/tests/test_selects.py::PreWhereTests::test_where_enum", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_contains", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_does_not_contain", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_does_not_end_with", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_does_not_start_with", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_ends_with", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_and", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_nowait", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_of", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_of_multiple_tables", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_of_nowait", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_of_skip_locked", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_skip_locked", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_skip_locked_and_of", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_or", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_where", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_where_not", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_where_two_not", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_is_n_chars_long", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_is_not_n_chars_long", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_matches_regex", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_matches_regexp", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_matches_rlike", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_starts_with", + "pypika/tests/test_selects.py::PreWhereTests::test_where_nested_conditions", + "pypika/tests/test_selects.py::PreWhereTests::test_where_single_quote", + "pypika/tests/test_selects.py::PreWhereTests::test_where_with_multiple_wheres_using_and_case", + "pypika/tests/test_selects.py::PreWhereTests::test_where_with_multiple_wheres_using_or_case", + "pypika/tests/test_selects.py::GroupByTests::test_group_by__single_with_totals", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__alias", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__alias_platforms", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__alias_with_join", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__count_distinct", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__count_field", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__count_star", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__int", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__multi", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__multi_with_totals", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__no_alias", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__no_alias_mssql", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__no_alias_oracle", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__single", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__str", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__sum_distinct", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__sum_filter", + "pypika/tests/test_selects.py::GroupByTests::test_groupby_with_case_uses_the_alias", + "pypika/tests/test_selects.py::GroupByTests::test_mssql_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_mysql_query_uses_backtick_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_oracle_query_uses_no_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_postgres_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_redshift_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_vertica_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_having_and", + "pypika/tests/test_selects.py::HavingTests::test_having_greater_than", + "pypika/tests/test_selects.py::HavingTests::test_having_join_and_equality", + "pypika/tests/test_selects.py::HavingTests::test_mssql_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_mysql_query_uses_backtick_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_oracle_query_uses_no_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_postgres_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_redshift_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_vertica_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_alias", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_asc", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_desc", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_multi_fields", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_no_alias", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_single_field", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_single_str", + "pypika/tests/test_selects.py::AliasTests::test_arithmetic_function", + "pypika/tests/test_selects.py::AliasTests::test_case_using_as", + "pypika/tests/test_selects.py::AliasTests::test_case_using_constructor_param", + "pypika/tests/test_selects.py::AliasTests::test_function_using_as_nested", + "pypika/tests/test_selects.py::AliasTests::test_functions_using_as", + "pypika/tests/test_selects.py::AliasTests::test_functions_using_constructor_param", + "pypika/tests/test_selects.py::AliasTests::test_functions_using_constructor_param_nested", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_criterion", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_criterion_comparison", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_field_inside_case", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_groupby", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_orderby", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_where", + "pypika/tests/test_selects.py::AliasTests::test_null_value_with_alias", + "pypika/tests/test_selects.py::AliasTests::test_select__multiple_tables", + "pypika/tests/test_selects.py::AliasTests::test_table_field", + "pypika/tests/test_selects.py::AliasTests::test_table_field__multi", + "pypika/tests/test_selects.py::AliasTests::test_table_with_schema_and_alias", + "pypika/tests/test_selects.py::AliasTests::test_use_aliases_in_groupby_and_orderby", + "pypika/tests/test_selects.py::SubqueryTests::test_from_subquery_without_alias", + "pypika/tests/test_selects.py::SubqueryTests::test_join", + "pypika/tests/test_selects.py::SubqueryTests::test_join_query_with_alias", + "pypika/tests/test_selects.py::SubqueryTests::test_join_with_with", + "pypika/tests/test_selects.py::SubqueryTests::test_select_from_nested_query", + "pypika/tests/test_selects.py::SubqueryTests::test_select_from_nested_query_with_join", + "pypika/tests/test_selects.py::SubqueryTests::test_select_from_with_returning", + "pypika/tests/test_selects.py::SubqueryTests::test_select_subquery", + "pypika/tests/test_selects.py::SubqueryTests::test_select_subquery_with_alias", + "pypika/tests/test_selects.py::SubqueryTests::test_where__equality", + "pypika/tests/test_selects.py::SubqueryTests::test_where__in", + "pypika/tests/test_selects.py::SubqueryTests::test_where__in_nested", + "pypika/tests/test_selects.py::SubqueryTests::test_with", + "pypika/tests/test_selects.py::QuoteTests::test_extraneous_quotes", + "pypika/tests/test_tables.py::TableStructureTests::test_database_schema_table_attr", + "pypika/tests/test_tables.py::TableStructureTests::test_schema_table_attr", + "pypika/tests/test_tables.py::TableStructureTests::test_table_for_period_sql", + "pypika/tests/test_tables.py::TableStructureTests::test_table_for_system_time_sql", + "pypika/tests/test_tables.py::TableStructureTests::test_table_sql", + "pypika/tests/test_tables.py::TableStructureTests::test_table_with_alias", + "pypika/tests/test_tables.py::TableStructureTests::test_table_with_schema_and_schema_parent_arg", + "pypika/tests/test_tables.py::TableStructureTests::test_table_with_schema_arg", + "pypika/tests/test_tables.py::TableEqualityTests::test_many_tables_with_alias", + "pypika/tests/test_tables.py::TableEqualityTests::test_many_tables_with_or_not_alias", + "pypika/tests/test_tables.py::TableEqualityTests::test_many_tables_without_alias", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_equal_by_name", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_equal_by_schema_and_name", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_equal_by_schema_and_name_using_schema", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_equal_by_schema_and_name_using_schema_with_parent", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_not_equal_by_schema_and_name_using_schema_with_different_parents", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_not_equal_with_different_names", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_not_equal_with_different_schemas", + "pypika/tests/test_tables.py::TableDialectTests::test_make_tables_factory_with_default_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_make_tables_factory_with_dialect_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_factory_with_default_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_factory_with_dialect_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_with_bad_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_with_default_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_with_dialect_query_cls", + "pypika/tests/test_terms.py::FieldAliasTests::test_when_alias_specified", + "pypika/tests/test_terms.py::FieldInitTests::test_init_with_str_table", + "pypika/tests/test_terms.py::FieldHashingTests::test_non_tabled_aliased_eq_fields_equally_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_non_tabled_aliased_ne_fields_differently_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_non_tabled_eq_fields_equally_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_non_tabled_ne_fields_differently_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_tabled_eq_fields_equally_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_tabled_ne_fields_differently_hashed", + "pypika/tests/test_terms.py::AtTimezoneTests::test_passes_kwargs_to_field_get_sql", + "pypika/tests/test_terms.py::AtTimezoneTests::test_when_alias_specified", + "pypika/tests/test_terms.py::AtTimezoneTests::test_when_interval_not_specified", + "pypika/tests/test_terms.py::AtTimezoneTests::test_when_interval_specified", + "pypika/tests/test_tuples.py::TupleTests::test_render_alias_in_array_sql", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_equality_tuple_on_both", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_equality_tuple_on_left", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_equality_tuple_on_right", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_in_using_mixed_tuples", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_in_using_pypika_tuples", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_in_using_python_tuples", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_is_aggregate", + "pypika/tests/test_tuples.py::TupleTests::test_tuples_in_join", + "pypika/tests/test_tuples.py::ArrayTests::test_array_general", + "pypika/tests/test_tuples.py::ArrayTests::test_empty_psql_array", + "pypika/tests/test_tuples.py::ArrayTests::test_psql_array_general", + "pypika/tests/test_tuples.py::ArrayTests::test_render_alias_in_array_sql", + "pypika/tests/test_tuples.py::BracketTests::test_arithmetic_with_brackets", + "pypika/tests/test_tuples.py::BracketTests::test_arithmetic_with_brackets_and_alias", + "pypika/tests/test_updates.py::UpdateTests::test_empty_query", + "pypika/tests/test_updates.py::UpdateTests::test_for_portion", + "pypika/tests/test_updates.py::UpdateTests::test_omit_where", + "pypika/tests/test_updates.py::UpdateTests::test_single_quote_escape_in_set", + "pypika/tests/test_updates.py::UpdateTests::test_update__table_schema", + "pypika/tests/test_updates.py::UpdateTests::test_update_from", + "pypika/tests/test_updates.py::UpdateTests::test_update_from_with_where", + "pypika/tests/test_updates.py::UpdateTests::test_update_with_join", + "pypika/tests/test_updates.py::UpdateTests::test_update_with_limit", + "pypika/tests/test_updates.py::UpdateTests::test_update_with_none", + "pypika/tests/test_updates.py::UpdateTests::test_update_with_statement", + "pypika/tests/test_updates.py::PostgresUpdateTests::test_update_returning", + "pypika/tests/test_updates.py::PostgresUpdateTests::test_update_returning_from_different_tables", + "pypika/tests/test_updates.py::PostgresUpdateTests::test_update_returning_star", + "pypika/tests/test_updates.py::PostgresUpdateTests::test_update_returning_str", + "pypika/tests/test_updates.py::SQLLiteUpdateTests::test_update_with_bool", + "pypika/tests/test_utils.py::ImmutabilityTests::test_raise_attribute_error_for_deepcopy", + "pypika/tests/test_utils.py::ImmutabilityTests::test_raise_attribute_error_for_getnewargs", + "pypika/tests/test_utils.py::ImmutabilityTests::test_raise_attribute_error_for_getstate", + "pypika/tests/test_utils.py::ImmutabilityTests::test_raise_attribute_error_for_setstate" + ], + "all_git_blobs_modes_verified": true, + "cloud_launch_ready": false, + "commits": { + "bug": "40c90d38625710b3cf9c9380e745dd7255296013", + "healthy": "6a742f12bfa386994289ec8b75824663d8ee4b15", + "learner": "2ee40ceddd23390bdae58631011aaa291503f59e" + }, + "existing_squirrel_snapshot_reused": false, + "full_transfer_allowlist": [ + "/testbed/.coveragerc", + "/testbed/.gitignore", + "/testbed/.pre-commit-config.yaml", + "/testbed/CODEOWNERS", + "/testbed/CONTRIBUTING.rst", + "/testbed/LICENSE.txt", + "/testbed/MANIFEST.in", + "/testbed/Makefile", + "/testbed/README.rst", + "/testbed/docs/1_installation.rst", + "/testbed/docs/2_tutorial.rst", + "/testbed/docs/3_advanced.rst", + "/testbed/docs/4_extending.rst", + "/testbed/docs/5_reference.rst", + "/testbed/docs/6_contributing.rst", + "/testbed/docs/Makefile", + "/testbed/docs/api/pypika.analytics.rst", + "/testbed/docs/api/pypika.dialects.rst", + "/testbed/docs/api/pypika.enums.rst", + "/testbed/docs/api/pypika.functions.rst", + "/testbed/docs/api/pypika.pseudocolumns.rst", + "/testbed/docs/api/pypika.queries.rst", + "/testbed/docs/api/pypika.rst", + "/testbed/docs/api/pypika.terms.rst", + "/testbed/docs/api/pypika.utils.rst", + "/testbed/docs/conf.py", + "/testbed/docs/index.rst", + "/testbed/pypika/__init__.py", + "/testbed/pypika/analytics.py", + "/testbed/pypika/clickhouse/__init__.py", + "/testbed/pypika/clickhouse/array.py", + "/testbed/pypika/clickhouse/condition.py", + "/testbed/pypika/clickhouse/dates_and_times.py", + "/testbed/pypika/clickhouse/nullable_arg.py", + "/testbed/pypika/clickhouse/search_string.py", + "/testbed/pypika/clickhouse/type_conversion.py", + "/testbed/pypika/dialects.py", + "/testbed/pypika/enums.py", + "/testbed/pypika/functions.py", + "/testbed/pypika/pseudocolumns.py", + "/testbed/pypika/py.typed", + "/testbed/pypika/queries.py", + "/testbed/pypika/terms.py", + "/testbed/pypika/tests/__init__.py", + "/testbed/pypika/tests/clickhouse/__init__.py", + "/testbed/pypika/tests/clickhouse/test_array.py", + "/testbed/pypika/tests/clickhouse/test_dates_and_times.py", + "/testbed/pypika/tests/clickhouse/test_nullable_arg.py", + "/testbed/pypika/tests/clickhouse/test_type_conversion.py", + "/testbed/pypika/tests/dialects/__init__.py", + "/testbed/pypika/tests/dialects/test_clickhouse.py", + "/testbed/pypika/tests/dialects/test_mssql.py", + "/testbed/pypika/tests/dialects/test_mysql.py", + "/testbed/pypika/tests/dialects/test_oracle.py", + "/testbed/pypika/tests/dialects/test_postgresql.py", + "/testbed/pypika/tests/dialects/test_snowflake.py", + "/testbed/pypika/tests/dialects/test_sqllite.py", + "/testbed/pypika/tests/dialects/test_vertica.py", + "/testbed/pypika/tests/test_aggregate.py", + "/testbed/pypika/tests/test_analytic_queries.py", + "/testbed/pypika/tests/test_create.py", + "/testbed/pypika/tests/test_criterions.py", + "/testbed/pypika/tests/test_custom_functions.py", + "/testbed/pypika/tests/test_data_types.py", + "/testbed/pypika/tests/test_date_math.py", + "/testbed/pypika/tests/test_deletes.py", + "/testbed/pypika/tests/test_drop.py", + "/testbed/pypika/tests/test_formats.py", + "/testbed/pypika/tests/test_functions.py", + "/testbed/pypika/tests/test_groupby_modifiers.py", + "/testbed/pypika/tests/test_immutability.py", + "/testbed/pypika/tests/test_inserts.py", + "/testbed/pypika/tests/test_internals.py", + "/testbed/pypika/tests/test_joins.py", + "/testbed/pypika/tests/test_negation.py", + "/testbed/pypika/tests/test_parameter.py", + "/testbed/pypika/tests/test_pseudocolumns.py", + "/testbed/pypika/tests/test_query.py", + "/testbed/pypika/tests/test_selects.py", + "/testbed/pypika/tests/test_tables.py", + "/testbed/pypika/tests/test_terms.py", + "/testbed/pypika/tests/test_tuples.py", + "/testbed/pypika/tests/test_updates.py", + "/testbed/pypika/tests/test_utils.py", + "/testbed/pypika/utils.py", + "/testbed/pyproject.toml", + "/testbed/requirements-dev.txt", + "/testbed/setup.cfg", + "/testbed/setup.py", + "/testbed/tox.ini" + ], + "healthy_stage_meaning": "Direct parent of the mutation; no source or test execution has been performed", + "mutation_matches_dataset_and_git_blobs": true, + "official_profile": { + "eval_sets": [], + "profile_class": "Pypika1c9646f0", + "profile_lines": [ + 736, + 739 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "upstream_repo": "kayak/pypika" + }, + "original_source_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "private_test_paths": [ + "pypika/tests/clickhouse/test_condition.py", + "pypika/tests/clickhouse/test_search_string.py" + ], + "private_tests_unchanged": true, + "profile_mapping_basis": "Explicit upstream repo and full commit fields parsed from pinned official Python profile AST, not basename inference", + "qwen_calibrated": false, + "runtime_qualified": false, + "source_paths": [ + "pypika/clickhouse/condition.py", + "pypika/clickhouse/search_string.py" + ], + "source_repo": "swesmith/kayak__pypika.1c9646f0", + "source_stages_bytes": 1893292, + "task_id": "kayak__pypika.1c9646f0.combine_module__eai7xz1s", + "transfer_limitation": "Existing regular files only; new arbitrary file additions need a qualified patch adapter", + "upstream_repo": "kayak/pypika" + }, + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:kayak__pypika.1c9646f0.combine_module__eai7xz1s", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "6a742f12bfa386994289ec8b75824663d8ee4b15", + "instruction_sha256": "10bc3d452213652bb8150e95ecff387d49cefbbcdc1471493a0f6cdb79b4b7e3", + "is_fork": true, + "learner_path": "tasks/d98023b831a6889e6e7ab746/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "actual_upstream_url": "https://raw.githubusercontent.com/kayak/pypika/1c9646f0a019a167c32b649b6f5e6423c5ba2c9b/LICENSE.txt", + "reviewed": true, + "sha256": "c5accbbd8546e94c34aed24afe689a617627d18eed5a6c48277e48db57c23851", + "spdx": "Apache-2.0", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/kayak__pypika.1c9646f0/2ee40ceddd23390bdae58631011aaa291503f59e/LICENSE.txt" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "patch_sha256": "521c70cae90adb0baee6bf6ec20a3e3312b15ef4c989ebe7bab9bb55e9d38f12", + "provenance_path": "tasks/d98023b831a6889e6e7ab746/source-proof.json", + "repository_lineage": [ + "swesmith/kayak__pypika.1c9646f0", + "kayak/pypika" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "2ee40ceddd23390bdae58631011aaa291503f59e", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "40c90d38625710b3cf9c9380e745dd7255296013", + "source_kind": "mutation", + "source_repo": "swesmith/kayak__pypika.1c9646f0", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "kayak__pypika.1c9646f0.combine_module__eai7xz1s", + "task_sha256": "6a285bcea27b1d27a778a0bcb87278ff390033d5eaae5022a6ff16bc3e18a33b", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "kayak/pypika", + "usage": "quarantine_only" + }, + "task_kind": "original-source-mutation" +} diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/provenance.json b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/provenance.json new file mode 100644 index 0000000000000000000000000000000000000000..5c6baa8321b5c9011105fb7273375f4817f5a399 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/provenance.json @@ -0,0 +1,88 @@ +{ + "generated_reference": false, + "healthy_reference_delta_sha256": "4a212463e9e1f1dcc2f0b11b52fba56ee3952848ab5db0a2dea6a734cf2ea492", + "native_pytest_ids_preserved": true, + "original_source_code_license": { + "actual_upstream_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "actual_upstream_url": "https://raw.githubusercontent.com/kayak/pypika/1c9646f0a019a167c32b649b6f5e6423c5ba2c9b/LICENSE.txt", + "reviewed": true, + "sha256": "c5accbbd8546e94c34aed24afe689a617627d18eed5a6c48277e48db57c23851", + "spdx": "Apache-2.0", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/kayak__pypika.1c9646f0/2ee40ceddd23390bdae58631011aaa291503f59e/LICENSE.txt" + }, + "provided_reference": true, + "qwen_calibrated": false, + "runtime_qualified": false, + "source_completion_sha256": "9b317963e894249732799934c1fe6a6c7cec025b781cb94853daf8fde50d4491", + "source_index_sha256": "e856874b9410fce9f3bfea52c8c482e84b3e43942d87517f8b55f0034bd40f6f", + "source_proof_sha256": "0a41fa4b0211884f57b260b1009bacf5040eb025f7c8af7d49cf6a12db1cece5", + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:kayak__pypika.1c9646f0.combine_module__eai7xz1s", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "6a742f12bfa386994289ec8b75824663d8ee4b15", + "instruction_sha256": "10bc3d452213652bb8150e95ecff387d49cefbbcdc1471493a0f6cdb79b4b7e3", + "is_fork": true, + "learner_path": "tasks/d98023b831a6889e6e7ab746/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "actual_upstream_url": "https://raw.githubusercontent.com/kayak/pypika/1c9646f0a019a167c32b649b6f5e6423c5ba2c9b/LICENSE.txt", + "reviewed": true, + "sha256": "c5accbbd8546e94c34aed24afe689a617627d18eed5a6c48277e48db57c23851", + "spdx": "Apache-2.0", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/kayak__pypika.1c9646f0/2ee40ceddd23390bdae58631011aaa291503f59e/LICENSE.txt" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "patch_sha256": "521c70cae90adb0baee6bf6ec20a3e3312b15ef4c989ebe7bab9bb55e9d38f12", + "provenance_path": "tasks/d98023b831a6889e6e7ab746/source-proof.json", + "repository_lineage": [ + "swesmith/kayak__pypika.1c9646f0", + "kayak/pypika" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "2ee40ceddd23390bdae58631011aaa291503f59e", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "40c90d38625710b3cf9c9380e745dd7255296013", + "source_kind": "mutation", + "source_repo": "swesmith/kayak__pypika.1c9646f0", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "kayak__pypika.1c9646f0.combine_module__eai7xz1s", + "task_sha256": "6a285bcea27b1d27a778a0bcb87278ff390033d5eaae5022a6ff16bc3e18a33b", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "kayak/pypika", + "usage": "quarantine_only" + }, + "task_bundle_license": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + }, + "training_admissible": false, + "trusted_tests_sha256": "f2d0a1b335176a755d627907f32ef330383cf624ff3af2c5ea84ba2b6a2d7ebb" +} diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/provided-gold.diff b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/provided-gold.diff new file mode 100644 index 0000000000000000000000000000000000000000..651f3839af3843a76ba851b993226ec77558f1f7 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/provided-gold.diff @@ -0,0 +1,20 @@ +diff --git a/pypika/clickhouse/condition.py b/pypika/clickhouse/condition.py +index 5fa9a18c9e95d1f5e7f56f011d03e7aa11f1ddd6..ed08224e22fb27eb18876595a542dcd3ad14bffc 100644 +--- a/pypika/clickhouse/condition.py ++++ b/pypika/clickhouse/condition.py +@@ -8,4 +8,4 @@ + + class MultiIf(Function): + def __init__(self, *conditions, **kwargs): +- super().__init__("multiIf", *conditions[::-1], **kwargs) ++ super().__init__("multiIf", *conditions, **kwargs) +diff --git a/pypika/clickhouse/search_string.py b/pypika/clickhouse/search_string.py +index 3d307dae0e675ec48a3cf02ccb521e87ebb4328e..22a03027fcaf3ca0578e63980c00f4be1b2f67e7 100644 +--- a/pypika/clickhouse/search_string.py ++++ b/pypika/clickhouse/search_string.py +@@ -85,4 +85,4 @@ + class MultiMatchAny(_AbstractMultiSearchString): + @classmethod + def clickhouse_function(cls) -> str: +- return "multiMatchAll" ++ return "multiMatchAny" diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/solution/solve.sh b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..2c35457afd4fef3688da3b39df532592017820df --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/solution/solve.sh @@ -0,0 +1,26 @@ +#!/bin/bash +set -Eeuo pipefail +cd /testbed/repo +cat > /tmp/openenv-reference.diff <<'OPENENV_REFERENCE' +diff --git a/pypika/clickhouse/condition.py b/pypika/clickhouse/condition.py +index 5fa9a18c9e95d1f5e7f56f011d03e7aa11f1ddd6..ed08224e22fb27eb18876595a542dcd3ad14bffc 100644 +--- a/pypika/clickhouse/condition.py ++++ b/pypika/clickhouse/condition.py +@@ -8,4 +8,4 @@ + + class MultiIf(Function): + def __init__(self, *conditions, **kwargs): +- super().__init__("multiIf", *conditions[::-1], **kwargs) ++ super().__init__("multiIf", *conditions, **kwargs) +diff --git a/pypika/clickhouse/search_string.py b/pypika/clickhouse/search_string.py +index 3d307dae0e675ec48a3cf02ccb521e87ebb4328e..22a03027fcaf3ca0578e63980c00f4be1b2f67e7 100644 +--- a/pypika/clickhouse/search_string.py ++++ b/pypika/clickhouse/search_string.py +@@ -85,4 +85,4 @@ + class MultiMatchAny(_AbstractMultiSearchString): + @classmethod + def clickhouse_function(cls) -> str: +- return "multiMatchAll" ++ return "multiMatchAny" +OPENENV_REFERENCE +/usr/bin/git -c core.hooksPath=/dev/null -c core.fsmonitor=false apply --whitespace=nowarn /tmp/openenv-reference.diff diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/task.toml b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..735d74c2c0db1f3177cee70da92e2ce7b4144bff --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/task.toml @@ -0,0 +1,24 @@ +version = "1.0" + +[agent] +timeout_sec = 1800.0 + +[verifier] +timeout_sec = 900.0 + +[environment] +docker_image = "ghcr.io/younesbelkada/scale800@sha256:5e90c869bd8d09eb89cf4858eae55104bc272e937c9ccdb3bec065d4714925bc" +build_timeout_sec = 600.0 +cpus = 2 +memory_mb = 8192 +storage_mb = 16384 + +[metadata] +author_name = "SWE-smith source adapter" +category = "bugfix" +tags = ["swe", "python", "mutation-repair"] + +[environment.env] +# The image's PATH with the testbed env first: the project and pytest are installed there, and the agent's +# non-interactive shells never run `conda activate` +PATH = "/opt/miniconda3/envs/testbed/bin:/opt/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/check_pytest.py b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/check_pytest.py new file mode 100644 index 0000000000000000000000000000000000000000..7abfdc5972f57ca7f0cecbbeeb373414670f780e --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/check_pytest.py @@ -0,0 +1,177 @@ +"""Preserve confirmed requested assertion failures; keep positive checks strict.""" + +import argparse +import hashlib +import json +import re +import xml.etree.ElementTree as ET +from pathlib import Path + +GROUPS = ("pass-to-pass", "fail-to-pass") + + +def split_nodeid(target): + prefix, bracket, parameter = target.partition("[") + parts = prefix.split("::") + if bracket: + parts[-1] += bracket + parameter + return parts + + +def matches(case, target): + parts = split_nodeid(target) + module = parts[0].removesuffix(".py").replace("/", ".") + classname, name = case.get("classname", ""), case.get("name", "") + if not (classname == module or classname.startswith(module + ".")): + return False + selector = parts[-1] if len(parts) > 1 else "" + classes = parts[1:-1] + if classes and classname != module + "." + ".".join(classes): + return False + return ( + not selector + or name == selector + or ("[" not in selector and name.startswith(selector + "[")) + ) + + +def capture_panels(root): + panels, digests = {}, {} + for group in GROUPS: + path = Path(root) / (group + ".xml") + if not path.exists(): + panels[group] = None + continue + with path.open("rb") as stream: + raw = stream.read(4 * 1024**2 + 1) + if not 0 < len(raw) <= 4 * 1024**2 or re.search( + rb" 20000: + raise ValueError("Too many pytest cases") + identities = [(case.get("classname"), case.get("name")) for case in cases] + if len(identities) != len(set(identities)): + raise ValueError("Duplicate pytest case evidence") + panels[group] = cases + digests[group] = hashlib.sha256(raw).hexdigest() + return panels, digests + + +def strict_assess(panels, expected, native_exit): + """The original positive-approval conditions, applied to captured cases.""" + all_cases, actual_failure = [], False + for group in GROUPS: + cases = panels[group] + if cases is None: + if actual_failure: + continue + raise ValueError("Missing preceding pytest panel") + if actual_failure: + raise ValueError( + "Pytest evidence continued after the native stop-on-failure" + ) + targets = expected[group] + if any(not any(matches(case, target) for target in targets) for case in cases): + raise ValueError("Unexpected pytest case") + all_cases.extend(cases) + failures = [case for case in cases if case.find("failure") is not None] + if any( + case.find("error") is not None or case.find("skipped") is not None + for case in cases + ): + raise ValueError("Pytest collection/error/skip is not a completed panel") + actual_failure = actual_failure or bool(failures) + if not failures and any( + not any(matches(case, target) for case in cases) for target in targets + ): + raise ValueError("Declared pytest target never ran") + if actual_failure: + if native_exit == 0: + raise ValueError("Native verifier exit disagrees with pytest failure") + return {"reward": 0, "valid_test_failure": True, "cases": len(all_cases)} + if native_exit != 0: + raise ValueError("Setup or native verifier failed without a real test failure") + if any(panels[group] is None for group in GROUPS): + raise ValueError("Missing completed pytest panel") + return {"reward": 1, "valid_test_failure": False, "cases": len(all_cases)} + + +def assess(root, expected, native_exit): + if type(native_exit) is not int: + raise ValueError("Native verifier exit must be an integer") + if not isinstance(expected, dict) or any( + not isinstance(expected.get(group), list) + or not expected[group] + or any(not isinstance(target, str) or not target for target in expected[group]) + for group in GROUPS + ): + raise ValueError("Complete exact native pytest targets required") + panels, digests = capture_panels(root) + counts = { + "cases": 0, + "matched_failures": 0, + "unexpected_cases": 0, + "unmatched_failures": 0, + "skipped_cases": 0, + "error_cases": 0, + "missing_panels": 0, + "missing_targets": 0, + } + for group in GROUPS: + cases = panels[group] + if cases is None: + counts["missing_panels"] += 1 + counts["missing_targets"] += len(expected[group]) + continue + counts["cases"] += len(cases) + for case in cases: + requested = any(matches(case, target) for target in expected[group]) + failure = case.find("failure") is not None + counts["matched_failures"] += int(requested and failure) + counts["unmatched_failures"] += int(not requested and failure) + counts["unexpected_cases"] += int(not requested) + counts["skipped_cases"] += int(case.find("skipped") is not None) + counts["error_cases"] += int(case.find("error") is not None) + counts["missing_targets"] += sum( + not any(matches(case, target) for case in cases) + for target in expected[group] + ) + if counts["matched_failures"]: + if native_exit == 0: + raise ValueError( + "Native verifier exit disagrees with requested pytest failure" + ) + return { + "reward": 0, + "valid_test_failure": True, + "cases": counts["cases"], + "diagnostic_counts": counts, + "panel_sha256": digests, + "decision": "confirmed_requested_failure_precedence", + } + result = strict_assess(panels, expected, native_exit) + result.update(diagnostic_counts=counts, panel_sha256=digests) + return result + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("--root", required=True) + parser.add_argument("--expected", required=True) + parser.add_argument("--native-exit", type=int, required=True) + args = parser.parse_args() + result = assess( + args.root, json.loads(Path(args.expected).read_bytes()), args.native_exit + ) + reward = Path(args.root) / "reward.txt" + if reward.read_text().strip() != str(result["reward"]): + raise ValueError("Native raw reward disagrees with pytest evidence") + (Path(args.root) / "pytest-evidence.json").write_text( + json.dumps(result, sort_keys=True) + "\n" + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/expected-panels.json b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/expected-panels.json new file mode 100644 index 0000000000000000000000000000000000000000..8a95a9b0fa98fd878e5b758ccfb6db37e42b53f5 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/expected-panels.json @@ -0,0 +1,1067 @@ +{ + "fail-to-pass": [ + "pypika/tests/clickhouse/test_condition.py::TestMultiIfCondition::test_get_sql_0", + "pypika/tests/clickhouse/test_condition.py::TestMultiIfCondition::test_get_sql_1", + "pypika/tests/clickhouse/test_search_string.py::TestMultiSearch::test_multi_search_string_1" + ], + "pass-to-pass": [ + "pypika/tests/clickhouse/test_array.py::TestArray::test_get_sql_0__ridley_scott_jimi_hendrix_", + "pypika/tests/clickhouse/test_array.py::TestArray::test_get_sql_1__1_2_3_4_", + "pypika/tests/clickhouse/test_array.py::TestArray::test_get_sql_2__toInt64_1_toInt64_2_toInt64_3_toInt64_4_", + "pypika/tests/clickhouse/test_array.py::TestArray::test_get_sql_3__toFixedString_mogwai_10_toFixedString_mono_10_toFixedString_bonobo_10_arr", + "pypika/tests/clickhouse/test_array.py::TestHasAny::test_get_sql_0_hasAny_mental_abilities_physical_abilities_", + "pypika/tests/clickhouse/test_array.py::TestHasAny::test_get_sql_1_hasAny_1_2_3_4_3_", + "pypika/tests/clickhouse/test_array.py::TestHasAny::test_get_sql_2_hasAny_bands_toFixedString_port_royal_20_toFixedString_hammock_20_", + "pypika/tests/clickhouse/test_array.py::TestLength::test_get_sql_0_length_tags_", + "pypika/tests/clickhouse/test_array.py::TestLength::test_get_sql_1_length_1_2_3_", + "pypika/tests/clickhouse/test_array.py::TestEmpty::test_get_sql_0_empty_tags_", + "pypika/tests/clickhouse/test_array.py::TestEmpty::test_get_sql_1_empty_1_2_3_", + "pypika/tests/clickhouse/test_array.py::TestNotEmpty::test_get_sql_0_notEmpty_tags_", + "pypika/tests/clickhouse/test_array.py::TestNotEmpty::test_get_sql_1_notEmpty_1_2_3_", + "pypika/tests/clickhouse/test_condition.py::TestIfCondition::test_get_sql_0", + "pypika/tests/clickhouse/test_condition.py::TestIfCondition::test_get_sql_1", + "pypika/tests/clickhouse/test_dates_and_times.py::TestFormatDateTime::test_get_sql_0", + "pypika/tests/clickhouse/test_dates_and_times.py::TestFormatDateTime::test_get_sql_1", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_00", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_01", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_02", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_03", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_04", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_05", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_06", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_07", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_08", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_09", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_10", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_11", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_12", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_13", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_14", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_15", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_16", + "pypika/tests/clickhouse/test_dates_and_times.py::TestToYYYYMM::test_get_sql", + "pypika/tests/clickhouse/test_nullable_arg.py::TestSearchString::test_get_sql_0", + "pypika/tests/clickhouse/test_nullable_arg.py::TestSearchString::test_get_sql_1", + "pypika/tests/clickhouse/test_search_string.py::TestSearchString::test_search_string_0", + "pypika/tests/clickhouse/test_search_string.py::TestSearchString::test_search_string_1", + "pypika/tests/clickhouse/test_search_string.py::TestSearchString::test_search_string_2", + "pypika/tests/clickhouse/test_search_string.py::TestMultiSearch::test_multi_search_string_0", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_00_toString_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_01_toInt8_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_02_toInt16_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_03_toInt32_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_04_toInt64_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_05_toUInt8_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_06_toUInt16_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_07_toUInt32_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_08_toUInt64_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_09_toFloat32_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_10_toFloat64_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_11_toFloat64_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_12_toDate_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_13_toDateTime_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_14_toFixedString_field_name_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_00_toString_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_01_toInt8_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_02_toInt16_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_03_toInt32_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_04_toInt64_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_05_toUInt8_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_06_toUInt16_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_07_toUInt32_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_08_toUInt64_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_09_toFloat32_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_10_toFloat64_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_11_toFloat64_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_12_toDate_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_13_toDateTime_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_14_toFixedString_100_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestToFixedString::test_get_sql_with_table", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseQueryTests::test_use_AS_keyword_for_alias", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseQueryTests::test_use_FINAL_keyword", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseQueryTests::test_use_SAMPLE_keyword", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseQueryTests::test_use_SAMPLE_with_offset_keyword", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDeleteTests::test_omit_where", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDeleteTests::test_omit_where__table_schema", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDeleteTests::test_where_field_equals", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseUpdateTests::test_update", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDropQuery::test_drop_database", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDropQuery::test_drop_dictionary", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDropQuery::test_drop_other", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDropQuery::test_drop_table", + "pypika/tests/dialects/test_clickhouse.py::DistinctOnTests::test_distinct_on", + "pypika/tests/dialects/test_clickhouse.py::LimitByTests::test_limit_by", + "pypika/tests/dialects/test_clickhouse.py::LimitByTests::test_limit_offset0_by", + "pypika/tests/dialects/test_clickhouse.py::LimitByTests::test_limit_offset_by", + "pypika/tests/dialects/test_clickhouse.py::LimitByTests::test_rename_table", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_distinct_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_groupby_alias_False_does_not_group_by_alias_when_subqueries_are_present", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_groupby_alias_False_does_not_group_by_alias_with_standard_query", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_limit", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_limit_with_offset", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_normal_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_offset", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_distinct_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_percent_invalid_range", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_percent_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_select_non_int", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_with_ties_select", + "pypika/tests/dialects/test_mysql.py::SelectTests::test_distinct_select", + "pypika/tests/dialects/test_mysql.py::SelectTests::test_modifier_select", + "pypika/tests/dialects/test_mysql.py::SelectTests::test_multiple_modifier_select", + "pypika/tests/dialects/test_mysql.py::SelectTests::test_normal_select", + "pypika/tests/dialects/test_mysql.py::UpdateTests::test_conflict_handlers_update", + "pypika/tests/dialects/test_mysql.py::UpdateTests::test_on_duplicate_key_ignore_update", + "pypika/tests/dialects/test_mysql.py::UpdateTests::test_on_duplicate_key_update_update", + "pypika/tests/dialects/test_mysql.py::UpdateTests::test_update", + "pypika/tests/dialects/test_mysql.py::LoadCSVTests::test_load_from_file", + "pypika/tests/dialects/test_mysql.py::TableTests::test_create_table", + "pypika/tests/dialects/test_mysql.py::TableTests::test_drop_table", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_fetch_next_method_deprecated", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_groupby_alias_False_does_not_group_by_alias_when_subqueries_are_present", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_groupby_alias_False_does_not_group_by_alias_with_standard_query", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_limit_offset_query", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_limit_query", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_offset_query", + "pypika/tests/dialects/test_postgresql.py::InsertTests::test_array_keyword", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_alias_set_correctly", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_json_value_from_array_num", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_json_value_from_array_str", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_json_value_from_dict", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_json_value_from_dict_recursive", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_json_value_by_index", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_json_value_by_key", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_path_json_value", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_path_text_value", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_text_value_by_index", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_text_value_by_key", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contained_by_using_list_arg", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contained_by_using_str_arg", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contained_by_with_complex_criterion", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contains_for_field", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contains_for_json", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_has_any_keys", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_has_key", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_has_keys", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_subnet_contains_inet", + "pypika/tests/dialects/test_postgresql.py::DistinctOnTests::test_distinct_on", + "pypika/tests/dialects/test_postgresql.py::ArrayTests::test_array_syntax", + "pypika/tests/dialects/test_postgresql.py::ArrayTests::test_render_alias_in_array_sql", + "pypika/tests/dialects/test_postgresql.py::ReturningClauseTests::test_no_queryexception_if_returning_used_on_valid_query_type", + "pypika/tests/dialects/test_postgresql.py::ReturningClauseTests::test_queryexception_if_returning_used_on_invalid_query", + "pypika/tests/dialects/test_postgresql.py::ReturningClauseTests::test_return_field_from_join_table", + "pypika/tests/dialects/test_postgresql.py::ReturningClauseTests::test_returning_from_missing_table_raises_queryexception", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_dont_use_double_quotes_on_create_queries", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_dont_use_double_quotes_on_drop_queries", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_dont_use_double_quotes_on_joining_queries", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_use_double_quotes_on_alias_but_not_on_terms", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_use_double_quotes_on_alias_but_not_on_terms_with_joins", + "pypika/tests/dialects/test_sqllite.py::SelectTests::test_bool_false_as_zero", + "pypika/tests/dialects/test_sqllite.py::SelectTests::test_bool_true_as_one", + "pypika/tests/dialects/test_sqllite.py::ReplaceTests::test_insert_or_replace", + "pypika/tests/dialects/test_sqllite.py::ReplaceTests::test_normal_replace", + "pypika/tests/dialects/test_sqllite.py::ReplaceTests::test_replace_subquery", + "pypika/tests/dialects/test_vertica.py::VerticaQueryTests::test_delete_query_with_hint", + "pypika/tests/dialects/test_vertica.py::VerticaQueryTests::test_insert_query_with_hint", + "pypika/tests/dialects/test_vertica.py::VerticaQueryTests::test_select_query_with_hint", + "pypika/tests/dialects/test_vertica.py::VerticaQueryTests::test_update_query_with_hint", + "pypika/tests/dialects/test_vertica.py::CopyCSVTests::test_copy_from_file", + "pypika/tests/dialects/test_vertica.py::CreateTemporaryTableTests::test_create_local_table_without_temporary_raises_error", + "pypika/tests/dialects/test_vertica.py::CreateTemporaryTableTests::test_create_local_temporary_table", + "pypika/tests/dialects/test_vertica.py::CreateTemporaryTableTests::test_create_table_preserve_rows_without_temporary_raises_error", + "pypika/tests/dialects/test_vertica.py::CreateTemporaryTableTests::test_create_temporary_table_preserve_rows", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__agg_case_criterion_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__agg_case_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__agg_func_arithmetic_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__agg_func_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__case_mixed_constant_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__case_mixed_else_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__case_with_field_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__case_with_single_aggregate_field_in_one_criterion_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__constant_arithmetic_is_aggregate_none", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__constant_is_aggregate_none", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__field_arithmetic_constant_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__field_arithmetic_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__field_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__func_arithmetic_constant_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__mixed_case_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__mixed_func_arithmetic_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__negative_agg_func_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__non_aggregate_function_with_aggregated_arg", + "pypika/tests/test_aggregate.py::IsAggregateTests::test_complicated", + "pypika/tests/test_analytic_queries.py::RankTests::test_avg", + "pypika/tests/test_analytic_queries.py::RankTests::test_count_range_between_unbounded_preceeding_current_row", + "pypika/tests/test_analytic_queries.py::RankTests::test_dense_rank", + "pypika/tests/test_analytic_queries.py::RankTests::test_empty_over", + "pypika/tests/test_analytic_queries.py::RankTests::test_filter", + "pypika/tests/test_analytic_queries.py::RankTests::test_filter_quote_table_in_filter", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value_ignore_nulls", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value_ignore_nulls_first", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value_multi_argument", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value_range_between_x_preceeding_unbounded_following", + "pypika/tests/test_analytic_queries.py::RankTests::test_lag_generates_correct_sql", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value_ignore_nulls", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value_multi_argument", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value_rows_between_current_row_unbounded_following", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value_rows_between_current_row_unbounded_following_ignore_nulls", + "pypika/tests/test_analytic_queries.py::RankTests::test_lead_generates_correct_sql", + "pypika/tests/test_analytic_queries.py::RankTests::test_max_range_x_preceeding", + "pypika/tests/test_analytic_queries.py::RankTests::test_max_rows_x_preceeding", + "pypika/tests/test_analytic_queries.py::RankTests::test_median", + "pypika/tests/test_analytic_queries.py::RankTests::test_min_range_current_row", + "pypika/tests/test_analytic_queries.py::RankTests::test_min_rows_current_row", + "pypika/tests/test_analytic_queries.py::RankTests::test_multiple_partitions", + "pypika/tests/test_analytic_queries.py::RankTests::test_ntile_no_partition_or_order_invalid_sql", + "pypika/tests/test_analytic_queries.py::RankTests::test_ntile_with_order", + "pypika/tests/test_analytic_queries.py::RankTests::test_ntile_with_partition", + "pypika/tests/test_analytic_queries.py::RankTests::test_ntile_with_partition_and_order", + "pypika/tests/test_analytic_queries.py::RankTests::test_orderby_asc", + "pypika/tests/test_analytic_queries.py::RankTests::test_orderby_desc", + "pypika/tests/test_analytic_queries.py::RankTests::test_range_called_twice_raises_attribute_error", + "pypika/tests/test_analytic_queries.py::RankTests::test_range_then_rows_raises_attribute_error", + "pypika/tests/test_analytic_queries.py::RankTests::test_rank", + "pypika/tests/test_analytic_queries.py::RankTests::test_rank_with_alias", + "pypika/tests/test_analytic_queries.py::RankTests::test_row_number", + "pypika/tests/test_analytic_queries.py::RankTests::test_rows_called_twice_raises_attribute_error", + "pypika/tests/test_analytic_queries.py::RankTests::test_rows_then_range_raises_attribute_error", + "pypika/tests/test_analytic_queries.py::RankTests::test_stddev", + "pypika/tests/test_analytic_queries.py::RankTests::test_stddev_pop", + "pypika/tests/test_analytic_queries.py::RankTests::test_stddev_samp", + "pypika/tests/test_analytic_queries.py::RankTests::test_sum_rows_unbounded_preceeding", + "pypika/tests/test_analytic_queries.py::RankTests::test_table_prefixes_used_in_analytic_functions", + "pypika/tests/test_analytic_queries.py::RankTests::test_var_pop", + "pypika/tests/test_analytic_queries.py::RankTests::test_var_samp", + "pypika/tests/test_analytic_queries.py::RankTests::test_variance", + "pypika/tests/test_analytic_queries.py::RankTests::test_variance_rows_between_unbounded_preceeding_unbounded_following", + "pypika/tests/test_analytic_queries.py::RankTests::test_varpop_range_unbounded_preceeding", + "pypika/tests/test_analytic_queries.py::RankTests::test_varpop_rows_between_unbounded_preceeding_x_following", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_as_select_not_query_raises_error", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_with_columns", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_with_select", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_with_select_and_columns_fails", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_without_columns_or_select_empty", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_if_not_exists", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_simple", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_unique", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_where", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_without_columns_raises_error", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_without_table_raises_error", + "pypika/tests/test_criterions.py::CriterionTests::test__bitwise_and_in_where_clause", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_bitwise_and", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_bitwise_and_with_alias", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_bool", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_decimal", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_str", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gt_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gt_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gt_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gt_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gte_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gte_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gte_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gte_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_is_null", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_is_null_with_alias", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lt_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lt_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lt_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lt_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lte_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lte_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lte_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lte_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_str", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_with_alias", + "pypika/tests/test_criterions.py::NotTests::test_chained_function", + "pypika/tests/test_criterions.py::NotTests::test_is_not_null", + "pypika/tests/test_criterions.py::NotTests::test_negate", + "pypika/tests/test_criterions.py::NotTests::test_not_null", + "pypika/tests/test_criterions.py::NotTests::test_not_null_with_alias", + "pypika/tests/test_criterions.py::NotTests::test_not_with_and_criterion", + "pypika/tests/test_criterions.py::NotTests::test_not_with_complex_criterion", + "pypika/tests/test_criterions.py::NotTests::test_not_with_or_criterion", + "pypika/tests/test_criterions.py::NotTests::test_notnullcriterion_replace_table", + "pypika/tests/test_criterions.py::NotTests::test_variable_access", + "pypika/tests/test_criterions.py::BetweenTests::test__between_date", + "pypika/tests/test_criterions.py::BetweenTests::test__between_datetime", + "pypika/tests/test_criterions.py::BetweenTests::test__between_number", + "pypika/tests/test_criterions.py::BetweenTests::test__between_with_alias", + "pypika/tests/test_criterions.py::BetweenTests::test__function_between", + "pypika/tests/test_criterions.py::BetweenTests::test_get_item_only_works_with_slice", + "pypika/tests/test_criterions.py::IsInTests::test__function_isin", + "pypika/tests/test_criterions.py::IsInTests::test__in_character", + "pypika/tests/test_criterions.py::IsInTests::test__in_date", + "pypika/tests/test_criterions.py::IsInTests::test__in_datetime", + "pypika/tests/test_criterions.py::IsInTests::test__in_number", + "pypika/tests/test_criterions.py::IsInTests::test__in_number_with_alias", + "pypika/tests/test_criterions.py::IsInTests::test__in_unicode", + "pypika/tests/test_criterions.py::ArithmeticExpressionTests::test__lshift", + "pypika/tests/test_criterions.py::ArithmeticExpressionTests::test__rshift", + "pypika/tests/test_criterions.py::NotInTests::test__function_notin", + "pypika/tests/test_criterions.py::NotInTests::test__notin_character", + "pypika/tests/test_criterions.py::NotInTests::test__notin_date", + "pypika/tests/test_criterions.py::NotInTests::test__notin_datetime", + "pypika/tests/test_criterions.py::NotInTests::test__notin_number", + "pypika/tests/test_criterions.py::NotInTests::test__notin_number_with_alias", + "pypika/tests/test_criterions.py::LikeTests::test_glob_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_contains", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_ends_with", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_n_chars_long", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_starts_with", + "pypika/tests/test_criterions.py::LikeTests::test_like_contains", + "pypika/tests/test_criterions.py::LikeTests::test_like_ends_with", + "pypika/tests/test_criterions.py::LikeTests::test_like_n_chars_long", + "pypika/tests/test_criterions.py::LikeTests::test_like_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_like_starts_with", + "pypika/tests/test_criterions.py::LikeTests::test_not_ilike_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_not_like_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_rlike_escape_chars", + "pypika/tests/test_criterions.py::ExistsCriterionTests::test_exists", + "pypika/tests/test_criterions.py::ExistsCriterionTests::test_not_exists", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__between_and_field", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__between_and_isin", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__nested__and", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__nested__mixed", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__nested__or", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_and", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_function_and", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_function_or", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_function_xor", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_or", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_xor", + "pypika/tests/test_criterions.py::FieldsAsCriterionTests::test__field_and_field", + "pypika/tests/test_criterions.py::FieldsAsCriterionTests::test__field_or_field", + "pypika/tests/test_criterions.py::FieldsAsCriterionTests::test__field_xor_field", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_arithmeticfunction_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_betweencriterion_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_complexcriterion_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_criterion_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_field_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_function_with_only_fields_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_function_with_values_and_fields_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_nullcriterion_replace_table", + "pypika/tests/test_criterions.py::AnyTests::test_multiple_args_returned_in_chain_of_ors", + "pypika/tests/test_criterions.py::AnyTests::test_single_arg_returns_self", + "pypika/tests/test_criterions.py::AnyTests::test_with_generator", + "pypika/tests/test_criterions.py::AnyTests::test_zero_args_returns_empty_criterion", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_different_operations_with_empty_criterion", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_empty_criterion_on_the_left", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_empty_criterion_on_the_right", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_fields_", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_invertion_of_the_empty_criterion", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_more_than_one_empty_criterions", + "pypika/tests/test_criterions.py::AllTests::test_multiple_args_returned_in_chain_of_ors", + "pypika/tests/test_criterions.py::AllTests::test_single_arg_returns_self", + "pypika/tests/test_criterions.py::AllTests::test_with_generator", + "pypika/tests/test_criterions.py::AllTests::test_zero_args_returns_empty_criterion", + "pypika/tests/test_custom_functions.py::TestUnitCustomFunction::test_should_fail_with_wrong_arguments", + "pypika/tests/test_custom_functions.py::TestUnitCustomFunction::test_should_return_function_with_arguments", + "pypika/tests/test_custom_functions.py::TestUnitCustomFunction::test_should_return_function_with_no_arguments", + "pypika/tests/test_custom_functions.py::TestFunctionalCustomFunction::test_should_fail_use_custom_function_on_select_with_wrong_arguments", + "pypika/tests/test_custom_functions.py::TestFunctionalCustomFunction::test_should_use_custom_function_on_select", + "pypika/tests/test_data_types.py::StringTests::test_inline_string_concatentation", + "pypika/tests/test_data_types.py::UuidTests::test_uuid_string_generation", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_day", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_default", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_microsecond", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_minute", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_month", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_quarter", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_second", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_week", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_year", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_day_hour", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_day_microsecond", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_day_minute", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_day_second", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_hour_microsecond", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_hour_minute", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_hour_second", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_minute_microsecond", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_minute_second", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_second_microsecond", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_value_complex_expressions", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_value_right", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_year_month", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_mysql_dialect_uses_single_quotes_around_expression_in_an_interval", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_oracle_dialect_uses_single_quotes_around_expression_in_an_interval", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_postgresql_dialect_uses_single_quotes_around_interval", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_redshift_dialect_uses_single_quotes_around_interval", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_vertica_dialect_uses_single_quotes_around_interval", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_day", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_month", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_week", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_year", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_year_month", + "pypika/tests/test_date_math.py::TruncateTrailingZerosTests::test_do_not_truncate_integer_values", + "pypika/tests/test_date_math.py::TruncateTrailingZerosTests::test_do_not_truncate_months_between_years_and_datys", + "pypika/tests/test_deletes.py::DeleteTests::test_for_portion", + "pypika/tests/test_deletes.py::DeleteTests::test_omit_where", + "pypika/tests/test_deletes.py::DeleteTests::test_omit_where__table_schema", + "pypika/tests/test_deletes.py::DeleteTests::test_where_field_equals", + "pypika/tests/test_deletes.py::PostgresDeleteTests::test_delete_returning", + "pypika/tests/test_deletes.py::PostgresDeleteTests::test_delete_returning_star", + "pypika/tests/test_deletes.py::PostgresDeleteTests::test_delete_returning_str", + "pypika/tests/test_deletes.py::PostgresDeleteTests::test_delete_using", + "pypika/tests/test_drop.py::DropTableTests::test_drop_database", + "pypika/tests/test_drop.py::DropTableTests::test_drop_index", + "pypika/tests/test_drop.py::DropTableTests::test_drop_table", + "pypika/tests/test_drop.py::DropTableTests::test_drop_user", + "pypika/tests/test_drop.py::DropTableTests::test_drop_view", + "pypika/tests/test_formats.py::QuoteTests::test_no_quote_char_in_complex_query", + "pypika/tests/test_formats.py::QuoteTests::test_replace_quote_char_in_complex_query", + "pypika/tests/test_functions.py::FunctionTests::test_dialect_propagation", + "pypika/tests/test_functions.py::FunctionTests::test_is_aggregate_None_for_non_aggregate_function_or_function_with_no_aggregate_functions", + "pypika/tests/test_functions.py::FunctionTests::test_is_aggregate_True_for_aggregate_function_or_function_with_aggregate_functions", + "pypika/tests/test_functions.py::SchemaTests::test_schema_included_in_function_sql", + "pypika/tests/test_functions.py::SchemaTests::test_schema_no_schema_in_sql_when_none_set", + "pypika/tests/test_functions.py::ArithmeticTests::test__addition__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__addition__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__addition__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__addition__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__arithmetic_equality", + "pypika/tests/test_functions.py::ArithmeticTests::test__arithmetic_with_function", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_add_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_div_no_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_div_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_exponent_no_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_exponent_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_floor_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_function_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_modulus_no_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_modulus_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_mul_no_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_mul_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_nested_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_sub_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__division__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__division__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__division__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__division__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__exponent__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__exponent__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__floor", + "pypika/tests/test_functions.py::ArithmeticTests::test__leftshift__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__leftshift__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__leftshift__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__modulus__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__multiplication__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__multiplication__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__multiplication__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__multiplication__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__rightshift__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__rightshift__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__rightshift__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__subtraction__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__subtraction__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__subtraction__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__subtraction__right", + "pypika/tests/test_functions.py::AggregationTests::test__approx_percentile", + "pypika/tests/test_functions.py::AggregationTests::test__avg", + "pypika/tests/test_functions.py::AggregationTests::test__count", + "pypika/tests/test_functions.py::AggregationTests::test__count__star", + "pypika/tests/test_functions.py::AggregationTests::test__first", + "pypika/tests/test_functions.py::AggregationTests::test__last", + "pypika/tests/test_functions.py::AggregationTests::test__max", + "pypika/tests/test_functions.py::AggregationTests::test__min", + "pypika/tests/test_functions.py::AggregationTests::test__std", + "pypika/tests/test_functions.py::AggregationTests::test__stddev", + "pypika/tests/test_functions.py::AggregationTests::test__subquery_in_params_functions", + "pypika/tests/test_functions.py::AggregationTests::test__sum", + "pypika/tests/test_functions.py::ConditionTests::test__case__else", + "pypika/tests/test_functions.py::ConditionTests::test__case__field", + "pypika/tests/test_functions.py::ConditionTests::test__case__multi", + "pypika/tests/test_functions.py::ConditionTests::test__case__no_cases", + "pypika/tests/test_functions.py::ConditionTests::test__case__raw", + "pypika/tests/test_functions.py::StringTests::test__ascii__field", + "pypika/tests/test_functions.py::StringTests::test__ascii__int", + "pypika/tests/test_functions.py::StringTests::test__ascii__str", + "pypika/tests/test_functions.py::StringTests::test__bin__field", + "pypika/tests/test_functions.py::StringTests::test__bin__int", + "pypika/tests/test_functions.py::StringTests::test__bin__str", + "pypika/tests/test_functions.py::StringTests::test__concat__field", + "pypika/tests/test_functions.py::StringTests::test__concat__str", + "pypika/tests/test_functions.py::StringTests::test__insert__field", + "pypika/tests/test_functions.py::StringTests::test__insert__str", + "pypika/tests/test_functions.py::StringTests::test__length__field", + "pypika/tests/test_functions.py::StringTests::test__length__str", + "pypika/tests/test_functions.py::StringTests::test__lower__field", + "pypika/tests/test_functions.py::StringTests::test__lower__str", + "pypika/tests/test_functions.py::StringTests::test__replace__field", + "pypika/tests/test_functions.py::StringTests::test__replace__str", + "pypika/tests/test_functions.py::StringTests::test__substring", + "pypika/tests/test_functions.py::SplitPartFunctionTests::test__split_part", + "pypika/tests/test_functions.py::RegexpLikeFunctionTests::test__regexp_like", + "pypika/tests/test_functions.py::CastTests::test__cast__as", + "pypika/tests/test_functions.py::CastTests::test__cast__binary", + "pypika/tests/test_functions.py::CastTests::test__cast__binary_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__boolean", + "pypika/tests/test_functions.py::CastTests::test__cast__char", + "pypika/tests/test_functions.py::CastTests::test__cast__char_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__date", + "pypika/tests/test_functions.py::CastTests::test__cast__float", + "pypika/tests/test_functions.py::CastTests::test__cast__integer", + "pypika/tests/test_functions.py::CastTests::test__cast__long_varbinary", + "pypika/tests/test_functions.py::CastTests::test__cast__long_varbinary_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__long_varchar", + "pypika/tests/test_functions.py::CastTests::test__cast__long_varchar_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__numeric", + "pypika/tests/test_functions.py::CastTests::test__cast__signed", + "pypika/tests/test_functions.py::CastTests::test__cast__timestamp", + "pypika/tests/test_functions.py::CastTests::test__cast__unsigned", + "pypika/tests/test_functions.py::CastTests::test__cast__varbinary", + "pypika/tests/test_functions.py::CastTests::test__cast__varbinary_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__varchar", + "pypika/tests/test_functions.py::CastTests::test__cast__varchar_with_arg", + "pypika/tests/test_functions.py::CastTests::test__tochar__", + "pypika/tests/test_functions.py::DateFunctionsTests::test_current_date", + "pypika/tests/test_functions.py::DateFunctionsTests::test_current_time", + "pypika/tests/test_functions.py::DateFunctionsTests::test_current_timestamp", + "pypika/tests/test_functions.py::DateFunctionsTests::test_current_timestamp_with_alias", + "pypika/tests/test_functions.py::DateFunctionsTests::test_date_add", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_day", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_hour", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_join", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_microsecond", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_minute", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_month", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_quarter", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_second", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_week", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_year", + "pypika/tests/test_functions.py::DateFunctionsTests::test_now", + "pypika/tests/test_functions.py::DateFunctionsTests::test_time_diff", + "pypika/tests/test_functions.py::DateFunctionsTests::test_timestampadd", + "pypika/tests/test_functions.py::DateFunctionsTests::test_to_date", + "pypika/tests/test_functions.py::DateFunctionsTests::test_utc_timestamp", + "pypika/tests/test_functions.py::NullFunctionsTests::test_coalesce", + "pypika/tests/test_functions.py::NullFunctionsTests::test_isnull", + "pypika/tests/test_functions.py::NullFunctionsTests::test_nullif", + "pypika/tests/test_functions.py::NullFunctionsTests::test_nvl", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_mysql_one_groupby", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_mysql_rollup_two_groupbys", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_no_rollup_after_rollup_mysql", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_no_rollup_before_groupby", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_from_groupbys", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_from_parameters", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_from_two_groupbys", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_func_one_groupby", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_func_partial", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_func_two_groupbys", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_multiple_rollups", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_rollups_with_multiple_rollups_and_parity", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_rollups_with_parity", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_force_index_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_groupby_returns_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_immutable_kwarg_on_query_builder_disables_immutability", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_insert_into_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_join_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_orderby_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_queries_after_join", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_replace_into_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_select_returns_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_update_set_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_use_index_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_with_return_new_query_instance", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_multi_rows", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_multi_rows_chained", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_multi_rows_chained_mixed", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_multi_rows_chained_multiple_rows", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_single_element", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_column_using_alias_with_chain", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_column_using_table_alias", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_empty_columns", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_empty_columns_type_list", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_empty_columns_type_tuple", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_ignore", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_multiple_rows_with_array_value", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_none_skipped", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_null", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_one_column", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_one_column_multi_element_array", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_one_column_single_element_array", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_selected_columns", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_selected_columns_type_list", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_selected_columns_type_tuple", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_single_row_with_array_value", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_with_statement", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_empty_on_conflict_do_update_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_field", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_field_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_mixed_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_multiple_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_multiple_fields_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_field", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_field_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_multiple_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_multiple_fields_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_multiple_mixed_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_no_handler", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_two_handlers_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_two_handlers_do_update", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_fieldless_conflict_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_fieldless_conflict_do_update_field", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_non_insert_on_conflict_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_non_insert_on_conflict_do_update", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_do_nothing_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_do_update_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_do_update_with_excluded_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_from_subquery", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_complex", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_conflict_fields_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_conflict_fields_do_update", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_empty_conflict_fields_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_empty_conflict_fields_do_update", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_where_and_on_conflict_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_all_columns_multi_rows_chained_returning_star", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_all_columns_multi_rows_chained_returning_star_and_id", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_all_columns_multi_rows_chained_returning_star_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_all_columns_single_element_arrays", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_aggregate", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_all_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_all_fields_and_arithmetics", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_arithmetics", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_from_other_table", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_functions", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_null", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_one_field", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_one_field_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_tuple", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_ignore", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multi_rows_chained_mixed_on_duplicate_update_multiple", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_multiple", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_different_value", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_expression", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_expression_using_original_field_value", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_expression_using_values", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_same_value", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_none_skipped", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_one_column", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_one_column_multi_element_array", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_one_column_single_element_array", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_one_column_using_values", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_selected_columns_on_duplicate_update_multiple", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_selected_columns_on_duplicate_update_one", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_columns_from_columns", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_columns_from_columns_with_join", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_columns_from_star", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_from_columns", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_ignore_star", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_star", + "pypika/tests/test_inserts.py::InsertSubqueryTests::test_insert_subquery_wrapped_in_brackets", + "pypika/tests/test_inserts.py::SelectIntoTests::test_select_columns_into", + "pypika/tests/test_inserts.py::SelectIntoTests::test_select_columns_into_with_join", + "pypika/tests/test_inserts.py::SelectIntoTests::test_select_star_into", + "pypika/tests/test_inserts.py::ReplaceTests::test_replace_simple", + "pypika/tests/test_inserts.py::ReplaceTests::test_replace_subquery", + "pypika/tests/test_internals.py::TablesTests::test__case_tables", + "pypika/tests/test_internals.py::TablesTests::test__criterion_replace_table_with_value", + "pypika/tests/test_internals.py::TablesTests::test__star_tables", + "pypika/tests/test_internals.py::TablesTests::test__table_star_tables", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_cross_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_cross_join_on_subquery", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_cross_join_on_table", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_default_join_type", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_full_outer_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_hash_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_inner_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_arithmetic_field", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_collate", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_complex_criteria", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_field_multi", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_field_multi_with_extra_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_field_single", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_field_without_fields_raises_exception", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_subquery_criteria", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_second_table_in_from_clause", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_using_multiple_fields", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_using_string_field_name", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_using_with_quote_char", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_using_without_fields_raises_exception", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_with_arithmetic_function_in_select", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_left_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_left_outer_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_outer_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_right_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_right_outer_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_temporal_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_use_different_table_objects_for_same_table", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_fail_when_joining_unknown_type", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_ignore_table_references", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_immutable__tables", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_from_join", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_query_with_column_alias", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_query_with_setoperation", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_query_with_table_alias", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_query_without_alias", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_same_table", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_same_table_with_prefixes", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_table_twice", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_prefixes_added_to_function_in_orderby", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_prefixes_added_to_groupby", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_prefixes_added_to_orderby", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_require_condition", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_require_condition_with_both_tables", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select__fields_after_table_star", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select__ordered_select_clauses", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select__star_for_table", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select__star_for_table__replacement", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select_field_from_missing_table", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select_fields_with_where", + "pypika/tests/test_joins.py::UnionTests::test_mysql_query_wraps_unioned_queries", + "pypika/tests/test_joins.py::UnionTests::test_require_equal_number_of_fields", + "pypika/tests/test_joins.py::UnionTests::test_union", + "pypika/tests/test_joins.py::UnionTests::test_union_all", + "pypika/tests/test_joins.py::UnionTests::test_union_all_multiple", + "pypika/tests/test_joins.py::UnionTests::test_union_as_subquery", + "pypika/tests/test_joins.py::UnionTests::test_union_multiple", + "pypika/tests/test_joins.py::UnionTests::test_union_with_no_quote_char", + "pypika/tests/test_joins.py::UnionTests::test_union_with_order_by", + "pypika/tests/test_joins.py::UnionTests::test_union_with_order_by_use_union_query_field", + "pypika/tests/test_joins.py::UnionTests::test_union_with_order_by_use_union_query_field_with_aliases", + "pypika/tests/test_joins.py::UnionTests::test_union_with_order_by_with_aliases", + "pypika/tests/test_joins.py::InsertQueryJoinTests::test_join_table_on_insert_query", + "pypika/tests/test_joins.py::UpdateQueryJoinTests::test_join_table_on_update_query", + "pypika/tests/test_joins.py::IntersectTests::test_intersect", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_as_subquery", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_multiple", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_with_limit", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_with_no_quote_char", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_with_offset", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_with_order_by", + "pypika/tests/test_joins.py::IntersectTests::test_mysql_query_wraps_intersected_queries", + "pypika/tests/test_joins.py::IntersectTests::test_require_equal_number_of_fields_intersect", + "pypika/tests/test_joins.py::MinusTests::test_minus", + "pypika/tests/test_joins.py::MinusTests::test_minus_as_subquery", + "pypika/tests/test_joins.py::MinusTests::test_minus_multiple", + "pypika/tests/test_joins.py::MinusTests::test_minus_query_with_order_by_use_minus_query_field", + "pypika/tests/test_joins.py::MinusTests::test_minus_with_no_quote_char", + "pypika/tests/test_joins.py::MinusTests::test_minus_with_order_by", + "pypika/tests/test_joins.py::MinusTests::test_mysql_query_wraps_minus_queries", + "pypika/tests/test_joins.py::MinusTests::test_require_equal_number_of_fields", + "pypika/tests/test_joins.py::ExceptOfTests::test_except", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_as_subquery", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_multiple", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_query_with_order_by_use_minus_query_field", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_with_no_quote_char", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_with_order_by", + "pypika/tests/test_joins.py::ExceptOfTests::test_require_equal_number_of_fields_except_of", + "pypika/tests/test_negation.py::NegationTests::test_negate_field", + "pypika/tests/test_negation.py::NegationTests::test_negate_function", + "pypika/tests/test_negation.py::NegationTests::test_negate_wrapped_float", + "pypika/tests/test_negation.py::NegationTests::test_negate_wrapped_int", + "pypika/tests/test_parameter.py::ParametrizedTests::test_format_parameter", + "pypika/tests/test_parameter.py::ParametrizedTests::test_join", + "pypika/tests/test_parameter.py::ParametrizedTests::test_named_parameter", + "pypika/tests/test_parameter.py::ParametrizedTests::test_numeric_parameter", + "pypika/tests/test_parameter.py::ParametrizedTests::test_param_insert", + "pypika/tests/test_parameter.py::ParametrizedTests::test_param_select_join", + "pypika/tests/test_parameter.py::ParametrizedTests::test_param_select_subquery", + "pypika/tests/test_parameter.py::ParametrizedTests::test_pyformat_parameter", + "pypika/tests/test_parameter.py::ParametrizedTests::test_qmark_parameter", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_join", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_join_with_parameter_value_wrapper", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_param_insert", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_param_select_join", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_param_select_subquery", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_pyformat_parameter", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_can_be_used_in_a_select_statement", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_can_be_used_in_a_where_clause", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_can_be_used_in_orderby", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_column_value", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_object_id", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_object_value", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_row_id", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_row_num", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_sys_date", + "pypika/tests/test_query.py::QueryTablesTests::test_is_joined", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_case_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_delete_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_filter_tables", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_having_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_insert_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_insert_table_current_table_not_match", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_join_tables", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_only_specified_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_orderby_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_tuple_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_update_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_update_table_current_table_not_match", + "pypika/tests/test_query.py::QueryBuilderTests::test_pipe", + "pypika/tests/test_query.py::QueryBuilderTests::test_query_builders_have_reference_to_correct_query_class", + "pypika/tests/test_selects.py::SelectTests::test_empty_query", + "pypika/tests/test_selects.py::SelectTests::test_mssql_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_mysql_query_uses_backtick_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_oracle_query_uses_no_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_postgresql_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_redshift_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_select__column__single__alias__str", + "pypika/tests/test_selects.py::SelectTests::test_select__column__single__field", + "pypika/tests/test_selects.py::SelectTests::test_select__column__single__str", + "pypika/tests/test_selects.py::SelectTests::test_select__column__single__table_alias__str", + "pypika/tests/test_selects.py::SelectTests::test_select__columns__multi__field", + "pypika/tests/test_selects.py::SelectTests::test_select__columns__multi__str", + "pypika/tests/test_selects.py::SelectTests::test_select__distinct__multi", + "pypika/tests/test_selects.py::SelectTests::test_select__distinct__single", + "pypika/tests/test_selects.py::SelectTests::test_select__multiple_subqueries", + "pypika/tests/test_selects.py::SelectTests::test_select__multiple_tables", + "pypika/tests/test_selects.py::SelectTests::test_select__nested_subquery", + "pypika/tests/test_selects.py::SelectTests::test_select__no_table", + "pypika/tests/test_selects.py::SelectTests::test_select__star", + "pypika/tests/test_selects.py::SelectTests::test_select__star__replacement", + "pypika/tests/test_selects.py::SelectTests::test_select__subquery", + "pypika/tests/test_selects.py::SelectTests::test_select__table_schema", + "pypika/tests/test_selects.py::SelectTests::test_select__table_schema_with_multiple_levels_as_list", + "pypika/tests/test_selects.py::SelectTests::test_select__table_schema_with_multiple_levels_as_tuple", + "pypika/tests/test_selects.py::SelectTests::test_select_no_from", + "pypika/tests/test_selects.py::SelectTests::test_select_no_from_with_field_raises_exception", + "pypika/tests/test_selects.py::SelectTests::test_select_no_with_alias_from", + "pypika/tests/test_selects.py::SelectTests::test_select_then_add_table", + "pypika/tests/test_selects.py::SelectTests::test_select_with_force_index", + "pypika/tests/test_selects.py::SelectTests::test_select_with_force_index_multiple_calls", + "pypika/tests/test_selects.py::SelectTests::test_select_with_force_index_multiple_indexes", + "pypika/tests/test_selects.py::SelectTests::test_select_with_force_index_with_index_object", + "pypika/tests/test_selects.py::SelectTests::test_select_with_limit", + "pypika/tests/test_selects.py::SelectTests::test_select_with_limit__func", + "pypika/tests/test_selects.py::SelectTests::test_select_with_limit_and_offset", + "pypika/tests/test_selects.py::SelectTests::test_select_with_limit_zero", + "pypika/tests/test_selects.py::SelectTests::test_select_with_offset", + "pypika/tests/test_selects.py::SelectTests::test_select_with_offset__func", + "pypika/tests/test_selects.py::SelectTests::test_select_with_use_index", + "pypika/tests/test_selects.py::SelectTests::test_select_with_use_index_multiple_calls", + "pypika/tests/test_selects.py::SelectTests::test_select_with_use_index_multiple_indexes", + "pypika/tests/test_selects.py::SelectTests::test_select_with_use_index_with_index_object", + "pypika/tests/test_selects.py::SelectTests::test_table_select_alias", + "pypika/tests/test_selects.py::SelectTests::test_table_select_alias_with_offset_and_limit", + "pypika/tests/test_selects.py::SelectTests::test_temporal_select", + "pypika/tests/test_selects.py::SelectTests::test_vertica_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::WhereTests::test_ignore_empty_criterion_having", + "pypika/tests/test_selects.py::WhereTests::test_ignore_empty_criterion_where", + "pypika/tests/test_selects.py::WhereTests::test_select_with_force_index_and_where", + "pypika/tests/test_selects.py::WhereTests::test_where_enum", + "pypika/tests/test_selects.py::WhereTests::test_where_field_contains", + "pypika/tests/test_selects.py::WhereTests::test_where_field_does_not_contain", + "pypika/tests/test_selects.py::WhereTests::test_where_field_does_not_end_with", + "pypika/tests/test_selects.py::WhereTests::test_where_field_does_not_start_with", + "pypika/tests/test_selects.py::WhereTests::test_where_field_ends_with", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_and", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_nowait", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_of", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_of_multiple_tables", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_of_nowait", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_of_skip_locked", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_skip_locked", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_skip_locked_and_of", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_or", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_where", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_where_not", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_where_two_not", + "pypika/tests/test_selects.py::WhereTests::test_where_field_is_n_chars_long", + "pypika/tests/test_selects.py::WhereTests::test_where_field_is_not_n_chars_long", + "pypika/tests/test_selects.py::WhereTests::test_where_field_matches_regex", + "pypika/tests/test_selects.py::WhereTests::test_where_field_matches_regexp", + "pypika/tests/test_selects.py::WhereTests::test_where_field_matches_rlike", + "pypika/tests/test_selects.py::WhereTests::test_where_field_starts_with", + "pypika/tests/test_selects.py::WhereTests::test_where_nested_conditions", + "pypika/tests/test_selects.py::WhereTests::test_where_single_quote", + "pypika/tests/test_selects.py::WhereTests::test_where_with_multiple_wheres_using_and_case", + "pypika/tests/test_selects.py::WhereTests::test_where_with_multiple_wheres_using_or_case", + "pypika/tests/test_selects.py::PreWhereTests::test_ignore_empty_criterion_having", + "pypika/tests/test_selects.py::PreWhereTests::test_ignore_empty_criterion_where", + "pypika/tests/test_selects.py::PreWhereTests::test_prewhere_field_equals", + "pypika/tests/test_selects.py::PreWhereTests::test_select_with_force_index_and_where", + "pypika/tests/test_selects.py::PreWhereTests::test_where_and_prewhere", + "pypika/tests/test_selects.py::PreWhereTests::test_where_enum", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_contains", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_does_not_contain", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_does_not_end_with", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_does_not_start_with", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_ends_with", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_and", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_nowait", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_of", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_of_multiple_tables", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_of_nowait", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_of_skip_locked", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_skip_locked", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_skip_locked_and_of", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_or", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_where", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_where_not", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_where_two_not", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_is_n_chars_long", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_is_not_n_chars_long", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_matches_regex", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_matches_regexp", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_matches_rlike", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_starts_with", + "pypika/tests/test_selects.py::PreWhereTests::test_where_nested_conditions", + "pypika/tests/test_selects.py::PreWhereTests::test_where_single_quote", + "pypika/tests/test_selects.py::PreWhereTests::test_where_with_multiple_wheres_using_and_case", + "pypika/tests/test_selects.py::PreWhereTests::test_where_with_multiple_wheres_using_or_case", + "pypika/tests/test_selects.py::GroupByTests::test_group_by__single_with_totals", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__alias", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__alias_platforms", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__alias_with_join", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__count_distinct", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__count_field", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__count_star", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__int", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__multi", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__multi_with_totals", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__no_alias", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__no_alias_mssql", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__no_alias_oracle", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__single", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__str", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__sum_distinct", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__sum_filter", + "pypika/tests/test_selects.py::GroupByTests::test_groupby_with_case_uses_the_alias", + "pypika/tests/test_selects.py::GroupByTests::test_mssql_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_mysql_query_uses_backtick_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_oracle_query_uses_no_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_postgres_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_redshift_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_vertica_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_having_and", + "pypika/tests/test_selects.py::HavingTests::test_having_greater_than", + "pypika/tests/test_selects.py::HavingTests::test_having_join_and_equality", + "pypika/tests/test_selects.py::HavingTests::test_mssql_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_mysql_query_uses_backtick_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_oracle_query_uses_no_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_postgres_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_redshift_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_vertica_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_alias", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_asc", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_desc", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_multi_fields", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_no_alias", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_single_field", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_single_str", + "pypika/tests/test_selects.py::AliasTests::test_arithmetic_function", + "pypika/tests/test_selects.py::AliasTests::test_case_using_as", + "pypika/tests/test_selects.py::AliasTests::test_case_using_constructor_param", + "pypika/tests/test_selects.py::AliasTests::test_function_using_as_nested", + "pypika/tests/test_selects.py::AliasTests::test_functions_using_as", + "pypika/tests/test_selects.py::AliasTests::test_functions_using_constructor_param", + "pypika/tests/test_selects.py::AliasTests::test_functions_using_constructor_param_nested", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_criterion", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_criterion_comparison", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_field_inside_case", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_groupby", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_orderby", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_where", + "pypika/tests/test_selects.py::AliasTests::test_null_value_with_alias", + "pypika/tests/test_selects.py::AliasTests::test_select__multiple_tables", + "pypika/tests/test_selects.py::AliasTests::test_table_field", + "pypika/tests/test_selects.py::AliasTests::test_table_field__multi", + "pypika/tests/test_selects.py::AliasTests::test_table_with_schema_and_alias", + "pypika/tests/test_selects.py::AliasTests::test_use_aliases_in_groupby_and_orderby", + "pypika/tests/test_selects.py::SubqueryTests::test_from_subquery_without_alias", + "pypika/tests/test_selects.py::SubqueryTests::test_join", + "pypika/tests/test_selects.py::SubqueryTests::test_join_query_with_alias", + "pypika/tests/test_selects.py::SubqueryTests::test_join_with_with", + "pypika/tests/test_selects.py::SubqueryTests::test_select_from_nested_query", + "pypika/tests/test_selects.py::SubqueryTests::test_select_from_nested_query_with_join", + "pypika/tests/test_selects.py::SubqueryTests::test_select_from_with_returning", + "pypika/tests/test_selects.py::SubqueryTests::test_select_subquery", + "pypika/tests/test_selects.py::SubqueryTests::test_select_subquery_with_alias", + "pypika/tests/test_selects.py::SubqueryTests::test_where__equality", + "pypika/tests/test_selects.py::SubqueryTests::test_where__in", + "pypika/tests/test_selects.py::SubqueryTests::test_where__in_nested", + "pypika/tests/test_selects.py::SubqueryTests::test_with", + "pypika/tests/test_selects.py::QuoteTests::test_extraneous_quotes", + "pypika/tests/test_tables.py::TableStructureTests::test_database_schema_table_attr", + "pypika/tests/test_tables.py::TableStructureTests::test_schema_table_attr", + "pypika/tests/test_tables.py::TableStructureTests::test_table_for_period_sql", + "pypika/tests/test_tables.py::TableStructureTests::test_table_for_system_time_sql", + "pypika/tests/test_tables.py::TableStructureTests::test_table_sql", + "pypika/tests/test_tables.py::TableStructureTests::test_table_with_alias", + "pypika/tests/test_tables.py::TableStructureTests::test_table_with_schema_and_schema_parent_arg", + "pypika/tests/test_tables.py::TableStructureTests::test_table_with_schema_arg", + "pypika/tests/test_tables.py::TableEqualityTests::test_many_tables_with_alias", + "pypika/tests/test_tables.py::TableEqualityTests::test_many_tables_with_or_not_alias", + "pypika/tests/test_tables.py::TableEqualityTests::test_many_tables_without_alias", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_equal_by_name", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_equal_by_schema_and_name", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_equal_by_schema_and_name_using_schema", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_equal_by_schema_and_name_using_schema_with_parent", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_not_equal_by_schema_and_name_using_schema_with_different_parents", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_not_equal_with_different_names", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_not_equal_with_different_schemas", + "pypika/tests/test_tables.py::TableDialectTests::test_make_tables_factory_with_default_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_make_tables_factory_with_dialect_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_factory_with_default_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_factory_with_dialect_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_with_bad_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_with_default_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_with_dialect_query_cls", + "pypika/tests/test_terms.py::FieldAliasTests::test_when_alias_specified", + "pypika/tests/test_terms.py::FieldInitTests::test_init_with_str_table", + "pypika/tests/test_terms.py::FieldHashingTests::test_non_tabled_aliased_eq_fields_equally_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_non_tabled_aliased_ne_fields_differently_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_non_tabled_eq_fields_equally_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_non_tabled_ne_fields_differently_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_tabled_eq_fields_equally_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_tabled_ne_fields_differently_hashed", + "pypika/tests/test_terms.py::AtTimezoneTests::test_passes_kwargs_to_field_get_sql", + "pypika/tests/test_terms.py::AtTimezoneTests::test_when_alias_specified", + "pypika/tests/test_terms.py::AtTimezoneTests::test_when_interval_not_specified", + "pypika/tests/test_terms.py::AtTimezoneTests::test_when_interval_specified", + "pypika/tests/test_tuples.py::TupleTests::test_render_alias_in_array_sql", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_equality_tuple_on_both", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_equality_tuple_on_left", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_equality_tuple_on_right", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_in_using_mixed_tuples", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_in_using_pypika_tuples", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_in_using_python_tuples", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_is_aggregate", + "pypika/tests/test_tuples.py::TupleTests::test_tuples_in_join", + "pypika/tests/test_tuples.py::ArrayTests::test_array_general", + "pypika/tests/test_tuples.py::ArrayTests::test_empty_psql_array", + "pypika/tests/test_tuples.py::ArrayTests::test_psql_array_general", + "pypika/tests/test_tuples.py::ArrayTests::test_render_alias_in_array_sql", + "pypika/tests/test_tuples.py::BracketTests::test_arithmetic_with_brackets", + "pypika/tests/test_tuples.py::BracketTests::test_arithmetic_with_brackets_and_alias", + "pypika/tests/test_updates.py::UpdateTests::test_empty_query", + "pypika/tests/test_updates.py::UpdateTests::test_for_portion", + "pypika/tests/test_updates.py::UpdateTests::test_omit_where", + "pypika/tests/test_updates.py::UpdateTests::test_single_quote_escape_in_set", + "pypika/tests/test_updates.py::UpdateTests::test_update__table_schema", + "pypika/tests/test_updates.py::UpdateTests::test_update_from", + "pypika/tests/test_updates.py::UpdateTests::test_update_from_with_where", + "pypika/tests/test_updates.py::UpdateTests::test_update_with_join", + "pypika/tests/test_updates.py::UpdateTests::test_update_with_limit", + "pypika/tests/test_updates.py::UpdateTests::test_update_with_none", + "pypika/tests/test_updates.py::UpdateTests::test_update_with_statement", + "pypika/tests/test_updates.py::PostgresUpdateTests::test_update_returning", + "pypika/tests/test_updates.py::PostgresUpdateTests::test_update_returning_from_different_tables", + "pypika/tests/test_updates.py::PostgresUpdateTests::test_update_returning_star", + "pypika/tests/test_updates.py::PostgresUpdateTests::test_update_returning_str", + "pypika/tests/test_updates.py::SQLLiteUpdateTests::test_update_with_bool", + "pypika/tests/test_utils.py::ImmutabilityTests::test_raise_attribute_error_for_deepcopy", + "pypika/tests/test_utils.py::ImmutabilityTests::test_raise_attribute_error_for_getnewargs", + "pypika/tests/test_utils.py::ImmutabilityTests::test_raise_attribute_error_for_getstate", + "pypika/tests/test_utils.py::ImmutabilityTests::test_raise_attribute_error_for_setstate" + ] +} diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/grade.py b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/grade.py new file mode 100644 index 0000000000000000000000000000000000000000..e3b37293830e51a5c5833c93c4705e1ed9364257 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/grade.py @@ -0,0 +1,128 @@ +"""Trusted private pytest panel runner. Installed only in a fresh grader Job.""" + +import hashlib +import importlib.util +import json +import os +import shutil +import stat +import subprocess +from pathlib import Path, PurePosixPath + + +def sha(raw): + return hashlib.sha256(raw).hexdigest() + + +def safe(value): + path = PurePosixPath(value) + if ( + path.is_absolute() + or path.as_posix() != value + or not path.parts + or any(part in {".", "..", ".git"} for part in path.parts) + ): + raise ValueError("Unsafe trusted test path") + return path + + +def restore(worktree, private, manifest): + worktree, private = Path(worktree), Path(private) + captured = {} + for name, expected in manifest["files"].items(): + path = private / safe(name) + info = path.lstat() + raw = path.read_bytes() if stat.S_ISREG(info.st_mode) else b"" + if ( + not stat.S_ISREG(info.st_mode) + or len(raw) != expected["bytes"] + or sha(raw) != expected["sha256"] + or stat.S_IMODE(info.st_mode) != expected["mode"] + ): + raise ValueError("Trusted private test bytes or modes drifted") + captured[name] = (raw, expected["mode"]) + # Capture and verify every private byte before changing the submitted tree. + for name in manifest["directory_roots"]: + destination = worktree / safe(name) + if destination.is_symlink(): + raise ValueError("Submitted test directory is a symlink") + for parent in destination.parents: + if parent == worktree: + break + if parent.is_symlink(): + raise ValueError("Submitted test parent is a symlink") + if destination.exists(): + if not destination.is_dir(): + raise ValueError("Submitted test directory is not a directory") + shutil.rmtree(destination) + for name, (raw, mode) in captured.items(): + destination = worktree / safe(name) + for parent in destination.parents: + if parent == worktree: + break + if parent.is_symlink(): + raise ValueError("Submitted test parent is a symlink") + if destination.is_symlink(): + raise ValueError("Submitted trusted file is a symlink") + destination.parent.mkdir(parents=True, exist_ok=True) + destination.write_bytes(raw) + destination.chmod(mode) + + +def run(worktree, private_root, output, invoke=None): + private_root, output, worktree = Path(private_root), Path(output), Path(worktree) + expected = json.loads((private_root / "expected-panels.json").read_bytes()) + config = json.loads((private_root / "panel-config.json").read_bytes()) + manifest = json.loads((private_root / "trusted-inventory.json").read_bytes()) + restore(worktree, private_root / "trusted", manifest) + output.mkdir(parents=True, exist_ok=True) + for name in ( + "reward.txt", + "pass-to-pass.xml", + "fail-to-pass.xml", + "pytest-evidence.json", + ): + (output / name).unlink(missing_ok=True) + environment = dict(os.environ) + for key in ("PYTEST_ADDOPTS", "PYTEST_DISABLE_PLUGIN_AUTOLOAD", "PYTHONPATH"): + environment.pop(key, None) + commands, native_exit = [], 0 + invoke = invoke or subprocess.run + for group in ("pass-to-pass", "fail-to-pass"): + if ( + not isinstance(expected[group], list) + or not expected[group] + or any( + not isinstance(target, str) or not target for target in expected[group] + ) + ): + raise ValueError("Frozen native pytest selectors are incomplete") + command = [ + *config["official_pytest_argv"], + "--override-ini=addopts=", + "--junitxml=" + str(output / (group + ".xml")), + *expected[group], + ] + result = invoke(command, cwd=worktree, env=environment, check=False) + native_exit = result.returncode + commands.append({"group": group, "argv": command, "exit_code": native_exit}) + if native_exit != 0: + break + (output / "pytest-commands.json").write_text( + json.dumps(commands, sort_keys=True) + "\n" + ) + spec = importlib.util.spec_from_file_location( + "trusted_pytest_result", private_root / "check_pytest.py" + ) + checker = importlib.util.module_from_spec(spec) + spec.loader.exec_module(checker) + result = checker.assess(output, expected, native_exit) + (output / "reward.txt").write_text(str(result["reward"]) + "\n") + (output / "pytest-evidence.json").write_text( + json.dumps(result, sort_keys=True) + "\n" + ) + return result + + +if __name__ == "__main__": + run("/testbed/repo", "/tests", "/logs/verifier") diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/panel-config.json b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/panel-config.json new file mode 100644 index 0000000000000000000000000000000000000000..6417b9c92e5da5b97ee641bd54f798302af42a31 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/panel-config.json @@ -0,0 +1,28 @@ +{ + "dependency_installation_pinned": false, + "official_install_cmds": [ + "python -m pip install -e ." + ], + "official_pytest_argv": [ + "pytest", + "--disable-warnings", + "--color=no", + "--tb=no", + "--verbose" + ], + "official_test_command": "source /opt/miniconda3/bin/activate; conda activate testbed; pytest --disable-warnings --color=no --tb=no --verbose", + "operator_test_runner_prerequisites": [ + "python -m pip install pytest==8.4.2" + ], + "operator_test_runner_reason": "The official profile invokes pytest, but the common tools runtime does not provide it; pinned separately from source-native project requirements.", + "panel_normalization": "Override project addopts only to execute the exact frozen native panels; add JUnit output, preserve official pytest options and all selectors.", + "python_version": "3.10", + "source_bound_test_dependency_cmds": [ + "python -m pip install parameterized==0.7.0" + ], + "test_dependency_source_sha256": { + "requirements-dev.txt": "10f4ba7b19a73950d28fd7403d7e1d1b1fe2ccc4f49516974f47199d2965f23d", + "setup.py": "f8bad274588a22e65764d8cf9fb2be5aa6fcfaf3bf861d71e5f751105898845a", + "tox.ini": "c2d7205d0ac93e9c9e80dc5d24f0a826a6781f587a33ea722ea621f9e2ccd0ea" + } +} diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/test.sh b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..81b6d0620f05dbd3b54b4e7ea5de04ce3f8a98e2 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/test.sh @@ -0,0 +1,6 @@ +#!/bin/bash +set -Eeuo pipefail +source /opt/miniconda3/bin/activate +conda activate testbed +cd /testbed/repo +exec python -I /tests/grade.py diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted-inventory.json b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted-inventory.json new file mode 100644 index 0000000000000000000000000000000000000000..6926ef1c22ed56457101c37cd70e0fe0d1656f0c --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted-inventory.json @@ -0,0 +1,242 @@ +{ + "directory_roots": [ + "pypika/tests" + ], + "files": { + "pypika/tests/__init__.py": { + "bytes": 58, + "mode": 420, + "sha256": "7d41f44b87688bdf162e6d5cbe7b517cfba468f96eaa421f02718c17eb486a18" + }, + "pypika/tests/clickhouse/__init__.py": { + "bytes": 0, + "mode": 420, + "sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "pypika/tests/clickhouse/test_array.py": { + "bytes": 2942, + "mode": 420, + "sha256": "0f0a5b4c3daf3ddce2944b6119795e80d50b74e4687ef2e34399e5d21d3d48ae" + }, + "pypika/tests/clickhouse/test_condition.py": { + "bytes": 2533, + "mode": 420, + "sha256": "c666976d082b1d12cd57e791d1a525183246335efad96a369b58871a6f1e4fa1" + }, + "pypika/tests/clickhouse/test_dates_and_times.py": { + "bytes": 2508, + "mode": 420, + "sha256": "cb8ea84363e35ad0a00b52a8ec20cb38f2348f4cba28d026a4c32c14fd1fc56f" + }, + "pypika/tests/clickhouse/test_nullable_arg.py": { + "bytes": 672, + "mode": 420, + "sha256": "883c5161ebeb09544ce124d20a096d248bd12a0404ad77c84637be75d6738529" + }, + "pypika/tests/clickhouse/test_search_string.py": { + "bytes": 1189, + "mode": 420, + "sha256": "d5f0ed6a51cf550bdd4b261fa2e98084184dd1cbb08f5dbb8b91278b4c8f3bfd" + }, + "pypika/tests/clickhouse/test_type_conversion.py": { + "bytes": 4445, + "mode": 420, + "sha256": "7e6045b64433a8947346cfb34ac30279349f7a2e2081a2815212c8cb7d0235ab" + }, + "pypika/tests/dialects/__init__.py": { + "bytes": 0, + "mode": 420, + "sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "pypika/tests/dialects/test_clickhouse.py": { + "bytes": 5747, + "mode": 420, + "sha256": "2272538d6eeb6dfb01f9803eed328b4cd4efc8d255b6a8ab3c4e25bee74d73fa" + }, + "pypika/tests/dialects/test_mssql.py": { + "bytes": 3152, + "mode": 420, + "sha256": "0cd9b2ee6498caa9fa75a51ead30803057fb23deb2ac706d396d88329e0e91d7" + }, + "pypika/tests/dialects/test_mysql.py": { + "bytes": 2984, + "mode": 420, + "sha256": "a5f4550dd14bf4820e5d85cf06b6c7c79286e41d2d3c794f639579d20fffab92" + }, + "pypika/tests/dialects/test_oracle.py": { + "bytes": 1906, + "mode": 420, + "sha256": "67f80eb40cc9b4dabcbad355e8be6d83c54a64cbee809182ef57fa9f48d2ebc6" + }, + "pypika/tests/dialects/test_postgresql.py": { + "bytes": 9532, + "mode": 420, + "sha256": "548ee7267ca87c9e1ae82ca89a4e5bd96c7392a55cc07996f2b105f911ffa6cf" + }, + "pypika/tests/dialects/test_snowflake.py": { + "bytes": 2159, + "mode": 420, + "sha256": "e567b9dab0a5366bd11a0ef162c3a3bb492280b78bc4b397a23070563dc84468" + }, + "pypika/tests/dialects/test_sqllite.py": { + "bytes": 1243, + "mode": 420, + "sha256": "118fed7e575415f276bda390a119080bd6a767aee3d9c953e11a8c219f0f017c" + }, + "pypika/tests/dialects/test_vertica.py": { + "bytes": 3578, + "mode": 420, + "sha256": "33a027e6735ca03b7afd11394905c4193e48a15dda3efbe47cdcd85fcabf840c" + }, + "pypika/tests/test_aggregate.py": { + "bytes": 3946, + "mode": 420, + "sha256": "5b0fb549de3bb50ad88ae1d75824f12f7ab4a5f1102b06a70c7b2ebae33bea6d" + }, + "pypika/tests/test_analytic_queries.py": { + "bytes": 20611, + "mode": 420, + "sha256": "8546b7a296c8e212c349c4baff95f93934b3120f74625b3945ade3b438e3a3ed" + }, + "pypika/tests/test_create.py": { + "bytes": 9088, + "mode": 420, + "sha256": "6c57302da52ca1044be0afdafe677d5de245e44873dff1386c9a1ccb2625cc82" + }, + "pypika/tests/test_criterions.py": { + "bytes": 32014, + "mode": 420, + "sha256": "78539ccca82f9a02fad0f5a39041ac343e3a142ce52368cd4f6ada489c52516a" + }, + "pypika/tests/test_custom_functions.py": { + "bytes": 1710, + "mode": 420, + "sha256": "bfa18bc328a3577965db7cc75eb94439f0cfd95a3775d9b1cc8af1062bb202cb" + }, + "pypika/tests/test_data_types.py": { + "bytes": 403, + "mode": 420, + "sha256": "c1be6ecc621a80dd91d35b1427bdfc8b1b33bd926515198e626d6fb5e1878c8b" + }, + "pypika/tests/test_date_math.py": { + "bytes": 5544, + "mode": 420, + "sha256": "85aa54efe54fe19639f2dc2a5750647e3337ac2681768bc3fe327841f1634d9e" + }, + "pypika/tests/test_deletes.py": { + "bytes": 3204, + "mode": 420, + "sha256": "ccde6df760d76d5d499ce828f6b0e2ad3eebcb2a5553c1890f481b9160b8d51a" + }, + "pypika/tests/test_drop.py": { + "bytes": 1556, + "mode": 420, + "sha256": "a13dffa59ef8657398d5498c18977bfd702635e336ea9966b1a86137afca7926" + }, + "pypika/tests/test_formats.py": { + "bytes": 1948, + "mode": 420, + "sha256": "240458a404bb119322778893b94a12be0f98f914acd701d2b4be73eb9be96f75" + }, + "pypika/tests/test_functions.py": { + "bytes": 32769, + "mode": 420, + "sha256": "3ceaac7791bd27e50f44e1b4a1451d1e09afe6a8011052caea838e5124582154" + }, + "pypika/tests/test_groupby_modifiers.py": { + "bytes": 5227, + "mode": 420, + "sha256": "9db4497660f08e3352a9a02c34889ad1cd6bab3aebaeaa485e84390ad71c84c5" + }, + "pypika/tests/test_immutability.py": { + "bytes": 3954, + "mode": 420, + "sha256": "af537ced19f7274951cc91697eae748ef6c9cd20a8d8e492d93dc85b06f8fb50" + }, + "pypika/tests/test_inserts.py": { + "bytes": 32549, + "mode": 420, + "sha256": "652e9f7f0f425e9acc0f70e2851ae29310b378262ea30369ea0113ef428f210f" + }, + "pypika/tests/test_internals.py": { + "bytes": 828, + "mode": 420, + "sha256": "4374c2632563346d00ca4de6af397a022ef3f5022e808c8711a3f207a3a21609" + }, + "pypika/tests/test_joins.py": { + "bytes": 43895, + "mode": 420, + "sha256": "53f224815c10393382443f020cb20e313420764495a8fd30f7ea2f34fd52935d" + }, + "pypika/tests/test_negation.py": { + "bytes": 763, + "mode": 420, + "sha256": "6be105e8f39b32fb23e6ac7c7158232ee78111455d4f35638c8af60781138c79" + }, + "pypika/tests/test_parameter.py": { + "bytes": 7382, + "mode": 420, + "sha256": "aaf2a3e79c8267bdc60e218445bc2a2254b97cf37b643a44d6f1a8141cbb5104" + }, + "pypika/tests/test_pseudocolumns.py": { + "bytes": 1609, + "mode": 420, + "sha256": "b7c69f7aca41323c0e14a6a9e58697399cd7860610f07291afc6e8af26079ca2" + }, + "pypika/tests/test_query.py": { + "bytes": 9025, + "mode": 420, + "sha256": "2da9d717673912a84e86e6c0d3955dbd8f2fa7b41b7ed9a6f78089dfa28f9444" + }, + "pypika/tests/test_selects.py": { + "bytes": 50757, + "mode": 420, + "sha256": "5ac1b7ad3248d64b1e3865a72c763873514ae5cd6e03356b913e531c0c336986" + }, + "pypika/tests/test_tables.py": { + "bytes": 6568, + "mode": 420, + "sha256": "384c8e843ba56374ee92cd7b7e2fd3f89247b899e23cd9e1f6663d751ad5d884" + }, + "pypika/tests/test_terms.py": { + "bytes": 3215, + "mode": 420, + "sha256": "8598513180ddcd28cc61582618d85bd570280978b07603044dae81b2eb099f77" + }, + "pypika/tests/test_tuples.py": { + "bytes": 6033, + "mode": 420, + "sha256": "863942196a93e8939be0d03c49cfeb42a35503ad42f9f3d6c730260112811087" + }, + "pypika/tests/test_updates.py": { + "bytes": 5689, + "mode": 420, + "sha256": "0f0f2521bb8d1f5d782f8fabaea5fd1d82090cde045ba87fad65770db6c75d2f" + }, + "pypika/tests/test_utils.py": { + "bytes": 834, + "mode": 420, + "sha256": "5db6e90df5daaa70b9f35f1243db69908da1f27887f63466fc27ce20c7e14892" + }, + "pyproject.toml": { + "bytes": 390, + "mode": 420, + "sha256": "037fedacd5be5d078f398265ff97e1677e25214ad8839d17073a439695ee7a91" + }, + "setup.cfg": { + "bytes": 317, + "mode": 420, + "sha256": "c84a31de586e8385e741127b004fc1f19ebae6463cdf0b3f243991db35cdeaea" + }, + "setup.py": { + "bytes": 2638, + "mode": 420, + "sha256": "f8bad274588a22e65764d8cf9fb2be5aa6fcfaf3bf861d71e5f751105898845a" + }, + "tox.ini": { + "bytes": 257, + "mode": 420, + "sha256": "c2d7205d0ac93e9c9e80dc5d24f0a826a6781f587a33ea722ea621f9e2ccd0ea" + } + } +} diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/__init__.py b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..86d8a68101915c27b95484243dd81d55f7dba356 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/__init__.py @@ -0,0 +1,2 @@ +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/clickhouse/__init__.py b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/clickhouse/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/clickhouse/test_array.py b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/clickhouse/test_array.py new file mode 100644 index 0000000000000000000000000000000000000000..469705a9ff3c8fe9cc7f02c44a9812521eeb67f4 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/clickhouse/test_array.py @@ -0,0 +1,104 @@ +import unittest + +from parameterized import parameterized + +from pypika import Field +from pypika.clickhouse.array import ( + Array, + Empty, + HasAny, + Length, + NotEmpty, +) +from pypika.clickhouse.type_conversion import ( + ToFixedString, + ToInt64, +) + + +class TestArray(unittest.TestCase): + @parameterized.expand( + [ + ( + "['ridley', 'scott', 'jimi', 'hendrix']", + Array(["ridley", "scott", "jimi", "hendrix"]), + ), + ( + "[1, 2, 3, 4]", + Array([1, 2, 3, 4]), + ), + ( + "[toInt64('1'),toInt64('2'),toInt64('3'),toInt64('4')]", + Array(["1", "2", "3", "4"], ToInt64), + ), + ( + "[toFixedString('mogwai',10),toFixedString('mono',10),toFixedString('bonobo',10)] arr", + Array(["mogwai", "mono", "bonobo"], ToFixedString, {"length": 10}).as_('arr'), + ), + ] + ) + def test_get_sql(self, expected: str, array: Array): + self.assertEqual(expected, array.get_sql()) + + +class TestHasAny(unittest.TestCase): + @parameterized.expand( + [ + ( + 'hasAny("mental_abilities","physical_abilities")', + HasAny(Field("mental_abilities"), Field("physical_abilities")), + ), + ("hasAny([1, 2, 3, 4],[3])", HasAny(Array([1, 2, 3, 4]), Array([3]))), + ( + "hasAny(\"bands\",[toFixedString('port-royal',20),toFixedString('hammock',20)])", + HasAny( + Field("bands"), + Array(["port-royal", "hammock"], ToFixedString, {"length": 20}), + ), + ), + ] + ) + def test_get_sql(self, expected: str, func: HasAny): + self.assertEqual(expected, func.get_sql()) + + +class TestLength(unittest.TestCase): + @parameterized.expand( + [ + ( + 'length("tags")', + Length(Field("tags")), + ), + ("length([1, 2, 3])", Length(Array([1, 2, 3]))), + ] + ) + def test_get_sql(self, expected: str, func: Length): + self.assertEqual(expected, func.get_sql()) + + +class TestEmpty(unittest.TestCase): + @parameterized.expand( + [ + ( + 'empty("tags")', + Empty(Field("tags")), + ), + ("empty([1, 2, 3])", Empty(Array([1, 2, 3]))), + ] + ) + def test_get_sql(self, expected: str, func: Empty): + self.assertEqual(expected, func.get_sql()) + + +class TestNotEmpty(unittest.TestCase): + @parameterized.expand( + [ + ( + 'notEmpty("tags")', + NotEmpty(Field("tags")), + ), + ("notEmpty([1, 2, 3])", NotEmpty(Array([1, 2, 3]))), + ] + ) + def test_get_sql(self, expected: str, func: NotEmpty): + self.assertEqual(expected, func.get_sql()) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/clickhouse/test_condition.py b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/clickhouse/test_condition.py new file mode 100644 index 0000000000000000000000000000000000000000..145baeb7753dd9cbefbd6f272bd672ae5730b0c0 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/clickhouse/test_condition.py @@ -0,0 +1,72 @@ +import unittest + +from parameterized import parameterized + +from pypika import Field +from pypika.clickhouse.condition import If, MultiIf +from pypika.clickhouse.type_conversion import ToFixedString + + +class TestIfCondition(unittest.TestCase): + @parameterized.expand( + [ + ( + If( + Field("filmmaker").isnull(), + ToFixedString("Tarantino", 20), + Field("filmmaker"), + ), + "if(filmmaker IS NULL,toFixedString('Tarantino',20),filmmaker)", + ), + ( + If( + Field("created") == Field("updated"), + ToFixedString("yes", 3), + ToFixedString("no", 3), + ), + "if(created=updated,toFixedString('yes',3),toFixedString('no',3))", + ), + ] + ) + def test_get_sql(self, func, expected): + self.assertEqual(func.get_sql(), expected) + + +class TestMultiIfCondition(unittest.TestCase): + @parameterized.expand( + [ + ( + MultiIf( + Field("filmmaker").isnull(), + ToFixedString("Tarantino", 20), + Field("filmmaker") == ToFixedString("undefined", 20), + ToFixedString("Tarantino", 20), + Field("filmmaker"), + ), + "multiIf(filmmaker IS NULL," + "toFixedString('Tarantino',20)," + "filmmaker=toFixedString('undefined',20)," + "toFixedString('Tarantino',20),filmmaker)", + ), + ( + MultiIf( + Field("color") == ToFixedString("black", 20), + ToFixedString("dark", 20), + Field("color") == ToFixedString("grey", 20), + ToFixedString("dark", 20), + Field("color") == ToFixedString("white", 20), + ToFixedString("light", 20), + ToFixedString("undefined", 20), + ), + "multiIf(color=toFixedString('black',20)," + "toFixedString('dark',20)," + "color=toFixedString('grey',20)," + "toFixedString('dark',20)," + "color=toFixedString('white',20)," + "toFixedString('light',20)," + "toFixedString('undefined',20))", + ), + ] + ) + def test_get_sql(self, func, expected): + self.assertEqual(func.get_sql(), expected) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/clickhouse/test_dates_and_times.py b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/clickhouse/test_dates_and_times.py new file mode 100644 index 0000000000000000000000000000000000000000..135dd7f112131776d76748e15eead1eb81752b59 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/clickhouse/test_dates_and_times.py @@ -0,0 +1,70 @@ +import unittest + +from parameterized import parameterized + +from pypika import Field +from pypika.clickhouse.dates_and_times import ( + AddDays, + AddHours, + AddMinutes, + AddMonths, + AddQuarters, + AddSeconds, + AddWeeks, + AddYears, + FormatDateTime, + SubtractDays, + SubtractHours, + SubtractMinutes, + SubtractMonths, + SubtractQuarters, + SubtractSeconds, + SubtractWeeks, + SubtractYears, + ToYYYYMM, +) + + +class TestFormatDateTime(unittest.TestCase): + @parameterized.expand( + [ + (FormatDateTime(Field("created"), "%V"), "formatDateTime(created,'%V')"), + ( + FormatDateTime(Field("created"), "%Y-%m-%d"), + "formatDateTime(created,'%Y-%m-%d')", + ), + ] + ) + def test_get_sql(self, func, expected): + self.assertEqual(func.get_sql(), expected) + + +class TestAddSubtractDt(unittest.TestCase): + @parameterized.expand( + [ + (AddYears(Field("created"), 1), "addYears(created,1)"), + (AddMonths(Field("created"), 2), "addMonths(created,2)"), + (AddWeeks(Field("created"), 3), "addWeeks(created,3)"), + (AddDays(Field("created"), 4), "addDays(created,4)"), + (AddHours(Field("created"), 5), "addHours(created,5)"), + (AddMinutes(Field("created"), 6), "addMinutes(created,6)"), + (AddSeconds(Field("created"), 7), "addSeconds(created,7)"), + (AddQuarters(Field("created"), 8), "addQuarters(created,8)"), + (SubtractYears(Field("created"), 9), "subtractYears(created,9)"), + (SubtractMonths(Field("created"), 10), "subtractMonths(created,10)"), + (SubtractWeeks(Field("created"), 11), "subtractWeeks(created,11)"), + (SubtractDays(Field("created"), 12), "subtractDays(created,12)"), + (SubtractHours(Field("created"), 13), "subtractHours(created,13)"), + (SubtractHours(Field("created"), 13), "subtractHours(created,13)"), + (SubtractMinutes(Field("created"), 14), "subtractMinutes(created,14)"), + (SubtractSeconds(Field("created"), 15), "subtractSeconds(created,15)"), + (SubtractQuarters(Field("created"), 16), "subtractQuarters(created,16)"), + ] + ) + def test_get_sql(self, func, expected): + self.assertEqual(func.get_sql(), expected) + + +class TestToYYYYMM(unittest.TestCase): + def test_get_sql(self): + self.assertEqual(ToYYYYMM(Field("created").get_sql()), "toYYYYMM(created)") diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/clickhouse/test_nullable_arg.py b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/clickhouse/test_nullable_arg.py new file mode 100644 index 0000000000000000000000000000000000000000..3c6c86207a4d0206b5c0ba80b77fac4cc257fa17 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/clickhouse/test_nullable_arg.py @@ -0,0 +1,24 @@ +import unittest + +from parameterized import parameterized + +from pypika import Field +from pypika.clickhouse.nullable_arg import IfNull +from pypika.clickhouse.type_conversion import ToFixedString + + +class TestSearchString(unittest.TestCase): + @parameterized.expand( + [ + ( + IfNull(Field("name"), Field("login")), + "ifNull(name,login)", + ), + ( + IfNull(Field("builder"), ToFixedString("pypika", 100)), + "ifNull(builder,toFixedString('pypika',100))", + ), + ] + ) + def test_get_sql(self, func, expected): + self.assertEqual(func.get_sql(), expected) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/clickhouse/test_search_string.py b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/clickhouse/test_search_string.py new file mode 100644 index 0000000000000000000000000000000000000000..9778eb32e47d4370c0bfe36dcd875903666d30b6 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/clickhouse/test_search_string.py @@ -0,0 +1,41 @@ +import unittest + +from parameterized import parameterized + +from pypika import Field +from pypika.clickhouse.search_string import ( + Match, + Like, + NotLike, + MultiSearchAny, + MultiMatchAny, +) + + +class TestSearchString(unittest.TestCase): + @parameterized.expand( + [ + (Match(Field("name"), "twheys"), "match(toString(\"name\"),'twheys')"), + (Like(Field("name"), "twheys"), "like(toString(\"name\"),'twheys')"), + (NotLike(Field("name"), "twheys"), "notLike(toString(\"name\"),'twheys')"), + ] + ) + def test_search_string(self, func, expected): + self.assertEqual(func, expected) + + +class TestMultiSearch(unittest.TestCase): + @parameterized.expand( + [ + ( + MultiSearchAny(Field("name"), ["sarah", "connor"]), + "multiSearchAny(toString(\"name\"),['sarah','connor'])", + ), + ( + MultiMatchAny(Field("name"), ["sarah", "connor"]), + "multiMatchAny(toString(\"name\"),['sarah','connor'])", + ), + ] + ) + def test_multi_search_string(self, func, expected): + self.assertEqual(func.get_sql(), expected) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/clickhouse/test_type_conversion.py b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/clickhouse/test_type_conversion.py new file mode 100644 index 0000000000000000000000000000000000000000..9692e17bee901e2629db9a5c77111e145358e8eb --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/clickhouse/test_type_conversion.py @@ -0,0 +1,176 @@ +import unittest + +from parameterized import parameterized + +from pypika import ClickHouseQuery, Field, Table +from pypika.clickhouse.type_conversion import ( + ToDate, + ToDateTime, + ToFixedString, + ToFloat32, + ToFloat64, + ToInt16, + ToInt32, + ToInt64, + ToInt8, + ToString, + ToUInt16, + ToUInt32, + ToUInt64, + ToUInt8, +) + + +class TestBasicTypeConverters(unittest.TestCase): + @parameterized.expand( + [ + ( + 'toString("field_name")', + ToString(Field("field_name")), + ), + ( + 'toInt8("field_name")', + ToInt8(Field("field_name")), + ), + ( + 'toInt16("field_name")', + ToInt16(Field("field_name")), + ), + ( + 'toInt32("field_name")', + ToInt32(Field("field_name")), + ), + ( + 'toInt64("field_name")', + ToInt64(Field("field_name")), + ), + ( + 'toUInt8("field_name")', + ToUInt8(Field("field_name")), + ), + ( + 'toUInt16("field_name")', + ToUInt16(Field("field_name")), + ), + ( + 'toUInt32("field_name")', + ToUInt32(Field("field_name")), + ), + ( + 'toUInt64("field_name")', + ToUInt64(Field("field_name")), + ), + ( + 'toFloat32("field_name")', + ToFloat32(Field("field_name")), + ), + ( + 'toFloat64("field_name")', + ToFloat64(Field("field_name")), + ), + ( + 'toFloat64("field_name")', + ToFloat64(Field("field_name")), + ), + ( + 'toDate("field_name")', + ToDate(Field("field_name")), + ), + ( + 'toDateTime("field_name")', + ToDateTime(Field("field_name")), + ), + ( + 'toFixedString("field_name",100)', + ToFixedString(Field("field_name"), 100), + ), + ] + ) + def test_basic_types_field(self, expected, func): + self.assertEqual(func, expected) + + @parameterized.expand( + [ + ( + "toString('100')", + ToString("100"), + ), + ( + "toInt8('100')", + ToInt8("100"), + ), + ( + "toInt16('100')", + ToInt16("100"), + ), + ( + "toInt32('100')", + ToInt32("100"), + ), + ( + "toInt64('100')", + ToInt64("100"), + ), + ( + "toUInt8('100')", + ToUInt8("100"), + ), + ( + "toUInt16('100')", + ToUInt16("100"), + ), + ( + "toUInt32('100')", + ToUInt32("100"), + ), + ( + "toUInt64('100')", + ToUInt64("100"), + ), + ( + "toFloat32('100')", + ToFloat32("100"), + ), + ( + "toFloat64('100')", + ToFloat64("100"), + ), + ( + "toFloat64('100')", + ToFloat64("100"), + ), + ( + "toDate('100')", + ToDate("100"), + ), + ( + "toDateTime('100')", + ToDateTime("100"), + ), + ( + "toFixedString('100',100)", + ToFixedString("100", 100), + ), + ] + ) + def test_basic_types_value(self, expected, func): + self.assertEqual(func, expected) + + +class TestToFixedString(unittest.TestCase): + def test_get_sql_with_table(self): + table = Table("example") + query = ( + ClickHouseQuery.from_(table) + .select( + table.name, + ) + .where( + table.name == ToFixedString("name", 50), + ) + ) + + self.assertEqual( + 'SELECT "name" FROM "example" WHERE "name"=toFixedString(\'name\',50)', + query.get_sql(), + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/dialects/__init__.py b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/dialects/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/dialects/test_clickhouse.py b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/dialects/test_clickhouse.py new file mode 100644 index 0000000000000000000000000000000000000000..f319c4627bd25d7004894181906a284b8b1c64cf --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/dialects/test_clickhouse.py @@ -0,0 +1,146 @@ +from unittest import TestCase + +from pypika import ( + ClickHouseQuery, + Database, + Table, +) + + +class ClickHouseQueryTests(TestCase): + def test_use_AS_keyword_for_alias(self): + t = Table('abc') + query = ClickHouseQuery.from_(t).select(t.foo.as_('f1'), t.bar.as_('f2')) + self.assertEqual(str(query), 'SELECT "foo" AS "f1","bar" AS "f2" FROM "abc"') + + def test_use_SAMPLE_keyword(self): + t = Table('abc') + query = ClickHouseQuery.from_(t).select(t.foo).sample(10) + self.assertEqual(str(query), 'SELECT "foo" FROM "abc" SAMPLE 10') + + def test_use_SAMPLE_with_offset_keyword(self): + t = Table('abc') + query = ClickHouseQuery.from_(t).select(t.foo).sample(10, 5) + self.assertEqual(str(query), 'SELECT "foo" FROM "abc" SAMPLE 10 OFFSET 5') + + def test_use_FINAL_keyword(self): + t = Table('abc') + query = ClickHouseQuery.from_(t).select(t.foo).final() + self.assertEqual(str(query), 'SELECT "foo" FROM "abc" FINAL') + + +class ClickHouseDeleteTests(TestCase): + table_abc = Table("abc") + + def test_omit_where(self): + q = ClickHouseQuery.from_("abc").delete() + + self.assertEqual('ALTER TABLE "abc" DELETE', str(q)) + + def test_omit_where__table_schema(self): + q = ClickHouseQuery.from_(Table("abc", "schema1")).delete() + + self.assertEqual('ALTER TABLE "schema1"."abc" DELETE', str(q)) + + def test_where_field_equals(self): + q1 = ClickHouseQuery.from_(self.table_abc).where(self.table_abc.foo == self.table_abc.bar).delete() + q2 = ClickHouseQuery.from_(self.table_abc).where(self.table_abc.foo.eq(self.table_abc.bar)).delete() + + self.assertEqual('ALTER TABLE "abc" DELETE WHERE "foo"="bar"', str(q1)) + self.assertEqual('ALTER TABLE "abc" DELETE WHERE "foo"="bar"', str(q2)) + + +class ClickHouseUpdateTests(TestCase): + table_abc = Table("abc") + + def test_update(self): + q = ClickHouseQuery.update(self.table_abc).where(self.table_abc.foo == 0).set("foo", "bar") + + self.assertEqual('ALTER TABLE "abc" UPDATE "foo"=\'bar\' WHERE "foo"=0', str(q)) + + +class ClickHouseDropQuery(TestCase): + table_abc = Table("abc") + database_xyz = Database("mydb") + cluster_name = "mycluster" + + def test_drop_database(self): + q1 = ClickHouseQuery.drop_database(self.database_xyz) + q2 = ClickHouseQuery.drop_database(self.database_xyz).on_cluster(self.cluster_name) + q3 = ClickHouseQuery.drop_database(self.database_xyz).if_exists().on_cluster(self.cluster_name) + + self.assertEqual('DROP DATABASE "mydb"', str(q1)) + self.assertEqual('DROP DATABASE "mydb" ON CLUSTER "mycluster"', str(q2)) + self.assertEqual('DROP DATABASE IF EXISTS "mydb" ON CLUSTER "mycluster"', str(q3)) + + def test_drop_table(self): + q1 = ClickHouseQuery.drop_table(self.table_abc) + q2 = ClickHouseQuery.drop_table(self.table_abc).on_cluster(self.cluster_name) + q3 = ClickHouseQuery.drop_table(self.table_abc).if_exists().on_cluster(self.cluster_name) + + self.assertEqual('DROP TABLE "abc"', str(q1)) + self.assertEqual('DROP TABLE "abc" ON CLUSTER "mycluster"', str(q2)) + self.assertEqual('DROP TABLE IF EXISTS "abc" ON CLUSTER "mycluster"', str(q3)) + + def test_drop_dictionary(self): + q1 = ClickHouseQuery.drop_dictionary("dict") + q2 = ClickHouseQuery.drop_dictionary("dict").on_cluster(self.cluster_name) + q3 = ClickHouseQuery.drop_dictionary("dict").if_exists().on_cluster(self.cluster_name) + + self.assertEqual('DROP DICTIONARY "dict"', str(q1)) + self.assertEqual('DROP DICTIONARY "dict"', str(q2)) # NO CLUSTER + self.assertEqual('DROP DICTIONARY IF EXISTS "dict"', str(q3)) # NO CLUSTER + + def test_drop_other(self): + q1 = ClickHouseQuery.drop_quota("myquota") + q2 = ClickHouseQuery.drop_user("myuser") + q3 = ClickHouseQuery.drop_view("myview") + + self.assertEqual('DROP QUOTA "myquota"', str(q1)) + self.assertEqual('DROP USER "myuser"', str(q2)) + self.assertEqual('DROP VIEW "myview"', str(q3)) + + +class DistinctOnTests(TestCase): + table_abc = Table("abc") + + def test_distinct_on(self): + q = ClickHouseQuery.from_(self.table_abc).distinct_on("lname", self.table_abc.fname).select("lname", "id") + + self.assertEqual('''SELECT DISTINCT ON("lname","fname") "lname","id" FROM "abc"''', str(q)) + + +class LimitByTests(TestCase): + table_abc = Table("abc") + + def test_limit_by(self): + q = ClickHouseQuery.from_(self.table_abc).limit_by(1, "a", self.table_abc.b).select("a", "b", "c") + + self.assertEqual('''SELECT "a","b","c" FROM "abc" LIMIT 1 BY ("a","b")''', str(q)) + + def test_limit_offset_by(self): + q = ClickHouseQuery.from_(self.table_abc).limit_offset_by(1, 2, "a", self.table_abc.b).select("a", "b", "c") + + self.assertEqual('''SELECT "a","b","c" FROM "abc" LIMIT 1 OFFSET 2 BY ("a","b")''', str(q)) + + def test_limit_offset0_by(self): + q = ClickHouseQuery.from_(self.table_abc).limit_offset_by(1, 0, "a", self.table_abc.b).select("a", "b", "c") + + self.assertEqual('''SELECT "a","b","c" FROM "abc" LIMIT 1 BY ("a","b")''', str(q)) + + def test_rename_table(self): + table_join = Table("join") + + q = ( + ClickHouseQuery.from_(self.table_abc) + .join(table_join) + .using("a") + .limit_by(1, self.table_abc.a, table_join.a) + .select(self.table_abc.b, table_join.b) + ) + q = q.replace_table(self.table_abc, Table("xyz")) + + self.assertEqual( + '''SELECT "xyz"."b","join"."b" FROM "xyz" JOIN "join" USING ("a") LIMIT 1 BY ("xyz"."a","join"."a")''', + str(q), + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/dialects/test_mssql.py b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/dialects/test_mssql.py new file mode 100644 index 0000000000000000000000000000000000000000..7cf53b228f413a8c7cd3e414fef5522a82f99b29 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/dialects/test_mssql.py @@ -0,0 +1,81 @@ +import unittest + +from pypika import Table +from pypika.analytics import Count +from pypika.dialects import MSSQLQuery +from pypika.utils import QueryException + + +class SelectTests(unittest.TestCase): + def test_normal_select(self): + q = MSSQLQuery.from_("abc").select("def") + + self.assertEqual('SELECT "def" FROM "abc"', str(q)) + + def test_distinct_select(self): + q = MSSQLQuery.from_("abc").select("def").distinct() + + self.assertEqual('SELECT DISTINCT "def" FROM "abc"', str(q)) + + def test_top_distinct_select(self): + q = MSSQLQuery.from_("abc").select("def").top(10).distinct() + + self.assertEqual('SELECT DISTINCT TOP (10) "def" FROM "abc"', str(q)) + + def test_top_select(self): + q = MSSQLQuery.from_("abc").select("def").top(10) + + self.assertEqual('SELECT TOP (10) "def" FROM "abc"', str(q)) + + def test_top_with_ties_select(self): + q = MSSQLQuery.from_("abc").select("def").top(10, with_ties=True) + + self.assertEqual('SELECT TOP (10) WITH TIES "def" FROM "abc"', str(q)) + + def test_top_percent_select(self): + q = MSSQLQuery.from_("abc").select("def").top(10, percent=True) + + self.assertEqual('SELECT TOP (10) PERCENT "def" FROM "abc"', str(q)) + + def test_top_percent_invalid_range(self): + for invalid_top in [-1, 101]: + with self.assertRaisesRegex( + QueryException, "TOP value must be between 0 and 100 when `percent` is specified" + ): + MSSQLQuery.from_("abc").select("def").top(invalid_top, percent=True) + + def test_top_select_non_int(self): + with self.assertRaisesRegex(QueryException, "TOP value must be an integer"): + MSSQLQuery.from_("abc").select("def").top("a") + + def test_limit(self): + q = MSSQLQuery.from_("abc").select("def").orderby("def").limit(10) + + self.assertEqual('SELECT "def" FROM "abc" ORDER BY "def" OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY', str(q)) + + def test_offset(self): + q = MSSQLQuery.from_("abc").select("def").orderby("def").offset(10) + + self.assertEqual('SELECT "def" FROM "abc" ORDER BY "def" OFFSET 10 ROWS', str(q)) + + def test_limit_with_offset(self): + q = MSSQLQuery.from_("abc").select("def").orderby("def").limit(10).offset(10) + + self.assertEqual('SELECT "def" FROM "abc" ORDER BY "def" OFFSET 10 ROWS FETCH NEXT 10 ROWS ONLY', str(q)) + + def test_groupby_alias_False_does_not_group_by_alias_with_standard_query(self): + t = Table('table1') + col = t.abc.as_('a') + q = MSSQLQuery.from_(t).select(col, Count('*')).groupby(col) + + self.assertEqual('SELECT "abc" "a",COUNT(\'*\') FROM "table1" GROUP BY "abc"', str(q)) + + def test_groupby_alias_False_does_not_group_by_alias_when_subqueries_are_present(self): + t = Table('table1') + subquery = MSSQLQuery.from_(t).select(t.abc) + col = subquery.abc.as_('a') + q = MSSQLQuery.from_(subquery).select(col, Count('*')).groupby(col) + + self.assertEqual( + 'SELECT "sq0"."abc" "a",COUNT(\'*\') FROM (SELECT "abc" FROM "table1") "sq0" GROUP BY "sq0"."abc"', str(q) + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/dialects/test_mysql.py b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/dialects/test_mysql.py new file mode 100644 index 0000000000000000000000000000000000000000..619d064adcdf8b5ff9ecd054fa4ab00eff1d69b3 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/dialects/test_mysql.py @@ -0,0 +1,91 @@ +import unittest + +from pypika import MySQLQuery, QueryException, Table, Column + + +class SelectTests(unittest.TestCase): + table_abc = Table("abc") + + def test_normal_select(self): + q = MySQLQuery.from_("abc").select("def") + + self.assertEqual("SELECT `def` FROM `abc`", str(q)) + + def test_distinct_select(self): + q = MySQLQuery.from_("abc").select("def").distinct() + + self.assertEqual("SELECT DISTINCT `def` FROM `abc`", str(q)) + + def test_modifier_select(self): + q = MySQLQuery.from_("abc").select("def").select("ghi").modifier("SQL_CALC_FOUND_ROWS") + + self.assertEqual("SELECT SQL_CALC_FOUND_ROWS `def`,`ghi` FROM `abc`", str(q)) + + def test_multiple_modifier_select(self): + q = MySQLQuery.from_("abc").select("def").modifier("HIGH_PRIORITY").modifier("SQL_CALC_FOUND_ROWS") + + self.assertEqual("SELECT HIGH_PRIORITY SQL_CALC_FOUND_ROWS `def` FROM `abc`", str(q)) + + +class UpdateTests(unittest.TestCase): + table_abc = Table("abc") + + def test_update(self): + q = MySQLQuery.into("abc").insert(1, [1, "a", True]) + + self.assertEqual("INSERT INTO `abc` VALUES (1,[1,'a',true])", str(q)) + + def test_on_duplicate_key_ignore_update(self): + q = MySQLQuery.into("abc").insert(1, [1, "a", True]).on_duplicate_key_ignore() + + self.assertEqual("INSERT INTO `abc` VALUES (1,[1,'a',true]) ON DUPLICATE KEY IGNORE", str(q)) + + def test_on_duplicate_key_update_update(self): + q = MySQLQuery.into("abc").insert(1, [1, "a", True]).on_duplicate_key_update(self.table_abc.a, 'b') + + self.assertEqual("INSERT INTO `abc` VALUES (1,[1,'a',true]) ON DUPLICATE KEY UPDATE `a`='b'", str(q)) + + def test_conflict_handlers_update(self): + with self.assertRaises(QueryException): + ( + MySQLQuery.into("abc") + .insert(1, [1, "a", True]) + .on_duplicate_key_ignore() + .on_duplicate_key_update(self.table_abc.a, 'b') + ) + + +class LoadCSVTests(unittest.TestCase): + table_abc = Table("abc") + + def test_load_from_file(self): + q1 = MySQLQuery.load("/path/to/file").into("abc") + + q2 = MySQLQuery.load("/path/to/file").into(self.table_abc) + + self.assertEqual( + "LOAD DATA LOCAL INFILE '/path/to/file' INTO TABLE `abc` FIELDS TERMINATED BY ','", + str(q1), + ) + self.assertEqual( + "LOAD DATA LOCAL INFILE '/path/to/file' INTO TABLE `abc` FIELDS TERMINATED BY ','", + str(q2), + ) + + +class TableTests(unittest.TestCase): + table_abc = Table("abc") + + def test_create_table(self): + q = MySQLQuery.create_table(self.table_abc).columns(Column("id", "INT")) + self.assertEqual( + 'CREATE TABLE `abc` (`id` INT)', + str(q), + ) + + def test_drop_table(self): + q = MySQLQuery.drop_table(self.table_abc) + self.assertEqual( + 'DROP TABLE `abc`', + str(q), + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/dialects/test_oracle.py b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/dialects/test_oracle.py new file mode 100644 index 0000000000000000000000000000000000000000..21b54f16fd5d3518b5c767d3605068637898a73f --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/dialects/test_oracle.py @@ -0,0 +1,51 @@ +import unittest + +from pypika import OracleQuery, Table +from pypika.analytics import Count + + +class SelectTests(unittest.TestCase): + def test_groupby_alias_False_does_not_group_by_alias_with_standard_query(self): + t = Table('table1') + col = t.abc.as_('a') + q = OracleQuery.from_(t).select(col, Count('*')).groupby(col) + + self.assertEqual('SELECT abc a,COUNT(\'*\') FROM table1 GROUP BY abc', str(q)) + + def test_groupby_alias_False_does_not_group_by_alias_when_subqueries_are_present(self): + t = Table('table1') + subquery = OracleQuery.from_(t).select(t.abc) + col = subquery.abc.as_('a') + q = OracleQuery.from_(subquery).select(col, Count('*')).groupby(col) + + self.assertEqual('SELECT sq0.abc a,COUNT(\'*\') FROM (SELECT abc FROM table1) sq0 GROUP BY sq0.abc', str(q)) + + def test_limit_query(self): + t = Table('table1') + limit = 5 + q = OracleQuery.from_(t).select(t.test).limit(limit) + + self.assertEqual(f'SELECT test FROM table1 FETCH NEXT {limit} ROWS ONLY', str(q)) + + def test_offset_query(self): + t = Table('table1') + offset = 5 + q = OracleQuery.from_(t).select(t.test).offset(offset) + + self.assertEqual(f'SELECT test FROM table1 OFFSET {offset} ROWS', str(q)) + + def test_limit_offset_query(self): + t = Table('table1') + limit = 5 + offset = 5 + q = OracleQuery.from_(t).select(t.test).limit(limit).offset(offset) + + self.assertEqual(f'SELECT test FROM table1 OFFSET {offset} ROWS FETCH NEXT {limit} ROWS ONLY', str(q)) + + def test_fetch_next_method_deprecated(self): + with self.assertWarns(DeprecationWarning): + t = Table('table1') + limit = 5 + q = OracleQuery.from_(t).select(t.test).fetch_next(limit) + + self.assertEqual(f'SELECT test FROM table1 FETCH NEXT {limit} ROWS ONLY', str(q)) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/dialects/test_postgresql.py b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/dialects/test_postgresql.py new file mode 100644 index 0000000000000000000000000000000000000000..437eed03e120485ed2a357a4c2d92426f1466e14 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/dialects/test_postgresql.py @@ -0,0 +1,262 @@ +import unittest +from collections import OrderedDict + +from pypika import ( + Array, + Field, + JSON, + QueryException, + Table, +) +from pypika.dialects import PostgreSQLQuery + + +class InsertTests(unittest.TestCase): + table_abc = Table("abc") + + def test_array_keyword(self): + q = PostgreSQLQuery.into(self.table_abc).insert(1, [1, "a", True]) + + self.assertEqual("INSERT INTO \"abc\" VALUES (1,ARRAY[1,'a',true])", str(q)) + + +class JSONObjectTests(unittest.TestCase): + def test_alias_set_correctly(self): + table = Table('jsonb_table') + q = PostgreSQLQuery.from_('abc').select(table.value.get_text_value('a').as_('name')) + + self.assertEqual('''SELECT "value"->>'a' "name" FROM "abc"''', str(q)) + + def test_json_value_from_dict(self): + q = PostgreSQLQuery.select(JSON({"a": "foo"})) + + self.assertEqual('SELECT \'{"a":"foo"}\'', str(q)) + + def test_json_value_from_array_num(self): + q = PostgreSQLQuery.select(JSON([1, 2, 3])) + + self.assertEqual("SELECT '[1,2,3]'", str(q)) + + def test_json_value_from_array_str(self): + q = PostgreSQLQuery.select(JSON(["a", "b", "c"])) + + self.assertEqual('SELECT \'["a","b","c"]\'', str(q)) + + def test_json_value_from_dict_recursive(self): + q = PostgreSQLQuery.select(JSON({"a": "z", "b": {"c": "foo"}, "d": 1})) + + # gotta split this one up to avoid the indeterminate order + sql = str(q) + start, end = 9, -2 + self.assertEqual("SELECT '{}'", sql[:start] + sql[end:]) + + members_set = set(sql[start:end].split(",")) + self.assertSetEqual({'"a":"z"', '"b":{"c":"foo"}', '"d":1'}, members_set) + + +class JSONOperatorsTests(unittest.TestCase): + # reference https://www.postgresql.org/docs/9.5/functions-json.html + table_abc = Table("abc") + + def test_get_json_value_by_key(self): + q = PostgreSQLQuery.from_(self.table_abc).select("*").where(self.table_abc.json.get_json_value("dates")) + + self.assertEqual('SELECT * FROM "abc" WHERE "json"->\'dates\'', str(q)) + + def test_get_json_value_by_index(self): + q = PostgreSQLQuery.from_(self.table_abc).select("*").where(self.table_abc.json.get_json_value(1)) + + self.assertEqual('SELECT * FROM "abc" WHERE "json"->1', str(q)) + + def test_get_text_value_by_key(self): + q = PostgreSQLQuery.from_(self.table_abc).select("*").where(self.table_abc.json.get_text_value("dates")) + + self.assertEqual('SELECT * FROM "abc" WHERE "json"->>\'dates\'', str(q)) + + def test_get_text_value_by_index(self): + q = PostgreSQLQuery.from_(self.table_abc).select("*").where(self.table_abc.json.get_text_value(1)) + + self.assertEqual('SELECT * FROM "abc" WHERE "json"->>1', str(q)) + + def test_get_path_json_value(self): + q = PostgreSQLQuery.from_(self.table_abc).select("*").where(self.table_abc.json.get_path_json_value("{a,b}")) + + self.assertEqual('SELECT * FROM "abc" WHERE "json"#>\'{a,b}\'', str(q)) + + def test_get_path_text_value(self): + q = PostgreSQLQuery.from_(self.table_abc).select("*").where(self.table_abc.json.get_path_text_value("{a,b}")) + + self.assertEqual('SELECT * FROM "abc" WHERE "json"#>>\'{a,b}\'', str(q)) + + +class JSONBOperatorsTests(unittest.TestCase): + # reference https://www.postgresql.org/docs/9.5/functions-json.html + table_abc = Table("abc") + + def test_json_contains_for_json(self): + q = PostgreSQLQuery.select(JSON({"a": 1, "b": 2}).contains({"a": 1})) + + # gotta split this one up to avoid the indeterminate order + sql = str(q) + start, end = 9, -13 + self.assertEqual("SELECT '{}'@>'{\"a\":1}'", sql[:start] + sql[end:]) + + members_set = set(sql[start:end].split(",")) + self.assertSetEqual({'"a":1', '"b":2'}, members_set) + + def test_json_contains_for_field(self): + q = ( + PostgreSQLQuery.from_(self.table_abc) + .select("*") + .where(self.table_abc.json.contains({"dates": "2018-07-10 - 2018-07-17"})) + ) + + self.assertEqual( + "SELECT * " 'FROM "abc" ' 'WHERE "json"@>\'{"dates":"2018-07-10 - 2018-07-17"}\'', + str(q), + ) + + def test_json_contained_by_using_str_arg(self): + q = ( + PostgreSQLQuery.from_(self.table_abc) + .select("*") + .where( + self.table_abc.json.contained_by( + OrderedDict( + [ + ("dates", "2018-07-10 - 2018-07-17"), + ("imported", "8"), + ] + ) + ) + ) + ) + self.assertEqual( + 'SELECT * FROM "abc" ' 'WHERE "json"<@\'{"dates":"2018-07-10 - 2018-07-17","imported":"8"}\'', + str(q), + ) + + def test_json_contained_by_using_list_arg(self): + q = ( + PostgreSQLQuery.from_(self.table_abc) + .select("*") + .where(self.table_abc.json.contained_by(["One", "Two", "Three"])) + ) + + self.assertEqual('SELECT * FROM "abc" WHERE "json"<@\'["One","Two","Three"]\'', str(q)) + + def test_json_contained_by_with_complex_criterion(self): + q = ( + PostgreSQLQuery.from_(self.table_abc) + .select("*") + .where(self.table_abc.json.contained_by(["One", "Two", "Three"]) & (self.table_abc.id == 26)) + ) + + self.assertEqual( + 'SELECT * FROM "abc" WHERE "json"<@\'["One","Two","Three"]\' AND "id"=26', + str(q), + ) + + def test_json_has_key(self): + q = PostgreSQLQuery.from_(self.table_abc).select("*").where(self.table_abc.json.has_key("dates")) + + self.assertEqual('SELECT * FROM "abc" WHERE "json"?\'dates\'', str(q)) + + def test_json_has_keys(self): + q = PostgreSQLQuery.from_(self.table_abc).select("*").where(self.table_abc.json.has_keys(["dates", "imported"])) + + self.assertEqual("SELECT * FROM \"abc\" WHERE \"json\"?&ARRAY['dates','imported']", str(q)) + + def test_json_has_any_keys(self): + q = ( + PostgreSQLQuery.from_(self.table_abc) + .select("*") + .where(self.table_abc.json.has_any_keys(["dates", "imported"])) + ) + + self.assertEqual("SELECT * FROM \"abc\" WHERE \"json\"?|ARRAY['dates','imported']", str(q)) + + def test_subnet_contains_inet(self): + q = ( + PostgreSQLQuery.from_(self.table_abc) + .select(self.table_abc.a.lshift(2)) + .where(self.table_abc.cidr >> "1.1.1.1") + ) + + self.assertEqual("SELECT \"a\"<<2 FROM \"abc\" WHERE \"cidr\">>'1.1.1.1'", str(q)) + + +class DistinctOnTests(unittest.TestCase): + table_abc = Table("abc") + + def test_distinct_on(self): + q = PostgreSQLQuery.from_(self.table_abc).distinct_on("lname", self.table_abc.fname).select("lname", "id") + + self.assertEqual('''SELECT DISTINCT ON("lname","fname") "lname","id" FROM "abc"''', str(q)) + + +class ArrayTests(unittest.TestCase): + def test_array_syntax(self): + tb = Table("tb") + q = PostgreSQLQuery.from_(tb).select(Array(1, "a", ["b", 2, 3])) + + self.assertEqual(str(q), "SELECT ARRAY[1,'a',ARRAY['b',2,3]] FROM \"tb\"") + + def test_render_alias_in_array_sql(self): + tb = Table("tb") + + q = PostgreSQLQuery.from_(tb).select(Array(tb.col).as_("different_name")) + self.assertEqual(str(q), 'SELECT ARRAY["col"] "different_name" FROM "tb"') + + +class ReturningClauseTests(unittest.TestCase): + @classmethod + def setUpClass(cls) -> None: + super().setUpClass() + cls.table_abc = Table('abc') + + def test_returning_from_missing_table_raises_queryexception(self): + field_from_diff_table = Field('xyz', table=Table('other')) + + with self.assertRaisesRegex(QueryException, "You can't return from other tables"): + ( + PostgreSQLQuery.from_(self.table_abc) + .where(self.table_abc.foo == self.table_abc.bar) + .delete() + .returning(field_from_diff_table) + ) + + def test_queryexception_if_returning_used_on_invalid_query(self): + with self.assertRaisesRegex(QueryException, "Returning can't be used in this query"): + PostgreSQLQuery.from_(self.table_abc).select('abc').returning('abc') + + def test_no_queryexception_if_returning_used_on_valid_query_type(self): + # No exceptions for insert, update and delete queries + with self.subTest('DELETE'): + PostgreSQLQuery.from_(self.table_abc).where(self.table_abc.foo == self.table_abc.bar).delete().returning( + "id" + ) + with self.subTest('UPDATE'): + PostgreSQLQuery.update(self.table_abc).where(self.table_abc.foo == 0).set("foo", "bar").returning("id") + with self.subTest('INSERT'): + PostgreSQLQuery.into(self.table_abc).insert('abc').returning('abc') + + def test_return_field_from_join_table(self): + new_table = Table('xyz') + q = ( + PostgreSQLQuery.update(self.table_abc) + .join(new_table) + .on(new_table.id == self.table_abc.xyz) + .where(self.table_abc.foo == 0) + .set("foo", "bar") + .returning(new_table.a) + ) + + self.assertEqual( + 'UPDATE "abc" ' + 'JOIN "xyz" ON "xyz"."id"="abc"."xyz" ' + 'SET "foo"=\'bar\' ' + 'WHERE "abc"."foo"=0 ' + 'RETURNING "xyz"."a"', + str(q), + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/dialects/test_snowflake.py b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/dialects/test_snowflake.py new file mode 100644 index 0000000000000000000000000000000000000000..5ac08b2d8b8b5496ed6f3510acf4be1ec7893405 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/dialects/test_snowflake.py @@ -0,0 +1,58 @@ +import unittest + +from pypika import ( + Tables, + functions as fn, + Column, +) +from pypika.dialects import SnowflakeQuery + + +class QuoteTests(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_use_double_quotes_on_alias_but_not_on_terms(self): + q = SnowflakeQuery.from_(self.table_abc).select(self.table_abc.a.as_("bar")) + + self.assertEqual('SELECT a "bar" FROM abc', q.get_sql(with_namespace=True)) + + def test_use_double_quotes_on_alias_but_not_on_terms_with_joins(self): + foo = self.table_abc.as_("foo") + bar = self.table_efg.as_("bar") + + q = SnowflakeQuery.from_(foo).join(bar).on(foo.fk == bar.id).select(foo.a, bar.b) + + self.assertEqual( + "SELECT foo.a,bar.b " 'FROM abc "foo" ' 'JOIN efg "bar" ' "ON foo.fk=bar.id", + q.get_sql(with_namespace=True), + ) + + def test_use_double_quotes_on_alias_but_not_on_terms(self): + idx = self.table_abc.index.as_("idx") + val = fn.Sum(self.table_abc.value).as_("val") + q = SnowflakeQuery.from_(self.table_abc).select(idx, val).groupby(idx).orderby(idx) + + self.assertEqual( + 'SELECT index "idx",SUM(value) "val" ' "FROM abc " 'GROUP BY "idx" ' 'ORDER BY "idx"', + q.get_sql(with_namespace=True), + ) + + def test_dont_use_double_quotes_on_joining_queries(self): + foo = self.table_abc + bar = self.table_efg + q1 = SnowflakeQuery.from_(foo).select(foo.b) + q2 = SnowflakeQuery.from_(bar).select(bar.b) + q = SnowflakeQuery.from_(q1).join(q2).on(q1.b == q2.b).select("*") + + self.assertEqual( + "SELECT * " 'FROM (SELECT b FROM abc) sq0 ' 'JOIN (SELECT b FROM efg) sq1 ' "ON sq0.b=sq1.b", + q.get_sql(), + ) + + def test_dont_use_double_quotes_on_create_queries(self): + q = SnowflakeQuery.create_table(self.table_abc).columns(Column("id", "INT")) + self.assertEqual("CREATE TABLE abc (id INT)", q.get_sql()) + + def test_dont_use_double_quotes_on_drop_queries(self): + q = SnowflakeQuery.drop_table(self.table_abc) + self.assertEqual("DROP TABLE abc", q.get_sql()) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/dialects/test_sqllite.py b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/dialects/test_sqllite.py new file mode 100644 index 0000000000000000000000000000000000000000..104a7235b6ea2d46fd365989f68c5d081eb20076 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/dialects/test_sqllite.py @@ -0,0 +1,35 @@ +import unittest + +from pypika import Table +from pypika.dialects import SQLLiteQuery + + +class SelectTests(unittest.TestCase): + table_abc = Table("abc") + + def test_bool_true_as_one(self): + q = SQLLiteQuery.from_("abc").select(True) + + self.assertEqual('SELECT 1 FROM "abc"', str(q)) + + def test_bool_false_as_zero(self): + q = SQLLiteQuery.from_("abc").select(False) + + self.assertEqual('SELECT 0 FROM "abc"', str(q)) + + +class ReplaceTests(unittest.TestCase): + def test_normal_replace(self): + query = SQLLiteQuery.into("abc").replace("v1", "v2", "v3") + expected_output = "REPLACE INTO \"abc\" VALUES ('v1','v2','v3')" + self.assertEqual(expected_output, str(query)) + + def test_replace_subquery(self): + query = SQLLiteQuery.into("abc").replace(SQLLiteQuery.from_("def").select("f1", "f2")) + expected_output = 'REPLACE INTO "abc" VALUES ((SELECT "f1","f2" FROM "def"))' + self.assertEqual(expected_output, str(query)) + + def test_insert_or_replace(self): + query = SQLLiteQuery.into("abc").insert_or_replace("v1", "v2", "v3") + expected_output = "INSERT OR REPLACE INTO \"abc\" VALUES ('v1','v2','v3')" + self.assertEqual(expected_output, str(query)) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/dialects/test_vertica.py b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/dialects/test_vertica.py new file mode 100644 index 0000000000000000000000000000000000000000..61985bfc244fcd663e7d8a904b4645901f3abdfc --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/dialects/test_vertica.py @@ -0,0 +1,93 @@ +import unittest + +from pypika import Columns, Table, Tables, VerticaQuery + + +class VerticaQueryTests(unittest.TestCase): + table_abc = Table("abc") + + def test_select_query_with_hint(self): + q = VerticaQuery.from_("abc").select("*").hint("test_hint") + + self.assertEqual('SELECT /*+label(test_hint)*/ * FROM "abc"', str(q)) + + def test_insert_query_with_hint(self): + query = VerticaQuery.into(self.table_abc).insert(1).hint("test_hint") + + self.assertEqual('INSERT /*+label(test_hint)*/ INTO "abc" VALUES (1)', str(query)) + + def test_update_query_with_hint(self): + q = VerticaQuery.update(self.table_abc).set("foo", "bar").hint("test_hint") + + self.assertEqual('UPDATE /*+label(test_hint)*/ "abc" SET "foo"=\'bar\'', str(q)) + + def test_delete_query_with_hint(self): + q = VerticaQuery.from_("abc").delete().hint("test_hint") + + self.assertEqual('DELETE /*+label(test_hint)*/ FROM "abc"', str(q)) + + +class CopyCSVTests(unittest.TestCase): + table_abc = Table("abc") + + def test_copy_from_file(self): + with self.subTest("with table as string"): + q = VerticaQuery.from_file("/path/to/file").copy_("abc") + + self.assertEqual( + "COPY \"abc\" FROM LOCAL '/path/to/file' PARSER fcsvparser(header=false)", + str(q), + ) + + with self.subTest("with table"): + q = VerticaQuery.from_file("/path/to/file").copy_(self.table_abc) + + self.assertEqual( + "COPY \"abc\" FROM LOCAL '/path/to/file' PARSER fcsvparser(header=false)", + str(q), + ) + + +class CreateTemporaryTableTests(unittest.TestCase): + new_table, existing_table = Tables("abc", "efg") + foo, bar = Columns(("a", "INT"), ("b", "VARCHAR(100)")) + select = VerticaQuery.from_(existing_table).select(existing_table.foo, existing_table.bar) + + def test_create_local_temporary_table(self): + with self.subTest("with columns"): + q = VerticaQuery.create_table(self.new_table).temporary().local().columns(self.foo, self.bar) + + self.assertEqual('CREATE LOCAL TEMPORARY TABLE "abc" ("a" INT,"b" VARCHAR(100))', str(q)) + + with self.subTest("with select"): + q = VerticaQuery.create_table(self.new_table).temporary().local().as_select(self.select) + + self.assertEqual( + 'CREATE LOCAL TEMPORARY TABLE "abc" AS (SELECT "foo","bar" FROM "efg")', + str(q), + ) + + def test_create_local_table_without_temporary_raises_error(self): + with self.assertRaises(AttributeError): + VerticaQuery.create_table(self.new_table).local() + + def test_create_temporary_table_preserve_rows(self): + with self.subTest("with columns"): + q = VerticaQuery.create_table(self.new_table).temporary().preserve_rows().columns(self.foo, self.bar) + + self.assertEqual( + 'CREATE TEMPORARY TABLE "abc" ("a" INT,"b" VARCHAR(100)) ON COMMIT PRESERVE ROWS', + str(q), + ) + + with self.subTest("with select"): + q = VerticaQuery.create_table(self.new_table).temporary().preserve_rows().as_select(self.select) + + self.assertEqual( + 'CREATE TEMPORARY TABLE "abc" ON COMMIT PRESERVE ROWS AS (SELECT "foo","bar" FROM "efg")', + str(q), + ) + + def test_create_table_preserve_rows_without_temporary_raises_error(self): + with self.assertRaises(AttributeError): + VerticaQuery.create_table(self.new_table).preserve_rows() diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/test_aggregate.py b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/test_aggregate.py new file mode 100644 index 0000000000000000000000000000000000000000..1c627d8e9c2d65410c67cf2c39974949b0720a0e --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/test_aggregate.py @@ -0,0 +1,122 @@ +import unittest + +from pypika import ( + Case, + Field, + Table, + functions as fn, +) +from pypika.terms import ( + Negative, + ValueWrapper, +) + + +class IsAggregateTests(unittest.TestCase): + def test__field_is_not_aggregate(self): + v = Field("foo") + self.assertFalse(v.is_aggregate) + + def test__constant_is_aggregate_none(self): + v = ValueWrapper(100) + self.assertIsNone(v.is_aggregate) + + def test__constant_arithmetic_is_aggregate_none(self): + v = ValueWrapper(100) + ValueWrapper(100) + self.assertIsNone(v.is_aggregate) + + def test__field_arithmetic_is_not_aggregate(self): + v = Field("foo") + Field("bar") + self.assertFalse(v.is_aggregate) + + def test__field_arithmetic_constant_is_not_aggregate(self): + v = Field("foo") + 1 + self.assertFalse(v.is_aggregate) + + def test__agg_func_is_aggregate(self): + v = fn.Sum(Field("foo")) + self.assertTrue(v.is_aggregate) + + def test__negative_agg_func_is_aggregate(self): + v = Negative(fn.Sum(Field("foo"))) + self.assertTrue(v.is_aggregate) + + def test__agg_func_arithmetic_is_aggregate(self): + v = fn.Sum(Field("foo")) / fn.Sum(Field("foo")) + self.assertTrue(v.is_aggregate) + + def test__mixed_func_arithmetic_is_not_aggregate(self): + v = Field("foo") / fn.Sum(Field("foo")) + self.assertFalse(v.is_aggregate) + + def test__func_arithmetic_constant_is_not_aggregate(self): + v = 1 / fn.Sum(Field("foo")) + self.assertTrue(v.is_aggregate) + + def test__agg_case_criterion_is_aggregate(self): + v = Case().when(fn.Sum(Field("foo")) > 666, 'More than 666').else_('Less than 666') + + self.assertTrue(v.is_aggregate) + + def test__agg_case_is_aggregate(self): + v = ( + Case() + .when(Field("foo") == 1, fn.Sum(Field("bar"))) + .when(Field("foo") == 2, fn.Sum(Field("fiz"))) + .else_(fn.Sum(Field("fiz"))) + ) + + self.assertTrue(v.is_aggregate) + + def test__mixed_case_is_not_aggregate(self): + v = Case().when(Field("foo") == 1, fn.Sum(Field("bar"))).when(Field("foo") == 2, Field("fiz")) + + self.assertFalse(v.is_aggregate) + + def test__case_mixed_else_is_not_aggregate(self): + v = ( + Case() + .when(Field("foo") == 1, fn.Sum(Field("bar"))) + .when(Field("foo") == 2, fn.Sum(Field("fiz"))) + .else_(Field("fiz")) + ) + + self.assertFalse(v.is_aggregate) + + def test__case_mixed_constant_is_not_aggregate(self): + v = Case().when(Field("foo") == 1, fn.Sum(Field("bar"))).when(Field("foo") == 2, fn.Sum(Field("fiz"))).else_(1) + + self.assertTrue(v.is_aggregate) + + def test__case_with_field_is_not_aggregate(self): + v = Case().when(Field("foo") == 1, 1).when(Field("foo") == 2, 2).else_(3) + + self.assertFalse(v.is_aggregate) + + def test__case_with_single_aggregate_field_in_one_criterion_is_aggregate(self): + v = Case().when(Field("foo") == 1, 1).when(fn.Sum(Field("foo")) == 2, 2).else_(3) + + self.assertTrue(v.is_aggregate) + + def test__non_aggregate_function_with_aggregated_arg(self): + t = Table("abc") + expr = fn.Sqrt(fn.Sum(t.a)) + + self.assertTrue(expr.is_aggregate) + + def test_complicated(self): + t = Table("abc") + is_placebo = t.campaign_extra_info == "placebo" + + pixel_mobile_search = Case().when(is_placebo, t.action_fb_pixel_search + t.action_fb_mobile_search) + unique_impressions = Case().when(is_placebo, t.unique_impressions) + + v = fn.Sum(pixel_mobile_search) / fn.Sum(unique_impressions) - 1.96 * fn.Sqrt( + 1 + / fn.Sum(unique_impressions) + * fn.Sum(pixel_mobile_search) + / fn.Sum(unique_impressions) + * (1 - fn.Sum(pixel_mobile_search) / fn.Sum(unique_impressions)) + ) + + self.assertTrue(v.is_aggregate) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/test_analytic_queries.py b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/test_analytic_queries.py new file mode 100644 index 0000000000000000000000000000000000000000..6a35ab854b30e3b0f91e633b3349706a22e0a2fd --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/test_analytic_queries.py @@ -0,0 +1,610 @@ +import unittest + +from pypika import Criterion, JoinType, Order, Query, Tables, analytics as an +from pypika.analytics import Lag, Lead + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + + +class RankTests(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_rank(self): + expr = an.Rank().over(self.table_abc.foo).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " "RANK() " 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_dense_rank(self): + expr = an.DenseRank().over(self.table_abc.foo).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " "DENSE_RANK() " 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_row_number(self): + expr = an.RowNumber().over(self.table_abc.foo).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " "ROW_NUMBER() " 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_rank_with_alias(self): + expr = an.Rank().over(self.table_abc.foo).orderby(self.table_abc.date).as_("rank") + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " "RANK() " 'OVER(PARTITION BY "foo" ORDER BY "date") "rank" ' 'FROM "abc"', + str(q), + ) + + def test_multiple_partitions(self): + expr = an.Rank().orderby(self.table_abc.date).over(self.table_abc.foo, self.table_abc.bar) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " "RANK() " 'OVER(PARTITION BY "foo","bar" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_ntile_no_partition_or_order_invalid_sql(self): + expr = an.NTile(5) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual("SELECT " "NTILE(5) " 'FROM "abc"', str(q)) + + def test_ntile_with_partition(self): + expr = an.NTile(5).over(self.table_abc.foo) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual("SELECT " "NTILE(5) " 'OVER(PARTITION BY "foo") ' 'FROM "abc"', str(q)) + + def test_ntile_with_order(self): + expr = an.NTile(5).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual("SELECT " "NTILE(5) " 'OVER(ORDER BY "date") ' 'FROM "abc"', str(q)) + + def test_ntile_with_partition_and_order(self): + expr = an.NTile(5).over(self.table_abc.foo).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " "NTILE(5) " 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_first_value(self): + expr = an.FirstValue(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'FIRST_VALUE("fizz") ' 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_first_value_ignore_nulls(self): + expr = an.FirstValue(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).ignore_nulls() + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'FIRST_VALUE("fizz" IGNORE NULLS) ' 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_first_value_ignore_nulls_first(self): + expr = an.FirstValue(self.table_abc.fizz).ignore_nulls().over(self.table_abc.foo).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'FIRST_VALUE("fizz" IGNORE NULLS) ' 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_first_value_multi_argument(self): + expr = ( + an.FirstValue(self.table_abc.fizz, self.table_abc.buzz) + .over(self.table_abc.foo) + .orderby(self.table_abc.date) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'FIRST_VALUE("fizz","buzz") ' 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_last_value(self): + expr = an.LastValue(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'LAST_VALUE("fizz") ' 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_filter(self): + expr = ( + an.LastValue(self.table_abc.fizz) + .filter(Criterion.all([self.table_abc.bar == True])) + .over(self.table_abc.foo) + .orderby(self.table_abc.date) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'LAST_VALUE("fizz") ' + 'FILTER(WHERE "bar"=true) ' + 'OVER(PARTITION BY "foo" ORDER BY "date") ' + 'FROM "abc"', + str(q), + ) + + def test_filter_quote_table_in_filter(self): + expr = ( + an.LastValue(self.table_efg.fizz) + .filter(self.table_efg.filed.eq('yes')) + .over(self.table_efg.foo) + .orderby(self.table_efg.date) + ) + + q = ( + Query.from_(self.table_abc) + .inner_join(self.table_efg) + .on(self.table_abc.id.eq(self.table_efg.id)) + .select(expr) + ) + + self.assertEqual( + 'SELECT ' + 'LAST_VALUE("efg"."fizz") ' + 'FILTER(WHERE "efg"."filed"=\'yes\') ' + 'OVER(PARTITION BY "efg"."foo" ORDER BY "efg"."date") ' + 'FROM "abc" ' + 'JOIN "efg" ON "abc"."id"="efg"."id"', + str(q), + ) + + def test_orderby_asc(self): + expr = an.LastValue(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date, order=Order.asc) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'LAST_VALUE("fizz") ' 'OVER(PARTITION BY "foo" ORDER BY "date" ASC) ' 'FROM "abc"', + str(q), + ) + + def test_orderby_desc(self): + expr = an.LastValue(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date, order=Order.desc) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'LAST_VALUE("fizz") ' 'OVER(PARTITION BY "foo" ORDER BY "date" DESC) ' 'FROM "abc"', + str(q), + ) + + def test_last_value_multi_argument(self): + expr = ( + an.LastValue(self.table_abc.fizz, self.table_abc.buzz).over(self.table_abc.foo).orderby(self.table_abc.date) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'LAST_VALUE("fizz","buzz") ' 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_last_value_ignore_nulls(self): + expr = an.LastValue(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).ignore_nulls() + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'LAST_VALUE("fizz" IGNORE NULLS) ' 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_median(self): + expr = an.Median(self.table_abc.fizz).over(self.table_abc.foo, self.table_abc.bar).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'MEDIAN("fizz") ' 'OVER(PARTITION BY "foo","bar" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_avg(self): + expr = an.Avg(self.table_abc.fizz).over(self.table_abc.foo, self.table_abc.bar).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'AVG("fizz") ' 'OVER(PARTITION BY "foo","bar" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_stddev(self): + expr = an.StdDev(self.table_abc.fizz).over(self.table_abc.foo, self.table_abc.bar).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'STDDEV("fizz") ' 'OVER(PARTITION BY "foo","bar" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_stddev_pop(self): + expr = ( + an.StdDevPop(self.table_abc.fizz).over(self.table_abc.foo, self.table_abc.bar).orderby(self.table_abc.date) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'STDDEV_POP("fizz") ' 'OVER(PARTITION BY "foo","bar" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_stddev_samp(self): + expr = ( + an.StdDevSamp(self.table_abc.fizz).over(self.table_abc.foo, self.table_abc.bar).orderby(self.table_abc.date) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'STDDEV_SAMP("fizz") ' 'OVER(PARTITION BY "foo","bar" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_variance(self): + expr = ( + an.Variance(self.table_abc.fizz).over(self.table_abc.foo, self.table_abc.bar).orderby(self.table_abc.date) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'VARIANCE("fizz") ' 'OVER(PARTITION BY "foo","bar" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_var_pop(self): + expr = an.VarPop(self.table_abc.fizz).over(self.table_abc.foo, self.table_abc.bar).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'VAR_POP("fizz") ' 'OVER(PARTITION BY "foo","bar" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_var_samp(self): + expr = an.VarSamp(self.table_abc.fizz).over(self.table_abc.foo, self.table_abc.bar).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'VAR_SAMP("fizz") ' 'OVER(PARTITION BY "foo","bar" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_table_prefixes_used_in_analytic_functions(self): + expr = an.Rank().over(self.table_abc.foo).orderby(self.table_efg.date) + + query = ( + Query.from_(self.table_abc) + .join(self.table_efg, how=JoinType.left) + .on(self.table_abc.foo == self.table_efg.bar) + .select("*", expr) + ) + + self.assertEqual( + 'SELECT *,RANK() OVER(PARTITION BY "abc"."foo" ORDER BY "efg"."date") ' + 'FROM "abc" LEFT JOIN "efg" ON "abc"."foo"="efg"."bar"', + str(query), + ) + + def test_sum_rows_unbounded_preceeding(self): + expr = an.Sum(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).rows(an.Preceding()) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'SUM("fizz") ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "ROWS UNBOUNDED PRECEDING" + ") " + 'FROM "abc"', + str(q), + ) + + def test_max_rows_x_preceeding(self): + expr = an.Max(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).rows(an.Preceding(5)) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'MAX("fizz") ' "OVER(" 'PARTITION BY "foo" ORDER BY "date" ' "ROWS 5 PRECEDING" ") " 'FROM "abc"', + str(q), + ) + + def test_min_rows_current_row(self): + expr = an.Min(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).rows(an.CURRENT_ROW) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'MIN("fizz") ' "OVER(" 'PARTITION BY "foo" ORDER BY "date" ' "ROWS CURRENT ROW" ") " 'FROM "abc"', + str(q), + ) + + def test_varpop_range_unbounded_preceeding(self): + expr = ( + an.VarPop(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).range(an.Preceding()) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'VAR_POP("fizz") ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "RANGE UNBOUNDED PRECEDING" + ") " + 'FROM "abc"', + str(q), + ) + + def test_max_range_x_preceeding(self): + expr = an.Max(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).range(an.Preceding(5)) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'MAX("fizz") ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "RANGE 5 PRECEDING" + ") " + 'FROM "abc"', + str(q), + ) + + def test_min_range_current_row(self): + expr = an.Min(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).range(an.CURRENT_ROW) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'MIN("fizz") ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "RANGE CURRENT ROW" + ") " + 'FROM "abc"', + str(q), + ) + + def test_variance_rows_between_unbounded_preceeding_unbounded_following(self): + expr = ( + an.Variance(self.table_abc.fizz) + .over(self.table_abc.foo) + .orderby(self.table_abc.date) + .rows(an.Preceding(), an.Following()) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'VARIANCE("fizz") ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING" + ") " + 'FROM "abc"', + str(q), + ) + + def test_first_value_range_between_x_preceeding_unbounded_following(self): + expr = ( + an.FirstValue(self.table_abc.fizz) + .over(self.table_abc.foo) + .orderby(self.table_abc.date) + .range(an.Preceding(3), an.Following()) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'FIRST_VALUE("fizz") ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "RANGE BETWEEN 3 PRECEDING AND UNBOUNDED FOLLOWING" + ") " + 'FROM "abc"', + str(q), + ) + + def test_varpop_rows_between_unbounded_preceeding_x_following(self): + expr = ( + an.VarPop(self.table_abc.fizz) + .over(self.table_abc.foo) + .orderby(self.table_abc.date) + .rows(an.Preceding(), an.Following(6)) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'VAR_POP("fizz") ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "ROWS BETWEEN UNBOUNDED PRECEDING AND 6 FOLLOWING" + ") " + 'FROM "abc"', + str(q), + ) + + def test_count_range_between_unbounded_preceeding_current_row(self): + expr = ( + an.Count(self.table_abc.fizz) + .over(self.table_abc.foo) + .orderby(self.table_abc.date) + .range(an.Preceding(), an.CURRENT_ROW) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'COUNT("fizz") ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW" + ") " + 'FROM "abc"', + str(q), + ) + + def test_last_value_rows_between_current_row_unbounded_following(self): + expr = ( + an.LastValue(self.table_abc.fizz) + .over(self.table_abc.foo) + .orderby(self.table_abc.date) + .rows(an.CURRENT_ROW, an.Following()) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'LAST_VALUE("fizz") ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING" + ") " + 'FROM "abc"', + str(q), + ) + + def test_last_value_rows_between_current_row_unbounded_following_ignore_nulls(self): + expr = ( + an.LastValue(self.table_abc.fizz) + .over(self.table_abc.foo) + .orderby(self.table_abc.date) + .ignore_nulls() + .rows(an.CURRENT_ROW, an.Following(8)) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'LAST_VALUE("fizz" IGNORE NULLS) ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "ROWS BETWEEN CURRENT ROW AND 8 FOLLOWING" + ") " + 'FROM "abc"', + str(q), + ) + + def test_empty_over(self): + query = Query.from_(self.table_abc).select(an.Sum(self.table_abc.fizz).over()) + + self.assertEqual("SELECT " 'SUM("fizz") OVER() ' 'FROM "abc"', str(query)) + + def test_rows_called_twice_raises_attribute_error(self): + with self.assertRaises(AttributeError): + an.Sum(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).rows(an.Preceding()).rows( + an.Preceding() + ) + + def test_range_called_twice_raises_attribute_error(self): + with self.assertRaises(AttributeError): + an.Sum(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).range( + an.Preceding() + ).range(an.Preceding()) + + def test_rows_then_range_raises_attribute_error(self): + with self.assertRaises(AttributeError): + an.Sum(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).rows( + an.Preceding() + ).range(an.Preceding()) + + def test_range_then_rows_raises_attribute_error(self): + with self.assertRaises(AttributeError): + an.Sum(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).range( + an.Preceding() + ).rows(an.Preceding()) + + def test_lag_generates_correct_sql(self): + with self.subTest('without partition by'): + q = Query.from_(self.table_abc).select( + Lag(self.table_abc.date, 1, '2000-01-01').orderby(self.table_abc.date) + ) + + self.assertEqual('SELECT LAG("date",1,\'2000-01-01\') OVER(ORDER BY "date") FROM "abc"', str(q)) + + with self.subTest('with partition by'): + q = Query.from_(self.table_abc).select( + Lag(self.table_abc.date, 1, '2000-01-01').over(self.table_abc.foo).orderby(self.table_abc.date) + ) + + self.assertEqual( + 'SELECT LAG("date",1,\'2000-01-01\') OVER(PARTITION BY "foo" ORDER BY "date") FROM "abc"', str(q) + ) + + def test_lead_generates_correct_sql(self): + with self.subTest('without partition by'): + q = Query.from_(self.table_abc).select( + Lead(self.table_abc.date, 1, '2000-01-01').orderby(self.table_abc.date) + ) + + self.assertEqual('SELECT LEAD("date",1,\'2000-01-01\') OVER(ORDER BY "date") FROM "abc"', str(q)) + + with self.subTest('with partition by'): + q = Query.from_(self.table_abc).select( + Lead(self.table_abc.date, 1, '2000-01-01').over(self.table_abc.foo).orderby(self.table_abc.date) + ) + + self.assertEqual( + 'SELECT LEAD("date",1,\'2000-01-01\') OVER(PARTITION BY "foo" ORDER BY "date") FROM "abc"', str(q) + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/test_create.py b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/test_create.py new file mode 100644 index 0000000000000000000000000000000000000000..325076544e3824b0d07f82f2378b88218b910dde --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/test_create.py @@ -0,0 +1,210 @@ +import unittest + +from pypika import Column, Columns, Query, Tables, Table +from pypika.terms import ValueWrapper, Index +from pypika.enums import ReferenceOption + + +class CreateTableTests(unittest.TestCase): + new_table, existing_table = Tables("abc", "efg") + foo, bar = Columns(("a", "INT"), ("b", "VARCHAR(100)")) + + def test_create_table_with_columns(self): + with self.subTest("with nullable"): + a = Column("a", "INT", True) + b = Column("b", "VARCHAR(100)", False) + q = Query.create_table(self.new_table).columns(a, b) + + self.assertEqual('CREATE TABLE "abc" ("a" INT NULL,"b" VARCHAR(100) NOT NULL)', str(q)) + + with self.subTest("with defaults"): + a = Column("a", "INT", default=ValueWrapper(42)) + b = Column("b", "VARCHAR(100)", default=ValueWrapper("foo")) + q = Query.create_table(self.new_table).columns(a, b) + + self.assertEqual('CREATE TABLE "abc" ("a" INT DEFAULT 42,"b" VARCHAR(100) DEFAULT \'foo\')', str(q)) + + with self.subTest("with unwrapped defaults"): + a = Column("a", "INT", default=42) + b = Column("b", "VARCHAR(100)", default="foo") + q = Query.create_table(self.new_table).columns(a, b) + + self.assertEqual('CREATE TABLE "abc" ("a" INT DEFAULT 42,"b" VARCHAR(100) DEFAULT \'foo\')', str(q)) + + with self.subTest("with period for"): + a = Column("id", "INT") + b = Column("valid_from", "DATETIME") + c = Column("valid_to", "DATETIME") + q = Query.create_table(self.new_table).columns(a, b, c).period_for('valid_period', b, c) + + self.assertEqual( + 'CREATE TABLE "abc" (' + '"id" INT,' + '"valid_from" DATETIME,' + '"valid_to" DATETIME,' + 'PERIOD FOR "valid_period" ("valid_from","valid_to"))', + str(q), + ) + + with self.subTest("without temporary keyword"): + q = Query.create_table(self.new_table).columns(self.foo, self.bar) + + self.assertEqual('CREATE TABLE "abc" ("a" INT,"b" VARCHAR(100))', str(q)) + + with self.subTest("with temporary keyword"): + q = Query.create_table(self.new_table).temporary().columns(self.foo, self.bar) + + self.assertEqual('CREATE TEMPORARY TABLE "abc" ("a" INT,"b" VARCHAR(100))', str(q)) + + with self.subTest("with primary key"): + q = Query.create_table(self.new_table).columns(self.foo, self.bar).primary_key(self.foo, self.bar) + + self.assertEqual('CREATE TABLE "abc" ("a" INT,"b" VARCHAR(100),PRIMARY KEY ("a","b"))', str(q)) + + with self.subTest("with simple foreign key"): + cref, dref = Columns(("c", "INT"), ("d", "VARCHAR(100)")) + q = ( + Query.create_table(self.new_table) + .columns(self.foo, self.bar) + .foreign_key([self.foo, self.bar], self.existing_table, [cref, dref]) + ) + + self.assertEqual( + 'CREATE TABLE "abc" (' + '"a" INT,' + '"b" VARCHAR(100),' + 'FOREIGN KEY ("a","b") REFERENCES "efg" ("c","d"))', + str(q), + ) + + with self.subTest("with foreign key reference options"): + cref, dref = Columns(("c", "INT"), ("d", "VARCHAR(100)")) + q = ( + Query.create_table(self.new_table) + .columns(self.foo, self.bar) + .foreign_key( + [self.foo, self.bar], + self.existing_table, + [cref, dref], + on_delete=ReferenceOption.cascade, + on_update=ReferenceOption.restrict, + ) + ) + + self.assertEqual( + 'CREATE TABLE "abc" (' + '"a" INT,' + '"b" VARCHAR(100),' + 'FOREIGN KEY ("a","b") REFERENCES "efg" ("c","d") ON DELETE CASCADE ON UPDATE RESTRICT)', + str(q), + ) + + with self.subTest("with unique keys"): + q = ( + Query.create_table(self.new_table) + .columns(self.foo, self.bar) + .unique(self.foo, self.bar) + .unique(self.foo) + ) + + self.assertEqual('CREATE TABLE "abc" ("a" INT,"b" VARCHAR(100),UNIQUE ("a","b"),UNIQUE ("a"))', str(q)) + + with self.subTest("with system versioning"): + q = Query.create_table(self.new_table).columns(self.foo, self.bar).with_system_versioning() + + self.assertEqual('CREATE TABLE "abc" ("a" INT,"b" VARCHAR(100)) WITH SYSTEM VERSIONING', str(q)) + + with self.subTest("with unlogged keyword"): + q = Query.create_table(self.new_table).unlogged().columns(self.foo, self.bar) + + self.assertEqual('CREATE UNLOGGED TABLE "abc" ("a" INT,"b" VARCHAR(100))', str(q)) + + with self.subTest("with if not exists keyword"): + q = Query.create_table(self.new_table).if_not_exists().columns(self.foo, self.bar) + + self.assertEqual('CREATE TABLE IF NOT EXISTS "abc" ("a" INT,"b" VARCHAR(100))', str(q)) + + def test_create_table_with_select(self): + select = Query.from_(self.existing_table).select(self.existing_table.foo, self.existing_table.bar) + + with self.subTest("without temporary keyword"): + q = Query.create_table(self.new_table).as_select(select) + + self.assertEqual('CREATE TABLE "abc" AS (SELECT "foo","bar" FROM "efg")', str(q)) + + with self.subTest("with temporary keyword"): + q = Query.create_table(self.new_table).temporary().as_select(select) + + self.assertEqual( + 'CREATE TEMPORARY TABLE "abc" AS (SELECT "foo","bar" FROM "efg")', + str(q), + ) + + def test_create_table_without_columns_or_select_empty(self): + q = Query.create_table(self.new_table) + + self.assertEqual("", str(q)) + + def test_create_table_with_select_and_columns_fails(self): + select = Query.from_(self.existing_table).select(self.existing_table.foo, self.existing_table.bar) + + with self.subTest("for columns before as_select"): + with self.assertRaises(AttributeError): + Query.create_table(self.new_table).columns(self.foo, self.bar).as_select(select) + + with self.subTest("for as_select before columns"): + with self.assertRaises(AttributeError): + Query.create_table(self.new_table).as_select(select).columns(self.foo, self.bar) + + with self.subTest("repeated foreign key"): + with self.assertRaises(AttributeError): + Query.create_table(self.new_table).foreign_key([self.foo], self.existing_table, [self.bar]).foreign_key( + [self.foo], self.existing_table, [self.bar] + ) + + def test_create_table_as_select_not_query_raises_error(self): + with self.assertRaises(TypeError): + Query.create_table(self.new_table).as_select("abc") + + +class CreateIndexTests(unittest.TestCase): + new_index = Index("abc") + new_table = Table("my_table") + columns = (new_table.a, new_table.b) + where = new_table.a > 1 + + def test_create_index_simple(self) -> None: + q = Query.create_index(self.new_index).on(self.new_table).columns(*self.columns) + self.assertEqual( + f'CREATE INDEX "{self.new_index.name}" ON "{self.new_table.get_table_name()}"({", ".join([c.name for c in self.columns])})', + q.get_sql(), + ) + + def test_create_index_where(self) -> None: + q = Query.create_index(self.new_index).on(self.new_table).columns(*self.columns).where(self.where) + self.assertEqual( + f'CREATE INDEX "{self.new_index.name}" ON "{self.new_table.get_table_name()}"({", ".join([c.name for c in self.columns])}) WHERE {self.where.get_sql()}', + q.get_sql(), + ) + + def test_create_index_unique(self) -> None: + q = Query.create_index(self.new_index).on(self.new_table).columns(*self.columns).unique() + self.assertEqual( + f'CREATE UNIQUE INDEX "{self.new_index.name}" ON "{self.new_table.get_table_name()}"({", ".join([c.name for c in self.columns])})', + q.get_sql(), + ) + + def test_create_index_if_not_exists(self) -> None: + q = Query.create_index(self.new_index).on(self.new_table).columns(*self.columns).if_not_exists() + self.assertEqual( + f'CREATE INDEX IF NOT EXISTS "{self.new_index.name}" ON "{self.new_table.get_table_name()}"({", ".join([c.name for c in self.columns])})', + q.get_sql(), + ) + + def test_create_index_without_columns_raises_error(self) -> None: + with self.assertRaises(AttributeError): + Query.create_index(self.new_index).on(self.new_table).get_sql() + + def test_create_index_without_table_raises_error(self) -> None: + with self.assertRaises(AttributeError): + Query.create_index(self.new_index).columns(*self.columns).get_sql() diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/test_criterions.py b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/test_criterions.py new file mode 100644 index 0000000000000000000000000000000000000000..fca2ceeeb18db88e34ebc38776f644fdcda67e93 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/test_criterions.py @@ -0,0 +1,873 @@ +import unittest +from datetime import ( + date, + datetime, +) + +from pypika import ( + Criterion, + EmptyCriterion, + Field, + Table, + functions as fn, +) +from pypika.queries import QueryBuilder +from pypika.terms import ExistsCriterion, Mod + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + + +class CriterionTests(unittest.TestCase): + t = Table("test", alias="crit") + + def test__criterion_with_alias(self): + c1 = (Field("foo") == Field("bar")).as_("criterion") + + self.assertEqual('"foo"="bar"', str(c1)) + self.assertEqual('"foo"="bar" "criterion"', c1.get_sql(with_alias=True, quote_char='"', alias_quote_char='"')) + + def test__criterion_eq_number(self): + c1 = Field("foo") == 1 + c2 = Field("foo", table=self.t).eq(0) + c3 = Field("foo", table=self.t) == -1 + + self.assertEqual('"foo"=1', str(c1)) + self.assertEqual('"crit"."foo"=0', str(c2)) + self.assertEqual('"crit"."foo"=-1', str(c3)) + + def test__criterion_eq_decimal(self): + c1 = Field("foo") == 1.0 + c2 = Field("foo", table=self.t).eq(0.5) + + self.assertEqual('"foo"=1.0', str(c1)) + self.assertEqual('"crit"."foo"=0.5', str(c2)) + + def test__criterion_eq_bool(self): + c1 = Field("foo") == True + c2 = Field("foo", table=self.t).eq(True) + c3 = Field("foo") == False + c4 = Field("foo", table=self.t).eq(False) + + self.assertEqual('"foo"=true', str(c1)) + self.assertEqual('"crit"."foo"=true', str(c2)) + self.assertEqual('"foo"=false', str(c3)) + self.assertEqual('"crit"."foo"=false', str(c4)) + + def test__criterion_eq_str(self): + c1 = Field("foo") == "abc" + c2 = Field("foo", table=self.t).eq("abc") + + self.assertEqual("\"foo\"='abc'", str(c1)) + self.assertEqual('"crit"."foo"=\'abc\'', str(c2)) + + def test__criterion_eq_date(self): + c1 = Field("foo") == date(2000, 1, 1) + c2 = Field("foo", table=self.t).eq(date(2000, 1, 1)) + + self.assertEqual("\"foo\"='2000-01-01'", str(c1)) + self.assertEqual('"crit"."foo"=\'2000-01-01\'', str(c2)) + + def test__criterion_eq_datetime(self): + c1 = Field("foo") == datetime(2000, 1, 1, 12, 30, 55) + c2 = Field("foo", table=self.t).eq(datetime(2000, 1, 1, 12, 30, 55)) + + self.assertEqual("\"foo\"='2000-01-01T12:30:55'", str(c1)) + self.assertEqual('"crit"."foo"=\'2000-01-01T12:30:55\'', str(c2)) + + def test__criterion_eq_right(self): + c1 = 1 == Field("foo") + c2 = -1 == Field("foo", table=self.t) + + self.assertEqual('"foo"=1', str(c1)) + self.assertEqual('"crit"."foo"=-1', str(c2)) + + def test__criterion_is_null(self): + c1 = Field("foo").isnull() + c2 = Field("foo", table=self.t).isnull() + + self.assertEqual('"foo" IS NULL', str(c1)) + self.assertEqual('"crit"."foo" IS NULL', str(c2)) + + def test__criterion_is_null_with_alias(self): + c1 = Field("foo").isnull().as_('alias') + c2 = Field("foo", table=self.t).isnull().as_('alias') + + self.assertEqual('"foo" IS NULL "alias"', str(c1)) + self.assertEqual('"crit"."foo" IS NULL "alias"', str(c2)) + + def test__criterion_ne_number(self): + c1 = Field("foo") != 1 + c2 = Field("foo", table=self.t).ne(0) + c3 = Field("foo") != -1 + + self.assertEqual('"foo"<>1', str(c1)) + self.assertEqual('"crit"."foo"<>0', str(c2)) + self.assertEqual('"foo"<>-1', str(c3)) + + def test__criterion_ne_str(self): + c1 = Field("foo") != "abc" + c2 = Field("foo", table=self.t).ne("abc") + + self.assertEqual("\"foo\"<>'abc'", str(c1)) + self.assertEqual('"crit"."foo"<>\'abc\'', str(c2)) + + def test__criterion_ne_date(self): + c1 = Field("foo") != date(2000, 1, 1) + c2 = Field("foo", table=self.t).ne(date(2000, 1, 1)) + + self.assertEqual("\"foo\"<>'2000-01-01'", str(c1)) + self.assertEqual('"crit"."foo"<>\'2000-01-01\'', str(c2)) + + def test__criterion_ne_datetime(self): + c1 = Field("foo") != datetime(2000, 1, 1, 12, 30, 55) + c2 = Field("foo", table=self.t).ne(datetime(2000, 1, 1, 12, 30, 55)) + + self.assertEqual("\"foo\"<>'2000-01-01T12:30:55'", str(c1)) + self.assertEqual('"crit"."foo"<>\'2000-01-01T12:30:55\'', str(c2)) + + def test__criterion_ne_right(self): + c1 = 1 != Field("foo") + c2 = -1 != Field("foo", table=self.t) + + self.assertEqual('"foo"<>1', str(c1)) + self.assertEqual('"crit"."foo"<>-1', str(c2)) + + def test__criterion_lt_number(self): + c1 = Field("foo") < 1 + c2 = Field("foo", table=self.t).lt(0) + c3 = Field("foo") < -1 + + self.assertEqual('"foo"<1', str(c1)) + self.assertEqual('"crit"."foo"<0', str(c2)) + self.assertEqual('"foo"<-1', str(c3)) + + def test__criterion_lt_date(self): + c1 = Field("foo") < date(2000, 1, 1) + c2 = Field("foo", table=self.t).lt(date(2000, 1, 1)) + + self.assertEqual("\"foo\"<'2000-01-01'", str(c1)) + self.assertEqual('"crit"."foo"<\'2000-01-01\'', str(c2)) + + def test__criterion_lt_datetime(self): + c1 = Field("foo") < datetime(2000, 1, 1, 12, 30, 55) + c2 = Field("foo", table=self.t).lt(datetime(2000, 1, 1, 12, 30, 55)) + + self.assertEqual("\"foo\"<'2000-01-01T12:30:55'", str(c1)) + self.assertEqual('"crit"."foo"<\'2000-01-01T12:30:55\'', str(c2)) + + def test__criterion_lt_right(self): + c1 = 1 > Field("foo") + c2 = -1 > Field("foo", table=self.t) + + self.assertEqual('"foo"<1', str(c1)) + self.assertEqual('"crit"."foo"<-1', str(c2)) + + def test__criterion_gt_number(self): + c1 = Field("foo") > 1 + c2 = Field("foo", table=self.t).gt(0) + c3 = Field("foo") > -1 + + self.assertEqual('"foo">1', str(c1)) + self.assertEqual('"crit"."foo">0', str(c2)) + self.assertEqual('"foo">-1', str(c3)) + + def test__criterion_gt_date(self): + c1 = Field("foo") > date(2000, 1, 1) + c2 = Field("foo", table=self.t).gt(date(2000, 1, 1)) + + self.assertEqual("\"foo\">'2000-01-01'", str(c1)) + self.assertEqual('"crit"."foo">\'2000-01-01\'', str(c2)) + + def test__criterion_gt_datetime(self): + c1 = Field("foo") > datetime(2000, 1, 1, 12, 30, 55) + c2 = Field("foo", table=self.t).gt(datetime(2000, 1, 1, 12, 30, 55)) + + self.assertEqual("\"foo\">'2000-01-01T12:30:55'", str(c1)) + self.assertEqual('"crit"."foo">\'2000-01-01T12:30:55\'', str(c2)) + + def test__criterion_gt_right(self): + c1 = 1 < Field("foo") + c2 = -1 < Field("foo", table=self.t) + + self.assertEqual('"foo">1', str(c1)) + self.assertEqual('"crit"."foo">-1', str(c2)) + + def test__criterion_lte_number(self): + c1 = Field("foo") <= 1 + c2 = Field("foo", table=self.t).lte(0) + c3 = Field("foo") <= -1 + + self.assertEqual('"foo"<=1', str(c1)) + self.assertEqual('"crit"."foo"<=0', str(c2)) + self.assertEqual('"foo"<=-1', str(c3)) + + def test__criterion_lte_date(self): + c1 = Field("foo") <= date(2000, 1, 1) + c2 = Field("foo", table=self.t).lte(date(2000, 1, 1)) + + self.assertEqual("\"foo\"<='2000-01-01'", str(c1)) + self.assertEqual('"crit"."foo"<=\'2000-01-01\'', str(c2)) + + def test__criterion_lte_datetime(self): + c1 = Field("foo") <= datetime(2000, 1, 1, 12, 30, 55) + c2 = Field("foo", table=self.t).lte(datetime(2000, 1, 1, 12, 30, 55)) + + self.assertEqual("\"foo\"<='2000-01-01T12:30:55'", str(c1)) + self.assertEqual('"crit"."foo"<=\'2000-01-01T12:30:55\'', str(c2)) + + def test__criterion_lte_right(self): + c1 = 1 >= Field("foo") + c2 = -1 >= Field("foo", table=self.t) + + self.assertEqual('"foo"<=1', str(c1)) + self.assertEqual('"crit"."foo"<=-1', str(c2)) + + def test__criterion_gte_number(self): + c1 = Field("foo") >= 1 + c2 = Field("foo", table=self.t).gte(0) + c3 = Field("foo") >= -1 + + self.assertEqual('"foo">=1', str(c1)) + self.assertEqual('"crit"."foo">=0', str(c2)) + self.assertEqual('"foo">=-1', str(c3)) + + def test__criterion_gte_date(self): + c1 = Field("foo") >= date(2000, 1, 1) + c2 = Field("foo", table=self.t).gte(date(2000, 1, 1)) + + self.assertEqual("\"foo\">='2000-01-01'", str(c1)) + self.assertEqual('"crit"."foo">=\'2000-01-01\'', str(c2)) + + def test__criterion_gte_datetime(self): + c1 = Field("foo") >= datetime(2000, 1, 1, 12, 30, 55) + c2 = Field("foo", table=self.t).gte(datetime(2000, 1, 1, 12, 30, 55)) + + self.assertEqual("\"foo\">='2000-01-01T12:30:55'", str(c1)) + self.assertEqual('"crit"."foo">=\'2000-01-01T12:30:55\'', str(c2)) + + def test__criterion_gte_right(self): + c1 = 1 <= Field("foo") + c2 = -1 <= Field("foo", table=self.t) + + self.assertEqual('"foo">=1', str(c1)) + self.assertEqual('"crit"."foo">=-1', str(c2)) + + def test__criterion_bitwise_and(self): + c1 = Field("foo").bitwiseand(2) + c2 = Field("foo", table=self.t).bitwiseand(10) == 2 + + self.assertEqual('("foo" & 2)', str(c1)) + self.assertEqual('("crit"."foo" & 10)=2', str(c2)) + + def test__criterion_bitwise_and_with_alias(self): + c1 = Field("foo").bitwiseand(2).as_('alias') + + self.assertEqual('("foo" & 2) "alias"', str(c1)) + + def test__bitwise_and_in_where_clause(self): + q = QueryBuilder().from_('items').select('abc').where(Field("foo").bitwiseand(1) == 1) + + self.assertEqual('SELECT "abc" FROM "items" WHERE ("foo" & 1)=1', str(q)) + + +class NotTests(unittest.TestCase): + table_abc, table_efg = Table("abc", alias="cx0"), Table("efg", alias="cx1") + + def test_negate(self): + c1 = Field("foo") >= 1 + c2 = c1.negate() + + self.assertEqual('"foo">=1', str(c1)) + self.assertEqual('NOT "foo">=1', str(c2)) + + def test_variable_access(self): + c1 = Field("foo").negate() + + self.assertEqual(c1.is_aggregate, False) + + def test_chained_function(self): + field1 = Field("foo").negate() + field2 = field1.eq("bar") + + self.assertEqual('NOT "foo"', str(field1)) + self.assertEqual("NOT \"foo\"='bar'", str(field2)) + self.assertIsNot(field1, field2) + + def test_not_null(self): + c1 = Field("foo").notnull() + c2 = Field("foo", table=self.table_abc).notnull() + + self.assertEqual('NOT "foo" IS NULL', str(c1)) + self.assertEqual('NOT "cx0"."foo" IS NULL', str(c2)) + + def test_is_not_null(self): + c1 = Field("foo").isnotnull() + c2 = Field("foo", table=self.table_abc).isnotnull() + + self.assertEqual('"foo" IS NOT NULL', str(c1)) + self.assertEqual('"cx0"."foo" IS NOT NULL', str(c2)) + + def test_not_null_with_alias(self): + c1 = Field("foo").notnull().as_("something") + c2 = Field("foo", table=self.table_abc).notnull().as_("something") + + self.assertEqual('NOT "foo" IS NULL "something"', str(c1)) + self.assertEqual('NOT "cx0"."foo" IS NULL "something"', str(c2)) + + def test_notnullcriterion_replace_table(self): + f = self.table_abc.foo.notnull().replace_table(self.table_abc, self.table_efg) + + self.assertEqual('NOT "cx1"."foo" IS NULL', str(f)) + + def test_not_with_or_criterion(self): + self.assertEqual('NOT ("foo" OR "bar")', str(~(Field("foo") | Field("bar")))) + + def test_not_with_and_criterion(self): + self.assertEqual('NOT ("foo" AND "bar")', str(~(Field("foo") & Field("bar")))) + + def test_not_with_complex_criterion(self): + self.assertEqual( + 'NOT ("foo" AND "bar" AND "fizz" AND "buzz")', + str(~(Field("foo") & Field("bar") & Field("fizz") & Field("buzz"))), + ) + + +class BetweenTests(unittest.TestCase): + t = Table("abc", alias="btw") + + def test__between_number(self): + c1 = Field("foo").between(0, 1) + c2 = Field("foo", table=self.t).between(0, 1) + c3 = Field("foo")[0:1] + + self.assertEqual('"foo" BETWEEN 0 AND 1', str(c1)) + self.assertEqual('"btw"."foo" BETWEEN 0 AND 1', str(c2)) + self.assertEqual('"foo" BETWEEN 0 AND 1', str(c3)) + + def test__between_with_alias(self): + c1 = Field("foo").between(0, 1).as_('alias') + c2 = Field("foo", table=self.t).between(0, 1).as_('alias') + c3 = Field("foo")[0:1].as_('alias') + + self.assertEqual('"foo" BETWEEN 0 AND 1 "alias"', str(c1)) + self.assertEqual('"btw"."foo" BETWEEN 0 AND 1 "alias"', str(c2)) + self.assertEqual('"foo" BETWEEN 0 AND 1 "alias"', str(c3)) + + def test__between_date(self): + c1 = Field("foo").between(date(2000, 1, 1), date(2000, 12, 31)) + c2 = Field("foo", table=self.t).between(date(2000, 1, 1), date(2000, 12, 31)) + c3 = Field("foo")[date(2000, 1, 1) : date(2000, 12, 31)] + + self.assertEqual("\"foo\" BETWEEN '2000-01-01' AND '2000-12-31'", str(c1)) + self.assertEqual("\"btw\".\"foo\" BETWEEN '2000-01-01' AND '2000-12-31'", str(c2)) + self.assertEqual("\"foo\" BETWEEN '2000-01-01' AND '2000-12-31'", str(c3)) + + def test__between_datetime(self): + c1 = Field("foo").between(datetime(2000, 1, 1, 0, 0, 0), datetime(2000, 12, 31, 23, 59, 59)) + c2 = Field("foo", table=self.t).between(datetime(2000, 1, 1, 0, 0, 0), datetime(2000, 12, 31, 23, 59, 59)) + c3 = Field("foo")[datetime(2000, 1, 1, 0, 0, 0) : datetime(2000, 12, 31, 23, 59, 59)] + + self.assertEqual("\"foo\" BETWEEN '2000-01-01T00:00:00' AND '2000-12-31T23:59:59'", str(c1)) + self.assertEqual( + "\"btw\".\"foo\" BETWEEN '2000-01-01T00:00:00' AND '2000-12-31T23:59:59'", + str(c2), + ) + self.assertEqual("\"foo\" BETWEEN '2000-01-01T00:00:00' AND '2000-12-31T23:59:59'", str(c3)) + + def test__function_between(self): + c1 = fn.Coalesce(Field("foo"), 0)[0:1] + c2 = fn.Coalesce(Field("foo", table=self.t), 0)[0:1] + + self.assertEqual('COALESCE("foo",0) BETWEEN 0 AND 1', str(c1)) + self.assertEqual('COALESCE("btw"."foo",0) BETWEEN 0 AND 1', str(c2)) + + def test_get_item_only_works_with_slice(self): + with self.assertRaises(TypeError): + Field("foo")[0] + + with self.assertRaises(TypeError): + Field("foo")[date(2000, 1, 1)] + + with self.assertRaises(TypeError): + Field("foo")[datetime(2000, 1, 1, 0, 0, 0)] + + +class IsInTests(unittest.TestCase): + t = Table("abc", alias="isin") + + def test__in_number(self): + c1 = Field("foo").isin([0, 1]) + c2 = Field("foo", table=self.t).isin([0, 1]) + + self.assertEqual('"foo" IN (0,1)', str(c1)) + self.assertEqual('"isin"."foo" IN (0,1)', str(c2)) + + def test__in_number_with_alias(self): + c1 = Field("foo").isin([0, 1]).as_('alias') + c2 = Field("foo", table=self.t).isin([0, 1]).as_('alias') + + self.assertEqual('"foo" IN (0,1) "alias"', str(c1)) + self.assertEqual('"isin"."foo" IN (0,1) "alias"', str(c2)) + + def test__in_character(self): + c1 = Field("foo").isin(["a", "b"]) + c2 = Field("foo", table=self.t).isin(["a", "b"]) + + self.assertEqual("\"foo\" IN ('a','b')", str(c1)) + self.assertEqual("\"isin\".\"foo\" IN ('a','b')", str(c2)) + + def test__in_date(self): + c1 = Field("foo").isin([date(2000, 1, 1), date(2000, 12, 31)]) + c2 = Field("foo", table=self.t).isin([date(2000, 1, 1), date(2000, 12, 31)]) + + self.assertEqual("\"foo\" IN ('2000-01-01','2000-12-31')", str(c1)) + self.assertEqual("\"isin\".\"foo\" IN ('2000-01-01','2000-12-31')", str(c2)) + + def test__in_datetime(self): + c1 = Field("foo").isin([datetime(2000, 1, 1, 0, 0, 0), datetime(2000, 12, 31, 23, 59, 59)]) + c2 = Field("foo", table=self.t).isin([datetime(2000, 1, 1, 0, 0, 0), datetime(2000, 12, 31, 23, 59, 59)]) + + self.assertEqual("\"foo\" IN ('2000-01-01T00:00:00','2000-12-31T23:59:59')", str(c1)) + self.assertEqual("\"isin\".\"foo\" IN ('2000-01-01T00:00:00','2000-12-31T23:59:59')", str(c2)) + + def test__function_isin(self): + c1 = fn.Coalesce(Field("foo"), 0).isin([0, 1]) + c2 = fn.Coalesce(Field("foo", table=self.t), 0).isin([0, 1]) + + self.assertEqual('COALESCE("foo",0) IN (0,1)', str(c1)) + self.assertEqual('COALESCE("isin"."foo",0) IN (0,1)', str(c2)) + + for t in (list, tuple, set, frozenset): + c_type = fn.Coalesce(Field("foo"), 0).isin(t([0, 1])) + self.assertEqual('COALESCE("foo",0) IN (0,1)', str(c_type)) + + self.assertRaises(AttributeError, lambda: str(fn.Coalesce(Field("foo"), 0).isin('SHOULD_FAIL'))) + + def test__in_unicode(self): + c1 = Field("foo").isin([u"a", u"b"]) + c2 = Field("foo", table=self.t).isin([u"a", u"b"]) + + self.assertEqual("\"foo\" IN ('a','b')", str(c1)) + self.assertEqual("\"isin\".\"foo\" IN ('a','b')", str(c2)) + + +class ArithmeticExpressionTests(unittest.TestCase): + def test__lshift(self): + c1 = Field("foo").lshift("1") + c2 = Field("foo").lshift("2") + + self.assertEqual("\"foo\"<<'1'", str(c1)) + self.assertEqual("\"foo\"<<'2'", str(c2)) + + def test__rshift(self): + c1 = Field("foo").rshift("1") + c2 = Field("foo").rshift("2") + + self.assertEqual("\"foo\">>'1'", str(c1)) + self.assertEqual("\"foo\">>'2'", str(c2)) + + +class NotInTests(unittest.TestCase): + t = Table("abc", alias="notin") + + def test__notin_number(self): + c1 = Field("foo").notin([0, 1]) + c2 = Field("foo", table=self.t).notin([0, 1]) + + self.assertEqual('"foo" NOT IN (0,1)', str(c1)) + self.assertEqual('"notin"."foo" NOT IN (0,1)', str(c2)) + + def test__notin_number_with_alias(self): + c1 = Field("foo").notin([0, 1]).as_('alias') + c2 = Field("foo", table=self.t).notin([0, 1]).as_('alias') + + self.assertEqual('"foo" NOT IN (0,1) "alias"', str(c1)) + self.assertEqual('"notin"."foo" NOT IN (0,1) "alias"', str(c2)) + + def test__notin_character(self): + c1 = Field("foo").notin(["a", "b"]) + c2 = Field("foo", table=self.t).notin(["a", "b"]) + + self.assertEqual("\"foo\" NOT IN ('a','b')", str(c1)) + self.assertEqual("\"notin\".\"foo\" NOT IN ('a','b')", str(c2)) + + def test__notin_date(self): + c1 = Field("foo").notin([date(2000, 1, 1), date(2000, 12, 31)]) + c2 = Field("foo", table=self.t).notin([date(2000, 1, 1), date(2000, 12, 31)]) + + self.assertEqual("\"foo\" NOT IN ('2000-01-01','2000-12-31')", str(c1)) + self.assertEqual("\"notin\".\"foo\" NOT IN ('2000-01-01','2000-12-31')", str(c2)) + + def test__notin_datetime(self): + c1 = Field("foo").notin([datetime(2000, 1, 1, 0, 0, 0), datetime(2000, 12, 31, 23, 59, 59)]) + c2 = Field("foo", table=self.t).notin([datetime(2000, 1, 1, 0, 0, 0), datetime(2000, 12, 31, 23, 59, 59)]) + + self.assertEqual("\"foo\" NOT IN ('2000-01-01T00:00:00','2000-12-31T23:59:59')", str(c1)) + self.assertEqual( + "\"notin\".\"foo\" NOT IN ('2000-01-01T00:00:00','2000-12-31T23:59:59')", + str(c2), + ) + + def test__function_notin(self): + c1 = fn.Coalesce(Field("foo"), 0).notin([0, 1]) + c2 = fn.Coalesce(Field("foo", table=self.t), 0).notin([0, 1]) + + self.assertEqual('COALESCE("foo",0) NOT IN (0,1)', str(c1)) + self.assertEqual('COALESCE("notin"."foo",0) NOT IN (0,1)', str(c2)) + + +class LikeTests(unittest.TestCase): + t = Table("abc", alias="like") + + def test_like_starts_with(self): + c1 = Field("foo").like("ab%") + c2 = Field("foo", table=self.t).like("ab%") + + self.assertEqual("\"foo\" LIKE 'ab%'", str(c1)) + self.assertEqual('"like"."foo" LIKE \'ab%\'', str(c2)) + + def test_like_contains(self): + c1 = Field("foo").like("%ab%") + c2 = Field("foo", table=self.t).like("%ab%") + + self.assertEqual("\"foo\" LIKE '%ab%'", str(c1)) + self.assertEqual('"like"."foo" LIKE \'%ab%\'', str(c2)) + + def test_like_ends_with(self): + c1 = Field("foo").like("%ab") + c2 = Field("foo", table=self.t).like("%ab") + + self.assertEqual("\"foo\" LIKE '%ab'", str(c1)) + self.assertEqual('"like"."foo" LIKE \'%ab\'', str(c2)) + + def test_like_n_chars_long(self): + c1 = Field("foo").like("___") + c2 = Field("foo", table=self.t).like("___") + + self.assertEqual("\"foo\" LIKE '___'", str(c1)) + self.assertEqual('"like"."foo" LIKE \'___\'', str(c2)) + + def test_like_single_chars_and_various_chars(self): + c1 = Field("foo").like("a_b%c") + c2 = Field("foo", table=self.t).like("a_b%c") + + self.assertEqual("\"foo\" LIKE 'a_b%c'", str(c1)) + self.assertEqual('"like"."foo" LIKE \'a_b%c\'', str(c2)) + + def test_not_like_single_chars_and_various_chars(self): + c1 = Field("foo").not_like("a_b%c") + c2 = Field("foo", table=self.t).not_like("a_b%c") + + self.assertEqual("\"foo\" NOT LIKE 'a_b%c'", str(c1)) + self.assertEqual('"like"."foo" NOT LIKE \'a_b%c\'', str(c2)) + + def test_ilike_starts_with(self): + c1 = Field("foo").ilike("ab%") + c2 = Field("foo", table=self.t).ilike("ab%") + + self.assertEqual("\"foo\" ILIKE 'ab%'", str(c1)) + self.assertEqual('"like"."foo" ILIKE \'ab%\'', str(c2)) + + def test_ilike_contains(self): + c1 = Field("foo").ilike("%ab%") + c2 = Field("foo", table=self.t).ilike("%ab%") + + self.assertEqual("\"foo\" ILIKE '%ab%'", str(c1)) + self.assertEqual('"like"."foo" ILIKE \'%ab%\'', str(c2)) + + def test_ilike_ends_with(self): + c1 = Field("foo").ilike("%ab") + c2 = Field("foo", table=self.t).ilike("%ab") + + self.assertEqual("\"foo\" ILIKE '%ab'", str(c1)) + self.assertEqual('"like"."foo" ILIKE \'%ab\'', str(c2)) + + def test_ilike_n_chars_long(self): + c1 = Field("foo").ilike("___") + c2 = Field("foo", table=self.t).ilike("___") + + self.assertEqual("\"foo\" ILIKE '___'", str(c1)) + self.assertEqual('"like"."foo" ILIKE \'___\'', str(c2)) + + def test_ilike_single_chars_and_various_chars(self): + c1 = Field("foo").ilike("a_b%c") + c2 = Field("foo", table=self.t).ilike("a_b%c") + + self.assertEqual("\"foo\" ILIKE 'a_b%c'", str(c1)) + self.assertEqual('"like"."foo" ILIKE \'a_b%c\'', str(c2)) + + def test_not_ilike_single_chars_and_various_chars(self): + c1 = Field("foo").not_ilike("a_b%c") + c2 = Field("foo", table=self.t).not_ilike("a_b%c") + + self.assertEqual("\"foo\" NOT ILIKE 'a_b%c'", str(c1)) + self.assertEqual('"like"."foo" NOT ILIKE \'a_b%c\'', str(c2)) + + def test_rlike_escape_chars(self): + c1 = Field("foo").rlike("\\\\d+$") + c2 = Field("foo", table=self.t).rlike("\\\\d+$") + + self.assertEqual("\"foo\" RLIKE '\\\\d+$'", str(c1)) + self.assertEqual('"like"."foo" RLIKE \'\\\\d+$\'', str(c2)) + + def test_glob_single_chars_and_various_chars(self): + c1 = Field("foo").glob("a_b*") + c2 = Field("foo", table=self.t).glob("a_b*") + + self.assertEqual("\"foo\" GLOB 'a_b*'", str(c1)) + self.assertEqual('"like"."foo" GLOB \'a_b*\'', str(c2)) + + +class ExistsCriterionTests(unittest.TestCase): + t2 = Table("abc", alias="t2") + q2 = QueryBuilder().from_(t2).select(t2.field2) + + def test_exists(self): + t1 = Table("def", alias="t1") + q1 = QueryBuilder().from_(t1).where(ExistsCriterion(self.q2)).select(t1.field1) + + self.assertEqual( + 'SELECT "t1"."field1" FROM "def" "t1" WHERE EXISTS (SELECT "t2"."field2" FROM "abc" "t2")', str(q1) + ) + + def test_not_exists(self): + t1 = Table("def", alias="t1") + q1 = QueryBuilder().from_(t1).where(ExistsCriterion(self.q2).negate()).select(t1.field1) + + self.assertEqual( + 'SELECT "t1"."field1" FROM "def" "t1" WHERE NOT EXISTS (SELECT "t2"."field2" FROM "abc" "t2")', str(q1) + ) + + +class ComplexCriterionTests(unittest.TestCase): + table_abc, table_efg = Table("abc", alias="cx0"), Table("efg", alias="cx1") + + def test_and(self): + c1 = (Field("foo") == 1) & (Field("bar") == 2) + c2 = (Field("foo", table=self.table_abc) == 1) & (Field("bar", table=self.table_efg) == 2) + + self.assertEqual('"foo"=1 AND "bar"=2', str(c1)) + self.assertEqual('"cx0"."foo"=1 AND "cx1"."bar"=2', str(c2)) + + def test_or(self): + c1 = (Field("foo") == 1) | (Field("bar") == 2) + c2 = (Field("foo", table=self.table_abc) == 1) | (Field("bar", table=self.table_efg) == 2) + + self.assertEqual('"foo"=1 OR "bar"=2', str(c1)) + self.assertEqual('"cx0"."foo"=1 OR "cx1"."bar"=2', str(c2)) + + def test_xor(self): + c1 = (Field("foo") == 1) ^ (Field("bar") == 2) + c2 = (Field("foo", table=self.table_abc) == 1) ^ (Field("bar", table=self.table_efg) == 2) + + self.assertEqual('"foo"=1 XOR "bar"=2', str(c1)) + self.assertEqual('"cx0"."foo"=1 XOR "cx1"."bar"=2', str(c2)) + + def test_function_and(self): + c1 = fn.IsNull(Field("foo")) & (Field("bar") == 2) + + self.assertEqual('ISNULL("foo") AND "bar"=2', str(c1)) + + def test_function_or(self): + c1 = fn.IsNull(Field("foo")) | (Field("bar") == 2) + + self.assertEqual('ISNULL("foo") OR "bar"=2', str(c1)) + + def test_function_xor(self): + c1 = fn.IsNull(Field("foo")) ^ (Field("bar") == 2) + + self.assertEqual('ISNULL("foo") XOR "bar"=2', str(c1)) + + def test__nested__and(self): + c = (Field("foo") == 1) & (Field("bar") == 2) & (Field("buz") == 3) + + self.assertEqual('"foo"=1 AND "bar"=2 AND "buz"=3', str(c)) + + def test__nested__or(self): + c = (Field("foo") == 1) | (Field("bar") == 2) | (Field("buz") == 3) + + self.assertEqual('"foo"=1 OR "bar"=2 OR "buz"=3', str(c)) + + def test__nested__mixed(self): + c = ((Field("foo") == 1) & (Field("bar") == 2)) | (Field("buz") == 3) + + self.assertEqual('("foo"=1 AND "bar"=2) OR "buz"=3', str(c)) + + def test__between_and_isin(self): + c = Field("foo").isin([1, 2, 3]) & Field("bar").between(0, 1) + + self.assertEqual('"foo" IN (1,2,3) AND "bar" BETWEEN 0 AND 1', str(c)) + + def test__between_and_field(self): + c1 = Field("foo").between(0, 1) + c2 = Field("bool_field") + + self.assertEqual('"foo" BETWEEN 0 AND 1 AND "bool_field"', str(c1 & c2)) + self.assertEqual('"bool_field" AND "foo" BETWEEN 0 AND 1', str(c2 & c1)) + + +class FieldsAsCriterionTests(unittest.TestCase): + def test__field_and_field(self): + c1 = Field("a") + c2 = Field("b") + + self.assertEqual('"a" AND "b"', str(c1 & c2)) + + def test__field_or_field(self): + c1 = Field("a") + c2 = Field("b") + + self.assertEqual('"a" OR "b"', str(c1 | c2)) + + def test__field_xor_field(self): + c1 = Field("a") + c2 = Field("b") + + self.assertEqual('"a" XOR "b"', str(c1 ^ c2)) + + +class CriterionOperationsTests(unittest.TestCase): + table_abc, table_efg = Table("abc", alias="cx0"), Table("efg", alias="cx1") + + def test_field_replace_table(self): + f = self.table_abc.foo.replace_table(self.table_abc, self.table_efg) + + self.assertEqual('"cx1"."foo"', str(f)) + + def test_arithmeticfunction_replace_table(self): + f = (self.table_abc.foo + self.table_abc.bar).replace_table(self.table_abc, self.table_efg) + + self.assertEqual('"cx1"."foo"+"cx1"."bar"', str(f)) + + def test_criterion_replace_table(self): + f = (self.table_abc.foo < self.table_abc.bar).replace_table(self.table_abc, self.table_efg) + + self.assertEqual('"cx1"."foo"<"cx1"."bar"', str(f)) + + def test_complexcriterion_replace_table(self): + f = (self.table_abc.foo < self.table_abc.bar) & (self.table_abc.fiz > self.table_abc.buz) + f = f.replace_table(self.table_abc, self.table_efg) + + self.assertEqual('"cx1"."foo"<"cx1"."bar" AND "cx1"."fiz">"cx1"."buz"', str(f)) + + def test_function_with_only_fields_replace_table(self): + f = fn.Sum(self.table_abc.foo).replace_table(self.table_abc, self.table_efg) + + self.assertEqual('SUM("cx1"."foo")', str(f)) + + def test_function_with_values_and_fields_replace_table(self): + f = Mod(self.table_abc.foo, 2).replace_table(self.table_abc, self.table_efg) + + self.assertEqual('MOD("cx1"."foo",2)', str(f)) + + def test_betweencriterion_replace_table(self): + f = self.table_abc.foo[0:1].replace_table(self.table_abc, self.table_efg) + + self.assertEqual('"cx1"."foo" BETWEEN 0 AND 1', str(f)) + + def test_nullcriterion_replace_table(self): + f = self.table_abc.foo.isnull().replace_table(self.table_abc, self.table_efg) + + self.assertEqual('"cx1"."foo" IS NULL', str(f)) + + +class AnyTests(unittest.TestCase): + def test_zero_args_returns_empty_criterion(self): + crit = Criterion.any() + self.assertIsInstance(crit, EmptyCriterion) + + def test_single_arg_returns_self(self): + f = Field("a") + crit = Criterion.any([f]) + self.assertEqual(str(f), str(crit)) + + def test_multiple_args_returned_in_chain_of_ors(self): + crit = Criterion.any([Field("a"), Field("b"), Field("c"), Field("d")]) + self.assertEqual(str(crit), '"a" OR "b" OR "c" OR "d"') + + def test_with_generator(self): + crit = Criterion.any(Field(letter) for letter in "abcd") + self.assertEqual(str(crit), '"a" OR "b" OR "c" OR "d"') + + +class EmptyCriterionTests(unittest.TestCase): + def test_fields_(self): + empty_criterion = EmptyCriterion() + + self.assertEqual(len(empty_criterion.fields_()), 0) + + def test_empty_criterion_on_the_left(self): + t = Table("test1") + q = EmptyCriterion() & t.f1 == "v1" + + self.assertEqual( + '"test1"."f1"=\'v1\'', + q.get_sql(with_namespace=True), + ) + + def test_empty_criterion_on_the_right(self): + t = Table("test1") + q = (t.f1 == "v1") & EmptyCriterion() + + self.assertEqual( + '"test1"."f1"=\'v1\'', + q.get_sql(with_namespace=True), + ) + + def test_invertion_of_the_empty_criterion(self): + t = Table("test1") + q = (t.f1 == "v1") & ~EmptyCriterion() + + self.assertEqual( + '"test1"."f1"=\'v1\'', + q.get_sql(with_namespace=True), + ) + + def test_different_operations_with_empty_criterion(self): + t = Table("test1") + q1 = (t.f1 == "v1") & EmptyCriterion() + q2 = (t.f1 == "v1") | EmptyCriterion() + q3 = (t.f1 == "v1") ^ EmptyCriterion() + + expected_sql = '"test1"."f1"=\'v1\'' + self.assertEqual( + expected_sql, + q1.get_sql(with_namespace=True), + ) + self.assertEqual( + expected_sql, + q2.get_sql(with_namespace=True), + ) + self.assertEqual( + expected_sql, + q3.get_sql(with_namespace=True), + ) + + def test_more_than_one_empty_criterions(self): + t = Table("test1") + q = EmptyCriterion() & ~(EmptyCriterion() | EmptyCriterion()) & (t.f1 == "v1") & ~EmptyCriterion() + + self.assertEqual( + '"test1"."f1"=\'v1\'', + q.get_sql(with_namespace=True), + ) + + +class AllTests(unittest.TestCase): + def test_zero_args_returns_empty_criterion(self): + crit = Criterion.all() + self.assertIsInstance(crit, EmptyCriterion) + + def test_single_arg_returns_self(self): + f = Field("a") + crit = Criterion.all([f]) + self.assertEqual(str(f), str(crit)) + + def test_multiple_args_returned_in_chain_of_ors(self): + crit = Criterion.all([Field("a"), Field("b"), Field("c"), Field("d")]) + self.assertEqual(str(crit), '"a" AND "b" AND "c" AND "d"') + + def test_with_generator(self): + crit = Criterion.all(Field(letter) for letter in "abcd") + self.assertEqual(str(crit), '"a" AND "b" AND "c" AND "d"') diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/test_custom_functions.py b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/test_custom_functions.py new file mode 100644 index 0000000000000000000000000000000000000000..60ffd3cd8e6191e3fc782dac003c41bfb7a78528 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/test_custom_functions.py @@ -0,0 +1,49 @@ +import unittest + +from pypika import CustomFunction, FunctionException, Query, Table + +__author__ = "Airton Zanon" +__email__ = "me@airton.dev" + + +class TestUnitCustomFunction(unittest.TestCase): + def test_should_fail_with_wrong_arguments(self): + DateDiff = CustomFunction("DATE_DIFF", ["interval", "start_date", "end_date"]) + + with self.assertRaises(FunctionException): + DateDiff("foo") + + def test_should_return_function_with_arguments(self): + DateDiff = CustomFunction("DATE_DIFF", ["interval", "start_date", "end_date"]) + + self.assertEqual( + "DATE_DIFF('day','start_date','end_date')", + str(DateDiff("day", "start_date", "end_date")), + ) + + def test_should_return_function_with_no_arguments(self): + CurrentDate = CustomFunction("CURRENT_DATE") + + self.assertEqual("CURRENT_DATE()", str(CurrentDate())) + + +class TestFunctionalCustomFunction(unittest.TestCase): + def test_should_use_custom_function_on_select(self): + service = Table("service") + + DateDiff = CustomFunction("DATE_DIFF", ["interval", "start_date", "end_date"]) + + q = Query.from_(service).select(DateDiff("day", service.created_date, service.updated_date)) + + self.assertEqual( + 'SELECT DATE_DIFF(\'day\',"created_date","updated_date") FROM "service"', + str(q), + ) + + def test_should_fail_use_custom_function_on_select_with_wrong_arguments(self): + service = Table("service") + + DateDiff = CustomFunction("DATE_DIFF", ["interval", "start_date", "end_date"]) + + with self.assertRaises(FunctionException): + Query.from_(service).select(DateDiff("day", service.created_date)) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/test_data_types.py b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/test_data_types.py new file mode 100644 index 0000000000000000000000000000000000000000..52fb4487fe7be3ae28a4e9eb08628fba89dc0f79 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/test_data_types.py @@ -0,0 +1,15 @@ +import unittest +import uuid + +from pypika.terms import ValueWrapper + + +class StringTests(unittest.TestCase): + def test_inline_string_concatentation(self): + self.assertEqual("'it''s'", ValueWrapper("it's").get_sql()) + + +class UuidTests(unittest.TestCase): + def test_uuid_string_generation(self): + id = uuid.uuid4() + self.assertEqual("'{}'".format(id), ValueWrapper(id).get_sql()) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/test_date_math.py b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/test_date_math.py new file mode 100644 index 0000000000000000000000000000000000000000..38db8ef2f8e812a97c6980a7ec6b9a3909d804fb --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/test_date_math.py @@ -0,0 +1,179 @@ +import unittest + +from pypika import ( + Field as F, + Interval, +) +from pypika.enums import Dialects + +dt = F("dt") + + +class AddIntervalTests(unittest.TestCase): + def test_add_microsecond(self): + c = dt + Interval(microseconds=1) + + self.assertEqual("\"dt\"+INTERVAL '1 MICROSECOND'", str(c)) + + def test_add_second(self): + c = dt + Interval(seconds=1) + + self.assertEqual("\"dt\"+INTERVAL '1 SECOND'", str(c)) + + def test_add_minute(self): + c = dt + Interval(minutes=1) + + self.assertEqual("\"dt\"+INTERVAL '1 MINUTE'", str(c)) + + def test_add_day(self): + c = dt + Interval(days=1) + + self.assertEqual("\"dt\"+INTERVAL '1 DAY'", str(c)) + + def test_add_week(self): + c = dt + Interval(weeks=1) + + self.assertEqual("\"dt\"+INTERVAL '1 WEEK'", str(c)) + + def test_add_month(self): + c = dt + Interval(months=1) + + self.assertEqual("\"dt\"+INTERVAL '1 MONTH'", str(c)) + + def test_add_quarter(self): + c = dt + Interval(quarters=1) + + self.assertEqual("\"dt\"+INTERVAL '1 QUARTER'", str(c)) + + def test_add_year(self): + c = dt + Interval(years=1) + + self.assertEqual("\"dt\"+INTERVAL '1 YEAR'", str(c)) + + def test_add_default(self): + c = dt + Interval(days=0) + + self.assertEqual("\"dt\"+INTERVAL '0 DAY'", str(c)) + + +class AddIntervalMultipleUnitsTests(unittest.TestCase): + def test_add_second_microsecond(self): + c = dt + Interval(seconds=1, microseconds=1) + + self.assertEqual("\"dt\"+INTERVAL '1.1 SECOND_MICROSECOND'", str(c)) + + def test_add_minute_microsecond(self): + c = dt + Interval(minutes=1, microseconds=1) + + self.assertEqual("\"dt\"+INTERVAL '1:0.1 MINUTE_MICROSECOND'", str(c)) + + def test_add_minute_second(self): + c = dt + Interval(minutes=1, seconds=1) + + self.assertEqual("\"dt\"+INTERVAL '1:1 MINUTE_SECOND'", str(c)) + + def test_add_hour_microsecond(self): + c = dt + Interval(hours=1, microseconds=1) + + self.assertEqual("\"dt\"+INTERVAL '1:0:0.1 HOUR_MICROSECOND'", str(c)) + + def test_add_hour_second(self): + c = dt + Interval(hours=1, seconds=1) + + self.assertEqual("\"dt\"+INTERVAL '1:0:1 HOUR_SECOND'", str(c)) + + def test_add_hour_minute(self): + c = dt + Interval(hours=1, minutes=1) + + self.assertEqual("\"dt\"+INTERVAL '1:1 HOUR_MINUTE'", str(c)) + + def test_add_day_microsecond(self): + c = dt + Interval(days=1, microseconds=1) + + self.assertEqual("\"dt\"+INTERVAL '1 0:0:0.1 DAY_MICROSECOND'", str(c)) + + def test_add_day_second(self): + c = dt + Interval(days=1, seconds=1) + + self.assertEqual("\"dt\"+INTERVAL '1 0:0:1 DAY_SECOND'", str(c)) + + def test_add_day_minute(self): + c = dt + Interval(days=1, minutes=1) + + self.assertEqual("\"dt\"+INTERVAL '1 0:1 DAY_MINUTE'", str(c)) + + def test_add_day_hour(self): + c = dt + Interval(days=1, hours=1) + + self.assertEqual("\"dt\"+INTERVAL '1 1 DAY_HOUR'", str(c)) + + def test_add_year_month(self): + c = dt + Interval(years=1, months=1) + + self.assertEqual("\"dt\"+INTERVAL '1-1 YEAR_MONTH'", str(c)) + + def test_add_value_right(self): + c = Interval(microseconds=1) - dt + + self.assertEqual("INTERVAL '1 MICROSECOND'-\"dt\"", str(c)) + + def test_add_value_complex_expressions(self): + c = dt + Interval(quarters=1) + Interval(weeks=1) + + self.assertEqual("\"dt\"+INTERVAL '1 QUARTER'+INTERVAL '1 WEEK'", str(c)) + + +class DialectIntervalTests(unittest.TestCase): + def test_mysql_dialect_uses_single_quotes_around_expression_in_an_interval(self): + c = Interval(days=1).get_sql(dialect=Dialects.MYSQL) + self.assertEqual("INTERVAL '1' DAY", c) + + def test_oracle_dialect_uses_single_quotes_around_expression_in_an_interval(self): + c = Interval(days=1).get_sql(dialect=Dialects.ORACLE) + self.assertEqual("INTERVAL '1' DAY", c) + + def test_vertica_dialect_uses_single_quotes_around_interval(self): + c = Interval(days=1).get_sql(dialect=Dialects.VERTICA) + self.assertEqual("INTERVAL '1 DAY'", c) + + def test_redshift_dialect_uses_single_quotes_around_interval(self): + c = Interval(days=1).get_sql(dialect=Dialects.REDSHIFT) + self.assertEqual("INTERVAL '1 DAY'", c) + + def test_postgresql_dialect_uses_single_quotes_around_interval(self): + c = Interval(days=1).get_sql(dialect=Dialects.POSTGRESQL) + self.assertEqual("INTERVAL '1 DAY'", c) + + +class TestNegativeIntervals(unittest.TestCase): + def test_day(self): + c = Interval(days=-1).get_sql() + self.assertEqual("INTERVAL '-1 DAY'", c) + + def test_week(self): + c = Interval(weeks=-1).get_sql() + self.assertEqual("INTERVAL '-1 WEEK'", c) + + def test_month(self): + c = Interval(months=-1).get_sql() + self.assertEqual("INTERVAL '-1 MONTH'", c) + + def test_year(self): + c = Interval(years=-1).get_sql() + self.assertEqual("INTERVAL '-1 YEAR'", c) + + def test_year_month(self): + c = Interval(years=-1, months=-4).get_sql() + self.assertEqual("INTERVAL '-1-4 YEAR_MONTH'", c) + + +class TruncateTrailingZerosTests(unittest.TestCase): + def test_do_not_truncate_integer_values(self): + i = Interval(seconds=10) + + self.assertEqual("INTERVAL '10 SECOND'", str(i)) + + def test_do_not_truncate_months_between_years_and_datys(self): + i = Interval(years=10, days=10) + + self.assertEqual("INTERVAL '10-0-10 YEAR_DAY'", str(i)) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/test_deletes.py b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/test_deletes.py new file mode 100644 index 0000000000000000000000000000000000000000..09df93f5331b845b0c3aed628bf1c4a3ec6b0f02 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/test_deletes.py @@ -0,0 +1,97 @@ +import unittest + +from pypika import PostgreSQLQuery, Query, SYSTEM_TIME, Table + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + +from pypika.terms import Star + + +class DeleteTests(unittest.TestCase): + @classmethod + def setUpClass(cls) -> None: + super().setUpClass() + cls.table_abc = Table("abc") + + def test_omit_where(self): + q = Query.from_("abc").delete() + + self.assertEqual('DELETE FROM "abc"', str(q)) + + def test_omit_where__table_schema(self): + q = Query.from_(Table("abc", "schema1")).delete() + + self.assertEqual('DELETE FROM "schema1"."abc"', str(q)) + + def test_where_field_equals(self): + q1 = Query.from_(self.table_abc).where(self.table_abc.foo == self.table_abc.bar).delete() + q2 = Query.from_(self.table_abc).where(self.table_abc.foo.eq(self.table_abc.bar)).delete() + + self.assertEqual('DELETE FROM "abc" WHERE "foo"="bar"', str(q1)) + self.assertEqual('DELETE FROM "abc" WHERE "foo"="bar"', str(q2)) + + def test_for_portion(self): + with self.subTest("with system time"): + q = Query.from_(self.table_abc.for_portion(SYSTEM_TIME.from_to('2020-01-01', '2020-02-01'))).delete() + + self.assertEqual( + 'DELETE FROM "abc" FOR PORTION OF SYSTEM_TIME FROM \'2020-01-01\' TO \'2020-02-01\'', str(q) + ) + + with self.subTest("with column"): + q = Query.from_( + self.table_abc.for_portion(self.table_abc.valid_period.from_to('2020-01-01', '2020-02-01')) + ).delete() + + self.assertEqual( + 'DELETE FROM "abc" FOR PORTION OF "valid_period" FROM \'2020-01-01\' TO \'2020-02-01\'', str(q) + ) + + +class PostgresDeleteTests(unittest.TestCase): + @classmethod + def setUpClass(cls) -> None: + super().setUpClass() + cls.table_abc = Table("abc") + + def test_delete_returning(self): + q1 = ( + PostgreSQLQuery.from_(self.table_abc) + .where(self.table_abc.foo == self.table_abc.bar) + .delete() + .returning(self.table_abc.id) + ) + + self.assertEqual('DELETE FROM "abc" WHERE "foo"="bar" RETURNING "id"', str(q1)) + + def test_delete_returning_str(self): + q1 = ( + PostgreSQLQuery.from_(self.table_abc) + .where(self.table_abc.foo == self.table_abc.bar) + .delete() + .returning("id") + ) + + self.assertEqual('DELETE FROM "abc" WHERE "foo"="bar" RETURNING "id"', str(q1)) + + def test_delete_returning_star(self): + q1 = ( + PostgreSQLQuery.from_(self.table_abc) + .where(self.table_abc.foo == self.table_abc.bar) + .delete() + .returning(Star()) + ) + + self.assertEqual('DELETE FROM "abc" WHERE "foo"="bar" RETURNING *', str(q1)) + + def test_delete_using(self): + table_trash = Table('trash') + q1 = ( + PostgreSQLQuery.from_(self.table_abc) + .using(table_trash) + .where(self.table_abc.id == table_trash.abc_id) + .delete() + ) + + self.assertEqual('DELETE FROM "abc" USING "trash" WHERE "abc"."id"="trash"."abc_id"', str(q1)) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/test_drop.py b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/test_drop.py new file mode 100644 index 0000000000000000000000000000000000000000..265ae7350d2054549731f9a8c4379fdac95dc580 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/test_drop.py @@ -0,0 +1,49 @@ +import unittest + +from pypika import ( + Columns, + Database, + Query, + Tables, +) + + +class DropTableTests(unittest.TestCase): + database_xyz = Database("mydb") + new_table, existing_table = Tables("abc", "efg") + foo, bar = Columns(("a", "INT"), ("b", "VARCHAR(100)")) + + def test_drop_database(self): + q1 = Query.drop_database(self.database_xyz) + q2 = Query.drop_database(self.database_xyz).if_exists() + + self.assertEqual('DROP DATABASE "mydb"', str(q1)) + self.assertEqual('DROP DATABASE IF EXISTS "mydb"', str(q2)) + + def test_drop_table(self): + q1 = Query.drop_table(self.new_table) + q2 = Query.drop_table(self.new_table).if_exists() + + self.assertEqual('DROP TABLE "abc"', str(q1)) + self.assertEqual('DROP TABLE IF EXISTS "abc"', str(q2)) + + def test_drop_user(self): + q1 = Query.drop_user("myuser") + q2 = Query.drop_user("myuser").if_exists() + + self.assertEqual('DROP USER "myuser"', str(q1)) + self.assertEqual('DROP USER IF EXISTS "myuser"', str(q2)) + + def test_drop_view(self): + q1 = Query.drop_view("myview") + q2 = Query.drop_view("myview").if_exists() + + self.assertEqual('DROP VIEW "myview"', str(q1)) + self.assertEqual('DROP VIEW IF EXISTS "myview"', str(q2)) + + def test_drop_index(self): + q1 = Query.drop_index("myindex") + q2 = Query.drop_index("myindex").if_exists() + + self.assertEqual('DROP INDEX "myindex"', str(q1)) + self.assertEqual('DROP INDEX IF EXISTS "myindex"', str(q2)) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/test_formats.py b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/test_formats.py new file mode 100644 index 0000000000000000000000000000000000000000..6a442757c6659a215661e03f1ca9c3771d394d96 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/test_formats.py @@ -0,0 +1,68 @@ +import unittest + +from pypika import Query, Tables, functions as fn + + +class QuoteTests(unittest.TestCase): + maxDiff = None + + table_abc, table_efg = Tables("abc", "efg") + + def setUp(self): + subquery1 = ( + Query.from_(self.table_abc) + .select( + self.table_abc.foo, + fn.Sum(self.table_abc.fizz + self.table_abc.buzz).as_("fizzbuzz"), + ) + .groupby(self.table_abc.foo) + ) + + subquery2 = Query.from_(self.table_efg).select( + self.table_efg.foo.as_("foo_two"), + self.table_efg.bar, + ) + + self.query = ( + Query.from_(subquery1) + .select(subquery1.foo, subquery1.fizzbuzz) + .join(subquery2) + .on(subquery1.foo == subquery2.foo_two) + .select(subquery2.foo_two, subquery2.bar) + ) + + def test_replace_quote_char_in_complex_query(self): + self.assertEqual( + "SELECT " + "`sq0`.`foo`,`sq0`.`fizzbuzz`," + "`sq1`.`foo_two`,`sq1`.`bar` " + "FROM (" + "SELECT " + "`foo`,SUM(`fizz`+`buzz`) `fizzbuzz` " + "FROM `abc` " + "GROUP BY `foo`" + ") `sq0` JOIN (" + "SELECT " + "`foo` `foo_two`,`bar` " + "FROM `efg`" + ") `sq1` ON `sq0`.`foo`=`sq1`.`foo_two`", + self.query.get_sql(quote_char="`"), + ) + + def test_no_quote_char_in_complex_query(self): + self.assertEqual( + "SELECT " + "sq0.foo,sq0.fizzbuzz," + "sq1.foo_two,sq1.bar " + "FROM (" + "SELECT " + "foo,SUM(fizz+buzz) fizzbuzz " + "FROM abc " + "GROUP BY foo" + ") sq0 JOIN (" + "SELECT " + "foo foo_two,bar " + "FROM efg" + ") sq1 ON sq0.foo=sq1.foo_two", + self.query.get_sql(quote_char=None), + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/test_functions.py b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/test_functions.py new file mode 100644 index 0000000000000000000000000000000000000000..f526966eefc554ec68d0e15fb69de7d69f1604c3 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/test_functions.py @@ -0,0 +1,847 @@ +import unittest + +from pypika import ( + Case, + CaseException, + DatePart, + Field as F, + Query, + Query as Q, + Schema, + Table as T, + VerticaQuery, + functions as fn, +) +from pypika.enums import Dialects, SqlTypes + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + + +class FunctionTests(unittest.TestCase): + def test_dialect_propagation(self): + func = fn.Function("func", ["a"], ["b"]) + self.assertEqual("func(ARRAY['a'],ARRAY['b'])", func.get_sql(dialect=Dialects.POSTGRESQL)) + + def test_is_aggregate_None_for_non_aggregate_function_or_function_with_no_aggregate_functions(self): + self.assertIsNone(fn.Coalesce('a', 0).is_aggregate) + self.assertIsNone(fn.Coalesce(fn.NullIf('a', 0), 0).is_aggregate) + + def test_is_aggregate_True_for_aggregate_function_or_function_with_aggregate_functions(self): + self.assertTrue(fn.Sum('a').is_aggregate) + self.assertTrue(fn.Coalesce(fn.Avg('a'), 0).is_aggregate) + self.assertTrue(fn.Coalesce(fn.NullIf(fn.Sum('a'), 0), 0).is_aggregate) + + +class SchemaTests(unittest.TestCase): + def test_schema_no_schema_in_sql_when_none_set(self): + func = fn.Function("my_proc", 1, 2, 3) + + self.assertEqual("my_proc(1,2,3)", func.get_sql(quote_char='"')) + + def test_schema_included_in_function_sql(self): + a = Schema("a") + func = fn.Function("my_proc", 1, 2, 3, schema=a) + + self.assertEqual('"a".my_proc(1,2,3)', func.get_sql(quote_char='"')) + + +class ArithmeticTests(unittest.TestCase): + t = T("abc") + + def test__addition__fields(self): + q1 = Q.from_("abc").select(F("a") + F("b")) + q2 = Q.from_(self.t).select(self.t.a + self.t.b) + + self.assertEqual('SELECT "a"+"b" FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"+"b" FROM "abc"', str(q2)) + + def test__addition__number(self): + q1 = Q.from_("abc").select(F("a") + 1) + q2 = Q.from_(self.t).select(self.t.a + 1) + + self.assertEqual('SELECT "a"+1 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"+1 FROM "abc"', str(q2)) + + def test__addition__decimal(self): + q1 = Q.from_("abc").select(F("a") + 1.0) + q2 = Q.from_(self.t).select(self.t.a + 1.0) + + self.assertEqual('SELECT "a"+1.0 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"+1.0 FROM "abc"', str(q2)) + + def test__addition__right(self): + q1 = Q.from_("abc").select(1 + F("a")) + q2 = Q.from_(self.t).select(1 + self.t.a) + + self.assertEqual('SELECT 1+"a" FROM "abc"', str(q1)) + self.assertEqual('SELECT 1+"a" FROM "abc"', str(q2)) + + def test__subtraction__fields(self): + q1 = Q.from_("abc").select(F("a") - F("b")) + q2 = Q.from_(self.t).select(self.t.a - self.t.b) + + self.assertEqual('SELECT "a"-"b" FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"-"b" FROM "abc"', str(q2)) + + def test__subtraction__number(self): + q1 = Q.from_("abc").select(F("a") - 1) + q2 = Q.from_(self.t).select(self.t.a - 1) + + self.assertEqual('SELECT "a"-1 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"-1 FROM "abc"', str(q2)) + + def test__subtraction__decimal(self): + q1 = Q.from_("abc").select(F("a") - 1.0) + q2 = Q.from_(self.t).select(self.t.a - 1.0) + + self.assertEqual('SELECT "a"-1.0 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"-1.0 FROM "abc"', str(q2)) + + def test__subtraction__right(self): + q1 = Q.from_("abc").select(1 - F("a")) + q2 = Q.from_(self.t).select(1 - self.t.a) + + self.assertEqual('SELECT 1-"a" FROM "abc"', str(q1)) + self.assertEqual('SELECT 1-"a" FROM "abc"', str(q2)) + + def test__multiplication__fields(self): + q1 = Q.from_("abc").select(F("a") * F("b")) + q2 = Q.from_(self.t).select(self.t.a * self.t.b) + + self.assertEqual('SELECT "a"*"b" FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"*"b" FROM "abc"', str(q2)) + + def test__multiplication__number(self): + q1 = Q.from_("abc").select(F("a") * 1) + q2 = Q.from_(self.t).select(self.t.a * 1) + + self.assertEqual('SELECT "a"*1 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"*1 FROM "abc"', str(q2)) + + def test__multiplication__decimal(self): + q1 = Q.from_("abc").select(F("a") * 1.0) + q2 = Q.from_(self.t).select(self.t.a * 1.0) + + self.assertEqual('SELECT "a"*1.0 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"*1.0 FROM "abc"', str(q2)) + + def test__multiplication__right(self): + q1 = Q.from_("abc").select(1 * F("a")) + q2 = Q.from_(self.t).select(1 * self.t.a) + + self.assertEqual('SELECT 1*"a" FROM "abc"', str(q1)) + self.assertEqual('SELECT 1*"a" FROM "abc"', str(q2)) + + def test__division__fields(self): + q1 = Q.from_("abc").select(F("a") / F("b")) + q2 = Q.from_(self.t).select(self.t.a / self.t.b) + + self.assertEqual('SELECT "a"/"b" FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"/"b" FROM "abc"', str(q2)) + + def test__division__number(self): + q1 = Q.from_("abc").select(F("a") / 1) + q2 = Q.from_(self.t).select(self.t.a / 1) + + self.assertEqual('SELECT "a"/1 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"/1 FROM "abc"', str(q2)) + + def test__division__decimal(self): + q1 = Q.from_("abc").select(F("a") / 1.0) + q2 = Q.from_(self.t).select(self.t.a / 1.0) + + self.assertEqual('SELECT "a"/1.0 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"/1.0 FROM "abc"', str(q2)) + + def test__division__right(self): + q1 = Q.from_("abc").select(1 / F("a")) + q2 = Q.from_(self.t).select(1 / self.t.a) + + self.assertEqual('SELECT 1/"a" FROM "abc"', str(q1)) + self.assertEqual('SELECT 1/"a" FROM "abc"', str(q2)) + + def test__leftshift__fields(self): + q1 = Q.from_("abc").select(F("a") << F("b")) + q2 = Q.from_(self.t).select(self.t.a << self.t.b) + + self.assertEqual('SELECT "a"<<"b" FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"<<"b" FROM "abc"', str(q2)) + + def test__leftshift__number(self): + q1 = Q.from_("abc").select(F('a') << 2) + q2 = Q.from_(self.t).select(self.t.a << 2) + + self.assertEqual('SELECT "a"<<2 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"<<2 FROM "abc"', str(q2)) + + def test__leftshift__right(self): + q1 = Q.from_("abc").select(1 << F("a")) + q2 = Q.from_(self.t).select(1 << self.t.a) + + self.assertEqual('SELECT 1<<"a" FROM "abc"', str(q1)) + self.assertEqual('SELECT 1<<"a" FROM "abc"', str(q2)) + + def test__rightshift__fields(self): + q1 = Q.from_("abc").select(F("a") >> F("b")) + q2 = Q.from_(self.t).select(self.t.a >> self.t.b) + + self.assertEqual('SELECT "a">>"b" FROM "abc"', str(q1)) + self.assertEqual('SELECT "a">>"b" FROM "abc"', str(q2)) + + def test__rightshift__number(self): + q1 = Q.from_("abc").select(F('a') >> 2) + q2 = Q.from_(self.t).select(self.t.a >> 2) + + self.assertEqual('SELECT "a">>2 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a">>2 FROM "abc"', str(q2)) + + def test__rightshift__right(self): + q1 = Q.from_("abc").select(1 >> F("a")) + q2 = Q.from_(self.t).select(1 >> self.t.a) + + self.assertEqual('SELECT 1>>"a" FROM "abc"', str(q1)) + self.assertEqual('SELECT 1>>"a" FROM "abc"', str(q2)) + + def test__complex_op(self): + q1 = Q.from_("abc").select(2 + 1 / F("a") - 5) + q2 = Q.from_(self.t).select(2 + 1 / self.t.a - 5) + + self.assertEqual('SELECT 2+1/"a"-5 FROM "abc"', str(q1)) + self.assertEqual('SELECT 2+1/"a"-5 FROM "abc"', str(q2)) + + def test__complex_op_add_parentheses(self): + q1 = Q.from_("abc").select((F("a") + 1) + (F("b") - 5)) + q2 = Q.from_(self.t).select((self.t.a + 1) + (self.t.b - 5)) + q3 = Q.from_("abc").select((F("a") / 1) + (F("b") / 5)) + q4 = Q.from_(self.t).select((self.t.a / 1) + (self.t.b / 5)) + + self.assertEqual('SELECT "a"+1+"b"-5 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"+1+"b"-5 FROM "abc"', str(q2)) + self.assertEqual('SELECT "a"/1+"b"/5 FROM "abc"', str(q3)) + self.assertEqual('SELECT "a"/1+"b"/5 FROM "abc"', str(q4)) + + def test__complex_op_sub_parentheses(self): + q1 = Q.from_("abc").select((F("a") + 1) - (F("b") - 5)) + q2 = Q.from_(self.t).select((self.t.a + 1) - (self.t.b - 5)) + q3 = Q.from_("abc").select((F("a") / 1) - (F("b") / 5)) + q4 = Q.from_(self.t).select((self.t.a / 1) - (self.t.b / 5)) + + self.assertEqual('SELECT "a"+1-("b"-5) FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"+1-("b"-5) FROM "abc"', str(q2)) + self.assertEqual('SELECT "a"/1-"b"/5 FROM "abc"', str(q3)) + self.assertEqual('SELECT "a"/1-"b"/5 FROM "abc"', str(q4)) + + def test__complex_op_mul_parentheses(self): + q1 = Q.from_("abc").select((F("a") + 1) * (F("b") - 5)) + q2 = Q.from_(self.t).select((self.t.a + 1) * (self.t.b - 5)) + q3 = Q.from_("abc").select((F("a") / 1) * (F("b") - 5)) + q4 = Q.from_(self.t).select((self.t.a / 1) * (self.t.b - 5)) + q5 = Q.from_("abc").select((F("a") + 1) * (F("b") / 5)) + q6 = Q.from_(self.t).select((self.t.a + 1) * (self.t.b / 5)) + + self.assertEqual('SELECT ("a"+1)*("b"-5) FROM "abc"', str(q1)) + self.assertEqual('SELECT ("a"+1)*("b"-5) FROM "abc"', str(q2)) + self.assertEqual('SELECT "a"/1*("b"-5) FROM "abc"', str(q3)) + self.assertEqual('SELECT "a"/1*("b"-5) FROM "abc"', str(q4)) + self.assertEqual('SELECT ("a"+1)*"b"/5 FROM "abc"', str(q5)) + self.assertEqual('SELECT ("a"+1)*"b"/5 FROM "abc"', str(q6)) + + def test__complex_op_mul_no_parentheses(self): + q = Q.from_("abc").select(F("a") + 1 * F("b") - 5) + + self.assertEqual('SELECT "a"+1*"b"-5 FROM "abc"', str(q)) + + def test__complex_op_div_parentheses(self): + q1 = Q.from_("abc").select((F("a") + 1) / (F("b") - 5)) + q2 = Q.from_(self.t).select((self.t.a + 1) / (self.t.b - 5)) + q3 = Q.from_("abc").select((F("a") / 1) / (F("b") - 5)) + q4 = Q.from_(self.t).select((self.t.a / 1) / (self.t.b - 5)) + q5 = Q.from_("abc").select((F("a") + 1) / (F("b") * 5)) + q6 = Q.from_(self.t).select((self.t.a + 1) / (self.t.b * 5)) + + self.assertEqual('SELECT ("a"+1)/("b"-5) FROM "abc"', str(q1)) + self.assertEqual('SELECT ("a"+1)/("b"-5) FROM "abc"', str(q2)) + self.assertEqual('SELECT "a"/1/("b"-5) FROM "abc"', str(q3)) + self.assertEqual('SELECT "a"/1/("b"-5) FROM "abc"', str(q4)) + self.assertEqual('SELECT ("a"+1)/("b"*5) FROM "abc"', str(q5)) + self.assertEqual('SELECT ("a"+1)/("b"*5) FROM "abc"', str(q6)) + + def test__complex_op_div_no_parentheses(self): + q = Q.from_("abc").select(F("a") + 1 / F("b") - 5) + + self.assertEqual('SELECT "a"+1/"b"-5 FROM "abc"', str(q)) + + def test__complex_op_exponent_parentheses(self): + q1 = Q.from_("abc").select(F("a") / (F("b") ** 2)) + q2 = Q.from_(self.t).select(self.t.a / (self.t.b**2)) + q3 = Q.from_("abc").select(F("a") ** (F("b") / 2)) + q4 = Q.from_(self.t).select(self.t.a ** (self.t.b / 2)) + q5 = Q.from_("abc").select((F("a") ** F("b")) ** 2) + q6 = Q.from_(self.t).select((self.t.a**self.t.b) ** 2) + + self.assertEqual('SELECT "a"/POW("b",2) FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"/POW("b",2) FROM "abc"', str(q2)) + self.assertEqual('SELECT POW("a","b"/2) FROM "abc"', str(q3)) + self.assertEqual('SELECT POW("a","b"/2) FROM "abc"', str(q4)) + self.assertEqual('SELECT POW(POW("a","b"),2) FROM "abc"', str(q5)) + self.assertEqual('SELECT POW(POW("a","b"),2) FROM "abc"', str(q6)) + + def test__complex_op_exponent_no_parentheses(self): + q1 = Q.from_("abc").select(F("a") ** F("b") ** 2) + q2 = Q.from_(self.t).select(self.t.a**self.t.b**2) + q3 = Q.from_("abc").select(F("a") / F("b") ** 2) + q4 = Q.from_(self.t).select(self.t.a / self.t.b**2) + + self.assertEqual('SELECT POW("a",POW("b",2)) FROM "abc"', str(q1)) + self.assertEqual('SELECT POW("a",POW("b",2)) FROM "abc"', str(q2)) + self.assertEqual('SELECT "a"/POW("b",2) FROM "abc"', str(q3)) + self.assertEqual('SELECT "a"/POW("b",2) FROM "abc"', str(q4)) + + def test__complex_op_function_parentheses(self): + q1 = Q.from_("abc").select(F("a") / (fn.Sum(F("b")) / 2)) + q2 = Q.from_("abc").select(self.t.a / (fn.Sum(self.t.b) / 2)) + q3 = Q.from_("abc").select(fn.Sum(F("a") / (F("b") / 2))) + q4 = Q.from_("abc").select(fn.Sum(self.t.a / (self.t.b / 2))) + + self.assertEqual('SELECT "a"/(SUM("b")/2) FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"/(SUM("b")/2) FROM "abc"', str(q2)) + self.assertEqual('SELECT SUM("a"/("b"/2)) FROM "abc"', str(q3)) + self.assertEqual('SELECT SUM("a"/("b"/2)) FROM "abc"', str(q4)) + + def test__complex_op_modulus_parentheses(self): + q1 = Q.from_("abc").select(F("a") / (F("b") % 2)) + q2 = Q.from_(self.t).select(self.t.a / (self.t.b % 2)) + q3 = Q.from_("abc").select(F("a") % (F("b") / 2)) + q4 = Q.from_(self.t).select(self.t.a % (self.t.b / 2)) + q5 = Q.from_("abc").select(F("a") % (F("b") % 2)) + q6 = Q.from_("abc").select(self.t.a % (self.t.b % 2)) + + self.assertEqual('SELECT "a"/MOD("b",2) FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"/MOD("b",2) FROM "abc"', str(q2)) + self.assertEqual('SELECT MOD("a","b"/2) FROM "abc"', str(q3)) + self.assertEqual('SELECT MOD("a","b"/2) FROM "abc"', str(q4)) + self.assertEqual('SELECT MOD("a",MOD("b",2)) FROM "abc"', str(q5)) + self.assertEqual('SELECT MOD("a",MOD("b",2)) FROM "abc"', str(q6)) + + def test__complex_op_modulus_no_parentheses(self): + q1 = Q.from_("abc").select(F("a") % F("b") % 2) + q2 = Q.from_(self.t).select(self.t.a % self.t.b % 2) + q3 = Q.from_("abc").select(F("a") / F("b") % 2) + q4 = Q.from_(self.t).select(self.t.a / self.t.b % 2) + + self.assertEqual('SELECT MOD(MOD("a","b"),2) FROM "abc"', str(q1)) + self.assertEqual('SELECT MOD(MOD("a","b"),2) FROM "abc"', str(q2)) + self.assertEqual('SELECT MOD("a"/"b",2) FROM "abc"', str(q3)) + self.assertEqual('SELECT MOD("a"/"b",2) FROM "abc"', str(q4)) + + def test__complex_op_floor_parentheses(self): + q1 = Q.from_("abc").select(F("a") / (fn.Floor(F("b")) / 2)) + q2 = Q.from_("abc").select(self.t.a / (fn.Floor(self.t.b) / 2)) + q3 = Q.from_("abc").select(fn.Floor(F("a") / (F("b") / 2))) + q4 = Q.from_("abc").select(fn.Floor(self.t.a / (self.t.b / 2))) + + self.assertEqual('SELECT "a"/(FLOOR("b")/2) FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"/(FLOOR("b")/2) FROM "abc"', str(q2)) + self.assertEqual('SELECT FLOOR("a"/("b"/2)) FROM "abc"', str(q3)) + self.assertEqual('SELECT FLOOR("a"/("b"/2)) FROM "abc"', str(q4)) + + def test__complex_op_nested_parentheses(self): + q1 = Q.from_("abc").select(F("a") / (F("b") / ((F("c") / 2)))) + q2 = Q.from_("abc").select(self.t.a / (self.t.b / ((self.t.c / 2)))) + + self.assertEqual('SELECT "a"/("b"/("c"/2)) FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"/("b"/("c"/2)) FROM "abc"', str(q2)) + + def test__arithmetic_equality(self): + q1 = Q.from_("abc").select(F("a") / 2 == 2) + q2 = Q.from_(self.t).select(self.t.a / 2 == 2) + + self.assertEqual('SELECT "a"/2=2 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"/2=2 FROM "abc"', str(q2)) + + def test__arithmetic_with_function(self): + q1 = Q.from_("abc").select(fn.Sum(F("foo")) + 1) + q2 = Q.from_(self.t).select(fn.Sum(self.t.foo) + 1) + + self.assertEqual('SELECT SUM("foo")+1 FROM "abc"', str(q1)) + self.assertEqual('SELECT SUM("foo")+1 FROM "abc"', str(q2)) + + def test__exponent__number(self): + q1 = Q.from_("abc").select(F("a") ** 2) + q2 = Q.from_(self.t).select(self.t.a**2) + + self.assertEqual('SELECT POW("a",2) FROM "abc"', str(q1)) + self.assertEqual('SELECT POW("a",2) FROM "abc"', str(q2)) + + def test__exponent__decimal(self): + q1 = Q.from_("abc").select(F("a") ** 0.5) + q2 = Q.from_(self.t).select(self.t.a**0.5) + + self.assertEqual('SELECT POW("a",0.5) FROM "abc"', str(q1)) + self.assertEqual('SELECT POW("a",0.5) FROM "abc"', str(q2)) + + def test__modulus__number(self): + q1 = Q.from_("abc").select(F("a") % 2) + q2 = Q.from_(self.t).select(self.t.a % 2) + + self.assertEqual('SELECT MOD("a",2) FROM "abc"', str(q1)) + self.assertEqual('SELECT MOD("a",2) FROM "abc"', str(q2)) + + def test__floor(self): + q1 = Q.from_("abc").select(fn.Floor(F("foo"))) + q2 = Q.from_(self.t).select(fn.Floor(self.t.foo)) + + self.assertEqual('SELECT FLOOR("foo") FROM "abc"', str(q1)) + self.assertEqual('SELECT FLOOR("foo") FROM "abc"', str(q2)) + + +class AggregationTests(unittest.TestCase): + def test__count(self): + q = Q.from_("abc").select(fn.Count(F("foo"))) + + self.assertEqual('SELECT COUNT("foo") FROM "abc"', str(q)) + + def test__count__star(self): + q = Q.from_("abc").select(fn.Count("*")) + + self.assertEqual('SELECT COUNT(*) FROM "abc"', str(q)) + + def test__sum(self): + q = Q.from_("abc").select(fn.Sum(F("foo"))) + + self.assertEqual('SELECT SUM("foo") FROM "abc"', str(q)) + + def test__avg(self): + q = Q.from_("abc").select(fn.Avg(F("foo"))) + + self.assertEqual('SELECT AVG("foo") FROM "abc"', str(q)) + + def test__first(self): + q = Q.from_("abc").select(fn.First(F("foo"))) + + self.assertEqual('SELECT FIRST("foo") FROM "abc"', str(q)) + + def test__last(self): + q = Q.from_("abc").select(fn.Last(F("foo"))) + + self.assertEqual('SELECT LAST("foo") FROM "abc"', str(q)) + + def test__min(self): + q = Q.from_("abc").select(fn.Min(F("foo"))) + + self.assertEqual('SELECT MIN("foo") FROM "abc"', str(q)) + + def test__max(self): + q = Q.from_("abc").select(fn.Max(F("foo"))) + + self.assertEqual('SELECT MAX("foo") FROM "abc"', str(q)) + + def test__std(self): + q = Q.from_("abc").select(fn.Std(F("foo"))) + + self.assertEqual('SELECT STD("foo") FROM "abc"', str(q)) + + def test__stddev(self): + q = Q.from_("abc").select(fn.StdDev(F("foo"))) + + self.assertEqual('SELECT STDDEV("foo") FROM "abc"', str(q)) + + def test__approx_percentile(self): + q = Q.from_("abc").select(fn.ApproximatePercentile(F("foo"), 0.5)) + + self.assertEqual( + 'SELECT APPROXIMATE_PERCENTILE("foo" USING PARAMETERS percentile=0.5) FROM "abc"', + str(q), + ) + + def test__subquery_in_params_functions(self): + subquery = Query.from_('table').select('id') + func = fn.Function('func', 'id', subquery) + self.assertEqual("func('id',(SELECT id FROM table))", func.get_sql()) + + +class ConditionTests(unittest.TestCase): + def test__case__raw(self): + q = Q.from_("abc").select(Case().when(F("foo") == 1, "a")) + + self.assertEqual('SELECT CASE WHEN "foo"=1 THEN \'a\' END FROM "abc"', str(q)) + + def test__case__else(self): + q = Q.from_("abc").select(Case().when(F("foo") == 1, "a").else_("b")) + + self.assertEqual("SELECT CASE WHEN \"foo\"=1 THEN 'a' ELSE 'b' END FROM \"abc\"", str(q)) + + def test__case__field(self): + q = Q.from_("abc").select(Case().when(F("foo") == 1, F("bar")).else_(F("buz"))) + + self.assertEqual('SELECT CASE WHEN "foo"=1 THEN "bar" ELSE "buz" END FROM "abc"', str(q)) + + def test__case__multi(self): + q = Q.from_("abc").select(Case().when(F("foo") > 0, F("fiz")).when(F("bar") <= 0, F("buz")).else_(1)) + + self.assertEqual( + 'SELECT CASE WHEN "foo">0 THEN "fiz" WHEN "bar"<=0 THEN "buz" ELSE 1 END FROM "abc"', + str(q), + ) + + def test__case__no_cases(self): + with self.assertRaises(CaseException): + q = Q.from_("abc").select(Case()) + + str(q) + + +class StringTests(unittest.TestCase): + t = T("abc") + + def test__ascii__str(self): + q = Q.select(fn.Ascii("2")) + + self.assertEqual("SELECT ASCII('2')", str(q)) + + def test__ascii__int(self): + q = Q.select(fn.Ascii(2)) + + self.assertEqual("SELECT ASCII(2)", str(q)) + + def test__ascii__field(self): + q = Q.from_(self.t).select(fn.Ascii(self.t.foo)) + + self.assertEqual('SELECT ASCII("foo") FROM "abc"', str(q)) + + def test__bin__str(self): + q = Q.select(fn.Bin("2")) + + self.assertEqual("SELECT BIN('2')", str(q)) + + def test__bin__int(self): + q = Q.select(fn.Bin(2)) + + self.assertEqual("SELECT BIN(2)", str(q)) + + def test__bin__field(self): + q = Q.from_(self.t).select(fn.Bin(self.t.foo)) + + self.assertEqual('SELECT BIN("foo") FROM "abc"', str(q)) + + def test__concat__str(self): + q = Q.select(fn.Concat("p", "y", "q", "b")) + + self.assertEqual("SELECT CONCAT('p','y','q','b')", str(q)) + + def test__concat__field(self): + q = Q.from_(self.t).select(fn.Concat(self.t.foo, self.t.bar)) + + self.assertEqual('SELECT CONCAT("foo","bar") FROM "abc"', str(q)) + + def test__insert__str(self): + q = Q.select(fn.Insert("Quadratic", 3, 4, "What")) + + self.assertEqual("SELECT INSERT('Quadratic',3,4,'What')", str(q)) + + def test__insert__field(self): + q = Q.from_(self.t).select(fn.Insert(self.t.foo, 3, 4, self.t.bar)) + + self.assertEqual('SELECT INSERT("foo",3,4,"bar") FROM "abc"', str(q)) + + def test__lower__str(self): + q = Q.select(fn.Lower("ABC")) + + self.assertEqual("SELECT LOWER('ABC')", str(q)) + + def test__lower__field(self): + q = Q.from_(self.t).select(fn.Lower(self.t.foo)) + + self.assertEqual('SELECT LOWER("foo") FROM "abc"', str(q)) + + def test__length__str(self): + q = Q.select(fn.Length("ABC")) + + self.assertEqual("SELECT LENGTH('ABC')", str(q)) + + def test__length__field(self): + q = Q.from_(self.t).select(fn.Length(self.t.foo)) + + self.assertEqual('SELECT LENGTH("foo") FROM "abc"', str(q)) + + def test__substring(self): + q = Q.from_(self.t).select(fn.Substring(self.t.foo, 2, 6)) + + self.assertEqual('SELECT SUBSTRING("foo",2,6) FROM "abc"', str(q)) + + def test__replace__str(self): + q = Q.select(fn.Replace("ABC_DEF", "_", " ")) + self.assertEqual("SELECT REPLACE('ABC_DEF','_',' ')", str(q)) + + def test__replace__field(self): + q = Q.from_(self.t).select(fn.Replace(self.t.foobar, self.t.foo, self.t.bar)) + self.assertEqual('SELECT REPLACE("foobar","foo","bar") FROM "abc"', str(q)) + + +class SplitPartFunctionTests(unittest.TestCase): + t = T("abc") + + def test__split_part(self): + q = VerticaQuery.from_(self.t).select(fn.SplitPart(self.t.foo, "|", 3)) + + self.assertEqual('SELECT SPLIT_PART("foo",\'|\',3) FROM "abc"', str(q)) + + +class RegexpLikeFunctionTests(unittest.TestCase): + t = T("abc") + + def test__regexp_like(self): + q = VerticaQuery.from_(self.t).select(fn.RegexpLike(self.t.foo, "^a", "x")) + + self.assertEqual("SELECT REGEXP_LIKE(\"foo\",'^a','x') FROM \"abc\"", str(q)) + + +class CastTests(unittest.TestCase): + t = T("abc") + + def test__cast__as(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.UNSIGNED)) + + self.assertEqual('SELECT CAST("foo" AS UNSIGNED) FROM "abc"', str(q)) + + def test__cast__signed(self): + q1 = Q.from_(self.t).select(fn.Signed(self.t.foo)) + q2 = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.SIGNED)) + + self.assertEqual('SELECT CAST("foo" AS SIGNED) FROM "abc"', str(q1)) + self.assertEqual('SELECT CAST("foo" AS SIGNED) FROM "abc"', str(q2)) + + def test__cast__unsigned(self): + q1 = Q.from_(self.t).select(fn.Unsigned(self.t.foo)) + q2 = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.UNSIGNED)) + + self.assertEqual('SELECT CAST("foo" AS UNSIGNED) FROM "abc"', str(q1)) + self.assertEqual('SELECT CAST("foo" AS UNSIGNED) FROM "abc"', str(q2)) + + def test__cast__date(self): + q1 = Q.from_(self.t).select(fn.Date(self.t.foo)) + q2 = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.DATE)) + + self.assertEqual('SELECT DATE("foo") FROM "abc"', str(q1)) + self.assertEqual('SELECT CAST("foo" AS DATE) FROM "abc"', str(q2)) + + def test__cast__timestamp(self): + q1 = Q.from_(self.t).select(fn.Timestamp(self.t.foo)) + q2 = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.TIMESTAMP)) + + self.assertEqual('SELECT TIMESTAMP("foo") FROM "abc"', str(q1)) + self.assertEqual('SELECT CAST("foo" AS TIMESTAMP) FROM "abc"', str(q2)) + + def test__cast__char(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.CHAR)) + + self.assertEqual('SELECT CAST("foo" AS CHAR) FROM "abc"', str(q)) + + def test__cast__char_with_arg(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.VARCHAR(24))) + + self.assertEqual('SELECT CAST("foo" AS VARCHAR(24)) FROM "abc"', str(q)) + + def test__cast__varchar(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.VARCHAR)) + + self.assertEqual('SELECT CAST("foo" AS VARCHAR) FROM "abc"', str(q)) + + def test__cast__varchar_with_arg(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.VARCHAR(24))) + + self.assertEqual('SELECT CAST("foo" AS VARCHAR(24)) FROM "abc"', str(q)) + + def test__cast__long_varchar(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.LONG_VARCHAR)) + + self.assertEqual('SELECT CAST("foo" AS LONG VARCHAR) FROM "abc"', str(q)) + + def test__cast__long_varchar_with_arg(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.LONG_VARCHAR(24))) + + self.assertEqual('SELECT CAST("foo" AS LONG VARCHAR(24)) FROM "abc"', str(q)) + + def test__cast__binary(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.BINARY)) + + self.assertEqual('SELECT CAST("foo" AS BINARY) FROM "abc"', str(q)) + + def test__cast__binary_with_arg(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.BINARY(24))) + + self.assertEqual('SELECT CAST("foo" AS BINARY(24)) FROM "abc"', str(q)) + + def test__cast__varbinary(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.VARBINARY)) + + self.assertEqual('SELECT CAST("foo" AS VARBINARY) FROM "abc"', str(q)) + + def test__cast__varbinary_with_arg(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.VARBINARY(24))) + + self.assertEqual('SELECT CAST("foo" AS VARBINARY(24)) FROM "abc"', str(q)) + + def test__cast__long_varbinary(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.LONG_VARBINARY)) + + self.assertEqual('SELECT CAST("foo" AS LONG VARBINARY) FROM "abc"', str(q)) + + def test__cast__long_varbinary_with_arg(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.LONG_VARBINARY(24))) + + self.assertEqual('SELECT CAST("foo" AS LONG VARBINARY(24)) FROM "abc"', str(q)) + + def test__cast__boolean(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.BOOLEAN)) + + self.assertEqual('SELECT CAST("foo" AS BOOLEAN) FROM "abc"', str(q)) + + def test__cast__integer(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.INTEGER)) + + self.assertEqual('SELECT CAST("foo" AS INTEGER) FROM "abc"', str(q)) + + def test__cast__float(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.FLOAT)) + + self.assertEqual('SELECT CAST("foo" AS FLOAT) FROM "abc"', str(q)) + + def test__cast__numeric(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.NUMERIC)) + + self.assertEqual('SELECT CAST("foo" AS NUMERIC) FROM "abc"', str(q)) + + def test__tochar__(self): + q = Q.from_(self.t).select(fn.ToChar(self.t.foo, "SomeFormat")) + + self.assertEqual('SELECT TO_CHAR("foo",\'SomeFormat\') FROM "abc"', str(q)) + + +class DateFunctionsTests(unittest.TestCase): + dt = F("dt") + t = T("abc") + t2 = T("efg") + + def _test_extract_datepart(self, date_part): + q = Q.from_(self.t).select(fn.Extract(date_part, self.t.foo)) + + value = getattr(date_part, 'value', date_part) + self.assertEqual('SELECT EXTRACT(%s FROM "foo") FROM "abc"' % value, str(q)) + + def test_extract_microsecond(self): + self._test_extract_datepart(DatePart.microsecond) + self._test_extract_datepart(DatePart.microsecond.value) + + def test_extract_second(self): + self._test_extract_datepart(DatePart.second) + self._test_extract_datepart(DatePart.second.value) + + def test_extract_minute(self): + self._test_extract_datepart(DatePart.minute) + self._test_extract_datepart(DatePart.minute.value) + + def test_extract_hour(self): + self._test_extract_datepart(DatePart.hour) + self._test_extract_datepart(DatePart.hour.value) + + def test_extract_day(self): + self._test_extract_datepart(DatePart.day) + self._test_extract_datepart(DatePart.day.value) + + def test_extract_week(self): + self._test_extract_datepart(DatePart.week) + self._test_extract_datepart(DatePart.week.value) + + def test_extract_month(self): + self._test_extract_datepart(DatePart.month) + self._test_extract_datepart(DatePart.month.value) + + def test_extract_quarter(self): + self._test_extract_datepart(DatePart.quarter) + self._test_extract_datepart(DatePart.quarter.value) + + def test_extract_year(self): + self._test_extract_datepart(DatePart.year) + self._test_extract_datepart(DatePart.year.value) + + def test_extract_join(self): + q = Q.from_(self.t).join(self.t2).on(self.t.id == self.t2.t_id).select(fn.Extract(DatePart.year, self.t.foo)) + + self.assertEqual( + 'SELECT EXTRACT(YEAR FROM "abc"."foo") FROM "abc" ' 'JOIN "efg" ON "abc"."id"="efg"."t_id"', str(q) + ) + + def test_timestampadd(self): + a = fn.TimestampAdd("year", 1, "2017-10-01") + self.assertEqual(str(a), "TIMESTAMPADD(year,1,'2017-10-01')") + + def test_time_diff(self): + a = fn.TimeDiff("18:00:00", "10:00:00") + self.assertEqual(str(a), "TIMEDIFF('18:00:00','10:00:00')") + + def test_date_add(self): + a = fn.DateAdd("year", 1, "2017-10-01") + self.assertEqual(str(a), "DATE_ADD(year,1,'2017-10-01')") + + def test_now(self): + query = Query.select(fn.Now()) + + self.assertEqual("SELECT NOW()", str(query)) + + def test_utc_timestamp(self): + query = Query.select(fn.UtcTimestamp()) + + self.assertEqual("SELECT UTC_TIMESTAMP()", str(query)) + + def test_current_date(self): + query = Query.select(fn.CurDate()) + + self.assertEqual("SELECT CURRENT_DATE()", str(query)) + + def test_current_time(self): + query = Query.select(fn.CurTime()) + + self.assertEqual("SELECT CURRENT_TIME()", str(query)) + + def test_current_timestamp(self): + query = Query.select(fn.CurTimestamp()) + + self.assertEqual("SELECT CURRENT_TIMESTAMP", str(query)) + + def test_current_timestamp_with_alias(self): + query = Query.select(fn.CurTimestamp("ts")) + + self.assertEqual('SELECT CURRENT_TIMESTAMP "ts"', str(query)) + + def test_to_date(self): + q1 = fn.ToDate("2019-06-21", "yyyy-mm-dd") + q2 = Query.from_(self.t).select(fn.ToDate("2019-06-21", "yyyy-mm-dd")) + q3 = Query.from_(self.t).select(fn.ToDate(F("foo"), "yyyy-mm-dd")) + + self.assertEqual(str(q1), "TO_DATE('2019-06-21','yyyy-mm-dd')") + self.assertEqual(str(q2), "SELECT TO_DATE('2019-06-21','yyyy-mm-dd') FROM \"abc\"") + self.assertEqual(str(q3), 'SELECT TO_DATE("foo",\'yyyy-mm-dd\') FROM "abc"') + + +class NullFunctionsTests(unittest.TestCase): + def test_isnull(self): + q = Q.from_("abc").select(fn.IsNull(F("foo"))) + + self.assertEqual('SELECT ISNULL("foo") FROM "abc"', str(q)) + + def test_coalesce(self): + q = Q.from_("abc").select(fn.Coalesce(F("foo"), 0)) + + self.assertEqual('SELECT COALESCE("foo",0) FROM "abc"', str(q)) + + def test_nullif(self): + q = Q.from_("abc").select(fn.NullIf(F("foo"), 0)) + + self.assertEqual('SELECT NULLIF("foo",0) FROM "abc"', str(q)) + + def test_nvl(self): + q = Q.from_("abc").select(fn.NVL(F("foo"), 0)) + + self.assertEqual('SELECT NVL("foo",0) FROM "abc"', str(q)) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/test_groupby_modifiers.py b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/test_groupby_modifiers.py new file mode 100644 index 0000000000000000000000000000000000000000..978834c2409f4b4800fedb9b1bb2538a31d0f31c --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/test_groupby_modifiers.py @@ -0,0 +1,168 @@ +import unittest + +from pypika import Query, Rollup, RollupException, Table, functions as fn + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + + +class RollupTests(unittest.TestCase): + table = Table("abc") + + def test_mysql_one_groupby(self): + q = ( + Query.from_(self.table) + .select(self.table.foo, fn.Sum(self.table.bar)) + .rollup(self.table.foo, vendor="mysql") + ) + + self.assertEqual('SELECT "foo",SUM("bar") FROM "abc" GROUP BY "foo" WITH ROLLUP', str(q)) + + def test_mysql_rollup_two_groupbys(self): + q = ( + Query.from_(self.table) + .select(self.table.foo, self.table.fiz, fn.Sum(self.table.bar)) + .rollup(self.table.foo, self.table.fiz, vendor="mysql") + ) + + self.assertEqual( + 'SELECT "foo","fiz",SUM("bar") FROM "abc" GROUP BY "foo","fiz" WITH ROLLUP', + str(q), + ) + + def test_no_rollup_before_groupby(self): + with self.assertRaises(RollupException): + Query.from_(self.table).select(self.table.foo, fn.Sum(self.table.bar)).rollup(vendor="mysql") + + def test_no_rollup_after_rollup_mysql(self): + with self.assertRaises(AttributeError): + Query.from_(self.table).select(self.table.foo, self.table.fiz, fn.Sum(self.table.bar)).rollup( + self.table.foo, vendor="mysql" + ).rollup(self.table.fiz, vendor="mysql") + + def test_verticaoracle_func_one_groupby(self): + q = Query.from_(self.table).select(self.table.foo, fn.Sum(self.table.bar)).groupby(Rollup(self.table.foo)) + + self.assertEqual('SELECT "foo",SUM("bar") FROM "abc" GROUP BY ROLLUP("foo")', str(q)) + + def test_verticaoracle_func_two_groupbys(self): + q = ( + Query.from_(self.table) + .select(self.table.foo, self.table.fiz, fn.Sum(self.table.bar)) + .groupby( + Rollup( + self.table.foo, + self.table.fiz, + ) + ) + ) + + self.assertEqual( + 'SELECT "foo","fiz",SUM("bar") FROM "abc" GROUP BY ROLLUP("foo","fiz")', + str(q), + ) + + def test_verticaoracle_func_partial(self): + q = ( + Query.from_(self.table) + .select(self.table.foo, self.table.fiz, self.table.buz, fn.Sum(self.table.bar)) + .groupby( + Rollup( + self.table.foo, + self.table.fiz, + ), + self.table.buz, + ) + ) + + self.assertEqual( + 'SELECT "foo","fiz","buz",SUM("bar") FROM "abc" GROUP BY ROLLUP("foo","fiz"),"buz"', + str(q), + ) + + def test_verticaoracle_from_groupbys(self): + q = Query.from_(self.table).select(self.table.foo, fn.Sum(self.table.bar)).rollup(self.table.foo) + + self.assertEqual('SELECT "foo",SUM("bar") FROM "abc" GROUP BY ROLLUP("foo")', str(q)) + + def test_verticaoracle_from_two_groupbys(self): + q = ( + Query.from_(self.table) + .select(self.table.foo, self.table.fiz, fn.Sum(self.table.bar)) + .rollup( + self.table.foo, + self.table.fiz, + ) + ) + + self.assertEqual( + 'SELECT "foo","fiz",SUM("bar") FROM "abc" GROUP BY ROLLUP("foo","fiz")', + str(q), + ) + + def test_verticaoracle_from_parameters(self): + q = ( + Query.from_(self.table) + .select(self.table.foo, self.table.fiz, fn.Sum(self.table.bar)) + .groupby( + self.table.foo, + ) + .rollup( + self.table.fiz, + ) + ) + + self.assertEqual( + 'SELECT "foo","fiz",SUM("bar") FROM "abc" GROUP BY "foo",ROLLUP("fiz")', + str(q), + ) + + def test_verticaoracle_multiple_rollups(self): + q = ( + Query.from_(self.table) + .select(self.table.foo, self.table.fiz, fn.Sum(self.table.bar)) + .rollup( + self.table.foo, + ) + .rollup( + self.table.fiz, + ) + ) + + self.assertEqual( + 'SELECT "foo","fiz",SUM("bar") FROM "abc" GROUP BY ROLLUP("foo","fiz")', + str(q), + ) + + def test_verticaoracle_rollups_with_parity(self): + q = ( + Query.from_(self.table) + .select( + self.table.buz, + ) + .rollup( + [self.table.foo, self.table.bar], + self.table.fiz, + ) + ) + + self.assertEqual('SELECT "buz" FROM "abc" GROUP BY ROLLUP(("foo","bar"),"fiz")', str(q)) + + def test_verticaoracle_rollups_with_multiple_rollups_and_parity(self): + q = ( + Query.from_(self.table) + .select( + self.table.buz, + ) + .rollup( + [self.table.foo, self.table.bar], + ) + .rollup( + [self.table.fiz, self.table.buz], + ) + ) + + self.assertEqual( + 'SELECT "buz" FROM "abc" GROUP BY ROLLUP(("foo","bar"),("fiz","buz"))', + str(q), + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/test_immutability.py b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/test_immutability.py new file mode 100644 index 0000000000000000000000000000000000000000..ee539bfa1e9c4509b929e7a86a03f098dd923515 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/test_immutability.py @@ -0,0 +1,99 @@ +import unittest + +from pypika import ( + AliasedQuery, + Query, + Tables, +) + + +class ImmutabilityTests(unittest.TestCase): + table_a, table_b, table_c = Tables("a", "b", "c") + + def test_select_returns_new_query_instance(self): + query_a = Query.from_(self.table_a).select(self.table_a.foo) + query_b = query_a.select(self.table_a.bar) + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_groupby_returns_new_query_instance(self): + query_a = Query.from_(self.table_a).select(self.table_a.foo).groupby(self.table_a.foo) + query_b = query_a.groupby(self.table_a.bar) + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_orderby_return_new_query_instance(self): + query_a = Query.from_(self.table_a).select(self.table_a.foo).orderby(self.table_a.foo) + query_b = query_a.orderby(self.table_a.bar) + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_join_return_new_query_instance(self): + base = Query.from_(self.table_a).select(self.table_a.foo) + query_a = base.join(self.table_b).on(self.table_a.foo == self.table_b.bar).select(self.table_b.bar) + query_b = query_a.join(self.table_c).on(self.table_a.foo == self.table_c.baz).select(self.table_c.baz) + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_use_index_return_new_query_instance(self): + query_a = Query.from_(self.table_a).select(self.table_a.foo).use_index('idx1') + query_b = query_a.use_index('idx2') + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_force_index_return_new_query_instance(self): + query_a = Query.from_(self.table_a).select(self.table_a.foo).force_index('idx1') + query_b = query_a.force_index('idx2') + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_with_return_new_query_instance(self): + alias_1 = Query.from_(self.table_a).select(self.table_a.foo) + alias_2 = Query.from_(self.table_b).select(self.table_b.bar) + query_a = Query.from_(AliasedQuery('a1')).select('foo').with_(alias_1, 'a1') + query_b = query_a.with_(alias_2, 'a2') + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_insert_into_return_new_query_instance(self): + query_a = Query.into(self.table_a).insert('foo1') + query_b = query_a.insert('foo2') + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_replace_into_return_new_query_instance(self): + query_a = Query.into(self.table_a).replace('foo') + query_b = query_a.replace('bar') + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_update_set_return_new_query_instance(self): + query_a = Query.update(self.table_a).set(self.table_a.foo, 'foo') + query_b = query_a.set(self.table_a.bar, 'bar') + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_queries_after_join(self): + query1 = Query.from_(self.table_a).select(self.table_a.foo) + query2 = query1.join(self.table_b).on(self.table_a.foo == self.table_b.bar).select(self.table_b.buz) + + self.assertEqual('SELECT "foo" FROM "a"', str(query1)) + self.assertEqual( + 'SELECT "a"."foo","b"."buz" FROM "a" JOIN "b" ON "a"."foo"="b"."bar"', + str(query2), + ) + + def test_immutable_kwarg_on_query_builder_disables_immutability(self): + query0 = Query.from_(self.table_a, immutable=False) + query1 = query0.select(self.table_a.foo) + self.assertIs(query0, query1) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/test_inserts.py b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/test_inserts.py new file mode 100644 index 0000000000000000000000000000000000000000..f86efd7a76dc498a69b61c6353951695f1933a61 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/test_inserts.py @@ -0,0 +1,885 @@ +import unittest + +from pypika import ( + AliasedQuery, + Case, + Field as F, + MySQLQuery, + PostgreSQLQuery, + Query, + Table, + Tables, + functions as fn, +) +from pypika.functions import ( + Avg, + Cast, +) +from pypika.terms import Values +from pypika.utils import QueryException + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + + +class InsertIntoTests(unittest.TestCase): + table_abc = Table("abc") + + def test_insert_one_column(self): + query = Query.into(self.table_abc).insert(1) + + self.assertEqual('INSERT INTO "abc" VALUES (1)', str(query)) + + def test_insert_one_column_single_element_array(self): + query = Query.into(self.table_abc).insert((1,)) + + self.assertEqual('INSERT INTO "abc" VALUES (1)', str(query)) + + def test_insert_one_column_multi_element_array(self): + query = Query.into(self.table_abc).insert((1,), (2,)) + + self.assertEqual('INSERT INTO "abc" VALUES (1),(2)', str(query)) + + def test_insert_single_row_with_array_value(self): + query = Query.into(self.table_abc).insert(1, ["a", "b", "c"]) + + self.assertEqual("INSERT INTO \"abc\" VALUES (1,['a','b','c'])", str(query)) + + def test_insert_multiple_rows_with_array_value(self): + query = Query.into(self.table_abc).insert( + (1, ["a", "b", "c"]), + (2, ["c", "d", "e"]), + ) + + self.assertEqual( + 'INSERT INTO "abc" ' "VALUES (1,['a','b','c']),(2,['c','d','e'])", + str(query), + ) + + def test_insert_all_columns(self): + query = Query.into(self.table_abc).insert(1, "a", True) + + self.assertEqual("INSERT INTO \"abc\" VALUES (1,'a',true)", str(query)) + + def test_insert_all_columns_single_element(self): + query = Query.into(self.table_abc).insert((1, "a", True)) + + self.assertEqual("INSERT INTO \"abc\" VALUES (1,'a',true)", str(query)) + + def test_insert_all_columns_multi_rows(self): + query = Query.into(self.table_abc).insert((1, "a", True), (2, "b", False)) + + self.assertEqual("INSERT INTO \"abc\" VALUES (1,'a',true),(2,'b',false)", str(query)) + + def test_insert_all_columns_multi_rows_chained(self): + query = Query.into(self.table_abc).insert(1, "a", True).insert(2, "b", False) + + self.assertEqual("INSERT INTO \"abc\" VALUES (1,'a',true),(2,'b',false)", str(query)) + + def test_insert_all_columns_multi_rows_chained_mixed(self): + query = Query.into(self.table_abc).insert((1, "a", True), (2, "b", False)).insert(3, "c", True) + + self.assertEqual( + 'INSERT INTO "abc" VALUES ' "(1,'a',true),(2,'b',false)," "(3,'c',true)", + str(query), + ) + + def test_insert_all_columns_multi_rows_chained_multiple_rows(self): + query = ( + Query.into(self.table_abc).insert((1, "a", True), (2, "b", False)).insert((3, "c", True), (4, "d", False)) + ) + + self.assertEqual( + 'INSERT INTO "abc" VALUES ' "(1,'a',true),(2,'b',false)," "(3,'c',true),(4,'d',false)", + str(query), + ) + + def test_insert_selected_columns(self): + query = ( + Query.into(self.table_abc) + .columns(self.table_abc.foo, self.table_abc.bar, self.table_abc.buz) + .insert(1, "a", True) + ) + + self.assertEqual('INSERT INTO "abc" ("foo","bar","buz") VALUES (1,\'a\',true)', str(query)) + + def test_insert_empty_columns(self): + query = Query.into(self.table_abc).columns().insert(1, "a", True) + + self.assertEqual('INSERT INTO "abc" VALUES (1,\'a\',true)', str(query)) + + def test_insert_selected_columns_type_list(self): + query = ( + Query.into(self.table_abc) + .columns([self.table_abc.foo, self.table_abc.bar, self.table_abc.buz]) + .insert(1, "a", True) + ) + + self.assertEqual('INSERT INTO "abc" ("foo","bar","buz") VALUES (1,\'a\',true)', str(query)) + + def test_insert_empty_columns_type_list(self): + query = Query.into(self.table_abc).columns([]).insert(1, "a", True) + + self.assertEqual('INSERT INTO "abc" VALUES (1,\'a\',true)', str(query)) + + def test_insert_selected_columns_type_tuple(self): + query = ( + Query.into(self.table_abc) + .columns((self.table_abc.foo, self.table_abc.bar, self.table_abc.buz)) + .insert(1, "a", True) + ) + + self.assertEqual('INSERT INTO "abc" ("foo","bar","buz") VALUES (1,\'a\',true)', str(query)) + + def test_insert_empty_columns_type_tuple(self): + query = Query.into(self.table_abc).columns(()).insert(1, "a", True) + + self.assertEqual('INSERT INTO "abc" VALUES (1,\'a\',true)', str(query)) + + def test_insert_none_skipped(self): + query = Query.into(self.table_abc).insert() + + self.assertEqual("", str(query)) + + def test_insert_ignore(self): + query = Query.into(self.table_abc).insert(1).ignore() + + self.assertEqual('INSERT IGNORE INTO "abc" VALUES (1)', str(query)) + + def test_insert_null(self): + query = Query.into(self.table_abc).insert(None) + + self.assertEqual('INSERT INTO "abc" VALUES (NULL)', str(query)) + + def test_insert_column_using_table_alias(self): + q = self.table_abc.insert(1) + self.assertEqual('INSERT INTO "abc" VALUES (1)', str(q)) + + def test_insert_column_using_alias_with_chain(self): + q = self.table_abc.insert(1, "a", True).insert(2, "b", False) + self.assertEqual("INSERT INTO \"abc\" VALUES (1,'a',true),(2,'b',false)", str(q)) + + def test_insert_with_statement(self): + sub_query = Query().select(self.table_abc.id).from_(self.table_abc) + aliased = AliasedQuery('sub_qs') + + q = Query().with_(sub_query, 'sub_qs').into(self.table_abc).select(aliased.id).from_(aliased) + self.assertEqual( + 'WITH sub_qs AS (SELECT "id" FROM "abc") INSERT INTO "abc" SELECT "sub_qs"."id" FROM sub_qs', str(q) + ) + + +class PostgresInsertIntoOnConflictTests(unittest.TestCase): + table_abc = Table("abc") + + def test_insert_on_conflict_do_nothing_field(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).on_conflict(self.table_abc.id).do_nothing() + + self.assertEqual('INSERT INTO "abc" VALUES (1) ON CONFLICT ("id") DO NOTHING', str(query)) + + def test_insert_on_conflict_do_nothing_multiple_fields(self): + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1) + .on_conflict(self.table_abc.id, self.table_abc.sub_id) + .do_nothing() + ) + + self.assertEqual('INSERT INTO "abc" VALUES (1) ON CONFLICT ("id", "sub_id") DO NOTHING', str(query)) + + def test_insert_on_conflict_do_nothing_field_str(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).on_conflict("id").do_nothing() + + self.assertEqual('INSERT INTO "abc" VALUES (1) ON CONFLICT ("id") DO NOTHING', str(query)) + + def test_insert_on_conflict_do_nothing_multiple_fields_str(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).on_conflict("id", "sub_id").do_nothing() + + self.assertEqual('INSERT INTO "abc" VALUES (1) ON CONFLICT ("id", "sub_id") DO NOTHING', str(query)) + + def test_insert_on_conflict_do_nothing_mixed_fields(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).on_conflict("id", self.table_abc.sub_id).do_nothing() + + self.assertEqual('INSERT INTO "abc" VALUES (1) ON CONFLICT ("id", "sub_id") DO NOTHING', str(query)) + + def test_insert_on_conflict_do_update_field(self): + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict(self.table_abc.id) + .do_update(self.table_abc.name, "m") + ) + + self.assertEqual( + "INSERT INTO \"abc\" VALUES (1,'m') ON CONFLICT (\"id\") DO UPDATE SET \"name\"='m'", + str(query), + ) + + def test_insert_on_conflict_do_update_multiple_fields(self): + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict(self.table_abc.id, self.table_abc.sub_id) + .do_update(self.table_abc.name, "m") + ) + + self.assertEqual( + "INSERT INTO \"abc\" VALUES (1,'m') ON CONFLICT (\"id\", \"sub_id\") DO UPDATE SET \"name\"='m'", + str(query), + ) + + def test_insert_on_conflict_do_update_field_str(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1, "m").on_conflict("id").do_update("name", "m") + + self.assertEqual( + "INSERT INTO \"abc\" VALUES (1,'m') ON CONFLICT (\"id\") DO UPDATE SET \"name\"='m'", + str(query), + ) + + def test_insert_on_conflict_do_update_multiple_fields_str(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1, "m").on_conflict("id", "sub_id").do_update("name", "m") + + self.assertEqual( + "INSERT INTO \"abc\" VALUES (1,'m') ON CONFLICT (\"id\", \"sub_id\") DO UPDATE SET \"name\"='m'", + str(query), + ) + + def test_insert_on_conflict_do_update_multiple_mixed_fields(self): + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict("id", self.table_abc.sub_id) + .do_update("name", "m") + ) + + self.assertEqual( + "INSERT INTO \"abc\" VALUES (1,'m') ON CONFLICT (\"id\", \"sub_id\") DO UPDATE SET \"name\"='m'", + str(query), + ) + + def test_insert_on_conflict_no_handler(self): + with self.assertRaises(QueryException): + query = str(PostgreSQLQuery.into(self.table_abc).insert(1).on_conflict(self.table_abc.id)) + + def test_insert_on_conflict_two_handlers_do_nothing(self): + with self.assertRaises(QueryException): + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1) + .on_conflict("id") + .do_nothing() + .do_update(self.table_abc.name, "m") + ) + + def test_insert_on_conflict_two_handlers_do_update(self): + with self.assertRaises(QueryException): + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1) + .on_conflict(self.table_abc.id) + .do_update(self.table_abc.name, "m") + .do_nothing() + ) + + def test_non_insert_on_conflict_do_nothing(self): + with self.assertRaises(QueryException): + query = PostgreSQLQuery.update(self.table_abc).set("foo", "bar").on_conflict("id").do_nothing() + + def test_non_insert_on_conflict_do_update(self): + with self.assertRaises(QueryException): + query = ( + PostgreSQLQuery.update(self.table_abc).set("foo", "bar").on_conflict("id").do_update(["name"], ["m"]) + ) + + def test_insert_on_fieldless_conflict_do_nothing(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).on_conflict(None).do_nothing() + + self.assertEqual('INSERT INTO "abc" VALUES (1) ON CONFLICT DO NOTHING', str(query)) + + def test_insert_on_fieldless_conflict_do_update_field(self): + with self.assertRaises(QueryException): + query = str( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict(None) + .do_update(self.table_abc.name, "m") + ) + + def test_on_conflict_from_subquery(self): + table_bcd = Table('bcd') + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(self.table_abc.fname, self.table_abc.lname) + .select(table_bcd.fname, table_bcd.lname) + .from_(table_bcd) + .on_conflict(self.table_abc.id, self.table_abc.sub_id) + .do_update(self.table_abc.fname, 1) + .do_update(self.table_abc.lname, table_bcd.lname) + .do_update( + self.table_abc.cname, + Case().when(self.table_abc.cname.eq('cname'), 'new_name').else_(self.table_abc.cname), + ) + ) + + self.assertEqual( + 'INSERT INTO "abc" VALUES ("fname","lname") ' + 'ON CONFLICT ("id", "sub_id") ' + 'DO UPDATE SET "fname"=1,"lname"="bcd"."lname",' + '"cname"=CASE WHEN "abc"."cname"=\'cname\' THEN \'new_name\' ELSE "abc"."cname" END', + str(query), + ) + + def test_on_conflict_where_empty_conflict_fields_do_nothing(self): + with self.assertRaises(QueryException): + ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict() + .where(self.table_abc.abc.eq(0)) + .where(self.table_abc.cde.eq(0)) + .do_nothing() + ) + + def test_on_conflict_where_conflict_fields_do_nothing(self): + qs = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict('id') + .where(self.table_abc.abc.eq(0)) + .where(self.table_abc.cde.eq(0)) + .do_nothing() + ) + self.assertEqual( + '''INSERT INTO "abc" VALUES (1,'m') ON CONFLICT ("id") WHERE "abc"=0 AND "cde"=0 DO NOTHING''', str(qs) + ) + + def test_on_conflict_where_empty_conflict_fields_do_update(self): + with self.assertRaises(QueryException): + ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict() + .where(self.table_abc.abc.eq(0)) + .where(self.table_abc.cde.eq(0)) + .do_update('field', 'val') + ) + + def test_on_conflict_where_conflict_fields_do_update(self): + qs = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict('id') + .where(self.table_abc.abc.eq(0)) + .where(self.table_abc.cde.eq(0)) + .do_update('field', 'val') + ) + self.assertEqual( + '''INSERT INTO "abc" VALUES (1,'m') ON CONFLICT ("id") WHERE "abc"=0 AND "cde"=0 ''' + '''DO UPDATE SET "field"='val\'''', + str(qs), + ) + + def test_where_and_on_conflict_where(self): + table_bcd = Table('bcd') + + qs = ( + PostgreSQLQuery.into(self.table_abc) + .select(table_bcd.abc) + .from_(table_bcd) + .where(table_bcd.abc.eq('1')) + .on_conflict('id') + .where(self.table_abc.abc.eq(0)) + .where(self.table_abc.cde.eq(0)) + .do_update('field', 'val') + ) + + self.assertEqual( + 'INSERT INTO "abc" SELECT "abc" FROM "bcd" WHERE "abc"=\'1\' ' + 'ON CONFLICT ("id") WHERE "abc"=0 AND "cde"=0 DO UPDATE SET "field"=\'val\'', + str(qs), + ) + + def test_on_conflict_do_nothing_where(self): + with self.assertRaises(QueryException): + ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict() + .do_nothing() + .where(self.table_abc.abc.eq(1)) + ) + + def test_empty_on_conflict_do_update_where(self): + with self.assertRaises(QueryException): + ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict() + .do_update('abc', 1) + .where(self.table_abc.abc.eq(1)) + ) + + def test_on_conflict_do_update_where(self): + qs = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict("id") + .do_update('abc', 1) + .where(self.table_abc.abc.eq(1)) + ) + self.assertEqual( + 'INSERT INTO "abc" VALUES (1,\'m\') ON CONFLICT ("id") DO UPDATE SET "abc"=1 WHERE "abc"."abc"=1', str(qs) + ) + + def test_on_conflict_do_update_with_excluded_where(self): + qs = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict("id") + .do_update('abc') + .where(self.table_abc.abc.eq(1)) + ) + self.assertEqual( + 'INSERT INTO "abc" VALUES (1,\'m\') ON CONFLICT ("id") DO UPDATE SET "abc"=EXCLUDED."abc" WHERE ' + '"abc"."abc"=1', + str(qs), + ) + + def test_on_conflict_where_complex(self): + table_bcd = Table('bcd') + + qs = ( + PostgreSQLQuery.into(self.table_abc) + .select(table_bcd.abc) + .from_(table_bcd) + .where(table_bcd.abc.eq('1')) + .on_conflict('id') + .where(self.table_abc.abc.eq(0)) + .where(self.table_abc.cde.eq(0)) + .do_update('field', 'val') + .where(self.table_abc.id.eq(2)) + .where(self.table_abc.sub_id.eq(3)) + ) + self.assertEqual( + 'INSERT INTO "abc" SELECT "abc" FROM "bcd" WHERE "abc"=\'1\' ' + 'ON CONFLICT ("id") WHERE "abc"=0 AND "cde"=0 ' + 'DO UPDATE SET "field"=\'val\' WHERE "abc"."id"=2 AND "abc"."sub_id"=3', + str(qs), + ) + + +class PostgresInsertIntoReturningTests(unittest.TestCase): + table_abc = Table("abc") + + def test_insert_returning_one_field(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).returning(self.table_abc.id) + + self.assertEqual('INSERT INTO "abc" VALUES (1) RETURNING "id"', str(query)) + + def test_insert_returning_one_field_str(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).returning("id") + + self.assertEqual('INSERT INTO "abc" VALUES (1) RETURNING "id"', str(query)) + + def test_insert_returning_all_fields(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).returning(self.table_abc.star) + + self.assertEqual('INSERT INTO "abc" VALUES (1) RETURNING *', str(query)) + + def test_insert_returning_all_fields_and_arithmetics(self): + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1) + .returning(self.table_abc.star, self.table_abc.f1 + self.table_abc.f2) + ) + + self.assertEqual('INSERT INTO "abc" VALUES (1) RETURNING *,"f1"+"f2"', str(query)) + + def test_insert_all_columns_multi_rows_chained_returning_star(self): + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "a", True) + .insert(2, "b", False) + .returning(self.table_abc.star) + ) + + self.assertEqual( + "INSERT INTO \"abc\" VALUES (1,'a',true),(2,'b',false) RETURNING *", + str(query), + ) + + def test_insert_all_columns_multi_rows_chained_returning_star_and_id(self): + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "a", True) + .insert(2, "b", False) + .returning( + self.table_abc.name, + self.table_abc.star, + self.table_abc.id, + ) + ) + + self.assertEqual( + "INSERT INTO \"abc\" VALUES (1,'a',true),(2,'b',false) RETURNING *", + str(query), + ) + + def test_insert_all_columns_multi_rows_chained_returning_star_str(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1, "a", True).insert(2, "b", False).returning("*") + + self.assertEqual( + "INSERT INTO \"abc\" VALUES (1,'a',true),(2,'b',false) RETURNING *", + str(query), + ) + + def test_insert_all_columns_single_element_arrays(self): + query = PostgreSQLQuery.into(self.table_abc).insert((1, "a", True)).returning(self.table_abc.star) + + self.assertEqual("INSERT INTO \"abc\" VALUES (1,'a',true) RETURNING *", str(query)) + + def test_insert_returning_null(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).returning(None) + + self.assertEqual('INSERT INTO "abc" VALUES (1) RETURNING NULL', str(query)) + + def test_insert_returning_tuple(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).returning((1, 2, 3)) + + self.assertEqual('INSERT INTO "abc" VALUES (1) RETURNING (1,2,3)', str(query)) + + def test_insert_returning_arithmetics(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).returning(self.table_abc.f1 + self.table_abc.f2) + + self.assertEqual('INSERT INTO "abc" VALUES (1) RETURNING "f1"+"f2"', str(query)) + + def test_insert_returning_functions(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).returning(Cast(self.table_abc.f1, "int")) + + self.assertEqual('INSERT INTO "abc" VALUES (1) RETURNING CAST("f1" AS INT)', str(query)) + + def test_insert_returning_aggregate(self): + with self.assertRaises(QueryException): + PostgreSQLQuery.into(self.table_abc).insert(1).returning(Avg(self.table_abc.views)) + + def test_insert_returning_from_other_table(self): + table_cba = Table("cba") + with self.assertRaises(QueryException): + PostgreSQLQuery.into(self.table_abc).insert(1).returning(table_cba.id) + + +class InsertIntoOnDuplicateTests(unittest.TestCase): + table_abc = Table("abc") + + def test_insert_one_column(self): + query = ( + MySQLQuery.into(self.table_abc).insert(1).on_duplicate_key_update(self.table_abc.foo, self.table_abc.foo) + ) + self.assertEqual( + "INSERT INTO `abc` VALUES (1) ON DUPLICATE KEY UPDATE `foo`=`foo`", + str(query), + ) + + def test_insert_one_column_using_values(self): + query = ( + MySQLQuery.into(self.table_abc) + .insert(1) + .on_duplicate_key_update(self.table_abc.foo, Values(self.table_abc.foo)) + ) + self.assertEqual( + "INSERT INTO `abc` VALUES (1) ON DUPLICATE KEY UPDATE `foo`=VALUES(`foo`)", + str(query), + ) + + def test_insert_one_column_single_element_array(self): + query = ( + MySQLQuery.into(self.table_abc).insert((1,)).on_duplicate_key_update(self.table_abc.foo, self.table_abc.foo) + ) + + self.assertEqual( + "INSERT INTO `abc` VALUES (1) ON DUPLICATE KEY UPDATE `foo`=`foo`", + str(query), + ) + + def test_insert_one_column_multi_element_array(self): + query = ( + MySQLQuery.into(self.table_abc) + .insert((1,), (2,)) + .on_duplicate_key_update(self.table_abc.foo, self.table_abc.foo) + ) + + self.assertEqual( + "INSERT INTO `abc` VALUES (1),(2) ON DUPLICATE KEY UPDATE `foo`=`foo`", + str(query), + ) + + def test_insert_multiple_columns_on_duplicate_update_one_with_same_value(self): + query = ( + MySQLQuery.into(self.table_abc) + .insert(1, "a") + .on_duplicate_key_update(self.table_abc.bar, Values(self.table_abc.bar)) + ) + + self.assertEqual( + "INSERT INTO `abc` VALUES (1,'a') ON DUPLICATE KEY UPDATE `bar`=VALUES(`bar`)", + str(query), + ) + + def test_insert_multiple_columns_on_duplicate_update_one_with_different_value(self): + query = MySQLQuery.into(self.table_abc).insert(1, "a").on_duplicate_key_update(self.table_abc.bar, "b") + + self.assertEqual( + "INSERT INTO `abc` VALUES (1,'a') ON DUPLICATE KEY UPDATE `bar`='b'", + str(query), + ) + + def test_insert_multiple_columns_on_duplicate_update_one_with_expression(self): + query = ( + MySQLQuery.into(self.table_abc).insert(1, 2).on_duplicate_key_update(self.table_abc.bar, 4 + F("bar")) + ) # todo sql expression? not python + + self.assertEqual( + "INSERT INTO `abc` VALUES (1,2) ON DUPLICATE KEY UPDATE `bar`=4+`bar`", + str(query), + ) + + def test_insert_multiple_columns_on_duplicate_update_one_with_expression_using_original_field_value( + self, + ): + query = ( + MySQLQuery.into(self.table_abc) + .insert(1, "a") + .on_duplicate_key_update(self.table_abc.bar, fn.Concat(self.table_abc.bar, "update")) + ) + + self.assertEqual( + "INSERT INTO `abc` VALUES (1,'a') ON DUPLICATE KEY UPDATE `bar`=CONCAT(`bar`,'update')", + str(query), + ) + + def test_insert_multiple_columns_on_duplicate_update_one_with_expression_using_values( + self, + ): + query = ( + MySQLQuery.into(self.table_abc) + .insert(1, "a") + .on_duplicate_key_update(self.table_abc.bar, fn.Concat(Values(self.table_abc.bar), "update")) + ) + + self.assertEqual( + "INSERT INTO `abc` VALUES (1,'a') ON DUPLICATE KEY UPDATE `bar`=CONCAT(VALUES(`bar`),'update')", + str(query), + ) + + def test_insert_multiple_columns_on_duplicate_update_multiple(self): + query = ( + MySQLQuery.into(self.table_abc) + .insert(1, "a", "b") + .on_duplicate_key_update(self.table_abc.bar, "b") + .on_duplicate_key_update(self.table_abc.baz, "c") + ) + + self.assertEqual( + "INSERT INTO `abc` VALUES (1,'a','b') ON DUPLICATE KEY UPDATE `bar`='b',`baz`='c'", + str(query), + ) + + def test_insert_multi_rows_chained_mixed_on_duplicate_update_multiple(self): + query = ( + MySQLQuery.into(self.table_abc) + .insert((1, "a", True), (2, "b", False)) + .insert(3, "c", True) + .on_duplicate_key_update(self.table_abc.foo, self.table_abc.foo) + .on_duplicate_key_update(self.table_abc.bar, Values(self.table_abc.bar)) + ) + + self.assertEqual( + "INSERT INTO `abc` VALUES (1,'a',true),(2,'b',false),(3,'c',true) " + "ON DUPLICATE KEY UPDATE `foo`=`foo`,`bar`=VALUES(`bar`)", + str(query), + ) + + def test_insert_selected_columns_on_duplicate_update_one(self): + query = ( + MySQLQuery.into(self.table_abc) + .columns(self.table_abc.foo, self.table_abc.bar, self.table_abc.baz) + .insert(1, "a", True) + .on_duplicate_key_update(self.table_abc.baz, False) + ) + + self.assertEqual( + "INSERT INTO `abc` (`foo`,`bar`,`baz`) VALUES (1,'a',true) ON DUPLICATE KEY UPDATE `baz`=false", + str(query), + ) + + def test_insert_selected_columns_on_duplicate_update_multiple(self): + query = ( + MySQLQuery.into(self.table_abc) + .columns(self.table_abc.foo, self.table_abc.bar, self.table_abc.baz) + .insert(1, "a", True) + .on_duplicate_key_update(self.table_abc.baz, False) + .on_duplicate_key_update(self.table_abc.bar, Values(self.table_abc.bar)) + ) + + self.assertEqual( + "INSERT INTO `abc` (`foo`,`bar`,`baz`) VALUES (1,'a',true) " + "ON DUPLICATE KEY UPDATE `baz`=false,`bar`=VALUES(`bar`)", + str(query), + ) + + def test_insert_none_skipped(self): + query = MySQLQuery.into(self.table_abc).insert().on_duplicate_key_update(self.table_abc.baz, False) + + self.assertEqual("", str(query)) + + def test_insert_ignore(self): + query = MySQLQuery.into(self.table_abc).insert(1).ignore().on_duplicate_key_update(self.table_abc.baz, False) + + self.assertEqual( + "INSERT IGNORE INTO `abc` VALUES (1) ON DUPLICATE KEY UPDATE `baz`=false", + str(query), + ) + + +class InsertSelectFromTests(unittest.TestCase): + table_abc, table_efg, table_hij = Tables("abc", "efg", "hij") + + def test_insert_star(self): + query = Query.into(self.table_abc).from_(self.table_efg).select("*") + + self.assertEqual('INSERT INTO "abc" SELECT * FROM "efg"', str(query)) + + def test_insert_ignore_star(self): + query = Query.into(self.table_abc).from_(self.table_efg).select("*").ignore() + + self.assertEqual('INSERT IGNORE INTO "abc" SELECT * FROM "efg"', str(query)) + + def test_insert_from_columns(self): + query = ( + Query.into(self.table_abc) + .from_(self.table_efg) + .select(self.table_efg.fiz, self.table_efg.buz, self.table_efg.baz) + ) + + self.assertEqual('INSERT INTO "abc" ' 'SELECT "fiz","buz","baz" FROM "efg"', str(query)) + + def test_insert_columns_from_star(self): + query = ( + Query.into(self.table_abc) + .columns( + self.table_abc.foo, + self.table_abc.bar, + self.table_abc.buz, + ) + .from_(self.table_efg) + .select("*") + ) + + self.assertEqual('INSERT INTO "abc" ("foo","bar","buz") ' 'SELECT * FROM "efg"', str(query)) + + def test_insert_columns_from_columns(self): + query = ( + Query.into(self.table_abc) + .columns(self.table_abc.foo, self.table_abc.bar, self.table_abc.buz) + .from_(self.table_efg) + .select(self.table_efg.fiz, self.table_efg.buz, self.table_efg.baz) + ) + + self.assertEqual( + 'INSERT INTO "abc" ("foo","bar","buz") ' 'SELECT "fiz","buz","baz" FROM "efg"', + str(query), + ) + + def test_insert_columns_from_columns_with_join(self): + query = ( + Query.into(self.table_abc) + .columns( + self.table_abc.c1, + self.table_abc.c2, + self.table_abc.c3, + self.table_abc.c4, + ) + .from_(self.table_efg) + .select(self.table_efg.foo, self.table_efg.bar) + .join(self.table_hij) + .on(self.table_efg.id == self.table_hij.abc_id) + .select(self.table_hij.fiz, self.table_hij.buz) + ) + + self.assertEqual( + 'INSERT INTO "abc" ("c1","c2","c3","c4") ' + 'SELECT "efg"."foo","efg"."bar","hij"."fiz","hij"."buz" FROM "efg" ' + 'JOIN "hij" ON "efg"."id"="hij"."abc_id"', + str(query), + ) + + +class InsertSubqueryTests(unittest.TestCase): + def test_insert_subquery_wrapped_in_brackets(self): + purchase_order_item, part = Tables("purchase_order_item", "part") + + q = ( + Query.into(purchase_order_item) + .columns(purchase_order_item.id_part, purchase_order_item.id_customer) + .insert( + Query.from_(part).select(part.part_id).where(part.part_number == "FOOBAR"), + 12345, + ) + ) + + self.assertEqual( + 'INSERT INTO "purchase_order_item" ' + '("id_part","id_customer") ' + "VALUES " + '((SELECT "part_id" FROM "part" WHERE "part_number"=\'FOOBAR\'),12345)', + str(q), + ) + + +class SelectIntoTests(unittest.TestCase): + table_abc, table_efg, table_hij = Tables("abc", "efg", "hij") + + def test_select_star_into(self): + query = Query.from_(self.table_abc).select("*").into(self.table_efg) + + self.assertEqual('SELECT * INTO "efg" FROM "abc"', str(query)) + + def test_select_columns_into(self): + query = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, self.table_abc.bar, self.table_abc.buz) + .into(self.table_efg) + ) + + self.assertEqual('SELECT "foo","bar","buz" INTO "efg" FROM "abc"', str(query)) + + def test_select_columns_into_with_join(self): + query = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, self.table_abc.bar) + .join(self.table_hij) + .on(self.table_abc.id == self.table_hij.abc_id) + .select(self.table_hij.fiz, self.table_hij.buz) + .into(self.table_efg) + ) + + self.assertEqual( + 'SELECT "abc"."foo","abc"."bar","hij"."fiz","hij"."buz" ' + 'INTO "efg" FROM "abc" ' + 'JOIN "hij" ON "abc"."id"="hij"."abc_id"', + str(query), + ) + + +class ReplaceTests(unittest.TestCase): + table_abc, table_def = Tables("abc", "efg") + + def test_replace_simple(self): + query = Query.into(self.table_abc).replace("v1", "v2", "v3") + expected_output = "REPLACE INTO \"abc\" VALUES ('v1','v2','v3')" + self.assertEqual(str(query), expected_output) + + def test_replace_subquery(self): + query = Query.into(self.table_abc).replace(Query.from_(self.table_def).select("f1", "f2")) + expected_output = 'REPLACE INTO "abc" VALUES ((SELECT "f1","f2" FROM "efg"))' + self.assertEqual(str(query), expected_output) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/test_internals.py b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/test_internals.py new file mode 100644 index 0000000000000000000000000000000000000000..921e381ba8613d4a83cc53bd60d111d9547e2c1f --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/test_internals.py @@ -0,0 +1,35 @@ +import unittest + +from pypika import ( + Case, + Field, + Table, +) +from pypika.terms import Star + + +class TablesTests(unittest.TestCase): + def test__criterion_replace_table_with_value(self): + table = Table("a") + + c = (Field("foo") > 1).replace_table(None, table) + self.assertEqual(c.left, table) + self.assertEqual(c.tables_, {table}) + + def test__case_tables(self): + table = Table("a") + + c = Case().when(table.a == 1, 2 * table.a) + self.assertIsInstance(c.tables_, set) + self.assertSetEqual(c.tables_, {table}) + + def test__star_tables(self): + star = Star() + + self.assertEqual(star.tables_, set()) + + def test__table_star_tables(self): + table = Table("a") + star = Star(table=table) + + self.assertEqual(star.tables_, {table}) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/test_joins.py b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/test_joins.py new file mode 100644 index 0000000000000000000000000000000000000000..03142d583921edbe966e0ae191d254e7b8bf46ba --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/test_joins.py @@ -0,0 +1,1168 @@ +import unittest + +from pypika import ( + Field, + Interval, + JoinException, + JoinType, + MySQLQuery, + Query, + SetOperationException, + Table, + Tables, + functions as fn, + SYSTEM_TIME, +) + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + + +class SelectQueryJoinTests(unittest.TestCase): + table0, table1, hij = Tables("abc", "efg", "hij") + + def test_default_join_type(self): + query = Query.from_(self.table0).join(self.table1).on(self.table0.foo == self.table1.bar).select("*") + + self.assertEqual('SELECT * FROM "abc" JOIN "efg" ON "abc"."foo"="efg"."bar"', str(query)) + + def test_inner_join(self): + expected = 'SELECT * FROM "abc" JOIN "efg" ON "abc"."foo"="efg"."bar"' + + with self.subTest("join with enum"): + query = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.inner) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + self.assertEqual(expected, str(query)) + + with self.subTest("join function"): + query = Query.from_(self.table0).inner_join(self.table1).on(self.table0.foo == self.table1.bar).select("*") + self.assertEqual(expected, str(query)) + + def test_left_join(self): + expected = 'SELECT * FROM "abc" LEFT JOIN "efg" ON "abc"."foo"="efg"."bar"' + + with self.subTest("join with enum"): + query = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.left) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + + self.assertEqual(expected, str(query)) + + with self.subTest("join function"): + query = Query.from_(self.table0).left_join(self.table1).on(self.table0.foo == self.table1.bar).select("*") + self.assertEqual(expected, str(query)) + + def test_right_join(self): + expected = 'SELECT * FROM "abc" RIGHT JOIN "efg" ON "abc"."foo"="efg"."bar"' + + with self.subTest("join with enum"): + query = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.right) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + + self.assertEqual(expected, str(query)) + + with self.subTest("join function"): + query = Query.from_(self.table0).right_join(self.table1).on(self.table0.foo == self.table1.bar).select("*") + self.assertEqual(expected, str(query)) + + def test_hash_join(self): + expected = 'SELECT * FROM "abc" HASH JOIN "efg" ON "abc"."foo"="efg"."bar"' + + with self.subTest("join with enum"): + query = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.hash) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + + self.assertEqual(expected, str(query)) + + with self.subTest("join function"): + query = Query.from_(self.table0).hash_join(self.table1).on(self.table0.foo == self.table1.bar).select("*") + self.assertEqual(expected, str(query)) + + def test_outer_join(self): + expected = 'SELECT * FROM "abc" FULL OUTER JOIN "efg" ON "abc"."foo"="efg"."bar"' + + with self.subTest("join with enum"): + query = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.outer) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + + self.assertEqual(expected, str(query)) + + with self.subTest("join function"): + query = Query.from_(self.table0).outer_join(self.table1).on(self.table0.foo == self.table1.bar).select("*") + self.assertEqual(expected, str(query)) + + def test_cross_join(self): + expected = 'SELECT * FROM "abc" CROSS JOIN "efg" ON "abc"."foo"="efg"."bar"' + + with self.subTest("join with enum"): + query = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.cross) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + + self.assertEqual(expected, str(query)) + + with self.subTest("join function"): + query = Query.from_(self.table0).cross_join(self.table1).on(self.table0.foo == self.table1.bar).select("*") + self.assertEqual(expected, str(query)) + + def test_left_outer_join(self): + expected = 'SELECT * FROM "abc" LEFT OUTER JOIN "efg" ON "abc"."foo"="efg"."bar"' + with self.subTest("join with enum"): + query = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.left_outer) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + + self.assertEqual(expected, str(query)) + + with self.subTest("join function"): + query = ( + Query.from_(self.table0).left_outer_join(self.table1).on(self.table0.foo == self.table1.bar).select("*") + ) + + self.assertEqual(expected, str(query)) + + def test_right_outer_join(self): + expected = 'SELECT * FROM "abc" RIGHT OUTER JOIN "efg" ON "abc"."foo"="efg"."bar"' + with self.subTest("join with enum"): + query = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.right_outer) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + + self.assertEqual(expected, str(query)) + + with self.subTest("join function"): + query = ( + Query.from_(self.table0) + .right_outer_join(self.table1) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + + self.assertEqual(expected, str(query)) + + def test_full_outer_join(self): + expected = 'SELECT * FROM "abc" FULL OUTER JOIN "efg" ON "abc"."foo"="efg"."bar"' + + with self.subTest("join with enum"): + query = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.full_outer) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + + self.assertEqual(expected, str(query)) + + with self.subTest("join function"): + query = ( + Query.from_(self.table0).full_outer_join(self.table1).on(self.table0.foo == self.table1.bar).select("*") + ) + + self.assertEqual(expected, str(query)) + + def test_join_on_field_single(self): + query = Query.from_(self.table0).join(self.table1).on_field("foo").select("*") + self.assertEqual('SELECT * FROM "abc" JOIN "efg" ON "abc"."foo"="efg"."foo"', str(query)) + + def test_join_on_field_multi(self): + query = Query.from_(self.table0).join(self.table1).on_field("foo", "bar").select("*") + self.assertEqual( + 'SELECT * FROM "abc" JOIN "efg" ON "abc"."foo"="efg"."foo" ' 'AND "abc"."bar"="efg"."bar"', + str(query), + ) + + def test_join_on_field_multi_with_extra_join(self): + query = ( + Query.from_(self.table0) + .join(self.hij) + .on_field("buzz") + .join(self.table1) + .on_field("foo", "bar") + .select("*") + ) + + self.assertEqual( + 'SELECT * FROM "abc" JOIN "hij" ON "abc"."buzz"="hij"."buzz" ' + 'JOIN "efg" ON "abc"."foo"="efg"."foo" AND "abc"."bar"="efg"."bar"', + str(query), + ) + + def test_join_using_string_field_name(self): + query = Query.from_(self.table0).join(self.table1).using("id").select("*") + + self.assertEqual('SELECT * FROM "abc" JOIN "efg" USING ("id")', str(query)) + + def test_join_using_multiple_fields(self): + query = Query.from_(self.table0).join(self.table1).using("foo", "bar").select("*") + + self.assertEqual('SELECT * FROM "abc" JOIN "efg" USING ("foo","bar")', str(query)) + + def test_join_using_with_quote_char(self): + query = Query.from_(self.table0).join(self.table1).using("foo", "bar").select("*") + + self.assertEqual("SELECT * FROM abc JOIN efg USING (foo,bar)", query.get_sql(quote_char="")) + + def test_join_using_without_fields_raises_exception(self): + with self.assertRaises(JoinException): + Query.from_(self.table0).join(self.table1).using() + + def test_join_on_field_without_fields_raises_exception(self): + with self.assertRaises(JoinException): + Query.from_(self.table0).join(self.table1).on_field() + + def test_join_arithmetic_field(self): + q = ( + Query.from_(self.table0) + .join(self.table1) + .on(self.table0.dt == (self.table1.dt - Interval(weeks=1))) + .select("*") + ) + + self.assertEqual( + 'SELECT * FROM "abc" ' 'JOIN "efg" ON "abc"."dt"="efg"."dt"-INTERVAL \'1 WEEK\'', + str(q), + ) + + def test_join_with_arithmetic_function_in_select(self): + q = ( + Query.from_( + self.table0, + ) + .join(self.table1) + .on(self.table0.dt == (self.table1.dt - Interval(weeks=1))) + .select(self.table0.fiz - self.table0.buz, self.table1.star) + ) + + self.assertEqual( + 'SELECT "abc"."fiz"-"abc"."buz","efg".* FROM "abc" ' + 'JOIN "efg" ON "abc"."dt"="efg"."dt"-INTERVAL \'1 WEEK\'', + str(q), + ) + + def test_join_on_complex_criteria(self): + q = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.right) + .on((self.table0.foo == self.table1.fiz) & (self.table0.bar == self.table1.buz)) + .select("*") + ) + + self.assertEqual( + 'SELECT * FROM "abc" ' 'RIGHT JOIN "efg" ON "abc"."foo"="efg"."fiz" AND "abc"."bar"="efg"."buz"', + str(q), + ) + + def test_join_on_subquery_criteria(self): + table_a, table_b, table_c = Tables("a", "b", "c") + subquery = Query.from_(table_c).select("id").limit(1) + query = ( + Query.from_(table_a).select("*").join(table_b).on((table_a.b_id == table_b.id) & (table_b.c_id == subquery)) + ) + + self.assertEqual( + "SELECT * " 'FROM "a" ' 'JOIN "b" ON "a"."b_id"="b"."id" AND "b"."c_id"=' '(SELECT "id" FROM "c" LIMIT 1)', + str(query), + ) + + def test_use_different_table_objects_for_same_table(self): + table = Table("t") + q = Query.from_(table).select("*").where(Field("id", table=table) == 1) + + self.assertEqual('SELECT * FROM "t" WHERE "id"=1', str(q)) + + def test_join_second_table_in_from_clause(self): + table_a, table_b, table_c = Tables("a", "b", "c") + q = Query.from_(table_a).from_(table_b).select("*").join(table_c).on(table_b.c_id == table_c.id) + + self.assertEqual("SELECT * " 'FROM "a","b" ' 'JOIN "c" ON "b"."c_id"="c"."id"', str(q)) + + def test_cross_join_on_table(self): + table_a, table_b = Tables("a", "b") + q = Query.from_(table_a).join(table_b).cross().select("*") + + self.assertEqual('SELECT * FROM "a" CROSS JOIN "b"', str(q)) + + def test_cross_join_on_subquery(self): + table_a, table_b = Tables("a", "b") + q_a = Query.from_(table_a).select("*") + q_b = Query.from_(table_b).select("*").join(q_a).cross().select("*") + + self.assertEqual('SELECT * FROM "b" CROSS JOIN (SELECT * FROM "a") "sq0"', str(q_b)) + + def test_join_on_collate(self): + table_a, table_b = Tables("a", "b") + + q1 = ( + Query.from_(table_a) + .select(table_b.ouch) + .join(table_b) + .on(table_a.foo == table_b.boo, collate="utf8_general_ci") + ) + q2 = Query.from_(table_a).select(table_b.ouch).join(table_b).on(table_a.foo == table_b.boo) + + self.assertEqual( + 'SELECT "b"."ouch" FROM "a" JOIN "b" ON "a"."foo"="b"."boo" COLLATE utf8_general_ci', + str(q1), + ) + self.assertEqual('SELECT "b"."ouch" FROM "a" JOIN "b" ON "a"."foo"="b"."boo"', str(q2)) + + def test_temporal_join(self): + t0 = self.table0.for_(SYSTEM_TIME.as_of('2020-01-01')) + t1 = self.table1.for_(SYSTEM_TIME.as_of('2020-01-01')) + query = Query.from_(t0).join(t1).on(t0.foo == t1.bar).select("*") + + self.assertEqual( + 'SELECT * FROM "abc" FOR SYSTEM_TIME AS OF \'2020-01-01\' ' + 'JOIN "efg" FOR SYSTEM_TIME AS OF \'2020-01-01\' ' + 'ON "abc"."foo"="efg"."bar"', + str(query), + ) + + +class JoinBehaviorTests(unittest.TestCase): + table_abc, table_efg, table_hij, table_klm = Tables("abc", "efg", "hij", "klm") + + def test_select__ordered_select_clauses(self): + q = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .select( + self.table_abc.baz, + self.table_efg.buz, + self.table_abc.fiz, + self.table_efg.bam, + ) + ) + + self.assertEqual( + 'SELECT "abc"."baz","efg"."buz","abc"."fiz","efg"."bam" FROM "abc" ' + 'JOIN "efg" ON "abc"."foo"="efg"."bar"', + str(q), + ) + + def test_select__star_for_table(self): + q = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .join(self.table_hij) + .on(self.table_abc.buz == self.table_hij.bam) + .select(self.table_abc.star) + .select(self.table_efg.star) + .select(self.table_hij.star) + ) + + self.assertEqual( + 'SELECT "abc".*,"efg".*,"hij".* FROM "abc" ' + 'JOIN "efg" ON "abc"."foo"="efg"."bar" ' + 'JOIN "hij" ON "abc"."buz"="hij"."bam"', + str(q), + ) + + def test_select__star_for_table__replacement(self): + q = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .join(self.table_hij) + .on(self.table_abc.buz == self.table_hij.bam) + .select(self.table_abc.foo, self.table_efg.bar, self.table_hij.bam) + .select(self.table_abc.star, self.table_efg.star, self.table_hij.star) + ) + + self.assertEqual( + 'SELECT "abc".*,"efg".*,"hij".* FROM "abc" ' + 'JOIN "efg" ON "abc"."foo"="efg"."bar" ' + 'JOIN "hij" ON "abc"."buz"="hij"."bam"', + str(q), + ) + + def test_select_fields_with_where(self): + q = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .join(self.table_hij) + .on(self.table_abc.buz == self.table_hij.bam) + .select(self.table_abc.foo, self.table_efg.bar, self.table_hij.bam) + .where(self.table_abc.foo > 1) + .where(self.table_efg.bar != 2) + ) + + self.assertEqual( + 'SELECT "abc"."foo","efg"."bar","hij"."bam" FROM "abc" ' + 'JOIN "efg" ON "abc"."foo"="efg"."bar" ' + 'JOIN "hij" ON "abc"."buz"="hij"."bam" ' + 'WHERE "abc"."foo">1 AND "efg"."bar"<>2', + str(q), + ) + + def test_require_condition(self): + with self.assertRaises(JoinException): + Query.from_(self.table_abc).join(self.table_efg).on(None) + + def test_require_condition_with_both_tables(self): + with self.assertRaises(JoinException): + Query.from_(self.table_abc).join(self.table_efg).on(self.table_abc.foo == self.table_hij.bar) + + with self.assertRaises(JoinException): + Query.from_(self.table_abc).join(self.table_efg).on(self.table_hij.foo == self.table_efg.bar) + + with self.assertRaises(JoinException): + Query.from_(self.table_abc).join(self.table_efg).on(self.table_hij.foo == self.table_klm.bar) + + def test_join_same_table(self): + table1 = Table("abc") + table2 = Table("abc") + q = Query.from_(table1).join(table2).on(table1.foo == table2.bar).select(table1.foo, table2.buz) + + self.assertEqual( + 'SELECT "abc"."foo","abc2"."buz" FROM "abc" ' 'JOIN "abc" "abc2" ON "abc"."foo"="abc2"."bar"', + str(q), + ) + + def test_join_same_table_with_prefixes(self): + table1 = Table("abc").as_("x") + table2 = Table("abc").as_("y") + q = Query.from_(table1).join(table2).on(table1.foo == table2.bar).select(table1.foo, table2.buz) + + self.assertEqual( + 'SELECT "x"."foo","y"."buz" FROM "abc" "x" ' 'JOIN "abc" "y" ON "x"."foo"="y"."bar"', + str(q), + ) + + def test_join_table_twice(self): + table1, table2 = Table("efg").as_("efg1"), Table("efg").as_("efg2") + q = ( + Query.from_(self.table_abc) + .join(table1) + .on(self.table_abc.foo == table1.bar) + .join(table2) + .on(self.table_abc.foo == table2.bam) + .select(self.table_abc.foo, table1.fiz, table2.buz) + ) + + self.assertEqual( + 'SELECT "abc"."foo","efg1"."fiz","efg2"."buz" FROM "abc" ' + 'JOIN "efg" "efg1" ON "abc"."foo"="efg1"."bar" ' + 'JOIN "efg" "efg2" ON "abc"."foo"="efg2"."bam"', + str(q), + ) + + def test_select__fields_after_table_star(self): + q = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .select(self.table_abc.star, self.table_efg.bar) + .select(self.table_abc.foo) + ) + + self.assertEqual( + 'SELECT "abc".*,"efg"."bar" FROM "abc" JOIN "efg" ON "abc"."foo"="efg"."bar"', + str(q), + ) + + def test_fail_when_joining_unknown_type(self): + with self.assertRaises(ValueError): + Query.from_(self.table_abc).join("this is a string") + + def test_immutable__tables(self): + query1 = Query.from_(self.table_abc).select(self.table_abc.foo) + query2 = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .select(self.table_abc.foo, self.table_efg.buz) + ) + + self.assertEqual( + 'SELECT "abc"."foo","efg"."buz" FROM "abc" ' 'JOIN "efg" ON "abc"."foo"="efg"."bar"', + str(query2), + ) + self.assertEqual('SELECT "foo" FROM "abc"', str(query1)) + + def test_select_field_from_missing_table(self): + """ + Previously we validated the select field was a member of a table + in the query (e.g. FROM clause or a JOIN). However this made + correlated subqueries awkward to write (subqueries which refer + to their parent table. So the validation was removed. + + None of the following raise an error. Previously raised JoinException + """ + Query.from_(self.table_abc).select(self.table_efg.foo) + + Query.from_(self.table_abc).where(self.table_efg.foo == 0) + + Query.from_(self.table_abc).where(fn.Sum(self.table_efg.foo) == 0) + + Query.from_(self.table_abc).select(fn.Sum(self.table_abc.bar * 2) + fn.Sum(self.table_efg.foo * 2)) + + Query.from_(self.table_abc).groupby(self.table_efg.foo) + + Query.from_(self.table_abc).groupby(self.table_abc.foo).having(self.table_efg.bar) + + subquery = ( + Query.from_(self.table_efg).select(self.table_efg.id).where(self.table_efg.abc_id == self.table_abc.id) + ) + query = Query.from_(self.table_abc).select(subquery.as_("efg_id").limit(1)) + self.assertEqual( + 'SELECT (SELECT "efg"."id" FROM "efg" WHERE "efg"."abc_id"="abc"."id" LIMIT 1) "efg_id" FROM "abc"', + str(query), + ) + + def test_ignore_table_references(self): + query = Query.from_(Table("abc")).select(Table("abc").foo) + + self.assertEqual('SELECT "foo" FROM "abc"', str(query)) + + def test_prefixes_added_to_groupby(self): + test_query = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .select(self.table_abc.foo, fn.Sum(self.table_efg.buz)) + .groupby(self.table_abc.foo) + ) + + self.assertEqual( + 'SELECT "abc"."foo",SUM("efg"."buz") FROM "abc" ' + 'JOIN "efg" ON "abc"."foo"="efg"."bar" ' + 'GROUP BY "abc"."foo"', + str(test_query), + ) + + def test_prefixes_added_to_orderby(self): + test_query = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .select(self.table_abc.foo, self.table_efg.buz) + .orderby(self.table_abc.foo) + ) + + self.assertEqual( + 'SELECT "abc"."foo","efg"."buz" FROM "abc" ' + 'JOIN "efg" ON "abc"."foo"="efg"."bar" ' + 'ORDER BY "abc"."foo"', + str(test_query), + ) + + def test_prefixes_added_to_function_in_orderby(self): + test_query = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .select(self.table_abc.foo, self.table_efg.buz) + .orderby(fn.Date(self.table_abc.foo)) + ) + + self.assertEqual( + 'SELECT "abc"."foo","efg"."buz" FROM "abc" ' + 'JOIN "efg" ON "abc"."foo"="efg"."bar" ' + 'ORDER BY DATE("abc"."foo")', + str(test_query), + ) + + def test_join_from_join(self): + test_query = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.efg_id == self.table_efg.id) + .join(self.table_hij) + .on(self.table_efg.hij_id == self.table_hij.id) + .select(self.table_abc.foo, self.table_efg.bar, self.table_hij.fizz) + ) + + self.assertEqual( + 'SELECT "abc"."foo","efg"."bar","hij"."fizz" FROM "abc" ' + 'JOIN "efg" ON "abc"."efg_id"="efg"."id" ' + 'JOIN "hij" ON "efg"."hij_id"="hij"."id"', + str(test_query), + ) + + def test_join_query_without_alias(self): + subquery = Query.from_(self.table_efg).select( + self.table_efg.base_id.as_("x"), self.table_efg.fizz, self.table_efg.buzz + ) + + test_query = ( + Query.from_(self.table_abc) + .join(subquery) + .on(subquery.x == self.table_abc.id) + .select(self.table_abc.foo, subquery.fizz, subquery.buzz) + ) + + self.assertEqual( + 'SELECT "abc"."foo","sq0"."fizz","sq0"."buzz" ' + 'FROM "abc" JOIN (' + 'SELECT "base_id" "x","fizz","buzz" FROM "efg"' + ') "sq0" ' + 'ON "sq0"."x"="abc"."id"', + str(test_query), + ) + + def test_join_query_with_column_alias(self): + subquery = ( + Query.from_(self.table_efg) + .select( + self.table_efg.base_id.as_("x"), + self.table_efg.fizz, + self.table_efg.buzz, + ) + .as_("subq") + ) + + test_query = ( + Query.from_(self.table_abc) + .join(subquery) + .on(subquery.x == self.table_abc.id) + .select(self.table_abc.foo, subquery.fizz, subquery.buzz) + ) + + self.assertEqual( + 'SELECT "abc"."foo","subq"."fizz","subq"."buzz" ' + 'FROM "abc" JOIN (' + 'SELECT "base_id" "x","fizz","buzz" FROM "efg"' + ') "subq" ' + 'ON "subq"."x"="abc"."id"', + str(test_query), + ) + + def test_join_query_with_table_alias(self): + xxx = self.table_efg.as_("xxx") + subquery = Query.from_(xxx).select(xxx.base_id, xxx.fizz, xxx.buzz).as_("subq") + + test_query = ( + Query.from_(self.table_abc) + .join(subquery) + .on(subquery.x == self.table_abc.id) + .select(self.table_abc.foo, subquery.fizz, subquery.buzz) + ) + + self.assertEqual( + 'SELECT "abc"."foo","subq"."fizz","subq"."buzz" ' + 'FROM "abc" JOIN (' + 'SELECT "xxx"."base_id","xxx"."fizz","xxx"."buzz" FROM "efg" "xxx"' + ') "subq" ' + 'ON "subq"."x"="abc"."id"', + str(test_query), + ) + + def test_join_query_with_setoperation(self): + subquery = Query.from_(self.table_abc).select("*").union(Query.from_(self.table_abc).select("*")).as_("subq") + + test_query = ( + Query.from_(self.table_abc).join(subquery).on(subquery.x == self.table_abc.id).select(self.table_abc.foo) + ) + + self.assertEqual( + 'SELECT "abc"."foo" FROM "abc" ' + 'JOIN ' + '((SELECT * FROM "abc") ' + 'UNION ' + '(SELECT * FROM "abc")) "subq" ' + 'ON "subq"."x"="abc"."id"', + str(test_query), + ) + + +class UnionTests(unittest.TestCase): + table1, table2 = Tables("abc", "efg") + + def test_union(self): + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + + self.assertEqual( + '(SELECT "foo" FROM "abc") UNION (SELECT "bar" FROM "efg")', + str(query1 + query2), + ) + self.assertEqual( + '(SELECT "foo" FROM "abc") UNION (SELECT "bar" FROM "efg")', + str(query1.union(query2)), + ) + + def test_union_multiple(self): + table3, table4 = Tables("hij", "lmn") + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + query3 = Query.from_(table3).select(table3.baz) + query4 = Query.from_(table4).select(table4.faz) + + self.assertEqual( + '(SELECT "foo" FROM "abc") UNION ' + '(SELECT "bar" FROM "efg") UNION ' + '(SELECT "baz" FROM "hij") UNION ' + '(SELECT "faz" FROM "lmn")', + str(query1 + query2 + query3 + query4), + ) + self.assertEqual( + '(SELECT "foo" FROM "abc") UNION ' + '(SELECT "bar" FROM "efg") UNION ' + '(SELECT "baz" FROM "hij") UNION ' + '(SELECT "faz" FROM "lmn")', + str(query1.union(query2).union(query3).union(query4)), + ) + + def test_union_all(self): + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + + self.assertEqual( + '(SELECT "foo" FROM "abc") UNION ALL (SELECT "bar" FROM "efg")', + str(query1 * query2), + ) + self.assertEqual( + '(SELECT "foo" FROM "abc") UNION ALL (SELECT "bar" FROM "efg")', + str(query1.union_all(query2)), + ) + + def test_union_all_multiple(self): + table3, table4 = Tables("hij", "lmn") + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + query3 = Query.from_(table3).select(table3.baz) + query4 = Query.from_(table4).select(table4.faz) + + self.assertEqual( + '(SELECT "foo" FROM "abc") UNION ALL ' + '(SELECT "bar" FROM "efg") UNION ALL ' + '(SELECT "baz" FROM "hij") UNION ALL ' + '(SELECT "faz" FROM "lmn")', + str(query1 * query2 * query3 * query4), + ) + self.assertEqual( + '(SELECT "foo" FROM "abc") UNION ALL ' + '(SELECT "bar" FROM "efg") UNION ALL ' + '(SELECT "baz" FROM "hij") UNION ALL ' + '(SELECT "faz" FROM "lmn")', + str(query1.union_all(query2).union_all(query3).union_all(query4)), + ) + + def test_union_with_order_by(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + union_query = str((query1 + query2).orderby(query1.field("a"))) + union_all_query = str((query1 * query2).orderby(query1.field("a"))) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "UNION " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "a"', + union_query, + ) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "UNION ALL " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "a"', + union_all_query, + ) + + def test_union_with_order_by_use_union_query_field(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + union_query = query1 + query2 + union_query = str(union_query.orderby(union_query.field("a"))) + union_all_query = query1 * query2 + union_all_query = str(union_all_query.orderby(union_all_query.field("a"))) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "UNION " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "a"', + union_query, + ) + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "UNION ALL " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "a"', + union_all_query, + ) + + def test_union_with_order_by_with_aliases(self): + query1 = Query.from_(self.table1.as_("a")).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2.as_("b")).select(self.table2.bar.as_("a")) + + union_all_query = str((query1 * query2).orderby(query1.field("a"))) + union_query = str((query1 + query2).orderby(query1.field("a"))) + self.assertEqual( + '(SELECT "foo" "a" FROM "abc" "a")' " UNION ALL " '(SELECT "bar" "a" FROM "efg" "b")' ' ORDER BY "a"', + union_all_query, + ) + self.assertEqual( + '(SELECT "foo" "a" FROM "abc" "a")' " UNION " '(SELECT "bar" "a" FROM "efg" "b")' ' ORDER BY "a"', + union_query, + ) + + def test_union_with_order_by_use_union_query_field_with_aliases(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + union_query = (query1 + query2).as_("x") + union_query = union_query.orderby(union_query.field("a")) + union_all_query = (query1 * query2).as_("x") + union_all_query = union_all_query.orderby(union_all_query.field("a")) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "UNION " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "x"."a"', + str(union_query), + ) + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "UNION ALL " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "x"."a"', + str(union_all_query), + ) + + def test_require_equal_number_of_fields(self): + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.fiz, self.table2.buz) + + with self.assertRaises(SetOperationException): + str(query1 + query2) + + def test_mysql_query_wraps_unioned_queries(self): + query1 = MySQLQuery.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + + self.assertEqual( + "(SELECT `foo` FROM `abc`) UNION (SELECT `bar` FROM `efg`)", + str(query1 + query2), + ) + + def test_union_as_subquery(self): + abc, efg = Tables("abc", "efg") + hij = Query.from_(abc).select(abc.t).union(Query.from_(efg).select(efg.t)) + q = Query.from_(hij).select(fn.Avg(hij.t)) + + self.assertEqual( + 'SELECT AVG("sq0"."t") FROM ((SELECT "t" FROM "abc") UNION (SELECT "t" FROM "efg")) "sq0"', + str(q), + ) + + def test_union_with_no_quote_char(self): + abc, efg = Tables("abc", "efg") + hij = Query.from_(abc).select(abc.t).union(Query.from_(efg).select(efg.t)) + q = Query.from_(hij).select(fn.Avg(hij.t)) + + self.assertEqual( + "SELECT AVG(sq0.t) FROM ((SELECT t FROM abc) UNION (SELECT t FROM efg)) sq0", + q.get_sql(quote_char=None), + ) + + +class InsertQueryJoinTests(unittest.TestCase): + def test_join_table_on_insert_query(self): + a, b, c = Tables("a", "b", "c") + q = Query.into(c).from_(a).join(b).on(a.fkey_id == b.id).where(b.foo == 1).select("a.*", "b.*") + + self.assertEqual( + 'INSERT INTO "c" ' + 'SELECT "a"."a.*","a"."b.*" ' + 'FROM "a" JOIN "b" ' + 'ON "a"."fkey_id"="b"."id" ' + 'WHERE "b"."foo"=1', + str(q), + ) + + +class UpdateQueryJoinTests(unittest.TestCase): + def test_join_table_on_update_query(self): + a, b = Tables("a", "b") + q = Query.update(a).join(b).on(a.fkey_id == b.id).where(b.foo == 1).set("adwords_batch_job_id", 1) + + self.assertEqual( + 'UPDATE "a" ' 'JOIN "b" ' 'ON "a"."fkey_id"="b"."id" ' 'SET "adwords_batch_job_id"=1 ' 'WHERE "b"."foo"=1', + str(q), + ) + + +class IntersectTests(unittest.TestCase): + table1, table2 = Tables("abc", "efg") + + def test_intersect(self): + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + + self.assertEqual( + '(SELECT "foo" FROM "abc") INTERSECT (SELECT "bar" FROM "efg")', + str(query1.intersect(query2)), + ) + + def test_intersect_multiple(self): + table3, table4 = Tables("hij", "lmn") + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + query3 = Query.from_(table3).select(table3.baz) + query4 = Query.from_(table4).select(table4.faz) + + self.assertEqual( + '(SELECT "foo" FROM "abc") INTERSECT ' + '(SELECT "bar" FROM "efg") INTERSECT ' + '(SELECT "baz" FROM "hij") INTERSECT ' + '(SELECT "faz" FROM "lmn")', + str(query1.intersect(query2).intersect(query3).intersect(query4)), + ) + + def test_intersect_with_order_by(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + intersect_query = str((query1.intersect(query2)).orderby(query1.field("a"))) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "INTERSECT " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "a"', + intersect_query, + ) + + def test_intersect_with_limit(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + intersect_query = str((query1.intersect(query2)).limit(10)) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "INTERSECT " '(SELECT "bar" "a" FROM "efg") ' 'LIMIT 10', + intersect_query, + ) + + def test_intersect_with_offset(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + intersect_query = str((query1.intersect(query2)).offset(10)) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "INTERSECT " '(SELECT "bar" "a" FROM "efg") ' 'OFFSET 10', + intersect_query, + ) + + def test_require_equal_number_of_fields_intersect(self): + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.fiz, self.table2.buz) + + with self.assertRaises(SetOperationException): + str(query1.intersect(query2)) + + def test_mysql_query_wraps_intersected_queries(self): + query1 = MySQLQuery.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + + self.assertEqual( + "(SELECT `foo` FROM `abc`) INTERSECT (SELECT `bar` FROM `efg`)", + str(query1.intersect(query2)), + ) + + def test_intersect_as_subquery(self): + abc, efg = Tables("abc", "efg") + hij = Query.from_(abc).select(abc.t).intersect(Query.from_(efg).select(efg.t)) + q = Query.from_(hij).select(fn.Avg(hij.t)) + + self.assertEqual( + 'SELECT AVG("sq0"."t") FROM ((SELECT "t" FROM "abc") INTERSECT (SELECT "t" FROM "efg")) "sq0"', + str(q), + ) + + def test_intersect_with_no_quote_char(self): + abc, efg = Tables("abc", "efg") + hij = Query.from_(abc).select(abc.t).intersect(Query.from_(efg).select(efg.t)) + q = Query.from_(hij).select(fn.Avg(hij.t)) + + self.assertEqual( + "SELECT AVG(sq0.t) FROM ((SELECT t FROM abc) INTERSECT (SELECT t FROM efg)) sq0", + q.get_sql(quote_char=None), + ) + + +class MinusTests(unittest.TestCase): + table1, table2 = Tables("abc", "efg") + + def test_minus(self): + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + + self.assertEqual('(SELECT "foo" FROM "abc") MINUS (SELECT "bar" FROM "efg")', str(query1.minus(query2))) + + self.assertEqual( + '(SELECT "foo" FROM "abc") MINUS (SELECT "bar" FROM "efg")', + str(query1 - query2), + ) + + def test_minus_multiple(self): + table3, table4 = Tables("hij", "lmn") + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + query3 = Query.from_(table3).select(table3.baz) + query4 = Query.from_(table4).select(table4.faz) + + self.assertEqual( + '(SELECT "foo" FROM "abc") MINUS ' + '(SELECT "bar" FROM "efg") MINUS ' + '(SELECT "baz" FROM "hij") MINUS ' + '(SELECT "faz" FROM "lmn")', + str(query1 - query2 - query3 - query4), + ) + + self.assertEqual( + '(SELECT "foo" FROM "abc") MINUS ' + '(SELECT "bar" FROM "efg") MINUS ' + '(SELECT "baz" FROM "hij") MINUS ' + '(SELECT "faz" FROM "lmn")', + str(query1.minus(query2).minus(query3).minus(query4)), + ) + + def test_minus_with_order_by(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + minus_query = str(query1.minus(query2).orderby(query1.field("a"))) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "MINUS " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "a"', minus_query + ) + + def test_minus_query_with_order_by_use_minus_query_field(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + minus_query = query1.minus(query2) + minus_query = str(minus_query.orderby(minus_query.field("b"))) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "MINUS " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "b"', + minus_query, + ) + + def test_require_equal_number_of_fields(self): + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.fiz, self.table2.buz) + + with self.assertRaises(SetOperationException): + str(query1.minus(query2)) + + def test_mysql_query_wraps_minus_queries(self): + query1 = MySQLQuery.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + + self.assertEqual( + "(SELECT `foo` FROM `abc`) MINUS (SELECT `bar` FROM `efg`)", + str(query1 - query2), + ) + + def test_minus_as_subquery(self): + abc, efg = Tables("abc", "efg") + hij = Query.from_(abc).select(abc.t).minus(Query.from_(efg).select(efg.t)) + q = Query.from_(hij).select(fn.Avg(hij.t)) + + self.assertEqual( + 'SELECT AVG("sq0"."t") FROM ((SELECT "t" FROM "abc") MINUS (SELECT "t" FROM "efg")) "sq0"', + str(q), + ) + + def test_minus_with_no_quote_char(self): + abc, efg = Tables("abc", "efg") + hij = Query.from_(abc).select(abc.t).minus(Query.from_(efg).select(efg.t)) + q = Query.from_(hij).select(fn.Avg(hij.t)) + + self.assertEqual( + "SELECT AVG(sq0.t) FROM ((SELECT t FROM abc) MINUS (SELECT t FROM efg)) sq0", + q.get_sql(quote_char=None), + ) + + +class ExceptOfTests(unittest.TestCase): + table1, table2 = Tables("abc", "efg") + + def test_except(self): + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + + self.assertEqual('(SELECT "foo" FROM "abc") EXCEPT (SELECT "bar" FROM "efg")', str(query1.except_of(query2))) + + def test_except_multiple(self): + table3, table4 = Tables("hij", "lmn") + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + query3 = Query.from_(table3).select(table3.baz) + query4 = Query.from_(table4).select(table4.faz) + + self.assertEqual( + '(SELECT "foo" FROM "abc") EXCEPT ' + '(SELECT "bar" FROM "efg") EXCEPT ' + '(SELECT "baz" FROM "hij") EXCEPT ' + '(SELECT "faz" FROM "lmn")', + str(query1.except_of(query2).except_of(query3).except_of(query4)), + ) + + def test_except_with_order_by(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + except_query = str(query1.except_of(query2).orderby(query1.field("a"))) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "EXCEPT " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "a"', except_query + ) + + def test_except_query_with_order_by_use_minus_query_field(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + except_query = query1.except_of(query2) + except_query = str(except_query.orderby(except_query.field("b"))) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "EXCEPT " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "b"', + except_query, + ) + + def test_require_equal_number_of_fields_except_of(self): + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.fiz, self.table2.buz) + + with self.assertRaises(SetOperationException): + str(query1.except_of(query2)) + + def test_except_as_subquery(self): + abc, efg = Tables("abc", "efg") + hij = Query.from_(abc).select(abc.t).except_of(Query.from_(efg).select(efg.t)) + q = Query.from_(hij).select(fn.Avg(hij.t)) + + self.assertEqual( + 'SELECT AVG("sq0"."t") FROM ((SELECT "t" FROM "abc") EXCEPT (SELECT "t" FROM "efg")) "sq0"', + str(q), + ) + + def test_except_with_no_quote_char(self): + abc, efg = Tables("abc", "efg") + hij = Query.from_(abc).select(abc.t).except_of(Query.from_(efg).select(efg.t)) + q = Query.from_(hij).select(fn.Avg(hij.t)) + + self.assertEqual( + "SELECT AVG(sq0.t) FROM ((SELECT t FROM abc) EXCEPT (SELECT t FROM efg)) sq0", + q.get_sql(quote_char=None), + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/test_negation.py b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/test_negation.py new file mode 100644 index 0000000000000000000000000000000000000000..9f4db83b560dbc8546ce6d384b781dfccefd319d --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/test_negation.py @@ -0,0 +1,31 @@ +import unittest + +from pypika import ( + Tables, + functions as fn, +) +from pypika.terms import ValueWrapper + + +class NegationTests(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_negate_wrapped_float(self): + q = -ValueWrapper(1.0) + + self.assertEqual("-1.0", q.get_sql()) + + def test_negate_wrapped_int(self): + q = -ValueWrapper(1) + + self.assertEqual("-1", q.get_sql()) + + def test_negate_field(self): + q = -self.table_abc.foo + + self.assertEqual('-"abc"."foo"', q.get_sql(with_namespace=True, quote_char='"')) + + def test_negate_function(self): + q = -fn.Sum(self.table_abc.foo) + + self.assertEqual('-SUM("abc"."foo")', q.get_sql(with_namespace=True, quote_char='"')) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/test_parameter.py b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/test_parameter.py new file mode 100644 index 0000000000000000000000000000000000000000..c11e9afcd9624abb0a7313306eda34ebcf4c99ba --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/test_parameter.py @@ -0,0 +1,206 @@ +import unittest +from datetime import date + +from pypika import ( + FormatParameter, + NamedParameter, + NumericParameter, + Parameter, + PyformatParameter, + QmarkParameter, + Query, + Tables, +) +from pypika.terms import ListParameter, ParameterValueWrapper + + +class ParametrizedTests(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_param_insert(self): + q = Query.into(self.table_abc).columns("a", "b", "c").insert(Parameter("?"), Parameter("?"), Parameter("?")) + + self.assertEqual('INSERT INTO "abc" ("a","b","c") VALUES (?,?,?)', q.get_sql()) + + def test_param_select_join(self): + q = ( + Query.from_(self.table_abc) + .select("*") + .where(self.table_abc.category == Parameter("%s")) + .join(self.table_efg) + .on(self.table_abc.id == self.table_efg.abc_id) + .where(self.table_efg.date >= Parameter("%s")) + .limit(10) + ) + + self.assertEqual( + 'SELECT * FROM "abc" JOIN "efg" ON "abc"."id"="efg"."abc_id" WHERE "abc"."category"=%s AND "efg"."date">=%s LIMIT 10', + q.get_sql(), + ) + + def test_param_select_subquery(self): + q = ( + Query.from_(self.table_abc) + .select("*") + .where(self.table_abc.category == Parameter("&1")) + .where( + self.table_abc.id.isin( + Query.from_(self.table_efg) + .select(self.table_efg.abc_id) + .where(self.table_efg.date >= Parameter("&2")) + ) + ) + .limit(10) + ) + + self.assertEqual( + 'SELECT * FROM "abc" WHERE "category"=&1 AND "id" IN (SELECT "abc_id" FROM "efg" WHERE "date">=&2) LIMIT 10', + q.get_sql(), + ) + + def test_join(self): + subquery = ( + Query.from_(self.table_efg) + .select(self.table_efg.fiz, self.table_efg.buz) + .where(self.table_efg.buz == Parameter(":buz")) + ) + + q = ( + Query.from_(self.table_abc) + .join(subquery) + .on(self.table_abc.bar == subquery.buz) + .select(self.table_abc.foo, subquery.fiz) + .where(self.table_abc.bar == Parameter(":bar")) + ) + + self.assertEqual( + 'SELECT "abc"."foo","sq0"."fiz" FROM "abc" JOIN (SELECT "fiz","buz" FROM "efg" WHERE "buz"=:buz)' + ' "sq0" ON "abc"."bar"="sq0"."buz" WHERE "abc"."bar"=:bar', + q.get_sql(), + ) + + def test_qmark_parameter(self): + self.assertEqual('?', QmarkParameter().get_sql()) + + def test_numeric_parameter(self): + self.assertEqual(':14', NumericParameter('14').get_sql()) + self.assertEqual(':15', NumericParameter(15).get_sql()) + + def test_named_parameter(self): + self.assertEqual(':buz', NamedParameter('buz').get_sql()) + + def test_format_parameter(self): + self.assertEqual('%s', FormatParameter().get_sql()) + + def test_pyformat_parameter(self): + self.assertEqual('%(buz)s', PyformatParameter('buz').get_sql()) + + +class ParametrizedTestsWithValues(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_param_insert(self): + q = Query.into(self.table_abc).columns("a", "b", "c").insert(1, 2.2, 'foo') + + parameter = QmarkParameter() + sql = q.get_sql(parameter=parameter) + self.assertEqual('INSERT INTO "abc" ("a","b","c") VALUES (?,?,?)', sql) + self.assertEqual([1, 2.2, 'foo'], parameter.get_parameters()) + + def test_param_select_join(self): + q = ( + Query.from_(self.table_abc) + .select("*") + .where(self.table_abc.category == 'foobar') + .join(self.table_efg) + .on(self.table_abc.id == self.table_efg.abc_id) + .where(self.table_efg.date >= date(2024, 2, 22)) + .limit(10) + ) + + parameter = FormatParameter() + sql = q.get_sql(parameter=parameter) + self.assertEqual( + 'SELECT * FROM "abc" JOIN "efg" ON "abc"."id"="efg"."abc_id" WHERE "abc"."category"=%s AND "efg"."date">=%s LIMIT 10', + sql, + ) + self.assertEqual(['foobar', '2024-02-22'], parameter.get_parameters()) + + def test_param_select_subquery(self): + q = ( + Query.from_(self.table_abc) + .select("*") + .where(self.table_abc.category == 'foobar') + .where( + self.table_abc.id.isin( + Query.from_(self.table_efg) + .select(self.table_efg.abc_id) + .where(self.table_efg.date >= date(2024, 2, 22)) + ) + ) + .limit(10) + ) + + parameter = ListParameter(placeholder=lambda idx: f'&{idx+1}') + sql = q.get_sql(parameter=parameter) + self.assertEqual( + 'SELECT * FROM "abc" WHERE "category"=&1 AND "id" IN (SELECT "abc_id" FROM "efg" WHERE "date">=&2) LIMIT 10', + sql, + ) + self.assertEqual(['foobar', '2024-02-22'], parameter.get_parameters()) + + def test_join(self): + subquery = ( + Query.from_(self.table_efg) + .select(self.table_efg.fiz, self.table_efg.buz) + .where(self.table_efg.buz == 'buz') + ) + + q = ( + Query.from_(self.table_abc) + .join(subquery) + .on(self.table_abc.bar == subquery.buz) + .select(self.table_abc.foo, subquery.fiz) + .where(self.table_abc.bar == 'bar') + ) + + parameter = NamedParameter() + sql = q.get_sql(parameter=parameter) + self.assertEqual( + 'SELECT "abc"."foo","sq0"."fiz" FROM "abc" JOIN (SELECT "fiz","buz" FROM "efg" WHERE "buz"=:param1)' + ' "sq0" ON "abc"."bar"="sq0"."buz" WHERE "abc"."bar"=:param2', + sql, + ) + self.assertEqual({'param1': 'buz', 'param2': 'bar'}, parameter.get_parameters()) + + def test_join_with_parameter_value_wrapper(self): + subquery = ( + Query.from_(self.table_efg) + .select(self.table_efg.fiz, self.table_efg.buz) + .where(self.table_efg.buz == ParameterValueWrapper(Parameter(':buz'), 'buz')) + ) + + q = ( + Query.from_(self.table_abc) + .join(subquery) + .on(self.table_abc.bar == subquery.buz) + .select(self.table_abc.foo, subquery.fiz) + .where(self.table_abc.bar == ParameterValueWrapper(NamedParameter('bar'), 'bar')) + ) + + parameter = NamedParameter() + sql = q.get_sql(parameter=parameter) + self.assertEqual( + 'SELECT "abc"."foo","sq0"."fiz" FROM "abc" JOIN (SELECT "fiz","buz" FROM "efg" WHERE "buz"=:buz)' + ' "sq0" ON "abc"."bar"="sq0"."buz" WHERE "abc"."bar"=:bar', + sql, + ) + self.assertEqual({':buz': 'buz', 'bar': 'bar'}, parameter.get_parameters()) + + def test_pyformat_parameter(self): + q = Query.into(self.table_abc).columns("a", "b", "c").insert(1, 2.2, 'foo') + + parameter = PyformatParameter() + sql = q.get_sql(parameter=parameter) + self.assertEqual('INSERT INTO "abc" ("a","b","c") VALUES (%(param1)s,%(param2)s,%(param3)s)', sql) + self.assertEqual({"param1": 1, "param2": 2.2, "param3": "foo"}, parameter.get_parameters()) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/test_pseudocolumns.py b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/test_pseudocolumns.py new file mode 100644 index 0000000000000000000000000000000000000000..6a25c70269b2ccc98ac3870ac64a43c8a32ddbe9 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/test_pseudocolumns.py @@ -0,0 +1,51 @@ +import unittest + +from pypika import Query, Table +from pypika.pseudocolumns import ( + ColumnValue, + ObjectID, + ObjectValue, + RowID, + RowNum, + SysDate, +) +from pypika.terms import PseudoColumn + + +class PseudoColumnsTest(unittest.TestCase): + @classmethod + def setUpClass(cls): + super(PseudoColumnsTest, cls).setUpClass() + cls.table1 = Table("table1") + + def test_column_value(self): + self.assertEqual("COLUMN_VALUE", ColumnValue) + + def test_object_id(self): + self.assertEqual("OBJECT_ID", ObjectID) + + def test_object_value(self): + self.assertEqual("OBJECT_VALUE", ObjectValue) + + def test_row_id(self): + self.assertEqual("ROWID", RowID) + + def test_row_num(self): + self.assertEqual("ROWNUM", RowNum) + + def test_sys_date(self): + self.assertEqual("SYSDATE", SysDate) + + def test_can_be_used_in_a_select_statement(self): + query = Query.from_(self.table1).where(self.table1.is_active == 1).select(PseudoColumn("abcde")) + + self.assertEqual(str(query), 'SELECT abcde FROM "table1" WHERE "is_active"=1') + + def test_can_be_used_in_a_where_clause(self): + query = Query.from_(self.table1).where(PseudoColumn("abcde") > 1).select(self.table1.is_active) + + self.assertEqual(str(query), 'SELECT "is_active" FROM "table1" WHERE abcde>1') + + def test_can_be_used_in_orderby(self): + query = Query.from_(self.table1).select(self.table1.abcde.as_("some_name")).orderby(PseudoColumn("some_name")) + self.assertEqual(str(query), 'SELECT "abcde" "some_name" FROM "table1" ORDER BY some_name') diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/test_query.py b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/test_query.py new file mode 100644 index 0000000000000000000000000000000000000000..ae8dc01599a6a562b591ce15391bfe9b5c87e0f9 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/test_query.py @@ -0,0 +1,242 @@ +import unittest + +from pypika import Case, Query, Tables, Tuple, functions, Field +from pypika.dialects import ( + ClickHouseQuery, + ClickHouseQueryBuilder, + MSSQLQuery, + MSSQLQueryBuilder, + MySQLLoadQueryBuilder, + MySQLQuery, + MySQLQueryBuilder, + OracleQuery, + OracleQueryBuilder, + PostgreSQLQuery, + PostgreSQLQueryBuilder, + RedShiftQueryBuilder, + RedshiftQuery, + SQLLiteQuery, + SQLLiteQueryBuilder, + SnowflakeQuery, + SnowflakeQueryBuilder, + VerticaCopyQueryBuilder, + VerticaCreateQueryBuilder, + VerticaQuery, + VerticaQueryBuilder, +) +from pypika.queries import CreateQueryBuilder, DropQueryBuilder, QueryBuilder + + +class QueryTablesTests(unittest.TestCase): + table_a, table_b, table_c, table_d = Tables("a", "b", "c", "d") + + def test_replace_table(self): + query = Query.from_(self.table_a).select(self.table_a.time) + query = query.replace_table(self.table_a, self.table_b) + + self.assertEqual('SELECT "time" FROM "b"', str(query)) + + def test_replace_only_specified_table(self): + query = Query.from_(self.table_a).select(self.table_a.time) + query = query.replace_table(self.table_b, self.table_c) + + self.assertEqual('SELECT "time" FROM "a"', str(query)) + + def test_replace_insert_table(self): + query = Query.into(self.table_a).insert(1) + query = query.replace_table(self.table_a, self.table_b) + + self.assertEqual('INSERT INTO "b" VALUES (1)', str(query)) + + def test_replace_insert_table_current_table_not_match(self): + query = Query.into(self.table_a).insert(1) + query = query.replace_table(self.table_c, self.table_b) + + self.assertEqual('INSERT INTO "a" VALUES (1)', str(query)) + + def test_replace_update_table(self): + query = Query.update(self.table_a).set("foo", "bar") + query = query.replace_table(self.table_a, self.table_b) + + self.assertEqual('UPDATE "b" SET "foo"=\'bar\'', str(query)) + + def test_replace_update_table_current_table_not_match(self): + query = Query.update(self.table_a).set("foo", "bar") + query = query.replace_table(self.table_c, self.table_b) + + self.assertEqual('UPDATE "a" SET "foo"=\'bar\'', str(query)) + + def test_replace_delete_table(self): + query = Query.from_(self.table_a).delete() + query = query.replace_table(self.table_a, self.table_b) + + self.assertEqual('DELETE FROM "b"', str(query)) + + def test_replace_join_tables(self): + query = ( + Query.from_(self.table_a) + .join(self.table_b) + .on(self.table_a.customer_id == self.table_b.id) + .join(self.table_c) + .on(self.table_b.seller_id == self.table_c.id) + .select(self.table_a.star) + ) + query = query.replace_table(self.table_a, self.table_d) + + self.assertEqual( + 'SELECT "d".* ' + 'FROM "d" ' + 'JOIN "b" ON "d"."customer_id"="b"."id" ' + 'JOIN "c" ON "b"."seller_id"="c"."id"', + str(query), + ) + + def test_replace_filter_tables(self): + query = Query.from_(self.table_a).select(self.table_a.name).where(self.table_a.name == "Mustermann") + query = query.replace_table(self.table_a, self.table_b) + + self.assertEqual('SELECT "name" FROM "b" WHERE "name"=\'Mustermann\'', str(query)) + + def test_replace_having_table(self): + query = ( + Query.from_(self.table_a) + .select(functions.Sum(self.table_a.revenue)) + .groupby(self.table_a.customer) + .having(functions.Sum(self.table_a.revenue) >= 1000) + ) + query = query.replace_table(self.table_a, self.table_b) + + self.assertEqual( + 'SELECT SUM("revenue") ' 'FROM "b" ' 'GROUP BY "customer" ' 'HAVING SUM("revenue")>=1000', + str(query), + ) + + def test_replace_case_table(self): + query = Query.from_(self.table_a).select( + Case() + .when(self.table_a.fname == "Tom", "It was Tom") + .when(self.table_a.fname == "John", "It was John") + .else_("It was someone else.") + .as_("who_was_it") + ) + query = query.replace_table(self.table_a, self.table_b) + + self.assertEqual( + "SELECT CASE " + "WHEN \"fname\"='Tom' THEN 'It was Tom' " + "WHEN \"fname\"='John' THEN 'It was John' " + "ELSE 'It was someone else.' END \"who_was_it\" " + 'FROM "b"', + str(query), + ) + + def test_replace_orderby_table(self): + query = Query.from_(self.table_a).select(self.table_a.customer).orderby(self.table_a.customer) + query = query.replace_table(self.table_a, self.table_b) + + self.assertEqual('SELECT "customer" FROM "b" ORDER BY "customer"', str(query)) + + def test_replace_tuple_table(self): + query = ( + Query.from_(self.table_a) + .select(self.table_a.cost, self.table_a.revenue) + .where((self.table_a.cost, self.table_a.revenue) == Tuple(1, 2)) + ) + + query = query.replace_table(self.table_a, self.table_b) + + # Order is reversed due to lack of right equals method + self.assertEqual( + 'SELECT "cost","revenue" FROM "b" WHERE (1,2)=("cost","revenue")', + str(query), + ) + + def test_is_joined(self): + q = Query.from_(self.table_a).join(self.table_b).on(self.table_a.foo == self.table_b.boo) + + self.assertTrue(q.is_joined(self.table_b)) + self.assertFalse(q.is_joined(self.table_c)) + + +class QueryBuilderTests(unittest.TestCase): + def test_query_builders_have_reference_to_correct_query_class(self): + with self.subTest('QueryBuilder'): + self.assertEqual(Query, QueryBuilder.QUERY_CLS) + + with self.subTest('DropQueryBuilder'): + self.assertEqual(Query, DropQueryBuilder.QUERY_CLS) + + with self.subTest('CreateQueryBuilder'): + self.assertEqual(Query, CreateQueryBuilder.QUERY_CLS) + + with self.subTest('MySQLQueryBuilder'): + self.assertEqual(MySQLQuery, MySQLQueryBuilder.QUERY_CLS) + + with self.subTest('MySQLLoadQueryBuilder'): + self.assertEqual(MySQLQuery, MySQLLoadQueryBuilder.QUERY_CLS) + + with self.subTest('VerticaQueryBuilder'): + self.assertEqual(VerticaQuery, VerticaQueryBuilder.QUERY_CLS) + + with self.subTest('VerticaCreateQueryBuilder'): + self.assertEqual(VerticaQuery, VerticaCreateQueryBuilder.QUERY_CLS) + + with self.subTest('VerticaCopyQueryBuilder'): + self.assertEqual(VerticaQuery, VerticaCopyQueryBuilder.QUERY_CLS) + + with self.subTest('PostgreSQLQueryBuilder'): + self.assertEqual(PostgreSQLQuery, PostgreSQLQueryBuilder.QUERY_CLS) + + with self.subTest('MSSQLQueryBuilder'): + self.assertEqual(MSSQLQuery, MSSQLQueryBuilder.QUERY_CLS) + + with self.subTest('SnowflakeQueryBuilder'): + self.assertEqual(SnowflakeQuery, SnowflakeQueryBuilder.QUERY_CLS) + + with self.subTest('ClickHouseQueryBuilder'): + self.assertEqual(ClickHouseQuery, ClickHouseQueryBuilder.QUERY_CLS) + + with self.subTest('RedShiftQueryBuilder'): + self.assertEqual(RedshiftQuery, RedShiftQueryBuilder.QUERY_CLS) + + with self.subTest('SQLLiteQueryBuilder'): + self.assertEqual(SQLLiteQuery, SQLLiteQueryBuilder.QUERY_CLS) + + with self.subTest('OracleQueryBuilder'): + self.assertEqual(OracleQuery, OracleQueryBuilder.QUERY_CLS) + + def test_pipe(self) -> None: + base_query = Query.from_("test") + + def select(query: QueryBuilder) -> QueryBuilder: + return query.select("test1", "test2") + + def count_group(query: QueryBuilder, *groups) -> QueryBuilder: + return query.groupby(*groups).select(*groups, functions.Count("*")) + + for func, args, kwargs, expected_str in [ + (select, [], {}, 'SELECT "test1","test2" FROM "test"'), + ( + count_group, + ["test1", "test2"], + {}, + 'SELECT "test1","test2",COUNT(*) FROM "test" GROUP BY "test1","test2"', + ), + (count_group, ["test1"], {}, 'SELECT "test1",COUNT(*) FROM "test" GROUP BY "test1"'), + ]: + result_str = str(base_query.pipe(func, *args, **kwargs)) + self.assertEqual(result_str, str(func(base_query, *args, **kwargs))) + self.assertEqual(result_str, expected_str) + + def where_clause(query: QueryBuilder, num_days: int) -> QueryBuilder: + return query.where(Field("date") > functions.Now() - num_days) + + result_str = str(base_query.pipe(select).pipe(where_clause, num_days=1)) + self.assertEqual( + result_str, + str(select(where_clause(base_query, num_days=1))), + ) + self.assertEqual( + result_str, + 'SELECT "test1","test2" FROM "test" WHERE "date">NOW()-1', + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/test_selects.py b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/test_selects.py new file mode 100644 index 0000000000000000000000000000000000000000..1ce04937492e655db362b7e2a0a6856abf22a48f --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/test_selects.py @@ -0,0 +1,1331 @@ +import unittest +from datetime import date +from enum import Enum + +from pypika import ( + AliasedQuery, + Case, + ClickHouseQuery, + EmptyCriterion, + Field as F, + Index, + MSSQLQuery, + MySQLQuery, + NullValue, + OracleQuery, + Order, + PostgreSQLQuery, + Query, + QueryException, + RedshiftQuery, + SQLLiteQuery, + Table, + Tables, + VerticaQuery, + functions as fn, + SYSTEM_TIME, +) +from pypika.terms import ValueWrapper + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + + +class SelectTests(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_empty_query(self): + q = Query.from_("abc") + + self.assertEqual("", str(q)) + + def test_select_no_from(self): + q = Query.select(1) + + self.assertEqual("SELECT 1", str(q)) + + def test_select_no_with_alias_from(self): + q = Query.select(ValueWrapper(1, "test")) + + self.assertEqual('SELECT 1 "test"', str(q)) + + def test_select_no_from_with_field_raises_exception(self): + with self.assertRaises(QueryException): + Query.select("asdf") + + def test_select__star(self): + q = Query.from_("abc").select("*") + + self.assertEqual('SELECT * FROM "abc"', str(q)) + + def test_select__table_schema(self): + q = Query.from_(Table("abc", "schema1")).select("*") + + self.assertEqual('SELECT * FROM "schema1"."abc"', str(q)) + + def test_select__table_schema_with_multiple_levels_as_tuple(self): + q = Query.from_(Table("abc", ("schema1", "schema2"))).select("*") + + self.assertEqual('SELECT * FROM "schema1"."schema2"."abc"', str(q)) + + def test_select__table_schema_with_multiple_levels_as_list(self): + q = Query.from_(Table("abc", ["schema1", "schema2"])).select("*") + + self.assertEqual('SELECT * FROM "schema1"."schema2"."abc"', str(q)) + + def test_select__star__replacement(self): + q = Query.from_("abc").select("foo").select("*") + + self.assertEqual('SELECT * FROM "abc"', str(q)) + + def test_select__distinct__single(self): + q = Query.from_("abc").select("foo").distinct() + + self.assertEqual('SELECT DISTINCT "foo" FROM "abc"', str(q)) + + def test_select__distinct__multi(self): + q = Query.from_("abc").select("foo", "bar").distinct() + + self.assertEqual('SELECT DISTINCT "foo","bar" FROM "abc"', str(q)) + + def test_select__column__single__str(self): + q = Query.from_("abc").select("foo") + + self.assertEqual('SELECT "foo" FROM "abc"', str(q)) + + def test_select__column__single__alias__str(self): + q = Query.from_(self.table_abc).select(self.table_abc.foo.as_("bar")) + + self.assertEqual('SELECT "foo" "bar" FROM "abc"', str(q)) + + def test_select__column__single__table_alias__str(self): + q = Query.from_(self.table_abc.as_("fizzbuzz")).select(self.table_abc.foo.as_("bar")) + + self.assertEqual('SELECT "foo" "bar" FROM "abc" "fizzbuzz"', str(q)) + + def test_select__column__single__field(self): + t = Table("abc") + q = Query.from_(t).select(t.foo) + + self.assertEqual('SELECT "foo" FROM "abc"', str(q)) + + def test_select__columns__multi__str(self): + q1 = Query.from_("abc").select("foo", "bar") + q2 = Query.from_("abc").select("foo").select("bar") + + self.assertEqual('SELECT "foo","bar" FROM "abc"', str(q1)) + self.assertEqual('SELECT "foo","bar" FROM "abc"', str(q2)) + + def test_select__columns__multi__field(self): + q1 = Query.from_(self.table_abc).select(self.table_abc.foo, self.table_abc.bar) + q2 = Query.from_(self.table_abc).select(self.table_abc.foo).select(self.table_abc.bar) + + self.assertEqual('SELECT "foo","bar" FROM "abc"', str(q1)) + self.assertEqual('SELECT "foo","bar" FROM "abc"', str(q2)) + + def test_select__multiple_tables(self): + q = Query.from_(self.table_abc).select(self.table_abc.foo).from_(self.table_efg).select(self.table_efg.bar) + + self.assertEqual('SELECT "abc"."foo","efg"."bar" FROM "abc","efg"', str(q)) + + def test_select__subquery(self): + subquery = Query.from_(self.table_abc).select("*") + q = Query.from_(subquery).select(subquery.foo, subquery.bar) + + self.assertEqual('SELECT "sq0"."foo","sq0"."bar" ' 'FROM (SELECT * FROM "abc") "sq0"', str(q)) + + def test_select__multiple_subqueries(self): + subquery0 = Query.from_(self.table_abc).select("foo") + subquery1 = Query.from_(self.table_efg).select("bar") + q = Query.from_(subquery0).from_(subquery1).select(subquery0.foo, subquery1.bar) + + self.assertEqual( + 'SELECT "sq0"."foo","sq1"."bar" ' 'FROM (SELECT "foo" FROM "abc") "sq0",' '(SELECT "bar" FROM "efg") "sq1"', + str(q), + ) + + def test_select__nested_subquery(self): + subquery0 = Query.from_(self.table_abc).select("*") + subquery1 = Query.from_(subquery0).select(subquery0.foo, subquery0.bar) + subquery2 = Query.from_(subquery1).select(subquery1.foo) + + q = Query.from_(subquery2).select(subquery2.foo) + + self.assertEqual( + 'SELECT "sq2"."foo" ' + 'FROM (SELECT "sq1"."foo" ' + 'FROM (SELECT "sq0"."foo","sq0"."bar" ' + 'FROM (SELECT * FROM "abc") "sq0") "sq1") "sq2"', + str(q), + ) + + def test_select__no_table(self): + q = Query.select(1, 2, 3) + + self.assertEqual("SELECT 1,2,3", str(q)) + + def test_select_then_add_table(self): + q = Query.select(1).select(2, 3).from_("abc").select("foo") + + self.assertEqual('SELECT 1,2,3,"foo" FROM "abc"', str(q)) + + def test_select_with_limit(self): + q1 = Query.from_("abc").select("foo")[:10] + + self.assertEqual('SELECT "foo" FROM "abc" LIMIT 10', str(q1)) + + def test_select_with_limit_zero(self): + with self.subTest('using python slice'): + q1 = Query.from_("abc").select("foo")[:0] + self.assertEqual('SELECT "foo" FROM "abc" LIMIT 0', str(q1)) + + with self.subTest('using limit method'): + q2 = Query.from_("abc").select("foo").limit(0) + self.assertEqual('SELECT "foo" FROM "abc" LIMIT 0', str(q2)) + + def test_select_with_limit__func(self): + q1 = Query.from_("abc").select("foo").limit(10) + + self.assertEqual('SELECT "foo" FROM "abc" LIMIT 10', str(q1)) + + def test_select_with_offset(self): + q1 = Query.from_("abc").select("foo")[10:] + + self.assertEqual('SELECT "foo" FROM "abc" OFFSET 10', str(q1)) + + def test_select_with_offset__func(self): + q1 = Query.from_("abc").select("foo").offset(10) + + self.assertEqual('SELECT "foo" FROM "abc" OFFSET 10', str(q1)) + + def test_select_with_limit_and_offset(self): + q1 = Query.from_("abc").select("foo")[10:10] + + self.assertEqual('SELECT "foo" FROM "abc" LIMIT 10 OFFSET 10', str(q1)) + + def test_select_with_force_index(self): + q = Query.from_("abc").select("foo").force_index("egg") + + self.assertEqual('SELECT "foo" FROM "abc" FORCE INDEX ("egg")', str(q)) + + def test_select_with_force_index_with_index_object(self): + index = Index("egg") + q = Query.from_("abc").select("foo").force_index(index) + + self.assertEqual('SELECT "foo" FROM "abc" FORCE INDEX ("egg")', str(q)) + + def test_select_with_force_index_multiple_indexes(self): + q = Query.from_("abc").select("foo").force_index("egg", "bacon") + + self.assertEqual('SELECT "foo" FROM "abc" FORCE INDEX ("egg","bacon")', str(q)) + + def test_select_with_force_index_multiple_calls(self): + q = ( + Query.from_("abc") + .select("foo") + .force_index( + "egg", + ) + .force_index("spam") + ) + + self.assertEqual('SELECT "foo" FROM "abc" FORCE INDEX ("egg","spam")', str(q)) + + def test_select_with_use_index(self): + q = Query.from_("abc").select("foo").use_index("egg") + + self.assertEqual('SELECT "foo" FROM "abc" USE INDEX ("egg")', str(q)) + + def test_select_with_use_index_with_index_object(self): + index = Index("egg") + q = Query.from_("abc").select("foo").use_index(index) + + self.assertEqual('SELECT "foo" FROM "abc" USE INDEX ("egg")', str(q)) + + def test_select_with_use_index_multiple_indexes(self): + q = Query.from_("abc").select("foo").use_index("egg", "bacon") + + self.assertEqual('SELECT "foo" FROM "abc" USE INDEX ("egg","bacon")', str(q)) + + def test_select_with_use_index_multiple_calls(self): + q = ( + Query.from_("abc") + .select("foo") + .use_index( + "egg", + ) + .use_index("spam") + ) + + self.assertEqual('SELECT "foo" FROM "abc" USE INDEX ("egg","spam")', str(q)) + + def test_mysql_query_uses_backtick_quote_chars(self): + q = MySQLQuery.from_("abc").select("foo", "bar") + + self.assertEqual("SELECT `foo`,`bar` FROM `abc`", str(q)) + + def test_vertica_query_uses_double_quote_chars(self): + q = VerticaQuery.from_("abc").select("foo", "bar") + + self.assertEqual('SELECT "foo","bar" FROM "abc"', str(q)) + + def test_mssql_query_uses_double_quote_chars(self): + q = MSSQLQuery.from_("abc").select("foo", "bar") + + self.assertEqual('SELECT "foo","bar" FROM "abc"', str(q)) + + def test_oracle_query_uses_no_quote_chars(self): + q = OracleQuery.from_("abc").select("foo", "bar") + + self.assertEqual('SELECT foo,bar FROM abc', str(q)) + + def test_postgresql_query_uses_double_quote_chars(self): + q = PostgreSQLQuery.from_("abc").select("foo", "bar") + + self.assertEqual('SELECT "foo","bar" FROM "abc"', str(q)) + + def test_redshift_query_uses_double_quote_chars(self): + q = RedshiftQuery.from_("abc").select("foo", "bar") + + self.assertEqual('SELECT "foo","bar" FROM "abc"', str(q)) + + def test_table_select_alias(self): + q = self.table_abc.select(1) + + self.assertEqual('SELECT 1 FROM "abc"', str(q)) + self.assertEqual(q, Query.from_("abc").select(1)) + + def test_table_select_alias_with_offset_and_limit(self): + self.assertEqual(self.table_abc.select("foo")[10:10], Query.from_("abc").select("foo")[10:10]) + self.assertEqual( + self.table_abc.select(self.table_abc.foo)[10:10], + Query.from_("abc").select("foo")[10:10], + ) + + def test_temporal_select(self): + t = Table("abc") + + with self.subTest("with system time as of"): + q = Query.from_(t.for_(SYSTEM_TIME.as_of('2020-01-01'))).select("*") + + self.assertEqual('SELECT * FROM "abc" FOR SYSTEM_TIME AS OF \'2020-01-01\'', str(q)) + + with self.subTest("with system time between"): + q = Query.from_(t.for_(SYSTEM_TIME.between('2020-01-01', '2020-02-01'))).select("*") + + self.assertEqual('SELECT * FROM "abc" FOR SYSTEM_TIME BETWEEN \'2020-01-01\' AND \'2020-02-01\'', str(q)) + + with self.subTest("with system time from to"): + q = Query.from_(t.for_(SYSTEM_TIME.from_to('2020-01-01', '2020-02-01'))).select("*") + + self.assertEqual('SELECT * FROM "abc" FOR SYSTEM_TIME FROM \'2020-01-01\' TO \'2020-02-01\'', str(q)) + + with self.subTest("with ALL"): + q = Query.from_(t.for_(SYSTEM_TIME.all_())).select("*") + + self.assertEqual('SELECT * FROM "abc" FOR SYSTEM_TIME ALL', str(q)) + + with self.subTest("with period between"): + q = Query.from_(t.for_(t.valid_period.between('2020-01-01', '2020-02-01'))).select("*") + + self.assertEqual('SELECT * FROM "abc" FOR "valid_period" BETWEEN \'2020-01-01\' AND \'2020-02-01\'', str(q)) + + with self.subTest("with period from to"): + q = Query.from_(t.for_(t.valid_period.from_to('2020-01-01', '2020-02-01'))).select("*") + + self.assertEqual('SELECT * FROM "abc" FOR "valid_period" FROM \'2020-01-01\' TO \'2020-02-01\'', str(q)) + + with self.subTest("with ALL"): + q = Query.from_(t.for_(t.valid_period.all_())).select("*") + + self.assertEqual('SELECT * FROM "abc" FOR "valid_period" ALL', str(q)) + + +class MyEnum(Enum): + STR = "foo" + INT = 0 + BOOL = True + DATE = date(2020, 2, 2) + NONE = None + + +class WhereTests(unittest.TestCase): + t = Table("abc") + t2 = Table("cba") + + def test_where_enum(self): + q1 = Query.from_(self.t).select("*").where(self.t.foo == MyEnum.STR) + q2 = Query.from_(self.t).select("*").where(self.t.foo == MyEnum.INT) + q3 = Query.from_(self.t).select("*").where(self.t.foo == MyEnum.BOOL) + q4 = Query.from_(self.t).select("*").where(self.t.foo == MyEnum.DATE) + q5 = Query.from_(self.t).select("*").where(self.t.foo == MyEnum.NONE) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo"=\'foo\'', str(q1)) + self.assertEqual('SELECT * FROM "abc" WHERE "foo"=0', str(q2)) + self.assertEqual('SELECT * FROM "abc" WHERE "foo"=true', str(q3)) + self.assertEqual('SELECT * FROM "abc" WHERE "foo"=\'2020-02-02\'', str(q4)) + self.assertEqual('SELECT * FROM "abc" WHERE "foo"=null', str(q5)) + + def test_where_field_equals(self): + q1 = Query.from_(self.t).select("*").where(self.t.foo == self.t.bar) + q2 = Query.from_(self.t).select("*").where(self.t.foo.eq(self.t.bar)) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo"="bar"', str(q1)) + self.assertEqual('SELECT * FROM "abc" WHERE "foo"="bar"', str(q2)) + q = self.t.select("*").where(self.t.foo == self.t.bar) + self.assertEqual(q, q1) + + def test_where_field_equals_for_update(self): + q = Query.from_(self.t).select("*").where(self.t.foo == self.t.bar).for_update() + self.assertEqual('SELECT * FROM "abc" WHERE "foo"="bar" FOR UPDATE', str(q)) + + def test_where_field_equals_for_update_nowait(self): + for query_cls in [ + MySQLQuery, + PostgreSQLQuery, + ]: + quote_char = query_cls._builder().QUOTE_CHAR if isinstance(query_cls._builder().QUOTE_CHAR, str) else '"' + q = query_cls.from_(self.t).select("*").where(self.t.foo == self.t.bar).for_update(nowait=True) + self.assertEqual( + 'SELECT * ' + 'FROM {quote_char}abc{quote_char} ' + 'WHERE {quote_char}foo{quote_char}={quote_char}bar{quote_char} ' + 'FOR UPDATE NOWAIT'.format( + quote_char=quote_char, + ), + str(q), + ) + + def test_where_field_equals_for_update_skip_locked(self): + for query_cls in [ + MySQLQuery, + PostgreSQLQuery, + ]: + quote_char = query_cls._builder().QUOTE_CHAR if isinstance(query_cls._builder().QUOTE_CHAR, str) else '"' + q = query_cls.from_(self.t).select("*").where(self.t.foo == self.t.bar).for_update(skip_locked=True) + self.assertEqual( + 'SELECT * ' + 'FROM {quote_char}abc{quote_char} ' + 'WHERE {quote_char}foo{quote_char}={quote_char}bar{quote_char} ' + 'FOR UPDATE SKIP LOCKED'.format( + quote_char=quote_char, + ), + str(q), + ) + + def test_where_field_equals_for_update_of(self): + for query_cls in [ + MySQLQuery, + PostgreSQLQuery, + ]: + quote_char = query_cls._builder().QUOTE_CHAR if isinstance(query_cls._builder().QUOTE_CHAR, str) else '"' + q = query_cls.from_(self.t).select("*").where(self.t.foo == self.t.bar).for_update(of=("abc",)) + self.assertEqual( + 'SELECT * ' + 'FROM {quote_char}abc{quote_char} ' + 'WHERE {quote_char}foo{quote_char}={quote_char}bar{quote_char} ' + 'FOR UPDATE OF {quote_char}abc{quote_char}'.format( + quote_char=quote_char, + ), + str(q), + ) + + def test_where_field_equals_for_update_of_multiple_tables(self): + for query_cls in [ + MySQLQuery, + PostgreSQLQuery, + ]: + q = ( + query_cls.from_(self.t) + .join(self.t2) + .on(self.t.id == self.t2.abc_id) + .select("*") + .where(self.t.foo == self.t.bar) + .for_update(of=("abc", "cba")) + ) + quote_char = query_cls._builder().QUOTE_CHAR if isinstance(query_cls._builder().QUOTE_CHAR, str) else '"' + self.assertIn( + str(q), + [ + 'SELECT * ' + 'FROM {quote_char}abc{quote_char} ' + 'JOIN {quote_char}cba{quote_char} ' + 'ON {quote_char}abc{quote_char}.{quote_char}id{quote_char}=' + '{quote_char}cba{quote_char}.{quote_char}abc_id{quote_char} ' + 'WHERE {quote_char}abc{quote_char}.{quote_char}foo{quote_char}=' + '{quote_char}abc{quote_char}.{quote_char}bar{quote_char} ' + 'FOR UPDATE OF {quote_char}cba{quote_char}, {quote_char}abc{quote_char}'.format( + quote_char=quote_char, + ), + 'SELECT * ' + 'FROM {quote_char}abc{quote_char} ' + 'JOIN {quote_char}cba{quote_char} ' + 'ON {quote_char}abc{quote_char}.{quote_char}id{quote_char}=' + '{quote_char}cba{quote_char}.{quote_char}abc_id{quote_char} ' + 'WHERE {quote_char}abc{quote_char}.{quote_char}foo{quote_char}=' + '{quote_char}abc{quote_char}.{quote_char}bar{quote_char} ' + 'FOR UPDATE OF {quote_char}abc{quote_char}, {quote_char}cba{quote_char}'.format( + quote_char=quote_char, + ), + ], + ) + + def test_where_field_equals_for_update_of_nowait(self): + for query_cls in [ + MySQLQuery, + PostgreSQLQuery, + ]: + q = query_cls.from_(self.t).select("*").where(self.t.foo == self.t.bar).for_update(of=("abc",), nowait=True) + quote_char = query_cls._builder().QUOTE_CHAR if isinstance(query_cls._builder().QUOTE_CHAR, str) else '"' + self.assertEqual( + 'SELECT * ' + 'FROM {quote_char}abc{quote_char} ' + 'WHERE {quote_char}foo{quote_char}={quote_char}bar{quote_char} ' + 'FOR UPDATE OF {quote_char}abc{quote_char} NOWAIT'.format( + quote_char=quote_char, + ), + str(q), + ) + + def test_where_field_equals_for_update_of_skip_locked(self): + for query_cls in [ + MySQLQuery, + PostgreSQLQuery, + ]: + q = ( + query_cls.from_(self.t) + .select("*") + .where(self.t.foo == self.t.bar) + .for_update(of=("abc",), skip_locked=True) + ) + quote_char = query_cls._builder().QUOTE_CHAR if isinstance(query_cls._builder().QUOTE_CHAR, str) else '"' + self.assertEqual( + 'SELECT * ' + 'FROM {quote_char}abc{quote_char} ' + 'WHERE {quote_char}foo{quote_char}={quote_char}bar{quote_char} ' + 'FOR UPDATE OF {quote_char}abc{quote_char} SKIP LOCKED'.format( + quote_char=quote_char, + ), + str(q), + ) + + def test_where_field_equals_for_update_skip_locked_and_of(self): + for query_cls in [ + MySQLQuery, + PostgreSQLQuery, + ]: + q = ( + query_cls.from_(self.t) + .select("*") + .where(self.t.foo == self.t.bar) + .for_update(nowait=False, skip_locked=True, of=("abc",)) + ) + quote_char = query_cls._builder().QUOTE_CHAR if isinstance(query_cls._builder().QUOTE_CHAR, str) else '"' + self.assertEqual( + 'SELECT * ' + 'FROM {quote_char}abc{quote_char} ' + 'WHERE {quote_char}foo{quote_char}={quote_char}bar{quote_char} ' + 'FOR UPDATE OF {quote_char}abc{quote_char} SKIP LOCKED'.format( + quote_char=quote_char, + ), + str(q), + ) + + def test_where_field_equals_where(self): + q = Query.from_(self.t).select("*").where(self.t.foo == 1).where(self.t.bar == self.t.baz) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo"=1 AND "bar"="baz"', str(q)) + + def test_where_field_equals_where_not(self): + q = Query.from_(self.t).select("*").where((self.t.foo == 1).negate()).where(self.t.bar == self.t.baz) + + self.assertEqual('SELECT * FROM "abc" WHERE NOT "foo"=1 AND "bar"="baz"', str(q)) + + def test_where_field_equals_where_two_not(self): + q = Query.from_(self.t).select("*").where((self.t.foo == 1).negate()).where((self.t.bar == self.t.baz).negate()) + + self.assertEqual('SELECT * FROM "abc" WHERE NOT "foo"=1 AND NOT "bar"="baz"', str(q)) + + def test_where_single_quote(self): + q1 = Query.from_(self.t).select("*").where(self.t.foo == "bar'foo") + + self.assertEqual("SELECT * FROM \"abc\" WHERE \"foo\"='bar''foo'", str(q1)) + + def test_where_field_equals_and(self): + q = Query.from_(self.t).select("*").where((self.t.foo == 1) & (self.t.bar == self.t.baz)) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo"=1 AND "bar"="baz"', str(q)) + + def test_where_field_equals_or(self): + q = Query.from_(self.t).select("*").where((self.t.foo == 1) | (self.t.bar == self.t.baz)) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo"=1 OR "bar"="baz"', str(q)) + + def test_where_nested_conditions(self): + q = Query.from_(self.t).select("*").where((self.t.foo == 1) | (self.t.bar == self.t.baz)).where(self.t.baz == 0) + + self.assertEqual('SELECT * FROM "abc" WHERE ("foo"=1 OR "bar"="baz") AND "baz"=0', str(q)) + + def test_where_field_starts_with(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.like("ab%")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" LIKE \'ab%\'', str(q)) + + def test_where_field_contains(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.like("%fg%")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" LIKE \'%fg%\'', str(q)) + + def test_where_field_ends_with(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.like("%yz")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" LIKE \'%yz\'', str(q)) + + def test_where_field_is_n_chars_long(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.like("___")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" LIKE \'___\'', str(q)) + + def test_where_field_does_not_start_with(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.not_like("ab%")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" NOT LIKE \'ab%\'', str(q)) + + def test_where_field_does_not_contain(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.not_like("%fg%")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" NOT LIKE \'%fg%\'', str(q)) + + def test_where_field_does_not_end_with(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.not_like("%yz")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" NOT LIKE \'%yz\'', str(q)) + + def test_where_field_is_not_n_chars_long(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.not_like("___")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" NOT LIKE \'___\'', str(q)) + + def test_where_field_matches_regex(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.regex(r"^b")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" REGEX \'^b\'', str(q)) + + def test_where_field_matches_regexp(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.regexp(r"^b")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" REGEXP \'^b\'', str(q)) + + def test_where_field_matches_rlike(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.rlike(r"^b")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" RLIKE \'^b\'', str(q)) + + def test_ignore_empty_criterion_where(self): + q1 = Query.from_(self.t).select("*").where(EmptyCriterion()) + + self.assertEqual('SELECT * FROM "abc"', str(q1)) + + def test_ignore_empty_criterion_having(self): + q1 = Query.from_(self.t).select("*").having(EmptyCriterion()) + + self.assertEqual('SELECT * FROM "abc"', str(q1)) + + def test_select_with_force_index_and_where(self): + q = Query.from_("abc").select("foo").where(self.t.foo == self.t.bar).force_index("egg") + + self.assertEqual('SELECT "foo" FROM "abc" FORCE INDEX ("egg") WHERE "foo"="bar"', str(q)) + + def test_where_with_multiple_wheres_using_and_case(self): + case_stmt = Case().when(self.t.foo == 'bar', 1).else_(0) + query = Query.from_(self.t).select(case_stmt).where(case_stmt & self.t.blah.isin(['test'])) + + self.assertEqual( + 'SELECT CASE WHEN "foo"=\'bar\' THEN 1 ELSE 0 END FROM "abc" WHERE CASE WHEN "foo"=\'bar\' THEN 1 ELSE 0 ' + 'END AND "blah" IN (\'test\')', + str(query), + ) + + def test_where_with_multiple_wheres_using_or_case(self): + case_stmt = Case().when(self.t.foo == 'bar', 1).else_(0) + query = Query.from_(self.t).select(case_stmt).where(case_stmt | self.t.blah.isin(['test'])) + + self.assertEqual( + 'SELECT CASE WHEN "foo"=\'bar\' THEN 1 ELSE 0 END FROM "abc" WHERE CASE WHEN "foo"=\'bar\' THEN 1 ELSE 0 ' + 'END OR "blah" IN (\'test\')', + str(query), + ) + + +class PreWhereTests(WhereTests): + t = Table("abc") + + def test_prewhere_field_equals(self): + q1 = Query.from_(self.t).select("*").prewhere(self.t.foo == self.t.bar) + q2 = Query.from_(self.t).select("*").prewhere(self.t.foo.eq(self.t.bar)) + + self.assertEqual('SELECT * FROM "abc" PREWHERE "foo"="bar"', str(q1)) + self.assertEqual('SELECT * FROM "abc" PREWHERE "foo"="bar"', str(q2)) + + def test_where_and_prewhere(self): + q = Query.from_(self.t).select("*").prewhere(self.t.foo == self.t.bar).where(self.t.foo == self.t.bar) + + self.assertEqual('SELECT * FROM "abc" PREWHERE "foo"="bar" WHERE "foo"="bar"', str(q)) + + +class GroupByTests(unittest.TestCase): + t = Table("abc") + maxDiff = None + + def test_groupby__single(self): + q = Query.from_(self.t).groupby(self.t.foo).select(self.t.foo) + + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo"', str(q)) + + def test_groupby__multi(self): + q = Query.from_(self.t).groupby(self.t.foo, self.t.bar).select(self.t.foo, self.t.bar) + + self.assertEqual('SELECT "foo","bar" FROM "abc" GROUP BY "foo","bar"', str(q)) + + def test_groupby__count_star(self): + q = Query.from_(self.t).groupby(self.t.foo).select(self.t.foo, fn.Count("*")) + + self.assertEqual('SELECT "foo",COUNT(*) FROM "abc" GROUP BY "foo"', str(q)) + + def test_groupby__count_field(self): + q = Query.from_(self.t).groupby(self.t.foo).select(self.t.foo, fn.Count(self.t.bar)) + + self.assertEqual('SELECT "foo",COUNT("bar") FROM "abc" GROUP BY "foo"', str(q)) + + def test_groupby__count_distinct(self): + q = Query.from_(self.t).groupby(self.t.foo).select(self.t.foo, fn.Count("*").distinct()) + + self.assertEqual('SELECT "foo",COUNT(DISTINCT *) FROM "abc" GROUP BY "foo"', str(q)) + + def test_groupby__sum_distinct(self): + q = Query.from_(self.t).groupby(self.t.foo).select(self.t.foo, fn.Sum(self.t.bar).distinct()) + + self.assertEqual('SELECT "foo",SUM(DISTINCT "bar") FROM "abc" GROUP BY "foo"', str(q)) + + def test_groupby__sum_filter(self): + q = ( + Query.from_(self.t) + .groupby(self.t.foo) + .select(self.t.foo, fn.Sum(self.t.bar).filter(self.t.id.eq(1) & self.t.cid.gt(2))) + ) + + self.assertEqual('SELECT "foo",SUM("bar") FILTER(WHERE "id"=1 AND "cid">2) FROM "abc" GROUP BY "foo"', str(q)) + + def test_groupby__str(self): + q = Query.from_("abc").groupby("foo").select("foo", fn.Count("*").distinct()) + + self.assertEqual('SELECT "foo",COUNT(DISTINCT *) FROM "abc" GROUP BY "foo"', str(q)) + + def test_groupby__int(self): + q = Query.from_("abc").groupby(1).select("foo", fn.Count("*").distinct()) + + self.assertEqual('SELECT "foo",COUNT(DISTINCT *) FROM "abc" GROUP BY 1', str(q)) + + def test_groupby__alias(self): + bar = self.t.bar.as_("bar01") + q = Query.from_(self.t).select(fn.Sum(self.t.foo), bar).groupby(bar) + + self.assertEqual('SELECT SUM("foo"),"bar" "bar01" FROM "abc" GROUP BY "bar01"', str(q)) + + def test_groupby__no_alias(self): + bar = self.t.bar.as_("bar01") + q = Query.from_(self.t).select(fn.Sum(self.t.foo), bar).groupby(bar) + + self.assertEqual( + 'SELECT SUM("foo"),"bar" "bar01" FROM "abc" GROUP BY "bar"', + q.get_sql(groupby_alias=False), + ) + + def test_groupby__no_alias_mssql(self): + bar = self.t.bar.as_("bar01") + q = MSSQLQuery.from_(self.t).select(fn.Sum(self.t.foo), bar).groupby(bar) + + self.assertEqual('SELECT SUM("foo"),"bar" "bar01" FROM "abc" GROUP BY "bar"', str(q)) + + def test_groupby__no_alias_oracle(self): + bar = self.t.bar.as_("bar01") + q = OracleQuery.from_(self.t).select(fn.Sum(self.t.foo), bar).groupby(bar) + + self.assertEqual('SELECT SUM(foo),bar bar01 FROM abc GROUP BY bar', str(q)) + + def test_groupby__alias_platforms(self): + bar = self.t.bar.as_("bar01") + + for query_cls in [ + MySQLQuery, + VerticaQuery, + PostgreSQLQuery, + RedshiftQuery, + ClickHouseQuery, + SQLLiteQuery, + ]: + q = query_cls.from_(self.t).select(fn.Sum(self.t.foo), bar).groupby(bar) + + quote_char = query_cls._builder().QUOTE_CHAR if isinstance(query_cls._builder().QUOTE_CHAR, str) else '"' + + self.assertEqual( + "SELECT " + "SUM({quote_char}foo{quote_char})," + "{quote_char}bar{quote_char}{as_keyword}{quote_char}bar01{quote_char} " + "FROM {quote_char}abc{quote_char} " + "GROUP BY {quote_char}bar01{quote_char}".format( + as_keyword=' AS ' if query_cls is ClickHouseQuery else ' ', quote_char=quote_char + ), + str(q), + ) + + def test_groupby__alias_with_join(self): + table1 = Table("table1", alias="t1") + bar = table1.bar.as_("bar01") + q = Query.from_(self.t).join(table1).on(self.t.id == table1.t_ref).select(fn.Sum(self.t.foo), bar).groupby(bar) + + self.assertEqual( + 'SELECT SUM("abc"."foo"),"t1"."bar" "bar01" FROM "abc" ' + 'JOIN "table1" "t1" ON "abc"."id"="t1"."t_ref" ' + 'GROUP BY "bar01"', + str(q), + ) + + def test_groupby_with_case_uses_the_alias(self): + q = ( + Query.from_(self.t) + .select( + fn.Sum(self.t.foo).as_("bar"), + Case().when(self.t.fname == "Tom", "It was Tom").else_("It was someone else.").as_("who_was_it"), + ) + .groupby(Case().when(self.t.fname == "Tom", "It was Tom").else_("It was someone else.").as_("who_was_it")) + ) + + self.assertEqual( + 'SELECT SUM("foo") "bar",' + "CASE WHEN \"fname\"='Tom' THEN 'It was Tom' " + "ELSE 'It was someone else.' END \"who_was_it\" " + 'FROM "abc" ' + 'GROUP BY "who_was_it"', + str(q), + ) + + def test_mysql_query_uses_backtick_quote_chars(self): + q = MySQLQuery.from_(self.t).groupby(self.t.foo).select(self.t.foo) + + self.assertEqual("SELECT `foo` FROM `abc` GROUP BY `foo`", str(q)) + + def test_vertica_query_uses_double_quote_chars(self): + q = VerticaQuery.from_(self.t).groupby(self.t.foo).select(self.t.foo) + + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo"', str(q)) + + def test_mssql_query_uses_double_quote_chars(self): + q = MSSQLQuery.from_(self.t).groupby(self.t.foo).select(self.t.foo) + + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo"', str(q)) + + def test_oracle_query_uses_no_quote_chars(self): + q = OracleQuery.from_(self.t).groupby(self.t.foo).select(self.t.foo) + + self.assertEqual('SELECT foo FROM abc GROUP BY foo', str(q)) + + def test_postgres_query_uses_double_quote_chars(self): + q = PostgreSQLQuery.from_(self.t).groupby(self.t.foo).select(self.t.foo) + + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo"', str(q)) + + def test_redshift_query_uses_double_quote_chars(self): + q = RedshiftQuery.from_(self.t).groupby(self.t.foo).select(self.t.foo) + + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo"', str(q)) + + def test_group_by__single_with_totals(self): + q = Query.from_(self.t).groupby(self.t.foo).select(self.t.foo).with_totals() + + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo" WITH TOTALS', str(q)) + + def test_groupby__multi_with_totals(self): + q = Query.from_(self.t).groupby(self.t.foo, self.t.bar).select(self.t.foo, self.t.bar).with_totals() + + self.assertEqual('SELECT "foo","bar" FROM "abc" GROUP BY "foo","bar" WITH TOTALS', str(q)) + + +class HavingTests(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_having_greater_than(self): + q = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, fn.Sum(self.table_abc.bar)) + .groupby(self.table_abc.foo) + .having(fn.Sum(self.table_abc.bar) > 1) + ) + + self.assertEqual( + 'SELECT "foo",SUM("bar") FROM "abc" GROUP BY "foo" HAVING SUM("bar")>1', + str(q), + ) + + def test_having_and(self): + q = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, fn.Sum(self.table_abc.bar)) + .groupby(self.table_abc.foo) + .having((fn.Sum(self.table_abc.bar) > 1) & (fn.Sum(self.table_abc.bar) < 100)) + ) + + self.assertEqual( + 'SELECT "foo",SUM("bar") FROM "abc" GROUP BY "foo" HAVING SUM("bar")>1 AND SUM("bar")<100', + str(q), + ) + + def test_having_join_and_equality(self): + q = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.foo) + .select(self.table_abc.foo, fn.Sum(self.table_efg.bar), self.table_abc.buz) + .groupby(self.table_abc.foo) + .having(self.table_abc.buz == "fiz") + .having(fn.Sum(self.table_efg.bar) > 100) + ) + + self.assertEqual( + 'SELECT "abc"."foo",SUM("efg"."bar"),"abc"."buz" FROM "abc" ' + 'JOIN "efg" ON "abc"."foo"="efg"."foo" ' + 'GROUP BY "abc"."foo" ' + 'HAVING "abc"."buz"=\'fiz\' AND SUM("efg"."bar")>100', + str(q), + ) + + def test_mysql_query_uses_backtick_quote_chars(self): + q = ( + MySQLQuery.from_(self.table_abc) + .select(self.table_abc.foo) + .groupby(self.table_abc.foo) + .having(self.table_abc.buz == "fiz") + ) + self.assertEqual("SELECT `foo` FROM `abc` GROUP BY `foo` HAVING `buz`='fiz'", str(q)) + + def test_vertica_query_uses_double_quote_chars(self): + q = ( + VerticaQuery.from_(self.table_abc) + .select(self.table_abc.foo) + .groupby(self.table_abc.foo) + .having(self.table_abc.buz == "fiz") + ) + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo" HAVING "buz"=\'fiz\'', str(q)) + + def test_mssql_query_uses_double_quote_chars(self): + q = ( + MSSQLQuery.from_(self.table_abc) + .select(self.table_abc.foo) + .groupby(self.table_abc.foo) + .having(self.table_abc.buz == "fiz") + ) + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo" HAVING "buz"=\'fiz\'', str(q)) + + def test_oracle_query_uses_no_quote_chars(self): + q = ( + OracleQuery.from_(self.table_abc) + .select(self.table_abc.foo) + .groupby(self.table_abc.foo) + .having(self.table_abc.buz == "fiz") + ) + self.assertEqual('SELECT foo FROM abc GROUP BY foo HAVING buz=\'fiz\'', str(q)) + + def test_postgres_query_uses_double_quote_chars(self): + q = ( + PostgreSQLQuery.from_(self.table_abc) + .select(self.table_abc.foo) + .groupby(self.table_abc.foo) + .having(self.table_abc.buz == "fiz") + ) + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo" HAVING "buz"=\'fiz\'', str(q)) + + def test_redshift_query_uses_double_quote_chars(self): + q = ( + RedshiftQuery.from_(self.table_abc) + .select(self.table_abc.foo) + .groupby(self.table_abc.foo) + .having(self.table_abc.buz == "fiz") + ) + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo" HAVING "buz"=\'fiz\'', str(q)) + + +class OrderByTests(unittest.TestCase): + t = Table("abc") + + def test_orderby_single_field(self): + q = Query.from_(self.t).orderby(self.t.foo).select(self.t.foo) + + self.assertEqual('SELECT "foo" FROM "abc" ORDER BY "foo"', str(q)) + + def test_orderby_multi_fields(self): + q = Query.from_(self.t).orderby(self.t.foo, self.t.bar).select(self.t.foo, self.t.bar) + + self.assertEqual('SELECT "foo","bar" FROM "abc" ORDER BY "foo","bar"', str(q)) + + def test_orderby_single_str(self): + q = Query.from_("abc").orderby("foo").select("foo") + + self.assertEqual('SELECT "foo" FROM "abc" ORDER BY "foo"', str(q)) + + def test_orderby_asc(self): + q = Query.from_(self.t).orderby(self.t.foo, order=Order.asc).select(self.t.foo) + + self.assertEqual('SELECT "foo" FROM "abc" ORDER BY "foo" ASC', str(q)) + + def test_orderby_desc(self): + q = Query.from_(self.t).orderby(self.t.foo, order=Order.desc).select(self.t.foo) + + self.assertEqual('SELECT "foo" FROM "abc" ORDER BY "foo" DESC', str(q)) + + def test_orderby_no_alias(self): + bar = self.t.bar.as_("bar01") + q = Query.from_(self.t).select(fn.Sum(self.t.foo), bar).orderby(bar) + + self.assertEqual( + 'SELECT SUM("foo"),"bar" "bar01" FROM "abc" ORDER BY "bar"', + q.get_sql(orderby_alias=False), + ) + + def test_orderby_alias(self): + bar = self.t.bar.as_("bar01") + q = Query.from_(self.t).select(fn.Sum(self.t.foo), bar).orderby(bar) + + self.assertEqual('SELECT SUM("foo"),"bar" "bar01" FROM "abc" ORDER BY "bar01"', q.get_sql()) + + +class AliasTests(unittest.TestCase): + t = Table("abc") + + def test_table_field(self): + q = Query.from_(self.t).select(self.t.foo.as_("bar")) + + self.assertEqual('SELECT "foo" "bar" FROM "abc"', str(q)) + + def test_table_field__multi(self): + q = Query.from_(self.t).select(self.t.foo.as_("bar"), self.t.fiz.as_("buz")) + + self.assertEqual('SELECT "foo" "bar","fiz" "buz" FROM "abc"', str(q)) + + def test_arithmetic_function(self): + q = Query.from_(self.t).select((self.t.foo + self.t.bar).as_("biz")) + + self.assertEqual('SELECT "foo"+"bar" "biz" FROM "abc"', str(q)) + + def test_functions_using_as(self): + q = Query.from_(self.t).select(fn.Count("*").as_("foo")) + + self.assertEqual('SELECT COUNT(*) "foo" FROM "abc"', str(q)) + + def test_functions_using_constructor_param(self): + q = Query.from_(self.t).select(fn.Count("*", alias="foo")) + + self.assertEqual('SELECT COUNT(*) "foo" FROM "abc"', str(q)) + + def test_function_using_as_nested(self): + """ + We don't show aliases of fields that are arguments of a function. + """ + q = Query.from_(self.t).select(fn.Sqrt(fn.Count("*").as_("foo")).as_("bar")) + + self.assertEqual('SELECT SQRT(COUNT(*)) "bar" FROM "abc"', str(q)) + + def test_functions_using_constructor_param_nested(self): + """ + We don't show aliases of fields that are arguments of a function. + """ + q = Query.from_(self.t).select(fn.Sqrt(fn.Count("*", alias="foo"), alias="bar")) + + self.assertEqual('SELECT SQRT(COUNT(*)) "bar" FROM "abc"', str(q)) + + def test_ignored_in_where(self): + q = Query.from_(self.t).select(self.t.foo).where(self.t.foo.as_("bar") == 1) + + self.assertEqual('SELECT "foo" FROM "abc" WHERE "foo"=1', str(q)) + + def test_ignored_in_groupby(self): + q = Query.from_(self.t).select(self.t.foo).groupby(self.t.foo.as_("bar")) + + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo"', str(q)) + + def test_ignored_in_orderby(self): + q = Query.from_(self.t).select(self.t.foo).orderby(self.t.foo.as_("bar")) + + self.assertEqual('SELECT "foo" FROM "abc" ORDER BY "foo"', str(q)) + + def test_ignored_in_criterion(self): + c = self.t.foo.as_("bar") == 1 + + self.assertEqual('"foo"=1', str(c)) + + def test_ignored_in_criterion_comparison(self): + c = self.t.foo.as_("bar") == self.t.fiz.as_("buz") + + self.assertEqual('"foo"="fiz"', str(c)) + + def test_ignored_in_field_inside_case(self): + q = Query.from_(self.t).select(Case().when(self.t.foo == 1, "a").else_(self.t.bar.as_('"buz"'))) + + self.assertEqual('SELECT CASE WHEN "foo"=1 THEN \'a\' ELSE "bar" END FROM "abc"', str(q)) + + def test_case_using_as(self): + q = Query.from_(self.t).select(Case().when(self.t.foo == 1, "a").else_("b").as_("bar")) + + self.assertEqual( + 'SELECT CASE WHEN "foo"=1 THEN \'a\' ELSE \'b\' END "bar" FROM "abc"', + str(q), + ) + + def test_case_using_constructor_param(self): + q = Query.from_(self.t).select(Case(alias="bar").when(self.t.foo == 1, "a").else_("b")) + + self.assertEqual( + 'SELECT CASE WHEN "foo"=1 THEN \'a\' ELSE \'b\' END "bar" FROM "abc"', + str(q), + ) + + def test_select__multiple_tables(self): + table_abc, table_efg = Table("abc", alias="q0"), Table("efg", alias="q1") + + q = Query.from_(table_abc).select(table_abc.foo).from_(table_efg).select(table_efg.bar) + + self.assertEqual('SELECT "q0"."foo","q1"."bar" FROM "abc" "q0","efg" "q1"', str(q)) + + def test_use_aliases_in_groupby_and_orderby(self): + table_abc = Table("abc", alias="q0") + + my_foo = table_abc.foo.as_("my_foo") + q = Query.from_(table_abc).select(my_foo, table_abc.bar).groupby(my_foo).orderby(my_foo) + + self.assertEqual( + 'SELECT "q0"."foo" "my_foo","q0"."bar" ' 'FROM "abc" "q0" ' 'GROUP BY "my_foo" ' 'ORDER BY "my_foo"', + str(q), + ) + + def test_table_with_schema_and_alias(self): + table = Table("abc", schema="schema", alias="alias") + self.assertEqual('"schema"."abc" "alias"', str(table)) + + def test_null_value_with_alias(self): + q = Query.select(NullValue().as_("abcdef")) + + self.assertEqual('SELECT NULL "abcdef"', str(q)) + + +class SubqueryTests(unittest.TestCase): + maxDiff = None + + table_abc, table_efg, table_hij = Tables("abc", "efg", "hij") + + def test_where__in(self): + q = ( + Query.from_(self.table_abc) + .select("*") + .where( + self.table_abc.foo.isin( + Query.from_(self.table_efg).select(self.table_efg.foo).where(self.table_efg.bar == 0) + ) + ) + ) + + self.assertEqual( + 'SELECT * FROM "abc" WHERE "foo" IN (SELECT "foo" FROM "efg" WHERE "bar"=0)', + str(q), + ) + + def test_where__in_nested(self): + q = Query.from_(self.table_abc).select("*").where(self.table_abc.foo).isin(self.table_efg.select("*")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" IN (SELECT * FROM "efg")', str(q)) + + def test_join(self): + subquery = Query.from_("efg").select("fiz", "buz").where(F("buz") == 0) + + q = ( + Query.from_(self.table_abc) + .join(subquery) + .on(self.table_abc.bar == subquery.buz) + .select(self.table_abc.foo, subquery.fiz) + ) + + self.assertEqual( + 'SELECT "abc"."foo","sq0"."fiz" FROM "abc" ' + 'JOIN (SELECT "fiz","buz" FROM "efg" WHERE "buz"=0) "sq0" ' + 'ON "abc"."bar"="sq0"."buz"', + str(q), + ) + + def test_select_subquery(self): + subq = Query.from_(self.table_efg).select("fizzbuzz").where(self.table_efg.id == 1) + + q = Query.from_(self.table_abc).select("foo", "bar").select(subq) + + self.assertEqual( + 'SELECT "foo","bar",(SELECT "fizzbuzz" FROM "efg" WHERE "id"=1) ' 'FROM "abc"', + str(q), + ) + + def test_select_subquery_with_alias(self): + subq = Query.from_(self.table_efg).select("fizzbuzz").where(self.table_efg.id == 1) + + q = Query.from_(self.table_abc).select("foo", "bar").select(subq.as_("sq")) + + self.assertEqual( + 'SELECT "foo","bar",(SELECT "fizzbuzz" FROM "efg" WHERE "id"=1) "sq" ' 'FROM "abc"', + str(q), + ) + + def test_where__equality(self): + subquery = Query.from_("efg").select("fiz").where(F("buz") == 0) + query = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, self.table_abc.bar) + .where(self.table_abc.bar == subquery) + ) + + self.assertEqual( + 'SELECT "foo","bar" FROM "abc" ' 'WHERE "bar"=(SELECT "fiz" FROM "efg" WHERE "buz"=0)', + str(query), + ) + + def test_select_from_nested_query(self): + subquery = Query.from_(self.table_abc).select( + self.table_abc.foo, + self.table_abc.bar, + (self.table_abc.fizz + self.table_abc.buzz).as_("fizzbuzz"), + ) + + query = Query.from_(subquery).select(subquery.foo, subquery.bar, subquery.fizzbuzz) + + self.assertEqual( + 'SELECT "sq0"."foo","sq0"."bar","sq0"."fizzbuzz" ' + "FROM (" + 'SELECT "foo","bar","fizz"+"buzz" "fizzbuzz" ' + 'FROM "abc"' + ') "sq0"', + str(query), + ) + + def test_select_from_nested_query_with_join(self): + subquery1 = ( + Query.from_(self.table_abc) + .select( + self.table_abc.foo, + fn.Sum(self.table_abc.fizz + self.table_abc.buzz).as_("fizzbuzz"), + ) + .groupby(self.table_abc.foo) + ) + + subquery2 = Query.from_(self.table_efg).select( + self.table_efg.foo.as_("foo_two"), + self.table_efg.bar, + ) + + query = ( + Query.from_(subquery1) + .select(subquery1.foo, subquery1.fizzbuzz) + .join(subquery2) + .on(subquery1.foo == subquery2.foo_two) + .select(subquery2.foo_two, subquery2.bar) + ) + + self.assertEqual( + "SELECT " + '"sq0"."foo","sq0"."fizzbuzz",' + '"sq1"."foo_two","sq1"."bar" ' + "FROM (" + "SELECT " + '"foo",SUM("fizz"+"buzz") "fizzbuzz" ' + 'FROM "abc" ' + 'GROUP BY "foo"' + ') "sq0" JOIN (' + "SELECT " + '"foo" "foo_two","bar" ' + 'FROM "efg"' + ') "sq1" ON "sq0"."foo"="sq1"."foo_two"', + str(query), + ) + + def test_from_subquery_without_alias(self): + subquery = Query.from_(self.table_efg).select( + self.table_efg.base_id.as_("x"), self.table_efg.fizz, self.table_efg.buzz + ) + + test_query = Query.from_(subquery).select(subquery.x, subquery.fizz, subquery.buzz) + + self.assertEqual( + 'SELECT "sq0"."x","sq0"."fizz","sq0"."buzz" ' + "FROM (" + 'SELECT "base_id" "x","fizz","buzz" FROM "efg"' + ') "sq0"', + str(test_query), + ) + + def test_join_query_with_alias(self): + subquery = ( + Query.from_(self.table_efg) + .select( + self.table_efg.base_id.as_("x"), + self.table_efg.fizz, + self.table_efg.buzz, + ) + .as_("subq") + ) + + test_query = Query.from_(subquery).select(subquery.x, subquery.fizz, subquery.buzz) + + self.assertEqual( + 'SELECT "subq"."x","subq"."fizz","subq"."buzz" ' + "FROM (" + 'SELECT "base_id" "x","fizz","buzz" FROM "efg"' + ') "subq"', + str(test_query), + ) + + def test_with(self): + sub_query = Query.from_(self.table_efg).select("fizz") + test_query = Query.with_(sub_query, "an_alias").from_(AliasedQuery("an_alias")).select("*") + + self.assertEqual( + 'WITH an_alias AS (SELECT "fizz" FROM "efg") SELECT * FROM an_alias', + str(test_query), + ) + + def test_join_with_with(self): + sub_query = Query.from_(self.table_efg).select("fizz") + test_query = ( + Query.with_(sub_query, "an_alias") + .from_(self.table_abc) + .join(AliasedQuery("an_alias")) + .on(AliasedQuery("an_alias").fizz == self.table_abc.buzz) + .select("*") + ) + self.assertEqual( + 'WITH an_alias AS (SELECT "fizz" FROM "efg") ' + 'SELECT * FROM "abc" JOIN an_alias ON "an_alias"."fizz"="abc"."buzz"', + str(test_query), + ) + + def test_select_from_with_returning(self): + sub_query = PostgreSQLQuery.into(self.table_abc).insert(1).returning('*') + test_query = Query.with_(sub_query, "an_alias").from_(AliasedQuery("an_alias")).select("*") + self.assertEqual( + 'WITH an_alias AS (INSERT INTO "abc" VALUES (1) RETURNING *) SELECT * FROM an_alias', str(test_query) + ) + + +class QuoteTests(unittest.TestCase): + def test_extraneous_quotes(self): + t1 = Table("table1", alias="t1") + t2 = Table("table2", alias="t2") + + query = Query.from_(t1).join(t2).on(t1.Value.between(t2.start, t2.end)).select(t1.value) + + self.assertEqual( + "SELECT t1.value FROM table1 t1 " "JOIN table2 t2 ON t1.Value " "BETWEEN t2.start AND t2.end", + query.get_sql(quote_char=None), + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/test_tables.py b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/test_tables.py new file mode 100644 index 0000000000000000000000000000000000000000..f43e740915f642d29ce7497c36e3b68f01311016 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/test_tables.py @@ -0,0 +1,186 @@ +# from pypika.terms import ValueWrapper, SystemTimeValue +import unittest + +from pypika import Database, Dialects, Schema, SQLLiteQuery, Table, Tables, Query, SYSTEM_TIME + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + + +class TableStructureTests(unittest.TestCase): + def test_table_sql(self): + table = Table("test_table") + + self.assertEqual('"test_table"', str(table)) + + def test_table_with_alias(self): + table = Table("test_table").as_("my_table") + + self.assertEqual('"test_table" "my_table"', table.get_sql(with_alias=True, quote_char='"')) + + def test_schema_table_attr(self): + table = Schema("x_schema").test_table + + self.assertEqual('"x_schema"."test_table"', str(table)) + + def test_table_with_schema_arg(self): + table = Table("test_table", schema=Schema("x_schema")) + + self.assertEqual('"x_schema"."test_table"', str(table)) + + def test_database_schema_table_attr(self): + table = Database("x_db").x_schema.test_table + + self.assertEqual('"x_db"."x_schema"."test_table"', str(table)) + + def test_table_with_schema_and_schema_parent_arg(self): + table = Table("test_table", schema=Schema("x_schema", parent=Database("x_db"))) + + self.assertEqual('"x_db"."x_schema"."test_table"', str(table)) + + def test_table_for_system_time_sql(self): + with self.subTest("with between criterion"): + table = Table("test_table").for_(SYSTEM_TIME.between('2020-01-01', '2020-02-01')) + + self.assertEqual('"test_table" FOR SYSTEM_TIME BETWEEN \'2020-01-01\' AND \'2020-02-01\'', str(table)) + + with self.subTest("with as of criterion"): + table = Table("test_table").for_(SYSTEM_TIME.as_of('2020-01-01')) + + self.assertEqual('"test_table" FOR SYSTEM_TIME AS OF \'2020-01-01\'', str(table)) + + with self.subTest("with from to criterion"): + table = Table("test_table").for_(SYSTEM_TIME.from_to('2020-01-01', '2020-02-01')) + + self.assertEqual('"test_table" FOR SYSTEM_TIME FROM \'2020-01-01\' TO \'2020-02-01\'', str(table)) + + def test_table_for_period_sql(self): + with self.subTest("with between criterion"): + table = Table("test_table") + table = table.for_(table.valid_period.between('2020-01-01', '2020-02-01')) + + self.assertEqual('"test_table" FOR "valid_period" BETWEEN \'2020-01-01\' AND \'2020-02-01\'', str(table)) + + with self.subTest("with as of criterion"): + table = Table("test_table") + table = table.for_(table.valid_period.as_of('2020-01-01')) + + self.assertEqual('"test_table" FOR "valid_period" AS OF \'2020-01-01\'', str(table)) + + with self.subTest("with from to criterion"): + table = Table("test_table") + table = table.for_(table.valid_period.from_to('2020-01-01', '2020-02-01')) + + self.assertEqual('"test_table" FOR "valid_period" FROM \'2020-01-01\' TO \'2020-02-01\'', str(table)) + + +class TableEqualityTests(unittest.TestCase): + def test_tables_equal_by_name(self): + t1 = Table("t") + t2 = Table("t") + + self.assertEqual(t1, t2) + + def test_tables_equal_by_schema_and_name(self): + t1 = Table("t", schema="a") + t2 = Table("t", schema="a") + + self.assertEqual(t1, t2) + + def test_tables_equal_by_schema_and_name_using_schema(self): + a = Schema("a") + t1 = Table("t", schema=a) + t2 = Table("t", schema=a) + + self.assertEqual(t1, t2) + + def test_tables_equal_by_schema_and_name_using_schema_with_parent(self): + parent = Schema("parent") + a = Schema("a", parent=parent) + t1 = Table("t", schema=a) + t2 = Table("t", schema=a) + + self.assertEqual(t1, t2) + + def test_tables_not_equal_by_schema_and_name_using_schema_with_different_parents( + self, + ): + parent = Schema("parent") + a = Schema("a", parent=parent) + t1 = Table("t", schema=a) + t2 = Table("t", schema=Schema("a")) + + self.assertNotEqual(t1, t2) + + def test_tables_not_equal_with_different_schemas(self): + t1 = Table("t", schema="a") + t2 = Table("t", schema="b") + + self.assertNotEqual(t1, t2) + + def test_tables_not_equal_with_different_names(self): + t1 = Table("t", schema="a") + t2 = Table("q", schema="a") + + self.assertNotEqual(t1, t2) + + def test_many_tables_with_alias(self): + tables_data = [("table1", "t1"), ("table2", "t2"), ("table3", "t3")] + tables = Tables(*tables_data) + for el in tables: + self.assertIsNotNone(el.alias) + + def test_many_tables_without_alias(self): + tables_data = ["table1", "table2", "table3"] + tables = Tables(*tables_data) + for el in tables: + self.assertIsNone(el.alias) + + def test_many_tables_with_or_not_alias(self): + tables_data = [("table1", "t1"), ("table2"), "table3"] + tables = Tables(*tables_data) + for i in range(len(tables)): + if isinstance(tables_data[i], tuple): + self.assertIsNotNone(tables[i].alias) + else: + self.assertIsNone(tables[i].alias) + + +class TableDialectTests(unittest.TestCase): + def test_table_with_default_query_cls(self): + table = Table("abc") + q = table.select("1") + self.assertIs(q.dialect, None) + + def test_table_with_dialect_query_cls(self): + table = Table("abc", query_cls=SQLLiteQuery) + q = table.select("1") + self.assertIs(q.dialect, Dialects.SQLLITE) + + def test_table_factory_with_default_query_cls(self): + table = Query.Table("abc") + q = table.select("1") + self.assertIs(q.dialect, None) + + def test_table_factory_with_dialect_query_cls(self): + table = SQLLiteQuery.Table("abc") + q = table.select("1") + self.assertIs(q.dialect, Dialects.SQLLITE) + + def test_make_tables_factory_with_default_query_cls(self): + t1, t2 = Query.Tables("abc", "def") + q1 = t1.select("1") + q2 = t2.select("2") + self.assertIs(q1.dialect, None) + self.assertIs(q2.dialect, None) + + def test_make_tables_factory_with_dialect_query_cls(self): + t1, t2 = SQLLiteQuery.Tables("abc", "def") + q1 = t1.select("1") + q2 = t2.select("2") + self.assertIs(q1.dialect, Dialects.SQLLITE) + self.assertIs(q2.dialect, Dialects.SQLLITE) + + def test_table_with_bad_query_cls(self): + with self.assertRaises(TypeError): + Table("abc", query_cls=object) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/test_terms.py b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/test_terms.py new file mode 100644 index 0000000000000000000000000000000000000000..4c7590dfce129bac97a3f30de99b596cc746c893 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/test_terms.py @@ -0,0 +1,82 @@ +from unittest import TestCase + +from pypika import Query, Table, Field +from pypika.terms import AtTimezone + + +class FieldAliasTests(TestCase): + t = Table("test", alias="crit") + + def test_when_alias_specified(self): + c1 = Field("foo", alias="bar") + self.assertEqual('bar', str(c1.alias)) + + c1 = Field("foo").as_("bar") + self.assertEqual('bar', str(c1.alias)) + + +class FieldInitTests(TestCase): + def test_init_with_str_table(self): + test_table_name = "test_table" + field = Field(name="name", table=test_table_name) + self.assertEqual(field.table, Table(name=test_table_name)) + + +class FieldHashingTests(TestCase): + def test_tabled_eq_fields_equally_hashed(self): + client_name1 = Field(name="name", table=Table("clients")) + client_name2 = Field(name="name", table=Table("clients")) + self.assertTrue(hash(client_name1) == hash(client_name2)) + + def test_tabled_ne_fields_differently_hashed(self): + customer_name = Field(name="name", table=Table("customers")) + client_name = Field(name="name", table=Table("clients")) + self.assertTrue(hash(customer_name) != hash(client_name)) + + def test_non_tabled_aliased_eq_fields_equally_hashed(self): + self.assertTrue(hash(Field(name="A", alias="my_a")) == hash(Field(name="A", alias="my_a"))) + + def test_non_tabled_aliased_ne_fields_differently_hashed(self): + self.assertTrue(hash(Field(name="A", alias="my_a1")) != hash(Field(name="A", alias="my_a2"))) + + def test_non_tabled_eq_fields_equally_hashed(self): + self.assertTrue(hash(Field(name="A")) == hash(Field(name="A"))) + + def test_non_tabled_ne_fields_differently_hashed(self): + self.assertTrue(hash(Field(name="A")) != hash(Field(name="B"))) + + +class AtTimezoneTests(TestCase): + def test_when_interval_not_specified(self): + query = Query.from_("customers").select(AtTimezone("date", "US/Eastern")) + self.assertEqual('SELECT "date" AT TIME ZONE \'US/Eastern\' FROM "customers"', str(query)) + + def test_when_interval_specified(self): + query = Query.from_("customers").select(AtTimezone("date", "-06:00", interval=True)) + self.assertEqual( + 'SELECT "date" AT TIME ZONE INTERVAL \'-06:00\' FROM "customers"', + str(query), + ) + + def test_when_alias_specified(self): + query = Query.from_("customers").select(AtTimezone("date", "US/Eastern", alias="alias1")) + self.assertEqual( + 'SELECT "date" AT TIME ZONE \'US/Eastern\' "alias1" FROM "customers"', + str(query), + ) + + def test_passes_kwargs_to_field_get_sql(self): + customers = Table("customers") + accounts = Table("accounts") + query = ( + Query.from_(customers) + .join(accounts) + .on(customers.account_id == accounts.account_id) + .select(AtTimezone(customers.date, "US/Eastern", alias="alias1")) + ) + + self.assertEqual( + 'SELECT "customers"."date" AT TIME ZONE \'US/Eastern\' "alias1" ' + 'FROM "customers" JOIN "accounts" ON "customers"."account_id"="accounts"."account_id"', + query.get_sql(with_namespace=True), + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/test_tuples.py b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/test_tuples.py new file mode 100644 index 0000000000000000000000000000000000000000..c8ebc8e41b0115777f8b3c8cb01c04e62f13ee18 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/test_tuples.py @@ -0,0 +1,162 @@ +import unittest + +from pypika import ( + Array, + Bracket, + Query, + PostgreSQLQuery, + Table, + Tables, + Tuple, +) +from pypika.functions import Coalesce, NullIf, Sum +from pypika.terms import Field + + +class TupleTests(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_tuple_equality_tuple_on_both(self): + q = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, self.table_abc.bar) + .where(Tuple(self.table_abc.foo, self.table_abc.bar) == Tuple(1, 2)) + ) + + self.assertEqual('SELECT "foo","bar" FROM "abc" ' 'WHERE ("foo","bar")=(1,2)', str(q)) + + def test_tuple_equality_tuple_on_left(self): + q = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, self.table_abc.bar) + .where(Tuple(self.table_abc.foo, self.table_abc.bar) == (1, 2)) + ) + + self.assertEqual('SELECT "foo","bar" FROM "abc" ' 'WHERE ("foo","bar")=(1,2)', str(q)) + + def test_tuple_equality_tuple_on_right(self): + q = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, self.table_abc.bar) + .where((self.table_abc.foo, self.table_abc.bar) == Tuple(1, 2)) + ) + + # Order is reversed due to lack of right equals method + self.assertEqual('SELECT "foo","bar" FROM "abc" ' 'WHERE (1,2)=("foo","bar")', str(q)) + + def test_tuple_in_using_python_tuples(self): + q = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, self.table_abc.bar) + .where(Tuple(self.table_abc.foo, self.table_abc.bar).isin([(1, 1), (2, 2), (3, 3)])) + ) + + self.assertEqual( + 'SELECT "foo","bar" FROM "abc" ' 'WHERE ("foo","bar") IN ((1,1),(2,2),(3,3))', + str(q), + ) + + def test_tuple_in_using_pypika_tuples(self): + q = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, self.table_abc.bar) + .where(Tuple(self.table_abc.foo, self.table_abc.bar).isin([Tuple(1, 1), Tuple(2, 2), Tuple(3, 3)])) + ) + + self.assertEqual( + 'SELECT "foo","bar" FROM "abc" ' 'WHERE ("foo","bar") IN ((1,1),(2,2),(3,3))', + str(q), + ) + + def test_tuple_in_using_mixed_tuples(self): + q = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, self.table_abc.bar) + .where(Tuple(self.table_abc.foo, self.table_abc.bar).isin([(1, 1), Tuple(2, 2), (3, 3)])) + ) + + self.assertEqual( + 'SELECT "foo","bar" FROM "abc" ' 'WHERE ("foo","bar") IN ((1,1),(2,2),(3,3))', + str(q), + ) + + def test_tuples_in_join(self): + query = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .select("*") + .where(Tuple(self.table_abc.foo, self.table_efg.bar).isin([(1, 1), Tuple(2, 2), (3, 3)])) + ) + + self.assertEqual( + 'SELECT * FROM "abc" JOIN "efg" ON "abc"."foo"="efg"."bar" ' + 'WHERE ("abc"."foo","efg"."bar") IN ((1,1),(2,2),(3,3))', + str(query), + ) + + def test_render_alias_in_array_sql(self): + tb = Table("tb") + + q = Query.from_(tb).select(Tuple(tb.col).as_("different_name")) + self.assertEqual(str(q), 'SELECT ("col") "different_name" FROM "tb"') + + def test_tuple_is_aggregate(self): + with self.subTest('None if single argument returns None for is_aggregate'): + self.assertEqual(None, Tuple(0).is_aggregate) + self.assertEqual(None, Tuple(Coalesce('col')).is_aggregate) + + with self.subTest('None if multiple arguments all return None for is_aggregate'): + self.assertEqual(None, Tuple(0, 'a').is_aggregate) + self.assertEqual(None, Tuple(Coalesce('col'), NullIf('col2', 0)).is_aggregate) + + with self.subTest('True if single argument returns True for is_aggregate'): + self.assertEqual(True, Tuple(Sum('col')).is_aggregate) + + with self.subTest('True if multiple arguments return True for is_aggregate'): + self.assertEqual(True, Tuple(Sum('col'), Sum('col2')).is_aggregate) + + with self.subTest('True when mix of arguments returning None and True for is_aggregate'): + self.assertEqual(True, Tuple(Coalesce('col'), Coalesce('col2', 0), Sum('col3')).is_aggregate) + + with self.subTest('False when one of the arguments returns False for is_aggregate'): + self.assertEqual(False, Tuple(Field('col1'), Sum('col2')).is_aggregate) + + +class ArrayTests(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_array_general(self): + query = Query.from_(self.table_abc).select(Array(1, "a", ["b", 2, 3])) + + self.assertEqual("SELECT [1,'a',['b',2,3]] FROM \"abc\"", str(query)) + + def test_empty_psql_array(self): + query = PostgreSQLQuery.from_(self.table_abc).select(Array()) + + self.assertEqual("SELECT '{}' FROM \"abc\"", str(query)) + + def test_psql_array_general(self): + query = PostgreSQLQuery.from_(self.table_abc).select(Array(1, Array(2, 2, 2), 3)) + + self.assertEqual("SELECT ARRAY[1,ARRAY[2,2,2],3] FROM \"abc\"", str(query)) + + def test_render_alias_in_array_sql(self): + tb = Table("tb") + + q = Query.from_(tb).select(Array(tb.col).as_("different_name")) + self.assertEqual(str(q), 'SELECT ["col"] "different_name" FROM "tb"') + + +class BracketTests(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_arithmetic_with_brackets(self): + q = Query.from_(self.table_abc).select(Bracket(self.table_abc.foo / 2) / 2) + + self.assertEqual('SELECT ("foo"/2)/2 FROM "abc"', str(q)) + + def test_arithmetic_with_brackets_and_alias(self): + q = Query.from_(self.table_abc).select(Bracket(self.table_abc.foo / 2).as_("alias")) + + self.assertEqual('SELECT ("foo"/2) "alias" FROM "abc"', str(q)) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/test_updates.py b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/test_updates.py new file mode 100644 index 0000000000000000000000000000000000000000..fb9d714dbcb8213b4bda04bf7b8dd9b2419410ec --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/test_updates.py @@ -0,0 +1,162 @@ +import unittest + +from pypika import AliasedQuery, PostgreSQLQuery, Query, SQLLiteQuery, SYSTEM_TIME, Table + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + +from pypika.terms import Star + + +class UpdateTests(unittest.TestCase): + table_abc = Table("abc") + table_def = Table("def") + + def test_empty_query(self): + q = Query.update("abc") + + self.assertEqual("", str(q)) + + def test_omit_where(self): + q = Query.update(self.table_abc).set("foo", "bar") + + self.assertEqual('UPDATE "abc" SET "foo"=\'bar\'', str(q)) + + def test_single_quote_escape_in_set(self): + q = Query.update(self.table_abc).set("foo", "bar'foo") + + self.assertEqual("UPDATE \"abc\" SET \"foo\"='bar''foo'", str(q)) + + def test_update__table_schema(self): + table = Table("abc", "schema1") + q = Query.update(table).set(table.foo, 1).where(table.foo == 0) + + self.assertEqual('UPDATE "schema1"."abc" SET "foo"=1 WHERE "foo"=0', str(q)) + + def test_update_with_none(self): + q = Query.update("abc").set("foo", None) + self.assertEqual('UPDATE "abc" SET "foo"=null', str(q)) + + def test_update_with_join(self): + q = ( + Query.update(self.table_abc) + .join(self.table_def) + .on(self.table_def.abc_id == self.table_abc.id) + .set(self.table_abc.lname, self.table_def.lname) + ) + self.assertEqual( + 'UPDATE "abc" JOIN "def" ON "def"."abc_id"="abc"."id" SET "lname"="def"."lname"', + str(q), + ) + + def test_update_with_limit(self): + q = Query.update(self.table_abc).set(self.table_abc.lname, "test").limit(1) + self.assertEqual('UPDATE "abc" SET "lname"=\'test\' LIMIT 1', str(q)) + + def test_update_from(self): + from_table = Table('from_table') + + q = Query.update(self.table_abc).set(self.table_abc.lname, from_table.long_name).from_(from_table) + self.assertEqual('UPDATE "abc" SET "lname"="from_table"."long_name" FROM "from_table"', str(q)) + + def test_update_from_with_where(self): + from_table = Table('from_table') + + q = ( + Query.update(self.table_abc) + .set(self.table_abc.lname, from_table.long_name) + .from_(from_table) + .where(self.table_abc.fname.eq(from_table.full_name)) + ) + self.assertEqual( + 'UPDATE "abc" SET "lname"="from_table"."long_name" FROM "from_table" ' + 'WHERE "abc"."fname"="from_table"."full_name"', + str(q), + ) + + def test_update_with_statement(self): + table_efg = Table('efg') + + sub_query = Query.from_(table_efg).select("fizz") + an_alias = AliasedQuery("an_alias") + + q = ( + Query.with_(sub_query, "an_alias") + .update(self.table_abc) + .from_(an_alias) + .set(self.table_abc.lname, an_alias.long_name) + .where(self.table_abc.comp.eq(an_alias.alias_comp)) + ) + self.assertEqual( + 'WITH an_alias AS (SELECT "fizz" FROM "efg") ' + 'UPDATE "abc" SET "lname"="an_alias"."long_name" FROM an_alias ' + 'WHERE "abc"."comp"="an_alias"."alias_comp"', + str(q), + ) + + def test_for_portion(self): + with self.subTest("with system time"): + q = Query.update(self.table_abc.for_portion(SYSTEM_TIME.from_to('2020-01-01', '2020-02-01'))).set( + "foo", "bar" + ) + + self.assertEqual( + 'UPDATE "abc" FOR PORTION OF SYSTEM_TIME FROM \'2020-01-01\' TO \'2020-02-01\' SET "foo"=\'bar\'', + str(q), + ) + + with self.subTest("with column"): + q = Query.update( + self.table_abc.for_portion(self.table_abc.valid_period.from_to('2020-01-01', '2020-02-01')) + ).set("foo", "bar") + + self.assertEqual( + 'UPDATE "abc" FOR PORTION OF "valid_period" FROM \'2020-01-01\' TO \'2020-02-01\' SET "foo"=\'bar\'', + str(q), + ) + + +class PostgresUpdateTests(unittest.TestCase): + table_abc = Table("abc") + + def test_update_returning_str(self): + q = PostgreSQLQuery.update(self.table_abc).where(self.table_abc.foo == 0).set("foo", "bar").returning("id") + + self.assertEqual('UPDATE "abc" SET "foo"=\'bar\' WHERE "foo"=0 RETURNING "abc"."id"', str(q)) + + def test_update_returning(self): + q = ( + PostgreSQLQuery.update(self.table_abc) + .where(self.table_abc.foo == 0) + .set("foo", "bar") + .returning(self.table_abc.id) + ) + + self.assertEqual('UPDATE "abc" SET "foo"=\'bar\' WHERE "foo"=0 RETURNING "abc"."id"', str(q)) + + def test_update_returning_from_different_tables(self): + table_bcd = Table('bcd') + + q = ( + PostgreSQLQuery.update(self.table_abc) + .from_(table_bcd) + .set(self.table_abc.lname, table_bcd.long_name) + .returning(self.table_abc.id, table_bcd.fname) + ) + self.assertEqual( + 'UPDATE "abc" SET "lname"="bcd"."long_name" FROM "bcd" RETURNING "abc"."id","bcd"."fname"', str(q) + ) + + def test_update_returning_star(self): + q = PostgreSQLQuery.update(self.table_abc).where(self.table_abc.foo == 0).set("foo", "bar").returning(Star()) + + self.assertEqual('UPDATE "abc" SET "foo"=\'bar\' WHERE "foo"=0 RETURNING *', str(q)) + + +class SQLLiteUpdateTests(unittest.TestCase): + table_abc = Table("abc") + + def test_update_with_bool(self): + q = SQLLiteQuery.update(self.table_abc).set(self.table_abc.foo, True) + + self.assertEqual('UPDATE "abc" SET "foo"=1', str(q)) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/test_utils.py b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/test_utils.py new file mode 100644 index 0000000000000000000000000000000000000000..bb9a9b1c68fe8671989f7c49f9db90e389d06f59 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pypika/tests/test_utils.py @@ -0,0 +1,24 @@ +import unittest + +from pypika import utils + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + + +class ImmutabilityTests(unittest.TestCase): + def test_raise_attribute_error_for_deepcopy(self): + with self.assertRaises(AttributeError): + utils.raise_attribute_for_copy("Test", "__deepcopy__") + + def test_raise_attribute_error_for_getstate(self): + with self.assertRaises(AttributeError): + utils.raise_attribute_for_copy("Test", "__getstate__") + + def test_raise_attribute_error_for_setstate(self): + with self.assertRaises(AttributeError): + utils.raise_attribute_for_copy("Test", "__setstate__") + + def test_raise_attribute_error_for_getnewargs(self): + with self.assertRaises(AttributeError): + utils.raise_attribute_for_copy("Test", "__getnewargs__") diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pyproject.toml b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pyproject.toml new file mode 100644 index 0000000000000000000000000000000000000000..dcc56baede23e3571b336625e695c466ab833a56 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/pyproject.toml @@ -0,0 +1,22 @@ +[tool.black] +line-length = 120 +skip-string-normalization = true +target-version = ['py38', 'py39', 'py310', 'py311'] +force-exclude = ''' +( + /( + \.eggs # exclude a few common directories in the + | \.git # root of the project + | \.hg + | \.mypy_cache + | \.tox + | \.venv + | _build + | buck-out + | build + | dist + | docs + )/ + | setup.py +) +''' diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/setup.cfg b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/setup.cfg new file mode 100644 index 0000000000000000000000000000000000000000..46084aaf2ca9e95b2f9bb7680e432e637fc3ed90 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/setup.cfg @@ -0,0 +1,16 @@ +[bumpversion] +current_version = 0.48.9 +commit = True +tag = True + +[bumpversion:file:pypika/__init__.py] +search = __version__ = "{current_version}" +replace = __version__ = "{new_version}" + +[bdist_wheel] +universal = 1 + +[flake8] +exclude = docs, .git, __pycache__ +max-line-length = 120 +per-file-ignores = __init__.py:F401 diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/setup.py b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/setup.py new file mode 100644 index 0000000000000000000000000000000000000000..41cce7d742df3e33e8d76f267d77df486f69249a --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/setup.py @@ -0,0 +1,81 @@ +import ast + +from setuptools import setup + + +def readme(): + with open('README.rst', 'rb') as f: + return f.read().decode('UTF-8') + + +def version(): + path = 'pypika/__init__.py' + with open(path, 'r') as file: + t = compile(file.read(), path, 'exec', ast.PyCF_ONLY_AST) + for node in (n for n in t.body if isinstance(n, ast.Assign)): + if len(node.targets) == 1: + name = node.targets[0] + if isinstance(name, ast.Name) and name.id in ('__version__', '__version_info__', 'VERSION'): + v = node.value + if isinstance(v, ast.Str): + return v.s + + if isinstance(v, ast.Tuple): + r = [] + for e in v.elts: + if isinstance(e, ast.Str): + r.append(e.s) + elif isinstance(e, ast.Num): + r.append(str(e.n)) + return '.'.join(r) + + +setup( + # Application name: + name="PyPika", + + # Version number: + version=version(), + + # Application author details: + author="Timothy Heys", + author_email="theys@kayak.com", + + # License + license='Apache License Version 2.0', + + # Packages + packages=["pypika", "pypika.clickhouse"], + + # Include additional files into the package + package_data={"pypika": ["py.typed"]}, + include_package_data=True, + + install_requires=[], + + # Details + url="https://github.com/kayak/pypika", + + description="A SQL query builder API for Python", + long_description=readme(), + + classifiers=[ + 'License :: OSI Approved :: Apache Software License', + 'Development Status :: 5 - Production/Stable', + 'Intended Audience :: Developers', + 'Programming Language :: Python :: 3', + 'Programming Language :: PL/SQL', + 'Topic :: Software Development :: Libraries :: Python Modules', + 'Topic :: Scientific/Engineering :: Information Analysis', + 'Topic :: Scientific/Engineering :: Mathematics', + 'Operating System :: POSIX', + 'Operating System :: MacOS :: MacOS X', + 'Operating System :: Microsoft :: Windows', + ], + keywords=('pypika python query builder querybuilder sql mysql postgres psql oracle vertica aggregated ' + 'relational database rdbms business analytics bi data science analysis pandas ' + 'orm object mapper'), + + # Dependent packages (distributions) + test_suite="pypika.tests", +) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/tox.ini b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/tox.ini new file mode 100644 index 0000000000000000000000000000000000000000..2f0e6893243b1ca2ead6a12825e9014dc66364ce --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/tests/trusted/tox.ini @@ -0,0 +1,16 @@ +[tox] +envlist = py38,py39,py310,py311,pypy3 + +[testenv] +description = testing against {basepython} +deps = -r requirements-dev.txt +commands = + coverage run + coverage xml + +[gh-actions] +python = + 3.8: py38 + 3.9: py39 + 3.10: py310 + 3.11: py311 diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/validation/canaries/first-hunk-only.sh b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/validation/canaries/first-hunk-only.sh new file mode 100644 index 0000000000000000000000000000000000000000..8563214730da693b1ea6ae1c3d228aecfac09cb5 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/validation/canaries/first-hunk-only.sh @@ -0,0 +1,16 @@ +#!/bin/bash +set -Eeuo pipefail +cd /testbed/repo +cat > /tmp/openenv-reference.diff <<'OPENENV_PARTIAL' +diff --git a/pypika/clickhouse/condition.py b/pypika/clickhouse/condition.py +index 5fa9a18c9e95d1f5e7f56f011d03e7aa11f1ddd6..ed08224e22fb27eb18876595a542dcd3ad14bffc 100644 +--- a/pypika/clickhouse/condition.py ++++ b/pypika/clickhouse/condition.py +@@ -8,4 +8,4 @@ + + class MultiIf(Function): + def __init__(self, *conditions, **kwargs): +- super().__init__("multiIf", *conditions[::-1], **kwargs) ++ super().__init__("multiIf", *conditions, **kwargs) +OPENENV_PARTIAL +/usr/bin/git -c core.hooksPath=/dev/null -c core.fsmonitor=false apply --whitespace=nowarn /tmp/openenv-reference.diff diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/validation/canaries/original-bug.sh b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/validation/canaries/original-bug.sh new file mode 100644 index 0000000000000000000000000000000000000000..927547df786c86ab3bb5eeb917a31e0fa1895f8b --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/validation/canaries/original-bug.sh @@ -0,0 +1,3 @@ +#!/bin/bash +set -Eeuo pipefail +: diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/validation/openenv.json b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/validation/openenv.json new file mode 100644 index 0000000000000000000000000000000000000000..a13b3c577df494f6c894584d2b608ab051ebc44f --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__eai7xz1s/validation/openenv.json @@ -0,0 +1,27 @@ +{ + "canaries": "validation/canaries", + "profile": "harbor-semantic-v1", + "requires_credentials": false, + "resources": { + "cpu": 2, + "disk_mb": 16384, + "episode_timeout_s": 1800, + "memory_mb": 8192 + }, + "reward": { + "floor_margin": 0.1, + "oracle_tolerance": 0, + "range": [ + 0, + 1 + ] + }, + "reward_key": "reward", + "types": { + "tags": [ + "swe", + "python", + "mutation-repair" + ] + } +} diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/LICENSE.source b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/LICENSE.source new file mode 100644 index 0000000000000000000000000000000000000000..9c8f3ea0871e0bfe81da0fa6e7c1d7d156dc380e --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/LICENSE.source @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. \ No newline at end of file diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/adapter.json b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/adapter.json new file mode 100644 index 0000000000000000000000000000000000000000..15db6db00ccf8bdec8f86a3553d67e0eeb5d3122 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/adapter.json @@ -0,0 +1,135 @@ +{ + "canary_selection": "Fixed first provided gold hunk only when at least2hunks exist; strict subset, never reward-selected. Single-hunk task original-bug canary is explicitly NOP-equivalent and adds no signal beyond floor_gap.", + "collector_sha256": "352e555112f2de8a1393f939903e4971c9ace0e944843762b707a725c5c72481", + "dependency_installation_pinned": false, + "dependency_setup_sha256": "ed8673d02878e91c7ae0b51b9178d6a15792b79c6992f800c14a941d95242392", + "gold_patch_sha256": "e7157321656723776cca21e73b0820e95c856f91557e8be91b8bb65e4dff6f6c", + "hostile_code_isolation_established": false, + "known_wrong_semantic_implementations": 0, + "native_inventory_sha256": "3033d0be7fe79966ce9bd5b70077d9ea2d970b919f2e7f389ba9ea66839b32b0", + "new_files_deletions_and_executable_modes_supported": true, + "official_profile": { + "eval_sets": [], + "profile_class": "Pypika1c9646f0", + "profile_lines": [ + 736, + 739 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "upstream_repo": "kayak/pypika" + }, + "original_bug_canary_nop_equivalent": true, + "original_bug_runtime_wrongness_established": false, + "partial_repair_canary": true, + "partial_repair_sha256": "a630ca9d3b19d3a447e3e595a9d1cc54f0292823ee129d17ca712b0476ce3c45", + "partial_repair_wrongness_established": false, + "positive_approval_policy": "All original strict presence/identity/no-skip/no-error/exit checks retained", + "private_checker_sha256": "f0a641064b725415e23a0221bb53c90446d7efcb7f9ece5ede93a220d18dd9e7", + "private_checker_version": "matched-failure-precedence-v2", + "provided_original_bug_control": true, + "repo_url": "https://github.com/swesmith/kayak__pypika.1c9646f0.git", + "runtime_image": null, + "runtime_ready": false, + "runtime_recipe": { + "dependency_installation_pinned": false, + "official_install_cmds": [ + "python -m pip install -e ." + ], + "official_pytest_argv": [ + "pytest", + "--disable-warnings", + "--color=no", + "--tb=no", + "--verbose" + ], + "official_test_command": "source /opt/miniconda3/bin/activate; conda activate testbed; pytest --disable-warnings --color=no --tb=no --verbose", + "operator_test_runner_prerequisites": [ + "python -m pip install pytest==8.4.2" + ], + "operator_test_runner_reason": "The official profile invokes pytest, but the common tools runtime does not provide it; pinned separately from source-native project requirements.", + "panel_normalization": "Override project addopts only to execute the exact frozen native panels; add JUnit output, preserve official pytest options and all selectors.", + "python_version": "3.10", + "source_bound_test_dependency_cmds": [ + "python -m pip install parameterized==0.7.0" + ], + "test_dependency_source_sha256": { + "requirements-dev.txt": "10f4ba7b19a73950d28fd7403d7e1d1b1fe2ccc4f49516974f47199d2965f23d", + "setup.py": "f8bad274588a22e65764d8cf9fb2be5aa6fcfaf3bf861d71e5f751105898845a", + "tox.ini": "c2d7205d0ac93e9c9e80dc5d24f0a826a6781f587a33ea722ea621f9e2ccd0ea" + } + }, + "runtime_resource_review_required": false, + "schema": "python-git-patch-jobs-v1", + "source_base_commit": "5f8baff10c73a4fb9731f2d2b970a9944a4643bc", + "source_completion_sha256": "51061f904fc02de67f5f5633b66e4512f60100386184b9b426d0e197fb0c3fd5", + "source_index_sha256": "e856874b9410fce9f3bfea52c8c482e84b3e43942d87517f8b55f0034bd40f6f", + "source_pr_url": null, + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:kayak__pypika.1c9646f0.combine_module__g1xozw84", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "6a742f12bfa386994289ec8b75824663d8ee4b15", + "instruction_sha256": "b755f3370d81a2fff69ebf4d2d29f6f9aa4de297a3ec1865456ebfc9b34030be", + "is_fork": true, + "learner_path": "tasks/a48aedc69877bdf12df5136c/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "actual_upstream_url": "https://raw.githubusercontent.com/kayak/pypika/1c9646f0a019a167c32b649b6f5e6423c5ba2c9b/LICENSE.txt", + "reviewed": true, + "sha256": "c5accbbd8546e94c34aed24afe689a617627d18eed5a6c48277e48db57c23851", + "spdx": "Apache-2.0", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/kayak__pypika.1c9646f0/5f8baff10c73a4fb9731f2d2b970a9944a4643bc/LICENSE.txt" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "patch_sha256": "ca1a07bb1a76c6c897645feb9f45e64ea5211eb7f44ab21f5c5993573bd0b8e4", + "provenance_path": "tasks/a48aedc69877bdf12df5136c/source-proof.json", + "repository_lineage": [ + "swesmith/kayak__pypika.1c9646f0", + "kayak/pypika" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "5f8baff10c73a4fb9731f2d2b970a9944a4643bc", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "a3346da7c9311514ea745140ea553fbd9da576ed", + "source_kind": "mutation", + "source_repo": "swesmith/kayak__pypika.1c9646f0", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "kayak__pypika.1c9646f0.combine_module__g1xozw84", + "task_sha256": "cc482af05ba5140c258a59da5d780b4d967f3e4c6a52aa06dd0b9479bea1dd1c", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "kayak/pypika", + "usage": "quarantine_only" + }, + "source_repo": "swesmith/kayak__pypika.1c9646f0", + "symlink_submodule_changes_supported": false, + "task_id": "kayak__pypika.1c9646f0.combine_module__g1xozw84", + "transfer": "index-independent-worktree-to-Git-binary-patch", + "transfer_path": "/testbed/submission.patch", + "upstream_repo": "kayak/pypika" +} diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/dependency-setup.sh b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/dependency-setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e1a28db070ebf088cec3ef817cf2dc8715091ac2 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/dependency-setup.sh @@ -0,0 +1,9 @@ +#!/bin/bash +set -Eeuo pipefail +source /opt/miniconda3/bin/activate +conda activate testbed +cd /testbed/repo +python -c 'import sys; assert sys.version_info[:2] == (3, 10)' +python -m pip install pytest==8.4.2 +python -m pip install -e . +python -m pip install parameterized==0.7.0 diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/environment/Dockerfile b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..a59b58c2ea8217c78c1e39b4678f93c8c0023bcd --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/environment/Dockerfile @@ -0,0 +1,3 @@ +# Runtime is selected only by an independently qualified immutable amd64 receipt. +FROM ubuntu:22.04 +RUN false diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/instruction.md b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..19feecafb5790ae12121849c5def2208bf395515 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/instruction.md @@ -0,0 +1,59 @@ +# ClickHouse function names incorrect in PyPika + +I'm trying to use the ClickHouse functions in PyPika but I'm getting unexpected results. The SQL generated is using incorrect function names. + +## Issue 1: If function + +When using the `If` function, it's generating SQL with `switch` instead of `if`. Also, the parameters seem to be in reverse order. + +For example, when I do: +```python +from pypika.clickhouse.condition import If +from pypika import Table + +t = Table("test") +query = t.select(If(t.a > 10, "high", "low").as_("category")) +print(query.get_sql()) +``` + +I get: +``` +SELECT switch("low","high",test.a>10) AS category FROM test +``` + +But I should get: +``` +SELECT if(test.a>10,"high","low") AS category FROM test +``` + +## Issue 2: MultiSearch functions + +The `MultiSearchAny` and `MultiMatchAny` functions are also generating incorrect SQL. + +When I try: +```python +from pypika.clickhouse.search_string import MultiSearchAny +from pypika import Table + +t = Table("test") +query = t.select(MultiSearchAny(t.text, ["pattern1", "pattern2"]).as_("found")) +print(query.get_sql()) +``` + +It generates: +``` +SELECT singleSearchAll(test.text,['pattern1','pattern2']) AS found FROM test +``` + +But it should be: +``` +SELECT multiSearchAny(test.text,['pattern1','pattern2']) AS found FROM test +``` + +Similarly, `MultiMatchAny` is generating `multiMatchAll` instead of `multiMatchAny`. + +This is breaking my queries when I try to use them with ClickHouse. Can someone please fix these function names? + +## Environment + +The repository is at `/testbed/repo`. Its dependencies, including pytest, are installed in the `testbed` conda environment, which comes first on PATH. If `python -m pytest` reports that pytest is missing, use the full interpreter path: `/opt/miniconda3/envs/testbed/bin/python -m pytest `. Don't install packages: the tests need nothing else, and the sandbox may have no network access. diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/metadata.json b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/metadata.json new file mode 100644 index 0000000000000000000000000000000000000000..bbfc551e21e01e848487b7ca57a321dac66abef4 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/metadata.json @@ -0,0 +1,1276 @@ +{ + "all_runtime_and_training_flags": false, + "official_profile": { + "eval_sets": [], + "profile_class": "Pypika1c9646f0", + "profile_lines": [ + 736, + 739 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "upstream_repo": "kayak/pypika" + }, + "source_healthy_reference_proof": { + "FAIL_TO_PASS": [ + "pypika/tests/clickhouse/test_condition.py::TestIfCondition::test_get_sql_0", + "pypika/tests/clickhouse/test_condition.py::TestIfCondition::test_get_sql_1", + "pypika/tests/clickhouse/test_search_string.py::TestMultiSearch::test_multi_search_string_0", + "pypika/tests/clickhouse/test_search_string.py::TestMultiSearch::test_multi_search_string_1" + ], + "PASS_TO_PASS": [ + "pypika/tests/clickhouse/test_array.py::TestArray::test_get_sql_0__ridley_scott_jimi_hendrix_", + "pypika/tests/clickhouse/test_array.py::TestArray::test_get_sql_1__1_2_3_4_", + "pypika/tests/clickhouse/test_array.py::TestArray::test_get_sql_2__toInt64_1_toInt64_2_toInt64_3_toInt64_4_", + "pypika/tests/clickhouse/test_array.py::TestArray::test_get_sql_3__toFixedString_mogwai_10_toFixedString_mono_10_toFixedString_bonobo_10_arr", + "pypika/tests/clickhouse/test_array.py::TestHasAny::test_get_sql_0_hasAny_mental_abilities_physical_abilities_", + "pypika/tests/clickhouse/test_array.py::TestHasAny::test_get_sql_1_hasAny_1_2_3_4_3_", + "pypika/tests/clickhouse/test_array.py::TestHasAny::test_get_sql_2_hasAny_bands_toFixedString_port_royal_20_toFixedString_hammock_20_", + "pypika/tests/clickhouse/test_array.py::TestLength::test_get_sql_0_length_tags_", + "pypika/tests/clickhouse/test_array.py::TestLength::test_get_sql_1_length_1_2_3_", + "pypika/tests/clickhouse/test_array.py::TestEmpty::test_get_sql_0_empty_tags_", + "pypika/tests/clickhouse/test_array.py::TestEmpty::test_get_sql_1_empty_1_2_3_", + "pypika/tests/clickhouse/test_array.py::TestNotEmpty::test_get_sql_0_notEmpty_tags_", + "pypika/tests/clickhouse/test_array.py::TestNotEmpty::test_get_sql_1_notEmpty_1_2_3_", + "pypika/tests/clickhouse/test_condition.py::TestMultiIfCondition::test_get_sql_0", + "pypika/tests/clickhouse/test_condition.py::TestMultiIfCondition::test_get_sql_1", + "pypika/tests/clickhouse/test_dates_and_times.py::TestFormatDateTime::test_get_sql_0", + "pypika/tests/clickhouse/test_dates_and_times.py::TestFormatDateTime::test_get_sql_1", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_00", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_01", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_02", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_03", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_04", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_05", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_06", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_07", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_08", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_09", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_10", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_11", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_12", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_13", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_14", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_15", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_16", + "pypika/tests/clickhouse/test_dates_and_times.py::TestToYYYYMM::test_get_sql", + "pypika/tests/clickhouse/test_nullable_arg.py::TestSearchString::test_get_sql_0", + "pypika/tests/clickhouse/test_nullable_arg.py::TestSearchString::test_get_sql_1", + "pypika/tests/clickhouse/test_search_string.py::TestSearchString::test_search_string_0", + "pypika/tests/clickhouse/test_search_string.py::TestSearchString::test_search_string_1", + "pypika/tests/clickhouse/test_search_string.py::TestSearchString::test_search_string_2", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_00_toString_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_01_toInt8_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_02_toInt16_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_03_toInt32_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_04_toInt64_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_05_toUInt8_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_06_toUInt16_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_07_toUInt32_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_08_toUInt64_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_09_toFloat32_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_10_toFloat64_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_11_toFloat64_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_12_toDate_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_13_toDateTime_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_14_toFixedString_field_name_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_00_toString_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_01_toInt8_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_02_toInt16_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_03_toInt32_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_04_toInt64_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_05_toUInt8_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_06_toUInt16_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_07_toUInt32_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_08_toUInt64_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_09_toFloat32_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_10_toFloat64_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_11_toFloat64_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_12_toDate_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_13_toDateTime_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_14_toFixedString_100_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestToFixedString::test_get_sql_with_table", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseQueryTests::test_use_AS_keyword_for_alias", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseQueryTests::test_use_FINAL_keyword", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseQueryTests::test_use_SAMPLE_keyword", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseQueryTests::test_use_SAMPLE_with_offset_keyword", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDeleteTests::test_omit_where", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDeleteTests::test_omit_where__table_schema", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDeleteTests::test_where_field_equals", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseUpdateTests::test_update", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDropQuery::test_drop_database", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDropQuery::test_drop_dictionary", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDropQuery::test_drop_other", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDropQuery::test_drop_table", + "pypika/tests/dialects/test_clickhouse.py::DistinctOnTests::test_distinct_on", + "pypika/tests/dialects/test_clickhouse.py::LimitByTests::test_limit_by", + "pypika/tests/dialects/test_clickhouse.py::LimitByTests::test_limit_offset0_by", + "pypika/tests/dialects/test_clickhouse.py::LimitByTests::test_limit_offset_by", + "pypika/tests/dialects/test_clickhouse.py::LimitByTests::test_rename_table", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_distinct_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_groupby_alias_False_does_not_group_by_alias_when_subqueries_are_present", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_groupby_alias_False_does_not_group_by_alias_with_standard_query", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_limit", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_limit_with_offset", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_normal_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_offset", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_distinct_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_percent_invalid_range", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_percent_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_select_non_int", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_with_ties_select", + "pypika/tests/dialects/test_mysql.py::SelectTests::test_distinct_select", + "pypika/tests/dialects/test_mysql.py::SelectTests::test_modifier_select", + "pypika/tests/dialects/test_mysql.py::SelectTests::test_multiple_modifier_select", + "pypika/tests/dialects/test_mysql.py::SelectTests::test_normal_select", + "pypika/tests/dialects/test_mysql.py::UpdateTests::test_conflict_handlers_update", + "pypika/tests/dialects/test_mysql.py::UpdateTests::test_on_duplicate_key_ignore_update", + "pypika/tests/dialects/test_mysql.py::UpdateTests::test_on_duplicate_key_update_update", + "pypika/tests/dialects/test_mysql.py::UpdateTests::test_update", + "pypika/tests/dialects/test_mysql.py::LoadCSVTests::test_load_from_file", + "pypika/tests/dialects/test_mysql.py::TableTests::test_create_table", + "pypika/tests/dialects/test_mysql.py::TableTests::test_drop_table", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_fetch_next_method_deprecated", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_groupby_alias_False_does_not_group_by_alias_when_subqueries_are_present", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_groupby_alias_False_does_not_group_by_alias_with_standard_query", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_limit_offset_query", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_limit_query", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_offset_query", + "pypika/tests/dialects/test_postgresql.py::InsertTests::test_array_keyword", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_alias_set_correctly", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_json_value_from_array_num", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_json_value_from_array_str", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_json_value_from_dict", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_json_value_from_dict_recursive", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_json_value_by_index", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_json_value_by_key", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_path_json_value", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_path_text_value", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_text_value_by_index", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_text_value_by_key", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contained_by_using_list_arg", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contained_by_using_str_arg", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contained_by_with_complex_criterion", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contains_for_field", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contains_for_json", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_has_any_keys", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_has_key", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_has_keys", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_subnet_contains_inet", + "pypika/tests/dialects/test_postgresql.py::DistinctOnTests::test_distinct_on", + "pypika/tests/dialects/test_postgresql.py::ArrayTests::test_array_syntax", + "pypika/tests/dialects/test_postgresql.py::ArrayTests::test_render_alias_in_array_sql", + "pypika/tests/dialects/test_postgresql.py::ReturningClauseTests::test_no_queryexception_if_returning_used_on_valid_query_type", + "pypika/tests/dialects/test_postgresql.py::ReturningClauseTests::test_queryexception_if_returning_used_on_invalid_query", + "pypika/tests/dialects/test_postgresql.py::ReturningClauseTests::test_return_field_from_join_table", + "pypika/tests/dialects/test_postgresql.py::ReturningClauseTests::test_returning_from_missing_table_raises_queryexception", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_dont_use_double_quotes_on_create_queries", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_dont_use_double_quotes_on_drop_queries", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_dont_use_double_quotes_on_joining_queries", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_use_double_quotes_on_alias_but_not_on_terms", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_use_double_quotes_on_alias_but_not_on_terms_with_joins", + "pypika/tests/dialects/test_sqllite.py::SelectTests::test_bool_false_as_zero", + "pypika/tests/dialects/test_sqllite.py::SelectTests::test_bool_true_as_one", + "pypika/tests/dialects/test_sqllite.py::ReplaceTests::test_insert_or_replace", + "pypika/tests/dialects/test_sqllite.py::ReplaceTests::test_normal_replace", + "pypika/tests/dialects/test_sqllite.py::ReplaceTests::test_replace_subquery", + "pypika/tests/dialects/test_vertica.py::VerticaQueryTests::test_delete_query_with_hint", + "pypika/tests/dialects/test_vertica.py::VerticaQueryTests::test_insert_query_with_hint", + "pypika/tests/dialects/test_vertica.py::VerticaQueryTests::test_select_query_with_hint", + "pypika/tests/dialects/test_vertica.py::VerticaQueryTests::test_update_query_with_hint", + "pypika/tests/dialects/test_vertica.py::CopyCSVTests::test_copy_from_file", + "pypika/tests/dialects/test_vertica.py::CreateTemporaryTableTests::test_create_local_table_without_temporary_raises_error", + "pypika/tests/dialects/test_vertica.py::CreateTemporaryTableTests::test_create_local_temporary_table", + "pypika/tests/dialects/test_vertica.py::CreateTemporaryTableTests::test_create_table_preserve_rows_without_temporary_raises_error", + "pypika/tests/dialects/test_vertica.py::CreateTemporaryTableTests::test_create_temporary_table_preserve_rows", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__agg_case_criterion_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__agg_case_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__agg_func_arithmetic_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__agg_func_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__case_mixed_constant_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__case_mixed_else_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__case_with_field_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__case_with_single_aggregate_field_in_one_criterion_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__constant_arithmetic_is_aggregate_none", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__constant_is_aggregate_none", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__field_arithmetic_constant_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__field_arithmetic_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__field_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__func_arithmetic_constant_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__mixed_case_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__mixed_func_arithmetic_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__negative_agg_func_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__non_aggregate_function_with_aggregated_arg", + "pypika/tests/test_aggregate.py::IsAggregateTests::test_complicated", + "pypika/tests/test_analytic_queries.py::RankTests::test_avg", + "pypika/tests/test_analytic_queries.py::RankTests::test_count_range_between_unbounded_preceeding_current_row", + "pypika/tests/test_analytic_queries.py::RankTests::test_dense_rank", + "pypika/tests/test_analytic_queries.py::RankTests::test_empty_over", + "pypika/tests/test_analytic_queries.py::RankTests::test_filter", + "pypika/tests/test_analytic_queries.py::RankTests::test_filter_quote_table_in_filter", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value_ignore_nulls", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value_ignore_nulls_first", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value_multi_argument", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value_range_between_x_preceeding_unbounded_following", + "pypika/tests/test_analytic_queries.py::RankTests::test_lag_generates_correct_sql", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value_ignore_nulls", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value_multi_argument", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value_rows_between_current_row_unbounded_following", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value_rows_between_current_row_unbounded_following_ignore_nulls", + "pypika/tests/test_analytic_queries.py::RankTests::test_lead_generates_correct_sql", + "pypika/tests/test_analytic_queries.py::RankTests::test_max_range_x_preceeding", + "pypika/tests/test_analytic_queries.py::RankTests::test_max_rows_x_preceeding", + "pypika/tests/test_analytic_queries.py::RankTests::test_median", + "pypika/tests/test_analytic_queries.py::RankTests::test_min_range_current_row", + "pypika/tests/test_analytic_queries.py::RankTests::test_min_rows_current_row", + "pypika/tests/test_analytic_queries.py::RankTests::test_multiple_partitions", + "pypika/tests/test_analytic_queries.py::RankTests::test_ntile_no_partition_or_order_invalid_sql", + "pypika/tests/test_analytic_queries.py::RankTests::test_ntile_with_order", + "pypika/tests/test_analytic_queries.py::RankTests::test_ntile_with_partition", + "pypika/tests/test_analytic_queries.py::RankTests::test_ntile_with_partition_and_order", + "pypika/tests/test_analytic_queries.py::RankTests::test_orderby_asc", + "pypika/tests/test_analytic_queries.py::RankTests::test_orderby_desc", + "pypika/tests/test_analytic_queries.py::RankTests::test_range_called_twice_raises_attribute_error", + "pypika/tests/test_analytic_queries.py::RankTests::test_range_then_rows_raises_attribute_error", + "pypika/tests/test_analytic_queries.py::RankTests::test_rank", + "pypika/tests/test_analytic_queries.py::RankTests::test_rank_with_alias", + "pypika/tests/test_analytic_queries.py::RankTests::test_row_number", + "pypika/tests/test_analytic_queries.py::RankTests::test_rows_called_twice_raises_attribute_error", + "pypika/tests/test_analytic_queries.py::RankTests::test_rows_then_range_raises_attribute_error", + "pypika/tests/test_analytic_queries.py::RankTests::test_stddev", + "pypika/tests/test_analytic_queries.py::RankTests::test_stddev_pop", + "pypika/tests/test_analytic_queries.py::RankTests::test_stddev_samp", + "pypika/tests/test_analytic_queries.py::RankTests::test_sum_rows_unbounded_preceeding", + "pypika/tests/test_analytic_queries.py::RankTests::test_table_prefixes_used_in_analytic_functions", + "pypika/tests/test_analytic_queries.py::RankTests::test_var_pop", + "pypika/tests/test_analytic_queries.py::RankTests::test_var_samp", + "pypika/tests/test_analytic_queries.py::RankTests::test_variance", + "pypika/tests/test_analytic_queries.py::RankTests::test_variance_rows_between_unbounded_preceeding_unbounded_following", + "pypika/tests/test_analytic_queries.py::RankTests::test_varpop_range_unbounded_preceeding", + "pypika/tests/test_analytic_queries.py::RankTests::test_varpop_rows_between_unbounded_preceeding_x_following", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_as_select_not_query_raises_error", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_with_columns", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_with_select", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_with_select_and_columns_fails", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_without_columns_or_select_empty", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_if_not_exists", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_simple", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_unique", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_where", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_without_columns_raises_error", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_without_table_raises_error", + "pypika/tests/test_criterions.py::CriterionTests::test__bitwise_and_in_where_clause", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_bitwise_and", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_bitwise_and_with_alias", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_bool", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_decimal", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_str", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gt_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gt_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gt_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gt_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gte_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gte_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gte_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gte_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_is_null", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_is_null_with_alias", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lt_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lt_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lt_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lt_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lte_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lte_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lte_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lte_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_str", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_with_alias", + "pypika/tests/test_criterions.py::NotTests::test_chained_function", + "pypika/tests/test_criterions.py::NotTests::test_is_not_null", + "pypika/tests/test_criterions.py::NotTests::test_negate", + "pypika/tests/test_criterions.py::NotTests::test_not_null", + "pypika/tests/test_criterions.py::NotTests::test_not_null_with_alias", + "pypika/tests/test_criterions.py::NotTests::test_not_with_and_criterion", + "pypika/tests/test_criterions.py::NotTests::test_not_with_complex_criterion", + "pypika/tests/test_criterions.py::NotTests::test_not_with_or_criterion", + "pypika/tests/test_criterions.py::NotTests::test_notnullcriterion_replace_table", + "pypika/tests/test_criterions.py::NotTests::test_variable_access", + "pypika/tests/test_criterions.py::BetweenTests::test__between_date", + "pypika/tests/test_criterions.py::BetweenTests::test__between_datetime", + "pypika/tests/test_criterions.py::BetweenTests::test__between_number", + "pypika/tests/test_criterions.py::BetweenTests::test__between_with_alias", + "pypika/tests/test_criterions.py::BetweenTests::test__function_between", + "pypika/tests/test_criterions.py::BetweenTests::test_get_item_only_works_with_slice", + "pypika/tests/test_criterions.py::IsInTests::test__function_isin", + "pypika/tests/test_criterions.py::IsInTests::test__in_character", + "pypika/tests/test_criterions.py::IsInTests::test__in_date", + "pypika/tests/test_criterions.py::IsInTests::test__in_datetime", + "pypika/tests/test_criterions.py::IsInTests::test__in_number", + "pypika/tests/test_criterions.py::IsInTests::test__in_number_with_alias", + "pypika/tests/test_criterions.py::IsInTests::test__in_unicode", + "pypika/tests/test_criterions.py::ArithmeticExpressionTests::test__lshift", + "pypika/tests/test_criterions.py::ArithmeticExpressionTests::test__rshift", + "pypika/tests/test_criterions.py::NotInTests::test__function_notin", + "pypika/tests/test_criterions.py::NotInTests::test__notin_character", + "pypika/tests/test_criterions.py::NotInTests::test__notin_date", + "pypika/tests/test_criterions.py::NotInTests::test__notin_datetime", + "pypika/tests/test_criterions.py::NotInTests::test__notin_number", + "pypika/tests/test_criterions.py::NotInTests::test__notin_number_with_alias", + "pypika/tests/test_criterions.py::LikeTests::test_glob_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_contains", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_ends_with", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_n_chars_long", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_starts_with", + "pypika/tests/test_criterions.py::LikeTests::test_like_contains", + "pypika/tests/test_criterions.py::LikeTests::test_like_ends_with", + "pypika/tests/test_criterions.py::LikeTests::test_like_n_chars_long", + "pypika/tests/test_criterions.py::LikeTests::test_like_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_like_starts_with", + "pypika/tests/test_criterions.py::LikeTests::test_not_ilike_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_not_like_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_rlike_escape_chars", + "pypika/tests/test_criterions.py::ExistsCriterionTests::test_exists", + "pypika/tests/test_criterions.py::ExistsCriterionTests::test_not_exists", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__between_and_field", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__between_and_isin", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__nested__and", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__nested__mixed", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__nested__or", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_and", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_function_and", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_function_or", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_function_xor", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_or", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_xor", + "pypika/tests/test_criterions.py::FieldsAsCriterionTests::test__field_and_field", + "pypika/tests/test_criterions.py::FieldsAsCriterionTests::test__field_or_field", + "pypika/tests/test_criterions.py::FieldsAsCriterionTests::test__field_xor_field", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_arithmeticfunction_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_betweencriterion_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_complexcriterion_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_criterion_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_field_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_function_with_only_fields_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_function_with_values_and_fields_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_nullcriterion_replace_table", + "pypika/tests/test_criterions.py::AnyTests::test_multiple_args_returned_in_chain_of_ors", + "pypika/tests/test_criterions.py::AnyTests::test_single_arg_returns_self", + "pypika/tests/test_criterions.py::AnyTests::test_with_generator", + "pypika/tests/test_criterions.py::AnyTests::test_zero_args_returns_empty_criterion", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_different_operations_with_empty_criterion", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_empty_criterion_on_the_left", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_empty_criterion_on_the_right", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_fields_", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_invertion_of_the_empty_criterion", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_more_than_one_empty_criterions", + "pypika/tests/test_criterions.py::AllTests::test_multiple_args_returned_in_chain_of_ors", + "pypika/tests/test_criterions.py::AllTests::test_single_arg_returns_self", + "pypika/tests/test_criterions.py::AllTests::test_with_generator", + "pypika/tests/test_criterions.py::AllTests::test_zero_args_returns_empty_criterion", + "pypika/tests/test_custom_functions.py::TestUnitCustomFunction::test_should_fail_with_wrong_arguments", + "pypika/tests/test_custom_functions.py::TestUnitCustomFunction::test_should_return_function_with_arguments", + "pypika/tests/test_custom_functions.py::TestUnitCustomFunction::test_should_return_function_with_no_arguments", + "pypika/tests/test_custom_functions.py::TestFunctionalCustomFunction::test_should_fail_use_custom_function_on_select_with_wrong_arguments", + "pypika/tests/test_custom_functions.py::TestFunctionalCustomFunction::test_should_use_custom_function_on_select", + "pypika/tests/test_data_types.py::StringTests::test_inline_string_concatentation", + "pypika/tests/test_data_types.py::UuidTests::test_uuid_string_generation", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_day", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_default", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_microsecond", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_minute", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_month", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_quarter", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_second", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_week", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_year", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_day_hour", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_day_microsecond", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_day_minute", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_day_second", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_hour_microsecond", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_hour_minute", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_hour_second", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_minute_microsecond", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_minute_second", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_second_microsecond", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_value_complex_expressions", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_value_right", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_year_month", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_mysql_dialect_uses_single_quotes_around_expression_in_an_interval", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_oracle_dialect_uses_single_quotes_around_expression_in_an_interval", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_postgresql_dialect_uses_single_quotes_around_interval", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_redshift_dialect_uses_single_quotes_around_interval", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_vertica_dialect_uses_single_quotes_around_interval", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_day", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_month", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_week", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_year", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_year_month", + "pypika/tests/test_date_math.py::TruncateTrailingZerosTests::test_do_not_truncate_integer_values", + "pypika/tests/test_date_math.py::TruncateTrailingZerosTests::test_do_not_truncate_months_between_years_and_datys", + "pypika/tests/test_deletes.py::DeleteTests::test_for_portion", + "pypika/tests/test_deletes.py::DeleteTests::test_omit_where", + "pypika/tests/test_deletes.py::DeleteTests::test_omit_where__table_schema", + "pypika/tests/test_deletes.py::DeleteTests::test_where_field_equals", + "pypika/tests/test_deletes.py::PostgresDeleteTests::test_delete_returning", + "pypika/tests/test_deletes.py::PostgresDeleteTests::test_delete_returning_star", + "pypika/tests/test_deletes.py::PostgresDeleteTests::test_delete_returning_str", + "pypika/tests/test_deletes.py::PostgresDeleteTests::test_delete_using", + "pypika/tests/test_drop.py::DropTableTests::test_drop_database", + "pypika/tests/test_drop.py::DropTableTests::test_drop_index", + "pypika/tests/test_drop.py::DropTableTests::test_drop_table", + "pypika/tests/test_drop.py::DropTableTests::test_drop_user", + "pypika/tests/test_drop.py::DropTableTests::test_drop_view", + "pypika/tests/test_formats.py::QuoteTests::test_no_quote_char_in_complex_query", + "pypika/tests/test_formats.py::QuoteTests::test_replace_quote_char_in_complex_query", + "pypika/tests/test_functions.py::FunctionTests::test_dialect_propagation", + "pypika/tests/test_functions.py::FunctionTests::test_is_aggregate_None_for_non_aggregate_function_or_function_with_no_aggregate_functions", + "pypika/tests/test_functions.py::FunctionTests::test_is_aggregate_True_for_aggregate_function_or_function_with_aggregate_functions", + "pypika/tests/test_functions.py::SchemaTests::test_schema_included_in_function_sql", + "pypika/tests/test_functions.py::SchemaTests::test_schema_no_schema_in_sql_when_none_set", + "pypika/tests/test_functions.py::ArithmeticTests::test__addition__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__addition__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__addition__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__addition__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__arithmetic_equality", + "pypika/tests/test_functions.py::ArithmeticTests::test__arithmetic_with_function", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_add_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_div_no_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_div_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_exponent_no_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_exponent_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_floor_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_function_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_modulus_no_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_modulus_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_mul_no_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_mul_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_nested_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_sub_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__division__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__division__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__division__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__division__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__exponent__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__exponent__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__floor", + "pypika/tests/test_functions.py::ArithmeticTests::test__leftshift__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__leftshift__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__leftshift__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__modulus__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__multiplication__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__multiplication__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__multiplication__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__multiplication__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__rightshift__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__rightshift__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__rightshift__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__subtraction__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__subtraction__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__subtraction__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__subtraction__right", + "pypika/tests/test_functions.py::AggregationTests::test__approx_percentile", + "pypika/tests/test_functions.py::AggregationTests::test__avg", + "pypika/tests/test_functions.py::AggregationTests::test__count", + "pypika/tests/test_functions.py::AggregationTests::test__count__star", + "pypika/tests/test_functions.py::AggregationTests::test__first", + "pypika/tests/test_functions.py::AggregationTests::test__last", + "pypika/tests/test_functions.py::AggregationTests::test__max", + "pypika/tests/test_functions.py::AggregationTests::test__min", + "pypika/tests/test_functions.py::AggregationTests::test__std", + "pypika/tests/test_functions.py::AggregationTests::test__stddev", + "pypika/tests/test_functions.py::AggregationTests::test__subquery_in_params_functions", + "pypika/tests/test_functions.py::AggregationTests::test__sum", + "pypika/tests/test_functions.py::ConditionTests::test__case__else", + "pypika/tests/test_functions.py::ConditionTests::test__case__field", + "pypika/tests/test_functions.py::ConditionTests::test__case__multi", + "pypika/tests/test_functions.py::ConditionTests::test__case__no_cases", + "pypika/tests/test_functions.py::ConditionTests::test__case__raw", + "pypika/tests/test_functions.py::StringTests::test__ascii__field", + "pypika/tests/test_functions.py::StringTests::test__ascii__int", + "pypika/tests/test_functions.py::StringTests::test__ascii__str", + "pypika/tests/test_functions.py::StringTests::test__bin__field", + "pypika/tests/test_functions.py::StringTests::test__bin__int", + "pypika/tests/test_functions.py::StringTests::test__bin__str", + "pypika/tests/test_functions.py::StringTests::test__concat__field", + "pypika/tests/test_functions.py::StringTests::test__concat__str", + "pypika/tests/test_functions.py::StringTests::test__insert__field", + "pypika/tests/test_functions.py::StringTests::test__insert__str", + "pypika/tests/test_functions.py::StringTests::test__length__field", + "pypika/tests/test_functions.py::StringTests::test__length__str", + "pypika/tests/test_functions.py::StringTests::test__lower__field", + "pypika/tests/test_functions.py::StringTests::test__lower__str", + "pypika/tests/test_functions.py::StringTests::test__replace__field", + "pypika/tests/test_functions.py::StringTests::test__replace__str", + "pypika/tests/test_functions.py::StringTests::test__substring", + "pypika/tests/test_functions.py::SplitPartFunctionTests::test__split_part", + "pypika/tests/test_functions.py::RegexpLikeFunctionTests::test__regexp_like", + "pypika/tests/test_functions.py::CastTests::test__cast__as", + "pypika/tests/test_functions.py::CastTests::test__cast__binary", + "pypika/tests/test_functions.py::CastTests::test__cast__binary_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__boolean", + "pypika/tests/test_functions.py::CastTests::test__cast__char", + "pypika/tests/test_functions.py::CastTests::test__cast__char_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__date", + "pypika/tests/test_functions.py::CastTests::test__cast__float", + "pypika/tests/test_functions.py::CastTests::test__cast__integer", + "pypika/tests/test_functions.py::CastTests::test__cast__long_varbinary", + "pypika/tests/test_functions.py::CastTests::test__cast__long_varbinary_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__long_varchar", + "pypika/tests/test_functions.py::CastTests::test__cast__long_varchar_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__numeric", + "pypika/tests/test_functions.py::CastTests::test__cast__signed", + "pypika/tests/test_functions.py::CastTests::test__cast__timestamp", + "pypika/tests/test_functions.py::CastTests::test__cast__unsigned", + "pypika/tests/test_functions.py::CastTests::test__cast__varbinary", + "pypika/tests/test_functions.py::CastTests::test__cast__varbinary_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__varchar", + "pypika/tests/test_functions.py::CastTests::test__cast__varchar_with_arg", + "pypika/tests/test_functions.py::CastTests::test__tochar__", + "pypika/tests/test_functions.py::DateFunctionsTests::test_current_date", + "pypika/tests/test_functions.py::DateFunctionsTests::test_current_time", + "pypika/tests/test_functions.py::DateFunctionsTests::test_current_timestamp", + "pypika/tests/test_functions.py::DateFunctionsTests::test_current_timestamp_with_alias", + "pypika/tests/test_functions.py::DateFunctionsTests::test_date_add", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_day", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_hour", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_join", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_microsecond", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_minute", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_month", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_quarter", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_second", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_week", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_year", + "pypika/tests/test_functions.py::DateFunctionsTests::test_now", + "pypika/tests/test_functions.py::DateFunctionsTests::test_time_diff", + "pypika/tests/test_functions.py::DateFunctionsTests::test_timestampadd", + "pypika/tests/test_functions.py::DateFunctionsTests::test_to_date", + "pypika/tests/test_functions.py::DateFunctionsTests::test_utc_timestamp", + "pypika/tests/test_functions.py::NullFunctionsTests::test_coalesce", + "pypika/tests/test_functions.py::NullFunctionsTests::test_isnull", + "pypika/tests/test_functions.py::NullFunctionsTests::test_nullif", + "pypika/tests/test_functions.py::NullFunctionsTests::test_nvl", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_mysql_one_groupby", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_mysql_rollup_two_groupbys", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_no_rollup_after_rollup_mysql", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_no_rollup_before_groupby", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_from_groupbys", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_from_parameters", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_from_two_groupbys", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_func_one_groupby", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_func_partial", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_func_two_groupbys", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_multiple_rollups", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_rollups_with_multiple_rollups_and_parity", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_rollups_with_parity", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_force_index_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_groupby_returns_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_immutable_kwarg_on_query_builder_disables_immutability", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_insert_into_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_join_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_orderby_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_queries_after_join", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_replace_into_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_select_returns_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_update_set_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_use_index_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_with_return_new_query_instance", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_multi_rows", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_multi_rows_chained", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_multi_rows_chained_mixed", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_multi_rows_chained_multiple_rows", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_single_element", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_column_using_alias_with_chain", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_column_using_table_alias", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_empty_columns", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_empty_columns_type_list", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_empty_columns_type_tuple", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_ignore", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_multiple_rows_with_array_value", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_none_skipped", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_null", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_one_column", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_one_column_multi_element_array", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_one_column_single_element_array", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_selected_columns", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_selected_columns_type_list", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_selected_columns_type_tuple", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_single_row_with_array_value", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_with_statement", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_empty_on_conflict_do_update_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_field", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_field_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_mixed_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_multiple_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_multiple_fields_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_field", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_field_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_multiple_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_multiple_fields_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_multiple_mixed_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_no_handler", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_two_handlers_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_two_handlers_do_update", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_fieldless_conflict_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_fieldless_conflict_do_update_field", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_non_insert_on_conflict_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_non_insert_on_conflict_do_update", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_do_nothing_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_do_update_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_do_update_with_excluded_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_from_subquery", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_complex", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_conflict_fields_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_conflict_fields_do_update", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_empty_conflict_fields_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_empty_conflict_fields_do_update", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_where_and_on_conflict_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_all_columns_multi_rows_chained_returning_star", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_all_columns_multi_rows_chained_returning_star_and_id", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_all_columns_multi_rows_chained_returning_star_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_all_columns_single_element_arrays", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_aggregate", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_all_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_all_fields_and_arithmetics", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_arithmetics", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_from_other_table", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_functions", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_null", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_one_field", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_one_field_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_tuple", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_ignore", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multi_rows_chained_mixed_on_duplicate_update_multiple", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_multiple", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_different_value", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_expression", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_expression_using_original_field_value", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_expression_using_values", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_same_value", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_none_skipped", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_one_column", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_one_column_multi_element_array", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_one_column_single_element_array", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_one_column_using_values", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_selected_columns_on_duplicate_update_multiple", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_selected_columns_on_duplicate_update_one", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_columns_from_columns", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_columns_from_columns_with_join", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_columns_from_star", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_from_columns", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_ignore_star", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_star", + "pypika/tests/test_inserts.py::InsertSubqueryTests::test_insert_subquery_wrapped_in_brackets", + "pypika/tests/test_inserts.py::SelectIntoTests::test_select_columns_into", + "pypika/tests/test_inserts.py::SelectIntoTests::test_select_columns_into_with_join", + "pypika/tests/test_inserts.py::SelectIntoTests::test_select_star_into", + "pypika/tests/test_inserts.py::ReplaceTests::test_replace_simple", + "pypika/tests/test_inserts.py::ReplaceTests::test_replace_subquery", + "pypika/tests/test_internals.py::TablesTests::test__case_tables", + "pypika/tests/test_internals.py::TablesTests::test__criterion_replace_table_with_value", + "pypika/tests/test_internals.py::TablesTests::test__star_tables", + "pypika/tests/test_internals.py::TablesTests::test__table_star_tables", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_cross_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_cross_join_on_subquery", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_cross_join_on_table", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_default_join_type", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_full_outer_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_hash_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_inner_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_arithmetic_field", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_collate", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_complex_criteria", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_field_multi", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_field_multi_with_extra_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_field_single", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_field_without_fields_raises_exception", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_subquery_criteria", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_second_table_in_from_clause", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_using_multiple_fields", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_using_string_field_name", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_using_with_quote_char", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_using_without_fields_raises_exception", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_with_arithmetic_function_in_select", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_left_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_left_outer_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_outer_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_right_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_right_outer_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_temporal_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_use_different_table_objects_for_same_table", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_fail_when_joining_unknown_type", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_ignore_table_references", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_immutable__tables", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_from_join", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_query_with_column_alias", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_query_with_setoperation", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_query_with_table_alias", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_query_without_alias", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_same_table", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_same_table_with_prefixes", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_table_twice", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_prefixes_added_to_function_in_orderby", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_prefixes_added_to_groupby", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_prefixes_added_to_orderby", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_require_condition", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_require_condition_with_both_tables", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select__fields_after_table_star", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select__ordered_select_clauses", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select__star_for_table", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select__star_for_table__replacement", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select_field_from_missing_table", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select_fields_with_where", + "pypika/tests/test_joins.py::UnionTests::test_mysql_query_wraps_unioned_queries", + "pypika/tests/test_joins.py::UnionTests::test_require_equal_number_of_fields", + "pypika/tests/test_joins.py::UnionTests::test_union", + "pypika/tests/test_joins.py::UnionTests::test_union_all", + "pypika/tests/test_joins.py::UnionTests::test_union_all_multiple", + "pypika/tests/test_joins.py::UnionTests::test_union_as_subquery", + "pypika/tests/test_joins.py::UnionTests::test_union_multiple", + "pypika/tests/test_joins.py::UnionTests::test_union_with_no_quote_char", + "pypika/tests/test_joins.py::UnionTests::test_union_with_order_by", + "pypika/tests/test_joins.py::UnionTests::test_union_with_order_by_use_union_query_field", + "pypika/tests/test_joins.py::UnionTests::test_union_with_order_by_use_union_query_field_with_aliases", + "pypika/tests/test_joins.py::UnionTests::test_union_with_order_by_with_aliases", + "pypika/tests/test_joins.py::InsertQueryJoinTests::test_join_table_on_insert_query", + "pypika/tests/test_joins.py::UpdateQueryJoinTests::test_join_table_on_update_query", + "pypika/tests/test_joins.py::IntersectTests::test_intersect", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_as_subquery", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_multiple", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_with_limit", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_with_no_quote_char", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_with_offset", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_with_order_by", + "pypika/tests/test_joins.py::IntersectTests::test_mysql_query_wraps_intersected_queries", + "pypika/tests/test_joins.py::IntersectTests::test_require_equal_number_of_fields_intersect", + "pypika/tests/test_joins.py::MinusTests::test_minus", + "pypika/tests/test_joins.py::MinusTests::test_minus_as_subquery", + "pypika/tests/test_joins.py::MinusTests::test_minus_multiple", + "pypika/tests/test_joins.py::MinusTests::test_minus_query_with_order_by_use_minus_query_field", + "pypika/tests/test_joins.py::MinusTests::test_minus_with_no_quote_char", + "pypika/tests/test_joins.py::MinusTests::test_minus_with_order_by", + "pypika/tests/test_joins.py::MinusTests::test_mysql_query_wraps_minus_queries", + "pypika/tests/test_joins.py::MinusTests::test_require_equal_number_of_fields", + "pypika/tests/test_joins.py::ExceptOfTests::test_except", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_as_subquery", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_multiple", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_query_with_order_by_use_minus_query_field", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_with_no_quote_char", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_with_order_by", + "pypika/tests/test_joins.py::ExceptOfTests::test_require_equal_number_of_fields_except_of", + "pypika/tests/test_negation.py::NegationTests::test_negate_field", + "pypika/tests/test_negation.py::NegationTests::test_negate_function", + "pypika/tests/test_negation.py::NegationTests::test_negate_wrapped_float", + "pypika/tests/test_negation.py::NegationTests::test_negate_wrapped_int", + "pypika/tests/test_parameter.py::ParametrizedTests::test_format_parameter", + "pypika/tests/test_parameter.py::ParametrizedTests::test_join", + "pypika/tests/test_parameter.py::ParametrizedTests::test_named_parameter", + "pypika/tests/test_parameter.py::ParametrizedTests::test_numeric_parameter", + "pypika/tests/test_parameter.py::ParametrizedTests::test_param_insert", + "pypika/tests/test_parameter.py::ParametrizedTests::test_param_select_join", + "pypika/tests/test_parameter.py::ParametrizedTests::test_param_select_subquery", + "pypika/tests/test_parameter.py::ParametrizedTests::test_pyformat_parameter", + "pypika/tests/test_parameter.py::ParametrizedTests::test_qmark_parameter", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_join", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_join_with_parameter_value_wrapper", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_param_insert", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_param_select_join", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_param_select_subquery", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_pyformat_parameter", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_can_be_used_in_a_select_statement", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_can_be_used_in_a_where_clause", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_can_be_used_in_orderby", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_column_value", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_object_id", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_object_value", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_row_id", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_row_num", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_sys_date", + "pypika/tests/test_query.py::QueryTablesTests::test_is_joined", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_case_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_delete_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_filter_tables", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_having_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_insert_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_insert_table_current_table_not_match", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_join_tables", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_only_specified_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_orderby_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_tuple_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_update_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_update_table_current_table_not_match", + "pypika/tests/test_query.py::QueryBuilderTests::test_pipe", + "pypika/tests/test_query.py::QueryBuilderTests::test_query_builders_have_reference_to_correct_query_class", + "pypika/tests/test_selects.py::SelectTests::test_empty_query", + "pypika/tests/test_selects.py::SelectTests::test_mssql_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_mysql_query_uses_backtick_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_oracle_query_uses_no_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_postgresql_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_redshift_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_select__column__single__alias__str", + "pypika/tests/test_selects.py::SelectTests::test_select__column__single__field", + "pypika/tests/test_selects.py::SelectTests::test_select__column__single__str", + "pypika/tests/test_selects.py::SelectTests::test_select__column__single__table_alias__str", + "pypika/tests/test_selects.py::SelectTests::test_select__columns__multi__field", + "pypika/tests/test_selects.py::SelectTests::test_select__columns__multi__str", + "pypika/tests/test_selects.py::SelectTests::test_select__distinct__multi", + "pypika/tests/test_selects.py::SelectTests::test_select__distinct__single", + "pypika/tests/test_selects.py::SelectTests::test_select__multiple_subqueries", + "pypika/tests/test_selects.py::SelectTests::test_select__multiple_tables", + "pypika/tests/test_selects.py::SelectTests::test_select__nested_subquery", + "pypika/tests/test_selects.py::SelectTests::test_select__no_table", + "pypika/tests/test_selects.py::SelectTests::test_select__star", + "pypika/tests/test_selects.py::SelectTests::test_select__star__replacement", + "pypika/tests/test_selects.py::SelectTests::test_select__subquery", + "pypika/tests/test_selects.py::SelectTests::test_select__table_schema", + "pypika/tests/test_selects.py::SelectTests::test_select__table_schema_with_multiple_levels_as_list", + "pypika/tests/test_selects.py::SelectTests::test_select__table_schema_with_multiple_levels_as_tuple", + "pypika/tests/test_selects.py::SelectTests::test_select_no_from", + "pypika/tests/test_selects.py::SelectTests::test_select_no_from_with_field_raises_exception", + "pypika/tests/test_selects.py::SelectTests::test_select_no_with_alias_from", + "pypika/tests/test_selects.py::SelectTests::test_select_then_add_table", + "pypika/tests/test_selects.py::SelectTests::test_select_with_force_index", + "pypika/tests/test_selects.py::SelectTests::test_select_with_force_index_multiple_calls", + "pypika/tests/test_selects.py::SelectTests::test_select_with_force_index_multiple_indexes", + "pypika/tests/test_selects.py::SelectTests::test_select_with_force_index_with_index_object", + "pypika/tests/test_selects.py::SelectTests::test_select_with_limit", + "pypika/tests/test_selects.py::SelectTests::test_select_with_limit__func", + "pypika/tests/test_selects.py::SelectTests::test_select_with_limit_and_offset", + "pypika/tests/test_selects.py::SelectTests::test_select_with_limit_zero", + "pypika/tests/test_selects.py::SelectTests::test_select_with_offset", + "pypika/tests/test_selects.py::SelectTests::test_select_with_offset__func", + "pypika/tests/test_selects.py::SelectTests::test_select_with_use_index", + "pypika/tests/test_selects.py::SelectTests::test_select_with_use_index_multiple_calls", + "pypika/tests/test_selects.py::SelectTests::test_select_with_use_index_multiple_indexes", + "pypika/tests/test_selects.py::SelectTests::test_select_with_use_index_with_index_object", + "pypika/tests/test_selects.py::SelectTests::test_table_select_alias", + "pypika/tests/test_selects.py::SelectTests::test_table_select_alias_with_offset_and_limit", + "pypika/tests/test_selects.py::SelectTests::test_temporal_select", + "pypika/tests/test_selects.py::SelectTests::test_vertica_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::WhereTests::test_ignore_empty_criterion_having", + "pypika/tests/test_selects.py::WhereTests::test_ignore_empty_criterion_where", + "pypika/tests/test_selects.py::WhereTests::test_select_with_force_index_and_where", + "pypika/tests/test_selects.py::WhereTests::test_where_enum", + "pypika/tests/test_selects.py::WhereTests::test_where_field_contains", + "pypika/tests/test_selects.py::WhereTests::test_where_field_does_not_contain", + "pypika/tests/test_selects.py::WhereTests::test_where_field_does_not_end_with", + "pypika/tests/test_selects.py::WhereTests::test_where_field_does_not_start_with", + "pypika/tests/test_selects.py::WhereTests::test_where_field_ends_with", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_and", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_nowait", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_of", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_of_multiple_tables", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_of_nowait", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_of_skip_locked", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_skip_locked", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_skip_locked_and_of", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_or", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_where", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_where_not", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_where_two_not", + "pypika/tests/test_selects.py::WhereTests::test_where_field_is_n_chars_long", + "pypika/tests/test_selects.py::WhereTests::test_where_field_is_not_n_chars_long", + "pypika/tests/test_selects.py::WhereTests::test_where_field_matches_regex", + "pypika/tests/test_selects.py::WhereTests::test_where_field_matches_regexp", + "pypika/tests/test_selects.py::WhereTests::test_where_field_matches_rlike", + "pypika/tests/test_selects.py::WhereTests::test_where_field_starts_with", + "pypika/tests/test_selects.py::WhereTests::test_where_nested_conditions", + "pypika/tests/test_selects.py::WhereTests::test_where_single_quote", + "pypika/tests/test_selects.py::WhereTests::test_where_with_multiple_wheres_using_and_case", + "pypika/tests/test_selects.py::WhereTests::test_where_with_multiple_wheres_using_or_case", + "pypika/tests/test_selects.py::PreWhereTests::test_ignore_empty_criterion_having", + "pypika/tests/test_selects.py::PreWhereTests::test_ignore_empty_criterion_where", + "pypika/tests/test_selects.py::PreWhereTests::test_prewhere_field_equals", + "pypika/tests/test_selects.py::PreWhereTests::test_select_with_force_index_and_where", + "pypika/tests/test_selects.py::PreWhereTests::test_where_and_prewhere", + "pypika/tests/test_selects.py::PreWhereTests::test_where_enum", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_contains", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_does_not_contain", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_does_not_end_with", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_does_not_start_with", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_ends_with", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_and", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_nowait", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_of", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_of_multiple_tables", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_of_nowait", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_of_skip_locked", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_skip_locked", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_skip_locked_and_of", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_or", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_where", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_where_not", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_where_two_not", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_is_n_chars_long", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_is_not_n_chars_long", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_matches_regex", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_matches_regexp", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_matches_rlike", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_starts_with", + "pypika/tests/test_selects.py::PreWhereTests::test_where_nested_conditions", + "pypika/tests/test_selects.py::PreWhereTests::test_where_single_quote", + "pypika/tests/test_selects.py::PreWhereTests::test_where_with_multiple_wheres_using_and_case", + "pypika/tests/test_selects.py::PreWhereTests::test_where_with_multiple_wheres_using_or_case", + "pypika/tests/test_selects.py::GroupByTests::test_group_by__single_with_totals", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__alias", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__alias_platforms", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__alias_with_join", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__count_distinct", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__count_field", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__count_star", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__int", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__multi", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__multi_with_totals", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__no_alias", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__no_alias_mssql", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__no_alias_oracle", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__single", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__str", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__sum_distinct", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__sum_filter", + "pypika/tests/test_selects.py::GroupByTests::test_groupby_with_case_uses_the_alias", + "pypika/tests/test_selects.py::GroupByTests::test_mssql_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_mysql_query_uses_backtick_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_oracle_query_uses_no_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_postgres_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_redshift_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_vertica_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_having_and", + "pypika/tests/test_selects.py::HavingTests::test_having_greater_than", + "pypika/tests/test_selects.py::HavingTests::test_having_join_and_equality", + "pypika/tests/test_selects.py::HavingTests::test_mssql_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_mysql_query_uses_backtick_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_oracle_query_uses_no_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_postgres_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_redshift_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_vertica_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_alias", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_asc", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_desc", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_multi_fields", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_no_alias", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_single_field", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_single_str", + "pypika/tests/test_selects.py::AliasTests::test_arithmetic_function", + "pypika/tests/test_selects.py::AliasTests::test_case_using_as", + "pypika/tests/test_selects.py::AliasTests::test_case_using_constructor_param", + "pypika/tests/test_selects.py::AliasTests::test_function_using_as_nested", + "pypika/tests/test_selects.py::AliasTests::test_functions_using_as", + "pypika/tests/test_selects.py::AliasTests::test_functions_using_constructor_param", + "pypika/tests/test_selects.py::AliasTests::test_functions_using_constructor_param_nested", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_criterion", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_criterion_comparison", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_field_inside_case", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_groupby", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_orderby", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_where", + "pypika/tests/test_selects.py::AliasTests::test_null_value_with_alias", + "pypika/tests/test_selects.py::AliasTests::test_select__multiple_tables", + "pypika/tests/test_selects.py::AliasTests::test_table_field", + "pypika/tests/test_selects.py::AliasTests::test_table_field__multi", + "pypika/tests/test_selects.py::AliasTests::test_table_with_schema_and_alias", + "pypika/tests/test_selects.py::AliasTests::test_use_aliases_in_groupby_and_orderby", + "pypika/tests/test_selects.py::SubqueryTests::test_from_subquery_without_alias", + "pypika/tests/test_selects.py::SubqueryTests::test_join", + "pypika/tests/test_selects.py::SubqueryTests::test_join_query_with_alias", + "pypika/tests/test_selects.py::SubqueryTests::test_join_with_with", + "pypika/tests/test_selects.py::SubqueryTests::test_select_from_nested_query", + "pypika/tests/test_selects.py::SubqueryTests::test_select_from_nested_query_with_join", + "pypika/tests/test_selects.py::SubqueryTests::test_select_from_with_returning", + "pypika/tests/test_selects.py::SubqueryTests::test_select_subquery", + "pypika/tests/test_selects.py::SubqueryTests::test_select_subquery_with_alias", + "pypika/tests/test_selects.py::SubqueryTests::test_where__equality", + "pypika/tests/test_selects.py::SubqueryTests::test_where__in", + "pypika/tests/test_selects.py::SubqueryTests::test_where__in_nested", + "pypika/tests/test_selects.py::SubqueryTests::test_with", + "pypika/tests/test_selects.py::QuoteTests::test_extraneous_quotes", + "pypika/tests/test_tables.py::TableStructureTests::test_database_schema_table_attr", + "pypika/tests/test_tables.py::TableStructureTests::test_schema_table_attr", + "pypika/tests/test_tables.py::TableStructureTests::test_table_for_period_sql", + "pypika/tests/test_tables.py::TableStructureTests::test_table_for_system_time_sql", + "pypika/tests/test_tables.py::TableStructureTests::test_table_sql", + "pypika/tests/test_tables.py::TableStructureTests::test_table_with_alias", + "pypika/tests/test_tables.py::TableStructureTests::test_table_with_schema_and_schema_parent_arg", + "pypika/tests/test_tables.py::TableStructureTests::test_table_with_schema_arg", + "pypika/tests/test_tables.py::TableEqualityTests::test_many_tables_with_alias", + "pypika/tests/test_tables.py::TableEqualityTests::test_many_tables_with_or_not_alias", + "pypika/tests/test_tables.py::TableEqualityTests::test_many_tables_without_alias", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_equal_by_name", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_equal_by_schema_and_name", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_equal_by_schema_and_name_using_schema", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_equal_by_schema_and_name_using_schema_with_parent", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_not_equal_by_schema_and_name_using_schema_with_different_parents", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_not_equal_with_different_names", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_not_equal_with_different_schemas", + "pypika/tests/test_tables.py::TableDialectTests::test_make_tables_factory_with_default_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_make_tables_factory_with_dialect_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_factory_with_default_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_factory_with_dialect_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_with_bad_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_with_default_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_with_dialect_query_cls", + "pypika/tests/test_terms.py::FieldAliasTests::test_when_alias_specified", + "pypika/tests/test_terms.py::FieldInitTests::test_init_with_str_table", + "pypika/tests/test_terms.py::FieldHashingTests::test_non_tabled_aliased_eq_fields_equally_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_non_tabled_aliased_ne_fields_differently_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_non_tabled_eq_fields_equally_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_non_tabled_ne_fields_differently_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_tabled_eq_fields_equally_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_tabled_ne_fields_differently_hashed", + "pypika/tests/test_terms.py::AtTimezoneTests::test_passes_kwargs_to_field_get_sql", + "pypika/tests/test_terms.py::AtTimezoneTests::test_when_alias_specified", + "pypika/tests/test_terms.py::AtTimezoneTests::test_when_interval_not_specified", + "pypika/tests/test_terms.py::AtTimezoneTests::test_when_interval_specified", + "pypika/tests/test_tuples.py::TupleTests::test_render_alias_in_array_sql", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_equality_tuple_on_both", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_equality_tuple_on_left", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_equality_tuple_on_right", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_in_using_mixed_tuples", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_in_using_pypika_tuples", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_in_using_python_tuples", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_is_aggregate", + "pypika/tests/test_tuples.py::TupleTests::test_tuples_in_join", + "pypika/tests/test_tuples.py::ArrayTests::test_array_general", + "pypika/tests/test_tuples.py::ArrayTests::test_empty_psql_array", + "pypika/tests/test_tuples.py::ArrayTests::test_psql_array_general", + "pypika/tests/test_tuples.py::ArrayTests::test_render_alias_in_array_sql", + "pypika/tests/test_tuples.py::BracketTests::test_arithmetic_with_brackets", + "pypika/tests/test_tuples.py::BracketTests::test_arithmetic_with_brackets_and_alias", + "pypika/tests/test_updates.py::UpdateTests::test_empty_query", + "pypika/tests/test_updates.py::UpdateTests::test_for_portion", + "pypika/tests/test_updates.py::UpdateTests::test_omit_where", + "pypika/tests/test_updates.py::UpdateTests::test_single_quote_escape_in_set", + "pypika/tests/test_updates.py::UpdateTests::test_update__table_schema", + "pypika/tests/test_updates.py::UpdateTests::test_update_from", + "pypika/tests/test_updates.py::UpdateTests::test_update_from_with_where", + "pypika/tests/test_updates.py::UpdateTests::test_update_with_join", + "pypika/tests/test_updates.py::UpdateTests::test_update_with_limit", + "pypika/tests/test_updates.py::UpdateTests::test_update_with_none", + "pypika/tests/test_updates.py::UpdateTests::test_update_with_statement", + "pypika/tests/test_updates.py::PostgresUpdateTests::test_update_returning", + "pypika/tests/test_updates.py::PostgresUpdateTests::test_update_returning_from_different_tables", + "pypika/tests/test_updates.py::PostgresUpdateTests::test_update_returning_star", + "pypika/tests/test_updates.py::PostgresUpdateTests::test_update_returning_str", + "pypika/tests/test_updates.py::SQLLiteUpdateTests::test_update_with_bool", + "pypika/tests/test_utils.py::ImmutabilityTests::test_raise_attribute_error_for_deepcopy", + "pypika/tests/test_utils.py::ImmutabilityTests::test_raise_attribute_error_for_getnewargs", + "pypika/tests/test_utils.py::ImmutabilityTests::test_raise_attribute_error_for_getstate", + "pypika/tests/test_utils.py::ImmutabilityTests::test_raise_attribute_error_for_setstate" + ], + "all_git_blobs_modes_verified": true, + "cloud_launch_ready": false, + "commits": { + "bug": "a3346da7c9311514ea745140ea553fbd9da576ed", + "healthy": "6a742f12bfa386994289ec8b75824663d8ee4b15", + "learner": "5f8baff10c73a4fb9731f2d2b970a9944a4643bc" + }, + "existing_squirrel_snapshot_reused": false, + "full_transfer_allowlist": [ + "/testbed/.coveragerc", + "/testbed/.gitignore", + "/testbed/.pre-commit-config.yaml", + "/testbed/CODEOWNERS", + "/testbed/CONTRIBUTING.rst", + "/testbed/LICENSE.txt", + "/testbed/MANIFEST.in", + "/testbed/Makefile", + "/testbed/README.rst", + "/testbed/docs/1_installation.rst", + "/testbed/docs/2_tutorial.rst", + "/testbed/docs/3_advanced.rst", + "/testbed/docs/4_extending.rst", + "/testbed/docs/5_reference.rst", + "/testbed/docs/6_contributing.rst", + "/testbed/docs/Makefile", + "/testbed/docs/api/pypika.analytics.rst", + "/testbed/docs/api/pypika.dialects.rst", + "/testbed/docs/api/pypika.enums.rst", + "/testbed/docs/api/pypika.functions.rst", + "/testbed/docs/api/pypika.pseudocolumns.rst", + "/testbed/docs/api/pypika.queries.rst", + "/testbed/docs/api/pypika.rst", + "/testbed/docs/api/pypika.terms.rst", + "/testbed/docs/api/pypika.utils.rst", + "/testbed/docs/conf.py", + "/testbed/docs/index.rst", + "/testbed/pypika/__init__.py", + "/testbed/pypika/analytics.py", + "/testbed/pypika/clickhouse/__init__.py", + "/testbed/pypika/clickhouse/array.py", + "/testbed/pypika/clickhouse/condition.py", + "/testbed/pypika/clickhouse/dates_and_times.py", + "/testbed/pypika/clickhouse/nullable_arg.py", + "/testbed/pypika/clickhouse/search_string.py", + "/testbed/pypika/clickhouse/type_conversion.py", + "/testbed/pypika/dialects.py", + "/testbed/pypika/enums.py", + "/testbed/pypika/functions.py", + "/testbed/pypika/pseudocolumns.py", + "/testbed/pypika/py.typed", + "/testbed/pypika/queries.py", + "/testbed/pypika/terms.py", + "/testbed/pypika/tests/__init__.py", + "/testbed/pypika/tests/clickhouse/__init__.py", + "/testbed/pypika/tests/clickhouse/test_array.py", + "/testbed/pypika/tests/clickhouse/test_dates_and_times.py", + "/testbed/pypika/tests/clickhouse/test_nullable_arg.py", + "/testbed/pypika/tests/clickhouse/test_type_conversion.py", + "/testbed/pypika/tests/dialects/__init__.py", + "/testbed/pypika/tests/dialects/test_clickhouse.py", + "/testbed/pypika/tests/dialects/test_mssql.py", + "/testbed/pypika/tests/dialects/test_mysql.py", + "/testbed/pypika/tests/dialects/test_oracle.py", + "/testbed/pypika/tests/dialects/test_postgresql.py", + "/testbed/pypika/tests/dialects/test_snowflake.py", + "/testbed/pypika/tests/dialects/test_sqllite.py", + "/testbed/pypika/tests/dialects/test_vertica.py", + "/testbed/pypika/tests/test_aggregate.py", + "/testbed/pypika/tests/test_analytic_queries.py", + "/testbed/pypika/tests/test_create.py", + "/testbed/pypika/tests/test_criterions.py", + "/testbed/pypika/tests/test_custom_functions.py", + "/testbed/pypika/tests/test_data_types.py", + "/testbed/pypika/tests/test_date_math.py", + "/testbed/pypika/tests/test_deletes.py", + "/testbed/pypika/tests/test_drop.py", + "/testbed/pypika/tests/test_formats.py", + "/testbed/pypika/tests/test_functions.py", + "/testbed/pypika/tests/test_groupby_modifiers.py", + "/testbed/pypika/tests/test_immutability.py", + "/testbed/pypika/tests/test_inserts.py", + "/testbed/pypika/tests/test_internals.py", + "/testbed/pypika/tests/test_joins.py", + "/testbed/pypika/tests/test_negation.py", + "/testbed/pypika/tests/test_parameter.py", + "/testbed/pypika/tests/test_pseudocolumns.py", + "/testbed/pypika/tests/test_query.py", + "/testbed/pypika/tests/test_selects.py", + "/testbed/pypika/tests/test_tables.py", + "/testbed/pypika/tests/test_terms.py", + "/testbed/pypika/tests/test_tuples.py", + "/testbed/pypika/tests/test_updates.py", + "/testbed/pypika/tests/test_utils.py", + "/testbed/pypika/utils.py", + "/testbed/pyproject.toml", + "/testbed/requirements-dev.txt", + "/testbed/setup.cfg", + "/testbed/setup.py", + "/testbed/tox.ini" + ], + "healthy_stage_meaning": "Direct parent of the mutation; no source or test execution has been performed", + "mutation_matches_dataset_and_git_blobs": true, + "official_profile": { + "eval_sets": [], + "profile_class": "Pypika1c9646f0", + "profile_lines": [ + 736, + 739 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "upstream_repo": "kayak/pypika" + }, + "original_source_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "private_test_paths": [ + "pypika/tests/clickhouse/test_condition.py", + "pypika/tests/clickhouse/test_search_string.py" + ], + "private_tests_unchanged": true, + "profile_mapping_basis": "Explicit upstream repo and full commit fields parsed from pinned official Python profile AST, not basename inference", + "qwen_calibrated": false, + "runtime_qualified": false, + "source_paths": [ + "pypika/clickhouse/condition.py", + "pypika/clickhouse/search_string.py" + ], + "source_repo": "swesmith/kayak__pypika.1c9646f0", + "source_stages_bytes": 1893310, + "task_id": "kayak__pypika.1c9646f0.combine_module__g1xozw84", + "transfer_limitation": "Existing regular files only; new arbitrary file additions need a qualified patch adapter", + "upstream_repo": "kayak/pypika" + }, + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:kayak__pypika.1c9646f0.combine_module__g1xozw84", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "6a742f12bfa386994289ec8b75824663d8ee4b15", + "instruction_sha256": "b755f3370d81a2fff69ebf4d2d29f6f9aa4de297a3ec1865456ebfc9b34030be", + "is_fork": true, + "learner_path": "tasks/a48aedc69877bdf12df5136c/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "actual_upstream_url": "https://raw.githubusercontent.com/kayak/pypika/1c9646f0a019a167c32b649b6f5e6423c5ba2c9b/LICENSE.txt", + "reviewed": true, + "sha256": "c5accbbd8546e94c34aed24afe689a617627d18eed5a6c48277e48db57c23851", + "spdx": "Apache-2.0", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/kayak__pypika.1c9646f0/5f8baff10c73a4fb9731f2d2b970a9944a4643bc/LICENSE.txt" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "patch_sha256": "ca1a07bb1a76c6c897645feb9f45e64ea5211eb7f44ab21f5c5993573bd0b8e4", + "provenance_path": "tasks/a48aedc69877bdf12df5136c/source-proof.json", + "repository_lineage": [ + "swesmith/kayak__pypika.1c9646f0", + "kayak/pypika" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "5f8baff10c73a4fb9731f2d2b970a9944a4643bc", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "a3346da7c9311514ea745140ea553fbd9da576ed", + "source_kind": "mutation", + "source_repo": "swesmith/kayak__pypika.1c9646f0", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "kayak__pypika.1c9646f0.combine_module__g1xozw84", + "task_sha256": "cc482af05ba5140c258a59da5d780b4d967f3e4c6a52aa06dd0b9479bea1dd1c", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "kayak/pypika", + "usage": "quarantine_only" + }, + "task_kind": "original-source-mutation" +} diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/provenance.json b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/provenance.json new file mode 100644 index 0000000000000000000000000000000000000000..99621024be2e805bf154546410516908809998a1 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/provenance.json @@ -0,0 +1,88 @@ +{ + "generated_reference": false, + "healthy_reference_delta_sha256": "e7157321656723776cca21e73b0820e95c856f91557e8be91b8bb65e4dff6f6c", + "native_pytest_ids_preserved": true, + "original_source_code_license": { + "actual_upstream_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "actual_upstream_url": "https://raw.githubusercontent.com/kayak/pypika/1c9646f0a019a167c32b649b6f5e6423c5ba2c9b/LICENSE.txt", + "reviewed": true, + "sha256": "c5accbbd8546e94c34aed24afe689a617627d18eed5a6c48277e48db57c23851", + "spdx": "Apache-2.0", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/kayak__pypika.1c9646f0/5f8baff10c73a4fb9731f2d2b970a9944a4643bc/LICENSE.txt" + }, + "provided_reference": true, + "qwen_calibrated": false, + "runtime_qualified": false, + "source_completion_sha256": "51061f904fc02de67f5f5633b66e4512f60100386184b9b426d0e197fb0c3fd5", + "source_index_sha256": "e856874b9410fce9f3bfea52c8c482e84b3e43942d87517f8b55f0034bd40f6f", + "source_proof_sha256": "dd0c2458587598d5240d8323f15a5856089aa77664b0cb1ed5324e1ba35c05ab", + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:kayak__pypika.1c9646f0.combine_module__g1xozw84", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "6a742f12bfa386994289ec8b75824663d8ee4b15", + "instruction_sha256": "b755f3370d81a2fff69ebf4d2d29f6f9aa4de297a3ec1865456ebfc9b34030be", + "is_fork": true, + "learner_path": "tasks/a48aedc69877bdf12df5136c/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "actual_upstream_url": "https://raw.githubusercontent.com/kayak/pypika/1c9646f0a019a167c32b649b6f5e6423c5ba2c9b/LICENSE.txt", + "reviewed": true, + "sha256": "c5accbbd8546e94c34aed24afe689a617627d18eed5a6c48277e48db57c23851", + "spdx": "Apache-2.0", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/kayak__pypika.1c9646f0/5f8baff10c73a4fb9731f2d2b970a9944a4643bc/LICENSE.txt" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "patch_sha256": "ca1a07bb1a76c6c897645feb9f45e64ea5211eb7f44ab21f5c5993573bd0b8e4", + "provenance_path": "tasks/a48aedc69877bdf12df5136c/source-proof.json", + "repository_lineage": [ + "swesmith/kayak__pypika.1c9646f0", + "kayak/pypika" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "5f8baff10c73a4fb9731f2d2b970a9944a4643bc", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "a3346da7c9311514ea745140ea553fbd9da576ed", + "source_kind": "mutation", + "source_repo": "swesmith/kayak__pypika.1c9646f0", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "kayak__pypika.1c9646f0.combine_module__g1xozw84", + "task_sha256": "cc482af05ba5140c258a59da5d780b4d967f3e4c6a52aa06dd0b9479bea1dd1c", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "kayak/pypika", + "usage": "quarantine_only" + }, + "task_bundle_license": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + }, + "training_admissible": false, + "trusted_tests_sha256": "f2d0a1b335176a755d627907f32ef330383cf624ff3af2c5ea84ba2b6a2d7ebb" +} diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/provided-gold.diff b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/provided-gold.diff new file mode 100644 index 0000000000000000000000000000000000000000..dd04793d19557fad77216ed77797100c2d0af5eb --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/provided-gold.diff @@ -0,0 +1,30 @@ +diff --git a/pypika/clickhouse/condition.py b/pypika/clickhouse/condition.py +index c9545f3b46a7dca6861f9e93453a48eb15a5639e..ed08224e22fb27eb18876595a542dcd3ad14bffc 100644 +--- a/pypika/clickhouse/condition.py ++++ b/pypika/clickhouse/condition.py +@@ -3,7 +3,7 @@ + + class If(Function): + def __init__(self, *conditions, **kwargs): +- super().__init__("switch", *reversed(conditions), **kwargs) ++ super().__init__("if", *conditions, **kwargs) + + + class MultiIf(Function): +diff --git a/pypika/clickhouse/search_string.py b/pypika/clickhouse/search_string.py +index 31f0c5345c3ee288a062f49a56687fdf96a48ea5..22a03027fcaf3ca0578e63980c00f4be1b2f67e7 100644 +--- a/pypika/clickhouse/search_string.py ++++ b/pypika/clickhouse/search_string.py +@@ -79,10 +79,10 @@ + class MultiSearchAny(_AbstractMultiSearchString): + @classmethod + def clickhouse_function(cls) -> str: +- return "singleSearchAll" ++ return "multiSearchAny" + + + class MultiMatchAny(_AbstractMultiSearchString): + @classmethod + def clickhouse_function(cls) -> str: +- return "multiMatchAll" ++ return "multiMatchAny" diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/solution/solve.sh b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..1cdc90c5616fc714d025810d6ab4df728276e704 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/solution/solve.sh @@ -0,0 +1,36 @@ +#!/bin/bash +set -Eeuo pipefail +cd /testbed/repo +cat > /tmp/openenv-reference.diff <<'OPENENV_REFERENCE' +diff --git a/pypika/clickhouse/condition.py b/pypika/clickhouse/condition.py +index c9545f3b46a7dca6861f9e93453a48eb15a5639e..ed08224e22fb27eb18876595a542dcd3ad14bffc 100644 +--- a/pypika/clickhouse/condition.py ++++ b/pypika/clickhouse/condition.py +@@ -3,7 +3,7 @@ + + class If(Function): + def __init__(self, *conditions, **kwargs): +- super().__init__("switch", *reversed(conditions), **kwargs) ++ super().__init__("if", *conditions, **kwargs) + + + class MultiIf(Function): +diff --git a/pypika/clickhouse/search_string.py b/pypika/clickhouse/search_string.py +index 31f0c5345c3ee288a062f49a56687fdf96a48ea5..22a03027fcaf3ca0578e63980c00f4be1b2f67e7 100644 +--- a/pypika/clickhouse/search_string.py ++++ b/pypika/clickhouse/search_string.py +@@ -79,10 +79,10 @@ + class MultiSearchAny(_AbstractMultiSearchString): + @classmethod + def clickhouse_function(cls) -> str: +- return "singleSearchAll" ++ return "multiSearchAny" + + + class MultiMatchAny(_AbstractMultiSearchString): + @classmethod + def clickhouse_function(cls) -> str: +- return "multiMatchAll" ++ return "multiMatchAny" +OPENENV_REFERENCE +/usr/bin/git -c core.hooksPath=/dev/null -c core.fsmonitor=false apply --whitespace=nowarn /tmp/openenv-reference.diff diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/task.toml b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..8a6b859fe1e8a2aa3562db0259a505291a6063f8 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/task.toml @@ -0,0 +1,24 @@ +version = "1.0" + +[agent] +timeout_sec = 1800.0 + +[verifier] +timeout_sec = 900.0 + +[environment] +docker_image = "ghcr.io/younesbelkada/scale800@sha256:ce3c9e2038fa4b4abac5c7f78e20ac0121ceced8100757606ff6b5707c10bba6" +build_timeout_sec = 600.0 +cpus = 2 +memory_mb = 8192 +storage_mb = 16384 + +[metadata] +author_name = "SWE-smith source adapter" +category = "bugfix" +tags = ["swe", "python", "mutation-repair"] + +[environment.env] +# The image's PATH with the testbed env first: the project and pytest are installed there, and the agent's +# non-interactive shells never run `conda activate` +PATH = "/opt/miniconda3/envs/testbed/bin:/opt/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/check_pytest.py b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/check_pytest.py new file mode 100644 index 0000000000000000000000000000000000000000..7abfdc5972f57ca7f0cecbbeeb373414670f780e --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/check_pytest.py @@ -0,0 +1,177 @@ +"""Preserve confirmed requested assertion failures; keep positive checks strict.""" + +import argparse +import hashlib +import json +import re +import xml.etree.ElementTree as ET +from pathlib import Path + +GROUPS = ("pass-to-pass", "fail-to-pass") + + +def split_nodeid(target): + prefix, bracket, parameter = target.partition("[") + parts = prefix.split("::") + if bracket: + parts[-1] += bracket + parameter + return parts + + +def matches(case, target): + parts = split_nodeid(target) + module = parts[0].removesuffix(".py").replace("/", ".") + classname, name = case.get("classname", ""), case.get("name", "") + if not (classname == module or classname.startswith(module + ".")): + return False + selector = parts[-1] if len(parts) > 1 else "" + classes = parts[1:-1] + if classes and classname != module + "." + ".".join(classes): + return False + return ( + not selector + or name == selector + or ("[" not in selector and name.startswith(selector + "[")) + ) + + +def capture_panels(root): + panels, digests = {}, {} + for group in GROUPS: + path = Path(root) / (group + ".xml") + if not path.exists(): + panels[group] = None + continue + with path.open("rb") as stream: + raw = stream.read(4 * 1024**2 + 1) + if not 0 < len(raw) <= 4 * 1024**2 or re.search( + rb" 20000: + raise ValueError("Too many pytest cases") + identities = [(case.get("classname"), case.get("name")) for case in cases] + if len(identities) != len(set(identities)): + raise ValueError("Duplicate pytest case evidence") + panels[group] = cases + digests[group] = hashlib.sha256(raw).hexdigest() + return panels, digests + + +def strict_assess(panels, expected, native_exit): + """The original positive-approval conditions, applied to captured cases.""" + all_cases, actual_failure = [], False + for group in GROUPS: + cases = panels[group] + if cases is None: + if actual_failure: + continue + raise ValueError("Missing preceding pytest panel") + if actual_failure: + raise ValueError( + "Pytest evidence continued after the native stop-on-failure" + ) + targets = expected[group] + if any(not any(matches(case, target) for target in targets) for case in cases): + raise ValueError("Unexpected pytest case") + all_cases.extend(cases) + failures = [case for case in cases if case.find("failure") is not None] + if any( + case.find("error") is not None or case.find("skipped") is not None + for case in cases + ): + raise ValueError("Pytest collection/error/skip is not a completed panel") + actual_failure = actual_failure or bool(failures) + if not failures and any( + not any(matches(case, target) for case in cases) for target in targets + ): + raise ValueError("Declared pytest target never ran") + if actual_failure: + if native_exit == 0: + raise ValueError("Native verifier exit disagrees with pytest failure") + return {"reward": 0, "valid_test_failure": True, "cases": len(all_cases)} + if native_exit != 0: + raise ValueError("Setup or native verifier failed without a real test failure") + if any(panels[group] is None for group in GROUPS): + raise ValueError("Missing completed pytest panel") + return {"reward": 1, "valid_test_failure": False, "cases": len(all_cases)} + + +def assess(root, expected, native_exit): + if type(native_exit) is not int: + raise ValueError("Native verifier exit must be an integer") + if not isinstance(expected, dict) or any( + not isinstance(expected.get(group), list) + or not expected[group] + or any(not isinstance(target, str) or not target for target in expected[group]) + for group in GROUPS + ): + raise ValueError("Complete exact native pytest targets required") + panels, digests = capture_panels(root) + counts = { + "cases": 0, + "matched_failures": 0, + "unexpected_cases": 0, + "unmatched_failures": 0, + "skipped_cases": 0, + "error_cases": 0, + "missing_panels": 0, + "missing_targets": 0, + } + for group in GROUPS: + cases = panels[group] + if cases is None: + counts["missing_panels"] += 1 + counts["missing_targets"] += len(expected[group]) + continue + counts["cases"] += len(cases) + for case in cases: + requested = any(matches(case, target) for target in expected[group]) + failure = case.find("failure") is not None + counts["matched_failures"] += int(requested and failure) + counts["unmatched_failures"] += int(not requested and failure) + counts["unexpected_cases"] += int(not requested) + counts["skipped_cases"] += int(case.find("skipped") is not None) + counts["error_cases"] += int(case.find("error") is not None) + counts["missing_targets"] += sum( + not any(matches(case, target) for case in cases) + for target in expected[group] + ) + if counts["matched_failures"]: + if native_exit == 0: + raise ValueError( + "Native verifier exit disagrees with requested pytest failure" + ) + return { + "reward": 0, + "valid_test_failure": True, + "cases": counts["cases"], + "diagnostic_counts": counts, + "panel_sha256": digests, + "decision": "confirmed_requested_failure_precedence", + } + result = strict_assess(panels, expected, native_exit) + result.update(diagnostic_counts=counts, panel_sha256=digests) + return result + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("--root", required=True) + parser.add_argument("--expected", required=True) + parser.add_argument("--native-exit", type=int, required=True) + args = parser.parse_args() + result = assess( + args.root, json.loads(Path(args.expected).read_bytes()), args.native_exit + ) + reward = Path(args.root) / "reward.txt" + if reward.read_text().strip() != str(result["reward"]): + raise ValueError("Native raw reward disagrees with pytest evidence") + (Path(args.root) / "pytest-evidence.json").write_text( + json.dumps(result, sort_keys=True) + "\n" + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/expected-panels.json b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/expected-panels.json new file mode 100644 index 0000000000000000000000000000000000000000..761a553640f6d84ddb7c841a5e9ea524f0a13e02 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/expected-panels.json @@ -0,0 +1,1067 @@ +{ + "fail-to-pass": [ + "pypika/tests/clickhouse/test_condition.py::TestIfCondition::test_get_sql_0", + "pypika/tests/clickhouse/test_condition.py::TestIfCondition::test_get_sql_1", + "pypika/tests/clickhouse/test_search_string.py::TestMultiSearch::test_multi_search_string_0", + "pypika/tests/clickhouse/test_search_string.py::TestMultiSearch::test_multi_search_string_1" + ], + "pass-to-pass": [ + "pypika/tests/clickhouse/test_array.py::TestArray::test_get_sql_0__ridley_scott_jimi_hendrix_", + "pypika/tests/clickhouse/test_array.py::TestArray::test_get_sql_1__1_2_3_4_", + "pypika/tests/clickhouse/test_array.py::TestArray::test_get_sql_2__toInt64_1_toInt64_2_toInt64_3_toInt64_4_", + "pypika/tests/clickhouse/test_array.py::TestArray::test_get_sql_3__toFixedString_mogwai_10_toFixedString_mono_10_toFixedString_bonobo_10_arr", + "pypika/tests/clickhouse/test_array.py::TestHasAny::test_get_sql_0_hasAny_mental_abilities_physical_abilities_", + "pypika/tests/clickhouse/test_array.py::TestHasAny::test_get_sql_1_hasAny_1_2_3_4_3_", + "pypika/tests/clickhouse/test_array.py::TestHasAny::test_get_sql_2_hasAny_bands_toFixedString_port_royal_20_toFixedString_hammock_20_", + "pypika/tests/clickhouse/test_array.py::TestLength::test_get_sql_0_length_tags_", + "pypika/tests/clickhouse/test_array.py::TestLength::test_get_sql_1_length_1_2_3_", + "pypika/tests/clickhouse/test_array.py::TestEmpty::test_get_sql_0_empty_tags_", + "pypika/tests/clickhouse/test_array.py::TestEmpty::test_get_sql_1_empty_1_2_3_", + "pypika/tests/clickhouse/test_array.py::TestNotEmpty::test_get_sql_0_notEmpty_tags_", + "pypika/tests/clickhouse/test_array.py::TestNotEmpty::test_get_sql_1_notEmpty_1_2_3_", + "pypika/tests/clickhouse/test_condition.py::TestMultiIfCondition::test_get_sql_0", + "pypika/tests/clickhouse/test_condition.py::TestMultiIfCondition::test_get_sql_1", + "pypika/tests/clickhouse/test_dates_and_times.py::TestFormatDateTime::test_get_sql_0", + "pypika/tests/clickhouse/test_dates_and_times.py::TestFormatDateTime::test_get_sql_1", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_00", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_01", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_02", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_03", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_04", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_05", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_06", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_07", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_08", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_09", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_10", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_11", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_12", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_13", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_14", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_15", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_16", + "pypika/tests/clickhouse/test_dates_and_times.py::TestToYYYYMM::test_get_sql", + "pypika/tests/clickhouse/test_nullable_arg.py::TestSearchString::test_get_sql_0", + "pypika/tests/clickhouse/test_nullable_arg.py::TestSearchString::test_get_sql_1", + "pypika/tests/clickhouse/test_search_string.py::TestSearchString::test_search_string_0", + "pypika/tests/clickhouse/test_search_string.py::TestSearchString::test_search_string_1", + "pypika/tests/clickhouse/test_search_string.py::TestSearchString::test_search_string_2", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_00_toString_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_01_toInt8_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_02_toInt16_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_03_toInt32_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_04_toInt64_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_05_toUInt8_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_06_toUInt16_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_07_toUInt32_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_08_toUInt64_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_09_toFloat32_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_10_toFloat64_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_11_toFloat64_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_12_toDate_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_13_toDateTime_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_14_toFixedString_field_name_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_00_toString_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_01_toInt8_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_02_toInt16_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_03_toInt32_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_04_toInt64_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_05_toUInt8_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_06_toUInt16_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_07_toUInt32_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_08_toUInt64_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_09_toFloat32_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_10_toFloat64_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_11_toFloat64_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_12_toDate_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_13_toDateTime_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_14_toFixedString_100_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestToFixedString::test_get_sql_with_table", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseQueryTests::test_use_AS_keyword_for_alias", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseQueryTests::test_use_FINAL_keyword", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseQueryTests::test_use_SAMPLE_keyword", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseQueryTests::test_use_SAMPLE_with_offset_keyword", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDeleteTests::test_omit_where", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDeleteTests::test_omit_where__table_schema", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDeleteTests::test_where_field_equals", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseUpdateTests::test_update", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDropQuery::test_drop_database", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDropQuery::test_drop_dictionary", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDropQuery::test_drop_other", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDropQuery::test_drop_table", + "pypika/tests/dialects/test_clickhouse.py::DistinctOnTests::test_distinct_on", + "pypika/tests/dialects/test_clickhouse.py::LimitByTests::test_limit_by", + "pypika/tests/dialects/test_clickhouse.py::LimitByTests::test_limit_offset0_by", + "pypika/tests/dialects/test_clickhouse.py::LimitByTests::test_limit_offset_by", + "pypika/tests/dialects/test_clickhouse.py::LimitByTests::test_rename_table", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_distinct_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_groupby_alias_False_does_not_group_by_alias_when_subqueries_are_present", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_groupby_alias_False_does_not_group_by_alias_with_standard_query", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_limit", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_limit_with_offset", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_normal_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_offset", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_distinct_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_percent_invalid_range", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_percent_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_select_non_int", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_with_ties_select", + "pypika/tests/dialects/test_mysql.py::SelectTests::test_distinct_select", + "pypika/tests/dialects/test_mysql.py::SelectTests::test_modifier_select", + "pypika/tests/dialects/test_mysql.py::SelectTests::test_multiple_modifier_select", + "pypika/tests/dialects/test_mysql.py::SelectTests::test_normal_select", + "pypika/tests/dialects/test_mysql.py::UpdateTests::test_conflict_handlers_update", + "pypika/tests/dialects/test_mysql.py::UpdateTests::test_on_duplicate_key_ignore_update", + "pypika/tests/dialects/test_mysql.py::UpdateTests::test_on_duplicate_key_update_update", + "pypika/tests/dialects/test_mysql.py::UpdateTests::test_update", + "pypika/tests/dialects/test_mysql.py::LoadCSVTests::test_load_from_file", + "pypika/tests/dialects/test_mysql.py::TableTests::test_create_table", + "pypika/tests/dialects/test_mysql.py::TableTests::test_drop_table", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_fetch_next_method_deprecated", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_groupby_alias_False_does_not_group_by_alias_when_subqueries_are_present", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_groupby_alias_False_does_not_group_by_alias_with_standard_query", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_limit_offset_query", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_limit_query", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_offset_query", + "pypika/tests/dialects/test_postgresql.py::InsertTests::test_array_keyword", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_alias_set_correctly", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_json_value_from_array_num", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_json_value_from_array_str", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_json_value_from_dict", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_json_value_from_dict_recursive", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_json_value_by_index", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_json_value_by_key", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_path_json_value", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_path_text_value", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_text_value_by_index", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_text_value_by_key", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contained_by_using_list_arg", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contained_by_using_str_arg", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contained_by_with_complex_criterion", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contains_for_field", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contains_for_json", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_has_any_keys", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_has_key", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_has_keys", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_subnet_contains_inet", + "pypika/tests/dialects/test_postgresql.py::DistinctOnTests::test_distinct_on", + "pypika/tests/dialects/test_postgresql.py::ArrayTests::test_array_syntax", + "pypika/tests/dialects/test_postgresql.py::ArrayTests::test_render_alias_in_array_sql", + "pypika/tests/dialects/test_postgresql.py::ReturningClauseTests::test_no_queryexception_if_returning_used_on_valid_query_type", + "pypika/tests/dialects/test_postgresql.py::ReturningClauseTests::test_queryexception_if_returning_used_on_invalid_query", + "pypika/tests/dialects/test_postgresql.py::ReturningClauseTests::test_return_field_from_join_table", + "pypika/tests/dialects/test_postgresql.py::ReturningClauseTests::test_returning_from_missing_table_raises_queryexception", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_dont_use_double_quotes_on_create_queries", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_dont_use_double_quotes_on_drop_queries", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_dont_use_double_quotes_on_joining_queries", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_use_double_quotes_on_alias_but_not_on_terms", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_use_double_quotes_on_alias_but_not_on_terms_with_joins", + "pypika/tests/dialects/test_sqllite.py::SelectTests::test_bool_false_as_zero", + "pypika/tests/dialects/test_sqllite.py::SelectTests::test_bool_true_as_one", + "pypika/tests/dialects/test_sqllite.py::ReplaceTests::test_insert_or_replace", + "pypika/tests/dialects/test_sqllite.py::ReplaceTests::test_normal_replace", + "pypika/tests/dialects/test_sqllite.py::ReplaceTests::test_replace_subquery", + "pypika/tests/dialects/test_vertica.py::VerticaQueryTests::test_delete_query_with_hint", + "pypika/tests/dialects/test_vertica.py::VerticaQueryTests::test_insert_query_with_hint", + "pypika/tests/dialects/test_vertica.py::VerticaQueryTests::test_select_query_with_hint", + "pypika/tests/dialects/test_vertica.py::VerticaQueryTests::test_update_query_with_hint", + "pypika/tests/dialects/test_vertica.py::CopyCSVTests::test_copy_from_file", + "pypika/tests/dialects/test_vertica.py::CreateTemporaryTableTests::test_create_local_table_without_temporary_raises_error", + "pypika/tests/dialects/test_vertica.py::CreateTemporaryTableTests::test_create_local_temporary_table", + "pypika/tests/dialects/test_vertica.py::CreateTemporaryTableTests::test_create_table_preserve_rows_without_temporary_raises_error", + "pypika/tests/dialects/test_vertica.py::CreateTemporaryTableTests::test_create_temporary_table_preserve_rows", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__agg_case_criterion_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__agg_case_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__agg_func_arithmetic_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__agg_func_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__case_mixed_constant_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__case_mixed_else_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__case_with_field_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__case_with_single_aggregate_field_in_one_criterion_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__constant_arithmetic_is_aggregate_none", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__constant_is_aggregate_none", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__field_arithmetic_constant_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__field_arithmetic_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__field_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__func_arithmetic_constant_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__mixed_case_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__mixed_func_arithmetic_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__negative_agg_func_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__non_aggregate_function_with_aggregated_arg", + "pypika/tests/test_aggregate.py::IsAggregateTests::test_complicated", + "pypika/tests/test_analytic_queries.py::RankTests::test_avg", + "pypika/tests/test_analytic_queries.py::RankTests::test_count_range_between_unbounded_preceeding_current_row", + "pypika/tests/test_analytic_queries.py::RankTests::test_dense_rank", + "pypika/tests/test_analytic_queries.py::RankTests::test_empty_over", + "pypika/tests/test_analytic_queries.py::RankTests::test_filter", + "pypika/tests/test_analytic_queries.py::RankTests::test_filter_quote_table_in_filter", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value_ignore_nulls", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value_ignore_nulls_first", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value_multi_argument", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value_range_between_x_preceeding_unbounded_following", + "pypika/tests/test_analytic_queries.py::RankTests::test_lag_generates_correct_sql", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value_ignore_nulls", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value_multi_argument", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value_rows_between_current_row_unbounded_following", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value_rows_between_current_row_unbounded_following_ignore_nulls", + "pypika/tests/test_analytic_queries.py::RankTests::test_lead_generates_correct_sql", + "pypika/tests/test_analytic_queries.py::RankTests::test_max_range_x_preceeding", + "pypika/tests/test_analytic_queries.py::RankTests::test_max_rows_x_preceeding", + "pypika/tests/test_analytic_queries.py::RankTests::test_median", + "pypika/tests/test_analytic_queries.py::RankTests::test_min_range_current_row", + "pypika/tests/test_analytic_queries.py::RankTests::test_min_rows_current_row", + "pypika/tests/test_analytic_queries.py::RankTests::test_multiple_partitions", + "pypika/tests/test_analytic_queries.py::RankTests::test_ntile_no_partition_or_order_invalid_sql", + "pypika/tests/test_analytic_queries.py::RankTests::test_ntile_with_order", + "pypika/tests/test_analytic_queries.py::RankTests::test_ntile_with_partition", + "pypika/tests/test_analytic_queries.py::RankTests::test_ntile_with_partition_and_order", + "pypika/tests/test_analytic_queries.py::RankTests::test_orderby_asc", + "pypika/tests/test_analytic_queries.py::RankTests::test_orderby_desc", + "pypika/tests/test_analytic_queries.py::RankTests::test_range_called_twice_raises_attribute_error", + "pypika/tests/test_analytic_queries.py::RankTests::test_range_then_rows_raises_attribute_error", + "pypika/tests/test_analytic_queries.py::RankTests::test_rank", + "pypika/tests/test_analytic_queries.py::RankTests::test_rank_with_alias", + "pypika/tests/test_analytic_queries.py::RankTests::test_row_number", + "pypika/tests/test_analytic_queries.py::RankTests::test_rows_called_twice_raises_attribute_error", + "pypika/tests/test_analytic_queries.py::RankTests::test_rows_then_range_raises_attribute_error", + "pypika/tests/test_analytic_queries.py::RankTests::test_stddev", + "pypika/tests/test_analytic_queries.py::RankTests::test_stddev_pop", + "pypika/tests/test_analytic_queries.py::RankTests::test_stddev_samp", + "pypika/tests/test_analytic_queries.py::RankTests::test_sum_rows_unbounded_preceeding", + "pypika/tests/test_analytic_queries.py::RankTests::test_table_prefixes_used_in_analytic_functions", + "pypika/tests/test_analytic_queries.py::RankTests::test_var_pop", + "pypika/tests/test_analytic_queries.py::RankTests::test_var_samp", + "pypika/tests/test_analytic_queries.py::RankTests::test_variance", + "pypika/tests/test_analytic_queries.py::RankTests::test_variance_rows_between_unbounded_preceeding_unbounded_following", + "pypika/tests/test_analytic_queries.py::RankTests::test_varpop_range_unbounded_preceeding", + "pypika/tests/test_analytic_queries.py::RankTests::test_varpop_rows_between_unbounded_preceeding_x_following", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_as_select_not_query_raises_error", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_with_columns", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_with_select", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_with_select_and_columns_fails", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_without_columns_or_select_empty", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_if_not_exists", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_simple", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_unique", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_where", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_without_columns_raises_error", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_without_table_raises_error", + "pypika/tests/test_criterions.py::CriterionTests::test__bitwise_and_in_where_clause", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_bitwise_and", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_bitwise_and_with_alias", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_bool", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_decimal", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_str", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gt_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gt_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gt_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gt_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gte_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gte_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gte_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gte_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_is_null", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_is_null_with_alias", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lt_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lt_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lt_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lt_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lte_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lte_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lte_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lte_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_str", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_with_alias", + "pypika/tests/test_criterions.py::NotTests::test_chained_function", + "pypika/tests/test_criterions.py::NotTests::test_is_not_null", + "pypika/tests/test_criterions.py::NotTests::test_negate", + "pypika/tests/test_criterions.py::NotTests::test_not_null", + "pypika/tests/test_criterions.py::NotTests::test_not_null_with_alias", + "pypika/tests/test_criterions.py::NotTests::test_not_with_and_criterion", + "pypika/tests/test_criterions.py::NotTests::test_not_with_complex_criterion", + "pypika/tests/test_criterions.py::NotTests::test_not_with_or_criterion", + "pypika/tests/test_criterions.py::NotTests::test_notnullcriterion_replace_table", + "pypika/tests/test_criterions.py::NotTests::test_variable_access", + "pypika/tests/test_criterions.py::BetweenTests::test__between_date", + "pypika/tests/test_criterions.py::BetweenTests::test__between_datetime", + "pypika/tests/test_criterions.py::BetweenTests::test__between_number", + "pypika/tests/test_criterions.py::BetweenTests::test__between_with_alias", + "pypika/tests/test_criterions.py::BetweenTests::test__function_between", + "pypika/tests/test_criterions.py::BetweenTests::test_get_item_only_works_with_slice", + "pypika/tests/test_criterions.py::IsInTests::test__function_isin", + "pypika/tests/test_criterions.py::IsInTests::test__in_character", + "pypika/tests/test_criterions.py::IsInTests::test__in_date", + "pypika/tests/test_criterions.py::IsInTests::test__in_datetime", + "pypika/tests/test_criterions.py::IsInTests::test__in_number", + "pypika/tests/test_criterions.py::IsInTests::test__in_number_with_alias", + "pypika/tests/test_criterions.py::IsInTests::test__in_unicode", + "pypika/tests/test_criterions.py::ArithmeticExpressionTests::test__lshift", + "pypika/tests/test_criterions.py::ArithmeticExpressionTests::test__rshift", + "pypika/tests/test_criterions.py::NotInTests::test__function_notin", + "pypika/tests/test_criterions.py::NotInTests::test__notin_character", + "pypika/tests/test_criterions.py::NotInTests::test__notin_date", + "pypika/tests/test_criterions.py::NotInTests::test__notin_datetime", + "pypika/tests/test_criterions.py::NotInTests::test__notin_number", + "pypika/tests/test_criterions.py::NotInTests::test__notin_number_with_alias", + "pypika/tests/test_criterions.py::LikeTests::test_glob_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_contains", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_ends_with", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_n_chars_long", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_starts_with", + "pypika/tests/test_criterions.py::LikeTests::test_like_contains", + "pypika/tests/test_criterions.py::LikeTests::test_like_ends_with", + "pypika/tests/test_criterions.py::LikeTests::test_like_n_chars_long", + "pypika/tests/test_criterions.py::LikeTests::test_like_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_like_starts_with", + "pypika/tests/test_criterions.py::LikeTests::test_not_ilike_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_not_like_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_rlike_escape_chars", + "pypika/tests/test_criterions.py::ExistsCriterionTests::test_exists", + "pypika/tests/test_criterions.py::ExistsCriterionTests::test_not_exists", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__between_and_field", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__between_and_isin", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__nested__and", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__nested__mixed", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__nested__or", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_and", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_function_and", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_function_or", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_function_xor", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_or", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_xor", + "pypika/tests/test_criterions.py::FieldsAsCriterionTests::test__field_and_field", + "pypika/tests/test_criterions.py::FieldsAsCriterionTests::test__field_or_field", + "pypika/tests/test_criterions.py::FieldsAsCriterionTests::test__field_xor_field", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_arithmeticfunction_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_betweencriterion_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_complexcriterion_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_criterion_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_field_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_function_with_only_fields_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_function_with_values_and_fields_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_nullcriterion_replace_table", + "pypika/tests/test_criterions.py::AnyTests::test_multiple_args_returned_in_chain_of_ors", + "pypika/tests/test_criterions.py::AnyTests::test_single_arg_returns_self", + "pypika/tests/test_criterions.py::AnyTests::test_with_generator", + "pypika/tests/test_criterions.py::AnyTests::test_zero_args_returns_empty_criterion", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_different_operations_with_empty_criterion", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_empty_criterion_on_the_left", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_empty_criterion_on_the_right", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_fields_", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_invertion_of_the_empty_criterion", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_more_than_one_empty_criterions", + "pypika/tests/test_criterions.py::AllTests::test_multiple_args_returned_in_chain_of_ors", + "pypika/tests/test_criterions.py::AllTests::test_single_arg_returns_self", + "pypika/tests/test_criterions.py::AllTests::test_with_generator", + "pypika/tests/test_criterions.py::AllTests::test_zero_args_returns_empty_criterion", + "pypika/tests/test_custom_functions.py::TestUnitCustomFunction::test_should_fail_with_wrong_arguments", + "pypika/tests/test_custom_functions.py::TestUnitCustomFunction::test_should_return_function_with_arguments", + "pypika/tests/test_custom_functions.py::TestUnitCustomFunction::test_should_return_function_with_no_arguments", + "pypika/tests/test_custom_functions.py::TestFunctionalCustomFunction::test_should_fail_use_custom_function_on_select_with_wrong_arguments", + "pypika/tests/test_custom_functions.py::TestFunctionalCustomFunction::test_should_use_custom_function_on_select", + "pypika/tests/test_data_types.py::StringTests::test_inline_string_concatentation", + "pypika/tests/test_data_types.py::UuidTests::test_uuid_string_generation", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_day", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_default", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_microsecond", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_minute", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_month", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_quarter", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_second", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_week", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_year", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_day_hour", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_day_microsecond", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_day_minute", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_day_second", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_hour_microsecond", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_hour_minute", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_hour_second", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_minute_microsecond", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_minute_second", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_second_microsecond", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_value_complex_expressions", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_value_right", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_year_month", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_mysql_dialect_uses_single_quotes_around_expression_in_an_interval", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_oracle_dialect_uses_single_quotes_around_expression_in_an_interval", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_postgresql_dialect_uses_single_quotes_around_interval", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_redshift_dialect_uses_single_quotes_around_interval", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_vertica_dialect_uses_single_quotes_around_interval", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_day", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_month", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_week", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_year", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_year_month", + "pypika/tests/test_date_math.py::TruncateTrailingZerosTests::test_do_not_truncate_integer_values", + "pypika/tests/test_date_math.py::TruncateTrailingZerosTests::test_do_not_truncate_months_between_years_and_datys", + "pypika/tests/test_deletes.py::DeleteTests::test_for_portion", + "pypika/tests/test_deletes.py::DeleteTests::test_omit_where", + "pypika/tests/test_deletes.py::DeleteTests::test_omit_where__table_schema", + "pypika/tests/test_deletes.py::DeleteTests::test_where_field_equals", + "pypika/tests/test_deletes.py::PostgresDeleteTests::test_delete_returning", + "pypika/tests/test_deletes.py::PostgresDeleteTests::test_delete_returning_star", + "pypika/tests/test_deletes.py::PostgresDeleteTests::test_delete_returning_str", + "pypika/tests/test_deletes.py::PostgresDeleteTests::test_delete_using", + "pypika/tests/test_drop.py::DropTableTests::test_drop_database", + "pypika/tests/test_drop.py::DropTableTests::test_drop_index", + "pypika/tests/test_drop.py::DropTableTests::test_drop_table", + "pypika/tests/test_drop.py::DropTableTests::test_drop_user", + "pypika/tests/test_drop.py::DropTableTests::test_drop_view", + "pypika/tests/test_formats.py::QuoteTests::test_no_quote_char_in_complex_query", + "pypika/tests/test_formats.py::QuoteTests::test_replace_quote_char_in_complex_query", + "pypika/tests/test_functions.py::FunctionTests::test_dialect_propagation", + "pypika/tests/test_functions.py::FunctionTests::test_is_aggregate_None_for_non_aggregate_function_or_function_with_no_aggregate_functions", + "pypika/tests/test_functions.py::FunctionTests::test_is_aggregate_True_for_aggregate_function_or_function_with_aggregate_functions", + "pypika/tests/test_functions.py::SchemaTests::test_schema_included_in_function_sql", + "pypika/tests/test_functions.py::SchemaTests::test_schema_no_schema_in_sql_when_none_set", + "pypika/tests/test_functions.py::ArithmeticTests::test__addition__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__addition__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__addition__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__addition__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__arithmetic_equality", + "pypika/tests/test_functions.py::ArithmeticTests::test__arithmetic_with_function", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_add_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_div_no_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_div_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_exponent_no_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_exponent_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_floor_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_function_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_modulus_no_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_modulus_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_mul_no_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_mul_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_nested_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_sub_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__division__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__division__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__division__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__division__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__exponent__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__exponent__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__floor", + "pypika/tests/test_functions.py::ArithmeticTests::test__leftshift__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__leftshift__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__leftshift__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__modulus__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__multiplication__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__multiplication__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__multiplication__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__multiplication__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__rightshift__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__rightshift__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__rightshift__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__subtraction__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__subtraction__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__subtraction__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__subtraction__right", + "pypika/tests/test_functions.py::AggregationTests::test__approx_percentile", + "pypika/tests/test_functions.py::AggregationTests::test__avg", + "pypika/tests/test_functions.py::AggregationTests::test__count", + "pypika/tests/test_functions.py::AggregationTests::test__count__star", + "pypika/tests/test_functions.py::AggregationTests::test__first", + "pypika/tests/test_functions.py::AggregationTests::test__last", + "pypika/tests/test_functions.py::AggregationTests::test__max", + "pypika/tests/test_functions.py::AggregationTests::test__min", + "pypika/tests/test_functions.py::AggregationTests::test__std", + "pypika/tests/test_functions.py::AggregationTests::test__stddev", + "pypika/tests/test_functions.py::AggregationTests::test__subquery_in_params_functions", + "pypika/tests/test_functions.py::AggregationTests::test__sum", + "pypika/tests/test_functions.py::ConditionTests::test__case__else", + "pypika/tests/test_functions.py::ConditionTests::test__case__field", + "pypika/tests/test_functions.py::ConditionTests::test__case__multi", + "pypika/tests/test_functions.py::ConditionTests::test__case__no_cases", + "pypika/tests/test_functions.py::ConditionTests::test__case__raw", + "pypika/tests/test_functions.py::StringTests::test__ascii__field", + "pypika/tests/test_functions.py::StringTests::test__ascii__int", + "pypika/tests/test_functions.py::StringTests::test__ascii__str", + "pypika/tests/test_functions.py::StringTests::test__bin__field", + "pypika/tests/test_functions.py::StringTests::test__bin__int", + "pypika/tests/test_functions.py::StringTests::test__bin__str", + "pypika/tests/test_functions.py::StringTests::test__concat__field", + "pypika/tests/test_functions.py::StringTests::test__concat__str", + "pypika/tests/test_functions.py::StringTests::test__insert__field", + "pypika/tests/test_functions.py::StringTests::test__insert__str", + "pypika/tests/test_functions.py::StringTests::test__length__field", + "pypika/tests/test_functions.py::StringTests::test__length__str", + "pypika/tests/test_functions.py::StringTests::test__lower__field", + "pypika/tests/test_functions.py::StringTests::test__lower__str", + "pypika/tests/test_functions.py::StringTests::test__replace__field", + "pypika/tests/test_functions.py::StringTests::test__replace__str", + "pypika/tests/test_functions.py::StringTests::test__substring", + "pypika/tests/test_functions.py::SplitPartFunctionTests::test__split_part", + "pypika/tests/test_functions.py::RegexpLikeFunctionTests::test__regexp_like", + "pypika/tests/test_functions.py::CastTests::test__cast__as", + "pypika/tests/test_functions.py::CastTests::test__cast__binary", + "pypika/tests/test_functions.py::CastTests::test__cast__binary_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__boolean", + "pypika/tests/test_functions.py::CastTests::test__cast__char", + "pypika/tests/test_functions.py::CastTests::test__cast__char_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__date", + "pypika/tests/test_functions.py::CastTests::test__cast__float", + "pypika/tests/test_functions.py::CastTests::test__cast__integer", + "pypika/tests/test_functions.py::CastTests::test__cast__long_varbinary", + "pypika/tests/test_functions.py::CastTests::test__cast__long_varbinary_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__long_varchar", + "pypika/tests/test_functions.py::CastTests::test__cast__long_varchar_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__numeric", + "pypika/tests/test_functions.py::CastTests::test__cast__signed", + "pypika/tests/test_functions.py::CastTests::test__cast__timestamp", + "pypika/tests/test_functions.py::CastTests::test__cast__unsigned", + "pypika/tests/test_functions.py::CastTests::test__cast__varbinary", + "pypika/tests/test_functions.py::CastTests::test__cast__varbinary_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__varchar", + "pypika/tests/test_functions.py::CastTests::test__cast__varchar_with_arg", + "pypika/tests/test_functions.py::CastTests::test__tochar__", + "pypika/tests/test_functions.py::DateFunctionsTests::test_current_date", + "pypika/tests/test_functions.py::DateFunctionsTests::test_current_time", + "pypika/tests/test_functions.py::DateFunctionsTests::test_current_timestamp", + "pypika/tests/test_functions.py::DateFunctionsTests::test_current_timestamp_with_alias", + "pypika/tests/test_functions.py::DateFunctionsTests::test_date_add", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_day", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_hour", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_join", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_microsecond", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_minute", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_month", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_quarter", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_second", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_week", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_year", + "pypika/tests/test_functions.py::DateFunctionsTests::test_now", + "pypika/tests/test_functions.py::DateFunctionsTests::test_time_diff", + "pypika/tests/test_functions.py::DateFunctionsTests::test_timestampadd", + "pypika/tests/test_functions.py::DateFunctionsTests::test_to_date", + "pypika/tests/test_functions.py::DateFunctionsTests::test_utc_timestamp", + "pypika/tests/test_functions.py::NullFunctionsTests::test_coalesce", + "pypika/tests/test_functions.py::NullFunctionsTests::test_isnull", + "pypika/tests/test_functions.py::NullFunctionsTests::test_nullif", + "pypika/tests/test_functions.py::NullFunctionsTests::test_nvl", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_mysql_one_groupby", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_mysql_rollup_two_groupbys", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_no_rollup_after_rollup_mysql", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_no_rollup_before_groupby", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_from_groupbys", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_from_parameters", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_from_two_groupbys", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_func_one_groupby", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_func_partial", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_func_two_groupbys", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_multiple_rollups", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_rollups_with_multiple_rollups_and_parity", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_rollups_with_parity", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_force_index_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_groupby_returns_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_immutable_kwarg_on_query_builder_disables_immutability", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_insert_into_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_join_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_orderby_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_queries_after_join", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_replace_into_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_select_returns_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_update_set_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_use_index_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_with_return_new_query_instance", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_multi_rows", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_multi_rows_chained", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_multi_rows_chained_mixed", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_multi_rows_chained_multiple_rows", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_single_element", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_column_using_alias_with_chain", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_column_using_table_alias", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_empty_columns", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_empty_columns_type_list", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_empty_columns_type_tuple", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_ignore", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_multiple_rows_with_array_value", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_none_skipped", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_null", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_one_column", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_one_column_multi_element_array", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_one_column_single_element_array", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_selected_columns", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_selected_columns_type_list", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_selected_columns_type_tuple", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_single_row_with_array_value", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_with_statement", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_empty_on_conflict_do_update_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_field", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_field_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_mixed_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_multiple_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_multiple_fields_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_field", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_field_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_multiple_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_multiple_fields_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_multiple_mixed_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_no_handler", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_two_handlers_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_two_handlers_do_update", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_fieldless_conflict_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_fieldless_conflict_do_update_field", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_non_insert_on_conflict_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_non_insert_on_conflict_do_update", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_do_nothing_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_do_update_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_do_update_with_excluded_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_from_subquery", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_complex", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_conflict_fields_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_conflict_fields_do_update", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_empty_conflict_fields_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_empty_conflict_fields_do_update", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_where_and_on_conflict_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_all_columns_multi_rows_chained_returning_star", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_all_columns_multi_rows_chained_returning_star_and_id", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_all_columns_multi_rows_chained_returning_star_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_all_columns_single_element_arrays", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_aggregate", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_all_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_all_fields_and_arithmetics", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_arithmetics", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_from_other_table", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_functions", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_null", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_one_field", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_one_field_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_tuple", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_ignore", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multi_rows_chained_mixed_on_duplicate_update_multiple", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_multiple", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_different_value", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_expression", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_expression_using_original_field_value", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_expression_using_values", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_same_value", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_none_skipped", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_one_column", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_one_column_multi_element_array", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_one_column_single_element_array", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_one_column_using_values", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_selected_columns_on_duplicate_update_multiple", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_selected_columns_on_duplicate_update_one", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_columns_from_columns", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_columns_from_columns_with_join", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_columns_from_star", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_from_columns", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_ignore_star", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_star", + "pypika/tests/test_inserts.py::InsertSubqueryTests::test_insert_subquery_wrapped_in_brackets", + "pypika/tests/test_inserts.py::SelectIntoTests::test_select_columns_into", + "pypika/tests/test_inserts.py::SelectIntoTests::test_select_columns_into_with_join", + "pypika/tests/test_inserts.py::SelectIntoTests::test_select_star_into", + "pypika/tests/test_inserts.py::ReplaceTests::test_replace_simple", + "pypika/tests/test_inserts.py::ReplaceTests::test_replace_subquery", + "pypika/tests/test_internals.py::TablesTests::test__case_tables", + "pypika/tests/test_internals.py::TablesTests::test__criterion_replace_table_with_value", + "pypika/tests/test_internals.py::TablesTests::test__star_tables", + "pypika/tests/test_internals.py::TablesTests::test__table_star_tables", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_cross_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_cross_join_on_subquery", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_cross_join_on_table", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_default_join_type", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_full_outer_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_hash_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_inner_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_arithmetic_field", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_collate", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_complex_criteria", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_field_multi", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_field_multi_with_extra_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_field_single", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_field_without_fields_raises_exception", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_subquery_criteria", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_second_table_in_from_clause", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_using_multiple_fields", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_using_string_field_name", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_using_with_quote_char", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_using_without_fields_raises_exception", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_with_arithmetic_function_in_select", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_left_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_left_outer_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_outer_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_right_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_right_outer_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_temporal_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_use_different_table_objects_for_same_table", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_fail_when_joining_unknown_type", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_ignore_table_references", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_immutable__tables", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_from_join", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_query_with_column_alias", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_query_with_setoperation", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_query_with_table_alias", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_query_without_alias", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_same_table", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_same_table_with_prefixes", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_table_twice", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_prefixes_added_to_function_in_orderby", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_prefixes_added_to_groupby", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_prefixes_added_to_orderby", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_require_condition", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_require_condition_with_both_tables", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select__fields_after_table_star", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select__ordered_select_clauses", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select__star_for_table", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select__star_for_table__replacement", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select_field_from_missing_table", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select_fields_with_where", + "pypika/tests/test_joins.py::UnionTests::test_mysql_query_wraps_unioned_queries", + "pypika/tests/test_joins.py::UnionTests::test_require_equal_number_of_fields", + "pypika/tests/test_joins.py::UnionTests::test_union", + "pypika/tests/test_joins.py::UnionTests::test_union_all", + "pypika/tests/test_joins.py::UnionTests::test_union_all_multiple", + "pypika/tests/test_joins.py::UnionTests::test_union_as_subquery", + "pypika/tests/test_joins.py::UnionTests::test_union_multiple", + "pypika/tests/test_joins.py::UnionTests::test_union_with_no_quote_char", + "pypika/tests/test_joins.py::UnionTests::test_union_with_order_by", + "pypika/tests/test_joins.py::UnionTests::test_union_with_order_by_use_union_query_field", + "pypika/tests/test_joins.py::UnionTests::test_union_with_order_by_use_union_query_field_with_aliases", + "pypika/tests/test_joins.py::UnionTests::test_union_with_order_by_with_aliases", + "pypika/tests/test_joins.py::InsertQueryJoinTests::test_join_table_on_insert_query", + "pypika/tests/test_joins.py::UpdateQueryJoinTests::test_join_table_on_update_query", + "pypika/tests/test_joins.py::IntersectTests::test_intersect", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_as_subquery", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_multiple", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_with_limit", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_with_no_quote_char", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_with_offset", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_with_order_by", + "pypika/tests/test_joins.py::IntersectTests::test_mysql_query_wraps_intersected_queries", + "pypika/tests/test_joins.py::IntersectTests::test_require_equal_number_of_fields_intersect", + "pypika/tests/test_joins.py::MinusTests::test_minus", + "pypika/tests/test_joins.py::MinusTests::test_minus_as_subquery", + "pypika/tests/test_joins.py::MinusTests::test_minus_multiple", + "pypika/tests/test_joins.py::MinusTests::test_minus_query_with_order_by_use_minus_query_field", + "pypika/tests/test_joins.py::MinusTests::test_minus_with_no_quote_char", + "pypika/tests/test_joins.py::MinusTests::test_minus_with_order_by", + "pypika/tests/test_joins.py::MinusTests::test_mysql_query_wraps_minus_queries", + "pypika/tests/test_joins.py::MinusTests::test_require_equal_number_of_fields", + "pypika/tests/test_joins.py::ExceptOfTests::test_except", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_as_subquery", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_multiple", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_query_with_order_by_use_minus_query_field", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_with_no_quote_char", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_with_order_by", + "pypika/tests/test_joins.py::ExceptOfTests::test_require_equal_number_of_fields_except_of", + "pypika/tests/test_negation.py::NegationTests::test_negate_field", + "pypika/tests/test_negation.py::NegationTests::test_negate_function", + "pypika/tests/test_negation.py::NegationTests::test_negate_wrapped_float", + "pypika/tests/test_negation.py::NegationTests::test_negate_wrapped_int", + "pypika/tests/test_parameter.py::ParametrizedTests::test_format_parameter", + "pypika/tests/test_parameter.py::ParametrizedTests::test_join", + "pypika/tests/test_parameter.py::ParametrizedTests::test_named_parameter", + "pypika/tests/test_parameter.py::ParametrizedTests::test_numeric_parameter", + "pypika/tests/test_parameter.py::ParametrizedTests::test_param_insert", + "pypika/tests/test_parameter.py::ParametrizedTests::test_param_select_join", + "pypika/tests/test_parameter.py::ParametrizedTests::test_param_select_subquery", + "pypika/tests/test_parameter.py::ParametrizedTests::test_pyformat_parameter", + "pypika/tests/test_parameter.py::ParametrizedTests::test_qmark_parameter", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_join", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_join_with_parameter_value_wrapper", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_param_insert", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_param_select_join", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_param_select_subquery", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_pyformat_parameter", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_can_be_used_in_a_select_statement", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_can_be_used_in_a_where_clause", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_can_be_used_in_orderby", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_column_value", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_object_id", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_object_value", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_row_id", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_row_num", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_sys_date", + "pypika/tests/test_query.py::QueryTablesTests::test_is_joined", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_case_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_delete_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_filter_tables", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_having_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_insert_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_insert_table_current_table_not_match", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_join_tables", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_only_specified_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_orderby_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_tuple_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_update_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_update_table_current_table_not_match", + "pypika/tests/test_query.py::QueryBuilderTests::test_pipe", + "pypika/tests/test_query.py::QueryBuilderTests::test_query_builders_have_reference_to_correct_query_class", + "pypika/tests/test_selects.py::SelectTests::test_empty_query", + "pypika/tests/test_selects.py::SelectTests::test_mssql_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_mysql_query_uses_backtick_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_oracle_query_uses_no_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_postgresql_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_redshift_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_select__column__single__alias__str", + "pypika/tests/test_selects.py::SelectTests::test_select__column__single__field", + "pypika/tests/test_selects.py::SelectTests::test_select__column__single__str", + "pypika/tests/test_selects.py::SelectTests::test_select__column__single__table_alias__str", + "pypika/tests/test_selects.py::SelectTests::test_select__columns__multi__field", + "pypika/tests/test_selects.py::SelectTests::test_select__columns__multi__str", + "pypika/tests/test_selects.py::SelectTests::test_select__distinct__multi", + "pypika/tests/test_selects.py::SelectTests::test_select__distinct__single", + "pypika/tests/test_selects.py::SelectTests::test_select__multiple_subqueries", + "pypika/tests/test_selects.py::SelectTests::test_select__multiple_tables", + "pypika/tests/test_selects.py::SelectTests::test_select__nested_subquery", + "pypika/tests/test_selects.py::SelectTests::test_select__no_table", + "pypika/tests/test_selects.py::SelectTests::test_select__star", + "pypika/tests/test_selects.py::SelectTests::test_select__star__replacement", + "pypika/tests/test_selects.py::SelectTests::test_select__subquery", + "pypika/tests/test_selects.py::SelectTests::test_select__table_schema", + "pypika/tests/test_selects.py::SelectTests::test_select__table_schema_with_multiple_levels_as_list", + "pypika/tests/test_selects.py::SelectTests::test_select__table_schema_with_multiple_levels_as_tuple", + "pypika/tests/test_selects.py::SelectTests::test_select_no_from", + "pypika/tests/test_selects.py::SelectTests::test_select_no_from_with_field_raises_exception", + "pypika/tests/test_selects.py::SelectTests::test_select_no_with_alias_from", + "pypika/tests/test_selects.py::SelectTests::test_select_then_add_table", + "pypika/tests/test_selects.py::SelectTests::test_select_with_force_index", + "pypika/tests/test_selects.py::SelectTests::test_select_with_force_index_multiple_calls", + "pypika/tests/test_selects.py::SelectTests::test_select_with_force_index_multiple_indexes", + "pypika/tests/test_selects.py::SelectTests::test_select_with_force_index_with_index_object", + "pypika/tests/test_selects.py::SelectTests::test_select_with_limit", + "pypika/tests/test_selects.py::SelectTests::test_select_with_limit__func", + "pypika/tests/test_selects.py::SelectTests::test_select_with_limit_and_offset", + "pypika/tests/test_selects.py::SelectTests::test_select_with_limit_zero", + "pypika/tests/test_selects.py::SelectTests::test_select_with_offset", + "pypika/tests/test_selects.py::SelectTests::test_select_with_offset__func", + "pypika/tests/test_selects.py::SelectTests::test_select_with_use_index", + "pypika/tests/test_selects.py::SelectTests::test_select_with_use_index_multiple_calls", + "pypika/tests/test_selects.py::SelectTests::test_select_with_use_index_multiple_indexes", + "pypika/tests/test_selects.py::SelectTests::test_select_with_use_index_with_index_object", + "pypika/tests/test_selects.py::SelectTests::test_table_select_alias", + "pypika/tests/test_selects.py::SelectTests::test_table_select_alias_with_offset_and_limit", + "pypika/tests/test_selects.py::SelectTests::test_temporal_select", + "pypika/tests/test_selects.py::SelectTests::test_vertica_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::WhereTests::test_ignore_empty_criterion_having", + "pypika/tests/test_selects.py::WhereTests::test_ignore_empty_criterion_where", + "pypika/tests/test_selects.py::WhereTests::test_select_with_force_index_and_where", + "pypika/tests/test_selects.py::WhereTests::test_where_enum", + "pypika/tests/test_selects.py::WhereTests::test_where_field_contains", + "pypika/tests/test_selects.py::WhereTests::test_where_field_does_not_contain", + "pypika/tests/test_selects.py::WhereTests::test_where_field_does_not_end_with", + "pypika/tests/test_selects.py::WhereTests::test_where_field_does_not_start_with", + "pypika/tests/test_selects.py::WhereTests::test_where_field_ends_with", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_and", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_nowait", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_of", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_of_multiple_tables", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_of_nowait", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_of_skip_locked", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_skip_locked", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_skip_locked_and_of", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_or", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_where", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_where_not", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_where_two_not", + "pypika/tests/test_selects.py::WhereTests::test_where_field_is_n_chars_long", + "pypika/tests/test_selects.py::WhereTests::test_where_field_is_not_n_chars_long", + "pypika/tests/test_selects.py::WhereTests::test_where_field_matches_regex", + "pypika/tests/test_selects.py::WhereTests::test_where_field_matches_regexp", + "pypika/tests/test_selects.py::WhereTests::test_where_field_matches_rlike", + "pypika/tests/test_selects.py::WhereTests::test_where_field_starts_with", + "pypika/tests/test_selects.py::WhereTests::test_where_nested_conditions", + "pypika/tests/test_selects.py::WhereTests::test_where_single_quote", + "pypika/tests/test_selects.py::WhereTests::test_where_with_multiple_wheres_using_and_case", + "pypika/tests/test_selects.py::WhereTests::test_where_with_multiple_wheres_using_or_case", + "pypika/tests/test_selects.py::PreWhereTests::test_ignore_empty_criterion_having", + "pypika/tests/test_selects.py::PreWhereTests::test_ignore_empty_criterion_where", + "pypika/tests/test_selects.py::PreWhereTests::test_prewhere_field_equals", + "pypika/tests/test_selects.py::PreWhereTests::test_select_with_force_index_and_where", + "pypika/tests/test_selects.py::PreWhereTests::test_where_and_prewhere", + "pypika/tests/test_selects.py::PreWhereTests::test_where_enum", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_contains", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_does_not_contain", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_does_not_end_with", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_does_not_start_with", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_ends_with", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_and", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_nowait", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_of", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_of_multiple_tables", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_of_nowait", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_of_skip_locked", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_skip_locked", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_skip_locked_and_of", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_or", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_where", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_where_not", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_where_two_not", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_is_n_chars_long", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_is_not_n_chars_long", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_matches_regex", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_matches_regexp", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_matches_rlike", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_starts_with", + "pypika/tests/test_selects.py::PreWhereTests::test_where_nested_conditions", + "pypika/tests/test_selects.py::PreWhereTests::test_where_single_quote", + "pypika/tests/test_selects.py::PreWhereTests::test_where_with_multiple_wheres_using_and_case", + "pypika/tests/test_selects.py::PreWhereTests::test_where_with_multiple_wheres_using_or_case", + "pypika/tests/test_selects.py::GroupByTests::test_group_by__single_with_totals", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__alias", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__alias_platforms", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__alias_with_join", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__count_distinct", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__count_field", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__count_star", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__int", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__multi", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__multi_with_totals", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__no_alias", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__no_alias_mssql", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__no_alias_oracle", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__single", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__str", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__sum_distinct", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__sum_filter", + "pypika/tests/test_selects.py::GroupByTests::test_groupby_with_case_uses_the_alias", + "pypika/tests/test_selects.py::GroupByTests::test_mssql_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_mysql_query_uses_backtick_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_oracle_query_uses_no_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_postgres_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_redshift_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_vertica_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_having_and", + "pypika/tests/test_selects.py::HavingTests::test_having_greater_than", + "pypika/tests/test_selects.py::HavingTests::test_having_join_and_equality", + "pypika/tests/test_selects.py::HavingTests::test_mssql_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_mysql_query_uses_backtick_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_oracle_query_uses_no_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_postgres_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_redshift_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_vertica_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_alias", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_asc", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_desc", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_multi_fields", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_no_alias", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_single_field", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_single_str", + "pypika/tests/test_selects.py::AliasTests::test_arithmetic_function", + "pypika/tests/test_selects.py::AliasTests::test_case_using_as", + "pypika/tests/test_selects.py::AliasTests::test_case_using_constructor_param", + "pypika/tests/test_selects.py::AliasTests::test_function_using_as_nested", + "pypika/tests/test_selects.py::AliasTests::test_functions_using_as", + "pypika/tests/test_selects.py::AliasTests::test_functions_using_constructor_param", + "pypika/tests/test_selects.py::AliasTests::test_functions_using_constructor_param_nested", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_criterion", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_criterion_comparison", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_field_inside_case", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_groupby", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_orderby", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_where", + "pypika/tests/test_selects.py::AliasTests::test_null_value_with_alias", + "pypika/tests/test_selects.py::AliasTests::test_select__multiple_tables", + "pypika/tests/test_selects.py::AliasTests::test_table_field", + "pypika/tests/test_selects.py::AliasTests::test_table_field__multi", + "pypika/tests/test_selects.py::AliasTests::test_table_with_schema_and_alias", + "pypika/tests/test_selects.py::AliasTests::test_use_aliases_in_groupby_and_orderby", + "pypika/tests/test_selects.py::SubqueryTests::test_from_subquery_without_alias", + "pypika/tests/test_selects.py::SubqueryTests::test_join", + "pypika/tests/test_selects.py::SubqueryTests::test_join_query_with_alias", + "pypika/tests/test_selects.py::SubqueryTests::test_join_with_with", + "pypika/tests/test_selects.py::SubqueryTests::test_select_from_nested_query", + "pypika/tests/test_selects.py::SubqueryTests::test_select_from_nested_query_with_join", + "pypika/tests/test_selects.py::SubqueryTests::test_select_from_with_returning", + "pypika/tests/test_selects.py::SubqueryTests::test_select_subquery", + "pypika/tests/test_selects.py::SubqueryTests::test_select_subquery_with_alias", + "pypika/tests/test_selects.py::SubqueryTests::test_where__equality", + "pypika/tests/test_selects.py::SubqueryTests::test_where__in", + "pypika/tests/test_selects.py::SubqueryTests::test_where__in_nested", + "pypika/tests/test_selects.py::SubqueryTests::test_with", + "pypika/tests/test_selects.py::QuoteTests::test_extraneous_quotes", + "pypika/tests/test_tables.py::TableStructureTests::test_database_schema_table_attr", + "pypika/tests/test_tables.py::TableStructureTests::test_schema_table_attr", + "pypika/tests/test_tables.py::TableStructureTests::test_table_for_period_sql", + "pypika/tests/test_tables.py::TableStructureTests::test_table_for_system_time_sql", + "pypika/tests/test_tables.py::TableStructureTests::test_table_sql", + "pypika/tests/test_tables.py::TableStructureTests::test_table_with_alias", + "pypika/tests/test_tables.py::TableStructureTests::test_table_with_schema_and_schema_parent_arg", + "pypika/tests/test_tables.py::TableStructureTests::test_table_with_schema_arg", + "pypika/tests/test_tables.py::TableEqualityTests::test_many_tables_with_alias", + "pypika/tests/test_tables.py::TableEqualityTests::test_many_tables_with_or_not_alias", + "pypika/tests/test_tables.py::TableEqualityTests::test_many_tables_without_alias", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_equal_by_name", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_equal_by_schema_and_name", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_equal_by_schema_and_name_using_schema", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_equal_by_schema_and_name_using_schema_with_parent", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_not_equal_by_schema_and_name_using_schema_with_different_parents", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_not_equal_with_different_names", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_not_equal_with_different_schemas", + "pypika/tests/test_tables.py::TableDialectTests::test_make_tables_factory_with_default_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_make_tables_factory_with_dialect_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_factory_with_default_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_factory_with_dialect_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_with_bad_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_with_default_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_with_dialect_query_cls", + "pypika/tests/test_terms.py::FieldAliasTests::test_when_alias_specified", + "pypika/tests/test_terms.py::FieldInitTests::test_init_with_str_table", + "pypika/tests/test_terms.py::FieldHashingTests::test_non_tabled_aliased_eq_fields_equally_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_non_tabled_aliased_ne_fields_differently_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_non_tabled_eq_fields_equally_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_non_tabled_ne_fields_differently_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_tabled_eq_fields_equally_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_tabled_ne_fields_differently_hashed", + "pypika/tests/test_terms.py::AtTimezoneTests::test_passes_kwargs_to_field_get_sql", + "pypika/tests/test_terms.py::AtTimezoneTests::test_when_alias_specified", + "pypika/tests/test_terms.py::AtTimezoneTests::test_when_interval_not_specified", + "pypika/tests/test_terms.py::AtTimezoneTests::test_when_interval_specified", + "pypika/tests/test_tuples.py::TupleTests::test_render_alias_in_array_sql", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_equality_tuple_on_both", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_equality_tuple_on_left", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_equality_tuple_on_right", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_in_using_mixed_tuples", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_in_using_pypika_tuples", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_in_using_python_tuples", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_is_aggregate", + "pypika/tests/test_tuples.py::TupleTests::test_tuples_in_join", + "pypika/tests/test_tuples.py::ArrayTests::test_array_general", + "pypika/tests/test_tuples.py::ArrayTests::test_empty_psql_array", + "pypika/tests/test_tuples.py::ArrayTests::test_psql_array_general", + "pypika/tests/test_tuples.py::ArrayTests::test_render_alias_in_array_sql", + "pypika/tests/test_tuples.py::BracketTests::test_arithmetic_with_brackets", + "pypika/tests/test_tuples.py::BracketTests::test_arithmetic_with_brackets_and_alias", + "pypika/tests/test_updates.py::UpdateTests::test_empty_query", + "pypika/tests/test_updates.py::UpdateTests::test_for_portion", + "pypika/tests/test_updates.py::UpdateTests::test_omit_where", + "pypika/tests/test_updates.py::UpdateTests::test_single_quote_escape_in_set", + "pypika/tests/test_updates.py::UpdateTests::test_update__table_schema", + "pypika/tests/test_updates.py::UpdateTests::test_update_from", + "pypika/tests/test_updates.py::UpdateTests::test_update_from_with_where", + "pypika/tests/test_updates.py::UpdateTests::test_update_with_join", + "pypika/tests/test_updates.py::UpdateTests::test_update_with_limit", + "pypika/tests/test_updates.py::UpdateTests::test_update_with_none", + "pypika/tests/test_updates.py::UpdateTests::test_update_with_statement", + "pypika/tests/test_updates.py::PostgresUpdateTests::test_update_returning", + "pypika/tests/test_updates.py::PostgresUpdateTests::test_update_returning_from_different_tables", + "pypika/tests/test_updates.py::PostgresUpdateTests::test_update_returning_star", + "pypika/tests/test_updates.py::PostgresUpdateTests::test_update_returning_str", + "pypika/tests/test_updates.py::SQLLiteUpdateTests::test_update_with_bool", + "pypika/tests/test_utils.py::ImmutabilityTests::test_raise_attribute_error_for_deepcopy", + "pypika/tests/test_utils.py::ImmutabilityTests::test_raise_attribute_error_for_getnewargs", + "pypika/tests/test_utils.py::ImmutabilityTests::test_raise_attribute_error_for_getstate", + "pypika/tests/test_utils.py::ImmutabilityTests::test_raise_attribute_error_for_setstate" + ] +} diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/grade.py b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/grade.py new file mode 100644 index 0000000000000000000000000000000000000000..e3b37293830e51a5c5833c93c4705e1ed9364257 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/grade.py @@ -0,0 +1,128 @@ +"""Trusted private pytest panel runner. Installed only in a fresh grader Job.""" + +import hashlib +import importlib.util +import json +import os +import shutil +import stat +import subprocess +from pathlib import Path, PurePosixPath + + +def sha(raw): + return hashlib.sha256(raw).hexdigest() + + +def safe(value): + path = PurePosixPath(value) + if ( + path.is_absolute() + or path.as_posix() != value + or not path.parts + or any(part in {".", "..", ".git"} for part in path.parts) + ): + raise ValueError("Unsafe trusted test path") + return path + + +def restore(worktree, private, manifest): + worktree, private = Path(worktree), Path(private) + captured = {} + for name, expected in manifest["files"].items(): + path = private / safe(name) + info = path.lstat() + raw = path.read_bytes() if stat.S_ISREG(info.st_mode) else b"" + if ( + not stat.S_ISREG(info.st_mode) + or len(raw) != expected["bytes"] + or sha(raw) != expected["sha256"] + or stat.S_IMODE(info.st_mode) != expected["mode"] + ): + raise ValueError("Trusted private test bytes or modes drifted") + captured[name] = (raw, expected["mode"]) + # Capture and verify every private byte before changing the submitted tree. + for name in manifest["directory_roots"]: + destination = worktree / safe(name) + if destination.is_symlink(): + raise ValueError("Submitted test directory is a symlink") + for parent in destination.parents: + if parent == worktree: + break + if parent.is_symlink(): + raise ValueError("Submitted test parent is a symlink") + if destination.exists(): + if not destination.is_dir(): + raise ValueError("Submitted test directory is not a directory") + shutil.rmtree(destination) + for name, (raw, mode) in captured.items(): + destination = worktree / safe(name) + for parent in destination.parents: + if parent == worktree: + break + if parent.is_symlink(): + raise ValueError("Submitted test parent is a symlink") + if destination.is_symlink(): + raise ValueError("Submitted trusted file is a symlink") + destination.parent.mkdir(parents=True, exist_ok=True) + destination.write_bytes(raw) + destination.chmod(mode) + + +def run(worktree, private_root, output, invoke=None): + private_root, output, worktree = Path(private_root), Path(output), Path(worktree) + expected = json.loads((private_root / "expected-panels.json").read_bytes()) + config = json.loads((private_root / "panel-config.json").read_bytes()) + manifest = json.loads((private_root / "trusted-inventory.json").read_bytes()) + restore(worktree, private_root / "trusted", manifest) + output.mkdir(parents=True, exist_ok=True) + for name in ( + "reward.txt", + "pass-to-pass.xml", + "fail-to-pass.xml", + "pytest-evidence.json", + ): + (output / name).unlink(missing_ok=True) + environment = dict(os.environ) + for key in ("PYTEST_ADDOPTS", "PYTEST_DISABLE_PLUGIN_AUTOLOAD", "PYTHONPATH"): + environment.pop(key, None) + commands, native_exit = [], 0 + invoke = invoke or subprocess.run + for group in ("pass-to-pass", "fail-to-pass"): + if ( + not isinstance(expected[group], list) + or not expected[group] + or any( + not isinstance(target, str) or not target for target in expected[group] + ) + ): + raise ValueError("Frozen native pytest selectors are incomplete") + command = [ + *config["official_pytest_argv"], + "--override-ini=addopts=", + "--junitxml=" + str(output / (group + ".xml")), + *expected[group], + ] + result = invoke(command, cwd=worktree, env=environment, check=False) + native_exit = result.returncode + commands.append({"group": group, "argv": command, "exit_code": native_exit}) + if native_exit != 0: + break + (output / "pytest-commands.json").write_text( + json.dumps(commands, sort_keys=True) + "\n" + ) + spec = importlib.util.spec_from_file_location( + "trusted_pytest_result", private_root / "check_pytest.py" + ) + checker = importlib.util.module_from_spec(spec) + spec.loader.exec_module(checker) + result = checker.assess(output, expected, native_exit) + (output / "reward.txt").write_text(str(result["reward"]) + "\n") + (output / "pytest-evidence.json").write_text( + json.dumps(result, sort_keys=True) + "\n" + ) + return result + + +if __name__ == "__main__": + run("/testbed/repo", "/tests", "/logs/verifier") diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/panel-config.json b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/panel-config.json new file mode 100644 index 0000000000000000000000000000000000000000..6417b9c92e5da5b97ee641bd54f798302af42a31 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/panel-config.json @@ -0,0 +1,28 @@ +{ + "dependency_installation_pinned": false, + "official_install_cmds": [ + "python -m pip install -e ." + ], + "official_pytest_argv": [ + "pytest", + "--disable-warnings", + "--color=no", + "--tb=no", + "--verbose" + ], + "official_test_command": "source /opt/miniconda3/bin/activate; conda activate testbed; pytest --disable-warnings --color=no --tb=no --verbose", + "operator_test_runner_prerequisites": [ + "python -m pip install pytest==8.4.2" + ], + "operator_test_runner_reason": "The official profile invokes pytest, but the common tools runtime does not provide it; pinned separately from source-native project requirements.", + "panel_normalization": "Override project addopts only to execute the exact frozen native panels; add JUnit output, preserve official pytest options and all selectors.", + "python_version": "3.10", + "source_bound_test_dependency_cmds": [ + "python -m pip install parameterized==0.7.0" + ], + "test_dependency_source_sha256": { + "requirements-dev.txt": "10f4ba7b19a73950d28fd7403d7e1d1b1fe2ccc4f49516974f47199d2965f23d", + "setup.py": "f8bad274588a22e65764d8cf9fb2be5aa6fcfaf3bf861d71e5f751105898845a", + "tox.ini": "c2d7205d0ac93e9c9e80dc5d24f0a826a6781f587a33ea722ea621f9e2ccd0ea" + } +} diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/test.sh b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..81b6d0620f05dbd3b54b4e7ea5de04ce3f8a98e2 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/test.sh @@ -0,0 +1,6 @@ +#!/bin/bash +set -Eeuo pipefail +source /opt/miniconda3/bin/activate +conda activate testbed +cd /testbed/repo +exec python -I /tests/grade.py diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted-inventory.json b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted-inventory.json new file mode 100644 index 0000000000000000000000000000000000000000..6926ef1c22ed56457101c37cd70e0fe0d1656f0c --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted-inventory.json @@ -0,0 +1,242 @@ +{ + "directory_roots": [ + "pypika/tests" + ], + "files": { + "pypika/tests/__init__.py": { + "bytes": 58, + "mode": 420, + "sha256": "7d41f44b87688bdf162e6d5cbe7b517cfba468f96eaa421f02718c17eb486a18" + }, + "pypika/tests/clickhouse/__init__.py": { + "bytes": 0, + "mode": 420, + "sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "pypika/tests/clickhouse/test_array.py": { + "bytes": 2942, + "mode": 420, + "sha256": "0f0a5b4c3daf3ddce2944b6119795e80d50b74e4687ef2e34399e5d21d3d48ae" + }, + "pypika/tests/clickhouse/test_condition.py": { + "bytes": 2533, + "mode": 420, + "sha256": "c666976d082b1d12cd57e791d1a525183246335efad96a369b58871a6f1e4fa1" + }, + "pypika/tests/clickhouse/test_dates_and_times.py": { + "bytes": 2508, + "mode": 420, + "sha256": "cb8ea84363e35ad0a00b52a8ec20cb38f2348f4cba28d026a4c32c14fd1fc56f" + }, + "pypika/tests/clickhouse/test_nullable_arg.py": { + "bytes": 672, + "mode": 420, + "sha256": "883c5161ebeb09544ce124d20a096d248bd12a0404ad77c84637be75d6738529" + }, + "pypika/tests/clickhouse/test_search_string.py": { + "bytes": 1189, + "mode": 420, + "sha256": "d5f0ed6a51cf550bdd4b261fa2e98084184dd1cbb08f5dbb8b91278b4c8f3bfd" + }, + "pypika/tests/clickhouse/test_type_conversion.py": { + "bytes": 4445, + "mode": 420, + "sha256": "7e6045b64433a8947346cfb34ac30279349f7a2e2081a2815212c8cb7d0235ab" + }, + "pypika/tests/dialects/__init__.py": { + "bytes": 0, + "mode": 420, + "sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "pypika/tests/dialects/test_clickhouse.py": { + "bytes": 5747, + "mode": 420, + "sha256": "2272538d6eeb6dfb01f9803eed328b4cd4efc8d255b6a8ab3c4e25bee74d73fa" + }, + "pypika/tests/dialects/test_mssql.py": { + "bytes": 3152, + "mode": 420, + "sha256": "0cd9b2ee6498caa9fa75a51ead30803057fb23deb2ac706d396d88329e0e91d7" + }, + "pypika/tests/dialects/test_mysql.py": { + "bytes": 2984, + "mode": 420, + "sha256": "a5f4550dd14bf4820e5d85cf06b6c7c79286e41d2d3c794f639579d20fffab92" + }, + "pypika/tests/dialects/test_oracle.py": { + "bytes": 1906, + "mode": 420, + "sha256": "67f80eb40cc9b4dabcbad355e8be6d83c54a64cbee809182ef57fa9f48d2ebc6" + }, + "pypika/tests/dialects/test_postgresql.py": { + "bytes": 9532, + "mode": 420, + "sha256": "548ee7267ca87c9e1ae82ca89a4e5bd96c7392a55cc07996f2b105f911ffa6cf" + }, + "pypika/tests/dialects/test_snowflake.py": { + "bytes": 2159, + "mode": 420, + "sha256": "e567b9dab0a5366bd11a0ef162c3a3bb492280b78bc4b397a23070563dc84468" + }, + "pypika/tests/dialects/test_sqllite.py": { + "bytes": 1243, + "mode": 420, + "sha256": "118fed7e575415f276bda390a119080bd6a767aee3d9c953e11a8c219f0f017c" + }, + "pypika/tests/dialects/test_vertica.py": { + "bytes": 3578, + "mode": 420, + "sha256": "33a027e6735ca03b7afd11394905c4193e48a15dda3efbe47cdcd85fcabf840c" + }, + "pypika/tests/test_aggregate.py": { + "bytes": 3946, + "mode": 420, + "sha256": "5b0fb549de3bb50ad88ae1d75824f12f7ab4a5f1102b06a70c7b2ebae33bea6d" + }, + "pypika/tests/test_analytic_queries.py": { + "bytes": 20611, + "mode": 420, + "sha256": "8546b7a296c8e212c349c4baff95f93934b3120f74625b3945ade3b438e3a3ed" + }, + "pypika/tests/test_create.py": { + "bytes": 9088, + "mode": 420, + "sha256": "6c57302da52ca1044be0afdafe677d5de245e44873dff1386c9a1ccb2625cc82" + }, + "pypika/tests/test_criterions.py": { + "bytes": 32014, + "mode": 420, + "sha256": "78539ccca82f9a02fad0f5a39041ac343e3a142ce52368cd4f6ada489c52516a" + }, + "pypika/tests/test_custom_functions.py": { + "bytes": 1710, + "mode": 420, + "sha256": "bfa18bc328a3577965db7cc75eb94439f0cfd95a3775d9b1cc8af1062bb202cb" + }, + "pypika/tests/test_data_types.py": { + "bytes": 403, + "mode": 420, + "sha256": "c1be6ecc621a80dd91d35b1427bdfc8b1b33bd926515198e626d6fb5e1878c8b" + }, + "pypika/tests/test_date_math.py": { + "bytes": 5544, + "mode": 420, + "sha256": "85aa54efe54fe19639f2dc2a5750647e3337ac2681768bc3fe327841f1634d9e" + }, + "pypika/tests/test_deletes.py": { + "bytes": 3204, + "mode": 420, + "sha256": "ccde6df760d76d5d499ce828f6b0e2ad3eebcb2a5553c1890f481b9160b8d51a" + }, + "pypika/tests/test_drop.py": { + "bytes": 1556, + "mode": 420, + "sha256": "a13dffa59ef8657398d5498c18977bfd702635e336ea9966b1a86137afca7926" + }, + "pypika/tests/test_formats.py": { + "bytes": 1948, + "mode": 420, + "sha256": "240458a404bb119322778893b94a12be0f98f914acd701d2b4be73eb9be96f75" + }, + "pypika/tests/test_functions.py": { + "bytes": 32769, + "mode": 420, + "sha256": "3ceaac7791bd27e50f44e1b4a1451d1e09afe6a8011052caea838e5124582154" + }, + "pypika/tests/test_groupby_modifiers.py": { + "bytes": 5227, + "mode": 420, + "sha256": "9db4497660f08e3352a9a02c34889ad1cd6bab3aebaeaa485e84390ad71c84c5" + }, + "pypika/tests/test_immutability.py": { + "bytes": 3954, + "mode": 420, + "sha256": "af537ced19f7274951cc91697eae748ef6c9cd20a8d8e492d93dc85b06f8fb50" + }, + "pypika/tests/test_inserts.py": { + "bytes": 32549, + "mode": 420, + "sha256": "652e9f7f0f425e9acc0f70e2851ae29310b378262ea30369ea0113ef428f210f" + }, + "pypika/tests/test_internals.py": { + "bytes": 828, + "mode": 420, + "sha256": "4374c2632563346d00ca4de6af397a022ef3f5022e808c8711a3f207a3a21609" + }, + "pypika/tests/test_joins.py": { + "bytes": 43895, + "mode": 420, + "sha256": "53f224815c10393382443f020cb20e313420764495a8fd30f7ea2f34fd52935d" + }, + "pypika/tests/test_negation.py": { + "bytes": 763, + "mode": 420, + "sha256": "6be105e8f39b32fb23e6ac7c7158232ee78111455d4f35638c8af60781138c79" + }, + "pypika/tests/test_parameter.py": { + "bytes": 7382, + "mode": 420, + "sha256": "aaf2a3e79c8267bdc60e218445bc2a2254b97cf37b643a44d6f1a8141cbb5104" + }, + "pypika/tests/test_pseudocolumns.py": { + "bytes": 1609, + "mode": 420, + "sha256": "b7c69f7aca41323c0e14a6a9e58697399cd7860610f07291afc6e8af26079ca2" + }, + "pypika/tests/test_query.py": { + "bytes": 9025, + "mode": 420, + "sha256": "2da9d717673912a84e86e6c0d3955dbd8f2fa7b41b7ed9a6f78089dfa28f9444" + }, + "pypika/tests/test_selects.py": { + "bytes": 50757, + "mode": 420, + "sha256": "5ac1b7ad3248d64b1e3865a72c763873514ae5cd6e03356b913e531c0c336986" + }, + "pypika/tests/test_tables.py": { + "bytes": 6568, + "mode": 420, + "sha256": "384c8e843ba56374ee92cd7b7e2fd3f89247b899e23cd9e1f6663d751ad5d884" + }, + "pypika/tests/test_terms.py": { + "bytes": 3215, + "mode": 420, + "sha256": "8598513180ddcd28cc61582618d85bd570280978b07603044dae81b2eb099f77" + }, + "pypika/tests/test_tuples.py": { + "bytes": 6033, + "mode": 420, + "sha256": "863942196a93e8939be0d03c49cfeb42a35503ad42f9f3d6c730260112811087" + }, + "pypika/tests/test_updates.py": { + "bytes": 5689, + "mode": 420, + "sha256": "0f0f2521bb8d1f5d782f8fabaea5fd1d82090cde045ba87fad65770db6c75d2f" + }, + "pypika/tests/test_utils.py": { + "bytes": 834, + "mode": 420, + "sha256": "5db6e90df5daaa70b9f35f1243db69908da1f27887f63466fc27ce20c7e14892" + }, + "pyproject.toml": { + "bytes": 390, + "mode": 420, + "sha256": "037fedacd5be5d078f398265ff97e1677e25214ad8839d17073a439695ee7a91" + }, + "setup.cfg": { + "bytes": 317, + "mode": 420, + "sha256": "c84a31de586e8385e741127b004fc1f19ebae6463cdf0b3f243991db35cdeaea" + }, + "setup.py": { + "bytes": 2638, + "mode": 420, + "sha256": "f8bad274588a22e65764d8cf9fb2be5aa6fcfaf3bf861d71e5f751105898845a" + }, + "tox.ini": { + "bytes": 257, + "mode": 420, + "sha256": "c2d7205d0ac93e9c9e80dc5d24f0a826a6781f587a33ea722ea621f9e2ccd0ea" + } + } +} diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/__init__.py b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..86d8a68101915c27b95484243dd81d55f7dba356 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/__init__.py @@ -0,0 +1,2 @@ +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/clickhouse/__init__.py b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/clickhouse/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/clickhouse/test_array.py b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/clickhouse/test_array.py new file mode 100644 index 0000000000000000000000000000000000000000..469705a9ff3c8fe9cc7f02c44a9812521eeb67f4 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/clickhouse/test_array.py @@ -0,0 +1,104 @@ +import unittest + +from parameterized import parameterized + +from pypika import Field +from pypika.clickhouse.array import ( + Array, + Empty, + HasAny, + Length, + NotEmpty, +) +from pypika.clickhouse.type_conversion import ( + ToFixedString, + ToInt64, +) + + +class TestArray(unittest.TestCase): + @parameterized.expand( + [ + ( + "['ridley', 'scott', 'jimi', 'hendrix']", + Array(["ridley", "scott", "jimi", "hendrix"]), + ), + ( + "[1, 2, 3, 4]", + Array([1, 2, 3, 4]), + ), + ( + "[toInt64('1'),toInt64('2'),toInt64('3'),toInt64('4')]", + Array(["1", "2", "3", "4"], ToInt64), + ), + ( + "[toFixedString('mogwai',10),toFixedString('mono',10),toFixedString('bonobo',10)] arr", + Array(["mogwai", "mono", "bonobo"], ToFixedString, {"length": 10}).as_('arr'), + ), + ] + ) + def test_get_sql(self, expected: str, array: Array): + self.assertEqual(expected, array.get_sql()) + + +class TestHasAny(unittest.TestCase): + @parameterized.expand( + [ + ( + 'hasAny("mental_abilities","physical_abilities")', + HasAny(Field("mental_abilities"), Field("physical_abilities")), + ), + ("hasAny([1, 2, 3, 4],[3])", HasAny(Array([1, 2, 3, 4]), Array([3]))), + ( + "hasAny(\"bands\",[toFixedString('port-royal',20),toFixedString('hammock',20)])", + HasAny( + Field("bands"), + Array(["port-royal", "hammock"], ToFixedString, {"length": 20}), + ), + ), + ] + ) + def test_get_sql(self, expected: str, func: HasAny): + self.assertEqual(expected, func.get_sql()) + + +class TestLength(unittest.TestCase): + @parameterized.expand( + [ + ( + 'length("tags")', + Length(Field("tags")), + ), + ("length([1, 2, 3])", Length(Array([1, 2, 3]))), + ] + ) + def test_get_sql(self, expected: str, func: Length): + self.assertEqual(expected, func.get_sql()) + + +class TestEmpty(unittest.TestCase): + @parameterized.expand( + [ + ( + 'empty("tags")', + Empty(Field("tags")), + ), + ("empty([1, 2, 3])", Empty(Array([1, 2, 3]))), + ] + ) + def test_get_sql(self, expected: str, func: Empty): + self.assertEqual(expected, func.get_sql()) + + +class TestNotEmpty(unittest.TestCase): + @parameterized.expand( + [ + ( + 'notEmpty("tags")', + NotEmpty(Field("tags")), + ), + ("notEmpty([1, 2, 3])", NotEmpty(Array([1, 2, 3]))), + ] + ) + def test_get_sql(self, expected: str, func: NotEmpty): + self.assertEqual(expected, func.get_sql()) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/clickhouse/test_condition.py b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/clickhouse/test_condition.py new file mode 100644 index 0000000000000000000000000000000000000000..145baeb7753dd9cbefbd6f272bd672ae5730b0c0 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/clickhouse/test_condition.py @@ -0,0 +1,72 @@ +import unittest + +from parameterized import parameterized + +from pypika import Field +from pypika.clickhouse.condition import If, MultiIf +from pypika.clickhouse.type_conversion import ToFixedString + + +class TestIfCondition(unittest.TestCase): + @parameterized.expand( + [ + ( + If( + Field("filmmaker").isnull(), + ToFixedString("Tarantino", 20), + Field("filmmaker"), + ), + "if(filmmaker IS NULL,toFixedString('Tarantino',20),filmmaker)", + ), + ( + If( + Field("created") == Field("updated"), + ToFixedString("yes", 3), + ToFixedString("no", 3), + ), + "if(created=updated,toFixedString('yes',3),toFixedString('no',3))", + ), + ] + ) + def test_get_sql(self, func, expected): + self.assertEqual(func.get_sql(), expected) + + +class TestMultiIfCondition(unittest.TestCase): + @parameterized.expand( + [ + ( + MultiIf( + Field("filmmaker").isnull(), + ToFixedString("Tarantino", 20), + Field("filmmaker") == ToFixedString("undefined", 20), + ToFixedString("Tarantino", 20), + Field("filmmaker"), + ), + "multiIf(filmmaker IS NULL," + "toFixedString('Tarantino',20)," + "filmmaker=toFixedString('undefined',20)," + "toFixedString('Tarantino',20),filmmaker)", + ), + ( + MultiIf( + Field("color") == ToFixedString("black", 20), + ToFixedString("dark", 20), + Field("color") == ToFixedString("grey", 20), + ToFixedString("dark", 20), + Field("color") == ToFixedString("white", 20), + ToFixedString("light", 20), + ToFixedString("undefined", 20), + ), + "multiIf(color=toFixedString('black',20)," + "toFixedString('dark',20)," + "color=toFixedString('grey',20)," + "toFixedString('dark',20)," + "color=toFixedString('white',20)," + "toFixedString('light',20)," + "toFixedString('undefined',20))", + ), + ] + ) + def test_get_sql(self, func, expected): + self.assertEqual(func.get_sql(), expected) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/clickhouse/test_dates_and_times.py b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/clickhouse/test_dates_and_times.py new file mode 100644 index 0000000000000000000000000000000000000000..135dd7f112131776d76748e15eead1eb81752b59 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/clickhouse/test_dates_and_times.py @@ -0,0 +1,70 @@ +import unittest + +from parameterized import parameterized + +from pypika import Field +from pypika.clickhouse.dates_and_times import ( + AddDays, + AddHours, + AddMinutes, + AddMonths, + AddQuarters, + AddSeconds, + AddWeeks, + AddYears, + FormatDateTime, + SubtractDays, + SubtractHours, + SubtractMinutes, + SubtractMonths, + SubtractQuarters, + SubtractSeconds, + SubtractWeeks, + SubtractYears, + ToYYYYMM, +) + + +class TestFormatDateTime(unittest.TestCase): + @parameterized.expand( + [ + (FormatDateTime(Field("created"), "%V"), "formatDateTime(created,'%V')"), + ( + FormatDateTime(Field("created"), "%Y-%m-%d"), + "formatDateTime(created,'%Y-%m-%d')", + ), + ] + ) + def test_get_sql(self, func, expected): + self.assertEqual(func.get_sql(), expected) + + +class TestAddSubtractDt(unittest.TestCase): + @parameterized.expand( + [ + (AddYears(Field("created"), 1), "addYears(created,1)"), + (AddMonths(Field("created"), 2), "addMonths(created,2)"), + (AddWeeks(Field("created"), 3), "addWeeks(created,3)"), + (AddDays(Field("created"), 4), "addDays(created,4)"), + (AddHours(Field("created"), 5), "addHours(created,5)"), + (AddMinutes(Field("created"), 6), "addMinutes(created,6)"), + (AddSeconds(Field("created"), 7), "addSeconds(created,7)"), + (AddQuarters(Field("created"), 8), "addQuarters(created,8)"), + (SubtractYears(Field("created"), 9), "subtractYears(created,9)"), + (SubtractMonths(Field("created"), 10), "subtractMonths(created,10)"), + (SubtractWeeks(Field("created"), 11), "subtractWeeks(created,11)"), + (SubtractDays(Field("created"), 12), "subtractDays(created,12)"), + (SubtractHours(Field("created"), 13), "subtractHours(created,13)"), + (SubtractHours(Field("created"), 13), "subtractHours(created,13)"), + (SubtractMinutes(Field("created"), 14), "subtractMinutes(created,14)"), + (SubtractSeconds(Field("created"), 15), "subtractSeconds(created,15)"), + (SubtractQuarters(Field("created"), 16), "subtractQuarters(created,16)"), + ] + ) + def test_get_sql(self, func, expected): + self.assertEqual(func.get_sql(), expected) + + +class TestToYYYYMM(unittest.TestCase): + def test_get_sql(self): + self.assertEqual(ToYYYYMM(Field("created").get_sql()), "toYYYYMM(created)") diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/clickhouse/test_nullable_arg.py b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/clickhouse/test_nullable_arg.py new file mode 100644 index 0000000000000000000000000000000000000000..3c6c86207a4d0206b5c0ba80b77fac4cc257fa17 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/clickhouse/test_nullable_arg.py @@ -0,0 +1,24 @@ +import unittest + +from parameterized import parameterized + +from pypika import Field +from pypika.clickhouse.nullable_arg import IfNull +from pypika.clickhouse.type_conversion import ToFixedString + + +class TestSearchString(unittest.TestCase): + @parameterized.expand( + [ + ( + IfNull(Field("name"), Field("login")), + "ifNull(name,login)", + ), + ( + IfNull(Field("builder"), ToFixedString("pypika", 100)), + "ifNull(builder,toFixedString('pypika',100))", + ), + ] + ) + def test_get_sql(self, func, expected): + self.assertEqual(func.get_sql(), expected) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/clickhouse/test_search_string.py b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/clickhouse/test_search_string.py new file mode 100644 index 0000000000000000000000000000000000000000..9778eb32e47d4370c0bfe36dcd875903666d30b6 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/clickhouse/test_search_string.py @@ -0,0 +1,41 @@ +import unittest + +from parameterized import parameterized + +from pypika import Field +from pypika.clickhouse.search_string import ( + Match, + Like, + NotLike, + MultiSearchAny, + MultiMatchAny, +) + + +class TestSearchString(unittest.TestCase): + @parameterized.expand( + [ + (Match(Field("name"), "twheys"), "match(toString(\"name\"),'twheys')"), + (Like(Field("name"), "twheys"), "like(toString(\"name\"),'twheys')"), + (NotLike(Field("name"), "twheys"), "notLike(toString(\"name\"),'twheys')"), + ] + ) + def test_search_string(self, func, expected): + self.assertEqual(func, expected) + + +class TestMultiSearch(unittest.TestCase): + @parameterized.expand( + [ + ( + MultiSearchAny(Field("name"), ["sarah", "connor"]), + "multiSearchAny(toString(\"name\"),['sarah','connor'])", + ), + ( + MultiMatchAny(Field("name"), ["sarah", "connor"]), + "multiMatchAny(toString(\"name\"),['sarah','connor'])", + ), + ] + ) + def test_multi_search_string(self, func, expected): + self.assertEqual(func.get_sql(), expected) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/clickhouse/test_type_conversion.py b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/clickhouse/test_type_conversion.py new file mode 100644 index 0000000000000000000000000000000000000000..9692e17bee901e2629db9a5c77111e145358e8eb --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/clickhouse/test_type_conversion.py @@ -0,0 +1,176 @@ +import unittest + +from parameterized import parameterized + +from pypika import ClickHouseQuery, Field, Table +from pypika.clickhouse.type_conversion import ( + ToDate, + ToDateTime, + ToFixedString, + ToFloat32, + ToFloat64, + ToInt16, + ToInt32, + ToInt64, + ToInt8, + ToString, + ToUInt16, + ToUInt32, + ToUInt64, + ToUInt8, +) + + +class TestBasicTypeConverters(unittest.TestCase): + @parameterized.expand( + [ + ( + 'toString("field_name")', + ToString(Field("field_name")), + ), + ( + 'toInt8("field_name")', + ToInt8(Field("field_name")), + ), + ( + 'toInt16("field_name")', + ToInt16(Field("field_name")), + ), + ( + 'toInt32("field_name")', + ToInt32(Field("field_name")), + ), + ( + 'toInt64("field_name")', + ToInt64(Field("field_name")), + ), + ( + 'toUInt8("field_name")', + ToUInt8(Field("field_name")), + ), + ( + 'toUInt16("field_name")', + ToUInt16(Field("field_name")), + ), + ( + 'toUInt32("field_name")', + ToUInt32(Field("field_name")), + ), + ( + 'toUInt64("field_name")', + ToUInt64(Field("field_name")), + ), + ( + 'toFloat32("field_name")', + ToFloat32(Field("field_name")), + ), + ( + 'toFloat64("field_name")', + ToFloat64(Field("field_name")), + ), + ( + 'toFloat64("field_name")', + ToFloat64(Field("field_name")), + ), + ( + 'toDate("field_name")', + ToDate(Field("field_name")), + ), + ( + 'toDateTime("field_name")', + ToDateTime(Field("field_name")), + ), + ( + 'toFixedString("field_name",100)', + ToFixedString(Field("field_name"), 100), + ), + ] + ) + def test_basic_types_field(self, expected, func): + self.assertEqual(func, expected) + + @parameterized.expand( + [ + ( + "toString('100')", + ToString("100"), + ), + ( + "toInt8('100')", + ToInt8("100"), + ), + ( + "toInt16('100')", + ToInt16("100"), + ), + ( + "toInt32('100')", + ToInt32("100"), + ), + ( + "toInt64('100')", + ToInt64("100"), + ), + ( + "toUInt8('100')", + ToUInt8("100"), + ), + ( + "toUInt16('100')", + ToUInt16("100"), + ), + ( + "toUInt32('100')", + ToUInt32("100"), + ), + ( + "toUInt64('100')", + ToUInt64("100"), + ), + ( + "toFloat32('100')", + ToFloat32("100"), + ), + ( + "toFloat64('100')", + ToFloat64("100"), + ), + ( + "toFloat64('100')", + ToFloat64("100"), + ), + ( + "toDate('100')", + ToDate("100"), + ), + ( + "toDateTime('100')", + ToDateTime("100"), + ), + ( + "toFixedString('100',100)", + ToFixedString("100", 100), + ), + ] + ) + def test_basic_types_value(self, expected, func): + self.assertEqual(func, expected) + + +class TestToFixedString(unittest.TestCase): + def test_get_sql_with_table(self): + table = Table("example") + query = ( + ClickHouseQuery.from_(table) + .select( + table.name, + ) + .where( + table.name == ToFixedString("name", 50), + ) + ) + + self.assertEqual( + 'SELECT "name" FROM "example" WHERE "name"=toFixedString(\'name\',50)', + query.get_sql(), + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/dialects/__init__.py b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/dialects/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/dialects/test_clickhouse.py b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/dialects/test_clickhouse.py new file mode 100644 index 0000000000000000000000000000000000000000..f319c4627bd25d7004894181906a284b8b1c64cf --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/dialects/test_clickhouse.py @@ -0,0 +1,146 @@ +from unittest import TestCase + +from pypika import ( + ClickHouseQuery, + Database, + Table, +) + + +class ClickHouseQueryTests(TestCase): + def test_use_AS_keyword_for_alias(self): + t = Table('abc') + query = ClickHouseQuery.from_(t).select(t.foo.as_('f1'), t.bar.as_('f2')) + self.assertEqual(str(query), 'SELECT "foo" AS "f1","bar" AS "f2" FROM "abc"') + + def test_use_SAMPLE_keyword(self): + t = Table('abc') + query = ClickHouseQuery.from_(t).select(t.foo).sample(10) + self.assertEqual(str(query), 'SELECT "foo" FROM "abc" SAMPLE 10') + + def test_use_SAMPLE_with_offset_keyword(self): + t = Table('abc') + query = ClickHouseQuery.from_(t).select(t.foo).sample(10, 5) + self.assertEqual(str(query), 'SELECT "foo" FROM "abc" SAMPLE 10 OFFSET 5') + + def test_use_FINAL_keyword(self): + t = Table('abc') + query = ClickHouseQuery.from_(t).select(t.foo).final() + self.assertEqual(str(query), 'SELECT "foo" FROM "abc" FINAL') + + +class ClickHouseDeleteTests(TestCase): + table_abc = Table("abc") + + def test_omit_where(self): + q = ClickHouseQuery.from_("abc").delete() + + self.assertEqual('ALTER TABLE "abc" DELETE', str(q)) + + def test_omit_where__table_schema(self): + q = ClickHouseQuery.from_(Table("abc", "schema1")).delete() + + self.assertEqual('ALTER TABLE "schema1"."abc" DELETE', str(q)) + + def test_where_field_equals(self): + q1 = ClickHouseQuery.from_(self.table_abc).where(self.table_abc.foo == self.table_abc.bar).delete() + q2 = ClickHouseQuery.from_(self.table_abc).where(self.table_abc.foo.eq(self.table_abc.bar)).delete() + + self.assertEqual('ALTER TABLE "abc" DELETE WHERE "foo"="bar"', str(q1)) + self.assertEqual('ALTER TABLE "abc" DELETE WHERE "foo"="bar"', str(q2)) + + +class ClickHouseUpdateTests(TestCase): + table_abc = Table("abc") + + def test_update(self): + q = ClickHouseQuery.update(self.table_abc).where(self.table_abc.foo == 0).set("foo", "bar") + + self.assertEqual('ALTER TABLE "abc" UPDATE "foo"=\'bar\' WHERE "foo"=0', str(q)) + + +class ClickHouseDropQuery(TestCase): + table_abc = Table("abc") + database_xyz = Database("mydb") + cluster_name = "mycluster" + + def test_drop_database(self): + q1 = ClickHouseQuery.drop_database(self.database_xyz) + q2 = ClickHouseQuery.drop_database(self.database_xyz).on_cluster(self.cluster_name) + q3 = ClickHouseQuery.drop_database(self.database_xyz).if_exists().on_cluster(self.cluster_name) + + self.assertEqual('DROP DATABASE "mydb"', str(q1)) + self.assertEqual('DROP DATABASE "mydb" ON CLUSTER "mycluster"', str(q2)) + self.assertEqual('DROP DATABASE IF EXISTS "mydb" ON CLUSTER "mycluster"', str(q3)) + + def test_drop_table(self): + q1 = ClickHouseQuery.drop_table(self.table_abc) + q2 = ClickHouseQuery.drop_table(self.table_abc).on_cluster(self.cluster_name) + q3 = ClickHouseQuery.drop_table(self.table_abc).if_exists().on_cluster(self.cluster_name) + + self.assertEqual('DROP TABLE "abc"', str(q1)) + self.assertEqual('DROP TABLE "abc" ON CLUSTER "mycluster"', str(q2)) + self.assertEqual('DROP TABLE IF EXISTS "abc" ON CLUSTER "mycluster"', str(q3)) + + def test_drop_dictionary(self): + q1 = ClickHouseQuery.drop_dictionary("dict") + q2 = ClickHouseQuery.drop_dictionary("dict").on_cluster(self.cluster_name) + q3 = ClickHouseQuery.drop_dictionary("dict").if_exists().on_cluster(self.cluster_name) + + self.assertEqual('DROP DICTIONARY "dict"', str(q1)) + self.assertEqual('DROP DICTIONARY "dict"', str(q2)) # NO CLUSTER + self.assertEqual('DROP DICTIONARY IF EXISTS "dict"', str(q3)) # NO CLUSTER + + def test_drop_other(self): + q1 = ClickHouseQuery.drop_quota("myquota") + q2 = ClickHouseQuery.drop_user("myuser") + q3 = ClickHouseQuery.drop_view("myview") + + self.assertEqual('DROP QUOTA "myquota"', str(q1)) + self.assertEqual('DROP USER "myuser"', str(q2)) + self.assertEqual('DROP VIEW "myview"', str(q3)) + + +class DistinctOnTests(TestCase): + table_abc = Table("abc") + + def test_distinct_on(self): + q = ClickHouseQuery.from_(self.table_abc).distinct_on("lname", self.table_abc.fname).select("lname", "id") + + self.assertEqual('''SELECT DISTINCT ON("lname","fname") "lname","id" FROM "abc"''', str(q)) + + +class LimitByTests(TestCase): + table_abc = Table("abc") + + def test_limit_by(self): + q = ClickHouseQuery.from_(self.table_abc).limit_by(1, "a", self.table_abc.b).select("a", "b", "c") + + self.assertEqual('''SELECT "a","b","c" FROM "abc" LIMIT 1 BY ("a","b")''', str(q)) + + def test_limit_offset_by(self): + q = ClickHouseQuery.from_(self.table_abc).limit_offset_by(1, 2, "a", self.table_abc.b).select("a", "b", "c") + + self.assertEqual('''SELECT "a","b","c" FROM "abc" LIMIT 1 OFFSET 2 BY ("a","b")''', str(q)) + + def test_limit_offset0_by(self): + q = ClickHouseQuery.from_(self.table_abc).limit_offset_by(1, 0, "a", self.table_abc.b).select("a", "b", "c") + + self.assertEqual('''SELECT "a","b","c" FROM "abc" LIMIT 1 BY ("a","b")''', str(q)) + + def test_rename_table(self): + table_join = Table("join") + + q = ( + ClickHouseQuery.from_(self.table_abc) + .join(table_join) + .using("a") + .limit_by(1, self.table_abc.a, table_join.a) + .select(self.table_abc.b, table_join.b) + ) + q = q.replace_table(self.table_abc, Table("xyz")) + + self.assertEqual( + '''SELECT "xyz"."b","join"."b" FROM "xyz" JOIN "join" USING ("a") LIMIT 1 BY ("xyz"."a","join"."a")''', + str(q), + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/dialects/test_mssql.py b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/dialects/test_mssql.py new file mode 100644 index 0000000000000000000000000000000000000000..7cf53b228f413a8c7cd3e414fef5522a82f99b29 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/dialects/test_mssql.py @@ -0,0 +1,81 @@ +import unittest + +from pypika import Table +from pypika.analytics import Count +from pypika.dialects import MSSQLQuery +from pypika.utils import QueryException + + +class SelectTests(unittest.TestCase): + def test_normal_select(self): + q = MSSQLQuery.from_("abc").select("def") + + self.assertEqual('SELECT "def" FROM "abc"', str(q)) + + def test_distinct_select(self): + q = MSSQLQuery.from_("abc").select("def").distinct() + + self.assertEqual('SELECT DISTINCT "def" FROM "abc"', str(q)) + + def test_top_distinct_select(self): + q = MSSQLQuery.from_("abc").select("def").top(10).distinct() + + self.assertEqual('SELECT DISTINCT TOP (10) "def" FROM "abc"', str(q)) + + def test_top_select(self): + q = MSSQLQuery.from_("abc").select("def").top(10) + + self.assertEqual('SELECT TOP (10) "def" FROM "abc"', str(q)) + + def test_top_with_ties_select(self): + q = MSSQLQuery.from_("abc").select("def").top(10, with_ties=True) + + self.assertEqual('SELECT TOP (10) WITH TIES "def" FROM "abc"', str(q)) + + def test_top_percent_select(self): + q = MSSQLQuery.from_("abc").select("def").top(10, percent=True) + + self.assertEqual('SELECT TOP (10) PERCENT "def" FROM "abc"', str(q)) + + def test_top_percent_invalid_range(self): + for invalid_top in [-1, 101]: + with self.assertRaisesRegex( + QueryException, "TOP value must be between 0 and 100 when `percent` is specified" + ): + MSSQLQuery.from_("abc").select("def").top(invalid_top, percent=True) + + def test_top_select_non_int(self): + with self.assertRaisesRegex(QueryException, "TOP value must be an integer"): + MSSQLQuery.from_("abc").select("def").top("a") + + def test_limit(self): + q = MSSQLQuery.from_("abc").select("def").orderby("def").limit(10) + + self.assertEqual('SELECT "def" FROM "abc" ORDER BY "def" OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY', str(q)) + + def test_offset(self): + q = MSSQLQuery.from_("abc").select("def").orderby("def").offset(10) + + self.assertEqual('SELECT "def" FROM "abc" ORDER BY "def" OFFSET 10 ROWS', str(q)) + + def test_limit_with_offset(self): + q = MSSQLQuery.from_("abc").select("def").orderby("def").limit(10).offset(10) + + self.assertEqual('SELECT "def" FROM "abc" ORDER BY "def" OFFSET 10 ROWS FETCH NEXT 10 ROWS ONLY', str(q)) + + def test_groupby_alias_False_does_not_group_by_alias_with_standard_query(self): + t = Table('table1') + col = t.abc.as_('a') + q = MSSQLQuery.from_(t).select(col, Count('*')).groupby(col) + + self.assertEqual('SELECT "abc" "a",COUNT(\'*\') FROM "table1" GROUP BY "abc"', str(q)) + + def test_groupby_alias_False_does_not_group_by_alias_when_subqueries_are_present(self): + t = Table('table1') + subquery = MSSQLQuery.from_(t).select(t.abc) + col = subquery.abc.as_('a') + q = MSSQLQuery.from_(subquery).select(col, Count('*')).groupby(col) + + self.assertEqual( + 'SELECT "sq0"."abc" "a",COUNT(\'*\') FROM (SELECT "abc" FROM "table1") "sq0" GROUP BY "sq0"."abc"', str(q) + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/dialects/test_mysql.py b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/dialects/test_mysql.py new file mode 100644 index 0000000000000000000000000000000000000000..619d064adcdf8b5ff9ecd054fa4ab00eff1d69b3 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/dialects/test_mysql.py @@ -0,0 +1,91 @@ +import unittest + +from pypika import MySQLQuery, QueryException, Table, Column + + +class SelectTests(unittest.TestCase): + table_abc = Table("abc") + + def test_normal_select(self): + q = MySQLQuery.from_("abc").select("def") + + self.assertEqual("SELECT `def` FROM `abc`", str(q)) + + def test_distinct_select(self): + q = MySQLQuery.from_("abc").select("def").distinct() + + self.assertEqual("SELECT DISTINCT `def` FROM `abc`", str(q)) + + def test_modifier_select(self): + q = MySQLQuery.from_("abc").select("def").select("ghi").modifier("SQL_CALC_FOUND_ROWS") + + self.assertEqual("SELECT SQL_CALC_FOUND_ROWS `def`,`ghi` FROM `abc`", str(q)) + + def test_multiple_modifier_select(self): + q = MySQLQuery.from_("abc").select("def").modifier("HIGH_PRIORITY").modifier("SQL_CALC_FOUND_ROWS") + + self.assertEqual("SELECT HIGH_PRIORITY SQL_CALC_FOUND_ROWS `def` FROM `abc`", str(q)) + + +class UpdateTests(unittest.TestCase): + table_abc = Table("abc") + + def test_update(self): + q = MySQLQuery.into("abc").insert(1, [1, "a", True]) + + self.assertEqual("INSERT INTO `abc` VALUES (1,[1,'a',true])", str(q)) + + def test_on_duplicate_key_ignore_update(self): + q = MySQLQuery.into("abc").insert(1, [1, "a", True]).on_duplicate_key_ignore() + + self.assertEqual("INSERT INTO `abc` VALUES (1,[1,'a',true]) ON DUPLICATE KEY IGNORE", str(q)) + + def test_on_duplicate_key_update_update(self): + q = MySQLQuery.into("abc").insert(1, [1, "a", True]).on_duplicate_key_update(self.table_abc.a, 'b') + + self.assertEqual("INSERT INTO `abc` VALUES (1,[1,'a',true]) ON DUPLICATE KEY UPDATE `a`='b'", str(q)) + + def test_conflict_handlers_update(self): + with self.assertRaises(QueryException): + ( + MySQLQuery.into("abc") + .insert(1, [1, "a", True]) + .on_duplicate_key_ignore() + .on_duplicate_key_update(self.table_abc.a, 'b') + ) + + +class LoadCSVTests(unittest.TestCase): + table_abc = Table("abc") + + def test_load_from_file(self): + q1 = MySQLQuery.load("/path/to/file").into("abc") + + q2 = MySQLQuery.load("/path/to/file").into(self.table_abc) + + self.assertEqual( + "LOAD DATA LOCAL INFILE '/path/to/file' INTO TABLE `abc` FIELDS TERMINATED BY ','", + str(q1), + ) + self.assertEqual( + "LOAD DATA LOCAL INFILE '/path/to/file' INTO TABLE `abc` FIELDS TERMINATED BY ','", + str(q2), + ) + + +class TableTests(unittest.TestCase): + table_abc = Table("abc") + + def test_create_table(self): + q = MySQLQuery.create_table(self.table_abc).columns(Column("id", "INT")) + self.assertEqual( + 'CREATE TABLE `abc` (`id` INT)', + str(q), + ) + + def test_drop_table(self): + q = MySQLQuery.drop_table(self.table_abc) + self.assertEqual( + 'DROP TABLE `abc`', + str(q), + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/dialects/test_oracle.py b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/dialects/test_oracle.py new file mode 100644 index 0000000000000000000000000000000000000000..21b54f16fd5d3518b5c767d3605068637898a73f --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/dialects/test_oracle.py @@ -0,0 +1,51 @@ +import unittest + +from pypika import OracleQuery, Table +from pypika.analytics import Count + + +class SelectTests(unittest.TestCase): + def test_groupby_alias_False_does_not_group_by_alias_with_standard_query(self): + t = Table('table1') + col = t.abc.as_('a') + q = OracleQuery.from_(t).select(col, Count('*')).groupby(col) + + self.assertEqual('SELECT abc a,COUNT(\'*\') FROM table1 GROUP BY abc', str(q)) + + def test_groupby_alias_False_does_not_group_by_alias_when_subqueries_are_present(self): + t = Table('table1') + subquery = OracleQuery.from_(t).select(t.abc) + col = subquery.abc.as_('a') + q = OracleQuery.from_(subquery).select(col, Count('*')).groupby(col) + + self.assertEqual('SELECT sq0.abc a,COUNT(\'*\') FROM (SELECT abc FROM table1) sq0 GROUP BY sq0.abc', str(q)) + + def test_limit_query(self): + t = Table('table1') + limit = 5 + q = OracleQuery.from_(t).select(t.test).limit(limit) + + self.assertEqual(f'SELECT test FROM table1 FETCH NEXT {limit} ROWS ONLY', str(q)) + + def test_offset_query(self): + t = Table('table1') + offset = 5 + q = OracleQuery.from_(t).select(t.test).offset(offset) + + self.assertEqual(f'SELECT test FROM table1 OFFSET {offset} ROWS', str(q)) + + def test_limit_offset_query(self): + t = Table('table1') + limit = 5 + offset = 5 + q = OracleQuery.from_(t).select(t.test).limit(limit).offset(offset) + + self.assertEqual(f'SELECT test FROM table1 OFFSET {offset} ROWS FETCH NEXT {limit} ROWS ONLY', str(q)) + + def test_fetch_next_method_deprecated(self): + with self.assertWarns(DeprecationWarning): + t = Table('table1') + limit = 5 + q = OracleQuery.from_(t).select(t.test).fetch_next(limit) + + self.assertEqual(f'SELECT test FROM table1 FETCH NEXT {limit} ROWS ONLY', str(q)) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/dialects/test_postgresql.py b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/dialects/test_postgresql.py new file mode 100644 index 0000000000000000000000000000000000000000..437eed03e120485ed2a357a4c2d92426f1466e14 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/dialects/test_postgresql.py @@ -0,0 +1,262 @@ +import unittest +from collections import OrderedDict + +from pypika import ( + Array, + Field, + JSON, + QueryException, + Table, +) +from pypika.dialects import PostgreSQLQuery + + +class InsertTests(unittest.TestCase): + table_abc = Table("abc") + + def test_array_keyword(self): + q = PostgreSQLQuery.into(self.table_abc).insert(1, [1, "a", True]) + + self.assertEqual("INSERT INTO \"abc\" VALUES (1,ARRAY[1,'a',true])", str(q)) + + +class JSONObjectTests(unittest.TestCase): + def test_alias_set_correctly(self): + table = Table('jsonb_table') + q = PostgreSQLQuery.from_('abc').select(table.value.get_text_value('a').as_('name')) + + self.assertEqual('''SELECT "value"->>'a' "name" FROM "abc"''', str(q)) + + def test_json_value_from_dict(self): + q = PostgreSQLQuery.select(JSON({"a": "foo"})) + + self.assertEqual('SELECT \'{"a":"foo"}\'', str(q)) + + def test_json_value_from_array_num(self): + q = PostgreSQLQuery.select(JSON([1, 2, 3])) + + self.assertEqual("SELECT '[1,2,3]'", str(q)) + + def test_json_value_from_array_str(self): + q = PostgreSQLQuery.select(JSON(["a", "b", "c"])) + + self.assertEqual('SELECT \'["a","b","c"]\'', str(q)) + + def test_json_value_from_dict_recursive(self): + q = PostgreSQLQuery.select(JSON({"a": "z", "b": {"c": "foo"}, "d": 1})) + + # gotta split this one up to avoid the indeterminate order + sql = str(q) + start, end = 9, -2 + self.assertEqual("SELECT '{}'", sql[:start] + sql[end:]) + + members_set = set(sql[start:end].split(",")) + self.assertSetEqual({'"a":"z"', '"b":{"c":"foo"}', '"d":1'}, members_set) + + +class JSONOperatorsTests(unittest.TestCase): + # reference https://www.postgresql.org/docs/9.5/functions-json.html + table_abc = Table("abc") + + def test_get_json_value_by_key(self): + q = PostgreSQLQuery.from_(self.table_abc).select("*").where(self.table_abc.json.get_json_value("dates")) + + self.assertEqual('SELECT * FROM "abc" WHERE "json"->\'dates\'', str(q)) + + def test_get_json_value_by_index(self): + q = PostgreSQLQuery.from_(self.table_abc).select("*").where(self.table_abc.json.get_json_value(1)) + + self.assertEqual('SELECT * FROM "abc" WHERE "json"->1', str(q)) + + def test_get_text_value_by_key(self): + q = PostgreSQLQuery.from_(self.table_abc).select("*").where(self.table_abc.json.get_text_value("dates")) + + self.assertEqual('SELECT * FROM "abc" WHERE "json"->>\'dates\'', str(q)) + + def test_get_text_value_by_index(self): + q = PostgreSQLQuery.from_(self.table_abc).select("*").where(self.table_abc.json.get_text_value(1)) + + self.assertEqual('SELECT * FROM "abc" WHERE "json"->>1', str(q)) + + def test_get_path_json_value(self): + q = PostgreSQLQuery.from_(self.table_abc).select("*").where(self.table_abc.json.get_path_json_value("{a,b}")) + + self.assertEqual('SELECT * FROM "abc" WHERE "json"#>\'{a,b}\'', str(q)) + + def test_get_path_text_value(self): + q = PostgreSQLQuery.from_(self.table_abc).select("*").where(self.table_abc.json.get_path_text_value("{a,b}")) + + self.assertEqual('SELECT * FROM "abc" WHERE "json"#>>\'{a,b}\'', str(q)) + + +class JSONBOperatorsTests(unittest.TestCase): + # reference https://www.postgresql.org/docs/9.5/functions-json.html + table_abc = Table("abc") + + def test_json_contains_for_json(self): + q = PostgreSQLQuery.select(JSON({"a": 1, "b": 2}).contains({"a": 1})) + + # gotta split this one up to avoid the indeterminate order + sql = str(q) + start, end = 9, -13 + self.assertEqual("SELECT '{}'@>'{\"a\":1}'", sql[:start] + sql[end:]) + + members_set = set(sql[start:end].split(",")) + self.assertSetEqual({'"a":1', '"b":2'}, members_set) + + def test_json_contains_for_field(self): + q = ( + PostgreSQLQuery.from_(self.table_abc) + .select("*") + .where(self.table_abc.json.contains({"dates": "2018-07-10 - 2018-07-17"})) + ) + + self.assertEqual( + "SELECT * " 'FROM "abc" ' 'WHERE "json"@>\'{"dates":"2018-07-10 - 2018-07-17"}\'', + str(q), + ) + + def test_json_contained_by_using_str_arg(self): + q = ( + PostgreSQLQuery.from_(self.table_abc) + .select("*") + .where( + self.table_abc.json.contained_by( + OrderedDict( + [ + ("dates", "2018-07-10 - 2018-07-17"), + ("imported", "8"), + ] + ) + ) + ) + ) + self.assertEqual( + 'SELECT * FROM "abc" ' 'WHERE "json"<@\'{"dates":"2018-07-10 - 2018-07-17","imported":"8"}\'', + str(q), + ) + + def test_json_contained_by_using_list_arg(self): + q = ( + PostgreSQLQuery.from_(self.table_abc) + .select("*") + .where(self.table_abc.json.contained_by(["One", "Two", "Three"])) + ) + + self.assertEqual('SELECT * FROM "abc" WHERE "json"<@\'["One","Two","Three"]\'', str(q)) + + def test_json_contained_by_with_complex_criterion(self): + q = ( + PostgreSQLQuery.from_(self.table_abc) + .select("*") + .where(self.table_abc.json.contained_by(["One", "Two", "Three"]) & (self.table_abc.id == 26)) + ) + + self.assertEqual( + 'SELECT * FROM "abc" WHERE "json"<@\'["One","Two","Three"]\' AND "id"=26', + str(q), + ) + + def test_json_has_key(self): + q = PostgreSQLQuery.from_(self.table_abc).select("*").where(self.table_abc.json.has_key("dates")) + + self.assertEqual('SELECT * FROM "abc" WHERE "json"?\'dates\'', str(q)) + + def test_json_has_keys(self): + q = PostgreSQLQuery.from_(self.table_abc).select("*").where(self.table_abc.json.has_keys(["dates", "imported"])) + + self.assertEqual("SELECT * FROM \"abc\" WHERE \"json\"?&ARRAY['dates','imported']", str(q)) + + def test_json_has_any_keys(self): + q = ( + PostgreSQLQuery.from_(self.table_abc) + .select("*") + .where(self.table_abc.json.has_any_keys(["dates", "imported"])) + ) + + self.assertEqual("SELECT * FROM \"abc\" WHERE \"json\"?|ARRAY['dates','imported']", str(q)) + + def test_subnet_contains_inet(self): + q = ( + PostgreSQLQuery.from_(self.table_abc) + .select(self.table_abc.a.lshift(2)) + .where(self.table_abc.cidr >> "1.1.1.1") + ) + + self.assertEqual("SELECT \"a\"<<2 FROM \"abc\" WHERE \"cidr\">>'1.1.1.1'", str(q)) + + +class DistinctOnTests(unittest.TestCase): + table_abc = Table("abc") + + def test_distinct_on(self): + q = PostgreSQLQuery.from_(self.table_abc).distinct_on("lname", self.table_abc.fname).select("lname", "id") + + self.assertEqual('''SELECT DISTINCT ON("lname","fname") "lname","id" FROM "abc"''', str(q)) + + +class ArrayTests(unittest.TestCase): + def test_array_syntax(self): + tb = Table("tb") + q = PostgreSQLQuery.from_(tb).select(Array(1, "a", ["b", 2, 3])) + + self.assertEqual(str(q), "SELECT ARRAY[1,'a',ARRAY['b',2,3]] FROM \"tb\"") + + def test_render_alias_in_array_sql(self): + tb = Table("tb") + + q = PostgreSQLQuery.from_(tb).select(Array(tb.col).as_("different_name")) + self.assertEqual(str(q), 'SELECT ARRAY["col"] "different_name" FROM "tb"') + + +class ReturningClauseTests(unittest.TestCase): + @classmethod + def setUpClass(cls) -> None: + super().setUpClass() + cls.table_abc = Table('abc') + + def test_returning_from_missing_table_raises_queryexception(self): + field_from_diff_table = Field('xyz', table=Table('other')) + + with self.assertRaisesRegex(QueryException, "You can't return from other tables"): + ( + PostgreSQLQuery.from_(self.table_abc) + .where(self.table_abc.foo == self.table_abc.bar) + .delete() + .returning(field_from_diff_table) + ) + + def test_queryexception_if_returning_used_on_invalid_query(self): + with self.assertRaisesRegex(QueryException, "Returning can't be used in this query"): + PostgreSQLQuery.from_(self.table_abc).select('abc').returning('abc') + + def test_no_queryexception_if_returning_used_on_valid_query_type(self): + # No exceptions for insert, update and delete queries + with self.subTest('DELETE'): + PostgreSQLQuery.from_(self.table_abc).where(self.table_abc.foo == self.table_abc.bar).delete().returning( + "id" + ) + with self.subTest('UPDATE'): + PostgreSQLQuery.update(self.table_abc).where(self.table_abc.foo == 0).set("foo", "bar").returning("id") + with self.subTest('INSERT'): + PostgreSQLQuery.into(self.table_abc).insert('abc').returning('abc') + + def test_return_field_from_join_table(self): + new_table = Table('xyz') + q = ( + PostgreSQLQuery.update(self.table_abc) + .join(new_table) + .on(new_table.id == self.table_abc.xyz) + .where(self.table_abc.foo == 0) + .set("foo", "bar") + .returning(new_table.a) + ) + + self.assertEqual( + 'UPDATE "abc" ' + 'JOIN "xyz" ON "xyz"."id"="abc"."xyz" ' + 'SET "foo"=\'bar\' ' + 'WHERE "abc"."foo"=0 ' + 'RETURNING "xyz"."a"', + str(q), + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/dialects/test_snowflake.py b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/dialects/test_snowflake.py new file mode 100644 index 0000000000000000000000000000000000000000..5ac08b2d8b8b5496ed6f3510acf4be1ec7893405 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/dialects/test_snowflake.py @@ -0,0 +1,58 @@ +import unittest + +from pypika import ( + Tables, + functions as fn, + Column, +) +from pypika.dialects import SnowflakeQuery + + +class QuoteTests(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_use_double_quotes_on_alias_but_not_on_terms(self): + q = SnowflakeQuery.from_(self.table_abc).select(self.table_abc.a.as_("bar")) + + self.assertEqual('SELECT a "bar" FROM abc', q.get_sql(with_namespace=True)) + + def test_use_double_quotes_on_alias_but_not_on_terms_with_joins(self): + foo = self.table_abc.as_("foo") + bar = self.table_efg.as_("bar") + + q = SnowflakeQuery.from_(foo).join(bar).on(foo.fk == bar.id).select(foo.a, bar.b) + + self.assertEqual( + "SELECT foo.a,bar.b " 'FROM abc "foo" ' 'JOIN efg "bar" ' "ON foo.fk=bar.id", + q.get_sql(with_namespace=True), + ) + + def test_use_double_quotes_on_alias_but_not_on_terms(self): + idx = self.table_abc.index.as_("idx") + val = fn.Sum(self.table_abc.value).as_("val") + q = SnowflakeQuery.from_(self.table_abc).select(idx, val).groupby(idx).orderby(idx) + + self.assertEqual( + 'SELECT index "idx",SUM(value) "val" ' "FROM abc " 'GROUP BY "idx" ' 'ORDER BY "idx"', + q.get_sql(with_namespace=True), + ) + + def test_dont_use_double_quotes_on_joining_queries(self): + foo = self.table_abc + bar = self.table_efg + q1 = SnowflakeQuery.from_(foo).select(foo.b) + q2 = SnowflakeQuery.from_(bar).select(bar.b) + q = SnowflakeQuery.from_(q1).join(q2).on(q1.b == q2.b).select("*") + + self.assertEqual( + "SELECT * " 'FROM (SELECT b FROM abc) sq0 ' 'JOIN (SELECT b FROM efg) sq1 ' "ON sq0.b=sq1.b", + q.get_sql(), + ) + + def test_dont_use_double_quotes_on_create_queries(self): + q = SnowflakeQuery.create_table(self.table_abc).columns(Column("id", "INT")) + self.assertEqual("CREATE TABLE abc (id INT)", q.get_sql()) + + def test_dont_use_double_quotes_on_drop_queries(self): + q = SnowflakeQuery.drop_table(self.table_abc) + self.assertEqual("DROP TABLE abc", q.get_sql()) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/dialects/test_sqllite.py b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/dialects/test_sqllite.py new file mode 100644 index 0000000000000000000000000000000000000000..104a7235b6ea2d46fd365989f68c5d081eb20076 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/dialects/test_sqllite.py @@ -0,0 +1,35 @@ +import unittest + +from pypika import Table +from pypika.dialects import SQLLiteQuery + + +class SelectTests(unittest.TestCase): + table_abc = Table("abc") + + def test_bool_true_as_one(self): + q = SQLLiteQuery.from_("abc").select(True) + + self.assertEqual('SELECT 1 FROM "abc"', str(q)) + + def test_bool_false_as_zero(self): + q = SQLLiteQuery.from_("abc").select(False) + + self.assertEqual('SELECT 0 FROM "abc"', str(q)) + + +class ReplaceTests(unittest.TestCase): + def test_normal_replace(self): + query = SQLLiteQuery.into("abc").replace("v1", "v2", "v3") + expected_output = "REPLACE INTO \"abc\" VALUES ('v1','v2','v3')" + self.assertEqual(expected_output, str(query)) + + def test_replace_subquery(self): + query = SQLLiteQuery.into("abc").replace(SQLLiteQuery.from_("def").select("f1", "f2")) + expected_output = 'REPLACE INTO "abc" VALUES ((SELECT "f1","f2" FROM "def"))' + self.assertEqual(expected_output, str(query)) + + def test_insert_or_replace(self): + query = SQLLiteQuery.into("abc").insert_or_replace("v1", "v2", "v3") + expected_output = "INSERT OR REPLACE INTO \"abc\" VALUES ('v1','v2','v3')" + self.assertEqual(expected_output, str(query)) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/dialects/test_vertica.py b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/dialects/test_vertica.py new file mode 100644 index 0000000000000000000000000000000000000000..61985bfc244fcd663e7d8a904b4645901f3abdfc --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/dialects/test_vertica.py @@ -0,0 +1,93 @@ +import unittest + +from pypika import Columns, Table, Tables, VerticaQuery + + +class VerticaQueryTests(unittest.TestCase): + table_abc = Table("abc") + + def test_select_query_with_hint(self): + q = VerticaQuery.from_("abc").select("*").hint("test_hint") + + self.assertEqual('SELECT /*+label(test_hint)*/ * FROM "abc"', str(q)) + + def test_insert_query_with_hint(self): + query = VerticaQuery.into(self.table_abc).insert(1).hint("test_hint") + + self.assertEqual('INSERT /*+label(test_hint)*/ INTO "abc" VALUES (1)', str(query)) + + def test_update_query_with_hint(self): + q = VerticaQuery.update(self.table_abc).set("foo", "bar").hint("test_hint") + + self.assertEqual('UPDATE /*+label(test_hint)*/ "abc" SET "foo"=\'bar\'', str(q)) + + def test_delete_query_with_hint(self): + q = VerticaQuery.from_("abc").delete().hint("test_hint") + + self.assertEqual('DELETE /*+label(test_hint)*/ FROM "abc"', str(q)) + + +class CopyCSVTests(unittest.TestCase): + table_abc = Table("abc") + + def test_copy_from_file(self): + with self.subTest("with table as string"): + q = VerticaQuery.from_file("/path/to/file").copy_("abc") + + self.assertEqual( + "COPY \"abc\" FROM LOCAL '/path/to/file' PARSER fcsvparser(header=false)", + str(q), + ) + + with self.subTest("with table"): + q = VerticaQuery.from_file("/path/to/file").copy_(self.table_abc) + + self.assertEqual( + "COPY \"abc\" FROM LOCAL '/path/to/file' PARSER fcsvparser(header=false)", + str(q), + ) + + +class CreateTemporaryTableTests(unittest.TestCase): + new_table, existing_table = Tables("abc", "efg") + foo, bar = Columns(("a", "INT"), ("b", "VARCHAR(100)")) + select = VerticaQuery.from_(existing_table).select(existing_table.foo, existing_table.bar) + + def test_create_local_temporary_table(self): + with self.subTest("with columns"): + q = VerticaQuery.create_table(self.new_table).temporary().local().columns(self.foo, self.bar) + + self.assertEqual('CREATE LOCAL TEMPORARY TABLE "abc" ("a" INT,"b" VARCHAR(100))', str(q)) + + with self.subTest("with select"): + q = VerticaQuery.create_table(self.new_table).temporary().local().as_select(self.select) + + self.assertEqual( + 'CREATE LOCAL TEMPORARY TABLE "abc" AS (SELECT "foo","bar" FROM "efg")', + str(q), + ) + + def test_create_local_table_without_temporary_raises_error(self): + with self.assertRaises(AttributeError): + VerticaQuery.create_table(self.new_table).local() + + def test_create_temporary_table_preserve_rows(self): + with self.subTest("with columns"): + q = VerticaQuery.create_table(self.new_table).temporary().preserve_rows().columns(self.foo, self.bar) + + self.assertEqual( + 'CREATE TEMPORARY TABLE "abc" ("a" INT,"b" VARCHAR(100)) ON COMMIT PRESERVE ROWS', + str(q), + ) + + with self.subTest("with select"): + q = VerticaQuery.create_table(self.new_table).temporary().preserve_rows().as_select(self.select) + + self.assertEqual( + 'CREATE TEMPORARY TABLE "abc" ON COMMIT PRESERVE ROWS AS (SELECT "foo","bar" FROM "efg")', + str(q), + ) + + def test_create_table_preserve_rows_without_temporary_raises_error(self): + with self.assertRaises(AttributeError): + VerticaQuery.create_table(self.new_table).preserve_rows() diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/test_aggregate.py b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/test_aggregate.py new file mode 100644 index 0000000000000000000000000000000000000000..1c627d8e9c2d65410c67cf2c39974949b0720a0e --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/test_aggregate.py @@ -0,0 +1,122 @@ +import unittest + +from pypika import ( + Case, + Field, + Table, + functions as fn, +) +from pypika.terms import ( + Negative, + ValueWrapper, +) + + +class IsAggregateTests(unittest.TestCase): + def test__field_is_not_aggregate(self): + v = Field("foo") + self.assertFalse(v.is_aggregate) + + def test__constant_is_aggregate_none(self): + v = ValueWrapper(100) + self.assertIsNone(v.is_aggregate) + + def test__constant_arithmetic_is_aggregate_none(self): + v = ValueWrapper(100) + ValueWrapper(100) + self.assertIsNone(v.is_aggregate) + + def test__field_arithmetic_is_not_aggregate(self): + v = Field("foo") + Field("bar") + self.assertFalse(v.is_aggregate) + + def test__field_arithmetic_constant_is_not_aggregate(self): + v = Field("foo") + 1 + self.assertFalse(v.is_aggregate) + + def test__agg_func_is_aggregate(self): + v = fn.Sum(Field("foo")) + self.assertTrue(v.is_aggregate) + + def test__negative_agg_func_is_aggregate(self): + v = Negative(fn.Sum(Field("foo"))) + self.assertTrue(v.is_aggregate) + + def test__agg_func_arithmetic_is_aggregate(self): + v = fn.Sum(Field("foo")) / fn.Sum(Field("foo")) + self.assertTrue(v.is_aggregate) + + def test__mixed_func_arithmetic_is_not_aggregate(self): + v = Field("foo") / fn.Sum(Field("foo")) + self.assertFalse(v.is_aggregate) + + def test__func_arithmetic_constant_is_not_aggregate(self): + v = 1 / fn.Sum(Field("foo")) + self.assertTrue(v.is_aggregate) + + def test__agg_case_criterion_is_aggregate(self): + v = Case().when(fn.Sum(Field("foo")) > 666, 'More than 666').else_('Less than 666') + + self.assertTrue(v.is_aggregate) + + def test__agg_case_is_aggregate(self): + v = ( + Case() + .when(Field("foo") == 1, fn.Sum(Field("bar"))) + .when(Field("foo") == 2, fn.Sum(Field("fiz"))) + .else_(fn.Sum(Field("fiz"))) + ) + + self.assertTrue(v.is_aggregate) + + def test__mixed_case_is_not_aggregate(self): + v = Case().when(Field("foo") == 1, fn.Sum(Field("bar"))).when(Field("foo") == 2, Field("fiz")) + + self.assertFalse(v.is_aggregate) + + def test__case_mixed_else_is_not_aggregate(self): + v = ( + Case() + .when(Field("foo") == 1, fn.Sum(Field("bar"))) + .when(Field("foo") == 2, fn.Sum(Field("fiz"))) + .else_(Field("fiz")) + ) + + self.assertFalse(v.is_aggregate) + + def test__case_mixed_constant_is_not_aggregate(self): + v = Case().when(Field("foo") == 1, fn.Sum(Field("bar"))).when(Field("foo") == 2, fn.Sum(Field("fiz"))).else_(1) + + self.assertTrue(v.is_aggregate) + + def test__case_with_field_is_not_aggregate(self): + v = Case().when(Field("foo") == 1, 1).when(Field("foo") == 2, 2).else_(3) + + self.assertFalse(v.is_aggregate) + + def test__case_with_single_aggregate_field_in_one_criterion_is_aggregate(self): + v = Case().when(Field("foo") == 1, 1).when(fn.Sum(Field("foo")) == 2, 2).else_(3) + + self.assertTrue(v.is_aggregate) + + def test__non_aggregate_function_with_aggregated_arg(self): + t = Table("abc") + expr = fn.Sqrt(fn.Sum(t.a)) + + self.assertTrue(expr.is_aggregate) + + def test_complicated(self): + t = Table("abc") + is_placebo = t.campaign_extra_info == "placebo" + + pixel_mobile_search = Case().when(is_placebo, t.action_fb_pixel_search + t.action_fb_mobile_search) + unique_impressions = Case().when(is_placebo, t.unique_impressions) + + v = fn.Sum(pixel_mobile_search) / fn.Sum(unique_impressions) - 1.96 * fn.Sqrt( + 1 + / fn.Sum(unique_impressions) + * fn.Sum(pixel_mobile_search) + / fn.Sum(unique_impressions) + * (1 - fn.Sum(pixel_mobile_search) / fn.Sum(unique_impressions)) + ) + + self.assertTrue(v.is_aggregate) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/test_analytic_queries.py b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/test_analytic_queries.py new file mode 100644 index 0000000000000000000000000000000000000000..6a35ab854b30e3b0f91e633b3349706a22e0a2fd --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/test_analytic_queries.py @@ -0,0 +1,610 @@ +import unittest + +from pypika import Criterion, JoinType, Order, Query, Tables, analytics as an +from pypika.analytics import Lag, Lead + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + + +class RankTests(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_rank(self): + expr = an.Rank().over(self.table_abc.foo).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " "RANK() " 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_dense_rank(self): + expr = an.DenseRank().over(self.table_abc.foo).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " "DENSE_RANK() " 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_row_number(self): + expr = an.RowNumber().over(self.table_abc.foo).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " "ROW_NUMBER() " 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_rank_with_alias(self): + expr = an.Rank().over(self.table_abc.foo).orderby(self.table_abc.date).as_("rank") + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " "RANK() " 'OVER(PARTITION BY "foo" ORDER BY "date") "rank" ' 'FROM "abc"', + str(q), + ) + + def test_multiple_partitions(self): + expr = an.Rank().orderby(self.table_abc.date).over(self.table_abc.foo, self.table_abc.bar) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " "RANK() " 'OVER(PARTITION BY "foo","bar" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_ntile_no_partition_or_order_invalid_sql(self): + expr = an.NTile(5) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual("SELECT " "NTILE(5) " 'FROM "abc"', str(q)) + + def test_ntile_with_partition(self): + expr = an.NTile(5).over(self.table_abc.foo) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual("SELECT " "NTILE(5) " 'OVER(PARTITION BY "foo") ' 'FROM "abc"', str(q)) + + def test_ntile_with_order(self): + expr = an.NTile(5).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual("SELECT " "NTILE(5) " 'OVER(ORDER BY "date") ' 'FROM "abc"', str(q)) + + def test_ntile_with_partition_and_order(self): + expr = an.NTile(5).over(self.table_abc.foo).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " "NTILE(5) " 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_first_value(self): + expr = an.FirstValue(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'FIRST_VALUE("fizz") ' 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_first_value_ignore_nulls(self): + expr = an.FirstValue(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).ignore_nulls() + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'FIRST_VALUE("fizz" IGNORE NULLS) ' 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_first_value_ignore_nulls_first(self): + expr = an.FirstValue(self.table_abc.fizz).ignore_nulls().over(self.table_abc.foo).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'FIRST_VALUE("fizz" IGNORE NULLS) ' 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_first_value_multi_argument(self): + expr = ( + an.FirstValue(self.table_abc.fizz, self.table_abc.buzz) + .over(self.table_abc.foo) + .orderby(self.table_abc.date) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'FIRST_VALUE("fizz","buzz") ' 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_last_value(self): + expr = an.LastValue(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'LAST_VALUE("fizz") ' 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_filter(self): + expr = ( + an.LastValue(self.table_abc.fizz) + .filter(Criterion.all([self.table_abc.bar == True])) + .over(self.table_abc.foo) + .orderby(self.table_abc.date) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'LAST_VALUE("fizz") ' + 'FILTER(WHERE "bar"=true) ' + 'OVER(PARTITION BY "foo" ORDER BY "date") ' + 'FROM "abc"', + str(q), + ) + + def test_filter_quote_table_in_filter(self): + expr = ( + an.LastValue(self.table_efg.fizz) + .filter(self.table_efg.filed.eq('yes')) + .over(self.table_efg.foo) + .orderby(self.table_efg.date) + ) + + q = ( + Query.from_(self.table_abc) + .inner_join(self.table_efg) + .on(self.table_abc.id.eq(self.table_efg.id)) + .select(expr) + ) + + self.assertEqual( + 'SELECT ' + 'LAST_VALUE("efg"."fizz") ' + 'FILTER(WHERE "efg"."filed"=\'yes\') ' + 'OVER(PARTITION BY "efg"."foo" ORDER BY "efg"."date") ' + 'FROM "abc" ' + 'JOIN "efg" ON "abc"."id"="efg"."id"', + str(q), + ) + + def test_orderby_asc(self): + expr = an.LastValue(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date, order=Order.asc) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'LAST_VALUE("fizz") ' 'OVER(PARTITION BY "foo" ORDER BY "date" ASC) ' 'FROM "abc"', + str(q), + ) + + def test_orderby_desc(self): + expr = an.LastValue(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date, order=Order.desc) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'LAST_VALUE("fizz") ' 'OVER(PARTITION BY "foo" ORDER BY "date" DESC) ' 'FROM "abc"', + str(q), + ) + + def test_last_value_multi_argument(self): + expr = ( + an.LastValue(self.table_abc.fizz, self.table_abc.buzz).over(self.table_abc.foo).orderby(self.table_abc.date) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'LAST_VALUE("fizz","buzz") ' 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_last_value_ignore_nulls(self): + expr = an.LastValue(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).ignore_nulls() + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'LAST_VALUE("fizz" IGNORE NULLS) ' 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_median(self): + expr = an.Median(self.table_abc.fizz).over(self.table_abc.foo, self.table_abc.bar).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'MEDIAN("fizz") ' 'OVER(PARTITION BY "foo","bar" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_avg(self): + expr = an.Avg(self.table_abc.fizz).over(self.table_abc.foo, self.table_abc.bar).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'AVG("fizz") ' 'OVER(PARTITION BY "foo","bar" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_stddev(self): + expr = an.StdDev(self.table_abc.fizz).over(self.table_abc.foo, self.table_abc.bar).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'STDDEV("fizz") ' 'OVER(PARTITION BY "foo","bar" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_stddev_pop(self): + expr = ( + an.StdDevPop(self.table_abc.fizz).over(self.table_abc.foo, self.table_abc.bar).orderby(self.table_abc.date) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'STDDEV_POP("fizz") ' 'OVER(PARTITION BY "foo","bar" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_stddev_samp(self): + expr = ( + an.StdDevSamp(self.table_abc.fizz).over(self.table_abc.foo, self.table_abc.bar).orderby(self.table_abc.date) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'STDDEV_SAMP("fizz") ' 'OVER(PARTITION BY "foo","bar" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_variance(self): + expr = ( + an.Variance(self.table_abc.fizz).over(self.table_abc.foo, self.table_abc.bar).orderby(self.table_abc.date) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'VARIANCE("fizz") ' 'OVER(PARTITION BY "foo","bar" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_var_pop(self): + expr = an.VarPop(self.table_abc.fizz).over(self.table_abc.foo, self.table_abc.bar).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'VAR_POP("fizz") ' 'OVER(PARTITION BY "foo","bar" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_var_samp(self): + expr = an.VarSamp(self.table_abc.fizz).over(self.table_abc.foo, self.table_abc.bar).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'VAR_SAMP("fizz") ' 'OVER(PARTITION BY "foo","bar" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_table_prefixes_used_in_analytic_functions(self): + expr = an.Rank().over(self.table_abc.foo).orderby(self.table_efg.date) + + query = ( + Query.from_(self.table_abc) + .join(self.table_efg, how=JoinType.left) + .on(self.table_abc.foo == self.table_efg.bar) + .select("*", expr) + ) + + self.assertEqual( + 'SELECT *,RANK() OVER(PARTITION BY "abc"."foo" ORDER BY "efg"."date") ' + 'FROM "abc" LEFT JOIN "efg" ON "abc"."foo"="efg"."bar"', + str(query), + ) + + def test_sum_rows_unbounded_preceeding(self): + expr = an.Sum(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).rows(an.Preceding()) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'SUM("fizz") ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "ROWS UNBOUNDED PRECEDING" + ") " + 'FROM "abc"', + str(q), + ) + + def test_max_rows_x_preceeding(self): + expr = an.Max(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).rows(an.Preceding(5)) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'MAX("fizz") ' "OVER(" 'PARTITION BY "foo" ORDER BY "date" ' "ROWS 5 PRECEDING" ") " 'FROM "abc"', + str(q), + ) + + def test_min_rows_current_row(self): + expr = an.Min(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).rows(an.CURRENT_ROW) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'MIN("fizz") ' "OVER(" 'PARTITION BY "foo" ORDER BY "date" ' "ROWS CURRENT ROW" ") " 'FROM "abc"', + str(q), + ) + + def test_varpop_range_unbounded_preceeding(self): + expr = ( + an.VarPop(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).range(an.Preceding()) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'VAR_POP("fizz") ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "RANGE UNBOUNDED PRECEDING" + ") " + 'FROM "abc"', + str(q), + ) + + def test_max_range_x_preceeding(self): + expr = an.Max(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).range(an.Preceding(5)) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'MAX("fizz") ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "RANGE 5 PRECEDING" + ") " + 'FROM "abc"', + str(q), + ) + + def test_min_range_current_row(self): + expr = an.Min(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).range(an.CURRENT_ROW) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'MIN("fizz") ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "RANGE CURRENT ROW" + ") " + 'FROM "abc"', + str(q), + ) + + def test_variance_rows_between_unbounded_preceeding_unbounded_following(self): + expr = ( + an.Variance(self.table_abc.fizz) + .over(self.table_abc.foo) + .orderby(self.table_abc.date) + .rows(an.Preceding(), an.Following()) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'VARIANCE("fizz") ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING" + ") " + 'FROM "abc"', + str(q), + ) + + def test_first_value_range_between_x_preceeding_unbounded_following(self): + expr = ( + an.FirstValue(self.table_abc.fizz) + .over(self.table_abc.foo) + .orderby(self.table_abc.date) + .range(an.Preceding(3), an.Following()) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'FIRST_VALUE("fizz") ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "RANGE BETWEEN 3 PRECEDING AND UNBOUNDED FOLLOWING" + ") " + 'FROM "abc"', + str(q), + ) + + def test_varpop_rows_between_unbounded_preceeding_x_following(self): + expr = ( + an.VarPop(self.table_abc.fizz) + .over(self.table_abc.foo) + .orderby(self.table_abc.date) + .rows(an.Preceding(), an.Following(6)) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'VAR_POP("fizz") ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "ROWS BETWEEN UNBOUNDED PRECEDING AND 6 FOLLOWING" + ") " + 'FROM "abc"', + str(q), + ) + + def test_count_range_between_unbounded_preceeding_current_row(self): + expr = ( + an.Count(self.table_abc.fizz) + .over(self.table_abc.foo) + .orderby(self.table_abc.date) + .range(an.Preceding(), an.CURRENT_ROW) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'COUNT("fizz") ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW" + ") " + 'FROM "abc"', + str(q), + ) + + def test_last_value_rows_between_current_row_unbounded_following(self): + expr = ( + an.LastValue(self.table_abc.fizz) + .over(self.table_abc.foo) + .orderby(self.table_abc.date) + .rows(an.CURRENT_ROW, an.Following()) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'LAST_VALUE("fizz") ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING" + ") " + 'FROM "abc"', + str(q), + ) + + def test_last_value_rows_between_current_row_unbounded_following_ignore_nulls(self): + expr = ( + an.LastValue(self.table_abc.fizz) + .over(self.table_abc.foo) + .orderby(self.table_abc.date) + .ignore_nulls() + .rows(an.CURRENT_ROW, an.Following(8)) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'LAST_VALUE("fizz" IGNORE NULLS) ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "ROWS BETWEEN CURRENT ROW AND 8 FOLLOWING" + ") " + 'FROM "abc"', + str(q), + ) + + def test_empty_over(self): + query = Query.from_(self.table_abc).select(an.Sum(self.table_abc.fizz).over()) + + self.assertEqual("SELECT " 'SUM("fizz") OVER() ' 'FROM "abc"', str(query)) + + def test_rows_called_twice_raises_attribute_error(self): + with self.assertRaises(AttributeError): + an.Sum(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).rows(an.Preceding()).rows( + an.Preceding() + ) + + def test_range_called_twice_raises_attribute_error(self): + with self.assertRaises(AttributeError): + an.Sum(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).range( + an.Preceding() + ).range(an.Preceding()) + + def test_rows_then_range_raises_attribute_error(self): + with self.assertRaises(AttributeError): + an.Sum(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).rows( + an.Preceding() + ).range(an.Preceding()) + + def test_range_then_rows_raises_attribute_error(self): + with self.assertRaises(AttributeError): + an.Sum(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).range( + an.Preceding() + ).rows(an.Preceding()) + + def test_lag_generates_correct_sql(self): + with self.subTest('without partition by'): + q = Query.from_(self.table_abc).select( + Lag(self.table_abc.date, 1, '2000-01-01').orderby(self.table_abc.date) + ) + + self.assertEqual('SELECT LAG("date",1,\'2000-01-01\') OVER(ORDER BY "date") FROM "abc"', str(q)) + + with self.subTest('with partition by'): + q = Query.from_(self.table_abc).select( + Lag(self.table_abc.date, 1, '2000-01-01').over(self.table_abc.foo).orderby(self.table_abc.date) + ) + + self.assertEqual( + 'SELECT LAG("date",1,\'2000-01-01\') OVER(PARTITION BY "foo" ORDER BY "date") FROM "abc"', str(q) + ) + + def test_lead_generates_correct_sql(self): + with self.subTest('without partition by'): + q = Query.from_(self.table_abc).select( + Lead(self.table_abc.date, 1, '2000-01-01').orderby(self.table_abc.date) + ) + + self.assertEqual('SELECT LEAD("date",1,\'2000-01-01\') OVER(ORDER BY "date") FROM "abc"', str(q)) + + with self.subTest('with partition by'): + q = Query.from_(self.table_abc).select( + Lead(self.table_abc.date, 1, '2000-01-01').over(self.table_abc.foo).orderby(self.table_abc.date) + ) + + self.assertEqual( + 'SELECT LEAD("date",1,\'2000-01-01\') OVER(PARTITION BY "foo" ORDER BY "date") FROM "abc"', str(q) + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/test_create.py b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/test_create.py new file mode 100644 index 0000000000000000000000000000000000000000..325076544e3824b0d07f82f2378b88218b910dde --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/test_create.py @@ -0,0 +1,210 @@ +import unittest + +from pypika import Column, Columns, Query, Tables, Table +from pypika.terms import ValueWrapper, Index +from pypika.enums import ReferenceOption + + +class CreateTableTests(unittest.TestCase): + new_table, existing_table = Tables("abc", "efg") + foo, bar = Columns(("a", "INT"), ("b", "VARCHAR(100)")) + + def test_create_table_with_columns(self): + with self.subTest("with nullable"): + a = Column("a", "INT", True) + b = Column("b", "VARCHAR(100)", False) + q = Query.create_table(self.new_table).columns(a, b) + + self.assertEqual('CREATE TABLE "abc" ("a" INT NULL,"b" VARCHAR(100) NOT NULL)', str(q)) + + with self.subTest("with defaults"): + a = Column("a", "INT", default=ValueWrapper(42)) + b = Column("b", "VARCHAR(100)", default=ValueWrapper("foo")) + q = Query.create_table(self.new_table).columns(a, b) + + self.assertEqual('CREATE TABLE "abc" ("a" INT DEFAULT 42,"b" VARCHAR(100) DEFAULT \'foo\')', str(q)) + + with self.subTest("with unwrapped defaults"): + a = Column("a", "INT", default=42) + b = Column("b", "VARCHAR(100)", default="foo") + q = Query.create_table(self.new_table).columns(a, b) + + self.assertEqual('CREATE TABLE "abc" ("a" INT DEFAULT 42,"b" VARCHAR(100) DEFAULT \'foo\')', str(q)) + + with self.subTest("with period for"): + a = Column("id", "INT") + b = Column("valid_from", "DATETIME") + c = Column("valid_to", "DATETIME") + q = Query.create_table(self.new_table).columns(a, b, c).period_for('valid_period', b, c) + + self.assertEqual( + 'CREATE TABLE "abc" (' + '"id" INT,' + '"valid_from" DATETIME,' + '"valid_to" DATETIME,' + 'PERIOD FOR "valid_period" ("valid_from","valid_to"))', + str(q), + ) + + with self.subTest("without temporary keyword"): + q = Query.create_table(self.new_table).columns(self.foo, self.bar) + + self.assertEqual('CREATE TABLE "abc" ("a" INT,"b" VARCHAR(100))', str(q)) + + with self.subTest("with temporary keyword"): + q = Query.create_table(self.new_table).temporary().columns(self.foo, self.bar) + + self.assertEqual('CREATE TEMPORARY TABLE "abc" ("a" INT,"b" VARCHAR(100))', str(q)) + + with self.subTest("with primary key"): + q = Query.create_table(self.new_table).columns(self.foo, self.bar).primary_key(self.foo, self.bar) + + self.assertEqual('CREATE TABLE "abc" ("a" INT,"b" VARCHAR(100),PRIMARY KEY ("a","b"))', str(q)) + + with self.subTest("with simple foreign key"): + cref, dref = Columns(("c", "INT"), ("d", "VARCHAR(100)")) + q = ( + Query.create_table(self.new_table) + .columns(self.foo, self.bar) + .foreign_key([self.foo, self.bar], self.existing_table, [cref, dref]) + ) + + self.assertEqual( + 'CREATE TABLE "abc" (' + '"a" INT,' + '"b" VARCHAR(100),' + 'FOREIGN KEY ("a","b") REFERENCES "efg" ("c","d"))', + str(q), + ) + + with self.subTest("with foreign key reference options"): + cref, dref = Columns(("c", "INT"), ("d", "VARCHAR(100)")) + q = ( + Query.create_table(self.new_table) + .columns(self.foo, self.bar) + .foreign_key( + [self.foo, self.bar], + self.existing_table, + [cref, dref], + on_delete=ReferenceOption.cascade, + on_update=ReferenceOption.restrict, + ) + ) + + self.assertEqual( + 'CREATE TABLE "abc" (' + '"a" INT,' + '"b" VARCHAR(100),' + 'FOREIGN KEY ("a","b") REFERENCES "efg" ("c","d") ON DELETE CASCADE ON UPDATE RESTRICT)', + str(q), + ) + + with self.subTest("with unique keys"): + q = ( + Query.create_table(self.new_table) + .columns(self.foo, self.bar) + .unique(self.foo, self.bar) + .unique(self.foo) + ) + + self.assertEqual('CREATE TABLE "abc" ("a" INT,"b" VARCHAR(100),UNIQUE ("a","b"),UNIQUE ("a"))', str(q)) + + with self.subTest("with system versioning"): + q = Query.create_table(self.new_table).columns(self.foo, self.bar).with_system_versioning() + + self.assertEqual('CREATE TABLE "abc" ("a" INT,"b" VARCHAR(100)) WITH SYSTEM VERSIONING', str(q)) + + with self.subTest("with unlogged keyword"): + q = Query.create_table(self.new_table).unlogged().columns(self.foo, self.bar) + + self.assertEqual('CREATE UNLOGGED TABLE "abc" ("a" INT,"b" VARCHAR(100))', str(q)) + + with self.subTest("with if not exists keyword"): + q = Query.create_table(self.new_table).if_not_exists().columns(self.foo, self.bar) + + self.assertEqual('CREATE TABLE IF NOT EXISTS "abc" ("a" INT,"b" VARCHAR(100))', str(q)) + + def test_create_table_with_select(self): + select = Query.from_(self.existing_table).select(self.existing_table.foo, self.existing_table.bar) + + with self.subTest("without temporary keyword"): + q = Query.create_table(self.new_table).as_select(select) + + self.assertEqual('CREATE TABLE "abc" AS (SELECT "foo","bar" FROM "efg")', str(q)) + + with self.subTest("with temporary keyword"): + q = Query.create_table(self.new_table).temporary().as_select(select) + + self.assertEqual( + 'CREATE TEMPORARY TABLE "abc" AS (SELECT "foo","bar" FROM "efg")', + str(q), + ) + + def test_create_table_without_columns_or_select_empty(self): + q = Query.create_table(self.new_table) + + self.assertEqual("", str(q)) + + def test_create_table_with_select_and_columns_fails(self): + select = Query.from_(self.existing_table).select(self.existing_table.foo, self.existing_table.bar) + + with self.subTest("for columns before as_select"): + with self.assertRaises(AttributeError): + Query.create_table(self.new_table).columns(self.foo, self.bar).as_select(select) + + with self.subTest("for as_select before columns"): + with self.assertRaises(AttributeError): + Query.create_table(self.new_table).as_select(select).columns(self.foo, self.bar) + + with self.subTest("repeated foreign key"): + with self.assertRaises(AttributeError): + Query.create_table(self.new_table).foreign_key([self.foo], self.existing_table, [self.bar]).foreign_key( + [self.foo], self.existing_table, [self.bar] + ) + + def test_create_table_as_select_not_query_raises_error(self): + with self.assertRaises(TypeError): + Query.create_table(self.new_table).as_select("abc") + + +class CreateIndexTests(unittest.TestCase): + new_index = Index("abc") + new_table = Table("my_table") + columns = (new_table.a, new_table.b) + where = new_table.a > 1 + + def test_create_index_simple(self) -> None: + q = Query.create_index(self.new_index).on(self.new_table).columns(*self.columns) + self.assertEqual( + f'CREATE INDEX "{self.new_index.name}" ON "{self.new_table.get_table_name()}"({", ".join([c.name for c in self.columns])})', + q.get_sql(), + ) + + def test_create_index_where(self) -> None: + q = Query.create_index(self.new_index).on(self.new_table).columns(*self.columns).where(self.where) + self.assertEqual( + f'CREATE INDEX "{self.new_index.name}" ON "{self.new_table.get_table_name()}"({", ".join([c.name for c in self.columns])}) WHERE {self.where.get_sql()}', + q.get_sql(), + ) + + def test_create_index_unique(self) -> None: + q = Query.create_index(self.new_index).on(self.new_table).columns(*self.columns).unique() + self.assertEqual( + f'CREATE UNIQUE INDEX "{self.new_index.name}" ON "{self.new_table.get_table_name()}"({", ".join([c.name for c in self.columns])})', + q.get_sql(), + ) + + def test_create_index_if_not_exists(self) -> None: + q = Query.create_index(self.new_index).on(self.new_table).columns(*self.columns).if_not_exists() + self.assertEqual( + f'CREATE INDEX IF NOT EXISTS "{self.new_index.name}" ON "{self.new_table.get_table_name()}"({", ".join([c.name for c in self.columns])})', + q.get_sql(), + ) + + def test_create_index_without_columns_raises_error(self) -> None: + with self.assertRaises(AttributeError): + Query.create_index(self.new_index).on(self.new_table).get_sql() + + def test_create_index_without_table_raises_error(self) -> None: + with self.assertRaises(AttributeError): + Query.create_index(self.new_index).columns(*self.columns).get_sql() diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/test_criterions.py b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/test_criterions.py new file mode 100644 index 0000000000000000000000000000000000000000..fca2ceeeb18db88e34ebc38776f644fdcda67e93 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/test_criterions.py @@ -0,0 +1,873 @@ +import unittest +from datetime import ( + date, + datetime, +) + +from pypika import ( + Criterion, + EmptyCriterion, + Field, + Table, + functions as fn, +) +from pypika.queries import QueryBuilder +from pypika.terms import ExistsCriterion, Mod + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + + +class CriterionTests(unittest.TestCase): + t = Table("test", alias="crit") + + def test__criterion_with_alias(self): + c1 = (Field("foo") == Field("bar")).as_("criterion") + + self.assertEqual('"foo"="bar"', str(c1)) + self.assertEqual('"foo"="bar" "criterion"', c1.get_sql(with_alias=True, quote_char='"', alias_quote_char='"')) + + def test__criterion_eq_number(self): + c1 = Field("foo") == 1 + c2 = Field("foo", table=self.t).eq(0) + c3 = Field("foo", table=self.t) == -1 + + self.assertEqual('"foo"=1', str(c1)) + self.assertEqual('"crit"."foo"=0', str(c2)) + self.assertEqual('"crit"."foo"=-1', str(c3)) + + def test__criterion_eq_decimal(self): + c1 = Field("foo") == 1.0 + c2 = Field("foo", table=self.t).eq(0.5) + + self.assertEqual('"foo"=1.0', str(c1)) + self.assertEqual('"crit"."foo"=0.5', str(c2)) + + def test__criterion_eq_bool(self): + c1 = Field("foo") == True + c2 = Field("foo", table=self.t).eq(True) + c3 = Field("foo") == False + c4 = Field("foo", table=self.t).eq(False) + + self.assertEqual('"foo"=true', str(c1)) + self.assertEqual('"crit"."foo"=true', str(c2)) + self.assertEqual('"foo"=false', str(c3)) + self.assertEqual('"crit"."foo"=false', str(c4)) + + def test__criterion_eq_str(self): + c1 = Field("foo") == "abc" + c2 = Field("foo", table=self.t).eq("abc") + + self.assertEqual("\"foo\"='abc'", str(c1)) + self.assertEqual('"crit"."foo"=\'abc\'', str(c2)) + + def test__criterion_eq_date(self): + c1 = Field("foo") == date(2000, 1, 1) + c2 = Field("foo", table=self.t).eq(date(2000, 1, 1)) + + self.assertEqual("\"foo\"='2000-01-01'", str(c1)) + self.assertEqual('"crit"."foo"=\'2000-01-01\'', str(c2)) + + def test__criterion_eq_datetime(self): + c1 = Field("foo") == datetime(2000, 1, 1, 12, 30, 55) + c2 = Field("foo", table=self.t).eq(datetime(2000, 1, 1, 12, 30, 55)) + + self.assertEqual("\"foo\"='2000-01-01T12:30:55'", str(c1)) + self.assertEqual('"crit"."foo"=\'2000-01-01T12:30:55\'', str(c2)) + + def test__criterion_eq_right(self): + c1 = 1 == Field("foo") + c2 = -1 == Field("foo", table=self.t) + + self.assertEqual('"foo"=1', str(c1)) + self.assertEqual('"crit"."foo"=-1', str(c2)) + + def test__criterion_is_null(self): + c1 = Field("foo").isnull() + c2 = Field("foo", table=self.t).isnull() + + self.assertEqual('"foo" IS NULL', str(c1)) + self.assertEqual('"crit"."foo" IS NULL', str(c2)) + + def test__criterion_is_null_with_alias(self): + c1 = Field("foo").isnull().as_('alias') + c2 = Field("foo", table=self.t).isnull().as_('alias') + + self.assertEqual('"foo" IS NULL "alias"', str(c1)) + self.assertEqual('"crit"."foo" IS NULL "alias"', str(c2)) + + def test__criterion_ne_number(self): + c1 = Field("foo") != 1 + c2 = Field("foo", table=self.t).ne(0) + c3 = Field("foo") != -1 + + self.assertEqual('"foo"<>1', str(c1)) + self.assertEqual('"crit"."foo"<>0', str(c2)) + self.assertEqual('"foo"<>-1', str(c3)) + + def test__criterion_ne_str(self): + c1 = Field("foo") != "abc" + c2 = Field("foo", table=self.t).ne("abc") + + self.assertEqual("\"foo\"<>'abc'", str(c1)) + self.assertEqual('"crit"."foo"<>\'abc\'', str(c2)) + + def test__criterion_ne_date(self): + c1 = Field("foo") != date(2000, 1, 1) + c2 = Field("foo", table=self.t).ne(date(2000, 1, 1)) + + self.assertEqual("\"foo\"<>'2000-01-01'", str(c1)) + self.assertEqual('"crit"."foo"<>\'2000-01-01\'', str(c2)) + + def test__criterion_ne_datetime(self): + c1 = Field("foo") != datetime(2000, 1, 1, 12, 30, 55) + c2 = Field("foo", table=self.t).ne(datetime(2000, 1, 1, 12, 30, 55)) + + self.assertEqual("\"foo\"<>'2000-01-01T12:30:55'", str(c1)) + self.assertEqual('"crit"."foo"<>\'2000-01-01T12:30:55\'', str(c2)) + + def test__criterion_ne_right(self): + c1 = 1 != Field("foo") + c2 = -1 != Field("foo", table=self.t) + + self.assertEqual('"foo"<>1', str(c1)) + self.assertEqual('"crit"."foo"<>-1', str(c2)) + + def test__criterion_lt_number(self): + c1 = Field("foo") < 1 + c2 = Field("foo", table=self.t).lt(0) + c3 = Field("foo") < -1 + + self.assertEqual('"foo"<1', str(c1)) + self.assertEqual('"crit"."foo"<0', str(c2)) + self.assertEqual('"foo"<-1', str(c3)) + + def test__criterion_lt_date(self): + c1 = Field("foo") < date(2000, 1, 1) + c2 = Field("foo", table=self.t).lt(date(2000, 1, 1)) + + self.assertEqual("\"foo\"<'2000-01-01'", str(c1)) + self.assertEqual('"crit"."foo"<\'2000-01-01\'', str(c2)) + + def test__criterion_lt_datetime(self): + c1 = Field("foo") < datetime(2000, 1, 1, 12, 30, 55) + c2 = Field("foo", table=self.t).lt(datetime(2000, 1, 1, 12, 30, 55)) + + self.assertEqual("\"foo\"<'2000-01-01T12:30:55'", str(c1)) + self.assertEqual('"crit"."foo"<\'2000-01-01T12:30:55\'', str(c2)) + + def test__criterion_lt_right(self): + c1 = 1 > Field("foo") + c2 = -1 > Field("foo", table=self.t) + + self.assertEqual('"foo"<1', str(c1)) + self.assertEqual('"crit"."foo"<-1', str(c2)) + + def test__criterion_gt_number(self): + c1 = Field("foo") > 1 + c2 = Field("foo", table=self.t).gt(0) + c3 = Field("foo") > -1 + + self.assertEqual('"foo">1', str(c1)) + self.assertEqual('"crit"."foo">0', str(c2)) + self.assertEqual('"foo">-1', str(c3)) + + def test__criterion_gt_date(self): + c1 = Field("foo") > date(2000, 1, 1) + c2 = Field("foo", table=self.t).gt(date(2000, 1, 1)) + + self.assertEqual("\"foo\">'2000-01-01'", str(c1)) + self.assertEqual('"crit"."foo">\'2000-01-01\'', str(c2)) + + def test__criterion_gt_datetime(self): + c1 = Field("foo") > datetime(2000, 1, 1, 12, 30, 55) + c2 = Field("foo", table=self.t).gt(datetime(2000, 1, 1, 12, 30, 55)) + + self.assertEqual("\"foo\">'2000-01-01T12:30:55'", str(c1)) + self.assertEqual('"crit"."foo">\'2000-01-01T12:30:55\'', str(c2)) + + def test__criterion_gt_right(self): + c1 = 1 < Field("foo") + c2 = -1 < Field("foo", table=self.t) + + self.assertEqual('"foo">1', str(c1)) + self.assertEqual('"crit"."foo">-1', str(c2)) + + def test__criterion_lte_number(self): + c1 = Field("foo") <= 1 + c2 = Field("foo", table=self.t).lte(0) + c3 = Field("foo") <= -1 + + self.assertEqual('"foo"<=1', str(c1)) + self.assertEqual('"crit"."foo"<=0', str(c2)) + self.assertEqual('"foo"<=-1', str(c3)) + + def test__criterion_lte_date(self): + c1 = Field("foo") <= date(2000, 1, 1) + c2 = Field("foo", table=self.t).lte(date(2000, 1, 1)) + + self.assertEqual("\"foo\"<='2000-01-01'", str(c1)) + self.assertEqual('"crit"."foo"<=\'2000-01-01\'', str(c2)) + + def test__criterion_lte_datetime(self): + c1 = Field("foo") <= datetime(2000, 1, 1, 12, 30, 55) + c2 = Field("foo", table=self.t).lte(datetime(2000, 1, 1, 12, 30, 55)) + + self.assertEqual("\"foo\"<='2000-01-01T12:30:55'", str(c1)) + self.assertEqual('"crit"."foo"<=\'2000-01-01T12:30:55\'', str(c2)) + + def test__criterion_lte_right(self): + c1 = 1 >= Field("foo") + c2 = -1 >= Field("foo", table=self.t) + + self.assertEqual('"foo"<=1', str(c1)) + self.assertEqual('"crit"."foo"<=-1', str(c2)) + + def test__criterion_gte_number(self): + c1 = Field("foo") >= 1 + c2 = Field("foo", table=self.t).gte(0) + c3 = Field("foo") >= -1 + + self.assertEqual('"foo">=1', str(c1)) + self.assertEqual('"crit"."foo">=0', str(c2)) + self.assertEqual('"foo">=-1', str(c3)) + + def test__criterion_gte_date(self): + c1 = Field("foo") >= date(2000, 1, 1) + c2 = Field("foo", table=self.t).gte(date(2000, 1, 1)) + + self.assertEqual("\"foo\">='2000-01-01'", str(c1)) + self.assertEqual('"crit"."foo">=\'2000-01-01\'', str(c2)) + + def test__criterion_gte_datetime(self): + c1 = Field("foo") >= datetime(2000, 1, 1, 12, 30, 55) + c2 = Field("foo", table=self.t).gte(datetime(2000, 1, 1, 12, 30, 55)) + + self.assertEqual("\"foo\">='2000-01-01T12:30:55'", str(c1)) + self.assertEqual('"crit"."foo">=\'2000-01-01T12:30:55\'', str(c2)) + + def test__criterion_gte_right(self): + c1 = 1 <= Field("foo") + c2 = -1 <= Field("foo", table=self.t) + + self.assertEqual('"foo">=1', str(c1)) + self.assertEqual('"crit"."foo">=-1', str(c2)) + + def test__criterion_bitwise_and(self): + c1 = Field("foo").bitwiseand(2) + c2 = Field("foo", table=self.t).bitwiseand(10) == 2 + + self.assertEqual('("foo" & 2)', str(c1)) + self.assertEqual('("crit"."foo" & 10)=2', str(c2)) + + def test__criterion_bitwise_and_with_alias(self): + c1 = Field("foo").bitwiseand(2).as_('alias') + + self.assertEqual('("foo" & 2) "alias"', str(c1)) + + def test__bitwise_and_in_where_clause(self): + q = QueryBuilder().from_('items').select('abc').where(Field("foo").bitwiseand(1) == 1) + + self.assertEqual('SELECT "abc" FROM "items" WHERE ("foo" & 1)=1', str(q)) + + +class NotTests(unittest.TestCase): + table_abc, table_efg = Table("abc", alias="cx0"), Table("efg", alias="cx1") + + def test_negate(self): + c1 = Field("foo") >= 1 + c2 = c1.negate() + + self.assertEqual('"foo">=1', str(c1)) + self.assertEqual('NOT "foo">=1', str(c2)) + + def test_variable_access(self): + c1 = Field("foo").negate() + + self.assertEqual(c1.is_aggregate, False) + + def test_chained_function(self): + field1 = Field("foo").negate() + field2 = field1.eq("bar") + + self.assertEqual('NOT "foo"', str(field1)) + self.assertEqual("NOT \"foo\"='bar'", str(field2)) + self.assertIsNot(field1, field2) + + def test_not_null(self): + c1 = Field("foo").notnull() + c2 = Field("foo", table=self.table_abc).notnull() + + self.assertEqual('NOT "foo" IS NULL', str(c1)) + self.assertEqual('NOT "cx0"."foo" IS NULL', str(c2)) + + def test_is_not_null(self): + c1 = Field("foo").isnotnull() + c2 = Field("foo", table=self.table_abc).isnotnull() + + self.assertEqual('"foo" IS NOT NULL', str(c1)) + self.assertEqual('"cx0"."foo" IS NOT NULL', str(c2)) + + def test_not_null_with_alias(self): + c1 = Field("foo").notnull().as_("something") + c2 = Field("foo", table=self.table_abc).notnull().as_("something") + + self.assertEqual('NOT "foo" IS NULL "something"', str(c1)) + self.assertEqual('NOT "cx0"."foo" IS NULL "something"', str(c2)) + + def test_notnullcriterion_replace_table(self): + f = self.table_abc.foo.notnull().replace_table(self.table_abc, self.table_efg) + + self.assertEqual('NOT "cx1"."foo" IS NULL', str(f)) + + def test_not_with_or_criterion(self): + self.assertEqual('NOT ("foo" OR "bar")', str(~(Field("foo") | Field("bar")))) + + def test_not_with_and_criterion(self): + self.assertEqual('NOT ("foo" AND "bar")', str(~(Field("foo") & Field("bar")))) + + def test_not_with_complex_criterion(self): + self.assertEqual( + 'NOT ("foo" AND "bar" AND "fizz" AND "buzz")', + str(~(Field("foo") & Field("bar") & Field("fizz") & Field("buzz"))), + ) + + +class BetweenTests(unittest.TestCase): + t = Table("abc", alias="btw") + + def test__between_number(self): + c1 = Field("foo").between(0, 1) + c2 = Field("foo", table=self.t).between(0, 1) + c3 = Field("foo")[0:1] + + self.assertEqual('"foo" BETWEEN 0 AND 1', str(c1)) + self.assertEqual('"btw"."foo" BETWEEN 0 AND 1', str(c2)) + self.assertEqual('"foo" BETWEEN 0 AND 1', str(c3)) + + def test__between_with_alias(self): + c1 = Field("foo").between(0, 1).as_('alias') + c2 = Field("foo", table=self.t).between(0, 1).as_('alias') + c3 = Field("foo")[0:1].as_('alias') + + self.assertEqual('"foo" BETWEEN 0 AND 1 "alias"', str(c1)) + self.assertEqual('"btw"."foo" BETWEEN 0 AND 1 "alias"', str(c2)) + self.assertEqual('"foo" BETWEEN 0 AND 1 "alias"', str(c3)) + + def test__between_date(self): + c1 = Field("foo").between(date(2000, 1, 1), date(2000, 12, 31)) + c2 = Field("foo", table=self.t).between(date(2000, 1, 1), date(2000, 12, 31)) + c3 = Field("foo")[date(2000, 1, 1) : date(2000, 12, 31)] + + self.assertEqual("\"foo\" BETWEEN '2000-01-01' AND '2000-12-31'", str(c1)) + self.assertEqual("\"btw\".\"foo\" BETWEEN '2000-01-01' AND '2000-12-31'", str(c2)) + self.assertEqual("\"foo\" BETWEEN '2000-01-01' AND '2000-12-31'", str(c3)) + + def test__between_datetime(self): + c1 = Field("foo").between(datetime(2000, 1, 1, 0, 0, 0), datetime(2000, 12, 31, 23, 59, 59)) + c2 = Field("foo", table=self.t).between(datetime(2000, 1, 1, 0, 0, 0), datetime(2000, 12, 31, 23, 59, 59)) + c3 = Field("foo")[datetime(2000, 1, 1, 0, 0, 0) : datetime(2000, 12, 31, 23, 59, 59)] + + self.assertEqual("\"foo\" BETWEEN '2000-01-01T00:00:00' AND '2000-12-31T23:59:59'", str(c1)) + self.assertEqual( + "\"btw\".\"foo\" BETWEEN '2000-01-01T00:00:00' AND '2000-12-31T23:59:59'", + str(c2), + ) + self.assertEqual("\"foo\" BETWEEN '2000-01-01T00:00:00' AND '2000-12-31T23:59:59'", str(c3)) + + def test__function_between(self): + c1 = fn.Coalesce(Field("foo"), 0)[0:1] + c2 = fn.Coalesce(Field("foo", table=self.t), 0)[0:1] + + self.assertEqual('COALESCE("foo",0) BETWEEN 0 AND 1', str(c1)) + self.assertEqual('COALESCE("btw"."foo",0) BETWEEN 0 AND 1', str(c2)) + + def test_get_item_only_works_with_slice(self): + with self.assertRaises(TypeError): + Field("foo")[0] + + with self.assertRaises(TypeError): + Field("foo")[date(2000, 1, 1)] + + with self.assertRaises(TypeError): + Field("foo")[datetime(2000, 1, 1, 0, 0, 0)] + + +class IsInTests(unittest.TestCase): + t = Table("abc", alias="isin") + + def test__in_number(self): + c1 = Field("foo").isin([0, 1]) + c2 = Field("foo", table=self.t).isin([0, 1]) + + self.assertEqual('"foo" IN (0,1)', str(c1)) + self.assertEqual('"isin"."foo" IN (0,1)', str(c2)) + + def test__in_number_with_alias(self): + c1 = Field("foo").isin([0, 1]).as_('alias') + c2 = Field("foo", table=self.t).isin([0, 1]).as_('alias') + + self.assertEqual('"foo" IN (0,1) "alias"', str(c1)) + self.assertEqual('"isin"."foo" IN (0,1) "alias"', str(c2)) + + def test__in_character(self): + c1 = Field("foo").isin(["a", "b"]) + c2 = Field("foo", table=self.t).isin(["a", "b"]) + + self.assertEqual("\"foo\" IN ('a','b')", str(c1)) + self.assertEqual("\"isin\".\"foo\" IN ('a','b')", str(c2)) + + def test__in_date(self): + c1 = Field("foo").isin([date(2000, 1, 1), date(2000, 12, 31)]) + c2 = Field("foo", table=self.t).isin([date(2000, 1, 1), date(2000, 12, 31)]) + + self.assertEqual("\"foo\" IN ('2000-01-01','2000-12-31')", str(c1)) + self.assertEqual("\"isin\".\"foo\" IN ('2000-01-01','2000-12-31')", str(c2)) + + def test__in_datetime(self): + c1 = Field("foo").isin([datetime(2000, 1, 1, 0, 0, 0), datetime(2000, 12, 31, 23, 59, 59)]) + c2 = Field("foo", table=self.t).isin([datetime(2000, 1, 1, 0, 0, 0), datetime(2000, 12, 31, 23, 59, 59)]) + + self.assertEqual("\"foo\" IN ('2000-01-01T00:00:00','2000-12-31T23:59:59')", str(c1)) + self.assertEqual("\"isin\".\"foo\" IN ('2000-01-01T00:00:00','2000-12-31T23:59:59')", str(c2)) + + def test__function_isin(self): + c1 = fn.Coalesce(Field("foo"), 0).isin([0, 1]) + c2 = fn.Coalesce(Field("foo", table=self.t), 0).isin([0, 1]) + + self.assertEqual('COALESCE("foo",0) IN (0,1)', str(c1)) + self.assertEqual('COALESCE("isin"."foo",0) IN (0,1)', str(c2)) + + for t in (list, tuple, set, frozenset): + c_type = fn.Coalesce(Field("foo"), 0).isin(t([0, 1])) + self.assertEqual('COALESCE("foo",0) IN (0,1)', str(c_type)) + + self.assertRaises(AttributeError, lambda: str(fn.Coalesce(Field("foo"), 0).isin('SHOULD_FAIL'))) + + def test__in_unicode(self): + c1 = Field("foo").isin([u"a", u"b"]) + c2 = Field("foo", table=self.t).isin([u"a", u"b"]) + + self.assertEqual("\"foo\" IN ('a','b')", str(c1)) + self.assertEqual("\"isin\".\"foo\" IN ('a','b')", str(c2)) + + +class ArithmeticExpressionTests(unittest.TestCase): + def test__lshift(self): + c1 = Field("foo").lshift("1") + c2 = Field("foo").lshift("2") + + self.assertEqual("\"foo\"<<'1'", str(c1)) + self.assertEqual("\"foo\"<<'2'", str(c2)) + + def test__rshift(self): + c1 = Field("foo").rshift("1") + c2 = Field("foo").rshift("2") + + self.assertEqual("\"foo\">>'1'", str(c1)) + self.assertEqual("\"foo\">>'2'", str(c2)) + + +class NotInTests(unittest.TestCase): + t = Table("abc", alias="notin") + + def test__notin_number(self): + c1 = Field("foo").notin([0, 1]) + c2 = Field("foo", table=self.t).notin([0, 1]) + + self.assertEqual('"foo" NOT IN (0,1)', str(c1)) + self.assertEqual('"notin"."foo" NOT IN (0,1)', str(c2)) + + def test__notin_number_with_alias(self): + c1 = Field("foo").notin([0, 1]).as_('alias') + c2 = Field("foo", table=self.t).notin([0, 1]).as_('alias') + + self.assertEqual('"foo" NOT IN (0,1) "alias"', str(c1)) + self.assertEqual('"notin"."foo" NOT IN (0,1) "alias"', str(c2)) + + def test__notin_character(self): + c1 = Field("foo").notin(["a", "b"]) + c2 = Field("foo", table=self.t).notin(["a", "b"]) + + self.assertEqual("\"foo\" NOT IN ('a','b')", str(c1)) + self.assertEqual("\"notin\".\"foo\" NOT IN ('a','b')", str(c2)) + + def test__notin_date(self): + c1 = Field("foo").notin([date(2000, 1, 1), date(2000, 12, 31)]) + c2 = Field("foo", table=self.t).notin([date(2000, 1, 1), date(2000, 12, 31)]) + + self.assertEqual("\"foo\" NOT IN ('2000-01-01','2000-12-31')", str(c1)) + self.assertEqual("\"notin\".\"foo\" NOT IN ('2000-01-01','2000-12-31')", str(c2)) + + def test__notin_datetime(self): + c1 = Field("foo").notin([datetime(2000, 1, 1, 0, 0, 0), datetime(2000, 12, 31, 23, 59, 59)]) + c2 = Field("foo", table=self.t).notin([datetime(2000, 1, 1, 0, 0, 0), datetime(2000, 12, 31, 23, 59, 59)]) + + self.assertEqual("\"foo\" NOT IN ('2000-01-01T00:00:00','2000-12-31T23:59:59')", str(c1)) + self.assertEqual( + "\"notin\".\"foo\" NOT IN ('2000-01-01T00:00:00','2000-12-31T23:59:59')", + str(c2), + ) + + def test__function_notin(self): + c1 = fn.Coalesce(Field("foo"), 0).notin([0, 1]) + c2 = fn.Coalesce(Field("foo", table=self.t), 0).notin([0, 1]) + + self.assertEqual('COALESCE("foo",0) NOT IN (0,1)', str(c1)) + self.assertEqual('COALESCE("notin"."foo",0) NOT IN (0,1)', str(c2)) + + +class LikeTests(unittest.TestCase): + t = Table("abc", alias="like") + + def test_like_starts_with(self): + c1 = Field("foo").like("ab%") + c2 = Field("foo", table=self.t).like("ab%") + + self.assertEqual("\"foo\" LIKE 'ab%'", str(c1)) + self.assertEqual('"like"."foo" LIKE \'ab%\'', str(c2)) + + def test_like_contains(self): + c1 = Field("foo").like("%ab%") + c2 = Field("foo", table=self.t).like("%ab%") + + self.assertEqual("\"foo\" LIKE '%ab%'", str(c1)) + self.assertEqual('"like"."foo" LIKE \'%ab%\'', str(c2)) + + def test_like_ends_with(self): + c1 = Field("foo").like("%ab") + c2 = Field("foo", table=self.t).like("%ab") + + self.assertEqual("\"foo\" LIKE '%ab'", str(c1)) + self.assertEqual('"like"."foo" LIKE \'%ab\'', str(c2)) + + def test_like_n_chars_long(self): + c1 = Field("foo").like("___") + c2 = Field("foo", table=self.t).like("___") + + self.assertEqual("\"foo\" LIKE '___'", str(c1)) + self.assertEqual('"like"."foo" LIKE \'___\'', str(c2)) + + def test_like_single_chars_and_various_chars(self): + c1 = Field("foo").like("a_b%c") + c2 = Field("foo", table=self.t).like("a_b%c") + + self.assertEqual("\"foo\" LIKE 'a_b%c'", str(c1)) + self.assertEqual('"like"."foo" LIKE \'a_b%c\'', str(c2)) + + def test_not_like_single_chars_and_various_chars(self): + c1 = Field("foo").not_like("a_b%c") + c2 = Field("foo", table=self.t).not_like("a_b%c") + + self.assertEqual("\"foo\" NOT LIKE 'a_b%c'", str(c1)) + self.assertEqual('"like"."foo" NOT LIKE \'a_b%c\'', str(c2)) + + def test_ilike_starts_with(self): + c1 = Field("foo").ilike("ab%") + c2 = Field("foo", table=self.t).ilike("ab%") + + self.assertEqual("\"foo\" ILIKE 'ab%'", str(c1)) + self.assertEqual('"like"."foo" ILIKE \'ab%\'', str(c2)) + + def test_ilike_contains(self): + c1 = Field("foo").ilike("%ab%") + c2 = Field("foo", table=self.t).ilike("%ab%") + + self.assertEqual("\"foo\" ILIKE '%ab%'", str(c1)) + self.assertEqual('"like"."foo" ILIKE \'%ab%\'', str(c2)) + + def test_ilike_ends_with(self): + c1 = Field("foo").ilike("%ab") + c2 = Field("foo", table=self.t).ilike("%ab") + + self.assertEqual("\"foo\" ILIKE '%ab'", str(c1)) + self.assertEqual('"like"."foo" ILIKE \'%ab\'', str(c2)) + + def test_ilike_n_chars_long(self): + c1 = Field("foo").ilike("___") + c2 = Field("foo", table=self.t).ilike("___") + + self.assertEqual("\"foo\" ILIKE '___'", str(c1)) + self.assertEqual('"like"."foo" ILIKE \'___\'', str(c2)) + + def test_ilike_single_chars_and_various_chars(self): + c1 = Field("foo").ilike("a_b%c") + c2 = Field("foo", table=self.t).ilike("a_b%c") + + self.assertEqual("\"foo\" ILIKE 'a_b%c'", str(c1)) + self.assertEqual('"like"."foo" ILIKE \'a_b%c\'', str(c2)) + + def test_not_ilike_single_chars_and_various_chars(self): + c1 = Field("foo").not_ilike("a_b%c") + c2 = Field("foo", table=self.t).not_ilike("a_b%c") + + self.assertEqual("\"foo\" NOT ILIKE 'a_b%c'", str(c1)) + self.assertEqual('"like"."foo" NOT ILIKE \'a_b%c\'', str(c2)) + + def test_rlike_escape_chars(self): + c1 = Field("foo").rlike("\\\\d+$") + c2 = Field("foo", table=self.t).rlike("\\\\d+$") + + self.assertEqual("\"foo\" RLIKE '\\\\d+$'", str(c1)) + self.assertEqual('"like"."foo" RLIKE \'\\\\d+$\'', str(c2)) + + def test_glob_single_chars_and_various_chars(self): + c1 = Field("foo").glob("a_b*") + c2 = Field("foo", table=self.t).glob("a_b*") + + self.assertEqual("\"foo\" GLOB 'a_b*'", str(c1)) + self.assertEqual('"like"."foo" GLOB \'a_b*\'', str(c2)) + + +class ExistsCriterionTests(unittest.TestCase): + t2 = Table("abc", alias="t2") + q2 = QueryBuilder().from_(t2).select(t2.field2) + + def test_exists(self): + t1 = Table("def", alias="t1") + q1 = QueryBuilder().from_(t1).where(ExistsCriterion(self.q2)).select(t1.field1) + + self.assertEqual( + 'SELECT "t1"."field1" FROM "def" "t1" WHERE EXISTS (SELECT "t2"."field2" FROM "abc" "t2")', str(q1) + ) + + def test_not_exists(self): + t1 = Table("def", alias="t1") + q1 = QueryBuilder().from_(t1).where(ExistsCriterion(self.q2).negate()).select(t1.field1) + + self.assertEqual( + 'SELECT "t1"."field1" FROM "def" "t1" WHERE NOT EXISTS (SELECT "t2"."field2" FROM "abc" "t2")', str(q1) + ) + + +class ComplexCriterionTests(unittest.TestCase): + table_abc, table_efg = Table("abc", alias="cx0"), Table("efg", alias="cx1") + + def test_and(self): + c1 = (Field("foo") == 1) & (Field("bar") == 2) + c2 = (Field("foo", table=self.table_abc) == 1) & (Field("bar", table=self.table_efg) == 2) + + self.assertEqual('"foo"=1 AND "bar"=2', str(c1)) + self.assertEqual('"cx0"."foo"=1 AND "cx1"."bar"=2', str(c2)) + + def test_or(self): + c1 = (Field("foo") == 1) | (Field("bar") == 2) + c2 = (Field("foo", table=self.table_abc) == 1) | (Field("bar", table=self.table_efg) == 2) + + self.assertEqual('"foo"=1 OR "bar"=2', str(c1)) + self.assertEqual('"cx0"."foo"=1 OR "cx1"."bar"=2', str(c2)) + + def test_xor(self): + c1 = (Field("foo") == 1) ^ (Field("bar") == 2) + c2 = (Field("foo", table=self.table_abc) == 1) ^ (Field("bar", table=self.table_efg) == 2) + + self.assertEqual('"foo"=1 XOR "bar"=2', str(c1)) + self.assertEqual('"cx0"."foo"=1 XOR "cx1"."bar"=2', str(c2)) + + def test_function_and(self): + c1 = fn.IsNull(Field("foo")) & (Field("bar") == 2) + + self.assertEqual('ISNULL("foo") AND "bar"=2', str(c1)) + + def test_function_or(self): + c1 = fn.IsNull(Field("foo")) | (Field("bar") == 2) + + self.assertEqual('ISNULL("foo") OR "bar"=2', str(c1)) + + def test_function_xor(self): + c1 = fn.IsNull(Field("foo")) ^ (Field("bar") == 2) + + self.assertEqual('ISNULL("foo") XOR "bar"=2', str(c1)) + + def test__nested__and(self): + c = (Field("foo") == 1) & (Field("bar") == 2) & (Field("buz") == 3) + + self.assertEqual('"foo"=1 AND "bar"=2 AND "buz"=3', str(c)) + + def test__nested__or(self): + c = (Field("foo") == 1) | (Field("bar") == 2) | (Field("buz") == 3) + + self.assertEqual('"foo"=1 OR "bar"=2 OR "buz"=3', str(c)) + + def test__nested__mixed(self): + c = ((Field("foo") == 1) & (Field("bar") == 2)) | (Field("buz") == 3) + + self.assertEqual('("foo"=1 AND "bar"=2) OR "buz"=3', str(c)) + + def test__between_and_isin(self): + c = Field("foo").isin([1, 2, 3]) & Field("bar").between(0, 1) + + self.assertEqual('"foo" IN (1,2,3) AND "bar" BETWEEN 0 AND 1', str(c)) + + def test__between_and_field(self): + c1 = Field("foo").between(0, 1) + c2 = Field("bool_field") + + self.assertEqual('"foo" BETWEEN 0 AND 1 AND "bool_field"', str(c1 & c2)) + self.assertEqual('"bool_field" AND "foo" BETWEEN 0 AND 1', str(c2 & c1)) + + +class FieldsAsCriterionTests(unittest.TestCase): + def test__field_and_field(self): + c1 = Field("a") + c2 = Field("b") + + self.assertEqual('"a" AND "b"', str(c1 & c2)) + + def test__field_or_field(self): + c1 = Field("a") + c2 = Field("b") + + self.assertEqual('"a" OR "b"', str(c1 | c2)) + + def test__field_xor_field(self): + c1 = Field("a") + c2 = Field("b") + + self.assertEqual('"a" XOR "b"', str(c1 ^ c2)) + + +class CriterionOperationsTests(unittest.TestCase): + table_abc, table_efg = Table("abc", alias="cx0"), Table("efg", alias="cx1") + + def test_field_replace_table(self): + f = self.table_abc.foo.replace_table(self.table_abc, self.table_efg) + + self.assertEqual('"cx1"."foo"', str(f)) + + def test_arithmeticfunction_replace_table(self): + f = (self.table_abc.foo + self.table_abc.bar).replace_table(self.table_abc, self.table_efg) + + self.assertEqual('"cx1"."foo"+"cx1"."bar"', str(f)) + + def test_criterion_replace_table(self): + f = (self.table_abc.foo < self.table_abc.bar).replace_table(self.table_abc, self.table_efg) + + self.assertEqual('"cx1"."foo"<"cx1"."bar"', str(f)) + + def test_complexcriterion_replace_table(self): + f = (self.table_abc.foo < self.table_abc.bar) & (self.table_abc.fiz > self.table_abc.buz) + f = f.replace_table(self.table_abc, self.table_efg) + + self.assertEqual('"cx1"."foo"<"cx1"."bar" AND "cx1"."fiz">"cx1"."buz"', str(f)) + + def test_function_with_only_fields_replace_table(self): + f = fn.Sum(self.table_abc.foo).replace_table(self.table_abc, self.table_efg) + + self.assertEqual('SUM("cx1"."foo")', str(f)) + + def test_function_with_values_and_fields_replace_table(self): + f = Mod(self.table_abc.foo, 2).replace_table(self.table_abc, self.table_efg) + + self.assertEqual('MOD("cx1"."foo",2)', str(f)) + + def test_betweencriterion_replace_table(self): + f = self.table_abc.foo[0:1].replace_table(self.table_abc, self.table_efg) + + self.assertEqual('"cx1"."foo" BETWEEN 0 AND 1', str(f)) + + def test_nullcriterion_replace_table(self): + f = self.table_abc.foo.isnull().replace_table(self.table_abc, self.table_efg) + + self.assertEqual('"cx1"."foo" IS NULL', str(f)) + + +class AnyTests(unittest.TestCase): + def test_zero_args_returns_empty_criterion(self): + crit = Criterion.any() + self.assertIsInstance(crit, EmptyCriterion) + + def test_single_arg_returns_self(self): + f = Field("a") + crit = Criterion.any([f]) + self.assertEqual(str(f), str(crit)) + + def test_multiple_args_returned_in_chain_of_ors(self): + crit = Criterion.any([Field("a"), Field("b"), Field("c"), Field("d")]) + self.assertEqual(str(crit), '"a" OR "b" OR "c" OR "d"') + + def test_with_generator(self): + crit = Criterion.any(Field(letter) for letter in "abcd") + self.assertEqual(str(crit), '"a" OR "b" OR "c" OR "d"') + + +class EmptyCriterionTests(unittest.TestCase): + def test_fields_(self): + empty_criterion = EmptyCriterion() + + self.assertEqual(len(empty_criterion.fields_()), 0) + + def test_empty_criterion_on_the_left(self): + t = Table("test1") + q = EmptyCriterion() & t.f1 == "v1" + + self.assertEqual( + '"test1"."f1"=\'v1\'', + q.get_sql(with_namespace=True), + ) + + def test_empty_criterion_on_the_right(self): + t = Table("test1") + q = (t.f1 == "v1") & EmptyCriterion() + + self.assertEqual( + '"test1"."f1"=\'v1\'', + q.get_sql(with_namespace=True), + ) + + def test_invertion_of_the_empty_criterion(self): + t = Table("test1") + q = (t.f1 == "v1") & ~EmptyCriterion() + + self.assertEqual( + '"test1"."f1"=\'v1\'', + q.get_sql(with_namespace=True), + ) + + def test_different_operations_with_empty_criterion(self): + t = Table("test1") + q1 = (t.f1 == "v1") & EmptyCriterion() + q2 = (t.f1 == "v1") | EmptyCriterion() + q3 = (t.f1 == "v1") ^ EmptyCriterion() + + expected_sql = '"test1"."f1"=\'v1\'' + self.assertEqual( + expected_sql, + q1.get_sql(with_namespace=True), + ) + self.assertEqual( + expected_sql, + q2.get_sql(with_namespace=True), + ) + self.assertEqual( + expected_sql, + q3.get_sql(with_namespace=True), + ) + + def test_more_than_one_empty_criterions(self): + t = Table("test1") + q = EmptyCriterion() & ~(EmptyCriterion() | EmptyCriterion()) & (t.f1 == "v1") & ~EmptyCriterion() + + self.assertEqual( + '"test1"."f1"=\'v1\'', + q.get_sql(with_namespace=True), + ) + + +class AllTests(unittest.TestCase): + def test_zero_args_returns_empty_criterion(self): + crit = Criterion.all() + self.assertIsInstance(crit, EmptyCriterion) + + def test_single_arg_returns_self(self): + f = Field("a") + crit = Criterion.all([f]) + self.assertEqual(str(f), str(crit)) + + def test_multiple_args_returned_in_chain_of_ors(self): + crit = Criterion.all([Field("a"), Field("b"), Field("c"), Field("d")]) + self.assertEqual(str(crit), '"a" AND "b" AND "c" AND "d"') + + def test_with_generator(self): + crit = Criterion.all(Field(letter) for letter in "abcd") + self.assertEqual(str(crit), '"a" AND "b" AND "c" AND "d"') diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/test_custom_functions.py b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/test_custom_functions.py new file mode 100644 index 0000000000000000000000000000000000000000..60ffd3cd8e6191e3fc782dac003c41bfb7a78528 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/test_custom_functions.py @@ -0,0 +1,49 @@ +import unittest + +from pypika import CustomFunction, FunctionException, Query, Table + +__author__ = "Airton Zanon" +__email__ = "me@airton.dev" + + +class TestUnitCustomFunction(unittest.TestCase): + def test_should_fail_with_wrong_arguments(self): + DateDiff = CustomFunction("DATE_DIFF", ["interval", "start_date", "end_date"]) + + with self.assertRaises(FunctionException): + DateDiff("foo") + + def test_should_return_function_with_arguments(self): + DateDiff = CustomFunction("DATE_DIFF", ["interval", "start_date", "end_date"]) + + self.assertEqual( + "DATE_DIFF('day','start_date','end_date')", + str(DateDiff("day", "start_date", "end_date")), + ) + + def test_should_return_function_with_no_arguments(self): + CurrentDate = CustomFunction("CURRENT_DATE") + + self.assertEqual("CURRENT_DATE()", str(CurrentDate())) + + +class TestFunctionalCustomFunction(unittest.TestCase): + def test_should_use_custom_function_on_select(self): + service = Table("service") + + DateDiff = CustomFunction("DATE_DIFF", ["interval", "start_date", "end_date"]) + + q = Query.from_(service).select(DateDiff("day", service.created_date, service.updated_date)) + + self.assertEqual( + 'SELECT DATE_DIFF(\'day\',"created_date","updated_date") FROM "service"', + str(q), + ) + + def test_should_fail_use_custom_function_on_select_with_wrong_arguments(self): + service = Table("service") + + DateDiff = CustomFunction("DATE_DIFF", ["interval", "start_date", "end_date"]) + + with self.assertRaises(FunctionException): + Query.from_(service).select(DateDiff("day", service.created_date)) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/test_data_types.py b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/test_data_types.py new file mode 100644 index 0000000000000000000000000000000000000000..52fb4487fe7be3ae28a4e9eb08628fba89dc0f79 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/test_data_types.py @@ -0,0 +1,15 @@ +import unittest +import uuid + +from pypika.terms import ValueWrapper + + +class StringTests(unittest.TestCase): + def test_inline_string_concatentation(self): + self.assertEqual("'it''s'", ValueWrapper("it's").get_sql()) + + +class UuidTests(unittest.TestCase): + def test_uuid_string_generation(self): + id = uuid.uuid4() + self.assertEqual("'{}'".format(id), ValueWrapper(id).get_sql()) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/test_date_math.py b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/test_date_math.py new file mode 100644 index 0000000000000000000000000000000000000000..38db8ef2f8e812a97c6980a7ec6b9a3909d804fb --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/test_date_math.py @@ -0,0 +1,179 @@ +import unittest + +from pypika import ( + Field as F, + Interval, +) +from pypika.enums import Dialects + +dt = F("dt") + + +class AddIntervalTests(unittest.TestCase): + def test_add_microsecond(self): + c = dt + Interval(microseconds=1) + + self.assertEqual("\"dt\"+INTERVAL '1 MICROSECOND'", str(c)) + + def test_add_second(self): + c = dt + Interval(seconds=1) + + self.assertEqual("\"dt\"+INTERVAL '1 SECOND'", str(c)) + + def test_add_minute(self): + c = dt + Interval(minutes=1) + + self.assertEqual("\"dt\"+INTERVAL '1 MINUTE'", str(c)) + + def test_add_day(self): + c = dt + Interval(days=1) + + self.assertEqual("\"dt\"+INTERVAL '1 DAY'", str(c)) + + def test_add_week(self): + c = dt + Interval(weeks=1) + + self.assertEqual("\"dt\"+INTERVAL '1 WEEK'", str(c)) + + def test_add_month(self): + c = dt + Interval(months=1) + + self.assertEqual("\"dt\"+INTERVAL '1 MONTH'", str(c)) + + def test_add_quarter(self): + c = dt + Interval(quarters=1) + + self.assertEqual("\"dt\"+INTERVAL '1 QUARTER'", str(c)) + + def test_add_year(self): + c = dt + Interval(years=1) + + self.assertEqual("\"dt\"+INTERVAL '1 YEAR'", str(c)) + + def test_add_default(self): + c = dt + Interval(days=0) + + self.assertEqual("\"dt\"+INTERVAL '0 DAY'", str(c)) + + +class AddIntervalMultipleUnitsTests(unittest.TestCase): + def test_add_second_microsecond(self): + c = dt + Interval(seconds=1, microseconds=1) + + self.assertEqual("\"dt\"+INTERVAL '1.1 SECOND_MICROSECOND'", str(c)) + + def test_add_minute_microsecond(self): + c = dt + Interval(minutes=1, microseconds=1) + + self.assertEqual("\"dt\"+INTERVAL '1:0.1 MINUTE_MICROSECOND'", str(c)) + + def test_add_minute_second(self): + c = dt + Interval(minutes=1, seconds=1) + + self.assertEqual("\"dt\"+INTERVAL '1:1 MINUTE_SECOND'", str(c)) + + def test_add_hour_microsecond(self): + c = dt + Interval(hours=1, microseconds=1) + + self.assertEqual("\"dt\"+INTERVAL '1:0:0.1 HOUR_MICROSECOND'", str(c)) + + def test_add_hour_second(self): + c = dt + Interval(hours=1, seconds=1) + + self.assertEqual("\"dt\"+INTERVAL '1:0:1 HOUR_SECOND'", str(c)) + + def test_add_hour_minute(self): + c = dt + Interval(hours=1, minutes=1) + + self.assertEqual("\"dt\"+INTERVAL '1:1 HOUR_MINUTE'", str(c)) + + def test_add_day_microsecond(self): + c = dt + Interval(days=1, microseconds=1) + + self.assertEqual("\"dt\"+INTERVAL '1 0:0:0.1 DAY_MICROSECOND'", str(c)) + + def test_add_day_second(self): + c = dt + Interval(days=1, seconds=1) + + self.assertEqual("\"dt\"+INTERVAL '1 0:0:1 DAY_SECOND'", str(c)) + + def test_add_day_minute(self): + c = dt + Interval(days=1, minutes=1) + + self.assertEqual("\"dt\"+INTERVAL '1 0:1 DAY_MINUTE'", str(c)) + + def test_add_day_hour(self): + c = dt + Interval(days=1, hours=1) + + self.assertEqual("\"dt\"+INTERVAL '1 1 DAY_HOUR'", str(c)) + + def test_add_year_month(self): + c = dt + Interval(years=1, months=1) + + self.assertEqual("\"dt\"+INTERVAL '1-1 YEAR_MONTH'", str(c)) + + def test_add_value_right(self): + c = Interval(microseconds=1) - dt + + self.assertEqual("INTERVAL '1 MICROSECOND'-\"dt\"", str(c)) + + def test_add_value_complex_expressions(self): + c = dt + Interval(quarters=1) + Interval(weeks=1) + + self.assertEqual("\"dt\"+INTERVAL '1 QUARTER'+INTERVAL '1 WEEK'", str(c)) + + +class DialectIntervalTests(unittest.TestCase): + def test_mysql_dialect_uses_single_quotes_around_expression_in_an_interval(self): + c = Interval(days=1).get_sql(dialect=Dialects.MYSQL) + self.assertEqual("INTERVAL '1' DAY", c) + + def test_oracle_dialect_uses_single_quotes_around_expression_in_an_interval(self): + c = Interval(days=1).get_sql(dialect=Dialects.ORACLE) + self.assertEqual("INTERVAL '1' DAY", c) + + def test_vertica_dialect_uses_single_quotes_around_interval(self): + c = Interval(days=1).get_sql(dialect=Dialects.VERTICA) + self.assertEqual("INTERVAL '1 DAY'", c) + + def test_redshift_dialect_uses_single_quotes_around_interval(self): + c = Interval(days=1).get_sql(dialect=Dialects.REDSHIFT) + self.assertEqual("INTERVAL '1 DAY'", c) + + def test_postgresql_dialect_uses_single_quotes_around_interval(self): + c = Interval(days=1).get_sql(dialect=Dialects.POSTGRESQL) + self.assertEqual("INTERVAL '1 DAY'", c) + + +class TestNegativeIntervals(unittest.TestCase): + def test_day(self): + c = Interval(days=-1).get_sql() + self.assertEqual("INTERVAL '-1 DAY'", c) + + def test_week(self): + c = Interval(weeks=-1).get_sql() + self.assertEqual("INTERVAL '-1 WEEK'", c) + + def test_month(self): + c = Interval(months=-1).get_sql() + self.assertEqual("INTERVAL '-1 MONTH'", c) + + def test_year(self): + c = Interval(years=-1).get_sql() + self.assertEqual("INTERVAL '-1 YEAR'", c) + + def test_year_month(self): + c = Interval(years=-1, months=-4).get_sql() + self.assertEqual("INTERVAL '-1-4 YEAR_MONTH'", c) + + +class TruncateTrailingZerosTests(unittest.TestCase): + def test_do_not_truncate_integer_values(self): + i = Interval(seconds=10) + + self.assertEqual("INTERVAL '10 SECOND'", str(i)) + + def test_do_not_truncate_months_between_years_and_datys(self): + i = Interval(years=10, days=10) + + self.assertEqual("INTERVAL '10-0-10 YEAR_DAY'", str(i)) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/test_deletes.py b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/test_deletes.py new file mode 100644 index 0000000000000000000000000000000000000000..09df93f5331b845b0c3aed628bf1c4a3ec6b0f02 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/test_deletes.py @@ -0,0 +1,97 @@ +import unittest + +from pypika import PostgreSQLQuery, Query, SYSTEM_TIME, Table + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + +from pypika.terms import Star + + +class DeleteTests(unittest.TestCase): + @classmethod + def setUpClass(cls) -> None: + super().setUpClass() + cls.table_abc = Table("abc") + + def test_omit_where(self): + q = Query.from_("abc").delete() + + self.assertEqual('DELETE FROM "abc"', str(q)) + + def test_omit_where__table_schema(self): + q = Query.from_(Table("abc", "schema1")).delete() + + self.assertEqual('DELETE FROM "schema1"."abc"', str(q)) + + def test_where_field_equals(self): + q1 = Query.from_(self.table_abc).where(self.table_abc.foo == self.table_abc.bar).delete() + q2 = Query.from_(self.table_abc).where(self.table_abc.foo.eq(self.table_abc.bar)).delete() + + self.assertEqual('DELETE FROM "abc" WHERE "foo"="bar"', str(q1)) + self.assertEqual('DELETE FROM "abc" WHERE "foo"="bar"', str(q2)) + + def test_for_portion(self): + with self.subTest("with system time"): + q = Query.from_(self.table_abc.for_portion(SYSTEM_TIME.from_to('2020-01-01', '2020-02-01'))).delete() + + self.assertEqual( + 'DELETE FROM "abc" FOR PORTION OF SYSTEM_TIME FROM \'2020-01-01\' TO \'2020-02-01\'', str(q) + ) + + with self.subTest("with column"): + q = Query.from_( + self.table_abc.for_portion(self.table_abc.valid_period.from_to('2020-01-01', '2020-02-01')) + ).delete() + + self.assertEqual( + 'DELETE FROM "abc" FOR PORTION OF "valid_period" FROM \'2020-01-01\' TO \'2020-02-01\'', str(q) + ) + + +class PostgresDeleteTests(unittest.TestCase): + @classmethod + def setUpClass(cls) -> None: + super().setUpClass() + cls.table_abc = Table("abc") + + def test_delete_returning(self): + q1 = ( + PostgreSQLQuery.from_(self.table_abc) + .where(self.table_abc.foo == self.table_abc.bar) + .delete() + .returning(self.table_abc.id) + ) + + self.assertEqual('DELETE FROM "abc" WHERE "foo"="bar" RETURNING "id"', str(q1)) + + def test_delete_returning_str(self): + q1 = ( + PostgreSQLQuery.from_(self.table_abc) + .where(self.table_abc.foo == self.table_abc.bar) + .delete() + .returning("id") + ) + + self.assertEqual('DELETE FROM "abc" WHERE "foo"="bar" RETURNING "id"', str(q1)) + + def test_delete_returning_star(self): + q1 = ( + PostgreSQLQuery.from_(self.table_abc) + .where(self.table_abc.foo == self.table_abc.bar) + .delete() + .returning(Star()) + ) + + self.assertEqual('DELETE FROM "abc" WHERE "foo"="bar" RETURNING *', str(q1)) + + def test_delete_using(self): + table_trash = Table('trash') + q1 = ( + PostgreSQLQuery.from_(self.table_abc) + .using(table_trash) + .where(self.table_abc.id == table_trash.abc_id) + .delete() + ) + + self.assertEqual('DELETE FROM "abc" USING "trash" WHERE "abc"."id"="trash"."abc_id"', str(q1)) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/test_drop.py b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/test_drop.py new file mode 100644 index 0000000000000000000000000000000000000000..265ae7350d2054549731f9a8c4379fdac95dc580 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/test_drop.py @@ -0,0 +1,49 @@ +import unittest + +from pypika import ( + Columns, + Database, + Query, + Tables, +) + + +class DropTableTests(unittest.TestCase): + database_xyz = Database("mydb") + new_table, existing_table = Tables("abc", "efg") + foo, bar = Columns(("a", "INT"), ("b", "VARCHAR(100)")) + + def test_drop_database(self): + q1 = Query.drop_database(self.database_xyz) + q2 = Query.drop_database(self.database_xyz).if_exists() + + self.assertEqual('DROP DATABASE "mydb"', str(q1)) + self.assertEqual('DROP DATABASE IF EXISTS "mydb"', str(q2)) + + def test_drop_table(self): + q1 = Query.drop_table(self.new_table) + q2 = Query.drop_table(self.new_table).if_exists() + + self.assertEqual('DROP TABLE "abc"', str(q1)) + self.assertEqual('DROP TABLE IF EXISTS "abc"', str(q2)) + + def test_drop_user(self): + q1 = Query.drop_user("myuser") + q2 = Query.drop_user("myuser").if_exists() + + self.assertEqual('DROP USER "myuser"', str(q1)) + self.assertEqual('DROP USER IF EXISTS "myuser"', str(q2)) + + def test_drop_view(self): + q1 = Query.drop_view("myview") + q2 = Query.drop_view("myview").if_exists() + + self.assertEqual('DROP VIEW "myview"', str(q1)) + self.assertEqual('DROP VIEW IF EXISTS "myview"', str(q2)) + + def test_drop_index(self): + q1 = Query.drop_index("myindex") + q2 = Query.drop_index("myindex").if_exists() + + self.assertEqual('DROP INDEX "myindex"', str(q1)) + self.assertEqual('DROP INDEX IF EXISTS "myindex"', str(q2)) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/test_formats.py b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/test_formats.py new file mode 100644 index 0000000000000000000000000000000000000000..6a442757c6659a215661e03f1ca9c3771d394d96 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/test_formats.py @@ -0,0 +1,68 @@ +import unittest + +from pypika import Query, Tables, functions as fn + + +class QuoteTests(unittest.TestCase): + maxDiff = None + + table_abc, table_efg = Tables("abc", "efg") + + def setUp(self): + subquery1 = ( + Query.from_(self.table_abc) + .select( + self.table_abc.foo, + fn.Sum(self.table_abc.fizz + self.table_abc.buzz).as_("fizzbuzz"), + ) + .groupby(self.table_abc.foo) + ) + + subquery2 = Query.from_(self.table_efg).select( + self.table_efg.foo.as_("foo_two"), + self.table_efg.bar, + ) + + self.query = ( + Query.from_(subquery1) + .select(subquery1.foo, subquery1.fizzbuzz) + .join(subquery2) + .on(subquery1.foo == subquery2.foo_two) + .select(subquery2.foo_two, subquery2.bar) + ) + + def test_replace_quote_char_in_complex_query(self): + self.assertEqual( + "SELECT " + "`sq0`.`foo`,`sq0`.`fizzbuzz`," + "`sq1`.`foo_two`,`sq1`.`bar` " + "FROM (" + "SELECT " + "`foo`,SUM(`fizz`+`buzz`) `fizzbuzz` " + "FROM `abc` " + "GROUP BY `foo`" + ") `sq0` JOIN (" + "SELECT " + "`foo` `foo_two`,`bar` " + "FROM `efg`" + ") `sq1` ON `sq0`.`foo`=`sq1`.`foo_two`", + self.query.get_sql(quote_char="`"), + ) + + def test_no_quote_char_in_complex_query(self): + self.assertEqual( + "SELECT " + "sq0.foo,sq0.fizzbuzz," + "sq1.foo_two,sq1.bar " + "FROM (" + "SELECT " + "foo,SUM(fizz+buzz) fizzbuzz " + "FROM abc " + "GROUP BY foo" + ") sq0 JOIN (" + "SELECT " + "foo foo_two,bar " + "FROM efg" + ") sq1 ON sq0.foo=sq1.foo_two", + self.query.get_sql(quote_char=None), + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/test_functions.py b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/test_functions.py new file mode 100644 index 0000000000000000000000000000000000000000..f526966eefc554ec68d0e15fb69de7d69f1604c3 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/test_functions.py @@ -0,0 +1,847 @@ +import unittest + +from pypika import ( + Case, + CaseException, + DatePart, + Field as F, + Query, + Query as Q, + Schema, + Table as T, + VerticaQuery, + functions as fn, +) +from pypika.enums import Dialects, SqlTypes + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + + +class FunctionTests(unittest.TestCase): + def test_dialect_propagation(self): + func = fn.Function("func", ["a"], ["b"]) + self.assertEqual("func(ARRAY['a'],ARRAY['b'])", func.get_sql(dialect=Dialects.POSTGRESQL)) + + def test_is_aggregate_None_for_non_aggregate_function_or_function_with_no_aggregate_functions(self): + self.assertIsNone(fn.Coalesce('a', 0).is_aggregate) + self.assertIsNone(fn.Coalesce(fn.NullIf('a', 0), 0).is_aggregate) + + def test_is_aggregate_True_for_aggregate_function_or_function_with_aggregate_functions(self): + self.assertTrue(fn.Sum('a').is_aggregate) + self.assertTrue(fn.Coalesce(fn.Avg('a'), 0).is_aggregate) + self.assertTrue(fn.Coalesce(fn.NullIf(fn.Sum('a'), 0), 0).is_aggregate) + + +class SchemaTests(unittest.TestCase): + def test_schema_no_schema_in_sql_when_none_set(self): + func = fn.Function("my_proc", 1, 2, 3) + + self.assertEqual("my_proc(1,2,3)", func.get_sql(quote_char='"')) + + def test_schema_included_in_function_sql(self): + a = Schema("a") + func = fn.Function("my_proc", 1, 2, 3, schema=a) + + self.assertEqual('"a".my_proc(1,2,3)', func.get_sql(quote_char='"')) + + +class ArithmeticTests(unittest.TestCase): + t = T("abc") + + def test__addition__fields(self): + q1 = Q.from_("abc").select(F("a") + F("b")) + q2 = Q.from_(self.t).select(self.t.a + self.t.b) + + self.assertEqual('SELECT "a"+"b" FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"+"b" FROM "abc"', str(q2)) + + def test__addition__number(self): + q1 = Q.from_("abc").select(F("a") + 1) + q2 = Q.from_(self.t).select(self.t.a + 1) + + self.assertEqual('SELECT "a"+1 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"+1 FROM "abc"', str(q2)) + + def test__addition__decimal(self): + q1 = Q.from_("abc").select(F("a") + 1.0) + q2 = Q.from_(self.t).select(self.t.a + 1.0) + + self.assertEqual('SELECT "a"+1.0 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"+1.0 FROM "abc"', str(q2)) + + def test__addition__right(self): + q1 = Q.from_("abc").select(1 + F("a")) + q2 = Q.from_(self.t).select(1 + self.t.a) + + self.assertEqual('SELECT 1+"a" FROM "abc"', str(q1)) + self.assertEqual('SELECT 1+"a" FROM "abc"', str(q2)) + + def test__subtraction__fields(self): + q1 = Q.from_("abc").select(F("a") - F("b")) + q2 = Q.from_(self.t).select(self.t.a - self.t.b) + + self.assertEqual('SELECT "a"-"b" FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"-"b" FROM "abc"', str(q2)) + + def test__subtraction__number(self): + q1 = Q.from_("abc").select(F("a") - 1) + q2 = Q.from_(self.t).select(self.t.a - 1) + + self.assertEqual('SELECT "a"-1 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"-1 FROM "abc"', str(q2)) + + def test__subtraction__decimal(self): + q1 = Q.from_("abc").select(F("a") - 1.0) + q2 = Q.from_(self.t).select(self.t.a - 1.0) + + self.assertEqual('SELECT "a"-1.0 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"-1.0 FROM "abc"', str(q2)) + + def test__subtraction__right(self): + q1 = Q.from_("abc").select(1 - F("a")) + q2 = Q.from_(self.t).select(1 - self.t.a) + + self.assertEqual('SELECT 1-"a" FROM "abc"', str(q1)) + self.assertEqual('SELECT 1-"a" FROM "abc"', str(q2)) + + def test__multiplication__fields(self): + q1 = Q.from_("abc").select(F("a") * F("b")) + q2 = Q.from_(self.t).select(self.t.a * self.t.b) + + self.assertEqual('SELECT "a"*"b" FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"*"b" FROM "abc"', str(q2)) + + def test__multiplication__number(self): + q1 = Q.from_("abc").select(F("a") * 1) + q2 = Q.from_(self.t).select(self.t.a * 1) + + self.assertEqual('SELECT "a"*1 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"*1 FROM "abc"', str(q2)) + + def test__multiplication__decimal(self): + q1 = Q.from_("abc").select(F("a") * 1.0) + q2 = Q.from_(self.t).select(self.t.a * 1.0) + + self.assertEqual('SELECT "a"*1.0 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"*1.0 FROM "abc"', str(q2)) + + def test__multiplication__right(self): + q1 = Q.from_("abc").select(1 * F("a")) + q2 = Q.from_(self.t).select(1 * self.t.a) + + self.assertEqual('SELECT 1*"a" FROM "abc"', str(q1)) + self.assertEqual('SELECT 1*"a" FROM "abc"', str(q2)) + + def test__division__fields(self): + q1 = Q.from_("abc").select(F("a") / F("b")) + q2 = Q.from_(self.t).select(self.t.a / self.t.b) + + self.assertEqual('SELECT "a"/"b" FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"/"b" FROM "abc"', str(q2)) + + def test__division__number(self): + q1 = Q.from_("abc").select(F("a") / 1) + q2 = Q.from_(self.t).select(self.t.a / 1) + + self.assertEqual('SELECT "a"/1 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"/1 FROM "abc"', str(q2)) + + def test__division__decimal(self): + q1 = Q.from_("abc").select(F("a") / 1.0) + q2 = Q.from_(self.t).select(self.t.a / 1.0) + + self.assertEqual('SELECT "a"/1.0 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"/1.0 FROM "abc"', str(q2)) + + def test__division__right(self): + q1 = Q.from_("abc").select(1 / F("a")) + q2 = Q.from_(self.t).select(1 / self.t.a) + + self.assertEqual('SELECT 1/"a" FROM "abc"', str(q1)) + self.assertEqual('SELECT 1/"a" FROM "abc"', str(q2)) + + def test__leftshift__fields(self): + q1 = Q.from_("abc").select(F("a") << F("b")) + q2 = Q.from_(self.t).select(self.t.a << self.t.b) + + self.assertEqual('SELECT "a"<<"b" FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"<<"b" FROM "abc"', str(q2)) + + def test__leftshift__number(self): + q1 = Q.from_("abc").select(F('a') << 2) + q2 = Q.from_(self.t).select(self.t.a << 2) + + self.assertEqual('SELECT "a"<<2 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"<<2 FROM "abc"', str(q2)) + + def test__leftshift__right(self): + q1 = Q.from_("abc").select(1 << F("a")) + q2 = Q.from_(self.t).select(1 << self.t.a) + + self.assertEqual('SELECT 1<<"a" FROM "abc"', str(q1)) + self.assertEqual('SELECT 1<<"a" FROM "abc"', str(q2)) + + def test__rightshift__fields(self): + q1 = Q.from_("abc").select(F("a") >> F("b")) + q2 = Q.from_(self.t).select(self.t.a >> self.t.b) + + self.assertEqual('SELECT "a">>"b" FROM "abc"', str(q1)) + self.assertEqual('SELECT "a">>"b" FROM "abc"', str(q2)) + + def test__rightshift__number(self): + q1 = Q.from_("abc").select(F('a') >> 2) + q2 = Q.from_(self.t).select(self.t.a >> 2) + + self.assertEqual('SELECT "a">>2 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a">>2 FROM "abc"', str(q2)) + + def test__rightshift__right(self): + q1 = Q.from_("abc").select(1 >> F("a")) + q2 = Q.from_(self.t).select(1 >> self.t.a) + + self.assertEqual('SELECT 1>>"a" FROM "abc"', str(q1)) + self.assertEqual('SELECT 1>>"a" FROM "abc"', str(q2)) + + def test__complex_op(self): + q1 = Q.from_("abc").select(2 + 1 / F("a") - 5) + q2 = Q.from_(self.t).select(2 + 1 / self.t.a - 5) + + self.assertEqual('SELECT 2+1/"a"-5 FROM "abc"', str(q1)) + self.assertEqual('SELECT 2+1/"a"-5 FROM "abc"', str(q2)) + + def test__complex_op_add_parentheses(self): + q1 = Q.from_("abc").select((F("a") + 1) + (F("b") - 5)) + q2 = Q.from_(self.t).select((self.t.a + 1) + (self.t.b - 5)) + q3 = Q.from_("abc").select((F("a") / 1) + (F("b") / 5)) + q4 = Q.from_(self.t).select((self.t.a / 1) + (self.t.b / 5)) + + self.assertEqual('SELECT "a"+1+"b"-5 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"+1+"b"-5 FROM "abc"', str(q2)) + self.assertEqual('SELECT "a"/1+"b"/5 FROM "abc"', str(q3)) + self.assertEqual('SELECT "a"/1+"b"/5 FROM "abc"', str(q4)) + + def test__complex_op_sub_parentheses(self): + q1 = Q.from_("abc").select((F("a") + 1) - (F("b") - 5)) + q2 = Q.from_(self.t).select((self.t.a + 1) - (self.t.b - 5)) + q3 = Q.from_("abc").select((F("a") / 1) - (F("b") / 5)) + q4 = Q.from_(self.t).select((self.t.a / 1) - (self.t.b / 5)) + + self.assertEqual('SELECT "a"+1-("b"-5) FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"+1-("b"-5) FROM "abc"', str(q2)) + self.assertEqual('SELECT "a"/1-"b"/5 FROM "abc"', str(q3)) + self.assertEqual('SELECT "a"/1-"b"/5 FROM "abc"', str(q4)) + + def test__complex_op_mul_parentheses(self): + q1 = Q.from_("abc").select((F("a") + 1) * (F("b") - 5)) + q2 = Q.from_(self.t).select((self.t.a + 1) * (self.t.b - 5)) + q3 = Q.from_("abc").select((F("a") / 1) * (F("b") - 5)) + q4 = Q.from_(self.t).select((self.t.a / 1) * (self.t.b - 5)) + q5 = Q.from_("abc").select((F("a") + 1) * (F("b") / 5)) + q6 = Q.from_(self.t).select((self.t.a + 1) * (self.t.b / 5)) + + self.assertEqual('SELECT ("a"+1)*("b"-5) FROM "abc"', str(q1)) + self.assertEqual('SELECT ("a"+1)*("b"-5) FROM "abc"', str(q2)) + self.assertEqual('SELECT "a"/1*("b"-5) FROM "abc"', str(q3)) + self.assertEqual('SELECT "a"/1*("b"-5) FROM "abc"', str(q4)) + self.assertEqual('SELECT ("a"+1)*"b"/5 FROM "abc"', str(q5)) + self.assertEqual('SELECT ("a"+1)*"b"/5 FROM "abc"', str(q6)) + + def test__complex_op_mul_no_parentheses(self): + q = Q.from_("abc").select(F("a") + 1 * F("b") - 5) + + self.assertEqual('SELECT "a"+1*"b"-5 FROM "abc"', str(q)) + + def test__complex_op_div_parentheses(self): + q1 = Q.from_("abc").select((F("a") + 1) / (F("b") - 5)) + q2 = Q.from_(self.t).select((self.t.a + 1) / (self.t.b - 5)) + q3 = Q.from_("abc").select((F("a") / 1) / (F("b") - 5)) + q4 = Q.from_(self.t).select((self.t.a / 1) / (self.t.b - 5)) + q5 = Q.from_("abc").select((F("a") + 1) / (F("b") * 5)) + q6 = Q.from_(self.t).select((self.t.a + 1) / (self.t.b * 5)) + + self.assertEqual('SELECT ("a"+1)/("b"-5) FROM "abc"', str(q1)) + self.assertEqual('SELECT ("a"+1)/("b"-5) FROM "abc"', str(q2)) + self.assertEqual('SELECT "a"/1/("b"-5) FROM "abc"', str(q3)) + self.assertEqual('SELECT "a"/1/("b"-5) FROM "abc"', str(q4)) + self.assertEqual('SELECT ("a"+1)/("b"*5) FROM "abc"', str(q5)) + self.assertEqual('SELECT ("a"+1)/("b"*5) FROM "abc"', str(q6)) + + def test__complex_op_div_no_parentheses(self): + q = Q.from_("abc").select(F("a") + 1 / F("b") - 5) + + self.assertEqual('SELECT "a"+1/"b"-5 FROM "abc"', str(q)) + + def test__complex_op_exponent_parentheses(self): + q1 = Q.from_("abc").select(F("a") / (F("b") ** 2)) + q2 = Q.from_(self.t).select(self.t.a / (self.t.b**2)) + q3 = Q.from_("abc").select(F("a") ** (F("b") / 2)) + q4 = Q.from_(self.t).select(self.t.a ** (self.t.b / 2)) + q5 = Q.from_("abc").select((F("a") ** F("b")) ** 2) + q6 = Q.from_(self.t).select((self.t.a**self.t.b) ** 2) + + self.assertEqual('SELECT "a"/POW("b",2) FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"/POW("b",2) FROM "abc"', str(q2)) + self.assertEqual('SELECT POW("a","b"/2) FROM "abc"', str(q3)) + self.assertEqual('SELECT POW("a","b"/2) FROM "abc"', str(q4)) + self.assertEqual('SELECT POW(POW("a","b"),2) FROM "abc"', str(q5)) + self.assertEqual('SELECT POW(POW("a","b"),2) FROM "abc"', str(q6)) + + def test__complex_op_exponent_no_parentheses(self): + q1 = Q.from_("abc").select(F("a") ** F("b") ** 2) + q2 = Q.from_(self.t).select(self.t.a**self.t.b**2) + q3 = Q.from_("abc").select(F("a") / F("b") ** 2) + q4 = Q.from_(self.t).select(self.t.a / self.t.b**2) + + self.assertEqual('SELECT POW("a",POW("b",2)) FROM "abc"', str(q1)) + self.assertEqual('SELECT POW("a",POW("b",2)) FROM "abc"', str(q2)) + self.assertEqual('SELECT "a"/POW("b",2) FROM "abc"', str(q3)) + self.assertEqual('SELECT "a"/POW("b",2) FROM "abc"', str(q4)) + + def test__complex_op_function_parentheses(self): + q1 = Q.from_("abc").select(F("a") / (fn.Sum(F("b")) / 2)) + q2 = Q.from_("abc").select(self.t.a / (fn.Sum(self.t.b) / 2)) + q3 = Q.from_("abc").select(fn.Sum(F("a") / (F("b") / 2))) + q4 = Q.from_("abc").select(fn.Sum(self.t.a / (self.t.b / 2))) + + self.assertEqual('SELECT "a"/(SUM("b")/2) FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"/(SUM("b")/2) FROM "abc"', str(q2)) + self.assertEqual('SELECT SUM("a"/("b"/2)) FROM "abc"', str(q3)) + self.assertEqual('SELECT SUM("a"/("b"/2)) FROM "abc"', str(q4)) + + def test__complex_op_modulus_parentheses(self): + q1 = Q.from_("abc").select(F("a") / (F("b") % 2)) + q2 = Q.from_(self.t).select(self.t.a / (self.t.b % 2)) + q3 = Q.from_("abc").select(F("a") % (F("b") / 2)) + q4 = Q.from_(self.t).select(self.t.a % (self.t.b / 2)) + q5 = Q.from_("abc").select(F("a") % (F("b") % 2)) + q6 = Q.from_("abc").select(self.t.a % (self.t.b % 2)) + + self.assertEqual('SELECT "a"/MOD("b",2) FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"/MOD("b",2) FROM "abc"', str(q2)) + self.assertEqual('SELECT MOD("a","b"/2) FROM "abc"', str(q3)) + self.assertEqual('SELECT MOD("a","b"/2) FROM "abc"', str(q4)) + self.assertEqual('SELECT MOD("a",MOD("b",2)) FROM "abc"', str(q5)) + self.assertEqual('SELECT MOD("a",MOD("b",2)) FROM "abc"', str(q6)) + + def test__complex_op_modulus_no_parentheses(self): + q1 = Q.from_("abc").select(F("a") % F("b") % 2) + q2 = Q.from_(self.t).select(self.t.a % self.t.b % 2) + q3 = Q.from_("abc").select(F("a") / F("b") % 2) + q4 = Q.from_(self.t).select(self.t.a / self.t.b % 2) + + self.assertEqual('SELECT MOD(MOD("a","b"),2) FROM "abc"', str(q1)) + self.assertEqual('SELECT MOD(MOD("a","b"),2) FROM "abc"', str(q2)) + self.assertEqual('SELECT MOD("a"/"b",2) FROM "abc"', str(q3)) + self.assertEqual('SELECT MOD("a"/"b",2) FROM "abc"', str(q4)) + + def test__complex_op_floor_parentheses(self): + q1 = Q.from_("abc").select(F("a") / (fn.Floor(F("b")) / 2)) + q2 = Q.from_("abc").select(self.t.a / (fn.Floor(self.t.b) / 2)) + q3 = Q.from_("abc").select(fn.Floor(F("a") / (F("b") / 2))) + q4 = Q.from_("abc").select(fn.Floor(self.t.a / (self.t.b / 2))) + + self.assertEqual('SELECT "a"/(FLOOR("b")/2) FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"/(FLOOR("b")/2) FROM "abc"', str(q2)) + self.assertEqual('SELECT FLOOR("a"/("b"/2)) FROM "abc"', str(q3)) + self.assertEqual('SELECT FLOOR("a"/("b"/2)) FROM "abc"', str(q4)) + + def test__complex_op_nested_parentheses(self): + q1 = Q.from_("abc").select(F("a") / (F("b") / ((F("c") / 2)))) + q2 = Q.from_("abc").select(self.t.a / (self.t.b / ((self.t.c / 2)))) + + self.assertEqual('SELECT "a"/("b"/("c"/2)) FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"/("b"/("c"/2)) FROM "abc"', str(q2)) + + def test__arithmetic_equality(self): + q1 = Q.from_("abc").select(F("a") / 2 == 2) + q2 = Q.from_(self.t).select(self.t.a / 2 == 2) + + self.assertEqual('SELECT "a"/2=2 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"/2=2 FROM "abc"', str(q2)) + + def test__arithmetic_with_function(self): + q1 = Q.from_("abc").select(fn.Sum(F("foo")) + 1) + q2 = Q.from_(self.t).select(fn.Sum(self.t.foo) + 1) + + self.assertEqual('SELECT SUM("foo")+1 FROM "abc"', str(q1)) + self.assertEqual('SELECT SUM("foo")+1 FROM "abc"', str(q2)) + + def test__exponent__number(self): + q1 = Q.from_("abc").select(F("a") ** 2) + q2 = Q.from_(self.t).select(self.t.a**2) + + self.assertEqual('SELECT POW("a",2) FROM "abc"', str(q1)) + self.assertEqual('SELECT POW("a",2) FROM "abc"', str(q2)) + + def test__exponent__decimal(self): + q1 = Q.from_("abc").select(F("a") ** 0.5) + q2 = Q.from_(self.t).select(self.t.a**0.5) + + self.assertEqual('SELECT POW("a",0.5) FROM "abc"', str(q1)) + self.assertEqual('SELECT POW("a",0.5) FROM "abc"', str(q2)) + + def test__modulus__number(self): + q1 = Q.from_("abc").select(F("a") % 2) + q2 = Q.from_(self.t).select(self.t.a % 2) + + self.assertEqual('SELECT MOD("a",2) FROM "abc"', str(q1)) + self.assertEqual('SELECT MOD("a",2) FROM "abc"', str(q2)) + + def test__floor(self): + q1 = Q.from_("abc").select(fn.Floor(F("foo"))) + q2 = Q.from_(self.t).select(fn.Floor(self.t.foo)) + + self.assertEqual('SELECT FLOOR("foo") FROM "abc"', str(q1)) + self.assertEqual('SELECT FLOOR("foo") FROM "abc"', str(q2)) + + +class AggregationTests(unittest.TestCase): + def test__count(self): + q = Q.from_("abc").select(fn.Count(F("foo"))) + + self.assertEqual('SELECT COUNT("foo") FROM "abc"', str(q)) + + def test__count__star(self): + q = Q.from_("abc").select(fn.Count("*")) + + self.assertEqual('SELECT COUNT(*) FROM "abc"', str(q)) + + def test__sum(self): + q = Q.from_("abc").select(fn.Sum(F("foo"))) + + self.assertEqual('SELECT SUM("foo") FROM "abc"', str(q)) + + def test__avg(self): + q = Q.from_("abc").select(fn.Avg(F("foo"))) + + self.assertEqual('SELECT AVG("foo") FROM "abc"', str(q)) + + def test__first(self): + q = Q.from_("abc").select(fn.First(F("foo"))) + + self.assertEqual('SELECT FIRST("foo") FROM "abc"', str(q)) + + def test__last(self): + q = Q.from_("abc").select(fn.Last(F("foo"))) + + self.assertEqual('SELECT LAST("foo") FROM "abc"', str(q)) + + def test__min(self): + q = Q.from_("abc").select(fn.Min(F("foo"))) + + self.assertEqual('SELECT MIN("foo") FROM "abc"', str(q)) + + def test__max(self): + q = Q.from_("abc").select(fn.Max(F("foo"))) + + self.assertEqual('SELECT MAX("foo") FROM "abc"', str(q)) + + def test__std(self): + q = Q.from_("abc").select(fn.Std(F("foo"))) + + self.assertEqual('SELECT STD("foo") FROM "abc"', str(q)) + + def test__stddev(self): + q = Q.from_("abc").select(fn.StdDev(F("foo"))) + + self.assertEqual('SELECT STDDEV("foo") FROM "abc"', str(q)) + + def test__approx_percentile(self): + q = Q.from_("abc").select(fn.ApproximatePercentile(F("foo"), 0.5)) + + self.assertEqual( + 'SELECT APPROXIMATE_PERCENTILE("foo" USING PARAMETERS percentile=0.5) FROM "abc"', + str(q), + ) + + def test__subquery_in_params_functions(self): + subquery = Query.from_('table').select('id') + func = fn.Function('func', 'id', subquery) + self.assertEqual("func('id',(SELECT id FROM table))", func.get_sql()) + + +class ConditionTests(unittest.TestCase): + def test__case__raw(self): + q = Q.from_("abc").select(Case().when(F("foo") == 1, "a")) + + self.assertEqual('SELECT CASE WHEN "foo"=1 THEN \'a\' END FROM "abc"', str(q)) + + def test__case__else(self): + q = Q.from_("abc").select(Case().when(F("foo") == 1, "a").else_("b")) + + self.assertEqual("SELECT CASE WHEN \"foo\"=1 THEN 'a' ELSE 'b' END FROM \"abc\"", str(q)) + + def test__case__field(self): + q = Q.from_("abc").select(Case().when(F("foo") == 1, F("bar")).else_(F("buz"))) + + self.assertEqual('SELECT CASE WHEN "foo"=1 THEN "bar" ELSE "buz" END FROM "abc"', str(q)) + + def test__case__multi(self): + q = Q.from_("abc").select(Case().when(F("foo") > 0, F("fiz")).when(F("bar") <= 0, F("buz")).else_(1)) + + self.assertEqual( + 'SELECT CASE WHEN "foo">0 THEN "fiz" WHEN "bar"<=0 THEN "buz" ELSE 1 END FROM "abc"', + str(q), + ) + + def test__case__no_cases(self): + with self.assertRaises(CaseException): + q = Q.from_("abc").select(Case()) + + str(q) + + +class StringTests(unittest.TestCase): + t = T("abc") + + def test__ascii__str(self): + q = Q.select(fn.Ascii("2")) + + self.assertEqual("SELECT ASCII('2')", str(q)) + + def test__ascii__int(self): + q = Q.select(fn.Ascii(2)) + + self.assertEqual("SELECT ASCII(2)", str(q)) + + def test__ascii__field(self): + q = Q.from_(self.t).select(fn.Ascii(self.t.foo)) + + self.assertEqual('SELECT ASCII("foo") FROM "abc"', str(q)) + + def test__bin__str(self): + q = Q.select(fn.Bin("2")) + + self.assertEqual("SELECT BIN('2')", str(q)) + + def test__bin__int(self): + q = Q.select(fn.Bin(2)) + + self.assertEqual("SELECT BIN(2)", str(q)) + + def test__bin__field(self): + q = Q.from_(self.t).select(fn.Bin(self.t.foo)) + + self.assertEqual('SELECT BIN("foo") FROM "abc"', str(q)) + + def test__concat__str(self): + q = Q.select(fn.Concat("p", "y", "q", "b")) + + self.assertEqual("SELECT CONCAT('p','y','q','b')", str(q)) + + def test__concat__field(self): + q = Q.from_(self.t).select(fn.Concat(self.t.foo, self.t.bar)) + + self.assertEqual('SELECT CONCAT("foo","bar") FROM "abc"', str(q)) + + def test__insert__str(self): + q = Q.select(fn.Insert("Quadratic", 3, 4, "What")) + + self.assertEqual("SELECT INSERT('Quadratic',3,4,'What')", str(q)) + + def test__insert__field(self): + q = Q.from_(self.t).select(fn.Insert(self.t.foo, 3, 4, self.t.bar)) + + self.assertEqual('SELECT INSERT("foo",3,4,"bar") FROM "abc"', str(q)) + + def test__lower__str(self): + q = Q.select(fn.Lower("ABC")) + + self.assertEqual("SELECT LOWER('ABC')", str(q)) + + def test__lower__field(self): + q = Q.from_(self.t).select(fn.Lower(self.t.foo)) + + self.assertEqual('SELECT LOWER("foo") FROM "abc"', str(q)) + + def test__length__str(self): + q = Q.select(fn.Length("ABC")) + + self.assertEqual("SELECT LENGTH('ABC')", str(q)) + + def test__length__field(self): + q = Q.from_(self.t).select(fn.Length(self.t.foo)) + + self.assertEqual('SELECT LENGTH("foo") FROM "abc"', str(q)) + + def test__substring(self): + q = Q.from_(self.t).select(fn.Substring(self.t.foo, 2, 6)) + + self.assertEqual('SELECT SUBSTRING("foo",2,6) FROM "abc"', str(q)) + + def test__replace__str(self): + q = Q.select(fn.Replace("ABC_DEF", "_", " ")) + self.assertEqual("SELECT REPLACE('ABC_DEF','_',' ')", str(q)) + + def test__replace__field(self): + q = Q.from_(self.t).select(fn.Replace(self.t.foobar, self.t.foo, self.t.bar)) + self.assertEqual('SELECT REPLACE("foobar","foo","bar") FROM "abc"', str(q)) + + +class SplitPartFunctionTests(unittest.TestCase): + t = T("abc") + + def test__split_part(self): + q = VerticaQuery.from_(self.t).select(fn.SplitPart(self.t.foo, "|", 3)) + + self.assertEqual('SELECT SPLIT_PART("foo",\'|\',3) FROM "abc"', str(q)) + + +class RegexpLikeFunctionTests(unittest.TestCase): + t = T("abc") + + def test__regexp_like(self): + q = VerticaQuery.from_(self.t).select(fn.RegexpLike(self.t.foo, "^a", "x")) + + self.assertEqual("SELECT REGEXP_LIKE(\"foo\",'^a','x') FROM \"abc\"", str(q)) + + +class CastTests(unittest.TestCase): + t = T("abc") + + def test__cast__as(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.UNSIGNED)) + + self.assertEqual('SELECT CAST("foo" AS UNSIGNED) FROM "abc"', str(q)) + + def test__cast__signed(self): + q1 = Q.from_(self.t).select(fn.Signed(self.t.foo)) + q2 = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.SIGNED)) + + self.assertEqual('SELECT CAST("foo" AS SIGNED) FROM "abc"', str(q1)) + self.assertEqual('SELECT CAST("foo" AS SIGNED) FROM "abc"', str(q2)) + + def test__cast__unsigned(self): + q1 = Q.from_(self.t).select(fn.Unsigned(self.t.foo)) + q2 = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.UNSIGNED)) + + self.assertEqual('SELECT CAST("foo" AS UNSIGNED) FROM "abc"', str(q1)) + self.assertEqual('SELECT CAST("foo" AS UNSIGNED) FROM "abc"', str(q2)) + + def test__cast__date(self): + q1 = Q.from_(self.t).select(fn.Date(self.t.foo)) + q2 = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.DATE)) + + self.assertEqual('SELECT DATE("foo") FROM "abc"', str(q1)) + self.assertEqual('SELECT CAST("foo" AS DATE) FROM "abc"', str(q2)) + + def test__cast__timestamp(self): + q1 = Q.from_(self.t).select(fn.Timestamp(self.t.foo)) + q2 = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.TIMESTAMP)) + + self.assertEqual('SELECT TIMESTAMP("foo") FROM "abc"', str(q1)) + self.assertEqual('SELECT CAST("foo" AS TIMESTAMP) FROM "abc"', str(q2)) + + def test__cast__char(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.CHAR)) + + self.assertEqual('SELECT CAST("foo" AS CHAR) FROM "abc"', str(q)) + + def test__cast__char_with_arg(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.VARCHAR(24))) + + self.assertEqual('SELECT CAST("foo" AS VARCHAR(24)) FROM "abc"', str(q)) + + def test__cast__varchar(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.VARCHAR)) + + self.assertEqual('SELECT CAST("foo" AS VARCHAR) FROM "abc"', str(q)) + + def test__cast__varchar_with_arg(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.VARCHAR(24))) + + self.assertEqual('SELECT CAST("foo" AS VARCHAR(24)) FROM "abc"', str(q)) + + def test__cast__long_varchar(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.LONG_VARCHAR)) + + self.assertEqual('SELECT CAST("foo" AS LONG VARCHAR) FROM "abc"', str(q)) + + def test__cast__long_varchar_with_arg(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.LONG_VARCHAR(24))) + + self.assertEqual('SELECT CAST("foo" AS LONG VARCHAR(24)) FROM "abc"', str(q)) + + def test__cast__binary(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.BINARY)) + + self.assertEqual('SELECT CAST("foo" AS BINARY) FROM "abc"', str(q)) + + def test__cast__binary_with_arg(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.BINARY(24))) + + self.assertEqual('SELECT CAST("foo" AS BINARY(24)) FROM "abc"', str(q)) + + def test__cast__varbinary(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.VARBINARY)) + + self.assertEqual('SELECT CAST("foo" AS VARBINARY) FROM "abc"', str(q)) + + def test__cast__varbinary_with_arg(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.VARBINARY(24))) + + self.assertEqual('SELECT CAST("foo" AS VARBINARY(24)) FROM "abc"', str(q)) + + def test__cast__long_varbinary(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.LONG_VARBINARY)) + + self.assertEqual('SELECT CAST("foo" AS LONG VARBINARY) FROM "abc"', str(q)) + + def test__cast__long_varbinary_with_arg(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.LONG_VARBINARY(24))) + + self.assertEqual('SELECT CAST("foo" AS LONG VARBINARY(24)) FROM "abc"', str(q)) + + def test__cast__boolean(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.BOOLEAN)) + + self.assertEqual('SELECT CAST("foo" AS BOOLEAN) FROM "abc"', str(q)) + + def test__cast__integer(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.INTEGER)) + + self.assertEqual('SELECT CAST("foo" AS INTEGER) FROM "abc"', str(q)) + + def test__cast__float(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.FLOAT)) + + self.assertEqual('SELECT CAST("foo" AS FLOAT) FROM "abc"', str(q)) + + def test__cast__numeric(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.NUMERIC)) + + self.assertEqual('SELECT CAST("foo" AS NUMERIC) FROM "abc"', str(q)) + + def test__tochar__(self): + q = Q.from_(self.t).select(fn.ToChar(self.t.foo, "SomeFormat")) + + self.assertEqual('SELECT TO_CHAR("foo",\'SomeFormat\') FROM "abc"', str(q)) + + +class DateFunctionsTests(unittest.TestCase): + dt = F("dt") + t = T("abc") + t2 = T("efg") + + def _test_extract_datepart(self, date_part): + q = Q.from_(self.t).select(fn.Extract(date_part, self.t.foo)) + + value = getattr(date_part, 'value', date_part) + self.assertEqual('SELECT EXTRACT(%s FROM "foo") FROM "abc"' % value, str(q)) + + def test_extract_microsecond(self): + self._test_extract_datepart(DatePart.microsecond) + self._test_extract_datepart(DatePart.microsecond.value) + + def test_extract_second(self): + self._test_extract_datepart(DatePart.second) + self._test_extract_datepart(DatePart.second.value) + + def test_extract_minute(self): + self._test_extract_datepart(DatePart.minute) + self._test_extract_datepart(DatePart.minute.value) + + def test_extract_hour(self): + self._test_extract_datepart(DatePart.hour) + self._test_extract_datepart(DatePart.hour.value) + + def test_extract_day(self): + self._test_extract_datepart(DatePart.day) + self._test_extract_datepart(DatePart.day.value) + + def test_extract_week(self): + self._test_extract_datepart(DatePart.week) + self._test_extract_datepart(DatePart.week.value) + + def test_extract_month(self): + self._test_extract_datepart(DatePart.month) + self._test_extract_datepart(DatePart.month.value) + + def test_extract_quarter(self): + self._test_extract_datepart(DatePart.quarter) + self._test_extract_datepart(DatePart.quarter.value) + + def test_extract_year(self): + self._test_extract_datepart(DatePart.year) + self._test_extract_datepart(DatePart.year.value) + + def test_extract_join(self): + q = Q.from_(self.t).join(self.t2).on(self.t.id == self.t2.t_id).select(fn.Extract(DatePart.year, self.t.foo)) + + self.assertEqual( + 'SELECT EXTRACT(YEAR FROM "abc"."foo") FROM "abc" ' 'JOIN "efg" ON "abc"."id"="efg"."t_id"', str(q) + ) + + def test_timestampadd(self): + a = fn.TimestampAdd("year", 1, "2017-10-01") + self.assertEqual(str(a), "TIMESTAMPADD(year,1,'2017-10-01')") + + def test_time_diff(self): + a = fn.TimeDiff("18:00:00", "10:00:00") + self.assertEqual(str(a), "TIMEDIFF('18:00:00','10:00:00')") + + def test_date_add(self): + a = fn.DateAdd("year", 1, "2017-10-01") + self.assertEqual(str(a), "DATE_ADD(year,1,'2017-10-01')") + + def test_now(self): + query = Query.select(fn.Now()) + + self.assertEqual("SELECT NOW()", str(query)) + + def test_utc_timestamp(self): + query = Query.select(fn.UtcTimestamp()) + + self.assertEqual("SELECT UTC_TIMESTAMP()", str(query)) + + def test_current_date(self): + query = Query.select(fn.CurDate()) + + self.assertEqual("SELECT CURRENT_DATE()", str(query)) + + def test_current_time(self): + query = Query.select(fn.CurTime()) + + self.assertEqual("SELECT CURRENT_TIME()", str(query)) + + def test_current_timestamp(self): + query = Query.select(fn.CurTimestamp()) + + self.assertEqual("SELECT CURRENT_TIMESTAMP", str(query)) + + def test_current_timestamp_with_alias(self): + query = Query.select(fn.CurTimestamp("ts")) + + self.assertEqual('SELECT CURRENT_TIMESTAMP "ts"', str(query)) + + def test_to_date(self): + q1 = fn.ToDate("2019-06-21", "yyyy-mm-dd") + q2 = Query.from_(self.t).select(fn.ToDate("2019-06-21", "yyyy-mm-dd")) + q3 = Query.from_(self.t).select(fn.ToDate(F("foo"), "yyyy-mm-dd")) + + self.assertEqual(str(q1), "TO_DATE('2019-06-21','yyyy-mm-dd')") + self.assertEqual(str(q2), "SELECT TO_DATE('2019-06-21','yyyy-mm-dd') FROM \"abc\"") + self.assertEqual(str(q3), 'SELECT TO_DATE("foo",\'yyyy-mm-dd\') FROM "abc"') + + +class NullFunctionsTests(unittest.TestCase): + def test_isnull(self): + q = Q.from_("abc").select(fn.IsNull(F("foo"))) + + self.assertEqual('SELECT ISNULL("foo") FROM "abc"', str(q)) + + def test_coalesce(self): + q = Q.from_("abc").select(fn.Coalesce(F("foo"), 0)) + + self.assertEqual('SELECT COALESCE("foo",0) FROM "abc"', str(q)) + + def test_nullif(self): + q = Q.from_("abc").select(fn.NullIf(F("foo"), 0)) + + self.assertEqual('SELECT NULLIF("foo",0) FROM "abc"', str(q)) + + def test_nvl(self): + q = Q.from_("abc").select(fn.NVL(F("foo"), 0)) + + self.assertEqual('SELECT NVL("foo",0) FROM "abc"', str(q)) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/test_groupby_modifiers.py b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/test_groupby_modifiers.py new file mode 100644 index 0000000000000000000000000000000000000000..978834c2409f4b4800fedb9b1bb2538a31d0f31c --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/test_groupby_modifiers.py @@ -0,0 +1,168 @@ +import unittest + +from pypika import Query, Rollup, RollupException, Table, functions as fn + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + + +class RollupTests(unittest.TestCase): + table = Table("abc") + + def test_mysql_one_groupby(self): + q = ( + Query.from_(self.table) + .select(self.table.foo, fn.Sum(self.table.bar)) + .rollup(self.table.foo, vendor="mysql") + ) + + self.assertEqual('SELECT "foo",SUM("bar") FROM "abc" GROUP BY "foo" WITH ROLLUP', str(q)) + + def test_mysql_rollup_two_groupbys(self): + q = ( + Query.from_(self.table) + .select(self.table.foo, self.table.fiz, fn.Sum(self.table.bar)) + .rollup(self.table.foo, self.table.fiz, vendor="mysql") + ) + + self.assertEqual( + 'SELECT "foo","fiz",SUM("bar") FROM "abc" GROUP BY "foo","fiz" WITH ROLLUP', + str(q), + ) + + def test_no_rollup_before_groupby(self): + with self.assertRaises(RollupException): + Query.from_(self.table).select(self.table.foo, fn.Sum(self.table.bar)).rollup(vendor="mysql") + + def test_no_rollup_after_rollup_mysql(self): + with self.assertRaises(AttributeError): + Query.from_(self.table).select(self.table.foo, self.table.fiz, fn.Sum(self.table.bar)).rollup( + self.table.foo, vendor="mysql" + ).rollup(self.table.fiz, vendor="mysql") + + def test_verticaoracle_func_one_groupby(self): + q = Query.from_(self.table).select(self.table.foo, fn.Sum(self.table.bar)).groupby(Rollup(self.table.foo)) + + self.assertEqual('SELECT "foo",SUM("bar") FROM "abc" GROUP BY ROLLUP("foo")', str(q)) + + def test_verticaoracle_func_two_groupbys(self): + q = ( + Query.from_(self.table) + .select(self.table.foo, self.table.fiz, fn.Sum(self.table.bar)) + .groupby( + Rollup( + self.table.foo, + self.table.fiz, + ) + ) + ) + + self.assertEqual( + 'SELECT "foo","fiz",SUM("bar") FROM "abc" GROUP BY ROLLUP("foo","fiz")', + str(q), + ) + + def test_verticaoracle_func_partial(self): + q = ( + Query.from_(self.table) + .select(self.table.foo, self.table.fiz, self.table.buz, fn.Sum(self.table.bar)) + .groupby( + Rollup( + self.table.foo, + self.table.fiz, + ), + self.table.buz, + ) + ) + + self.assertEqual( + 'SELECT "foo","fiz","buz",SUM("bar") FROM "abc" GROUP BY ROLLUP("foo","fiz"),"buz"', + str(q), + ) + + def test_verticaoracle_from_groupbys(self): + q = Query.from_(self.table).select(self.table.foo, fn.Sum(self.table.bar)).rollup(self.table.foo) + + self.assertEqual('SELECT "foo",SUM("bar") FROM "abc" GROUP BY ROLLUP("foo")', str(q)) + + def test_verticaoracle_from_two_groupbys(self): + q = ( + Query.from_(self.table) + .select(self.table.foo, self.table.fiz, fn.Sum(self.table.bar)) + .rollup( + self.table.foo, + self.table.fiz, + ) + ) + + self.assertEqual( + 'SELECT "foo","fiz",SUM("bar") FROM "abc" GROUP BY ROLLUP("foo","fiz")', + str(q), + ) + + def test_verticaoracle_from_parameters(self): + q = ( + Query.from_(self.table) + .select(self.table.foo, self.table.fiz, fn.Sum(self.table.bar)) + .groupby( + self.table.foo, + ) + .rollup( + self.table.fiz, + ) + ) + + self.assertEqual( + 'SELECT "foo","fiz",SUM("bar") FROM "abc" GROUP BY "foo",ROLLUP("fiz")', + str(q), + ) + + def test_verticaoracle_multiple_rollups(self): + q = ( + Query.from_(self.table) + .select(self.table.foo, self.table.fiz, fn.Sum(self.table.bar)) + .rollup( + self.table.foo, + ) + .rollup( + self.table.fiz, + ) + ) + + self.assertEqual( + 'SELECT "foo","fiz",SUM("bar") FROM "abc" GROUP BY ROLLUP("foo","fiz")', + str(q), + ) + + def test_verticaoracle_rollups_with_parity(self): + q = ( + Query.from_(self.table) + .select( + self.table.buz, + ) + .rollup( + [self.table.foo, self.table.bar], + self.table.fiz, + ) + ) + + self.assertEqual('SELECT "buz" FROM "abc" GROUP BY ROLLUP(("foo","bar"),"fiz")', str(q)) + + def test_verticaoracle_rollups_with_multiple_rollups_and_parity(self): + q = ( + Query.from_(self.table) + .select( + self.table.buz, + ) + .rollup( + [self.table.foo, self.table.bar], + ) + .rollup( + [self.table.fiz, self.table.buz], + ) + ) + + self.assertEqual( + 'SELECT "buz" FROM "abc" GROUP BY ROLLUP(("foo","bar"),("fiz","buz"))', + str(q), + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/test_immutability.py b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/test_immutability.py new file mode 100644 index 0000000000000000000000000000000000000000..ee539bfa1e9c4509b929e7a86a03f098dd923515 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/test_immutability.py @@ -0,0 +1,99 @@ +import unittest + +from pypika import ( + AliasedQuery, + Query, + Tables, +) + + +class ImmutabilityTests(unittest.TestCase): + table_a, table_b, table_c = Tables("a", "b", "c") + + def test_select_returns_new_query_instance(self): + query_a = Query.from_(self.table_a).select(self.table_a.foo) + query_b = query_a.select(self.table_a.bar) + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_groupby_returns_new_query_instance(self): + query_a = Query.from_(self.table_a).select(self.table_a.foo).groupby(self.table_a.foo) + query_b = query_a.groupby(self.table_a.bar) + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_orderby_return_new_query_instance(self): + query_a = Query.from_(self.table_a).select(self.table_a.foo).orderby(self.table_a.foo) + query_b = query_a.orderby(self.table_a.bar) + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_join_return_new_query_instance(self): + base = Query.from_(self.table_a).select(self.table_a.foo) + query_a = base.join(self.table_b).on(self.table_a.foo == self.table_b.bar).select(self.table_b.bar) + query_b = query_a.join(self.table_c).on(self.table_a.foo == self.table_c.baz).select(self.table_c.baz) + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_use_index_return_new_query_instance(self): + query_a = Query.from_(self.table_a).select(self.table_a.foo).use_index('idx1') + query_b = query_a.use_index('idx2') + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_force_index_return_new_query_instance(self): + query_a = Query.from_(self.table_a).select(self.table_a.foo).force_index('idx1') + query_b = query_a.force_index('idx2') + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_with_return_new_query_instance(self): + alias_1 = Query.from_(self.table_a).select(self.table_a.foo) + alias_2 = Query.from_(self.table_b).select(self.table_b.bar) + query_a = Query.from_(AliasedQuery('a1')).select('foo').with_(alias_1, 'a1') + query_b = query_a.with_(alias_2, 'a2') + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_insert_into_return_new_query_instance(self): + query_a = Query.into(self.table_a).insert('foo1') + query_b = query_a.insert('foo2') + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_replace_into_return_new_query_instance(self): + query_a = Query.into(self.table_a).replace('foo') + query_b = query_a.replace('bar') + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_update_set_return_new_query_instance(self): + query_a = Query.update(self.table_a).set(self.table_a.foo, 'foo') + query_b = query_a.set(self.table_a.bar, 'bar') + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_queries_after_join(self): + query1 = Query.from_(self.table_a).select(self.table_a.foo) + query2 = query1.join(self.table_b).on(self.table_a.foo == self.table_b.bar).select(self.table_b.buz) + + self.assertEqual('SELECT "foo" FROM "a"', str(query1)) + self.assertEqual( + 'SELECT "a"."foo","b"."buz" FROM "a" JOIN "b" ON "a"."foo"="b"."bar"', + str(query2), + ) + + def test_immutable_kwarg_on_query_builder_disables_immutability(self): + query0 = Query.from_(self.table_a, immutable=False) + query1 = query0.select(self.table_a.foo) + self.assertIs(query0, query1) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/test_inserts.py b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/test_inserts.py new file mode 100644 index 0000000000000000000000000000000000000000..f86efd7a76dc498a69b61c6353951695f1933a61 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/test_inserts.py @@ -0,0 +1,885 @@ +import unittest + +from pypika import ( + AliasedQuery, + Case, + Field as F, + MySQLQuery, + PostgreSQLQuery, + Query, + Table, + Tables, + functions as fn, +) +from pypika.functions import ( + Avg, + Cast, +) +from pypika.terms import Values +from pypika.utils import QueryException + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + + +class InsertIntoTests(unittest.TestCase): + table_abc = Table("abc") + + def test_insert_one_column(self): + query = Query.into(self.table_abc).insert(1) + + self.assertEqual('INSERT INTO "abc" VALUES (1)', str(query)) + + def test_insert_one_column_single_element_array(self): + query = Query.into(self.table_abc).insert((1,)) + + self.assertEqual('INSERT INTO "abc" VALUES (1)', str(query)) + + def test_insert_one_column_multi_element_array(self): + query = Query.into(self.table_abc).insert((1,), (2,)) + + self.assertEqual('INSERT INTO "abc" VALUES (1),(2)', str(query)) + + def test_insert_single_row_with_array_value(self): + query = Query.into(self.table_abc).insert(1, ["a", "b", "c"]) + + self.assertEqual("INSERT INTO \"abc\" VALUES (1,['a','b','c'])", str(query)) + + def test_insert_multiple_rows_with_array_value(self): + query = Query.into(self.table_abc).insert( + (1, ["a", "b", "c"]), + (2, ["c", "d", "e"]), + ) + + self.assertEqual( + 'INSERT INTO "abc" ' "VALUES (1,['a','b','c']),(2,['c','d','e'])", + str(query), + ) + + def test_insert_all_columns(self): + query = Query.into(self.table_abc).insert(1, "a", True) + + self.assertEqual("INSERT INTO \"abc\" VALUES (1,'a',true)", str(query)) + + def test_insert_all_columns_single_element(self): + query = Query.into(self.table_abc).insert((1, "a", True)) + + self.assertEqual("INSERT INTO \"abc\" VALUES (1,'a',true)", str(query)) + + def test_insert_all_columns_multi_rows(self): + query = Query.into(self.table_abc).insert((1, "a", True), (2, "b", False)) + + self.assertEqual("INSERT INTO \"abc\" VALUES (1,'a',true),(2,'b',false)", str(query)) + + def test_insert_all_columns_multi_rows_chained(self): + query = Query.into(self.table_abc).insert(1, "a", True).insert(2, "b", False) + + self.assertEqual("INSERT INTO \"abc\" VALUES (1,'a',true),(2,'b',false)", str(query)) + + def test_insert_all_columns_multi_rows_chained_mixed(self): + query = Query.into(self.table_abc).insert((1, "a", True), (2, "b", False)).insert(3, "c", True) + + self.assertEqual( + 'INSERT INTO "abc" VALUES ' "(1,'a',true),(2,'b',false)," "(3,'c',true)", + str(query), + ) + + def test_insert_all_columns_multi_rows_chained_multiple_rows(self): + query = ( + Query.into(self.table_abc).insert((1, "a", True), (2, "b", False)).insert((3, "c", True), (4, "d", False)) + ) + + self.assertEqual( + 'INSERT INTO "abc" VALUES ' "(1,'a',true),(2,'b',false)," "(3,'c',true),(4,'d',false)", + str(query), + ) + + def test_insert_selected_columns(self): + query = ( + Query.into(self.table_abc) + .columns(self.table_abc.foo, self.table_abc.bar, self.table_abc.buz) + .insert(1, "a", True) + ) + + self.assertEqual('INSERT INTO "abc" ("foo","bar","buz") VALUES (1,\'a\',true)', str(query)) + + def test_insert_empty_columns(self): + query = Query.into(self.table_abc).columns().insert(1, "a", True) + + self.assertEqual('INSERT INTO "abc" VALUES (1,\'a\',true)', str(query)) + + def test_insert_selected_columns_type_list(self): + query = ( + Query.into(self.table_abc) + .columns([self.table_abc.foo, self.table_abc.bar, self.table_abc.buz]) + .insert(1, "a", True) + ) + + self.assertEqual('INSERT INTO "abc" ("foo","bar","buz") VALUES (1,\'a\',true)', str(query)) + + def test_insert_empty_columns_type_list(self): + query = Query.into(self.table_abc).columns([]).insert(1, "a", True) + + self.assertEqual('INSERT INTO "abc" VALUES (1,\'a\',true)', str(query)) + + def test_insert_selected_columns_type_tuple(self): + query = ( + Query.into(self.table_abc) + .columns((self.table_abc.foo, self.table_abc.bar, self.table_abc.buz)) + .insert(1, "a", True) + ) + + self.assertEqual('INSERT INTO "abc" ("foo","bar","buz") VALUES (1,\'a\',true)', str(query)) + + def test_insert_empty_columns_type_tuple(self): + query = Query.into(self.table_abc).columns(()).insert(1, "a", True) + + self.assertEqual('INSERT INTO "abc" VALUES (1,\'a\',true)', str(query)) + + def test_insert_none_skipped(self): + query = Query.into(self.table_abc).insert() + + self.assertEqual("", str(query)) + + def test_insert_ignore(self): + query = Query.into(self.table_abc).insert(1).ignore() + + self.assertEqual('INSERT IGNORE INTO "abc" VALUES (1)', str(query)) + + def test_insert_null(self): + query = Query.into(self.table_abc).insert(None) + + self.assertEqual('INSERT INTO "abc" VALUES (NULL)', str(query)) + + def test_insert_column_using_table_alias(self): + q = self.table_abc.insert(1) + self.assertEqual('INSERT INTO "abc" VALUES (1)', str(q)) + + def test_insert_column_using_alias_with_chain(self): + q = self.table_abc.insert(1, "a", True).insert(2, "b", False) + self.assertEqual("INSERT INTO \"abc\" VALUES (1,'a',true),(2,'b',false)", str(q)) + + def test_insert_with_statement(self): + sub_query = Query().select(self.table_abc.id).from_(self.table_abc) + aliased = AliasedQuery('sub_qs') + + q = Query().with_(sub_query, 'sub_qs').into(self.table_abc).select(aliased.id).from_(aliased) + self.assertEqual( + 'WITH sub_qs AS (SELECT "id" FROM "abc") INSERT INTO "abc" SELECT "sub_qs"."id" FROM sub_qs', str(q) + ) + + +class PostgresInsertIntoOnConflictTests(unittest.TestCase): + table_abc = Table("abc") + + def test_insert_on_conflict_do_nothing_field(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).on_conflict(self.table_abc.id).do_nothing() + + self.assertEqual('INSERT INTO "abc" VALUES (1) ON CONFLICT ("id") DO NOTHING', str(query)) + + def test_insert_on_conflict_do_nothing_multiple_fields(self): + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1) + .on_conflict(self.table_abc.id, self.table_abc.sub_id) + .do_nothing() + ) + + self.assertEqual('INSERT INTO "abc" VALUES (1) ON CONFLICT ("id", "sub_id") DO NOTHING', str(query)) + + def test_insert_on_conflict_do_nothing_field_str(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).on_conflict("id").do_nothing() + + self.assertEqual('INSERT INTO "abc" VALUES (1) ON CONFLICT ("id") DO NOTHING', str(query)) + + def test_insert_on_conflict_do_nothing_multiple_fields_str(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).on_conflict("id", "sub_id").do_nothing() + + self.assertEqual('INSERT INTO "abc" VALUES (1) ON CONFLICT ("id", "sub_id") DO NOTHING', str(query)) + + def test_insert_on_conflict_do_nothing_mixed_fields(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).on_conflict("id", self.table_abc.sub_id).do_nothing() + + self.assertEqual('INSERT INTO "abc" VALUES (1) ON CONFLICT ("id", "sub_id") DO NOTHING', str(query)) + + def test_insert_on_conflict_do_update_field(self): + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict(self.table_abc.id) + .do_update(self.table_abc.name, "m") + ) + + self.assertEqual( + "INSERT INTO \"abc\" VALUES (1,'m') ON CONFLICT (\"id\") DO UPDATE SET \"name\"='m'", + str(query), + ) + + def test_insert_on_conflict_do_update_multiple_fields(self): + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict(self.table_abc.id, self.table_abc.sub_id) + .do_update(self.table_abc.name, "m") + ) + + self.assertEqual( + "INSERT INTO \"abc\" VALUES (1,'m') ON CONFLICT (\"id\", \"sub_id\") DO UPDATE SET \"name\"='m'", + str(query), + ) + + def test_insert_on_conflict_do_update_field_str(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1, "m").on_conflict("id").do_update("name", "m") + + self.assertEqual( + "INSERT INTO \"abc\" VALUES (1,'m') ON CONFLICT (\"id\") DO UPDATE SET \"name\"='m'", + str(query), + ) + + def test_insert_on_conflict_do_update_multiple_fields_str(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1, "m").on_conflict("id", "sub_id").do_update("name", "m") + + self.assertEqual( + "INSERT INTO \"abc\" VALUES (1,'m') ON CONFLICT (\"id\", \"sub_id\") DO UPDATE SET \"name\"='m'", + str(query), + ) + + def test_insert_on_conflict_do_update_multiple_mixed_fields(self): + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict("id", self.table_abc.sub_id) + .do_update("name", "m") + ) + + self.assertEqual( + "INSERT INTO \"abc\" VALUES (1,'m') ON CONFLICT (\"id\", \"sub_id\") DO UPDATE SET \"name\"='m'", + str(query), + ) + + def test_insert_on_conflict_no_handler(self): + with self.assertRaises(QueryException): + query = str(PostgreSQLQuery.into(self.table_abc).insert(1).on_conflict(self.table_abc.id)) + + def test_insert_on_conflict_two_handlers_do_nothing(self): + with self.assertRaises(QueryException): + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1) + .on_conflict("id") + .do_nothing() + .do_update(self.table_abc.name, "m") + ) + + def test_insert_on_conflict_two_handlers_do_update(self): + with self.assertRaises(QueryException): + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1) + .on_conflict(self.table_abc.id) + .do_update(self.table_abc.name, "m") + .do_nothing() + ) + + def test_non_insert_on_conflict_do_nothing(self): + with self.assertRaises(QueryException): + query = PostgreSQLQuery.update(self.table_abc).set("foo", "bar").on_conflict("id").do_nothing() + + def test_non_insert_on_conflict_do_update(self): + with self.assertRaises(QueryException): + query = ( + PostgreSQLQuery.update(self.table_abc).set("foo", "bar").on_conflict("id").do_update(["name"], ["m"]) + ) + + def test_insert_on_fieldless_conflict_do_nothing(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).on_conflict(None).do_nothing() + + self.assertEqual('INSERT INTO "abc" VALUES (1) ON CONFLICT DO NOTHING', str(query)) + + def test_insert_on_fieldless_conflict_do_update_field(self): + with self.assertRaises(QueryException): + query = str( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict(None) + .do_update(self.table_abc.name, "m") + ) + + def test_on_conflict_from_subquery(self): + table_bcd = Table('bcd') + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(self.table_abc.fname, self.table_abc.lname) + .select(table_bcd.fname, table_bcd.lname) + .from_(table_bcd) + .on_conflict(self.table_abc.id, self.table_abc.sub_id) + .do_update(self.table_abc.fname, 1) + .do_update(self.table_abc.lname, table_bcd.lname) + .do_update( + self.table_abc.cname, + Case().when(self.table_abc.cname.eq('cname'), 'new_name').else_(self.table_abc.cname), + ) + ) + + self.assertEqual( + 'INSERT INTO "abc" VALUES ("fname","lname") ' + 'ON CONFLICT ("id", "sub_id") ' + 'DO UPDATE SET "fname"=1,"lname"="bcd"."lname",' + '"cname"=CASE WHEN "abc"."cname"=\'cname\' THEN \'new_name\' ELSE "abc"."cname" END', + str(query), + ) + + def test_on_conflict_where_empty_conflict_fields_do_nothing(self): + with self.assertRaises(QueryException): + ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict() + .where(self.table_abc.abc.eq(0)) + .where(self.table_abc.cde.eq(0)) + .do_nothing() + ) + + def test_on_conflict_where_conflict_fields_do_nothing(self): + qs = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict('id') + .where(self.table_abc.abc.eq(0)) + .where(self.table_abc.cde.eq(0)) + .do_nothing() + ) + self.assertEqual( + '''INSERT INTO "abc" VALUES (1,'m') ON CONFLICT ("id") WHERE "abc"=0 AND "cde"=0 DO NOTHING''', str(qs) + ) + + def test_on_conflict_where_empty_conflict_fields_do_update(self): + with self.assertRaises(QueryException): + ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict() + .where(self.table_abc.abc.eq(0)) + .where(self.table_abc.cde.eq(0)) + .do_update('field', 'val') + ) + + def test_on_conflict_where_conflict_fields_do_update(self): + qs = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict('id') + .where(self.table_abc.abc.eq(0)) + .where(self.table_abc.cde.eq(0)) + .do_update('field', 'val') + ) + self.assertEqual( + '''INSERT INTO "abc" VALUES (1,'m') ON CONFLICT ("id") WHERE "abc"=0 AND "cde"=0 ''' + '''DO UPDATE SET "field"='val\'''', + str(qs), + ) + + def test_where_and_on_conflict_where(self): + table_bcd = Table('bcd') + + qs = ( + PostgreSQLQuery.into(self.table_abc) + .select(table_bcd.abc) + .from_(table_bcd) + .where(table_bcd.abc.eq('1')) + .on_conflict('id') + .where(self.table_abc.abc.eq(0)) + .where(self.table_abc.cde.eq(0)) + .do_update('field', 'val') + ) + + self.assertEqual( + 'INSERT INTO "abc" SELECT "abc" FROM "bcd" WHERE "abc"=\'1\' ' + 'ON CONFLICT ("id") WHERE "abc"=0 AND "cde"=0 DO UPDATE SET "field"=\'val\'', + str(qs), + ) + + def test_on_conflict_do_nothing_where(self): + with self.assertRaises(QueryException): + ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict() + .do_nothing() + .where(self.table_abc.abc.eq(1)) + ) + + def test_empty_on_conflict_do_update_where(self): + with self.assertRaises(QueryException): + ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict() + .do_update('abc', 1) + .where(self.table_abc.abc.eq(1)) + ) + + def test_on_conflict_do_update_where(self): + qs = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict("id") + .do_update('abc', 1) + .where(self.table_abc.abc.eq(1)) + ) + self.assertEqual( + 'INSERT INTO "abc" VALUES (1,\'m\') ON CONFLICT ("id") DO UPDATE SET "abc"=1 WHERE "abc"."abc"=1', str(qs) + ) + + def test_on_conflict_do_update_with_excluded_where(self): + qs = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict("id") + .do_update('abc') + .where(self.table_abc.abc.eq(1)) + ) + self.assertEqual( + 'INSERT INTO "abc" VALUES (1,\'m\') ON CONFLICT ("id") DO UPDATE SET "abc"=EXCLUDED."abc" WHERE ' + '"abc"."abc"=1', + str(qs), + ) + + def test_on_conflict_where_complex(self): + table_bcd = Table('bcd') + + qs = ( + PostgreSQLQuery.into(self.table_abc) + .select(table_bcd.abc) + .from_(table_bcd) + .where(table_bcd.abc.eq('1')) + .on_conflict('id') + .where(self.table_abc.abc.eq(0)) + .where(self.table_abc.cde.eq(0)) + .do_update('field', 'val') + .where(self.table_abc.id.eq(2)) + .where(self.table_abc.sub_id.eq(3)) + ) + self.assertEqual( + 'INSERT INTO "abc" SELECT "abc" FROM "bcd" WHERE "abc"=\'1\' ' + 'ON CONFLICT ("id") WHERE "abc"=0 AND "cde"=0 ' + 'DO UPDATE SET "field"=\'val\' WHERE "abc"."id"=2 AND "abc"."sub_id"=3', + str(qs), + ) + + +class PostgresInsertIntoReturningTests(unittest.TestCase): + table_abc = Table("abc") + + def test_insert_returning_one_field(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).returning(self.table_abc.id) + + self.assertEqual('INSERT INTO "abc" VALUES (1) RETURNING "id"', str(query)) + + def test_insert_returning_one_field_str(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).returning("id") + + self.assertEqual('INSERT INTO "abc" VALUES (1) RETURNING "id"', str(query)) + + def test_insert_returning_all_fields(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).returning(self.table_abc.star) + + self.assertEqual('INSERT INTO "abc" VALUES (1) RETURNING *', str(query)) + + def test_insert_returning_all_fields_and_arithmetics(self): + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1) + .returning(self.table_abc.star, self.table_abc.f1 + self.table_abc.f2) + ) + + self.assertEqual('INSERT INTO "abc" VALUES (1) RETURNING *,"f1"+"f2"', str(query)) + + def test_insert_all_columns_multi_rows_chained_returning_star(self): + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "a", True) + .insert(2, "b", False) + .returning(self.table_abc.star) + ) + + self.assertEqual( + "INSERT INTO \"abc\" VALUES (1,'a',true),(2,'b',false) RETURNING *", + str(query), + ) + + def test_insert_all_columns_multi_rows_chained_returning_star_and_id(self): + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "a", True) + .insert(2, "b", False) + .returning( + self.table_abc.name, + self.table_abc.star, + self.table_abc.id, + ) + ) + + self.assertEqual( + "INSERT INTO \"abc\" VALUES (1,'a',true),(2,'b',false) RETURNING *", + str(query), + ) + + def test_insert_all_columns_multi_rows_chained_returning_star_str(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1, "a", True).insert(2, "b", False).returning("*") + + self.assertEqual( + "INSERT INTO \"abc\" VALUES (1,'a',true),(2,'b',false) RETURNING *", + str(query), + ) + + def test_insert_all_columns_single_element_arrays(self): + query = PostgreSQLQuery.into(self.table_abc).insert((1, "a", True)).returning(self.table_abc.star) + + self.assertEqual("INSERT INTO \"abc\" VALUES (1,'a',true) RETURNING *", str(query)) + + def test_insert_returning_null(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).returning(None) + + self.assertEqual('INSERT INTO "abc" VALUES (1) RETURNING NULL', str(query)) + + def test_insert_returning_tuple(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).returning((1, 2, 3)) + + self.assertEqual('INSERT INTO "abc" VALUES (1) RETURNING (1,2,3)', str(query)) + + def test_insert_returning_arithmetics(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).returning(self.table_abc.f1 + self.table_abc.f2) + + self.assertEqual('INSERT INTO "abc" VALUES (1) RETURNING "f1"+"f2"', str(query)) + + def test_insert_returning_functions(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).returning(Cast(self.table_abc.f1, "int")) + + self.assertEqual('INSERT INTO "abc" VALUES (1) RETURNING CAST("f1" AS INT)', str(query)) + + def test_insert_returning_aggregate(self): + with self.assertRaises(QueryException): + PostgreSQLQuery.into(self.table_abc).insert(1).returning(Avg(self.table_abc.views)) + + def test_insert_returning_from_other_table(self): + table_cba = Table("cba") + with self.assertRaises(QueryException): + PostgreSQLQuery.into(self.table_abc).insert(1).returning(table_cba.id) + + +class InsertIntoOnDuplicateTests(unittest.TestCase): + table_abc = Table("abc") + + def test_insert_one_column(self): + query = ( + MySQLQuery.into(self.table_abc).insert(1).on_duplicate_key_update(self.table_abc.foo, self.table_abc.foo) + ) + self.assertEqual( + "INSERT INTO `abc` VALUES (1) ON DUPLICATE KEY UPDATE `foo`=`foo`", + str(query), + ) + + def test_insert_one_column_using_values(self): + query = ( + MySQLQuery.into(self.table_abc) + .insert(1) + .on_duplicate_key_update(self.table_abc.foo, Values(self.table_abc.foo)) + ) + self.assertEqual( + "INSERT INTO `abc` VALUES (1) ON DUPLICATE KEY UPDATE `foo`=VALUES(`foo`)", + str(query), + ) + + def test_insert_one_column_single_element_array(self): + query = ( + MySQLQuery.into(self.table_abc).insert((1,)).on_duplicate_key_update(self.table_abc.foo, self.table_abc.foo) + ) + + self.assertEqual( + "INSERT INTO `abc` VALUES (1) ON DUPLICATE KEY UPDATE `foo`=`foo`", + str(query), + ) + + def test_insert_one_column_multi_element_array(self): + query = ( + MySQLQuery.into(self.table_abc) + .insert((1,), (2,)) + .on_duplicate_key_update(self.table_abc.foo, self.table_abc.foo) + ) + + self.assertEqual( + "INSERT INTO `abc` VALUES (1),(2) ON DUPLICATE KEY UPDATE `foo`=`foo`", + str(query), + ) + + def test_insert_multiple_columns_on_duplicate_update_one_with_same_value(self): + query = ( + MySQLQuery.into(self.table_abc) + .insert(1, "a") + .on_duplicate_key_update(self.table_abc.bar, Values(self.table_abc.bar)) + ) + + self.assertEqual( + "INSERT INTO `abc` VALUES (1,'a') ON DUPLICATE KEY UPDATE `bar`=VALUES(`bar`)", + str(query), + ) + + def test_insert_multiple_columns_on_duplicate_update_one_with_different_value(self): + query = MySQLQuery.into(self.table_abc).insert(1, "a").on_duplicate_key_update(self.table_abc.bar, "b") + + self.assertEqual( + "INSERT INTO `abc` VALUES (1,'a') ON DUPLICATE KEY UPDATE `bar`='b'", + str(query), + ) + + def test_insert_multiple_columns_on_duplicate_update_one_with_expression(self): + query = ( + MySQLQuery.into(self.table_abc).insert(1, 2).on_duplicate_key_update(self.table_abc.bar, 4 + F("bar")) + ) # todo sql expression? not python + + self.assertEqual( + "INSERT INTO `abc` VALUES (1,2) ON DUPLICATE KEY UPDATE `bar`=4+`bar`", + str(query), + ) + + def test_insert_multiple_columns_on_duplicate_update_one_with_expression_using_original_field_value( + self, + ): + query = ( + MySQLQuery.into(self.table_abc) + .insert(1, "a") + .on_duplicate_key_update(self.table_abc.bar, fn.Concat(self.table_abc.bar, "update")) + ) + + self.assertEqual( + "INSERT INTO `abc` VALUES (1,'a') ON DUPLICATE KEY UPDATE `bar`=CONCAT(`bar`,'update')", + str(query), + ) + + def test_insert_multiple_columns_on_duplicate_update_one_with_expression_using_values( + self, + ): + query = ( + MySQLQuery.into(self.table_abc) + .insert(1, "a") + .on_duplicate_key_update(self.table_abc.bar, fn.Concat(Values(self.table_abc.bar), "update")) + ) + + self.assertEqual( + "INSERT INTO `abc` VALUES (1,'a') ON DUPLICATE KEY UPDATE `bar`=CONCAT(VALUES(`bar`),'update')", + str(query), + ) + + def test_insert_multiple_columns_on_duplicate_update_multiple(self): + query = ( + MySQLQuery.into(self.table_abc) + .insert(1, "a", "b") + .on_duplicate_key_update(self.table_abc.bar, "b") + .on_duplicate_key_update(self.table_abc.baz, "c") + ) + + self.assertEqual( + "INSERT INTO `abc` VALUES (1,'a','b') ON DUPLICATE KEY UPDATE `bar`='b',`baz`='c'", + str(query), + ) + + def test_insert_multi_rows_chained_mixed_on_duplicate_update_multiple(self): + query = ( + MySQLQuery.into(self.table_abc) + .insert((1, "a", True), (2, "b", False)) + .insert(3, "c", True) + .on_duplicate_key_update(self.table_abc.foo, self.table_abc.foo) + .on_duplicate_key_update(self.table_abc.bar, Values(self.table_abc.bar)) + ) + + self.assertEqual( + "INSERT INTO `abc` VALUES (1,'a',true),(2,'b',false),(3,'c',true) " + "ON DUPLICATE KEY UPDATE `foo`=`foo`,`bar`=VALUES(`bar`)", + str(query), + ) + + def test_insert_selected_columns_on_duplicate_update_one(self): + query = ( + MySQLQuery.into(self.table_abc) + .columns(self.table_abc.foo, self.table_abc.bar, self.table_abc.baz) + .insert(1, "a", True) + .on_duplicate_key_update(self.table_abc.baz, False) + ) + + self.assertEqual( + "INSERT INTO `abc` (`foo`,`bar`,`baz`) VALUES (1,'a',true) ON DUPLICATE KEY UPDATE `baz`=false", + str(query), + ) + + def test_insert_selected_columns_on_duplicate_update_multiple(self): + query = ( + MySQLQuery.into(self.table_abc) + .columns(self.table_abc.foo, self.table_abc.bar, self.table_abc.baz) + .insert(1, "a", True) + .on_duplicate_key_update(self.table_abc.baz, False) + .on_duplicate_key_update(self.table_abc.bar, Values(self.table_abc.bar)) + ) + + self.assertEqual( + "INSERT INTO `abc` (`foo`,`bar`,`baz`) VALUES (1,'a',true) " + "ON DUPLICATE KEY UPDATE `baz`=false,`bar`=VALUES(`bar`)", + str(query), + ) + + def test_insert_none_skipped(self): + query = MySQLQuery.into(self.table_abc).insert().on_duplicate_key_update(self.table_abc.baz, False) + + self.assertEqual("", str(query)) + + def test_insert_ignore(self): + query = MySQLQuery.into(self.table_abc).insert(1).ignore().on_duplicate_key_update(self.table_abc.baz, False) + + self.assertEqual( + "INSERT IGNORE INTO `abc` VALUES (1) ON DUPLICATE KEY UPDATE `baz`=false", + str(query), + ) + + +class InsertSelectFromTests(unittest.TestCase): + table_abc, table_efg, table_hij = Tables("abc", "efg", "hij") + + def test_insert_star(self): + query = Query.into(self.table_abc).from_(self.table_efg).select("*") + + self.assertEqual('INSERT INTO "abc" SELECT * FROM "efg"', str(query)) + + def test_insert_ignore_star(self): + query = Query.into(self.table_abc).from_(self.table_efg).select("*").ignore() + + self.assertEqual('INSERT IGNORE INTO "abc" SELECT * FROM "efg"', str(query)) + + def test_insert_from_columns(self): + query = ( + Query.into(self.table_abc) + .from_(self.table_efg) + .select(self.table_efg.fiz, self.table_efg.buz, self.table_efg.baz) + ) + + self.assertEqual('INSERT INTO "abc" ' 'SELECT "fiz","buz","baz" FROM "efg"', str(query)) + + def test_insert_columns_from_star(self): + query = ( + Query.into(self.table_abc) + .columns( + self.table_abc.foo, + self.table_abc.bar, + self.table_abc.buz, + ) + .from_(self.table_efg) + .select("*") + ) + + self.assertEqual('INSERT INTO "abc" ("foo","bar","buz") ' 'SELECT * FROM "efg"', str(query)) + + def test_insert_columns_from_columns(self): + query = ( + Query.into(self.table_abc) + .columns(self.table_abc.foo, self.table_abc.bar, self.table_abc.buz) + .from_(self.table_efg) + .select(self.table_efg.fiz, self.table_efg.buz, self.table_efg.baz) + ) + + self.assertEqual( + 'INSERT INTO "abc" ("foo","bar","buz") ' 'SELECT "fiz","buz","baz" FROM "efg"', + str(query), + ) + + def test_insert_columns_from_columns_with_join(self): + query = ( + Query.into(self.table_abc) + .columns( + self.table_abc.c1, + self.table_abc.c2, + self.table_abc.c3, + self.table_abc.c4, + ) + .from_(self.table_efg) + .select(self.table_efg.foo, self.table_efg.bar) + .join(self.table_hij) + .on(self.table_efg.id == self.table_hij.abc_id) + .select(self.table_hij.fiz, self.table_hij.buz) + ) + + self.assertEqual( + 'INSERT INTO "abc" ("c1","c2","c3","c4") ' + 'SELECT "efg"."foo","efg"."bar","hij"."fiz","hij"."buz" FROM "efg" ' + 'JOIN "hij" ON "efg"."id"="hij"."abc_id"', + str(query), + ) + + +class InsertSubqueryTests(unittest.TestCase): + def test_insert_subquery_wrapped_in_brackets(self): + purchase_order_item, part = Tables("purchase_order_item", "part") + + q = ( + Query.into(purchase_order_item) + .columns(purchase_order_item.id_part, purchase_order_item.id_customer) + .insert( + Query.from_(part).select(part.part_id).where(part.part_number == "FOOBAR"), + 12345, + ) + ) + + self.assertEqual( + 'INSERT INTO "purchase_order_item" ' + '("id_part","id_customer") ' + "VALUES " + '((SELECT "part_id" FROM "part" WHERE "part_number"=\'FOOBAR\'),12345)', + str(q), + ) + + +class SelectIntoTests(unittest.TestCase): + table_abc, table_efg, table_hij = Tables("abc", "efg", "hij") + + def test_select_star_into(self): + query = Query.from_(self.table_abc).select("*").into(self.table_efg) + + self.assertEqual('SELECT * INTO "efg" FROM "abc"', str(query)) + + def test_select_columns_into(self): + query = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, self.table_abc.bar, self.table_abc.buz) + .into(self.table_efg) + ) + + self.assertEqual('SELECT "foo","bar","buz" INTO "efg" FROM "abc"', str(query)) + + def test_select_columns_into_with_join(self): + query = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, self.table_abc.bar) + .join(self.table_hij) + .on(self.table_abc.id == self.table_hij.abc_id) + .select(self.table_hij.fiz, self.table_hij.buz) + .into(self.table_efg) + ) + + self.assertEqual( + 'SELECT "abc"."foo","abc"."bar","hij"."fiz","hij"."buz" ' + 'INTO "efg" FROM "abc" ' + 'JOIN "hij" ON "abc"."id"="hij"."abc_id"', + str(query), + ) + + +class ReplaceTests(unittest.TestCase): + table_abc, table_def = Tables("abc", "efg") + + def test_replace_simple(self): + query = Query.into(self.table_abc).replace("v1", "v2", "v3") + expected_output = "REPLACE INTO \"abc\" VALUES ('v1','v2','v3')" + self.assertEqual(str(query), expected_output) + + def test_replace_subquery(self): + query = Query.into(self.table_abc).replace(Query.from_(self.table_def).select("f1", "f2")) + expected_output = 'REPLACE INTO "abc" VALUES ((SELECT "f1","f2" FROM "efg"))' + self.assertEqual(str(query), expected_output) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/test_internals.py b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/test_internals.py new file mode 100644 index 0000000000000000000000000000000000000000..921e381ba8613d4a83cc53bd60d111d9547e2c1f --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/test_internals.py @@ -0,0 +1,35 @@ +import unittest + +from pypika import ( + Case, + Field, + Table, +) +from pypika.terms import Star + + +class TablesTests(unittest.TestCase): + def test__criterion_replace_table_with_value(self): + table = Table("a") + + c = (Field("foo") > 1).replace_table(None, table) + self.assertEqual(c.left, table) + self.assertEqual(c.tables_, {table}) + + def test__case_tables(self): + table = Table("a") + + c = Case().when(table.a == 1, 2 * table.a) + self.assertIsInstance(c.tables_, set) + self.assertSetEqual(c.tables_, {table}) + + def test__star_tables(self): + star = Star() + + self.assertEqual(star.tables_, set()) + + def test__table_star_tables(self): + table = Table("a") + star = Star(table=table) + + self.assertEqual(star.tables_, {table}) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/test_joins.py b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/test_joins.py new file mode 100644 index 0000000000000000000000000000000000000000..03142d583921edbe966e0ae191d254e7b8bf46ba --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/test_joins.py @@ -0,0 +1,1168 @@ +import unittest + +from pypika import ( + Field, + Interval, + JoinException, + JoinType, + MySQLQuery, + Query, + SetOperationException, + Table, + Tables, + functions as fn, + SYSTEM_TIME, +) + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + + +class SelectQueryJoinTests(unittest.TestCase): + table0, table1, hij = Tables("abc", "efg", "hij") + + def test_default_join_type(self): + query = Query.from_(self.table0).join(self.table1).on(self.table0.foo == self.table1.bar).select("*") + + self.assertEqual('SELECT * FROM "abc" JOIN "efg" ON "abc"."foo"="efg"."bar"', str(query)) + + def test_inner_join(self): + expected = 'SELECT * FROM "abc" JOIN "efg" ON "abc"."foo"="efg"."bar"' + + with self.subTest("join with enum"): + query = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.inner) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + self.assertEqual(expected, str(query)) + + with self.subTest("join function"): + query = Query.from_(self.table0).inner_join(self.table1).on(self.table0.foo == self.table1.bar).select("*") + self.assertEqual(expected, str(query)) + + def test_left_join(self): + expected = 'SELECT * FROM "abc" LEFT JOIN "efg" ON "abc"."foo"="efg"."bar"' + + with self.subTest("join with enum"): + query = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.left) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + + self.assertEqual(expected, str(query)) + + with self.subTest("join function"): + query = Query.from_(self.table0).left_join(self.table1).on(self.table0.foo == self.table1.bar).select("*") + self.assertEqual(expected, str(query)) + + def test_right_join(self): + expected = 'SELECT * FROM "abc" RIGHT JOIN "efg" ON "abc"."foo"="efg"."bar"' + + with self.subTest("join with enum"): + query = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.right) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + + self.assertEqual(expected, str(query)) + + with self.subTest("join function"): + query = Query.from_(self.table0).right_join(self.table1).on(self.table0.foo == self.table1.bar).select("*") + self.assertEqual(expected, str(query)) + + def test_hash_join(self): + expected = 'SELECT * FROM "abc" HASH JOIN "efg" ON "abc"."foo"="efg"."bar"' + + with self.subTest("join with enum"): + query = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.hash) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + + self.assertEqual(expected, str(query)) + + with self.subTest("join function"): + query = Query.from_(self.table0).hash_join(self.table1).on(self.table0.foo == self.table1.bar).select("*") + self.assertEqual(expected, str(query)) + + def test_outer_join(self): + expected = 'SELECT * FROM "abc" FULL OUTER JOIN "efg" ON "abc"."foo"="efg"."bar"' + + with self.subTest("join with enum"): + query = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.outer) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + + self.assertEqual(expected, str(query)) + + with self.subTest("join function"): + query = Query.from_(self.table0).outer_join(self.table1).on(self.table0.foo == self.table1.bar).select("*") + self.assertEqual(expected, str(query)) + + def test_cross_join(self): + expected = 'SELECT * FROM "abc" CROSS JOIN "efg" ON "abc"."foo"="efg"."bar"' + + with self.subTest("join with enum"): + query = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.cross) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + + self.assertEqual(expected, str(query)) + + with self.subTest("join function"): + query = Query.from_(self.table0).cross_join(self.table1).on(self.table0.foo == self.table1.bar).select("*") + self.assertEqual(expected, str(query)) + + def test_left_outer_join(self): + expected = 'SELECT * FROM "abc" LEFT OUTER JOIN "efg" ON "abc"."foo"="efg"."bar"' + with self.subTest("join with enum"): + query = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.left_outer) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + + self.assertEqual(expected, str(query)) + + with self.subTest("join function"): + query = ( + Query.from_(self.table0).left_outer_join(self.table1).on(self.table0.foo == self.table1.bar).select("*") + ) + + self.assertEqual(expected, str(query)) + + def test_right_outer_join(self): + expected = 'SELECT * FROM "abc" RIGHT OUTER JOIN "efg" ON "abc"."foo"="efg"."bar"' + with self.subTest("join with enum"): + query = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.right_outer) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + + self.assertEqual(expected, str(query)) + + with self.subTest("join function"): + query = ( + Query.from_(self.table0) + .right_outer_join(self.table1) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + + self.assertEqual(expected, str(query)) + + def test_full_outer_join(self): + expected = 'SELECT * FROM "abc" FULL OUTER JOIN "efg" ON "abc"."foo"="efg"."bar"' + + with self.subTest("join with enum"): + query = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.full_outer) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + + self.assertEqual(expected, str(query)) + + with self.subTest("join function"): + query = ( + Query.from_(self.table0).full_outer_join(self.table1).on(self.table0.foo == self.table1.bar).select("*") + ) + + self.assertEqual(expected, str(query)) + + def test_join_on_field_single(self): + query = Query.from_(self.table0).join(self.table1).on_field("foo").select("*") + self.assertEqual('SELECT * FROM "abc" JOIN "efg" ON "abc"."foo"="efg"."foo"', str(query)) + + def test_join_on_field_multi(self): + query = Query.from_(self.table0).join(self.table1).on_field("foo", "bar").select("*") + self.assertEqual( + 'SELECT * FROM "abc" JOIN "efg" ON "abc"."foo"="efg"."foo" ' 'AND "abc"."bar"="efg"."bar"', + str(query), + ) + + def test_join_on_field_multi_with_extra_join(self): + query = ( + Query.from_(self.table0) + .join(self.hij) + .on_field("buzz") + .join(self.table1) + .on_field("foo", "bar") + .select("*") + ) + + self.assertEqual( + 'SELECT * FROM "abc" JOIN "hij" ON "abc"."buzz"="hij"."buzz" ' + 'JOIN "efg" ON "abc"."foo"="efg"."foo" AND "abc"."bar"="efg"."bar"', + str(query), + ) + + def test_join_using_string_field_name(self): + query = Query.from_(self.table0).join(self.table1).using("id").select("*") + + self.assertEqual('SELECT * FROM "abc" JOIN "efg" USING ("id")', str(query)) + + def test_join_using_multiple_fields(self): + query = Query.from_(self.table0).join(self.table1).using("foo", "bar").select("*") + + self.assertEqual('SELECT * FROM "abc" JOIN "efg" USING ("foo","bar")', str(query)) + + def test_join_using_with_quote_char(self): + query = Query.from_(self.table0).join(self.table1).using("foo", "bar").select("*") + + self.assertEqual("SELECT * FROM abc JOIN efg USING (foo,bar)", query.get_sql(quote_char="")) + + def test_join_using_without_fields_raises_exception(self): + with self.assertRaises(JoinException): + Query.from_(self.table0).join(self.table1).using() + + def test_join_on_field_without_fields_raises_exception(self): + with self.assertRaises(JoinException): + Query.from_(self.table0).join(self.table1).on_field() + + def test_join_arithmetic_field(self): + q = ( + Query.from_(self.table0) + .join(self.table1) + .on(self.table0.dt == (self.table1.dt - Interval(weeks=1))) + .select("*") + ) + + self.assertEqual( + 'SELECT * FROM "abc" ' 'JOIN "efg" ON "abc"."dt"="efg"."dt"-INTERVAL \'1 WEEK\'', + str(q), + ) + + def test_join_with_arithmetic_function_in_select(self): + q = ( + Query.from_( + self.table0, + ) + .join(self.table1) + .on(self.table0.dt == (self.table1.dt - Interval(weeks=1))) + .select(self.table0.fiz - self.table0.buz, self.table1.star) + ) + + self.assertEqual( + 'SELECT "abc"."fiz"-"abc"."buz","efg".* FROM "abc" ' + 'JOIN "efg" ON "abc"."dt"="efg"."dt"-INTERVAL \'1 WEEK\'', + str(q), + ) + + def test_join_on_complex_criteria(self): + q = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.right) + .on((self.table0.foo == self.table1.fiz) & (self.table0.bar == self.table1.buz)) + .select("*") + ) + + self.assertEqual( + 'SELECT * FROM "abc" ' 'RIGHT JOIN "efg" ON "abc"."foo"="efg"."fiz" AND "abc"."bar"="efg"."buz"', + str(q), + ) + + def test_join_on_subquery_criteria(self): + table_a, table_b, table_c = Tables("a", "b", "c") + subquery = Query.from_(table_c).select("id").limit(1) + query = ( + Query.from_(table_a).select("*").join(table_b).on((table_a.b_id == table_b.id) & (table_b.c_id == subquery)) + ) + + self.assertEqual( + "SELECT * " 'FROM "a" ' 'JOIN "b" ON "a"."b_id"="b"."id" AND "b"."c_id"=' '(SELECT "id" FROM "c" LIMIT 1)', + str(query), + ) + + def test_use_different_table_objects_for_same_table(self): + table = Table("t") + q = Query.from_(table).select("*").where(Field("id", table=table) == 1) + + self.assertEqual('SELECT * FROM "t" WHERE "id"=1', str(q)) + + def test_join_second_table_in_from_clause(self): + table_a, table_b, table_c = Tables("a", "b", "c") + q = Query.from_(table_a).from_(table_b).select("*").join(table_c).on(table_b.c_id == table_c.id) + + self.assertEqual("SELECT * " 'FROM "a","b" ' 'JOIN "c" ON "b"."c_id"="c"."id"', str(q)) + + def test_cross_join_on_table(self): + table_a, table_b = Tables("a", "b") + q = Query.from_(table_a).join(table_b).cross().select("*") + + self.assertEqual('SELECT * FROM "a" CROSS JOIN "b"', str(q)) + + def test_cross_join_on_subquery(self): + table_a, table_b = Tables("a", "b") + q_a = Query.from_(table_a).select("*") + q_b = Query.from_(table_b).select("*").join(q_a).cross().select("*") + + self.assertEqual('SELECT * FROM "b" CROSS JOIN (SELECT * FROM "a") "sq0"', str(q_b)) + + def test_join_on_collate(self): + table_a, table_b = Tables("a", "b") + + q1 = ( + Query.from_(table_a) + .select(table_b.ouch) + .join(table_b) + .on(table_a.foo == table_b.boo, collate="utf8_general_ci") + ) + q2 = Query.from_(table_a).select(table_b.ouch).join(table_b).on(table_a.foo == table_b.boo) + + self.assertEqual( + 'SELECT "b"."ouch" FROM "a" JOIN "b" ON "a"."foo"="b"."boo" COLLATE utf8_general_ci', + str(q1), + ) + self.assertEqual('SELECT "b"."ouch" FROM "a" JOIN "b" ON "a"."foo"="b"."boo"', str(q2)) + + def test_temporal_join(self): + t0 = self.table0.for_(SYSTEM_TIME.as_of('2020-01-01')) + t1 = self.table1.for_(SYSTEM_TIME.as_of('2020-01-01')) + query = Query.from_(t0).join(t1).on(t0.foo == t1.bar).select("*") + + self.assertEqual( + 'SELECT * FROM "abc" FOR SYSTEM_TIME AS OF \'2020-01-01\' ' + 'JOIN "efg" FOR SYSTEM_TIME AS OF \'2020-01-01\' ' + 'ON "abc"."foo"="efg"."bar"', + str(query), + ) + + +class JoinBehaviorTests(unittest.TestCase): + table_abc, table_efg, table_hij, table_klm = Tables("abc", "efg", "hij", "klm") + + def test_select__ordered_select_clauses(self): + q = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .select( + self.table_abc.baz, + self.table_efg.buz, + self.table_abc.fiz, + self.table_efg.bam, + ) + ) + + self.assertEqual( + 'SELECT "abc"."baz","efg"."buz","abc"."fiz","efg"."bam" FROM "abc" ' + 'JOIN "efg" ON "abc"."foo"="efg"."bar"', + str(q), + ) + + def test_select__star_for_table(self): + q = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .join(self.table_hij) + .on(self.table_abc.buz == self.table_hij.bam) + .select(self.table_abc.star) + .select(self.table_efg.star) + .select(self.table_hij.star) + ) + + self.assertEqual( + 'SELECT "abc".*,"efg".*,"hij".* FROM "abc" ' + 'JOIN "efg" ON "abc"."foo"="efg"."bar" ' + 'JOIN "hij" ON "abc"."buz"="hij"."bam"', + str(q), + ) + + def test_select__star_for_table__replacement(self): + q = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .join(self.table_hij) + .on(self.table_abc.buz == self.table_hij.bam) + .select(self.table_abc.foo, self.table_efg.bar, self.table_hij.bam) + .select(self.table_abc.star, self.table_efg.star, self.table_hij.star) + ) + + self.assertEqual( + 'SELECT "abc".*,"efg".*,"hij".* FROM "abc" ' + 'JOIN "efg" ON "abc"."foo"="efg"."bar" ' + 'JOIN "hij" ON "abc"."buz"="hij"."bam"', + str(q), + ) + + def test_select_fields_with_where(self): + q = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .join(self.table_hij) + .on(self.table_abc.buz == self.table_hij.bam) + .select(self.table_abc.foo, self.table_efg.bar, self.table_hij.bam) + .where(self.table_abc.foo > 1) + .where(self.table_efg.bar != 2) + ) + + self.assertEqual( + 'SELECT "abc"."foo","efg"."bar","hij"."bam" FROM "abc" ' + 'JOIN "efg" ON "abc"."foo"="efg"."bar" ' + 'JOIN "hij" ON "abc"."buz"="hij"."bam" ' + 'WHERE "abc"."foo">1 AND "efg"."bar"<>2', + str(q), + ) + + def test_require_condition(self): + with self.assertRaises(JoinException): + Query.from_(self.table_abc).join(self.table_efg).on(None) + + def test_require_condition_with_both_tables(self): + with self.assertRaises(JoinException): + Query.from_(self.table_abc).join(self.table_efg).on(self.table_abc.foo == self.table_hij.bar) + + with self.assertRaises(JoinException): + Query.from_(self.table_abc).join(self.table_efg).on(self.table_hij.foo == self.table_efg.bar) + + with self.assertRaises(JoinException): + Query.from_(self.table_abc).join(self.table_efg).on(self.table_hij.foo == self.table_klm.bar) + + def test_join_same_table(self): + table1 = Table("abc") + table2 = Table("abc") + q = Query.from_(table1).join(table2).on(table1.foo == table2.bar).select(table1.foo, table2.buz) + + self.assertEqual( + 'SELECT "abc"."foo","abc2"."buz" FROM "abc" ' 'JOIN "abc" "abc2" ON "abc"."foo"="abc2"."bar"', + str(q), + ) + + def test_join_same_table_with_prefixes(self): + table1 = Table("abc").as_("x") + table2 = Table("abc").as_("y") + q = Query.from_(table1).join(table2).on(table1.foo == table2.bar).select(table1.foo, table2.buz) + + self.assertEqual( + 'SELECT "x"."foo","y"."buz" FROM "abc" "x" ' 'JOIN "abc" "y" ON "x"."foo"="y"."bar"', + str(q), + ) + + def test_join_table_twice(self): + table1, table2 = Table("efg").as_("efg1"), Table("efg").as_("efg2") + q = ( + Query.from_(self.table_abc) + .join(table1) + .on(self.table_abc.foo == table1.bar) + .join(table2) + .on(self.table_abc.foo == table2.bam) + .select(self.table_abc.foo, table1.fiz, table2.buz) + ) + + self.assertEqual( + 'SELECT "abc"."foo","efg1"."fiz","efg2"."buz" FROM "abc" ' + 'JOIN "efg" "efg1" ON "abc"."foo"="efg1"."bar" ' + 'JOIN "efg" "efg2" ON "abc"."foo"="efg2"."bam"', + str(q), + ) + + def test_select__fields_after_table_star(self): + q = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .select(self.table_abc.star, self.table_efg.bar) + .select(self.table_abc.foo) + ) + + self.assertEqual( + 'SELECT "abc".*,"efg"."bar" FROM "abc" JOIN "efg" ON "abc"."foo"="efg"."bar"', + str(q), + ) + + def test_fail_when_joining_unknown_type(self): + with self.assertRaises(ValueError): + Query.from_(self.table_abc).join("this is a string") + + def test_immutable__tables(self): + query1 = Query.from_(self.table_abc).select(self.table_abc.foo) + query2 = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .select(self.table_abc.foo, self.table_efg.buz) + ) + + self.assertEqual( + 'SELECT "abc"."foo","efg"."buz" FROM "abc" ' 'JOIN "efg" ON "abc"."foo"="efg"."bar"', + str(query2), + ) + self.assertEqual('SELECT "foo" FROM "abc"', str(query1)) + + def test_select_field_from_missing_table(self): + """ + Previously we validated the select field was a member of a table + in the query (e.g. FROM clause or a JOIN). However this made + correlated subqueries awkward to write (subqueries which refer + to their parent table. So the validation was removed. + + None of the following raise an error. Previously raised JoinException + """ + Query.from_(self.table_abc).select(self.table_efg.foo) + + Query.from_(self.table_abc).where(self.table_efg.foo == 0) + + Query.from_(self.table_abc).where(fn.Sum(self.table_efg.foo) == 0) + + Query.from_(self.table_abc).select(fn.Sum(self.table_abc.bar * 2) + fn.Sum(self.table_efg.foo * 2)) + + Query.from_(self.table_abc).groupby(self.table_efg.foo) + + Query.from_(self.table_abc).groupby(self.table_abc.foo).having(self.table_efg.bar) + + subquery = ( + Query.from_(self.table_efg).select(self.table_efg.id).where(self.table_efg.abc_id == self.table_abc.id) + ) + query = Query.from_(self.table_abc).select(subquery.as_("efg_id").limit(1)) + self.assertEqual( + 'SELECT (SELECT "efg"."id" FROM "efg" WHERE "efg"."abc_id"="abc"."id" LIMIT 1) "efg_id" FROM "abc"', + str(query), + ) + + def test_ignore_table_references(self): + query = Query.from_(Table("abc")).select(Table("abc").foo) + + self.assertEqual('SELECT "foo" FROM "abc"', str(query)) + + def test_prefixes_added_to_groupby(self): + test_query = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .select(self.table_abc.foo, fn.Sum(self.table_efg.buz)) + .groupby(self.table_abc.foo) + ) + + self.assertEqual( + 'SELECT "abc"."foo",SUM("efg"."buz") FROM "abc" ' + 'JOIN "efg" ON "abc"."foo"="efg"."bar" ' + 'GROUP BY "abc"."foo"', + str(test_query), + ) + + def test_prefixes_added_to_orderby(self): + test_query = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .select(self.table_abc.foo, self.table_efg.buz) + .orderby(self.table_abc.foo) + ) + + self.assertEqual( + 'SELECT "abc"."foo","efg"."buz" FROM "abc" ' + 'JOIN "efg" ON "abc"."foo"="efg"."bar" ' + 'ORDER BY "abc"."foo"', + str(test_query), + ) + + def test_prefixes_added_to_function_in_orderby(self): + test_query = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .select(self.table_abc.foo, self.table_efg.buz) + .orderby(fn.Date(self.table_abc.foo)) + ) + + self.assertEqual( + 'SELECT "abc"."foo","efg"."buz" FROM "abc" ' + 'JOIN "efg" ON "abc"."foo"="efg"."bar" ' + 'ORDER BY DATE("abc"."foo")', + str(test_query), + ) + + def test_join_from_join(self): + test_query = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.efg_id == self.table_efg.id) + .join(self.table_hij) + .on(self.table_efg.hij_id == self.table_hij.id) + .select(self.table_abc.foo, self.table_efg.bar, self.table_hij.fizz) + ) + + self.assertEqual( + 'SELECT "abc"."foo","efg"."bar","hij"."fizz" FROM "abc" ' + 'JOIN "efg" ON "abc"."efg_id"="efg"."id" ' + 'JOIN "hij" ON "efg"."hij_id"="hij"."id"', + str(test_query), + ) + + def test_join_query_without_alias(self): + subquery = Query.from_(self.table_efg).select( + self.table_efg.base_id.as_("x"), self.table_efg.fizz, self.table_efg.buzz + ) + + test_query = ( + Query.from_(self.table_abc) + .join(subquery) + .on(subquery.x == self.table_abc.id) + .select(self.table_abc.foo, subquery.fizz, subquery.buzz) + ) + + self.assertEqual( + 'SELECT "abc"."foo","sq0"."fizz","sq0"."buzz" ' + 'FROM "abc" JOIN (' + 'SELECT "base_id" "x","fizz","buzz" FROM "efg"' + ') "sq0" ' + 'ON "sq0"."x"="abc"."id"', + str(test_query), + ) + + def test_join_query_with_column_alias(self): + subquery = ( + Query.from_(self.table_efg) + .select( + self.table_efg.base_id.as_("x"), + self.table_efg.fizz, + self.table_efg.buzz, + ) + .as_("subq") + ) + + test_query = ( + Query.from_(self.table_abc) + .join(subquery) + .on(subquery.x == self.table_abc.id) + .select(self.table_abc.foo, subquery.fizz, subquery.buzz) + ) + + self.assertEqual( + 'SELECT "abc"."foo","subq"."fizz","subq"."buzz" ' + 'FROM "abc" JOIN (' + 'SELECT "base_id" "x","fizz","buzz" FROM "efg"' + ') "subq" ' + 'ON "subq"."x"="abc"."id"', + str(test_query), + ) + + def test_join_query_with_table_alias(self): + xxx = self.table_efg.as_("xxx") + subquery = Query.from_(xxx).select(xxx.base_id, xxx.fizz, xxx.buzz).as_("subq") + + test_query = ( + Query.from_(self.table_abc) + .join(subquery) + .on(subquery.x == self.table_abc.id) + .select(self.table_abc.foo, subquery.fizz, subquery.buzz) + ) + + self.assertEqual( + 'SELECT "abc"."foo","subq"."fizz","subq"."buzz" ' + 'FROM "abc" JOIN (' + 'SELECT "xxx"."base_id","xxx"."fizz","xxx"."buzz" FROM "efg" "xxx"' + ') "subq" ' + 'ON "subq"."x"="abc"."id"', + str(test_query), + ) + + def test_join_query_with_setoperation(self): + subquery = Query.from_(self.table_abc).select("*").union(Query.from_(self.table_abc).select("*")).as_("subq") + + test_query = ( + Query.from_(self.table_abc).join(subquery).on(subquery.x == self.table_abc.id).select(self.table_abc.foo) + ) + + self.assertEqual( + 'SELECT "abc"."foo" FROM "abc" ' + 'JOIN ' + '((SELECT * FROM "abc") ' + 'UNION ' + '(SELECT * FROM "abc")) "subq" ' + 'ON "subq"."x"="abc"."id"', + str(test_query), + ) + + +class UnionTests(unittest.TestCase): + table1, table2 = Tables("abc", "efg") + + def test_union(self): + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + + self.assertEqual( + '(SELECT "foo" FROM "abc") UNION (SELECT "bar" FROM "efg")', + str(query1 + query2), + ) + self.assertEqual( + '(SELECT "foo" FROM "abc") UNION (SELECT "bar" FROM "efg")', + str(query1.union(query2)), + ) + + def test_union_multiple(self): + table3, table4 = Tables("hij", "lmn") + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + query3 = Query.from_(table3).select(table3.baz) + query4 = Query.from_(table4).select(table4.faz) + + self.assertEqual( + '(SELECT "foo" FROM "abc") UNION ' + '(SELECT "bar" FROM "efg") UNION ' + '(SELECT "baz" FROM "hij") UNION ' + '(SELECT "faz" FROM "lmn")', + str(query1 + query2 + query3 + query4), + ) + self.assertEqual( + '(SELECT "foo" FROM "abc") UNION ' + '(SELECT "bar" FROM "efg") UNION ' + '(SELECT "baz" FROM "hij") UNION ' + '(SELECT "faz" FROM "lmn")', + str(query1.union(query2).union(query3).union(query4)), + ) + + def test_union_all(self): + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + + self.assertEqual( + '(SELECT "foo" FROM "abc") UNION ALL (SELECT "bar" FROM "efg")', + str(query1 * query2), + ) + self.assertEqual( + '(SELECT "foo" FROM "abc") UNION ALL (SELECT "bar" FROM "efg")', + str(query1.union_all(query2)), + ) + + def test_union_all_multiple(self): + table3, table4 = Tables("hij", "lmn") + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + query3 = Query.from_(table3).select(table3.baz) + query4 = Query.from_(table4).select(table4.faz) + + self.assertEqual( + '(SELECT "foo" FROM "abc") UNION ALL ' + '(SELECT "bar" FROM "efg") UNION ALL ' + '(SELECT "baz" FROM "hij") UNION ALL ' + '(SELECT "faz" FROM "lmn")', + str(query1 * query2 * query3 * query4), + ) + self.assertEqual( + '(SELECT "foo" FROM "abc") UNION ALL ' + '(SELECT "bar" FROM "efg") UNION ALL ' + '(SELECT "baz" FROM "hij") UNION ALL ' + '(SELECT "faz" FROM "lmn")', + str(query1.union_all(query2).union_all(query3).union_all(query4)), + ) + + def test_union_with_order_by(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + union_query = str((query1 + query2).orderby(query1.field("a"))) + union_all_query = str((query1 * query2).orderby(query1.field("a"))) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "UNION " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "a"', + union_query, + ) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "UNION ALL " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "a"', + union_all_query, + ) + + def test_union_with_order_by_use_union_query_field(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + union_query = query1 + query2 + union_query = str(union_query.orderby(union_query.field("a"))) + union_all_query = query1 * query2 + union_all_query = str(union_all_query.orderby(union_all_query.field("a"))) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "UNION " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "a"', + union_query, + ) + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "UNION ALL " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "a"', + union_all_query, + ) + + def test_union_with_order_by_with_aliases(self): + query1 = Query.from_(self.table1.as_("a")).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2.as_("b")).select(self.table2.bar.as_("a")) + + union_all_query = str((query1 * query2).orderby(query1.field("a"))) + union_query = str((query1 + query2).orderby(query1.field("a"))) + self.assertEqual( + '(SELECT "foo" "a" FROM "abc" "a")' " UNION ALL " '(SELECT "bar" "a" FROM "efg" "b")' ' ORDER BY "a"', + union_all_query, + ) + self.assertEqual( + '(SELECT "foo" "a" FROM "abc" "a")' " UNION " '(SELECT "bar" "a" FROM "efg" "b")' ' ORDER BY "a"', + union_query, + ) + + def test_union_with_order_by_use_union_query_field_with_aliases(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + union_query = (query1 + query2).as_("x") + union_query = union_query.orderby(union_query.field("a")) + union_all_query = (query1 * query2).as_("x") + union_all_query = union_all_query.orderby(union_all_query.field("a")) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "UNION " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "x"."a"', + str(union_query), + ) + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "UNION ALL " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "x"."a"', + str(union_all_query), + ) + + def test_require_equal_number_of_fields(self): + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.fiz, self.table2.buz) + + with self.assertRaises(SetOperationException): + str(query1 + query2) + + def test_mysql_query_wraps_unioned_queries(self): + query1 = MySQLQuery.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + + self.assertEqual( + "(SELECT `foo` FROM `abc`) UNION (SELECT `bar` FROM `efg`)", + str(query1 + query2), + ) + + def test_union_as_subquery(self): + abc, efg = Tables("abc", "efg") + hij = Query.from_(abc).select(abc.t).union(Query.from_(efg).select(efg.t)) + q = Query.from_(hij).select(fn.Avg(hij.t)) + + self.assertEqual( + 'SELECT AVG("sq0"."t") FROM ((SELECT "t" FROM "abc") UNION (SELECT "t" FROM "efg")) "sq0"', + str(q), + ) + + def test_union_with_no_quote_char(self): + abc, efg = Tables("abc", "efg") + hij = Query.from_(abc).select(abc.t).union(Query.from_(efg).select(efg.t)) + q = Query.from_(hij).select(fn.Avg(hij.t)) + + self.assertEqual( + "SELECT AVG(sq0.t) FROM ((SELECT t FROM abc) UNION (SELECT t FROM efg)) sq0", + q.get_sql(quote_char=None), + ) + + +class InsertQueryJoinTests(unittest.TestCase): + def test_join_table_on_insert_query(self): + a, b, c = Tables("a", "b", "c") + q = Query.into(c).from_(a).join(b).on(a.fkey_id == b.id).where(b.foo == 1).select("a.*", "b.*") + + self.assertEqual( + 'INSERT INTO "c" ' + 'SELECT "a"."a.*","a"."b.*" ' + 'FROM "a" JOIN "b" ' + 'ON "a"."fkey_id"="b"."id" ' + 'WHERE "b"."foo"=1', + str(q), + ) + + +class UpdateQueryJoinTests(unittest.TestCase): + def test_join_table_on_update_query(self): + a, b = Tables("a", "b") + q = Query.update(a).join(b).on(a.fkey_id == b.id).where(b.foo == 1).set("adwords_batch_job_id", 1) + + self.assertEqual( + 'UPDATE "a" ' 'JOIN "b" ' 'ON "a"."fkey_id"="b"."id" ' 'SET "adwords_batch_job_id"=1 ' 'WHERE "b"."foo"=1', + str(q), + ) + + +class IntersectTests(unittest.TestCase): + table1, table2 = Tables("abc", "efg") + + def test_intersect(self): + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + + self.assertEqual( + '(SELECT "foo" FROM "abc") INTERSECT (SELECT "bar" FROM "efg")', + str(query1.intersect(query2)), + ) + + def test_intersect_multiple(self): + table3, table4 = Tables("hij", "lmn") + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + query3 = Query.from_(table3).select(table3.baz) + query4 = Query.from_(table4).select(table4.faz) + + self.assertEqual( + '(SELECT "foo" FROM "abc") INTERSECT ' + '(SELECT "bar" FROM "efg") INTERSECT ' + '(SELECT "baz" FROM "hij") INTERSECT ' + '(SELECT "faz" FROM "lmn")', + str(query1.intersect(query2).intersect(query3).intersect(query4)), + ) + + def test_intersect_with_order_by(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + intersect_query = str((query1.intersect(query2)).orderby(query1.field("a"))) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "INTERSECT " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "a"', + intersect_query, + ) + + def test_intersect_with_limit(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + intersect_query = str((query1.intersect(query2)).limit(10)) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "INTERSECT " '(SELECT "bar" "a" FROM "efg") ' 'LIMIT 10', + intersect_query, + ) + + def test_intersect_with_offset(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + intersect_query = str((query1.intersect(query2)).offset(10)) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "INTERSECT " '(SELECT "bar" "a" FROM "efg") ' 'OFFSET 10', + intersect_query, + ) + + def test_require_equal_number_of_fields_intersect(self): + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.fiz, self.table2.buz) + + with self.assertRaises(SetOperationException): + str(query1.intersect(query2)) + + def test_mysql_query_wraps_intersected_queries(self): + query1 = MySQLQuery.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + + self.assertEqual( + "(SELECT `foo` FROM `abc`) INTERSECT (SELECT `bar` FROM `efg`)", + str(query1.intersect(query2)), + ) + + def test_intersect_as_subquery(self): + abc, efg = Tables("abc", "efg") + hij = Query.from_(abc).select(abc.t).intersect(Query.from_(efg).select(efg.t)) + q = Query.from_(hij).select(fn.Avg(hij.t)) + + self.assertEqual( + 'SELECT AVG("sq0"."t") FROM ((SELECT "t" FROM "abc") INTERSECT (SELECT "t" FROM "efg")) "sq0"', + str(q), + ) + + def test_intersect_with_no_quote_char(self): + abc, efg = Tables("abc", "efg") + hij = Query.from_(abc).select(abc.t).intersect(Query.from_(efg).select(efg.t)) + q = Query.from_(hij).select(fn.Avg(hij.t)) + + self.assertEqual( + "SELECT AVG(sq0.t) FROM ((SELECT t FROM abc) INTERSECT (SELECT t FROM efg)) sq0", + q.get_sql(quote_char=None), + ) + + +class MinusTests(unittest.TestCase): + table1, table2 = Tables("abc", "efg") + + def test_minus(self): + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + + self.assertEqual('(SELECT "foo" FROM "abc") MINUS (SELECT "bar" FROM "efg")', str(query1.minus(query2))) + + self.assertEqual( + '(SELECT "foo" FROM "abc") MINUS (SELECT "bar" FROM "efg")', + str(query1 - query2), + ) + + def test_minus_multiple(self): + table3, table4 = Tables("hij", "lmn") + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + query3 = Query.from_(table3).select(table3.baz) + query4 = Query.from_(table4).select(table4.faz) + + self.assertEqual( + '(SELECT "foo" FROM "abc") MINUS ' + '(SELECT "bar" FROM "efg") MINUS ' + '(SELECT "baz" FROM "hij") MINUS ' + '(SELECT "faz" FROM "lmn")', + str(query1 - query2 - query3 - query4), + ) + + self.assertEqual( + '(SELECT "foo" FROM "abc") MINUS ' + '(SELECT "bar" FROM "efg") MINUS ' + '(SELECT "baz" FROM "hij") MINUS ' + '(SELECT "faz" FROM "lmn")', + str(query1.minus(query2).minus(query3).minus(query4)), + ) + + def test_minus_with_order_by(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + minus_query = str(query1.minus(query2).orderby(query1.field("a"))) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "MINUS " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "a"', minus_query + ) + + def test_minus_query_with_order_by_use_minus_query_field(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + minus_query = query1.minus(query2) + minus_query = str(minus_query.orderby(minus_query.field("b"))) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "MINUS " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "b"', + minus_query, + ) + + def test_require_equal_number_of_fields(self): + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.fiz, self.table2.buz) + + with self.assertRaises(SetOperationException): + str(query1.minus(query2)) + + def test_mysql_query_wraps_minus_queries(self): + query1 = MySQLQuery.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + + self.assertEqual( + "(SELECT `foo` FROM `abc`) MINUS (SELECT `bar` FROM `efg`)", + str(query1 - query2), + ) + + def test_minus_as_subquery(self): + abc, efg = Tables("abc", "efg") + hij = Query.from_(abc).select(abc.t).minus(Query.from_(efg).select(efg.t)) + q = Query.from_(hij).select(fn.Avg(hij.t)) + + self.assertEqual( + 'SELECT AVG("sq0"."t") FROM ((SELECT "t" FROM "abc") MINUS (SELECT "t" FROM "efg")) "sq0"', + str(q), + ) + + def test_minus_with_no_quote_char(self): + abc, efg = Tables("abc", "efg") + hij = Query.from_(abc).select(abc.t).minus(Query.from_(efg).select(efg.t)) + q = Query.from_(hij).select(fn.Avg(hij.t)) + + self.assertEqual( + "SELECT AVG(sq0.t) FROM ((SELECT t FROM abc) MINUS (SELECT t FROM efg)) sq0", + q.get_sql(quote_char=None), + ) + + +class ExceptOfTests(unittest.TestCase): + table1, table2 = Tables("abc", "efg") + + def test_except(self): + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + + self.assertEqual('(SELECT "foo" FROM "abc") EXCEPT (SELECT "bar" FROM "efg")', str(query1.except_of(query2))) + + def test_except_multiple(self): + table3, table4 = Tables("hij", "lmn") + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + query3 = Query.from_(table3).select(table3.baz) + query4 = Query.from_(table4).select(table4.faz) + + self.assertEqual( + '(SELECT "foo" FROM "abc") EXCEPT ' + '(SELECT "bar" FROM "efg") EXCEPT ' + '(SELECT "baz" FROM "hij") EXCEPT ' + '(SELECT "faz" FROM "lmn")', + str(query1.except_of(query2).except_of(query3).except_of(query4)), + ) + + def test_except_with_order_by(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + except_query = str(query1.except_of(query2).orderby(query1.field("a"))) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "EXCEPT " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "a"', except_query + ) + + def test_except_query_with_order_by_use_minus_query_field(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + except_query = query1.except_of(query2) + except_query = str(except_query.orderby(except_query.field("b"))) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "EXCEPT " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "b"', + except_query, + ) + + def test_require_equal_number_of_fields_except_of(self): + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.fiz, self.table2.buz) + + with self.assertRaises(SetOperationException): + str(query1.except_of(query2)) + + def test_except_as_subquery(self): + abc, efg = Tables("abc", "efg") + hij = Query.from_(abc).select(abc.t).except_of(Query.from_(efg).select(efg.t)) + q = Query.from_(hij).select(fn.Avg(hij.t)) + + self.assertEqual( + 'SELECT AVG("sq0"."t") FROM ((SELECT "t" FROM "abc") EXCEPT (SELECT "t" FROM "efg")) "sq0"', + str(q), + ) + + def test_except_with_no_quote_char(self): + abc, efg = Tables("abc", "efg") + hij = Query.from_(abc).select(abc.t).except_of(Query.from_(efg).select(efg.t)) + q = Query.from_(hij).select(fn.Avg(hij.t)) + + self.assertEqual( + "SELECT AVG(sq0.t) FROM ((SELECT t FROM abc) EXCEPT (SELECT t FROM efg)) sq0", + q.get_sql(quote_char=None), + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/test_negation.py b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/test_negation.py new file mode 100644 index 0000000000000000000000000000000000000000..9f4db83b560dbc8546ce6d384b781dfccefd319d --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/test_negation.py @@ -0,0 +1,31 @@ +import unittest + +from pypika import ( + Tables, + functions as fn, +) +from pypika.terms import ValueWrapper + + +class NegationTests(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_negate_wrapped_float(self): + q = -ValueWrapper(1.0) + + self.assertEqual("-1.0", q.get_sql()) + + def test_negate_wrapped_int(self): + q = -ValueWrapper(1) + + self.assertEqual("-1", q.get_sql()) + + def test_negate_field(self): + q = -self.table_abc.foo + + self.assertEqual('-"abc"."foo"', q.get_sql(with_namespace=True, quote_char='"')) + + def test_negate_function(self): + q = -fn.Sum(self.table_abc.foo) + + self.assertEqual('-SUM("abc"."foo")', q.get_sql(with_namespace=True, quote_char='"')) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/test_parameter.py b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/test_parameter.py new file mode 100644 index 0000000000000000000000000000000000000000..c11e9afcd9624abb0a7313306eda34ebcf4c99ba --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/test_parameter.py @@ -0,0 +1,206 @@ +import unittest +from datetime import date + +from pypika import ( + FormatParameter, + NamedParameter, + NumericParameter, + Parameter, + PyformatParameter, + QmarkParameter, + Query, + Tables, +) +from pypika.terms import ListParameter, ParameterValueWrapper + + +class ParametrizedTests(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_param_insert(self): + q = Query.into(self.table_abc).columns("a", "b", "c").insert(Parameter("?"), Parameter("?"), Parameter("?")) + + self.assertEqual('INSERT INTO "abc" ("a","b","c") VALUES (?,?,?)', q.get_sql()) + + def test_param_select_join(self): + q = ( + Query.from_(self.table_abc) + .select("*") + .where(self.table_abc.category == Parameter("%s")) + .join(self.table_efg) + .on(self.table_abc.id == self.table_efg.abc_id) + .where(self.table_efg.date >= Parameter("%s")) + .limit(10) + ) + + self.assertEqual( + 'SELECT * FROM "abc" JOIN "efg" ON "abc"."id"="efg"."abc_id" WHERE "abc"."category"=%s AND "efg"."date">=%s LIMIT 10', + q.get_sql(), + ) + + def test_param_select_subquery(self): + q = ( + Query.from_(self.table_abc) + .select("*") + .where(self.table_abc.category == Parameter("&1")) + .where( + self.table_abc.id.isin( + Query.from_(self.table_efg) + .select(self.table_efg.abc_id) + .where(self.table_efg.date >= Parameter("&2")) + ) + ) + .limit(10) + ) + + self.assertEqual( + 'SELECT * FROM "abc" WHERE "category"=&1 AND "id" IN (SELECT "abc_id" FROM "efg" WHERE "date">=&2) LIMIT 10', + q.get_sql(), + ) + + def test_join(self): + subquery = ( + Query.from_(self.table_efg) + .select(self.table_efg.fiz, self.table_efg.buz) + .where(self.table_efg.buz == Parameter(":buz")) + ) + + q = ( + Query.from_(self.table_abc) + .join(subquery) + .on(self.table_abc.bar == subquery.buz) + .select(self.table_abc.foo, subquery.fiz) + .where(self.table_abc.bar == Parameter(":bar")) + ) + + self.assertEqual( + 'SELECT "abc"."foo","sq0"."fiz" FROM "abc" JOIN (SELECT "fiz","buz" FROM "efg" WHERE "buz"=:buz)' + ' "sq0" ON "abc"."bar"="sq0"."buz" WHERE "abc"."bar"=:bar', + q.get_sql(), + ) + + def test_qmark_parameter(self): + self.assertEqual('?', QmarkParameter().get_sql()) + + def test_numeric_parameter(self): + self.assertEqual(':14', NumericParameter('14').get_sql()) + self.assertEqual(':15', NumericParameter(15).get_sql()) + + def test_named_parameter(self): + self.assertEqual(':buz', NamedParameter('buz').get_sql()) + + def test_format_parameter(self): + self.assertEqual('%s', FormatParameter().get_sql()) + + def test_pyformat_parameter(self): + self.assertEqual('%(buz)s', PyformatParameter('buz').get_sql()) + + +class ParametrizedTestsWithValues(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_param_insert(self): + q = Query.into(self.table_abc).columns("a", "b", "c").insert(1, 2.2, 'foo') + + parameter = QmarkParameter() + sql = q.get_sql(parameter=parameter) + self.assertEqual('INSERT INTO "abc" ("a","b","c") VALUES (?,?,?)', sql) + self.assertEqual([1, 2.2, 'foo'], parameter.get_parameters()) + + def test_param_select_join(self): + q = ( + Query.from_(self.table_abc) + .select("*") + .where(self.table_abc.category == 'foobar') + .join(self.table_efg) + .on(self.table_abc.id == self.table_efg.abc_id) + .where(self.table_efg.date >= date(2024, 2, 22)) + .limit(10) + ) + + parameter = FormatParameter() + sql = q.get_sql(parameter=parameter) + self.assertEqual( + 'SELECT * FROM "abc" JOIN "efg" ON "abc"."id"="efg"."abc_id" WHERE "abc"."category"=%s AND "efg"."date">=%s LIMIT 10', + sql, + ) + self.assertEqual(['foobar', '2024-02-22'], parameter.get_parameters()) + + def test_param_select_subquery(self): + q = ( + Query.from_(self.table_abc) + .select("*") + .where(self.table_abc.category == 'foobar') + .where( + self.table_abc.id.isin( + Query.from_(self.table_efg) + .select(self.table_efg.abc_id) + .where(self.table_efg.date >= date(2024, 2, 22)) + ) + ) + .limit(10) + ) + + parameter = ListParameter(placeholder=lambda idx: f'&{idx+1}') + sql = q.get_sql(parameter=parameter) + self.assertEqual( + 'SELECT * FROM "abc" WHERE "category"=&1 AND "id" IN (SELECT "abc_id" FROM "efg" WHERE "date">=&2) LIMIT 10', + sql, + ) + self.assertEqual(['foobar', '2024-02-22'], parameter.get_parameters()) + + def test_join(self): + subquery = ( + Query.from_(self.table_efg) + .select(self.table_efg.fiz, self.table_efg.buz) + .where(self.table_efg.buz == 'buz') + ) + + q = ( + Query.from_(self.table_abc) + .join(subquery) + .on(self.table_abc.bar == subquery.buz) + .select(self.table_abc.foo, subquery.fiz) + .where(self.table_abc.bar == 'bar') + ) + + parameter = NamedParameter() + sql = q.get_sql(parameter=parameter) + self.assertEqual( + 'SELECT "abc"."foo","sq0"."fiz" FROM "abc" JOIN (SELECT "fiz","buz" FROM "efg" WHERE "buz"=:param1)' + ' "sq0" ON "abc"."bar"="sq0"."buz" WHERE "abc"."bar"=:param2', + sql, + ) + self.assertEqual({'param1': 'buz', 'param2': 'bar'}, parameter.get_parameters()) + + def test_join_with_parameter_value_wrapper(self): + subquery = ( + Query.from_(self.table_efg) + .select(self.table_efg.fiz, self.table_efg.buz) + .where(self.table_efg.buz == ParameterValueWrapper(Parameter(':buz'), 'buz')) + ) + + q = ( + Query.from_(self.table_abc) + .join(subquery) + .on(self.table_abc.bar == subquery.buz) + .select(self.table_abc.foo, subquery.fiz) + .where(self.table_abc.bar == ParameterValueWrapper(NamedParameter('bar'), 'bar')) + ) + + parameter = NamedParameter() + sql = q.get_sql(parameter=parameter) + self.assertEqual( + 'SELECT "abc"."foo","sq0"."fiz" FROM "abc" JOIN (SELECT "fiz","buz" FROM "efg" WHERE "buz"=:buz)' + ' "sq0" ON "abc"."bar"="sq0"."buz" WHERE "abc"."bar"=:bar', + sql, + ) + self.assertEqual({':buz': 'buz', 'bar': 'bar'}, parameter.get_parameters()) + + def test_pyformat_parameter(self): + q = Query.into(self.table_abc).columns("a", "b", "c").insert(1, 2.2, 'foo') + + parameter = PyformatParameter() + sql = q.get_sql(parameter=parameter) + self.assertEqual('INSERT INTO "abc" ("a","b","c") VALUES (%(param1)s,%(param2)s,%(param3)s)', sql) + self.assertEqual({"param1": 1, "param2": 2.2, "param3": "foo"}, parameter.get_parameters()) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/test_pseudocolumns.py b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/test_pseudocolumns.py new file mode 100644 index 0000000000000000000000000000000000000000..6a25c70269b2ccc98ac3870ac64a43c8a32ddbe9 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/test_pseudocolumns.py @@ -0,0 +1,51 @@ +import unittest + +from pypika import Query, Table +from pypika.pseudocolumns import ( + ColumnValue, + ObjectID, + ObjectValue, + RowID, + RowNum, + SysDate, +) +from pypika.terms import PseudoColumn + + +class PseudoColumnsTest(unittest.TestCase): + @classmethod + def setUpClass(cls): + super(PseudoColumnsTest, cls).setUpClass() + cls.table1 = Table("table1") + + def test_column_value(self): + self.assertEqual("COLUMN_VALUE", ColumnValue) + + def test_object_id(self): + self.assertEqual("OBJECT_ID", ObjectID) + + def test_object_value(self): + self.assertEqual("OBJECT_VALUE", ObjectValue) + + def test_row_id(self): + self.assertEqual("ROWID", RowID) + + def test_row_num(self): + self.assertEqual("ROWNUM", RowNum) + + def test_sys_date(self): + self.assertEqual("SYSDATE", SysDate) + + def test_can_be_used_in_a_select_statement(self): + query = Query.from_(self.table1).where(self.table1.is_active == 1).select(PseudoColumn("abcde")) + + self.assertEqual(str(query), 'SELECT abcde FROM "table1" WHERE "is_active"=1') + + def test_can_be_used_in_a_where_clause(self): + query = Query.from_(self.table1).where(PseudoColumn("abcde") > 1).select(self.table1.is_active) + + self.assertEqual(str(query), 'SELECT "is_active" FROM "table1" WHERE abcde>1') + + def test_can_be_used_in_orderby(self): + query = Query.from_(self.table1).select(self.table1.abcde.as_("some_name")).orderby(PseudoColumn("some_name")) + self.assertEqual(str(query), 'SELECT "abcde" "some_name" FROM "table1" ORDER BY some_name') diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/test_query.py b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/test_query.py new file mode 100644 index 0000000000000000000000000000000000000000..ae8dc01599a6a562b591ce15391bfe9b5c87e0f9 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/test_query.py @@ -0,0 +1,242 @@ +import unittest + +from pypika import Case, Query, Tables, Tuple, functions, Field +from pypika.dialects import ( + ClickHouseQuery, + ClickHouseQueryBuilder, + MSSQLQuery, + MSSQLQueryBuilder, + MySQLLoadQueryBuilder, + MySQLQuery, + MySQLQueryBuilder, + OracleQuery, + OracleQueryBuilder, + PostgreSQLQuery, + PostgreSQLQueryBuilder, + RedShiftQueryBuilder, + RedshiftQuery, + SQLLiteQuery, + SQLLiteQueryBuilder, + SnowflakeQuery, + SnowflakeQueryBuilder, + VerticaCopyQueryBuilder, + VerticaCreateQueryBuilder, + VerticaQuery, + VerticaQueryBuilder, +) +from pypika.queries import CreateQueryBuilder, DropQueryBuilder, QueryBuilder + + +class QueryTablesTests(unittest.TestCase): + table_a, table_b, table_c, table_d = Tables("a", "b", "c", "d") + + def test_replace_table(self): + query = Query.from_(self.table_a).select(self.table_a.time) + query = query.replace_table(self.table_a, self.table_b) + + self.assertEqual('SELECT "time" FROM "b"', str(query)) + + def test_replace_only_specified_table(self): + query = Query.from_(self.table_a).select(self.table_a.time) + query = query.replace_table(self.table_b, self.table_c) + + self.assertEqual('SELECT "time" FROM "a"', str(query)) + + def test_replace_insert_table(self): + query = Query.into(self.table_a).insert(1) + query = query.replace_table(self.table_a, self.table_b) + + self.assertEqual('INSERT INTO "b" VALUES (1)', str(query)) + + def test_replace_insert_table_current_table_not_match(self): + query = Query.into(self.table_a).insert(1) + query = query.replace_table(self.table_c, self.table_b) + + self.assertEqual('INSERT INTO "a" VALUES (1)', str(query)) + + def test_replace_update_table(self): + query = Query.update(self.table_a).set("foo", "bar") + query = query.replace_table(self.table_a, self.table_b) + + self.assertEqual('UPDATE "b" SET "foo"=\'bar\'', str(query)) + + def test_replace_update_table_current_table_not_match(self): + query = Query.update(self.table_a).set("foo", "bar") + query = query.replace_table(self.table_c, self.table_b) + + self.assertEqual('UPDATE "a" SET "foo"=\'bar\'', str(query)) + + def test_replace_delete_table(self): + query = Query.from_(self.table_a).delete() + query = query.replace_table(self.table_a, self.table_b) + + self.assertEqual('DELETE FROM "b"', str(query)) + + def test_replace_join_tables(self): + query = ( + Query.from_(self.table_a) + .join(self.table_b) + .on(self.table_a.customer_id == self.table_b.id) + .join(self.table_c) + .on(self.table_b.seller_id == self.table_c.id) + .select(self.table_a.star) + ) + query = query.replace_table(self.table_a, self.table_d) + + self.assertEqual( + 'SELECT "d".* ' + 'FROM "d" ' + 'JOIN "b" ON "d"."customer_id"="b"."id" ' + 'JOIN "c" ON "b"."seller_id"="c"."id"', + str(query), + ) + + def test_replace_filter_tables(self): + query = Query.from_(self.table_a).select(self.table_a.name).where(self.table_a.name == "Mustermann") + query = query.replace_table(self.table_a, self.table_b) + + self.assertEqual('SELECT "name" FROM "b" WHERE "name"=\'Mustermann\'', str(query)) + + def test_replace_having_table(self): + query = ( + Query.from_(self.table_a) + .select(functions.Sum(self.table_a.revenue)) + .groupby(self.table_a.customer) + .having(functions.Sum(self.table_a.revenue) >= 1000) + ) + query = query.replace_table(self.table_a, self.table_b) + + self.assertEqual( + 'SELECT SUM("revenue") ' 'FROM "b" ' 'GROUP BY "customer" ' 'HAVING SUM("revenue")>=1000', + str(query), + ) + + def test_replace_case_table(self): + query = Query.from_(self.table_a).select( + Case() + .when(self.table_a.fname == "Tom", "It was Tom") + .when(self.table_a.fname == "John", "It was John") + .else_("It was someone else.") + .as_("who_was_it") + ) + query = query.replace_table(self.table_a, self.table_b) + + self.assertEqual( + "SELECT CASE " + "WHEN \"fname\"='Tom' THEN 'It was Tom' " + "WHEN \"fname\"='John' THEN 'It was John' " + "ELSE 'It was someone else.' END \"who_was_it\" " + 'FROM "b"', + str(query), + ) + + def test_replace_orderby_table(self): + query = Query.from_(self.table_a).select(self.table_a.customer).orderby(self.table_a.customer) + query = query.replace_table(self.table_a, self.table_b) + + self.assertEqual('SELECT "customer" FROM "b" ORDER BY "customer"', str(query)) + + def test_replace_tuple_table(self): + query = ( + Query.from_(self.table_a) + .select(self.table_a.cost, self.table_a.revenue) + .where((self.table_a.cost, self.table_a.revenue) == Tuple(1, 2)) + ) + + query = query.replace_table(self.table_a, self.table_b) + + # Order is reversed due to lack of right equals method + self.assertEqual( + 'SELECT "cost","revenue" FROM "b" WHERE (1,2)=("cost","revenue")', + str(query), + ) + + def test_is_joined(self): + q = Query.from_(self.table_a).join(self.table_b).on(self.table_a.foo == self.table_b.boo) + + self.assertTrue(q.is_joined(self.table_b)) + self.assertFalse(q.is_joined(self.table_c)) + + +class QueryBuilderTests(unittest.TestCase): + def test_query_builders_have_reference_to_correct_query_class(self): + with self.subTest('QueryBuilder'): + self.assertEqual(Query, QueryBuilder.QUERY_CLS) + + with self.subTest('DropQueryBuilder'): + self.assertEqual(Query, DropQueryBuilder.QUERY_CLS) + + with self.subTest('CreateQueryBuilder'): + self.assertEqual(Query, CreateQueryBuilder.QUERY_CLS) + + with self.subTest('MySQLQueryBuilder'): + self.assertEqual(MySQLQuery, MySQLQueryBuilder.QUERY_CLS) + + with self.subTest('MySQLLoadQueryBuilder'): + self.assertEqual(MySQLQuery, MySQLLoadQueryBuilder.QUERY_CLS) + + with self.subTest('VerticaQueryBuilder'): + self.assertEqual(VerticaQuery, VerticaQueryBuilder.QUERY_CLS) + + with self.subTest('VerticaCreateQueryBuilder'): + self.assertEqual(VerticaQuery, VerticaCreateQueryBuilder.QUERY_CLS) + + with self.subTest('VerticaCopyQueryBuilder'): + self.assertEqual(VerticaQuery, VerticaCopyQueryBuilder.QUERY_CLS) + + with self.subTest('PostgreSQLQueryBuilder'): + self.assertEqual(PostgreSQLQuery, PostgreSQLQueryBuilder.QUERY_CLS) + + with self.subTest('MSSQLQueryBuilder'): + self.assertEqual(MSSQLQuery, MSSQLQueryBuilder.QUERY_CLS) + + with self.subTest('SnowflakeQueryBuilder'): + self.assertEqual(SnowflakeQuery, SnowflakeQueryBuilder.QUERY_CLS) + + with self.subTest('ClickHouseQueryBuilder'): + self.assertEqual(ClickHouseQuery, ClickHouseQueryBuilder.QUERY_CLS) + + with self.subTest('RedShiftQueryBuilder'): + self.assertEqual(RedshiftQuery, RedShiftQueryBuilder.QUERY_CLS) + + with self.subTest('SQLLiteQueryBuilder'): + self.assertEqual(SQLLiteQuery, SQLLiteQueryBuilder.QUERY_CLS) + + with self.subTest('OracleQueryBuilder'): + self.assertEqual(OracleQuery, OracleQueryBuilder.QUERY_CLS) + + def test_pipe(self) -> None: + base_query = Query.from_("test") + + def select(query: QueryBuilder) -> QueryBuilder: + return query.select("test1", "test2") + + def count_group(query: QueryBuilder, *groups) -> QueryBuilder: + return query.groupby(*groups).select(*groups, functions.Count("*")) + + for func, args, kwargs, expected_str in [ + (select, [], {}, 'SELECT "test1","test2" FROM "test"'), + ( + count_group, + ["test1", "test2"], + {}, + 'SELECT "test1","test2",COUNT(*) FROM "test" GROUP BY "test1","test2"', + ), + (count_group, ["test1"], {}, 'SELECT "test1",COUNT(*) FROM "test" GROUP BY "test1"'), + ]: + result_str = str(base_query.pipe(func, *args, **kwargs)) + self.assertEqual(result_str, str(func(base_query, *args, **kwargs))) + self.assertEqual(result_str, expected_str) + + def where_clause(query: QueryBuilder, num_days: int) -> QueryBuilder: + return query.where(Field("date") > functions.Now() - num_days) + + result_str = str(base_query.pipe(select).pipe(where_clause, num_days=1)) + self.assertEqual( + result_str, + str(select(where_clause(base_query, num_days=1))), + ) + self.assertEqual( + result_str, + 'SELECT "test1","test2" FROM "test" WHERE "date">NOW()-1', + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/test_selects.py b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/test_selects.py new file mode 100644 index 0000000000000000000000000000000000000000..1ce04937492e655db362b7e2a0a6856abf22a48f --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/test_selects.py @@ -0,0 +1,1331 @@ +import unittest +from datetime import date +from enum import Enum + +from pypika import ( + AliasedQuery, + Case, + ClickHouseQuery, + EmptyCriterion, + Field as F, + Index, + MSSQLQuery, + MySQLQuery, + NullValue, + OracleQuery, + Order, + PostgreSQLQuery, + Query, + QueryException, + RedshiftQuery, + SQLLiteQuery, + Table, + Tables, + VerticaQuery, + functions as fn, + SYSTEM_TIME, +) +from pypika.terms import ValueWrapper + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + + +class SelectTests(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_empty_query(self): + q = Query.from_("abc") + + self.assertEqual("", str(q)) + + def test_select_no_from(self): + q = Query.select(1) + + self.assertEqual("SELECT 1", str(q)) + + def test_select_no_with_alias_from(self): + q = Query.select(ValueWrapper(1, "test")) + + self.assertEqual('SELECT 1 "test"', str(q)) + + def test_select_no_from_with_field_raises_exception(self): + with self.assertRaises(QueryException): + Query.select("asdf") + + def test_select__star(self): + q = Query.from_("abc").select("*") + + self.assertEqual('SELECT * FROM "abc"', str(q)) + + def test_select__table_schema(self): + q = Query.from_(Table("abc", "schema1")).select("*") + + self.assertEqual('SELECT * FROM "schema1"."abc"', str(q)) + + def test_select__table_schema_with_multiple_levels_as_tuple(self): + q = Query.from_(Table("abc", ("schema1", "schema2"))).select("*") + + self.assertEqual('SELECT * FROM "schema1"."schema2"."abc"', str(q)) + + def test_select__table_schema_with_multiple_levels_as_list(self): + q = Query.from_(Table("abc", ["schema1", "schema2"])).select("*") + + self.assertEqual('SELECT * FROM "schema1"."schema2"."abc"', str(q)) + + def test_select__star__replacement(self): + q = Query.from_("abc").select("foo").select("*") + + self.assertEqual('SELECT * FROM "abc"', str(q)) + + def test_select__distinct__single(self): + q = Query.from_("abc").select("foo").distinct() + + self.assertEqual('SELECT DISTINCT "foo" FROM "abc"', str(q)) + + def test_select__distinct__multi(self): + q = Query.from_("abc").select("foo", "bar").distinct() + + self.assertEqual('SELECT DISTINCT "foo","bar" FROM "abc"', str(q)) + + def test_select__column__single__str(self): + q = Query.from_("abc").select("foo") + + self.assertEqual('SELECT "foo" FROM "abc"', str(q)) + + def test_select__column__single__alias__str(self): + q = Query.from_(self.table_abc).select(self.table_abc.foo.as_("bar")) + + self.assertEqual('SELECT "foo" "bar" FROM "abc"', str(q)) + + def test_select__column__single__table_alias__str(self): + q = Query.from_(self.table_abc.as_("fizzbuzz")).select(self.table_abc.foo.as_("bar")) + + self.assertEqual('SELECT "foo" "bar" FROM "abc" "fizzbuzz"', str(q)) + + def test_select__column__single__field(self): + t = Table("abc") + q = Query.from_(t).select(t.foo) + + self.assertEqual('SELECT "foo" FROM "abc"', str(q)) + + def test_select__columns__multi__str(self): + q1 = Query.from_("abc").select("foo", "bar") + q2 = Query.from_("abc").select("foo").select("bar") + + self.assertEqual('SELECT "foo","bar" FROM "abc"', str(q1)) + self.assertEqual('SELECT "foo","bar" FROM "abc"', str(q2)) + + def test_select__columns__multi__field(self): + q1 = Query.from_(self.table_abc).select(self.table_abc.foo, self.table_abc.bar) + q2 = Query.from_(self.table_abc).select(self.table_abc.foo).select(self.table_abc.bar) + + self.assertEqual('SELECT "foo","bar" FROM "abc"', str(q1)) + self.assertEqual('SELECT "foo","bar" FROM "abc"', str(q2)) + + def test_select__multiple_tables(self): + q = Query.from_(self.table_abc).select(self.table_abc.foo).from_(self.table_efg).select(self.table_efg.bar) + + self.assertEqual('SELECT "abc"."foo","efg"."bar" FROM "abc","efg"', str(q)) + + def test_select__subquery(self): + subquery = Query.from_(self.table_abc).select("*") + q = Query.from_(subquery).select(subquery.foo, subquery.bar) + + self.assertEqual('SELECT "sq0"."foo","sq0"."bar" ' 'FROM (SELECT * FROM "abc") "sq0"', str(q)) + + def test_select__multiple_subqueries(self): + subquery0 = Query.from_(self.table_abc).select("foo") + subquery1 = Query.from_(self.table_efg).select("bar") + q = Query.from_(subquery0).from_(subquery1).select(subquery0.foo, subquery1.bar) + + self.assertEqual( + 'SELECT "sq0"."foo","sq1"."bar" ' 'FROM (SELECT "foo" FROM "abc") "sq0",' '(SELECT "bar" FROM "efg") "sq1"', + str(q), + ) + + def test_select__nested_subquery(self): + subquery0 = Query.from_(self.table_abc).select("*") + subquery1 = Query.from_(subquery0).select(subquery0.foo, subquery0.bar) + subquery2 = Query.from_(subquery1).select(subquery1.foo) + + q = Query.from_(subquery2).select(subquery2.foo) + + self.assertEqual( + 'SELECT "sq2"."foo" ' + 'FROM (SELECT "sq1"."foo" ' + 'FROM (SELECT "sq0"."foo","sq0"."bar" ' + 'FROM (SELECT * FROM "abc") "sq0") "sq1") "sq2"', + str(q), + ) + + def test_select__no_table(self): + q = Query.select(1, 2, 3) + + self.assertEqual("SELECT 1,2,3", str(q)) + + def test_select_then_add_table(self): + q = Query.select(1).select(2, 3).from_("abc").select("foo") + + self.assertEqual('SELECT 1,2,3,"foo" FROM "abc"', str(q)) + + def test_select_with_limit(self): + q1 = Query.from_("abc").select("foo")[:10] + + self.assertEqual('SELECT "foo" FROM "abc" LIMIT 10', str(q1)) + + def test_select_with_limit_zero(self): + with self.subTest('using python slice'): + q1 = Query.from_("abc").select("foo")[:0] + self.assertEqual('SELECT "foo" FROM "abc" LIMIT 0', str(q1)) + + with self.subTest('using limit method'): + q2 = Query.from_("abc").select("foo").limit(0) + self.assertEqual('SELECT "foo" FROM "abc" LIMIT 0', str(q2)) + + def test_select_with_limit__func(self): + q1 = Query.from_("abc").select("foo").limit(10) + + self.assertEqual('SELECT "foo" FROM "abc" LIMIT 10', str(q1)) + + def test_select_with_offset(self): + q1 = Query.from_("abc").select("foo")[10:] + + self.assertEqual('SELECT "foo" FROM "abc" OFFSET 10', str(q1)) + + def test_select_with_offset__func(self): + q1 = Query.from_("abc").select("foo").offset(10) + + self.assertEqual('SELECT "foo" FROM "abc" OFFSET 10', str(q1)) + + def test_select_with_limit_and_offset(self): + q1 = Query.from_("abc").select("foo")[10:10] + + self.assertEqual('SELECT "foo" FROM "abc" LIMIT 10 OFFSET 10', str(q1)) + + def test_select_with_force_index(self): + q = Query.from_("abc").select("foo").force_index("egg") + + self.assertEqual('SELECT "foo" FROM "abc" FORCE INDEX ("egg")', str(q)) + + def test_select_with_force_index_with_index_object(self): + index = Index("egg") + q = Query.from_("abc").select("foo").force_index(index) + + self.assertEqual('SELECT "foo" FROM "abc" FORCE INDEX ("egg")', str(q)) + + def test_select_with_force_index_multiple_indexes(self): + q = Query.from_("abc").select("foo").force_index("egg", "bacon") + + self.assertEqual('SELECT "foo" FROM "abc" FORCE INDEX ("egg","bacon")', str(q)) + + def test_select_with_force_index_multiple_calls(self): + q = ( + Query.from_("abc") + .select("foo") + .force_index( + "egg", + ) + .force_index("spam") + ) + + self.assertEqual('SELECT "foo" FROM "abc" FORCE INDEX ("egg","spam")', str(q)) + + def test_select_with_use_index(self): + q = Query.from_("abc").select("foo").use_index("egg") + + self.assertEqual('SELECT "foo" FROM "abc" USE INDEX ("egg")', str(q)) + + def test_select_with_use_index_with_index_object(self): + index = Index("egg") + q = Query.from_("abc").select("foo").use_index(index) + + self.assertEqual('SELECT "foo" FROM "abc" USE INDEX ("egg")', str(q)) + + def test_select_with_use_index_multiple_indexes(self): + q = Query.from_("abc").select("foo").use_index("egg", "bacon") + + self.assertEqual('SELECT "foo" FROM "abc" USE INDEX ("egg","bacon")', str(q)) + + def test_select_with_use_index_multiple_calls(self): + q = ( + Query.from_("abc") + .select("foo") + .use_index( + "egg", + ) + .use_index("spam") + ) + + self.assertEqual('SELECT "foo" FROM "abc" USE INDEX ("egg","spam")', str(q)) + + def test_mysql_query_uses_backtick_quote_chars(self): + q = MySQLQuery.from_("abc").select("foo", "bar") + + self.assertEqual("SELECT `foo`,`bar` FROM `abc`", str(q)) + + def test_vertica_query_uses_double_quote_chars(self): + q = VerticaQuery.from_("abc").select("foo", "bar") + + self.assertEqual('SELECT "foo","bar" FROM "abc"', str(q)) + + def test_mssql_query_uses_double_quote_chars(self): + q = MSSQLQuery.from_("abc").select("foo", "bar") + + self.assertEqual('SELECT "foo","bar" FROM "abc"', str(q)) + + def test_oracle_query_uses_no_quote_chars(self): + q = OracleQuery.from_("abc").select("foo", "bar") + + self.assertEqual('SELECT foo,bar FROM abc', str(q)) + + def test_postgresql_query_uses_double_quote_chars(self): + q = PostgreSQLQuery.from_("abc").select("foo", "bar") + + self.assertEqual('SELECT "foo","bar" FROM "abc"', str(q)) + + def test_redshift_query_uses_double_quote_chars(self): + q = RedshiftQuery.from_("abc").select("foo", "bar") + + self.assertEqual('SELECT "foo","bar" FROM "abc"', str(q)) + + def test_table_select_alias(self): + q = self.table_abc.select(1) + + self.assertEqual('SELECT 1 FROM "abc"', str(q)) + self.assertEqual(q, Query.from_("abc").select(1)) + + def test_table_select_alias_with_offset_and_limit(self): + self.assertEqual(self.table_abc.select("foo")[10:10], Query.from_("abc").select("foo")[10:10]) + self.assertEqual( + self.table_abc.select(self.table_abc.foo)[10:10], + Query.from_("abc").select("foo")[10:10], + ) + + def test_temporal_select(self): + t = Table("abc") + + with self.subTest("with system time as of"): + q = Query.from_(t.for_(SYSTEM_TIME.as_of('2020-01-01'))).select("*") + + self.assertEqual('SELECT * FROM "abc" FOR SYSTEM_TIME AS OF \'2020-01-01\'', str(q)) + + with self.subTest("with system time between"): + q = Query.from_(t.for_(SYSTEM_TIME.between('2020-01-01', '2020-02-01'))).select("*") + + self.assertEqual('SELECT * FROM "abc" FOR SYSTEM_TIME BETWEEN \'2020-01-01\' AND \'2020-02-01\'', str(q)) + + with self.subTest("with system time from to"): + q = Query.from_(t.for_(SYSTEM_TIME.from_to('2020-01-01', '2020-02-01'))).select("*") + + self.assertEqual('SELECT * FROM "abc" FOR SYSTEM_TIME FROM \'2020-01-01\' TO \'2020-02-01\'', str(q)) + + with self.subTest("with ALL"): + q = Query.from_(t.for_(SYSTEM_TIME.all_())).select("*") + + self.assertEqual('SELECT * FROM "abc" FOR SYSTEM_TIME ALL', str(q)) + + with self.subTest("with period between"): + q = Query.from_(t.for_(t.valid_period.between('2020-01-01', '2020-02-01'))).select("*") + + self.assertEqual('SELECT * FROM "abc" FOR "valid_period" BETWEEN \'2020-01-01\' AND \'2020-02-01\'', str(q)) + + with self.subTest("with period from to"): + q = Query.from_(t.for_(t.valid_period.from_to('2020-01-01', '2020-02-01'))).select("*") + + self.assertEqual('SELECT * FROM "abc" FOR "valid_period" FROM \'2020-01-01\' TO \'2020-02-01\'', str(q)) + + with self.subTest("with ALL"): + q = Query.from_(t.for_(t.valid_period.all_())).select("*") + + self.assertEqual('SELECT * FROM "abc" FOR "valid_period" ALL', str(q)) + + +class MyEnum(Enum): + STR = "foo" + INT = 0 + BOOL = True + DATE = date(2020, 2, 2) + NONE = None + + +class WhereTests(unittest.TestCase): + t = Table("abc") + t2 = Table("cba") + + def test_where_enum(self): + q1 = Query.from_(self.t).select("*").where(self.t.foo == MyEnum.STR) + q2 = Query.from_(self.t).select("*").where(self.t.foo == MyEnum.INT) + q3 = Query.from_(self.t).select("*").where(self.t.foo == MyEnum.BOOL) + q4 = Query.from_(self.t).select("*").where(self.t.foo == MyEnum.DATE) + q5 = Query.from_(self.t).select("*").where(self.t.foo == MyEnum.NONE) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo"=\'foo\'', str(q1)) + self.assertEqual('SELECT * FROM "abc" WHERE "foo"=0', str(q2)) + self.assertEqual('SELECT * FROM "abc" WHERE "foo"=true', str(q3)) + self.assertEqual('SELECT * FROM "abc" WHERE "foo"=\'2020-02-02\'', str(q4)) + self.assertEqual('SELECT * FROM "abc" WHERE "foo"=null', str(q5)) + + def test_where_field_equals(self): + q1 = Query.from_(self.t).select("*").where(self.t.foo == self.t.bar) + q2 = Query.from_(self.t).select("*").where(self.t.foo.eq(self.t.bar)) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo"="bar"', str(q1)) + self.assertEqual('SELECT * FROM "abc" WHERE "foo"="bar"', str(q2)) + q = self.t.select("*").where(self.t.foo == self.t.bar) + self.assertEqual(q, q1) + + def test_where_field_equals_for_update(self): + q = Query.from_(self.t).select("*").where(self.t.foo == self.t.bar).for_update() + self.assertEqual('SELECT * FROM "abc" WHERE "foo"="bar" FOR UPDATE', str(q)) + + def test_where_field_equals_for_update_nowait(self): + for query_cls in [ + MySQLQuery, + PostgreSQLQuery, + ]: + quote_char = query_cls._builder().QUOTE_CHAR if isinstance(query_cls._builder().QUOTE_CHAR, str) else '"' + q = query_cls.from_(self.t).select("*").where(self.t.foo == self.t.bar).for_update(nowait=True) + self.assertEqual( + 'SELECT * ' + 'FROM {quote_char}abc{quote_char} ' + 'WHERE {quote_char}foo{quote_char}={quote_char}bar{quote_char} ' + 'FOR UPDATE NOWAIT'.format( + quote_char=quote_char, + ), + str(q), + ) + + def test_where_field_equals_for_update_skip_locked(self): + for query_cls in [ + MySQLQuery, + PostgreSQLQuery, + ]: + quote_char = query_cls._builder().QUOTE_CHAR if isinstance(query_cls._builder().QUOTE_CHAR, str) else '"' + q = query_cls.from_(self.t).select("*").where(self.t.foo == self.t.bar).for_update(skip_locked=True) + self.assertEqual( + 'SELECT * ' + 'FROM {quote_char}abc{quote_char} ' + 'WHERE {quote_char}foo{quote_char}={quote_char}bar{quote_char} ' + 'FOR UPDATE SKIP LOCKED'.format( + quote_char=quote_char, + ), + str(q), + ) + + def test_where_field_equals_for_update_of(self): + for query_cls in [ + MySQLQuery, + PostgreSQLQuery, + ]: + quote_char = query_cls._builder().QUOTE_CHAR if isinstance(query_cls._builder().QUOTE_CHAR, str) else '"' + q = query_cls.from_(self.t).select("*").where(self.t.foo == self.t.bar).for_update(of=("abc",)) + self.assertEqual( + 'SELECT * ' + 'FROM {quote_char}abc{quote_char} ' + 'WHERE {quote_char}foo{quote_char}={quote_char}bar{quote_char} ' + 'FOR UPDATE OF {quote_char}abc{quote_char}'.format( + quote_char=quote_char, + ), + str(q), + ) + + def test_where_field_equals_for_update_of_multiple_tables(self): + for query_cls in [ + MySQLQuery, + PostgreSQLQuery, + ]: + q = ( + query_cls.from_(self.t) + .join(self.t2) + .on(self.t.id == self.t2.abc_id) + .select("*") + .where(self.t.foo == self.t.bar) + .for_update(of=("abc", "cba")) + ) + quote_char = query_cls._builder().QUOTE_CHAR if isinstance(query_cls._builder().QUOTE_CHAR, str) else '"' + self.assertIn( + str(q), + [ + 'SELECT * ' + 'FROM {quote_char}abc{quote_char} ' + 'JOIN {quote_char}cba{quote_char} ' + 'ON {quote_char}abc{quote_char}.{quote_char}id{quote_char}=' + '{quote_char}cba{quote_char}.{quote_char}abc_id{quote_char} ' + 'WHERE {quote_char}abc{quote_char}.{quote_char}foo{quote_char}=' + '{quote_char}abc{quote_char}.{quote_char}bar{quote_char} ' + 'FOR UPDATE OF {quote_char}cba{quote_char}, {quote_char}abc{quote_char}'.format( + quote_char=quote_char, + ), + 'SELECT * ' + 'FROM {quote_char}abc{quote_char} ' + 'JOIN {quote_char}cba{quote_char} ' + 'ON {quote_char}abc{quote_char}.{quote_char}id{quote_char}=' + '{quote_char}cba{quote_char}.{quote_char}abc_id{quote_char} ' + 'WHERE {quote_char}abc{quote_char}.{quote_char}foo{quote_char}=' + '{quote_char}abc{quote_char}.{quote_char}bar{quote_char} ' + 'FOR UPDATE OF {quote_char}abc{quote_char}, {quote_char}cba{quote_char}'.format( + quote_char=quote_char, + ), + ], + ) + + def test_where_field_equals_for_update_of_nowait(self): + for query_cls in [ + MySQLQuery, + PostgreSQLQuery, + ]: + q = query_cls.from_(self.t).select("*").where(self.t.foo == self.t.bar).for_update(of=("abc",), nowait=True) + quote_char = query_cls._builder().QUOTE_CHAR if isinstance(query_cls._builder().QUOTE_CHAR, str) else '"' + self.assertEqual( + 'SELECT * ' + 'FROM {quote_char}abc{quote_char} ' + 'WHERE {quote_char}foo{quote_char}={quote_char}bar{quote_char} ' + 'FOR UPDATE OF {quote_char}abc{quote_char} NOWAIT'.format( + quote_char=quote_char, + ), + str(q), + ) + + def test_where_field_equals_for_update_of_skip_locked(self): + for query_cls in [ + MySQLQuery, + PostgreSQLQuery, + ]: + q = ( + query_cls.from_(self.t) + .select("*") + .where(self.t.foo == self.t.bar) + .for_update(of=("abc",), skip_locked=True) + ) + quote_char = query_cls._builder().QUOTE_CHAR if isinstance(query_cls._builder().QUOTE_CHAR, str) else '"' + self.assertEqual( + 'SELECT * ' + 'FROM {quote_char}abc{quote_char} ' + 'WHERE {quote_char}foo{quote_char}={quote_char}bar{quote_char} ' + 'FOR UPDATE OF {quote_char}abc{quote_char} SKIP LOCKED'.format( + quote_char=quote_char, + ), + str(q), + ) + + def test_where_field_equals_for_update_skip_locked_and_of(self): + for query_cls in [ + MySQLQuery, + PostgreSQLQuery, + ]: + q = ( + query_cls.from_(self.t) + .select("*") + .where(self.t.foo == self.t.bar) + .for_update(nowait=False, skip_locked=True, of=("abc",)) + ) + quote_char = query_cls._builder().QUOTE_CHAR if isinstance(query_cls._builder().QUOTE_CHAR, str) else '"' + self.assertEqual( + 'SELECT * ' + 'FROM {quote_char}abc{quote_char} ' + 'WHERE {quote_char}foo{quote_char}={quote_char}bar{quote_char} ' + 'FOR UPDATE OF {quote_char}abc{quote_char} SKIP LOCKED'.format( + quote_char=quote_char, + ), + str(q), + ) + + def test_where_field_equals_where(self): + q = Query.from_(self.t).select("*").where(self.t.foo == 1).where(self.t.bar == self.t.baz) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo"=1 AND "bar"="baz"', str(q)) + + def test_where_field_equals_where_not(self): + q = Query.from_(self.t).select("*").where((self.t.foo == 1).negate()).where(self.t.bar == self.t.baz) + + self.assertEqual('SELECT * FROM "abc" WHERE NOT "foo"=1 AND "bar"="baz"', str(q)) + + def test_where_field_equals_where_two_not(self): + q = Query.from_(self.t).select("*").where((self.t.foo == 1).negate()).where((self.t.bar == self.t.baz).negate()) + + self.assertEqual('SELECT * FROM "abc" WHERE NOT "foo"=1 AND NOT "bar"="baz"', str(q)) + + def test_where_single_quote(self): + q1 = Query.from_(self.t).select("*").where(self.t.foo == "bar'foo") + + self.assertEqual("SELECT * FROM \"abc\" WHERE \"foo\"='bar''foo'", str(q1)) + + def test_where_field_equals_and(self): + q = Query.from_(self.t).select("*").where((self.t.foo == 1) & (self.t.bar == self.t.baz)) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo"=1 AND "bar"="baz"', str(q)) + + def test_where_field_equals_or(self): + q = Query.from_(self.t).select("*").where((self.t.foo == 1) | (self.t.bar == self.t.baz)) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo"=1 OR "bar"="baz"', str(q)) + + def test_where_nested_conditions(self): + q = Query.from_(self.t).select("*").where((self.t.foo == 1) | (self.t.bar == self.t.baz)).where(self.t.baz == 0) + + self.assertEqual('SELECT * FROM "abc" WHERE ("foo"=1 OR "bar"="baz") AND "baz"=0', str(q)) + + def test_where_field_starts_with(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.like("ab%")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" LIKE \'ab%\'', str(q)) + + def test_where_field_contains(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.like("%fg%")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" LIKE \'%fg%\'', str(q)) + + def test_where_field_ends_with(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.like("%yz")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" LIKE \'%yz\'', str(q)) + + def test_where_field_is_n_chars_long(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.like("___")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" LIKE \'___\'', str(q)) + + def test_where_field_does_not_start_with(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.not_like("ab%")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" NOT LIKE \'ab%\'', str(q)) + + def test_where_field_does_not_contain(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.not_like("%fg%")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" NOT LIKE \'%fg%\'', str(q)) + + def test_where_field_does_not_end_with(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.not_like("%yz")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" NOT LIKE \'%yz\'', str(q)) + + def test_where_field_is_not_n_chars_long(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.not_like("___")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" NOT LIKE \'___\'', str(q)) + + def test_where_field_matches_regex(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.regex(r"^b")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" REGEX \'^b\'', str(q)) + + def test_where_field_matches_regexp(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.regexp(r"^b")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" REGEXP \'^b\'', str(q)) + + def test_where_field_matches_rlike(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.rlike(r"^b")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" RLIKE \'^b\'', str(q)) + + def test_ignore_empty_criterion_where(self): + q1 = Query.from_(self.t).select("*").where(EmptyCriterion()) + + self.assertEqual('SELECT * FROM "abc"', str(q1)) + + def test_ignore_empty_criterion_having(self): + q1 = Query.from_(self.t).select("*").having(EmptyCriterion()) + + self.assertEqual('SELECT * FROM "abc"', str(q1)) + + def test_select_with_force_index_and_where(self): + q = Query.from_("abc").select("foo").where(self.t.foo == self.t.bar).force_index("egg") + + self.assertEqual('SELECT "foo" FROM "abc" FORCE INDEX ("egg") WHERE "foo"="bar"', str(q)) + + def test_where_with_multiple_wheres_using_and_case(self): + case_stmt = Case().when(self.t.foo == 'bar', 1).else_(0) + query = Query.from_(self.t).select(case_stmt).where(case_stmt & self.t.blah.isin(['test'])) + + self.assertEqual( + 'SELECT CASE WHEN "foo"=\'bar\' THEN 1 ELSE 0 END FROM "abc" WHERE CASE WHEN "foo"=\'bar\' THEN 1 ELSE 0 ' + 'END AND "blah" IN (\'test\')', + str(query), + ) + + def test_where_with_multiple_wheres_using_or_case(self): + case_stmt = Case().when(self.t.foo == 'bar', 1).else_(0) + query = Query.from_(self.t).select(case_stmt).where(case_stmt | self.t.blah.isin(['test'])) + + self.assertEqual( + 'SELECT CASE WHEN "foo"=\'bar\' THEN 1 ELSE 0 END FROM "abc" WHERE CASE WHEN "foo"=\'bar\' THEN 1 ELSE 0 ' + 'END OR "blah" IN (\'test\')', + str(query), + ) + + +class PreWhereTests(WhereTests): + t = Table("abc") + + def test_prewhere_field_equals(self): + q1 = Query.from_(self.t).select("*").prewhere(self.t.foo == self.t.bar) + q2 = Query.from_(self.t).select("*").prewhere(self.t.foo.eq(self.t.bar)) + + self.assertEqual('SELECT * FROM "abc" PREWHERE "foo"="bar"', str(q1)) + self.assertEqual('SELECT * FROM "abc" PREWHERE "foo"="bar"', str(q2)) + + def test_where_and_prewhere(self): + q = Query.from_(self.t).select("*").prewhere(self.t.foo == self.t.bar).where(self.t.foo == self.t.bar) + + self.assertEqual('SELECT * FROM "abc" PREWHERE "foo"="bar" WHERE "foo"="bar"', str(q)) + + +class GroupByTests(unittest.TestCase): + t = Table("abc") + maxDiff = None + + def test_groupby__single(self): + q = Query.from_(self.t).groupby(self.t.foo).select(self.t.foo) + + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo"', str(q)) + + def test_groupby__multi(self): + q = Query.from_(self.t).groupby(self.t.foo, self.t.bar).select(self.t.foo, self.t.bar) + + self.assertEqual('SELECT "foo","bar" FROM "abc" GROUP BY "foo","bar"', str(q)) + + def test_groupby__count_star(self): + q = Query.from_(self.t).groupby(self.t.foo).select(self.t.foo, fn.Count("*")) + + self.assertEqual('SELECT "foo",COUNT(*) FROM "abc" GROUP BY "foo"', str(q)) + + def test_groupby__count_field(self): + q = Query.from_(self.t).groupby(self.t.foo).select(self.t.foo, fn.Count(self.t.bar)) + + self.assertEqual('SELECT "foo",COUNT("bar") FROM "abc" GROUP BY "foo"', str(q)) + + def test_groupby__count_distinct(self): + q = Query.from_(self.t).groupby(self.t.foo).select(self.t.foo, fn.Count("*").distinct()) + + self.assertEqual('SELECT "foo",COUNT(DISTINCT *) FROM "abc" GROUP BY "foo"', str(q)) + + def test_groupby__sum_distinct(self): + q = Query.from_(self.t).groupby(self.t.foo).select(self.t.foo, fn.Sum(self.t.bar).distinct()) + + self.assertEqual('SELECT "foo",SUM(DISTINCT "bar") FROM "abc" GROUP BY "foo"', str(q)) + + def test_groupby__sum_filter(self): + q = ( + Query.from_(self.t) + .groupby(self.t.foo) + .select(self.t.foo, fn.Sum(self.t.bar).filter(self.t.id.eq(1) & self.t.cid.gt(2))) + ) + + self.assertEqual('SELECT "foo",SUM("bar") FILTER(WHERE "id"=1 AND "cid">2) FROM "abc" GROUP BY "foo"', str(q)) + + def test_groupby__str(self): + q = Query.from_("abc").groupby("foo").select("foo", fn.Count("*").distinct()) + + self.assertEqual('SELECT "foo",COUNT(DISTINCT *) FROM "abc" GROUP BY "foo"', str(q)) + + def test_groupby__int(self): + q = Query.from_("abc").groupby(1).select("foo", fn.Count("*").distinct()) + + self.assertEqual('SELECT "foo",COUNT(DISTINCT *) FROM "abc" GROUP BY 1', str(q)) + + def test_groupby__alias(self): + bar = self.t.bar.as_("bar01") + q = Query.from_(self.t).select(fn.Sum(self.t.foo), bar).groupby(bar) + + self.assertEqual('SELECT SUM("foo"),"bar" "bar01" FROM "abc" GROUP BY "bar01"', str(q)) + + def test_groupby__no_alias(self): + bar = self.t.bar.as_("bar01") + q = Query.from_(self.t).select(fn.Sum(self.t.foo), bar).groupby(bar) + + self.assertEqual( + 'SELECT SUM("foo"),"bar" "bar01" FROM "abc" GROUP BY "bar"', + q.get_sql(groupby_alias=False), + ) + + def test_groupby__no_alias_mssql(self): + bar = self.t.bar.as_("bar01") + q = MSSQLQuery.from_(self.t).select(fn.Sum(self.t.foo), bar).groupby(bar) + + self.assertEqual('SELECT SUM("foo"),"bar" "bar01" FROM "abc" GROUP BY "bar"', str(q)) + + def test_groupby__no_alias_oracle(self): + bar = self.t.bar.as_("bar01") + q = OracleQuery.from_(self.t).select(fn.Sum(self.t.foo), bar).groupby(bar) + + self.assertEqual('SELECT SUM(foo),bar bar01 FROM abc GROUP BY bar', str(q)) + + def test_groupby__alias_platforms(self): + bar = self.t.bar.as_("bar01") + + for query_cls in [ + MySQLQuery, + VerticaQuery, + PostgreSQLQuery, + RedshiftQuery, + ClickHouseQuery, + SQLLiteQuery, + ]: + q = query_cls.from_(self.t).select(fn.Sum(self.t.foo), bar).groupby(bar) + + quote_char = query_cls._builder().QUOTE_CHAR if isinstance(query_cls._builder().QUOTE_CHAR, str) else '"' + + self.assertEqual( + "SELECT " + "SUM({quote_char}foo{quote_char})," + "{quote_char}bar{quote_char}{as_keyword}{quote_char}bar01{quote_char} " + "FROM {quote_char}abc{quote_char} " + "GROUP BY {quote_char}bar01{quote_char}".format( + as_keyword=' AS ' if query_cls is ClickHouseQuery else ' ', quote_char=quote_char + ), + str(q), + ) + + def test_groupby__alias_with_join(self): + table1 = Table("table1", alias="t1") + bar = table1.bar.as_("bar01") + q = Query.from_(self.t).join(table1).on(self.t.id == table1.t_ref).select(fn.Sum(self.t.foo), bar).groupby(bar) + + self.assertEqual( + 'SELECT SUM("abc"."foo"),"t1"."bar" "bar01" FROM "abc" ' + 'JOIN "table1" "t1" ON "abc"."id"="t1"."t_ref" ' + 'GROUP BY "bar01"', + str(q), + ) + + def test_groupby_with_case_uses_the_alias(self): + q = ( + Query.from_(self.t) + .select( + fn.Sum(self.t.foo).as_("bar"), + Case().when(self.t.fname == "Tom", "It was Tom").else_("It was someone else.").as_("who_was_it"), + ) + .groupby(Case().when(self.t.fname == "Tom", "It was Tom").else_("It was someone else.").as_("who_was_it")) + ) + + self.assertEqual( + 'SELECT SUM("foo") "bar",' + "CASE WHEN \"fname\"='Tom' THEN 'It was Tom' " + "ELSE 'It was someone else.' END \"who_was_it\" " + 'FROM "abc" ' + 'GROUP BY "who_was_it"', + str(q), + ) + + def test_mysql_query_uses_backtick_quote_chars(self): + q = MySQLQuery.from_(self.t).groupby(self.t.foo).select(self.t.foo) + + self.assertEqual("SELECT `foo` FROM `abc` GROUP BY `foo`", str(q)) + + def test_vertica_query_uses_double_quote_chars(self): + q = VerticaQuery.from_(self.t).groupby(self.t.foo).select(self.t.foo) + + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo"', str(q)) + + def test_mssql_query_uses_double_quote_chars(self): + q = MSSQLQuery.from_(self.t).groupby(self.t.foo).select(self.t.foo) + + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo"', str(q)) + + def test_oracle_query_uses_no_quote_chars(self): + q = OracleQuery.from_(self.t).groupby(self.t.foo).select(self.t.foo) + + self.assertEqual('SELECT foo FROM abc GROUP BY foo', str(q)) + + def test_postgres_query_uses_double_quote_chars(self): + q = PostgreSQLQuery.from_(self.t).groupby(self.t.foo).select(self.t.foo) + + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo"', str(q)) + + def test_redshift_query_uses_double_quote_chars(self): + q = RedshiftQuery.from_(self.t).groupby(self.t.foo).select(self.t.foo) + + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo"', str(q)) + + def test_group_by__single_with_totals(self): + q = Query.from_(self.t).groupby(self.t.foo).select(self.t.foo).with_totals() + + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo" WITH TOTALS', str(q)) + + def test_groupby__multi_with_totals(self): + q = Query.from_(self.t).groupby(self.t.foo, self.t.bar).select(self.t.foo, self.t.bar).with_totals() + + self.assertEqual('SELECT "foo","bar" FROM "abc" GROUP BY "foo","bar" WITH TOTALS', str(q)) + + +class HavingTests(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_having_greater_than(self): + q = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, fn.Sum(self.table_abc.bar)) + .groupby(self.table_abc.foo) + .having(fn.Sum(self.table_abc.bar) > 1) + ) + + self.assertEqual( + 'SELECT "foo",SUM("bar") FROM "abc" GROUP BY "foo" HAVING SUM("bar")>1', + str(q), + ) + + def test_having_and(self): + q = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, fn.Sum(self.table_abc.bar)) + .groupby(self.table_abc.foo) + .having((fn.Sum(self.table_abc.bar) > 1) & (fn.Sum(self.table_abc.bar) < 100)) + ) + + self.assertEqual( + 'SELECT "foo",SUM("bar") FROM "abc" GROUP BY "foo" HAVING SUM("bar")>1 AND SUM("bar")<100', + str(q), + ) + + def test_having_join_and_equality(self): + q = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.foo) + .select(self.table_abc.foo, fn.Sum(self.table_efg.bar), self.table_abc.buz) + .groupby(self.table_abc.foo) + .having(self.table_abc.buz == "fiz") + .having(fn.Sum(self.table_efg.bar) > 100) + ) + + self.assertEqual( + 'SELECT "abc"."foo",SUM("efg"."bar"),"abc"."buz" FROM "abc" ' + 'JOIN "efg" ON "abc"."foo"="efg"."foo" ' + 'GROUP BY "abc"."foo" ' + 'HAVING "abc"."buz"=\'fiz\' AND SUM("efg"."bar")>100', + str(q), + ) + + def test_mysql_query_uses_backtick_quote_chars(self): + q = ( + MySQLQuery.from_(self.table_abc) + .select(self.table_abc.foo) + .groupby(self.table_abc.foo) + .having(self.table_abc.buz == "fiz") + ) + self.assertEqual("SELECT `foo` FROM `abc` GROUP BY `foo` HAVING `buz`='fiz'", str(q)) + + def test_vertica_query_uses_double_quote_chars(self): + q = ( + VerticaQuery.from_(self.table_abc) + .select(self.table_abc.foo) + .groupby(self.table_abc.foo) + .having(self.table_abc.buz == "fiz") + ) + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo" HAVING "buz"=\'fiz\'', str(q)) + + def test_mssql_query_uses_double_quote_chars(self): + q = ( + MSSQLQuery.from_(self.table_abc) + .select(self.table_abc.foo) + .groupby(self.table_abc.foo) + .having(self.table_abc.buz == "fiz") + ) + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo" HAVING "buz"=\'fiz\'', str(q)) + + def test_oracle_query_uses_no_quote_chars(self): + q = ( + OracleQuery.from_(self.table_abc) + .select(self.table_abc.foo) + .groupby(self.table_abc.foo) + .having(self.table_abc.buz == "fiz") + ) + self.assertEqual('SELECT foo FROM abc GROUP BY foo HAVING buz=\'fiz\'', str(q)) + + def test_postgres_query_uses_double_quote_chars(self): + q = ( + PostgreSQLQuery.from_(self.table_abc) + .select(self.table_abc.foo) + .groupby(self.table_abc.foo) + .having(self.table_abc.buz == "fiz") + ) + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo" HAVING "buz"=\'fiz\'', str(q)) + + def test_redshift_query_uses_double_quote_chars(self): + q = ( + RedshiftQuery.from_(self.table_abc) + .select(self.table_abc.foo) + .groupby(self.table_abc.foo) + .having(self.table_abc.buz == "fiz") + ) + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo" HAVING "buz"=\'fiz\'', str(q)) + + +class OrderByTests(unittest.TestCase): + t = Table("abc") + + def test_orderby_single_field(self): + q = Query.from_(self.t).orderby(self.t.foo).select(self.t.foo) + + self.assertEqual('SELECT "foo" FROM "abc" ORDER BY "foo"', str(q)) + + def test_orderby_multi_fields(self): + q = Query.from_(self.t).orderby(self.t.foo, self.t.bar).select(self.t.foo, self.t.bar) + + self.assertEqual('SELECT "foo","bar" FROM "abc" ORDER BY "foo","bar"', str(q)) + + def test_orderby_single_str(self): + q = Query.from_("abc").orderby("foo").select("foo") + + self.assertEqual('SELECT "foo" FROM "abc" ORDER BY "foo"', str(q)) + + def test_orderby_asc(self): + q = Query.from_(self.t).orderby(self.t.foo, order=Order.asc).select(self.t.foo) + + self.assertEqual('SELECT "foo" FROM "abc" ORDER BY "foo" ASC', str(q)) + + def test_orderby_desc(self): + q = Query.from_(self.t).orderby(self.t.foo, order=Order.desc).select(self.t.foo) + + self.assertEqual('SELECT "foo" FROM "abc" ORDER BY "foo" DESC', str(q)) + + def test_orderby_no_alias(self): + bar = self.t.bar.as_("bar01") + q = Query.from_(self.t).select(fn.Sum(self.t.foo), bar).orderby(bar) + + self.assertEqual( + 'SELECT SUM("foo"),"bar" "bar01" FROM "abc" ORDER BY "bar"', + q.get_sql(orderby_alias=False), + ) + + def test_orderby_alias(self): + bar = self.t.bar.as_("bar01") + q = Query.from_(self.t).select(fn.Sum(self.t.foo), bar).orderby(bar) + + self.assertEqual('SELECT SUM("foo"),"bar" "bar01" FROM "abc" ORDER BY "bar01"', q.get_sql()) + + +class AliasTests(unittest.TestCase): + t = Table("abc") + + def test_table_field(self): + q = Query.from_(self.t).select(self.t.foo.as_("bar")) + + self.assertEqual('SELECT "foo" "bar" FROM "abc"', str(q)) + + def test_table_field__multi(self): + q = Query.from_(self.t).select(self.t.foo.as_("bar"), self.t.fiz.as_("buz")) + + self.assertEqual('SELECT "foo" "bar","fiz" "buz" FROM "abc"', str(q)) + + def test_arithmetic_function(self): + q = Query.from_(self.t).select((self.t.foo + self.t.bar).as_("biz")) + + self.assertEqual('SELECT "foo"+"bar" "biz" FROM "abc"', str(q)) + + def test_functions_using_as(self): + q = Query.from_(self.t).select(fn.Count("*").as_("foo")) + + self.assertEqual('SELECT COUNT(*) "foo" FROM "abc"', str(q)) + + def test_functions_using_constructor_param(self): + q = Query.from_(self.t).select(fn.Count("*", alias="foo")) + + self.assertEqual('SELECT COUNT(*) "foo" FROM "abc"', str(q)) + + def test_function_using_as_nested(self): + """ + We don't show aliases of fields that are arguments of a function. + """ + q = Query.from_(self.t).select(fn.Sqrt(fn.Count("*").as_("foo")).as_("bar")) + + self.assertEqual('SELECT SQRT(COUNT(*)) "bar" FROM "abc"', str(q)) + + def test_functions_using_constructor_param_nested(self): + """ + We don't show aliases of fields that are arguments of a function. + """ + q = Query.from_(self.t).select(fn.Sqrt(fn.Count("*", alias="foo"), alias="bar")) + + self.assertEqual('SELECT SQRT(COUNT(*)) "bar" FROM "abc"', str(q)) + + def test_ignored_in_where(self): + q = Query.from_(self.t).select(self.t.foo).where(self.t.foo.as_("bar") == 1) + + self.assertEqual('SELECT "foo" FROM "abc" WHERE "foo"=1', str(q)) + + def test_ignored_in_groupby(self): + q = Query.from_(self.t).select(self.t.foo).groupby(self.t.foo.as_("bar")) + + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo"', str(q)) + + def test_ignored_in_orderby(self): + q = Query.from_(self.t).select(self.t.foo).orderby(self.t.foo.as_("bar")) + + self.assertEqual('SELECT "foo" FROM "abc" ORDER BY "foo"', str(q)) + + def test_ignored_in_criterion(self): + c = self.t.foo.as_("bar") == 1 + + self.assertEqual('"foo"=1', str(c)) + + def test_ignored_in_criterion_comparison(self): + c = self.t.foo.as_("bar") == self.t.fiz.as_("buz") + + self.assertEqual('"foo"="fiz"', str(c)) + + def test_ignored_in_field_inside_case(self): + q = Query.from_(self.t).select(Case().when(self.t.foo == 1, "a").else_(self.t.bar.as_('"buz"'))) + + self.assertEqual('SELECT CASE WHEN "foo"=1 THEN \'a\' ELSE "bar" END FROM "abc"', str(q)) + + def test_case_using_as(self): + q = Query.from_(self.t).select(Case().when(self.t.foo == 1, "a").else_("b").as_("bar")) + + self.assertEqual( + 'SELECT CASE WHEN "foo"=1 THEN \'a\' ELSE \'b\' END "bar" FROM "abc"', + str(q), + ) + + def test_case_using_constructor_param(self): + q = Query.from_(self.t).select(Case(alias="bar").when(self.t.foo == 1, "a").else_("b")) + + self.assertEqual( + 'SELECT CASE WHEN "foo"=1 THEN \'a\' ELSE \'b\' END "bar" FROM "abc"', + str(q), + ) + + def test_select__multiple_tables(self): + table_abc, table_efg = Table("abc", alias="q0"), Table("efg", alias="q1") + + q = Query.from_(table_abc).select(table_abc.foo).from_(table_efg).select(table_efg.bar) + + self.assertEqual('SELECT "q0"."foo","q1"."bar" FROM "abc" "q0","efg" "q1"', str(q)) + + def test_use_aliases_in_groupby_and_orderby(self): + table_abc = Table("abc", alias="q0") + + my_foo = table_abc.foo.as_("my_foo") + q = Query.from_(table_abc).select(my_foo, table_abc.bar).groupby(my_foo).orderby(my_foo) + + self.assertEqual( + 'SELECT "q0"."foo" "my_foo","q0"."bar" ' 'FROM "abc" "q0" ' 'GROUP BY "my_foo" ' 'ORDER BY "my_foo"', + str(q), + ) + + def test_table_with_schema_and_alias(self): + table = Table("abc", schema="schema", alias="alias") + self.assertEqual('"schema"."abc" "alias"', str(table)) + + def test_null_value_with_alias(self): + q = Query.select(NullValue().as_("abcdef")) + + self.assertEqual('SELECT NULL "abcdef"', str(q)) + + +class SubqueryTests(unittest.TestCase): + maxDiff = None + + table_abc, table_efg, table_hij = Tables("abc", "efg", "hij") + + def test_where__in(self): + q = ( + Query.from_(self.table_abc) + .select("*") + .where( + self.table_abc.foo.isin( + Query.from_(self.table_efg).select(self.table_efg.foo).where(self.table_efg.bar == 0) + ) + ) + ) + + self.assertEqual( + 'SELECT * FROM "abc" WHERE "foo" IN (SELECT "foo" FROM "efg" WHERE "bar"=0)', + str(q), + ) + + def test_where__in_nested(self): + q = Query.from_(self.table_abc).select("*").where(self.table_abc.foo).isin(self.table_efg.select("*")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" IN (SELECT * FROM "efg")', str(q)) + + def test_join(self): + subquery = Query.from_("efg").select("fiz", "buz").where(F("buz") == 0) + + q = ( + Query.from_(self.table_abc) + .join(subquery) + .on(self.table_abc.bar == subquery.buz) + .select(self.table_abc.foo, subquery.fiz) + ) + + self.assertEqual( + 'SELECT "abc"."foo","sq0"."fiz" FROM "abc" ' + 'JOIN (SELECT "fiz","buz" FROM "efg" WHERE "buz"=0) "sq0" ' + 'ON "abc"."bar"="sq0"."buz"', + str(q), + ) + + def test_select_subquery(self): + subq = Query.from_(self.table_efg).select("fizzbuzz").where(self.table_efg.id == 1) + + q = Query.from_(self.table_abc).select("foo", "bar").select(subq) + + self.assertEqual( + 'SELECT "foo","bar",(SELECT "fizzbuzz" FROM "efg" WHERE "id"=1) ' 'FROM "abc"', + str(q), + ) + + def test_select_subquery_with_alias(self): + subq = Query.from_(self.table_efg).select("fizzbuzz").where(self.table_efg.id == 1) + + q = Query.from_(self.table_abc).select("foo", "bar").select(subq.as_("sq")) + + self.assertEqual( + 'SELECT "foo","bar",(SELECT "fizzbuzz" FROM "efg" WHERE "id"=1) "sq" ' 'FROM "abc"', + str(q), + ) + + def test_where__equality(self): + subquery = Query.from_("efg").select("fiz").where(F("buz") == 0) + query = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, self.table_abc.bar) + .where(self.table_abc.bar == subquery) + ) + + self.assertEqual( + 'SELECT "foo","bar" FROM "abc" ' 'WHERE "bar"=(SELECT "fiz" FROM "efg" WHERE "buz"=0)', + str(query), + ) + + def test_select_from_nested_query(self): + subquery = Query.from_(self.table_abc).select( + self.table_abc.foo, + self.table_abc.bar, + (self.table_abc.fizz + self.table_abc.buzz).as_("fizzbuzz"), + ) + + query = Query.from_(subquery).select(subquery.foo, subquery.bar, subquery.fizzbuzz) + + self.assertEqual( + 'SELECT "sq0"."foo","sq0"."bar","sq0"."fizzbuzz" ' + "FROM (" + 'SELECT "foo","bar","fizz"+"buzz" "fizzbuzz" ' + 'FROM "abc"' + ') "sq0"', + str(query), + ) + + def test_select_from_nested_query_with_join(self): + subquery1 = ( + Query.from_(self.table_abc) + .select( + self.table_abc.foo, + fn.Sum(self.table_abc.fizz + self.table_abc.buzz).as_("fizzbuzz"), + ) + .groupby(self.table_abc.foo) + ) + + subquery2 = Query.from_(self.table_efg).select( + self.table_efg.foo.as_("foo_two"), + self.table_efg.bar, + ) + + query = ( + Query.from_(subquery1) + .select(subquery1.foo, subquery1.fizzbuzz) + .join(subquery2) + .on(subquery1.foo == subquery2.foo_two) + .select(subquery2.foo_two, subquery2.bar) + ) + + self.assertEqual( + "SELECT " + '"sq0"."foo","sq0"."fizzbuzz",' + '"sq1"."foo_two","sq1"."bar" ' + "FROM (" + "SELECT " + '"foo",SUM("fizz"+"buzz") "fizzbuzz" ' + 'FROM "abc" ' + 'GROUP BY "foo"' + ') "sq0" JOIN (' + "SELECT " + '"foo" "foo_two","bar" ' + 'FROM "efg"' + ') "sq1" ON "sq0"."foo"="sq1"."foo_two"', + str(query), + ) + + def test_from_subquery_without_alias(self): + subquery = Query.from_(self.table_efg).select( + self.table_efg.base_id.as_("x"), self.table_efg.fizz, self.table_efg.buzz + ) + + test_query = Query.from_(subquery).select(subquery.x, subquery.fizz, subquery.buzz) + + self.assertEqual( + 'SELECT "sq0"."x","sq0"."fizz","sq0"."buzz" ' + "FROM (" + 'SELECT "base_id" "x","fizz","buzz" FROM "efg"' + ') "sq0"', + str(test_query), + ) + + def test_join_query_with_alias(self): + subquery = ( + Query.from_(self.table_efg) + .select( + self.table_efg.base_id.as_("x"), + self.table_efg.fizz, + self.table_efg.buzz, + ) + .as_("subq") + ) + + test_query = Query.from_(subquery).select(subquery.x, subquery.fizz, subquery.buzz) + + self.assertEqual( + 'SELECT "subq"."x","subq"."fizz","subq"."buzz" ' + "FROM (" + 'SELECT "base_id" "x","fizz","buzz" FROM "efg"' + ') "subq"', + str(test_query), + ) + + def test_with(self): + sub_query = Query.from_(self.table_efg).select("fizz") + test_query = Query.with_(sub_query, "an_alias").from_(AliasedQuery("an_alias")).select("*") + + self.assertEqual( + 'WITH an_alias AS (SELECT "fizz" FROM "efg") SELECT * FROM an_alias', + str(test_query), + ) + + def test_join_with_with(self): + sub_query = Query.from_(self.table_efg).select("fizz") + test_query = ( + Query.with_(sub_query, "an_alias") + .from_(self.table_abc) + .join(AliasedQuery("an_alias")) + .on(AliasedQuery("an_alias").fizz == self.table_abc.buzz) + .select("*") + ) + self.assertEqual( + 'WITH an_alias AS (SELECT "fizz" FROM "efg") ' + 'SELECT * FROM "abc" JOIN an_alias ON "an_alias"."fizz"="abc"."buzz"', + str(test_query), + ) + + def test_select_from_with_returning(self): + sub_query = PostgreSQLQuery.into(self.table_abc).insert(1).returning('*') + test_query = Query.with_(sub_query, "an_alias").from_(AliasedQuery("an_alias")).select("*") + self.assertEqual( + 'WITH an_alias AS (INSERT INTO "abc" VALUES (1) RETURNING *) SELECT * FROM an_alias', str(test_query) + ) + + +class QuoteTests(unittest.TestCase): + def test_extraneous_quotes(self): + t1 = Table("table1", alias="t1") + t2 = Table("table2", alias="t2") + + query = Query.from_(t1).join(t2).on(t1.Value.between(t2.start, t2.end)).select(t1.value) + + self.assertEqual( + "SELECT t1.value FROM table1 t1 " "JOIN table2 t2 ON t1.Value " "BETWEEN t2.start AND t2.end", + query.get_sql(quote_char=None), + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/test_tables.py b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/test_tables.py new file mode 100644 index 0000000000000000000000000000000000000000..f43e740915f642d29ce7497c36e3b68f01311016 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/test_tables.py @@ -0,0 +1,186 @@ +# from pypika.terms import ValueWrapper, SystemTimeValue +import unittest + +from pypika import Database, Dialects, Schema, SQLLiteQuery, Table, Tables, Query, SYSTEM_TIME + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + + +class TableStructureTests(unittest.TestCase): + def test_table_sql(self): + table = Table("test_table") + + self.assertEqual('"test_table"', str(table)) + + def test_table_with_alias(self): + table = Table("test_table").as_("my_table") + + self.assertEqual('"test_table" "my_table"', table.get_sql(with_alias=True, quote_char='"')) + + def test_schema_table_attr(self): + table = Schema("x_schema").test_table + + self.assertEqual('"x_schema"."test_table"', str(table)) + + def test_table_with_schema_arg(self): + table = Table("test_table", schema=Schema("x_schema")) + + self.assertEqual('"x_schema"."test_table"', str(table)) + + def test_database_schema_table_attr(self): + table = Database("x_db").x_schema.test_table + + self.assertEqual('"x_db"."x_schema"."test_table"', str(table)) + + def test_table_with_schema_and_schema_parent_arg(self): + table = Table("test_table", schema=Schema("x_schema", parent=Database("x_db"))) + + self.assertEqual('"x_db"."x_schema"."test_table"', str(table)) + + def test_table_for_system_time_sql(self): + with self.subTest("with between criterion"): + table = Table("test_table").for_(SYSTEM_TIME.between('2020-01-01', '2020-02-01')) + + self.assertEqual('"test_table" FOR SYSTEM_TIME BETWEEN \'2020-01-01\' AND \'2020-02-01\'', str(table)) + + with self.subTest("with as of criterion"): + table = Table("test_table").for_(SYSTEM_TIME.as_of('2020-01-01')) + + self.assertEqual('"test_table" FOR SYSTEM_TIME AS OF \'2020-01-01\'', str(table)) + + with self.subTest("with from to criterion"): + table = Table("test_table").for_(SYSTEM_TIME.from_to('2020-01-01', '2020-02-01')) + + self.assertEqual('"test_table" FOR SYSTEM_TIME FROM \'2020-01-01\' TO \'2020-02-01\'', str(table)) + + def test_table_for_period_sql(self): + with self.subTest("with between criterion"): + table = Table("test_table") + table = table.for_(table.valid_period.between('2020-01-01', '2020-02-01')) + + self.assertEqual('"test_table" FOR "valid_period" BETWEEN \'2020-01-01\' AND \'2020-02-01\'', str(table)) + + with self.subTest("with as of criterion"): + table = Table("test_table") + table = table.for_(table.valid_period.as_of('2020-01-01')) + + self.assertEqual('"test_table" FOR "valid_period" AS OF \'2020-01-01\'', str(table)) + + with self.subTest("with from to criterion"): + table = Table("test_table") + table = table.for_(table.valid_period.from_to('2020-01-01', '2020-02-01')) + + self.assertEqual('"test_table" FOR "valid_period" FROM \'2020-01-01\' TO \'2020-02-01\'', str(table)) + + +class TableEqualityTests(unittest.TestCase): + def test_tables_equal_by_name(self): + t1 = Table("t") + t2 = Table("t") + + self.assertEqual(t1, t2) + + def test_tables_equal_by_schema_and_name(self): + t1 = Table("t", schema="a") + t2 = Table("t", schema="a") + + self.assertEqual(t1, t2) + + def test_tables_equal_by_schema_and_name_using_schema(self): + a = Schema("a") + t1 = Table("t", schema=a) + t2 = Table("t", schema=a) + + self.assertEqual(t1, t2) + + def test_tables_equal_by_schema_and_name_using_schema_with_parent(self): + parent = Schema("parent") + a = Schema("a", parent=parent) + t1 = Table("t", schema=a) + t2 = Table("t", schema=a) + + self.assertEqual(t1, t2) + + def test_tables_not_equal_by_schema_and_name_using_schema_with_different_parents( + self, + ): + parent = Schema("parent") + a = Schema("a", parent=parent) + t1 = Table("t", schema=a) + t2 = Table("t", schema=Schema("a")) + + self.assertNotEqual(t1, t2) + + def test_tables_not_equal_with_different_schemas(self): + t1 = Table("t", schema="a") + t2 = Table("t", schema="b") + + self.assertNotEqual(t1, t2) + + def test_tables_not_equal_with_different_names(self): + t1 = Table("t", schema="a") + t2 = Table("q", schema="a") + + self.assertNotEqual(t1, t2) + + def test_many_tables_with_alias(self): + tables_data = [("table1", "t1"), ("table2", "t2"), ("table3", "t3")] + tables = Tables(*tables_data) + for el in tables: + self.assertIsNotNone(el.alias) + + def test_many_tables_without_alias(self): + tables_data = ["table1", "table2", "table3"] + tables = Tables(*tables_data) + for el in tables: + self.assertIsNone(el.alias) + + def test_many_tables_with_or_not_alias(self): + tables_data = [("table1", "t1"), ("table2"), "table3"] + tables = Tables(*tables_data) + for i in range(len(tables)): + if isinstance(tables_data[i], tuple): + self.assertIsNotNone(tables[i].alias) + else: + self.assertIsNone(tables[i].alias) + + +class TableDialectTests(unittest.TestCase): + def test_table_with_default_query_cls(self): + table = Table("abc") + q = table.select("1") + self.assertIs(q.dialect, None) + + def test_table_with_dialect_query_cls(self): + table = Table("abc", query_cls=SQLLiteQuery) + q = table.select("1") + self.assertIs(q.dialect, Dialects.SQLLITE) + + def test_table_factory_with_default_query_cls(self): + table = Query.Table("abc") + q = table.select("1") + self.assertIs(q.dialect, None) + + def test_table_factory_with_dialect_query_cls(self): + table = SQLLiteQuery.Table("abc") + q = table.select("1") + self.assertIs(q.dialect, Dialects.SQLLITE) + + def test_make_tables_factory_with_default_query_cls(self): + t1, t2 = Query.Tables("abc", "def") + q1 = t1.select("1") + q2 = t2.select("2") + self.assertIs(q1.dialect, None) + self.assertIs(q2.dialect, None) + + def test_make_tables_factory_with_dialect_query_cls(self): + t1, t2 = SQLLiteQuery.Tables("abc", "def") + q1 = t1.select("1") + q2 = t2.select("2") + self.assertIs(q1.dialect, Dialects.SQLLITE) + self.assertIs(q2.dialect, Dialects.SQLLITE) + + def test_table_with_bad_query_cls(self): + with self.assertRaises(TypeError): + Table("abc", query_cls=object) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/test_terms.py b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/test_terms.py new file mode 100644 index 0000000000000000000000000000000000000000..4c7590dfce129bac97a3f30de99b596cc746c893 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/test_terms.py @@ -0,0 +1,82 @@ +from unittest import TestCase + +from pypika import Query, Table, Field +from pypika.terms import AtTimezone + + +class FieldAliasTests(TestCase): + t = Table("test", alias="crit") + + def test_when_alias_specified(self): + c1 = Field("foo", alias="bar") + self.assertEqual('bar', str(c1.alias)) + + c1 = Field("foo").as_("bar") + self.assertEqual('bar', str(c1.alias)) + + +class FieldInitTests(TestCase): + def test_init_with_str_table(self): + test_table_name = "test_table" + field = Field(name="name", table=test_table_name) + self.assertEqual(field.table, Table(name=test_table_name)) + + +class FieldHashingTests(TestCase): + def test_tabled_eq_fields_equally_hashed(self): + client_name1 = Field(name="name", table=Table("clients")) + client_name2 = Field(name="name", table=Table("clients")) + self.assertTrue(hash(client_name1) == hash(client_name2)) + + def test_tabled_ne_fields_differently_hashed(self): + customer_name = Field(name="name", table=Table("customers")) + client_name = Field(name="name", table=Table("clients")) + self.assertTrue(hash(customer_name) != hash(client_name)) + + def test_non_tabled_aliased_eq_fields_equally_hashed(self): + self.assertTrue(hash(Field(name="A", alias="my_a")) == hash(Field(name="A", alias="my_a"))) + + def test_non_tabled_aliased_ne_fields_differently_hashed(self): + self.assertTrue(hash(Field(name="A", alias="my_a1")) != hash(Field(name="A", alias="my_a2"))) + + def test_non_tabled_eq_fields_equally_hashed(self): + self.assertTrue(hash(Field(name="A")) == hash(Field(name="A"))) + + def test_non_tabled_ne_fields_differently_hashed(self): + self.assertTrue(hash(Field(name="A")) != hash(Field(name="B"))) + + +class AtTimezoneTests(TestCase): + def test_when_interval_not_specified(self): + query = Query.from_("customers").select(AtTimezone("date", "US/Eastern")) + self.assertEqual('SELECT "date" AT TIME ZONE \'US/Eastern\' FROM "customers"', str(query)) + + def test_when_interval_specified(self): + query = Query.from_("customers").select(AtTimezone("date", "-06:00", interval=True)) + self.assertEqual( + 'SELECT "date" AT TIME ZONE INTERVAL \'-06:00\' FROM "customers"', + str(query), + ) + + def test_when_alias_specified(self): + query = Query.from_("customers").select(AtTimezone("date", "US/Eastern", alias="alias1")) + self.assertEqual( + 'SELECT "date" AT TIME ZONE \'US/Eastern\' "alias1" FROM "customers"', + str(query), + ) + + def test_passes_kwargs_to_field_get_sql(self): + customers = Table("customers") + accounts = Table("accounts") + query = ( + Query.from_(customers) + .join(accounts) + .on(customers.account_id == accounts.account_id) + .select(AtTimezone(customers.date, "US/Eastern", alias="alias1")) + ) + + self.assertEqual( + 'SELECT "customers"."date" AT TIME ZONE \'US/Eastern\' "alias1" ' + 'FROM "customers" JOIN "accounts" ON "customers"."account_id"="accounts"."account_id"', + query.get_sql(with_namespace=True), + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/test_tuples.py b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/test_tuples.py new file mode 100644 index 0000000000000000000000000000000000000000..c8ebc8e41b0115777f8b3c8cb01c04e62f13ee18 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/test_tuples.py @@ -0,0 +1,162 @@ +import unittest + +from pypika import ( + Array, + Bracket, + Query, + PostgreSQLQuery, + Table, + Tables, + Tuple, +) +from pypika.functions import Coalesce, NullIf, Sum +from pypika.terms import Field + + +class TupleTests(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_tuple_equality_tuple_on_both(self): + q = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, self.table_abc.bar) + .where(Tuple(self.table_abc.foo, self.table_abc.bar) == Tuple(1, 2)) + ) + + self.assertEqual('SELECT "foo","bar" FROM "abc" ' 'WHERE ("foo","bar")=(1,2)', str(q)) + + def test_tuple_equality_tuple_on_left(self): + q = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, self.table_abc.bar) + .where(Tuple(self.table_abc.foo, self.table_abc.bar) == (1, 2)) + ) + + self.assertEqual('SELECT "foo","bar" FROM "abc" ' 'WHERE ("foo","bar")=(1,2)', str(q)) + + def test_tuple_equality_tuple_on_right(self): + q = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, self.table_abc.bar) + .where((self.table_abc.foo, self.table_abc.bar) == Tuple(1, 2)) + ) + + # Order is reversed due to lack of right equals method + self.assertEqual('SELECT "foo","bar" FROM "abc" ' 'WHERE (1,2)=("foo","bar")', str(q)) + + def test_tuple_in_using_python_tuples(self): + q = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, self.table_abc.bar) + .where(Tuple(self.table_abc.foo, self.table_abc.bar).isin([(1, 1), (2, 2), (3, 3)])) + ) + + self.assertEqual( + 'SELECT "foo","bar" FROM "abc" ' 'WHERE ("foo","bar") IN ((1,1),(2,2),(3,3))', + str(q), + ) + + def test_tuple_in_using_pypika_tuples(self): + q = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, self.table_abc.bar) + .where(Tuple(self.table_abc.foo, self.table_abc.bar).isin([Tuple(1, 1), Tuple(2, 2), Tuple(3, 3)])) + ) + + self.assertEqual( + 'SELECT "foo","bar" FROM "abc" ' 'WHERE ("foo","bar") IN ((1,1),(2,2),(3,3))', + str(q), + ) + + def test_tuple_in_using_mixed_tuples(self): + q = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, self.table_abc.bar) + .where(Tuple(self.table_abc.foo, self.table_abc.bar).isin([(1, 1), Tuple(2, 2), (3, 3)])) + ) + + self.assertEqual( + 'SELECT "foo","bar" FROM "abc" ' 'WHERE ("foo","bar") IN ((1,1),(2,2),(3,3))', + str(q), + ) + + def test_tuples_in_join(self): + query = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .select("*") + .where(Tuple(self.table_abc.foo, self.table_efg.bar).isin([(1, 1), Tuple(2, 2), (3, 3)])) + ) + + self.assertEqual( + 'SELECT * FROM "abc" JOIN "efg" ON "abc"."foo"="efg"."bar" ' + 'WHERE ("abc"."foo","efg"."bar") IN ((1,1),(2,2),(3,3))', + str(query), + ) + + def test_render_alias_in_array_sql(self): + tb = Table("tb") + + q = Query.from_(tb).select(Tuple(tb.col).as_("different_name")) + self.assertEqual(str(q), 'SELECT ("col") "different_name" FROM "tb"') + + def test_tuple_is_aggregate(self): + with self.subTest('None if single argument returns None for is_aggregate'): + self.assertEqual(None, Tuple(0).is_aggregate) + self.assertEqual(None, Tuple(Coalesce('col')).is_aggregate) + + with self.subTest('None if multiple arguments all return None for is_aggregate'): + self.assertEqual(None, Tuple(0, 'a').is_aggregate) + self.assertEqual(None, Tuple(Coalesce('col'), NullIf('col2', 0)).is_aggregate) + + with self.subTest('True if single argument returns True for is_aggregate'): + self.assertEqual(True, Tuple(Sum('col')).is_aggregate) + + with self.subTest('True if multiple arguments return True for is_aggregate'): + self.assertEqual(True, Tuple(Sum('col'), Sum('col2')).is_aggregate) + + with self.subTest('True when mix of arguments returning None and True for is_aggregate'): + self.assertEqual(True, Tuple(Coalesce('col'), Coalesce('col2', 0), Sum('col3')).is_aggregate) + + with self.subTest('False when one of the arguments returns False for is_aggregate'): + self.assertEqual(False, Tuple(Field('col1'), Sum('col2')).is_aggregate) + + +class ArrayTests(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_array_general(self): + query = Query.from_(self.table_abc).select(Array(1, "a", ["b", 2, 3])) + + self.assertEqual("SELECT [1,'a',['b',2,3]] FROM \"abc\"", str(query)) + + def test_empty_psql_array(self): + query = PostgreSQLQuery.from_(self.table_abc).select(Array()) + + self.assertEqual("SELECT '{}' FROM \"abc\"", str(query)) + + def test_psql_array_general(self): + query = PostgreSQLQuery.from_(self.table_abc).select(Array(1, Array(2, 2, 2), 3)) + + self.assertEqual("SELECT ARRAY[1,ARRAY[2,2,2],3] FROM \"abc\"", str(query)) + + def test_render_alias_in_array_sql(self): + tb = Table("tb") + + q = Query.from_(tb).select(Array(tb.col).as_("different_name")) + self.assertEqual(str(q), 'SELECT ["col"] "different_name" FROM "tb"') + + +class BracketTests(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_arithmetic_with_brackets(self): + q = Query.from_(self.table_abc).select(Bracket(self.table_abc.foo / 2) / 2) + + self.assertEqual('SELECT ("foo"/2)/2 FROM "abc"', str(q)) + + def test_arithmetic_with_brackets_and_alias(self): + q = Query.from_(self.table_abc).select(Bracket(self.table_abc.foo / 2).as_("alias")) + + self.assertEqual('SELECT ("foo"/2) "alias" FROM "abc"', str(q)) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/test_updates.py b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/test_updates.py new file mode 100644 index 0000000000000000000000000000000000000000..fb9d714dbcb8213b4bda04bf7b8dd9b2419410ec --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/test_updates.py @@ -0,0 +1,162 @@ +import unittest + +from pypika import AliasedQuery, PostgreSQLQuery, Query, SQLLiteQuery, SYSTEM_TIME, Table + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + +from pypika.terms import Star + + +class UpdateTests(unittest.TestCase): + table_abc = Table("abc") + table_def = Table("def") + + def test_empty_query(self): + q = Query.update("abc") + + self.assertEqual("", str(q)) + + def test_omit_where(self): + q = Query.update(self.table_abc).set("foo", "bar") + + self.assertEqual('UPDATE "abc" SET "foo"=\'bar\'', str(q)) + + def test_single_quote_escape_in_set(self): + q = Query.update(self.table_abc).set("foo", "bar'foo") + + self.assertEqual("UPDATE \"abc\" SET \"foo\"='bar''foo'", str(q)) + + def test_update__table_schema(self): + table = Table("abc", "schema1") + q = Query.update(table).set(table.foo, 1).where(table.foo == 0) + + self.assertEqual('UPDATE "schema1"."abc" SET "foo"=1 WHERE "foo"=0', str(q)) + + def test_update_with_none(self): + q = Query.update("abc").set("foo", None) + self.assertEqual('UPDATE "abc" SET "foo"=null', str(q)) + + def test_update_with_join(self): + q = ( + Query.update(self.table_abc) + .join(self.table_def) + .on(self.table_def.abc_id == self.table_abc.id) + .set(self.table_abc.lname, self.table_def.lname) + ) + self.assertEqual( + 'UPDATE "abc" JOIN "def" ON "def"."abc_id"="abc"."id" SET "lname"="def"."lname"', + str(q), + ) + + def test_update_with_limit(self): + q = Query.update(self.table_abc).set(self.table_abc.lname, "test").limit(1) + self.assertEqual('UPDATE "abc" SET "lname"=\'test\' LIMIT 1', str(q)) + + def test_update_from(self): + from_table = Table('from_table') + + q = Query.update(self.table_abc).set(self.table_abc.lname, from_table.long_name).from_(from_table) + self.assertEqual('UPDATE "abc" SET "lname"="from_table"."long_name" FROM "from_table"', str(q)) + + def test_update_from_with_where(self): + from_table = Table('from_table') + + q = ( + Query.update(self.table_abc) + .set(self.table_abc.lname, from_table.long_name) + .from_(from_table) + .where(self.table_abc.fname.eq(from_table.full_name)) + ) + self.assertEqual( + 'UPDATE "abc" SET "lname"="from_table"."long_name" FROM "from_table" ' + 'WHERE "abc"."fname"="from_table"."full_name"', + str(q), + ) + + def test_update_with_statement(self): + table_efg = Table('efg') + + sub_query = Query.from_(table_efg).select("fizz") + an_alias = AliasedQuery("an_alias") + + q = ( + Query.with_(sub_query, "an_alias") + .update(self.table_abc) + .from_(an_alias) + .set(self.table_abc.lname, an_alias.long_name) + .where(self.table_abc.comp.eq(an_alias.alias_comp)) + ) + self.assertEqual( + 'WITH an_alias AS (SELECT "fizz" FROM "efg") ' + 'UPDATE "abc" SET "lname"="an_alias"."long_name" FROM an_alias ' + 'WHERE "abc"."comp"="an_alias"."alias_comp"', + str(q), + ) + + def test_for_portion(self): + with self.subTest("with system time"): + q = Query.update(self.table_abc.for_portion(SYSTEM_TIME.from_to('2020-01-01', '2020-02-01'))).set( + "foo", "bar" + ) + + self.assertEqual( + 'UPDATE "abc" FOR PORTION OF SYSTEM_TIME FROM \'2020-01-01\' TO \'2020-02-01\' SET "foo"=\'bar\'', + str(q), + ) + + with self.subTest("with column"): + q = Query.update( + self.table_abc.for_portion(self.table_abc.valid_period.from_to('2020-01-01', '2020-02-01')) + ).set("foo", "bar") + + self.assertEqual( + 'UPDATE "abc" FOR PORTION OF "valid_period" FROM \'2020-01-01\' TO \'2020-02-01\' SET "foo"=\'bar\'', + str(q), + ) + + +class PostgresUpdateTests(unittest.TestCase): + table_abc = Table("abc") + + def test_update_returning_str(self): + q = PostgreSQLQuery.update(self.table_abc).where(self.table_abc.foo == 0).set("foo", "bar").returning("id") + + self.assertEqual('UPDATE "abc" SET "foo"=\'bar\' WHERE "foo"=0 RETURNING "abc"."id"', str(q)) + + def test_update_returning(self): + q = ( + PostgreSQLQuery.update(self.table_abc) + .where(self.table_abc.foo == 0) + .set("foo", "bar") + .returning(self.table_abc.id) + ) + + self.assertEqual('UPDATE "abc" SET "foo"=\'bar\' WHERE "foo"=0 RETURNING "abc"."id"', str(q)) + + def test_update_returning_from_different_tables(self): + table_bcd = Table('bcd') + + q = ( + PostgreSQLQuery.update(self.table_abc) + .from_(table_bcd) + .set(self.table_abc.lname, table_bcd.long_name) + .returning(self.table_abc.id, table_bcd.fname) + ) + self.assertEqual( + 'UPDATE "abc" SET "lname"="bcd"."long_name" FROM "bcd" RETURNING "abc"."id","bcd"."fname"', str(q) + ) + + def test_update_returning_star(self): + q = PostgreSQLQuery.update(self.table_abc).where(self.table_abc.foo == 0).set("foo", "bar").returning(Star()) + + self.assertEqual('UPDATE "abc" SET "foo"=\'bar\' WHERE "foo"=0 RETURNING *', str(q)) + + +class SQLLiteUpdateTests(unittest.TestCase): + table_abc = Table("abc") + + def test_update_with_bool(self): + q = SQLLiteQuery.update(self.table_abc).set(self.table_abc.foo, True) + + self.assertEqual('UPDATE "abc" SET "foo"=1', str(q)) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/test_utils.py b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/test_utils.py new file mode 100644 index 0000000000000000000000000000000000000000..bb9a9b1c68fe8671989f7c49f9db90e389d06f59 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pypika/tests/test_utils.py @@ -0,0 +1,24 @@ +import unittest + +from pypika import utils + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + + +class ImmutabilityTests(unittest.TestCase): + def test_raise_attribute_error_for_deepcopy(self): + with self.assertRaises(AttributeError): + utils.raise_attribute_for_copy("Test", "__deepcopy__") + + def test_raise_attribute_error_for_getstate(self): + with self.assertRaises(AttributeError): + utils.raise_attribute_for_copy("Test", "__getstate__") + + def test_raise_attribute_error_for_setstate(self): + with self.assertRaises(AttributeError): + utils.raise_attribute_for_copy("Test", "__setstate__") + + def test_raise_attribute_error_for_getnewargs(self): + with self.assertRaises(AttributeError): + utils.raise_attribute_for_copy("Test", "__getnewargs__") diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pyproject.toml b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pyproject.toml new file mode 100644 index 0000000000000000000000000000000000000000..dcc56baede23e3571b336625e695c466ab833a56 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/pyproject.toml @@ -0,0 +1,22 @@ +[tool.black] +line-length = 120 +skip-string-normalization = true +target-version = ['py38', 'py39', 'py310', 'py311'] +force-exclude = ''' +( + /( + \.eggs # exclude a few common directories in the + | \.git # root of the project + | \.hg + | \.mypy_cache + | \.tox + | \.venv + | _build + | buck-out + | build + | dist + | docs + )/ + | setup.py +) +''' diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/setup.cfg b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/setup.cfg new file mode 100644 index 0000000000000000000000000000000000000000..46084aaf2ca9e95b2f9bb7680e432e637fc3ed90 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/setup.cfg @@ -0,0 +1,16 @@ +[bumpversion] +current_version = 0.48.9 +commit = True +tag = True + +[bumpversion:file:pypika/__init__.py] +search = __version__ = "{current_version}" +replace = __version__ = "{new_version}" + +[bdist_wheel] +universal = 1 + +[flake8] +exclude = docs, .git, __pycache__ +max-line-length = 120 +per-file-ignores = __init__.py:F401 diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/setup.py b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/setup.py new file mode 100644 index 0000000000000000000000000000000000000000..41cce7d742df3e33e8d76f267d77df486f69249a --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/setup.py @@ -0,0 +1,81 @@ +import ast + +from setuptools import setup + + +def readme(): + with open('README.rst', 'rb') as f: + return f.read().decode('UTF-8') + + +def version(): + path = 'pypika/__init__.py' + with open(path, 'r') as file: + t = compile(file.read(), path, 'exec', ast.PyCF_ONLY_AST) + for node in (n for n in t.body if isinstance(n, ast.Assign)): + if len(node.targets) == 1: + name = node.targets[0] + if isinstance(name, ast.Name) and name.id in ('__version__', '__version_info__', 'VERSION'): + v = node.value + if isinstance(v, ast.Str): + return v.s + + if isinstance(v, ast.Tuple): + r = [] + for e in v.elts: + if isinstance(e, ast.Str): + r.append(e.s) + elif isinstance(e, ast.Num): + r.append(str(e.n)) + return '.'.join(r) + + +setup( + # Application name: + name="PyPika", + + # Version number: + version=version(), + + # Application author details: + author="Timothy Heys", + author_email="theys@kayak.com", + + # License + license='Apache License Version 2.0', + + # Packages + packages=["pypika", "pypika.clickhouse"], + + # Include additional files into the package + package_data={"pypika": ["py.typed"]}, + include_package_data=True, + + install_requires=[], + + # Details + url="https://github.com/kayak/pypika", + + description="A SQL query builder API for Python", + long_description=readme(), + + classifiers=[ + 'License :: OSI Approved :: Apache Software License', + 'Development Status :: 5 - Production/Stable', + 'Intended Audience :: Developers', + 'Programming Language :: Python :: 3', + 'Programming Language :: PL/SQL', + 'Topic :: Software Development :: Libraries :: Python Modules', + 'Topic :: Scientific/Engineering :: Information Analysis', + 'Topic :: Scientific/Engineering :: Mathematics', + 'Operating System :: POSIX', + 'Operating System :: MacOS :: MacOS X', + 'Operating System :: Microsoft :: Windows', + ], + keywords=('pypika python query builder querybuilder sql mysql postgres psql oracle vertica aggregated ' + 'relational database rdbms business analytics bi data science analysis pandas ' + 'orm object mapper'), + + # Dependent packages (distributions) + test_suite="pypika.tests", +) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/tox.ini b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/tox.ini new file mode 100644 index 0000000000000000000000000000000000000000..2f0e6893243b1ca2ead6a12825e9014dc66364ce --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/tests/trusted/tox.ini @@ -0,0 +1,16 @@ +[tox] +envlist = py38,py39,py310,py311,pypy3 + +[testenv] +description = testing against {basepython} +deps = -r requirements-dev.txt +commands = + coverage run + coverage xml + +[gh-actions] +python = + 3.8: py38 + 3.9: py39 + 3.10: py310 + 3.11: py311 diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/validation/canaries/first-hunk-only.sh b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/validation/canaries/first-hunk-only.sh new file mode 100644 index 0000000000000000000000000000000000000000..976eaaf9c1cd5b983849f24b1a863a585e0e5c1a --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/validation/canaries/first-hunk-only.sh @@ -0,0 +1,19 @@ +#!/bin/bash +set -Eeuo pipefail +cd /testbed/repo +cat > /tmp/openenv-reference.diff <<'OPENENV_PARTIAL' +diff --git a/pypika/clickhouse/condition.py b/pypika/clickhouse/condition.py +index c9545f3b46a7dca6861f9e93453a48eb15a5639e..ed08224e22fb27eb18876595a542dcd3ad14bffc 100644 +--- a/pypika/clickhouse/condition.py ++++ b/pypika/clickhouse/condition.py +@@ -3,7 +3,7 @@ + + class If(Function): + def __init__(self, *conditions, **kwargs): +- super().__init__("switch", *reversed(conditions), **kwargs) ++ super().__init__("if", *conditions, **kwargs) + + + class MultiIf(Function): +OPENENV_PARTIAL +/usr/bin/git -c core.hooksPath=/dev/null -c core.fsmonitor=false apply --whitespace=nowarn /tmp/openenv-reference.diff diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/validation/canaries/original-bug.sh b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/validation/canaries/original-bug.sh new file mode 100644 index 0000000000000000000000000000000000000000..927547df786c86ab3bb5eeb917a31e0fa1895f8b --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/validation/canaries/original-bug.sh @@ -0,0 +1,3 @@ +#!/bin/bash +set -Eeuo pipefail +: diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/validation/openenv.json b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/validation/openenv.json new file mode 100644 index 0000000000000000000000000000000000000000..a13b3c577df494f6c894584d2b608ab051ebc44f --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__g1xozw84/validation/openenv.json @@ -0,0 +1,27 @@ +{ + "canaries": "validation/canaries", + "profile": "harbor-semantic-v1", + "requires_credentials": false, + "resources": { + "cpu": 2, + "disk_mb": 16384, + "episode_timeout_s": 1800, + "memory_mb": 8192 + }, + "reward": { + "floor_margin": 0.1, + "oracle_tolerance": 0, + "range": [ + 0, + 1 + ] + }, + "reward_key": "reward", + "types": { + "tags": [ + "swe", + "python", + "mutation-repair" + ] + } +} diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/LICENSE.source b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/LICENSE.source new file mode 100644 index 0000000000000000000000000000000000000000..9c8f3ea0871e0bfe81da0fa6e7c1d7d156dc380e --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/LICENSE.source @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. \ No newline at end of file diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/adapter.json b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/adapter.json new file mode 100644 index 0000000000000000000000000000000000000000..138e753544c1caeab8b72a28ca909e3cfa8feb83 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/adapter.json @@ -0,0 +1,135 @@ +{ + "canary_selection": "Fixed first provided gold hunk only when at least2hunks exist; strict subset, never reward-selected. Single-hunk task original-bug canary is explicitly NOP-equivalent and adds no signal beyond floor_gap.", + "collector_sha256": "352e555112f2de8a1393f939903e4971c9ace0e944843762b707a725c5c72481", + "dependency_installation_pinned": false, + "dependency_setup_sha256": "ed8673d02878e91c7ae0b51b9178d6a15792b79c6992f800c14a941d95242392", + "gold_patch_sha256": "f312a0dc119f21e6b2329ce3954d94fcd520b946f56a732d4f5071fc24890b99", + "hostile_code_isolation_established": false, + "known_wrong_semantic_implementations": 0, + "native_inventory_sha256": "eacb94db0f1cc293c1a3557a6621626c0fcbda160214837c7b6315b95634f287", + "new_files_deletions_and_executable_modes_supported": true, + "official_profile": { + "eval_sets": [], + "profile_class": "Pypika1c9646f0", + "profile_lines": [ + 736, + 739 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "upstream_repo": "kayak/pypika" + }, + "original_bug_canary_nop_equivalent": true, + "original_bug_runtime_wrongness_established": false, + "partial_repair_canary": true, + "partial_repair_sha256": "da7cb0687d83f7740abcbcf034085466e1d286aa37816261c3960432c0baa1a9", + "partial_repair_wrongness_established": false, + "positive_approval_policy": "All original strict presence/identity/no-skip/no-error/exit checks retained", + "private_checker_sha256": "f0a641064b725415e23a0221bb53c90446d7efcb7f9ece5ede93a220d18dd9e7", + "private_checker_version": "matched-failure-precedence-v2", + "provided_original_bug_control": true, + "repo_url": "https://github.com/swesmith/kayak__pypika.1c9646f0.git", + "runtime_image": null, + "runtime_ready": false, + "runtime_recipe": { + "dependency_installation_pinned": false, + "official_install_cmds": [ + "python -m pip install -e ." + ], + "official_pytest_argv": [ + "pytest", + "--disable-warnings", + "--color=no", + "--tb=no", + "--verbose" + ], + "official_test_command": "source /opt/miniconda3/bin/activate; conda activate testbed; pytest --disable-warnings --color=no --tb=no --verbose", + "operator_test_runner_prerequisites": [ + "python -m pip install pytest==8.4.2" + ], + "operator_test_runner_reason": "The official profile invokes pytest, but the common tools runtime does not provide it; pinned separately from source-native project requirements.", + "panel_normalization": "Override project addopts only to execute the exact frozen native panels; add JUnit output, preserve official pytest options and all selectors.", + "python_version": "3.10", + "source_bound_test_dependency_cmds": [ + "python -m pip install parameterized==0.7.0" + ], + "test_dependency_source_sha256": { + "requirements-dev.txt": "10f4ba7b19a73950d28fd7403d7e1d1b1fe2ccc4f49516974f47199d2965f23d", + "setup.py": "f8bad274588a22e65764d8cf9fb2be5aa6fcfaf3bf861d71e5f751105898845a", + "tox.ini": "c2d7205d0ac93e9c9e80dc5d24f0a826a6781f587a33ea722ea621f9e2ccd0ea" + } + }, + "runtime_resource_review_required": false, + "schema": "python-git-patch-jobs-v1", + "source_base_commit": "82247035a7f894951e7fb6d10e7131af6c6566ea", + "source_completion_sha256": "a0f2204271a513de6c3a4abdf35b55b00e09f8e7a236a70464552aba48bf6903", + "source_index_sha256": "e856874b9410fce9f3bfea52c8c482e84b3e43942d87517f8b55f0034bd40f6f", + "source_pr_url": null, + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:kayak__pypika.1c9646f0.combine_module__laiatgzn", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "6a742f12bfa386994289ec8b75824663d8ee4b15", + "instruction_sha256": "e41e104a2a95739aa9d94543e83e96c2fbf2653ab8a9182cdc4d08156b17ac75", + "is_fork": true, + "learner_path": "tasks/0618f694d3ffe18f8751dc99/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "actual_upstream_url": "https://raw.githubusercontent.com/kayak/pypika/1c9646f0a019a167c32b649b6f5e6423c5ba2c9b/LICENSE.txt", + "reviewed": true, + "sha256": "c5accbbd8546e94c34aed24afe689a617627d18eed5a6c48277e48db57c23851", + "spdx": "Apache-2.0", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/kayak__pypika.1c9646f0/82247035a7f894951e7fb6d10e7131af6c6566ea/LICENSE.txt" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "patch_sha256": "cc4ee88a7f69f3a1d5d6071277f381a3eba6392650edb14dc6da83c3cb40119f", + "provenance_path": "tasks/0618f694d3ffe18f8751dc99/source-proof.json", + "repository_lineage": [ + "swesmith/kayak__pypika.1c9646f0", + "kayak/pypika" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "82247035a7f894951e7fb6d10e7131af6c6566ea", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "eab8d2d9fa3e22454811f9445f2e619443e277d3", + "source_kind": "mutation", + "source_repo": "swesmith/kayak__pypika.1c9646f0", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "kayak__pypika.1c9646f0.combine_module__laiatgzn", + "task_sha256": "70be651b50f586ddb1dfc1c05c523c924446c5626c3def9a1dcf1d90636f93b7", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "kayak/pypika", + "usage": "quarantine_only" + }, + "source_repo": "swesmith/kayak__pypika.1c9646f0", + "symlink_submodule_changes_supported": false, + "task_id": "kayak__pypika.1c9646f0.combine_module__laiatgzn", + "transfer": "index-independent-worktree-to-Git-binary-patch", + "transfer_path": "/testbed/submission.patch", + "upstream_repo": "kayak/pypika" +} diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/dependency-setup.sh b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/dependency-setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e1a28db070ebf088cec3ef817cf2dc8715091ac2 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/dependency-setup.sh @@ -0,0 +1,9 @@ +#!/bin/bash +set -Eeuo pipefail +source /opt/miniconda3/bin/activate +conda activate testbed +cd /testbed/repo +python -c 'import sys; assert sys.version_info[:2] == (3, 10)' +python -m pip install pytest==8.4.2 +python -m pip install -e . +python -m pip install parameterized==0.7.0 diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/environment/Dockerfile b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..a59b58c2ea8217c78c1e39b4678f93c8c0023bcd --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/environment/Dockerfile @@ -0,0 +1,3 @@ +# Runtime is selected only by an independently qualified immutable amd64 receipt. +FROM ubuntu:22.04 +RUN false diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/instruction.md b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..c4f6b01bba1c56c64c82ac98555ec496c170d006 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/instruction.md @@ -0,0 +1,34 @@ +ClickHouse functions broken after recent changes + +#### Description + +Several ClickHouse-specific functions are not working correctly. The array functions like `NotEmpty`, `Empty`, and `Length` are producing incorrect SQL output, and the `MultiIf` condition function is also broken. + +#### Steps/Code to Reproduce + +```python +from pypika.clickhouse import Field +from pypika.clickhouse.array import NotEmpty, Empty, Length +from pypika.clickhouse.condition import MultiIf + +# Array functions not working +tags = Field('tags') +not_empty_func = NotEmpty(tags) +print(not_empty_func.get_sql()) # Should output "notEmpty(tags)" but doesn't + +empty_func = Empty(tags) +print(empty_func.get_sql()) # Should output "empty(tags)" but doesn't + +length_func = Length(tags) +print(length_func.get_sql()) # Should output "length(tags)" but doesn't + +# MultiIf condition also broken +multi_if = MultiIf("condition1", "value1", "condition2", "value2", "default") +print(multi_if.get_sql()) # Arguments appear in wrong order +``` + +The functions seem to have their internal attributes mixed up and are not generating the expected ClickHouse SQL syntax. + +## Environment + +The repository is at `/testbed/repo`. Its dependencies, including pytest, are installed in the `testbed` conda environment, which comes first on PATH. If `python -m pytest` reports that pytest is missing, use the full interpreter path: `/opt/miniconda3/envs/testbed/bin/python -m pytest `. Don't install packages: the tests need nothing else, and the sandbox may have no network access. diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/metadata.json b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/metadata.json new file mode 100644 index 0000000000000000000000000000000000000000..37d213430e385425e2e1bc54e0870ff45c22edba --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/metadata.json @@ -0,0 +1,1277 @@ +{ + "all_runtime_and_training_flags": false, + "official_profile": { + "eval_sets": [], + "profile_class": "Pypika1c9646f0", + "profile_lines": [ + 736, + 739 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "upstream_repo": "kayak/pypika" + }, + "source_healthy_reference_proof": { + "FAIL_TO_PASS": [ + "pypika/tests/clickhouse/test_array.py::TestLength::test_get_sql_0_length_tags_", + "pypika/tests/clickhouse/test_array.py::TestLength::test_get_sql_1_length_1_2_3_", + "pypika/tests/clickhouse/test_array.py::TestEmpty::test_get_sql_0_empty_tags_", + "pypika/tests/clickhouse/test_array.py::TestEmpty::test_get_sql_1_empty_1_2_3_", + "pypika/tests/clickhouse/test_array.py::TestNotEmpty::test_get_sql_0_notEmpty_tags_", + "pypika/tests/clickhouse/test_array.py::TestNotEmpty::test_get_sql_1_notEmpty_1_2_3_", + "pypika/tests/clickhouse/test_condition.py::TestMultiIfCondition::test_get_sql_0", + "pypika/tests/clickhouse/test_condition.py::TestMultiIfCondition::test_get_sql_1", + "pypika/tests/clickhouse/test_search_string.py::TestMultiSearch::test_multi_search_string_0", + "pypika/tests/clickhouse/test_search_string.py::TestMultiSearch::test_multi_search_string_1" + ], + "PASS_TO_PASS": [ + "pypika/tests/clickhouse/test_array.py::TestArray::test_get_sql_0__ridley_scott_jimi_hendrix_", + "pypika/tests/clickhouse/test_array.py::TestArray::test_get_sql_1__1_2_3_4_", + "pypika/tests/clickhouse/test_array.py::TestArray::test_get_sql_2__toInt64_1_toInt64_2_toInt64_3_toInt64_4_", + "pypika/tests/clickhouse/test_array.py::TestArray::test_get_sql_3__toFixedString_mogwai_10_toFixedString_mono_10_toFixedString_bonobo_10_arr", + "pypika/tests/clickhouse/test_array.py::TestHasAny::test_get_sql_0_hasAny_mental_abilities_physical_abilities_", + "pypika/tests/clickhouse/test_array.py::TestHasAny::test_get_sql_1_hasAny_1_2_3_4_3_", + "pypika/tests/clickhouse/test_array.py::TestHasAny::test_get_sql_2_hasAny_bands_toFixedString_port_royal_20_toFixedString_hammock_20_", + "pypika/tests/clickhouse/test_condition.py::TestIfCondition::test_get_sql_0", + "pypika/tests/clickhouse/test_condition.py::TestIfCondition::test_get_sql_1", + "pypika/tests/clickhouse/test_dates_and_times.py::TestFormatDateTime::test_get_sql_0", + "pypika/tests/clickhouse/test_dates_and_times.py::TestFormatDateTime::test_get_sql_1", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_00", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_01", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_02", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_03", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_04", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_05", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_06", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_07", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_08", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_09", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_10", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_11", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_12", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_13", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_14", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_15", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_16", + "pypika/tests/clickhouse/test_dates_and_times.py::TestToYYYYMM::test_get_sql", + "pypika/tests/clickhouse/test_nullable_arg.py::TestSearchString::test_get_sql_0", + "pypika/tests/clickhouse/test_nullable_arg.py::TestSearchString::test_get_sql_1", + "pypika/tests/clickhouse/test_search_string.py::TestSearchString::test_search_string_0", + "pypika/tests/clickhouse/test_search_string.py::TestSearchString::test_search_string_1", + "pypika/tests/clickhouse/test_search_string.py::TestSearchString::test_search_string_2", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_00_toString_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_01_toInt8_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_02_toInt16_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_03_toInt32_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_04_toInt64_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_05_toUInt8_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_06_toUInt16_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_07_toUInt32_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_08_toUInt64_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_09_toFloat32_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_10_toFloat64_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_11_toFloat64_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_12_toDate_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_13_toDateTime_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_14_toFixedString_field_name_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_00_toString_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_01_toInt8_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_02_toInt16_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_03_toInt32_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_04_toInt64_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_05_toUInt8_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_06_toUInt16_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_07_toUInt32_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_08_toUInt64_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_09_toFloat32_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_10_toFloat64_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_11_toFloat64_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_12_toDate_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_13_toDateTime_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_14_toFixedString_100_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestToFixedString::test_get_sql_with_table", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseQueryTests::test_use_AS_keyword_for_alias", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseQueryTests::test_use_FINAL_keyword", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseQueryTests::test_use_SAMPLE_keyword", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseQueryTests::test_use_SAMPLE_with_offset_keyword", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDeleteTests::test_omit_where", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDeleteTests::test_omit_where__table_schema", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDeleteTests::test_where_field_equals", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseUpdateTests::test_update", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDropQuery::test_drop_database", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDropQuery::test_drop_dictionary", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDropQuery::test_drop_other", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDropQuery::test_drop_table", + "pypika/tests/dialects/test_clickhouse.py::DistinctOnTests::test_distinct_on", + "pypika/tests/dialects/test_clickhouse.py::LimitByTests::test_limit_by", + "pypika/tests/dialects/test_clickhouse.py::LimitByTests::test_limit_offset0_by", + "pypika/tests/dialects/test_clickhouse.py::LimitByTests::test_limit_offset_by", + "pypika/tests/dialects/test_clickhouse.py::LimitByTests::test_rename_table", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_distinct_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_groupby_alias_False_does_not_group_by_alias_when_subqueries_are_present", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_groupby_alias_False_does_not_group_by_alias_with_standard_query", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_limit", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_limit_with_offset", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_normal_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_offset", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_distinct_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_percent_invalid_range", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_percent_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_select_non_int", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_with_ties_select", + "pypika/tests/dialects/test_mysql.py::SelectTests::test_distinct_select", + "pypika/tests/dialects/test_mysql.py::SelectTests::test_modifier_select", + "pypika/tests/dialects/test_mysql.py::SelectTests::test_multiple_modifier_select", + "pypika/tests/dialects/test_mysql.py::SelectTests::test_normal_select", + "pypika/tests/dialects/test_mysql.py::UpdateTests::test_conflict_handlers_update", + "pypika/tests/dialects/test_mysql.py::UpdateTests::test_on_duplicate_key_ignore_update", + "pypika/tests/dialects/test_mysql.py::UpdateTests::test_on_duplicate_key_update_update", + "pypika/tests/dialects/test_mysql.py::UpdateTests::test_update", + "pypika/tests/dialects/test_mysql.py::LoadCSVTests::test_load_from_file", + "pypika/tests/dialects/test_mysql.py::TableTests::test_create_table", + "pypika/tests/dialects/test_mysql.py::TableTests::test_drop_table", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_fetch_next_method_deprecated", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_groupby_alias_False_does_not_group_by_alias_when_subqueries_are_present", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_groupby_alias_False_does_not_group_by_alias_with_standard_query", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_limit_offset_query", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_limit_query", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_offset_query", + "pypika/tests/dialects/test_postgresql.py::InsertTests::test_array_keyword", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_alias_set_correctly", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_json_value_from_array_num", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_json_value_from_array_str", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_json_value_from_dict", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_json_value_from_dict_recursive", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_json_value_by_index", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_json_value_by_key", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_path_json_value", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_path_text_value", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_text_value_by_index", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_text_value_by_key", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contained_by_using_list_arg", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contained_by_using_str_arg", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contained_by_with_complex_criterion", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contains_for_field", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contains_for_json", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_has_any_keys", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_has_key", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_has_keys", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_subnet_contains_inet", + "pypika/tests/dialects/test_postgresql.py::DistinctOnTests::test_distinct_on", + "pypika/tests/dialects/test_postgresql.py::ArrayTests::test_array_syntax", + "pypika/tests/dialects/test_postgresql.py::ArrayTests::test_render_alias_in_array_sql", + "pypika/tests/dialects/test_postgresql.py::ReturningClauseTests::test_no_queryexception_if_returning_used_on_valid_query_type", + "pypika/tests/dialects/test_postgresql.py::ReturningClauseTests::test_queryexception_if_returning_used_on_invalid_query", + "pypika/tests/dialects/test_postgresql.py::ReturningClauseTests::test_return_field_from_join_table", + "pypika/tests/dialects/test_postgresql.py::ReturningClauseTests::test_returning_from_missing_table_raises_queryexception", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_dont_use_double_quotes_on_create_queries", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_dont_use_double_quotes_on_drop_queries", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_dont_use_double_quotes_on_joining_queries", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_use_double_quotes_on_alias_but_not_on_terms", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_use_double_quotes_on_alias_but_not_on_terms_with_joins", + "pypika/tests/dialects/test_sqllite.py::SelectTests::test_bool_false_as_zero", + "pypika/tests/dialects/test_sqllite.py::SelectTests::test_bool_true_as_one", + "pypika/tests/dialects/test_sqllite.py::ReplaceTests::test_insert_or_replace", + "pypika/tests/dialects/test_sqllite.py::ReplaceTests::test_normal_replace", + "pypika/tests/dialects/test_sqllite.py::ReplaceTests::test_replace_subquery", + "pypika/tests/dialects/test_vertica.py::VerticaQueryTests::test_delete_query_with_hint", + "pypika/tests/dialects/test_vertica.py::VerticaQueryTests::test_insert_query_with_hint", + "pypika/tests/dialects/test_vertica.py::VerticaQueryTests::test_select_query_with_hint", + "pypika/tests/dialects/test_vertica.py::VerticaQueryTests::test_update_query_with_hint", + "pypika/tests/dialects/test_vertica.py::CopyCSVTests::test_copy_from_file", + "pypika/tests/dialects/test_vertica.py::CreateTemporaryTableTests::test_create_local_table_without_temporary_raises_error", + "pypika/tests/dialects/test_vertica.py::CreateTemporaryTableTests::test_create_local_temporary_table", + "pypika/tests/dialects/test_vertica.py::CreateTemporaryTableTests::test_create_table_preserve_rows_without_temporary_raises_error", + "pypika/tests/dialects/test_vertica.py::CreateTemporaryTableTests::test_create_temporary_table_preserve_rows", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__agg_case_criterion_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__agg_case_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__agg_func_arithmetic_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__agg_func_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__case_mixed_constant_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__case_mixed_else_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__case_with_field_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__case_with_single_aggregate_field_in_one_criterion_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__constant_arithmetic_is_aggregate_none", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__constant_is_aggregate_none", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__field_arithmetic_constant_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__field_arithmetic_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__field_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__func_arithmetic_constant_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__mixed_case_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__mixed_func_arithmetic_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__negative_agg_func_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__non_aggregate_function_with_aggregated_arg", + "pypika/tests/test_aggregate.py::IsAggregateTests::test_complicated", + "pypika/tests/test_analytic_queries.py::RankTests::test_avg", + "pypika/tests/test_analytic_queries.py::RankTests::test_count_range_between_unbounded_preceeding_current_row", + "pypika/tests/test_analytic_queries.py::RankTests::test_dense_rank", + "pypika/tests/test_analytic_queries.py::RankTests::test_empty_over", + "pypika/tests/test_analytic_queries.py::RankTests::test_filter", + "pypika/tests/test_analytic_queries.py::RankTests::test_filter_quote_table_in_filter", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value_ignore_nulls", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value_ignore_nulls_first", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value_multi_argument", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value_range_between_x_preceeding_unbounded_following", + "pypika/tests/test_analytic_queries.py::RankTests::test_lag_generates_correct_sql", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value_ignore_nulls", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value_multi_argument", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value_rows_between_current_row_unbounded_following", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value_rows_between_current_row_unbounded_following_ignore_nulls", + "pypika/tests/test_analytic_queries.py::RankTests::test_lead_generates_correct_sql", + "pypika/tests/test_analytic_queries.py::RankTests::test_max_range_x_preceeding", + "pypika/tests/test_analytic_queries.py::RankTests::test_max_rows_x_preceeding", + "pypika/tests/test_analytic_queries.py::RankTests::test_median", + "pypika/tests/test_analytic_queries.py::RankTests::test_min_range_current_row", + "pypika/tests/test_analytic_queries.py::RankTests::test_min_rows_current_row", + "pypika/tests/test_analytic_queries.py::RankTests::test_multiple_partitions", + "pypika/tests/test_analytic_queries.py::RankTests::test_ntile_no_partition_or_order_invalid_sql", + "pypika/tests/test_analytic_queries.py::RankTests::test_ntile_with_order", + "pypika/tests/test_analytic_queries.py::RankTests::test_ntile_with_partition", + "pypika/tests/test_analytic_queries.py::RankTests::test_ntile_with_partition_and_order", + "pypika/tests/test_analytic_queries.py::RankTests::test_orderby_asc", + "pypika/tests/test_analytic_queries.py::RankTests::test_orderby_desc", + "pypika/tests/test_analytic_queries.py::RankTests::test_range_called_twice_raises_attribute_error", + "pypika/tests/test_analytic_queries.py::RankTests::test_range_then_rows_raises_attribute_error", + "pypika/tests/test_analytic_queries.py::RankTests::test_rank", + "pypika/tests/test_analytic_queries.py::RankTests::test_rank_with_alias", + "pypika/tests/test_analytic_queries.py::RankTests::test_row_number", + "pypika/tests/test_analytic_queries.py::RankTests::test_rows_called_twice_raises_attribute_error", + "pypika/tests/test_analytic_queries.py::RankTests::test_rows_then_range_raises_attribute_error", + "pypika/tests/test_analytic_queries.py::RankTests::test_stddev", + "pypika/tests/test_analytic_queries.py::RankTests::test_stddev_pop", + "pypika/tests/test_analytic_queries.py::RankTests::test_stddev_samp", + "pypika/tests/test_analytic_queries.py::RankTests::test_sum_rows_unbounded_preceeding", + "pypika/tests/test_analytic_queries.py::RankTests::test_table_prefixes_used_in_analytic_functions", + "pypika/tests/test_analytic_queries.py::RankTests::test_var_pop", + "pypika/tests/test_analytic_queries.py::RankTests::test_var_samp", + "pypika/tests/test_analytic_queries.py::RankTests::test_variance", + "pypika/tests/test_analytic_queries.py::RankTests::test_variance_rows_between_unbounded_preceeding_unbounded_following", + "pypika/tests/test_analytic_queries.py::RankTests::test_varpop_range_unbounded_preceeding", + "pypika/tests/test_analytic_queries.py::RankTests::test_varpop_rows_between_unbounded_preceeding_x_following", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_as_select_not_query_raises_error", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_with_columns", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_with_select", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_with_select_and_columns_fails", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_without_columns_or_select_empty", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_if_not_exists", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_simple", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_unique", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_where", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_without_columns_raises_error", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_without_table_raises_error", + "pypika/tests/test_criterions.py::CriterionTests::test__bitwise_and_in_where_clause", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_bitwise_and", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_bitwise_and_with_alias", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_bool", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_decimal", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_str", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gt_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gt_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gt_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gt_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gte_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gte_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gte_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gte_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_is_null", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_is_null_with_alias", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lt_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lt_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lt_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lt_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lte_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lte_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lte_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lte_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_str", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_with_alias", + "pypika/tests/test_criterions.py::NotTests::test_chained_function", + "pypika/tests/test_criterions.py::NotTests::test_is_not_null", + "pypika/tests/test_criterions.py::NotTests::test_negate", + "pypika/tests/test_criterions.py::NotTests::test_not_null", + "pypika/tests/test_criterions.py::NotTests::test_not_null_with_alias", + "pypika/tests/test_criterions.py::NotTests::test_not_with_and_criterion", + "pypika/tests/test_criterions.py::NotTests::test_not_with_complex_criterion", + "pypika/tests/test_criterions.py::NotTests::test_not_with_or_criterion", + "pypika/tests/test_criterions.py::NotTests::test_notnullcriterion_replace_table", + "pypika/tests/test_criterions.py::NotTests::test_variable_access", + "pypika/tests/test_criterions.py::BetweenTests::test__between_date", + "pypika/tests/test_criterions.py::BetweenTests::test__between_datetime", + "pypika/tests/test_criterions.py::BetweenTests::test__between_number", + "pypika/tests/test_criterions.py::BetweenTests::test__between_with_alias", + "pypika/tests/test_criterions.py::BetweenTests::test__function_between", + "pypika/tests/test_criterions.py::BetweenTests::test_get_item_only_works_with_slice", + "pypika/tests/test_criterions.py::IsInTests::test__function_isin", + "pypika/tests/test_criterions.py::IsInTests::test__in_character", + "pypika/tests/test_criterions.py::IsInTests::test__in_date", + "pypika/tests/test_criterions.py::IsInTests::test__in_datetime", + "pypika/tests/test_criterions.py::IsInTests::test__in_number", + "pypika/tests/test_criterions.py::IsInTests::test__in_number_with_alias", + "pypika/tests/test_criterions.py::IsInTests::test__in_unicode", + "pypika/tests/test_criterions.py::ArithmeticExpressionTests::test__lshift", + "pypika/tests/test_criterions.py::ArithmeticExpressionTests::test__rshift", + "pypika/tests/test_criterions.py::NotInTests::test__function_notin", + "pypika/tests/test_criterions.py::NotInTests::test__notin_character", + "pypika/tests/test_criterions.py::NotInTests::test__notin_date", + "pypika/tests/test_criterions.py::NotInTests::test__notin_datetime", + "pypika/tests/test_criterions.py::NotInTests::test__notin_number", + "pypika/tests/test_criterions.py::NotInTests::test__notin_number_with_alias", + "pypika/tests/test_criterions.py::LikeTests::test_glob_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_contains", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_ends_with", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_n_chars_long", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_starts_with", + "pypika/tests/test_criterions.py::LikeTests::test_like_contains", + "pypika/tests/test_criterions.py::LikeTests::test_like_ends_with", + "pypika/tests/test_criterions.py::LikeTests::test_like_n_chars_long", + "pypika/tests/test_criterions.py::LikeTests::test_like_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_like_starts_with", + "pypika/tests/test_criterions.py::LikeTests::test_not_ilike_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_not_like_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_rlike_escape_chars", + "pypika/tests/test_criterions.py::ExistsCriterionTests::test_exists", + "pypika/tests/test_criterions.py::ExistsCriterionTests::test_not_exists", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__between_and_field", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__between_and_isin", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__nested__and", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__nested__mixed", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__nested__or", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_and", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_function_and", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_function_or", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_function_xor", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_or", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_xor", + "pypika/tests/test_criterions.py::FieldsAsCriterionTests::test__field_and_field", + "pypika/tests/test_criterions.py::FieldsAsCriterionTests::test__field_or_field", + "pypika/tests/test_criterions.py::FieldsAsCriterionTests::test__field_xor_field", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_arithmeticfunction_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_betweencriterion_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_complexcriterion_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_criterion_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_field_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_function_with_only_fields_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_function_with_values_and_fields_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_nullcriterion_replace_table", + "pypika/tests/test_criterions.py::AnyTests::test_multiple_args_returned_in_chain_of_ors", + "pypika/tests/test_criterions.py::AnyTests::test_single_arg_returns_self", + "pypika/tests/test_criterions.py::AnyTests::test_with_generator", + "pypika/tests/test_criterions.py::AnyTests::test_zero_args_returns_empty_criterion", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_different_operations_with_empty_criterion", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_empty_criterion_on_the_left", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_empty_criterion_on_the_right", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_fields_", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_invertion_of_the_empty_criterion", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_more_than_one_empty_criterions", + "pypika/tests/test_criterions.py::AllTests::test_multiple_args_returned_in_chain_of_ors", + "pypika/tests/test_criterions.py::AllTests::test_single_arg_returns_self", + "pypika/tests/test_criterions.py::AllTests::test_with_generator", + "pypika/tests/test_criterions.py::AllTests::test_zero_args_returns_empty_criterion", + "pypika/tests/test_custom_functions.py::TestUnitCustomFunction::test_should_fail_with_wrong_arguments", + "pypika/tests/test_custom_functions.py::TestUnitCustomFunction::test_should_return_function_with_arguments", + "pypika/tests/test_custom_functions.py::TestUnitCustomFunction::test_should_return_function_with_no_arguments", + "pypika/tests/test_custom_functions.py::TestFunctionalCustomFunction::test_should_fail_use_custom_function_on_select_with_wrong_arguments", + "pypika/tests/test_custom_functions.py::TestFunctionalCustomFunction::test_should_use_custom_function_on_select", + "pypika/tests/test_data_types.py::StringTests::test_inline_string_concatentation", + "pypika/tests/test_data_types.py::UuidTests::test_uuid_string_generation", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_day", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_default", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_microsecond", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_minute", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_month", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_quarter", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_second", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_week", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_year", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_day_hour", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_day_microsecond", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_day_minute", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_day_second", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_hour_microsecond", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_hour_minute", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_hour_second", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_minute_microsecond", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_minute_second", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_second_microsecond", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_value_complex_expressions", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_value_right", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_year_month", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_mysql_dialect_uses_single_quotes_around_expression_in_an_interval", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_oracle_dialect_uses_single_quotes_around_expression_in_an_interval", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_postgresql_dialect_uses_single_quotes_around_interval", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_redshift_dialect_uses_single_quotes_around_interval", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_vertica_dialect_uses_single_quotes_around_interval", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_day", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_month", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_week", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_year", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_year_month", + "pypika/tests/test_date_math.py::TruncateTrailingZerosTests::test_do_not_truncate_integer_values", + "pypika/tests/test_date_math.py::TruncateTrailingZerosTests::test_do_not_truncate_months_between_years_and_datys", + "pypika/tests/test_deletes.py::DeleteTests::test_for_portion", + "pypika/tests/test_deletes.py::DeleteTests::test_omit_where", + "pypika/tests/test_deletes.py::DeleteTests::test_omit_where__table_schema", + "pypika/tests/test_deletes.py::DeleteTests::test_where_field_equals", + "pypika/tests/test_deletes.py::PostgresDeleteTests::test_delete_returning", + "pypika/tests/test_deletes.py::PostgresDeleteTests::test_delete_returning_star", + "pypika/tests/test_deletes.py::PostgresDeleteTests::test_delete_returning_str", + "pypika/tests/test_deletes.py::PostgresDeleteTests::test_delete_using", + "pypika/tests/test_drop.py::DropTableTests::test_drop_database", + "pypika/tests/test_drop.py::DropTableTests::test_drop_index", + "pypika/tests/test_drop.py::DropTableTests::test_drop_table", + "pypika/tests/test_drop.py::DropTableTests::test_drop_user", + "pypika/tests/test_drop.py::DropTableTests::test_drop_view", + "pypika/tests/test_formats.py::QuoteTests::test_no_quote_char_in_complex_query", + "pypika/tests/test_formats.py::QuoteTests::test_replace_quote_char_in_complex_query", + "pypika/tests/test_functions.py::FunctionTests::test_dialect_propagation", + "pypika/tests/test_functions.py::FunctionTests::test_is_aggregate_None_for_non_aggregate_function_or_function_with_no_aggregate_functions", + "pypika/tests/test_functions.py::FunctionTests::test_is_aggregate_True_for_aggregate_function_or_function_with_aggregate_functions", + "pypika/tests/test_functions.py::SchemaTests::test_schema_included_in_function_sql", + "pypika/tests/test_functions.py::SchemaTests::test_schema_no_schema_in_sql_when_none_set", + "pypika/tests/test_functions.py::ArithmeticTests::test__addition__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__addition__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__addition__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__addition__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__arithmetic_equality", + "pypika/tests/test_functions.py::ArithmeticTests::test__arithmetic_with_function", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_add_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_div_no_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_div_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_exponent_no_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_exponent_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_floor_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_function_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_modulus_no_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_modulus_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_mul_no_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_mul_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_nested_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_sub_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__division__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__division__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__division__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__division__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__exponent__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__exponent__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__floor", + "pypika/tests/test_functions.py::ArithmeticTests::test__leftshift__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__leftshift__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__leftshift__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__modulus__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__multiplication__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__multiplication__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__multiplication__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__multiplication__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__rightshift__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__rightshift__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__rightshift__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__subtraction__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__subtraction__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__subtraction__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__subtraction__right", + "pypika/tests/test_functions.py::AggregationTests::test__approx_percentile", + "pypika/tests/test_functions.py::AggregationTests::test__avg", + "pypika/tests/test_functions.py::AggregationTests::test__count", + "pypika/tests/test_functions.py::AggregationTests::test__count__star", + "pypika/tests/test_functions.py::AggregationTests::test__first", + "pypika/tests/test_functions.py::AggregationTests::test__last", + "pypika/tests/test_functions.py::AggregationTests::test__max", + "pypika/tests/test_functions.py::AggregationTests::test__min", + "pypika/tests/test_functions.py::AggregationTests::test__std", + "pypika/tests/test_functions.py::AggregationTests::test__stddev", + "pypika/tests/test_functions.py::AggregationTests::test__subquery_in_params_functions", + "pypika/tests/test_functions.py::AggregationTests::test__sum", + "pypika/tests/test_functions.py::ConditionTests::test__case__else", + "pypika/tests/test_functions.py::ConditionTests::test__case__field", + "pypika/tests/test_functions.py::ConditionTests::test__case__multi", + "pypika/tests/test_functions.py::ConditionTests::test__case__no_cases", + "pypika/tests/test_functions.py::ConditionTests::test__case__raw", + "pypika/tests/test_functions.py::StringTests::test__ascii__field", + "pypika/tests/test_functions.py::StringTests::test__ascii__int", + "pypika/tests/test_functions.py::StringTests::test__ascii__str", + "pypika/tests/test_functions.py::StringTests::test__bin__field", + "pypika/tests/test_functions.py::StringTests::test__bin__int", + "pypika/tests/test_functions.py::StringTests::test__bin__str", + "pypika/tests/test_functions.py::StringTests::test__concat__field", + "pypika/tests/test_functions.py::StringTests::test__concat__str", + "pypika/tests/test_functions.py::StringTests::test__insert__field", + "pypika/tests/test_functions.py::StringTests::test__insert__str", + "pypika/tests/test_functions.py::StringTests::test__length__field", + "pypika/tests/test_functions.py::StringTests::test__length__str", + "pypika/tests/test_functions.py::StringTests::test__lower__field", + "pypika/tests/test_functions.py::StringTests::test__lower__str", + "pypika/tests/test_functions.py::StringTests::test__replace__field", + "pypika/tests/test_functions.py::StringTests::test__replace__str", + "pypika/tests/test_functions.py::StringTests::test__substring", + "pypika/tests/test_functions.py::SplitPartFunctionTests::test__split_part", + "pypika/tests/test_functions.py::RegexpLikeFunctionTests::test__regexp_like", + "pypika/tests/test_functions.py::CastTests::test__cast__as", + "pypika/tests/test_functions.py::CastTests::test__cast__binary", + "pypika/tests/test_functions.py::CastTests::test__cast__binary_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__boolean", + "pypika/tests/test_functions.py::CastTests::test__cast__char", + "pypika/tests/test_functions.py::CastTests::test__cast__char_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__date", + "pypika/tests/test_functions.py::CastTests::test__cast__float", + "pypika/tests/test_functions.py::CastTests::test__cast__integer", + "pypika/tests/test_functions.py::CastTests::test__cast__long_varbinary", + "pypika/tests/test_functions.py::CastTests::test__cast__long_varbinary_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__long_varchar", + "pypika/tests/test_functions.py::CastTests::test__cast__long_varchar_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__numeric", + "pypika/tests/test_functions.py::CastTests::test__cast__signed", + "pypika/tests/test_functions.py::CastTests::test__cast__timestamp", + "pypika/tests/test_functions.py::CastTests::test__cast__unsigned", + "pypika/tests/test_functions.py::CastTests::test__cast__varbinary", + "pypika/tests/test_functions.py::CastTests::test__cast__varbinary_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__varchar", + "pypika/tests/test_functions.py::CastTests::test__cast__varchar_with_arg", + "pypika/tests/test_functions.py::CastTests::test__tochar__", + "pypika/tests/test_functions.py::DateFunctionsTests::test_current_date", + "pypika/tests/test_functions.py::DateFunctionsTests::test_current_time", + "pypika/tests/test_functions.py::DateFunctionsTests::test_current_timestamp", + "pypika/tests/test_functions.py::DateFunctionsTests::test_current_timestamp_with_alias", + "pypika/tests/test_functions.py::DateFunctionsTests::test_date_add", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_day", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_hour", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_join", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_microsecond", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_minute", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_month", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_quarter", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_second", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_week", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_year", + "pypika/tests/test_functions.py::DateFunctionsTests::test_now", + "pypika/tests/test_functions.py::DateFunctionsTests::test_time_diff", + "pypika/tests/test_functions.py::DateFunctionsTests::test_timestampadd", + "pypika/tests/test_functions.py::DateFunctionsTests::test_to_date", + "pypika/tests/test_functions.py::DateFunctionsTests::test_utc_timestamp", + "pypika/tests/test_functions.py::NullFunctionsTests::test_coalesce", + "pypika/tests/test_functions.py::NullFunctionsTests::test_isnull", + "pypika/tests/test_functions.py::NullFunctionsTests::test_nullif", + "pypika/tests/test_functions.py::NullFunctionsTests::test_nvl", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_mysql_one_groupby", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_mysql_rollup_two_groupbys", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_no_rollup_after_rollup_mysql", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_no_rollup_before_groupby", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_from_groupbys", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_from_parameters", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_from_two_groupbys", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_func_one_groupby", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_func_partial", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_func_two_groupbys", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_multiple_rollups", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_rollups_with_multiple_rollups_and_parity", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_rollups_with_parity", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_force_index_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_groupby_returns_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_immutable_kwarg_on_query_builder_disables_immutability", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_insert_into_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_join_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_orderby_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_queries_after_join", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_replace_into_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_select_returns_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_update_set_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_use_index_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_with_return_new_query_instance", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_multi_rows", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_multi_rows_chained", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_multi_rows_chained_mixed", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_multi_rows_chained_multiple_rows", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_single_element", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_column_using_alias_with_chain", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_column_using_table_alias", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_empty_columns", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_empty_columns_type_list", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_empty_columns_type_tuple", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_ignore", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_multiple_rows_with_array_value", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_none_skipped", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_null", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_one_column", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_one_column_multi_element_array", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_one_column_single_element_array", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_selected_columns", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_selected_columns_type_list", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_selected_columns_type_tuple", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_single_row_with_array_value", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_with_statement", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_empty_on_conflict_do_update_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_field", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_field_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_mixed_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_multiple_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_multiple_fields_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_field", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_field_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_multiple_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_multiple_fields_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_multiple_mixed_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_no_handler", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_two_handlers_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_two_handlers_do_update", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_fieldless_conflict_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_fieldless_conflict_do_update_field", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_non_insert_on_conflict_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_non_insert_on_conflict_do_update", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_do_nothing_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_do_update_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_do_update_with_excluded_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_from_subquery", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_complex", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_conflict_fields_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_conflict_fields_do_update", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_empty_conflict_fields_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_empty_conflict_fields_do_update", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_where_and_on_conflict_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_all_columns_multi_rows_chained_returning_star", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_all_columns_multi_rows_chained_returning_star_and_id", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_all_columns_multi_rows_chained_returning_star_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_all_columns_single_element_arrays", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_aggregate", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_all_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_all_fields_and_arithmetics", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_arithmetics", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_from_other_table", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_functions", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_null", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_one_field", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_one_field_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_tuple", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_ignore", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multi_rows_chained_mixed_on_duplicate_update_multiple", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_multiple", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_different_value", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_expression", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_expression_using_original_field_value", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_expression_using_values", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_same_value", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_none_skipped", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_one_column", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_one_column_multi_element_array", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_one_column_single_element_array", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_one_column_using_values", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_selected_columns_on_duplicate_update_multiple", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_selected_columns_on_duplicate_update_one", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_columns_from_columns", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_columns_from_columns_with_join", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_columns_from_star", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_from_columns", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_ignore_star", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_star", + "pypika/tests/test_inserts.py::InsertSubqueryTests::test_insert_subquery_wrapped_in_brackets", + "pypika/tests/test_inserts.py::SelectIntoTests::test_select_columns_into", + "pypika/tests/test_inserts.py::SelectIntoTests::test_select_columns_into_with_join", + "pypika/tests/test_inserts.py::SelectIntoTests::test_select_star_into", + "pypika/tests/test_inserts.py::ReplaceTests::test_replace_simple", + "pypika/tests/test_inserts.py::ReplaceTests::test_replace_subquery", + "pypika/tests/test_internals.py::TablesTests::test__case_tables", + "pypika/tests/test_internals.py::TablesTests::test__criterion_replace_table_with_value", + "pypika/tests/test_internals.py::TablesTests::test__star_tables", + "pypika/tests/test_internals.py::TablesTests::test__table_star_tables", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_cross_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_cross_join_on_subquery", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_cross_join_on_table", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_default_join_type", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_full_outer_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_hash_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_inner_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_arithmetic_field", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_collate", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_complex_criteria", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_field_multi", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_field_multi_with_extra_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_field_single", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_field_without_fields_raises_exception", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_subquery_criteria", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_second_table_in_from_clause", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_using_multiple_fields", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_using_string_field_name", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_using_with_quote_char", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_using_without_fields_raises_exception", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_with_arithmetic_function_in_select", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_left_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_left_outer_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_outer_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_right_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_right_outer_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_temporal_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_use_different_table_objects_for_same_table", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_fail_when_joining_unknown_type", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_ignore_table_references", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_immutable__tables", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_from_join", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_query_with_column_alias", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_query_with_setoperation", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_query_with_table_alias", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_query_without_alias", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_same_table", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_same_table_with_prefixes", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_table_twice", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_prefixes_added_to_function_in_orderby", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_prefixes_added_to_groupby", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_prefixes_added_to_orderby", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_require_condition", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_require_condition_with_both_tables", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select__fields_after_table_star", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select__ordered_select_clauses", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select__star_for_table", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select__star_for_table__replacement", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select_field_from_missing_table", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select_fields_with_where", + "pypika/tests/test_joins.py::UnionTests::test_mysql_query_wraps_unioned_queries", + "pypika/tests/test_joins.py::UnionTests::test_require_equal_number_of_fields", + "pypika/tests/test_joins.py::UnionTests::test_union", + "pypika/tests/test_joins.py::UnionTests::test_union_all", + "pypika/tests/test_joins.py::UnionTests::test_union_all_multiple", + "pypika/tests/test_joins.py::UnionTests::test_union_as_subquery", + "pypika/tests/test_joins.py::UnionTests::test_union_multiple", + "pypika/tests/test_joins.py::UnionTests::test_union_with_no_quote_char", + "pypika/tests/test_joins.py::UnionTests::test_union_with_order_by", + "pypika/tests/test_joins.py::UnionTests::test_union_with_order_by_use_union_query_field", + "pypika/tests/test_joins.py::UnionTests::test_union_with_order_by_use_union_query_field_with_aliases", + "pypika/tests/test_joins.py::UnionTests::test_union_with_order_by_with_aliases", + "pypika/tests/test_joins.py::InsertQueryJoinTests::test_join_table_on_insert_query", + "pypika/tests/test_joins.py::UpdateQueryJoinTests::test_join_table_on_update_query", + "pypika/tests/test_joins.py::IntersectTests::test_intersect", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_as_subquery", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_multiple", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_with_limit", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_with_no_quote_char", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_with_offset", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_with_order_by", + "pypika/tests/test_joins.py::IntersectTests::test_mysql_query_wraps_intersected_queries", + "pypika/tests/test_joins.py::IntersectTests::test_require_equal_number_of_fields_intersect", + "pypika/tests/test_joins.py::MinusTests::test_minus", + "pypika/tests/test_joins.py::MinusTests::test_minus_as_subquery", + "pypika/tests/test_joins.py::MinusTests::test_minus_multiple", + "pypika/tests/test_joins.py::MinusTests::test_minus_query_with_order_by_use_minus_query_field", + "pypika/tests/test_joins.py::MinusTests::test_minus_with_no_quote_char", + "pypika/tests/test_joins.py::MinusTests::test_minus_with_order_by", + "pypika/tests/test_joins.py::MinusTests::test_mysql_query_wraps_minus_queries", + "pypika/tests/test_joins.py::MinusTests::test_require_equal_number_of_fields", + "pypika/tests/test_joins.py::ExceptOfTests::test_except", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_as_subquery", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_multiple", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_query_with_order_by_use_minus_query_field", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_with_no_quote_char", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_with_order_by", + "pypika/tests/test_joins.py::ExceptOfTests::test_require_equal_number_of_fields_except_of", + "pypika/tests/test_negation.py::NegationTests::test_negate_field", + "pypika/tests/test_negation.py::NegationTests::test_negate_function", + "pypika/tests/test_negation.py::NegationTests::test_negate_wrapped_float", + "pypika/tests/test_negation.py::NegationTests::test_negate_wrapped_int", + "pypika/tests/test_parameter.py::ParametrizedTests::test_format_parameter", + "pypika/tests/test_parameter.py::ParametrizedTests::test_join", + "pypika/tests/test_parameter.py::ParametrizedTests::test_named_parameter", + "pypika/tests/test_parameter.py::ParametrizedTests::test_numeric_parameter", + "pypika/tests/test_parameter.py::ParametrizedTests::test_param_insert", + "pypika/tests/test_parameter.py::ParametrizedTests::test_param_select_join", + "pypika/tests/test_parameter.py::ParametrizedTests::test_param_select_subquery", + "pypika/tests/test_parameter.py::ParametrizedTests::test_pyformat_parameter", + "pypika/tests/test_parameter.py::ParametrizedTests::test_qmark_parameter", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_join", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_join_with_parameter_value_wrapper", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_param_insert", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_param_select_join", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_param_select_subquery", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_pyformat_parameter", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_can_be_used_in_a_select_statement", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_can_be_used_in_a_where_clause", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_can_be_used_in_orderby", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_column_value", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_object_id", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_object_value", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_row_id", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_row_num", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_sys_date", + "pypika/tests/test_query.py::QueryTablesTests::test_is_joined", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_case_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_delete_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_filter_tables", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_having_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_insert_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_insert_table_current_table_not_match", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_join_tables", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_only_specified_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_orderby_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_tuple_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_update_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_update_table_current_table_not_match", + "pypika/tests/test_query.py::QueryBuilderTests::test_pipe", + "pypika/tests/test_query.py::QueryBuilderTests::test_query_builders_have_reference_to_correct_query_class", + "pypika/tests/test_selects.py::SelectTests::test_empty_query", + "pypika/tests/test_selects.py::SelectTests::test_mssql_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_mysql_query_uses_backtick_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_oracle_query_uses_no_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_postgresql_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_redshift_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_select__column__single__alias__str", + "pypika/tests/test_selects.py::SelectTests::test_select__column__single__field", + "pypika/tests/test_selects.py::SelectTests::test_select__column__single__str", + "pypika/tests/test_selects.py::SelectTests::test_select__column__single__table_alias__str", + "pypika/tests/test_selects.py::SelectTests::test_select__columns__multi__field", + "pypika/tests/test_selects.py::SelectTests::test_select__columns__multi__str", + "pypika/tests/test_selects.py::SelectTests::test_select__distinct__multi", + "pypika/tests/test_selects.py::SelectTests::test_select__distinct__single", + "pypika/tests/test_selects.py::SelectTests::test_select__multiple_subqueries", + "pypika/tests/test_selects.py::SelectTests::test_select__multiple_tables", + "pypika/tests/test_selects.py::SelectTests::test_select__nested_subquery", + "pypika/tests/test_selects.py::SelectTests::test_select__no_table", + "pypika/tests/test_selects.py::SelectTests::test_select__star", + "pypika/tests/test_selects.py::SelectTests::test_select__star__replacement", + "pypika/tests/test_selects.py::SelectTests::test_select__subquery", + "pypika/tests/test_selects.py::SelectTests::test_select__table_schema", + "pypika/tests/test_selects.py::SelectTests::test_select__table_schema_with_multiple_levels_as_list", + "pypika/tests/test_selects.py::SelectTests::test_select__table_schema_with_multiple_levels_as_tuple", + "pypika/tests/test_selects.py::SelectTests::test_select_no_from", + "pypika/tests/test_selects.py::SelectTests::test_select_no_from_with_field_raises_exception", + "pypika/tests/test_selects.py::SelectTests::test_select_no_with_alias_from", + "pypika/tests/test_selects.py::SelectTests::test_select_then_add_table", + "pypika/tests/test_selects.py::SelectTests::test_select_with_force_index", + "pypika/tests/test_selects.py::SelectTests::test_select_with_force_index_multiple_calls", + "pypika/tests/test_selects.py::SelectTests::test_select_with_force_index_multiple_indexes", + "pypika/tests/test_selects.py::SelectTests::test_select_with_force_index_with_index_object", + "pypika/tests/test_selects.py::SelectTests::test_select_with_limit", + "pypika/tests/test_selects.py::SelectTests::test_select_with_limit__func", + "pypika/tests/test_selects.py::SelectTests::test_select_with_limit_and_offset", + "pypika/tests/test_selects.py::SelectTests::test_select_with_limit_zero", + "pypika/tests/test_selects.py::SelectTests::test_select_with_offset", + "pypika/tests/test_selects.py::SelectTests::test_select_with_offset__func", + "pypika/tests/test_selects.py::SelectTests::test_select_with_use_index", + "pypika/tests/test_selects.py::SelectTests::test_select_with_use_index_multiple_calls", + "pypika/tests/test_selects.py::SelectTests::test_select_with_use_index_multiple_indexes", + "pypika/tests/test_selects.py::SelectTests::test_select_with_use_index_with_index_object", + "pypika/tests/test_selects.py::SelectTests::test_table_select_alias", + "pypika/tests/test_selects.py::SelectTests::test_table_select_alias_with_offset_and_limit", + "pypika/tests/test_selects.py::SelectTests::test_temporal_select", + "pypika/tests/test_selects.py::SelectTests::test_vertica_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::WhereTests::test_ignore_empty_criterion_having", + "pypika/tests/test_selects.py::WhereTests::test_ignore_empty_criterion_where", + "pypika/tests/test_selects.py::WhereTests::test_select_with_force_index_and_where", + "pypika/tests/test_selects.py::WhereTests::test_where_enum", + "pypika/tests/test_selects.py::WhereTests::test_where_field_contains", + "pypika/tests/test_selects.py::WhereTests::test_where_field_does_not_contain", + "pypika/tests/test_selects.py::WhereTests::test_where_field_does_not_end_with", + "pypika/tests/test_selects.py::WhereTests::test_where_field_does_not_start_with", + "pypika/tests/test_selects.py::WhereTests::test_where_field_ends_with", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_and", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_nowait", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_of", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_of_multiple_tables", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_of_nowait", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_of_skip_locked", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_skip_locked", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_skip_locked_and_of", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_or", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_where", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_where_not", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_where_two_not", + "pypika/tests/test_selects.py::WhereTests::test_where_field_is_n_chars_long", + "pypika/tests/test_selects.py::WhereTests::test_where_field_is_not_n_chars_long", + "pypika/tests/test_selects.py::WhereTests::test_where_field_matches_regex", + "pypika/tests/test_selects.py::WhereTests::test_where_field_matches_regexp", + "pypika/tests/test_selects.py::WhereTests::test_where_field_matches_rlike", + "pypika/tests/test_selects.py::WhereTests::test_where_field_starts_with", + "pypika/tests/test_selects.py::WhereTests::test_where_nested_conditions", + "pypika/tests/test_selects.py::WhereTests::test_where_single_quote", + "pypika/tests/test_selects.py::WhereTests::test_where_with_multiple_wheres_using_and_case", + "pypika/tests/test_selects.py::WhereTests::test_where_with_multiple_wheres_using_or_case", + "pypika/tests/test_selects.py::PreWhereTests::test_ignore_empty_criterion_having", + "pypika/tests/test_selects.py::PreWhereTests::test_ignore_empty_criterion_where", + "pypika/tests/test_selects.py::PreWhereTests::test_prewhere_field_equals", + "pypika/tests/test_selects.py::PreWhereTests::test_select_with_force_index_and_where", + "pypika/tests/test_selects.py::PreWhereTests::test_where_and_prewhere", + "pypika/tests/test_selects.py::PreWhereTests::test_where_enum", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_contains", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_does_not_contain", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_does_not_end_with", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_does_not_start_with", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_ends_with", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_and", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_nowait", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_of", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_of_multiple_tables", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_of_nowait", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_of_skip_locked", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_skip_locked", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_skip_locked_and_of", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_or", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_where", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_where_not", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_where_two_not", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_is_n_chars_long", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_is_not_n_chars_long", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_matches_regex", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_matches_regexp", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_matches_rlike", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_starts_with", + "pypika/tests/test_selects.py::PreWhereTests::test_where_nested_conditions", + "pypika/tests/test_selects.py::PreWhereTests::test_where_single_quote", + "pypika/tests/test_selects.py::PreWhereTests::test_where_with_multiple_wheres_using_and_case", + "pypika/tests/test_selects.py::PreWhereTests::test_where_with_multiple_wheres_using_or_case", + "pypika/tests/test_selects.py::GroupByTests::test_group_by__single_with_totals", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__alias", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__alias_platforms", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__alias_with_join", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__count_distinct", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__count_field", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__count_star", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__int", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__multi", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__multi_with_totals", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__no_alias", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__no_alias_mssql", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__no_alias_oracle", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__single", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__str", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__sum_distinct", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__sum_filter", + "pypika/tests/test_selects.py::GroupByTests::test_groupby_with_case_uses_the_alias", + "pypika/tests/test_selects.py::GroupByTests::test_mssql_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_mysql_query_uses_backtick_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_oracle_query_uses_no_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_postgres_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_redshift_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_vertica_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_having_and", + "pypika/tests/test_selects.py::HavingTests::test_having_greater_than", + "pypika/tests/test_selects.py::HavingTests::test_having_join_and_equality", + "pypika/tests/test_selects.py::HavingTests::test_mssql_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_mysql_query_uses_backtick_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_oracle_query_uses_no_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_postgres_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_redshift_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_vertica_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_alias", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_asc", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_desc", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_multi_fields", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_no_alias", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_single_field", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_single_str", + "pypika/tests/test_selects.py::AliasTests::test_arithmetic_function", + "pypika/tests/test_selects.py::AliasTests::test_case_using_as", + "pypika/tests/test_selects.py::AliasTests::test_case_using_constructor_param", + "pypika/tests/test_selects.py::AliasTests::test_function_using_as_nested", + "pypika/tests/test_selects.py::AliasTests::test_functions_using_as", + "pypika/tests/test_selects.py::AliasTests::test_functions_using_constructor_param", + "pypika/tests/test_selects.py::AliasTests::test_functions_using_constructor_param_nested", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_criterion", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_criterion_comparison", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_field_inside_case", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_groupby", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_orderby", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_where", + "pypika/tests/test_selects.py::AliasTests::test_null_value_with_alias", + "pypika/tests/test_selects.py::AliasTests::test_select__multiple_tables", + "pypika/tests/test_selects.py::AliasTests::test_table_field", + "pypika/tests/test_selects.py::AliasTests::test_table_field__multi", + "pypika/tests/test_selects.py::AliasTests::test_table_with_schema_and_alias", + "pypika/tests/test_selects.py::AliasTests::test_use_aliases_in_groupby_and_orderby", + "pypika/tests/test_selects.py::SubqueryTests::test_from_subquery_without_alias", + "pypika/tests/test_selects.py::SubqueryTests::test_join", + "pypika/tests/test_selects.py::SubqueryTests::test_join_query_with_alias", + "pypika/tests/test_selects.py::SubqueryTests::test_join_with_with", + "pypika/tests/test_selects.py::SubqueryTests::test_select_from_nested_query", + "pypika/tests/test_selects.py::SubqueryTests::test_select_from_nested_query_with_join", + "pypika/tests/test_selects.py::SubqueryTests::test_select_from_with_returning", + "pypika/tests/test_selects.py::SubqueryTests::test_select_subquery", + "pypika/tests/test_selects.py::SubqueryTests::test_select_subquery_with_alias", + "pypika/tests/test_selects.py::SubqueryTests::test_where__equality", + "pypika/tests/test_selects.py::SubqueryTests::test_where__in", + "pypika/tests/test_selects.py::SubqueryTests::test_where__in_nested", + "pypika/tests/test_selects.py::SubqueryTests::test_with", + "pypika/tests/test_selects.py::QuoteTests::test_extraneous_quotes", + "pypika/tests/test_tables.py::TableStructureTests::test_database_schema_table_attr", + "pypika/tests/test_tables.py::TableStructureTests::test_schema_table_attr", + "pypika/tests/test_tables.py::TableStructureTests::test_table_for_period_sql", + "pypika/tests/test_tables.py::TableStructureTests::test_table_for_system_time_sql", + "pypika/tests/test_tables.py::TableStructureTests::test_table_sql", + "pypika/tests/test_tables.py::TableStructureTests::test_table_with_alias", + "pypika/tests/test_tables.py::TableStructureTests::test_table_with_schema_and_schema_parent_arg", + "pypika/tests/test_tables.py::TableStructureTests::test_table_with_schema_arg", + "pypika/tests/test_tables.py::TableEqualityTests::test_many_tables_with_alias", + "pypika/tests/test_tables.py::TableEqualityTests::test_many_tables_with_or_not_alias", + "pypika/tests/test_tables.py::TableEqualityTests::test_many_tables_without_alias", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_equal_by_name", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_equal_by_schema_and_name", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_equal_by_schema_and_name_using_schema", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_equal_by_schema_and_name_using_schema_with_parent", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_not_equal_by_schema_and_name_using_schema_with_different_parents", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_not_equal_with_different_names", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_not_equal_with_different_schemas", + "pypika/tests/test_tables.py::TableDialectTests::test_make_tables_factory_with_default_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_make_tables_factory_with_dialect_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_factory_with_default_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_factory_with_dialect_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_with_bad_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_with_default_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_with_dialect_query_cls", + "pypika/tests/test_terms.py::FieldAliasTests::test_when_alias_specified", + "pypika/tests/test_terms.py::FieldInitTests::test_init_with_str_table", + "pypika/tests/test_terms.py::FieldHashingTests::test_non_tabled_aliased_eq_fields_equally_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_non_tabled_aliased_ne_fields_differently_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_non_tabled_eq_fields_equally_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_non_tabled_ne_fields_differently_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_tabled_eq_fields_equally_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_tabled_ne_fields_differently_hashed", + "pypika/tests/test_terms.py::AtTimezoneTests::test_passes_kwargs_to_field_get_sql", + "pypika/tests/test_terms.py::AtTimezoneTests::test_when_alias_specified", + "pypika/tests/test_terms.py::AtTimezoneTests::test_when_interval_not_specified", + "pypika/tests/test_terms.py::AtTimezoneTests::test_when_interval_specified", + "pypika/tests/test_tuples.py::TupleTests::test_render_alias_in_array_sql", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_equality_tuple_on_both", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_equality_tuple_on_left", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_equality_tuple_on_right", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_in_using_mixed_tuples", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_in_using_pypika_tuples", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_in_using_python_tuples", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_is_aggregate", + "pypika/tests/test_tuples.py::TupleTests::test_tuples_in_join", + "pypika/tests/test_tuples.py::ArrayTests::test_array_general", + "pypika/tests/test_tuples.py::ArrayTests::test_empty_psql_array", + "pypika/tests/test_tuples.py::ArrayTests::test_psql_array_general", + "pypika/tests/test_tuples.py::ArrayTests::test_render_alias_in_array_sql", + "pypika/tests/test_tuples.py::BracketTests::test_arithmetic_with_brackets", + "pypika/tests/test_tuples.py::BracketTests::test_arithmetic_with_brackets_and_alias", + "pypika/tests/test_updates.py::UpdateTests::test_empty_query", + "pypika/tests/test_updates.py::UpdateTests::test_for_portion", + "pypika/tests/test_updates.py::UpdateTests::test_omit_where", + "pypika/tests/test_updates.py::UpdateTests::test_single_quote_escape_in_set", + "pypika/tests/test_updates.py::UpdateTests::test_update__table_schema", + "pypika/tests/test_updates.py::UpdateTests::test_update_from", + "pypika/tests/test_updates.py::UpdateTests::test_update_from_with_where", + "pypika/tests/test_updates.py::UpdateTests::test_update_with_join", + "pypika/tests/test_updates.py::UpdateTests::test_update_with_limit", + "pypika/tests/test_updates.py::UpdateTests::test_update_with_none", + "pypika/tests/test_updates.py::UpdateTests::test_update_with_statement", + "pypika/tests/test_updates.py::PostgresUpdateTests::test_update_returning", + "pypika/tests/test_updates.py::PostgresUpdateTests::test_update_returning_from_different_tables", + "pypika/tests/test_updates.py::PostgresUpdateTests::test_update_returning_star", + "pypika/tests/test_updates.py::PostgresUpdateTests::test_update_returning_str", + "pypika/tests/test_updates.py::SQLLiteUpdateTests::test_update_with_bool", + "pypika/tests/test_utils.py::ImmutabilityTests::test_raise_attribute_error_for_deepcopy", + "pypika/tests/test_utils.py::ImmutabilityTests::test_raise_attribute_error_for_getnewargs", + "pypika/tests/test_utils.py::ImmutabilityTests::test_raise_attribute_error_for_getstate", + "pypika/tests/test_utils.py::ImmutabilityTests::test_raise_attribute_error_for_setstate" + ], + "all_git_blobs_modes_verified": true, + "cloud_launch_ready": false, + "commits": { + "bug": "eab8d2d9fa3e22454811f9445f2e619443e277d3", + "healthy": "6a742f12bfa386994289ec8b75824663d8ee4b15", + "learner": "82247035a7f894951e7fb6d10e7131af6c6566ea" + }, + "existing_squirrel_snapshot_reused": false, + "full_transfer_allowlist": [ + "/testbed/.coveragerc", + "/testbed/.gitignore", + "/testbed/.pre-commit-config.yaml", + "/testbed/CODEOWNERS", + "/testbed/CONTRIBUTING.rst", + "/testbed/LICENSE.txt", + "/testbed/MANIFEST.in", + "/testbed/Makefile", + "/testbed/README.rst", + "/testbed/docs/1_installation.rst", + "/testbed/docs/2_tutorial.rst", + "/testbed/docs/3_advanced.rst", + "/testbed/docs/4_extending.rst", + "/testbed/docs/5_reference.rst", + "/testbed/docs/6_contributing.rst", + "/testbed/docs/Makefile", + "/testbed/docs/api/pypika.analytics.rst", + "/testbed/docs/api/pypika.dialects.rst", + "/testbed/docs/api/pypika.enums.rst", + "/testbed/docs/api/pypika.functions.rst", + "/testbed/docs/api/pypika.pseudocolumns.rst", + "/testbed/docs/api/pypika.queries.rst", + "/testbed/docs/api/pypika.rst", + "/testbed/docs/api/pypika.terms.rst", + "/testbed/docs/api/pypika.utils.rst", + "/testbed/docs/conf.py", + "/testbed/docs/index.rst", + "/testbed/pypika/__init__.py", + "/testbed/pypika/analytics.py", + "/testbed/pypika/clickhouse/__init__.py", + "/testbed/pypika/clickhouse/array.py", + "/testbed/pypika/clickhouse/condition.py", + "/testbed/pypika/clickhouse/dates_and_times.py", + "/testbed/pypika/clickhouse/nullable_arg.py", + "/testbed/pypika/clickhouse/search_string.py", + "/testbed/pypika/clickhouse/type_conversion.py", + "/testbed/pypika/dialects.py", + "/testbed/pypika/enums.py", + "/testbed/pypika/functions.py", + "/testbed/pypika/pseudocolumns.py", + "/testbed/pypika/py.typed", + "/testbed/pypika/queries.py", + "/testbed/pypika/terms.py", + "/testbed/pypika/tests/__init__.py", + "/testbed/pypika/tests/clickhouse/__init__.py", + "/testbed/pypika/tests/clickhouse/test_dates_and_times.py", + "/testbed/pypika/tests/clickhouse/test_nullable_arg.py", + "/testbed/pypika/tests/clickhouse/test_type_conversion.py", + "/testbed/pypika/tests/dialects/__init__.py", + "/testbed/pypika/tests/dialects/test_clickhouse.py", + "/testbed/pypika/tests/dialects/test_mssql.py", + "/testbed/pypika/tests/dialects/test_mysql.py", + "/testbed/pypika/tests/dialects/test_oracle.py", + "/testbed/pypika/tests/dialects/test_postgresql.py", + "/testbed/pypika/tests/dialects/test_snowflake.py", + "/testbed/pypika/tests/dialects/test_sqllite.py", + "/testbed/pypika/tests/dialects/test_vertica.py", + "/testbed/pypika/tests/test_aggregate.py", + "/testbed/pypika/tests/test_analytic_queries.py", + "/testbed/pypika/tests/test_create.py", + "/testbed/pypika/tests/test_criterions.py", + "/testbed/pypika/tests/test_custom_functions.py", + "/testbed/pypika/tests/test_data_types.py", + "/testbed/pypika/tests/test_date_math.py", + "/testbed/pypika/tests/test_deletes.py", + "/testbed/pypika/tests/test_drop.py", + "/testbed/pypika/tests/test_formats.py", + "/testbed/pypika/tests/test_functions.py", + "/testbed/pypika/tests/test_groupby_modifiers.py", + "/testbed/pypika/tests/test_immutability.py", + "/testbed/pypika/tests/test_inserts.py", + "/testbed/pypika/tests/test_internals.py", + "/testbed/pypika/tests/test_joins.py", + "/testbed/pypika/tests/test_negation.py", + "/testbed/pypika/tests/test_parameter.py", + "/testbed/pypika/tests/test_pseudocolumns.py", + "/testbed/pypika/tests/test_query.py", + "/testbed/pypika/tests/test_selects.py", + "/testbed/pypika/tests/test_tables.py", + "/testbed/pypika/tests/test_terms.py", + "/testbed/pypika/tests/test_tuples.py", + "/testbed/pypika/tests/test_updates.py", + "/testbed/pypika/tests/test_utils.py", + "/testbed/pypika/utils.py", + "/testbed/pyproject.toml", + "/testbed/requirements-dev.txt", + "/testbed/setup.cfg", + "/testbed/setup.py", + "/testbed/tox.ini" + ], + "healthy_stage_meaning": "Direct parent of the mutation; no source or test execution has been performed", + "mutation_matches_dataset_and_git_blobs": true, + "official_profile": { + "eval_sets": [], + "profile_class": "Pypika1c9646f0", + "profile_lines": [ + 736, + 739 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "upstream_repo": "kayak/pypika" + }, + "original_source_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "private_test_paths": [ + "pypika/tests/clickhouse/test_array.py", + "pypika/tests/clickhouse/test_condition.py", + "pypika/tests/clickhouse/test_search_string.py" + ], + "private_tests_unchanged": true, + "profile_mapping_basis": "Explicit upstream repo and full commit fields parsed from pinned official Python profile AST, not basename inference", + "qwen_calibrated": false, + "runtime_qualified": false, + "source_paths": [ + "pypika/clickhouse/array.py", + "pypika/clickhouse/condition.py", + "pypika/clickhouse/search_string.py" + ], + "source_repo": "swesmith/kayak__pypika.1c9646f0", + "source_stages_bytes": 1890314, + "task_id": "kayak__pypika.1c9646f0.combine_module__laiatgzn", + "transfer_limitation": "Existing regular files only; new arbitrary file additions need a qualified patch adapter", + "upstream_repo": "kayak/pypika" + }, + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:kayak__pypika.1c9646f0.combine_module__laiatgzn", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "6a742f12bfa386994289ec8b75824663d8ee4b15", + "instruction_sha256": "e41e104a2a95739aa9d94543e83e96c2fbf2653ab8a9182cdc4d08156b17ac75", + "is_fork": true, + "learner_path": "tasks/0618f694d3ffe18f8751dc99/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "actual_upstream_url": "https://raw.githubusercontent.com/kayak/pypika/1c9646f0a019a167c32b649b6f5e6423c5ba2c9b/LICENSE.txt", + "reviewed": true, + "sha256": "c5accbbd8546e94c34aed24afe689a617627d18eed5a6c48277e48db57c23851", + "spdx": "Apache-2.0", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/kayak__pypika.1c9646f0/82247035a7f894951e7fb6d10e7131af6c6566ea/LICENSE.txt" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "patch_sha256": "cc4ee88a7f69f3a1d5d6071277f381a3eba6392650edb14dc6da83c3cb40119f", + "provenance_path": "tasks/0618f694d3ffe18f8751dc99/source-proof.json", + "repository_lineage": [ + "swesmith/kayak__pypika.1c9646f0", + "kayak/pypika" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "82247035a7f894951e7fb6d10e7131af6c6566ea", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "eab8d2d9fa3e22454811f9445f2e619443e277d3", + "source_kind": "mutation", + "source_repo": "swesmith/kayak__pypika.1c9646f0", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "kayak__pypika.1c9646f0.combine_module__laiatgzn", + "task_sha256": "70be651b50f586ddb1dfc1c05c523c924446c5626c3def9a1dcf1d90636f93b7", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "kayak/pypika", + "usage": "quarantine_only" + }, + "task_kind": "original-source-mutation" +} diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/provenance.json b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/provenance.json new file mode 100644 index 0000000000000000000000000000000000000000..ad02f61420d8bd37331ad3aad6f18afb1582fb70 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/provenance.json @@ -0,0 +1,88 @@ +{ + "generated_reference": false, + "healthy_reference_delta_sha256": "f312a0dc119f21e6b2329ce3954d94fcd520b946f56a732d4f5071fc24890b99", + "native_pytest_ids_preserved": true, + "original_source_code_license": { + "actual_upstream_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "actual_upstream_url": "https://raw.githubusercontent.com/kayak/pypika/1c9646f0a019a167c32b649b6f5e6423c5ba2c9b/LICENSE.txt", + "reviewed": true, + "sha256": "c5accbbd8546e94c34aed24afe689a617627d18eed5a6c48277e48db57c23851", + "spdx": "Apache-2.0", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/kayak__pypika.1c9646f0/82247035a7f894951e7fb6d10e7131af6c6566ea/LICENSE.txt" + }, + "provided_reference": true, + "qwen_calibrated": false, + "runtime_qualified": false, + "source_completion_sha256": "a0f2204271a513de6c3a4abdf35b55b00e09f8e7a236a70464552aba48bf6903", + "source_index_sha256": "e856874b9410fce9f3bfea52c8c482e84b3e43942d87517f8b55f0034bd40f6f", + "source_proof_sha256": "aae309875ba7d2190bb2dbe69c8fa8c3468333aeb5487d85756a71b8a627c912", + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:kayak__pypika.1c9646f0.combine_module__laiatgzn", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "6a742f12bfa386994289ec8b75824663d8ee4b15", + "instruction_sha256": "e41e104a2a95739aa9d94543e83e96c2fbf2653ab8a9182cdc4d08156b17ac75", + "is_fork": true, + "learner_path": "tasks/0618f694d3ffe18f8751dc99/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "actual_upstream_url": "https://raw.githubusercontent.com/kayak/pypika/1c9646f0a019a167c32b649b6f5e6423c5ba2c9b/LICENSE.txt", + "reviewed": true, + "sha256": "c5accbbd8546e94c34aed24afe689a617627d18eed5a6c48277e48db57c23851", + "spdx": "Apache-2.0", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/kayak__pypika.1c9646f0/82247035a7f894951e7fb6d10e7131af6c6566ea/LICENSE.txt" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "patch_sha256": "cc4ee88a7f69f3a1d5d6071277f381a3eba6392650edb14dc6da83c3cb40119f", + "provenance_path": "tasks/0618f694d3ffe18f8751dc99/source-proof.json", + "repository_lineage": [ + "swesmith/kayak__pypika.1c9646f0", + "kayak/pypika" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "82247035a7f894951e7fb6d10e7131af6c6566ea", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "eab8d2d9fa3e22454811f9445f2e619443e277d3", + "source_kind": "mutation", + "source_repo": "swesmith/kayak__pypika.1c9646f0", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "kayak__pypika.1c9646f0.combine_module__laiatgzn", + "task_sha256": "70be651b50f586ddb1dfc1c05c523c924446c5626c3def9a1dcf1d90636f93b7", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "kayak/pypika", + "usage": "quarantine_only" + }, + "task_bundle_license": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + }, + "training_admissible": false, + "trusted_tests_sha256": "f2d0a1b335176a755d627907f32ef330383cf624ff3af2c5ea84ba2b6a2d7ebb" +} diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/provided-gold.diff b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/provided-gold.diff new file mode 100644 index 0000000000000000000000000000000000000000..5dacb5787a7ea0218e20b41e436059ffb474b728 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/provided-gold.diff @@ -0,0 +1,54 @@ +diff --git a/pypika/clickhouse/array.py b/pypika/clickhouse/array.py +index e554ab65de0ee41a80eba3911b1237c61a64e4a8..67929f1664e8a3d63d5b1a83cdf66ae590c53ce4 100644 +--- a/pypika/clickhouse/array.py ++++ b/pypika/clickhouse/array.py +@@ -57,10 +57,10 @@ + + class _AbstractArrayFunction(Function, metaclass=abc.ABCMeta): + def __init__(self, array: Array or Field, alias: str = None, schema: str = None): +- self.schema = alias +- self.alias = self.clickhouse_function() +- self.name = schema +- self._array = None ++ self.schema = schema ++ self.alias = alias ++ self.name = self.clickhouse_function() ++ self._array = array + + def get_sql(self, with_namespace=False, quote_char=None, dialect=None, **kwargs): + array = self._array.get_sql() +@@ -79,7 +79,7 @@ + class NotEmpty(_AbstractArrayFunction): + @classmethod + def clickhouse_function(cls) -> str: +- return "isEmpty" ++ return "notEmpty" + + + class Empty(_AbstractArrayFunction): +diff --git a/pypika/clickhouse/condition.py b/pypika/clickhouse/condition.py +index 5fa9a18c9e95d1f5e7f56f011d03e7aa11f1ddd6..ed08224e22fb27eb18876595a542dcd3ad14bffc 100644 +--- a/pypika/clickhouse/condition.py ++++ b/pypika/clickhouse/condition.py +@@ -8,4 +8,4 @@ + + class MultiIf(Function): + def __init__(self, *conditions, **kwargs): +- super().__init__("multiIf", *conditions[::-1], **kwargs) ++ super().__init__("multiIf", *conditions, **kwargs) +diff --git a/pypika/clickhouse/search_string.py b/pypika/clickhouse/search_string.py +index 166ef485c681363382906fd66ba73127e07fe220..22a03027fcaf3ca0578e63980c00f4be1b2f67e7 100644 +--- a/pypika/clickhouse/search_string.py ++++ b/pypika/clickhouse/search_string.py +@@ -51,9 +51,9 @@ + + class _AbstractMultiSearchString(Function, metaclass=abc.ABCMeta): + def __init__(self, name, patterns: list, alias: str = None): +- super(_AbstractMultiSearchString, self).__init__(self, name, alias=alias) ++ super(_AbstractMultiSearchString, self).__init__(self.clickhouse_function(), name, alias=alias) + +- self._patterns = patterns[::-1] ++ self._patterns = patterns + + @classmethod + @abc.abstractmethod diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/solution/solve.sh b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..e3487b6e4462b64d34dde3f821c637aaa870a43e --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/solution/solve.sh @@ -0,0 +1,60 @@ +#!/bin/bash +set -Eeuo pipefail +cd /testbed/repo +cat > /tmp/openenv-reference.diff <<'OPENENV_REFERENCE' +diff --git a/pypika/clickhouse/array.py b/pypika/clickhouse/array.py +index e554ab65de0ee41a80eba3911b1237c61a64e4a8..67929f1664e8a3d63d5b1a83cdf66ae590c53ce4 100644 +--- a/pypika/clickhouse/array.py ++++ b/pypika/clickhouse/array.py +@@ -57,10 +57,10 @@ + + class _AbstractArrayFunction(Function, metaclass=abc.ABCMeta): + def __init__(self, array: Array or Field, alias: str = None, schema: str = None): +- self.schema = alias +- self.alias = self.clickhouse_function() +- self.name = schema +- self._array = None ++ self.schema = schema ++ self.alias = alias ++ self.name = self.clickhouse_function() ++ self._array = array + + def get_sql(self, with_namespace=False, quote_char=None, dialect=None, **kwargs): + array = self._array.get_sql() +@@ -79,7 +79,7 @@ + class NotEmpty(_AbstractArrayFunction): + @classmethod + def clickhouse_function(cls) -> str: +- return "isEmpty" ++ return "notEmpty" + + + class Empty(_AbstractArrayFunction): +diff --git a/pypika/clickhouse/condition.py b/pypika/clickhouse/condition.py +index 5fa9a18c9e95d1f5e7f56f011d03e7aa11f1ddd6..ed08224e22fb27eb18876595a542dcd3ad14bffc 100644 +--- a/pypika/clickhouse/condition.py ++++ b/pypika/clickhouse/condition.py +@@ -8,4 +8,4 @@ + + class MultiIf(Function): + def __init__(self, *conditions, **kwargs): +- super().__init__("multiIf", *conditions[::-1], **kwargs) ++ super().__init__("multiIf", *conditions, **kwargs) +diff --git a/pypika/clickhouse/search_string.py b/pypika/clickhouse/search_string.py +index 166ef485c681363382906fd66ba73127e07fe220..22a03027fcaf3ca0578e63980c00f4be1b2f67e7 100644 +--- a/pypika/clickhouse/search_string.py ++++ b/pypika/clickhouse/search_string.py +@@ -51,9 +51,9 @@ + + class _AbstractMultiSearchString(Function, metaclass=abc.ABCMeta): + def __init__(self, name, patterns: list, alias: str = None): +- super(_AbstractMultiSearchString, self).__init__(self, name, alias=alias) ++ super(_AbstractMultiSearchString, self).__init__(self.clickhouse_function(), name, alias=alias) + +- self._patterns = patterns[::-1] ++ self._patterns = patterns + + @classmethod + @abc.abstractmethod +OPENENV_REFERENCE +/usr/bin/git -c core.hooksPath=/dev/null -c core.fsmonitor=false apply --whitespace=nowarn /tmp/openenv-reference.diff diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/task.toml b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..ce8523a7674d6c7dfaca4d7f13573355bf53f3c4 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/task.toml @@ -0,0 +1,24 @@ +version = "1.0" + +[agent] +timeout_sec = 1800.0 + +[verifier] +timeout_sec = 900.0 + +[environment] +docker_image = "ghcr.io/younesbelkada/scale800@sha256:732fb68e8ce0d7c8ea6d40ce0aabf1eeb27278ecbaaf8114e00d83be11bb3054" +build_timeout_sec = 600.0 +cpus = 2 +memory_mb = 8192 +storage_mb = 16384 + +[metadata] +author_name = "SWE-smith source adapter" +category = "bugfix" +tags = ["swe", "python", "mutation-repair"] + +[environment.env] +# The image's PATH with the testbed env first: the project and pytest are installed there, and the agent's +# non-interactive shells never run `conda activate` +PATH = "/opt/miniconda3/envs/testbed/bin:/opt/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/check_pytest.py b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/check_pytest.py new file mode 100644 index 0000000000000000000000000000000000000000..7abfdc5972f57ca7f0cecbbeeb373414670f780e --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/check_pytest.py @@ -0,0 +1,177 @@ +"""Preserve confirmed requested assertion failures; keep positive checks strict.""" + +import argparse +import hashlib +import json +import re +import xml.etree.ElementTree as ET +from pathlib import Path + +GROUPS = ("pass-to-pass", "fail-to-pass") + + +def split_nodeid(target): + prefix, bracket, parameter = target.partition("[") + parts = prefix.split("::") + if bracket: + parts[-1] += bracket + parameter + return parts + + +def matches(case, target): + parts = split_nodeid(target) + module = parts[0].removesuffix(".py").replace("/", ".") + classname, name = case.get("classname", ""), case.get("name", "") + if not (classname == module or classname.startswith(module + ".")): + return False + selector = parts[-1] if len(parts) > 1 else "" + classes = parts[1:-1] + if classes and classname != module + "." + ".".join(classes): + return False + return ( + not selector + or name == selector + or ("[" not in selector and name.startswith(selector + "[")) + ) + + +def capture_panels(root): + panels, digests = {}, {} + for group in GROUPS: + path = Path(root) / (group + ".xml") + if not path.exists(): + panels[group] = None + continue + with path.open("rb") as stream: + raw = stream.read(4 * 1024**2 + 1) + if not 0 < len(raw) <= 4 * 1024**2 or re.search( + rb" 20000: + raise ValueError("Too many pytest cases") + identities = [(case.get("classname"), case.get("name")) for case in cases] + if len(identities) != len(set(identities)): + raise ValueError("Duplicate pytest case evidence") + panels[group] = cases + digests[group] = hashlib.sha256(raw).hexdigest() + return panels, digests + + +def strict_assess(panels, expected, native_exit): + """The original positive-approval conditions, applied to captured cases.""" + all_cases, actual_failure = [], False + for group in GROUPS: + cases = panels[group] + if cases is None: + if actual_failure: + continue + raise ValueError("Missing preceding pytest panel") + if actual_failure: + raise ValueError( + "Pytest evidence continued after the native stop-on-failure" + ) + targets = expected[group] + if any(not any(matches(case, target) for target in targets) for case in cases): + raise ValueError("Unexpected pytest case") + all_cases.extend(cases) + failures = [case for case in cases if case.find("failure") is not None] + if any( + case.find("error") is not None or case.find("skipped") is not None + for case in cases + ): + raise ValueError("Pytest collection/error/skip is not a completed panel") + actual_failure = actual_failure or bool(failures) + if not failures and any( + not any(matches(case, target) for case in cases) for target in targets + ): + raise ValueError("Declared pytest target never ran") + if actual_failure: + if native_exit == 0: + raise ValueError("Native verifier exit disagrees with pytest failure") + return {"reward": 0, "valid_test_failure": True, "cases": len(all_cases)} + if native_exit != 0: + raise ValueError("Setup or native verifier failed without a real test failure") + if any(panels[group] is None for group in GROUPS): + raise ValueError("Missing completed pytest panel") + return {"reward": 1, "valid_test_failure": False, "cases": len(all_cases)} + + +def assess(root, expected, native_exit): + if type(native_exit) is not int: + raise ValueError("Native verifier exit must be an integer") + if not isinstance(expected, dict) or any( + not isinstance(expected.get(group), list) + or not expected[group] + or any(not isinstance(target, str) or not target for target in expected[group]) + for group in GROUPS + ): + raise ValueError("Complete exact native pytest targets required") + panels, digests = capture_panels(root) + counts = { + "cases": 0, + "matched_failures": 0, + "unexpected_cases": 0, + "unmatched_failures": 0, + "skipped_cases": 0, + "error_cases": 0, + "missing_panels": 0, + "missing_targets": 0, + } + for group in GROUPS: + cases = panels[group] + if cases is None: + counts["missing_panels"] += 1 + counts["missing_targets"] += len(expected[group]) + continue + counts["cases"] += len(cases) + for case in cases: + requested = any(matches(case, target) for target in expected[group]) + failure = case.find("failure") is not None + counts["matched_failures"] += int(requested and failure) + counts["unmatched_failures"] += int(not requested and failure) + counts["unexpected_cases"] += int(not requested) + counts["skipped_cases"] += int(case.find("skipped") is not None) + counts["error_cases"] += int(case.find("error") is not None) + counts["missing_targets"] += sum( + not any(matches(case, target) for case in cases) + for target in expected[group] + ) + if counts["matched_failures"]: + if native_exit == 0: + raise ValueError( + "Native verifier exit disagrees with requested pytest failure" + ) + return { + "reward": 0, + "valid_test_failure": True, + "cases": counts["cases"], + "diagnostic_counts": counts, + "panel_sha256": digests, + "decision": "confirmed_requested_failure_precedence", + } + result = strict_assess(panels, expected, native_exit) + result.update(diagnostic_counts=counts, panel_sha256=digests) + return result + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("--root", required=True) + parser.add_argument("--expected", required=True) + parser.add_argument("--native-exit", type=int, required=True) + args = parser.parse_args() + result = assess( + args.root, json.loads(Path(args.expected).read_bytes()), args.native_exit + ) + reward = Path(args.root) / "reward.txt" + if reward.read_text().strip() != str(result["reward"]): + raise ValueError("Native raw reward disagrees with pytest evidence") + (Path(args.root) / "pytest-evidence.json").write_text( + json.dumps(result, sort_keys=True) + "\n" + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/expected-panels.json b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/expected-panels.json new file mode 100644 index 0000000000000000000000000000000000000000..f3509a84fc5031521002e4c82f3e3e30595fae0e --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/expected-panels.json @@ -0,0 +1,1067 @@ +{ + "fail-to-pass": [ + "pypika/tests/clickhouse/test_array.py::TestLength::test_get_sql_0_length_tags_", + "pypika/tests/clickhouse/test_array.py::TestLength::test_get_sql_1_length_1_2_3_", + "pypika/tests/clickhouse/test_array.py::TestEmpty::test_get_sql_0_empty_tags_", + "pypika/tests/clickhouse/test_array.py::TestEmpty::test_get_sql_1_empty_1_2_3_", + "pypika/tests/clickhouse/test_array.py::TestNotEmpty::test_get_sql_0_notEmpty_tags_", + "pypika/tests/clickhouse/test_array.py::TestNotEmpty::test_get_sql_1_notEmpty_1_2_3_", + "pypika/tests/clickhouse/test_condition.py::TestMultiIfCondition::test_get_sql_0", + "pypika/tests/clickhouse/test_condition.py::TestMultiIfCondition::test_get_sql_1", + "pypika/tests/clickhouse/test_search_string.py::TestMultiSearch::test_multi_search_string_0", + "pypika/tests/clickhouse/test_search_string.py::TestMultiSearch::test_multi_search_string_1" + ], + "pass-to-pass": [ + "pypika/tests/clickhouse/test_array.py::TestArray::test_get_sql_0__ridley_scott_jimi_hendrix_", + "pypika/tests/clickhouse/test_array.py::TestArray::test_get_sql_1__1_2_3_4_", + "pypika/tests/clickhouse/test_array.py::TestArray::test_get_sql_2__toInt64_1_toInt64_2_toInt64_3_toInt64_4_", + "pypika/tests/clickhouse/test_array.py::TestArray::test_get_sql_3__toFixedString_mogwai_10_toFixedString_mono_10_toFixedString_bonobo_10_arr", + "pypika/tests/clickhouse/test_array.py::TestHasAny::test_get_sql_0_hasAny_mental_abilities_physical_abilities_", + "pypika/tests/clickhouse/test_array.py::TestHasAny::test_get_sql_1_hasAny_1_2_3_4_3_", + "pypika/tests/clickhouse/test_array.py::TestHasAny::test_get_sql_2_hasAny_bands_toFixedString_port_royal_20_toFixedString_hammock_20_", + "pypika/tests/clickhouse/test_condition.py::TestIfCondition::test_get_sql_0", + "pypika/tests/clickhouse/test_condition.py::TestIfCondition::test_get_sql_1", + "pypika/tests/clickhouse/test_dates_and_times.py::TestFormatDateTime::test_get_sql_0", + "pypika/tests/clickhouse/test_dates_and_times.py::TestFormatDateTime::test_get_sql_1", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_00", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_01", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_02", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_03", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_04", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_05", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_06", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_07", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_08", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_09", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_10", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_11", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_12", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_13", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_14", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_15", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_16", + "pypika/tests/clickhouse/test_dates_and_times.py::TestToYYYYMM::test_get_sql", + "pypika/tests/clickhouse/test_nullable_arg.py::TestSearchString::test_get_sql_0", + "pypika/tests/clickhouse/test_nullable_arg.py::TestSearchString::test_get_sql_1", + "pypika/tests/clickhouse/test_search_string.py::TestSearchString::test_search_string_0", + "pypika/tests/clickhouse/test_search_string.py::TestSearchString::test_search_string_1", + "pypika/tests/clickhouse/test_search_string.py::TestSearchString::test_search_string_2", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_00_toString_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_01_toInt8_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_02_toInt16_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_03_toInt32_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_04_toInt64_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_05_toUInt8_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_06_toUInt16_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_07_toUInt32_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_08_toUInt64_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_09_toFloat32_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_10_toFloat64_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_11_toFloat64_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_12_toDate_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_13_toDateTime_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_14_toFixedString_field_name_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_00_toString_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_01_toInt8_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_02_toInt16_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_03_toInt32_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_04_toInt64_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_05_toUInt8_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_06_toUInt16_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_07_toUInt32_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_08_toUInt64_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_09_toFloat32_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_10_toFloat64_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_11_toFloat64_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_12_toDate_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_13_toDateTime_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_14_toFixedString_100_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestToFixedString::test_get_sql_with_table", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseQueryTests::test_use_AS_keyword_for_alias", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseQueryTests::test_use_FINAL_keyword", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseQueryTests::test_use_SAMPLE_keyword", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseQueryTests::test_use_SAMPLE_with_offset_keyword", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDeleteTests::test_omit_where", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDeleteTests::test_omit_where__table_schema", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDeleteTests::test_where_field_equals", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseUpdateTests::test_update", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDropQuery::test_drop_database", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDropQuery::test_drop_dictionary", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDropQuery::test_drop_other", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDropQuery::test_drop_table", + "pypika/tests/dialects/test_clickhouse.py::DistinctOnTests::test_distinct_on", + "pypika/tests/dialects/test_clickhouse.py::LimitByTests::test_limit_by", + "pypika/tests/dialects/test_clickhouse.py::LimitByTests::test_limit_offset0_by", + "pypika/tests/dialects/test_clickhouse.py::LimitByTests::test_limit_offset_by", + "pypika/tests/dialects/test_clickhouse.py::LimitByTests::test_rename_table", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_distinct_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_groupby_alias_False_does_not_group_by_alias_when_subqueries_are_present", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_groupby_alias_False_does_not_group_by_alias_with_standard_query", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_limit", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_limit_with_offset", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_normal_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_offset", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_distinct_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_percent_invalid_range", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_percent_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_select_non_int", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_with_ties_select", + "pypika/tests/dialects/test_mysql.py::SelectTests::test_distinct_select", + "pypika/tests/dialects/test_mysql.py::SelectTests::test_modifier_select", + "pypika/tests/dialects/test_mysql.py::SelectTests::test_multiple_modifier_select", + "pypika/tests/dialects/test_mysql.py::SelectTests::test_normal_select", + "pypika/tests/dialects/test_mysql.py::UpdateTests::test_conflict_handlers_update", + "pypika/tests/dialects/test_mysql.py::UpdateTests::test_on_duplicate_key_ignore_update", + "pypika/tests/dialects/test_mysql.py::UpdateTests::test_on_duplicate_key_update_update", + "pypika/tests/dialects/test_mysql.py::UpdateTests::test_update", + "pypika/tests/dialects/test_mysql.py::LoadCSVTests::test_load_from_file", + "pypika/tests/dialects/test_mysql.py::TableTests::test_create_table", + "pypika/tests/dialects/test_mysql.py::TableTests::test_drop_table", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_fetch_next_method_deprecated", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_groupby_alias_False_does_not_group_by_alias_when_subqueries_are_present", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_groupby_alias_False_does_not_group_by_alias_with_standard_query", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_limit_offset_query", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_limit_query", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_offset_query", + "pypika/tests/dialects/test_postgresql.py::InsertTests::test_array_keyword", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_alias_set_correctly", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_json_value_from_array_num", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_json_value_from_array_str", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_json_value_from_dict", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_json_value_from_dict_recursive", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_json_value_by_index", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_json_value_by_key", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_path_json_value", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_path_text_value", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_text_value_by_index", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_text_value_by_key", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contained_by_using_list_arg", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contained_by_using_str_arg", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contained_by_with_complex_criterion", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contains_for_field", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contains_for_json", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_has_any_keys", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_has_key", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_has_keys", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_subnet_contains_inet", + "pypika/tests/dialects/test_postgresql.py::DistinctOnTests::test_distinct_on", + "pypika/tests/dialects/test_postgresql.py::ArrayTests::test_array_syntax", + "pypika/tests/dialects/test_postgresql.py::ArrayTests::test_render_alias_in_array_sql", + "pypika/tests/dialects/test_postgresql.py::ReturningClauseTests::test_no_queryexception_if_returning_used_on_valid_query_type", + "pypika/tests/dialects/test_postgresql.py::ReturningClauseTests::test_queryexception_if_returning_used_on_invalid_query", + "pypika/tests/dialects/test_postgresql.py::ReturningClauseTests::test_return_field_from_join_table", + "pypika/tests/dialects/test_postgresql.py::ReturningClauseTests::test_returning_from_missing_table_raises_queryexception", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_dont_use_double_quotes_on_create_queries", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_dont_use_double_quotes_on_drop_queries", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_dont_use_double_quotes_on_joining_queries", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_use_double_quotes_on_alias_but_not_on_terms", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_use_double_quotes_on_alias_but_not_on_terms_with_joins", + "pypika/tests/dialects/test_sqllite.py::SelectTests::test_bool_false_as_zero", + "pypika/tests/dialects/test_sqllite.py::SelectTests::test_bool_true_as_one", + "pypika/tests/dialects/test_sqllite.py::ReplaceTests::test_insert_or_replace", + "pypika/tests/dialects/test_sqllite.py::ReplaceTests::test_normal_replace", + "pypika/tests/dialects/test_sqllite.py::ReplaceTests::test_replace_subquery", + "pypika/tests/dialects/test_vertica.py::VerticaQueryTests::test_delete_query_with_hint", + "pypika/tests/dialects/test_vertica.py::VerticaQueryTests::test_insert_query_with_hint", + "pypika/tests/dialects/test_vertica.py::VerticaQueryTests::test_select_query_with_hint", + "pypika/tests/dialects/test_vertica.py::VerticaQueryTests::test_update_query_with_hint", + "pypika/tests/dialects/test_vertica.py::CopyCSVTests::test_copy_from_file", + "pypika/tests/dialects/test_vertica.py::CreateTemporaryTableTests::test_create_local_table_without_temporary_raises_error", + "pypika/tests/dialects/test_vertica.py::CreateTemporaryTableTests::test_create_local_temporary_table", + "pypika/tests/dialects/test_vertica.py::CreateTemporaryTableTests::test_create_table_preserve_rows_without_temporary_raises_error", + "pypika/tests/dialects/test_vertica.py::CreateTemporaryTableTests::test_create_temporary_table_preserve_rows", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__agg_case_criterion_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__agg_case_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__agg_func_arithmetic_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__agg_func_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__case_mixed_constant_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__case_mixed_else_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__case_with_field_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__case_with_single_aggregate_field_in_one_criterion_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__constant_arithmetic_is_aggregate_none", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__constant_is_aggregate_none", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__field_arithmetic_constant_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__field_arithmetic_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__field_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__func_arithmetic_constant_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__mixed_case_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__mixed_func_arithmetic_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__negative_agg_func_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__non_aggregate_function_with_aggregated_arg", + "pypika/tests/test_aggregate.py::IsAggregateTests::test_complicated", + "pypika/tests/test_analytic_queries.py::RankTests::test_avg", + "pypika/tests/test_analytic_queries.py::RankTests::test_count_range_between_unbounded_preceeding_current_row", + "pypika/tests/test_analytic_queries.py::RankTests::test_dense_rank", + "pypika/tests/test_analytic_queries.py::RankTests::test_empty_over", + "pypika/tests/test_analytic_queries.py::RankTests::test_filter", + "pypika/tests/test_analytic_queries.py::RankTests::test_filter_quote_table_in_filter", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value_ignore_nulls", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value_ignore_nulls_first", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value_multi_argument", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value_range_between_x_preceeding_unbounded_following", + "pypika/tests/test_analytic_queries.py::RankTests::test_lag_generates_correct_sql", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value_ignore_nulls", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value_multi_argument", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value_rows_between_current_row_unbounded_following", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value_rows_between_current_row_unbounded_following_ignore_nulls", + "pypika/tests/test_analytic_queries.py::RankTests::test_lead_generates_correct_sql", + "pypika/tests/test_analytic_queries.py::RankTests::test_max_range_x_preceeding", + "pypika/tests/test_analytic_queries.py::RankTests::test_max_rows_x_preceeding", + "pypika/tests/test_analytic_queries.py::RankTests::test_median", + "pypika/tests/test_analytic_queries.py::RankTests::test_min_range_current_row", + "pypika/tests/test_analytic_queries.py::RankTests::test_min_rows_current_row", + "pypika/tests/test_analytic_queries.py::RankTests::test_multiple_partitions", + "pypika/tests/test_analytic_queries.py::RankTests::test_ntile_no_partition_or_order_invalid_sql", + "pypika/tests/test_analytic_queries.py::RankTests::test_ntile_with_order", + "pypika/tests/test_analytic_queries.py::RankTests::test_ntile_with_partition", + "pypika/tests/test_analytic_queries.py::RankTests::test_ntile_with_partition_and_order", + "pypika/tests/test_analytic_queries.py::RankTests::test_orderby_asc", + "pypika/tests/test_analytic_queries.py::RankTests::test_orderby_desc", + "pypika/tests/test_analytic_queries.py::RankTests::test_range_called_twice_raises_attribute_error", + "pypika/tests/test_analytic_queries.py::RankTests::test_range_then_rows_raises_attribute_error", + "pypika/tests/test_analytic_queries.py::RankTests::test_rank", + "pypika/tests/test_analytic_queries.py::RankTests::test_rank_with_alias", + "pypika/tests/test_analytic_queries.py::RankTests::test_row_number", + "pypika/tests/test_analytic_queries.py::RankTests::test_rows_called_twice_raises_attribute_error", + "pypika/tests/test_analytic_queries.py::RankTests::test_rows_then_range_raises_attribute_error", + "pypika/tests/test_analytic_queries.py::RankTests::test_stddev", + "pypika/tests/test_analytic_queries.py::RankTests::test_stddev_pop", + "pypika/tests/test_analytic_queries.py::RankTests::test_stddev_samp", + "pypika/tests/test_analytic_queries.py::RankTests::test_sum_rows_unbounded_preceeding", + "pypika/tests/test_analytic_queries.py::RankTests::test_table_prefixes_used_in_analytic_functions", + "pypika/tests/test_analytic_queries.py::RankTests::test_var_pop", + "pypika/tests/test_analytic_queries.py::RankTests::test_var_samp", + "pypika/tests/test_analytic_queries.py::RankTests::test_variance", + "pypika/tests/test_analytic_queries.py::RankTests::test_variance_rows_between_unbounded_preceeding_unbounded_following", + "pypika/tests/test_analytic_queries.py::RankTests::test_varpop_range_unbounded_preceeding", + "pypika/tests/test_analytic_queries.py::RankTests::test_varpop_rows_between_unbounded_preceeding_x_following", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_as_select_not_query_raises_error", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_with_columns", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_with_select", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_with_select_and_columns_fails", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_without_columns_or_select_empty", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_if_not_exists", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_simple", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_unique", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_where", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_without_columns_raises_error", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_without_table_raises_error", + "pypika/tests/test_criterions.py::CriterionTests::test__bitwise_and_in_where_clause", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_bitwise_and", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_bitwise_and_with_alias", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_bool", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_decimal", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_str", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gt_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gt_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gt_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gt_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gte_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gte_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gte_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gte_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_is_null", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_is_null_with_alias", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lt_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lt_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lt_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lt_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lte_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lte_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lte_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lte_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_str", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_with_alias", + "pypika/tests/test_criterions.py::NotTests::test_chained_function", + "pypika/tests/test_criterions.py::NotTests::test_is_not_null", + "pypika/tests/test_criterions.py::NotTests::test_negate", + "pypika/tests/test_criterions.py::NotTests::test_not_null", + "pypika/tests/test_criterions.py::NotTests::test_not_null_with_alias", + "pypika/tests/test_criterions.py::NotTests::test_not_with_and_criterion", + "pypika/tests/test_criterions.py::NotTests::test_not_with_complex_criterion", + "pypika/tests/test_criterions.py::NotTests::test_not_with_or_criterion", + "pypika/tests/test_criterions.py::NotTests::test_notnullcriterion_replace_table", + "pypika/tests/test_criterions.py::NotTests::test_variable_access", + "pypika/tests/test_criterions.py::BetweenTests::test__between_date", + "pypika/tests/test_criterions.py::BetweenTests::test__between_datetime", + "pypika/tests/test_criterions.py::BetweenTests::test__between_number", + "pypika/tests/test_criterions.py::BetweenTests::test__between_with_alias", + "pypika/tests/test_criterions.py::BetweenTests::test__function_between", + "pypika/tests/test_criterions.py::BetweenTests::test_get_item_only_works_with_slice", + "pypika/tests/test_criterions.py::IsInTests::test__function_isin", + "pypika/tests/test_criterions.py::IsInTests::test__in_character", + "pypika/tests/test_criterions.py::IsInTests::test__in_date", + "pypika/tests/test_criterions.py::IsInTests::test__in_datetime", + "pypika/tests/test_criterions.py::IsInTests::test__in_number", + "pypika/tests/test_criterions.py::IsInTests::test__in_number_with_alias", + "pypika/tests/test_criterions.py::IsInTests::test__in_unicode", + "pypika/tests/test_criterions.py::ArithmeticExpressionTests::test__lshift", + "pypika/tests/test_criterions.py::ArithmeticExpressionTests::test__rshift", + "pypika/tests/test_criterions.py::NotInTests::test__function_notin", + "pypika/tests/test_criterions.py::NotInTests::test__notin_character", + "pypika/tests/test_criterions.py::NotInTests::test__notin_date", + "pypika/tests/test_criterions.py::NotInTests::test__notin_datetime", + "pypika/tests/test_criterions.py::NotInTests::test__notin_number", + "pypika/tests/test_criterions.py::NotInTests::test__notin_number_with_alias", + "pypika/tests/test_criterions.py::LikeTests::test_glob_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_contains", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_ends_with", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_n_chars_long", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_starts_with", + "pypika/tests/test_criterions.py::LikeTests::test_like_contains", + "pypika/tests/test_criterions.py::LikeTests::test_like_ends_with", + "pypika/tests/test_criterions.py::LikeTests::test_like_n_chars_long", + "pypika/tests/test_criterions.py::LikeTests::test_like_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_like_starts_with", + "pypika/tests/test_criterions.py::LikeTests::test_not_ilike_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_not_like_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_rlike_escape_chars", + "pypika/tests/test_criterions.py::ExistsCriterionTests::test_exists", + "pypika/tests/test_criterions.py::ExistsCriterionTests::test_not_exists", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__between_and_field", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__between_and_isin", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__nested__and", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__nested__mixed", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__nested__or", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_and", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_function_and", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_function_or", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_function_xor", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_or", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_xor", + "pypika/tests/test_criterions.py::FieldsAsCriterionTests::test__field_and_field", + "pypika/tests/test_criterions.py::FieldsAsCriterionTests::test__field_or_field", + "pypika/tests/test_criterions.py::FieldsAsCriterionTests::test__field_xor_field", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_arithmeticfunction_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_betweencriterion_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_complexcriterion_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_criterion_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_field_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_function_with_only_fields_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_function_with_values_and_fields_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_nullcriterion_replace_table", + "pypika/tests/test_criterions.py::AnyTests::test_multiple_args_returned_in_chain_of_ors", + "pypika/tests/test_criterions.py::AnyTests::test_single_arg_returns_self", + "pypika/tests/test_criterions.py::AnyTests::test_with_generator", + "pypika/tests/test_criterions.py::AnyTests::test_zero_args_returns_empty_criterion", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_different_operations_with_empty_criterion", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_empty_criterion_on_the_left", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_empty_criterion_on_the_right", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_fields_", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_invertion_of_the_empty_criterion", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_more_than_one_empty_criterions", + "pypika/tests/test_criterions.py::AllTests::test_multiple_args_returned_in_chain_of_ors", + "pypika/tests/test_criterions.py::AllTests::test_single_arg_returns_self", + "pypika/tests/test_criterions.py::AllTests::test_with_generator", + "pypika/tests/test_criterions.py::AllTests::test_zero_args_returns_empty_criterion", + "pypika/tests/test_custom_functions.py::TestUnitCustomFunction::test_should_fail_with_wrong_arguments", + "pypika/tests/test_custom_functions.py::TestUnitCustomFunction::test_should_return_function_with_arguments", + "pypika/tests/test_custom_functions.py::TestUnitCustomFunction::test_should_return_function_with_no_arguments", + "pypika/tests/test_custom_functions.py::TestFunctionalCustomFunction::test_should_fail_use_custom_function_on_select_with_wrong_arguments", + "pypika/tests/test_custom_functions.py::TestFunctionalCustomFunction::test_should_use_custom_function_on_select", + "pypika/tests/test_data_types.py::StringTests::test_inline_string_concatentation", + "pypika/tests/test_data_types.py::UuidTests::test_uuid_string_generation", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_day", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_default", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_microsecond", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_minute", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_month", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_quarter", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_second", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_week", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_year", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_day_hour", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_day_microsecond", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_day_minute", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_day_second", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_hour_microsecond", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_hour_minute", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_hour_second", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_minute_microsecond", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_minute_second", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_second_microsecond", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_value_complex_expressions", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_value_right", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_year_month", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_mysql_dialect_uses_single_quotes_around_expression_in_an_interval", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_oracle_dialect_uses_single_quotes_around_expression_in_an_interval", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_postgresql_dialect_uses_single_quotes_around_interval", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_redshift_dialect_uses_single_quotes_around_interval", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_vertica_dialect_uses_single_quotes_around_interval", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_day", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_month", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_week", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_year", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_year_month", + "pypika/tests/test_date_math.py::TruncateTrailingZerosTests::test_do_not_truncate_integer_values", + "pypika/tests/test_date_math.py::TruncateTrailingZerosTests::test_do_not_truncate_months_between_years_and_datys", + "pypika/tests/test_deletes.py::DeleteTests::test_for_portion", + "pypika/tests/test_deletes.py::DeleteTests::test_omit_where", + "pypika/tests/test_deletes.py::DeleteTests::test_omit_where__table_schema", + "pypika/tests/test_deletes.py::DeleteTests::test_where_field_equals", + "pypika/tests/test_deletes.py::PostgresDeleteTests::test_delete_returning", + "pypika/tests/test_deletes.py::PostgresDeleteTests::test_delete_returning_star", + "pypika/tests/test_deletes.py::PostgresDeleteTests::test_delete_returning_str", + "pypika/tests/test_deletes.py::PostgresDeleteTests::test_delete_using", + "pypika/tests/test_drop.py::DropTableTests::test_drop_database", + "pypika/tests/test_drop.py::DropTableTests::test_drop_index", + "pypika/tests/test_drop.py::DropTableTests::test_drop_table", + "pypika/tests/test_drop.py::DropTableTests::test_drop_user", + "pypika/tests/test_drop.py::DropTableTests::test_drop_view", + "pypika/tests/test_formats.py::QuoteTests::test_no_quote_char_in_complex_query", + "pypika/tests/test_formats.py::QuoteTests::test_replace_quote_char_in_complex_query", + "pypika/tests/test_functions.py::FunctionTests::test_dialect_propagation", + "pypika/tests/test_functions.py::FunctionTests::test_is_aggregate_None_for_non_aggregate_function_or_function_with_no_aggregate_functions", + "pypika/tests/test_functions.py::FunctionTests::test_is_aggregate_True_for_aggregate_function_or_function_with_aggregate_functions", + "pypika/tests/test_functions.py::SchemaTests::test_schema_included_in_function_sql", + "pypika/tests/test_functions.py::SchemaTests::test_schema_no_schema_in_sql_when_none_set", + "pypika/tests/test_functions.py::ArithmeticTests::test__addition__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__addition__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__addition__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__addition__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__arithmetic_equality", + "pypika/tests/test_functions.py::ArithmeticTests::test__arithmetic_with_function", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_add_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_div_no_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_div_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_exponent_no_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_exponent_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_floor_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_function_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_modulus_no_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_modulus_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_mul_no_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_mul_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_nested_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_sub_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__division__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__division__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__division__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__division__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__exponent__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__exponent__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__floor", + "pypika/tests/test_functions.py::ArithmeticTests::test__leftshift__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__leftshift__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__leftshift__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__modulus__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__multiplication__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__multiplication__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__multiplication__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__multiplication__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__rightshift__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__rightshift__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__rightshift__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__subtraction__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__subtraction__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__subtraction__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__subtraction__right", + "pypika/tests/test_functions.py::AggregationTests::test__approx_percentile", + "pypika/tests/test_functions.py::AggregationTests::test__avg", + "pypika/tests/test_functions.py::AggregationTests::test__count", + "pypika/tests/test_functions.py::AggregationTests::test__count__star", + "pypika/tests/test_functions.py::AggregationTests::test__first", + "pypika/tests/test_functions.py::AggregationTests::test__last", + "pypika/tests/test_functions.py::AggregationTests::test__max", + "pypika/tests/test_functions.py::AggregationTests::test__min", + "pypika/tests/test_functions.py::AggregationTests::test__std", + "pypika/tests/test_functions.py::AggregationTests::test__stddev", + "pypika/tests/test_functions.py::AggregationTests::test__subquery_in_params_functions", + "pypika/tests/test_functions.py::AggregationTests::test__sum", + "pypika/tests/test_functions.py::ConditionTests::test__case__else", + "pypika/tests/test_functions.py::ConditionTests::test__case__field", + "pypika/tests/test_functions.py::ConditionTests::test__case__multi", + "pypika/tests/test_functions.py::ConditionTests::test__case__no_cases", + "pypika/tests/test_functions.py::ConditionTests::test__case__raw", + "pypika/tests/test_functions.py::StringTests::test__ascii__field", + "pypika/tests/test_functions.py::StringTests::test__ascii__int", + "pypika/tests/test_functions.py::StringTests::test__ascii__str", + "pypika/tests/test_functions.py::StringTests::test__bin__field", + "pypika/tests/test_functions.py::StringTests::test__bin__int", + "pypika/tests/test_functions.py::StringTests::test__bin__str", + "pypika/tests/test_functions.py::StringTests::test__concat__field", + "pypika/tests/test_functions.py::StringTests::test__concat__str", + "pypika/tests/test_functions.py::StringTests::test__insert__field", + "pypika/tests/test_functions.py::StringTests::test__insert__str", + "pypika/tests/test_functions.py::StringTests::test__length__field", + "pypika/tests/test_functions.py::StringTests::test__length__str", + "pypika/tests/test_functions.py::StringTests::test__lower__field", + "pypika/tests/test_functions.py::StringTests::test__lower__str", + "pypika/tests/test_functions.py::StringTests::test__replace__field", + "pypika/tests/test_functions.py::StringTests::test__replace__str", + "pypika/tests/test_functions.py::StringTests::test__substring", + "pypika/tests/test_functions.py::SplitPartFunctionTests::test__split_part", + "pypika/tests/test_functions.py::RegexpLikeFunctionTests::test__regexp_like", + "pypika/tests/test_functions.py::CastTests::test__cast__as", + "pypika/tests/test_functions.py::CastTests::test__cast__binary", + "pypika/tests/test_functions.py::CastTests::test__cast__binary_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__boolean", + "pypika/tests/test_functions.py::CastTests::test__cast__char", + "pypika/tests/test_functions.py::CastTests::test__cast__char_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__date", + "pypika/tests/test_functions.py::CastTests::test__cast__float", + "pypika/tests/test_functions.py::CastTests::test__cast__integer", + "pypika/tests/test_functions.py::CastTests::test__cast__long_varbinary", + "pypika/tests/test_functions.py::CastTests::test__cast__long_varbinary_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__long_varchar", + "pypika/tests/test_functions.py::CastTests::test__cast__long_varchar_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__numeric", + "pypika/tests/test_functions.py::CastTests::test__cast__signed", + "pypika/tests/test_functions.py::CastTests::test__cast__timestamp", + "pypika/tests/test_functions.py::CastTests::test__cast__unsigned", + "pypika/tests/test_functions.py::CastTests::test__cast__varbinary", + "pypika/tests/test_functions.py::CastTests::test__cast__varbinary_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__varchar", + "pypika/tests/test_functions.py::CastTests::test__cast__varchar_with_arg", + "pypika/tests/test_functions.py::CastTests::test__tochar__", + "pypika/tests/test_functions.py::DateFunctionsTests::test_current_date", + "pypika/tests/test_functions.py::DateFunctionsTests::test_current_time", + "pypika/tests/test_functions.py::DateFunctionsTests::test_current_timestamp", + "pypika/tests/test_functions.py::DateFunctionsTests::test_current_timestamp_with_alias", + "pypika/tests/test_functions.py::DateFunctionsTests::test_date_add", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_day", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_hour", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_join", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_microsecond", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_minute", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_month", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_quarter", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_second", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_week", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_year", + "pypika/tests/test_functions.py::DateFunctionsTests::test_now", + "pypika/tests/test_functions.py::DateFunctionsTests::test_time_diff", + "pypika/tests/test_functions.py::DateFunctionsTests::test_timestampadd", + "pypika/tests/test_functions.py::DateFunctionsTests::test_to_date", + "pypika/tests/test_functions.py::DateFunctionsTests::test_utc_timestamp", + "pypika/tests/test_functions.py::NullFunctionsTests::test_coalesce", + "pypika/tests/test_functions.py::NullFunctionsTests::test_isnull", + "pypika/tests/test_functions.py::NullFunctionsTests::test_nullif", + "pypika/tests/test_functions.py::NullFunctionsTests::test_nvl", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_mysql_one_groupby", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_mysql_rollup_two_groupbys", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_no_rollup_after_rollup_mysql", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_no_rollup_before_groupby", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_from_groupbys", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_from_parameters", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_from_two_groupbys", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_func_one_groupby", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_func_partial", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_func_two_groupbys", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_multiple_rollups", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_rollups_with_multiple_rollups_and_parity", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_rollups_with_parity", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_force_index_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_groupby_returns_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_immutable_kwarg_on_query_builder_disables_immutability", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_insert_into_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_join_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_orderby_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_queries_after_join", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_replace_into_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_select_returns_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_update_set_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_use_index_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_with_return_new_query_instance", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_multi_rows", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_multi_rows_chained", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_multi_rows_chained_mixed", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_multi_rows_chained_multiple_rows", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_single_element", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_column_using_alias_with_chain", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_column_using_table_alias", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_empty_columns", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_empty_columns_type_list", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_empty_columns_type_tuple", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_ignore", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_multiple_rows_with_array_value", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_none_skipped", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_null", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_one_column", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_one_column_multi_element_array", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_one_column_single_element_array", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_selected_columns", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_selected_columns_type_list", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_selected_columns_type_tuple", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_single_row_with_array_value", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_with_statement", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_empty_on_conflict_do_update_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_field", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_field_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_mixed_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_multiple_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_multiple_fields_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_field", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_field_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_multiple_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_multiple_fields_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_multiple_mixed_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_no_handler", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_two_handlers_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_two_handlers_do_update", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_fieldless_conflict_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_fieldless_conflict_do_update_field", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_non_insert_on_conflict_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_non_insert_on_conflict_do_update", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_do_nothing_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_do_update_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_do_update_with_excluded_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_from_subquery", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_complex", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_conflict_fields_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_conflict_fields_do_update", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_empty_conflict_fields_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_empty_conflict_fields_do_update", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_where_and_on_conflict_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_all_columns_multi_rows_chained_returning_star", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_all_columns_multi_rows_chained_returning_star_and_id", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_all_columns_multi_rows_chained_returning_star_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_all_columns_single_element_arrays", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_aggregate", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_all_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_all_fields_and_arithmetics", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_arithmetics", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_from_other_table", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_functions", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_null", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_one_field", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_one_field_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_tuple", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_ignore", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multi_rows_chained_mixed_on_duplicate_update_multiple", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_multiple", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_different_value", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_expression", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_expression_using_original_field_value", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_expression_using_values", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_same_value", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_none_skipped", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_one_column", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_one_column_multi_element_array", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_one_column_single_element_array", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_one_column_using_values", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_selected_columns_on_duplicate_update_multiple", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_selected_columns_on_duplicate_update_one", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_columns_from_columns", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_columns_from_columns_with_join", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_columns_from_star", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_from_columns", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_ignore_star", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_star", + "pypika/tests/test_inserts.py::InsertSubqueryTests::test_insert_subquery_wrapped_in_brackets", + "pypika/tests/test_inserts.py::SelectIntoTests::test_select_columns_into", + "pypika/tests/test_inserts.py::SelectIntoTests::test_select_columns_into_with_join", + "pypika/tests/test_inserts.py::SelectIntoTests::test_select_star_into", + "pypika/tests/test_inserts.py::ReplaceTests::test_replace_simple", + "pypika/tests/test_inserts.py::ReplaceTests::test_replace_subquery", + "pypika/tests/test_internals.py::TablesTests::test__case_tables", + "pypika/tests/test_internals.py::TablesTests::test__criterion_replace_table_with_value", + "pypika/tests/test_internals.py::TablesTests::test__star_tables", + "pypika/tests/test_internals.py::TablesTests::test__table_star_tables", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_cross_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_cross_join_on_subquery", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_cross_join_on_table", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_default_join_type", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_full_outer_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_hash_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_inner_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_arithmetic_field", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_collate", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_complex_criteria", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_field_multi", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_field_multi_with_extra_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_field_single", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_field_without_fields_raises_exception", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_subquery_criteria", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_second_table_in_from_clause", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_using_multiple_fields", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_using_string_field_name", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_using_with_quote_char", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_using_without_fields_raises_exception", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_with_arithmetic_function_in_select", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_left_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_left_outer_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_outer_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_right_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_right_outer_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_temporal_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_use_different_table_objects_for_same_table", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_fail_when_joining_unknown_type", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_ignore_table_references", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_immutable__tables", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_from_join", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_query_with_column_alias", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_query_with_setoperation", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_query_with_table_alias", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_query_without_alias", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_same_table", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_same_table_with_prefixes", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_table_twice", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_prefixes_added_to_function_in_orderby", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_prefixes_added_to_groupby", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_prefixes_added_to_orderby", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_require_condition", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_require_condition_with_both_tables", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select__fields_after_table_star", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select__ordered_select_clauses", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select__star_for_table", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select__star_for_table__replacement", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select_field_from_missing_table", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select_fields_with_where", + "pypika/tests/test_joins.py::UnionTests::test_mysql_query_wraps_unioned_queries", + "pypika/tests/test_joins.py::UnionTests::test_require_equal_number_of_fields", + "pypika/tests/test_joins.py::UnionTests::test_union", + "pypika/tests/test_joins.py::UnionTests::test_union_all", + "pypika/tests/test_joins.py::UnionTests::test_union_all_multiple", + "pypika/tests/test_joins.py::UnionTests::test_union_as_subquery", + "pypika/tests/test_joins.py::UnionTests::test_union_multiple", + "pypika/tests/test_joins.py::UnionTests::test_union_with_no_quote_char", + "pypika/tests/test_joins.py::UnionTests::test_union_with_order_by", + "pypika/tests/test_joins.py::UnionTests::test_union_with_order_by_use_union_query_field", + "pypika/tests/test_joins.py::UnionTests::test_union_with_order_by_use_union_query_field_with_aliases", + "pypika/tests/test_joins.py::UnionTests::test_union_with_order_by_with_aliases", + "pypika/tests/test_joins.py::InsertQueryJoinTests::test_join_table_on_insert_query", + "pypika/tests/test_joins.py::UpdateQueryJoinTests::test_join_table_on_update_query", + "pypika/tests/test_joins.py::IntersectTests::test_intersect", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_as_subquery", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_multiple", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_with_limit", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_with_no_quote_char", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_with_offset", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_with_order_by", + "pypika/tests/test_joins.py::IntersectTests::test_mysql_query_wraps_intersected_queries", + "pypika/tests/test_joins.py::IntersectTests::test_require_equal_number_of_fields_intersect", + "pypika/tests/test_joins.py::MinusTests::test_minus", + "pypika/tests/test_joins.py::MinusTests::test_minus_as_subquery", + "pypika/tests/test_joins.py::MinusTests::test_minus_multiple", + "pypika/tests/test_joins.py::MinusTests::test_minus_query_with_order_by_use_minus_query_field", + "pypika/tests/test_joins.py::MinusTests::test_minus_with_no_quote_char", + "pypika/tests/test_joins.py::MinusTests::test_minus_with_order_by", + "pypika/tests/test_joins.py::MinusTests::test_mysql_query_wraps_minus_queries", + "pypika/tests/test_joins.py::MinusTests::test_require_equal_number_of_fields", + "pypika/tests/test_joins.py::ExceptOfTests::test_except", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_as_subquery", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_multiple", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_query_with_order_by_use_minus_query_field", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_with_no_quote_char", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_with_order_by", + "pypika/tests/test_joins.py::ExceptOfTests::test_require_equal_number_of_fields_except_of", + "pypika/tests/test_negation.py::NegationTests::test_negate_field", + "pypika/tests/test_negation.py::NegationTests::test_negate_function", + "pypika/tests/test_negation.py::NegationTests::test_negate_wrapped_float", + "pypika/tests/test_negation.py::NegationTests::test_negate_wrapped_int", + "pypika/tests/test_parameter.py::ParametrizedTests::test_format_parameter", + "pypika/tests/test_parameter.py::ParametrizedTests::test_join", + "pypika/tests/test_parameter.py::ParametrizedTests::test_named_parameter", + "pypika/tests/test_parameter.py::ParametrizedTests::test_numeric_parameter", + "pypika/tests/test_parameter.py::ParametrizedTests::test_param_insert", + "pypika/tests/test_parameter.py::ParametrizedTests::test_param_select_join", + "pypika/tests/test_parameter.py::ParametrizedTests::test_param_select_subquery", + "pypika/tests/test_parameter.py::ParametrizedTests::test_pyformat_parameter", + "pypika/tests/test_parameter.py::ParametrizedTests::test_qmark_parameter", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_join", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_join_with_parameter_value_wrapper", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_param_insert", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_param_select_join", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_param_select_subquery", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_pyformat_parameter", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_can_be_used_in_a_select_statement", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_can_be_used_in_a_where_clause", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_can_be_used_in_orderby", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_column_value", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_object_id", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_object_value", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_row_id", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_row_num", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_sys_date", + "pypika/tests/test_query.py::QueryTablesTests::test_is_joined", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_case_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_delete_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_filter_tables", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_having_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_insert_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_insert_table_current_table_not_match", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_join_tables", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_only_specified_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_orderby_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_tuple_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_update_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_update_table_current_table_not_match", + "pypika/tests/test_query.py::QueryBuilderTests::test_pipe", + "pypika/tests/test_query.py::QueryBuilderTests::test_query_builders_have_reference_to_correct_query_class", + "pypika/tests/test_selects.py::SelectTests::test_empty_query", + "pypika/tests/test_selects.py::SelectTests::test_mssql_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_mysql_query_uses_backtick_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_oracle_query_uses_no_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_postgresql_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_redshift_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_select__column__single__alias__str", + "pypika/tests/test_selects.py::SelectTests::test_select__column__single__field", + "pypika/tests/test_selects.py::SelectTests::test_select__column__single__str", + "pypika/tests/test_selects.py::SelectTests::test_select__column__single__table_alias__str", + "pypika/tests/test_selects.py::SelectTests::test_select__columns__multi__field", + "pypika/tests/test_selects.py::SelectTests::test_select__columns__multi__str", + "pypika/tests/test_selects.py::SelectTests::test_select__distinct__multi", + "pypika/tests/test_selects.py::SelectTests::test_select__distinct__single", + "pypika/tests/test_selects.py::SelectTests::test_select__multiple_subqueries", + "pypika/tests/test_selects.py::SelectTests::test_select__multiple_tables", + "pypika/tests/test_selects.py::SelectTests::test_select__nested_subquery", + "pypika/tests/test_selects.py::SelectTests::test_select__no_table", + "pypika/tests/test_selects.py::SelectTests::test_select__star", + "pypika/tests/test_selects.py::SelectTests::test_select__star__replacement", + "pypika/tests/test_selects.py::SelectTests::test_select__subquery", + "pypika/tests/test_selects.py::SelectTests::test_select__table_schema", + "pypika/tests/test_selects.py::SelectTests::test_select__table_schema_with_multiple_levels_as_list", + "pypika/tests/test_selects.py::SelectTests::test_select__table_schema_with_multiple_levels_as_tuple", + "pypika/tests/test_selects.py::SelectTests::test_select_no_from", + "pypika/tests/test_selects.py::SelectTests::test_select_no_from_with_field_raises_exception", + "pypika/tests/test_selects.py::SelectTests::test_select_no_with_alias_from", + "pypika/tests/test_selects.py::SelectTests::test_select_then_add_table", + "pypika/tests/test_selects.py::SelectTests::test_select_with_force_index", + "pypika/tests/test_selects.py::SelectTests::test_select_with_force_index_multiple_calls", + "pypika/tests/test_selects.py::SelectTests::test_select_with_force_index_multiple_indexes", + "pypika/tests/test_selects.py::SelectTests::test_select_with_force_index_with_index_object", + "pypika/tests/test_selects.py::SelectTests::test_select_with_limit", + "pypika/tests/test_selects.py::SelectTests::test_select_with_limit__func", + "pypika/tests/test_selects.py::SelectTests::test_select_with_limit_and_offset", + "pypika/tests/test_selects.py::SelectTests::test_select_with_limit_zero", + "pypika/tests/test_selects.py::SelectTests::test_select_with_offset", + "pypika/tests/test_selects.py::SelectTests::test_select_with_offset__func", + "pypika/tests/test_selects.py::SelectTests::test_select_with_use_index", + "pypika/tests/test_selects.py::SelectTests::test_select_with_use_index_multiple_calls", + "pypika/tests/test_selects.py::SelectTests::test_select_with_use_index_multiple_indexes", + "pypika/tests/test_selects.py::SelectTests::test_select_with_use_index_with_index_object", + "pypika/tests/test_selects.py::SelectTests::test_table_select_alias", + "pypika/tests/test_selects.py::SelectTests::test_table_select_alias_with_offset_and_limit", + "pypika/tests/test_selects.py::SelectTests::test_temporal_select", + "pypika/tests/test_selects.py::SelectTests::test_vertica_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::WhereTests::test_ignore_empty_criterion_having", + "pypika/tests/test_selects.py::WhereTests::test_ignore_empty_criterion_where", + "pypika/tests/test_selects.py::WhereTests::test_select_with_force_index_and_where", + "pypika/tests/test_selects.py::WhereTests::test_where_enum", + "pypika/tests/test_selects.py::WhereTests::test_where_field_contains", + "pypika/tests/test_selects.py::WhereTests::test_where_field_does_not_contain", + "pypika/tests/test_selects.py::WhereTests::test_where_field_does_not_end_with", + "pypika/tests/test_selects.py::WhereTests::test_where_field_does_not_start_with", + "pypika/tests/test_selects.py::WhereTests::test_where_field_ends_with", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_and", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_nowait", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_of", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_of_multiple_tables", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_of_nowait", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_of_skip_locked", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_skip_locked", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_skip_locked_and_of", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_or", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_where", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_where_not", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_where_two_not", + "pypika/tests/test_selects.py::WhereTests::test_where_field_is_n_chars_long", + "pypika/tests/test_selects.py::WhereTests::test_where_field_is_not_n_chars_long", + "pypika/tests/test_selects.py::WhereTests::test_where_field_matches_regex", + "pypika/tests/test_selects.py::WhereTests::test_where_field_matches_regexp", + "pypika/tests/test_selects.py::WhereTests::test_where_field_matches_rlike", + "pypika/tests/test_selects.py::WhereTests::test_where_field_starts_with", + "pypika/tests/test_selects.py::WhereTests::test_where_nested_conditions", + "pypika/tests/test_selects.py::WhereTests::test_where_single_quote", + "pypika/tests/test_selects.py::WhereTests::test_where_with_multiple_wheres_using_and_case", + "pypika/tests/test_selects.py::WhereTests::test_where_with_multiple_wheres_using_or_case", + "pypika/tests/test_selects.py::PreWhereTests::test_ignore_empty_criterion_having", + "pypika/tests/test_selects.py::PreWhereTests::test_ignore_empty_criterion_where", + "pypika/tests/test_selects.py::PreWhereTests::test_prewhere_field_equals", + "pypika/tests/test_selects.py::PreWhereTests::test_select_with_force_index_and_where", + "pypika/tests/test_selects.py::PreWhereTests::test_where_and_prewhere", + "pypika/tests/test_selects.py::PreWhereTests::test_where_enum", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_contains", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_does_not_contain", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_does_not_end_with", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_does_not_start_with", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_ends_with", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_and", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_nowait", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_of", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_of_multiple_tables", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_of_nowait", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_of_skip_locked", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_skip_locked", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_skip_locked_and_of", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_or", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_where", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_where_not", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_where_two_not", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_is_n_chars_long", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_is_not_n_chars_long", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_matches_regex", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_matches_regexp", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_matches_rlike", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_starts_with", + "pypika/tests/test_selects.py::PreWhereTests::test_where_nested_conditions", + "pypika/tests/test_selects.py::PreWhereTests::test_where_single_quote", + "pypika/tests/test_selects.py::PreWhereTests::test_where_with_multiple_wheres_using_and_case", + "pypika/tests/test_selects.py::PreWhereTests::test_where_with_multiple_wheres_using_or_case", + "pypika/tests/test_selects.py::GroupByTests::test_group_by__single_with_totals", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__alias", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__alias_platforms", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__alias_with_join", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__count_distinct", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__count_field", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__count_star", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__int", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__multi", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__multi_with_totals", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__no_alias", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__no_alias_mssql", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__no_alias_oracle", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__single", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__str", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__sum_distinct", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__sum_filter", + "pypika/tests/test_selects.py::GroupByTests::test_groupby_with_case_uses_the_alias", + "pypika/tests/test_selects.py::GroupByTests::test_mssql_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_mysql_query_uses_backtick_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_oracle_query_uses_no_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_postgres_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_redshift_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_vertica_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_having_and", + "pypika/tests/test_selects.py::HavingTests::test_having_greater_than", + "pypika/tests/test_selects.py::HavingTests::test_having_join_and_equality", + "pypika/tests/test_selects.py::HavingTests::test_mssql_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_mysql_query_uses_backtick_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_oracle_query_uses_no_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_postgres_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_redshift_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_vertica_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_alias", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_asc", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_desc", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_multi_fields", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_no_alias", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_single_field", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_single_str", + "pypika/tests/test_selects.py::AliasTests::test_arithmetic_function", + "pypika/tests/test_selects.py::AliasTests::test_case_using_as", + "pypika/tests/test_selects.py::AliasTests::test_case_using_constructor_param", + "pypika/tests/test_selects.py::AliasTests::test_function_using_as_nested", + "pypika/tests/test_selects.py::AliasTests::test_functions_using_as", + "pypika/tests/test_selects.py::AliasTests::test_functions_using_constructor_param", + "pypika/tests/test_selects.py::AliasTests::test_functions_using_constructor_param_nested", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_criterion", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_criterion_comparison", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_field_inside_case", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_groupby", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_orderby", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_where", + "pypika/tests/test_selects.py::AliasTests::test_null_value_with_alias", + "pypika/tests/test_selects.py::AliasTests::test_select__multiple_tables", + "pypika/tests/test_selects.py::AliasTests::test_table_field", + "pypika/tests/test_selects.py::AliasTests::test_table_field__multi", + "pypika/tests/test_selects.py::AliasTests::test_table_with_schema_and_alias", + "pypika/tests/test_selects.py::AliasTests::test_use_aliases_in_groupby_and_orderby", + "pypika/tests/test_selects.py::SubqueryTests::test_from_subquery_without_alias", + "pypika/tests/test_selects.py::SubqueryTests::test_join", + "pypika/tests/test_selects.py::SubqueryTests::test_join_query_with_alias", + "pypika/tests/test_selects.py::SubqueryTests::test_join_with_with", + "pypika/tests/test_selects.py::SubqueryTests::test_select_from_nested_query", + "pypika/tests/test_selects.py::SubqueryTests::test_select_from_nested_query_with_join", + "pypika/tests/test_selects.py::SubqueryTests::test_select_from_with_returning", + "pypika/tests/test_selects.py::SubqueryTests::test_select_subquery", + "pypika/tests/test_selects.py::SubqueryTests::test_select_subquery_with_alias", + "pypika/tests/test_selects.py::SubqueryTests::test_where__equality", + "pypika/tests/test_selects.py::SubqueryTests::test_where__in", + "pypika/tests/test_selects.py::SubqueryTests::test_where__in_nested", + "pypika/tests/test_selects.py::SubqueryTests::test_with", + "pypika/tests/test_selects.py::QuoteTests::test_extraneous_quotes", + "pypika/tests/test_tables.py::TableStructureTests::test_database_schema_table_attr", + "pypika/tests/test_tables.py::TableStructureTests::test_schema_table_attr", + "pypika/tests/test_tables.py::TableStructureTests::test_table_for_period_sql", + "pypika/tests/test_tables.py::TableStructureTests::test_table_for_system_time_sql", + "pypika/tests/test_tables.py::TableStructureTests::test_table_sql", + "pypika/tests/test_tables.py::TableStructureTests::test_table_with_alias", + "pypika/tests/test_tables.py::TableStructureTests::test_table_with_schema_and_schema_parent_arg", + "pypika/tests/test_tables.py::TableStructureTests::test_table_with_schema_arg", + "pypika/tests/test_tables.py::TableEqualityTests::test_many_tables_with_alias", + "pypika/tests/test_tables.py::TableEqualityTests::test_many_tables_with_or_not_alias", + "pypika/tests/test_tables.py::TableEqualityTests::test_many_tables_without_alias", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_equal_by_name", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_equal_by_schema_and_name", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_equal_by_schema_and_name_using_schema", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_equal_by_schema_and_name_using_schema_with_parent", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_not_equal_by_schema_and_name_using_schema_with_different_parents", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_not_equal_with_different_names", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_not_equal_with_different_schemas", + "pypika/tests/test_tables.py::TableDialectTests::test_make_tables_factory_with_default_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_make_tables_factory_with_dialect_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_factory_with_default_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_factory_with_dialect_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_with_bad_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_with_default_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_with_dialect_query_cls", + "pypika/tests/test_terms.py::FieldAliasTests::test_when_alias_specified", + "pypika/tests/test_terms.py::FieldInitTests::test_init_with_str_table", + "pypika/tests/test_terms.py::FieldHashingTests::test_non_tabled_aliased_eq_fields_equally_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_non_tabled_aliased_ne_fields_differently_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_non_tabled_eq_fields_equally_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_non_tabled_ne_fields_differently_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_tabled_eq_fields_equally_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_tabled_ne_fields_differently_hashed", + "pypika/tests/test_terms.py::AtTimezoneTests::test_passes_kwargs_to_field_get_sql", + "pypika/tests/test_terms.py::AtTimezoneTests::test_when_alias_specified", + "pypika/tests/test_terms.py::AtTimezoneTests::test_when_interval_not_specified", + "pypika/tests/test_terms.py::AtTimezoneTests::test_when_interval_specified", + "pypika/tests/test_tuples.py::TupleTests::test_render_alias_in_array_sql", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_equality_tuple_on_both", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_equality_tuple_on_left", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_equality_tuple_on_right", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_in_using_mixed_tuples", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_in_using_pypika_tuples", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_in_using_python_tuples", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_is_aggregate", + "pypika/tests/test_tuples.py::TupleTests::test_tuples_in_join", + "pypika/tests/test_tuples.py::ArrayTests::test_array_general", + "pypika/tests/test_tuples.py::ArrayTests::test_empty_psql_array", + "pypika/tests/test_tuples.py::ArrayTests::test_psql_array_general", + "pypika/tests/test_tuples.py::ArrayTests::test_render_alias_in_array_sql", + "pypika/tests/test_tuples.py::BracketTests::test_arithmetic_with_brackets", + "pypika/tests/test_tuples.py::BracketTests::test_arithmetic_with_brackets_and_alias", + "pypika/tests/test_updates.py::UpdateTests::test_empty_query", + "pypika/tests/test_updates.py::UpdateTests::test_for_portion", + "pypika/tests/test_updates.py::UpdateTests::test_omit_where", + "pypika/tests/test_updates.py::UpdateTests::test_single_quote_escape_in_set", + "pypika/tests/test_updates.py::UpdateTests::test_update__table_schema", + "pypika/tests/test_updates.py::UpdateTests::test_update_from", + "pypika/tests/test_updates.py::UpdateTests::test_update_from_with_where", + "pypika/tests/test_updates.py::UpdateTests::test_update_with_join", + "pypika/tests/test_updates.py::UpdateTests::test_update_with_limit", + "pypika/tests/test_updates.py::UpdateTests::test_update_with_none", + "pypika/tests/test_updates.py::UpdateTests::test_update_with_statement", + "pypika/tests/test_updates.py::PostgresUpdateTests::test_update_returning", + "pypika/tests/test_updates.py::PostgresUpdateTests::test_update_returning_from_different_tables", + "pypika/tests/test_updates.py::PostgresUpdateTests::test_update_returning_star", + "pypika/tests/test_updates.py::PostgresUpdateTests::test_update_returning_str", + "pypika/tests/test_updates.py::SQLLiteUpdateTests::test_update_with_bool", + "pypika/tests/test_utils.py::ImmutabilityTests::test_raise_attribute_error_for_deepcopy", + "pypika/tests/test_utils.py::ImmutabilityTests::test_raise_attribute_error_for_getnewargs", + "pypika/tests/test_utils.py::ImmutabilityTests::test_raise_attribute_error_for_getstate", + "pypika/tests/test_utils.py::ImmutabilityTests::test_raise_attribute_error_for_setstate" + ] +} diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/grade.py b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/grade.py new file mode 100644 index 0000000000000000000000000000000000000000..e3b37293830e51a5c5833c93c4705e1ed9364257 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/grade.py @@ -0,0 +1,128 @@ +"""Trusted private pytest panel runner. Installed only in a fresh grader Job.""" + +import hashlib +import importlib.util +import json +import os +import shutil +import stat +import subprocess +from pathlib import Path, PurePosixPath + + +def sha(raw): + return hashlib.sha256(raw).hexdigest() + + +def safe(value): + path = PurePosixPath(value) + if ( + path.is_absolute() + or path.as_posix() != value + or not path.parts + or any(part in {".", "..", ".git"} for part in path.parts) + ): + raise ValueError("Unsafe trusted test path") + return path + + +def restore(worktree, private, manifest): + worktree, private = Path(worktree), Path(private) + captured = {} + for name, expected in manifest["files"].items(): + path = private / safe(name) + info = path.lstat() + raw = path.read_bytes() if stat.S_ISREG(info.st_mode) else b"" + if ( + not stat.S_ISREG(info.st_mode) + or len(raw) != expected["bytes"] + or sha(raw) != expected["sha256"] + or stat.S_IMODE(info.st_mode) != expected["mode"] + ): + raise ValueError("Trusted private test bytes or modes drifted") + captured[name] = (raw, expected["mode"]) + # Capture and verify every private byte before changing the submitted tree. + for name in manifest["directory_roots"]: + destination = worktree / safe(name) + if destination.is_symlink(): + raise ValueError("Submitted test directory is a symlink") + for parent in destination.parents: + if parent == worktree: + break + if parent.is_symlink(): + raise ValueError("Submitted test parent is a symlink") + if destination.exists(): + if not destination.is_dir(): + raise ValueError("Submitted test directory is not a directory") + shutil.rmtree(destination) + for name, (raw, mode) in captured.items(): + destination = worktree / safe(name) + for parent in destination.parents: + if parent == worktree: + break + if parent.is_symlink(): + raise ValueError("Submitted test parent is a symlink") + if destination.is_symlink(): + raise ValueError("Submitted trusted file is a symlink") + destination.parent.mkdir(parents=True, exist_ok=True) + destination.write_bytes(raw) + destination.chmod(mode) + + +def run(worktree, private_root, output, invoke=None): + private_root, output, worktree = Path(private_root), Path(output), Path(worktree) + expected = json.loads((private_root / "expected-panels.json").read_bytes()) + config = json.loads((private_root / "panel-config.json").read_bytes()) + manifest = json.loads((private_root / "trusted-inventory.json").read_bytes()) + restore(worktree, private_root / "trusted", manifest) + output.mkdir(parents=True, exist_ok=True) + for name in ( + "reward.txt", + "pass-to-pass.xml", + "fail-to-pass.xml", + "pytest-evidence.json", + ): + (output / name).unlink(missing_ok=True) + environment = dict(os.environ) + for key in ("PYTEST_ADDOPTS", "PYTEST_DISABLE_PLUGIN_AUTOLOAD", "PYTHONPATH"): + environment.pop(key, None) + commands, native_exit = [], 0 + invoke = invoke or subprocess.run + for group in ("pass-to-pass", "fail-to-pass"): + if ( + not isinstance(expected[group], list) + or not expected[group] + or any( + not isinstance(target, str) or not target for target in expected[group] + ) + ): + raise ValueError("Frozen native pytest selectors are incomplete") + command = [ + *config["official_pytest_argv"], + "--override-ini=addopts=", + "--junitxml=" + str(output / (group + ".xml")), + *expected[group], + ] + result = invoke(command, cwd=worktree, env=environment, check=False) + native_exit = result.returncode + commands.append({"group": group, "argv": command, "exit_code": native_exit}) + if native_exit != 0: + break + (output / "pytest-commands.json").write_text( + json.dumps(commands, sort_keys=True) + "\n" + ) + spec = importlib.util.spec_from_file_location( + "trusted_pytest_result", private_root / "check_pytest.py" + ) + checker = importlib.util.module_from_spec(spec) + spec.loader.exec_module(checker) + result = checker.assess(output, expected, native_exit) + (output / "reward.txt").write_text(str(result["reward"]) + "\n") + (output / "pytest-evidence.json").write_text( + json.dumps(result, sort_keys=True) + "\n" + ) + return result + + +if __name__ == "__main__": + run("/testbed/repo", "/tests", "/logs/verifier") diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/panel-config.json b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/panel-config.json new file mode 100644 index 0000000000000000000000000000000000000000..6417b9c92e5da5b97ee641bd54f798302af42a31 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/panel-config.json @@ -0,0 +1,28 @@ +{ + "dependency_installation_pinned": false, + "official_install_cmds": [ + "python -m pip install -e ." + ], + "official_pytest_argv": [ + "pytest", + "--disable-warnings", + "--color=no", + "--tb=no", + "--verbose" + ], + "official_test_command": "source /opt/miniconda3/bin/activate; conda activate testbed; pytest --disable-warnings --color=no --tb=no --verbose", + "operator_test_runner_prerequisites": [ + "python -m pip install pytest==8.4.2" + ], + "operator_test_runner_reason": "The official profile invokes pytest, but the common tools runtime does not provide it; pinned separately from source-native project requirements.", + "panel_normalization": "Override project addopts only to execute the exact frozen native panels; add JUnit output, preserve official pytest options and all selectors.", + "python_version": "3.10", + "source_bound_test_dependency_cmds": [ + "python -m pip install parameterized==0.7.0" + ], + "test_dependency_source_sha256": { + "requirements-dev.txt": "10f4ba7b19a73950d28fd7403d7e1d1b1fe2ccc4f49516974f47199d2965f23d", + "setup.py": "f8bad274588a22e65764d8cf9fb2be5aa6fcfaf3bf861d71e5f751105898845a", + "tox.ini": "c2d7205d0ac93e9c9e80dc5d24f0a826a6781f587a33ea722ea621f9e2ccd0ea" + } +} diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/test.sh b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..81b6d0620f05dbd3b54b4e7ea5de04ce3f8a98e2 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/test.sh @@ -0,0 +1,6 @@ +#!/bin/bash +set -Eeuo pipefail +source /opt/miniconda3/bin/activate +conda activate testbed +cd /testbed/repo +exec python -I /tests/grade.py diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted-inventory.json b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted-inventory.json new file mode 100644 index 0000000000000000000000000000000000000000..6926ef1c22ed56457101c37cd70e0fe0d1656f0c --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted-inventory.json @@ -0,0 +1,242 @@ +{ + "directory_roots": [ + "pypika/tests" + ], + "files": { + "pypika/tests/__init__.py": { + "bytes": 58, + "mode": 420, + "sha256": "7d41f44b87688bdf162e6d5cbe7b517cfba468f96eaa421f02718c17eb486a18" + }, + "pypika/tests/clickhouse/__init__.py": { + "bytes": 0, + "mode": 420, + "sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "pypika/tests/clickhouse/test_array.py": { + "bytes": 2942, + "mode": 420, + "sha256": "0f0a5b4c3daf3ddce2944b6119795e80d50b74e4687ef2e34399e5d21d3d48ae" + }, + "pypika/tests/clickhouse/test_condition.py": { + "bytes": 2533, + "mode": 420, + "sha256": "c666976d082b1d12cd57e791d1a525183246335efad96a369b58871a6f1e4fa1" + }, + "pypika/tests/clickhouse/test_dates_and_times.py": { + "bytes": 2508, + "mode": 420, + "sha256": "cb8ea84363e35ad0a00b52a8ec20cb38f2348f4cba28d026a4c32c14fd1fc56f" + }, + "pypika/tests/clickhouse/test_nullable_arg.py": { + "bytes": 672, + "mode": 420, + "sha256": "883c5161ebeb09544ce124d20a096d248bd12a0404ad77c84637be75d6738529" + }, + "pypika/tests/clickhouse/test_search_string.py": { + "bytes": 1189, + "mode": 420, + "sha256": "d5f0ed6a51cf550bdd4b261fa2e98084184dd1cbb08f5dbb8b91278b4c8f3bfd" + }, + "pypika/tests/clickhouse/test_type_conversion.py": { + "bytes": 4445, + "mode": 420, + "sha256": "7e6045b64433a8947346cfb34ac30279349f7a2e2081a2815212c8cb7d0235ab" + }, + "pypika/tests/dialects/__init__.py": { + "bytes": 0, + "mode": 420, + "sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "pypika/tests/dialects/test_clickhouse.py": { + "bytes": 5747, + "mode": 420, + "sha256": "2272538d6eeb6dfb01f9803eed328b4cd4efc8d255b6a8ab3c4e25bee74d73fa" + }, + "pypika/tests/dialects/test_mssql.py": { + "bytes": 3152, + "mode": 420, + "sha256": "0cd9b2ee6498caa9fa75a51ead30803057fb23deb2ac706d396d88329e0e91d7" + }, + "pypika/tests/dialects/test_mysql.py": { + "bytes": 2984, + "mode": 420, + "sha256": "a5f4550dd14bf4820e5d85cf06b6c7c79286e41d2d3c794f639579d20fffab92" + }, + "pypika/tests/dialects/test_oracle.py": { + "bytes": 1906, + "mode": 420, + "sha256": "67f80eb40cc9b4dabcbad355e8be6d83c54a64cbee809182ef57fa9f48d2ebc6" + }, + "pypika/tests/dialects/test_postgresql.py": { + "bytes": 9532, + "mode": 420, + "sha256": "548ee7267ca87c9e1ae82ca89a4e5bd96c7392a55cc07996f2b105f911ffa6cf" + }, + "pypika/tests/dialects/test_snowflake.py": { + "bytes": 2159, + "mode": 420, + "sha256": "e567b9dab0a5366bd11a0ef162c3a3bb492280b78bc4b397a23070563dc84468" + }, + "pypika/tests/dialects/test_sqllite.py": { + "bytes": 1243, + "mode": 420, + "sha256": "118fed7e575415f276bda390a119080bd6a767aee3d9c953e11a8c219f0f017c" + }, + "pypika/tests/dialects/test_vertica.py": { + "bytes": 3578, + "mode": 420, + "sha256": "33a027e6735ca03b7afd11394905c4193e48a15dda3efbe47cdcd85fcabf840c" + }, + "pypika/tests/test_aggregate.py": { + "bytes": 3946, + "mode": 420, + "sha256": "5b0fb549de3bb50ad88ae1d75824f12f7ab4a5f1102b06a70c7b2ebae33bea6d" + }, + "pypika/tests/test_analytic_queries.py": { + "bytes": 20611, + "mode": 420, + "sha256": "8546b7a296c8e212c349c4baff95f93934b3120f74625b3945ade3b438e3a3ed" + }, + "pypika/tests/test_create.py": { + "bytes": 9088, + "mode": 420, + "sha256": "6c57302da52ca1044be0afdafe677d5de245e44873dff1386c9a1ccb2625cc82" + }, + "pypika/tests/test_criterions.py": { + "bytes": 32014, + "mode": 420, + "sha256": "78539ccca82f9a02fad0f5a39041ac343e3a142ce52368cd4f6ada489c52516a" + }, + "pypika/tests/test_custom_functions.py": { + "bytes": 1710, + "mode": 420, + "sha256": "bfa18bc328a3577965db7cc75eb94439f0cfd95a3775d9b1cc8af1062bb202cb" + }, + "pypika/tests/test_data_types.py": { + "bytes": 403, + "mode": 420, + "sha256": "c1be6ecc621a80dd91d35b1427bdfc8b1b33bd926515198e626d6fb5e1878c8b" + }, + "pypika/tests/test_date_math.py": { + "bytes": 5544, + "mode": 420, + "sha256": "85aa54efe54fe19639f2dc2a5750647e3337ac2681768bc3fe327841f1634d9e" + }, + "pypika/tests/test_deletes.py": { + "bytes": 3204, + "mode": 420, + "sha256": "ccde6df760d76d5d499ce828f6b0e2ad3eebcb2a5553c1890f481b9160b8d51a" + }, + "pypika/tests/test_drop.py": { + "bytes": 1556, + "mode": 420, + "sha256": "a13dffa59ef8657398d5498c18977bfd702635e336ea9966b1a86137afca7926" + }, + "pypika/tests/test_formats.py": { + "bytes": 1948, + "mode": 420, + "sha256": "240458a404bb119322778893b94a12be0f98f914acd701d2b4be73eb9be96f75" + }, + "pypika/tests/test_functions.py": { + "bytes": 32769, + "mode": 420, + "sha256": "3ceaac7791bd27e50f44e1b4a1451d1e09afe6a8011052caea838e5124582154" + }, + "pypika/tests/test_groupby_modifiers.py": { + "bytes": 5227, + "mode": 420, + "sha256": "9db4497660f08e3352a9a02c34889ad1cd6bab3aebaeaa485e84390ad71c84c5" + }, + "pypika/tests/test_immutability.py": { + "bytes": 3954, + "mode": 420, + "sha256": "af537ced19f7274951cc91697eae748ef6c9cd20a8d8e492d93dc85b06f8fb50" + }, + "pypika/tests/test_inserts.py": { + "bytes": 32549, + "mode": 420, + "sha256": "652e9f7f0f425e9acc0f70e2851ae29310b378262ea30369ea0113ef428f210f" + }, + "pypika/tests/test_internals.py": { + "bytes": 828, + "mode": 420, + "sha256": "4374c2632563346d00ca4de6af397a022ef3f5022e808c8711a3f207a3a21609" + }, + "pypika/tests/test_joins.py": { + "bytes": 43895, + "mode": 420, + "sha256": "53f224815c10393382443f020cb20e313420764495a8fd30f7ea2f34fd52935d" + }, + "pypika/tests/test_negation.py": { + "bytes": 763, + "mode": 420, + "sha256": "6be105e8f39b32fb23e6ac7c7158232ee78111455d4f35638c8af60781138c79" + }, + "pypika/tests/test_parameter.py": { + "bytes": 7382, + "mode": 420, + "sha256": "aaf2a3e79c8267bdc60e218445bc2a2254b97cf37b643a44d6f1a8141cbb5104" + }, + "pypika/tests/test_pseudocolumns.py": { + "bytes": 1609, + "mode": 420, + "sha256": "b7c69f7aca41323c0e14a6a9e58697399cd7860610f07291afc6e8af26079ca2" + }, + "pypika/tests/test_query.py": { + "bytes": 9025, + "mode": 420, + "sha256": "2da9d717673912a84e86e6c0d3955dbd8f2fa7b41b7ed9a6f78089dfa28f9444" + }, + "pypika/tests/test_selects.py": { + "bytes": 50757, + "mode": 420, + "sha256": "5ac1b7ad3248d64b1e3865a72c763873514ae5cd6e03356b913e531c0c336986" + }, + "pypika/tests/test_tables.py": { + "bytes": 6568, + "mode": 420, + "sha256": "384c8e843ba56374ee92cd7b7e2fd3f89247b899e23cd9e1f6663d751ad5d884" + }, + "pypika/tests/test_terms.py": { + "bytes": 3215, + "mode": 420, + "sha256": "8598513180ddcd28cc61582618d85bd570280978b07603044dae81b2eb099f77" + }, + "pypika/tests/test_tuples.py": { + "bytes": 6033, + "mode": 420, + "sha256": "863942196a93e8939be0d03c49cfeb42a35503ad42f9f3d6c730260112811087" + }, + "pypika/tests/test_updates.py": { + "bytes": 5689, + "mode": 420, + "sha256": "0f0f2521bb8d1f5d782f8fabaea5fd1d82090cde045ba87fad65770db6c75d2f" + }, + "pypika/tests/test_utils.py": { + "bytes": 834, + "mode": 420, + "sha256": "5db6e90df5daaa70b9f35f1243db69908da1f27887f63466fc27ce20c7e14892" + }, + "pyproject.toml": { + "bytes": 390, + "mode": 420, + "sha256": "037fedacd5be5d078f398265ff97e1677e25214ad8839d17073a439695ee7a91" + }, + "setup.cfg": { + "bytes": 317, + "mode": 420, + "sha256": "c84a31de586e8385e741127b004fc1f19ebae6463cdf0b3f243991db35cdeaea" + }, + "setup.py": { + "bytes": 2638, + "mode": 420, + "sha256": "f8bad274588a22e65764d8cf9fb2be5aa6fcfaf3bf861d71e5f751105898845a" + }, + "tox.ini": { + "bytes": 257, + "mode": 420, + "sha256": "c2d7205d0ac93e9c9e80dc5d24f0a826a6781f587a33ea722ea621f9e2ccd0ea" + } + } +} diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/__init__.py b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..86d8a68101915c27b95484243dd81d55f7dba356 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/__init__.py @@ -0,0 +1,2 @@ +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/clickhouse/__init__.py b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/clickhouse/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/clickhouse/test_array.py b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/clickhouse/test_array.py new file mode 100644 index 0000000000000000000000000000000000000000..469705a9ff3c8fe9cc7f02c44a9812521eeb67f4 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/clickhouse/test_array.py @@ -0,0 +1,104 @@ +import unittest + +from parameterized import parameterized + +from pypika import Field +from pypika.clickhouse.array import ( + Array, + Empty, + HasAny, + Length, + NotEmpty, +) +from pypika.clickhouse.type_conversion import ( + ToFixedString, + ToInt64, +) + + +class TestArray(unittest.TestCase): + @parameterized.expand( + [ + ( + "['ridley', 'scott', 'jimi', 'hendrix']", + Array(["ridley", "scott", "jimi", "hendrix"]), + ), + ( + "[1, 2, 3, 4]", + Array([1, 2, 3, 4]), + ), + ( + "[toInt64('1'),toInt64('2'),toInt64('3'),toInt64('4')]", + Array(["1", "2", "3", "4"], ToInt64), + ), + ( + "[toFixedString('mogwai',10),toFixedString('mono',10),toFixedString('bonobo',10)] arr", + Array(["mogwai", "mono", "bonobo"], ToFixedString, {"length": 10}).as_('arr'), + ), + ] + ) + def test_get_sql(self, expected: str, array: Array): + self.assertEqual(expected, array.get_sql()) + + +class TestHasAny(unittest.TestCase): + @parameterized.expand( + [ + ( + 'hasAny("mental_abilities","physical_abilities")', + HasAny(Field("mental_abilities"), Field("physical_abilities")), + ), + ("hasAny([1, 2, 3, 4],[3])", HasAny(Array([1, 2, 3, 4]), Array([3]))), + ( + "hasAny(\"bands\",[toFixedString('port-royal',20),toFixedString('hammock',20)])", + HasAny( + Field("bands"), + Array(["port-royal", "hammock"], ToFixedString, {"length": 20}), + ), + ), + ] + ) + def test_get_sql(self, expected: str, func: HasAny): + self.assertEqual(expected, func.get_sql()) + + +class TestLength(unittest.TestCase): + @parameterized.expand( + [ + ( + 'length("tags")', + Length(Field("tags")), + ), + ("length([1, 2, 3])", Length(Array([1, 2, 3]))), + ] + ) + def test_get_sql(self, expected: str, func: Length): + self.assertEqual(expected, func.get_sql()) + + +class TestEmpty(unittest.TestCase): + @parameterized.expand( + [ + ( + 'empty("tags")', + Empty(Field("tags")), + ), + ("empty([1, 2, 3])", Empty(Array([1, 2, 3]))), + ] + ) + def test_get_sql(self, expected: str, func: Empty): + self.assertEqual(expected, func.get_sql()) + + +class TestNotEmpty(unittest.TestCase): + @parameterized.expand( + [ + ( + 'notEmpty("tags")', + NotEmpty(Field("tags")), + ), + ("notEmpty([1, 2, 3])", NotEmpty(Array([1, 2, 3]))), + ] + ) + def test_get_sql(self, expected: str, func: NotEmpty): + self.assertEqual(expected, func.get_sql()) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/clickhouse/test_condition.py b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/clickhouse/test_condition.py new file mode 100644 index 0000000000000000000000000000000000000000..145baeb7753dd9cbefbd6f272bd672ae5730b0c0 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/clickhouse/test_condition.py @@ -0,0 +1,72 @@ +import unittest + +from parameterized import parameterized + +from pypika import Field +from pypika.clickhouse.condition import If, MultiIf +from pypika.clickhouse.type_conversion import ToFixedString + + +class TestIfCondition(unittest.TestCase): + @parameterized.expand( + [ + ( + If( + Field("filmmaker").isnull(), + ToFixedString("Tarantino", 20), + Field("filmmaker"), + ), + "if(filmmaker IS NULL,toFixedString('Tarantino',20),filmmaker)", + ), + ( + If( + Field("created") == Field("updated"), + ToFixedString("yes", 3), + ToFixedString("no", 3), + ), + "if(created=updated,toFixedString('yes',3),toFixedString('no',3))", + ), + ] + ) + def test_get_sql(self, func, expected): + self.assertEqual(func.get_sql(), expected) + + +class TestMultiIfCondition(unittest.TestCase): + @parameterized.expand( + [ + ( + MultiIf( + Field("filmmaker").isnull(), + ToFixedString("Tarantino", 20), + Field("filmmaker") == ToFixedString("undefined", 20), + ToFixedString("Tarantino", 20), + Field("filmmaker"), + ), + "multiIf(filmmaker IS NULL," + "toFixedString('Tarantino',20)," + "filmmaker=toFixedString('undefined',20)," + "toFixedString('Tarantino',20),filmmaker)", + ), + ( + MultiIf( + Field("color") == ToFixedString("black", 20), + ToFixedString("dark", 20), + Field("color") == ToFixedString("grey", 20), + ToFixedString("dark", 20), + Field("color") == ToFixedString("white", 20), + ToFixedString("light", 20), + ToFixedString("undefined", 20), + ), + "multiIf(color=toFixedString('black',20)," + "toFixedString('dark',20)," + "color=toFixedString('grey',20)," + "toFixedString('dark',20)," + "color=toFixedString('white',20)," + "toFixedString('light',20)," + "toFixedString('undefined',20))", + ), + ] + ) + def test_get_sql(self, func, expected): + self.assertEqual(func.get_sql(), expected) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/clickhouse/test_dates_and_times.py b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/clickhouse/test_dates_and_times.py new file mode 100644 index 0000000000000000000000000000000000000000..135dd7f112131776d76748e15eead1eb81752b59 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/clickhouse/test_dates_and_times.py @@ -0,0 +1,70 @@ +import unittest + +from parameterized import parameterized + +from pypika import Field +from pypika.clickhouse.dates_and_times import ( + AddDays, + AddHours, + AddMinutes, + AddMonths, + AddQuarters, + AddSeconds, + AddWeeks, + AddYears, + FormatDateTime, + SubtractDays, + SubtractHours, + SubtractMinutes, + SubtractMonths, + SubtractQuarters, + SubtractSeconds, + SubtractWeeks, + SubtractYears, + ToYYYYMM, +) + + +class TestFormatDateTime(unittest.TestCase): + @parameterized.expand( + [ + (FormatDateTime(Field("created"), "%V"), "formatDateTime(created,'%V')"), + ( + FormatDateTime(Field("created"), "%Y-%m-%d"), + "formatDateTime(created,'%Y-%m-%d')", + ), + ] + ) + def test_get_sql(self, func, expected): + self.assertEqual(func.get_sql(), expected) + + +class TestAddSubtractDt(unittest.TestCase): + @parameterized.expand( + [ + (AddYears(Field("created"), 1), "addYears(created,1)"), + (AddMonths(Field("created"), 2), "addMonths(created,2)"), + (AddWeeks(Field("created"), 3), "addWeeks(created,3)"), + (AddDays(Field("created"), 4), "addDays(created,4)"), + (AddHours(Field("created"), 5), "addHours(created,5)"), + (AddMinutes(Field("created"), 6), "addMinutes(created,6)"), + (AddSeconds(Field("created"), 7), "addSeconds(created,7)"), + (AddQuarters(Field("created"), 8), "addQuarters(created,8)"), + (SubtractYears(Field("created"), 9), "subtractYears(created,9)"), + (SubtractMonths(Field("created"), 10), "subtractMonths(created,10)"), + (SubtractWeeks(Field("created"), 11), "subtractWeeks(created,11)"), + (SubtractDays(Field("created"), 12), "subtractDays(created,12)"), + (SubtractHours(Field("created"), 13), "subtractHours(created,13)"), + (SubtractHours(Field("created"), 13), "subtractHours(created,13)"), + (SubtractMinutes(Field("created"), 14), "subtractMinutes(created,14)"), + (SubtractSeconds(Field("created"), 15), "subtractSeconds(created,15)"), + (SubtractQuarters(Field("created"), 16), "subtractQuarters(created,16)"), + ] + ) + def test_get_sql(self, func, expected): + self.assertEqual(func.get_sql(), expected) + + +class TestToYYYYMM(unittest.TestCase): + def test_get_sql(self): + self.assertEqual(ToYYYYMM(Field("created").get_sql()), "toYYYYMM(created)") diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/clickhouse/test_nullable_arg.py b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/clickhouse/test_nullable_arg.py new file mode 100644 index 0000000000000000000000000000000000000000..3c6c86207a4d0206b5c0ba80b77fac4cc257fa17 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/clickhouse/test_nullable_arg.py @@ -0,0 +1,24 @@ +import unittest + +from parameterized import parameterized + +from pypika import Field +from pypika.clickhouse.nullable_arg import IfNull +from pypika.clickhouse.type_conversion import ToFixedString + + +class TestSearchString(unittest.TestCase): + @parameterized.expand( + [ + ( + IfNull(Field("name"), Field("login")), + "ifNull(name,login)", + ), + ( + IfNull(Field("builder"), ToFixedString("pypika", 100)), + "ifNull(builder,toFixedString('pypika',100))", + ), + ] + ) + def test_get_sql(self, func, expected): + self.assertEqual(func.get_sql(), expected) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/clickhouse/test_search_string.py b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/clickhouse/test_search_string.py new file mode 100644 index 0000000000000000000000000000000000000000..9778eb32e47d4370c0bfe36dcd875903666d30b6 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/clickhouse/test_search_string.py @@ -0,0 +1,41 @@ +import unittest + +from parameterized import parameterized + +from pypika import Field +from pypika.clickhouse.search_string import ( + Match, + Like, + NotLike, + MultiSearchAny, + MultiMatchAny, +) + + +class TestSearchString(unittest.TestCase): + @parameterized.expand( + [ + (Match(Field("name"), "twheys"), "match(toString(\"name\"),'twheys')"), + (Like(Field("name"), "twheys"), "like(toString(\"name\"),'twheys')"), + (NotLike(Field("name"), "twheys"), "notLike(toString(\"name\"),'twheys')"), + ] + ) + def test_search_string(self, func, expected): + self.assertEqual(func, expected) + + +class TestMultiSearch(unittest.TestCase): + @parameterized.expand( + [ + ( + MultiSearchAny(Field("name"), ["sarah", "connor"]), + "multiSearchAny(toString(\"name\"),['sarah','connor'])", + ), + ( + MultiMatchAny(Field("name"), ["sarah", "connor"]), + "multiMatchAny(toString(\"name\"),['sarah','connor'])", + ), + ] + ) + def test_multi_search_string(self, func, expected): + self.assertEqual(func.get_sql(), expected) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/clickhouse/test_type_conversion.py b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/clickhouse/test_type_conversion.py new file mode 100644 index 0000000000000000000000000000000000000000..9692e17bee901e2629db9a5c77111e145358e8eb --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/clickhouse/test_type_conversion.py @@ -0,0 +1,176 @@ +import unittest + +from parameterized import parameterized + +from pypika import ClickHouseQuery, Field, Table +from pypika.clickhouse.type_conversion import ( + ToDate, + ToDateTime, + ToFixedString, + ToFloat32, + ToFloat64, + ToInt16, + ToInt32, + ToInt64, + ToInt8, + ToString, + ToUInt16, + ToUInt32, + ToUInt64, + ToUInt8, +) + + +class TestBasicTypeConverters(unittest.TestCase): + @parameterized.expand( + [ + ( + 'toString("field_name")', + ToString(Field("field_name")), + ), + ( + 'toInt8("field_name")', + ToInt8(Field("field_name")), + ), + ( + 'toInt16("field_name")', + ToInt16(Field("field_name")), + ), + ( + 'toInt32("field_name")', + ToInt32(Field("field_name")), + ), + ( + 'toInt64("field_name")', + ToInt64(Field("field_name")), + ), + ( + 'toUInt8("field_name")', + ToUInt8(Field("field_name")), + ), + ( + 'toUInt16("field_name")', + ToUInt16(Field("field_name")), + ), + ( + 'toUInt32("field_name")', + ToUInt32(Field("field_name")), + ), + ( + 'toUInt64("field_name")', + ToUInt64(Field("field_name")), + ), + ( + 'toFloat32("field_name")', + ToFloat32(Field("field_name")), + ), + ( + 'toFloat64("field_name")', + ToFloat64(Field("field_name")), + ), + ( + 'toFloat64("field_name")', + ToFloat64(Field("field_name")), + ), + ( + 'toDate("field_name")', + ToDate(Field("field_name")), + ), + ( + 'toDateTime("field_name")', + ToDateTime(Field("field_name")), + ), + ( + 'toFixedString("field_name",100)', + ToFixedString(Field("field_name"), 100), + ), + ] + ) + def test_basic_types_field(self, expected, func): + self.assertEqual(func, expected) + + @parameterized.expand( + [ + ( + "toString('100')", + ToString("100"), + ), + ( + "toInt8('100')", + ToInt8("100"), + ), + ( + "toInt16('100')", + ToInt16("100"), + ), + ( + "toInt32('100')", + ToInt32("100"), + ), + ( + "toInt64('100')", + ToInt64("100"), + ), + ( + "toUInt8('100')", + ToUInt8("100"), + ), + ( + "toUInt16('100')", + ToUInt16("100"), + ), + ( + "toUInt32('100')", + ToUInt32("100"), + ), + ( + "toUInt64('100')", + ToUInt64("100"), + ), + ( + "toFloat32('100')", + ToFloat32("100"), + ), + ( + "toFloat64('100')", + ToFloat64("100"), + ), + ( + "toFloat64('100')", + ToFloat64("100"), + ), + ( + "toDate('100')", + ToDate("100"), + ), + ( + "toDateTime('100')", + ToDateTime("100"), + ), + ( + "toFixedString('100',100)", + ToFixedString("100", 100), + ), + ] + ) + def test_basic_types_value(self, expected, func): + self.assertEqual(func, expected) + + +class TestToFixedString(unittest.TestCase): + def test_get_sql_with_table(self): + table = Table("example") + query = ( + ClickHouseQuery.from_(table) + .select( + table.name, + ) + .where( + table.name == ToFixedString("name", 50), + ) + ) + + self.assertEqual( + 'SELECT "name" FROM "example" WHERE "name"=toFixedString(\'name\',50)', + query.get_sql(), + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/dialects/__init__.py b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/dialects/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/dialects/test_clickhouse.py b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/dialects/test_clickhouse.py new file mode 100644 index 0000000000000000000000000000000000000000..f319c4627bd25d7004894181906a284b8b1c64cf --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/dialects/test_clickhouse.py @@ -0,0 +1,146 @@ +from unittest import TestCase + +from pypika import ( + ClickHouseQuery, + Database, + Table, +) + + +class ClickHouseQueryTests(TestCase): + def test_use_AS_keyword_for_alias(self): + t = Table('abc') + query = ClickHouseQuery.from_(t).select(t.foo.as_('f1'), t.bar.as_('f2')) + self.assertEqual(str(query), 'SELECT "foo" AS "f1","bar" AS "f2" FROM "abc"') + + def test_use_SAMPLE_keyword(self): + t = Table('abc') + query = ClickHouseQuery.from_(t).select(t.foo).sample(10) + self.assertEqual(str(query), 'SELECT "foo" FROM "abc" SAMPLE 10') + + def test_use_SAMPLE_with_offset_keyword(self): + t = Table('abc') + query = ClickHouseQuery.from_(t).select(t.foo).sample(10, 5) + self.assertEqual(str(query), 'SELECT "foo" FROM "abc" SAMPLE 10 OFFSET 5') + + def test_use_FINAL_keyword(self): + t = Table('abc') + query = ClickHouseQuery.from_(t).select(t.foo).final() + self.assertEqual(str(query), 'SELECT "foo" FROM "abc" FINAL') + + +class ClickHouseDeleteTests(TestCase): + table_abc = Table("abc") + + def test_omit_where(self): + q = ClickHouseQuery.from_("abc").delete() + + self.assertEqual('ALTER TABLE "abc" DELETE', str(q)) + + def test_omit_where__table_schema(self): + q = ClickHouseQuery.from_(Table("abc", "schema1")).delete() + + self.assertEqual('ALTER TABLE "schema1"."abc" DELETE', str(q)) + + def test_where_field_equals(self): + q1 = ClickHouseQuery.from_(self.table_abc).where(self.table_abc.foo == self.table_abc.bar).delete() + q2 = ClickHouseQuery.from_(self.table_abc).where(self.table_abc.foo.eq(self.table_abc.bar)).delete() + + self.assertEqual('ALTER TABLE "abc" DELETE WHERE "foo"="bar"', str(q1)) + self.assertEqual('ALTER TABLE "abc" DELETE WHERE "foo"="bar"', str(q2)) + + +class ClickHouseUpdateTests(TestCase): + table_abc = Table("abc") + + def test_update(self): + q = ClickHouseQuery.update(self.table_abc).where(self.table_abc.foo == 0).set("foo", "bar") + + self.assertEqual('ALTER TABLE "abc" UPDATE "foo"=\'bar\' WHERE "foo"=0', str(q)) + + +class ClickHouseDropQuery(TestCase): + table_abc = Table("abc") + database_xyz = Database("mydb") + cluster_name = "mycluster" + + def test_drop_database(self): + q1 = ClickHouseQuery.drop_database(self.database_xyz) + q2 = ClickHouseQuery.drop_database(self.database_xyz).on_cluster(self.cluster_name) + q3 = ClickHouseQuery.drop_database(self.database_xyz).if_exists().on_cluster(self.cluster_name) + + self.assertEqual('DROP DATABASE "mydb"', str(q1)) + self.assertEqual('DROP DATABASE "mydb" ON CLUSTER "mycluster"', str(q2)) + self.assertEqual('DROP DATABASE IF EXISTS "mydb" ON CLUSTER "mycluster"', str(q3)) + + def test_drop_table(self): + q1 = ClickHouseQuery.drop_table(self.table_abc) + q2 = ClickHouseQuery.drop_table(self.table_abc).on_cluster(self.cluster_name) + q3 = ClickHouseQuery.drop_table(self.table_abc).if_exists().on_cluster(self.cluster_name) + + self.assertEqual('DROP TABLE "abc"', str(q1)) + self.assertEqual('DROP TABLE "abc" ON CLUSTER "mycluster"', str(q2)) + self.assertEqual('DROP TABLE IF EXISTS "abc" ON CLUSTER "mycluster"', str(q3)) + + def test_drop_dictionary(self): + q1 = ClickHouseQuery.drop_dictionary("dict") + q2 = ClickHouseQuery.drop_dictionary("dict").on_cluster(self.cluster_name) + q3 = ClickHouseQuery.drop_dictionary("dict").if_exists().on_cluster(self.cluster_name) + + self.assertEqual('DROP DICTIONARY "dict"', str(q1)) + self.assertEqual('DROP DICTIONARY "dict"', str(q2)) # NO CLUSTER + self.assertEqual('DROP DICTIONARY IF EXISTS "dict"', str(q3)) # NO CLUSTER + + def test_drop_other(self): + q1 = ClickHouseQuery.drop_quota("myquota") + q2 = ClickHouseQuery.drop_user("myuser") + q3 = ClickHouseQuery.drop_view("myview") + + self.assertEqual('DROP QUOTA "myquota"', str(q1)) + self.assertEqual('DROP USER "myuser"', str(q2)) + self.assertEqual('DROP VIEW "myview"', str(q3)) + + +class DistinctOnTests(TestCase): + table_abc = Table("abc") + + def test_distinct_on(self): + q = ClickHouseQuery.from_(self.table_abc).distinct_on("lname", self.table_abc.fname).select("lname", "id") + + self.assertEqual('''SELECT DISTINCT ON("lname","fname") "lname","id" FROM "abc"''', str(q)) + + +class LimitByTests(TestCase): + table_abc = Table("abc") + + def test_limit_by(self): + q = ClickHouseQuery.from_(self.table_abc).limit_by(1, "a", self.table_abc.b).select("a", "b", "c") + + self.assertEqual('''SELECT "a","b","c" FROM "abc" LIMIT 1 BY ("a","b")''', str(q)) + + def test_limit_offset_by(self): + q = ClickHouseQuery.from_(self.table_abc).limit_offset_by(1, 2, "a", self.table_abc.b).select("a", "b", "c") + + self.assertEqual('''SELECT "a","b","c" FROM "abc" LIMIT 1 OFFSET 2 BY ("a","b")''', str(q)) + + def test_limit_offset0_by(self): + q = ClickHouseQuery.from_(self.table_abc).limit_offset_by(1, 0, "a", self.table_abc.b).select("a", "b", "c") + + self.assertEqual('''SELECT "a","b","c" FROM "abc" LIMIT 1 BY ("a","b")''', str(q)) + + def test_rename_table(self): + table_join = Table("join") + + q = ( + ClickHouseQuery.from_(self.table_abc) + .join(table_join) + .using("a") + .limit_by(1, self.table_abc.a, table_join.a) + .select(self.table_abc.b, table_join.b) + ) + q = q.replace_table(self.table_abc, Table("xyz")) + + self.assertEqual( + '''SELECT "xyz"."b","join"."b" FROM "xyz" JOIN "join" USING ("a") LIMIT 1 BY ("xyz"."a","join"."a")''', + str(q), + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/dialects/test_mssql.py b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/dialects/test_mssql.py new file mode 100644 index 0000000000000000000000000000000000000000..7cf53b228f413a8c7cd3e414fef5522a82f99b29 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/dialects/test_mssql.py @@ -0,0 +1,81 @@ +import unittest + +from pypika import Table +from pypika.analytics import Count +from pypika.dialects import MSSQLQuery +from pypika.utils import QueryException + + +class SelectTests(unittest.TestCase): + def test_normal_select(self): + q = MSSQLQuery.from_("abc").select("def") + + self.assertEqual('SELECT "def" FROM "abc"', str(q)) + + def test_distinct_select(self): + q = MSSQLQuery.from_("abc").select("def").distinct() + + self.assertEqual('SELECT DISTINCT "def" FROM "abc"', str(q)) + + def test_top_distinct_select(self): + q = MSSQLQuery.from_("abc").select("def").top(10).distinct() + + self.assertEqual('SELECT DISTINCT TOP (10) "def" FROM "abc"', str(q)) + + def test_top_select(self): + q = MSSQLQuery.from_("abc").select("def").top(10) + + self.assertEqual('SELECT TOP (10) "def" FROM "abc"', str(q)) + + def test_top_with_ties_select(self): + q = MSSQLQuery.from_("abc").select("def").top(10, with_ties=True) + + self.assertEqual('SELECT TOP (10) WITH TIES "def" FROM "abc"', str(q)) + + def test_top_percent_select(self): + q = MSSQLQuery.from_("abc").select("def").top(10, percent=True) + + self.assertEqual('SELECT TOP (10) PERCENT "def" FROM "abc"', str(q)) + + def test_top_percent_invalid_range(self): + for invalid_top in [-1, 101]: + with self.assertRaisesRegex( + QueryException, "TOP value must be between 0 and 100 when `percent` is specified" + ): + MSSQLQuery.from_("abc").select("def").top(invalid_top, percent=True) + + def test_top_select_non_int(self): + with self.assertRaisesRegex(QueryException, "TOP value must be an integer"): + MSSQLQuery.from_("abc").select("def").top("a") + + def test_limit(self): + q = MSSQLQuery.from_("abc").select("def").orderby("def").limit(10) + + self.assertEqual('SELECT "def" FROM "abc" ORDER BY "def" OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY', str(q)) + + def test_offset(self): + q = MSSQLQuery.from_("abc").select("def").orderby("def").offset(10) + + self.assertEqual('SELECT "def" FROM "abc" ORDER BY "def" OFFSET 10 ROWS', str(q)) + + def test_limit_with_offset(self): + q = MSSQLQuery.from_("abc").select("def").orderby("def").limit(10).offset(10) + + self.assertEqual('SELECT "def" FROM "abc" ORDER BY "def" OFFSET 10 ROWS FETCH NEXT 10 ROWS ONLY', str(q)) + + def test_groupby_alias_False_does_not_group_by_alias_with_standard_query(self): + t = Table('table1') + col = t.abc.as_('a') + q = MSSQLQuery.from_(t).select(col, Count('*')).groupby(col) + + self.assertEqual('SELECT "abc" "a",COUNT(\'*\') FROM "table1" GROUP BY "abc"', str(q)) + + def test_groupby_alias_False_does_not_group_by_alias_when_subqueries_are_present(self): + t = Table('table1') + subquery = MSSQLQuery.from_(t).select(t.abc) + col = subquery.abc.as_('a') + q = MSSQLQuery.from_(subquery).select(col, Count('*')).groupby(col) + + self.assertEqual( + 'SELECT "sq0"."abc" "a",COUNT(\'*\') FROM (SELECT "abc" FROM "table1") "sq0" GROUP BY "sq0"."abc"', str(q) + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/dialects/test_mysql.py b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/dialects/test_mysql.py new file mode 100644 index 0000000000000000000000000000000000000000..619d064adcdf8b5ff9ecd054fa4ab00eff1d69b3 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/dialects/test_mysql.py @@ -0,0 +1,91 @@ +import unittest + +from pypika import MySQLQuery, QueryException, Table, Column + + +class SelectTests(unittest.TestCase): + table_abc = Table("abc") + + def test_normal_select(self): + q = MySQLQuery.from_("abc").select("def") + + self.assertEqual("SELECT `def` FROM `abc`", str(q)) + + def test_distinct_select(self): + q = MySQLQuery.from_("abc").select("def").distinct() + + self.assertEqual("SELECT DISTINCT `def` FROM `abc`", str(q)) + + def test_modifier_select(self): + q = MySQLQuery.from_("abc").select("def").select("ghi").modifier("SQL_CALC_FOUND_ROWS") + + self.assertEqual("SELECT SQL_CALC_FOUND_ROWS `def`,`ghi` FROM `abc`", str(q)) + + def test_multiple_modifier_select(self): + q = MySQLQuery.from_("abc").select("def").modifier("HIGH_PRIORITY").modifier("SQL_CALC_FOUND_ROWS") + + self.assertEqual("SELECT HIGH_PRIORITY SQL_CALC_FOUND_ROWS `def` FROM `abc`", str(q)) + + +class UpdateTests(unittest.TestCase): + table_abc = Table("abc") + + def test_update(self): + q = MySQLQuery.into("abc").insert(1, [1, "a", True]) + + self.assertEqual("INSERT INTO `abc` VALUES (1,[1,'a',true])", str(q)) + + def test_on_duplicate_key_ignore_update(self): + q = MySQLQuery.into("abc").insert(1, [1, "a", True]).on_duplicate_key_ignore() + + self.assertEqual("INSERT INTO `abc` VALUES (1,[1,'a',true]) ON DUPLICATE KEY IGNORE", str(q)) + + def test_on_duplicate_key_update_update(self): + q = MySQLQuery.into("abc").insert(1, [1, "a", True]).on_duplicate_key_update(self.table_abc.a, 'b') + + self.assertEqual("INSERT INTO `abc` VALUES (1,[1,'a',true]) ON DUPLICATE KEY UPDATE `a`='b'", str(q)) + + def test_conflict_handlers_update(self): + with self.assertRaises(QueryException): + ( + MySQLQuery.into("abc") + .insert(1, [1, "a", True]) + .on_duplicate_key_ignore() + .on_duplicate_key_update(self.table_abc.a, 'b') + ) + + +class LoadCSVTests(unittest.TestCase): + table_abc = Table("abc") + + def test_load_from_file(self): + q1 = MySQLQuery.load("/path/to/file").into("abc") + + q2 = MySQLQuery.load("/path/to/file").into(self.table_abc) + + self.assertEqual( + "LOAD DATA LOCAL INFILE '/path/to/file' INTO TABLE `abc` FIELDS TERMINATED BY ','", + str(q1), + ) + self.assertEqual( + "LOAD DATA LOCAL INFILE '/path/to/file' INTO TABLE `abc` FIELDS TERMINATED BY ','", + str(q2), + ) + + +class TableTests(unittest.TestCase): + table_abc = Table("abc") + + def test_create_table(self): + q = MySQLQuery.create_table(self.table_abc).columns(Column("id", "INT")) + self.assertEqual( + 'CREATE TABLE `abc` (`id` INT)', + str(q), + ) + + def test_drop_table(self): + q = MySQLQuery.drop_table(self.table_abc) + self.assertEqual( + 'DROP TABLE `abc`', + str(q), + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/dialects/test_oracle.py b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/dialects/test_oracle.py new file mode 100644 index 0000000000000000000000000000000000000000..21b54f16fd5d3518b5c767d3605068637898a73f --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/dialects/test_oracle.py @@ -0,0 +1,51 @@ +import unittest + +from pypika import OracleQuery, Table +from pypika.analytics import Count + + +class SelectTests(unittest.TestCase): + def test_groupby_alias_False_does_not_group_by_alias_with_standard_query(self): + t = Table('table1') + col = t.abc.as_('a') + q = OracleQuery.from_(t).select(col, Count('*')).groupby(col) + + self.assertEqual('SELECT abc a,COUNT(\'*\') FROM table1 GROUP BY abc', str(q)) + + def test_groupby_alias_False_does_not_group_by_alias_when_subqueries_are_present(self): + t = Table('table1') + subquery = OracleQuery.from_(t).select(t.abc) + col = subquery.abc.as_('a') + q = OracleQuery.from_(subquery).select(col, Count('*')).groupby(col) + + self.assertEqual('SELECT sq0.abc a,COUNT(\'*\') FROM (SELECT abc FROM table1) sq0 GROUP BY sq0.abc', str(q)) + + def test_limit_query(self): + t = Table('table1') + limit = 5 + q = OracleQuery.from_(t).select(t.test).limit(limit) + + self.assertEqual(f'SELECT test FROM table1 FETCH NEXT {limit} ROWS ONLY', str(q)) + + def test_offset_query(self): + t = Table('table1') + offset = 5 + q = OracleQuery.from_(t).select(t.test).offset(offset) + + self.assertEqual(f'SELECT test FROM table1 OFFSET {offset} ROWS', str(q)) + + def test_limit_offset_query(self): + t = Table('table1') + limit = 5 + offset = 5 + q = OracleQuery.from_(t).select(t.test).limit(limit).offset(offset) + + self.assertEqual(f'SELECT test FROM table1 OFFSET {offset} ROWS FETCH NEXT {limit} ROWS ONLY', str(q)) + + def test_fetch_next_method_deprecated(self): + with self.assertWarns(DeprecationWarning): + t = Table('table1') + limit = 5 + q = OracleQuery.from_(t).select(t.test).fetch_next(limit) + + self.assertEqual(f'SELECT test FROM table1 FETCH NEXT {limit} ROWS ONLY', str(q)) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/dialects/test_postgresql.py b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/dialects/test_postgresql.py new file mode 100644 index 0000000000000000000000000000000000000000..437eed03e120485ed2a357a4c2d92426f1466e14 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/dialects/test_postgresql.py @@ -0,0 +1,262 @@ +import unittest +from collections import OrderedDict + +from pypika import ( + Array, + Field, + JSON, + QueryException, + Table, +) +from pypika.dialects import PostgreSQLQuery + + +class InsertTests(unittest.TestCase): + table_abc = Table("abc") + + def test_array_keyword(self): + q = PostgreSQLQuery.into(self.table_abc).insert(1, [1, "a", True]) + + self.assertEqual("INSERT INTO \"abc\" VALUES (1,ARRAY[1,'a',true])", str(q)) + + +class JSONObjectTests(unittest.TestCase): + def test_alias_set_correctly(self): + table = Table('jsonb_table') + q = PostgreSQLQuery.from_('abc').select(table.value.get_text_value('a').as_('name')) + + self.assertEqual('''SELECT "value"->>'a' "name" FROM "abc"''', str(q)) + + def test_json_value_from_dict(self): + q = PostgreSQLQuery.select(JSON({"a": "foo"})) + + self.assertEqual('SELECT \'{"a":"foo"}\'', str(q)) + + def test_json_value_from_array_num(self): + q = PostgreSQLQuery.select(JSON([1, 2, 3])) + + self.assertEqual("SELECT '[1,2,3]'", str(q)) + + def test_json_value_from_array_str(self): + q = PostgreSQLQuery.select(JSON(["a", "b", "c"])) + + self.assertEqual('SELECT \'["a","b","c"]\'', str(q)) + + def test_json_value_from_dict_recursive(self): + q = PostgreSQLQuery.select(JSON({"a": "z", "b": {"c": "foo"}, "d": 1})) + + # gotta split this one up to avoid the indeterminate order + sql = str(q) + start, end = 9, -2 + self.assertEqual("SELECT '{}'", sql[:start] + sql[end:]) + + members_set = set(sql[start:end].split(",")) + self.assertSetEqual({'"a":"z"', '"b":{"c":"foo"}', '"d":1'}, members_set) + + +class JSONOperatorsTests(unittest.TestCase): + # reference https://www.postgresql.org/docs/9.5/functions-json.html + table_abc = Table("abc") + + def test_get_json_value_by_key(self): + q = PostgreSQLQuery.from_(self.table_abc).select("*").where(self.table_abc.json.get_json_value("dates")) + + self.assertEqual('SELECT * FROM "abc" WHERE "json"->\'dates\'', str(q)) + + def test_get_json_value_by_index(self): + q = PostgreSQLQuery.from_(self.table_abc).select("*").where(self.table_abc.json.get_json_value(1)) + + self.assertEqual('SELECT * FROM "abc" WHERE "json"->1', str(q)) + + def test_get_text_value_by_key(self): + q = PostgreSQLQuery.from_(self.table_abc).select("*").where(self.table_abc.json.get_text_value("dates")) + + self.assertEqual('SELECT * FROM "abc" WHERE "json"->>\'dates\'', str(q)) + + def test_get_text_value_by_index(self): + q = PostgreSQLQuery.from_(self.table_abc).select("*").where(self.table_abc.json.get_text_value(1)) + + self.assertEqual('SELECT * FROM "abc" WHERE "json"->>1', str(q)) + + def test_get_path_json_value(self): + q = PostgreSQLQuery.from_(self.table_abc).select("*").where(self.table_abc.json.get_path_json_value("{a,b}")) + + self.assertEqual('SELECT * FROM "abc" WHERE "json"#>\'{a,b}\'', str(q)) + + def test_get_path_text_value(self): + q = PostgreSQLQuery.from_(self.table_abc).select("*").where(self.table_abc.json.get_path_text_value("{a,b}")) + + self.assertEqual('SELECT * FROM "abc" WHERE "json"#>>\'{a,b}\'', str(q)) + + +class JSONBOperatorsTests(unittest.TestCase): + # reference https://www.postgresql.org/docs/9.5/functions-json.html + table_abc = Table("abc") + + def test_json_contains_for_json(self): + q = PostgreSQLQuery.select(JSON({"a": 1, "b": 2}).contains({"a": 1})) + + # gotta split this one up to avoid the indeterminate order + sql = str(q) + start, end = 9, -13 + self.assertEqual("SELECT '{}'@>'{\"a\":1}'", sql[:start] + sql[end:]) + + members_set = set(sql[start:end].split(",")) + self.assertSetEqual({'"a":1', '"b":2'}, members_set) + + def test_json_contains_for_field(self): + q = ( + PostgreSQLQuery.from_(self.table_abc) + .select("*") + .where(self.table_abc.json.contains({"dates": "2018-07-10 - 2018-07-17"})) + ) + + self.assertEqual( + "SELECT * " 'FROM "abc" ' 'WHERE "json"@>\'{"dates":"2018-07-10 - 2018-07-17"}\'', + str(q), + ) + + def test_json_contained_by_using_str_arg(self): + q = ( + PostgreSQLQuery.from_(self.table_abc) + .select("*") + .where( + self.table_abc.json.contained_by( + OrderedDict( + [ + ("dates", "2018-07-10 - 2018-07-17"), + ("imported", "8"), + ] + ) + ) + ) + ) + self.assertEqual( + 'SELECT * FROM "abc" ' 'WHERE "json"<@\'{"dates":"2018-07-10 - 2018-07-17","imported":"8"}\'', + str(q), + ) + + def test_json_contained_by_using_list_arg(self): + q = ( + PostgreSQLQuery.from_(self.table_abc) + .select("*") + .where(self.table_abc.json.contained_by(["One", "Two", "Three"])) + ) + + self.assertEqual('SELECT * FROM "abc" WHERE "json"<@\'["One","Two","Three"]\'', str(q)) + + def test_json_contained_by_with_complex_criterion(self): + q = ( + PostgreSQLQuery.from_(self.table_abc) + .select("*") + .where(self.table_abc.json.contained_by(["One", "Two", "Three"]) & (self.table_abc.id == 26)) + ) + + self.assertEqual( + 'SELECT * FROM "abc" WHERE "json"<@\'["One","Two","Three"]\' AND "id"=26', + str(q), + ) + + def test_json_has_key(self): + q = PostgreSQLQuery.from_(self.table_abc).select("*").where(self.table_abc.json.has_key("dates")) + + self.assertEqual('SELECT * FROM "abc" WHERE "json"?\'dates\'', str(q)) + + def test_json_has_keys(self): + q = PostgreSQLQuery.from_(self.table_abc).select("*").where(self.table_abc.json.has_keys(["dates", "imported"])) + + self.assertEqual("SELECT * FROM \"abc\" WHERE \"json\"?&ARRAY['dates','imported']", str(q)) + + def test_json_has_any_keys(self): + q = ( + PostgreSQLQuery.from_(self.table_abc) + .select("*") + .where(self.table_abc.json.has_any_keys(["dates", "imported"])) + ) + + self.assertEqual("SELECT * FROM \"abc\" WHERE \"json\"?|ARRAY['dates','imported']", str(q)) + + def test_subnet_contains_inet(self): + q = ( + PostgreSQLQuery.from_(self.table_abc) + .select(self.table_abc.a.lshift(2)) + .where(self.table_abc.cidr >> "1.1.1.1") + ) + + self.assertEqual("SELECT \"a\"<<2 FROM \"abc\" WHERE \"cidr\">>'1.1.1.1'", str(q)) + + +class DistinctOnTests(unittest.TestCase): + table_abc = Table("abc") + + def test_distinct_on(self): + q = PostgreSQLQuery.from_(self.table_abc).distinct_on("lname", self.table_abc.fname).select("lname", "id") + + self.assertEqual('''SELECT DISTINCT ON("lname","fname") "lname","id" FROM "abc"''', str(q)) + + +class ArrayTests(unittest.TestCase): + def test_array_syntax(self): + tb = Table("tb") + q = PostgreSQLQuery.from_(tb).select(Array(1, "a", ["b", 2, 3])) + + self.assertEqual(str(q), "SELECT ARRAY[1,'a',ARRAY['b',2,3]] FROM \"tb\"") + + def test_render_alias_in_array_sql(self): + tb = Table("tb") + + q = PostgreSQLQuery.from_(tb).select(Array(tb.col).as_("different_name")) + self.assertEqual(str(q), 'SELECT ARRAY["col"] "different_name" FROM "tb"') + + +class ReturningClauseTests(unittest.TestCase): + @classmethod + def setUpClass(cls) -> None: + super().setUpClass() + cls.table_abc = Table('abc') + + def test_returning_from_missing_table_raises_queryexception(self): + field_from_diff_table = Field('xyz', table=Table('other')) + + with self.assertRaisesRegex(QueryException, "You can't return from other tables"): + ( + PostgreSQLQuery.from_(self.table_abc) + .where(self.table_abc.foo == self.table_abc.bar) + .delete() + .returning(field_from_diff_table) + ) + + def test_queryexception_if_returning_used_on_invalid_query(self): + with self.assertRaisesRegex(QueryException, "Returning can't be used in this query"): + PostgreSQLQuery.from_(self.table_abc).select('abc').returning('abc') + + def test_no_queryexception_if_returning_used_on_valid_query_type(self): + # No exceptions for insert, update and delete queries + with self.subTest('DELETE'): + PostgreSQLQuery.from_(self.table_abc).where(self.table_abc.foo == self.table_abc.bar).delete().returning( + "id" + ) + with self.subTest('UPDATE'): + PostgreSQLQuery.update(self.table_abc).where(self.table_abc.foo == 0).set("foo", "bar").returning("id") + with self.subTest('INSERT'): + PostgreSQLQuery.into(self.table_abc).insert('abc').returning('abc') + + def test_return_field_from_join_table(self): + new_table = Table('xyz') + q = ( + PostgreSQLQuery.update(self.table_abc) + .join(new_table) + .on(new_table.id == self.table_abc.xyz) + .where(self.table_abc.foo == 0) + .set("foo", "bar") + .returning(new_table.a) + ) + + self.assertEqual( + 'UPDATE "abc" ' + 'JOIN "xyz" ON "xyz"."id"="abc"."xyz" ' + 'SET "foo"=\'bar\' ' + 'WHERE "abc"."foo"=0 ' + 'RETURNING "xyz"."a"', + str(q), + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/dialects/test_snowflake.py b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/dialects/test_snowflake.py new file mode 100644 index 0000000000000000000000000000000000000000..5ac08b2d8b8b5496ed6f3510acf4be1ec7893405 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/dialects/test_snowflake.py @@ -0,0 +1,58 @@ +import unittest + +from pypika import ( + Tables, + functions as fn, + Column, +) +from pypika.dialects import SnowflakeQuery + + +class QuoteTests(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_use_double_quotes_on_alias_but_not_on_terms(self): + q = SnowflakeQuery.from_(self.table_abc).select(self.table_abc.a.as_("bar")) + + self.assertEqual('SELECT a "bar" FROM abc', q.get_sql(with_namespace=True)) + + def test_use_double_quotes_on_alias_but_not_on_terms_with_joins(self): + foo = self.table_abc.as_("foo") + bar = self.table_efg.as_("bar") + + q = SnowflakeQuery.from_(foo).join(bar).on(foo.fk == bar.id).select(foo.a, bar.b) + + self.assertEqual( + "SELECT foo.a,bar.b " 'FROM abc "foo" ' 'JOIN efg "bar" ' "ON foo.fk=bar.id", + q.get_sql(with_namespace=True), + ) + + def test_use_double_quotes_on_alias_but_not_on_terms(self): + idx = self.table_abc.index.as_("idx") + val = fn.Sum(self.table_abc.value).as_("val") + q = SnowflakeQuery.from_(self.table_abc).select(idx, val).groupby(idx).orderby(idx) + + self.assertEqual( + 'SELECT index "idx",SUM(value) "val" ' "FROM abc " 'GROUP BY "idx" ' 'ORDER BY "idx"', + q.get_sql(with_namespace=True), + ) + + def test_dont_use_double_quotes_on_joining_queries(self): + foo = self.table_abc + bar = self.table_efg + q1 = SnowflakeQuery.from_(foo).select(foo.b) + q2 = SnowflakeQuery.from_(bar).select(bar.b) + q = SnowflakeQuery.from_(q1).join(q2).on(q1.b == q2.b).select("*") + + self.assertEqual( + "SELECT * " 'FROM (SELECT b FROM abc) sq0 ' 'JOIN (SELECT b FROM efg) sq1 ' "ON sq0.b=sq1.b", + q.get_sql(), + ) + + def test_dont_use_double_quotes_on_create_queries(self): + q = SnowflakeQuery.create_table(self.table_abc).columns(Column("id", "INT")) + self.assertEqual("CREATE TABLE abc (id INT)", q.get_sql()) + + def test_dont_use_double_quotes_on_drop_queries(self): + q = SnowflakeQuery.drop_table(self.table_abc) + self.assertEqual("DROP TABLE abc", q.get_sql()) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/dialects/test_sqllite.py b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/dialects/test_sqllite.py new file mode 100644 index 0000000000000000000000000000000000000000..104a7235b6ea2d46fd365989f68c5d081eb20076 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/dialects/test_sqllite.py @@ -0,0 +1,35 @@ +import unittest + +from pypika import Table +from pypika.dialects import SQLLiteQuery + + +class SelectTests(unittest.TestCase): + table_abc = Table("abc") + + def test_bool_true_as_one(self): + q = SQLLiteQuery.from_("abc").select(True) + + self.assertEqual('SELECT 1 FROM "abc"', str(q)) + + def test_bool_false_as_zero(self): + q = SQLLiteQuery.from_("abc").select(False) + + self.assertEqual('SELECT 0 FROM "abc"', str(q)) + + +class ReplaceTests(unittest.TestCase): + def test_normal_replace(self): + query = SQLLiteQuery.into("abc").replace("v1", "v2", "v3") + expected_output = "REPLACE INTO \"abc\" VALUES ('v1','v2','v3')" + self.assertEqual(expected_output, str(query)) + + def test_replace_subquery(self): + query = SQLLiteQuery.into("abc").replace(SQLLiteQuery.from_("def").select("f1", "f2")) + expected_output = 'REPLACE INTO "abc" VALUES ((SELECT "f1","f2" FROM "def"))' + self.assertEqual(expected_output, str(query)) + + def test_insert_or_replace(self): + query = SQLLiteQuery.into("abc").insert_or_replace("v1", "v2", "v3") + expected_output = "INSERT OR REPLACE INTO \"abc\" VALUES ('v1','v2','v3')" + self.assertEqual(expected_output, str(query)) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/dialects/test_vertica.py b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/dialects/test_vertica.py new file mode 100644 index 0000000000000000000000000000000000000000..61985bfc244fcd663e7d8a904b4645901f3abdfc --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/dialects/test_vertica.py @@ -0,0 +1,93 @@ +import unittest + +from pypika import Columns, Table, Tables, VerticaQuery + + +class VerticaQueryTests(unittest.TestCase): + table_abc = Table("abc") + + def test_select_query_with_hint(self): + q = VerticaQuery.from_("abc").select("*").hint("test_hint") + + self.assertEqual('SELECT /*+label(test_hint)*/ * FROM "abc"', str(q)) + + def test_insert_query_with_hint(self): + query = VerticaQuery.into(self.table_abc).insert(1).hint("test_hint") + + self.assertEqual('INSERT /*+label(test_hint)*/ INTO "abc" VALUES (1)', str(query)) + + def test_update_query_with_hint(self): + q = VerticaQuery.update(self.table_abc).set("foo", "bar").hint("test_hint") + + self.assertEqual('UPDATE /*+label(test_hint)*/ "abc" SET "foo"=\'bar\'', str(q)) + + def test_delete_query_with_hint(self): + q = VerticaQuery.from_("abc").delete().hint("test_hint") + + self.assertEqual('DELETE /*+label(test_hint)*/ FROM "abc"', str(q)) + + +class CopyCSVTests(unittest.TestCase): + table_abc = Table("abc") + + def test_copy_from_file(self): + with self.subTest("with table as string"): + q = VerticaQuery.from_file("/path/to/file").copy_("abc") + + self.assertEqual( + "COPY \"abc\" FROM LOCAL '/path/to/file' PARSER fcsvparser(header=false)", + str(q), + ) + + with self.subTest("with table"): + q = VerticaQuery.from_file("/path/to/file").copy_(self.table_abc) + + self.assertEqual( + "COPY \"abc\" FROM LOCAL '/path/to/file' PARSER fcsvparser(header=false)", + str(q), + ) + + +class CreateTemporaryTableTests(unittest.TestCase): + new_table, existing_table = Tables("abc", "efg") + foo, bar = Columns(("a", "INT"), ("b", "VARCHAR(100)")) + select = VerticaQuery.from_(existing_table).select(existing_table.foo, existing_table.bar) + + def test_create_local_temporary_table(self): + with self.subTest("with columns"): + q = VerticaQuery.create_table(self.new_table).temporary().local().columns(self.foo, self.bar) + + self.assertEqual('CREATE LOCAL TEMPORARY TABLE "abc" ("a" INT,"b" VARCHAR(100))', str(q)) + + with self.subTest("with select"): + q = VerticaQuery.create_table(self.new_table).temporary().local().as_select(self.select) + + self.assertEqual( + 'CREATE LOCAL TEMPORARY TABLE "abc" AS (SELECT "foo","bar" FROM "efg")', + str(q), + ) + + def test_create_local_table_without_temporary_raises_error(self): + with self.assertRaises(AttributeError): + VerticaQuery.create_table(self.new_table).local() + + def test_create_temporary_table_preserve_rows(self): + with self.subTest("with columns"): + q = VerticaQuery.create_table(self.new_table).temporary().preserve_rows().columns(self.foo, self.bar) + + self.assertEqual( + 'CREATE TEMPORARY TABLE "abc" ("a" INT,"b" VARCHAR(100)) ON COMMIT PRESERVE ROWS', + str(q), + ) + + with self.subTest("with select"): + q = VerticaQuery.create_table(self.new_table).temporary().preserve_rows().as_select(self.select) + + self.assertEqual( + 'CREATE TEMPORARY TABLE "abc" ON COMMIT PRESERVE ROWS AS (SELECT "foo","bar" FROM "efg")', + str(q), + ) + + def test_create_table_preserve_rows_without_temporary_raises_error(self): + with self.assertRaises(AttributeError): + VerticaQuery.create_table(self.new_table).preserve_rows() diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/test_aggregate.py b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/test_aggregate.py new file mode 100644 index 0000000000000000000000000000000000000000..1c627d8e9c2d65410c67cf2c39974949b0720a0e --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/test_aggregate.py @@ -0,0 +1,122 @@ +import unittest + +from pypika import ( + Case, + Field, + Table, + functions as fn, +) +from pypika.terms import ( + Negative, + ValueWrapper, +) + + +class IsAggregateTests(unittest.TestCase): + def test__field_is_not_aggregate(self): + v = Field("foo") + self.assertFalse(v.is_aggregate) + + def test__constant_is_aggregate_none(self): + v = ValueWrapper(100) + self.assertIsNone(v.is_aggregate) + + def test__constant_arithmetic_is_aggregate_none(self): + v = ValueWrapper(100) + ValueWrapper(100) + self.assertIsNone(v.is_aggregate) + + def test__field_arithmetic_is_not_aggregate(self): + v = Field("foo") + Field("bar") + self.assertFalse(v.is_aggregate) + + def test__field_arithmetic_constant_is_not_aggregate(self): + v = Field("foo") + 1 + self.assertFalse(v.is_aggregate) + + def test__agg_func_is_aggregate(self): + v = fn.Sum(Field("foo")) + self.assertTrue(v.is_aggregate) + + def test__negative_agg_func_is_aggregate(self): + v = Negative(fn.Sum(Field("foo"))) + self.assertTrue(v.is_aggregate) + + def test__agg_func_arithmetic_is_aggregate(self): + v = fn.Sum(Field("foo")) / fn.Sum(Field("foo")) + self.assertTrue(v.is_aggregate) + + def test__mixed_func_arithmetic_is_not_aggregate(self): + v = Field("foo") / fn.Sum(Field("foo")) + self.assertFalse(v.is_aggregate) + + def test__func_arithmetic_constant_is_not_aggregate(self): + v = 1 / fn.Sum(Field("foo")) + self.assertTrue(v.is_aggregate) + + def test__agg_case_criterion_is_aggregate(self): + v = Case().when(fn.Sum(Field("foo")) > 666, 'More than 666').else_('Less than 666') + + self.assertTrue(v.is_aggregate) + + def test__agg_case_is_aggregate(self): + v = ( + Case() + .when(Field("foo") == 1, fn.Sum(Field("bar"))) + .when(Field("foo") == 2, fn.Sum(Field("fiz"))) + .else_(fn.Sum(Field("fiz"))) + ) + + self.assertTrue(v.is_aggregate) + + def test__mixed_case_is_not_aggregate(self): + v = Case().when(Field("foo") == 1, fn.Sum(Field("bar"))).when(Field("foo") == 2, Field("fiz")) + + self.assertFalse(v.is_aggregate) + + def test__case_mixed_else_is_not_aggregate(self): + v = ( + Case() + .when(Field("foo") == 1, fn.Sum(Field("bar"))) + .when(Field("foo") == 2, fn.Sum(Field("fiz"))) + .else_(Field("fiz")) + ) + + self.assertFalse(v.is_aggregate) + + def test__case_mixed_constant_is_not_aggregate(self): + v = Case().when(Field("foo") == 1, fn.Sum(Field("bar"))).when(Field("foo") == 2, fn.Sum(Field("fiz"))).else_(1) + + self.assertTrue(v.is_aggregate) + + def test__case_with_field_is_not_aggregate(self): + v = Case().when(Field("foo") == 1, 1).when(Field("foo") == 2, 2).else_(3) + + self.assertFalse(v.is_aggregate) + + def test__case_with_single_aggregate_field_in_one_criterion_is_aggregate(self): + v = Case().when(Field("foo") == 1, 1).when(fn.Sum(Field("foo")) == 2, 2).else_(3) + + self.assertTrue(v.is_aggregate) + + def test__non_aggregate_function_with_aggregated_arg(self): + t = Table("abc") + expr = fn.Sqrt(fn.Sum(t.a)) + + self.assertTrue(expr.is_aggregate) + + def test_complicated(self): + t = Table("abc") + is_placebo = t.campaign_extra_info == "placebo" + + pixel_mobile_search = Case().when(is_placebo, t.action_fb_pixel_search + t.action_fb_mobile_search) + unique_impressions = Case().when(is_placebo, t.unique_impressions) + + v = fn.Sum(pixel_mobile_search) / fn.Sum(unique_impressions) - 1.96 * fn.Sqrt( + 1 + / fn.Sum(unique_impressions) + * fn.Sum(pixel_mobile_search) + / fn.Sum(unique_impressions) + * (1 - fn.Sum(pixel_mobile_search) / fn.Sum(unique_impressions)) + ) + + self.assertTrue(v.is_aggregate) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/test_analytic_queries.py b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/test_analytic_queries.py new file mode 100644 index 0000000000000000000000000000000000000000..6a35ab854b30e3b0f91e633b3349706a22e0a2fd --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/test_analytic_queries.py @@ -0,0 +1,610 @@ +import unittest + +from pypika import Criterion, JoinType, Order, Query, Tables, analytics as an +from pypika.analytics import Lag, Lead + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + + +class RankTests(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_rank(self): + expr = an.Rank().over(self.table_abc.foo).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " "RANK() " 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_dense_rank(self): + expr = an.DenseRank().over(self.table_abc.foo).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " "DENSE_RANK() " 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_row_number(self): + expr = an.RowNumber().over(self.table_abc.foo).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " "ROW_NUMBER() " 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_rank_with_alias(self): + expr = an.Rank().over(self.table_abc.foo).orderby(self.table_abc.date).as_("rank") + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " "RANK() " 'OVER(PARTITION BY "foo" ORDER BY "date") "rank" ' 'FROM "abc"', + str(q), + ) + + def test_multiple_partitions(self): + expr = an.Rank().orderby(self.table_abc.date).over(self.table_abc.foo, self.table_abc.bar) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " "RANK() " 'OVER(PARTITION BY "foo","bar" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_ntile_no_partition_or_order_invalid_sql(self): + expr = an.NTile(5) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual("SELECT " "NTILE(5) " 'FROM "abc"', str(q)) + + def test_ntile_with_partition(self): + expr = an.NTile(5).over(self.table_abc.foo) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual("SELECT " "NTILE(5) " 'OVER(PARTITION BY "foo") ' 'FROM "abc"', str(q)) + + def test_ntile_with_order(self): + expr = an.NTile(5).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual("SELECT " "NTILE(5) " 'OVER(ORDER BY "date") ' 'FROM "abc"', str(q)) + + def test_ntile_with_partition_and_order(self): + expr = an.NTile(5).over(self.table_abc.foo).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " "NTILE(5) " 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_first_value(self): + expr = an.FirstValue(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'FIRST_VALUE("fizz") ' 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_first_value_ignore_nulls(self): + expr = an.FirstValue(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).ignore_nulls() + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'FIRST_VALUE("fizz" IGNORE NULLS) ' 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_first_value_ignore_nulls_first(self): + expr = an.FirstValue(self.table_abc.fizz).ignore_nulls().over(self.table_abc.foo).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'FIRST_VALUE("fizz" IGNORE NULLS) ' 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_first_value_multi_argument(self): + expr = ( + an.FirstValue(self.table_abc.fizz, self.table_abc.buzz) + .over(self.table_abc.foo) + .orderby(self.table_abc.date) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'FIRST_VALUE("fizz","buzz") ' 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_last_value(self): + expr = an.LastValue(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'LAST_VALUE("fizz") ' 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_filter(self): + expr = ( + an.LastValue(self.table_abc.fizz) + .filter(Criterion.all([self.table_abc.bar == True])) + .over(self.table_abc.foo) + .orderby(self.table_abc.date) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'LAST_VALUE("fizz") ' + 'FILTER(WHERE "bar"=true) ' + 'OVER(PARTITION BY "foo" ORDER BY "date") ' + 'FROM "abc"', + str(q), + ) + + def test_filter_quote_table_in_filter(self): + expr = ( + an.LastValue(self.table_efg.fizz) + .filter(self.table_efg.filed.eq('yes')) + .over(self.table_efg.foo) + .orderby(self.table_efg.date) + ) + + q = ( + Query.from_(self.table_abc) + .inner_join(self.table_efg) + .on(self.table_abc.id.eq(self.table_efg.id)) + .select(expr) + ) + + self.assertEqual( + 'SELECT ' + 'LAST_VALUE("efg"."fizz") ' + 'FILTER(WHERE "efg"."filed"=\'yes\') ' + 'OVER(PARTITION BY "efg"."foo" ORDER BY "efg"."date") ' + 'FROM "abc" ' + 'JOIN "efg" ON "abc"."id"="efg"."id"', + str(q), + ) + + def test_orderby_asc(self): + expr = an.LastValue(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date, order=Order.asc) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'LAST_VALUE("fizz") ' 'OVER(PARTITION BY "foo" ORDER BY "date" ASC) ' 'FROM "abc"', + str(q), + ) + + def test_orderby_desc(self): + expr = an.LastValue(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date, order=Order.desc) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'LAST_VALUE("fizz") ' 'OVER(PARTITION BY "foo" ORDER BY "date" DESC) ' 'FROM "abc"', + str(q), + ) + + def test_last_value_multi_argument(self): + expr = ( + an.LastValue(self.table_abc.fizz, self.table_abc.buzz).over(self.table_abc.foo).orderby(self.table_abc.date) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'LAST_VALUE("fizz","buzz") ' 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_last_value_ignore_nulls(self): + expr = an.LastValue(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).ignore_nulls() + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'LAST_VALUE("fizz" IGNORE NULLS) ' 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_median(self): + expr = an.Median(self.table_abc.fizz).over(self.table_abc.foo, self.table_abc.bar).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'MEDIAN("fizz") ' 'OVER(PARTITION BY "foo","bar" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_avg(self): + expr = an.Avg(self.table_abc.fizz).over(self.table_abc.foo, self.table_abc.bar).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'AVG("fizz") ' 'OVER(PARTITION BY "foo","bar" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_stddev(self): + expr = an.StdDev(self.table_abc.fizz).over(self.table_abc.foo, self.table_abc.bar).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'STDDEV("fizz") ' 'OVER(PARTITION BY "foo","bar" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_stddev_pop(self): + expr = ( + an.StdDevPop(self.table_abc.fizz).over(self.table_abc.foo, self.table_abc.bar).orderby(self.table_abc.date) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'STDDEV_POP("fizz") ' 'OVER(PARTITION BY "foo","bar" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_stddev_samp(self): + expr = ( + an.StdDevSamp(self.table_abc.fizz).over(self.table_abc.foo, self.table_abc.bar).orderby(self.table_abc.date) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'STDDEV_SAMP("fizz") ' 'OVER(PARTITION BY "foo","bar" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_variance(self): + expr = ( + an.Variance(self.table_abc.fizz).over(self.table_abc.foo, self.table_abc.bar).orderby(self.table_abc.date) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'VARIANCE("fizz") ' 'OVER(PARTITION BY "foo","bar" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_var_pop(self): + expr = an.VarPop(self.table_abc.fizz).over(self.table_abc.foo, self.table_abc.bar).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'VAR_POP("fizz") ' 'OVER(PARTITION BY "foo","bar" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_var_samp(self): + expr = an.VarSamp(self.table_abc.fizz).over(self.table_abc.foo, self.table_abc.bar).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'VAR_SAMP("fizz") ' 'OVER(PARTITION BY "foo","bar" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_table_prefixes_used_in_analytic_functions(self): + expr = an.Rank().over(self.table_abc.foo).orderby(self.table_efg.date) + + query = ( + Query.from_(self.table_abc) + .join(self.table_efg, how=JoinType.left) + .on(self.table_abc.foo == self.table_efg.bar) + .select("*", expr) + ) + + self.assertEqual( + 'SELECT *,RANK() OVER(PARTITION BY "abc"."foo" ORDER BY "efg"."date") ' + 'FROM "abc" LEFT JOIN "efg" ON "abc"."foo"="efg"."bar"', + str(query), + ) + + def test_sum_rows_unbounded_preceeding(self): + expr = an.Sum(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).rows(an.Preceding()) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'SUM("fizz") ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "ROWS UNBOUNDED PRECEDING" + ") " + 'FROM "abc"', + str(q), + ) + + def test_max_rows_x_preceeding(self): + expr = an.Max(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).rows(an.Preceding(5)) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'MAX("fizz") ' "OVER(" 'PARTITION BY "foo" ORDER BY "date" ' "ROWS 5 PRECEDING" ") " 'FROM "abc"', + str(q), + ) + + def test_min_rows_current_row(self): + expr = an.Min(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).rows(an.CURRENT_ROW) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'MIN("fizz") ' "OVER(" 'PARTITION BY "foo" ORDER BY "date" ' "ROWS CURRENT ROW" ") " 'FROM "abc"', + str(q), + ) + + def test_varpop_range_unbounded_preceeding(self): + expr = ( + an.VarPop(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).range(an.Preceding()) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'VAR_POP("fizz") ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "RANGE UNBOUNDED PRECEDING" + ") " + 'FROM "abc"', + str(q), + ) + + def test_max_range_x_preceeding(self): + expr = an.Max(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).range(an.Preceding(5)) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'MAX("fizz") ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "RANGE 5 PRECEDING" + ") " + 'FROM "abc"', + str(q), + ) + + def test_min_range_current_row(self): + expr = an.Min(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).range(an.CURRENT_ROW) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'MIN("fizz") ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "RANGE CURRENT ROW" + ") " + 'FROM "abc"', + str(q), + ) + + def test_variance_rows_between_unbounded_preceeding_unbounded_following(self): + expr = ( + an.Variance(self.table_abc.fizz) + .over(self.table_abc.foo) + .orderby(self.table_abc.date) + .rows(an.Preceding(), an.Following()) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'VARIANCE("fizz") ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING" + ") " + 'FROM "abc"', + str(q), + ) + + def test_first_value_range_between_x_preceeding_unbounded_following(self): + expr = ( + an.FirstValue(self.table_abc.fizz) + .over(self.table_abc.foo) + .orderby(self.table_abc.date) + .range(an.Preceding(3), an.Following()) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'FIRST_VALUE("fizz") ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "RANGE BETWEEN 3 PRECEDING AND UNBOUNDED FOLLOWING" + ") " + 'FROM "abc"', + str(q), + ) + + def test_varpop_rows_between_unbounded_preceeding_x_following(self): + expr = ( + an.VarPop(self.table_abc.fizz) + .over(self.table_abc.foo) + .orderby(self.table_abc.date) + .rows(an.Preceding(), an.Following(6)) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'VAR_POP("fizz") ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "ROWS BETWEEN UNBOUNDED PRECEDING AND 6 FOLLOWING" + ") " + 'FROM "abc"', + str(q), + ) + + def test_count_range_between_unbounded_preceeding_current_row(self): + expr = ( + an.Count(self.table_abc.fizz) + .over(self.table_abc.foo) + .orderby(self.table_abc.date) + .range(an.Preceding(), an.CURRENT_ROW) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'COUNT("fizz") ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW" + ") " + 'FROM "abc"', + str(q), + ) + + def test_last_value_rows_between_current_row_unbounded_following(self): + expr = ( + an.LastValue(self.table_abc.fizz) + .over(self.table_abc.foo) + .orderby(self.table_abc.date) + .rows(an.CURRENT_ROW, an.Following()) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'LAST_VALUE("fizz") ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING" + ") " + 'FROM "abc"', + str(q), + ) + + def test_last_value_rows_between_current_row_unbounded_following_ignore_nulls(self): + expr = ( + an.LastValue(self.table_abc.fizz) + .over(self.table_abc.foo) + .orderby(self.table_abc.date) + .ignore_nulls() + .rows(an.CURRENT_ROW, an.Following(8)) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'LAST_VALUE("fizz" IGNORE NULLS) ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "ROWS BETWEEN CURRENT ROW AND 8 FOLLOWING" + ") " + 'FROM "abc"', + str(q), + ) + + def test_empty_over(self): + query = Query.from_(self.table_abc).select(an.Sum(self.table_abc.fizz).over()) + + self.assertEqual("SELECT " 'SUM("fizz") OVER() ' 'FROM "abc"', str(query)) + + def test_rows_called_twice_raises_attribute_error(self): + with self.assertRaises(AttributeError): + an.Sum(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).rows(an.Preceding()).rows( + an.Preceding() + ) + + def test_range_called_twice_raises_attribute_error(self): + with self.assertRaises(AttributeError): + an.Sum(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).range( + an.Preceding() + ).range(an.Preceding()) + + def test_rows_then_range_raises_attribute_error(self): + with self.assertRaises(AttributeError): + an.Sum(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).rows( + an.Preceding() + ).range(an.Preceding()) + + def test_range_then_rows_raises_attribute_error(self): + with self.assertRaises(AttributeError): + an.Sum(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).range( + an.Preceding() + ).rows(an.Preceding()) + + def test_lag_generates_correct_sql(self): + with self.subTest('without partition by'): + q = Query.from_(self.table_abc).select( + Lag(self.table_abc.date, 1, '2000-01-01').orderby(self.table_abc.date) + ) + + self.assertEqual('SELECT LAG("date",1,\'2000-01-01\') OVER(ORDER BY "date") FROM "abc"', str(q)) + + with self.subTest('with partition by'): + q = Query.from_(self.table_abc).select( + Lag(self.table_abc.date, 1, '2000-01-01').over(self.table_abc.foo).orderby(self.table_abc.date) + ) + + self.assertEqual( + 'SELECT LAG("date",1,\'2000-01-01\') OVER(PARTITION BY "foo" ORDER BY "date") FROM "abc"', str(q) + ) + + def test_lead_generates_correct_sql(self): + with self.subTest('without partition by'): + q = Query.from_(self.table_abc).select( + Lead(self.table_abc.date, 1, '2000-01-01').orderby(self.table_abc.date) + ) + + self.assertEqual('SELECT LEAD("date",1,\'2000-01-01\') OVER(ORDER BY "date") FROM "abc"', str(q)) + + with self.subTest('with partition by'): + q = Query.from_(self.table_abc).select( + Lead(self.table_abc.date, 1, '2000-01-01').over(self.table_abc.foo).orderby(self.table_abc.date) + ) + + self.assertEqual( + 'SELECT LEAD("date",1,\'2000-01-01\') OVER(PARTITION BY "foo" ORDER BY "date") FROM "abc"', str(q) + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/test_create.py b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/test_create.py new file mode 100644 index 0000000000000000000000000000000000000000..325076544e3824b0d07f82f2378b88218b910dde --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/test_create.py @@ -0,0 +1,210 @@ +import unittest + +from pypika import Column, Columns, Query, Tables, Table +from pypika.terms import ValueWrapper, Index +from pypika.enums import ReferenceOption + + +class CreateTableTests(unittest.TestCase): + new_table, existing_table = Tables("abc", "efg") + foo, bar = Columns(("a", "INT"), ("b", "VARCHAR(100)")) + + def test_create_table_with_columns(self): + with self.subTest("with nullable"): + a = Column("a", "INT", True) + b = Column("b", "VARCHAR(100)", False) + q = Query.create_table(self.new_table).columns(a, b) + + self.assertEqual('CREATE TABLE "abc" ("a" INT NULL,"b" VARCHAR(100) NOT NULL)', str(q)) + + with self.subTest("with defaults"): + a = Column("a", "INT", default=ValueWrapper(42)) + b = Column("b", "VARCHAR(100)", default=ValueWrapper("foo")) + q = Query.create_table(self.new_table).columns(a, b) + + self.assertEqual('CREATE TABLE "abc" ("a" INT DEFAULT 42,"b" VARCHAR(100) DEFAULT \'foo\')', str(q)) + + with self.subTest("with unwrapped defaults"): + a = Column("a", "INT", default=42) + b = Column("b", "VARCHAR(100)", default="foo") + q = Query.create_table(self.new_table).columns(a, b) + + self.assertEqual('CREATE TABLE "abc" ("a" INT DEFAULT 42,"b" VARCHAR(100) DEFAULT \'foo\')', str(q)) + + with self.subTest("with period for"): + a = Column("id", "INT") + b = Column("valid_from", "DATETIME") + c = Column("valid_to", "DATETIME") + q = Query.create_table(self.new_table).columns(a, b, c).period_for('valid_period', b, c) + + self.assertEqual( + 'CREATE TABLE "abc" (' + '"id" INT,' + '"valid_from" DATETIME,' + '"valid_to" DATETIME,' + 'PERIOD FOR "valid_period" ("valid_from","valid_to"))', + str(q), + ) + + with self.subTest("without temporary keyword"): + q = Query.create_table(self.new_table).columns(self.foo, self.bar) + + self.assertEqual('CREATE TABLE "abc" ("a" INT,"b" VARCHAR(100))', str(q)) + + with self.subTest("with temporary keyword"): + q = Query.create_table(self.new_table).temporary().columns(self.foo, self.bar) + + self.assertEqual('CREATE TEMPORARY TABLE "abc" ("a" INT,"b" VARCHAR(100))', str(q)) + + with self.subTest("with primary key"): + q = Query.create_table(self.new_table).columns(self.foo, self.bar).primary_key(self.foo, self.bar) + + self.assertEqual('CREATE TABLE "abc" ("a" INT,"b" VARCHAR(100),PRIMARY KEY ("a","b"))', str(q)) + + with self.subTest("with simple foreign key"): + cref, dref = Columns(("c", "INT"), ("d", "VARCHAR(100)")) + q = ( + Query.create_table(self.new_table) + .columns(self.foo, self.bar) + .foreign_key([self.foo, self.bar], self.existing_table, [cref, dref]) + ) + + self.assertEqual( + 'CREATE TABLE "abc" (' + '"a" INT,' + '"b" VARCHAR(100),' + 'FOREIGN KEY ("a","b") REFERENCES "efg" ("c","d"))', + str(q), + ) + + with self.subTest("with foreign key reference options"): + cref, dref = Columns(("c", "INT"), ("d", "VARCHAR(100)")) + q = ( + Query.create_table(self.new_table) + .columns(self.foo, self.bar) + .foreign_key( + [self.foo, self.bar], + self.existing_table, + [cref, dref], + on_delete=ReferenceOption.cascade, + on_update=ReferenceOption.restrict, + ) + ) + + self.assertEqual( + 'CREATE TABLE "abc" (' + '"a" INT,' + '"b" VARCHAR(100),' + 'FOREIGN KEY ("a","b") REFERENCES "efg" ("c","d") ON DELETE CASCADE ON UPDATE RESTRICT)', + str(q), + ) + + with self.subTest("with unique keys"): + q = ( + Query.create_table(self.new_table) + .columns(self.foo, self.bar) + .unique(self.foo, self.bar) + .unique(self.foo) + ) + + self.assertEqual('CREATE TABLE "abc" ("a" INT,"b" VARCHAR(100),UNIQUE ("a","b"),UNIQUE ("a"))', str(q)) + + with self.subTest("with system versioning"): + q = Query.create_table(self.new_table).columns(self.foo, self.bar).with_system_versioning() + + self.assertEqual('CREATE TABLE "abc" ("a" INT,"b" VARCHAR(100)) WITH SYSTEM VERSIONING', str(q)) + + with self.subTest("with unlogged keyword"): + q = Query.create_table(self.new_table).unlogged().columns(self.foo, self.bar) + + self.assertEqual('CREATE UNLOGGED TABLE "abc" ("a" INT,"b" VARCHAR(100))', str(q)) + + with self.subTest("with if not exists keyword"): + q = Query.create_table(self.new_table).if_not_exists().columns(self.foo, self.bar) + + self.assertEqual('CREATE TABLE IF NOT EXISTS "abc" ("a" INT,"b" VARCHAR(100))', str(q)) + + def test_create_table_with_select(self): + select = Query.from_(self.existing_table).select(self.existing_table.foo, self.existing_table.bar) + + with self.subTest("without temporary keyword"): + q = Query.create_table(self.new_table).as_select(select) + + self.assertEqual('CREATE TABLE "abc" AS (SELECT "foo","bar" FROM "efg")', str(q)) + + with self.subTest("with temporary keyword"): + q = Query.create_table(self.new_table).temporary().as_select(select) + + self.assertEqual( + 'CREATE TEMPORARY TABLE "abc" AS (SELECT "foo","bar" FROM "efg")', + str(q), + ) + + def test_create_table_without_columns_or_select_empty(self): + q = Query.create_table(self.new_table) + + self.assertEqual("", str(q)) + + def test_create_table_with_select_and_columns_fails(self): + select = Query.from_(self.existing_table).select(self.existing_table.foo, self.existing_table.bar) + + with self.subTest("for columns before as_select"): + with self.assertRaises(AttributeError): + Query.create_table(self.new_table).columns(self.foo, self.bar).as_select(select) + + with self.subTest("for as_select before columns"): + with self.assertRaises(AttributeError): + Query.create_table(self.new_table).as_select(select).columns(self.foo, self.bar) + + with self.subTest("repeated foreign key"): + with self.assertRaises(AttributeError): + Query.create_table(self.new_table).foreign_key([self.foo], self.existing_table, [self.bar]).foreign_key( + [self.foo], self.existing_table, [self.bar] + ) + + def test_create_table_as_select_not_query_raises_error(self): + with self.assertRaises(TypeError): + Query.create_table(self.new_table).as_select("abc") + + +class CreateIndexTests(unittest.TestCase): + new_index = Index("abc") + new_table = Table("my_table") + columns = (new_table.a, new_table.b) + where = new_table.a > 1 + + def test_create_index_simple(self) -> None: + q = Query.create_index(self.new_index).on(self.new_table).columns(*self.columns) + self.assertEqual( + f'CREATE INDEX "{self.new_index.name}" ON "{self.new_table.get_table_name()}"({", ".join([c.name for c in self.columns])})', + q.get_sql(), + ) + + def test_create_index_where(self) -> None: + q = Query.create_index(self.new_index).on(self.new_table).columns(*self.columns).where(self.where) + self.assertEqual( + f'CREATE INDEX "{self.new_index.name}" ON "{self.new_table.get_table_name()}"({", ".join([c.name for c in self.columns])}) WHERE {self.where.get_sql()}', + q.get_sql(), + ) + + def test_create_index_unique(self) -> None: + q = Query.create_index(self.new_index).on(self.new_table).columns(*self.columns).unique() + self.assertEqual( + f'CREATE UNIQUE INDEX "{self.new_index.name}" ON "{self.new_table.get_table_name()}"({", ".join([c.name for c in self.columns])})', + q.get_sql(), + ) + + def test_create_index_if_not_exists(self) -> None: + q = Query.create_index(self.new_index).on(self.new_table).columns(*self.columns).if_not_exists() + self.assertEqual( + f'CREATE INDEX IF NOT EXISTS "{self.new_index.name}" ON "{self.new_table.get_table_name()}"({", ".join([c.name for c in self.columns])})', + q.get_sql(), + ) + + def test_create_index_without_columns_raises_error(self) -> None: + with self.assertRaises(AttributeError): + Query.create_index(self.new_index).on(self.new_table).get_sql() + + def test_create_index_without_table_raises_error(self) -> None: + with self.assertRaises(AttributeError): + Query.create_index(self.new_index).columns(*self.columns).get_sql() diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/test_criterions.py b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/test_criterions.py new file mode 100644 index 0000000000000000000000000000000000000000..fca2ceeeb18db88e34ebc38776f644fdcda67e93 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/test_criterions.py @@ -0,0 +1,873 @@ +import unittest +from datetime import ( + date, + datetime, +) + +from pypika import ( + Criterion, + EmptyCriterion, + Field, + Table, + functions as fn, +) +from pypika.queries import QueryBuilder +from pypika.terms import ExistsCriterion, Mod + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + + +class CriterionTests(unittest.TestCase): + t = Table("test", alias="crit") + + def test__criterion_with_alias(self): + c1 = (Field("foo") == Field("bar")).as_("criterion") + + self.assertEqual('"foo"="bar"', str(c1)) + self.assertEqual('"foo"="bar" "criterion"', c1.get_sql(with_alias=True, quote_char='"', alias_quote_char='"')) + + def test__criterion_eq_number(self): + c1 = Field("foo") == 1 + c2 = Field("foo", table=self.t).eq(0) + c3 = Field("foo", table=self.t) == -1 + + self.assertEqual('"foo"=1', str(c1)) + self.assertEqual('"crit"."foo"=0', str(c2)) + self.assertEqual('"crit"."foo"=-1', str(c3)) + + def test__criterion_eq_decimal(self): + c1 = Field("foo") == 1.0 + c2 = Field("foo", table=self.t).eq(0.5) + + self.assertEqual('"foo"=1.0', str(c1)) + self.assertEqual('"crit"."foo"=0.5', str(c2)) + + def test__criterion_eq_bool(self): + c1 = Field("foo") == True + c2 = Field("foo", table=self.t).eq(True) + c3 = Field("foo") == False + c4 = Field("foo", table=self.t).eq(False) + + self.assertEqual('"foo"=true', str(c1)) + self.assertEqual('"crit"."foo"=true', str(c2)) + self.assertEqual('"foo"=false', str(c3)) + self.assertEqual('"crit"."foo"=false', str(c4)) + + def test__criterion_eq_str(self): + c1 = Field("foo") == "abc" + c2 = Field("foo", table=self.t).eq("abc") + + self.assertEqual("\"foo\"='abc'", str(c1)) + self.assertEqual('"crit"."foo"=\'abc\'', str(c2)) + + def test__criterion_eq_date(self): + c1 = Field("foo") == date(2000, 1, 1) + c2 = Field("foo", table=self.t).eq(date(2000, 1, 1)) + + self.assertEqual("\"foo\"='2000-01-01'", str(c1)) + self.assertEqual('"crit"."foo"=\'2000-01-01\'', str(c2)) + + def test__criterion_eq_datetime(self): + c1 = Field("foo") == datetime(2000, 1, 1, 12, 30, 55) + c2 = Field("foo", table=self.t).eq(datetime(2000, 1, 1, 12, 30, 55)) + + self.assertEqual("\"foo\"='2000-01-01T12:30:55'", str(c1)) + self.assertEqual('"crit"."foo"=\'2000-01-01T12:30:55\'', str(c2)) + + def test__criterion_eq_right(self): + c1 = 1 == Field("foo") + c2 = -1 == Field("foo", table=self.t) + + self.assertEqual('"foo"=1', str(c1)) + self.assertEqual('"crit"."foo"=-1', str(c2)) + + def test__criterion_is_null(self): + c1 = Field("foo").isnull() + c2 = Field("foo", table=self.t).isnull() + + self.assertEqual('"foo" IS NULL', str(c1)) + self.assertEqual('"crit"."foo" IS NULL', str(c2)) + + def test__criterion_is_null_with_alias(self): + c1 = Field("foo").isnull().as_('alias') + c2 = Field("foo", table=self.t).isnull().as_('alias') + + self.assertEqual('"foo" IS NULL "alias"', str(c1)) + self.assertEqual('"crit"."foo" IS NULL "alias"', str(c2)) + + def test__criterion_ne_number(self): + c1 = Field("foo") != 1 + c2 = Field("foo", table=self.t).ne(0) + c3 = Field("foo") != -1 + + self.assertEqual('"foo"<>1', str(c1)) + self.assertEqual('"crit"."foo"<>0', str(c2)) + self.assertEqual('"foo"<>-1', str(c3)) + + def test__criterion_ne_str(self): + c1 = Field("foo") != "abc" + c2 = Field("foo", table=self.t).ne("abc") + + self.assertEqual("\"foo\"<>'abc'", str(c1)) + self.assertEqual('"crit"."foo"<>\'abc\'', str(c2)) + + def test__criterion_ne_date(self): + c1 = Field("foo") != date(2000, 1, 1) + c2 = Field("foo", table=self.t).ne(date(2000, 1, 1)) + + self.assertEqual("\"foo\"<>'2000-01-01'", str(c1)) + self.assertEqual('"crit"."foo"<>\'2000-01-01\'', str(c2)) + + def test__criterion_ne_datetime(self): + c1 = Field("foo") != datetime(2000, 1, 1, 12, 30, 55) + c2 = Field("foo", table=self.t).ne(datetime(2000, 1, 1, 12, 30, 55)) + + self.assertEqual("\"foo\"<>'2000-01-01T12:30:55'", str(c1)) + self.assertEqual('"crit"."foo"<>\'2000-01-01T12:30:55\'', str(c2)) + + def test__criterion_ne_right(self): + c1 = 1 != Field("foo") + c2 = -1 != Field("foo", table=self.t) + + self.assertEqual('"foo"<>1', str(c1)) + self.assertEqual('"crit"."foo"<>-1', str(c2)) + + def test__criterion_lt_number(self): + c1 = Field("foo") < 1 + c2 = Field("foo", table=self.t).lt(0) + c3 = Field("foo") < -1 + + self.assertEqual('"foo"<1', str(c1)) + self.assertEqual('"crit"."foo"<0', str(c2)) + self.assertEqual('"foo"<-1', str(c3)) + + def test__criterion_lt_date(self): + c1 = Field("foo") < date(2000, 1, 1) + c2 = Field("foo", table=self.t).lt(date(2000, 1, 1)) + + self.assertEqual("\"foo\"<'2000-01-01'", str(c1)) + self.assertEqual('"crit"."foo"<\'2000-01-01\'', str(c2)) + + def test__criterion_lt_datetime(self): + c1 = Field("foo") < datetime(2000, 1, 1, 12, 30, 55) + c2 = Field("foo", table=self.t).lt(datetime(2000, 1, 1, 12, 30, 55)) + + self.assertEqual("\"foo\"<'2000-01-01T12:30:55'", str(c1)) + self.assertEqual('"crit"."foo"<\'2000-01-01T12:30:55\'', str(c2)) + + def test__criterion_lt_right(self): + c1 = 1 > Field("foo") + c2 = -1 > Field("foo", table=self.t) + + self.assertEqual('"foo"<1', str(c1)) + self.assertEqual('"crit"."foo"<-1', str(c2)) + + def test__criterion_gt_number(self): + c1 = Field("foo") > 1 + c2 = Field("foo", table=self.t).gt(0) + c3 = Field("foo") > -1 + + self.assertEqual('"foo">1', str(c1)) + self.assertEqual('"crit"."foo">0', str(c2)) + self.assertEqual('"foo">-1', str(c3)) + + def test__criterion_gt_date(self): + c1 = Field("foo") > date(2000, 1, 1) + c2 = Field("foo", table=self.t).gt(date(2000, 1, 1)) + + self.assertEqual("\"foo\">'2000-01-01'", str(c1)) + self.assertEqual('"crit"."foo">\'2000-01-01\'', str(c2)) + + def test__criterion_gt_datetime(self): + c1 = Field("foo") > datetime(2000, 1, 1, 12, 30, 55) + c2 = Field("foo", table=self.t).gt(datetime(2000, 1, 1, 12, 30, 55)) + + self.assertEqual("\"foo\">'2000-01-01T12:30:55'", str(c1)) + self.assertEqual('"crit"."foo">\'2000-01-01T12:30:55\'', str(c2)) + + def test__criterion_gt_right(self): + c1 = 1 < Field("foo") + c2 = -1 < Field("foo", table=self.t) + + self.assertEqual('"foo">1', str(c1)) + self.assertEqual('"crit"."foo">-1', str(c2)) + + def test__criterion_lte_number(self): + c1 = Field("foo") <= 1 + c2 = Field("foo", table=self.t).lte(0) + c3 = Field("foo") <= -1 + + self.assertEqual('"foo"<=1', str(c1)) + self.assertEqual('"crit"."foo"<=0', str(c2)) + self.assertEqual('"foo"<=-1', str(c3)) + + def test__criterion_lte_date(self): + c1 = Field("foo") <= date(2000, 1, 1) + c2 = Field("foo", table=self.t).lte(date(2000, 1, 1)) + + self.assertEqual("\"foo\"<='2000-01-01'", str(c1)) + self.assertEqual('"crit"."foo"<=\'2000-01-01\'', str(c2)) + + def test__criterion_lte_datetime(self): + c1 = Field("foo") <= datetime(2000, 1, 1, 12, 30, 55) + c2 = Field("foo", table=self.t).lte(datetime(2000, 1, 1, 12, 30, 55)) + + self.assertEqual("\"foo\"<='2000-01-01T12:30:55'", str(c1)) + self.assertEqual('"crit"."foo"<=\'2000-01-01T12:30:55\'', str(c2)) + + def test__criterion_lte_right(self): + c1 = 1 >= Field("foo") + c2 = -1 >= Field("foo", table=self.t) + + self.assertEqual('"foo"<=1', str(c1)) + self.assertEqual('"crit"."foo"<=-1', str(c2)) + + def test__criterion_gte_number(self): + c1 = Field("foo") >= 1 + c2 = Field("foo", table=self.t).gte(0) + c3 = Field("foo") >= -1 + + self.assertEqual('"foo">=1', str(c1)) + self.assertEqual('"crit"."foo">=0', str(c2)) + self.assertEqual('"foo">=-1', str(c3)) + + def test__criterion_gte_date(self): + c1 = Field("foo") >= date(2000, 1, 1) + c2 = Field("foo", table=self.t).gte(date(2000, 1, 1)) + + self.assertEqual("\"foo\">='2000-01-01'", str(c1)) + self.assertEqual('"crit"."foo">=\'2000-01-01\'', str(c2)) + + def test__criterion_gte_datetime(self): + c1 = Field("foo") >= datetime(2000, 1, 1, 12, 30, 55) + c2 = Field("foo", table=self.t).gte(datetime(2000, 1, 1, 12, 30, 55)) + + self.assertEqual("\"foo\">='2000-01-01T12:30:55'", str(c1)) + self.assertEqual('"crit"."foo">=\'2000-01-01T12:30:55\'', str(c2)) + + def test__criterion_gte_right(self): + c1 = 1 <= Field("foo") + c2 = -1 <= Field("foo", table=self.t) + + self.assertEqual('"foo">=1', str(c1)) + self.assertEqual('"crit"."foo">=-1', str(c2)) + + def test__criterion_bitwise_and(self): + c1 = Field("foo").bitwiseand(2) + c2 = Field("foo", table=self.t).bitwiseand(10) == 2 + + self.assertEqual('("foo" & 2)', str(c1)) + self.assertEqual('("crit"."foo" & 10)=2', str(c2)) + + def test__criterion_bitwise_and_with_alias(self): + c1 = Field("foo").bitwiseand(2).as_('alias') + + self.assertEqual('("foo" & 2) "alias"', str(c1)) + + def test__bitwise_and_in_where_clause(self): + q = QueryBuilder().from_('items').select('abc').where(Field("foo").bitwiseand(1) == 1) + + self.assertEqual('SELECT "abc" FROM "items" WHERE ("foo" & 1)=1', str(q)) + + +class NotTests(unittest.TestCase): + table_abc, table_efg = Table("abc", alias="cx0"), Table("efg", alias="cx1") + + def test_negate(self): + c1 = Field("foo") >= 1 + c2 = c1.negate() + + self.assertEqual('"foo">=1', str(c1)) + self.assertEqual('NOT "foo">=1', str(c2)) + + def test_variable_access(self): + c1 = Field("foo").negate() + + self.assertEqual(c1.is_aggregate, False) + + def test_chained_function(self): + field1 = Field("foo").negate() + field2 = field1.eq("bar") + + self.assertEqual('NOT "foo"', str(field1)) + self.assertEqual("NOT \"foo\"='bar'", str(field2)) + self.assertIsNot(field1, field2) + + def test_not_null(self): + c1 = Field("foo").notnull() + c2 = Field("foo", table=self.table_abc).notnull() + + self.assertEqual('NOT "foo" IS NULL', str(c1)) + self.assertEqual('NOT "cx0"."foo" IS NULL', str(c2)) + + def test_is_not_null(self): + c1 = Field("foo").isnotnull() + c2 = Field("foo", table=self.table_abc).isnotnull() + + self.assertEqual('"foo" IS NOT NULL', str(c1)) + self.assertEqual('"cx0"."foo" IS NOT NULL', str(c2)) + + def test_not_null_with_alias(self): + c1 = Field("foo").notnull().as_("something") + c2 = Field("foo", table=self.table_abc).notnull().as_("something") + + self.assertEqual('NOT "foo" IS NULL "something"', str(c1)) + self.assertEqual('NOT "cx0"."foo" IS NULL "something"', str(c2)) + + def test_notnullcriterion_replace_table(self): + f = self.table_abc.foo.notnull().replace_table(self.table_abc, self.table_efg) + + self.assertEqual('NOT "cx1"."foo" IS NULL', str(f)) + + def test_not_with_or_criterion(self): + self.assertEqual('NOT ("foo" OR "bar")', str(~(Field("foo") | Field("bar")))) + + def test_not_with_and_criterion(self): + self.assertEqual('NOT ("foo" AND "bar")', str(~(Field("foo") & Field("bar")))) + + def test_not_with_complex_criterion(self): + self.assertEqual( + 'NOT ("foo" AND "bar" AND "fizz" AND "buzz")', + str(~(Field("foo") & Field("bar") & Field("fizz") & Field("buzz"))), + ) + + +class BetweenTests(unittest.TestCase): + t = Table("abc", alias="btw") + + def test__between_number(self): + c1 = Field("foo").between(0, 1) + c2 = Field("foo", table=self.t).between(0, 1) + c3 = Field("foo")[0:1] + + self.assertEqual('"foo" BETWEEN 0 AND 1', str(c1)) + self.assertEqual('"btw"."foo" BETWEEN 0 AND 1', str(c2)) + self.assertEqual('"foo" BETWEEN 0 AND 1', str(c3)) + + def test__between_with_alias(self): + c1 = Field("foo").between(0, 1).as_('alias') + c2 = Field("foo", table=self.t).between(0, 1).as_('alias') + c3 = Field("foo")[0:1].as_('alias') + + self.assertEqual('"foo" BETWEEN 0 AND 1 "alias"', str(c1)) + self.assertEqual('"btw"."foo" BETWEEN 0 AND 1 "alias"', str(c2)) + self.assertEqual('"foo" BETWEEN 0 AND 1 "alias"', str(c3)) + + def test__between_date(self): + c1 = Field("foo").between(date(2000, 1, 1), date(2000, 12, 31)) + c2 = Field("foo", table=self.t).between(date(2000, 1, 1), date(2000, 12, 31)) + c3 = Field("foo")[date(2000, 1, 1) : date(2000, 12, 31)] + + self.assertEqual("\"foo\" BETWEEN '2000-01-01' AND '2000-12-31'", str(c1)) + self.assertEqual("\"btw\".\"foo\" BETWEEN '2000-01-01' AND '2000-12-31'", str(c2)) + self.assertEqual("\"foo\" BETWEEN '2000-01-01' AND '2000-12-31'", str(c3)) + + def test__between_datetime(self): + c1 = Field("foo").between(datetime(2000, 1, 1, 0, 0, 0), datetime(2000, 12, 31, 23, 59, 59)) + c2 = Field("foo", table=self.t).between(datetime(2000, 1, 1, 0, 0, 0), datetime(2000, 12, 31, 23, 59, 59)) + c3 = Field("foo")[datetime(2000, 1, 1, 0, 0, 0) : datetime(2000, 12, 31, 23, 59, 59)] + + self.assertEqual("\"foo\" BETWEEN '2000-01-01T00:00:00' AND '2000-12-31T23:59:59'", str(c1)) + self.assertEqual( + "\"btw\".\"foo\" BETWEEN '2000-01-01T00:00:00' AND '2000-12-31T23:59:59'", + str(c2), + ) + self.assertEqual("\"foo\" BETWEEN '2000-01-01T00:00:00' AND '2000-12-31T23:59:59'", str(c3)) + + def test__function_between(self): + c1 = fn.Coalesce(Field("foo"), 0)[0:1] + c2 = fn.Coalesce(Field("foo", table=self.t), 0)[0:1] + + self.assertEqual('COALESCE("foo",0) BETWEEN 0 AND 1', str(c1)) + self.assertEqual('COALESCE("btw"."foo",0) BETWEEN 0 AND 1', str(c2)) + + def test_get_item_only_works_with_slice(self): + with self.assertRaises(TypeError): + Field("foo")[0] + + with self.assertRaises(TypeError): + Field("foo")[date(2000, 1, 1)] + + with self.assertRaises(TypeError): + Field("foo")[datetime(2000, 1, 1, 0, 0, 0)] + + +class IsInTests(unittest.TestCase): + t = Table("abc", alias="isin") + + def test__in_number(self): + c1 = Field("foo").isin([0, 1]) + c2 = Field("foo", table=self.t).isin([0, 1]) + + self.assertEqual('"foo" IN (0,1)', str(c1)) + self.assertEqual('"isin"."foo" IN (0,1)', str(c2)) + + def test__in_number_with_alias(self): + c1 = Field("foo").isin([0, 1]).as_('alias') + c2 = Field("foo", table=self.t).isin([0, 1]).as_('alias') + + self.assertEqual('"foo" IN (0,1) "alias"', str(c1)) + self.assertEqual('"isin"."foo" IN (0,1) "alias"', str(c2)) + + def test__in_character(self): + c1 = Field("foo").isin(["a", "b"]) + c2 = Field("foo", table=self.t).isin(["a", "b"]) + + self.assertEqual("\"foo\" IN ('a','b')", str(c1)) + self.assertEqual("\"isin\".\"foo\" IN ('a','b')", str(c2)) + + def test__in_date(self): + c1 = Field("foo").isin([date(2000, 1, 1), date(2000, 12, 31)]) + c2 = Field("foo", table=self.t).isin([date(2000, 1, 1), date(2000, 12, 31)]) + + self.assertEqual("\"foo\" IN ('2000-01-01','2000-12-31')", str(c1)) + self.assertEqual("\"isin\".\"foo\" IN ('2000-01-01','2000-12-31')", str(c2)) + + def test__in_datetime(self): + c1 = Field("foo").isin([datetime(2000, 1, 1, 0, 0, 0), datetime(2000, 12, 31, 23, 59, 59)]) + c2 = Field("foo", table=self.t).isin([datetime(2000, 1, 1, 0, 0, 0), datetime(2000, 12, 31, 23, 59, 59)]) + + self.assertEqual("\"foo\" IN ('2000-01-01T00:00:00','2000-12-31T23:59:59')", str(c1)) + self.assertEqual("\"isin\".\"foo\" IN ('2000-01-01T00:00:00','2000-12-31T23:59:59')", str(c2)) + + def test__function_isin(self): + c1 = fn.Coalesce(Field("foo"), 0).isin([0, 1]) + c2 = fn.Coalesce(Field("foo", table=self.t), 0).isin([0, 1]) + + self.assertEqual('COALESCE("foo",0) IN (0,1)', str(c1)) + self.assertEqual('COALESCE("isin"."foo",0) IN (0,1)', str(c2)) + + for t in (list, tuple, set, frozenset): + c_type = fn.Coalesce(Field("foo"), 0).isin(t([0, 1])) + self.assertEqual('COALESCE("foo",0) IN (0,1)', str(c_type)) + + self.assertRaises(AttributeError, lambda: str(fn.Coalesce(Field("foo"), 0).isin('SHOULD_FAIL'))) + + def test__in_unicode(self): + c1 = Field("foo").isin([u"a", u"b"]) + c2 = Field("foo", table=self.t).isin([u"a", u"b"]) + + self.assertEqual("\"foo\" IN ('a','b')", str(c1)) + self.assertEqual("\"isin\".\"foo\" IN ('a','b')", str(c2)) + + +class ArithmeticExpressionTests(unittest.TestCase): + def test__lshift(self): + c1 = Field("foo").lshift("1") + c2 = Field("foo").lshift("2") + + self.assertEqual("\"foo\"<<'1'", str(c1)) + self.assertEqual("\"foo\"<<'2'", str(c2)) + + def test__rshift(self): + c1 = Field("foo").rshift("1") + c2 = Field("foo").rshift("2") + + self.assertEqual("\"foo\">>'1'", str(c1)) + self.assertEqual("\"foo\">>'2'", str(c2)) + + +class NotInTests(unittest.TestCase): + t = Table("abc", alias="notin") + + def test__notin_number(self): + c1 = Field("foo").notin([0, 1]) + c2 = Field("foo", table=self.t).notin([0, 1]) + + self.assertEqual('"foo" NOT IN (0,1)', str(c1)) + self.assertEqual('"notin"."foo" NOT IN (0,1)', str(c2)) + + def test__notin_number_with_alias(self): + c1 = Field("foo").notin([0, 1]).as_('alias') + c2 = Field("foo", table=self.t).notin([0, 1]).as_('alias') + + self.assertEqual('"foo" NOT IN (0,1) "alias"', str(c1)) + self.assertEqual('"notin"."foo" NOT IN (0,1) "alias"', str(c2)) + + def test__notin_character(self): + c1 = Field("foo").notin(["a", "b"]) + c2 = Field("foo", table=self.t).notin(["a", "b"]) + + self.assertEqual("\"foo\" NOT IN ('a','b')", str(c1)) + self.assertEqual("\"notin\".\"foo\" NOT IN ('a','b')", str(c2)) + + def test__notin_date(self): + c1 = Field("foo").notin([date(2000, 1, 1), date(2000, 12, 31)]) + c2 = Field("foo", table=self.t).notin([date(2000, 1, 1), date(2000, 12, 31)]) + + self.assertEqual("\"foo\" NOT IN ('2000-01-01','2000-12-31')", str(c1)) + self.assertEqual("\"notin\".\"foo\" NOT IN ('2000-01-01','2000-12-31')", str(c2)) + + def test__notin_datetime(self): + c1 = Field("foo").notin([datetime(2000, 1, 1, 0, 0, 0), datetime(2000, 12, 31, 23, 59, 59)]) + c2 = Field("foo", table=self.t).notin([datetime(2000, 1, 1, 0, 0, 0), datetime(2000, 12, 31, 23, 59, 59)]) + + self.assertEqual("\"foo\" NOT IN ('2000-01-01T00:00:00','2000-12-31T23:59:59')", str(c1)) + self.assertEqual( + "\"notin\".\"foo\" NOT IN ('2000-01-01T00:00:00','2000-12-31T23:59:59')", + str(c2), + ) + + def test__function_notin(self): + c1 = fn.Coalesce(Field("foo"), 0).notin([0, 1]) + c2 = fn.Coalesce(Field("foo", table=self.t), 0).notin([0, 1]) + + self.assertEqual('COALESCE("foo",0) NOT IN (0,1)', str(c1)) + self.assertEqual('COALESCE("notin"."foo",0) NOT IN (0,1)', str(c2)) + + +class LikeTests(unittest.TestCase): + t = Table("abc", alias="like") + + def test_like_starts_with(self): + c1 = Field("foo").like("ab%") + c2 = Field("foo", table=self.t).like("ab%") + + self.assertEqual("\"foo\" LIKE 'ab%'", str(c1)) + self.assertEqual('"like"."foo" LIKE \'ab%\'', str(c2)) + + def test_like_contains(self): + c1 = Field("foo").like("%ab%") + c2 = Field("foo", table=self.t).like("%ab%") + + self.assertEqual("\"foo\" LIKE '%ab%'", str(c1)) + self.assertEqual('"like"."foo" LIKE \'%ab%\'', str(c2)) + + def test_like_ends_with(self): + c1 = Field("foo").like("%ab") + c2 = Field("foo", table=self.t).like("%ab") + + self.assertEqual("\"foo\" LIKE '%ab'", str(c1)) + self.assertEqual('"like"."foo" LIKE \'%ab\'', str(c2)) + + def test_like_n_chars_long(self): + c1 = Field("foo").like("___") + c2 = Field("foo", table=self.t).like("___") + + self.assertEqual("\"foo\" LIKE '___'", str(c1)) + self.assertEqual('"like"."foo" LIKE \'___\'', str(c2)) + + def test_like_single_chars_and_various_chars(self): + c1 = Field("foo").like("a_b%c") + c2 = Field("foo", table=self.t).like("a_b%c") + + self.assertEqual("\"foo\" LIKE 'a_b%c'", str(c1)) + self.assertEqual('"like"."foo" LIKE \'a_b%c\'', str(c2)) + + def test_not_like_single_chars_and_various_chars(self): + c1 = Field("foo").not_like("a_b%c") + c2 = Field("foo", table=self.t).not_like("a_b%c") + + self.assertEqual("\"foo\" NOT LIKE 'a_b%c'", str(c1)) + self.assertEqual('"like"."foo" NOT LIKE \'a_b%c\'', str(c2)) + + def test_ilike_starts_with(self): + c1 = Field("foo").ilike("ab%") + c2 = Field("foo", table=self.t).ilike("ab%") + + self.assertEqual("\"foo\" ILIKE 'ab%'", str(c1)) + self.assertEqual('"like"."foo" ILIKE \'ab%\'', str(c2)) + + def test_ilike_contains(self): + c1 = Field("foo").ilike("%ab%") + c2 = Field("foo", table=self.t).ilike("%ab%") + + self.assertEqual("\"foo\" ILIKE '%ab%'", str(c1)) + self.assertEqual('"like"."foo" ILIKE \'%ab%\'', str(c2)) + + def test_ilike_ends_with(self): + c1 = Field("foo").ilike("%ab") + c2 = Field("foo", table=self.t).ilike("%ab") + + self.assertEqual("\"foo\" ILIKE '%ab'", str(c1)) + self.assertEqual('"like"."foo" ILIKE \'%ab\'', str(c2)) + + def test_ilike_n_chars_long(self): + c1 = Field("foo").ilike("___") + c2 = Field("foo", table=self.t).ilike("___") + + self.assertEqual("\"foo\" ILIKE '___'", str(c1)) + self.assertEqual('"like"."foo" ILIKE \'___\'', str(c2)) + + def test_ilike_single_chars_and_various_chars(self): + c1 = Field("foo").ilike("a_b%c") + c2 = Field("foo", table=self.t).ilike("a_b%c") + + self.assertEqual("\"foo\" ILIKE 'a_b%c'", str(c1)) + self.assertEqual('"like"."foo" ILIKE \'a_b%c\'', str(c2)) + + def test_not_ilike_single_chars_and_various_chars(self): + c1 = Field("foo").not_ilike("a_b%c") + c2 = Field("foo", table=self.t).not_ilike("a_b%c") + + self.assertEqual("\"foo\" NOT ILIKE 'a_b%c'", str(c1)) + self.assertEqual('"like"."foo" NOT ILIKE \'a_b%c\'', str(c2)) + + def test_rlike_escape_chars(self): + c1 = Field("foo").rlike("\\\\d+$") + c2 = Field("foo", table=self.t).rlike("\\\\d+$") + + self.assertEqual("\"foo\" RLIKE '\\\\d+$'", str(c1)) + self.assertEqual('"like"."foo" RLIKE \'\\\\d+$\'', str(c2)) + + def test_glob_single_chars_and_various_chars(self): + c1 = Field("foo").glob("a_b*") + c2 = Field("foo", table=self.t).glob("a_b*") + + self.assertEqual("\"foo\" GLOB 'a_b*'", str(c1)) + self.assertEqual('"like"."foo" GLOB \'a_b*\'', str(c2)) + + +class ExistsCriterionTests(unittest.TestCase): + t2 = Table("abc", alias="t2") + q2 = QueryBuilder().from_(t2).select(t2.field2) + + def test_exists(self): + t1 = Table("def", alias="t1") + q1 = QueryBuilder().from_(t1).where(ExistsCriterion(self.q2)).select(t1.field1) + + self.assertEqual( + 'SELECT "t1"."field1" FROM "def" "t1" WHERE EXISTS (SELECT "t2"."field2" FROM "abc" "t2")', str(q1) + ) + + def test_not_exists(self): + t1 = Table("def", alias="t1") + q1 = QueryBuilder().from_(t1).where(ExistsCriterion(self.q2).negate()).select(t1.field1) + + self.assertEqual( + 'SELECT "t1"."field1" FROM "def" "t1" WHERE NOT EXISTS (SELECT "t2"."field2" FROM "abc" "t2")', str(q1) + ) + + +class ComplexCriterionTests(unittest.TestCase): + table_abc, table_efg = Table("abc", alias="cx0"), Table("efg", alias="cx1") + + def test_and(self): + c1 = (Field("foo") == 1) & (Field("bar") == 2) + c2 = (Field("foo", table=self.table_abc) == 1) & (Field("bar", table=self.table_efg) == 2) + + self.assertEqual('"foo"=1 AND "bar"=2', str(c1)) + self.assertEqual('"cx0"."foo"=1 AND "cx1"."bar"=2', str(c2)) + + def test_or(self): + c1 = (Field("foo") == 1) | (Field("bar") == 2) + c2 = (Field("foo", table=self.table_abc) == 1) | (Field("bar", table=self.table_efg) == 2) + + self.assertEqual('"foo"=1 OR "bar"=2', str(c1)) + self.assertEqual('"cx0"."foo"=1 OR "cx1"."bar"=2', str(c2)) + + def test_xor(self): + c1 = (Field("foo") == 1) ^ (Field("bar") == 2) + c2 = (Field("foo", table=self.table_abc) == 1) ^ (Field("bar", table=self.table_efg) == 2) + + self.assertEqual('"foo"=1 XOR "bar"=2', str(c1)) + self.assertEqual('"cx0"."foo"=1 XOR "cx1"."bar"=2', str(c2)) + + def test_function_and(self): + c1 = fn.IsNull(Field("foo")) & (Field("bar") == 2) + + self.assertEqual('ISNULL("foo") AND "bar"=2', str(c1)) + + def test_function_or(self): + c1 = fn.IsNull(Field("foo")) | (Field("bar") == 2) + + self.assertEqual('ISNULL("foo") OR "bar"=2', str(c1)) + + def test_function_xor(self): + c1 = fn.IsNull(Field("foo")) ^ (Field("bar") == 2) + + self.assertEqual('ISNULL("foo") XOR "bar"=2', str(c1)) + + def test__nested__and(self): + c = (Field("foo") == 1) & (Field("bar") == 2) & (Field("buz") == 3) + + self.assertEqual('"foo"=1 AND "bar"=2 AND "buz"=3', str(c)) + + def test__nested__or(self): + c = (Field("foo") == 1) | (Field("bar") == 2) | (Field("buz") == 3) + + self.assertEqual('"foo"=1 OR "bar"=2 OR "buz"=3', str(c)) + + def test__nested__mixed(self): + c = ((Field("foo") == 1) & (Field("bar") == 2)) | (Field("buz") == 3) + + self.assertEqual('("foo"=1 AND "bar"=2) OR "buz"=3', str(c)) + + def test__between_and_isin(self): + c = Field("foo").isin([1, 2, 3]) & Field("bar").between(0, 1) + + self.assertEqual('"foo" IN (1,2,3) AND "bar" BETWEEN 0 AND 1', str(c)) + + def test__between_and_field(self): + c1 = Field("foo").between(0, 1) + c2 = Field("bool_field") + + self.assertEqual('"foo" BETWEEN 0 AND 1 AND "bool_field"', str(c1 & c2)) + self.assertEqual('"bool_field" AND "foo" BETWEEN 0 AND 1', str(c2 & c1)) + + +class FieldsAsCriterionTests(unittest.TestCase): + def test__field_and_field(self): + c1 = Field("a") + c2 = Field("b") + + self.assertEqual('"a" AND "b"', str(c1 & c2)) + + def test__field_or_field(self): + c1 = Field("a") + c2 = Field("b") + + self.assertEqual('"a" OR "b"', str(c1 | c2)) + + def test__field_xor_field(self): + c1 = Field("a") + c2 = Field("b") + + self.assertEqual('"a" XOR "b"', str(c1 ^ c2)) + + +class CriterionOperationsTests(unittest.TestCase): + table_abc, table_efg = Table("abc", alias="cx0"), Table("efg", alias="cx1") + + def test_field_replace_table(self): + f = self.table_abc.foo.replace_table(self.table_abc, self.table_efg) + + self.assertEqual('"cx1"."foo"', str(f)) + + def test_arithmeticfunction_replace_table(self): + f = (self.table_abc.foo + self.table_abc.bar).replace_table(self.table_abc, self.table_efg) + + self.assertEqual('"cx1"."foo"+"cx1"."bar"', str(f)) + + def test_criterion_replace_table(self): + f = (self.table_abc.foo < self.table_abc.bar).replace_table(self.table_abc, self.table_efg) + + self.assertEqual('"cx1"."foo"<"cx1"."bar"', str(f)) + + def test_complexcriterion_replace_table(self): + f = (self.table_abc.foo < self.table_abc.bar) & (self.table_abc.fiz > self.table_abc.buz) + f = f.replace_table(self.table_abc, self.table_efg) + + self.assertEqual('"cx1"."foo"<"cx1"."bar" AND "cx1"."fiz">"cx1"."buz"', str(f)) + + def test_function_with_only_fields_replace_table(self): + f = fn.Sum(self.table_abc.foo).replace_table(self.table_abc, self.table_efg) + + self.assertEqual('SUM("cx1"."foo")', str(f)) + + def test_function_with_values_and_fields_replace_table(self): + f = Mod(self.table_abc.foo, 2).replace_table(self.table_abc, self.table_efg) + + self.assertEqual('MOD("cx1"."foo",2)', str(f)) + + def test_betweencriterion_replace_table(self): + f = self.table_abc.foo[0:1].replace_table(self.table_abc, self.table_efg) + + self.assertEqual('"cx1"."foo" BETWEEN 0 AND 1', str(f)) + + def test_nullcriterion_replace_table(self): + f = self.table_abc.foo.isnull().replace_table(self.table_abc, self.table_efg) + + self.assertEqual('"cx1"."foo" IS NULL', str(f)) + + +class AnyTests(unittest.TestCase): + def test_zero_args_returns_empty_criterion(self): + crit = Criterion.any() + self.assertIsInstance(crit, EmptyCriterion) + + def test_single_arg_returns_self(self): + f = Field("a") + crit = Criterion.any([f]) + self.assertEqual(str(f), str(crit)) + + def test_multiple_args_returned_in_chain_of_ors(self): + crit = Criterion.any([Field("a"), Field("b"), Field("c"), Field("d")]) + self.assertEqual(str(crit), '"a" OR "b" OR "c" OR "d"') + + def test_with_generator(self): + crit = Criterion.any(Field(letter) for letter in "abcd") + self.assertEqual(str(crit), '"a" OR "b" OR "c" OR "d"') + + +class EmptyCriterionTests(unittest.TestCase): + def test_fields_(self): + empty_criterion = EmptyCriterion() + + self.assertEqual(len(empty_criterion.fields_()), 0) + + def test_empty_criterion_on_the_left(self): + t = Table("test1") + q = EmptyCriterion() & t.f1 == "v1" + + self.assertEqual( + '"test1"."f1"=\'v1\'', + q.get_sql(with_namespace=True), + ) + + def test_empty_criterion_on_the_right(self): + t = Table("test1") + q = (t.f1 == "v1") & EmptyCriterion() + + self.assertEqual( + '"test1"."f1"=\'v1\'', + q.get_sql(with_namespace=True), + ) + + def test_invertion_of_the_empty_criterion(self): + t = Table("test1") + q = (t.f1 == "v1") & ~EmptyCriterion() + + self.assertEqual( + '"test1"."f1"=\'v1\'', + q.get_sql(with_namespace=True), + ) + + def test_different_operations_with_empty_criterion(self): + t = Table("test1") + q1 = (t.f1 == "v1") & EmptyCriterion() + q2 = (t.f1 == "v1") | EmptyCriterion() + q3 = (t.f1 == "v1") ^ EmptyCriterion() + + expected_sql = '"test1"."f1"=\'v1\'' + self.assertEqual( + expected_sql, + q1.get_sql(with_namespace=True), + ) + self.assertEqual( + expected_sql, + q2.get_sql(with_namespace=True), + ) + self.assertEqual( + expected_sql, + q3.get_sql(with_namespace=True), + ) + + def test_more_than_one_empty_criterions(self): + t = Table("test1") + q = EmptyCriterion() & ~(EmptyCriterion() | EmptyCriterion()) & (t.f1 == "v1") & ~EmptyCriterion() + + self.assertEqual( + '"test1"."f1"=\'v1\'', + q.get_sql(with_namespace=True), + ) + + +class AllTests(unittest.TestCase): + def test_zero_args_returns_empty_criterion(self): + crit = Criterion.all() + self.assertIsInstance(crit, EmptyCriterion) + + def test_single_arg_returns_self(self): + f = Field("a") + crit = Criterion.all([f]) + self.assertEqual(str(f), str(crit)) + + def test_multiple_args_returned_in_chain_of_ors(self): + crit = Criterion.all([Field("a"), Field("b"), Field("c"), Field("d")]) + self.assertEqual(str(crit), '"a" AND "b" AND "c" AND "d"') + + def test_with_generator(self): + crit = Criterion.all(Field(letter) for letter in "abcd") + self.assertEqual(str(crit), '"a" AND "b" AND "c" AND "d"') diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/test_custom_functions.py b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/test_custom_functions.py new file mode 100644 index 0000000000000000000000000000000000000000..60ffd3cd8e6191e3fc782dac003c41bfb7a78528 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/test_custom_functions.py @@ -0,0 +1,49 @@ +import unittest + +from pypika import CustomFunction, FunctionException, Query, Table + +__author__ = "Airton Zanon" +__email__ = "me@airton.dev" + + +class TestUnitCustomFunction(unittest.TestCase): + def test_should_fail_with_wrong_arguments(self): + DateDiff = CustomFunction("DATE_DIFF", ["interval", "start_date", "end_date"]) + + with self.assertRaises(FunctionException): + DateDiff("foo") + + def test_should_return_function_with_arguments(self): + DateDiff = CustomFunction("DATE_DIFF", ["interval", "start_date", "end_date"]) + + self.assertEqual( + "DATE_DIFF('day','start_date','end_date')", + str(DateDiff("day", "start_date", "end_date")), + ) + + def test_should_return_function_with_no_arguments(self): + CurrentDate = CustomFunction("CURRENT_DATE") + + self.assertEqual("CURRENT_DATE()", str(CurrentDate())) + + +class TestFunctionalCustomFunction(unittest.TestCase): + def test_should_use_custom_function_on_select(self): + service = Table("service") + + DateDiff = CustomFunction("DATE_DIFF", ["interval", "start_date", "end_date"]) + + q = Query.from_(service).select(DateDiff("day", service.created_date, service.updated_date)) + + self.assertEqual( + 'SELECT DATE_DIFF(\'day\',"created_date","updated_date") FROM "service"', + str(q), + ) + + def test_should_fail_use_custom_function_on_select_with_wrong_arguments(self): + service = Table("service") + + DateDiff = CustomFunction("DATE_DIFF", ["interval", "start_date", "end_date"]) + + with self.assertRaises(FunctionException): + Query.from_(service).select(DateDiff("day", service.created_date)) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/test_data_types.py b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/test_data_types.py new file mode 100644 index 0000000000000000000000000000000000000000..52fb4487fe7be3ae28a4e9eb08628fba89dc0f79 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/test_data_types.py @@ -0,0 +1,15 @@ +import unittest +import uuid + +from pypika.terms import ValueWrapper + + +class StringTests(unittest.TestCase): + def test_inline_string_concatentation(self): + self.assertEqual("'it''s'", ValueWrapper("it's").get_sql()) + + +class UuidTests(unittest.TestCase): + def test_uuid_string_generation(self): + id = uuid.uuid4() + self.assertEqual("'{}'".format(id), ValueWrapper(id).get_sql()) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/test_date_math.py b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/test_date_math.py new file mode 100644 index 0000000000000000000000000000000000000000..38db8ef2f8e812a97c6980a7ec6b9a3909d804fb --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/test_date_math.py @@ -0,0 +1,179 @@ +import unittest + +from pypika import ( + Field as F, + Interval, +) +from pypika.enums import Dialects + +dt = F("dt") + + +class AddIntervalTests(unittest.TestCase): + def test_add_microsecond(self): + c = dt + Interval(microseconds=1) + + self.assertEqual("\"dt\"+INTERVAL '1 MICROSECOND'", str(c)) + + def test_add_second(self): + c = dt + Interval(seconds=1) + + self.assertEqual("\"dt\"+INTERVAL '1 SECOND'", str(c)) + + def test_add_minute(self): + c = dt + Interval(minutes=1) + + self.assertEqual("\"dt\"+INTERVAL '1 MINUTE'", str(c)) + + def test_add_day(self): + c = dt + Interval(days=1) + + self.assertEqual("\"dt\"+INTERVAL '1 DAY'", str(c)) + + def test_add_week(self): + c = dt + Interval(weeks=1) + + self.assertEqual("\"dt\"+INTERVAL '1 WEEK'", str(c)) + + def test_add_month(self): + c = dt + Interval(months=1) + + self.assertEqual("\"dt\"+INTERVAL '1 MONTH'", str(c)) + + def test_add_quarter(self): + c = dt + Interval(quarters=1) + + self.assertEqual("\"dt\"+INTERVAL '1 QUARTER'", str(c)) + + def test_add_year(self): + c = dt + Interval(years=1) + + self.assertEqual("\"dt\"+INTERVAL '1 YEAR'", str(c)) + + def test_add_default(self): + c = dt + Interval(days=0) + + self.assertEqual("\"dt\"+INTERVAL '0 DAY'", str(c)) + + +class AddIntervalMultipleUnitsTests(unittest.TestCase): + def test_add_second_microsecond(self): + c = dt + Interval(seconds=1, microseconds=1) + + self.assertEqual("\"dt\"+INTERVAL '1.1 SECOND_MICROSECOND'", str(c)) + + def test_add_minute_microsecond(self): + c = dt + Interval(minutes=1, microseconds=1) + + self.assertEqual("\"dt\"+INTERVAL '1:0.1 MINUTE_MICROSECOND'", str(c)) + + def test_add_minute_second(self): + c = dt + Interval(minutes=1, seconds=1) + + self.assertEqual("\"dt\"+INTERVAL '1:1 MINUTE_SECOND'", str(c)) + + def test_add_hour_microsecond(self): + c = dt + Interval(hours=1, microseconds=1) + + self.assertEqual("\"dt\"+INTERVAL '1:0:0.1 HOUR_MICROSECOND'", str(c)) + + def test_add_hour_second(self): + c = dt + Interval(hours=1, seconds=1) + + self.assertEqual("\"dt\"+INTERVAL '1:0:1 HOUR_SECOND'", str(c)) + + def test_add_hour_minute(self): + c = dt + Interval(hours=1, minutes=1) + + self.assertEqual("\"dt\"+INTERVAL '1:1 HOUR_MINUTE'", str(c)) + + def test_add_day_microsecond(self): + c = dt + Interval(days=1, microseconds=1) + + self.assertEqual("\"dt\"+INTERVAL '1 0:0:0.1 DAY_MICROSECOND'", str(c)) + + def test_add_day_second(self): + c = dt + Interval(days=1, seconds=1) + + self.assertEqual("\"dt\"+INTERVAL '1 0:0:1 DAY_SECOND'", str(c)) + + def test_add_day_minute(self): + c = dt + Interval(days=1, minutes=1) + + self.assertEqual("\"dt\"+INTERVAL '1 0:1 DAY_MINUTE'", str(c)) + + def test_add_day_hour(self): + c = dt + Interval(days=1, hours=1) + + self.assertEqual("\"dt\"+INTERVAL '1 1 DAY_HOUR'", str(c)) + + def test_add_year_month(self): + c = dt + Interval(years=1, months=1) + + self.assertEqual("\"dt\"+INTERVAL '1-1 YEAR_MONTH'", str(c)) + + def test_add_value_right(self): + c = Interval(microseconds=1) - dt + + self.assertEqual("INTERVAL '1 MICROSECOND'-\"dt\"", str(c)) + + def test_add_value_complex_expressions(self): + c = dt + Interval(quarters=1) + Interval(weeks=1) + + self.assertEqual("\"dt\"+INTERVAL '1 QUARTER'+INTERVAL '1 WEEK'", str(c)) + + +class DialectIntervalTests(unittest.TestCase): + def test_mysql_dialect_uses_single_quotes_around_expression_in_an_interval(self): + c = Interval(days=1).get_sql(dialect=Dialects.MYSQL) + self.assertEqual("INTERVAL '1' DAY", c) + + def test_oracle_dialect_uses_single_quotes_around_expression_in_an_interval(self): + c = Interval(days=1).get_sql(dialect=Dialects.ORACLE) + self.assertEqual("INTERVAL '1' DAY", c) + + def test_vertica_dialect_uses_single_quotes_around_interval(self): + c = Interval(days=1).get_sql(dialect=Dialects.VERTICA) + self.assertEqual("INTERVAL '1 DAY'", c) + + def test_redshift_dialect_uses_single_quotes_around_interval(self): + c = Interval(days=1).get_sql(dialect=Dialects.REDSHIFT) + self.assertEqual("INTERVAL '1 DAY'", c) + + def test_postgresql_dialect_uses_single_quotes_around_interval(self): + c = Interval(days=1).get_sql(dialect=Dialects.POSTGRESQL) + self.assertEqual("INTERVAL '1 DAY'", c) + + +class TestNegativeIntervals(unittest.TestCase): + def test_day(self): + c = Interval(days=-1).get_sql() + self.assertEqual("INTERVAL '-1 DAY'", c) + + def test_week(self): + c = Interval(weeks=-1).get_sql() + self.assertEqual("INTERVAL '-1 WEEK'", c) + + def test_month(self): + c = Interval(months=-1).get_sql() + self.assertEqual("INTERVAL '-1 MONTH'", c) + + def test_year(self): + c = Interval(years=-1).get_sql() + self.assertEqual("INTERVAL '-1 YEAR'", c) + + def test_year_month(self): + c = Interval(years=-1, months=-4).get_sql() + self.assertEqual("INTERVAL '-1-4 YEAR_MONTH'", c) + + +class TruncateTrailingZerosTests(unittest.TestCase): + def test_do_not_truncate_integer_values(self): + i = Interval(seconds=10) + + self.assertEqual("INTERVAL '10 SECOND'", str(i)) + + def test_do_not_truncate_months_between_years_and_datys(self): + i = Interval(years=10, days=10) + + self.assertEqual("INTERVAL '10-0-10 YEAR_DAY'", str(i)) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/test_deletes.py b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/test_deletes.py new file mode 100644 index 0000000000000000000000000000000000000000..09df93f5331b845b0c3aed628bf1c4a3ec6b0f02 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/test_deletes.py @@ -0,0 +1,97 @@ +import unittest + +from pypika import PostgreSQLQuery, Query, SYSTEM_TIME, Table + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + +from pypika.terms import Star + + +class DeleteTests(unittest.TestCase): + @classmethod + def setUpClass(cls) -> None: + super().setUpClass() + cls.table_abc = Table("abc") + + def test_omit_where(self): + q = Query.from_("abc").delete() + + self.assertEqual('DELETE FROM "abc"', str(q)) + + def test_omit_where__table_schema(self): + q = Query.from_(Table("abc", "schema1")).delete() + + self.assertEqual('DELETE FROM "schema1"."abc"', str(q)) + + def test_where_field_equals(self): + q1 = Query.from_(self.table_abc).where(self.table_abc.foo == self.table_abc.bar).delete() + q2 = Query.from_(self.table_abc).where(self.table_abc.foo.eq(self.table_abc.bar)).delete() + + self.assertEqual('DELETE FROM "abc" WHERE "foo"="bar"', str(q1)) + self.assertEqual('DELETE FROM "abc" WHERE "foo"="bar"', str(q2)) + + def test_for_portion(self): + with self.subTest("with system time"): + q = Query.from_(self.table_abc.for_portion(SYSTEM_TIME.from_to('2020-01-01', '2020-02-01'))).delete() + + self.assertEqual( + 'DELETE FROM "abc" FOR PORTION OF SYSTEM_TIME FROM \'2020-01-01\' TO \'2020-02-01\'', str(q) + ) + + with self.subTest("with column"): + q = Query.from_( + self.table_abc.for_portion(self.table_abc.valid_period.from_to('2020-01-01', '2020-02-01')) + ).delete() + + self.assertEqual( + 'DELETE FROM "abc" FOR PORTION OF "valid_period" FROM \'2020-01-01\' TO \'2020-02-01\'', str(q) + ) + + +class PostgresDeleteTests(unittest.TestCase): + @classmethod + def setUpClass(cls) -> None: + super().setUpClass() + cls.table_abc = Table("abc") + + def test_delete_returning(self): + q1 = ( + PostgreSQLQuery.from_(self.table_abc) + .where(self.table_abc.foo == self.table_abc.bar) + .delete() + .returning(self.table_abc.id) + ) + + self.assertEqual('DELETE FROM "abc" WHERE "foo"="bar" RETURNING "id"', str(q1)) + + def test_delete_returning_str(self): + q1 = ( + PostgreSQLQuery.from_(self.table_abc) + .where(self.table_abc.foo == self.table_abc.bar) + .delete() + .returning("id") + ) + + self.assertEqual('DELETE FROM "abc" WHERE "foo"="bar" RETURNING "id"', str(q1)) + + def test_delete_returning_star(self): + q1 = ( + PostgreSQLQuery.from_(self.table_abc) + .where(self.table_abc.foo == self.table_abc.bar) + .delete() + .returning(Star()) + ) + + self.assertEqual('DELETE FROM "abc" WHERE "foo"="bar" RETURNING *', str(q1)) + + def test_delete_using(self): + table_trash = Table('trash') + q1 = ( + PostgreSQLQuery.from_(self.table_abc) + .using(table_trash) + .where(self.table_abc.id == table_trash.abc_id) + .delete() + ) + + self.assertEqual('DELETE FROM "abc" USING "trash" WHERE "abc"."id"="trash"."abc_id"', str(q1)) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/test_drop.py b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/test_drop.py new file mode 100644 index 0000000000000000000000000000000000000000..265ae7350d2054549731f9a8c4379fdac95dc580 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/test_drop.py @@ -0,0 +1,49 @@ +import unittest + +from pypika import ( + Columns, + Database, + Query, + Tables, +) + + +class DropTableTests(unittest.TestCase): + database_xyz = Database("mydb") + new_table, existing_table = Tables("abc", "efg") + foo, bar = Columns(("a", "INT"), ("b", "VARCHAR(100)")) + + def test_drop_database(self): + q1 = Query.drop_database(self.database_xyz) + q2 = Query.drop_database(self.database_xyz).if_exists() + + self.assertEqual('DROP DATABASE "mydb"', str(q1)) + self.assertEqual('DROP DATABASE IF EXISTS "mydb"', str(q2)) + + def test_drop_table(self): + q1 = Query.drop_table(self.new_table) + q2 = Query.drop_table(self.new_table).if_exists() + + self.assertEqual('DROP TABLE "abc"', str(q1)) + self.assertEqual('DROP TABLE IF EXISTS "abc"', str(q2)) + + def test_drop_user(self): + q1 = Query.drop_user("myuser") + q2 = Query.drop_user("myuser").if_exists() + + self.assertEqual('DROP USER "myuser"', str(q1)) + self.assertEqual('DROP USER IF EXISTS "myuser"', str(q2)) + + def test_drop_view(self): + q1 = Query.drop_view("myview") + q2 = Query.drop_view("myview").if_exists() + + self.assertEqual('DROP VIEW "myview"', str(q1)) + self.assertEqual('DROP VIEW IF EXISTS "myview"', str(q2)) + + def test_drop_index(self): + q1 = Query.drop_index("myindex") + q2 = Query.drop_index("myindex").if_exists() + + self.assertEqual('DROP INDEX "myindex"', str(q1)) + self.assertEqual('DROP INDEX IF EXISTS "myindex"', str(q2)) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/test_formats.py b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/test_formats.py new file mode 100644 index 0000000000000000000000000000000000000000..6a442757c6659a215661e03f1ca9c3771d394d96 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/test_formats.py @@ -0,0 +1,68 @@ +import unittest + +from pypika import Query, Tables, functions as fn + + +class QuoteTests(unittest.TestCase): + maxDiff = None + + table_abc, table_efg = Tables("abc", "efg") + + def setUp(self): + subquery1 = ( + Query.from_(self.table_abc) + .select( + self.table_abc.foo, + fn.Sum(self.table_abc.fizz + self.table_abc.buzz).as_("fizzbuzz"), + ) + .groupby(self.table_abc.foo) + ) + + subquery2 = Query.from_(self.table_efg).select( + self.table_efg.foo.as_("foo_two"), + self.table_efg.bar, + ) + + self.query = ( + Query.from_(subquery1) + .select(subquery1.foo, subquery1.fizzbuzz) + .join(subquery2) + .on(subquery1.foo == subquery2.foo_two) + .select(subquery2.foo_two, subquery2.bar) + ) + + def test_replace_quote_char_in_complex_query(self): + self.assertEqual( + "SELECT " + "`sq0`.`foo`,`sq0`.`fizzbuzz`," + "`sq1`.`foo_two`,`sq1`.`bar` " + "FROM (" + "SELECT " + "`foo`,SUM(`fizz`+`buzz`) `fizzbuzz` " + "FROM `abc` " + "GROUP BY `foo`" + ") `sq0` JOIN (" + "SELECT " + "`foo` `foo_two`,`bar` " + "FROM `efg`" + ") `sq1` ON `sq0`.`foo`=`sq1`.`foo_two`", + self.query.get_sql(quote_char="`"), + ) + + def test_no_quote_char_in_complex_query(self): + self.assertEqual( + "SELECT " + "sq0.foo,sq0.fizzbuzz," + "sq1.foo_two,sq1.bar " + "FROM (" + "SELECT " + "foo,SUM(fizz+buzz) fizzbuzz " + "FROM abc " + "GROUP BY foo" + ") sq0 JOIN (" + "SELECT " + "foo foo_two,bar " + "FROM efg" + ") sq1 ON sq0.foo=sq1.foo_two", + self.query.get_sql(quote_char=None), + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/test_functions.py b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/test_functions.py new file mode 100644 index 0000000000000000000000000000000000000000..f526966eefc554ec68d0e15fb69de7d69f1604c3 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/test_functions.py @@ -0,0 +1,847 @@ +import unittest + +from pypika import ( + Case, + CaseException, + DatePart, + Field as F, + Query, + Query as Q, + Schema, + Table as T, + VerticaQuery, + functions as fn, +) +from pypika.enums import Dialects, SqlTypes + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + + +class FunctionTests(unittest.TestCase): + def test_dialect_propagation(self): + func = fn.Function("func", ["a"], ["b"]) + self.assertEqual("func(ARRAY['a'],ARRAY['b'])", func.get_sql(dialect=Dialects.POSTGRESQL)) + + def test_is_aggregate_None_for_non_aggregate_function_or_function_with_no_aggregate_functions(self): + self.assertIsNone(fn.Coalesce('a', 0).is_aggregate) + self.assertIsNone(fn.Coalesce(fn.NullIf('a', 0), 0).is_aggregate) + + def test_is_aggregate_True_for_aggregate_function_or_function_with_aggregate_functions(self): + self.assertTrue(fn.Sum('a').is_aggregate) + self.assertTrue(fn.Coalesce(fn.Avg('a'), 0).is_aggregate) + self.assertTrue(fn.Coalesce(fn.NullIf(fn.Sum('a'), 0), 0).is_aggregate) + + +class SchemaTests(unittest.TestCase): + def test_schema_no_schema_in_sql_when_none_set(self): + func = fn.Function("my_proc", 1, 2, 3) + + self.assertEqual("my_proc(1,2,3)", func.get_sql(quote_char='"')) + + def test_schema_included_in_function_sql(self): + a = Schema("a") + func = fn.Function("my_proc", 1, 2, 3, schema=a) + + self.assertEqual('"a".my_proc(1,2,3)', func.get_sql(quote_char='"')) + + +class ArithmeticTests(unittest.TestCase): + t = T("abc") + + def test__addition__fields(self): + q1 = Q.from_("abc").select(F("a") + F("b")) + q2 = Q.from_(self.t).select(self.t.a + self.t.b) + + self.assertEqual('SELECT "a"+"b" FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"+"b" FROM "abc"', str(q2)) + + def test__addition__number(self): + q1 = Q.from_("abc").select(F("a") + 1) + q2 = Q.from_(self.t).select(self.t.a + 1) + + self.assertEqual('SELECT "a"+1 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"+1 FROM "abc"', str(q2)) + + def test__addition__decimal(self): + q1 = Q.from_("abc").select(F("a") + 1.0) + q2 = Q.from_(self.t).select(self.t.a + 1.0) + + self.assertEqual('SELECT "a"+1.0 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"+1.0 FROM "abc"', str(q2)) + + def test__addition__right(self): + q1 = Q.from_("abc").select(1 + F("a")) + q2 = Q.from_(self.t).select(1 + self.t.a) + + self.assertEqual('SELECT 1+"a" FROM "abc"', str(q1)) + self.assertEqual('SELECT 1+"a" FROM "abc"', str(q2)) + + def test__subtraction__fields(self): + q1 = Q.from_("abc").select(F("a") - F("b")) + q2 = Q.from_(self.t).select(self.t.a - self.t.b) + + self.assertEqual('SELECT "a"-"b" FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"-"b" FROM "abc"', str(q2)) + + def test__subtraction__number(self): + q1 = Q.from_("abc").select(F("a") - 1) + q2 = Q.from_(self.t).select(self.t.a - 1) + + self.assertEqual('SELECT "a"-1 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"-1 FROM "abc"', str(q2)) + + def test__subtraction__decimal(self): + q1 = Q.from_("abc").select(F("a") - 1.0) + q2 = Q.from_(self.t).select(self.t.a - 1.0) + + self.assertEqual('SELECT "a"-1.0 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"-1.0 FROM "abc"', str(q2)) + + def test__subtraction__right(self): + q1 = Q.from_("abc").select(1 - F("a")) + q2 = Q.from_(self.t).select(1 - self.t.a) + + self.assertEqual('SELECT 1-"a" FROM "abc"', str(q1)) + self.assertEqual('SELECT 1-"a" FROM "abc"', str(q2)) + + def test__multiplication__fields(self): + q1 = Q.from_("abc").select(F("a") * F("b")) + q2 = Q.from_(self.t).select(self.t.a * self.t.b) + + self.assertEqual('SELECT "a"*"b" FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"*"b" FROM "abc"', str(q2)) + + def test__multiplication__number(self): + q1 = Q.from_("abc").select(F("a") * 1) + q2 = Q.from_(self.t).select(self.t.a * 1) + + self.assertEqual('SELECT "a"*1 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"*1 FROM "abc"', str(q2)) + + def test__multiplication__decimal(self): + q1 = Q.from_("abc").select(F("a") * 1.0) + q2 = Q.from_(self.t).select(self.t.a * 1.0) + + self.assertEqual('SELECT "a"*1.0 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"*1.0 FROM "abc"', str(q2)) + + def test__multiplication__right(self): + q1 = Q.from_("abc").select(1 * F("a")) + q2 = Q.from_(self.t).select(1 * self.t.a) + + self.assertEqual('SELECT 1*"a" FROM "abc"', str(q1)) + self.assertEqual('SELECT 1*"a" FROM "abc"', str(q2)) + + def test__division__fields(self): + q1 = Q.from_("abc").select(F("a") / F("b")) + q2 = Q.from_(self.t).select(self.t.a / self.t.b) + + self.assertEqual('SELECT "a"/"b" FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"/"b" FROM "abc"', str(q2)) + + def test__division__number(self): + q1 = Q.from_("abc").select(F("a") / 1) + q2 = Q.from_(self.t).select(self.t.a / 1) + + self.assertEqual('SELECT "a"/1 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"/1 FROM "abc"', str(q2)) + + def test__division__decimal(self): + q1 = Q.from_("abc").select(F("a") / 1.0) + q2 = Q.from_(self.t).select(self.t.a / 1.0) + + self.assertEqual('SELECT "a"/1.0 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"/1.0 FROM "abc"', str(q2)) + + def test__division__right(self): + q1 = Q.from_("abc").select(1 / F("a")) + q2 = Q.from_(self.t).select(1 / self.t.a) + + self.assertEqual('SELECT 1/"a" FROM "abc"', str(q1)) + self.assertEqual('SELECT 1/"a" FROM "abc"', str(q2)) + + def test__leftshift__fields(self): + q1 = Q.from_("abc").select(F("a") << F("b")) + q2 = Q.from_(self.t).select(self.t.a << self.t.b) + + self.assertEqual('SELECT "a"<<"b" FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"<<"b" FROM "abc"', str(q2)) + + def test__leftshift__number(self): + q1 = Q.from_("abc").select(F('a') << 2) + q2 = Q.from_(self.t).select(self.t.a << 2) + + self.assertEqual('SELECT "a"<<2 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"<<2 FROM "abc"', str(q2)) + + def test__leftshift__right(self): + q1 = Q.from_("abc").select(1 << F("a")) + q2 = Q.from_(self.t).select(1 << self.t.a) + + self.assertEqual('SELECT 1<<"a" FROM "abc"', str(q1)) + self.assertEqual('SELECT 1<<"a" FROM "abc"', str(q2)) + + def test__rightshift__fields(self): + q1 = Q.from_("abc").select(F("a") >> F("b")) + q2 = Q.from_(self.t).select(self.t.a >> self.t.b) + + self.assertEqual('SELECT "a">>"b" FROM "abc"', str(q1)) + self.assertEqual('SELECT "a">>"b" FROM "abc"', str(q2)) + + def test__rightshift__number(self): + q1 = Q.from_("abc").select(F('a') >> 2) + q2 = Q.from_(self.t).select(self.t.a >> 2) + + self.assertEqual('SELECT "a">>2 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a">>2 FROM "abc"', str(q2)) + + def test__rightshift__right(self): + q1 = Q.from_("abc").select(1 >> F("a")) + q2 = Q.from_(self.t).select(1 >> self.t.a) + + self.assertEqual('SELECT 1>>"a" FROM "abc"', str(q1)) + self.assertEqual('SELECT 1>>"a" FROM "abc"', str(q2)) + + def test__complex_op(self): + q1 = Q.from_("abc").select(2 + 1 / F("a") - 5) + q2 = Q.from_(self.t).select(2 + 1 / self.t.a - 5) + + self.assertEqual('SELECT 2+1/"a"-5 FROM "abc"', str(q1)) + self.assertEqual('SELECT 2+1/"a"-5 FROM "abc"', str(q2)) + + def test__complex_op_add_parentheses(self): + q1 = Q.from_("abc").select((F("a") + 1) + (F("b") - 5)) + q2 = Q.from_(self.t).select((self.t.a + 1) + (self.t.b - 5)) + q3 = Q.from_("abc").select((F("a") / 1) + (F("b") / 5)) + q4 = Q.from_(self.t).select((self.t.a / 1) + (self.t.b / 5)) + + self.assertEqual('SELECT "a"+1+"b"-5 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"+1+"b"-5 FROM "abc"', str(q2)) + self.assertEqual('SELECT "a"/1+"b"/5 FROM "abc"', str(q3)) + self.assertEqual('SELECT "a"/1+"b"/5 FROM "abc"', str(q4)) + + def test__complex_op_sub_parentheses(self): + q1 = Q.from_("abc").select((F("a") + 1) - (F("b") - 5)) + q2 = Q.from_(self.t).select((self.t.a + 1) - (self.t.b - 5)) + q3 = Q.from_("abc").select((F("a") / 1) - (F("b") / 5)) + q4 = Q.from_(self.t).select((self.t.a / 1) - (self.t.b / 5)) + + self.assertEqual('SELECT "a"+1-("b"-5) FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"+1-("b"-5) FROM "abc"', str(q2)) + self.assertEqual('SELECT "a"/1-"b"/5 FROM "abc"', str(q3)) + self.assertEqual('SELECT "a"/1-"b"/5 FROM "abc"', str(q4)) + + def test__complex_op_mul_parentheses(self): + q1 = Q.from_("abc").select((F("a") + 1) * (F("b") - 5)) + q2 = Q.from_(self.t).select((self.t.a + 1) * (self.t.b - 5)) + q3 = Q.from_("abc").select((F("a") / 1) * (F("b") - 5)) + q4 = Q.from_(self.t).select((self.t.a / 1) * (self.t.b - 5)) + q5 = Q.from_("abc").select((F("a") + 1) * (F("b") / 5)) + q6 = Q.from_(self.t).select((self.t.a + 1) * (self.t.b / 5)) + + self.assertEqual('SELECT ("a"+1)*("b"-5) FROM "abc"', str(q1)) + self.assertEqual('SELECT ("a"+1)*("b"-5) FROM "abc"', str(q2)) + self.assertEqual('SELECT "a"/1*("b"-5) FROM "abc"', str(q3)) + self.assertEqual('SELECT "a"/1*("b"-5) FROM "abc"', str(q4)) + self.assertEqual('SELECT ("a"+1)*"b"/5 FROM "abc"', str(q5)) + self.assertEqual('SELECT ("a"+1)*"b"/5 FROM "abc"', str(q6)) + + def test__complex_op_mul_no_parentheses(self): + q = Q.from_("abc").select(F("a") + 1 * F("b") - 5) + + self.assertEqual('SELECT "a"+1*"b"-5 FROM "abc"', str(q)) + + def test__complex_op_div_parentheses(self): + q1 = Q.from_("abc").select((F("a") + 1) / (F("b") - 5)) + q2 = Q.from_(self.t).select((self.t.a + 1) / (self.t.b - 5)) + q3 = Q.from_("abc").select((F("a") / 1) / (F("b") - 5)) + q4 = Q.from_(self.t).select((self.t.a / 1) / (self.t.b - 5)) + q5 = Q.from_("abc").select((F("a") + 1) / (F("b") * 5)) + q6 = Q.from_(self.t).select((self.t.a + 1) / (self.t.b * 5)) + + self.assertEqual('SELECT ("a"+1)/("b"-5) FROM "abc"', str(q1)) + self.assertEqual('SELECT ("a"+1)/("b"-5) FROM "abc"', str(q2)) + self.assertEqual('SELECT "a"/1/("b"-5) FROM "abc"', str(q3)) + self.assertEqual('SELECT "a"/1/("b"-5) FROM "abc"', str(q4)) + self.assertEqual('SELECT ("a"+1)/("b"*5) FROM "abc"', str(q5)) + self.assertEqual('SELECT ("a"+1)/("b"*5) FROM "abc"', str(q6)) + + def test__complex_op_div_no_parentheses(self): + q = Q.from_("abc").select(F("a") + 1 / F("b") - 5) + + self.assertEqual('SELECT "a"+1/"b"-5 FROM "abc"', str(q)) + + def test__complex_op_exponent_parentheses(self): + q1 = Q.from_("abc").select(F("a") / (F("b") ** 2)) + q2 = Q.from_(self.t).select(self.t.a / (self.t.b**2)) + q3 = Q.from_("abc").select(F("a") ** (F("b") / 2)) + q4 = Q.from_(self.t).select(self.t.a ** (self.t.b / 2)) + q5 = Q.from_("abc").select((F("a") ** F("b")) ** 2) + q6 = Q.from_(self.t).select((self.t.a**self.t.b) ** 2) + + self.assertEqual('SELECT "a"/POW("b",2) FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"/POW("b",2) FROM "abc"', str(q2)) + self.assertEqual('SELECT POW("a","b"/2) FROM "abc"', str(q3)) + self.assertEqual('SELECT POW("a","b"/2) FROM "abc"', str(q4)) + self.assertEqual('SELECT POW(POW("a","b"),2) FROM "abc"', str(q5)) + self.assertEqual('SELECT POW(POW("a","b"),2) FROM "abc"', str(q6)) + + def test__complex_op_exponent_no_parentheses(self): + q1 = Q.from_("abc").select(F("a") ** F("b") ** 2) + q2 = Q.from_(self.t).select(self.t.a**self.t.b**2) + q3 = Q.from_("abc").select(F("a") / F("b") ** 2) + q4 = Q.from_(self.t).select(self.t.a / self.t.b**2) + + self.assertEqual('SELECT POW("a",POW("b",2)) FROM "abc"', str(q1)) + self.assertEqual('SELECT POW("a",POW("b",2)) FROM "abc"', str(q2)) + self.assertEqual('SELECT "a"/POW("b",2) FROM "abc"', str(q3)) + self.assertEqual('SELECT "a"/POW("b",2) FROM "abc"', str(q4)) + + def test__complex_op_function_parentheses(self): + q1 = Q.from_("abc").select(F("a") / (fn.Sum(F("b")) / 2)) + q2 = Q.from_("abc").select(self.t.a / (fn.Sum(self.t.b) / 2)) + q3 = Q.from_("abc").select(fn.Sum(F("a") / (F("b") / 2))) + q4 = Q.from_("abc").select(fn.Sum(self.t.a / (self.t.b / 2))) + + self.assertEqual('SELECT "a"/(SUM("b")/2) FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"/(SUM("b")/2) FROM "abc"', str(q2)) + self.assertEqual('SELECT SUM("a"/("b"/2)) FROM "abc"', str(q3)) + self.assertEqual('SELECT SUM("a"/("b"/2)) FROM "abc"', str(q4)) + + def test__complex_op_modulus_parentheses(self): + q1 = Q.from_("abc").select(F("a") / (F("b") % 2)) + q2 = Q.from_(self.t).select(self.t.a / (self.t.b % 2)) + q3 = Q.from_("abc").select(F("a") % (F("b") / 2)) + q4 = Q.from_(self.t).select(self.t.a % (self.t.b / 2)) + q5 = Q.from_("abc").select(F("a") % (F("b") % 2)) + q6 = Q.from_("abc").select(self.t.a % (self.t.b % 2)) + + self.assertEqual('SELECT "a"/MOD("b",2) FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"/MOD("b",2) FROM "abc"', str(q2)) + self.assertEqual('SELECT MOD("a","b"/2) FROM "abc"', str(q3)) + self.assertEqual('SELECT MOD("a","b"/2) FROM "abc"', str(q4)) + self.assertEqual('SELECT MOD("a",MOD("b",2)) FROM "abc"', str(q5)) + self.assertEqual('SELECT MOD("a",MOD("b",2)) FROM "abc"', str(q6)) + + def test__complex_op_modulus_no_parentheses(self): + q1 = Q.from_("abc").select(F("a") % F("b") % 2) + q2 = Q.from_(self.t).select(self.t.a % self.t.b % 2) + q3 = Q.from_("abc").select(F("a") / F("b") % 2) + q4 = Q.from_(self.t).select(self.t.a / self.t.b % 2) + + self.assertEqual('SELECT MOD(MOD("a","b"),2) FROM "abc"', str(q1)) + self.assertEqual('SELECT MOD(MOD("a","b"),2) FROM "abc"', str(q2)) + self.assertEqual('SELECT MOD("a"/"b",2) FROM "abc"', str(q3)) + self.assertEqual('SELECT MOD("a"/"b",2) FROM "abc"', str(q4)) + + def test__complex_op_floor_parentheses(self): + q1 = Q.from_("abc").select(F("a") / (fn.Floor(F("b")) / 2)) + q2 = Q.from_("abc").select(self.t.a / (fn.Floor(self.t.b) / 2)) + q3 = Q.from_("abc").select(fn.Floor(F("a") / (F("b") / 2))) + q4 = Q.from_("abc").select(fn.Floor(self.t.a / (self.t.b / 2))) + + self.assertEqual('SELECT "a"/(FLOOR("b")/2) FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"/(FLOOR("b")/2) FROM "abc"', str(q2)) + self.assertEqual('SELECT FLOOR("a"/("b"/2)) FROM "abc"', str(q3)) + self.assertEqual('SELECT FLOOR("a"/("b"/2)) FROM "abc"', str(q4)) + + def test__complex_op_nested_parentheses(self): + q1 = Q.from_("abc").select(F("a") / (F("b") / ((F("c") / 2)))) + q2 = Q.from_("abc").select(self.t.a / (self.t.b / ((self.t.c / 2)))) + + self.assertEqual('SELECT "a"/("b"/("c"/2)) FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"/("b"/("c"/2)) FROM "abc"', str(q2)) + + def test__arithmetic_equality(self): + q1 = Q.from_("abc").select(F("a") / 2 == 2) + q2 = Q.from_(self.t).select(self.t.a / 2 == 2) + + self.assertEqual('SELECT "a"/2=2 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"/2=2 FROM "abc"', str(q2)) + + def test__arithmetic_with_function(self): + q1 = Q.from_("abc").select(fn.Sum(F("foo")) + 1) + q2 = Q.from_(self.t).select(fn.Sum(self.t.foo) + 1) + + self.assertEqual('SELECT SUM("foo")+1 FROM "abc"', str(q1)) + self.assertEqual('SELECT SUM("foo")+1 FROM "abc"', str(q2)) + + def test__exponent__number(self): + q1 = Q.from_("abc").select(F("a") ** 2) + q2 = Q.from_(self.t).select(self.t.a**2) + + self.assertEqual('SELECT POW("a",2) FROM "abc"', str(q1)) + self.assertEqual('SELECT POW("a",2) FROM "abc"', str(q2)) + + def test__exponent__decimal(self): + q1 = Q.from_("abc").select(F("a") ** 0.5) + q2 = Q.from_(self.t).select(self.t.a**0.5) + + self.assertEqual('SELECT POW("a",0.5) FROM "abc"', str(q1)) + self.assertEqual('SELECT POW("a",0.5) FROM "abc"', str(q2)) + + def test__modulus__number(self): + q1 = Q.from_("abc").select(F("a") % 2) + q2 = Q.from_(self.t).select(self.t.a % 2) + + self.assertEqual('SELECT MOD("a",2) FROM "abc"', str(q1)) + self.assertEqual('SELECT MOD("a",2) FROM "abc"', str(q2)) + + def test__floor(self): + q1 = Q.from_("abc").select(fn.Floor(F("foo"))) + q2 = Q.from_(self.t).select(fn.Floor(self.t.foo)) + + self.assertEqual('SELECT FLOOR("foo") FROM "abc"', str(q1)) + self.assertEqual('SELECT FLOOR("foo") FROM "abc"', str(q2)) + + +class AggregationTests(unittest.TestCase): + def test__count(self): + q = Q.from_("abc").select(fn.Count(F("foo"))) + + self.assertEqual('SELECT COUNT("foo") FROM "abc"', str(q)) + + def test__count__star(self): + q = Q.from_("abc").select(fn.Count("*")) + + self.assertEqual('SELECT COUNT(*) FROM "abc"', str(q)) + + def test__sum(self): + q = Q.from_("abc").select(fn.Sum(F("foo"))) + + self.assertEqual('SELECT SUM("foo") FROM "abc"', str(q)) + + def test__avg(self): + q = Q.from_("abc").select(fn.Avg(F("foo"))) + + self.assertEqual('SELECT AVG("foo") FROM "abc"', str(q)) + + def test__first(self): + q = Q.from_("abc").select(fn.First(F("foo"))) + + self.assertEqual('SELECT FIRST("foo") FROM "abc"', str(q)) + + def test__last(self): + q = Q.from_("abc").select(fn.Last(F("foo"))) + + self.assertEqual('SELECT LAST("foo") FROM "abc"', str(q)) + + def test__min(self): + q = Q.from_("abc").select(fn.Min(F("foo"))) + + self.assertEqual('SELECT MIN("foo") FROM "abc"', str(q)) + + def test__max(self): + q = Q.from_("abc").select(fn.Max(F("foo"))) + + self.assertEqual('SELECT MAX("foo") FROM "abc"', str(q)) + + def test__std(self): + q = Q.from_("abc").select(fn.Std(F("foo"))) + + self.assertEqual('SELECT STD("foo") FROM "abc"', str(q)) + + def test__stddev(self): + q = Q.from_("abc").select(fn.StdDev(F("foo"))) + + self.assertEqual('SELECT STDDEV("foo") FROM "abc"', str(q)) + + def test__approx_percentile(self): + q = Q.from_("abc").select(fn.ApproximatePercentile(F("foo"), 0.5)) + + self.assertEqual( + 'SELECT APPROXIMATE_PERCENTILE("foo" USING PARAMETERS percentile=0.5) FROM "abc"', + str(q), + ) + + def test__subquery_in_params_functions(self): + subquery = Query.from_('table').select('id') + func = fn.Function('func', 'id', subquery) + self.assertEqual("func('id',(SELECT id FROM table))", func.get_sql()) + + +class ConditionTests(unittest.TestCase): + def test__case__raw(self): + q = Q.from_("abc").select(Case().when(F("foo") == 1, "a")) + + self.assertEqual('SELECT CASE WHEN "foo"=1 THEN \'a\' END FROM "abc"', str(q)) + + def test__case__else(self): + q = Q.from_("abc").select(Case().when(F("foo") == 1, "a").else_("b")) + + self.assertEqual("SELECT CASE WHEN \"foo\"=1 THEN 'a' ELSE 'b' END FROM \"abc\"", str(q)) + + def test__case__field(self): + q = Q.from_("abc").select(Case().when(F("foo") == 1, F("bar")).else_(F("buz"))) + + self.assertEqual('SELECT CASE WHEN "foo"=1 THEN "bar" ELSE "buz" END FROM "abc"', str(q)) + + def test__case__multi(self): + q = Q.from_("abc").select(Case().when(F("foo") > 0, F("fiz")).when(F("bar") <= 0, F("buz")).else_(1)) + + self.assertEqual( + 'SELECT CASE WHEN "foo">0 THEN "fiz" WHEN "bar"<=0 THEN "buz" ELSE 1 END FROM "abc"', + str(q), + ) + + def test__case__no_cases(self): + with self.assertRaises(CaseException): + q = Q.from_("abc").select(Case()) + + str(q) + + +class StringTests(unittest.TestCase): + t = T("abc") + + def test__ascii__str(self): + q = Q.select(fn.Ascii("2")) + + self.assertEqual("SELECT ASCII('2')", str(q)) + + def test__ascii__int(self): + q = Q.select(fn.Ascii(2)) + + self.assertEqual("SELECT ASCII(2)", str(q)) + + def test__ascii__field(self): + q = Q.from_(self.t).select(fn.Ascii(self.t.foo)) + + self.assertEqual('SELECT ASCII("foo") FROM "abc"', str(q)) + + def test__bin__str(self): + q = Q.select(fn.Bin("2")) + + self.assertEqual("SELECT BIN('2')", str(q)) + + def test__bin__int(self): + q = Q.select(fn.Bin(2)) + + self.assertEqual("SELECT BIN(2)", str(q)) + + def test__bin__field(self): + q = Q.from_(self.t).select(fn.Bin(self.t.foo)) + + self.assertEqual('SELECT BIN("foo") FROM "abc"', str(q)) + + def test__concat__str(self): + q = Q.select(fn.Concat("p", "y", "q", "b")) + + self.assertEqual("SELECT CONCAT('p','y','q','b')", str(q)) + + def test__concat__field(self): + q = Q.from_(self.t).select(fn.Concat(self.t.foo, self.t.bar)) + + self.assertEqual('SELECT CONCAT("foo","bar") FROM "abc"', str(q)) + + def test__insert__str(self): + q = Q.select(fn.Insert("Quadratic", 3, 4, "What")) + + self.assertEqual("SELECT INSERT('Quadratic',3,4,'What')", str(q)) + + def test__insert__field(self): + q = Q.from_(self.t).select(fn.Insert(self.t.foo, 3, 4, self.t.bar)) + + self.assertEqual('SELECT INSERT("foo",3,4,"bar") FROM "abc"', str(q)) + + def test__lower__str(self): + q = Q.select(fn.Lower("ABC")) + + self.assertEqual("SELECT LOWER('ABC')", str(q)) + + def test__lower__field(self): + q = Q.from_(self.t).select(fn.Lower(self.t.foo)) + + self.assertEqual('SELECT LOWER("foo") FROM "abc"', str(q)) + + def test__length__str(self): + q = Q.select(fn.Length("ABC")) + + self.assertEqual("SELECT LENGTH('ABC')", str(q)) + + def test__length__field(self): + q = Q.from_(self.t).select(fn.Length(self.t.foo)) + + self.assertEqual('SELECT LENGTH("foo") FROM "abc"', str(q)) + + def test__substring(self): + q = Q.from_(self.t).select(fn.Substring(self.t.foo, 2, 6)) + + self.assertEqual('SELECT SUBSTRING("foo",2,6) FROM "abc"', str(q)) + + def test__replace__str(self): + q = Q.select(fn.Replace("ABC_DEF", "_", " ")) + self.assertEqual("SELECT REPLACE('ABC_DEF','_',' ')", str(q)) + + def test__replace__field(self): + q = Q.from_(self.t).select(fn.Replace(self.t.foobar, self.t.foo, self.t.bar)) + self.assertEqual('SELECT REPLACE("foobar","foo","bar") FROM "abc"', str(q)) + + +class SplitPartFunctionTests(unittest.TestCase): + t = T("abc") + + def test__split_part(self): + q = VerticaQuery.from_(self.t).select(fn.SplitPart(self.t.foo, "|", 3)) + + self.assertEqual('SELECT SPLIT_PART("foo",\'|\',3) FROM "abc"', str(q)) + + +class RegexpLikeFunctionTests(unittest.TestCase): + t = T("abc") + + def test__regexp_like(self): + q = VerticaQuery.from_(self.t).select(fn.RegexpLike(self.t.foo, "^a", "x")) + + self.assertEqual("SELECT REGEXP_LIKE(\"foo\",'^a','x') FROM \"abc\"", str(q)) + + +class CastTests(unittest.TestCase): + t = T("abc") + + def test__cast__as(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.UNSIGNED)) + + self.assertEqual('SELECT CAST("foo" AS UNSIGNED) FROM "abc"', str(q)) + + def test__cast__signed(self): + q1 = Q.from_(self.t).select(fn.Signed(self.t.foo)) + q2 = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.SIGNED)) + + self.assertEqual('SELECT CAST("foo" AS SIGNED) FROM "abc"', str(q1)) + self.assertEqual('SELECT CAST("foo" AS SIGNED) FROM "abc"', str(q2)) + + def test__cast__unsigned(self): + q1 = Q.from_(self.t).select(fn.Unsigned(self.t.foo)) + q2 = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.UNSIGNED)) + + self.assertEqual('SELECT CAST("foo" AS UNSIGNED) FROM "abc"', str(q1)) + self.assertEqual('SELECT CAST("foo" AS UNSIGNED) FROM "abc"', str(q2)) + + def test__cast__date(self): + q1 = Q.from_(self.t).select(fn.Date(self.t.foo)) + q2 = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.DATE)) + + self.assertEqual('SELECT DATE("foo") FROM "abc"', str(q1)) + self.assertEqual('SELECT CAST("foo" AS DATE) FROM "abc"', str(q2)) + + def test__cast__timestamp(self): + q1 = Q.from_(self.t).select(fn.Timestamp(self.t.foo)) + q2 = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.TIMESTAMP)) + + self.assertEqual('SELECT TIMESTAMP("foo") FROM "abc"', str(q1)) + self.assertEqual('SELECT CAST("foo" AS TIMESTAMP) FROM "abc"', str(q2)) + + def test__cast__char(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.CHAR)) + + self.assertEqual('SELECT CAST("foo" AS CHAR) FROM "abc"', str(q)) + + def test__cast__char_with_arg(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.VARCHAR(24))) + + self.assertEqual('SELECT CAST("foo" AS VARCHAR(24)) FROM "abc"', str(q)) + + def test__cast__varchar(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.VARCHAR)) + + self.assertEqual('SELECT CAST("foo" AS VARCHAR) FROM "abc"', str(q)) + + def test__cast__varchar_with_arg(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.VARCHAR(24))) + + self.assertEqual('SELECT CAST("foo" AS VARCHAR(24)) FROM "abc"', str(q)) + + def test__cast__long_varchar(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.LONG_VARCHAR)) + + self.assertEqual('SELECT CAST("foo" AS LONG VARCHAR) FROM "abc"', str(q)) + + def test__cast__long_varchar_with_arg(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.LONG_VARCHAR(24))) + + self.assertEqual('SELECT CAST("foo" AS LONG VARCHAR(24)) FROM "abc"', str(q)) + + def test__cast__binary(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.BINARY)) + + self.assertEqual('SELECT CAST("foo" AS BINARY) FROM "abc"', str(q)) + + def test__cast__binary_with_arg(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.BINARY(24))) + + self.assertEqual('SELECT CAST("foo" AS BINARY(24)) FROM "abc"', str(q)) + + def test__cast__varbinary(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.VARBINARY)) + + self.assertEqual('SELECT CAST("foo" AS VARBINARY) FROM "abc"', str(q)) + + def test__cast__varbinary_with_arg(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.VARBINARY(24))) + + self.assertEqual('SELECT CAST("foo" AS VARBINARY(24)) FROM "abc"', str(q)) + + def test__cast__long_varbinary(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.LONG_VARBINARY)) + + self.assertEqual('SELECT CAST("foo" AS LONG VARBINARY) FROM "abc"', str(q)) + + def test__cast__long_varbinary_with_arg(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.LONG_VARBINARY(24))) + + self.assertEqual('SELECT CAST("foo" AS LONG VARBINARY(24)) FROM "abc"', str(q)) + + def test__cast__boolean(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.BOOLEAN)) + + self.assertEqual('SELECT CAST("foo" AS BOOLEAN) FROM "abc"', str(q)) + + def test__cast__integer(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.INTEGER)) + + self.assertEqual('SELECT CAST("foo" AS INTEGER) FROM "abc"', str(q)) + + def test__cast__float(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.FLOAT)) + + self.assertEqual('SELECT CAST("foo" AS FLOAT) FROM "abc"', str(q)) + + def test__cast__numeric(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.NUMERIC)) + + self.assertEqual('SELECT CAST("foo" AS NUMERIC) FROM "abc"', str(q)) + + def test__tochar__(self): + q = Q.from_(self.t).select(fn.ToChar(self.t.foo, "SomeFormat")) + + self.assertEqual('SELECT TO_CHAR("foo",\'SomeFormat\') FROM "abc"', str(q)) + + +class DateFunctionsTests(unittest.TestCase): + dt = F("dt") + t = T("abc") + t2 = T("efg") + + def _test_extract_datepart(self, date_part): + q = Q.from_(self.t).select(fn.Extract(date_part, self.t.foo)) + + value = getattr(date_part, 'value', date_part) + self.assertEqual('SELECT EXTRACT(%s FROM "foo") FROM "abc"' % value, str(q)) + + def test_extract_microsecond(self): + self._test_extract_datepart(DatePart.microsecond) + self._test_extract_datepart(DatePart.microsecond.value) + + def test_extract_second(self): + self._test_extract_datepart(DatePart.second) + self._test_extract_datepart(DatePart.second.value) + + def test_extract_minute(self): + self._test_extract_datepart(DatePart.minute) + self._test_extract_datepart(DatePart.minute.value) + + def test_extract_hour(self): + self._test_extract_datepart(DatePart.hour) + self._test_extract_datepart(DatePart.hour.value) + + def test_extract_day(self): + self._test_extract_datepart(DatePart.day) + self._test_extract_datepart(DatePart.day.value) + + def test_extract_week(self): + self._test_extract_datepart(DatePart.week) + self._test_extract_datepart(DatePart.week.value) + + def test_extract_month(self): + self._test_extract_datepart(DatePart.month) + self._test_extract_datepart(DatePart.month.value) + + def test_extract_quarter(self): + self._test_extract_datepart(DatePart.quarter) + self._test_extract_datepart(DatePart.quarter.value) + + def test_extract_year(self): + self._test_extract_datepart(DatePart.year) + self._test_extract_datepart(DatePart.year.value) + + def test_extract_join(self): + q = Q.from_(self.t).join(self.t2).on(self.t.id == self.t2.t_id).select(fn.Extract(DatePart.year, self.t.foo)) + + self.assertEqual( + 'SELECT EXTRACT(YEAR FROM "abc"."foo") FROM "abc" ' 'JOIN "efg" ON "abc"."id"="efg"."t_id"', str(q) + ) + + def test_timestampadd(self): + a = fn.TimestampAdd("year", 1, "2017-10-01") + self.assertEqual(str(a), "TIMESTAMPADD(year,1,'2017-10-01')") + + def test_time_diff(self): + a = fn.TimeDiff("18:00:00", "10:00:00") + self.assertEqual(str(a), "TIMEDIFF('18:00:00','10:00:00')") + + def test_date_add(self): + a = fn.DateAdd("year", 1, "2017-10-01") + self.assertEqual(str(a), "DATE_ADD(year,1,'2017-10-01')") + + def test_now(self): + query = Query.select(fn.Now()) + + self.assertEqual("SELECT NOW()", str(query)) + + def test_utc_timestamp(self): + query = Query.select(fn.UtcTimestamp()) + + self.assertEqual("SELECT UTC_TIMESTAMP()", str(query)) + + def test_current_date(self): + query = Query.select(fn.CurDate()) + + self.assertEqual("SELECT CURRENT_DATE()", str(query)) + + def test_current_time(self): + query = Query.select(fn.CurTime()) + + self.assertEqual("SELECT CURRENT_TIME()", str(query)) + + def test_current_timestamp(self): + query = Query.select(fn.CurTimestamp()) + + self.assertEqual("SELECT CURRENT_TIMESTAMP", str(query)) + + def test_current_timestamp_with_alias(self): + query = Query.select(fn.CurTimestamp("ts")) + + self.assertEqual('SELECT CURRENT_TIMESTAMP "ts"', str(query)) + + def test_to_date(self): + q1 = fn.ToDate("2019-06-21", "yyyy-mm-dd") + q2 = Query.from_(self.t).select(fn.ToDate("2019-06-21", "yyyy-mm-dd")) + q3 = Query.from_(self.t).select(fn.ToDate(F("foo"), "yyyy-mm-dd")) + + self.assertEqual(str(q1), "TO_DATE('2019-06-21','yyyy-mm-dd')") + self.assertEqual(str(q2), "SELECT TO_DATE('2019-06-21','yyyy-mm-dd') FROM \"abc\"") + self.assertEqual(str(q3), 'SELECT TO_DATE("foo",\'yyyy-mm-dd\') FROM "abc"') + + +class NullFunctionsTests(unittest.TestCase): + def test_isnull(self): + q = Q.from_("abc").select(fn.IsNull(F("foo"))) + + self.assertEqual('SELECT ISNULL("foo") FROM "abc"', str(q)) + + def test_coalesce(self): + q = Q.from_("abc").select(fn.Coalesce(F("foo"), 0)) + + self.assertEqual('SELECT COALESCE("foo",0) FROM "abc"', str(q)) + + def test_nullif(self): + q = Q.from_("abc").select(fn.NullIf(F("foo"), 0)) + + self.assertEqual('SELECT NULLIF("foo",0) FROM "abc"', str(q)) + + def test_nvl(self): + q = Q.from_("abc").select(fn.NVL(F("foo"), 0)) + + self.assertEqual('SELECT NVL("foo",0) FROM "abc"', str(q)) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/test_groupby_modifiers.py b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/test_groupby_modifiers.py new file mode 100644 index 0000000000000000000000000000000000000000..978834c2409f4b4800fedb9b1bb2538a31d0f31c --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/test_groupby_modifiers.py @@ -0,0 +1,168 @@ +import unittest + +from pypika import Query, Rollup, RollupException, Table, functions as fn + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + + +class RollupTests(unittest.TestCase): + table = Table("abc") + + def test_mysql_one_groupby(self): + q = ( + Query.from_(self.table) + .select(self.table.foo, fn.Sum(self.table.bar)) + .rollup(self.table.foo, vendor="mysql") + ) + + self.assertEqual('SELECT "foo",SUM("bar") FROM "abc" GROUP BY "foo" WITH ROLLUP', str(q)) + + def test_mysql_rollup_two_groupbys(self): + q = ( + Query.from_(self.table) + .select(self.table.foo, self.table.fiz, fn.Sum(self.table.bar)) + .rollup(self.table.foo, self.table.fiz, vendor="mysql") + ) + + self.assertEqual( + 'SELECT "foo","fiz",SUM("bar") FROM "abc" GROUP BY "foo","fiz" WITH ROLLUP', + str(q), + ) + + def test_no_rollup_before_groupby(self): + with self.assertRaises(RollupException): + Query.from_(self.table).select(self.table.foo, fn.Sum(self.table.bar)).rollup(vendor="mysql") + + def test_no_rollup_after_rollup_mysql(self): + with self.assertRaises(AttributeError): + Query.from_(self.table).select(self.table.foo, self.table.fiz, fn.Sum(self.table.bar)).rollup( + self.table.foo, vendor="mysql" + ).rollup(self.table.fiz, vendor="mysql") + + def test_verticaoracle_func_one_groupby(self): + q = Query.from_(self.table).select(self.table.foo, fn.Sum(self.table.bar)).groupby(Rollup(self.table.foo)) + + self.assertEqual('SELECT "foo",SUM("bar") FROM "abc" GROUP BY ROLLUP("foo")', str(q)) + + def test_verticaoracle_func_two_groupbys(self): + q = ( + Query.from_(self.table) + .select(self.table.foo, self.table.fiz, fn.Sum(self.table.bar)) + .groupby( + Rollup( + self.table.foo, + self.table.fiz, + ) + ) + ) + + self.assertEqual( + 'SELECT "foo","fiz",SUM("bar") FROM "abc" GROUP BY ROLLUP("foo","fiz")', + str(q), + ) + + def test_verticaoracle_func_partial(self): + q = ( + Query.from_(self.table) + .select(self.table.foo, self.table.fiz, self.table.buz, fn.Sum(self.table.bar)) + .groupby( + Rollup( + self.table.foo, + self.table.fiz, + ), + self.table.buz, + ) + ) + + self.assertEqual( + 'SELECT "foo","fiz","buz",SUM("bar") FROM "abc" GROUP BY ROLLUP("foo","fiz"),"buz"', + str(q), + ) + + def test_verticaoracle_from_groupbys(self): + q = Query.from_(self.table).select(self.table.foo, fn.Sum(self.table.bar)).rollup(self.table.foo) + + self.assertEqual('SELECT "foo",SUM("bar") FROM "abc" GROUP BY ROLLUP("foo")', str(q)) + + def test_verticaoracle_from_two_groupbys(self): + q = ( + Query.from_(self.table) + .select(self.table.foo, self.table.fiz, fn.Sum(self.table.bar)) + .rollup( + self.table.foo, + self.table.fiz, + ) + ) + + self.assertEqual( + 'SELECT "foo","fiz",SUM("bar") FROM "abc" GROUP BY ROLLUP("foo","fiz")', + str(q), + ) + + def test_verticaoracle_from_parameters(self): + q = ( + Query.from_(self.table) + .select(self.table.foo, self.table.fiz, fn.Sum(self.table.bar)) + .groupby( + self.table.foo, + ) + .rollup( + self.table.fiz, + ) + ) + + self.assertEqual( + 'SELECT "foo","fiz",SUM("bar") FROM "abc" GROUP BY "foo",ROLLUP("fiz")', + str(q), + ) + + def test_verticaoracle_multiple_rollups(self): + q = ( + Query.from_(self.table) + .select(self.table.foo, self.table.fiz, fn.Sum(self.table.bar)) + .rollup( + self.table.foo, + ) + .rollup( + self.table.fiz, + ) + ) + + self.assertEqual( + 'SELECT "foo","fiz",SUM("bar") FROM "abc" GROUP BY ROLLUP("foo","fiz")', + str(q), + ) + + def test_verticaoracle_rollups_with_parity(self): + q = ( + Query.from_(self.table) + .select( + self.table.buz, + ) + .rollup( + [self.table.foo, self.table.bar], + self.table.fiz, + ) + ) + + self.assertEqual('SELECT "buz" FROM "abc" GROUP BY ROLLUP(("foo","bar"),"fiz")', str(q)) + + def test_verticaoracle_rollups_with_multiple_rollups_and_parity(self): + q = ( + Query.from_(self.table) + .select( + self.table.buz, + ) + .rollup( + [self.table.foo, self.table.bar], + ) + .rollup( + [self.table.fiz, self.table.buz], + ) + ) + + self.assertEqual( + 'SELECT "buz" FROM "abc" GROUP BY ROLLUP(("foo","bar"),("fiz","buz"))', + str(q), + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/test_immutability.py b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/test_immutability.py new file mode 100644 index 0000000000000000000000000000000000000000..ee539bfa1e9c4509b929e7a86a03f098dd923515 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/test_immutability.py @@ -0,0 +1,99 @@ +import unittest + +from pypika import ( + AliasedQuery, + Query, + Tables, +) + + +class ImmutabilityTests(unittest.TestCase): + table_a, table_b, table_c = Tables("a", "b", "c") + + def test_select_returns_new_query_instance(self): + query_a = Query.from_(self.table_a).select(self.table_a.foo) + query_b = query_a.select(self.table_a.bar) + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_groupby_returns_new_query_instance(self): + query_a = Query.from_(self.table_a).select(self.table_a.foo).groupby(self.table_a.foo) + query_b = query_a.groupby(self.table_a.bar) + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_orderby_return_new_query_instance(self): + query_a = Query.from_(self.table_a).select(self.table_a.foo).orderby(self.table_a.foo) + query_b = query_a.orderby(self.table_a.bar) + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_join_return_new_query_instance(self): + base = Query.from_(self.table_a).select(self.table_a.foo) + query_a = base.join(self.table_b).on(self.table_a.foo == self.table_b.bar).select(self.table_b.bar) + query_b = query_a.join(self.table_c).on(self.table_a.foo == self.table_c.baz).select(self.table_c.baz) + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_use_index_return_new_query_instance(self): + query_a = Query.from_(self.table_a).select(self.table_a.foo).use_index('idx1') + query_b = query_a.use_index('idx2') + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_force_index_return_new_query_instance(self): + query_a = Query.from_(self.table_a).select(self.table_a.foo).force_index('idx1') + query_b = query_a.force_index('idx2') + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_with_return_new_query_instance(self): + alias_1 = Query.from_(self.table_a).select(self.table_a.foo) + alias_2 = Query.from_(self.table_b).select(self.table_b.bar) + query_a = Query.from_(AliasedQuery('a1')).select('foo').with_(alias_1, 'a1') + query_b = query_a.with_(alias_2, 'a2') + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_insert_into_return_new_query_instance(self): + query_a = Query.into(self.table_a).insert('foo1') + query_b = query_a.insert('foo2') + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_replace_into_return_new_query_instance(self): + query_a = Query.into(self.table_a).replace('foo') + query_b = query_a.replace('bar') + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_update_set_return_new_query_instance(self): + query_a = Query.update(self.table_a).set(self.table_a.foo, 'foo') + query_b = query_a.set(self.table_a.bar, 'bar') + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_queries_after_join(self): + query1 = Query.from_(self.table_a).select(self.table_a.foo) + query2 = query1.join(self.table_b).on(self.table_a.foo == self.table_b.bar).select(self.table_b.buz) + + self.assertEqual('SELECT "foo" FROM "a"', str(query1)) + self.assertEqual( + 'SELECT "a"."foo","b"."buz" FROM "a" JOIN "b" ON "a"."foo"="b"."bar"', + str(query2), + ) + + def test_immutable_kwarg_on_query_builder_disables_immutability(self): + query0 = Query.from_(self.table_a, immutable=False) + query1 = query0.select(self.table_a.foo) + self.assertIs(query0, query1) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/test_inserts.py b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/test_inserts.py new file mode 100644 index 0000000000000000000000000000000000000000..f86efd7a76dc498a69b61c6353951695f1933a61 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/test_inserts.py @@ -0,0 +1,885 @@ +import unittest + +from pypika import ( + AliasedQuery, + Case, + Field as F, + MySQLQuery, + PostgreSQLQuery, + Query, + Table, + Tables, + functions as fn, +) +from pypika.functions import ( + Avg, + Cast, +) +from pypika.terms import Values +from pypika.utils import QueryException + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + + +class InsertIntoTests(unittest.TestCase): + table_abc = Table("abc") + + def test_insert_one_column(self): + query = Query.into(self.table_abc).insert(1) + + self.assertEqual('INSERT INTO "abc" VALUES (1)', str(query)) + + def test_insert_one_column_single_element_array(self): + query = Query.into(self.table_abc).insert((1,)) + + self.assertEqual('INSERT INTO "abc" VALUES (1)', str(query)) + + def test_insert_one_column_multi_element_array(self): + query = Query.into(self.table_abc).insert((1,), (2,)) + + self.assertEqual('INSERT INTO "abc" VALUES (1),(2)', str(query)) + + def test_insert_single_row_with_array_value(self): + query = Query.into(self.table_abc).insert(1, ["a", "b", "c"]) + + self.assertEqual("INSERT INTO \"abc\" VALUES (1,['a','b','c'])", str(query)) + + def test_insert_multiple_rows_with_array_value(self): + query = Query.into(self.table_abc).insert( + (1, ["a", "b", "c"]), + (2, ["c", "d", "e"]), + ) + + self.assertEqual( + 'INSERT INTO "abc" ' "VALUES (1,['a','b','c']),(2,['c','d','e'])", + str(query), + ) + + def test_insert_all_columns(self): + query = Query.into(self.table_abc).insert(1, "a", True) + + self.assertEqual("INSERT INTO \"abc\" VALUES (1,'a',true)", str(query)) + + def test_insert_all_columns_single_element(self): + query = Query.into(self.table_abc).insert((1, "a", True)) + + self.assertEqual("INSERT INTO \"abc\" VALUES (1,'a',true)", str(query)) + + def test_insert_all_columns_multi_rows(self): + query = Query.into(self.table_abc).insert((1, "a", True), (2, "b", False)) + + self.assertEqual("INSERT INTO \"abc\" VALUES (1,'a',true),(2,'b',false)", str(query)) + + def test_insert_all_columns_multi_rows_chained(self): + query = Query.into(self.table_abc).insert(1, "a", True).insert(2, "b", False) + + self.assertEqual("INSERT INTO \"abc\" VALUES (1,'a',true),(2,'b',false)", str(query)) + + def test_insert_all_columns_multi_rows_chained_mixed(self): + query = Query.into(self.table_abc).insert((1, "a", True), (2, "b", False)).insert(3, "c", True) + + self.assertEqual( + 'INSERT INTO "abc" VALUES ' "(1,'a',true),(2,'b',false)," "(3,'c',true)", + str(query), + ) + + def test_insert_all_columns_multi_rows_chained_multiple_rows(self): + query = ( + Query.into(self.table_abc).insert((1, "a", True), (2, "b", False)).insert((3, "c", True), (4, "d", False)) + ) + + self.assertEqual( + 'INSERT INTO "abc" VALUES ' "(1,'a',true),(2,'b',false)," "(3,'c',true),(4,'d',false)", + str(query), + ) + + def test_insert_selected_columns(self): + query = ( + Query.into(self.table_abc) + .columns(self.table_abc.foo, self.table_abc.bar, self.table_abc.buz) + .insert(1, "a", True) + ) + + self.assertEqual('INSERT INTO "abc" ("foo","bar","buz") VALUES (1,\'a\',true)', str(query)) + + def test_insert_empty_columns(self): + query = Query.into(self.table_abc).columns().insert(1, "a", True) + + self.assertEqual('INSERT INTO "abc" VALUES (1,\'a\',true)', str(query)) + + def test_insert_selected_columns_type_list(self): + query = ( + Query.into(self.table_abc) + .columns([self.table_abc.foo, self.table_abc.bar, self.table_abc.buz]) + .insert(1, "a", True) + ) + + self.assertEqual('INSERT INTO "abc" ("foo","bar","buz") VALUES (1,\'a\',true)', str(query)) + + def test_insert_empty_columns_type_list(self): + query = Query.into(self.table_abc).columns([]).insert(1, "a", True) + + self.assertEqual('INSERT INTO "abc" VALUES (1,\'a\',true)', str(query)) + + def test_insert_selected_columns_type_tuple(self): + query = ( + Query.into(self.table_abc) + .columns((self.table_abc.foo, self.table_abc.bar, self.table_abc.buz)) + .insert(1, "a", True) + ) + + self.assertEqual('INSERT INTO "abc" ("foo","bar","buz") VALUES (1,\'a\',true)', str(query)) + + def test_insert_empty_columns_type_tuple(self): + query = Query.into(self.table_abc).columns(()).insert(1, "a", True) + + self.assertEqual('INSERT INTO "abc" VALUES (1,\'a\',true)', str(query)) + + def test_insert_none_skipped(self): + query = Query.into(self.table_abc).insert() + + self.assertEqual("", str(query)) + + def test_insert_ignore(self): + query = Query.into(self.table_abc).insert(1).ignore() + + self.assertEqual('INSERT IGNORE INTO "abc" VALUES (1)', str(query)) + + def test_insert_null(self): + query = Query.into(self.table_abc).insert(None) + + self.assertEqual('INSERT INTO "abc" VALUES (NULL)', str(query)) + + def test_insert_column_using_table_alias(self): + q = self.table_abc.insert(1) + self.assertEqual('INSERT INTO "abc" VALUES (1)', str(q)) + + def test_insert_column_using_alias_with_chain(self): + q = self.table_abc.insert(1, "a", True).insert(2, "b", False) + self.assertEqual("INSERT INTO \"abc\" VALUES (1,'a',true),(2,'b',false)", str(q)) + + def test_insert_with_statement(self): + sub_query = Query().select(self.table_abc.id).from_(self.table_abc) + aliased = AliasedQuery('sub_qs') + + q = Query().with_(sub_query, 'sub_qs').into(self.table_abc).select(aliased.id).from_(aliased) + self.assertEqual( + 'WITH sub_qs AS (SELECT "id" FROM "abc") INSERT INTO "abc" SELECT "sub_qs"."id" FROM sub_qs', str(q) + ) + + +class PostgresInsertIntoOnConflictTests(unittest.TestCase): + table_abc = Table("abc") + + def test_insert_on_conflict_do_nothing_field(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).on_conflict(self.table_abc.id).do_nothing() + + self.assertEqual('INSERT INTO "abc" VALUES (1) ON CONFLICT ("id") DO NOTHING', str(query)) + + def test_insert_on_conflict_do_nothing_multiple_fields(self): + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1) + .on_conflict(self.table_abc.id, self.table_abc.sub_id) + .do_nothing() + ) + + self.assertEqual('INSERT INTO "abc" VALUES (1) ON CONFLICT ("id", "sub_id") DO NOTHING', str(query)) + + def test_insert_on_conflict_do_nothing_field_str(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).on_conflict("id").do_nothing() + + self.assertEqual('INSERT INTO "abc" VALUES (1) ON CONFLICT ("id") DO NOTHING', str(query)) + + def test_insert_on_conflict_do_nothing_multiple_fields_str(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).on_conflict("id", "sub_id").do_nothing() + + self.assertEqual('INSERT INTO "abc" VALUES (1) ON CONFLICT ("id", "sub_id") DO NOTHING', str(query)) + + def test_insert_on_conflict_do_nothing_mixed_fields(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).on_conflict("id", self.table_abc.sub_id).do_nothing() + + self.assertEqual('INSERT INTO "abc" VALUES (1) ON CONFLICT ("id", "sub_id") DO NOTHING', str(query)) + + def test_insert_on_conflict_do_update_field(self): + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict(self.table_abc.id) + .do_update(self.table_abc.name, "m") + ) + + self.assertEqual( + "INSERT INTO \"abc\" VALUES (1,'m') ON CONFLICT (\"id\") DO UPDATE SET \"name\"='m'", + str(query), + ) + + def test_insert_on_conflict_do_update_multiple_fields(self): + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict(self.table_abc.id, self.table_abc.sub_id) + .do_update(self.table_abc.name, "m") + ) + + self.assertEqual( + "INSERT INTO \"abc\" VALUES (1,'m') ON CONFLICT (\"id\", \"sub_id\") DO UPDATE SET \"name\"='m'", + str(query), + ) + + def test_insert_on_conflict_do_update_field_str(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1, "m").on_conflict("id").do_update("name", "m") + + self.assertEqual( + "INSERT INTO \"abc\" VALUES (1,'m') ON CONFLICT (\"id\") DO UPDATE SET \"name\"='m'", + str(query), + ) + + def test_insert_on_conflict_do_update_multiple_fields_str(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1, "m").on_conflict("id", "sub_id").do_update("name", "m") + + self.assertEqual( + "INSERT INTO \"abc\" VALUES (1,'m') ON CONFLICT (\"id\", \"sub_id\") DO UPDATE SET \"name\"='m'", + str(query), + ) + + def test_insert_on_conflict_do_update_multiple_mixed_fields(self): + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict("id", self.table_abc.sub_id) + .do_update("name", "m") + ) + + self.assertEqual( + "INSERT INTO \"abc\" VALUES (1,'m') ON CONFLICT (\"id\", \"sub_id\") DO UPDATE SET \"name\"='m'", + str(query), + ) + + def test_insert_on_conflict_no_handler(self): + with self.assertRaises(QueryException): + query = str(PostgreSQLQuery.into(self.table_abc).insert(1).on_conflict(self.table_abc.id)) + + def test_insert_on_conflict_two_handlers_do_nothing(self): + with self.assertRaises(QueryException): + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1) + .on_conflict("id") + .do_nothing() + .do_update(self.table_abc.name, "m") + ) + + def test_insert_on_conflict_two_handlers_do_update(self): + with self.assertRaises(QueryException): + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1) + .on_conflict(self.table_abc.id) + .do_update(self.table_abc.name, "m") + .do_nothing() + ) + + def test_non_insert_on_conflict_do_nothing(self): + with self.assertRaises(QueryException): + query = PostgreSQLQuery.update(self.table_abc).set("foo", "bar").on_conflict("id").do_nothing() + + def test_non_insert_on_conflict_do_update(self): + with self.assertRaises(QueryException): + query = ( + PostgreSQLQuery.update(self.table_abc).set("foo", "bar").on_conflict("id").do_update(["name"], ["m"]) + ) + + def test_insert_on_fieldless_conflict_do_nothing(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).on_conflict(None).do_nothing() + + self.assertEqual('INSERT INTO "abc" VALUES (1) ON CONFLICT DO NOTHING', str(query)) + + def test_insert_on_fieldless_conflict_do_update_field(self): + with self.assertRaises(QueryException): + query = str( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict(None) + .do_update(self.table_abc.name, "m") + ) + + def test_on_conflict_from_subquery(self): + table_bcd = Table('bcd') + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(self.table_abc.fname, self.table_abc.lname) + .select(table_bcd.fname, table_bcd.lname) + .from_(table_bcd) + .on_conflict(self.table_abc.id, self.table_abc.sub_id) + .do_update(self.table_abc.fname, 1) + .do_update(self.table_abc.lname, table_bcd.lname) + .do_update( + self.table_abc.cname, + Case().when(self.table_abc.cname.eq('cname'), 'new_name').else_(self.table_abc.cname), + ) + ) + + self.assertEqual( + 'INSERT INTO "abc" VALUES ("fname","lname") ' + 'ON CONFLICT ("id", "sub_id") ' + 'DO UPDATE SET "fname"=1,"lname"="bcd"."lname",' + '"cname"=CASE WHEN "abc"."cname"=\'cname\' THEN \'new_name\' ELSE "abc"."cname" END', + str(query), + ) + + def test_on_conflict_where_empty_conflict_fields_do_nothing(self): + with self.assertRaises(QueryException): + ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict() + .where(self.table_abc.abc.eq(0)) + .where(self.table_abc.cde.eq(0)) + .do_nothing() + ) + + def test_on_conflict_where_conflict_fields_do_nothing(self): + qs = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict('id') + .where(self.table_abc.abc.eq(0)) + .where(self.table_abc.cde.eq(0)) + .do_nothing() + ) + self.assertEqual( + '''INSERT INTO "abc" VALUES (1,'m') ON CONFLICT ("id") WHERE "abc"=0 AND "cde"=0 DO NOTHING''', str(qs) + ) + + def test_on_conflict_where_empty_conflict_fields_do_update(self): + with self.assertRaises(QueryException): + ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict() + .where(self.table_abc.abc.eq(0)) + .where(self.table_abc.cde.eq(0)) + .do_update('field', 'val') + ) + + def test_on_conflict_where_conflict_fields_do_update(self): + qs = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict('id') + .where(self.table_abc.abc.eq(0)) + .where(self.table_abc.cde.eq(0)) + .do_update('field', 'val') + ) + self.assertEqual( + '''INSERT INTO "abc" VALUES (1,'m') ON CONFLICT ("id") WHERE "abc"=0 AND "cde"=0 ''' + '''DO UPDATE SET "field"='val\'''', + str(qs), + ) + + def test_where_and_on_conflict_where(self): + table_bcd = Table('bcd') + + qs = ( + PostgreSQLQuery.into(self.table_abc) + .select(table_bcd.abc) + .from_(table_bcd) + .where(table_bcd.abc.eq('1')) + .on_conflict('id') + .where(self.table_abc.abc.eq(0)) + .where(self.table_abc.cde.eq(0)) + .do_update('field', 'val') + ) + + self.assertEqual( + 'INSERT INTO "abc" SELECT "abc" FROM "bcd" WHERE "abc"=\'1\' ' + 'ON CONFLICT ("id") WHERE "abc"=0 AND "cde"=0 DO UPDATE SET "field"=\'val\'', + str(qs), + ) + + def test_on_conflict_do_nothing_where(self): + with self.assertRaises(QueryException): + ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict() + .do_nothing() + .where(self.table_abc.abc.eq(1)) + ) + + def test_empty_on_conflict_do_update_where(self): + with self.assertRaises(QueryException): + ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict() + .do_update('abc', 1) + .where(self.table_abc.abc.eq(1)) + ) + + def test_on_conflict_do_update_where(self): + qs = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict("id") + .do_update('abc', 1) + .where(self.table_abc.abc.eq(1)) + ) + self.assertEqual( + 'INSERT INTO "abc" VALUES (1,\'m\') ON CONFLICT ("id") DO UPDATE SET "abc"=1 WHERE "abc"."abc"=1', str(qs) + ) + + def test_on_conflict_do_update_with_excluded_where(self): + qs = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict("id") + .do_update('abc') + .where(self.table_abc.abc.eq(1)) + ) + self.assertEqual( + 'INSERT INTO "abc" VALUES (1,\'m\') ON CONFLICT ("id") DO UPDATE SET "abc"=EXCLUDED."abc" WHERE ' + '"abc"."abc"=1', + str(qs), + ) + + def test_on_conflict_where_complex(self): + table_bcd = Table('bcd') + + qs = ( + PostgreSQLQuery.into(self.table_abc) + .select(table_bcd.abc) + .from_(table_bcd) + .where(table_bcd.abc.eq('1')) + .on_conflict('id') + .where(self.table_abc.abc.eq(0)) + .where(self.table_abc.cde.eq(0)) + .do_update('field', 'val') + .where(self.table_abc.id.eq(2)) + .where(self.table_abc.sub_id.eq(3)) + ) + self.assertEqual( + 'INSERT INTO "abc" SELECT "abc" FROM "bcd" WHERE "abc"=\'1\' ' + 'ON CONFLICT ("id") WHERE "abc"=0 AND "cde"=0 ' + 'DO UPDATE SET "field"=\'val\' WHERE "abc"."id"=2 AND "abc"."sub_id"=3', + str(qs), + ) + + +class PostgresInsertIntoReturningTests(unittest.TestCase): + table_abc = Table("abc") + + def test_insert_returning_one_field(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).returning(self.table_abc.id) + + self.assertEqual('INSERT INTO "abc" VALUES (1) RETURNING "id"', str(query)) + + def test_insert_returning_one_field_str(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).returning("id") + + self.assertEqual('INSERT INTO "abc" VALUES (1) RETURNING "id"', str(query)) + + def test_insert_returning_all_fields(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).returning(self.table_abc.star) + + self.assertEqual('INSERT INTO "abc" VALUES (1) RETURNING *', str(query)) + + def test_insert_returning_all_fields_and_arithmetics(self): + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1) + .returning(self.table_abc.star, self.table_abc.f1 + self.table_abc.f2) + ) + + self.assertEqual('INSERT INTO "abc" VALUES (1) RETURNING *,"f1"+"f2"', str(query)) + + def test_insert_all_columns_multi_rows_chained_returning_star(self): + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "a", True) + .insert(2, "b", False) + .returning(self.table_abc.star) + ) + + self.assertEqual( + "INSERT INTO \"abc\" VALUES (1,'a',true),(2,'b',false) RETURNING *", + str(query), + ) + + def test_insert_all_columns_multi_rows_chained_returning_star_and_id(self): + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "a", True) + .insert(2, "b", False) + .returning( + self.table_abc.name, + self.table_abc.star, + self.table_abc.id, + ) + ) + + self.assertEqual( + "INSERT INTO \"abc\" VALUES (1,'a',true),(2,'b',false) RETURNING *", + str(query), + ) + + def test_insert_all_columns_multi_rows_chained_returning_star_str(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1, "a", True).insert(2, "b", False).returning("*") + + self.assertEqual( + "INSERT INTO \"abc\" VALUES (1,'a',true),(2,'b',false) RETURNING *", + str(query), + ) + + def test_insert_all_columns_single_element_arrays(self): + query = PostgreSQLQuery.into(self.table_abc).insert((1, "a", True)).returning(self.table_abc.star) + + self.assertEqual("INSERT INTO \"abc\" VALUES (1,'a',true) RETURNING *", str(query)) + + def test_insert_returning_null(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).returning(None) + + self.assertEqual('INSERT INTO "abc" VALUES (1) RETURNING NULL', str(query)) + + def test_insert_returning_tuple(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).returning((1, 2, 3)) + + self.assertEqual('INSERT INTO "abc" VALUES (1) RETURNING (1,2,3)', str(query)) + + def test_insert_returning_arithmetics(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).returning(self.table_abc.f1 + self.table_abc.f2) + + self.assertEqual('INSERT INTO "abc" VALUES (1) RETURNING "f1"+"f2"', str(query)) + + def test_insert_returning_functions(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).returning(Cast(self.table_abc.f1, "int")) + + self.assertEqual('INSERT INTO "abc" VALUES (1) RETURNING CAST("f1" AS INT)', str(query)) + + def test_insert_returning_aggregate(self): + with self.assertRaises(QueryException): + PostgreSQLQuery.into(self.table_abc).insert(1).returning(Avg(self.table_abc.views)) + + def test_insert_returning_from_other_table(self): + table_cba = Table("cba") + with self.assertRaises(QueryException): + PostgreSQLQuery.into(self.table_abc).insert(1).returning(table_cba.id) + + +class InsertIntoOnDuplicateTests(unittest.TestCase): + table_abc = Table("abc") + + def test_insert_one_column(self): + query = ( + MySQLQuery.into(self.table_abc).insert(1).on_duplicate_key_update(self.table_abc.foo, self.table_abc.foo) + ) + self.assertEqual( + "INSERT INTO `abc` VALUES (1) ON DUPLICATE KEY UPDATE `foo`=`foo`", + str(query), + ) + + def test_insert_one_column_using_values(self): + query = ( + MySQLQuery.into(self.table_abc) + .insert(1) + .on_duplicate_key_update(self.table_abc.foo, Values(self.table_abc.foo)) + ) + self.assertEqual( + "INSERT INTO `abc` VALUES (1) ON DUPLICATE KEY UPDATE `foo`=VALUES(`foo`)", + str(query), + ) + + def test_insert_one_column_single_element_array(self): + query = ( + MySQLQuery.into(self.table_abc).insert((1,)).on_duplicate_key_update(self.table_abc.foo, self.table_abc.foo) + ) + + self.assertEqual( + "INSERT INTO `abc` VALUES (1) ON DUPLICATE KEY UPDATE `foo`=`foo`", + str(query), + ) + + def test_insert_one_column_multi_element_array(self): + query = ( + MySQLQuery.into(self.table_abc) + .insert((1,), (2,)) + .on_duplicate_key_update(self.table_abc.foo, self.table_abc.foo) + ) + + self.assertEqual( + "INSERT INTO `abc` VALUES (1),(2) ON DUPLICATE KEY UPDATE `foo`=`foo`", + str(query), + ) + + def test_insert_multiple_columns_on_duplicate_update_one_with_same_value(self): + query = ( + MySQLQuery.into(self.table_abc) + .insert(1, "a") + .on_duplicate_key_update(self.table_abc.bar, Values(self.table_abc.bar)) + ) + + self.assertEqual( + "INSERT INTO `abc` VALUES (1,'a') ON DUPLICATE KEY UPDATE `bar`=VALUES(`bar`)", + str(query), + ) + + def test_insert_multiple_columns_on_duplicate_update_one_with_different_value(self): + query = MySQLQuery.into(self.table_abc).insert(1, "a").on_duplicate_key_update(self.table_abc.bar, "b") + + self.assertEqual( + "INSERT INTO `abc` VALUES (1,'a') ON DUPLICATE KEY UPDATE `bar`='b'", + str(query), + ) + + def test_insert_multiple_columns_on_duplicate_update_one_with_expression(self): + query = ( + MySQLQuery.into(self.table_abc).insert(1, 2).on_duplicate_key_update(self.table_abc.bar, 4 + F("bar")) + ) # todo sql expression? not python + + self.assertEqual( + "INSERT INTO `abc` VALUES (1,2) ON DUPLICATE KEY UPDATE `bar`=4+`bar`", + str(query), + ) + + def test_insert_multiple_columns_on_duplicate_update_one_with_expression_using_original_field_value( + self, + ): + query = ( + MySQLQuery.into(self.table_abc) + .insert(1, "a") + .on_duplicate_key_update(self.table_abc.bar, fn.Concat(self.table_abc.bar, "update")) + ) + + self.assertEqual( + "INSERT INTO `abc` VALUES (1,'a') ON DUPLICATE KEY UPDATE `bar`=CONCAT(`bar`,'update')", + str(query), + ) + + def test_insert_multiple_columns_on_duplicate_update_one_with_expression_using_values( + self, + ): + query = ( + MySQLQuery.into(self.table_abc) + .insert(1, "a") + .on_duplicate_key_update(self.table_abc.bar, fn.Concat(Values(self.table_abc.bar), "update")) + ) + + self.assertEqual( + "INSERT INTO `abc` VALUES (1,'a') ON DUPLICATE KEY UPDATE `bar`=CONCAT(VALUES(`bar`),'update')", + str(query), + ) + + def test_insert_multiple_columns_on_duplicate_update_multiple(self): + query = ( + MySQLQuery.into(self.table_abc) + .insert(1, "a", "b") + .on_duplicate_key_update(self.table_abc.bar, "b") + .on_duplicate_key_update(self.table_abc.baz, "c") + ) + + self.assertEqual( + "INSERT INTO `abc` VALUES (1,'a','b') ON DUPLICATE KEY UPDATE `bar`='b',`baz`='c'", + str(query), + ) + + def test_insert_multi_rows_chained_mixed_on_duplicate_update_multiple(self): + query = ( + MySQLQuery.into(self.table_abc) + .insert((1, "a", True), (2, "b", False)) + .insert(3, "c", True) + .on_duplicate_key_update(self.table_abc.foo, self.table_abc.foo) + .on_duplicate_key_update(self.table_abc.bar, Values(self.table_abc.bar)) + ) + + self.assertEqual( + "INSERT INTO `abc` VALUES (1,'a',true),(2,'b',false),(3,'c',true) " + "ON DUPLICATE KEY UPDATE `foo`=`foo`,`bar`=VALUES(`bar`)", + str(query), + ) + + def test_insert_selected_columns_on_duplicate_update_one(self): + query = ( + MySQLQuery.into(self.table_abc) + .columns(self.table_abc.foo, self.table_abc.bar, self.table_abc.baz) + .insert(1, "a", True) + .on_duplicate_key_update(self.table_abc.baz, False) + ) + + self.assertEqual( + "INSERT INTO `abc` (`foo`,`bar`,`baz`) VALUES (1,'a',true) ON DUPLICATE KEY UPDATE `baz`=false", + str(query), + ) + + def test_insert_selected_columns_on_duplicate_update_multiple(self): + query = ( + MySQLQuery.into(self.table_abc) + .columns(self.table_abc.foo, self.table_abc.bar, self.table_abc.baz) + .insert(1, "a", True) + .on_duplicate_key_update(self.table_abc.baz, False) + .on_duplicate_key_update(self.table_abc.bar, Values(self.table_abc.bar)) + ) + + self.assertEqual( + "INSERT INTO `abc` (`foo`,`bar`,`baz`) VALUES (1,'a',true) " + "ON DUPLICATE KEY UPDATE `baz`=false,`bar`=VALUES(`bar`)", + str(query), + ) + + def test_insert_none_skipped(self): + query = MySQLQuery.into(self.table_abc).insert().on_duplicate_key_update(self.table_abc.baz, False) + + self.assertEqual("", str(query)) + + def test_insert_ignore(self): + query = MySQLQuery.into(self.table_abc).insert(1).ignore().on_duplicate_key_update(self.table_abc.baz, False) + + self.assertEqual( + "INSERT IGNORE INTO `abc` VALUES (1) ON DUPLICATE KEY UPDATE `baz`=false", + str(query), + ) + + +class InsertSelectFromTests(unittest.TestCase): + table_abc, table_efg, table_hij = Tables("abc", "efg", "hij") + + def test_insert_star(self): + query = Query.into(self.table_abc).from_(self.table_efg).select("*") + + self.assertEqual('INSERT INTO "abc" SELECT * FROM "efg"', str(query)) + + def test_insert_ignore_star(self): + query = Query.into(self.table_abc).from_(self.table_efg).select("*").ignore() + + self.assertEqual('INSERT IGNORE INTO "abc" SELECT * FROM "efg"', str(query)) + + def test_insert_from_columns(self): + query = ( + Query.into(self.table_abc) + .from_(self.table_efg) + .select(self.table_efg.fiz, self.table_efg.buz, self.table_efg.baz) + ) + + self.assertEqual('INSERT INTO "abc" ' 'SELECT "fiz","buz","baz" FROM "efg"', str(query)) + + def test_insert_columns_from_star(self): + query = ( + Query.into(self.table_abc) + .columns( + self.table_abc.foo, + self.table_abc.bar, + self.table_abc.buz, + ) + .from_(self.table_efg) + .select("*") + ) + + self.assertEqual('INSERT INTO "abc" ("foo","bar","buz") ' 'SELECT * FROM "efg"', str(query)) + + def test_insert_columns_from_columns(self): + query = ( + Query.into(self.table_abc) + .columns(self.table_abc.foo, self.table_abc.bar, self.table_abc.buz) + .from_(self.table_efg) + .select(self.table_efg.fiz, self.table_efg.buz, self.table_efg.baz) + ) + + self.assertEqual( + 'INSERT INTO "abc" ("foo","bar","buz") ' 'SELECT "fiz","buz","baz" FROM "efg"', + str(query), + ) + + def test_insert_columns_from_columns_with_join(self): + query = ( + Query.into(self.table_abc) + .columns( + self.table_abc.c1, + self.table_abc.c2, + self.table_abc.c3, + self.table_abc.c4, + ) + .from_(self.table_efg) + .select(self.table_efg.foo, self.table_efg.bar) + .join(self.table_hij) + .on(self.table_efg.id == self.table_hij.abc_id) + .select(self.table_hij.fiz, self.table_hij.buz) + ) + + self.assertEqual( + 'INSERT INTO "abc" ("c1","c2","c3","c4") ' + 'SELECT "efg"."foo","efg"."bar","hij"."fiz","hij"."buz" FROM "efg" ' + 'JOIN "hij" ON "efg"."id"="hij"."abc_id"', + str(query), + ) + + +class InsertSubqueryTests(unittest.TestCase): + def test_insert_subquery_wrapped_in_brackets(self): + purchase_order_item, part = Tables("purchase_order_item", "part") + + q = ( + Query.into(purchase_order_item) + .columns(purchase_order_item.id_part, purchase_order_item.id_customer) + .insert( + Query.from_(part).select(part.part_id).where(part.part_number == "FOOBAR"), + 12345, + ) + ) + + self.assertEqual( + 'INSERT INTO "purchase_order_item" ' + '("id_part","id_customer") ' + "VALUES " + '((SELECT "part_id" FROM "part" WHERE "part_number"=\'FOOBAR\'),12345)', + str(q), + ) + + +class SelectIntoTests(unittest.TestCase): + table_abc, table_efg, table_hij = Tables("abc", "efg", "hij") + + def test_select_star_into(self): + query = Query.from_(self.table_abc).select("*").into(self.table_efg) + + self.assertEqual('SELECT * INTO "efg" FROM "abc"', str(query)) + + def test_select_columns_into(self): + query = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, self.table_abc.bar, self.table_abc.buz) + .into(self.table_efg) + ) + + self.assertEqual('SELECT "foo","bar","buz" INTO "efg" FROM "abc"', str(query)) + + def test_select_columns_into_with_join(self): + query = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, self.table_abc.bar) + .join(self.table_hij) + .on(self.table_abc.id == self.table_hij.abc_id) + .select(self.table_hij.fiz, self.table_hij.buz) + .into(self.table_efg) + ) + + self.assertEqual( + 'SELECT "abc"."foo","abc"."bar","hij"."fiz","hij"."buz" ' + 'INTO "efg" FROM "abc" ' + 'JOIN "hij" ON "abc"."id"="hij"."abc_id"', + str(query), + ) + + +class ReplaceTests(unittest.TestCase): + table_abc, table_def = Tables("abc", "efg") + + def test_replace_simple(self): + query = Query.into(self.table_abc).replace("v1", "v2", "v3") + expected_output = "REPLACE INTO \"abc\" VALUES ('v1','v2','v3')" + self.assertEqual(str(query), expected_output) + + def test_replace_subquery(self): + query = Query.into(self.table_abc).replace(Query.from_(self.table_def).select("f1", "f2")) + expected_output = 'REPLACE INTO "abc" VALUES ((SELECT "f1","f2" FROM "efg"))' + self.assertEqual(str(query), expected_output) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/test_internals.py b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/test_internals.py new file mode 100644 index 0000000000000000000000000000000000000000..921e381ba8613d4a83cc53bd60d111d9547e2c1f --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/test_internals.py @@ -0,0 +1,35 @@ +import unittest + +from pypika import ( + Case, + Field, + Table, +) +from pypika.terms import Star + + +class TablesTests(unittest.TestCase): + def test__criterion_replace_table_with_value(self): + table = Table("a") + + c = (Field("foo") > 1).replace_table(None, table) + self.assertEqual(c.left, table) + self.assertEqual(c.tables_, {table}) + + def test__case_tables(self): + table = Table("a") + + c = Case().when(table.a == 1, 2 * table.a) + self.assertIsInstance(c.tables_, set) + self.assertSetEqual(c.tables_, {table}) + + def test__star_tables(self): + star = Star() + + self.assertEqual(star.tables_, set()) + + def test__table_star_tables(self): + table = Table("a") + star = Star(table=table) + + self.assertEqual(star.tables_, {table}) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/test_joins.py b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/test_joins.py new file mode 100644 index 0000000000000000000000000000000000000000..03142d583921edbe966e0ae191d254e7b8bf46ba --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/test_joins.py @@ -0,0 +1,1168 @@ +import unittest + +from pypika import ( + Field, + Interval, + JoinException, + JoinType, + MySQLQuery, + Query, + SetOperationException, + Table, + Tables, + functions as fn, + SYSTEM_TIME, +) + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + + +class SelectQueryJoinTests(unittest.TestCase): + table0, table1, hij = Tables("abc", "efg", "hij") + + def test_default_join_type(self): + query = Query.from_(self.table0).join(self.table1).on(self.table0.foo == self.table1.bar).select("*") + + self.assertEqual('SELECT * FROM "abc" JOIN "efg" ON "abc"."foo"="efg"."bar"', str(query)) + + def test_inner_join(self): + expected = 'SELECT * FROM "abc" JOIN "efg" ON "abc"."foo"="efg"."bar"' + + with self.subTest("join with enum"): + query = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.inner) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + self.assertEqual(expected, str(query)) + + with self.subTest("join function"): + query = Query.from_(self.table0).inner_join(self.table1).on(self.table0.foo == self.table1.bar).select("*") + self.assertEqual(expected, str(query)) + + def test_left_join(self): + expected = 'SELECT * FROM "abc" LEFT JOIN "efg" ON "abc"."foo"="efg"."bar"' + + with self.subTest("join with enum"): + query = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.left) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + + self.assertEqual(expected, str(query)) + + with self.subTest("join function"): + query = Query.from_(self.table0).left_join(self.table1).on(self.table0.foo == self.table1.bar).select("*") + self.assertEqual(expected, str(query)) + + def test_right_join(self): + expected = 'SELECT * FROM "abc" RIGHT JOIN "efg" ON "abc"."foo"="efg"."bar"' + + with self.subTest("join with enum"): + query = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.right) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + + self.assertEqual(expected, str(query)) + + with self.subTest("join function"): + query = Query.from_(self.table0).right_join(self.table1).on(self.table0.foo == self.table1.bar).select("*") + self.assertEqual(expected, str(query)) + + def test_hash_join(self): + expected = 'SELECT * FROM "abc" HASH JOIN "efg" ON "abc"."foo"="efg"."bar"' + + with self.subTest("join with enum"): + query = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.hash) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + + self.assertEqual(expected, str(query)) + + with self.subTest("join function"): + query = Query.from_(self.table0).hash_join(self.table1).on(self.table0.foo == self.table1.bar).select("*") + self.assertEqual(expected, str(query)) + + def test_outer_join(self): + expected = 'SELECT * FROM "abc" FULL OUTER JOIN "efg" ON "abc"."foo"="efg"."bar"' + + with self.subTest("join with enum"): + query = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.outer) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + + self.assertEqual(expected, str(query)) + + with self.subTest("join function"): + query = Query.from_(self.table0).outer_join(self.table1).on(self.table0.foo == self.table1.bar).select("*") + self.assertEqual(expected, str(query)) + + def test_cross_join(self): + expected = 'SELECT * FROM "abc" CROSS JOIN "efg" ON "abc"."foo"="efg"."bar"' + + with self.subTest("join with enum"): + query = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.cross) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + + self.assertEqual(expected, str(query)) + + with self.subTest("join function"): + query = Query.from_(self.table0).cross_join(self.table1).on(self.table0.foo == self.table1.bar).select("*") + self.assertEqual(expected, str(query)) + + def test_left_outer_join(self): + expected = 'SELECT * FROM "abc" LEFT OUTER JOIN "efg" ON "abc"."foo"="efg"."bar"' + with self.subTest("join with enum"): + query = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.left_outer) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + + self.assertEqual(expected, str(query)) + + with self.subTest("join function"): + query = ( + Query.from_(self.table0).left_outer_join(self.table1).on(self.table0.foo == self.table1.bar).select("*") + ) + + self.assertEqual(expected, str(query)) + + def test_right_outer_join(self): + expected = 'SELECT * FROM "abc" RIGHT OUTER JOIN "efg" ON "abc"."foo"="efg"."bar"' + with self.subTest("join with enum"): + query = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.right_outer) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + + self.assertEqual(expected, str(query)) + + with self.subTest("join function"): + query = ( + Query.from_(self.table0) + .right_outer_join(self.table1) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + + self.assertEqual(expected, str(query)) + + def test_full_outer_join(self): + expected = 'SELECT * FROM "abc" FULL OUTER JOIN "efg" ON "abc"."foo"="efg"."bar"' + + with self.subTest("join with enum"): + query = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.full_outer) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + + self.assertEqual(expected, str(query)) + + with self.subTest("join function"): + query = ( + Query.from_(self.table0).full_outer_join(self.table1).on(self.table0.foo == self.table1.bar).select("*") + ) + + self.assertEqual(expected, str(query)) + + def test_join_on_field_single(self): + query = Query.from_(self.table0).join(self.table1).on_field("foo").select("*") + self.assertEqual('SELECT * FROM "abc" JOIN "efg" ON "abc"."foo"="efg"."foo"', str(query)) + + def test_join_on_field_multi(self): + query = Query.from_(self.table0).join(self.table1).on_field("foo", "bar").select("*") + self.assertEqual( + 'SELECT * FROM "abc" JOIN "efg" ON "abc"."foo"="efg"."foo" ' 'AND "abc"."bar"="efg"."bar"', + str(query), + ) + + def test_join_on_field_multi_with_extra_join(self): + query = ( + Query.from_(self.table0) + .join(self.hij) + .on_field("buzz") + .join(self.table1) + .on_field("foo", "bar") + .select("*") + ) + + self.assertEqual( + 'SELECT * FROM "abc" JOIN "hij" ON "abc"."buzz"="hij"."buzz" ' + 'JOIN "efg" ON "abc"."foo"="efg"."foo" AND "abc"."bar"="efg"."bar"', + str(query), + ) + + def test_join_using_string_field_name(self): + query = Query.from_(self.table0).join(self.table1).using("id").select("*") + + self.assertEqual('SELECT * FROM "abc" JOIN "efg" USING ("id")', str(query)) + + def test_join_using_multiple_fields(self): + query = Query.from_(self.table0).join(self.table1).using("foo", "bar").select("*") + + self.assertEqual('SELECT * FROM "abc" JOIN "efg" USING ("foo","bar")', str(query)) + + def test_join_using_with_quote_char(self): + query = Query.from_(self.table0).join(self.table1).using("foo", "bar").select("*") + + self.assertEqual("SELECT * FROM abc JOIN efg USING (foo,bar)", query.get_sql(quote_char="")) + + def test_join_using_without_fields_raises_exception(self): + with self.assertRaises(JoinException): + Query.from_(self.table0).join(self.table1).using() + + def test_join_on_field_without_fields_raises_exception(self): + with self.assertRaises(JoinException): + Query.from_(self.table0).join(self.table1).on_field() + + def test_join_arithmetic_field(self): + q = ( + Query.from_(self.table0) + .join(self.table1) + .on(self.table0.dt == (self.table1.dt - Interval(weeks=1))) + .select("*") + ) + + self.assertEqual( + 'SELECT * FROM "abc" ' 'JOIN "efg" ON "abc"."dt"="efg"."dt"-INTERVAL \'1 WEEK\'', + str(q), + ) + + def test_join_with_arithmetic_function_in_select(self): + q = ( + Query.from_( + self.table0, + ) + .join(self.table1) + .on(self.table0.dt == (self.table1.dt - Interval(weeks=1))) + .select(self.table0.fiz - self.table0.buz, self.table1.star) + ) + + self.assertEqual( + 'SELECT "abc"."fiz"-"abc"."buz","efg".* FROM "abc" ' + 'JOIN "efg" ON "abc"."dt"="efg"."dt"-INTERVAL \'1 WEEK\'', + str(q), + ) + + def test_join_on_complex_criteria(self): + q = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.right) + .on((self.table0.foo == self.table1.fiz) & (self.table0.bar == self.table1.buz)) + .select("*") + ) + + self.assertEqual( + 'SELECT * FROM "abc" ' 'RIGHT JOIN "efg" ON "abc"."foo"="efg"."fiz" AND "abc"."bar"="efg"."buz"', + str(q), + ) + + def test_join_on_subquery_criteria(self): + table_a, table_b, table_c = Tables("a", "b", "c") + subquery = Query.from_(table_c).select("id").limit(1) + query = ( + Query.from_(table_a).select("*").join(table_b).on((table_a.b_id == table_b.id) & (table_b.c_id == subquery)) + ) + + self.assertEqual( + "SELECT * " 'FROM "a" ' 'JOIN "b" ON "a"."b_id"="b"."id" AND "b"."c_id"=' '(SELECT "id" FROM "c" LIMIT 1)', + str(query), + ) + + def test_use_different_table_objects_for_same_table(self): + table = Table("t") + q = Query.from_(table).select("*").where(Field("id", table=table) == 1) + + self.assertEqual('SELECT * FROM "t" WHERE "id"=1', str(q)) + + def test_join_second_table_in_from_clause(self): + table_a, table_b, table_c = Tables("a", "b", "c") + q = Query.from_(table_a).from_(table_b).select("*").join(table_c).on(table_b.c_id == table_c.id) + + self.assertEqual("SELECT * " 'FROM "a","b" ' 'JOIN "c" ON "b"."c_id"="c"."id"', str(q)) + + def test_cross_join_on_table(self): + table_a, table_b = Tables("a", "b") + q = Query.from_(table_a).join(table_b).cross().select("*") + + self.assertEqual('SELECT * FROM "a" CROSS JOIN "b"', str(q)) + + def test_cross_join_on_subquery(self): + table_a, table_b = Tables("a", "b") + q_a = Query.from_(table_a).select("*") + q_b = Query.from_(table_b).select("*").join(q_a).cross().select("*") + + self.assertEqual('SELECT * FROM "b" CROSS JOIN (SELECT * FROM "a") "sq0"', str(q_b)) + + def test_join_on_collate(self): + table_a, table_b = Tables("a", "b") + + q1 = ( + Query.from_(table_a) + .select(table_b.ouch) + .join(table_b) + .on(table_a.foo == table_b.boo, collate="utf8_general_ci") + ) + q2 = Query.from_(table_a).select(table_b.ouch).join(table_b).on(table_a.foo == table_b.boo) + + self.assertEqual( + 'SELECT "b"."ouch" FROM "a" JOIN "b" ON "a"."foo"="b"."boo" COLLATE utf8_general_ci', + str(q1), + ) + self.assertEqual('SELECT "b"."ouch" FROM "a" JOIN "b" ON "a"."foo"="b"."boo"', str(q2)) + + def test_temporal_join(self): + t0 = self.table0.for_(SYSTEM_TIME.as_of('2020-01-01')) + t1 = self.table1.for_(SYSTEM_TIME.as_of('2020-01-01')) + query = Query.from_(t0).join(t1).on(t0.foo == t1.bar).select("*") + + self.assertEqual( + 'SELECT * FROM "abc" FOR SYSTEM_TIME AS OF \'2020-01-01\' ' + 'JOIN "efg" FOR SYSTEM_TIME AS OF \'2020-01-01\' ' + 'ON "abc"."foo"="efg"."bar"', + str(query), + ) + + +class JoinBehaviorTests(unittest.TestCase): + table_abc, table_efg, table_hij, table_klm = Tables("abc", "efg", "hij", "klm") + + def test_select__ordered_select_clauses(self): + q = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .select( + self.table_abc.baz, + self.table_efg.buz, + self.table_abc.fiz, + self.table_efg.bam, + ) + ) + + self.assertEqual( + 'SELECT "abc"."baz","efg"."buz","abc"."fiz","efg"."bam" FROM "abc" ' + 'JOIN "efg" ON "abc"."foo"="efg"."bar"', + str(q), + ) + + def test_select__star_for_table(self): + q = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .join(self.table_hij) + .on(self.table_abc.buz == self.table_hij.bam) + .select(self.table_abc.star) + .select(self.table_efg.star) + .select(self.table_hij.star) + ) + + self.assertEqual( + 'SELECT "abc".*,"efg".*,"hij".* FROM "abc" ' + 'JOIN "efg" ON "abc"."foo"="efg"."bar" ' + 'JOIN "hij" ON "abc"."buz"="hij"."bam"', + str(q), + ) + + def test_select__star_for_table__replacement(self): + q = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .join(self.table_hij) + .on(self.table_abc.buz == self.table_hij.bam) + .select(self.table_abc.foo, self.table_efg.bar, self.table_hij.bam) + .select(self.table_abc.star, self.table_efg.star, self.table_hij.star) + ) + + self.assertEqual( + 'SELECT "abc".*,"efg".*,"hij".* FROM "abc" ' + 'JOIN "efg" ON "abc"."foo"="efg"."bar" ' + 'JOIN "hij" ON "abc"."buz"="hij"."bam"', + str(q), + ) + + def test_select_fields_with_where(self): + q = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .join(self.table_hij) + .on(self.table_abc.buz == self.table_hij.bam) + .select(self.table_abc.foo, self.table_efg.bar, self.table_hij.bam) + .where(self.table_abc.foo > 1) + .where(self.table_efg.bar != 2) + ) + + self.assertEqual( + 'SELECT "abc"."foo","efg"."bar","hij"."bam" FROM "abc" ' + 'JOIN "efg" ON "abc"."foo"="efg"."bar" ' + 'JOIN "hij" ON "abc"."buz"="hij"."bam" ' + 'WHERE "abc"."foo">1 AND "efg"."bar"<>2', + str(q), + ) + + def test_require_condition(self): + with self.assertRaises(JoinException): + Query.from_(self.table_abc).join(self.table_efg).on(None) + + def test_require_condition_with_both_tables(self): + with self.assertRaises(JoinException): + Query.from_(self.table_abc).join(self.table_efg).on(self.table_abc.foo == self.table_hij.bar) + + with self.assertRaises(JoinException): + Query.from_(self.table_abc).join(self.table_efg).on(self.table_hij.foo == self.table_efg.bar) + + with self.assertRaises(JoinException): + Query.from_(self.table_abc).join(self.table_efg).on(self.table_hij.foo == self.table_klm.bar) + + def test_join_same_table(self): + table1 = Table("abc") + table2 = Table("abc") + q = Query.from_(table1).join(table2).on(table1.foo == table2.bar).select(table1.foo, table2.buz) + + self.assertEqual( + 'SELECT "abc"."foo","abc2"."buz" FROM "abc" ' 'JOIN "abc" "abc2" ON "abc"."foo"="abc2"."bar"', + str(q), + ) + + def test_join_same_table_with_prefixes(self): + table1 = Table("abc").as_("x") + table2 = Table("abc").as_("y") + q = Query.from_(table1).join(table2).on(table1.foo == table2.bar).select(table1.foo, table2.buz) + + self.assertEqual( + 'SELECT "x"."foo","y"."buz" FROM "abc" "x" ' 'JOIN "abc" "y" ON "x"."foo"="y"."bar"', + str(q), + ) + + def test_join_table_twice(self): + table1, table2 = Table("efg").as_("efg1"), Table("efg").as_("efg2") + q = ( + Query.from_(self.table_abc) + .join(table1) + .on(self.table_abc.foo == table1.bar) + .join(table2) + .on(self.table_abc.foo == table2.bam) + .select(self.table_abc.foo, table1.fiz, table2.buz) + ) + + self.assertEqual( + 'SELECT "abc"."foo","efg1"."fiz","efg2"."buz" FROM "abc" ' + 'JOIN "efg" "efg1" ON "abc"."foo"="efg1"."bar" ' + 'JOIN "efg" "efg2" ON "abc"."foo"="efg2"."bam"', + str(q), + ) + + def test_select__fields_after_table_star(self): + q = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .select(self.table_abc.star, self.table_efg.bar) + .select(self.table_abc.foo) + ) + + self.assertEqual( + 'SELECT "abc".*,"efg"."bar" FROM "abc" JOIN "efg" ON "abc"."foo"="efg"."bar"', + str(q), + ) + + def test_fail_when_joining_unknown_type(self): + with self.assertRaises(ValueError): + Query.from_(self.table_abc).join("this is a string") + + def test_immutable__tables(self): + query1 = Query.from_(self.table_abc).select(self.table_abc.foo) + query2 = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .select(self.table_abc.foo, self.table_efg.buz) + ) + + self.assertEqual( + 'SELECT "abc"."foo","efg"."buz" FROM "abc" ' 'JOIN "efg" ON "abc"."foo"="efg"."bar"', + str(query2), + ) + self.assertEqual('SELECT "foo" FROM "abc"', str(query1)) + + def test_select_field_from_missing_table(self): + """ + Previously we validated the select field was a member of a table + in the query (e.g. FROM clause or a JOIN). However this made + correlated subqueries awkward to write (subqueries which refer + to their parent table. So the validation was removed. + + None of the following raise an error. Previously raised JoinException + """ + Query.from_(self.table_abc).select(self.table_efg.foo) + + Query.from_(self.table_abc).where(self.table_efg.foo == 0) + + Query.from_(self.table_abc).where(fn.Sum(self.table_efg.foo) == 0) + + Query.from_(self.table_abc).select(fn.Sum(self.table_abc.bar * 2) + fn.Sum(self.table_efg.foo * 2)) + + Query.from_(self.table_abc).groupby(self.table_efg.foo) + + Query.from_(self.table_abc).groupby(self.table_abc.foo).having(self.table_efg.bar) + + subquery = ( + Query.from_(self.table_efg).select(self.table_efg.id).where(self.table_efg.abc_id == self.table_abc.id) + ) + query = Query.from_(self.table_abc).select(subquery.as_("efg_id").limit(1)) + self.assertEqual( + 'SELECT (SELECT "efg"."id" FROM "efg" WHERE "efg"."abc_id"="abc"."id" LIMIT 1) "efg_id" FROM "abc"', + str(query), + ) + + def test_ignore_table_references(self): + query = Query.from_(Table("abc")).select(Table("abc").foo) + + self.assertEqual('SELECT "foo" FROM "abc"', str(query)) + + def test_prefixes_added_to_groupby(self): + test_query = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .select(self.table_abc.foo, fn.Sum(self.table_efg.buz)) + .groupby(self.table_abc.foo) + ) + + self.assertEqual( + 'SELECT "abc"."foo",SUM("efg"."buz") FROM "abc" ' + 'JOIN "efg" ON "abc"."foo"="efg"."bar" ' + 'GROUP BY "abc"."foo"', + str(test_query), + ) + + def test_prefixes_added_to_orderby(self): + test_query = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .select(self.table_abc.foo, self.table_efg.buz) + .orderby(self.table_abc.foo) + ) + + self.assertEqual( + 'SELECT "abc"."foo","efg"."buz" FROM "abc" ' + 'JOIN "efg" ON "abc"."foo"="efg"."bar" ' + 'ORDER BY "abc"."foo"', + str(test_query), + ) + + def test_prefixes_added_to_function_in_orderby(self): + test_query = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .select(self.table_abc.foo, self.table_efg.buz) + .orderby(fn.Date(self.table_abc.foo)) + ) + + self.assertEqual( + 'SELECT "abc"."foo","efg"."buz" FROM "abc" ' + 'JOIN "efg" ON "abc"."foo"="efg"."bar" ' + 'ORDER BY DATE("abc"."foo")', + str(test_query), + ) + + def test_join_from_join(self): + test_query = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.efg_id == self.table_efg.id) + .join(self.table_hij) + .on(self.table_efg.hij_id == self.table_hij.id) + .select(self.table_abc.foo, self.table_efg.bar, self.table_hij.fizz) + ) + + self.assertEqual( + 'SELECT "abc"."foo","efg"."bar","hij"."fizz" FROM "abc" ' + 'JOIN "efg" ON "abc"."efg_id"="efg"."id" ' + 'JOIN "hij" ON "efg"."hij_id"="hij"."id"', + str(test_query), + ) + + def test_join_query_without_alias(self): + subquery = Query.from_(self.table_efg).select( + self.table_efg.base_id.as_("x"), self.table_efg.fizz, self.table_efg.buzz + ) + + test_query = ( + Query.from_(self.table_abc) + .join(subquery) + .on(subquery.x == self.table_abc.id) + .select(self.table_abc.foo, subquery.fizz, subquery.buzz) + ) + + self.assertEqual( + 'SELECT "abc"."foo","sq0"."fizz","sq0"."buzz" ' + 'FROM "abc" JOIN (' + 'SELECT "base_id" "x","fizz","buzz" FROM "efg"' + ') "sq0" ' + 'ON "sq0"."x"="abc"."id"', + str(test_query), + ) + + def test_join_query_with_column_alias(self): + subquery = ( + Query.from_(self.table_efg) + .select( + self.table_efg.base_id.as_("x"), + self.table_efg.fizz, + self.table_efg.buzz, + ) + .as_("subq") + ) + + test_query = ( + Query.from_(self.table_abc) + .join(subquery) + .on(subquery.x == self.table_abc.id) + .select(self.table_abc.foo, subquery.fizz, subquery.buzz) + ) + + self.assertEqual( + 'SELECT "abc"."foo","subq"."fizz","subq"."buzz" ' + 'FROM "abc" JOIN (' + 'SELECT "base_id" "x","fizz","buzz" FROM "efg"' + ') "subq" ' + 'ON "subq"."x"="abc"."id"', + str(test_query), + ) + + def test_join_query_with_table_alias(self): + xxx = self.table_efg.as_("xxx") + subquery = Query.from_(xxx).select(xxx.base_id, xxx.fizz, xxx.buzz).as_("subq") + + test_query = ( + Query.from_(self.table_abc) + .join(subquery) + .on(subquery.x == self.table_abc.id) + .select(self.table_abc.foo, subquery.fizz, subquery.buzz) + ) + + self.assertEqual( + 'SELECT "abc"."foo","subq"."fizz","subq"."buzz" ' + 'FROM "abc" JOIN (' + 'SELECT "xxx"."base_id","xxx"."fizz","xxx"."buzz" FROM "efg" "xxx"' + ') "subq" ' + 'ON "subq"."x"="abc"."id"', + str(test_query), + ) + + def test_join_query_with_setoperation(self): + subquery = Query.from_(self.table_abc).select("*").union(Query.from_(self.table_abc).select("*")).as_("subq") + + test_query = ( + Query.from_(self.table_abc).join(subquery).on(subquery.x == self.table_abc.id).select(self.table_abc.foo) + ) + + self.assertEqual( + 'SELECT "abc"."foo" FROM "abc" ' + 'JOIN ' + '((SELECT * FROM "abc") ' + 'UNION ' + '(SELECT * FROM "abc")) "subq" ' + 'ON "subq"."x"="abc"."id"', + str(test_query), + ) + + +class UnionTests(unittest.TestCase): + table1, table2 = Tables("abc", "efg") + + def test_union(self): + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + + self.assertEqual( + '(SELECT "foo" FROM "abc") UNION (SELECT "bar" FROM "efg")', + str(query1 + query2), + ) + self.assertEqual( + '(SELECT "foo" FROM "abc") UNION (SELECT "bar" FROM "efg")', + str(query1.union(query2)), + ) + + def test_union_multiple(self): + table3, table4 = Tables("hij", "lmn") + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + query3 = Query.from_(table3).select(table3.baz) + query4 = Query.from_(table4).select(table4.faz) + + self.assertEqual( + '(SELECT "foo" FROM "abc") UNION ' + '(SELECT "bar" FROM "efg") UNION ' + '(SELECT "baz" FROM "hij") UNION ' + '(SELECT "faz" FROM "lmn")', + str(query1 + query2 + query3 + query4), + ) + self.assertEqual( + '(SELECT "foo" FROM "abc") UNION ' + '(SELECT "bar" FROM "efg") UNION ' + '(SELECT "baz" FROM "hij") UNION ' + '(SELECT "faz" FROM "lmn")', + str(query1.union(query2).union(query3).union(query4)), + ) + + def test_union_all(self): + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + + self.assertEqual( + '(SELECT "foo" FROM "abc") UNION ALL (SELECT "bar" FROM "efg")', + str(query1 * query2), + ) + self.assertEqual( + '(SELECT "foo" FROM "abc") UNION ALL (SELECT "bar" FROM "efg")', + str(query1.union_all(query2)), + ) + + def test_union_all_multiple(self): + table3, table4 = Tables("hij", "lmn") + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + query3 = Query.from_(table3).select(table3.baz) + query4 = Query.from_(table4).select(table4.faz) + + self.assertEqual( + '(SELECT "foo" FROM "abc") UNION ALL ' + '(SELECT "bar" FROM "efg") UNION ALL ' + '(SELECT "baz" FROM "hij") UNION ALL ' + '(SELECT "faz" FROM "lmn")', + str(query1 * query2 * query3 * query4), + ) + self.assertEqual( + '(SELECT "foo" FROM "abc") UNION ALL ' + '(SELECT "bar" FROM "efg") UNION ALL ' + '(SELECT "baz" FROM "hij") UNION ALL ' + '(SELECT "faz" FROM "lmn")', + str(query1.union_all(query2).union_all(query3).union_all(query4)), + ) + + def test_union_with_order_by(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + union_query = str((query1 + query2).orderby(query1.field("a"))) + union_all_query = str((query1 * query2).orderby(query1.field("a"))) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "UNION " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "a"', + union_query, + ) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "UNION ALL " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "a"', + union_all_query, + ) + + def test_union_with_order_by_use_union_query_field(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + union_query = query1 + query2 + union_query = str(union_query.orderby(union_query.field("a"))) + union_all_query = query1 * query2 + union_all_query = str(union_all_query.orderby(union_all_query.field("a"))) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "UNION " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "a"', + union_query, + ) + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "UNION ALL " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "a"', + union_all_query, + ) + + def test_union_with_order_by_with_aliases(self): + query1 = Query.from_(self.table1.as_("a")).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2.as_("b")).select(self.table2.bar.as_("a")) + + union_all_query = str((query1 * query2).orderby(query1.field("a"))) + union_query = str((query1 + query2).orderby(query1.field("a"))) + self.assertEqual( + '(SELECT "foo" "a" FROM "abc" "a")' " UNION ALL " '(SELECT "bar" "a" FROM "efg" "b")' ' ORDER BY "a"', + union_all_query, + ) + self.assertEqual( + '(SELECT "foo" "a" FROM "abc" "a")' " UNION " '(SELECT "bar" "a" FROM "efg" "b")' ' ORDER BY "a"', + union_query, + ) + + def test_union_with_order_by_use_union_query_field_with_aliases(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + union_query = (query1 + query2).as_("x") + union_query = union_query.orderby(union_query.field("a")) + union_all_query = (query1 * query2).as_("x") + union_all_query = union_all_query.orderby(union_all_query.field("a")) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "UNION " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "x"."a"', + str(union_query), + ) + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "UNION ALL " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "x"."a"', + str(union_all_query), + ) + + def test_require_equal_number_of_fields(self): + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.fiz, self.table2.buz) + + with self.assertRaises(SetOperationException): + str(query1 + query2) + + def test_mysql_query_wraps_unioned_queries(self): + query1 = MySQLQuery.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + + self.assertEqual( + "(SELECT `foo` FROM `abc`) UNION (SELECT `bar` FROM `efg`)", + str(query1 + query2), + ) + + def test_union_as_subquery(self): + abc, efg = Tables("abc", "efg") + hij = Query.from_(abc).select(abc.t).union(Query.from_(efg).select(efg.t)) + q = Query.from_(hij).select(fn.Avg(hij.t)) + + self.assertEqual( + 'SELECT AVG("sq0"."t") FROM ((SELECT "t" FROM "abc") UNION (SELECT "t" FROM "efg")) "sq0"', + str(q), + ) + + def test_union_with_no_quote_char(self): + abc, efg = Tables("abc", "efg") + hij = Query.from_(abc).select(abc.t).union(Query.from_(efg).select(efg.t)) + q = Query.from_(hij).select(fn.Avg(hij.t)) + + self.assertEqual( + "SELECT AVG(sq0.t) FROM ((SELECT t FROM abc) UNION (SELECT t FROM efg)) sq0", + q.get_sql(quote_char=None), + ) + + +class InsertQueryJoinTests(unittest.TestCase): + def test_join_table_on_insert_query(self): + a, b, c = Tables("a", "b", "c") + q = Query.into(c).from_(a).join(b).on(a.fkey_id == b.id).where(b.foo == 1).select("a.*", "b.*") + + self.assertEqual( + 'INSERT INTO "c" ' + 'SELECT "a"."a.*","a"."b.*" ' + 'FROM "a" JOIN "b" ' + 'ON "a"."fkey_id"="b"."id" ' + 'WHERE "b"."foo"=1', + str(q), + ) + + +class UpdateQueryJoinTests(unittest.TestCase): + def test_join_table_on_update_query(self): + a, b = Tables("a", "b") + q = Query.update(a).join(b).on(a.fkey_id == b.id).where(b.foo == 1).set("adwords_batch_job_id", 1) + + self.assertEqual( + 'UPDATE "a" ' 'JOIN "b" ' 'ON "a"."fkey_id"="b"."id" ' 'SET "adwords_batch_job_id"=1 ' 'WHERE "b"."foo"=1', + str(q), + ) + + +class IntersectTests(unittest.TestCase): + table1, table2 = Tables("abc", "efg") + + def test_intersect(self): + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + + self.assertEqual( + '(SELECT "foo" FROM "abc") INTERSECT (SELECT "bar" FROM "efg")', + str(query1.intersect(query2)), + ) + + def test_intersect_multiple(self): + table3, table4 = Tables("hij", "lmn") + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + query3 = Query.from_(table3).select(table3.baz) + query4 = Query.from_(table4).select(table4.faz) + + self.assertEqual( + '(SELECT "foo" FROM "abc") INTERSECT ' + '(SELECT "bar" FROM "efg") INTERSECT ' + '(SELECT "baz" FROM "hij") INTERSECT ' + '(SELECT "faz" FROM "lmn")', + str(query1.intersect(query2).intersect(query3).intersect(query4)), + ) + + def test_intersect_with_order_by(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + intersect_query = str((query1.intersect(query2)).orderby(query1.field("a"))) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "INTERSECT " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "a"', + intersect_query, + ) + + def test_intersect_with_limit(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + intersect_query = str((query1.intersect(query2)).limit(10)) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "INTERSECT " '(SELECT "bar" "a" FROM "efg") ' 'LIMIT 10', + intersect_query, + ) + + def test_intersect_with_offset(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + intersect_query = str((query1.intersect(query2)).offset(10)) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "INTERSECT " '(SELECT "bar" "a" FROM "efg") ' 'OFFSET 10', + intersect_query, + ) + + def test_require_equal_number_of_fields_intersect(self): + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.fiz, self.table2.buz) + + with self.assertRaises(SetOperationException): + str(query1.intersect(query2)) + + def test_mysql_query_wraps_intersected_queries(self): + query1 = MySQLQuery.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + + self.assertEqual( + "(SELECT `foo` FROM `abc`) INTERSECT (SELECT `bar` FROM `efg`)", + str(query1.intersect(query2)), + ) + + def test_intersect_as_subquery(self): + abc, efg = Tables("abc", "efg") + hij = Query.from_(abc).select(abc.t).intersect(Query.from_(efg).select(efg.t)) + q = Query.from_(hij).select(fn.Avg(hij.t)) + + self.assertEqual( + 'SELECT AVG("sq0"."t") FROM ((SELECT "t" FROM "abc") INTERSECT (SELECT "t" FROM "efg")) "sq0"', + str(q), + ) + + def test_intersect_with_no_quote_char(self): + abc, efg = Tables("abc", "efg") + hij = Query.from_(abc).select(abc.t).intersect(Query.from_(efg).select(efg.t)) + q = Query.from_(hij).select(fn.Avg(hij.t)) + + self.assertEqual( + "SELECT AVG(sq0.t) FROM ((SELECT t FROM abc) INTERSECT (SELECT t FROM efg)) sq0", + q.get_sql(quote_char=None), + ) + + +class MinusTests(unittest.TestCase): + table1, table2 = Tables("abc", "efg") + + def test_minus(self): + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + + self.assertEqual('(SELECT "foo" FROM "abc") MINUS (SELECT "bar" FROM "efg")', str(query1.minus(query2))) + + self.assertEqual( + '(SELECT "foo" FROM "abc") MINUS (SELECT "bar" FROM "efg")', + str(query1 - query2), + ) + + def test_minus_multiple(self): + table3, table4 = Tables("hij", "lmn") + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + query3 = Query.from_(table3).select(table3.baz) + query4 = Query.from_(table4).select(table4.faz) + + self.assertEqual( + '(SELECT "foo" FROM "abc") MINUS ' + '(SELECT "bar" FROM "efg") MINUS ' + '(SELECT "baz" FROM "hij") MINUS ' + '(SELECT "faz" FROM "lmn")', + str(query1 - query2 - query3 - query4), + ) + + self.assertEqual( + '(SELECT "foo" FROM "abc") MINUS ' + '(SELECT "bar" FROM "efg") MINUS ' + '(SELECT "baz" FROM "hij") MINUS ' + '(SELECT "faz" FROM "lmn")', + str(query1.minus(query2).minus(query3).minus(query4)), + ) + + def test_minus_with_order_by(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + minus_query = str(query1.minus(query2).orderby(query1.field("a"))) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "MINUS " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "a"', minus_query + ) + + def test_minus_query_with_order_by_use_minus_query_field(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + minus_query = query1.minus(query2) + minus_query = str(minus_query.orderby(minus_query.field("b"))) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "MINUS " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "b"', + minus_query, + ) + + def test_require_equal_number_of_fields(self): + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.fiz, self.table2.buz) + + with self.assertRaises(SetOperationException): + str(query1.minus(query2)) + + def test_mysql_query_wraps_minus_queries(self): + query1 = MySQLQuery.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + + self.assertEqual( + "(SELECT `foo` FROM `abc`) MINUS (SELECT `bar` FROM `efg`)", + str(query1 - query2), + ) + + def test_minus_as_subquery(self): + abc, efg = Tables("abc", "efg") + hij = Query.from_(abc).select(abc.t).minus(Query.from_(efg).select(efg.t)) + q = Query.from_(hij).select(fn.Avg(hij.t)) + + self.assertEqual( + 'SELECT AVG("sq0"."t") FROM ((SELECT "t" FROM "abc") MINUS (SELECT "t" FROM "efg")) "sq0"', + str(q), + ) + + def test_minus_with_no_quote_char(self): + abc, efg = Tables("abc", "efg") + hij = Query.from_(abc).select(abc.t).minus(Query.from_(efg).select(efg.t)) + q = Query.from_(hij).select(fn.Avg(hij.t)) + + self.assertEqual( + "SELECT AVG(sq0.t) FROM ((SELECT t FROM abc) MINUS (SELECT t FROM efg)) sq0", + q.get_sql(quote_char=None), + ) + + +class ExceptOfTests(unittest.TestCase): + table1, table2 = Tables("abc", "efg") + + def test_except(self): + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + + self.assertEqual('(SELECT "foo" FROM "abc") EXCEPT (SELECT "bar" FROM "efg")', str(query1.except_of(query2))) + + def test_except_multiple(self): + table3, table4 = Tables("hij", "lmn") + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + query3 = Query.from_(table3).select(table3.baz) + query4 = Query.from_(table4).select(table4.faz) + + self.assertEqual( + '(SELECT "foo" FROM "abc") EXCEPT ' + '(SELECT "bar" FROM "efg") EXCEPT ' + '(SELECT "baz" FROM "hij") EXCEPT ' + '(SELECT "faz" FROM "lmn")', + str(query1.except_of(query2).except_of(query3).except_of(query4)), + ) + + def test_except_with_order_by(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + except_query = str(query1.except_of(query2).orderby(query1.field("a"))) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "EXCEPT " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "a"', except_query + ) + + def test_except_query_with_order_by_use_minus_query_field(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + except_query = query1.except_of(query2) + except_query = str(except_query.orderby(except_query.field("b"))) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "EXCEPT " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "b"', + except_query, + ) + + def test_require_equal_number_of_fields_except_of(self): + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.fiz, self.table2.buz) + + with self.assertRaises(SetOperationException): + str(query1.except_of(query2)) + + def test_except_as_subquery(self): + abc, efg = Tables("abc", "efg") + hij = Query.from_(abc).select(abc.t).except_of(Query.from_(efg).select(efg.t)) + q = Query.from_(hij).select(fn.Avg(hij.t)) + + self.assertEqual( + 'SELECT AVG("sq0"."t") FROM ((SELECT "t" FROM "abc") EXCEPT (SELECT "t" FROM "efg")) "sq0"', + str(q), + ) + + def test_except_with_no_quote_char(self): + abc, efg = Tables("abc", "efg") + hij = Query.from_(abc).select(abc.t).except_of(Query.from_(efg).select(efg.t)) + q = Query.from_(hij).select(fn.Avg(hij.t)) + + self.assertEqual( + "SELECT AVG(sq0.t) FROM ((SELECT t FROM abc) EXCEPT (SELECT t FROM efg)) sq0", + q.get_sql(quote_char=None), + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/test_negation.py b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/test_negation.py new file mode 100644 index 0000000000000000000000000000000000000000..9f4db83b560dbc8546ce6d384b781dfccefd319d --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/test_negation.py @@ -0,0 +1,31 @@ +import unittest + +from pypika import ( + Tables, + functions as fn, +) +from pypika.terms import ValueWrapper + + +class NegationTests(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_negate_wrapped_float(self): + q = -ValueWrapper(1.0) + + self.assertEqual("-1.0", q.get_sql()) + + def test_negate_wrapped_int(self): + q = -ValueWrapper(1) + + self.assertEqual("-1", q.get_sql()) + + def test_negate_field(self): + q = -self.table_abc.foo + + self.assertEqual('-"abc"."foo"', q.get_sql(with_namespace=True, quote_char='"')) + + def test_negate_function(self): + q = -fn.Sum(self.table_abc.foo) + + self.assertEqual('-SUM("abc"."foo")', q.get_sql(with_namespace=True, quote_char='"')) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/test_parameter.py b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/test_parameter.py new file mode 100644 index 0000000000000000000000000000000000000000..c11e9afcd9624abb0a7313306eda34ebcf4c99ba --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/test_parameter.py @@ -0,0 +1,206 @@ +import unittest +from datetime import date + +from pypika import ( + FormatParameter, + NamedParameter, + NumericParameter, + Parameter, + PyformatParameter, + QmarkParameter, + Query, + Tables, +) +from pypika.terms import ListParameter, ParameterValueWrapper + + +class ParametrizedTests(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_param_insert(self): + q = Query.into(self.table_abc).columns("a", "b", "c").insert(Parameter("?"), Parameter("?"), Parameter("?")) + + self.assertEqual('INSERT INTO "abc" ("a","b","c") VALUES (?,?,?)', q.get_sql()) + + def test_param_select_join(self): + q = ( + Query.from_(self.table_abc) + .select("*") + .where(self.table_abc.category == Parameter("%s")) + .join(self.table_efg) + .on(self.table_abc.id == self.table_efg.abc_id) + .where(self.table_efg.date >= Parameter("%s")) + .limit(10) + ) + + self.assertEqual( + 'SELECT * FROM "abc" JOIN "efg" ON "abc"."id"="efg"."abc_id" WHERE "abc"."category"=%s AND "efg"."date">=%s LIMIT 10', + q.get_sql(), + ) + + def test_param_select_subquery(self): + q = ( + Query.from_(self.table_abc) + .select("*") + .where(self.table_abc.category == Parameter("&1")) + .where( + self.table_abc.id.isin( + Query.from_(self.table_efg) + .select(self.table_efg.abc_id) + .where(self.table_efg.date >= Parameter("&2")) + ) + ) + .limit(10) + ) + + self.assertEqual( + 'SELECT * FROM "abc" WHERE "category"=&1 AND "id" IN (SELECT "abc_id" FROM "efg" WHERE "date">=&2) LIMIT 10', + q.get_sql(), + ) + + def test_join(self): + subquery = ( + Query.from_(self.table_efg) + .select(self.table_efg.fiz, self.table_efg.buz) + .where(self.table_efg.buz == Parameter(":buz")) + ) + + q = ( + Query.from_(self.table_abc) + .join(subquery) + .on(self.table_abc.bar == subquery.buz) + .select(self.table_abc.foo, subquery.fiz) + .where(self.table_abc.bar == Parameter(":bar")) + ) + + self.assertEqual( + 'SELECT "abc"."foo","sq0"."fiz" FROM "abc" JOIN (SELECT "fiz","buz" FROM "efg" WHERE "buz"=:buz)' + ' "sq0" ON "abc"."bar"="sq0"."buz" WHERE "abc"."bar"=:bar', + q.get_sql(), + ) + + def test_qmark_parameter(self): + self.assertEqual('?', QmarkParameter().get_sql()) + + def test_numeric_parameter(self): + self.assertEqual(':14', NumericParameter('14').get_sql()) + self.assertEqual(':15', NumericParameter(15).get_sql()) + + def test_named_parameter(self): + self.assertEqual(':buz', NamedParameter('buz').get_sql()) + + def test_format_parameter(self): + self.assertEqual('%s', FormatParameter().get_sql()) + + def test_pyformat_parameter(self): + self.assertEqual('%(buz)s', PyformatParameter('buz').get_sql()) + + +class ParametrizedTestsWithValues(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_param_insert(self): + q = Query.into(self.table_abc).columns("a", "b", "c").insert(1, 2.2, 'foo') + + parameter = QmarkParameter() + sql = q.get_sql(parameter=parameter) + self.assertEqual('INSERT INTO "abc" ("a","b","c") VALUES (?,?,?)', sql) + self.assertEqual([1, 2.2, 'foo'], parameter.get_parameters()) + + def test_param_select_join(self): + q = ( + Query.from_(self.table_abc) + .select("*") + .where(self.table_abc.category == 'foobar') + .join(self.table_efg) + .on(self.table_abc.id == self.table_efg.abc_id) + .where(self.table_efg.date >= date(2024, 2, 22)) + .limit(10) + ) + + parameter = FormatParameter() + sql = q.get_sql(parameter=parameter) + self.assertEqual( + 'SELECT * FROM "abc" JOIN "efg" ON "abc"."id"="efg"."abc_id" WHERE "abc"."category"=%s AND "efg"."date">=%s LIMIT 10', + sql, + ) + self.assertEqual(['foobar', '2024-02-22'], parameter.get_parameters()) + + def test_param_select_subquery(self): + q = ( + Query.from_(self.table_abc) + .select("*") + .where(self.table_abc.category == 'foobar') + .where( + self.table_abc.id.isin( + Query.from_(self.table_efg) + .select(self.table_efg.abc_id) + .where(self.table_efg.date >= date(2024, 2, 22)) + ) + ) + .limit(10) + ) + + parameter = ListParameter(placeholder=lambda idx: f'&{idx+1}') + sql = q.get_sql(parameter=parameter) + self.assertEqual( + 'SELECT * FROM "abc" WHERE "category"=&1 AND "id" IN (SELECT "abc_id" FROM "efg" WHERE "date">=&2) LIMIT 10', + sql, + ) + self.assertEqual(['foobar', '2024-02-22'], parameter.get_parameters()) + + def test_join(self): + subquery = ( + Query.from_(self.table_efg) + .select(self.table_efg.fiz, self.table_efg.buz) + .where(self.table_efg.buz == 'buz') + ) + + q = ( + Query.from_(self.table_abc) + .join(subquery) + .on(self.table_abc.bar == subquery.buz) + .select(self.table_abc.foo, subquery.fiz) + .where(self.table_abc.bar == 'bar') + ) + + parameter = NamedParameter() + sql = q.get_sql(parameter=parameter) + self.assertEqual( + 'SELECT "abc"."foo","sq0"."fiz" FROM "abc" JOIN (SELECT "fiz","buz" FROM "efg" WHERE "buz"=:param1)' + ' "sq0" ON "abc"."bar"="sq0"."buz" WHERE "abc"."bar"=:param2', + sql, + ) + self.assertEqual({'param1': 'buz', 'param2': 'bar'}, parameter.get_parameters()) + + def test_join_with_parameter_value_wrapper(self): + subquery = ( + Query.from_(self.table_efg) + .select(self.table_efg.fiz, self.table_efg.buz) + .where(self.table_efg.buz == ParameterValueWrapper(Parameter(':buz'), 'buz')) + ) + + q = ( + Query.from_(self.table_abc) + .join(subquery) + .on(self.table_abc.bar == subquery.buz) + .select(self.table_abc.foo, subquery.fiz) + .where(self.table_abc.bar == ParameterValueWrapper(NamedParameter('bar'), 'bar')) + ) + + parameter = NamedParameter() + sql = q.get_sql(parameter=parameter) + self.assertEqual( + 'SELECT "abc"."foo","sq0"."fiz" FROM "abc" JOIN (SELECT "fiz","buz" FROM "efg" WHERE "buz"=:buz)' + ' "sq0" ON "abc"."bar"="sq0"."buz" WHERE "abc"."bar"=:bar', + sql, + ) + self.assertEqual({':buz': 'buz', 'bar': 'bar'}, parameter.get_parameters()) + + def test_pyformat_parameter(self): + q = Query.into(self.table_abc).columns("a", "b", "c").insert(1, 2.2, 'foo') + + parameter = PyformatParameter() + sql = q.get_sql(parameter=parameter) + self.assertEqual('INSERT INTO "abc" ("a","b","c") VALUES (%(param1)s,%(param2)s,%(param3)s)', sql) + self.assertEqual({"param1": 1, "param2": 2.2, "param3": "foo"}, parameter.get_parameters()) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/test_pseudocolumns.py b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/test_pseudocolumns.py new file mode 100644 index 0000000000000000000000000000000000000000..6a25c70269b2ccc98ac3870ac64a43c8a32ddbe9 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/test_pseudocolumns.py @@ -0,0 +1,51 @@ +import unittest + +from pypika import Query, Table +from pypika.pseudocolumns import ( + ColumnValue, + ObjectID, + ObjectValue, + RowID, + RowNum, + SysDate, +) +from pypika.terms import PseudoColumn + + +class PseudoColumnsTest(unittest.TestCase): + @classmethod + def setUpClass(cls): + super(PseudoColumnsTest, cls).setUpClass() + cls.table1 = Table("table1") + + def test_column_value(self): + self.assertEqual("COLUMN_VALUE", ColumnValue) + + def test_object_id(self): + self.assertEqual("OBJECT_ID", ObjectID) + + def test_object_value(self): + self.assertEqual("OBJECT_VALUE", ObjectValue) + + def test_row_id(self): + self.assertEqual("ROWID", RowID) + + def test_row_num(self): + self.assertEqual("ROWNUM", RowNum) + + def test_sys_date(self): + self.assertEqual("SYSDATE", SysDate) + + def test_can_be_used_in_a_select_statement(self): + query = Query.from_(self.table1).where(self.table1.is_active == 1).select(PseudoColumn("abcde")) + + self.assertEqual(str(query), 'SELECT abcde FROM "table1" WHERE "is_active"=1') + + def test_can_be_used_in_a_where_clause(self): + query = Query.from_(self.table1).where(PseudoColumn("abcde") > 1).select(self.table1.is_active) + + self.assertEqual(str(query), 'SELECT "is_active" FROM "table1" WHERE abcde>1') + + def test_can_be_used_in_orderby(self): + query = Query.from_(self.table1).select(self.table1.abcde.as_("some_name")).orderby(PseudoColumn("some_name")) + self.assertEqual(str(query), 'SELECT "abcde" "some_name" FROM "table1" ORDER BY some_name') diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/test_query.py b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/test_query.py new file mode 100644 index 0000000000000000000000000000000000000000..ae8dc01599a6a562b591ce15391bfe9b5c87e0f9 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/test_query.py @@ -0,0 +1,242 @@ +import unittest + +from pypika import Case, Query, Tables, Tuple, functions, Field +from pypika.dialects import ( + ClickHouseQuery, + ClickHouseQueryBuilder, + MSSQLQuery, + MSSQLQueryBuilder, + MySQLLoadQueryBuilder, + MySQLQuery, + MySQLQueryBuilder, + OracleQuery, + OracleQueryBuilder, + PostgreSQLQuery, + PostgreSQLQueryBuilder, + RedShiftQueryBuilder, + RedshiftQuery, + SQLLiteQuery, + SQLLiteQueryBuilder, + SnowflakeQuery, + SnowflakeQueryBuilder, + VerticaCopyQueryBuilder, + VerticaCreateQueryBuilder, + VerticaQuery, + VerticaQueryBuilder, +) +from pypika.queries import CreateQueryBuilder, DropQueryBuilder, QueryBuilder + + +class QueryTablesTests(unittest.TestCase): + table_a, table_b, table_c, table_d = Tables("a", "b", "c", "d") + + def test_replace_table(self): + query = Query.from_(self.table_a).select(self.table_a.time) + query = query.replace_table(self.table_a, self.table_b) + + self.assertEqual('SELECT "time" FROM "b"', str(query)) + + def test_replace_only_specified_table(self): + query = Query.from_(self.table_a).select(self.table_a.time) + query = query.replace_table(self.table_b, self.table_c) + + self.assertEqual('SELECT "time" FROM "a"', str(query)) + + def test_replace_insert_table(self): + query = Query.into(self.table_a).insert(1) + query = query.replace_table(self.table_a, self.table_b) + + self.assertEqual('INSERT INTO "b" VALUES (1)', str(query)) + + def test_replace_insert_table_current_table_not_match(self): + query = Query.into(self.table_a).insert(1) + query = query.replace_table(self.table_c, self.table_b) + + self.assertEqual('INSERT INTO "a" VALUES (1)', str(query)) + + def test_replace_update_table(self): + query = Query.update(self.table_a).set("foo", "bar") + query = query.replace_table(self.table_a, self.table_b) + + self.assertEqual('UPDATE "b" SET "foo"=\'bar\'', str(query)) + + def test_replace_update_table_current_table_not_match(self): + query = Query.update(self.table_a).set("foo", "bar") + query = query.replace_table(self.table_c, self.table_b) + + self.assertEqual('UPDATE "a" SET "foo"=\'bar\'', str(query)) + + def test_replace_delete_table(self): + query = Query.from_(self.table_a).delete() + query = query.replace_table(self.table_a, self.table_b) + + self.assertEqual('DELETE FROM "b"', str(query)) + + def test_replace_join_tables(self): + query = ( + Query.from_(self.table_a) + .join(self.table_b) + .on(self.table_a.customer_id == self.table_b.id) + .join(self.table_c) + .on(self.table_b.seller_id == self.table_c.id) + .select(self.table_a.star) + ) + query = query.replace_table(self.table_a, self.table_d) + + self.assertEqual( + 'SELECT "d".* ' + 'FROM "d" ' + 'JOIN "b" ON "d"."customer_id"="b"."id" ' + 'JOIN "c" ON "b"."seller_id"="c"."id"', + str(query), + ) + + def test_replace_filter_tables(self): + query = Query.from_(self.table_a).select(self.table_a.name).where(self.table_a.name == "Mustermann") + query = query.replace_table(self.table_a, self.table_b) + + self.assertEqual('SELECT "name" FROM "b" WHERE "name"=\'Mustermann\'', str(query)) + + def test_replace_having_table(self): + query = ( + Query.from_(self.table_a) + .select(functions.Sum(self.table_a.revenue)) + .groupby(self.table_a.customer) + .having(functions.Sum(self.table_a.revenue) >= 1000) + ) + query = query.replace_table(self.table_a, self.table_b) + + self.assertEqual( + 'SELECT SUM("revenue") ' 'FROM "b" ' 'GROUP BY "customer" ' 'HAVING SUM("revenue")>=1000', + str(query), + ) + + def test_replace_case_table(self): + query = Query.from_(self.table_a).select( + Case() + .when(self.table_a.fname == "Tom", "It was Tom") + .when(self.table_a.fname == "John", "It was John") + .else_("It was someone else.") + .as_("who_was_it") + ) + query = query.replace_table(self.table_a, self.table_b) + + self.assertEqual( + "SELECT CASE " + "WHEN \"fname\"='Tom' THEN 'It was Tom' " + "WHEN \"fname\"='John' THEN 'It was John' " + "ELSE 'It was someone else.' END \"who_was_it\" " + 'FROM "b"', + str(query), + ) + + def test_replace_orderby_table(self): + query = Query.from_(self.table_a).select(self.table_a.customer).orderby(self.table_a.customer) + query = query.replace_table(self.table_a, self.table_b) + + self.assertEqual('SELECT "customer" FROM "b" ORDER BY "customer"', str(query)) + + def test_replace_tuple_table(self): + query = ( + Query.from_(self.table_a) + .select(self.table_a.cost, self.table_a.revenue) + .where((self.table_a.cost, self.table_a.revenue) == Tuple(1, 2)) + ) + + query = query.replace_table(self.table_a, self.table_b) + + # Order is reversed due to lack of right equals method + self.assertEqual( + 'SELECT "cost","revenue" FROM "b" WHERE (1,2)=("cost","revenue")', + str(query), + ) + + def test_is_joined(self): + q = Query.from_(self.table_a).join(self.table_b).on(self.table_a.foo == self.table_b.boo) + + self.assertTrue(q.is_joined(self.table_b)) + self.assertFalse(q.is_joined(self.table_c)) + + +class QueryBuilderTests(unittest.TestCase): + def test_query_builders_have_reference_to_correct_query_class(self): + with self.subTest('QueryBuilder'): + self.assertEqual(Query, QueryBuilder.QUERY_CLS) + + with self.subTest('DropQueryBuilder'): + self.assertEqual(Query, DropQueryBuilder.QUERY_CLS) + + with self.subTest('CreateQueryBuilder'): + self.assertEqual(Query, CreateQueryBuilder.QUERY_CLS) + + with self.subTest('MySQLQueryBuilder'): + self.assertEqual(MySQLQuery, MySQLQueryBuilder.QUERY_CLS) + + with self.subTest('MySQLLoadQueryBuilder'): + self.assertEqual(MySQLQuery, MySQLLoadQueryBuilder.QUERY_CLS) + + with self.subTest('VerticaQueryBuilder'): + self.assertEqual(VerticaQuery, VerticaQueryBuilder.QUERY_CLS) + + with self.subTest('VerticaCreateQueryBuilder'): + self.assertEqual(VerticaQuery, VerticaCreateQueryBuilder.QUERY_CLS) + + with self.subTest('VerticaCopyQueryBuilder'): + self.assertEqual(VerticaQuery, VerticaCopyQueryBuilder.QUERY_CLS) + + with self.subTest('PostgreSQLQueryBuilder'): + self.assertEqual(PostgreSQLQuery, PostgreSQLQueryBuilder.QUERY_CLS) + + with self.subTest('MSSQLQueryBuilder'): + self.assertEqual(MSSQLQuery, MSSQLQueryBuilder.QUERY_CLS) + + with self.subTest('SnowflakeQueryBuilder'): + self.assertEqual(SnowflakeQuery, SnowflakeQueryBuilder.QUERY_CLS) + + with self.subTest('ClickHouseQueryBuilder'): + self.assertEqual(ClickHouseQuery, ClickHouseQueryBuilder.QUERY_CLS) + + with self.subTest('RedShiftQueryBuilder'): + self.assertEqual(RedshiftQuery, RedShiftQueryBuilder.QUERY_CLS) + + with self.subTest('SQLLiteQueryBuilder'): + self.assertEqual(SQLLiteQuery, SQLLiteQueryBuilder.QUERY_CLS) + + with self.subTest('OracleQueryBuilder'): + self.assertEqual(OracleQuery, OracleQueryBuilder.QUERY_CLS) + + def test_pipe(self) -> None: + base_query = Query.from_("test") + + def select(query: QueryBuilder) -> QueryBuilder: + return query.select("test1", "test2") + + def count_group(query: QueryBuilder, *groups) -> QueryBuilder: + return query.groupby(*groups).select(*groups, functions.Count("*")) + + for func, args, kwargs, expected_str in [ + (select, [], {}, 'SELECT "test1","test2" FROM "test"'), + ( + count_group, + ["test1", "test2"], + {}, + 'SELECT "test1","test2",COUNT(*) FROM "test" GROUP BY "test1","test2"', + ), + (count_group, ["test1"], {}, 'SELECT "test1",COUNT(*) FROM "test" GROUP BY "test1"'), + ]: + result_str = str(base_query.pipe(func, *args, **kwargs)) + self.assertEqual(result_str, str(func(base_query, *args, **kwargs))) + self.assertEqual(result_str, expected_str) + + def where_clause(query: QueryBuilder, num_days: int) -> QueryBuilder: + return query.where(Field("date") > functions.Now() - num_days) + + result_str = str(base_query.pipe(select).pipe(where_clause, num_days=1)) + self.assertEqual( + result_str, + str(select(where_clause(base_query, num_days=1))), + ) + self.assertEqual( + result_str, + 'SELECT "test1","test2" FROM "test" WHERE "date">NOW()-1', + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/test_selects.py b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/test_selects.py new file mode 100644 index 0000000000000000000000000000000000000000..1ce04937492e655db362b7e2a0a6856abf22a48f --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/test_selects.py @@ -0,0 +1,1331 @@ +import unittest +from datetime import date +from enum import Enum + +from pypika import ( + AliasedQuery, + Case, + ClickHouseQuery, + EmptyCriterion, + Field as F, + Index, + MSSQLQuery, + MySQLQuery, + NullValue, + OracleQuery, + Order, + PostgreSQLQuery, + Query, + QueryException, + RedshiftQuery, + SQLLiteQuery, + Table, + Tables, + VerticaQuery, + functions as fn, + SYSTEM_TIME, +) +from pypika.terms import ValueWrapper + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + + +class SelectTests(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_empty_query(self): + q = Query.from_("abc") + + self.assertEqual("", str(q)) + + def test_select_no_from(self): + q = Query.select(1) + + self.assertEqual("SELECT 1", str(q)) + + def test_select_no_with_alias_from(self): + q = Query.select(ValueWrapper(1, "test")) + + self.assertEqual('SELECT 1 "test"', str(q)) + + def test_select_no_from_with_field_raises_exception(self): + with self.assertRaises(QueryException): + Query.select("asdf") + + def test_select__star(self): + q = Query.from_("abc").select("*") + + self.assertEqual('SELECT * FROM "abc"', str(q)) + + def test_select__table_schema(self): + q = Query.from_(Table("abc", "schema1")).select("*") + + self.assertEqual('SELECT * FROM "schema1"."abc"', str(q)) + + def test_select__table_schema_with_multiple_levels_as_tuple(self): + q = Query.from_(Table("abc", ("schema1", "schema2"))).select("*") + + self.assertEqual('SELECT * FROM "schema1"."schema2"."abc"', str(q)) + + def test_select__table_schema_with_multiple_levels_as_list(self): + q = Query.from_(Table("abc", ["schema1", "schema2"])).select("*") + + self.assertEqual('SELECT * FROM "schema1"."schema2"."abc"', str(q)) + + def test_select__star__replacement(self): + q = Query.from_("abc").select("foo").select("*") + + self.assertEqual('SELECT * FROM "abc"', str(q)) + + def test_select__distinct__single(self): + q = Query.from_("abc").select("foo").distinct() + + self.assertEqual('SELECT DISTINCT "foo" FROM "abc"', str(q)) + + def test_select__distinct__multi(self): + q = Query.from_("abc").select("foo", "bar").distinct() + + self.assertEqual('SELECT DISTINCT "foo","bar" FROM "abc"', str(q)) + + def test_select__column__single__str(self): + q = Query.from_("abc").select("foo") + + self.assertEqual('SELECT "foo" FROM "abc"', str(q)) + + def test_select__column__single__alias__str(self): + q = Query.from_(self.table_abc).select(self.table_abc.foo.as_("bar")) + + self.assertEqual('SELECT "foo" "bar" FROM "abc"', str(q)) + + def test_select__column__single__table_alias__str(self): + q = Query.from_(self.table_abc.as_("fizzbuzz")).select(self.table_abc.foo.as_("bar")) + + self.assertEqual('SELECT "foo" "bar" FROM "abc" "fizzbuzz"', str(q)) + + def test_select__column__single__field(self): + t = Table("abc") + q = Query.from_(t).select(t.foo) + + self.assertEqual('SELECT "foo" FROM "abc"', str(q)) + + def test_select__columns__multi__str(self): + q1 = Query.from_("abc").select("foo", "bar") + q2 = Query.from_("abc").select("foo").select("bar") + + self.assertEqual('SELECT "foo","bar" FROM "abc"', str(q1)) + self.assertEqual('SELECT "foo","bar" FROM "abc"', str(q2)) + + def test_select__columns__multi__field(self): + q1 = Query.from_(self.table_abc).select(self.table_abc.foo, self.table_abc.bar) + q2 = Query.from_(self.table_abc).select(self.table_abc.foo).select(self.table_abc.bar) + + self.assertEqual('SELECT "foo","bar" FROM "abc"', str(q1)) + self.assertEqual('SELECT "foo","bar" FROM "abc"', str(q2)) + + def test_select__multiple_tables(self): + q = Query.from_(self.table_abc).select(self.table_abc.foo).from_(self.table_efg).select(self.table_efg.bar) + + self.assertEqual('SELECT "abc"."foo","efg"."bar" FROM "abc","efg"', str(q)) + + def test_select__subquery(self): + subquery = Query.from_(self.table_abc).select("*") + q = Query.from_(subquery).select(subquery.foo, subquery.bar) + + self.assertEqual('SELECT "sq0"."foo","sq0"."bar" ' 'FROM (SELECT * FROM "abc") "sq0"', str(q)) + + def test_select__multiple_subqueries(self): + subquery0 = Query.from_(self.table_abc).select("foo") + subquery1 = Query.from_(self.table_efg).select("bar") + q = Query.from_(subquery0).from_(subquery1).select(subquery0.foo, subquery1.bar) + + self.assertEqual( + 'SELECT "sq0"."foo","sq1"."bar" ' 'FROM (SELECT "foo" FROM "abc") "sq0",' '(SELECT "bar" FROM "efg") "sq1"', + str(q), + ) + + def test_select__nested_subquery(self): + subquery0 = Query.from_(self.table_abc).select("*") + subquery1 = Query.from_(subquery0).select(subquery0.foo, subquery0.bar) + subquery2 = Query.from_(subquery1).select(subquery1.foo) + + q = Query.from_(subquery2).select(subquery2.foo) + + self.assertEqual( + 'SELECT "sq2"."foo" ' + 'FROM (SELECT "sq1"."foo" ' + 'FROM (SELECT "sq0"."foo","sq0"."bar" ' + 'FROM (SELECT * FROM "abc") "sq0") "sq1") "sq2"', + str(q), + ) + + def test_select__no_table(self): + q = Query.select(1, 2, 3) + + self.assertEqual("SELECT 1,2,3", str(q)) + + def test_select_then_add_table(self): + q = Query.select(1).select(2, 3).from_("abc").select("foo") + + self.assertEqual('SELECT 1,2,3,"foo" FROM "abc"', str(q)) + + def test_select_with_limit(self): + q1 = Query.from_("abc").select("foo")[:10] + + self.assertEqual('SELECT "foo" FROM "abc" LIMIT 10', str(q1)) + + def test_select_with_limit_zero(self): + with self.subTest('using python slice'): + q1 = Query.from_("abc").select("foo")[:0] + self.assertEqual('SELECT "foo" FROM "abc" LIMIT 0', str(q1)) + + with self.subTest('using limit method'): + q2 = Query.from_("abc").select("foo").limit(0) + self.assertEqual('SELECT "foo" FROM "abc" LIMIT 0', str(q2)) + + def test_select_with_limit__func(self): + q1 = Query.from_("abc").select("foo").limit(10) + + self.assertEqual('SELECT "foo" FROM "abc" LIMIT 10', str(q1)) + + def test_select_with_offset(self): + q1 = Query.from_("abc").select("foo")[10:] + + self.assertEqual('SELECT "foo" FROM "abc" OFFSET 10', str(q1)) + + def test_select_with_offset__func(self): + q1 = Query.from_("abc").select("foo").offset(10) + + self.assertEqual('SELECT "foo" FROM "abc" OFFSET 10', str(q1)) + + def test_select_with_limit_and_offset(self): + q1 = Query.from_("abc").select("foo")[10:10] + + self.assertEqual('SELECT "foo" FROM "abc" LIMIT 10 OFFSET 10', str(q1)) + + def test_select_with_force_index(self): + q = Query.from_("abc").select("foo").force_index("egg") + + self.assertEqual('SELECT "foo" FROM "abc" FORCE INDEX ("egg")', str(q)) + + def test_select_with_force_index_with_index_object(self): + index = Index("egg") + q = Query.from_("abc").select("foo").force_index(index) + + self.assertEqual('SELECT "foo" FROM "abc" FORCE INDEX ("egg")', str(q)) + + def test_select_with_force_index_multiple_indexes(self): + q = Query.from_("abc").select("foo").force_index("egg", "bacon") + + self.assertEqual('SELECT "foo" FROM "abc" FORCE INDEX ("egg","bacon")', str(q)) + + def test_select_with_force_index_multiple_calls(self): + q = ( + Query.from_("abc") + .select("foo") + .force_index( + "egg", + ) + .force_index("spam") + ) + + self.assertEqual('SELECT "foo" FROM "abc" FORCE INDEX ("egg","spam")', str(q)) + + def test_select_with_use_index(self): + q = Query.from_("abc").select("foo").use_index("egg") + + self.assertEqual('SELECT "foo" FROM "abc" USE INDEX ("egg")', str(q)) + + def test_select_with_use_index_with_index_object(self): + index = Index("egg") + q = Query.from_("abc").select("foo").use_index(index) + + self.assertEqual('SELECT "foo" FROM "abc" USE INDEX ("egg")', str(q)) + + def test_select_with_use_index_multiple_indexes(self): + q = Query.from_("abc").select("foo").use_index("egg", "bacon") + + self.assertEqual('SELECT "foo" FROM "abc" USE INDEX ("egg","bacon")', str(q)) + + def test_select_with_use_index_multiple_calls(self): + q = ( + Query.from_("abc") + .select("foo") + .use_index( + "egg", + ) + .use_index("spam") + ) + + self.assertEqual('SELECT "foo" FROM "abc" USE INDEX ("egg","spam")', str(q)) + + def test_mysql_query_uses_backtick_quote_chars(self): + q = MySQLQuery.from_("abc").select("foo", "bar") + + self.assertEqual("SELECT `foo`,`bar` FROM `abc`", str(q)) + + def test_vertica_query_uses_double_quote_chars(self): + q = VerticaQuery.from_("abc").select("foo", "bar") + + self.assertEqual('SELECT "foo","bar" FROM "abc"', str(q)) + + def test_mssql_query_uses_double_quote_chars(self): + q = MSSQLQuery.from_("abc").select("foo", "bar") + + self.assertEqual('SELECT "foo","bar" FROM "abc"', str(q)) + + def test_oracle_query_uses_no_quote_chars(self): + q = OracleQuery.from_("abc").select("foo", "bar") + + self.assertEqual('SELECT foo,bar FROM abc', str(q)) + + def test_postgresql_query_uses_double_quote_chars(self): + q = PostgreSQLQuery.from_("abc").select("foo", "bar") + + self.assertEqual('SELECT "foo","bar" FROM "abc"', str(q)) + + def test_redshift_query_uses_double_quote_chars(self): + q = RedshiftQuery.from_("abc").select("foo", "bar") + + self.assertEqual('SELECT "foo","bar" FROM "abc"', str(q)) + + def test_table_select_alias(self): + q = self.table_abc.select(1) + + self.assertEqual('SELECT 1 FROM "abc"', str(q)) + self.assertEqual(q, Query.from_("abc").select(1)) + + def test_table_select_alias_with_offset_and_limit(self): + self.assertEqual(self.table_abc.select("foo")[10:10], Query.from_("abc").select("foo")[10:10]) + self.assertEqual( + self.table_abc.select(self.table_abc.foo)[10:10], + Query.from_("abc").select("foo")[10:10], + ) + + def test_temporal_select(self): + t = Table("abc") + + with self.subTest("with system time as of"): + q = Query.from_(t.for_(SYSTEM_TIME.as_of('2020-01-01'))).select("*") + + self.assertEqual('SELECT * FROM "abc" FOR SYSTEM_TIME AS OF \'2020-01-01\'', str(q)) + + with self.subTest("with system time between"): + q = Query.from_(t.for_(SYSTEM_TIME.between('2020-01-01', '2020-02-01'))).select("*") + + self.assertEqual('SELECT * FROM "abc" FOR SYSTEM_TIME BETWEEN \'2020-01-01\' AND \'2020-02-01\'', str(q)) + + with self.subTest("with system time from to"): + q = Query.from_(t.for_(SYSTEM_TIME.from_to('2020-01-01', '2020-02-01'))).select("*") + + self.assertEqual('SELECT * FROM "abc" FOR SYSTEM_TIME FROM \'2020-01-01\' TO \'2020-02-01\'', str(q)) + + with self.subTest("with ALL"): + q = Query.from_(t.for_(SYSTEM_TIME.all_())).select("*") + + self.assertEqual('SELECT * FROM "abc" FOR SYSTEM_TIME ALL', str(q)) + + with self.subTest("with period between"): + q = Query.from_(t.for_(t.valid_period.between('2020-01-01', '2020-02-01'))).select("*") + + self.assertEqual('SELECT * FROM "abc" FOR "valid_period" BETWEEN \'2020-01-01\' AND \'2020-02-01\'', str(q)) + + with self.subTest("with period from to"): + q = Query.from_(t.for_(t.valid_period.from_to('2020-01-01', '2020-02-01'))).select("*") + + self.assertEqual('SELECT * FROM "abc" FOR "valid_period" FROM \'2020-01-01\' TO \'2020-02-01\'', str(q)) + + with self.subTest("with ALL"): + q = Query.from_(t.for_(t.valid_period.all_())).select("*") + + self.assertEqual('SELECT * FROM "abc" FOR "valid_period" ALL', str(q)) + + +class MyEnum(Enum): + STR = "foo" + INT = 0 + BOOL = True + DATE = date(2020, 2, 2) + NONE = None + + +class WhereTests(unittest.TestCase): + t = Table("abc") + t2 = Table("cba") + + def test_where_enum(self): + q1 = Query.from_(self.t).select("*").where(self.t.foo == MyEnum.STR) + q2 = Query.from_(self.t).select("*").where(self.t.foo == MyEnum.INT) + q3 = Query.from_(self.t).select("*").where(self.t.foo == MyEnum.BOOL) + q4 = Query.from_(self.t).select("*").where(self.t.foo == MyEnum.DATE) + q5 = Query.from_(self.t).select("*").where(self.t.foo == MyEnum.NONE) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo"=\'foo\'', str(q1)) + self.assertEqual('SELECT * FROM "abc" WHERE "foo"=0', str(q2)) + self.assertEqual('SELECT * FROM "abc" WHERE "foo"=true', str(q3)) + self.assertEqual('SELECT * FROM "abc" WHERE "foo"=\'2020-02-02\'', str(q4)) + self.assertEqual('SELECT * FROM "abc" WHERE "foo"=null', str(q5)) + + def test_where_field_equals(self): + q1 = Query.from_(self.t).select("*").where(self.t.foo == self.t.bar) + q2 = Query.from_(self.t).select("*").where(self.t.foo.eq(self.t.bar)) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo"="bar"', str(q1)) + self.assertEqual('SELECT * FROM "abc" WHERE "foo"="bar"', str(q2)) + q = self.t.select("*").where(self.t.foo == self.t.bar) + self.assertEqual(q, q1) + + def test_where_field_equals_for_update(self): + q = Query.from_(self.t).select("*").where(self.t.foo == self.t.bar).for_update() + self.assertEqual('SELECT * FROM "abc" WHERE "foo"="bar" FOR UPDATE', str(q)) + + def test_where_field_equals_for_update_nowait(self): + for query_cls in [ + MySQLQuery, + PostgreSQLQuery, + ]: + quote_char = query_cls._builder().QUOTE_CHAR if isinstance(query_cls._builder().QUOTE_CHAR, str) else '"' + q = query_cls.from_(self.t).select("*").where(self.t.foo == self.t.bar).for_update(nowait=True) + self.assertEqual( + 'SELECT * ' + 'FROM {quote_char}abc{quote_char} ' + 'WHERE {quote_char}foo{quote_char}={quote_char}bar{quote_char} ' + 'FOR UPDATE NOWAIT'.format( + quote_char=quote_char, + ), + str(q), + ) + + def test_where_field_equals_for_update_skip_locked(self): + for query_cls in [ + MySQLQuery, + PostgreSQLQuery, + ]: + quote_char = query_cls._builder().QUOTE_CHAR if isinstance(query_cls._builder().QUOTE_CHAR, str) else '"' + q = query_cls.from_(self.t).select("*").where(self.t.foo == self.t.bar).for_update(skip_locked=True) + self.assertEqual( + 'SELECT * ' + 'FROM {quote_char}abc{quote_char} ' + 'WHERE {quote_char}foo{quote_char}={quote_char}bar{quote_char} ' + 'FOR UPDATE SKIP LOCKED'.format( + quote_char=quote_char, + ), + str(q), + ) + + def test_where_field_equals_for_update_of(self): + for query_cls in [ + MySQLQuery, + PostgreSQLQuery, + ]: + quote_char = query_cls._builder().QUOTE_CHAR if isinstance(query_cls._builder().QUOTE_CHAR, str) else '"' + q = query_cls.from_(self.t).select("*").where(self.t.foo == self.t.bar).for_update(of=("abc",)) + self.assertEqual( + 'SELECT * ' + 'FROM {quote_char}abc{quote_char} ' + 'WHERE {quote_char}foo{quote_char}={quote_char}bar{quote_char} ' + 'FOR UPDATE OF {quote_char}abc{quote_char}'.format( + quote_char=quote_char, + ), + str(q), + ) + + def test_where_field_equals_for_update_of_multiple_tables(self): + for query_cls in [ + MySQLQuery, + PostgreSQLQuery, + ]: + q = ( + query_cls.from_(self.t) + .join(self.t2) + .on(self.t.id == self.t2.abc_id) + .select("*") + .where(self.t.foo == self.t.bar) + .for_update(of=("abc", "cba")) + ) + quote_char = query_cls._builder().QUOTE_CHAR if isinstance(query_cls._builder().QUOTE_CHAR, str) else '"' + self.assertIn( + str(q), + [ + 'SELECT * ' + 'FROM {quote_char}abc{quote_char} ' + 'JOIN {quote_char}cba{quote_char} ' + 'ON {quote_char}abc{quote_char}.{quote_char}id{quote_char}=' + '{quote_char}cba{quote_char}.{quote_char}abc_id{quote_char} ' + 'WHERE {quote_char}abc{quote_char}.{quote_char}foo{quote_char}=' + '{quote_char}abc{quote_char}.{quote_char}bar{quote_char} ' + 'FOR UPDATE OF {quote_char}cba{quote_char}, {quote_char}abc{quote_char}'.format( + quote_char=quote_char, + ), + 'SELECT * ' + 'FROM {quote_char}abc{quote_char} ' + 'JOIN {quote_char}cba{quote_char} ' + 'ON {quote_char}abc{quote_char}.{quote_char}id{quote_char}=' + '{quote_char}cba{quote_char}.{quote_char}abc_id{quote_char} ' + 'WHERE {quote_char}abc{quote_char}.{quote_char}foo{quote_char}=' + '{quote_char}abc{quote_char}.{quote_char}bar{quote_char} ' + 'FOR UPDATE OF {quote_char}abc{quote_char}, {quote_char}cba{quote_char}'.format( + quote_char=quote_char, + ), + ], + ) + + def test_where_field_equals_for_update_of_nowait(self): + for query_cls in [ + MySQLQuery, + PostgreSQLQuery, + ]: + q = query_cls.from_(self.t).select("*").where(self.t.foo == self.t.bar).for_update(of=("abc",), nowait=True) + quote_char = query_cls._builder().QUOTE_CHAR if isinstance(query_cls._builder().QUOTE_CHAR, str) else '"' + self.assertEqual( + 'SELECT * ' + 'FROM {quote_char}abc{quote_char} ' + 'WHERE {quote_char}foo{quote_char}={quote_char}bar{quote_char} ' + 'FOR UPDATE OF {quote_char}abc{quote_char} NOWAIT'.format( + quote_char=quote_char, + ), + str(q), + ) + + def test_where_field_equals_for_update_of_skip_locked(self): + for query_cls in [ + MySQLQuery, + PostgreSQLQuery, + ]: + q = ( + query_cls.from_(self.t) + .select("*") + .where(self.t.foo == self.t.bar) + .for_update(of=("abc",), skip_locked=True) + ) + quote_char = query_cls._builder().QUOTE_CHAR if isinstance(query_cls._builder().QUOTE_CHAR, str) else '"' + self.assertEqual( + 'SELECT * ' + 'FROM {quote_char}abc{quote_char} ' + 'WHERE {quote_char}foo{quote_char}={quote_char}bar{quote_char} ' + 'FOR UPDATE OF {quote_char}abc{quote_char} SKIP LOCKED'.format( + quote_char=quote_char, + ), + str(q), + ) + + def test_where_field_equals_for_update_skip_locked_and_of(self): + for query_cls in [ + MySQLQuery, + PostgreSQLQuery, + ]: + q = ( + query_cls.from_(self.t) + .select("*") + .where(self.t.foo == self.t.bar) + .for_update(nowait=False, skip_locked=True, of=("abc",)) + ) + quote_char = query_cls._builder().QUOTE_CHAR if isinstance(query_cls._builder().QUOTE_CHAR, str) else '"' + self.assertEqual( + 'SELECT * ' + 'FROM {quote_char}abc{quote_char} ' + 'WHERE {quote_char}foo{quote_char}={quote_char}bar{quote_char} ' + 'FOR UPDATE OF {quote_char}abc{quote_char} SKIP LOCKED'.format( + quote_char=quote_char, + ), + str(q), + ) + + def test_where_field_equals_where(self): + q = Query.from_(self.t).select("*").where(self.t.foo == 1).where(self.t.bar == self.t.baz) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo"=1 AND "bar"="baz"', str(q)) + + def test_where_field_equals_where_not(self): + q = Query.from_(self.t).select("*").where((self.t.foo == 1).negate()).where(self.t.bar == self.t.baz) + + self.assertEqual('SELECT * FROM "abc" WHERE NOT "foo"=1 AND "bar"="baz"', str(q)) + + def test_where_field_equals_where_two_not(self): + q = Query.from_(self.t).select("*").where((self.t.foo == 1).negate()).where((self.t.bar == self.t.baz).negate()) + + self.assertEqual('SELECT * FROM "abc" WHERE NOT "foo"=1 AND NOT "bar"="baz"', str(q)) + + def test_where_single_quote(self): + q1 = Query.from_(self.t).select("*").where(self.t.foo == "bar'foo") + + self.assertEqual("SELECT * FROM \"abc\" WHERE \"foo\"='bar''foo'", str(q1)) + + def test_where_field_equals_and(self): + q = Query.from_(self.t).select("*").where((self.t.foo == 1) & (self.t.bar == self.t.baz)) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo"=1 AND "bar"="baz"', str(q)) + + def test_where_field_equals_or(self): + q = Query.from_(self.t).select("*").where((self.t.foo == 1) | (self.t.bar == self.t.baz)) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo"=1 OR "bar"="baz"', str(q)) + + def test_where_nested_conditions(self): + q = Query.from_(self.t).select("*").where((self.t.foo == 1) | (self.t.bar == self.t.baz)).where(self.t.baz == 0) + + self.assertEqual('SELECT * FROM "abc" WHERE ("foo"=1 OR "bar"="baz") AND "baz"=0', str(q)) + + def test_where_field_starts_with(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.like("ab%")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" LIKE \'ab%\'', str(q)) + + def test_where_field_contains(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.like("%fg%")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" LIKE \'%fg%\'', str(q)) + + def test_where_field_ends_with(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.like("%yz")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" LIKE \'%yz\'', str(q)) + + def test_where_field_is_n_chars_long(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.like("___")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" LIKE \'___\'', str(q)) + + def test_where_field_does_not_start_with(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.not_like("ab%")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" NOT LIKE \'ab%\'', str(q)) + + def test_where_field_does_not_contain(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.not_like("%fg%")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" NOT LIKE \'%fg%\'', str(q)) + + def test_where_field_does_not_end_with(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.not_like("%yz")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" NOT LIKE \'%yz\'', str(q)) + + def test_where_field_is_not_n_chars_long(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.not_like("___")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" NOT LIKE \'___\'', str(q)) + + def test_where_field_matches_regex(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.regex(r"^b")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" REGEX \'^b\'', str(q)) + + def test_where_field_matches_regexp(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.regexp(r"^b")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" REGEXP \'^b\'', str(q)) + + def test_where_field_matches_rlike(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.rlike(r"^b")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" RLIKE \'^b\'', str(q)) + + def test_ignore_empty_criterion_where(self): + q1 = Query.from_(self.t).select("*").where(EmptyCriterion()) + + self.assertEqual('SELECT * FROM "abc"', str(q1)) + + def test_ignore_empty_criterion_having(self): + q1 = Query.from_(self.t).select("*").having(EmptyCriterion()) + + self.assertEqual('SELECT * FROM "abc"', str(q1)) + + def test_select_with_force_index_and_where(self): + q = Query.from_("abc").select("foo").where(self.t.foo == self.t.bar).force_index("egg") + + self.assertEqual('SELECT "foo" FROM "abc" FORCE INDEX ("egg") WHERE "foo"="bar"', str(q)) + + def test_where_with_multiple_wheres_using_and_case(self): + case_stmt = Case().when(self.t.foo == 'bar', 1).else_(0) + query = Query.from_(self.t).select(case_stmt).where(case_stmt & self.t.blah.isin(['test'])) + + self.assertEqual( + 'SELECT CASE WHEN "foo"=\'bar\' THEN 1 ELSE 0 END FROM "abc" WHERE CASE WHEN "foo"=\'bar\' THEN 1 ELSE 0 ' + 'END AND "blah" IN (\'test\')', + str(query), + ) + + def test_where_with_multiple_wheres_using_or_case(self): + case_stmt = Case().when(self.t.foo == 'bar', 1).else_(0) + query = Query.from_(self.t).select(case_stmt).where(case_stmt | self.t.blah.isin(['test'])) + + self.assertEqual( + 'SELECT CASE WHEN "foo"=\'bar\' THEN 1 ELSE 0 END FROM "abc" WHERE CASE WHEN "foo"=\'bar\' THEN 1 ELSE 0 ' + 'END OR "blah" IN (\'test\')', + str(query), + ) + + +class PreWhereTests(WhereTests): + t = Table("abc") + + def test_prewhere_field_equals(self): + q1 = Query.from_(self.t).select("*").prewhere(self.t.foo == self.t.bar) + q2 = Query.from_(self.t).select("*").prewhere(self.t.foo.eq(self.t.bar)) + + self.assertEqual('SELECT * FROM "abc" PREWHERE "foo"="bar"', str(q1)) + self.assertEqual('SELECT * FROM "abc" PREWHERE "foo"="bar"', str(q2)) + + def test_where_and_prewhere(self): + q = Query.from_(self.t).select("*").prewhere(self.t.foo == self.t.bar).where(self.t.foo == self.t.bar) + + self.assertEqual('SELECT * FROM "abc" PREWHERE "foo"="bar" WHERE "foo"="bar"', str(q)) + + +class GroupByTests(unittest.TestCase): + t = Table("abc") + maxDiff = None + + def test_groupby__single(self): + q = Query.from_(self.t).groupby(self.t.foo).select(self.t.foo) + + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo"', str(q)) + + def test_groupby__multi(self): + q = Query.from_(self.t).groupby(self.t.foo, self.t.bar).select(self.t.foo, self.t.bar) + + self.assertEqual('SELECT "foo","bar" FROM "abc" GROUP BY "foo","bar"', str(q)) + + def test_groupby__count_star(self): + q = Query.from_(self.t).groupby(self.t.foo).select(self.t.foo, fn.Count("*")) + + self.assertEqual('SELECT "foo",COUNT(*) FROM "abc" GROUP BY "foo"', str(q)) + + def test_groupby__count_field(self): + q = Query.from_(self.t).groupby(self.t.foo).select(self.t.foo, fn.Count(self.t.bar)) + + self.assertEqual('SELECT "foo",COUNT("bar") FROM "abc" GROUP BY "foo"', str(q)) + + def test_groupby__count_distinct(self): + q = Query.from_(self.t).groupby(self.t.foo).select(self.t.foo, fn.Count("*").distinct()) + + self.assertEqual('SELECT "foo",COUNT(DISTINCT *) FROM "abc" GROUP BY "foo"', str(q)) + + def test_groupby__sum_distinct(self): + q = Query.from_(self.t).groupby(self.t.foo).select(self.t.foo, fn.Sum(self.t.bar).distinct()) + + self.assertEqual('SELECT "foo",SUM(DISTINCT "bar") FROM "abc" GROUP BY "foo"', str(q)) + + def test_groupby__sum_filter(self): + q = ( + Query.from_(self.t) + .groupby(self.t.foo) + .select(self.t.foo, fn.Sum(self.t.bar).filter(self.t.id.eq(1) & self.t.cid.gt(2))) + ) + + self.assertEqual('SELECT "foo",SUM("bar") FILTER(WHERE "id"=1 AND "cid">2) FROM "abc" GROUP BY "foo"', str(q)) + + def test_groupby__str(self): + q = Query.from_("abc").groupby("foo").select("foo", fn.Count("*").distinct()) + + self.assertEqual('SELECT "foo",COUNT(DISTINCT *) FROM "abc" GROUP BY "foo"', str(q)) + + def test_groupby__int(self): + q = Query.from_("abc").groupby(1).select("foo", fn.Count("*").distinct()) + + self.assertEqual('SELECT "foo",COUNT(DISTINCT *) FROM "abc" GROUP BY 1', str(q)) + + def test_groupby__alias(self): + bar = self.t.bar.as_("bar01") + q = Query.from_(self.t).select(fn.Sum(self.t.foo), bar).groupby(bar) + + self.assertEqual('SELECT SUM("foo"),"bar" "bar01" FROM "abc" GROUP BY "bar01"', str(q)) + + def test_groupby__no_alias(self): + bar = self.t.bar.as_("bar01") + q = Query.from_(self.t).select(fn.Sum(self.t.foo), bar).groupby(bar) + + self.assertEqual( + 'SELECT SUM("foo"),"bar" "bar01" FROM "abc" GROUP BY "bar"', + q.get_sql(groupby_alias=False), + ) + + def test_groupby__no_alias_mssql(self): + bar = self.t.bar.as_("bar01") + q = MSSQLQuery.from_(self.t).select(fn.Sum(self.t.foo), bar).groupby(bar) + + self.assertEqual('SELECT SUM("foo"),"bar" "bar01" FROM "abc" GROUP BY "bar"', str(q)) + + def test_groupby__no_alias_oracle(self): + bar = self.t.bar.as_("bar01") + q = OracleQuery.from_(self.t).select(fn.Sum(self.t.foo), bar).groupby(bar) + + self.assertEqual('SELECT SUM(foo),bar bar01 FROM abc GROUP BY bar', str(q)) + + def test_groupby__alias_platforms(self): + bar = self.t.bar.as_("bar01") + + for query_cls in [ + MySQLQuery, + VerticaQuery, + PostgreSQLQuery, + RedshiftQuery, + ClickHouseQuery, + SQLLiteQuery, + ]: + q = query_cls.from_(self.t).select(fn.Sum(self.t.foo), bar).groupby(bar) + + quote_char = query_cls._builder().QUOTE_CHAR if isinstance(query_cls._builder().QUOTE_CHAR, str) else '"' + + self.assertEqual( + "SELECT " + "SUM({quote_char}foo{quote_char})," + "{quote_char}bar{quote_char}{as_keyword}{quote_char}bar01{quote_char} " + "FROM {quote_char}abc{quote_char} " + "GROUP BY {quote_char}bar01{quote_char}".format( + as_keyword=' AS ' if query_cls is ClickHouseQuery else ' ', quote_char=quote_char + ), + str(q), + ) + + def test_groupby__alias_with_join(self): + table1 = Table("table1", alias="t1") + bar = table1.bar.as_("bar01") + q = Query.from_(self.t).join(table1).on(self.t.id == table1.t_ref).select(fn.Sum(self.t.foo), bar).groupby(bar) + + self.assertEqual( + 'SELECT SUM("abc"."foo"),"t1"."bar" "bar01" FROM "abc" ' + 'JOIN "table1" "t1" ON "abc"."id"="t1"."t_ref" ' + 'GROUP BY "bar01"', + str(q), + ) + + def test_groupby_with_case_uses_the_alias(self): + q = ( + Query.from_(self.t) + .select( + fn.Sum(self.t.foo).as_("bar"), + Case().when(self.t.fname == "Tom", "It was Tom").else_("It was someone else.").as_("who_was_it"), + ) + .groupby(Case().when(self.t.fname == "Tom", "It was Tom").else_("It was someone else.").as_("who_was_it")) + ) + + self.assertEqual( + 'SELECT SUM("foo") "bar",' + "CASE WHEN \"fname\"='Tom' THEN 'It was Tom' " + "ELSE 'It was someone else.' END \"who_was_it\" " + 'FROM "abc" ' + 'GROUP BY "who_was_it"', + str(q), + ) + + def test_mysql_query_uses_backtick_quote_chars(self): + q = MySQLQuery.from_(self.t).groupby(self.t.foo).select(self.t.foo) + + self.assertEqual("SELECT `foo` FROM `abc` GROUP BY `foo`", str(q)) + + def test_vertica_query_uses_double_quote_chars(self): + q = VerticaQuery.from_(self.t).groupby(self.t.foo).select(self.t.foo) + + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo"', str(q)) + + def test_mssql_query_uses_double_quote_chars(self): + q = MSSQLQuery.from_(self.t).groupby(self.t.foo).select(self.t.foo) + + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo"', str(q)) + + def test_oracle_query_uses_no_quote_chars(self): + q = OracleQuery.from_(self.t).groupby(self.t.foo).select(self.t.foo) + + self.assertEqual('SELECT foo FROM abc GROUP BY foo', str(q)) + + def test_postgres_query_uses_double_quote_chars(self): + q = PostgreSQLQuery.from_(self.t).groupby(self.t.foo).select(self.t.foo) + + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo"', str(q)) + + def test_redshift_query_uses_double_quote_chars(self): + q = RedshiftQuery.from_(self.t).groupby(self.t.foo).select(self.t.foo) + + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo"', str(q)) + + def test_group_by__single_with_totals(self): + q = Query.from_(self.t).groupby(self.t.foo).select(self.t.foo).with_totals() + + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo" WITH TOTALS', str(q)) + + def test_groupby__multi_with_totals(self): + q = Query.from_(self.t).groupby(self.t.foo, self.t.bar).select(self.t.foo, self.t.bar).with_totals() + + self.assertEqual('SELECT "foo","bar" FROM "abc" GROUP BY "foo","bar" WITH TOTALS', str(q)) + + +class HavingTests(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_having_greater_than(self): + q = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, fn.Sum(self.table_abc.bar)) + .groupby(self.table_abc.foo) + .having(fn.Sum(self.table_abc.bar) > 1) + ) + + self.assertEqual( + 'SELECT "foo",SUM("bar") FROM "abc" GROUP BY "foo" HAVING SUM("bar")>1', + str(q), + ) + + def test_having_and(self): + q = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, fn.Sum(self.table_abc.bar)) + .groupby(self.table_abc.foo) + .having((fn.Sum(self.table_abc.bar) > 1) & (fn.Sum(self.table_abc.bar) < 100)) + ) + + self.assertEqual( + 'SELECT "foo",SUM("bar") FROM "abc" GROUP BY "foo" HAVING SUM("bar")>1 AND SUM("bar")<100', + str(q), + ) + + def test_having_join_and_equality(self): + q = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.foo) + .select(self.table_abc.foo, fn.Sum(self.table_efg.bar), self.table_abc.buz) + .groupby(self.table_abc.foo) + .having(self.table_abc.buz == "fiz") + .having(fn.Sum(self.table_efg.bar) > 100) + ) + + self.assertEqual( + 'SELECT "abc"."foo",SUM("efg"."bar"),"abc"."buz" FROM "abc" ' + 'JOIN "efg" ON "abc"."foo"="efg"."foo" ' + 'GROUP BY "abc"."foo" ' + 'HAVING "abc"."buz"=\'fiz\' AND SUM("efg"."bar")>100', + str(q), + ) + + def test_mysql_query_uses_backtick_quote_chars(self): + q = ( + MySQLQuery.from_(self.table_abc) + .select(self.table_abc.foo) + .groupby(self.table_abc.foo) + .having(self.table_abc.buz == "fiz") + ) + self.assertEqual("SELECT `foo` FROM `abc` GROUP BY `foo` HAVING `buz`='fiz'", str(q)) + + def test_vertica_query_uses_double_quote_chars(self): + q = ( + VerticaQuery.from_(self.table_abc) + .select(self.table_abc.foo) + .groupby(self.table_abc.foo) + .having(self.table_abc.buz == "fiz") + ) + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo" HAVING "buz"=\'fiz\'', str(q)) + + def test_mssql_query_uses_double_quote_chars(self): + q = ( + MSSQLQuery.from_(self.table_abc) + .select(self.table_abc.foo) + .groupby(self.table_abc.foo) + .having(self.table_abc.buz == "fiz") + ) + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo" HAVING "buz"=\'fiz\'', str(q)) + + def test_oracle_query_uses_no_quote_chars(self): + q = ( + OracleQuery.from_(self.table_abc) + .select(self.table_abc.foo) + .groupby(self.table_abc.foo) + .having(self.table_abc.buz == "fiz") + ) + self.assertEqual('SELECT foo FROM abc GROUP BY foo HAVING buz=\'fiz\'', str(q)) + + def test_postgres_query_uses_double_quote_chars(self): + q = ( + PostgreSQLQuery.from_(self.table_abc) + .select(self.table_abc.foo) + .groupby(self.table_abc.foo) + .having(self.table_abc.buz == "fiz") + ) + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo" HAVING "buz"=\'fiz\'', str(q)) + + def test_redshift_query_uses_double_quote_chars(self): + q = ( + RedshiftQuery.from_(self.table_abc) + .select(self.table_abc.foo) + .groupby(self.table_abc.foo) + .having(self.table_abc.buz == "fiz") + ) + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo" HAVING "buz"=\'fiz\'', str(q)) + + +class OrderByTests(unittest.TestCase): + t = Table("abc") + + def test_orderby_single_field(self): + q = Query.from_(self.t).orderby(self.t.foo).select(self.t.foo) + + self.assertEqual('SELECT "foo" FROM "abc" ORDER BY "foo"', str(q)) + + def test_orderby_multi_fields(self): + q = Query.from_(self.t).orderby(self.t.foo, self.t.bar).select(self.t.foo, self.t.bar) + + self.assertEqual('SELECT "foo","bar" FROM "abc" ORDER BY "foo","bar"', str(q)) + + def test_orderby_single_str(self): + q = Query.from_("abc").orderby("foo").select("foo") + + self.assertEqual('SELECT "foo" FROM "abc" ORDER BY "foo"', str(q)) + + def test_orderby_asc(self): + q = Query.from_(self.t).orderby(self.t.foo, order=Order.asc).select(self.t.foo) + + self.assertEqual('SELECT "foo" FROM "abc" ORDER BY "foo" ASC', str(q)) + + def test_orderby_desc(self): + q = Query.from_(self.t).orderby(self.t.foo, order=Order.desc).select(self.t.foo) + + self.assertEqual('SELECT "foo" FROM "abc" ORDER BY "foo" DESC', str(q)) + + def test_orderby_no_alias(self): + bar = self.t.bar.as_("bar01") + q = Query.from_(self.t).select(fn.Sum(self.t.foo), bar).orderby(bar) + + self.assertEqual( + 'SELECT SUM("foo"),"bar" "bar01" FROM "abc" ORDER BY "bar"', + q.get_sql(orderby_alias=False), + ) + + def test_orderby_alias(self): + bar = self.t.bar.as_("bar01") + q = Query.from_(self.t).select(fn.Sum(self.t.foo), bar).orderby(bar) + + self.assertEqual('SELECT SUM("foo"),"bar" "bar01" FROM "abc" ORDER BY "bar01"', q.get_sql()) + + +class AliasTests(unittest.TestCase): + t = Table("abc") + + def test_table_field(self): + q = Query.from_(self.t).select(self.t.foo.as_("bar")) + + self.assertEqual('SELECT "foo" "bar" FROM "abc"', str(q)) + + def test_table_field__multi(self): + q = Query.from_(self.t).select(self.t.foo.as_("bar"), self.t.fiz.as_("buz")) + + self.assertEqual('SELECT "foo" "bar","fiz" "buz" FROM "abc"', str(q)) + + def test_arithmetic_function(self): + q = Query.from_(self.t).select((self.t.foo + self.t.bar).as_("biz")) + + self.assertEqual('SELECT "foo"+"bar" "biz" FROM "abc"', str(q)) + + def test_functions_using_as(self): + q = Query.from_(self.t).select(fn.Count("*").as_("foo")) + + self.assertEqual('SELECT COUNT(*) "foo" FROM "abc"', str(q)) + + def test_functions_using_constructor_param(self): + q = Query.from_(self.t).select(fn.Count("*", alias="foo")) + + self.assertEqual('SELECT COUNT(*) "foo" FROM "abc"', str(q)) + + def test_function_using_as_nested(self): + """ + We don't show aliases of fields that are arguments of a function. + """ + q = Query.from_(self.t).select(fn.Sqrt(fn.Count("*").as_("foo")).as_("bar")) + + self.assertEqual('SELECT SQRT(COUNT(*)) "bar" FROM "abc"', str(q)) + + def test_functions_using_constructor_param_nested(self): + """ + We don't show aliases of fields that are arguments of a function. + """ + q = Query.from_(self.t).select(fn.Sqrt(fn.Count("*", alias="foo"), alias="bar")) + + self.assertEqual('SELECT SQRT(COUNT(*)) "bar" FROM "abc"', str(q)) + + def test_ignored_in_where(self): + q = Query.from_(self.t).select(self.t.foo).where(self.t.foo.as_("bar") == 1) + + self.assertEqual('SELECT "foo" FROM "abc" WHERE "foo"=1', str(q)) + + def test_ignored_in_groupby(self): + q = Query.from_(self.t).select(self.t.foo).groupby(self.t.foo.as_("bar")) + + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo"', str(q)) + + def test_ignored_in_orderby(self): + q = Query.from_(self.t).select(self.t.foo).orderby(self.t.foo.as_("bar")) + + self.assertEqual('SELECT "foo" FROM "abc" ORDER BY "foo"', str(q)) + + def test_ignored_in_criterion(self): + c = self.t.foo.as_("bar") == 1 + + self.assertEqual('"foo"=1', str(c)) + + def test_ignored_in_criterion_comparison(self): + c = self.t.foo.as_("bar") == self.t.fiz.as_("buz") + + self.assertEqual('"foo"="fiz"', str(c)) + + def test_ignored_in_field_inside_case(self): + q = Query.from_(self.t).select(Case().when(self.t.foo == 1, "a").else_(self.t.bar.as_('"buz"'))) + + self.assertEqual('SELECT CASE WHEN "foo"=1 THEN \'a\' ELSE "bar" END FROM "abc"', str(q)) + + def test_case_using_as(self): + q = Query.from_(self.t).select(Case().when(self.t.foo == 1, "a").else_("b").as_("bar")) + + self.assertEqual( + 'SELECT CASE WHEN "foo"=1 THEN \'a\' ELSE \'b\' END "bar" FROM "abc"', + str(q), + ) + + def test_case_using_constructor_param(self): + q = Query.from_(self.t).select(Case(alias="bar").when(self.t.foo == 1, "a").else_("b")) + + self.assertEqual( + 'SELECT CASE WHEN "foo"=1 THEN \'a\' ELSE \'b\' END "bar" FROM "abc"', + str(q), + ) + + def test_select__multiple_tables(self): + table_abc, table_efg = Table("abc", alias="q0"), Table("efg", alias="q1") + + q = Query.from_(table_abc).select(table_abc.foo).from_(table_efg).select(table_efg.bar) + + self.assertEqual('SELECT "q0"."foo","q1"."bar" FROM "abc" "q0","efg" "q1"', str(q)) + + def test_use_aliases_in_groupby_and_orderby(self): + table_abc = Table("abc", alias="q0") + + my_foo = table_abc.foo.as_("my_foo") + q = Query.from_(table_abc).select(my_foo, table_abc.bar).groupby(my_foo).orderby(my_foo) + + self.assertEqual( + 'SELECT "q0"."foo" "my_foo","q0"."bar" ' 'FROM "abc" "q0" ' 'GROUP BY "my_foo" ' 'ORDER BY "my_foo"', + str(q), + ) + + def test_table_with_schema_and_alias(self): + table = Table("abc", schema="schema", alias="alias") + self.assertEqual('"schema"."abc" "alias"', str(table)) + + def test_null_value_with_alias(self): + q = Query.select(NullValue().as_("abcdef")) + + self.assertEqual('SELECT NULL "abcdef"', str(q)) + + +class SubqueryTests(unittest.TestCase): + maxDiff = None + + table_abc, table_efg, table_hij = Tables("abc", "efg", "hij") + + def test_where__in(self): + q = ( + Query.from_(self.table_abc) + .select("*") + .where( + self.table_abc.foo.isin( + Query.from_(self.table_efg).select(self.table_efg.foo).where(self.table_efg.bar == 0) + ) + ) + ) + + self.assertEqual( + 'SELECT * FROM "abc" WHERE "foo" IN (SELECT "foo" FROM "efg" WHERE "bar"=0)', + str(q), + ) + + def test_where__in_nested(self): + q = Query.from_(self.table_abc).select("*").where(self.table_abc.foo).isin(self.table_efg.select("*")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" IN (SELECT * FROM "efg")', str(q)) + + def test_join(self): + subquery = Query.from_("efg").select("fiz", "buz").where(F("buz") == 0) + + q = ( + Query.from_(self.table_abc) + .join(subquery) + .on(self.table_abc.bar == subquery.buz) + .select(self.table_abc.foo, subquery.fiz) + ) + + self.assertEqual( + 'SELECT "abc"."foo","sq0"."fiz" FROM "abc" ' + 'JOIN (SELECT "fiz","buz" FROM "efg" WHERE "buz"=0) "sq0" ' + 'ON "abc"."bar"="sq0"."buz"', + str(q), + ) + + def test_select_subquery(self): + subq = Query.from_(self.table_efg).select("fizzbuzz").where(self.table_efg.id == 1) + + q = Query.from_(self.table_abc).select("foo", "bar").select(subq) + + self.assertEqual( + 'SELECT "foo","bar",(SELECT "fizzbuzz" FROM "efg" WHERE "id"=1) ' 'FROM "abc"', + str(q), + ) + + def test_select_subquery_with_alias(self): + subq = Query.from_(self.table_efg).select("fizzbuzz").where(self.table_efg.id == 1) + + q = Query.from_(self.table_abc).select("foo", "bar").select(subq.as_("sq")) + + self.assertEqual( + 'SELECT "foo","bar",(SELECT "fizzbuzz" FROM "efg" WHERE "id"=1) "sq" ' 'FROM "abc"', + str(q), + ) + + def test_where__equality(self): + subquery = Query.from_("efg").select("fiz").where(F("buz") == 0) + query = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, self.table_abc.bar) + .where(self.table_abc.bar == subquery) + ) + + self.assertEqual( + 'SELECT "foo","bar" FROM "abc" ' 'WHERE "bar"=(SELECT "fiz" FROM "efg" WHERE "buz"=0)', + str(query), + ) + + def test_select_from_nested_query(self): + subquery = Query.from_(self.table_abc).select( + self.table_abc.foo, + self.table_abc.bar, + (self.table_abc.fizz + self.table_abc.buzz).as_("fizzbuzz"), + ) + + query = Query.from_(subquery).select(subquery.foo, subquery.bar, subquery.fizzbuzz) + + self.assertEqual( + 'SELECT "sq0"."foo","sq0"."bar","sq0"."fizzbuzz" ' + "FROM (" + 'SELECT "foo","bar","fizz"+"buzz" "fizzbuzz" ' + 'FROM "abc"' + ') "sq0"', + str(query), + ) + + def test_select_from_nested_query_with_join(self): + subquery1 = ( + Query.from_(self.table_abc) + .select( + self.table_abc.foo, + fn.Sum(self.table_abc.fizz + self.table_abc.buzz).as_("fizzbuzz"), + ) + .groupby(self.table_abc.foo) + ) + + subquery2 = Query.from_(self.table_efg).select( + self.table_efg.foo.as_("foo_two"), + self.table_efg.bar, + ) + + query = ( + Query.from_(subquery1) + .select(subquery1.foo, subquery1.fizzbuzz) + .join(subquery2) + .on(subquery1.foo == subquery2.foo_two) + .select(subquery2.foo_two, subquery2.bar) + ) + + self.assertEqual( + "SELECT " + '"sq0"."foo","sq0"."fizzbuzz",' + '"sq1"."foo_two","sq1"."bar" ' + "FROM (" + "SELECT " + '"foo",SUM("fizz"+"buzz") "fizzbuzz" ' + 'FROM "abc" ' + 'GROUP BY "foo"' + ') "sq0" JOIN (' + "SELECT " + '"foo" "foo_two","bar" ' + 'FROM "efg"' + ') "sq1" ON "sq0"."foo"="sq1"."foo_two"', + str(query), + ) + + def test_from_subquery_without_alias(self): + subquery = Query.from_(self.table_efg).select( + self.table_efg.base_id.as_("x"), self.table_efg.fizz, self.table_efg.buzz + ) + + test_query = Query.from_(subquery).select(subquery.x, subquery.fizz, subquery.buzz) + + self.assertEqual( + 'SELECT "sq0"."x","sq0"."fizz","sq0"."buzz" ' + "FROM (" + 'SELECT "base_id" "x","fizz","buzz" FROM "efg"' + ') "sq0"', + str(test_query), + ) + + def test_join_query_with_alias(self): + subquery = ( + Query.from_(self.table_efg) + .select( + self.table_efg.base_id.as_("x"), + self.table_efg.fizz, + self.table_efg.buzz, + ) + .as_("subq") + ) + + test_query = Query.from_(subquery).select(subquery.x, subquery.fizz, subquery.buzz) + + self.assertEqual( + 'SELECT "subq"."x","subq"."fizz","subq"."buzz" ' + "FROM (" + 'SELECT "base_id" "x","fizz","buzz" FROM "efg"' + ') "subq"', + str(test_query), + ) + + def test_with(self): + sub_query = Query.from_(self.table_efg).select("fizz") + test_query = Query.with_(sub_query, "an_alias").from_(AliasedQuery("an_alias")).select("*") + + self.assertEqual( + 'WITH an_alias AS (SELECT "fizz" FROM "efg") SELECT * FROM an_alias', + str(test_query), + ) + + def test_join_with_with(self): + sub_query = Query.from_(self.table_efg).select("fizz") + test_query = ( + Query.with_(sub_query, "an_alias") + .from_(self.table_abc) + .join(AliasedQuery("an_alias")) + .on(AliasedQuery("an_alias").fizz == self.table_abc.buzz) + .select("*") + ) + self.assertEqual( + 'WITH an_alias AS (SELECT "fizz" FROM "efg") ' + 'SELECT * FROM "abc" JOIN an_alias ON "an_alias"."fizz"="abc"."buzz"', + str(test_query), + ) + + def test_select_from_with_returning(self): + sub_query = PostgreSQLQuery.into(self.table_abc).insert(1).returning('*') + test_query = Query.with_(sub_query, "an_alias").from_(AliasedQuery("an_alias")).select("*") + self.assertEqual( + 'WITH an_alias AS (INSERT INTO "abc" VALUES (1) RETURNING *) SELECT * FROM an_alias', str(test_query) + ) + + +class QuoteTests(unittest.TestCase): + def test_extraneous_quotes(self): + t1 = Table("table1", alias="t1") + t2 = Table("table2", alias="t2") + + query = Query.from_(t1).join(t2).on(t1.Value.between(t2.start, t2.end)).select(t1.value) + + self.assertEqual( + "SELECT t1.value FROM table1 t1 " "JOIN table2 t2 ON t1.Value " "BETWEEN t2.start AND t2.end", + query.get_sql(quote_char=None), + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/test_tables.py b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/test_tables.py new file mode 100644 index 0000000000000000000000000000000000000000..f43e740915f642d29ce7497c36e3b68f01311016 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/test_tables.py @@ -0,0 +1,186 @@ +# from pypika.terms import ValueWrapper, SystemTimeValue +import unittest + +from pypika import Database, Dialects, Schema, SQLLiteQuery, Table, Tables, Query, SYSTEM_TIME + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + + +class TableStructureTests(unittest.TestCase): + def test_table_sql(self): + table = Table("test_table") + + self.assertEqual('"test_table"', str(table)) + + def test_table_with_alias(self): + table = Table("test_table").as_("my_table") + + self.assertEqual('"test_table" "my_table"', table.get_sql(with_alias=True, quote_char='"')) + + def test_schema_table_attr(self): + table = Schema("x_schema").test_table + + self.assertEqual('"x_schema"."test_table"', str(table)) + + def test_table_with_schema_arg(self): + table = Table("test_table", schema=Schema("x_schema")) + + self.assertEqual('"x_schema"."test_table"', str(table)) + + def test_database_schema_table_attr(self): + table = Database("x_db").x_schema.test_table + + self.assertEqual('"x_db"."x_schema"."test_table"', str(table)) + + def test_table_with_schema_and_schema_parent_arg(self): + table = Table("test_table", schema=Schema("x_schema", parent=Database("x_db"))) + + self.assertEqual('"x_db"."x_schema"."test_table"', str(table)) + + def test_table_for_system_time_sql(self): + with self.subTest("with between criterion"): + table = Table("test_table").for_(SYSTEM_TIME.between('2020-01-01', '2020-02-01')) + + self.assertEqual('"test_table" FOR SYSTEM_TIME BETWEEN \'2020-01-01\' AND \'2020-02-01\'', str(table)) + + with self.subTest("with as of criterion"): + table = Table("test_table").for_(SYSTEM_TIME.as_of('2020-01-01')) + + self.assertEqual('"test_table" FOR SYSTEM_TIME AS OF \'2020-01-01\'', str(table)) + + with self.subTest("with from to criterion"): + table = Table("test_table").for_(SYSTEM_TIME.from_to('2020-01-01', '2020-02-01')) + + self.assertEqual('"test_table" FOR SYSTEM_TIME FROM \'2020-01-01\' TO \'2020-02-01\'', str(table)) + + def test_table_for_period_sql(self): + with self.subTest("with between criterion"): + table = Table("test_table") + table = table.for_(table.valid_period.between('2020-01-01', '2020-02-01')) + + self.assertEqual('"test_table" FOR "valid_period" BETWEEN \'2020-01-01\' AND \'2020-02-01\'', str(table)) + + with self.subTest("with as of criterion"): + table = Table("test_table") + table = table.for_(table.valid_period.as_of('2020-01-01')) + + self.assertEqual('"test_table" FOR "valid_period" AS OF \'2020-01-01\'', str(table)) + + with self.subTest("with from to criterion"): + table = Table("test_table") + table = table.for_(table.valid_period.from_to('2020-01-01', '2020-02-01')) + + self.assertEqual('"test_table" FOR "valid_period" FROM \'2020-01-01\' TO \'2020-02-01\'', str(table)) + + +class TableEqualityTests(unittest.TestCase): + def test_tables_equal_by_name(self): + t1 = Table("t") + t2 = Table("t") + + self.assertEqual(t1, t2) + + def test_tables_equal_by_schema_and_name(self): + t1 = Table("t", schema="a") + t2 = Table("t", schema="a") + + self.assertEqual(t1, t2) + + def test_tables_equal_by_schema_and_name_using_schema(self): + a = Schema("a") + t1 = Table("t", schema=a) + t2 = Table("t", schema=a) + + self.assertEqual(t1, t2) + + def test_tables_equal_by_schema_and_name_using_schema_with_parent(self): + parent = Schema("parent") + a = Schema("a", parent=parent) + t1 = Table("t", schema=a) + t2 = Table("t", schema=a) + + self.assertEqual(t1, t2) + + def test_tables_not_equal_by_schema_and_name_using_schema_with_different_parents( + self, + ): + parent = Schema("parent") + a = Schema("a", parent=parent) + t1 = Table("t", schema=a) + t2 = Table("t", schema=Schema("a")) + + self.assertNotEqual(t1, t2) + + def test_tables_not_equal_with_different_schemas(self): + t1 = Table("t", schema="a") + t2 = Table("t", schema="b") + + self.assertNotEqual(t1, t2) + + def test_tables_not_equal_with_different_names(self): + t1 = Table("t", schema="a") + t2 = Table("q", schema="a") + + self.assertNotEqual(t1, t2) + + def test_many_tables_with_alias(self): + tables_data = [("table1", "t1"), ("table2", "t2"), ("table3", "t3")] + tables = Tables(*tables_data) + for el in tables: + self.assertIsNotNone(el.alias) + + def test_many_tables_without_alias(self): + tables_data = ["table1", "table2", "table3"] + tables = Tables(*tables_data) + for el in tables: + self.assertIsNone(el.alias) + + def test_many_tables_with_or_not_alias(self): + tables_data = [("table1", "t1"), ("table2"), "table3"] + tables = Tables(*tables_data) + for i in range(len(tables)): + if isinstance(tables_data[i], tuple): + self.assertIsNotNone(tables[i].alias) + else: + self.assertIsNone(tables[i].alias) + + +class TableDialectTests(unittest.TestCase): + def test_table_with_default_query_cls(self): + table = Table("abc") + q = table.select("1") + self.assertIs(q.dialect, None) + + def test_table_with_dialect_query_cls(self): + table = Table("abc", query_cls=SQLLiteQuery) + q = table.select("1") + self.assertIs(q.dialect, Dialects.SQLLITE) + + def test_table_factory_with_default_query_cls(self): + table = Query.Table("abc") + q = table.select("1") + self.assertIs(q.dialect, None) + + def test_table_factory_with_dialect_query_cls(self): + table = SQLLiteQuery.Table("abc") + q = table.select("1") + self.assertIs(q.dialect, Dialects.SQLLITE) + + def test_make_tables_factory_with_default_query_cls(self): + t1, t2 = Query.Tables("abc", "def") + q1 = t1.select("1") + q2 = t2.select("2") + self.assertIs(q1.dialect, None) + self.assertIs(q2.dialect, None) + + def test_make_tables_factory_with_dialect_query_cls(self): + t1, t2 = SQLLiteQuery.Tables("abc", "def") + q1 = t1.select("1") + q2 = t2.select("2") + self.assertIs(q1.dialect, Dialects.SQLLITE) + self.assertIs(q2.dialect, Dialects.SQLLITE) + + def test_table_with_bad_query_cls(self): + with self.assertRaises(TypeError): + Table("abc", query_cls=object) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/test_terms.py b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/test_terms.py new file mode 100644 index 0000000000000000000000000000000000000000..4c7590dfce129bac97a3f30de99b596cc746c893 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/test_terms.py @@ -0,0 +1,82 @@ +from unittest import TestCase + +from pypika import Query, Table, Field +from pypika.terms import AtTimezone + + +class FieldAliasTests(TestCase): + t = Table("test", alias="crit") + + def test_when_alias_specified(self): + c1 = Field("foo", alias="bar") + self.assertEqual('bar', str(c1.alias)) + + c1 = Field("foo").as_("bar") + self.assertEqual('bar', str(c1.alias)) + + +class FieldInitTests(TestCase): + def test_init_with_str_table(self): + test_table_name = "test_table" + field = Field(name="name", table=test_table_name) + self.assertEqual(field.table, Table(name=test_table_name)) + + +class FieldHashingTests(TestCase): + def test_tabled_eq_fields_equally_hashed(self): + client_name1 = Field(name="name", table=Table("clients")) + client_name2 = Field(name="name", table=Table("clients")) + self.assertTrue(hash(client_name1) == hash(client_name2)) + + def test_tabled_ne_fields_differently_hashed(self): + customer_name = Field(name="name", table=Table("customers")) + client_name = Field(name="name", table=Table("clients")) + self.assertTrue(hash(customer_name) != hash(client_name)) + + def test_non_tabled_aliased_eq_fields_equally_hashed(self): + self.assertTrue(hash(Field(name="A", alias="my_a")) == hash(Field(name="A", alias="my_a"))) + + def test_non_tabled_aliased_ne_fields_differently_hashed(self): + self.assertTrue(hash(Field(name="A", alias="my_a1")) != hash(Field(name="A", alias="my_a2"))) + + def test_non_tabled_eq_fields_equally_hashed(self): + self.assertTrue(hash(Field(name="A")) == hash(Field(name="A"))) + + def test_non_tabled_ne_fields_differently_hashed(self): + self.assertTrue(hash(Field(name="A")) != hash(Field(name="B"))) + + +class AtTimezoneTests(TestCase): + def test_when_interval_not_specified(self): + query = Query.from_("customers").select(AtTimezone("date", "US/Eastern")) + self.assertEqual('SELECT "date" AT TIME ZONE \'US/Eastern\' FROM "customers"', str(query)) + + def test_when_interval_specified(self): + query = Query.from_("customers").select(AtTimezone("date", "-06:00", interval=True)) + self.assertEqual( + 'SELECT "date" AT TIME ZONE INTERVAL \'-06:00\' FROM "customers"', + str(query), + ) + + def test_when_alias_specified(self): + query = Query.from_("customers").select(AtTimezone("date", "US/Eastern", alias="alias1")) + self.assertEqual( + 'SELECT "date" AT TIME ZONE \'US/Eastern\' "alias1" FROM "customers"', + str(query), + ) + + def test_passes_kwargs_to_field_get_sql(self): + customers = Table("customers") + accounts = Table("accounts") + query = ( + Query.from_(customers) + .join(accounts) + .on(customers.account_id == accounts.account_id) + .select(AtTimezone(customers.date, "US/Eastern", alias="alias1")) + ) + + self.assertEqual( + 'SELECT "customers"."date" AT TIME ZONE \'US/Eastern\' "alias1" ' + 'FROM "customers" JOIN "accounts" ON "customers"."account_id"="accounts"."account_id"', + query.get_sql(with_namespace=True), + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/test_tuples.py b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/test_tuples.py new file mode 100644 index 0000000000000000000000000000000000000000..c8ebc8e41b0115777f8b3c8cb01c04e62f13ee18 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/test_tuples.py @@ -0,0 +1,162 @@ +import unittest + +from pypika import ( + Array, + Bracket, + Query, + PostgreSQLQuery, + Table, + Tables, + Tuple, +) +from pypika.functions import Coalesce, NullIf, Sum +from pypika.terms import Field + + +class TupleTests(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_tuple_equality_tuple_on_both(self): + q = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, self.table_abc.bar) + .where(Tuple(self.table_abc.foo, self.table_abc.bar) == Tuple(1, 2)) + ) + + self.assertEqual('SELECT "foo","bar" FROM "abc" ' 'WHERE ("foo","bar")=(1,2)', str(q)) + + def test_tuple_equality_tuple_on_left(self): + q = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, self.table_abc.bar) + .where(Tuple(self.table_abc.foo, self.table_abc.bar) == (1, 2)) + ) + + self.assertEqual('SELECT "foo","bar" FROM "abc" ' 'WHERE ("foo","bar")=(1,2)', str(q)) + + def test_tuple_equality_tuple_on_right(self): + q = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, self.table_abc.bar) + .where((self.table_abc.foo, self.table_abc.bar) == Tuple(1, 2)) + ) + + # Order is reversed due to lack of right equals method + self.assertEqual('SELECT "foo","bar" FROM "abc" ' 'WHERE (1,2)=("foo","bar")', str(q)) + + def test_tuple_in_using_python_tuples(self): + q = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, self.table_abc.bar) + .where(Tuple(self.table_abc.foo, self.table_abc.bar).isin([(1, 1), (2, 2), (3, 3)])) + ) + + self.assertEqual( + 'SELECT "foo","bar" FROM "abc" ' 'WHERE ("foo","bar") IN ((1,1),(2,2),(3,3))', + str(q), + ) + + def test_tuple_in_using_pypika_tuples(self): + q = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, self.table_abc.bar) + .where(Tuple(self.table_abc.foo, self.table_abc.bar).isin([Tuple(1, 1), Tuple(2, 2), Tuple(3, 3)])) + ) + + self.assertEqual( + 'SELECT "foo","bar" FROM "abc" ' 'WHERE ("foo","bar") IN ((1,1),(2,2),(3,3))', + str(q), + ) + + def test_tuple_in_using_mixed_tuples(self): + q = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, self.table_abc.bar) + .where(Tuple(self.table_abc.foo, self.table_abc.bar).isin([(1, 1), Tuple(2, 2), (3, 3)])) + ) + + self.assertEqual( + 'SELECT "foo","bar" FROM "abc" ' 'WHERE ("foo","bar") IN ((1,1),(2,2),(3,3))', + str(q), + ) + + def test_tuples_in_join(self): + query = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .select("*") + .where(Tuple(self.table_abc.foo, self.table_efg.bar).isin([(1, 1), Tuple(2, 2), (3, 3)])) + ) + + self.assertEqual( + 'SELECT * FROM "abc" JOIN "efg" ON "abc"."foo"="efg"."bar" ' + 'WHERE ("abc"."foo","efg"."bar") IN ((1,1),(2,2),(3,3))', + str(query), + ) + + def test_render_alias_in_array_sql(self): + tb = Table("tb") + + q = Query.from_(tb).select(Tuple(tb.col).as_("different_name")) + self.assertEqual(str(q), 'SELECT ("col") "different_name" FROM "tb"') + + def test_tuple_is_aggregate(self): + with self.subTest('None if single argument returns None for is_aggregate'): + self.assertEqual(None, Tuple(0).is_aggregate) + self.assertEqual(None, Tuple(Coalesce('col')).is_aggregate) + + with self.subTest('None if multiple arguments all return None for is_aggregate'): + self.assertEqual(None, Tuple(0, 'a').is_aggregate) + self.assertEqual(None, Tuple(Coalesce('col'), NullIf('col2', 0)).is_aggregate) + + with self.subTest('True if single argument returns True for is_aggregate'): + self.assertEqual(True, Tuple(Sum('col')).is_aggregate) + + with self.subTest('True if multiple arguments return True for is_aggregate'): + self.assertEqual(True, Tuple(Sum('col'), Sum('col2')).is_aggregate) + + with self.subTest('True when mix of arguments returning None and True for is_aggregate'): + self.assertEqual(True, Tuple(Coalesce('col'), Coalesce('col2', 0), Sum('col3')).is_aggregate) + + with self.subTest('False when one of the arguments returns False for is_aggregate'): + self.assertEqual(False, Tuple(Field('col1'), Sum('col2')).is_aggregate) + + +class ArrayTests(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_array_general(self): + query = Query.from_(self.table_abc).select(Array(1, "a", ["b", 2, 3])) + + self.assertEqual("SELECT [1,'a',['b',2,3]] FROM \"abc\"", str(query)) + + def test_empty_psql_array(self): + query = PostgreSQLQuery.from_(self.table_abc).select(Array()) + + self.assertEqual("SELECT '{}' FROM \"abc\"", str(query)) + + def test_psql_array_general(self): + query = PostgreSQLQuery.from_(self.table_abc).select(Array(1, Array(2, 2, 2), 3)) + + self.assertEqual("SELECT ARRAY[1,ARRAY[2,2,2],3] FROM \"abc\"", str(query)) + + def test_render_alias_in_array_sql(self): + tb = Table("tb") + + q = Query.from_(tb).select(Array(tb.col).as_("different_name")) + self.assertEqual(str(q), 'SELECT ["col"] "different_name" FROM "tb"') + + +class BracketTests(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_arithmetic_with_brackets(self): + q = Query.from_(self.table_abc).select(Bracket(self.table_abc.foo / 2) / 2) + + self.assertEqual('SELECT ("foo"/2)/2 FROM "abc"', str(q)) + + def test_arithmetic_with_brackets_and_alias(self): + q = Query.from_(self.table_abc).select(Bracket(self.table_abc.foo / 2).as_("alias")) + + self.assertEqual('SELECT ("foo"/2) "alias" FROM "abc"', str(q)) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/test_updates.py b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/test_updates.py new file mode 100644 index 0000000000000000000000000000000000000000..fb9d714dbcb8213b4bda04bf7b8dd9b2419410ec --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/test_updates.py @@ -0,0 +1,162 @@ +import unittest + +from pypika import AliasedQuery, PostgreSQLQuery, Query, SQLLiteQuery, SYSTEM_TIME, Table + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + +from pypika.terms import Star + + +class UpdateTests(unittest.TestCase): + table_abc = Table("abc") + table_def = Table("def") + + def test_empty_query(self): + q = Query.update("abc") + + self.assertEqual("", str(q)) + + def test_omit_where(self): + q = Query.update(self.table_abc).set("foo", "bar") + + self.assertEqual('UPDATE "abc" SET "foo"=\'bar\'', str(q)) + + def test_single_quote_escape_in_set(self): + q = Query.update(self.table_abc).set("foo", "bar'foo") + + self.assertEqual("UPDATE \"abc\" SET \"foo\"='bar''foo'", str(q)) + + def test_update__table_schema(self): + table = Table("abc", "schema1") + q = Query.update(table).set(table.foo, 1).where(table.foo == 0) + + self.assertEqual('UPDATE "schema1"."abc" SET "foo"=1 WHERE "foo"=0', str(q)) + + def test_update_with_none(self): + q = Query.update("abc").set("foo", None) + self.assertEqual('UPDATE "abc" SET "foo"=null', str(q)) + + def test_update_with_join(self): + q = ( + Query.update(self.table_abc) + .join(self.table_def) + .on(self.table_def.abc_id == self.table_abc.id) + .set(self.table_abc.lname, self.table_def.lname) + ) + self.assertEqual( + 'UPDATE "abc" JOIN "def" ON "def"."abc_id"="abc"."id" SET "lname"="def"."lname"', + str(q), + ) + + def test_update_with_limit(self): + q = Query.update(self.table_abc).set(self.table_abc.lname, "test").limit(1) + self.assertEqual('UPDATE "abc" SET "lname"=\'test\' LIMIT 1', str(q)) + + def test_update_from(self): + from_table = Table('from_table') + + q = Query.update(self.table_abc).set(self.table_abc.lname, from_table.long_name).from_(from_table) + self.assertEqual('UPDATE "abc" SET "lname"="from_table"."long_name" FROM "from_table"', str(q)) + + def test_update_from_with_where(self): + from_table = Table('from_table') + + q = ( + Query.update(self.table_abc) + .set(self.table_abc.lname, from_table.long_name) + .from_(from_table) + .where(self.table_abc.fname.eq(from_table.full_name)) + ) + self.assertEqual( + 'UPDATE "abc" SET "lname"="from_table"."long_name" FROM "from_table" ' + 'WHERE "abc"."fname"="from_table"."full_name"', + str(q), + ) + + def test_update_with_statement(self): + table_efg = Table('efg') + + sub_query = Query.from_(table_efg).select("fizz") + an_alias = AliasedQuery("an_alias") + + q = ( + Query.with_(sub_query, "an_alias") + .update(self.table_abc) + .from_(an_alias) + .set(self.table_abc.lname, an_alias.long_name) + .where(self.table_abc.comp.eq(an_alias.alias_comp)) + ) + self.assertEqual( + 'WITH an_alias AS (SELECT "fizz" FROM "efg") ' + 'UPDATE "abc" SET "lname"="an_alias"."long_name" FROM an_alias ' + 'WHERE "abc"."comp"="an_alias"."alias_comp"', + str(q), + ) + + def test_for_portion(self): + with self.subTest("with system time"): + q = Query.update(self.table_abc.for_portion(SYSTEM_TIME.from_to('2020-01-01', '2020-02-01'))).set( + "foo", "bar" + ) + + self.assertEqual( + 'UPDATE "abc" FOR PORTION OF SYSTEM_TIME FROM \'2020-01-01\' TO \'2020-02-01\' SET "foo"=\'bar\'', + str(q), + ) + + with self.subTest("with column"): + q = Query.update( + self.table_abc.for_portion(self.table_abc.valid_period.from_to('2020-01-01', '2020-02-01')) + ).set("foo", "bar") + + self.assertEqual( + 'UPDATE "abc" FOR PORTION OF "valid_period" FROM \'2020-01-01\' TO \'2020-02-01\' SET "foo"=\'bar\'', + str(q), + ) + + +class PostgresUpdateTests(unittest.TestCase): + table_abc = Table("abc") + + def test_update_returning_str(self): + q = PostgreSQLQuery.update(self.table_abc).where(self.table_abc.foo == 0).set("foo", "bar").returning("id") + + self.assertEqual('UPDATE "abc" SET "foo"=\'bar\' WHERE "foo"=0 RETURNING "abc"."id"', str(q)) + + def test_update_returning(self): + q = ( + PostgreSQLQuery.update(self.table_abc) + .where(self.table_abc.foo == 0) + .set("foo", "bar") + .returning(self.table_abc.id) + ) + + self.assertEqual('UPDATE "abc" SET "foo"=\'bar\' WHERE "foo"=0 RETURNING "abc"."id"', str(q)) + + def test_update_returning_from_different_tables(self): + table_bcd = Table('bcd') + + q = ( + PostgreSQLQuery.update(self.table_abc) + .from_(table_bcd) + .set(self.table_abc.lname, table_bcd.long_name) + .returning(self.table_abc.id, table_bcd.fname) + ) + self.assertEqual( + 'UPDATE "abc" SET "lname"="bcd"."long_name" FROM "bcd" RETURNING "abc"."id","bcd"."fname"', str(q) + ) + + def test_update_returning_star(self): + q = PostgreSQLQuery.update(self.table_abc).where(self.table_abc.foo == 0).set("foo", "bar").returning(Star()) + + self.assertEqual('UPDATE "abc" SET "foo"=\'bar\' WHERE "foo"=0 RETURNING *', str(q)) + + +class SQLLiteUpdateTests(unittest.TestCase): + table_abc = Table("abc") + + def test_update_with_bool(self): + q = SQLLiteQuery.update(self.table_abc).set(self.table_abc.foo, True) + + self.assertEqual('UPDATE "abc" SET "foo"=1', str(q)) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/test_utils.py b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/test_utils.py new file mode 100644 index 0000000000000000000000000000000000000000..bb9a9b1c68fe8671989f7c49f9db90e389d06f59 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pypika/tests/test_utils.py @@ -0,0 +1,24 @@ +import unittest + +from pypika import utils + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + + +class ImmutabilityTests(unittest.TestCase): + def test_raise_attribute_error_for_deepcopy(self): + with self.assertRaises(AttributeError): + utils.raise_attribute_for_copy("Test", "__deepcopy__") + + def test_raise_attribute_error_for_getstate(self): + with self.assertRaises(AttributeError): + utils.raise_attribute_for_copy("Test", "__getstate__") + + def test_raise_attribute_error_for_setstate(self): + with self.assertRaises(AttributeError): + utils.raise_attribute_for_copy("Test", "__setstate__") + + def test_raise_attribute_error_for_getnewargs(self): + with self.assertRaises(AttributeError): + utils.raise_attribute_for_copy("Test", "__getnewargs__") diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pyproject.toml b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pyproject.toml new file mode 100644 index 0000000000000000000000000000000000000000..dcc56baede23e3571b336625e695c466ab833a56 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/pyproject.toml @@ -0,0 +1,22 @@ +[tool.black] +line-length = 120 +skip-string-normalization = true +target-version = ['py38', 'py39', 'py310', 'py311'] +force-exclude = ''' +( + /( + \.eggs # exclude a few common directories in the + | \.git # root of the project + | \.hg + | \.mypy_cache + | \.tox + | \.venv + | _build + | buck-out + | build + | dist + | docs + )/ + | setup.py +) +''' diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/setup.cfg b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/setup.cfg new file mode 100644 index 0000000000000000000000000000000000000000..46084aaf2ca9e95b2f9bb7680e432e637fc3ed90 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/setup.cfg @@ -0,0 +1,16 @@ +[bumpversion] +current_version = 0.48.9 +commit = True +tag = True + +[bumpversion:file:pypika/__init__.py] +search = __version__ = "{current_version}" +replace = __version__ = "{new_version}" + +[bdist_wheel] +universal = 1 + +[flake8] +exclude = docs, .git, __pycache__ +max-line-length = 120 +per-file-ignores = __init__.py:F401 diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/setup.py b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/setup.py new file mode 100644 index 0000000000000000000000000000000000000000..41cce7d742df3e33e8d76f267d77df486f69249a --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/setup.py @@ -0,0 +1,81 @@ +import ast + +from setuptools import setup + + +def readme(): + with open('README.rst', 'rb') as f: + return f.read().decode('UTF-8') + + +def version(): + path = 'pypika/__init__.py' + with open(path, 'r') as file: + t = compile(file.read(), path, 'exec', ast.PyCF_ONLY_AST) + for node in (n for n in t.body if isinstance(n, ast.Assign)): + if len(node.targets) == 1: + name = node.targets[0] + if isinstance(name, ast.Name) and name.id in ('__version__', '__version_info__', 'VERSION'): + v = node.value + if isinstance(v, ast.Str): + return v.s + + if isinstance(v, ast.Tuple): + r = [] + for e in v.elts: + if isinstance(e, ast.Str): + r.append(e.s) + elif isinstance(e, ast.Num): + r.append(str(e.n)) + return '.'.join(r) + + +setup( + # Application name: + name="PyPika", + + # Version number: + version=version(), + + # Application author details: + author="Timothy Heys", + author_email="theys@kayak.com", + + # License + license='Apache License Version 2.0', + + # Packages + packages=["pypika", "pypika.clickhouse"], + + # Include additional files into the package + package_data={"pypika": ["py.typed"]}, + include_package_data=True, + + install_requires=[], + + # Details + url="https://github.com/kayak/pypika", + + description="A SQL query builder API for Python", + long_description=readme(), + + classifiers=[ + 'License :: OSI Approved :: Apache Software License', + 'Development Status :: 5 - Production/Stable', + 'Intended Audience :: Developers', + 'Programming Language :: Python :: 3', + 'Programming Language :: PL/SQL', + 'Topic :: Software Development :: Libraries :: Python Modules', + 'Topic :: Scientific/Engineering :: Information Analysis', + 'Topic :: Scientific/Engineering :: Mathematics', + 'Operating System :: POSIX', + 'Operating System :: MacOS :: MacOS X', + 'Operating System :: Microsoft :: Windows', + ], + keywords=('pypika python query builder querybuilder sql mysql postgres psql oracle vertica aggregated ' + 'relational database rdbms business analytics bi data science analysis pandas ' + 'orm object mapper'), + + # Dependent packages (distributions) + test_suite="pypika.tests", +) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/tox.ini b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/tox.ini new file mode 100644 index 0000000000000000000000000000000000000000..2f0e6893243b1ca2ead6a12825e9014dc66364ce --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/tests/trusted/tox.ini @@ -0,0 +1,16 @@ +[tox] +envlist = py38,py39,py310,py311,pypy3 + +[testenv] +description = testing against {basepython} +deps = -r requirements-dev.txt +commands = + coverage run + coverage xml + +[gh-actions] +python = + 3.8: py38 + 3.9: py39 + 3.10: py310 + 3.11: py311 diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/validation/canaries/first-hunk-only.sh b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/validation/canaries/first-hunk-only.sh new file mode 100644 index 0000000000000000000000000000000000000000..11e73cbe312726d51e5a7b8845c1f5aa1049c0de --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/validation/canaries/first-hunk-only.sh @@ -0,0 +1,25 @@ +#!/bin/bash +set -Eeuo pipefail +cd /testbed/repo +cat > /tmp/openenv-reference.diff <<'OPENENV_PARTIAL' +diff --git a/pypika/clickhouse/array.py b/pypika/clickhouse/array.py +index e554ab65de0ee41a80eba3911b1237c61a64e4a8..67929f1664e8a3d63d5b1a83cdf66ae590c53ce4 100644 +--- a/pypika/clickhouse/array.py ++++ b/pypika/clickhouse/array.py +@@ -57,10 +57,10 @@ + + class _AbstractArrayFunction(Function, metaclass=abc.ABCMeta): + def __init__(self, array: Array or Field, alias: str = None, schema: str = None): +- self.schema = alias +- self.alias = self.clickhouse_function() +- self.name = schema +- self._array = None ++ self.schema = schema ++ self.alias = alias ++ self.name = self.clickhouse_function() ++ self._array = array + + def get_sql(self, with_namespace=False, quote_char=None, dialect=None, **kwargs): + array = self._array.get_sql() +OPENENV_PARTIAL +/usr/bin/git -c core.hooksPath=/dev/null -c core.fsmonitor=false apply --whitespace=nowarn /tmp/openenv-reference.diff diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/validation/canaries/original-bug.sh b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/validation/canaries/original-bug.sh new file mode 100644 index 0000000000000000000000000000000000000000..927547df786c86ab3bb5eeb917a31e0fa1895f8b --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/validation/canaries/original-bug.sh @@ -0,0 +1,3 @@ +#!/bin/bash +set -Eeuo pipefail +: diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/validation/openenv.json b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/validation/openenv.json new file mode 100644 index 0000000000000000000000000000000000000000..a13b3c577df494f6c894584d2b608ab051ebc44f --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__laiatgzn/validation/openenv.json @@ -0,0 +1,27 @@ +{ + "canaries": "validation/canaries", + "profile": "harbor-semantic-v1", + "requires_credentials": false, + "resources": { + "cpu": 2, + "disk_mb": 16384, + "episode_timeout_s": 1800, + "memory_mb": 8192 + }, + "reward": { + "floor_margin": 0.1, + "oracle_tolerance": 0, + "range": [ + 0, + 1 + ] + }, + "reward_key": "reward", + "types": { + "tags": [ + "swe", + "python", + "mutation-repair" + ] + } +} diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/LICENSE.source b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/LICENSE.source new file mode 100644 index 0000000000000000000000000000000000000000..9c8f3ea0871e0bfe81da0fa6e7c1d7d156dc380e --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/LICENSE.source @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. \ No newline at end of file diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/adapter.json b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/adapter.json new file mode 100644 index 0000000000000000000000000000000000000000..bef4e90cb5d197e72c12cb6d428fd7aaadec9bc1 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/adapter.json @@ -0,0 +1,135 @@ +{ + "canary_selection": "Fixed first provided gold hunk only when at least2hunks exist; strict subset, never reward-selected. Single-hunk task original-bug canary is explicitly NOP-equivalent and adds no signal beyond floor_gap.", + "collector_sha256": "352e555112f2de8a1393f939903e4971c9ace0e944843762b707a725c5c72481", + "dependency_installation_pinned": false, + "dependency_setup_sha256": "ed8673d02878e91c7ae0b51b9178d6a15792b79c6992f800c14a941d95242392", + "gold_patch_sha256": "351152071f7288bf17963dfc40b5f2362498944ed68fe06029b12b9bef6e1090", + "hostile_code_isolation_established": false, + "known_wrong_semantic_implementations": 0, + "native_inventory_sha256": "9036a51f01b975de153e8b06d173b0e8076db3b588109e87ebadb769bcafefc9", + "new_files_deletions_and_executable_modes_supported": true, + "official_profile": { + "eval_sets": [], + "profile_class": "Pypika1c9646f0", + "profile_lines": [ + 736, + 739 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "upstream_repo": "kayak/pypika" + }, + "original_bug_canary_nop_equivalent": true, + "original_bug_runtime_wrongness_established": false, + "partial_repair_canary": true, + "partial_repair_sha256": "33eda3105dd1fa9b835f96e2aa674b5dafb1b506fa071b848acf6094a10b457f", + "partial_repair_wrongness_established": false, + "positive_approval_policy": "All original strict presence/identity/no-skip/no-error/exit checks retained", + "private_checker_sha256": "f0a641064b725415e23a0221bb53c90446d7efcb7f9ece5ede93a220d18dd9e7", + "private_checker_version": "matched-failure-precedence-v2", + "provided_original_bug_control": true, + "repo_url": "https://github.com/swesmith/kayak__pypika.1c9646f0.git", + "runtime_image": null, + "runtime_ready": false, + "runtime_recipe": { + "dependency_installation_pinned": false, + "official_install_cmds": [ + "python -m pip install -e ." + ], + "official_pytest_argv": [ + "pytest", + "--disable-warnings", + "--color=no", + "--tb=no", + "--verbose" + ], + "official_test_command": "source /opt/miniconda3/bin/activate; conda activate testbed; pytest --disable-warnings --color=no --tb=no --verbose", + "operator_test_runner_prerequisites": [ + "python -m pip install pytest==8.4.2" + ], + "operator_test_runner_reason": "The official profile invokes pytest, but the common tools runtime does not provide it; pinned separately from source-native project requirements.", + "panel_normalization": "Override project addopts only to execute the exact frozen native panels; add JUnit output, preserve official pytest options and all selectors.", + "python_version": "3.10", + "source_bound_test_dependency_cmds": [ + "python -m pip install parameterized==0.7.0" + ], + "test_dependency_source_sha256": { + "requirements-dev.txt": "10f4ba7b19a73950d28fd7403d7e1d1b1fe2ccc4f49516974f47199d2965f23d", + "setup.py": "f8bad274588a22e65764d8cf9fb2be5aa6fcfaf3bf861d71e5f751105898845a", + "tox.ini": "c2d7205d0ac93e9c9e80dc5d24f0a826a6781f587a33ea722ea621f9e2ccd0ea" + } + }, + "runtime_resource_review_required": false, + "schema": "python-git-patch-jobs-v1", + "source_base_commit": "f0ce68b7ae9252cfd00a125242c3ebcf8e161015", + "source_completion_sha256": "aeafc48de8ba3717d6261c73dfe627c06204035ba14f1980ccba45df25358efa", + "source_index_sha256": "e856874b9410fce9f3bfea52c8c482e84b3e43942d87517f8b55f0034bd40f6f", + "source_pr_url": null, + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:kayak__pypika.1c9646f0.combine_module__q1pjmphb", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "6a742f12bfa386994289ec8b75824663d8ee4b15", + "instruction_sha256": "ee63b6bb66013a67214ea245b5ec31e4b1cc36daca7d658ac92209eaf637f210", + "is_fork": true, + "learner_path": "tasks/6986f4145368fdf626c9f968/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "actual_upstream_url": "https://raw.githubusercontent.com/kayak/pypika/1c9646f0a019a167c32b649b6f5e6423c5ba2c9b/LICENSE.txt", + "reviewed": true, + "sha256": "c5accbbd8546e94c34aed24afe689a617627d18eed5a6c48277e48db57c23851", + "spdx": "Apache-2.0", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/kayak__pypika.1c9646f0/f0ce68b7ae9252cfd00a125242c3ebcf8e161015/LICENSE.txt" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "patch_sha256": "03d8b4ef1919fec5d72e196826368c6d0c09d89b91fb89e1f0d7aeddb928a075", + "provenance_path": "tasks/6986f4145368fdf626c9f968/source-proof.json", + "repository_lineage": [ + "swesmith/kayak__pypika.1c9646f0", + "kayak/pypika" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "f0ce68b7ae9252cfd00a125242c3ebcf8e161015", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "589c4fe73ad443f0567da3690247b84179f963af", + "source_kind": "mutation", + "source_repo": "swesmith/kayak__pypika.1c9646f0", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "kayak__pypika.1c9646f0.combine_module__q1pjmphb", + "task_sha256": "b6f07f3bbc04770758db063eeb7f2cb7840b5d28bc4a7ec1ea4573984d234891", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "kayak/pypika", + "usage": "quarantine_only" + }, + "source_repo": "swesmith/kayak__pypika.1c9646f0", + "symlink_submodule_changes_supported": false, + "task_id": "kayak__pypika.1c9646f0.combine_module__q1pjmphb", + "transfer": "index-independent-worktree-to-Git-binary-patch", + "transfer_path": "/testbed/submission.patch", + "upstream_repo": "kayak/pypika" +} diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/dependency-setup.sh b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/dependency-setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e1a28db070ebf088cec3ef817cf2dc8715091ac2 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/dependency-setup.sh @@ -0,0 +1,9 @@ +#!/bin/bash +set -Eeuo pipefail +source /opt/miniconda3/bin/activate +conda activate testbed +cd /testbed/repo +python -c 'import sys; assert sys.version_info[:2] == (3, 10)' +python -m pip install pytest==8.4.2 +python -m pip install -e . +python -m pip install parameterized==0.7.0 diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/environment/Dockerfile b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..a59b58c2ea8217c78c1e39b4678f93c8c0023bcd --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/environment/Dockerfile @@ -0,0 +1,3 @@ +# Runtime is selected only by an independently qualified immutable amd64 receipt. +FROM ubuntu:22.04 +RUN false diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/instruction.md b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..8f495754ba30415d0df5029acecd1ed906a0496e --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/instruction.md @@ -0,0 +1,40 @@ +ClickHouse array and search string functions generating incorrect SQL + +#### Description + +The ClickHouse array functions and multi-search string functions are producing malformed SQL output. Arrays are being rendered with parentheses instead of square brackets, function names and arguments are swapped, and aliases are being reversed. + +#### Steps/Code to Reproduce + +```python +from pypika.clickhouse import Array, Length, HasAny +from pypika.clickhouse.search_string import MultiSearchAny +from pypika import Field + +# Array with simple values +arr = Array([1, 2, 3, 4]) +print("Expected: [1,2,3,4]") +print("Actual:", arr.get_sql()) + +# Array function like Length +field = Field('tags') +length_func = Length(field) +print("Expected: length(tags)") +print("Actual:", length_func.get_sql()) + +# HasAny function +has_any = HasAny([1, 2, 3, 4], 3) +print("Expected: hasAny([1,2,3,4], 3)") +print("Actual:", has_any.get_sql()) + +# Multi-search function +multi_search = MultiSearchAny(Field('text'), ['pattern1', 'pattern2']) +print("Expected: multiSearchAny(text, ['pattern1','pattern2'])") +print("Actual:", multi_search.get_sql()) +``` + +The output shows arrays using parentheses instead of square brackets, function names and parameters being swapped, and other formatting issues that make the generated SQL invalid for ClickHouse. + +## Environment + +The repository is at `/testbed/repo`. Its dependencies, including pytest, are installed in the `testbed` conda environment, which comes first on PATH. If `python -m pytest` reports that pytest is missing, use the full interpreter path: `/opt/miniconda3/envs/testbed/bin/python -m pytest `. Don't install packages: the tests need nothing else, and the sandbox may have no network access. diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/metadata.json b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/metadata.json new file mode 100644 index 0000000000000000000000000000000000000000..80daf44c571231826cf342b157f34da8cad202b1 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/metadata.json @@ -0,0 +1,1276 @@ +{ + "all_runtime_and_training_flags": false, + "official_profile": { + "eval_sets": [], + "profile_class": "Pypika1c9646f0", + "profile_lines": [ + 736, + 739 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "upstream_repo": "kayak/pypika" + }, + "source_healthy_reference_proof": { + "FAIL_TO_PASS": [ + "pypika/tests/clickhouse/test_array.py::TestArray::test_get_sql_0__ridley_scott_jimi_hendrix_", + "pypika/tests/clickhouse/test_array.py::TestArray::test_get_sql_1__1_2_3_4_", + "pypika/tests/clickhouse/test_array.py::TestArray::test_get_sql_2__toInt64_1_toInt64_2_toInt64_3_toInt64_4_", + "pypika/tests/clickhouse/test_array.py::TestArray::test_get_sql_3__toFixedString_mogwai_10_toFixedString_mono_10_toFixedString_bonobo_10_arr", + "pypika/tests/clickhouse/test_array.py::TestHasAny::test_get_sql_1_hasAny_1_2_3_4_3_", + "pypika/tests/clickhouse/test_array.py::TestHasAny::test_get_sql_2_hasAny_bands_toFixedString_port_royal_20_toFixedString_hammock_20_", + "pypika/tests/clickhouse/test_array.py::TestLength::test_get_sql_0_length_tags_", + "pypika/tests/clickhouse/test_array.py::TestLength::test_get_sql_1_length_1_2_3_", + "pypika/tests/clickhouse/test_array.py::TestEmpty::test_get_sql_0_empty_tags_", + "pypika/tests/clickhouse/test_array.py::TestEmpty::test_get_sql_1_empty_1_2_3_", + "pypika/tests/clickhouse/test_array.py::TestNotEmpty::test_get_sql_0_notEmpty_tags_", + "pypika/tests/clickhouse/test_array.py::TestNotEmpty::test_get_sql_1_notEmpty_1_2_3_", + "pypika/tests/clickhouse/test_search_string.py::TestMultiSearch::test_multi_search_string_0", + "pypika/tests/clickhouse/test_search_string.py::TestMultiSearch::test_multi_search_string_1" + ], + "PASS_TO_PASS": [ + "pypika/tests/clickhouse/test_array.py::TestHasAny::test_get_sql_0_hasAny_mental_abilities_physical_abilities_", + "pypika/tests/clickhouse/test_condition.py::TestIfCondition::test_get_sql_0", + "pypika/tests/clickhouse/test_condition.py::TestIfCondition::test_get_sql_1", + "pypika/tests/clickhouse/test_condition.py::TestMultiIfCondition::test_get_sql_0", + "pypika/tests/clickhouse/test_condition.py::TestMultiIfCondition::test_get_sql_1", + "pypika/tests/clickhouse/test_dates_and_times.py::TestFormatDateTime::test_get_sql_0", + "pypika/tests/clickhouse/test_dates_and_times.py::TestFormatDateTime::test_get_sql_1", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_00", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_01", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_02", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_03", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_04", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_05", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_06", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_07", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_08", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_09", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_10", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_11", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_12", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_13", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_14", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_15", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_16", + "pypika/tests/clickhouse/test_dates_and_times.py::TestToYYYYMM::test_get_sql", + "pypika/tests/clickhouse/test_nullable_arg.py::TestSearchString::test_get_sql_0", + "pypika/tests/clickhouse/test_nullable_arg.py::TestSearchString::test_get_sql_1", + "pypika/tests/clickhouse/test_search_string.py::TestSearchString::test_search_string_0", + "pypika/tests/clickhouse/test_search_string.py::TestSearchString::test_search_string_1", + "pypika/tests/clickhouse/test_search_string.py::TestSearchString::test_search_string_2", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_00_toString_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_01_toInt8_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_02_toInt16_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_03_toInt32_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_04_toInt64_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_05_toUInt8_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_06_toUInt16_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_07_toUInt32_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_08_toUInt64_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_09_toFloat32_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_10_toFloat64_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_11_toFloat64_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_12_toDate_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_13_toDateTime_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_14_toFixedString_field_name_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_00_toString_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_01_toInt8_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_02_toInt16_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_03_toInt32_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_04_toInt64_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_05_toUInt8_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_06_toUInt16_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_07_toUInt32_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_08_toUInt64_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_09_toFloat32_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_10_toFloat64_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_11_toFloat64_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_12_toDate_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_13_toDateTime_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_14_toFixedString_100_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestToFixedString::test_get_sql_with_table", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseQueryTests::test_use_AS_keyword_for_alias", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseQueryTests::test_use_FINAL_keyword", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseQueryTests::test_use_SAMPLE_keyword", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseQueryTests::test_use_SAMPLE_with_offset_keyword", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDeleteTests::test_omit_where", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDeleteTests::test_omit_where__table_schema", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDeleteTests::test_where_field_equals", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseUpdateTests::test_update", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDropQuery::test_drop_database", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDropQuery::test_drop_dictionary", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDropQuery::test_drop_other", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDropQuery::test_drop_table", + "pypika/tests/dialects/test_clickhouse.py::DistinctOnTests::test_distinct_on", + "pypika/tests/dialects/test_clickhouse.py::LimitByTests::test_limit_by", + "pypika/tests/dialects/test_clickhouse.py::LimitByTests::test_limit_offset0_by", + "pypika/tests/dialects/test_clickhouse.py::LimitByTests::test_limit_offset_by", + "pypika/tests/dialects/test_clickhouse.py::LimitByTests::test_rename_table", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_distinct_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_groupby_alias_False_does_not_group_by_alias_when_subqueries_are_present", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_groupby_alias_False_does_not_group_by_alias_with_standard_query", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_limit", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_limit_with_offset", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_normal_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_offset", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_distinct_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_percent_invalid_range", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_percent_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_select_non_int", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_with_ties_select", + "pypika/tests/dialects/test_mysql.py::SelectTests::test_distinct_select", + "pypika/tests/dialects/test_mysql.py::SelectTests::test_modifier_select", + "pypika/tests/dialects/test_mysql.py::SelectTests::test_multiple_modifier_select", + "pypika/tests/dialects/test_mysql.py::SelectTests::test_normal_select", + "pypika/tests/dialects/test_mysql.py::UpdateTests::test_conflict_handlers_update", + "pypika/tests/dialects/test_mysql.py::UpdateTests::test_on_duplicate_key_ignore_update", + "pypika/tests/dialects/test_mysql.py::UpdateTests::test_on_duplicate_key_update_update", + "pypika/tests/dialects/test_mysql.py::UpdateTests::test_update", + "pypika/tests/dialects/test_mysql.py::LoadCSVTests::test_load_from_file", + "pypika/tests/dialects/test_mysql.py::TableTests::test_create_table", + "pypika/tests/dialects/test_mysql.py::TableTests::test_drop_table", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_fetch_next_method_deprecated", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_groupby_alias_False_does_not_group_by_alias_when_subqueries_are_present", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_groupby_alias_False_does_not_group_by_alias_with_standard_query", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_limit_offset_query", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_limit_query", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_offset_query", + "pypika/tests/dialects/test_postgresql.py::InsertTests::test_array_keyword", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_alias_set_correctly", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_json_value_from_array_num", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_json_value_from_array_str", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_json_value_from_dict", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_json_value_from_dict_recursive", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_json_value_by_index", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_json_value_by_key", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_path_json_value", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_path_text_value", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_text_value_by_index", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_text_value_by_key", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contained_by_using_list_arg", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contained_by_using_str_arg", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contained_by_with_complex_criterion", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contains_for_field", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contains_for_json", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_has_any_keys", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_has_key", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_has_keys", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_subnet_contains_inet", + "pypika/tests/dialects/test_postgresql.py::DistinctOnTests::test_distinct_on", + "pypika/tests/dialects/test_postgresql.py::ArrayTests::test_array_syntax", + "pypika/tests/dialects/test_postgresql.py::ArrayTests::test_render_alias_in_array_sql", + "pypika/tests/dialects/test_postgresql.py::ReturningClauseTests::test_no_queryexception_if_returning_used_on_valid_query_type", + "pypika/tests/dialects/test_postgresql.py::ReturningClauseTests::test_queryexception_if_returning_used_on_invalid_query", + "pypika/tests/dialects/test_postgresql.py::ReturningClauseTests::test_return_field_from_join_table", + "pypika/tests/dialects/test_postgresql.py::ReturningClauseTests::test_returning_from_missing_table_raises_queryexception", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_dont_use_double_quotes_on_create_queries", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_dont_use_double_quotes_on_drop_queries", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_dont_use_double_quotes_on_joining_queries", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_use_double_quotes_on_alias_but_not_on_terms", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_use_double_quotes_on_alias_but_not_on_terms_with_joins", + "pypika/tests/dialects/test_sqllite.py::SelectTests::test_bool_false_as_zero", + "pypika/tests/dialects/test_sqllite.py::SelectTests::test_bool_true_as_one", + "pypika/tests/dialects/test_sqllite.py::ReplaceTests::test_insert_or_replace", + "pypika/tests/dialects/test_sqllite.py::ReplaceTests::test_normal_replace", + "pypika/tests/dialects/test_sqllite.py::ReplaceTests::test_replace_subquery", + "pypika/tests/dialects/test_vertica.py::VerticaQueryTests::test_delete_query_with_hint", + "pypika/tests/dialects/test_vertica.py::VerticaQueryTests::test_insert_query_with_hint", + "pypika/tests/dialects/test_vertica.py::VerticaQueryTests::test_select_query_with_hint", + "pypika/tests/dialects/test_vertica.py::VerticaQueryTests::test_update_query_with_hint", + "pypika/tests/dialects/test_vertica.py::CopyCSVTests::test_copy_from_file", + "pypika/tests/dialects/test_vertica.py::CreateTemporaryTableTests::test_create_local_table_without_temporary_raises_error", + "pypika/tests/dialects/test_vertica.py::CreateTemporaryTableTests::test_create_local_temporary_table", + "pypika/tests/dialects/test_vertica.py::CreateTemporaryTableTests::test_create_table_preserve_rows_without_temporary_raises_error", + "pypika/tests/dialects/test_vertica.py::CreateTemporaryTableTests::test_create_temporary_table_preserve_rows", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__agg_case_criterion_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__agg_case_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__agg_func_arithmetic_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__agg_func_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__case_mixed_constant_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__case_mixed_else_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__case_with_field_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__case_with_single_aggregate_field_in_one_criterion_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__constant_arithmetic_is_aggregate_none", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__constant_is_aggregate_none", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__field_arithmetic_constant_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__field_arithmetic_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__field_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__func_arithmetic_constant_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__mixed_case_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__mixed_func_arithmetic_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__negative_agg_func_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__non_aggregate_function_with_aggregated_arg", + "pypika/tests/test_aggregate.py::IsAggregateTests::test_complicated", + "pypika/tests/test_analytic_queries.py::RankTests::test_avg", + "pypika/tests/test_analytic_queries.py::RankTests::test_count_range_between_unbounded_preceeding_current_row", + "pypika/tests/test_analytic_queries.py::RankTests::test_dense_rank", + "pypika/tests/test_analytic_queries.py::RankTests::test_empty_over", + "pypika/tests/test_analytic_queries.py::RankTests::test_filter", + "pypika/tests/test_analytic_queries.py::RankTests::test_filter_quote_table_in_filter", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value_ignore_nulls", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value_ignore_nulls_first", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value_multi_argument", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value_range_between_x_preceeding_unbounded_following", + "pypika/tests/test_analytic_queries.py::RankTests::test_lag_generates_correct_sql", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value_ignore_nulls", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value_multi_argument", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value_rows_between_current_row_unbounded_following", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value_rows_between_current_row_unbounded_following_ignore_nulls", + "pypika/tests/test_analytic_queries.py::RankTests::test_lead_generates_correct_sql", + "pypika/tests/test_analytic_queries.py::RankTests::test_max_range_x_preceeding", + "pypika/tests/test_analytic_queries.py::RankTests::test_max_rows_x_preceeding", + "pypika/tests/test_analytic_queries.py::RankTests::test_median", + "pypika/tests/test_analytic_queries.py::RankTests::test_min_range_current_row", + "pypika/tests/test_analytic_queries.py::RankTests::test_min_rows_current_row", + "pypika/tests/test_analytic_queries.py::RankTests::test_multiple_partitions", + "pypika/tests/test_analytic_queries.py::RankTests::test_ntile_no_partition_or_order_invalid_sql", + "pypika/tests/test_analytic_queries.py::RankTests::test_ntile_with_order", + "pypika/tests/test_analytic_queries.py::RankTests::test_ntile_with_partition", + "pypika/tests/test_analytic_queries.py::RankTests::test_ntile_with_partition_and_order", + "pypika/tests/test_analytic_queries.py::RankTests::test_orderby_asc", + "pypika/tests/test_analytic_queries.py::RankTests::test_orderby_desc", + "pypika/tests/test_analytic_queries.py::RankTests::test_range_called_twice_raises_attribute_error", + "pypika/tests/test_analytic_queries.py::RankTests::test_range_then_rows_raises_attribute_error", + "pypika/tests/test_analytic_queries.py::RankTests::test_rank", + "pypika/tests/test_analytic_queries.py::RankTests::test_rank_with_alias", + "pypika/tests/test_analytic_queries.py::RankTests::test_row_number", + "pypika/tests/test_analytic_queries.py::RankTests::test_rows_called_twice_raises_attribute_error", + "pypika/tests/test_analytic_queries.py::RankTests::test_rows_then_range_raises_attribute_error", + "pypika/tests/test_analytic_queries.py::RankTests::test_stddev", + "pypika/tests/test_analytic_queries.py::RankTests::test_stddev_pop", + "pypika/tests/test_analytic_queries.py::RankTests::test_stddev_samp", + "pypika/tests/test_analytic_queries.py::RankTests::test_sum_rows_unbounded_preceeding", + "pypika/tests/test_analytic_queries.py::RankTests::test_table_prefixes_used_in_analytic_functions", + "pypika/tests/test_analytic_queries.py::RankTests::test_var_pop", + "pypika/tests/test_analytic_queries.py::RankTests::test_var_samp", + "pypika/tests/test_analytic_queries.py::RankTests::test_variance", + "pypika/tests/test_analytic_queries.py::RankTests::test_variance_rows_between_unbounded_preceeding_unbounded_following", + "pypika/tests/test_analytic_queries.py::RankTests::test_varpop_range_unbounded_preceeding", + "pypika/tests/test_analytic_queries.py::RankTests::test_varpop_rows_between_unbounded_preceeding_x_following", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_as_select_not_query_raises_error", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_with_columns", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_with_select", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_with_select_and_columns_fails", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_without_columns_or_select_empty", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_if_not_exists", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_simple", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_unique", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_where", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_without_columns_raises_error", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_without_table_raises_error", + "pypika/tests/test_criterions.py::CriterionTests::test__bitwise_and_in_where_clause", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_bitwise_and", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_bitwise_and_with_alias", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_bool", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_decimal", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_str", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gt_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gt_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gt_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gt_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gte_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gte_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gte_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gte_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_is_null", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_is_null_with_alias", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lt_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lt_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lt_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lt_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lte_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lte_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lte_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lte_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_str", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_with_alias", + "pypika/tests/test_criterions.py::NotTests::test_chained_function", + "pypika/tests/test_criterions.py::NotTests::test_is_not_null", + "pypika/tests/test_criterions.py::NotTests::test_negate", + "pypika/tests/test_criterions.py::NotTests::test_not_null", + "pypika/tests/test_criterions.py::NotTests::test_not_null_with_alias", + "pypika/tests/test_criterions.py::NotTests::test_not_with_and_criterion", + "pypika/tests/test_criterions.py::NotTests::test_not_with_complex_criterion", + "pypika/tests/test_criterions.py::NotTests::test_not_with_or_criterion", + "pypika/tests/test_criterions.py::NotTests::test_notnullcriterion_replace_table", + "pypika/tests/test_criterions.py::NotTests::test_variable_access", + "pypika/tests/test_criterions.py::BetweenTests::test__between_date", + "pypika/tests/test_criterions.py::BetweenTests::test__between_datetime", + "pypika/tests/test_criterions.py::BetweenTests::test__between_number", + "pypika/tests/test_criterions.py::BetweenTests::test__between_with_alias", + "pypika/tests/test_criterions.py::BetweenTests::test__function_between", + "pypika/tests/test_criterions.py::BetweenTests::test_get_item_only_works_with_slice", + "pypika/tests/test_criterions.py::IsInTests::test__function_isin", + "pypika/tests/test_criterions.py::IsInTests::test__in_character", + "pypika/tests/test_criterions.py::IsInTests::test__in_date", + "pypika/tests/test_criterions.py::IsInTests::test__in_datetime", + "pypika/tests/test_criterions.py::IsInTests::test__in_number", + "pypika/tests/test_criterions.py::IsInTests::test__in_number_with_alias", + "pypika/tests/test_criterions.py::IsInTests::test__in_unicode", + "pypika/tests/test_criterions.py::ArithmeticExpressionTests::test__lshift", + "pypika/tests/test_criterions.py::ArithmeticExpressionTests::test__rshift", + "pypika/tests/test_criterions.py::NotInTests::test__function_notin", + "pypika/tests/test_criterions.py::NotInTests::test__notin_character", + "pypika/tests/test_criterions.py::NotInTests::test__notin_date", + "pypika/tests/test_criterions.py::NotInTests::test__notin_datetime", + "pypika/tests/test_criterions.py::NotInTests::test__notin_number", + "pypika/tests/test_criterions.py::NotInTests::test__notin_number_with_alias", + "pypika/tests/test_criterions.py::LikeTests::test_glob_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_contains", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_ends_with", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_n_chars_long", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_starts_with", + "pypika/tests/test_criterions.py::LikeTests::test_like_contains", + "pypika/tests/test_criterions.py::LikeTests::test_like_ends_with", + "pypika/tests/test_criterions.py::LikeTests::test_like_n_chars_long", + "pypika/tests/test_criterions.py::LikeTests::test_like_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_like_starts_with", + "pypika/tests/test_criterions.py::LikeTests::test_not_ilike_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_not_like_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_rlike_escape_chars", + "pypika/tests/test_criterions.py::ExistsCriterionTests::test_exists", + "pypika/tests/test_criterions.py::ExistsCriterionTests::test_not_exists", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__between_and_field", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__between_and_isin", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__nested__and", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__nested__mixed", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__nested__or", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_and", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_function_and", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_function_or", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_function_xor", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_or", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_xor", + "pypika/tests/test_criterions.py::FieldsAsCriterionTests::test__field_and_field", + "pypika/tests/test_criterions.py::FieldsAsCriterionTests::test__field_or_field", + "pypika/tests/test_criterions.py::FieldsAsCriterionTests::test__field_xor_field", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_arithmeticfunction_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_betweencriterion_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_complexcriterion_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_criterion_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_field_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_function_with_only_fields_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_function_with_values_and_fields_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_nullcriterion_replace_table", + "pypika/tests/test_criterions.py::AnyTests::test_multiple_args_returned_in_chain_of_ors", + "pypika/tests/test_criterions.py::AnyTests::test_single_arg_returns_self", + "pypika/tests/test_criterions.py::AnyTests::test_with_generator", + "pypika/tests/test_criterions.py::AnyTests::test_zero_args_returns_empty_criterion", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_different_operations_with_empty_criterion", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_empty_criterion_on_the_left", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_empty_criterion_on_the_right", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_fields_", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_invertion_of_the_empty_criterion", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_more_than_one_empty_criterions", + "pypika/tests/test_criterions.py::AllTests::test_multiple_args_returned_in_chain_of_ors", + "pypika/tests/test_criterions.py::AllTests::test_single_arg_returns_self", + "pypika/tests/test_criterions.py::AllTests::test_with_generator", + "pypika/tests/test_criterions.py::AllTests::test_zero_args_returns_empty_criterion", + "pypika/tests/test_custom_functions.py::TestUnitCustomFunction::test_should_fail_with_wrong_arguments", + "pypika/tests/test_custom_functions.py::TestUnitCustomFunction::test_should_return_function_with_arguments", + "pypika/tests/test_custom_functions.py::TestUnitCustomFunction::test_should_return_function_with_no_arguments", + "pypika/tests/test_custom_functions.py::TestFunctionalCustomFunction::test_should_fail_use_custom_function_on_select_with_wrong_arguments", + "pypika/tests/test_custom_functions.py::TestFunctionalCustomFunction::test_should_use_custom_function_on_select", + "pypika/tests/test_data_types.py::StringTests::test_inline_string_concatentation", + "pypika/tests/test_data_types.py::UuidTests::test_uuid_string_generation", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_day", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_default", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_microsecond", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_minute", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_month", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_quarter", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_second", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_week", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_year", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_day_hour", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_day_microsecond", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_day_minute", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_day_second", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_hour_microsecond", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_hour_minute", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_hour_second", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_minute_microsecond", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_minute_second", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_second_microsecond", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_value_complex_expressions", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_value_right", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_year_month", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_mysql_dialect_uses_single_quotes_around_expression_in_an_interval", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_oracle_dialect_uses_single_quotes_around_expression_in_an_interval", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_postgresql_dialect_uses_single_quotes_around_interval", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_redshift_dialect_uses_single_quotes_around_interval", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_vertica_dialect_uses_single_quotes_around_interval", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_day", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_month", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_week", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_year", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_year_month", + "pypika/tests/test_date_math.py::TruncateTrailingZerosTests::test_do_not_truncate_integer_values", + "pypika/tests/test_date_math.py::TruncateTrailingZerosTests::test_do_not_truncate_months_between_years_and_datys", + "pypika/tests/test_deletes.py::DeleteTests::test_for_portion", + "pypika/tests/test_deletes.py::DeleteTests::test_omit_where", + "pypika/tests/test_deletes.py::DeleteTests::test_omit_where__table_schema", + "pypika/tests/test_deletes.py::DeleteTests::test_where_field_equals", + "pypika/tests/test_deletes.py::PostgresDeleteTests::test_delete_returning", + "pypika/tests/test_deletes.py::PostgresDeleteTests::test_delete_returning_star", + "pypika/tests/test_deletes.py::PostgresDeleteTests::test_delete_returning_str", + "pypika/tests/test_deletes.py::PostgresDeleteTests::test_delete_using", + "pypika/tests/test_drop.py::DropTableTests::test_drop_database", + "pypika/tests/test_drop.py::DropTableTests::test_drop_index", + "pypika/tests/test_drop.py::DropTableTests::test_drop_table", + "pypika/tests/test_drop.py::DropTableTests::test_drop_user", + "pypika/tests/test_drop.py::DropTableTests::test_drop_view", + "pypika/tests/test_formats.py::QuoteTests::test_no_quote_char_in_complex_query", + "pypika/tests/test_formats.py::QuoteTests::test_replace_quote_char_in_complex_query", + "pypika/tests/test_functions.py::FunctionTests::test_dialect_propagation", + "pypika/tests/test_functions.py::FunctionTests::test_is_aggregate_None_for_non_aggregate_function_or_function_with_no_aggregate_functions", + "pypika/tests/test_functions.py::FunctionTests::test_is_aggregate_True_for_aggregate_function_or_function_with_aggregate_functions", + "pypika/tests/test_functions.py::SchemaTests::test_schema_included_in_function_sql", + "pypika/tests/test_functions.py::SchemaTests::test_schema_no_schema_in_sql_when_none_set", + "pypika/tests/test_functions.py::ArithmeticTests::test__addition__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__addition__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__addition__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__addition__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__arithmetic_equality", + "pypika/tests/test_functions.py::ArithmeticTests::test__arithmetic_with_function", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_add_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_div_no_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_div_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_exponent_no_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_exponent_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_floor_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_function_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_modulus_no_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_modulus_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_mul_no_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_mul_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_nested_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_sub_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__division__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__division__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__division__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__division__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__exponent__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__exponent__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__floor", + "pypika/tests/test_functions.py::ArithmeticTests::test__leftshift__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__leftshift__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__leftshift__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__modulus__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__multiplication__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__multiplication__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__multiplication__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__multiplication__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__rightshift__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__rightshift__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__rightshift__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__subtraction__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__subtraction__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__subtraction__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__subtraction__right", + "pypika/tests/test_functions.py::AggregationTests::test__approx_percentile", + "pypika/tests/test_functions.py::AggregationTests::test__avg", + "pypika/tests/test_functions.py::AggregationTests::test__count", + "pypika/tests/test_functions.py::AggregationTests::test__count__star", + "pypika/tests/test_functions.py::AggregationTests::test__first", + "pypika/tests/test_functions.py::AggregationTests::test__last", + "pypika/tests/test_functions.py::AggregationTests::test__max", + "pypika/tests/test_functions.py::AggregationTests::test__min", + "pypika/tests/test_functions.py::AggregationTests::test__std", + "pypika/tests/test_functions.py::AggregationTests::test__stddev", + "pypika/tests/test_functions.py::AggregationTests::test__subquery_in_params_functions", + "pypika/tests/test_functions.py::AggregationTests::test__sum", + "pypika/tests/test_functions.py::ConditionTests::test__case__else", + "pypika/tests/test_functions.py::ConditionTests::test__case__field", + "pypika/tests/test_functions.py::ConditionTests::test__case__multi", + "pypika/tests/test_functions.py::ConditionTests::test__case__no_cases", + "pypika/tests/test_functions.py::ConditionTests::test__case__raw", + "pypika/tests/test_functions.py::StringTests::test__ascii__field", + "pypika/tests/test_functions.py::StringTests::test__ascii__int", + "pypika/tests/test_functions.py::StringTests::test__ascii__str", + "pypika/tests/test_functions.py::StringTests::test__bin__field", + "pypika/tests/test_functions.py::StringTests::test__bin__int", + "pypika/tests/test_functions.py::StringTests::test__bin__str", + "pypika/tests/test_functions.py::StringTests::test__concat__field", + "pypika/tests/test_functions.py::StringTests::test__concat__str", + "pypika/tests/test_functions.py::StringTests::test__insert__field", + "pypika/tests/test_functions.py::StringTests::test__insert__str", + "pypika/tests/test_functions.py::StringTests::test__length__field", + "pypika/tests/test_functions.py::StringTests::test__length__str", + "pypika/tests/test_functions.py::StringTests::test__lower__field", + "pypika/tests/test_functions.py::StringTests::test__lower__str", + "pypika/tests/test_functions.py::StringTests::test__replace__field", + "pypika/tests/test_functions.py::StringTests::test__replace__str", + "pypika/tests/test_functions.py::StringTests::test__substring", + "pypika/tests/test_functions.py::SplitPartFunctionTests::test__split_part", + "pypika/tests/test_functions.py::RegexpLikeFunctionTests::test__regexp_like", + "pypika/tests/test_functions.py::CastTests::test__cast__as", + "pypika/tests/test_functions.py::CastTests::test__cast__binary", + "pypika/tests/test_functions.py::CastTests::test__cast__binary_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__boolean", + "pypika/tests/test_functions.py::CastTests::test__cast__char", + "pypika/tests/test_functions.py::CastTests::test__cast__char_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__date", + "pypika/tests/test_functions.py::CastTests::test__cast__float", + "pypika/tests/test_functions.py::CastTests::test__cast__integer", + "pypika/tests/test_functions.py::CastTests::test__cast__long_varbinary", + "pypika/tests/test_functions.py::CastTests::test__cast__long_varbinary_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__long_varchar", + "pypika/tests/test_functions.py::CastTests::test__cast__long_varchar_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__numeric", + "pypika/tests/test_functions.py::CastTests::test__cast__signed", + "pypika/tests/test_functions.py::CastTests::test__cast__timestamp", + "pypika/tests/test_functions.py::CastTests::test__cast__unsigned", + "pypika/tests/test_functions.py::CastTests::test__cast__varbinary", + "pypika/tests/test_functions.py::CastTests::test__cast__varbinary_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__varchar", + "pypika/tests/test_functions.py::CastTests::test__cast__varchar_with_arg", + "pypika/tests/test_functions.py::CastTests::test__tochar__", + "pypika/tests/test_functions.py::DateFunctionsTests::test_current_date", + "pypika/tests/test_functions.py::DateFunctionsTests::test_current_time", + "pypika/tests/test_functions.py::DateFunctionsTests::test_current_timestamp", + "pypika/tests/test_functions.py::DateFunctionsTests::test_current_timestamp_with_alias", + "pypika/tests/test_functions.py::DateFunctionsTests::test_date_add", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_day", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_hour", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_join", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_microsecond", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_minute", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_month", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_quarter", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_second", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_week", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_year", + "pypika/tests/test_functions.py::DateFunctionsTests::test_now", + "pypika/tests/test_functions.py::DateFunctionsTests::test_time_diff", + "pypika/tests/test_functions.py::DateFunctionsTests::test_timestampadd", + "pypika/tests/test_functions.py::DateFunctionsTests::test_to_date", + "pypika/tests/test_functions.py::DateFunctionsTests::test_utc_timestamp", + "pypika/tests/test_functions.py::NullFunctionsTests::test_coalesce", + "pypika/tests/test_functions.py::NullFunctionsTests::test_isnull", + "pypika/tests/test_functions.py::NullFunctionsTests::test_nullif", + "pypika/tests/test_functions.py::NullFunctionsTests::test_nvl", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_mysql_one_groupby", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_mysql_rollup_two_groupbys", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_no_rollup_after_rollup_mysql", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_no_rollup_before_groupby", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_from_groupbys", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_from_parameters", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_from_two_groupbys", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_func_one_groupby", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_func_partial", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_func_two_groupbys", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_multiple_rollups", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_rollups_with_multiple_rollups_and_parity", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_rollups_with_parity", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_force_index_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_groupby_returns_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_immutable_kwarg_on_query_builder_disables_immutability", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_insert_into_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_join_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_orderby_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_queries_after_join", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_replace_into_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_select_returns_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_update_set_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_use_index_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_with_return_new_query_instance", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_multi_rows", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_multi_rows_chained", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_multi_rows_chained_mixed", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_multi_rows_chained_multiple_rows", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_single_element", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_column_using_alias_with_chain", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_column_using_table_alias", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_empty_columns", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_empty_columns_type_list", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_empty_columns_type_tuple", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_ignore", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_multiple_rows_with_array_value", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_none_skipped", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_null", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_one_column", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_one_column_multi_element_array", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_one_column_single_element_array", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_selected_columns", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_selected_columns_type_list", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_selected_columns_type_tuple", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_single_row_with_array_value", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_with_statement", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_empty_on_conflict_do_update_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_field", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_field_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_mixed_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_multiple_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_multiple_fields_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_field", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_field_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_multiple_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_multiple_fields_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_multiple_mixed_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_no_handler", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_two_handlers_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_two_handlers_do_update", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_fieldless_conflict_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_fieldless_conflict_do_update_field", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_non_insert_on_conflict_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_non_insert_on_conflict_do_update", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_do_nothing_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_do_update_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_do_update_with_excluded_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_from_subquery", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_complex", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_conflict_fields_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_conflict_fields_do_update", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_empty_conflict_fields_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_empty_conflict_fields_do_update", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_where_and_on_conflict_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_all_columns_multi_rows_chained_returning_star", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_all_columns_multi_rows_chained_returning_star_and_id", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_all_columns_multi_rows_chained_returning_star_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_all_columns_single_element_arrays", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_aggregate", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_all_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_all_fields_and_arithmetics", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_arithmetics", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_from_other_table", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_functions", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_null", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_one_field", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_one_field_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_tuple", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_ignore", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multi_rows_chained_mixed_on_duplicate_update_multiple", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_multiple", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_different_value", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_expression", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_expression_using_original_field_value", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_expression_using_values", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_same_value", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_none_skipped", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_one_column", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_one_column_multi_element_array", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_one_column_single_element_array", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_one_column_using_values", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_selected_columns_on_duplicate_update_multiple", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_selected_columns_on_duplicate_update_one", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_columns_from_columns", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_columns_from_columns_with_join", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_columns_from_star", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_from_columns", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_ignore_star", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_star", + "pypika/tests/test_inserts.py::InsertSubqueryTests::test_insert_subquery_wrapped_in_brackets", + "pypika/tests/test_inserts.py::SelectIntoTests::test_select_columns_into", + "pypika/tests/test_inserts.py::SelectIntoTests::test_select_columns_into_with_join", + "pypika/tests/test_inserts.py::SelectIntoTests::test_select_star_into", + "pypika/tests/test_inserts.py::ReplaceTests::test_replace_simple", + "pypika/tests/test_inserts.py::ReplaceTests::test_replace_subquery", + "pypika/tests/test_internals.py::TablesTests::test__case_tables", + "pypika/tests/test_internals.py::TablesTests::test__criterion_replace_table_with_value", + "pypika/tests/test_internals.py::TablesTests::test__star_tables", + "pypika/tests/test_internals.py::TablesTests::test__table_star_tables", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_cross_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_cross_join_on_subquery", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_cross_join_on_table", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_default_join_type", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_full_outer_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_hash_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_inner_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_arithmetic_field", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_collate", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_complex_criteria", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_field_multi", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_field_multi_with_extra_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_field_single", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_field_without_fields_raises_exception", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_subquery_criteria", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_second_table_in_from_clause", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_using_multiple_fields", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_using_string_field_name", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_using_with_quote_char", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_using_without_fields_raises_exception", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_with_arithmetic_function_in_select", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_left_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_left_outer_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_outer_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_right_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_right_outer_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_temporal_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_use_different_table_objects_for_same_table", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_fail_when_joining_unknown_type", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_ignore_table_references", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_immutable__tables", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_from_join", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_query_with_column_alias", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_query_with_setoperation", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_query_with_table_alias", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_query_without_alias", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_same_table", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_same_table_with_prefixes", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_table_twice", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_prefixes_added_to_function_in_orderby", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_prefixes_added_to_groupby", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_prefixes_added_to_orderby", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_require_condition", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_require_condition_with_both_tables", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select__fields_after_table_star", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select__ordered_select_clauses", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select__star_for_table", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select__star_for_table__replacement", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select_field_from_missing_table", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select_fields_with_where", + "pypika/tests/test_joins.py::UnionTests::test_mysql_query_wraps_unioned_queries", + "pypika/tests/test_joins.py::UnionTests::test_require_equal_number_of_fields", + "pypika/tests/test_joins.py::UnionTests::test_union", + "pypika/tests/test_joins.py::UnionTests::test_union_all", + "pypika/tests/test_joins.py::UnionTests::test_union_all_multiple", + "pypika/tests/test_joins.py::UnionTests::test_union_as_subquery", + "pypika/tests/test_joins.py::UnionTests::test_union_multiple", + "pypika/tests/test_joins.py::UnionTests::test_union_with_no_quote_char", + "pypika/tests/test_joins.py::UnionTests::test_union_with_order_by", + "pypika/tests/test_joins.py::UnionTests::test_union_with_order_by_use_union_query_field", + "pypika/tests/test_joins.py::UnionTests::test_union_with_order_by_use_union_query_field_with_aliases", + "pypika/tests/test_joins.py::UnionTests::test_union_with_order_by_with_aliases", + "pypika/tests/test_joins.py::InsertQueryJoinTests::test_join_table_on_insert_query", + "pypika/tests/test_joins.py::UpdateQueryJoinTests::test_join_table_on_update_query", + "pypika/tests/test_joins.py::IntersectTests::test_intersect", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_as_subquery", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_multiple", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_with_limit", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_with_no_quote_char", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_with_offset", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_with_order_by", + "pypika/tests/test_joins.py::IntersectTests::test_mysql_query_wraps_intersected_queries", + "pypika/tests/test_joins.py::IntersectTests::test_require_equal_number_of_fields_intersect", + "pypika/tests/test_joins.py::MinusTests::test_minus", + "pypika/tests/test_joins.py::MinusTests::test_minus_as_subquery", + "pypika/tests/test_joins.py::MinusTests::test_minus_multiple", + "pypika/tests/test_joins.py::MinusTests::test_minus_query_with_order_by_use_minus_query_field", + "pypika/tests/test_joins.py::MinusTests::test_minus_with_no_quote_char", + "pypika/tests/test_joins.py::MinusTests::test_minus_with_order_by", + "pypika/tests/test_joins.py::MinusTests::test_mysql_query_wraps_minus_queries", + "pypika/tests/test_joins.py::MinusTests::test_require_equal_number_of_fields", + "pypika/tests/test_joins.py::ExceptOfTests::test_except", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_as_subquery", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_multiple", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_query_with_order_by_use_minus_query_field", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_with_no_quote_char", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_with_order_by", + "pypika/tests/test_joins.py::ExceptOfTests::test_require_equal_number_of_fields_except_of", + "pypika/tests/test_negation.py::NegationTests::test_negate_field", + "pypika/tests/test_negation.py::NegationTests::test_negate_function", + "pypika/tests/test_negation.py::NegationTests::test_negate_wrapped_float", + "pypika/tests/test_negation.py::NegationTests::test_negate_wrapped_int", + "pypika/tests/test_parameter.py::ParametrizedTests::test_format_parameter", + "pypika/tests/test_parameter.py::ParametrizedTests::test_join", + "pypika/tests/test_parameter.py::ParametrizedTests::test_named_parameter", + "pypika/tests/test_parameter.py::ParametrizedTests::test_numeric_parameter", + "pypika/tests/test_parameter.py::ParametrizedTests::test_param_insert", + "pypika/tests/test_parameter.py::ParametrizedTests::test_param_select_join", + "pypika/tests/test_parameter.py::ParametrizedTests::test_param_select_subquery", + "pypika/tests/test_parameter.py::ParametrizedTests::test_pyformat_parameter", + "pypika/tests/test_parameter.py::ParametrizedTests::test_qmark_parameter", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_join", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_join_with_parameter_value_wrapper", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_param_insert", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_param_select_join", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_param_select_subquery", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_pyformat_parameter", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_can_be_used_in_a_select_statement", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_can_be_used_in_a_where_clause", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_can_be_used_in_orderby", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_column_value", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_object_id", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_object_value", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_row_id", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_row_num", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_sys_date", + "pypika/tests/test_query.py::QueryTablesTests::test_is_joined", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_case_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_delete_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_filter_tables", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_having_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_insert_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_insert_table_current_table_not_match", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_join_tables", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_only_specified_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_orderby_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_tuple_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_update_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_update_table_current_table_not_match", + "pypika/tests/test_query.py::QueryBuilderTests::test_pipe", + "pypika/tests/test_query.py::QueryBuilderTests::test_query_builders_have_reference_to_correct_query_class", + "pypika/tests/test_selects.py::SelectTests::test_empty_query", + "pypika/tests/test_selects.py::SelectTests::test_mssql_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_mysql_query_uses_backtick_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_oracle_query_uses_no_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_postgresql_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_redshift_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_select__column__single__alias__str", + "pypika/tests/test_selects.py::SelectTests::test_select__column__single__field", + "pypika/tests/test_selects.py::SelectTests::test_select__column__single__str", + "pypika/tests/test_selects.py::SelectTests::test_select__column__single__table_alias__str", + "pypika/tests/test_selects.py::SelectTests::test_select__columns__multi__field", + "pypika/tests/test_selects.py::SelectTests::test_select__columns__multi__str", + "pypika/tests/test_selects.py::SelectTests::test_select__distinct__multi", + "pypika/tests/test_selects.py::SelectTests::test_select__distinct__single", + "pypika/tests/test_selects.py::SelectTests::test_select__multiple_subqueries", + "pypika/tests/test_selects.py::SelectTests::test_select__multiple_tables", + "pypika/tests/test_selects.py::SelectTests::test_select__nested_subquery", + "pypika/tests/test_selects.py::SelectTests::test_select__no_table", + "pypika/tests/test_selects.py::SelectTests::test_select__star", + "pypika/tests/test_selects.py::SelectTests::test_select__star__replacement", + "pypika/tests/test_selects.py::SelectTests::test_select__subquery", + "pypika/tests/test_selects.py::SelectTests::test_select__table_schema", + "pypika/tests/test_selects.py::SelectTests::test_select__table_schema_with_multiple_levels_as_list", + "pypika/tests/test_selects.py::SelectTests::test_select__table_schema_with_multiple_levels_as_tuple", + "pypika/tests/test_selects.py::SelectTests::test_select_no_from", + "pypika/tests/test_selects.py::SelectTests::test_select_no_from_with_field_raises_exception", + "pypika/tests/test_selects.py::SelectTests::test_select_no_with_alias_from", + "pypika/tests/test_selects.py::SelectTests::test_select_then_add_table", + "pypika/tests/test_selects.py::SelectTests::test_select_with_force_index", + "pypika/tests/test_selects.py::SelectTests::test_select_with_force_index_multiple_calls", + "pypika/tests/test_selects.py::SelectTests::test_select_with_force_index_multiple_indexes", + "pypika/tests/test_selects.py::SelectTests::test_select_with_force_index_with_index_object", + "pypika/tests/test_selects.py::SelectTests::test_select_with_limit", + "pypika/tests/test_selects.py::SelectTests::test_select_with_limit__func", + "pypika/tests/test_selects.py::SelectTests::test_select_with_limit_and_offset", + "pypika/tests/test_selects.py::SelectTests::test_select_with_limit_zero", + "pypika/tests/test_selects.py::SelectTests::test_select_with_offset", + "pypika/tests/test_selects.py::SelectTests::test_select_with_offset__func", + "pypika/tests/test_selects.py::SelectTests::test_select_with_use_index", + "pypika/tests/test_selects.py::SelectTests::test_select_with_use_index_multiple_calls", + "pypika/tests/test_selects.py::SelectTests::test_select_with_use_index_multiple_indexes", + "pypika/tests/test_selects.py::SelectTests::test_select_with_use_index_with_index_object", + "pypika/tests/test_selects.py::SelectTests::test_table_select_alias", + "pypika/tests/test_selects.py::SelectTests::test_table_select_alias_with_offset_and_limit", + "pypika/tests/test_selects.py::SelectTests::test_temporal_select", + "pypika/tests/test_selects.py::SelectTests::test_vertica_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::WhereTests::test_ignore_empty_criterion_having", + "pypika/tests/test_selects.py::WhereTests::test_ignore_empty_criterion_where", + "pypika/tests/test_selects.py::WhereTests::test_select_with_force_index_and_where", + "pypika/tests/test_selects.py::WhereTests::test_where_enum", + "pypika/tests/test_selects.py::WhereTests::test_where_field_contains", + "pypika/tests/test_selects.py::WhereTests::test_where_field_does_not_contain", + "pypika/tests/test_selects.py::WhereTests::test_where_field_does_not_end_with", + "pypika/tests/test_selects.py::WhereTests::test_where_field_does_not_start_with", + "pypika/tests/test_selects.py::WhereTests::test_where_field_ends_with", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_and", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_nowait", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_of", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_of_multiple_tables", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_of_nowait", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_of_skip_locked", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_skip_locked", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_skip_locked_and_of", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_or", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_where", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_where_not", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_where_two_not", + "pypika/tests/test_selects.py::WhereTests::test_where_field_is_n_chars_long", + "pypika/tests/test_selects.py::WhereTests::test_where_field_is_not_n_chars_long", + "pypika/tests/test_selects.py::WhereTests::test_where_field_matches_regex", + "pypika/tests/test_selects.py::WhereTests::test_where_field_matches_regexp", + "pypika/tests/test_selects.py::WhereTests::test_where_field_matches_rlike", + "pypika/tests/test_selects.py::WhereTests::test_where_field_starts_with", + "pypika/tests/test_selects.py::WhereTests::test_where_nested_conditions", + "pypika/tests/test_selects.py::WhereTests::test_where_single_quote", + "pypika/tests/test_selects.py::WhereTests::test_where_with_multiple_wheres_using_and_case", + "pypika/tests/test_selects.py::WhereTests::test_where_with_multiple_wheres_using_or_case", + "pypika/tests/test_selects.py::PreWhereTests::test_ignore_empty_criterion_having", + "pypika/tests/test_selects.py::PreWhereTests::test_ignore_empty_criterion_where", + "pypika/tests/test_selects.py::PreWhereTests::test_prewhere_field_equals", + "pypika/tests/test_selects.py::PreWhereTests::test_select_with_force_index_and_where", + "pypika/tests/test_selects.py::PreWhereTests::test_where_and_prewhere", + "pypika/tests/test_selects.py::PreWhereTests::test_where_enum", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_contains", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_does_not_contain", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_does_not_end_with", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_does_not_start_with", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_ends_with", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_and", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_nowait", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_of", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_of_multiple_tables", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_of_nowait", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_of_skip_locked", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_skip_locked", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_skip_locked_and_of", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_or", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_where", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_where_not", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_where_two_not", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_is_n_chars_long", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_is_not_n_chars_long", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_matches_regex", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_matches_regexp", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_matches_rlike", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_starts_with", + "pypika/tests/test_selects.py::PreWhereTests::test_where_nested_conditions", + "pypika/tests/test_selects.py::PreWhereTests::test_where_single_quote", + "pypika/tests/test_selects.py::PreWhereTests::test_where_with_multiple_wheres_using_and_case", + "pypika/tests/test_selects.py::PreWhereTests::test_where_with_multiple_wheres_using_or_case", + "pypika/tests/test_selects.py::GroupByTests::test_group_by__single_with_totals", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__alias", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__alias_platforms", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__alias_with_join", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__count_distinct", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__count_field", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__count_star", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__int", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__multi", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__multi_with_totals", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__no_alias", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__no_alias_mssql", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__no_alias_oracle", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__single", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__str", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__sum_distinct", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__sum_filter", + "pypika/tests/test_selects.py::GroupByTests::test_groupby_with_case_uses_the_alias", + "pypika/tests/test_selects.py::GroupByTests::test_mssql_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_mysql_query_uses_backtick_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_oracle_query_uses_no_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_postgres_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_redshift_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_vertica_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_having_and", + "pypika/tests/test_selects.py::HavingTests::test_having_greater_than", + "pypika/tests/test_selects.py::HavingTests::test_having_join_and_equality", + "pypika/tests/test_selects.py::HavingTests::test_mssql_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_mysql_query_uses_backtick_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_oracle_query_uses_no_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_postgres_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_redshift_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_vertica_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_alias", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_asc", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_desc", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_multi_fields", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_no_alias", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_single_field", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_single_str", + "pypika/tests/test_selects.py::AliasTests::test_arithmetic_function", + "pypika/tests/test_selects.py::AliasTests::test_case_using_as", + "pypika/tests/test_selects.py::AliasTests::test_case_using_constructor_param", + "pypika/tests/test_selects.py::AliasTests::test_function_using_as_nested", + "pypika/tests/test_selects.py::AliasTests::test_functions_using_as", + "pypika/tests/test_selects.py::AliasTests::test_functions_using_constructor_param", + "pypika/tests/test_selects.py::AliasTests::test_functions_using_constructor_param_nested", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_criterion", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_criterion_comparison", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_field_inside_case", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_groupby", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_orderby", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_where", + "pypika/tests/test_selects.py::AliasTests::test_null_value_with_alias", + "pypika/tests/test_selects.py::AliasTests::test_select__multiple_tables", + "pypika/tests/test_selects.py::AliasTests::test_table_field", + "pypika/tests/test_selects.py::AliasTests::test_table_field__multi", + "pypika/tests/test_selects.py::AliasTests::test_table_with_schema_and_alias", + "pypika/tests/test_selects.py::AliasTests::test_use_aliases_in_groupby_and_orderby", + "pypika/tests/test_selects.py::SubqueryTests::test_from_subquery_without_alias", + "pypika/tests/test_selects.py::SubqueryTests::test_join", + "pypika/tests/test_selects.py::SubqueryTests::test_join_query_with_alias", + "pypika/tests/test_selects.py::SubqueryTests::test_join_with_with", + "pypika/tests/test_selects.py::SubqueryTests::test_select_from_nested_query", + "pypika/tests/test_selects.py::SubqueryTests::test_select_from_nested_query_with_join", + "pypika/tests/test_selects.py::SubqueryTests::test_select_from_with_returning", + "pypika/tests/test_selects.py::SubqueryTests::test_select_subquery", + "pypika/tests/test_selects.py::SubqueryTests::test_select_subquery_with_alias", + "pypika/tests/test_selects.py::SubqueryTests::test_where__equality", + "pypika/tests/test_selects.py::SubqueryTests::test_where__in", + "pypika/tests/test_selects.py::SubqueryTests::test_where__in_nested", + "pypika/tests/test_selects.py::SubqueryTests::test_with", + "pypika/tests/test_selects.py::QuoteTests::test_extraneous_quotes", + "pypika/tests/test_tables.py::TableStructureTests::test_database_schema_table_attr", + "pypika/tests/test_tables.py::TableStructureTests::test_schema_table_attr", + "pypika/tests/test_tables.py::TableStructureTests::test_table_for_period_sql", + "pypika/tests/test_tables.py::TableStructureTests::test_table_for_system_time_sql", + "pypika/tests/test_tables.py::TableStructureTests::test_table_sql", + "pypika/tests/test_tables.py::TableStructureTests::test_table_with_alias", + "pypika/tests/test_tables.py::TableStructureTests::test_table_with_schema_and_schema_parent_arg", + "pypika/tests/test_tables.py::TableStructureTests::test_table_with_schema_arg", + "pypika/tests/test_tables.py::TableEqualityTests::test_many_tables_with_alias", + "pypika/tests/test_tables.py::TableEqualityTests::test_many_tables_with_or_not_alias", + "pypika/tests/test_tables.py::TableEqualityTests::test_many_tables_without_alias", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_equal_by_name", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_equal_by_schema_and_name", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_equal_by_schema_and_name_using_schema", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_equal_by_schema_and_name_using_schema_with_parent", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_not_equal_by_schema_and_name_using_schema_with_different_parents", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_not_equal_with_different_names", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_not_equal_with_different_schemas", + "pypika/tests/test_tables.py::TableDialectTests::test_make_tables_factory_with_default_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_make_tables_factory_with_dialect_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_factory_with_default_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_factory_with_dialect_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_with_bad_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_with_default_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_with_dialect_query_cls", + "pypika/tests/test_terms.py::FieldAliasTests::test_when_alias_specified", + "pypika/tests/test_terms.py::FieldInitTests::test_init_with_str_table", + "pypika/tests/test_terms.py::FieldHashingTests::test_non_tabled_aliased_eq_fields_equally_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_non_tabled_aliased_ne_fields_differently_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_non_tabled_eq_fields_equally_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_non_tabled_ne_fields_differently_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_tabled_eq_fields_equally_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_tabled_ne_fields_differently_hashed", + "pypika/tests/test_terms.py::AtTimezoneTests::test_passes_kwargs_to_field_get_sql", + "pypika/tests/test_terms.py::AtTimezoneTests::test_when_alias_specified", + "pypika/tests/test_terms.py::AtTimezoneTests::test_when_interval_not_specified", + "pypika/tests/test_terms.py::AtTimezoneTests::test_when_interval_specified", + "pypika/tests/test_tuples.py::TupleTests::test_render_alias_in_array_sql", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_equality_tuple_on_both", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_equality_tuple_on_left", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_equality_tuple_on_right", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_in_using_mixed_tuples", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_in_using_pypika_tuples", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_in_using_python_tuples", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_is_aggregate", + "pypika/tests/test_tuples.py::TupleTests::test_tuples_in_join", + "pypika/tests/test_tuples.py::ArrayTests::test_array_general", + "pypika/tests/test_tuples.py::ArrayTests::test_empty_psql_array", + "pypika/tests/test_tuples.py::ArrayTests::test_psql_array_general", + "pypika/tests/test_tuples.py::ArrayTests::test_render_alias_in_array_sql", + "pypika/tests/test_tuples.py::BracketTests::test_arithmetic_with_brackets", + "pypika/tests/test_tuples.py::BracketTests::test_arithmetic_with_brackets_and_alias", + "pypika/tests/test_updates.py::UpdateTests::test_empty_query", + "pypika/tests/test_updates.py::UpdateTests::test_for_portion", + "pypika/tests/test_updates.py::UpdateTests::test_omit_where", + "pypika/tests/test_updates.py::UpdateTests::test_single_quote_escape_in_set", + "pypika/tests/test_updates.py::UpdateTests::test_update__table_schema", + "pypika/tests/test_updates.py::UpdateTests::test_update_from", + "pypika/tests/test_updates.py::UpdateTests::test_update_from_with_where", + "pypika/tests/test_updates.py::UpdateTests::test_update_with_join", + "pypika/tests/test_updates.py::UpdateTests::test_update_with_limit", + "pypika/tests/test_updates.py::UpdateTests::test_update_with_none", + "pypika/tests/test_updates.py::UpdateTests::test_update_with_statement", + "pypika/tests/test_updates.py::PostgresUpdateTests::test_update_returning", + "pypika/tests/test_updates.py::PostgresUpdateTests::test_update_returning_from_different_tables", + "pypika/tests/test_updates.py::PostgresUpdateTests::test_update_returning_star", + "pypika/tests/test_updates.py::PostgresUpdateTests::test_update_returning_str", + "pypika/tests/test_updates.py::SQLLiteUpdateTests::test_update_with_bool", + "pypika/tests/test_utils.py::ImmutabilityTests::test_raise_attribute_error_for_deepcopy", + "pypika/tests/test_utils.py::ImmutabilityTests::test_raise_attribute_error_for_getnewargs", + "pypika/tests/test_utils.py::ImmutabilityTests::test_raise_attribute_error_for_getstate", + "pypika/tests/test_utils.py::ImmutabilityTests::test_raise_attribute_error_for_setstate" + ], + "all_git_blobs_modes_verified": true, + "cloud_launch_ready": false, + "commits": { + "bug": "589c4fe73ad443f0567da3690247b84179f963af", + "healthy": "6a742f12bfa386994289ec8b75824663d8ee4b15", + "learner": "f0ce68b7ae9252cfd00a125242c3ebcf8e161015" + }, + "existing_squirrel_snapshot_reused": false, + "full_transfer_allowlist": [ + "/testbed/.coveragerc", + "/testbed/.gitignore", + "/testbed/.pre-commit-config.yaml", + "/testbed/CODEOWNERS", + "/testbed/CONTRIBUTING.rst", + "/testbed/LICENSE.txt", + "/testbed/MANIFEST.in", + "/testbed/Makefile", + "/testbed/README.rst", + "/testbed/docs/1_installation.rst", + "/testbed/docs/2_tutorial.rst", + "/testbed/docs/3_advanced.rst", + "/testbed/docs/4_extending.rst", + "/testbed/docs/5_reference.rst", + "/testbed/docs/6_contributing.rst", + "/testbed/docs/Makefile", + "/testbed/docs/api/pypika.analytics.rst", + "/testbed/docs/api/pypika.dialects.rst", + "/testbed/docs/api/pypika.enums.rst", + "/testbed/docs/api/pypika.functions.rst", + "/testbed/docs/api/pypika.pseudocolumns.rst", + "/testbed/docs/api/pypika.queries.rst", + "/testbed/docs/api/pypika.rst", + "/testbed/docs/api/pypika.terms.rst", + "/testbed/docs/api/pypika.utils.rst", + "/testbed/docs/conf.py", + "/testbed/docs/index.rst", + "/testbed/pypika/__init__.py", + "/testbed/pypika/analytics.py", + "/testbed/pypika/clickhouse/__init__.py", + "/testbed/pypika/clickhouse/array.py", + "/testbed/pypika/clickhouse/condition.py", + "/testbed/pypika/clickhouse/dates_and_times.py", + "/testbed/pypika/clickhouse/nullable_arg.py", + "/testbed/pypika/clickhouse/search_string.py", + "/testbed/pypika/clickhouse/type_conversion.py", + "/testbed/pypika/dialects.py", + "/testbed/pypika/enums.py", + "/testbed/pypika/functions.py", + "/testbed/pypika/pseudocolumns.py", + "/testbed/pypika/py.typed", + "/testbed/pypika/queries.py", + "/testbed/pypika/terms.py", + "/testbed/pypika/tests/__init__.py", + "/testbed/pypika/tests/clickhouse/__init__.py", + "/testbed/pypika/tests/clickhouse/test_condition.py", + "/testbed/pypika/tests/clickhouse/test_dates_and_times.py", + "/testbed/pypika/tests/clickhouse/test_nullable_arg.py", + "/testbed/pypika/tests/clickhouse/test_type_conversion.py", + "/testbed/pypika/tests/dialects/__init__.py", + "/testbed/pypika/tests/dialects/test_clickhouse.py", + "/testbed/pypika/tests/dialects/test_mssql.py", + "/testbed/pypika/tests/dialects/test_mysql.py", + "/testbed/pypika/tests/dialects/test_oracle.py", + "/testbed/pypika/tests/dialects/test_postgresql.py", + "/testbed/pypika/tests/dialects/test_snowflake.py", + "/testbed/pypika/tests/dialects/test_sqllite.py", + "/testbed/pypika/tests/dialects/test_vertica.py", + "/testbed/pypika/tests/test_aggregate.py", + "/testbed/pypika/tests/test_analytic_queries.py", + "/testbed/pypika/tests/test_create.py", + "/testbed/pypika/tests/test_criterions.py", + "/testbed/pypika/tests/test_custom_functions.py", + "/testbed/pypika/tests/test_data_types.py", + "/testbed/pypika/tests/test_date_math.py", + "/testbed/pypika/tests/test_deletes.py", + "/testbed/pypika/tests/test_drop.py", + "/testbed/pypika/tests/test_formats.py", + "/testbed/pypika/tests/test_functions.py", + "/testbed/pypika/tests/test_groupby_modifiers.py", + "/testbed/pypika/tests/test_immutability.py", + "/testbed/pypika/tests/test_inserts.py", + "/testbed/pypika/tests/test_internals.py", + "/testbed/pypika/tests/test_joins.py", + "/testbed/pypika/tests/test_negation.py", + "/testbed/pypika/tests/test_parameter.py", + "/testbed/pypika/tests/test_pseudocolumns.py", + "/testbed/pypika/tests/test_query.py", + "/testbed/pypika/tests/test_selects.py", + "/testbed/pypika/tests/test_tables.py", + "/testbed/pypika/tests/test_terms.py", + "/testbed/pypika/tests/test_tuples.py", + "/testbed/pypika/tests/test_updates.py", + "/testbed/pypika/tests/test_utils.py", + "/testbed/pypika/utils.py", + "/testbed/pyproject.toml", + "/testbed/requirements-dev.txt", + "/testbed/setup.cfg", + "/testbed/setup.py", + "/testbed/tox.ini" + ], + "healthy_stage_meaning": "Direct parent of the mutation; no source or test execution has been performed", + "mutation_matches_dataset_and_git_blobs": true, + "official_profile": { + "eval_sets": [], + "profile_class": "Pypika1c9646f0", + "profile_lines": [ + 736, + 739 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "upstream_repo": "kayak/pypika" + }, + "original_source_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "private_test_paths": [ + "pypika/tests/clickhouse/test_array.py", + "pypika/tests/clickhouse/test_search_string.py" + ], + "private_tests_unchanged": true, + "profile_mapping_basis": "Explicit upstream repo and full commit fields parsed from pinned official Python profile AST, not basename inference", + "qwen_calibrated": false, + "runtime_qualified": false, + "source_paths": [ + "pypika/clickhouse/array.py", + "pypika/clickhouse/search_string.py" + ], + "source_repo": "swesmith/kayak__pypika.1c9646f0", + "source_stages_bytes": 1892885, + "task_id": "kayak__pypika.1c9646f0.combine_module__q1pjmphb", + "transfer_limitation": "Existing regular files only; new arbitrary file additions need a qualified patch adapter", + "upstream_repo": "kayak/pypika" + }, + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:kayak__pypika.1c9646f0.combine_module__q1pjmphb", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "6a742f12bfa386994289ec8b75824663d8ee4b15", + "instruction_sha256": "ee63b6bb66013a67214ea245b5ec31e4b1cc36daca7d658ac92209eaf637f210", + "is_fork": true, + "learner_path": "tasks/6986f4145368fdf626c9f968/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "actual_upstream_url": "https://raw.githubusercontent.com/kayak/pypika/1c9646f0a019a167c32b649b6f5e6423c5ba2c9b/LICENSE.txt", + "reviewed": true, + "sha256": "c5accbbd8546e94c34aed24afe689a617627d18eed5a6c48277e48db57c23851", + "spdx": "Apache-2.0", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/kayak__pypika.1c9646f0/f0ce68b7ae9252cfd00a125242c3ebcf8e161015/LICENSE.txt" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "patch_sha256": "03d8b4ef1919fec5d72e196826368c6d0c09d89b91fb89e1f0d7aeddb928a075", + "provenance_path": "tasks/6986f4145368fdf626c9f968/source-proof.json", + "repository_lineage": [ + "swesmith/kayak__pypika.1c9646f0", + "kayak/pypika" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "f0ce68b7ae9252cfd00a125242c3ebcf8e161015", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "589c4fe73ad443f0567da3690247b84179f963af", + "source_kind": "mutation", + "source_repo": "swesmith/kayak__pypika.1c9646f0", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "kayak__pypika.1c9646f0.combine_module__q1pjmphb", + "task_sha256": "b6f07f3bbc04770758db063eeb7f2cb7840b5d28bc4a7ec1ea4573984d234891", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "kayak/pypika", + "usage": "quarantine_only" + }, + "task_kind": "original-source-mutation" +} diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/provenance.json b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/provenance.json new file mode 100644 index 0000000000000000000000000000000000000000..8a2088c4001e5794429b0e1c2493648e90bf1530 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/provenance.json @@ -0,0 +1,88 @@ +{ + "generated_reference": false, + "healthy_reference_delta_sha256": "351152071f7288bf17963dfc40b5f2362498944ed68fe06029b12b9bef6e1090", + "native_pytest_ids_preserved": true, + "original_source_code_license": { + "actual_upstream_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "actual_upstream_url": "https://raw.githubusercontent.com/kayak/pypika/1c9646f0a019a167c32b649b6f5e6423c5ba2c9b/LICENSE.txt", + "reviewed": true, + "sha256": "c5accbbd8546e94c34aed24afe689a617627d18eed5a6c48277e48db57c23851", + "spdx": "Apache-2.0", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/kayak__pypika.1c9646f0/f0ce68b7ae9252cfd00a125242c3ebcf8e161015/LICENSE.txt" + }, + "provided_reference": true, + "qwen_calibrated": false, + "runtime_qualified": false, + "source_completion_sha256": "aeafc48de8ba3717d6261c73dfe627c06204035ba14f1980ccba45df25358efa", + "source_index_sha256": "e856874b9410fce9f3bfea52c8c482e84b3e43942d87517f8b55f0034bd40f6f", + "source_proof_sha256": "75de8860c1990bdfb2f4e1a3d8e40a5674e3ca95fced8d049e45e51dab354a29", + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:kayak__pypika.1c9646f0.combine_module__q1pjmphb", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "6a742f12bfa386994289ec8b75824663d8ee4b15", + "instruction_sha256": "ee63b6bb66013a67214ea245b5ec31e4b1cc36daca7d658ac92209eaf637f210", + "is_fork": true, + "learner_path": "tasks/6986f4145368fdf626c9f968/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "actual_upstream_url": "https://raw.githubusercontent.com/kayak/pypika/1c9646f0a019a167c32b649b6f5e6423c5ba2c9b/LICENSE.txt", + "reviewed": true, + "sha256": "c5accbbd8546e94c34aed24afe689a617627d18eed5a6c48277e48db57c23851", + "spdx": "Apache-2.0", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/kayak__pypika.1c9646f0/f0ce68b7ae9252cfd00a125242c3ebcf8e161015/LICENSE.txt" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "patch_sha256": "03d8b4ef1919fec5d72e196826368c6d0c09d89b91fb89e1f0d7aeddb928a075", + "provenance_path": "tasks/6986f4145368fdf626c9f968/source-proof.json", + "repository_lineage": [ + "swesmith/kayak__pypika.1c9646f0", + "kayak/pypika" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "f0ce68b7ae9252cfd00a125242c3ebcf8e161015", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "589c4fe73ad443f0567da3690247b84179f963af", + "source_kind": "mutation", + "source_repo": "swesmith/kayak__pypika.1c9646f0", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "kayak__pypika.1c9646f0.combine_module__q1pjmphb", + "task_sha256": "b6f07f3bbc04770758db063eeb7f2cb7840b5d28bc4a7ec1ea4573984d234891", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "kayak/pypika", + "usage": "quarantine_only" + }, + "task_bundle_license": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + }, + "training_admissible": false, + "trusted_tests_sha256": "f2d0a1b335176a755d627907f32ef330383cf624ff3af2c5ea84ba2b6a2d7ebb" +} diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/provided-gold.diff b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/provided-gold.diff new file mode 100644 index 0000000000000000000000000000000000000000..877cdb9f02f03bd0ebd89c395848b28a04266e3c --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/provided-gold.diff @@ -0,0 +1,75 @@ +diff --git a/pypika/clickhouse/array.py b/pypika/clickhouse/array.py +index 8e8b68ccb1f0fd735b269b9c9e8fc4fef7dd5da8..67929f1664e8a3d63d5b1a83cdf66ae590c53ce4 100644 +--- a/pypika/clickhouse/array.py ++++ b/pypika/clickhouse/array.py +@@ -16,17 +16,17 @@ + self._converter_options = converter_options or dict() + + def get_sql(self): +- if not self._converter_cls: ++ if self._converter_cls: + converted = [] + for value in self._values: + converter = self._converter_cls(value, **self._converter_options) +- converted.append(str(value)) +- sql = "".join(["(", ",".join(converted), ")"]) ++ converted.append(converter.get_sql()) ++ sql = "".join(["[", ",".join(converted), "]"]) + + else: +- sql = repr(self._values) ++ sql = str(self._values) + +- return format_alias_sql(sql, self.alias[::-1]) ++ return format_alias_sql(sql, self.alias) + + + class HasAny(Function): +@@ -64,11 +64,11 @@ + + def get_sql(self, with_namespace=False, quote_char=None, dialect=None, **kwargs): + array = self._array.get_sql() +- sql = "{array}({name})".format( +- name='"%s"' % array if isinstance(self._array, Field) else array, +- array=self.name, ++ sql = "{name}({array})".format( ++ name=self.name, ++ array='"%s"' % array if isinstance(self._array, Field) else array, + ) +- return format_alias_sql(sql, self.alias[::-1], **kwargs) ++ return format_alias_sql(sql, self.alias, **kwargs) + + @classmethod + @abc.abstractmethod +diff --git a/pypika/clickhouse/search_string.py b/pypika/clickhouse/search_string.py +index 9185cfdb1e43801d568abe97edbdb6a483d61c3d..22a03027fcaf3ca0578e63980c00f4be1b2f67e7 100644 +--- a/pypika/clickhouse/search_string.py ++++ b/pypika/clickhouse/search_string.py +@@ -61,19 +61,20 @@ + pass + + def get_sql(self, with_alias=False, with_namespace=False, quote_char=None, dialect=None, **kwargs): +- return format_alias_sql(sql, self.alias, **kwargs) ++ args = [] ++ for p in self.args: ++ if hasattr(p, "get_sql"): ++ args.append('toString("{arg}")'.format(arg=p.get_sql(with_alias=False, **kwargs))) ++ else: ++ args.append(str(p)) + + sql = "{name}({args},[{patterns}])".format( + name=self.name, + args=",".join(args), + patterns=",".join(["'%s'" % i for i in self._patterns]), + ) +- args = [] +- for p in self.args: +- if hasattr(p, "get_sql"): +- args.append('toString("{arg}")'.format(arg=p.get_sql(with_alias=False, **kwargs))) +- else: +- args.append(str(p)) ++ return format_alias_sql(sql, self.alias, **kwargs) ++ + + class MultiSearchAny(_AbstractMultiSearchString): + @classmethod diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/solution/solve.sh b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..0040480545e3cdacf4271195056872c679bbc84f --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/solution/solve.sh @@ -0,0 +1,81 @@ +#!/bin/bash +set -Eeuo pipefail +cd /testbed/repo +cat > /tmp/openenv-reference.diff <<'OPENENV_REFERENCE' +diff --git a/pypika/clickhouse/array.py b/pypika/clickhouse/array.py +index 8e8b68ccb1f0fd735b269b9c9e8fc4fef7dd5da8..67929f1664e8a3d63d5b1a83cdf66ae590c53ce4 100644 +--- a/pypika/clickhouse/array.py ++++ b/pypika/clickhouse/array.py +@@ -16,17 +16,17 @@ + self._converter_options = converter_options or dict() + + def get_sql(self): +- if not self._converter_cls: ++ if self._converter_cls: + converted = [] + for value in self._values: + converter = self._converter_cls(value, **self._converter_options) +- converted.append(str(value)) +- sql = "".join(["(", ",".join(converted), ")"]) ++ converted.append(converter.get_sql()) ++ sql = "".join(["[", ",".join(converted), "]"]) + + else: +- sql = repr(self._values) ++ sql = str(self._values) + +- return format_alias_sql(sql, self.alias[::-1]) ++ return format_alias_sql(sql, self.alias) + + + class HasAny(Function): +@@ -64,11 +64,11 @@ + + def get_sql(self, with_namespace=False, quote_char=None, dialect=None, **kwargs): + array = self._array.get_sql() +- sql = "{array}({name})".format( +- name='"%s"' % array if isinstance(self._array, Field) else array, +- array=self.name, ++ sql = "{name}({array})".format( ++ name=self.name, ++ array='"%s"' % array if isinstance(self._array, Field) else array, + ) +- return format_alias_sql(sql, self.alias[::-1], **kwargs) ++ return format_alias_sql(sql, self.alias, **kwargs) + + @classmethod + @abc.abstractmethod +diff --git a/pypika/clickhouse/search_string.py b/pypika/clickhouse/search_string.py +index 9185cfdb1e43801d568abe97edbdb6a483d61c3d..22a03027fcaf3ca0578e63980c00f4be1b2f67e7 100644 +--- a/pypika/clickhouse/search_string.py ++++ b/pypika/clickhouse/search_string.py +@@ -61,19 +61,20 @@ + pass + + def get_sql(self, with_alias=False, with_namespace=False, quote_char=None, dialect=None, **kwargs): +- return format_alias_sql(sql, self.alias, **kwargs) ++ args = [] ++ for p in self.args: ++ if hasattr(p, "get_sql"): ++ args.append('toString("{arg}")'.format(arg=p.get_sql(with_alias=False, **kwargs))) ++ else: ++ args.append(str(p)) + + sql = "{name}({args},[{patterns}])".format( + name=self.name, + args=",".join(args), + patterns=",".join(["'%s'" % i for i in self._patterns]), + ) +- args = [] +- for p in self.args: +- if hasattr(p, "get_sql"): +- args.append('toString("{arg}")'.format(arg=p.get_sql(with_alias=False, **kwargs))) +- else: +- args.append(str(p)) ++ return format_alias_sql(sql, self.alias, **kwargs) ++ + + class MultiSearchAny(_AbstractMultiSearchString): + @classmethod +OPENENV_REFERENCE +/usr/bin/git -c core.hooksPath=/dev/null -c core.fsmonitor=false apply --whitespace=nowarn /tmp/openenv-reference.diff diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/task.toml b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..34d4ea97cb3173b374f41855d6cad2da97529b28 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/task.toml @@ -0,0 +1,24 @@ +version = "1.0" + +[agent] +timeout_sec = 1800.0 + +[verifier] +timeout_sec = 900.0 + +[environment] +docker_image = "ghcr.io/younesbelkada/scale800@sha256:8a27adb57bd52cc4e87255196e8e6bc5b1d7216d3eed6633ff55bdec0acad206" +build_timeout_sec = 600.0 +cpus = 2 +memory_mb = 8192 +storage_mb = 16384 + +[metadata] +author_name = "SWE-smith source adapter" +category = "bugfix" +tags = ["swe", "python", "mutation-repair"] + +[environment.env] +# The image's PATH with the testbed env first: the project and pytest are installed there, and the agent's +# non-interactive shells never run `conda activate` +PATH = "/opt/miniconda3/envs/testbed/bin:/opt/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/check_pytest.py b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/check_pytest.py new file mode 100644 index 0000000000000000000000000000000000000000..7abfdc5972f57ca7f0cecbbeeb373414670f780e --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/check_pytest.py @@ -0,0 +1,177 @@ +"""Preserve confirmed requested assertion failures; keep positive checks strict.""" + +import argparse +import hashlib +import json +import re +import xml.etree.ElementTree as ET +from pathlib import Path + +GROUPS = ("pass-to-pass", "fail-to-pass") + + +def split_nodeid(target): + prefix, bracket, parameter = target.partition("[") + parts = prefix.split("::") + if bracket: + parts[-1] += bracket + parameter + return parts + + +def matches(case, target): + parts = split_nodeid(target) + module = parts[0].removesuffix(".py").replace("/", ".") + classname, name = case.get("classname", ""), case.get("name", "") + if not (classname == module or classname.startswith(module + ".")): + return False + selector = parts[-1] if len(parts) > 1 else "" + classes = parts[1:-1] + if classes and classname != module + "." + ".".join(classes): + return False + return ( + not selector + or name == selector + or ("[" not in selector and name.startswith(selector + "[")) + ) + + +def capture_panels(root): + panels, digests = {}, {} + for group in GROUPS: + path = Path(root) / (group + ".xml") + if not path.exists(): + panels[group] = None + continue + with path.open("rb") as stream: + raw = stream.read(4 * 1024**2 + 1) + if not 0 < len(raw) <= 4 * 1024**2 or re.search( + rb" 20000: + raise ValueError("Too many pytest cases") + identities = [(case.get("classname"), case.get("name")) for case in cases] + if len(identities) != len(set(identities)): + raise ValueError("Duplicate pytest case evidence") + panels[group] = cases + digests[group] = hashlib.sha256(raw).hexdigest() + return panels, digests + + +def strict_assess(panels, expected, native_exit): + """The original positive-approval conditions, applied to captured cases.""" + all_cases, actual_failure = [], False + for group in GROUPS: + cases = panels[group] + if cases is None: + if actual_failure: + continue + raise ValueError("Missing preceding pytest panel") + if actual_failure: + raise ValueError( + "Pytest evidence continued after the native stop-on-failure" + ) + targets = expected[group] + if any(not any(matches(case, target) for target in targets) for case in cases): + raise ValueError("Unexpected pytest case") + all_cases.extend(cases) + failures = [case for case in cases if case.find("failure") is not None] + if any( + case.find("error") is not None or case.find("skipped") is not None + for case in cases + ): + raise ValueError("Pytest collection/error/skip is not a completed panel") + actual_failure = actual_failure or bool(failures) + if not failures and any( + not any(matches(case, target) for case in cases) for target in targets + ): + raise ValueError("Declared pytest target never ran") + if actual_failure: + if native_exit == 0: + raise ValueError("Native verifier exit disagrees with pytest failure") + return {"reward": 0, "valid_test_failure": True, "cases": len(all_cases)} + if native_exit != 0: + raise ValueError("Setup or native verifier failed without a real test failure") + if any(panels[group] is None for group in GROUPS): + raise ValueError("Missing completed pytest panel") + return {"reward": 1, "valid_test_failure": False, "cases": len(all_cases)} + + +def assess(root, expected, native_exit): + if type(native_exit) is not int: + raise ValueError("Native verifier exit must be an integer") + if not isinstance(expected, dict) or any( + not isinstance(expected.get(group), list) + or not expected[group] + or any(not isinstance(target, str) or not target for target in expected[group]) + for group in GROUPS + ): + raise ValueError("Complete exact native pytest targets required") + panels, digests = capture_panels(root) + counts = { + "cases": 0, + "matched_failures": 0, + "unexpected_cases": 0, + "unmatched_failures": 0, + "skipped_cases": 0, + "error_cases": 0, + "missing_panels": 0, + "missing_targets": 0, + } + for group in GROUPS: + cases = panels[group] + if cases is None: + counts["missing_panels"] += 1 + counts["missing_targets"] += len(expected[group]) + continue + counts["cases"] += len(cases) + for case in cases: + requested = any(matches(case, target) for target in expected[group]) + failure = case.find("failure") is not None + counts["matched_failures"] += int(requested and failure) + counts["unmatched_failures"] += int(not requested and failure) + counts["unexpected_cases"] += int(not requested) + counts["skipped_cases"] += int(case.find("skipped") is not None) + counts["error_cases"] += int(case.find("error") is not None) + counts["missing_targets"] += sum( + not any(matches(case, target) for case in cases) + for target in expected[group] + ) + if counts["matched_failures"]: + if native_exit == 0: + raise ValueError( + "Native verifier exit disagrees with requested pytest failure" + ) + return { + "reward": 0, + "valid_test_failure": True, + "cases": counts["cases"], + "diagnostic_counts": counts, + "panel_sha256": digests, + "decision": "confirmed_requested_failure_precedence", + } + result = strict_assess(panels, expected, native_exit) + result.update(diagnostic_counts=counts, panel_sha256=digests) + return result + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("--root", required=True) + parser.add_argument("--expected", required=True) + parser.add_argument("--native-exit", type=int, required=True) + args = parser.parse_args() + result = assess( + args.root, json.loads(Path(args.expected).read_bytes()), args.native_exit + ) + reward = Path(args.root) / "reward.txt" + if reward.read_text().strip() != str(result["reward"]): + raise ValueError("Native raw reward disagrees with pytest evidence") + (Path(args.root) / "pytest-evidence.json").write_text( + json.dumps(result, sort_keys=True) + "\n" + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/expected-panels.json b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/expected-panels.json new file mode 100644 index 0000000000000000000000000000000000000000..81cdc562ad793a252ea4f4a59a606959229418fc --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/expected-panels.json @@ -0,0 +1,1067 @@ +{ + "fail-to-pass": [ + "pypika/tests/clickhouse/test_array.py::TestArray::test_get_sql_0__ridley_scott_jimi_hendrix_", + "pypika/tests/clickhouse/test_array.py::TestArray::test_get_sql_1__1_2_3_4_", + "pypika/tests/clickhouse/test_array.py::TestArray::test_get_sql_2__toInt64_1_toInt64_2_toInt64_3_toInt64_4_", + "pypika/tests/clickhouse/test_array.py::TestArray::test_get_sql_3__toFixedString_mogwai_10_toFixedString_mono_10_toFixedString_bonobo_10_arr", + "pypika/tests/clickhouse/test_array.py::TestHasAny::test_get_sql_1_hasAny_1_2_3_4_3_", + "pypika/tests/clickhouse/test_array.py::TestHasAny::test_get_sql_2_hasAny_bands_toFixedString_port_royal_20_toFixedString_hammock_20_", + "pypika/tests/clickhouse/test_array.py::TestLength::test_get_sql_0_length_tags_", + "pypika/tests/clickhouse/test_array.py::TestLength::test_get_sql_1_length_1_2_3_", + "pypika/tests/clickhouse/test_array.py::TestEmpty::test_get_sql_0_empty_tags_", + "pypika/tests/clickhouse/test_array.py::TestEmpty::test_get_sql_1_empty_1_2_3_", + "pypika/tests/clickhouse/test_array.py::TestNotEmpty::test_get_sql_0_notEmpty_tags_", + "pypika/tests/clickhouse/test_array.py::TestNotEmpty::test_get_sql_1_notEmpty_1_2_3_", + "pypika/tests/clickhouse/test_search_string.py::TestMultiSearch::test_multi_search_string_0", + "pypika/tests/clickhouse/test_search_string.py::TestMultiSearch::test_multi_search_string_1" + ], + "pass-to-pass": [ + "pypika/tests/clickhouse/test_array.py::TestHasAny::test_get_sql_0_hasAny_mental_abilities_physical_abilities_", + "pypika/tests/clickhouse/test_condition.py::TestIfCondition::test_get_sql_0", + "pypika/tests/clickhouse/test_condition.py::TestIfCondition::test_get_sql_1", + "pypika/tests/clickhouse/test_condition.py::TestMultiIfCondition::test_get_sql_0", + "pypika/tests/clickhouse/test_condition.py::TestMultiIfCondition::test_get_sql_1", + "pypika/tests/clickhouse/test_dates_and_times.py::TestFormatDateTime::test_get_sql_0", + "pypika/tests/clickhouse/test_dates_and_times.py::TestFormatDateTime::test_get_sql_1", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_00", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_01", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_02", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_03", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_04", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_05", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_06", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_07", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_08", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_09", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_10", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_11", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_12", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_13", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_14", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_15", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_16", + "pypika/tests/clickhouse/test_dates_and_times.py::TestToYYYYMM::test_get_sql", + "pypika/tests/clickhouse/test_nullable_arg.py::TestSearchString::test_get_sql_0", + "pypika/tests/clickhouse/test_nullable_arg.py::TestSearchString::test_get_sql_1", + "pypika/tests/clickhouse/test_search_string.py::TestSearchString::test_search_string_0", + "pypika/tests/clickhouse/test_search_string.py::TestSearchString::test_search_string_1", + "pypika/tests/clickhouse/test_search_string.py::TestSearchString::test_search_string_2", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_00_toString_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_01_toInt8_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_02_toInt16_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_03_toInt32_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_04_toInt64_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_05_toUInt8_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_06_toUInt16_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_07_toUInt32_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_08_toUInt64_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_09_toFloat32_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_10_toFloat64_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_11_toFloat64_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_12_toDate_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_13_toDateTime_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_14_toFixedString_field_name_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_00_toString_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_01_toInt8_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_02_toInt16_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_03_toInt32_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_04_toInt64_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_05_toUInt8_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_06_toUInt16_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_07_toUInt32_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_08_toUInt64_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_09_toFloat32_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_10_toFloat64_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_11_toFloat64_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_12_toDate_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_13_toDateTime_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_14_toFixedString_100_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestToFixedString::test_get_sql_with_table", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseQueryTests::test_use_AS_keyword_for_alias", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseQueryTests::test_use_FINAL_keyword", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseQueryTests::test_use_SAMPLE_keyword", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseQueryTests::test_use_SAMPLE_with_offset_keyword", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDeleteTests::test_omit_where", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDeleteTests::test_omit_where__table_schema", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDeleteTests::test_where_field_equals", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseUpdateTests::test_update", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDropQuery::test_drop_database", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDropQuery::test_drop_dictionary", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDropQuery::test_drop_other", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDropQuery::test_drop_table", + "pypika/tests/dialects/test_clickhouse.py::DistinctOnTests::test_distinct_on", + "pypika/tests/dialects/test_clickhouse.py::LimitByTests::test_limit_by", + "pypika/tests/dialects/test_clickhouse.py::LimitByTests::test_limit_offset0_by", + "pypika/tests/dialects/test_clickhouse.py::LimitByTests::test_limit_offset_by", + "pypika/tests/dialects/test_clickhouse.py::LimitByTests::test_rename_table", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_distinct_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_groupby_alias_False_does_not_group_by_alias_when_subqueries_are_present", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_groupby_alias_False_does_not_group_by_alias_with_standard_query", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_limit", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_limit_with_offset", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_normal_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_offset", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_distinct_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_percent_invalid_range", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_percent_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_select_non_int", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_with_ties_select", + "pypika/tests/dialects/test_mysql.py::SelectTests::test_distinct_select", + "pypika/tests/dialects/test_mysql.py::SelectTests::test_modifier_select", + "pypika/tests/dialects/test_mysql.py::SelectTests::test_multiple_modifier_select", + "pypika/tests/dialects/test_mysql.py::SelectTests::test_normal_select", + "pypika/tests/dialects/test_mysql.py::UpdateTests::test_conflict_handlers_update", + "pypika/tests/dialects/test_mysql.py::UpdateTests::test_on_duplicate_key_ignore_update", + "pypika/tests/dialects/test_mysql.py::UpdateTests::test_on_duplicate_key_update_update", + "pypika/tests/dialects/test_mysql.py::UpdateTests::test_update", + "pypika/tests/dialects/test_mysql.py::LoadCSVTests::test_load_from_file", + "pypika/tests/dialects/test_mysql.py::TableTests::test_create_table", + "pypika/tests/dialects/test_mysql.py::TableTests::test_drop_table", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_fetch_next_method_deprecated", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_groupby_alias_False_does_not_group_by_alias_when_subqueries_are_present", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_groupby_alias_False_does_not_group_by_alias_with_standard_query", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_limit_offset_query", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_limit_query", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_offset_query", + "pypika/tests/dialects/test_postgresql.py::InsertTests::test_array_keyword", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_alias_set_correctly", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_json_value_from_array_num", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_json_value_from_array_str", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_json_value_from_dict", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_json_value_from_dict_recursive", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_json_value_by_index", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_json_value_by_key", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_path_json_value", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_path_text_value", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_text_value_by_index", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_text_value_by_key", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contained_by_using_list_arg", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contained_by_using_str_arg", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contained_by_with_complex_criterion", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contains_for_field", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contains_for_json", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_has_any_keys", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_has_key", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_has_keys", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_subnet_contains_inet", + "pypika/tests/dialects/test_postgresql.py::DistinctOnTests::test_distinct_on", + "pypika/tests/dialects/test_postgresql.py::ArrayTests::test_array_syntax", + "pypika/tests/dialects/test_postgresql.py::ArrayTests::test_render_alias_in_array_sql", + "pypika/tests/dialects/test_postgresql.py::ReturningClauseTests::test_no_queryexception_if_returning_used_on_valid_query_type", + "pypika/tests/dialects/test_postgresql.py::ReturningClauseTests::test_queryexception_if_returning_used_on_invalid_query", + "pypika/tests/dialects/test_postgresql.py::ReturningClauseTests::test_return_field_from_join_table", + "pypika/tests/dialects/test_postgresql.py::ReturningClauseTests::test_returning_from_missing_table_raises_queryexception", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_dont_use_double_quotes_on_create_queries", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_dont_use_double_quotes_on_drop_queries", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_dont_use_double_quotes_on_joining_queries", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_use_double_quotes_on_alias_but_not_on_terms", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_use_double_quotes_on_alias_but_not_on_terms_with_joins", + "pypika/tests/dialects/test_sqllite.py::SelectTests::test_bool_false_as_zero", + "pypika/tests/dialects/test_sqllite.py::SelectTests::test_bool_true_as_one", + "pypika/tests/dialects/test_sqllite.py::ReplaceTests::test_insert_or_replace", + "pypika/tests/dialects/test_sqllite.py::ReplaceTests::test_normal_replace", + "pypika/tests/dialects/test_sqllite.py::ReplaceTests::test_replace_subquery", + "pypika/tests/dialects/test_vertica.py::VerticaQueryTests::test_delete_query_with_hint", + "pypika/tests/dialects/test_vertica.py::VerticaQueryTests::test_insert_query_with_hint", + "pypika/tests/dialects/test_vertica.py::VerticaQueryTests::test_select_query_with_hint", + "pypika/tests/dialects/test_vertica.py::VerticaQueryTests::test_update_query_with_hint", + "pypika/tests/dialects/test_vertica.py::CopyCSVTests::test_copy_from_file", + "pypika/tests/dialects/test_vertica.py::CreateTemporaryTableTests::test_create_local_table_without_temporary_raises_error", + "pypika/tests/dialects/test_vertica.py::CreateTemporaryTableTests::test_create_local_temporary_table", + "pypika/tests/dialects/test_vertica.py::CreateTemporaryTableTests::test_create_table_preserve_rows_without_temporary_raises_error", + "pypika/tests/dialects/test_vertica.py::CreateTemporaryTableTests::test_create_temporary_table_preserve_rows", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__agg_case_criterion_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__agg_case_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__agg_func_arithmetic_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__agg_func_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__case_mixed_constant_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__case_mixed_else_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__case_with_field_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__case_with_single_aggregate_field_in_one_criterion_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__constant_arithmetic_is_aggregate_none", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__constant_is_aggregate_none", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__field_arithmetic_constant_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__field_arithmetic_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__field_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__func_arithmetic_constant_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__mixed_case_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__mixed_func_arithmetic_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__negative_agg_func_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__non_aggregate_function_with_aggregated_arg", + "pypika/tests/test_aggregate.py::IsAggregateTests::test_complicated", + "pypika/tests/test_analytic_queries.py::RankTests::test_avg", + "pypika/tests/test_analytic_queries.py::RankTests::test_count_range_between_unbounded_preceeding_current_row", + "pypika/tests/test_analytic_queries.py::RankTests::test_dense_rank", + "pypika/tests/test_analytic_queries.py::RankTests::test_empty_over", + "pypika/tests/test_analytic_queries.py::RankTests::test_filter", + "pypika/tests/test_analytic_queries.py::RankTests::test_filter_quote_table_in_filter", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value_ignore_nulls", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value_ignore_nulls_first", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value_multi_argument", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value_range_between_x_preceeding_unbounded_following", + "pypika/tests/test_analytic_queries.py::RankTests::test_lag_generates_correct_sql", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value_ignore_nulls", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value_multi_argument", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value_rows_between_current_row_unbounded_following", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value_rows_between_current_row_unbounded_following_ignore_nulls", + "pypika/tests/test_analytic_queries.py::RankTests::test_lead_generates_correct_sql", + "pypika/tests/test_analytic_queries.py::RankTests::test_max_range_x_preceeding", + "pypika/tests/test_analytic_queries.py::RankTests::test_max_rows_x_preceeding", + "pypika/tests/test_analytic_queries.py::RankTests::test_median", + "pypika/tests/test_analytic_queries.py::RankTests::test_min_range_current_row", + "pypika/tests/test_analytic_queries.py::RankTests::test_min_rows_current_row", + "pypika/tests/test_analytic_queries.py::RankTests::test_multiple_partitions", + "pypika/tests/test_analytic_queries.py::RankTests::test_ntile_no_partition_or_order_invalid_sql", + "pypika/tests/test_analytic_queries.py::RankTests::test_ntile_with_order", + "pypika/tests/test_analytic_queries.py::RankTests::test_ntile_with_partition", + "pypika/tests/test_analytic_queries.py::RankTests::test_ntile_with_partition_and_order", + "pypika/tests/test_analytic_queries.py::RankTests::test_orderby_asc", + "pypika/tests/test_analytic_queries.py::RankTests::test_orderby_desc", + "pypika/tests/test_analytic_queries.py::RankTests::test_range_called_twice_raises_attribute_error", + "pypika/tests/test_analytic_queries.py::RankTests::test_range_then_rows_raises_attribute_error", + "pypika/tests/test_analytic_queries.py::RankTests::test_rank", + "pypika/tests/test_analytic_queries.py::RankTests::test_rank_with_alias", + "pypika/tests/test_analytic_queries.py::RankTests::test_row_number", + "pypika/tests/test_analytic_queries.py::RankTests::test_rows_called_twice_raises_attribute_error", + "pypika/tests/test_analytic_queries.py::RankTests::test_rows_then_range_raises_attribute_error", + "pypika/tests/test_analytic_queries.py::RankTests::test_stddev", + "pypika/tests/test_analytic_queries.py::RankTests::test_stddev_pop", + "pypika/tests/test_analytic_queries.py::RankTests::test_stddev_samp", + "pypika/tests/test_analytic_queries.py::RankTests::test_sum_rows_unbounded_preceeding", + "pypika/tests/test_analytic_queries.py::RankTests::test_table_prefixes_used_in_analytic_functions", + "pypika/tests/test_analytic_queries.py::RankTests::test_var_pop", + "pypika/tests/test_analytic_queries.py::RankTests::test_var_samp", + "pypika/tests/test_analytic_queries.py::RankTests::test_variance", + "pypika/tests/test_analytic_queries.py::RankTests::test_variance_rows_between_unbounded_preceeding_unbounded_following", + "pypika/tests/test_analytic_queries.py::RankTests::test_varpop_range_unbounded_preceeding", + "pypika/tests/test_analytic_queries.py::RankTests::test_varpop_rows_between_unbounded_preceeding_x_following", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_as_select_not_query_raises_error", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_with_columns", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_with_select", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_with_select_and_columns_fails", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_without_columns_or_select_empty", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_if_not_exists", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_simple", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_unique", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_where", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_without_columns_raises_error", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_without_table_raises_error", + "pypika/tests/test_criterions.py::CriterionTests::test__bitwise_and_in_where_clause", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_bitwise_and", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_bitwise_and_with_alias", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_bool", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_decimal", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_str", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gt_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gt_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gt_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gt_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gte_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gte_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gte_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gte_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_is_null", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_is_null_with_alias", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lt_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lt_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lt_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lt_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lte_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lte_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lte_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lte_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_str", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_with_alias", + "pypika/tests/test_criterions.py::NotTests::test_chained_function", + "pypika/tests/test_criterions.py::NotTests::test_is_not_null", + "pypika/tests/test_criterions.py::NotTests::test_negate", + "pypika/tests/test_criterions.py::NotTests::test_not_null", + "pypika/tests/test_criterions.py::NotTests::test_not_null_with_alias", + "pypika/tests/test_criterions.py::NotTests::test_not_with_and_criterion", + "pypika/tests/test_criterions.py::NotTests::test_not_with_complex_criterion", + "pypika/tests/test_criterions.py::NotTests::test_not_with_or_criterion", + "pypika/tests/test_criterions.py::NotTests::test_notnullcriterion_replace_table", + "pypika/tests/test_criterions.py::NotTests::test_variable_access", + "pypika/tests/test_criterions.py::BetweenTests::test__between_date", + "pypika/tests/test_criterions.py::BetweenTests::test__between_datetime", + "pypika/tests/test_criterions.py::BetweenTests::test__between_number", + "pypika/tests/test_criterions.py::BetweenTests::test__between_with_alias", + "pypika/tests/test_criterions.py::BetweenTests::test__function_between", + "pypika/tests/test_criterions.py::BetweenTests::test_get_item_only_works_with_slice", + "pypika/tests/test_criterions.py::IsInTests::test__function_isin", + "pypika/tests/test_criterions.py::IsInTests::test__in_character", + "pypika/tests/test_criterions.py::IsInTests::test__in_date", + "pypika/tests/test_criterions.py::IsInTests::test__in_datetime", + "pypika/tests/test_criterions.py::IsInTests::test__in_number", + "pypika/tests/test_criterions.py::IsInTests::test__in_number_with_alias", + "pypika/tests/test_criterions.py::IsInTests::test__in_unicode", + "pypika/tests/test_criterions.py::ArithmeticExpressionTests::test__lshift", + "pypika/tests/test_criterions.py::ArithmeticExpressionTests::test__rshift", + "pypika/tests/test_criterions.py::NotInTests::test__function_notin", + "pypika/tests/test_criterions.py::NotInTests::test__notin_character", + "pypika/tests/test_criterions.py::NotInTests::test__notin_date", + "pypika/tests/test_criterions.py::NotInTests::test__notin_datetime", + "pypika/tests/test_criterions.py::NotInTests::test__notin_number", + "pypika/tests/test_criterions.py::NotInTests::test__notin_number_with_alias", + "pypika/tests/test_criterions.py::LikeTests::test_glob_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_contains", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_ends_with", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_n_chars_long", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_starts_with", + "pypika/tests/test_criterions.py::LikeTests::test_like_contains", + "pypika/tests/test_criterions.py::LikeTests::test_like_ends_with", + "pypika/tests/test_criterions.py::LikeTests::test_like_n_chars_long", + "pypika/tests/test_criterions.py::LikeTests::test_like_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_like_starts_with", + "pypika/tests/test_criterions.py::LikeTests::test_not_ilike_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_not_like_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_rlike_escape_chars", + "pypika/tests/test_criterions.py::ExistsCriterionTests::test_exists", + "pypika/tests/test_criterions.py::ExistsCriterionTests::test_not_exists", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__between_and_field", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__between_and_isin", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__nested__and", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__nested__mixed", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__nested__or", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_and", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_function_and", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_function_or", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_function_xor", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_or", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_xor", + "pypika/tests/test_criterions.py::FieldsAsCriterionTests::test__field_and_field", + "pypika/tests/test_criterions.py::FieldsAsCriterionTests::test__field_or_field", + "pypika/tests/test_criterions.py::FieldsAsCriterionTests::test__field_xor_field", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_arithmeticfunction_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_betweencriterion_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_complexcriterion_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_criterion_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_field_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_function_with_only_fields_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_function_with_values_and_fields_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_nullcriterion_replace_table", + "pypika/tests/test_criterions.py::AnyTests::test_multiple_args_returned_in_chain_of_ors", + "pypika/tests/test_criterions.py::AnyTests::test_single_arg_returns_self", + "pypika/tests/test_criterions.py::AnyTests::test_with_generator", + "pypika/tests/test_criterions.py::AnyTests::test_zero_args_returns_empty_criterion", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_different_operations_with_empty_criterion", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_empty_criterion_on_the_left", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_empty_criterion_on_the_right", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_fields_", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_invertion_of_the_empty_criterion", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_more_than_one_empty_criterions", + "pypika/tests/test_criterions.py::AllTests::test_multiple_args_returned_in_chain_of_ors", + "pypika/tests/test_criterions.py::AllTests::test_single_arg_returns_self", + "pypika/tests/test_criterions.py::AllTests::test_with_generator", + "pypika/tests/test_criterions.py::AllTests::test_zero_args_returns_empty_criterion", + "pypika/tests/test_custom_functions.py::TestUnitCustomFunction::test_should_fail_with_wrong_arguments", + "pypika/tests/test_custom_functions.py::TestUnitCustomFunction::test_should_return_function_with_arguments", + "pypika/tests/test_custom_functions.py::TestUnitCustomFunction::test_should_return_function_with_no_arguments", + "pypika/tests/test_custom_functions.py::TestFunctionalCustomFunction::test_should_fail_use_custom_function_on_select_with_wrong_arguments", + "pypika/tests/test_custom_functions.py::TestFunctionalCustomFunction::test_should_use_custom_function_on_select", + "pypika/tests/test_data_types.py::StringTests::test_inline_string_concatentation", + "pypika/tests/test_data_types.py::UuidTests::test_uuid_string_generation", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_day", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_default", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_microsecond", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_minute", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_month", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_quarter", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_second", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_week", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_year", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_day_hour", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_day_microsecond", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_day_minute", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_day_second", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_hour_microsecond", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_hour_minute", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_hour_second", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_minute_microsecond", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_minute_second", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_second_microsecond", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_value_complex_expressions", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_value_right", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_year_month", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_mysql_dialect_uses_single_quotes_around_expression_in_an_interval", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_oracle_dialect_uses_single_quotes_around_expression_in_an_interval", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_postgresql_dialect_uses_single_quotes_around_interval", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_redshift_dialect_uses_single_quotes_around_interval", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_vertica_dialect_uses_single_quotes_around_interval", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_day", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_month", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_week", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_year", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_year_month", + "pypika/tests/test_date_math.py::TruncateTrailingZerosTests::test_do_not_truncate_integer_values", + "pypika/tests/test_date_math.py::TruncateTrailingZerosTests::test_do_not_truncate_months_between_years_and_datys", + "pypika/tests/test_deletes.py::DeleteTests::test_for_portion", + "pypika/tests/test_deletes.py::DeleteTests::test_omit_where", + "pypika/tests/test_deletes.py::DeleteTests::test_omit_where__table_schema", + "pypika/tests/test_deletes.py::DeleteTests::test_where_field_equals", + "pypika/tests/test_deletes.py::PostgresDeleteTests::test_delete_returning", + "pypika/tests/test_deletes.py::PostgresDeleteTests::test_delete_returning_star", + "pypika/tests/test_deletes.py::PostgresDeleteTests::test_delete_returning_str", + "pypika/tests/test_deletes.py::PostgresDeleteTests::test_delete_using", + "pypika/tests/test_drop.py::DropTableTests::test_drop_database", + "pypika/tests/test_drop.py::DropTableTests::test_drop_index", + "pypika/tests/test_drop.py::DropTableTests::test_drop_table", + "pypika/tests/test_drop.py::DropTableTests::test_drop_user", + "pypika/tests/test_drop.py::DropTableTests::test_drop_view", + "pypika/tests/test_formats.py::QuoteTests::test_no_quote_char_in_complex_query", + "pypika/tests/test_formats.py::QuoteTests::test_replace_quote_char_in_complex_query", + "pypika/tests/test_functions.py::FunctionTests::test_dialect_propagation", + "pypika/tests/test_functions.py::FunctionTests::test_is_aggregate_None_for_non_aggregate_function_or_function_with_no_aggregate_functions", + "pypika/tests/test_functions.py::FunctionTests::test_is_aggregate_True_for_aggregate_function_or_function_with_aggregate_functions", + "pypika/tests/test_functions.py::SchemaTests::test_schema_included_in_function_sql", + "pypika/tests/test_functions.py::SchemaTests::test_schema_no_schema_in_sql_when_none_set", + "pypika/tests/test_functions.py::ArithmeticTests::test__addition__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__addition__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__addition__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__addition__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__arithmetic_equality", + "pypika/tests/test_functions.py::ArithmeticTests::test__arithmetic_with_function", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_add_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_div_no_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_div_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_exponent_no_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_exponent_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_floor_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_function_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_modulus_no_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_modulus_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_mul_no_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_mul_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_nested_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_sub_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__division__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__division__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__division__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__division__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__exponent__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__exponent__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__floor", + "pypika/tests/test_functions.py::ArithmeticTests::test__leftshift__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__leftshift__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__leftshift__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__modulus__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__multiplication__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__multiplication__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__multiplication__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__multiplication__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__rightshift__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__rightshift__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__rightshift__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__subtraction__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__subtraction__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__subtraction__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__subtraction__right", + "pypika/tests/test_functions.py::AggregationTests::test__approx_percentile", + "pypika/tests/test_functions.py::AggregationTests::test__avg", + "pypika/tests/test_functions.py::AggregationTests::test__count", + "pypika/tests/test_functions.py::AggregationTests::test__count__star", + "pypika/tests/test_functions.py::AggregationTests::test__first", + "pypika/tests/test_functions.py::AggregationTests::test__last", + "pypika/tests/test_functions.py::AggregationTests::test__max", + "pypika/tests/test_functions.py::AggregationTests::test__min", + "pypika/tests/test_functions.py::AggregationTests::test__std", + "pypika/tests/test_functions.py::AggregationTests::test__stddev", + "pypika/tests/test_functions.py::AggregationTests::test__subquery_in_params_functions", + "pypika/tests/test_functions.py::AggregationTests::test__sum", + "pypika/tests/test_functions.py::ConditionTests::test__case__else", + "pypika/tests/test_functions.py::ConditionTests::test__case__field", + "pypika/tests/test_functions.py::ConditionTests::test__case__multi", + "pypika/tests/test_functions.py::ConditionTests::test__case__no_cases", + "pypika/tests/test_functions.py::ConditionTests::test__case__raw", + "pypika/tests/test_functions.py::StringTests::test__ascii__field", + "pypika/tests/test_functions.py::StringTests::test__ascii__int", + "pypika/tests/test_functions.py::StringTests::test__ascii__str", + "pypika/tests/test_functions.py::StringTests::test__bin__field", + "pypika/tests/test_functions.py::StringTests::test__bin__int", + "pypika/tests/test_functions.py::StringTests::test__bin__str", + "pypika/tests/test_functions.py::StringTests::test__concat__field", + "pypika/tests/test_functions.py::StringTests::test__concat__str", + "pypika/tests/test_functions.py::StringTests::test__insert__field", + "pypika/tests/test_functions.py::StringTests::test__insert__str", + "pypika/tests/test_functions.py::StringTests::test__length__field", + "pypika/tests/test_functions.py::StringTests::test__length__str", + "pypika/tests/test_functions.py::StringTests::test__lower__field", + "pypika/tests/test_functions.py::StringTests::test__lower__str", + "pypika/tests/test_functions.py::StringTests::test__replace__field", + "pypika/tests/test_functions.py::StringTests::test__replace__str", + "pypika/tests/test_functions.py::StringTests::test__substring", + "pypika/tests/test_functions.py::SplitPartFunctionTests::test__split_part", + "pypika/tests/test_functions.py::RegexpLikeFunctionTests::test__regexp_like", + "pypika/tests/test_functions.py::CastTests::test__cast__as", + "pypika/tests/test_functions.py::CastTests::test__cast__binary", + "pypika/tests/test_functions.py::CastTests::test__cast__binary_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__boolean", + "pypika/tests/test_functions.py::CastTests::test__cast__char", + "pypika/tests/test_functions.py::CastTests::test__cast__char_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__date", + "pypika/tests/test_functions.py::CastTests::test__cast__float", + "pypika/tests/test_functions.py::CastTests::test__cast__integer", + "pypika/tests/test_functions.py::CastTests::test__cast__long_varbinary", + "pypika/tests/test_functions.py::CastTests::test__cast__long_varbinary_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__long_varchar", + "pypika/tests/test_functions.py::CastTests::test__cast__long_varchar_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__numeric", + "pypika/tests/test_functions.py::CastTests::test__cast__signed", + "pypika/tests/test_functions.py::CastTests::test__cast__timestamp", + "pypika/tests/test_functions.py::CastTests::test__cast__unsigned", + "pypika/tests/test_functions.py::CastTests::test__cast__varbinary", + "pypika/tests/test_functions.py::CastTests::test__cast__varbinary_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__varchar", + "pypika/tests/test_functions.py::CastTests::test__cast__varchar_with_arg", + "pypika/tests/test_functions.py::CastTests::test__tochar__", + "pypika/tests/test_functions.py::DateFunctionsTests::test_current_date", + "pypika/tests/test_functions.py::DateFunctionsTests::test_current_time", + "pypika/tests/test_functions.py::DateFunctionsTests::test_current_timestamp", + "pypika/tests/test_functions.py::DateFunctionsTests::test_current_timestamp_with_alias", + "pypika/tests/test_functions.py::DateFunctionsTests::test_date_add", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_day", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_hour", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_join", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_microsecond", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_minute", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_month", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_quarter", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_second", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_week", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_year", + "pypika/tests/test_functions.py::DateFunctionsTests::test_now", + "pypika/tests/test_functions.py::DateFunctionsTests::test_time_diff", + "pypika/tests/test_functions.py::DateFunctionsTests::test_timestampadd", + "pypika/tests/test_functions.py::DateFunctionsTests::test_to_date", + "pypika/tests/test_functions.py::DateFunctionsTests::test_utc_timestamp", + "pypika/tests/test_functions.py::NullFunctionsTests::test_coalesce", + "pypika/tests/test_functions.py::NullFunctionsTests::test_isnull", + "pypika/tests/test_functions.py::NullFunctionsTests::test_nullif", + "pypika/tests/test_functions.py::NullFunctionsTests::test_nvl", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_mysql_one_groupby", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_mysql_rollup_two_groupbys", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_no_rollup_after_rollup_mysql", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_no_rollup_before_groupby", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_from_groupbys", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_from_parameters", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_from_two_groupbys", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_func_one_groupby", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_func_partial", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_func_two_groupbys", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_multiple_rollups", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_rollups_with_multiple_rollups_and_parity", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_rollups_with_parity", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_force_index_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_groupby_returns_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_immutable_kwarg_on_query_builder_disables_immutability", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_insert_into_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_join_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_orderby_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_queries_after_join", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_replace_into_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_select_returns_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_update_set_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_use_index_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_with_return_new_query_instance", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_multi_rows", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_multi_rows_chained", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_multi_rows_chained_mixed", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_multi_rows_chained_multiple_rows", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_single_element", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_column_using_alias_with_chain", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_column_using_table_alias", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_empty_columns", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_empty_columns_type_list", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_empty_columns_type_tuple", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_ignore", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_multiple_rows_with_array_value", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_none_skipped", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_null", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_one_column", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_one_column_multi_element_array", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_one_column_single_element_array", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_selected_columns", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_selected_columns_type_list", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_selected_columns_type_tuple", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_single_row_with_array_value", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_with_statement", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_empty_on_conflict_do_update_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_field", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_field_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_mixed_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_multiple_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_multiple_fields_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_field", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_field_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_multiple_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_multiple_fields_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_multiple_mixed_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_no_handler", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_two_handlers_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_two_handlers_do_update", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_fieldless_conflict_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_fieldless_conflict_do_update_field", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_non_insert_on_conflict_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_non_insert_on_conflict_do_update", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_do_nothing_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_do_update_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_do_update_with_excluded_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_from_subquery", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_complex", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_conflict_fields_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_conflict_fields_do_update", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_empty_conflict_fields_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_empty_conflict_fields_do_update", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_where_and_on_conflict_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_all_columns_multi_rows_chained_returning_star", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_all_columns_multi_rows_chained_returning_star_and_id", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_all_columns_multi_rows_chained_returning_star_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_all_columns_single_element_arrays", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_aggregate", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_all_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_all_fields_and_arithmetics", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_arithmetics", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_from_other_table", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_functions", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_null", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_one_field", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_one_field_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_tuple", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_ignore", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multi_rows_chained_mixed_on_duplicate_update_multiple", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_multiple", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_different_value", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_expression", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_expression_using_original_field_value", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_expression_using_values", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_same_value", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_none_skipped", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_one_column", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_one_column_multi_element_array", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_one_column_single_element_array", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_one_column_using_values", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_selected_columns_on_duplicate_update_multiple", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_selected_columns_on_duplicate_update_one", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_columns_from_columns", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_columns_from_columns_with_join", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_columns_from_star", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_from_columns", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_ignore_star", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_star", + "pypika/tests/test_inserts.py::InsertSubqueryTests::test_insert_subquery_wrapped_in_brackets", + "pypika/tests/test_inserts.py::SelectIntoTests::test_select_columns_into", + "pypika/tests/test_inserts.py::SelectIntoTests::test_select_columns_into_with_join", + "pypika/tests/test_inserts.py::SelectIntoTests::test_select_star_into", + "pypika/tests/test_inserts.py::ReplaceTests::test_replace_simple", + "pypika/tests/test_inserts.py::ReplaceTests::test_replace_subquery", + "pypika/tests/test_internals.py::TablesTests::test__case_tables", + "pypika/tests/test_internals.py::TablesTests::test__criterion_replace_table_with_value", + "pypika/tests/test_internals.py::TablesTests::test__star_tables", + "pypika/tests/test_internals.py::TablesTests::test__table_star_tables", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_cross_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_cross_join_on_subquery", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_cross_join_on_table", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_default_join_type", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_full_outer_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_hash_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_inner_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_arithmetic_field", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_collate", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_complex_criteria", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_field_multi", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_field_multi_with_extra_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_field_single", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_field_without_fields_raises_exception", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_subquery_criteria", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_second_table_in_from_clause", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_using_multiple_fields", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_using_string_field_name", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_using_with_quote_char", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_using_without_fields_raises_exception", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_with_arithmetic_function_in_select", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_left_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_left_outer_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_outer_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_right_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_right_outer_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_temporal_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_use_different_table_objects_for_same_table", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_fail_when_joining_unknown_type", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_ignore_table_references", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_immutable__tables", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_from_join", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_query_with_column_alias", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_query_with_setoperation", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_query_with_table_alias", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_query_without_alias", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_same_table", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_same_table_with_prefixes", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_table_twice", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_prefixes_added_to_function_in_orderby", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_prefixes_added_to_groupby", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_prefixes_added_to_orderby", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_require_condition", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_require_condition_with_both_tables", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select__fields_after_table_star", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select__ordered_select_clauses", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select__star_for_table", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select__star_for_table__replacement", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select_field_from_missing_table", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select_fields_with_where", + "pypika/tests/test_joins.py::UnionTests::test_mysql_query_wraps_unioned_queries", + "pypika/tests/test_joins.py::UnionTests::test_require_equal_number_of_fields", + "pypika/tests/test_joins.py::UnionTests::test_union", + "pypika/tests/test_joins.py::UnionTests::test_union_all", + "pypika/tests/test_joins.py::UnionTests::test_union_all_multiple", + "pypika/tests/test_joins.py::UnionTests::test_union_as_subquery", + "pypika/tests/test_joins.py::UnionTests::test_union_multiple", + "pypika/tests/test_joins.py::UnionTests::test_union_with_no_quote_char", + "pypika/tests/test_joins.py::UnionTests::test_union_with_order_by", + "pypika/tests/test_joins.py::UnionTests::test_union_with_order_by_use_union_query_field", + "pypika/tests/test_joins.py::UnionTests::test_union_with_order_by_use_union_query_field_with_aliases", + "pypika/tests/test_joins.py::UnionTests::test_union_with_order_by_with_aliases", + "pypika/tests/test_joins.py::InsertQueryJoinTests::test_join_table_on_insert_query", + "pypika/tests/test_joins.py::UpdateQueryJoinTests::test_join_table_on_update_query", + "pypika/tests/test_joins.py::IntersectTests::test_intersect", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_as_subquery", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_multiple", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_with_limit", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_with_no_quote_char", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_with_offset", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_with_order_by", + "pypika/tests/test_joins.py::IntersectTests::test_mysql_query_wraps_intersected_queries", + "pypika/tests/test_joins.py::IntersectTests::test_require_equal_number_of_fields_intersect", + "pypika/tests/test_joins.py::MinusTests::test_minus", + "pypika/tests/test_joins.py::MinusTests::test_minus_as_subquery", + "pypika/tests/test_joins.py::MinusTests::test_minus_multiple", + "pypika/tests/test_joins.py::MinusTests::test_minus_query_with_order_by_use_minus_query_field", + "pypika/tests/test_joins.py::MinusTests::test_minus_with_no_quote_char", + "pypika/tests/test_joins.py::MinusTests::test_minus_with_order_by", + "pypika/tests/test_joins.py::MinusTests::test_mysql_query_wraps_minus_queries", + "pypika/tests/test_joins.py::MinusTests::test_require_equal_number_of_fields", + "pypika/tests/test_joins.py::ExceptOfTests::test_except", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_as_subquery", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_multiple", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_query_with_order_by_use_minus_query_field", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_with_no_quote_char", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_with_order_by", + "pypika/tests/test_joins.py::ExceptOfTests::test_require_equal_number_of_fields_except_of", + "pypika/tests/test_negation.py::NegationTests::test_negate_field", + "pypika/tests/test_negation.py::NegationTests::test_negate_function", + "pypika/tests/test_negation.py::NegationTests::test_negate_wrapped_float", + "pypika/tests/test_negation.py::NegationTests::test_negate_wrapped_int", + "pypika/tests/test_parameter.py::ParametrizedTests::test_format_parameter", + "pypika/tests/test_parameter.py::ParametrizedTests::test_join", + "pypika/tests/test_parameter.py::ParametrizedTests::test_named_parameter", + "pypika/tests/test_parameter.py::ParametrizedTests::test_numeric_parameter", + "pypika/tests/test_parameter.py::ParametrizedTests::test_param_insert", + "pypika/tests/test_parameter.py::ParametrizedTests::test_param_select_join", + "pypika/tests/test_parameter.py::ParametrizedTests::test_param_select_subquery", + "pypika/tests/test_parameter.py::ParametrizedTests::test_pyformat_parameter", + "pypika/tests/test_parameter.py::ParametrizedTests::test_qmark_parameter", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_join", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_join_with_parameter_value_wrapper", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_param_insert", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_param_select_join", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_param_select_subquery", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_pyformat_parameter", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_can_be_used_in_a_select_statement", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_can_be_used_in_a_where_clause", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_can_be_used_in_orderby", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_column_value", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_object_id", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_object_value", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_row_id", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_row_num", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_sys_date", + "pypika/tests/test_query.py::QueryTablesTests::test_is_joined", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_case_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_delete_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_filter_tables", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_having_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_insert_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_insert_table_current_table_not_match", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_join_tables", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_only_specified_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_orderby_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_tuple_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_update_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_update_table_current_table_not_match", + "pypika/tests/test_query.py::QueryBuilderTests::test_pipe", + "pypika/tests/test_query.py::QueryBuilderTests::test_query_builders_have_reference_to_correct_query_class", + "pypika/tests/test_selects.py::SelectTests::test_empty_query", + "pypika/tests/test_selects.py::SelectTests::test_mssql_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_mysql_query_uses_backtick_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_oracle_query_uses_no_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_postgresql_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_redshift_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_select__column__single__alias__str", + "pypika/tests/test_selects.py::SelectTests::test_select__column__single__field", + "pypika/tests/test_selects.py::SelectTests::test_select__column__single__str", + "pypika/tests/test_selects.py::SelectTests::test_select__column__single__table_alias__str", + "pypika/tests/test_selects.py::SelectTests::test_select__columns__multi__field", + "pypika/tests/test_selects.py::SelectTests::test_select__columns__multi__str", + "pypika/tests/test_selects.py::SelectTests::test_select__distinct__multi", + "pypika/tests/test_selects.py::SelectTests::test_select__distinct__single", + "pypika/tests/test_selects.py::SelectTests::test_select__multiple_subqueries", + "pypika/tests/test_selects.py::SelectTests::test_select__multiple_tables", + "pypika/tests/test_selects.py::SelectTests::test_select__nested_subquery", + "pypika/tests/test_selects.py::SelectTests::test_select__no_table", + "pypika/tests/test_selects.py::SelectTests::test_select__star", + "pypika/tests/test_selects.py::SelectTests::test_select__star__replacement", + "pypika/tests/test_selects.py::SelectTests::test_select__subquery", + "pypika/tests/test_selects.py::SelectTests::test_select__table_schema", + "pypika/tests/test_selects.py::SelectTests::test_select__table_schema_with_multiple_levels_as_list", + "pypika/tests/test_selects.py::SelectTests::test_select__table_schema_with_multiple_levels_as_tuple", + "pypika/tests/test_selects.py::SelectTests::test_select_no_from", + "pypika/tests/test_selects.py::SelectTests::test_select_no_from_with_field_raises_exception", + "pypika/tests/test_selects.py::SelectTests::test_select_no_with_alias_from", + "pypika/tests/test_selects.py::SelectTests::test_select_then_add_table", + "pypika/tests/test_selects.py::SelectTests::test_select_with_force_index", + "pypika/tests/test_selects.py::SelectTests::test_select_with_force_index_multiple_calls", + "pypika/tests/test_selects.py::SelectTests::test_select_with_force_index_multiple_indexes", + "pypika/tests/test_selects.py::SelectTests::test_select_with_force_index_with_index_object", + "pypika/tests/test_selects.py::SelectTests::test_select_with_limit", + "pypika/tests/test_selects.py::SelectTests::test_select_with_limit__func", + "pypika/tests/test_selects.py::SelectTests::test_select_with_limit_and_offset", + "pypika/tests/test_selects.py::SelectTests::test_select_with_limit_zero", + "pypika/tests/test_selects.py::SelectTests::test_select_with_offset", + "pypika/tests/test_selects.py::SelectTests::test_select_with_offset__func", + "pypika/tests/test_selects.py::SelectTests::test_select_with_use_index", + "pypika/tests/test_selects.py::SelectTests::test_select_with_use_index_multiple_calls", + "pypika/tests/test_selects.py::SelectTests::test_select_with_use_index_multiple_indexes", + "pypika/tests/test_selects.py::SelectTests::test_select_with_use_index_with_index_object", + "pypika/tests/test_selects.py::SelectTests::test_table_select_alias", + "pypika/tests/test_selects.py::SelectTests::test_table_select_alias_with_offset_and_limit", + "pypika/tests/test_selects.py::SelectTests::test_temporal_select", + "pypika/tests/test_selects.py::SelectTests::test_vertica_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::WhereTests::test_ignore_empty_criterion_having", + "pypika/tests/test_selects.py::WhereTests::test_ignore_empty_criterion_where", + "pypika/tests/test_selects.py::WhereTests::test_select_with_force_index_and_where", + "pypika/tests/test_selects.py::WhereTests::test_where_enum", + "pypika/tests/test_selects.py::WhereTests::test_where_field_contains", + "pypika/tests/test_selects.py::WhereTests::test_where_field_does_not_contain", + "pypika/tests/test_selects.py::WhereTests::test_where_field_does_not_end_with", + "pypika/tests/test_selects.py::WhereTests::test_where_field_does_not_start_with", + "pypika/tests/test_selects.py::WhereTests::test_where_field_ends_with", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_and", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_nowait", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_of", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_of_multiple_tables", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_of_nowait", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_of_skip_locked", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_skip_locked", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_skip_locked_and_of", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_or", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_where", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_where_not", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_where_two_not", + "pypika/tests/test_selects.py::WhereTests::test_where_field_is_n_chars_long", + "pypika/tests/test_selects.py::WhereTests::test_where_field_is_not_n_chars_long", + "pypika/tests/test_selects.py::WhereTests::test_where_field_matches_regex", + "pypika/tests/test_selects.py::WhereTests::test_where_field_matches_regexp", + "pypika/tests/test_selects.py::WhereTests::test_where_field_matches_rlike", + "pypika/tests/test_selects.py::WhereTests::test_where_field_starts_with", + "pypika/tests/test_selects.py::WhereTests::test_where_nested_conditions", + "pypika/tests/test_selects.py::WhereTests::test_where_single_quote", + "pypika/tests/test_selects.py::WhereTests::test_where_with_multiple_wheres_using_and_case", + "pypika/tests/test_selects.py::WhereTests::test_where_with_multiple_wheres_using_or_case", + "pypika/tests/test_selects.py::PreWhereTests::test_ignore_empty_criterion_having", + "pypika/tests/test_selects.py::PreWhereTests::test_ignore_empty_criterion_where", + "pypika/tests/test_selects.py::PreWhereTests::test_prewhere_field_equals", + "pypika/tests/test_selects.py::PreWhereTests::test_select_with_force_index_and_where", + "pypika/tests/test_selects.py::PreWhereTests::test_where_and_prewhere", + "pypika/tests/test_selects.py::PreWhereTests::test_where_enum", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_contains", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_does_not_contain", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_does_not_end_with", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_does_not_start_with", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_ends_with", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_and", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_nowait", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_of", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_of_multiple_tables", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_of_nowait", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_of_skip_locked", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_skip_locked", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_skip_locked_and_of", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_or", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_where", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_where_not", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_where_two_not", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_is_n_chars_long", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_is_not_n_chars_long", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_matches_regex", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_matches_regexp", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_matches_rlike", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_starts_with", + "pypika/tests/test_selects.py::PreWhereTests::test_where_nested_conditions", + "pypika/tests/test_selects.py::PreWhereTests::test_where_single_quote", + "pypika/tests/test_selects.py::PreWhereTests::test_where_with_multiple_wheres_using_and_case", + "pypika/tests/test_selects.py::PreWhereTests::test_where_with_multiple_wheres_using_or_case", + "pypika/tests/test_selects.py::GroupByTests::test_group_by__single_with_totals", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__alias", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__alias_platforms", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__alias_with_join", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__count_distinct", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__count_field", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__count_star", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__int", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__multi", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__multi_with_totals", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__no_alias", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__no_alias_mssql", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__no_alias_oracle", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__single", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__str", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__sum_distinct", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__sum_filter", + "pypika/tests/test_selects.py::GroupByTests::test_groupby_with_case_uses_the_alias", + "pypika/tests/test_selects.py::GroupByTests::test_mssql_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_mysql_query_uses_backtick_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_oracle_query_uses_no_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_postgres_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_redshift_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_vertica_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_having_and", + "pypika/tests/test_selects.py::HavingTests::test_having_greater_than", + "pypika/tests/test_selects.py::HavingTests::test_having_join_and_equality", + "pypika/tests/test_selects.py::HavingTests::test_mssql_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_mysql_query_uses_backtick_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_oracle_query_uses_no_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_postgres_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_redshift_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_vertica_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_alias", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_asc", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_desc", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_multi_fields", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_no_alias", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_single_field", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_single_str", + "pypika/tests/test_selects.py::AliasTests::test_arithmetic_function", + "pypika/tests/test_selects.py::AliasTests::test_case_using_as", + "pypika/tests/test_selects.py::AliasTests::test_case_using_constructor_param", + "pypika/tests/test_selects.py::AliasTests::test_function_using_as_nested", + "pypika/tests/test_selects.py::AliasTests::test_functions_using_as", + "pypika/tests/test_selects.py::AliasTests::test_functions_using_constructor_param", + "pypika/tests/test_selects.py::AliasTests::test_functions_using_constructor_param_nested", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_criterion", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_criterion_comparison", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_field_inside_case", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_groupby", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_orderby", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_where", + "pypika/tests/test_selects.py::AliasTests::test_null_value_with_alias", + "pypika/tests/test_selects.py::AliasTests::test_select__multiple_tables", + "pypika/tests/test_selects.py::AliasTests::test_table_field", + "pypika/tests/test_selects.py::AliasTests::test_table_field__multi", + "pypika/tests/test_selects.py::AliasTests::test_table_with_schema_and_alias", + "pypika/tests/test_selects.py::AliasTests::test_use_aliases_in_groupby_and_orderby", + "pypika/tests/test_selects.py::SubqueryTests::test_from_subquery_without_alias", + "pypika/tests/test_selects.py::SubqueryTests::test_join", + "pypika/tests/test_selects.py::SubqueryTests::test_join_query_with_alias", + "pypika/tests/test_selects.py::SubqueryTests::test_join_with_with", + "pypika/tests/test_selects.py::SubqueryTests::test_select_from_nested_query", + "pypika/tests/test_selects.py::SubqueryTests::test_select_from_nested_query_with_join", + "pypika/tests/test_selects.py::SubqueryTests::test_select_from_with_returning", + "pypika/tests/test_selects.py::SubqueryTests::test_select_subquery", + "pypika/tests/test_selects.py::SubqueryTests::test_select_subquery_with_alias", + "pypika/tests/test_selects.py::SubqueryTests::test_where__equality", + "pypika/tests/test_selects.py::SubqueryTests::test_where__in", + "pypika/tests/test_selects.py::SubqueryTests::test_where__in_nested", + "pypika/tests/test_selects.py::SubqueryTests::test_with", + "pypika/tests/test_selects.py::QuoteTests::test_extraneous_quotes", + "pypika/tests/test_tables.py::TableStructureTests::test_database_schema_table_attr", + "pypika/tests/test_tables.py::TableStructureTests::test_schema_table_attr", + "pypika/tests/test_tables.py::TableStructureTests::test_table_for_period_sql", + "pypika/tests/test_tables.py::TableStructureTests::test_table_for_system_time_sql", + "pypika/tests/test_tables.py::TableStructureTests::test_table_sql", + "pypika/tests/test_tables.py::TableStructureTests::test_table_with_alias", + "pypika/tests/test_tables.py::TableStructureTests::test_table_with_schema_and_schema_parent_arg", + "pypika/tests/test_tables.py::TableStructureTests::test_table_with_schema_arg", + "pypika/tests/test_tables.py::TableEqualityTests::test_many_tables_with_alias", + "pypika/tests/test_tables.py::TableEqualityTests::test_many_tables_with_or_not_alias", + "pypika/tests/test_tables.py::TableEqualityTests::test_many_tables_without_alias", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_equal_by_name", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_equal_by_schema_and_name", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_equal_by_schema_and_name_using_schema", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_equal_by_schema_and_name_using_schema_with_parent", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_not_equal_by_schema_and_name_using_schema_with_different_parents", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_not_equal_with_different_names", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_not_equal_with_different_schemas", + "pypika/tests/test_tables.py::TableDialectTests::test_make_tables_factory_with_default_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_make_tables_factory_with_dialect_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_factory_with_default_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_factory_with_dialect_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_with_bad_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_with_default_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_with_dialect_query_cls", + "pypika/tests/test_terms.py::FieldAliasTests::test_when_alias_specified", + "pypika/tests/test_terms.py::FieldInitTests::test_init_with_str_table", + "pypika/tests/test_terms.py::FieldHashingTests::test_non_tabled_aliased_eq_fields_equally_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_non_tabled_aliased_ne_fields_differently_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_non_tabled_eq_fields_equally_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_non_tabled_ne_fields_differently_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_tabled_eq_fields_equally_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_tabled_ne_fields_differently_hashed", + "pypika/tests/test_terms.py::AtTimezoneTests::test_passes_kwargs_to_field_get_sql", + "pypika/tests/test_terms.py::AtTimezoneTests::test_when_alias_specified", + "pypika/tests/test_terms.py::AtTimezoneTests::test_when_interval_not_specified", + "pypika/tests/test_terms.py::AtTimezoneTests::test_when_interval_specified", + "pypika/tests/test_tuples.py::TupleTests::test_render_alias_in_array_sql", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_equality_tuple_on_both", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_equality_tuple_on_left", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_equality_tuple_on_right", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_in_using_mixed_tuples", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_in_using_pypika_tuples", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_in_using_python_tuples", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_is_aggregate", + "pypika/tests/test_tuples.py::TupleTests::test_tuples_in_join", + "pypika/tests/test_tuples.py::ArrayTests::test_array_general", + "pypika/tests/test_tuples.py::ArrayTests::test_empty_psql_array", + "pypika/tests/test_tuples.py::ArrayTests::test_psql_array_general", + "pypika/tests/test_tuples.py::ArrayTests::test_render_alias_in_array_sql", + "pypika/tests/test_tuples.py::BracketTests::test_arithmetic_with_brackets", + "pypika/tests/test_tuples.py::BracketTests::test_arithmetic_with_brackets_and_alias", + "pypika/tests/test_updates.py::UpdateTests::test_empty_query", + "pypika/tests/test_updates.py::UpdateTests::test_for_portion", + "pypika/tests/test_updates.py::UpdateTests::test_omit_where", + "pypika/tests/test_updates.py::UpdateTests::test_single_quote_escape_in_set", + "pypika/tests/test_updates.py::UpdateTests::test_update__table_schema", + "pypika/tests/test_updates.py::UpdateTests::test_update_from", + "pypika/tests/test_updates.py::UpdateTests::test_update_from_with_where", + "pypika/tests/test_updates.py::UpdateTests::test_update_with_join", + "pypika/tests/test_updates.py::UpdateTests::test_update_with_limit", + "pypika/tests/test_updates.py::UpdateTests::test_update_with_none", + "pypika/tests/test_updates.py::UpdateTests::test_update_with_statement", + "pypika/tests/test_updates.py::PostgresUpdateTests::test_update_returning", + "pypika/tests/test_updates.py::PostgresUpdateTests::test_update_returning_from_different_tables", + "pypika/tests/test_updates.py::PostgresUpdateTests::test_update_returning_star", + "pypika/tests/test_updates.py::PostgresUpdateTests::test_update_returning_str", + "pypika/tests/test_updates.py::SQLLiteUpdateTests::test_update_with_bool", + "pypika/tests/test_utils.py::ImmutabilityTests::test_raise_attribute_error_for_deepcopy", + "pypika/tests/test_utils.py::ImmutabilityTests::test_raise_attribute_error_for_getnewargs", + "pypika/tests/test_utils.py::ImmutabilityTests::test_raise_attribute_error_for_getstate", + "pypika/tests/test_utils.py::ImmutabilityTests::test_raise_attribute_error_for_setstate" + ] +} diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/grade.py b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/grade.py new file mode 100644 index 0000000000000000000000000000000000000000..e3b37293830e51a5c5833c93c4705e1ed9364257 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/grade.py @@ -0,0 +1,128 @@ +"""Trusted private pytest panel runner. Installed only in a fresh grader Job.""" + +import hashlib +import importlib.util +import json +import os +import shutil +import stat +import subprocess +from pathlib import Path, PurePosixPath + + +def sha(raw): + return hashlib.sha256(raw).hexdigest() + + +def safe(value): + path = PurePosixPath(value) + if ( + path.is_absolute() + or path.as_posix() != value + or not path.parts + or any(part in {".", "..", ".git"} for part in path.parts) + ): + raise ValueError("Unsafe trusted test path") + return path + + +def restore(worktree, private, manifest): + worktree, private = Path(worktree), Path(private) + captured = {} + for name, expected in manifest["files"].items(): + path = private / safe(name) + info = path.lstat() + raw = path.read_bytes() if stat.S_ISREG(info.st_mode) else b"" + if ( + not stat.S_ISREG(info.st_mode) + or len(raw) != expected["bytes"] + or sha(raw) != expected["sha256"] + or stat.S_IMODE(info.st_mode) != expected["mode"] + ): + raise ValueError("Trusted private test bytes or modes drifted") + captured[name] = (raw, expected["mode"]) + # Capture and verify every private byte before changing the submitted tree. + for name in manifest["directory_roots"]: + destination = worktree / safe(name) + if destination.is_symlink(): + raise ValueError("Submitted test directory is a symlink") + for parent in destination.parents: + if parent == worktree: + break + if parent.is_symlink(): + raise ValueError("Submitted test parent is a symlink") + if destination.exists(): + if not destination.is_dir(): + raise ValueError("Submitted test directory is not a directory") + shutil.rmtree(destination) + for name, (raw, mode) in captured.items(): + destination = worktree / safe(name) + for parent in destination.parents: + if parent == worktree: + break + if parent.is_symlink(): + raise ValueError("Submitted test parent is a symlink") + if destination.is_symlink(): + raise ValueError("Submitted trusted file is a symlink") + destination.parent.mkdir(parents=True, exist_ok=True) + destination.write_bytes(raw) + destination.chmod(mode) + + +def run(worktree, private_root, output, invoke=None): + private_root, output, worktree = Path(private_root), Path(output), Path(worktree) + expected = json.loads((private_root / "expected-panels.json").read_bytes()) + config = json.loads((private_root / "panel-config.json").read_bytes()) + manifest = json.loads((private_root / "trusted-inventory.json").read_bytes()) + restore(worktree, private_root / "trusted", manifest) + output.mkdir(parents=True, exist_ok=True) + for name in ( + "reward.txt", + "pass-to-pass.xml", + "fail-to-pass.xml", + "pytest-evidence.json", + ): + (output / name).unlink(missing_ok=True) + environment = dict(os.environ) + for key in ("PYTEST_ADDOPTS", "PYTEST_DISABLE_PLUGIN_AUTOLOAD", "PYTHONPATH"): + environment.pop(key, None) + commands, native_exit = [], 0 + invoke = invoke or subprocess.run + for group in ("pass-to-pass", "fail-to-pass"): + if ( + not isinstance(expected[group], list) + or not expected[group] + or any( + not isinstance(target, str) or not target for target in expected[group] + ) + ): + raise ValueError("Frozen native pytest selectors are incomplete") + command = [ + *config["official_pytest_argv"], + "--override-ini=addopts=", + "--junitxml=" + str(output / (group + ".xml")), + *expected[group], + ] + result = invoke(command, cwd=worktree, env=environment, check=False) + native_exit = result.returncode + commands.append({"group": group, "argv": command, "exit_code": native_exit}) + if native_exit != 0: + break + (output / "pytest-commands.json").write_text( + json.dumps(commands, sort_keys=True) + "\n" + ) + spec = importlib.util.spec_from_file_location( + "trusted_pytest_result", private_root / "check_pytest.py" + ) + checker = importlib.util.module_from_spec(spec) + spec.loader.exec_module(checker) + result = checker.assess(output, expected, native_exit) + (output / "reward.txt").write_text(str(result["reward"]) + "\n") + (output / "pytest-evidence.json").write_text( + json.dumps(result, sort_keys=True) + "\n" + ) + return result + + +if __name__ == "__main__": + run("/testbed/repo", "/tests", "/logs/verifier") diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/panel-config.json b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/panel-config.json new file mode 100644 index 0000000000000000000000000000000000000000..6417b9c92e5da5b97ee641bd54f798302af42a31 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/panel-config.json @@ -0,0 +1,28 @@ +{ + "dependency_installation_pinned": false, + "official_install_cmds": [ + "python -m pip install -e ." + ], + "official_pytest_argv": [ + "pytest", + "--disable-warnings", + "--color=no", + "--tb=no", + "--verbose" + ], + "official_test_command": "source /opt/miniconda3/bin/activate; conda activate testbed; pytest --disable-warnings --color=no --tb=no --verbose", + "operator_test_runner_prerequisites": [ + "python -m pip install pytest==8.4.2" + ], + "operator_test_runner_reason": "The official profile invokes pytest, but the common tools runtime does not provide it; pinned separately from source-native project requirements.", + "panel_normalization": "Override project addopts only to execute the exact frozen native panels; add JUnit output, preserve official pytest options and all selectors.", + "python_version": "3.10", + "source_bound_test_dependency_cmds": [ + "python -m pip install parameterized==0.7.0" + ], + "test_dependency_source_sha256": { + "requirements-dev.txt": "10f4ba7b19a73950d28fd7403d7e1d1b1fe2ccc4f49516974f47199d2965f23d", + "setup.py": "f8bad274588a22e65764d8cf9fb2be5aa6fcfaf3bf861d71e5f751105898845a", + "tox.ini": "c2d7205d0ac93e9c9e80dc5d24f0a826a6781f587a33ea722ea621f9e2ccd0ea" + } +} diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/test.sh b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..81b6d0620f05dbd3b54b4e7ea5de04ce3f8a98e2 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/test.sh @@ -0,0 +1,6 @@ +#!/bin/bash +set -Eeuo pipefail +source /opt/miniconda3/bin/activate +conda activate testbed +cd /testbed/repo +exec python -I /tests/grade.py diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted-inventory.json b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted-inventory.json new file mode 100644 index 0000000000000000000000000000000000000000..6926ef1c22ed56457101c37cd70e0fe0d1656f0c --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted-inventory.json @@ -0,0 +1,242 @@ +{ + "directory_roots": [ + "pypika/tests" + ], + "files": { + "pypika/tests/__init__.py": { + "bytes": 58, + "mode": 420, + "sha256": "7d41f44b87688bdf162e6d5cbe7b517cfba468f96eaa421f02718c17eb486a18" + }, + "pypika/tests/clickhouse/__init__.py": { + "bytes": 0, + "mode": 420, + "sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "pypika/tests/clickhouse/test_array.py": { + "bytes": 2942, + "mode": 420, + "sha256": "0f0a5b4c3daf3ddce2944b6119795e80d50b74e4687ef2e34399e5d21d3d48ae" + }, + "pypika/tests/clickhouse/test_condition.py": { + "bytes": 2533, + "mode": 420, + "sha256": "c666976d082b1d12cd57e791d1a525183246335efad96a369b58871a6f1e4fa1" + }, + "pypika/tests/clickhouse/test_dates_and_times.py": { + "bytes": 2508, + "mode": 420, + "sha256": "cb8ea84363e35ad0a00b52a8ec20cb38f2348f4cba28d026a4c32c14fd1fc56f" + }, + "pypika/tests/clickhouse/test_nullable_arg.py": { + "bytes": 672, + "mode": 420, + "sha256": "883c5161ebeb09544ce124d20a096d248bd12a0404ad77c84637be75d6738529" + }, + "pypika/tests/clickhouse/test_search_string.py": { + "bytes": 1189, + "mode": 420, + "sha256": "d5f0ed6a51cf550bdd4b261fa2e98084184dd1cbb08f5dbb8b91278b4c8f3bfd" + }, + "pypika/tests/clickhouse/test_type_conversion.py": { + "bytes": 4445, + "mode": 420, + "sha256": "7e6045b64433a8947346cfb34ac30279349f7a2e2081a2815212c8cb7d0235ab" + }, + "pypika/tests/dialects/__init__.py": { + "bytes": 0, + "mode": 420, + "sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "pypika/tests/dialects/test_clickhouse.py": { + "bytes": 5747, + "mode": 420, + "sha256": "2272538d6eeb6dfb01f9803eed328b4cd4efc8d255b6a8ab3c4e25bee74d73fa" + }, + "pypika/tests/dialects/test_mssql.py": { + "bytes": 3152, + "mode": 420, + "sha256": "0cd9b2ee6498caa9fa75a51ead30803057fb23deb2ac706d396d88329e0e91d7" + }, + "pypika/tests/dialects/test_mysql.py": { + "bytes": 2984, + "mode": 420, + "sha256": "a5f4550dd14bf4820e5d85cf06b6c7c79286e41d2d3c794f639579d20fffab92" + }, + "pypika/tests/dialects/test_oracle.py": { + "bytes": 1906, + "mode": 420, + "sha256": "67f80eb40cc9b4dabcbad355e8be6d83c54a64cbee809182ef57fa9f48d2ebc6" + }, + "pypika/tests/dialects/test_postgresql.py": { + "bytes": 9532, + "mode": 420, + "sha256": "548ee7267ca87c9e1ae82ca89a4e5bd96c7392a55cc07996f2b105f911ffa6cf" + }, + "pypika/tests/dialects/test_snowflake.py": { + "bytes": 2159, + "mode": 420, + "sha256": "e567b9dab0a5366bd11a0ef162c3a3bb492280b78bc4b397a23070563dc84468" + }, + "pypika/tests/dialects/test_sqllite.py": { + "bytes": 1243, + "mode": 420, + "sha256": "118fed7e575415f276bda390a119080bd6a767aee3d9c953e11a8c219f0f017c" + }, + "pypika/tests/dialects/test_vertica.py": { + "bytes": 3578, + "mode": 420, + "sha256": "33a027e6735ca03b7afd11394905c4193e48a15dda3efbe47cdcd85fcabf840c" + }, + "pypika/tests/test_aggregate.py": { + "bytes": 3946, + "mode": 420, + "sha256": "5b0fb549de3bb50ad88ae1d75824f12f7ab4a5f1102b06a70c7b2ebae33bea6d" + }, + "pypika/tests/test_analytic_queries.py": { + "bytes": 20611, + "mode": 420, + "sha256": "8546b7a296c8e212c349c4baff95f93934b3120f74625b3945ade3b438e3a3ed" + }, + "pypika/tests/test_create.py": { + "bytes": 9088, + "mode": 420, + "sha256": "6c57302da52ca1044be0afdafe677d5de245e44873dff1386c9a1ccb2625cc82" + }, + "pypika/tests/test_criterions.py": { + "bytes": 32014, + "mode": 420, + "sha256": "78539ccca82f9a02fad0f5a39041ac343e3a142ce52368cd4f6ada489c52516a" + }, + "pypika/tests/test_custom_functions.py": { + "bytes": 1710, + "mode": 420, + "sha256": "bfa18bc328a3577965db7cc75eb94439f0cfd95a3775d9b1cc8af1062bb202cb" + }, + "pypika/tests/test_data_types.py": { + "bytes": 403, + "mode": 420, + "sha256": "c1be6ecc621a80dd91d35b1427bdfc8b1b33bd926515198e626d6fb5e1878c8b" + }, + "pypika/tests/test_date_math.py": { + "bytes": 5544, + "mode": 420, + "sha256": "85aa54efe54fe19639f2dc2a5750647e3337ac2681768bc3fe327841f1634d9e" + }, + "pypika/tests/test_deletes.py": { + "bytes": 3204, + "mode": 420, + "sha256": "ccde6df760d76d5d499ce828f6b0e2ad3eebcb2a5553c1890f481b9160b8d51a" + }, + "pypika/tests/test_drop.py": { + "bytes": 1556, + "mode": 420, + "sha256": "a13dffa59ef8657398d5498c18977bfd702635e336ea9966b1a86137afca7926" + }, + "pypika/tests/test_formats.py": { + "bytes": 1948, + "mode": 420, + "sha256": "240458a404bb119322778893b94a12be0f98f914acd701d2b4be73eb9be96f75" + }, + "pypika/tests/test_functions.py": { + "bytes": 32769, + "mode": 420, + "sha256": "3ceaac7791bd27e50f44e1b4a1451d1e09afe6a8011052caea838e5124582154" + }, + "pypika/tests/test_groupby_modifiers.py": { + "bytes": 5227, + "mode": 420, + "sha256": "9db4497660f08e3352a9a02c34889ad1cd6bab3aebaeaa485e84390ad71c84c5" + }, + "pypika/tests/test_immutability.py": { + "bytes": 3954, + "mode": 420, + "sha256": "af537ced19f7274951cc91697eae748ef6c9cd20a8d8e492d93dc85b06f8fb50" + }, + "pypika/tests/test_inserts.py": { + "bytes": 32549, + "mode": 420, + "sha256": "652e9f7f0f425e9acc0f70e2851ae29310b378262ea30369ea0113ef428f210f" + }, + "pypika/tests/test_internals.py": { + "bytes": 828, + "mode": 420, + "sha256": "4374c2632563346d00ca4de6af397a022ef3f5022e808c8711a3f207a3a21609" + }, + "pypika/tests/test_joins.py": { + "bytes": 43895, + "mode": 420, + "sha256": "53f224815c10393382443f020cb20e313420764495a8fd30f7ea2f34fd52935d" + }, + "pypika/tests/test_negation.py": { + "bytes": 763, + "mode": 420, + "sha256": "6be105e8f39b32fb23e6ac7c7158232ee78111455d4f35638c8af60781138c79" + }, + "pypika/tests/test_parameter.py": { + "bytes": 7382, + "mode": 420, + "sha256": "aaf2a3e79c8267bdc60e218445bc2a2254b97cf37b643a44d6f1a8141cbb5104" + }, + "pypika/tests/test_pseudocolumns.py": { + "bytes": 1609, + "mode": 420, + "sha256": "b7c69f7aca41323c0e14a6a9e58697399cd7860610f07291afc6e8af26079ca2" + }, + "pypika/tests/test_query.py": { + "bytes": 9025, + "mode": 420, + "sha256": "2da9d717673912a84e86e6c0d3955dbd8f2fa7b41b7ed9a6f78089dfa28f9444" + }, + "pypika/tests/test_selects.py": { + "bytes": 50757, + "mode": 420, + "sha256": "5ac1b7ad3248d64b1e3865a72c763873514ae5cd6e03356b913e531c0c336986" + }, + "pypika/tests/test_tables.py": { + "bytes": 6568, + "mode": 420, + "sha256": "384c8e843ba56374ee92cd7b7e2fd3f89247b899e23cd9e1f6663d751ad5d884" + }, + "pypika/tests/test_terms.py": { + "bytes": 3215, + "mode": 420, + "sha256": "8598513180ddcd28cc61582618d85bd570280978b07603044dae81b2eb099f77" + }, + "pypika/tests/test_tuples.py": { + "bytes": 6033, + "mode": 420, + "sha256": "863942196a93e8939be0d03c49cfeb42a35503ad42f9f3d6c730260112811087" + }, + "pypika/tests/test_updates.py": { + "bytes": 5689, + "mode": 420, + "sha256": "0f0f2521bb8d1f5d782f8fabaea5fd1d82090cde045ba87fad65770db6c75d2f" + }, + "pypika/tests/test_utils.py": { + "bytes": 834, + "mode": 420, + "sha256": "5db6e90df5daaa70b9f35f1243db69908da1f27887f63466fc27ce20c7e14892" + }, + "pyproject.toml": { + "bytes": 390, + "mode": 420, + "sha256": "037fedacd5be5d078f398265ff97e1677e25214ad8839d17073a439695ee7a91" + }, + "setup.cfg": { + "bytes": 317, + "mode": 420, + "sha256": "c84a31de586e8385e741127b004fc1f19ebae6463cdf0b3f243991db35cdeaea" + }, + "setup.py": { + "bytes": 2638, + "mode": 420, + "sha256": "f8bad274588a22e65764d8cf9fb2be5aa6fcfaf3bf861d71e5f751105898845a" + }, + "tox.ini": { + "bytes": 257, + "mode": 420, + "sha256": "c2d7205d0ac93e9c9e80dc5d24f0a826a6781f587a33ea722ea621f9e2ccd0ea" + } + } +} diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/__init__.py b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..86d8a68101915c27b95484243dd81d55f7dba356 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/__init__.py @@ -0,0 +1,2 @@ +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/clickhouse/__init__.py b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/clickhouse/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/clickhouse/test_array.py b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/clickhouse/test_array.py new file mode 100644 index 0000000000000000000000000000000000000000..469705a9ff3c8fe9cc7f02c44a9812521eeb67f4 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/clickhouse/test_array.py @@ -0,0 +1,104 @@ +import unittest + +from parameterized import parameterized + +from pypika import Field +from pypika.clickhouse.array import ( + Array, + Empty, + HasAny, + Length, + NotEmpty, +) +from pypika.clickhouse.type_conversion import ( + ToFixedString, + ToInt64, +) + + +class TestArray(unittest.TestCase): + @parameterized.expand( + [ + ( + "['ridley', 'scott', 'jimi', 'hendrix']", + Array(["ridley", "scott", "jimi", "hendrix"]), + ), + ( + "[1, 2, 3, 4]", + Array([1, 2, 3, 4]), + ), + ( + "[toInt64('1'),toInt64('2'),toInt64('3'),toInt64('4')]", + Array(["1", "2", "3", "4"], ToInt64), + ), + ( + "[toFixedString('mogwai',10),toFixedString('mono',10),toFixedString('bonobo',10)] arr", + Array(["mogwai", "mono", "bonobo"], ToFixedString, {"length": 10}).as_('arr'), + ), + ] + ) + def test_get_sql(self, expected: str, array: Array): + self.assertEqual(expected, array.get_sql()) + + +class TestHasAny(unittest.TestCase): + @parameterized.expand( + [ + ( + 'hasAny("mental_abilities","physical_abilities")', + HasAny(Field("mental_abilities"), Field("physical_abilities")), + ), + ("hasAny([1, 2, 3, 4],[3])", HasAny(Array([1, 2, 3, 4]), Array([3]))), + ( + "hasAny(\"bands\",[toFixedString('port-royal',20),toFixedString('hammock',20)])", + HasAny( + Field("bands"), + Array(["port-royal", "hammock"], ToFixedString, {"length": 20}), + ), + ), + ] + ) + def test_get_sql(self, expected: str, func: HasAny): + self.assertEqual(expected, func.get_sql()) + + +class TestLength(unittest.TestCase): + @parameterized.expand( + [ + ( + 'length("tags")', + Length(Field("tags")), + ), + ("length([1, 2, 3])", Length(Array([1, 2, 3]))), + ] + ) + def test_get_sql(self, expected: str, func: Length): + self.assertEqual(expected, func.get_sql()) + + +class TestEmpty(unittest.TestCase): + @parameterized.expand( + [ + ( + 'empty("tags")', + Empty(Field("tags")), + ), + ("empty([1, 2, 3])", Empty(Array([1, 2, 3]))), + ] + ) + def test_get_sql(self, expected: str, func: Empty): + self.assertEqual(expected, func.get_sql()) + + +class TestNotEmpty(unittest.TestCase): + @parameterized.expand( + [ + ( + 'notEmpty("tags")', + NotEmpty(Field("tags")), + ), + ("notEmpty([1, 2, 3])", NotEmpty(Array([1, 2, 3]))), + ] + ) + def test_get_sql(self, expected: str, func: NotEmpty): + self.assertEqual(expected, func.get_sql()) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/clickhouse/test_condition.py b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/clickhouse/test_condition.py new file mode 100644 index 0000000000000000000000000000000000000000..145baeb7753dd9cbefbd6f272bd672ae5730b0c0 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/clickhouse/test_condition.py @@ -0,0 +1,72 @@ +import unittest + +from parameterized import parameterized + +from pypika import Field +from pypika.clickhouse.condition import If, MultiIf +from pypika.clickhouse.type_conversion import ToFixedString + + +class TestIfCondition(unittest.TestCase): + @parameterized.expand( + [ + ( + If( + Field("filmmaker").isnull(), + ToFixedString("Tarantino", 20), + Field("filmmaker"), + ), + "if(filmmaker IS NULL,toFixedString('Tarantino',20),filmmaker)", + ), + ( + If( + Field("created") == Field("updated"), + ToFixedString("yes", 3), + ToFixedString("no", 3), + ), + "if(created=updated,toFixedString('yes',3),toFixedString('no',3))", + ), + ] + ) + def test_get_sql(self, func, expected): + self.assertEqual(func.get_sql(), expected) + + +class TestMultiIfCondition(unittest.TestCase): + @parameterized.expand( + [ + ( + MultiIf( + Field("filmmaker").isnull(), + ToFixedString("Tarantino", 20), + Field("filmmaker") == ToFixedString("undefined", 20), + ToFixedString("Tarantino", 20), + Field("filmmaker"), + ), + "multiIf(filmmaker IS NULL," + "toFixedString('Tarantino',20)," + "filmmaker=toFixedString('undefined',20)," + "toFixedString('Tarantino',20),filmmaker)", + ), + ( + MultiIf( + Field("color") == ToFixedString("black", 20), + ToFixedString("dark", 20), + Field("color") == ToFixedString("grey", 20), + ToFixedString("dark", 20), + Field("color") == ToFixedString("white", 20), + ToFixedString("light", 20), + ToFixedString("undefined", 20), + ), + "multiIf(color=toFixedString('black',20)," + "toFixedString('dark',20)," + "color=toFixedString('grey',20)," + "toFixedString('dark',20)," + "color=toFixedString('white',20)," + "toFixedString('light',20)," + "toFixedString('undefined',20))", + ), + ] + ) + def test_get_sql(self, func, expected): + self.assertEqual(func.get_sql(), expected) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/clickhouse/test_dates_and_times.py b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/clickhouse/test_dates_and_times.py new file mode 100644 index 0000000000000000000000000000000000000000..135dd7f112131776d76748e15eead1eb81752b59 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/clickhouse/test_dates_and_times.py @@ -0,0 +1,70 @@ +import unittest + +from parameterized import parameterized + +from pypika import Field +from pypika.clickhouse.dates_and_times import ( + AddDays, + AddHours, + AddMinutes, + AddMonths, + AddQuarters, + AddSeconds, + AddWeeks, + AddYears, + FormatDateTime, + SubtractDays, + SubtractHours, + SubtractMinutes, + SubtractMonths, + SubtractQuarters, + SubtractSeconds, + SubtractWeeks, + SubtractYears, + ToYYYYMM, +) + + +class TestFormatDateTime(unittest.TestCase): + @parameterized.expand( + [ + (FormatDateTime(Field("created"), "%V"), "formatDateTime(created,'%V')"), + ( + FormatDateTime(Field("created"), "%Y-%m-%d"), + "formatDateTime(created,'%Y-%m-%d')", + ), + ] + ) + def test_get_sql(self, func, expected): + self.assertEqual(func.get_sql(), expected) + + +class TestAddSubtractDt(unittest.TestCase): + @parameterized.expand( + [ + (AddYears(Field("created"), 1), "addYears(created,1)"), + (AddMonths(Field("created"), 2), "addMonths(created,2)"), + (AddWeeks(Field("created"), 3), "addWeeks(created,3)"), + (AddDays(Field("created"), 4), "addDays(created,4)"), + (AddHours(Field("created"), 5), "addHours(created,5)"), + (AddMinutes(Field("created"), 6), "addMinutes(created,6)"), + (AddSeconds(Field("created"), 7), "addSeconds(created,7)"), + (AddQuarters(Field("created"), 8), "addQuarters(created,8)"), + (SubtractYears(Field("created"), 9), "subtractYears(created,9)"), + (SubtractMonths(Field("created"), 10), "subtractMonths(created,10)"), + (SubtractWeeks(Field("created"), 11), "subtractWeeks(created,11)"), + (SubtractDays(Field("created"), 12), "subtractDays(created,12)"), + (SubtractHours(Field("created"), 13), "subtractHours(created,13)"), + (SubtractHours(Field("created"), 13), "subtractHours(created,13)"), + (SubtractMinutes(Field("created"), 14), "subtractMinutes(created,14)"), + (SubtractSeconds(Field("created"), 15), "subtractSeconds(created,15)"), + (SubtractQuarters(Field("created"), 16), "subtractQuarters(created,16)"), + ] + ) + def test_get_sql(self, func, expected): + self.assertEqual(func.get_sql(), expected) + + +class TestToYYYYMM(unittest.TestCase): + def test_get_sql(self): + self.assertEqual(ToYYYYMM(Field("created").get_sql()), "toYYYYMM(created)") diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/clickhouse/test_nullable_arg.py b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/clickhouse/test_nullable_arg.py new file mode 100644 index 0000000000000000000000000000000000000000..3c6c86207a4d0206b5c0ba80b77fac4cc257fa17 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/clickhouse/test_nullable_arg.py @@ -0,0 +1,24 @@ +import unittest + +from parameterized import parameterized + +from pypika import Field +from pypika.clickhouse.nullable_arg import IfNull +from pypika.clickhouse.type_conversion import ToFixedString + + +class TestSearchString(unittest.TestCase): + @parameterized.expand( + [ + ( + IfNull(Field("name"), Field("login")), + "ifNull(name,login)", + ), + ( + IfNull(Field("builder"), ToFixedString("pypika", 100)), + "ifNull(builder,toFixedString('pypika',100))", + ), + ] + ) + def test_get_sql(self, func, expected): + self.assertEqual(func.get_sql(), expected) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/clickhouse/test_search_string.py b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/clickhouse/test_search_string.py new file mode 100644 index 0000000000000000000000000000000000000000..9778eb32e47d4370c0bfe36dcd875903666d30b6 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/clickhouse/test_search_string.py @@ -0,0 +1,41 @@ +import unittest + +from parameterized import parameterized + +from pypika import Field +from pypika.clickhouse.search_string import ( + Match, + Like, + NotLike, + MultiSearchAny, + MultiMatchAny, +) + + +class TestSearchString(unittest.TestCase): + @parameterized.expand( + [ + (Match(Field("name"), "twheys"), "match(toString(\"name\"),'twheys')"), + (Like(Field("name"), "twheys"), "like(toString(\"name\"),'twheys')"), + (NotLike(Field("name"), "twheys"), "notLike(toString(\"name\"),'twheys')"), + ] + ) + def test_search_string(self, func, expected): + self.assertEqual(func, expected) + + +class TestMultiSearch(unittest.TestCase): + @parameterized.expand( + [ + ( + MultiSearchAny(Field("name"), ["sarah", "connor"]), + "multiSearchAny(toString(\"name\"),['sarah','connor'])", + ), + ( + MultiMatchAny(Field("name"), ["sarah", "connor"]), + "multiMatchAny(toString(\"name\"),['sarah','connor'])", + ), + ] + ) + def test_multi_search_string(self, func, expected): + self.assertEqual(func.get_sql(), expected) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/clickhouse/test_type_conversion.py b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/clickhouse/test_type_conversion.py new file mode 100644 index 0000000000000000000000000000000000000000..9692e17bee901e2629db9a5c77111e145358e8eb --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/clickhouse/test_type_conversion.py @@ -0,0 +1,176 @@ +import unittest + +from parameterized import parameterized + +from pypika import ClickHouseQuery, Field, Table +from pypika.clickhouse.type_conversion import ( + ToDate, + ToDateTime, + ToFixedString, + ToFloat32, + ToFloat64, + ToInt16, + ToInt32, + ToInt64, + ToInt8, + ToString, + ToUInt16, + ToUInt32, + ToUInt64, + ToUInt8, +) + + +class TestBasicTypeConverters(unittest.TestCase): + @parameterized.expand( + [ + ( + 'toString("field_name")', + ToString(Field("field_name")), + ), + ( + 'toInt8("field_name")', + ToInt8(Field("field_name")), + ), + ( + 'toInt16("field_name")', + ToInt16(Field("field_name")), + ), + ( + 'toInt32("field_name")', + ToInt32(Field("field_name")), + ), + ( + 'toInt64("field_name")', + ToInt64(Field("field_name")), + ), + ( + 'toUInt8("field_name")', + ToUInt8(Field("field_name")), + ), + ( + 'toUInt16("field_name")', + ToUInt16(Field("field_name")), + ), + ( + 'toUInt32("field_name")', + ToUInt32(Field("field_name")), + ), + ( + 'toUInt64("field_name")', + ToUInt64(Field("field_name")), + ), + ( + 'toFloat32("field_name")', + ToFloat32(Field("field_name")), + ), + ( + 'toFloat64("field_name")', + ToFloat64(Field("field_name")), + ), + ( + 'toFloat64("field_name")', + ToFloat64(Field("field_name")), + ), + ( + 'toDate("field_name")', + ToDate(Field("field_name")), + ), + ( + 'toDateTime("field_name")', + ToDateTime(Field("field_name")), + ), + ( + 'toFixedString("field_name",100)', + ToFixedString(Field("field_name"), 100), + ), + ] + ) + def test_basic_types_field(self, expected, func): + self.assertEqual(func, expected) + + @parameterized.expand( + [ + ( + "toString('100')", + ToString("100"), + ), + ( + "toInt8('100')", + ToInt8("100"), + ), + ( + "toInt16('100')", + ToInt16("100"), + ), + ( + "toInt32('100')", + ToInt32("100"), + ), + ( + "toInt64('100')", + ToInt64("100"), + ), + ( + "toUInt8('100')", + ToUInt8("100"), + ), + ( + "toUInt16('100')", + ToUInt16("100"), + ), + ( + "toUInt32('100')", + ToUInt32("100"), + ), + ( + "toUInt64('100')", + ToUInt64("100"), + ), + ( + "toFloat32('100')", + ToFloat32("100"), + ), + ( + "toFloat64('100')", + ToFloat64("100"), + ), + ( + "toFloat64('100')", + ToFloat64("100"), + ), + ( + "toDate('100')", + ToDate("100"), + ), + ( + "toDateTime('100')", + ToDateTime("100"), + ), + ( + "toFixedString('100',100)", + ToFixedString("100", 100), + ), + ] + ) + def test_basic_types_value(self, expected, func): + self.assertEqual(func, expected) + + +class TestToFixedString(unittest.TestCase): + def test_get_sql_with_table(self): + table = Table("example") + query = ( + ClickHouseQuery.from_(table) + .select( + table.name, + ) + .where( + table.name == ToFixedString("name", 50), + ) + ) + + self.assertEqual( + 'SELECT "name" FROM "example" WHERE "name"=toFixedString(\'name\',50)', + query.get_sql(), + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/dialects/__init__.py b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/dialects/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/dialects/test_clickhouse.py b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/dialects/test_clickhouse.py new file mode 100644 index 0000000000000000000000000000000000000000..f319c4627bd25d7004894181906a284b8b1c64cf --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/dialects/test_clickhouse.py @@ -0,0 +1,146 @@ +from unittest import TestCase + +from pypika import ( + ClickHouseQuery, + Database, + Table, +) + + +class ClickHouseQueryTests(TestCase): + def test_use_AS_keyword_for_alias(self): + t = Table('abc') + query = ClickHouseQuery.from_(t).select(t.foo.as_('f1'), t.bar.as_('f2')) + self.assertEqual(str(query), 'SELECT "foo" AS "f1","bar" AS "f2" FROM "abc"') + + def test_use_SAMPLE_keyword(self): + t = Table('abc') + query = ClickHouseQuery.from_(t).select(t.foo).sample(10) + self.assertEqual(str(query), 'SELECT "foo" FROM "abc" SAMPLE 10') + + def test_use_SAMPLE_with_offset_keyword(self): + t = Table('abc') + query = ClickHouseQuery.from_(t).select(t.foo).sample(10, 5) + self.assertEqual(str(query), 'SELECT "foo" FROM "abc" SAMPLE 10 OFFSET 5') + + def test_use_FINAL_keyword(self): + t = Table('abc') + query = ClickHouseQuery.from_(t).select(t.foo).final() + self.assertEqual(str(query), 'SELECT "foo" FROM "abc" FINAL') + + +class ClickHouseDeleteTests(TestCase): + table_abc = Table("abc") + + def test_omit_where(self): + q = ClickHouseQuery.from_("abc").delete() + + self.assertEqual('ALTER TABLE "abc" DELETE', str(q)) + + def test_omit_where__table_schema(self): + q = ClickHouseQuery.from_(Table("abc", "schema1")).delete() + + self.assertEqual('ALTER TABLE "schema1"."abc" DELETE', str(q)) + + def test_where_field_equals(self): + q1 = ClickHouseQuery.from_(self.table_abc).where(self.table_abc.foo == self.table_abc.bar).delete() + q2 = ClickHouseQuery.from_(self.table_abc).where(self.table_abc.foo.eq(self.table_abc.bar)).delete() + + self.assertEqual('ALTER TABLE "abc" DELETE WHERE "foo"="bar"', str(q1)) + self.assertEqual('ALTER TABLE "abc" DELETE WHERE "foo"="bar"', str(q2)) + + +class ClickHouseUpdateTests(TestCase): + table_abc = Table("abc") + + def test_update(self): + q = ClickHouseQuery.update(self.table_abc).where(self.table_abc.foo == 0).set("foo", "bar") + + self.assertEqual('ALTER TABLE "abc" UPDATE "foo"=\'bar\' WHERE "foo"=0', str(q)) + + +class ClickHouseDropQuery(TestCase): + table_abc = Table("abc") + database_xyz = Database("mydb") + cluster_name = "mycluster" + + def test_drop_database(self): + q1 = ClickHouseQuery.drop_database(self.database_xyz) + q2 = ClickHouseQuery.drop_database(self.database_xyz).on_cluster(self.cluster_name) + q3 = ClickHouseQuery.drop_database(self.database_xyz).if_exists().on_cluster(self.cluster_name) + + self.assertEqual('DROP DATABASE "mydb"', str(q1)) + self.assertEqual('DROP DATABASE "mydb" ON CLUSTER "mycluster"', str(q2)) + self.assertEqual('DROP DATABASE IF EXISTS "mydb" ON CLUSTER "mycluster"', str(q3)) + + def test_drop_table(self): + q1 = ClickHouseQuery.drop_table(self.table_abc) + q2 = ClickHouseQuery.drop_table(self.table_abc).on_cluster(self.cluster_name) + q3 = ClickHouseQuery.drop_table(self.table_abc).if_exists().on_cluster(self.cluster_name) + + self.assertEqual('DROP TABLE "abc"', str(q1)) + self.assertEqual('DROP TABLE "abc" ON CLUSTER "mycluster"', str(q2)) + self.assertEqual('DROP TABLE IF EXISTS "abc" ON CLUSTER "mycluster"', str(q3)) + + def test_drop_dictionary(self): + q1 = ClickHouseQuery.drop_dictionary("dict") + q2 = ClickHouseQuery.drop_dictionary("dict").on_cluster(self.cluster_name) + q3 = ClickHouseQuery.drop_dictionary("dict").if_exists().on_cluster(self.cluster_name) + + self.assertEqual('DROP DICTIONARY "dict"', str(q1)) + self.assertEqual('DROP DICTIONARY "dict"', str(q2)) # NO CLUSTER + self.assertEqual('DROP DICTIONARY IF EXISTS "dict"', str(q3)) # NO CLUSTER + + def test_drop_other(self): + q1 = ClickHouseQuery.drop_quota("myquota") + q2 = ClickHouseQuery.drop_user("myuser") + q3 = ClickHouseQuery.drop_view("myview") + + self.assertEqual('DROP QUOTA "myquota"', str(q1)) + self.assertEqual('DROP USER "myuser"', str(q2)) + self.assertEqual('DROP VIEW "myview"', str(q3)) + + +class DistinctOnTests(TestCase): + table_abc = Table("abc") + + def test_distinct_on(self): + q = ClickHouseQuery.from_(self.table_abc).distinct_on("lname", self.table_abc.fname).select("lname", "id") + + self.assertEqual('''SELECT DISTINCT ON("lname","fname") "lname","id" FROM "abc"''', str(q)) + + +class LimitByTests(TestCase): + table_abc = Table("abc") + + def test_limit_by(self): + q = ClickHouseQuery.from_(self.table_abc).limit_by(1, "a", self.table_abc.b).select("a", "b", "c") + + self.assertEqual('''SELECT "a","b","c" FROM "abc" LIMIT 1 BY ("a","b")''', str(q)) + + def test_limit_offset_by(self): + q = ClickHouseQuery.from_(self.table_abc).limit_offset_by(1, 2, "a", self.table_abc.b).select("a", "b", "c") + + self.assertEqual('''SELECT "a","b","c" FROM "abc" LIMIT 1 OFFSET 2 BY ("a","b")''', str(q)) + + def test_limit_offset0_by(self): + q = ClickHouseQuery.from_(self.table_abc).limit_offset_by(1, 0, "a", self.table_abc.b).select("a", "b", "c") + + self.assertEqual('''SELECT "a","b","c" FROM "abc" LIMIT 1 BY ("a","b")''', str(q)) + + def test_rename_table(self): + table_join = Table("join") + + q = ( + ClickHouseQuery.from_(self.table_abc) + .join(table_join) + .using("a") + .limit_by(1, self.table_abc.a, table_join.a) + .select(self.table_abc.b, table_join.b) + ) + q = q.replace_table(self.table_abc, Table("xyz")) + + self.assertEqual( + '''SELECT "xyz"."b","join"."b" FROM "xyz" JOIN "join" USING ("a") LIMIT 1 BY ("xyz"."a","join"."a")''', + str(q), + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/dialects/test_mssql.py b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/dialects/test_mssql.py new file mode 100644 index 0000000000000000000000000000000000000000..7cf53b228f413a8c7cd3e414fef5522a82f99b29 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/dialects/test_mssql.py @@ -0,0 +1,81 @@ +import unittest + +from pypika import Table +from pypika.analytics import Count +from pypika.dialects import MSSQLQuery +from pypika.utils import QueryException + + +class SelectTests(unittest.TestCase): + def test_normal_select(self): + q = MSSQLQuery.from_("abc").select("def") + + self.assertEqual('SELECT "def" FROM "abc"', str(q)) + + def test_distinct_select(self): + q = MSSQLQuery.from_("abc").select("def").distinct() + + self.assertEqual('SELECT DISTINCT "def" FROM "abc"', str(q)) + + def test_top_distinct_select(self): + q = MSSQLQuery.from_("abc").select("def").top(10).distinct() + + self.assertEqual('SELECT DISTINCT TOP (10) "def" FROM "abc"', str(q)) + + def test_top_select(self): + q = MSSQLQuery.from_("abc").select("def").top(10) + + self.assertEqual('SELECT TOP (10) "def" FROM "abc"', str(q)) + + def test_top_with_ties_select(self): + q = MSSQLQuery.from_("abc").select("def").top(10, with_ties=True) + + self.assertEqual('SELECT TOP (10) WITH TIES "def" FROM "abc"', str(q)) + + def test_top_percent_select(self): + q = MSSQLQuery.from_("abc").select("def").top(10, percent=True) + + self.assertEqual('SELECT TOP (10) PERCENT "def" FROM "abc"', str(q)) + + def test_top_percent_invalid_range(self): + for invalid_top in [-1, 101]: + with self.assertRaisesRegex( + QueryException, "TOP value must be between 0 and 100 when `percent` is specified" + ): + MSSQLQuery.from_("abc").select("def").top(invalid_top, percent=True) + + def test_top_select_non_int(self): + with self.assertRaisesRegex(QueryException, "TOP value must be an integer"): + MSSQLQuery.from_("abc").select("def").top("a") + + def test_limit(self): + q = MSSQLQuery.from_("abc").select("def").orderby("def").limit(10) + + self.assertEqual('SELECT "def" FROM "abc" ORDER BY "def" OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY', str(q)) + + def test_offset(self): + q = MSSQLQuery.from_("abc").select("def").orderby("def").offset(10) + + self.assertEqual('SELECT "def" FROM "abc" ORDER BY "def" OFFSET 10 ROWS', str(q)) + + def test_limit_with_offset(self): + q = MSSQLQuery.from_("abc").select("def").orderby("def").limit(10).offset(10) + + self.assertEqual('SELECT "def" FROM "abc" ORDER BY "def" OFFSET 10 ROWS FETCH NEXT 10 ROWS ONLY', str(q)) + + def test_groupby_alias_False_does_not_group_by_alias_with_standard_query(self): + t = Table('table1') + col = t.abc.as_('a') + q = MSSQLQuery.from_(t).select(col, Count('*')).groupby(col) + + self.assertEqual('SELECT "abc" "a",COUNT(\'*\') FROM "table1" GROUP BY "abc"', str(q)) + + def test_groupby_alias_False_does_not_group_by_alias_when_subqueries_are_present(self): + t = Table('table1') + subquery = MSSQLQuery.from_(t).select(t.abc) + col = subquery.abc.as_('a') + q = MSSQLQuery.from_(subquery).select(col, Count('*')).groupby(col) + + self.assertEqual( + 'SELECT "sq0"."abc" "a",COUNT(\'*\') FROM (SELECT "abc" FROM "table1") "sq0" GROUP BY "sq0"."abc"', str(q) + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/dialects/test_mysql.py b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/dialects/test_mysql.py new file mode 100644 index 0000000000000000000000000000000000000000..619d064adcdf8b5ff9ecd054fa4ab00eff1d69b3 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/dialects/test_mysql.py @@ -0,0 +1,91 @@ +import unittest + +from pypika import MySQLQuery, QueryException, Table, Column + + +class SelectTests(unittest.TestCase): + table_abc = Table("abc") + + def test_normal_select(self): + q = MySQLQuery.from_("abc").select("def") + + self.assertEqual("SELECT `def` FROM `abc`", str(q)) + + def test_distinct_select(self): + q = MySQLQuery.from_("abc").select("def").distinct() + + self.assertEqual("SELECT DISTINCT `def` FROM `abc`", str(q)) + + def test_modifier_select(self): + q = MySQLQuery.from_("abc").select("def").select("ghi").modifier("SQL_CALC_FOUND_ROWS") + + self.assertEqual("SELECT SQL_CALC_FOUND_ROWS `def`,`ghi` FROM `abc`", str(q)) + + def test_multiple_modifier_select(self): + q = MySQLQuery.from_("abc").select("def").modifier("HIGH_PRIORITY").modifier("SQL_CALC_FOUND_ROWS") + + self.assertEqual("SELECT HIGH_PRIORITY SQL_CALC_FOUND_ROWS `def` FROM `abc`", str(q)) + + +class UpdateTests(unittest.TestCase): + table_abc = Table("abc") + + def test_update(self): + q = MySQLQuery.into("abc").insert(1, [1, "a", True]) + + self.assertEqual("INSERT INTO `abc` VALUES (1,[1,'a',true])", str(q)) + + def test_on_duplicate_key_ignore_update(self): + q = MySQLQuery.into("abc").insert(1, [1, "a", True]).on_duplicate_key_ignore() + + self.assertEqual("INSERT INTO `abc` VALUES (1,[1,'a',true]) ON DUPLICATE KEY IGNORE", str(q)) + + def test_on_duplicate_key_update_update(self): + q = MySQLQuery.into("abc").insert(1, [1, "a", True]).on_duplicate_key_update(self.table_abc.a, 'b') + + self.assertEqual("INSERT INTO `abc` VALUES (1,[1,'a',true]) ON DUPLICATE KEY UPDATE `a`='b'", str(q)) + + def test_conflict_handlers_update(self): + with self.assertRaises(QueryException): + ( + MySQLQuery.into("abc") + .insert(1, [1, "a", True]) + .on_duplicate_key_ignore() + .on_duplicate_key_update(self.table_abc.a, 'b') + ) + + +class LoadCSVTests(unittest.TestCase): + table_abc = Table("abc") + + def test_load_from_file(self): + q1 = MySQLQuery.load("/path/to/file").into("abc") + + q2 = MySQLQuery.load("/path/to/file").into(self.table_abc) + + self.assertEqual( + "LOAD DATA LOCAL INFILE '/path/to/file' INTO TABLE `abc` FIELDS TERMINATED BY ','", + str(q1), + ) + self.assertEqual( + "LOAD DATA LOCAL INFILE '/path/to/file' INTO TABLE `abc` FIELDS TERMINATED BY ','", + str(q2), + ) + + +class TableTests(unittest.TestCase): + table_abc = Table("abc") + + def test_create_table(self): + q = MySQLQuery.create_table(self.table_abc).columns(Column("id", "INT")) + self.assertEqual( + 'CREATE TABLE `abc` (`id` INT)', + str(q), + ) + + def test_drop_table(self): + q = MySQLQuery.drop_table(self.table_abc) + self.assertEqual( + 'DROP TABLE `abc`', + str(q), + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/dialects/test_oracle.py b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/dialects/test_oracle.py new file mode 100644 index 0000000000000000000000000000000000000000..21b54f16fd5d3518b5c767d3605068637898a73f --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/dialects/test_oracle.py @@ -0,0 +1,51 @@ +import unittest + +from pypika import OracleQuery, Table +from pypika.analytics import Count + + +class SelectTests(unittest.TestCase): + def test_groupby_alias_False_does_not_group_by_alias_with_standard_query(self): + t = Table('table1') + col = t.abc.as_('a') + q = OracleQuery.from_(t).select(col, Count('*')).groupby(col) + + self.assertEqual('SELECT abc a,COUNT(\'*\') FROM table1 GROUP BY abc', str(q)) + + def test_groupby_alias_False_does_not_group_by_alias_when_subqueries_are_present(self): + t = Table('table1') + subquery = OracleQuery.from_(t).select(t.abc) + col = subquery.abc.as_('a') + q = OracleQuery.from_(subquery).select(col, Count('*')).groupby(col) + + self.assertEqual('SELECT sq0.abc a,COUNT(\'*\') FROM (SELECT abc FROM table1) sq0 GROUP BY sq0.abc', str(q)) + + def test_limit_query(self): + t = Table('table1') + limit = 5 + q = OracleQuery.from_(t).select(t.test).limit(limit) + + self.assertEqual(f'SELECT test FROM table1 FETCH NEXT {limit} ROWS ONLY', str(q)) + + def test_offset_query(self): + t = Table('table1') + offset = 5 + q = OracleQuery.from_(t).select(t.test).offset(offset) + + self.assertEqual(f'SELECT test FROM table1 OFFSET {offset} ROWS', str(q)) + + def test_limit_offset_query(self): + t = Table('table1') + limit = 5 + offset = 5 + q = OracleQuery.from_(t).select(t.test).limit(limit).offset(offset) + + self.assertEqual(f'SELECT test FROM table1 OFFSET {offset} ROWS FETCH NEXT {limit} ROWS ONLY', str(q)) + + def test_fetch_next_method_deprecated(self): + with self.assertWarns(DeprecationWarning): + t = Table('table1') + limit = 5 + q = OracleQuery.from_(t).select(t.test).fetch_next(limit) + + self.assertEqual(f'SELECT test FROM table1 FETCH NEXT {limit} ROWS ONLY', str(q)) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/dialects/test_postgresql.py b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/dialects/test_postgresql.py new file mode 100644 index 0000000000000000000000000000000000000000..437eed03e120485ed2a357a4c2d92426f1466e14 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/dialects/test_postgresql.py @@ -0,0 +1,262 @@ +import unittest +from collections import OrderedDict + +from pypika import ( + Array, + Field, + JSON, + QueryException, + Table, +) +from pypika.dialects import PostgreSQLQuery + + +class InsertTests(unittest.TestCase): + table_abc = Table("abc") + + def test_array_keyword(self): + q = PostgreSQLQuery.into(self.table_abc).insert(1, [1, "a", True]) + + self.assertEqual("INSERT INTO \"abc\" VALUES (1,ARRAY[1,'a',true])", str(q)) + + +class JSONObjectTests(unittest.TestCase): + def test_alias_set_correctly(self): + table = Table('jsonb_table') + q = PostgreSQLQuery.from_('abc').select(table.value.get_text_value('a').as_('name')) + + self.assertEqual('''SELECT "value"->>'a' "name" FROM "abc"''', str(q)) + + def test_json_value_from_dict(self): + q = PostgreSQLQuery.select(JSON({"a": "foo"})) + + self.assertEqual('SELECT \'{"a":"foo"}\'', str(q)) + + def test_json_value_from_array_num(self): + q = PostgreSQLQuery.select(JSON([1, 2, 3])) + + self.assertEqual("SELECT '[1,2,3]'", str(q)) + + def test_json_value_from_array_str(self): + q = PostgreSQLQuery.select(JSON(["a", "b", "c"])) + + self.assertEqual('SELECT \'["a","b","c"]\'', str(q)) + + def test_json_value_from_dict_recursive(self): + q = PostgreSQLQuery.select(JSON({"a": "z", "b": {"c": "foo"}, "d": 1})) + + # gotta split this one up to avoid the indeterminate order + sql = str(q) + start, end = 9, -2 + self.assertEqual("SELECT '{}'", sql[:start] + sql[end:]) + + members_set = set(sql[start:end].split(",")) + self.assertSetEqual({'"a":"z"', '"b":{"c":"foo"}', '"d":1'}, members_set) + + +class JSONOperatorsTests(unittest.TestCase): + # reference https://www.postgresql.org/docs/9.5/functions-json.html + table_abc = Table("abc") + + def test_get_json_value_by_key(self): + q = PostgreSQLQuery.from_(self.table_abc).select("*").where(self.table_abc.json.get_json_value("dates")) + + self.assertEqual('SELECT * FROM "abc" WHERE "json"->\'dates\'', str(q)) + + def test_get_json_value_by_index(self): + q = PostgreSQLQuery.from_(self.table_abc).select("*").where(self.table_abc.json.get_json_value(1)) + + self.assertEqual('SELECT * FROM "abc" WHERE "json"->1', str(q)) + + def test_get_text_value_by_key(self): + q = PostgreSQLQuery.from_(self.table_abc).select("*").where(self.table_abc.json.get_text_value("dates")) + + self.assertEqual('SELECT * FROM "abc" WHERE "json"->>\'dates\'', str(q)) + + def test_get_text_value_by_index(self): + q = PostgreSQLQuery.from_(self.table_abc).select("*").where(self.table_abc.json.get_text_value(1)) + + self.assertEqual('SELECT * FROM "abc" WHERE "json"->>1', str(q)) + + def test_get_path_json_value(self): + q = PostgreSQLQuery.from_(self.table_abc).select("*").where(self.table_abc.json.get_path_json_value("{a,b}")) + + self.assertEqual('SELECT * FROM "abc" WHERE "json"#>\'{a,b}\'', str(q)) + + def test_get_path_text_value(self): + q = PostgreSQLQuery.from_(self.table_abc).select("*").where(self.table_abc.json.get_path_text_value("{a,b}")) + + self.assertEqual('SELECT * FROM "abc" WHERE "json"#>>\'{a,b}\'', str(q)) + + +class JSONBOperatorsTests(unittest.TestCase): + # reference https://www.postgresql.org/docs/9.5/functions-json.html + table_abc = Table("abc") + + def test_json_contains_for_json(self): + q = PostgreSQLQuery.select(JSON({"a": 1, "b": 2}).contains({"a": 1})) + + # gotta split this one up to avoid the indeterminate order + sql = str(q) + start, end = 9, -13 + self.assertEqual("SELECT '{}'@>'{\"a\":1}'", sql[:start] + sql[end:]) + + members_set = set(sql[start:end].split(",")) + self.assertSetEqual({'"a":1', '"b":2'}, members_set) + + def test_json_contains_for_field(self): + q = ( + PostgreSQLQuery.from_(self.table_abc) + .select("*") + .where(self.table_abc.json.contains({"dates": "2018-07-10 - 2018-07-17"})) + ) + + self.assertEqual( + "SELECT * " 'FROM "abc" ' 'WHERE "json"@>\'{"dates":"2018-07-10 - 2018-07-17"}\'', + str(q), + ) + + def test_json_contained_by_using_str_arg(self): + q = ( + PostgreSQLQuery.from_(self.table_abc) + .select("*") + .where( + self.table_abc.json.contained_by( + OrderedDict( + [ + ("dates", "2018-07-10 - 2018-07-17"), + ("imported", "8"), + ] + ) + ) + ) + ) + self.assertEqual( + 'SELECT * FROM "abc" ' 'WHERE "json"<@\'{"dates":"2018-07-10 - 2018-07-17","imported":"8"}\'', + str(q), + ) + + def test_json_contained_by_using_list_arg(self): + q = ( + PostgreSQLQuery.from_(self.table_abc) + .select("*") + .where(self.table_abc.json.contained_by(["One", "Two", "Three"])) + ) + + self.assertEqual('SELECT * FROM "abc" WHERE "json"<@\'["One","Two","Three"]\'', str(q)) + + def test_json_contained_by_with_complex_criterion(self): + q = ( + PostgreSQLQuery.from_(self.table_abc) + .select("*") + .where(self.table_abc.json.contained_by(["One", "Two", "Three"]) & (self.table_abc.id == 26)) + ) + + self.assertEqual( + 'SELECT * FROM "abc" WHERE "json"<@\'["One","Two","Three"]\' AND "id"=26', + str(q), + ) + + def test_json_has_key(self): + q = PostgreSQLQuery.from_(self.table_abc).select("*").where(self.table_abc.json.has_key("dates")) + + self.assertEqual('SELECT * FROM "abc" WHERE "json"?\'dates\'', str(q)) + + def test_json_has_keys(self): + q = PostgreSQLQuery.from_(self.table_abc).select("*").where(self.table_abc.json.has_keys(["dates", "imported"])) + + self.assertEqual("SELECT * FROM \"abc\" WHERE \"json\"?&ARRAY['dates','imported']", str(q)) + + def test_json_has_any_keys(self): + q = ( + PostgreSQLQuery.from_(self.table_abc) + .select("*") + .where(self.table_abc.json.has_any_keys(["dates", "imported"])) + ) + + self.assertEqual("SELECT * FROM \"abc\" WHERE \"json\"?|ARRAY['dates','imported']", str(q)) + + def test_subnet_contains_inet(self): + q = ( + PostgreSQLQuery.from_(self.table_abc) + .select(self.table_abc.a.lshift(2)) + .where(self.table_abc.cidr >> "1.1.1.1") + ) + + self.assertEqual("SELECT \"a\"<<2 FROM \"abc\" WHERE \"cidr\">>'1.1.1.1'", str(q)) + + +class DistinctOnTests(unittest.TestCase): + table_abc = Table("abc") + + def test_distinct_on(self): + q = PostgreSQLQuery.from_(self.table_abc).distinct_on("lname", self.table_abc.fname).select("lname", "id") + + self.assertEqual('''SELECT DISTINCT ON("lname","fname") "lname","id" FROM "abc"''', str(q)) + + +class ArrayTests(unittest.TestCase): + def test_array_syntax(self): + tb = Table("tb") + q = PostgreSQLQuery.from_(tb).select(Array(1, "a", ["b", 2, 3])) + + self.assertEqual(str(q), "SELECT ARRAY[1,'a',ARRAY['b',2,3]] FROM \"tb\"") + + def test_render_alias_in_array_sql(self): + tb = Table("tb") + + q = PostgreSQLQuery.from_(tb).select(Array(tb.col).as_("different_name")) + self.assertEqual(str(q), 'SELECT ARRAY["col"] "different_name" FROM "tb"') + + +class ReturningClauseTests(unittest.TestCase): + @classmethod + def setUpClass(cls) -> None: + super().setUpClass() + cls.table_abc = Table('abc') + + def test_returning_from_missing_table_raises_queryexception(self): + field_from_diff_table = Field('xyz', table=Table('other')) + + with self.assertRaisesRegex(QueryException, "You can't return from other tables"): + ( + PostgreSQLQuery.from_(self.table_abc) + .where(self.table_abc.foo == self.table_abc.bar) + .delete() + .returning(field_from_diff_table) + ) + + def test_queryexception_if_returning_used_on_invalid_query(self): + with self.assertRaisesRegex(QueryException, "Returning can't be used in this query"): + PostgreSQLQuery.from_(self.table_abc).select('abc').returning('abc') + + def test_no_queryexception_if_returning_used_on_valid_query_type(self): + # No exceptions for insert, update and delete queries + with self.subTest('DELETE'): + PostgreSQLQuery.from_(self.table_abc).where(self.table_abc.foo == self.table_abc.bar).delete().returning( + "id" + ) + with self.subTest('UPDATE'): + PostgreSQLQuery.update(self.table_abc).where(self.table_abc.foo == 0).set("foo", "bar").returning("id") + with self.subTest('INSERT'): + PostgreSQLQuery.into(self.table_abc).insert('abc').returning('abc') + + def test_return_field_from_join_table(self): + new_table = Table('xyz') + q = ( + PostgreSQLQuery.update(self.table_abc) + .join(new_table) + .on(new_table.id == self.table_abc.xyz) + .where(self.table_abc.foo == 0) + .set("foo", "bar") + .returning(new_table.a) + ) + + self.assertEqual( + 'UPDATE "abc" ' + 'JOIN "xyz" ON "xyz"."id"="abc"."xyz" ' + 'SET "foo"=\'bar\' ' + 'WHERE "abc"."foo"=0 ' + 'RETURNING "xyz"."a"', + str(q), + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/dialects/test_snowflake.py b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/dialects/test_snowflake.py new file mode 100644 index 0000000000000000000000000000000000000000..5ac08b2d8b8b5496ed6f3510acf4be1ec7893405 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/dialects/test_snowflake.py @@ -0,0 +1,58 @@ +import unittest + +from pypika import ( + Tables, + functions as fn, + Column, +) +from pypika.dialects import SnowflakeQuery + + +class QuoteTests(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_use_double_quotes_on_alias_but_not_on_terms(self): + q = SnowflakeQuery.from_(self.table_abc).select(self.table_abc.a.as_("bar")) + + self.assertEqual('SELECT a "bar" FROM abc', q.get_sql(with_namespace=True)) + + def test_use_double_quotes_on_alias_but_not_on_terms_with_joins(self): + foo = self.table_abc.as_("foo") + bar = self.table_efg.as_("bar") + + q = SnowflakeQuery.from_(foo).join(bar).on(foo.fk == bar.id).select(foo.a, bar.b) + + self.assertEqual( + "SELECT foo.a,bar.b " 'FROM abc "foo" ' 'JOIN efg "bar" ' "ON foo.fk=bar.id", + q.get_sql(with_namespace=True), + ) + + def test_use_double_quotes_on_alias_but_not_on_terms(self): + idx = self.table_abc.index.as_("idx") + val = fn.Sum(self.table_abc.value).as_("val") + q = SnowflakeQuery.from_(self.table_abc).select(idx, val).groupby(idx).orderby(idx) + + self.assertEqual( + 'SELECT index "idx",SUM(value) "val" ' "FROM abc " 'GROUP BY "idx" ' 'ORDER BY "idx"', + q.get_sql(with_namespace=True), + ) + + def test_dont_use_double_quotes_on_joining_queries(self): + foo = self.table_abc + bar = self.table_efg + q1 = SnowflakeQuery.from_(foo).select(foo.b) + q2 = SnowflakeQuery.from_(bar).select(bar.b) + q = SnowflakeQuery.from_(q1).join(q2).on(q1.b == q2.b).select("*") + + self.assertEqual( + "SELECT * " 'FROM (SELECT b FROM abc) sq0 ' 'JOIN (SELECT b FROM efg) sq1 ' "ON sq0.b=sq1.b", + q.get_sql(), + ) + + def test_dont_use_double_quotes_on_create_queries(self): + q = SnowflakeQuery.create_table(self.table_abc).columns(Column("id", "INT")) + self.assertEqual("CREATE TABLE abc (id INT)", q.get_sql()) + + def test_dont_use_double_quotes_on_drop_queries(self): + q = SnowflakeQuery.drop_table(self.table_abc) + self.assertEqual("DROP TABLE abc", q.get_sql()) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/dialects/test_sqllite.py b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/dialects/test_sqllite.py new file mode 100644 index 0000000000000000000000000000000000000000..104a7235b6ea2d46fd365989f68c5d081eb20076 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/dialects/test_sqllite.py @@ -0,0 +1,35 @@ +import unittest + +from pypika import Table +from pypika.dialects import SQLLiteQuery + + +class SelectTests(unittest.TestCase): + table_abc = Table("abc") + + def test_bool_true_as_one(self): + q = SQLLiteQuery.from_("abc").select(True) + + self.assertEqual('SELECT 1 FROM "abc"', str(q)) + + def test_bool_false_as_zero(self): + q = SQLLiteQuery.from_("abc").select(False) + + self.assertEqual('SELECT 0 FROM "abc"', str(q)) + + +class ReplaceTests(unittest.TestCase): + def test_normal_replace(self): + query = SQLLiteQuery.into("abc").replace("v1", "v2", "v3") + expected_output = "REPLACE INTO \"abc\" VALUES ('v1','v2','v3')" + self.assertEqual(expected_output, str(query)) + + def test_replace_subquery(self): + query = SQLLiteQuery.into("abc").replace(SQLLiteQuery.from_("def").select("f1", "f2")) + expected_output = 'REPLACE INTO "abc" VALUES ((SELECT "f1","f2" FROM "def"))' + self.assertEqual(expected_output, str(query)) + + def test_insert_or_replace(self): + query = SQLLiteQuery.into("abc").insert_or_replace("v1", "v2", "v3") + expected_output = "INSERT OR REPLACE INTO \"abc\" VALUES ('v1','v2','v3')" + self.assertEqual(expected_output, str(query)) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/dialects/test_vertica.py b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/dialects/test_vertica.py new file mode 100644 index 0000000000000000000000000000000000000000..61985bfc244fcd663e7d8a904b4645901f3abdfc --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/dialects/test_vertica.py @@ -0,0 +1,93 @@ +import unittest + +from pypika import Columns, Table, Tables, VerticaQuery + + +class VerticaQueryTests(unittest.TestCase): + table_abc = Table("abc") + + def test_select_query_with_hint(self): + q = VerticaQuery.from_("abc").select("*").hint("test_hint") + + self.assertEqual('SELECT /*+label(test_hint)*/ * FROM "abc"', str(q)) + + def test_insert_query_with_hint(self): + query = VerticaQuery.into(self.table_abc).insert(1).hint("test_hint") + + self.assertEqual('INSERT /*+label(test_hint)*/ INTO "abc" VALUES (1)', str(query)) + + def test_update_query_with_hint(self): + q = VerticaQuery.update(self.table_abc).set("foo", "bar").hint("test_hint") + + self.assertEqual('UPDATE /*+label(test_hint)*/ "abc" SET "foo"=\'bar\'', str(q)) + + def test_delete_query_with_hint(self): + q = VerticaQuery.from_("abc").delete().hint("test_hint") + + self.assertEqual('DELETE /*+label(test_hint)*/ FROM "abc"', str(q)) + + +class CopyCSVTests(unittest.TestCase): + table_abc = Table("abc") + + def test_copy_from_file(self): + with self.subTest("with table as string"): + q = VerticaQuery.from_file("/path/to/file").copy_("abc") + + self.assertEqual( + "COPY \"abc\" FROM LOCAL '/path/to/file' PARSER fcsvparser(header=false)", + str(q), + ) + + with self.subTest("with table"): + q = VerticaQuery.from_file("/path/to/file").copy_(self.table_abc) + + self.assertEqual( + "COPY \"abc\" FROM LOCAL '/path/to/file' PARSER fcsvparser(header=false)", + str(q), + ) + + +class CreateTemporaryTableTests(unittest.TestCase): + new_table, existing_table = Tables("abc", "efg") + foo, bar = Columns(("a", "INT"), ("b", "VARCHAR(100)")) + select = VerticaQuery.from_(existing_table).select(existing_table.foo, existing_table.bar) + + def test_create_local_temporary_table(self): + with self.subTest("with columns"): + q = VerticaQuery.create_table(self.new_table).temporary().local().columns(self.foo, self.bar) + + self.assertEqual('CREATE LOCAL TEMPORARY TABLE "abc" ("a" INT,"b" VARCHAR(100))', str(q)) + + with self.subTest("with select"): + q = VerticaQuery.create_table(self.new_table).temporary().local().as_select(self.select) + + self.assertEqual( + 'CREATE LOCAL TEMPORARY TABLE "abc" AS (SELECT "foo","bar" FROM "efg")', + str(q), + ) + + def test_create_local_table_without_temporary_raises_error(self): + with self.assertRaises(AttributeError): + VerticaQuery.create_table(self.new_table).local() + + def test_create_temporary_table_preserve_rows(self): + with self.subTest("with columns"): + q = VerticaQuery.create_table(self.new_table).temporary().preserve_rows().columns(self.foo, self.bar) + + self.assertEqual( + 'CREATE TEMPORARY TABLE "abc" ("a" INT,"b" VARCHAR(100)) ON COMMIT PRESERVE ROWS', + str(q), + ) + + with self.subTest("with select"): + q = VerticaQuery.create_table(self.new_table).temporary().preserve_rows().as_select(self.select) + + self.assertEqual( + 'CREATE TEMPORARY TABLE "abc" ON COMMIT PRESERVE ROWS AS (SELECT "foo","bar" FROM "efg")', + str(q), + ) + + def test_create_table_preserve_rows_without_temporary_raises_error(self): + with self.assertRaises(AttributeError): + VerticaQuery.create_table(self.new_table).preserve_rows() diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/test_aggregate.py b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/test_aggregate.py new file mode 100644 index 0000000000000000000000000000000000000000..1c627d8e9c2d65410c67cf2c39974949b0720a0e --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/test_aggregate.py @@ -0,0 +1,122 @@ +import unittest + +from pypika import ( + Case, + Field, + Table, + functions as fn, +) +from pypika.terms import ( + Negative, + ValueWrapper, +) + + +class IsAggregateTests(unittest.TestCase): + def test__field_is_not_aggregate(self): + v = Field("foo") + self.assertFalse(v.is_aggregate) + + def test__constant_is_aggregate_none(self): + v = ValueWrapper(100) + self.assertIsNone(v.is_aggregate) + + def test__constant_arithmetic_is_aggregate_none(self): + v = ValueWrapper(100) + ValueWrapper(100) + self.assertIsNone(v.is_aggregate) + + def test__field_arithmetic_is_not_aggregate(self): + v = Field("foo") + Field("bar") + self.assertFalse(v.is_aggregate) + + def test__field_arithmetic_constant_is_not_aggregate(self): + v = Field("foo") + 1 + self.assertFalse(v.is_aggregate) + + def test__agg_func_is_aggregate(self): + v = fn.Sum(Field("foo")) + self.assertTrue(v.is_aggregate) + + def test__negative_agg_func_is_aggregate(self): + v = Negative(fn.Sum(Field("foo"))) + self.assertTrue(v.is_aggregate) + + def test__agg_func_arithmetic_is_aggregate(self): + v = fn.Sum(Field("foo")) / fn.Sum(Field("foo")) + self.assertTrue(v.is_aggregate) + + def test__mixed_func_arithmetic_is_not_aggregate(self): + v = Field("foo") / fn.Sum(Field("foo")) + self.assertFalse(v.is_aggregate) + + def test__func_arithmetic_constant_is_not_aggregate(self): + v = 1 / fn.Sum(Field("foo")) + self.assertTrue(v.is_aggregate) + + def test__agg_case_criterion_is_aggregate(self): + v = Case().when(fn.Sum(Field("foo")) > 666, 'More than 666').else_('Less than 666') + + self.assertTrue(v.is_aggregate) + + def test__agg_case_is_aggregate(self): + v = ( + Case() + .when(Field("foo") == 1, fn.Sum(Field("bar"))) + .when(Field("foo") == 2, fn.Sum(Field("fiz"))) + .else_(fn.Sum(Field("fiz"))) + ) + + self.assertTrue(v.is_aggregate) + + def test__mixed_case_is_not_aggregate(self): + v = Case().when(Field("foo") == 1, fn.Sum(Field("bar"))).when(Field("foo") == 2, Field("fiz")) + + self.assertFalse(v.is_aggregate) + + def test__case_mixed_else_is_not_aggregate(self): + v = ( + Case() + .when(Field("foo") == 1, fn.Sum(Field("bar"))) + .when(Field("foo") == 2, fn.Sum(Field("fiz"))) + .else_(Field("fiz")) + ) + + self.assertFalse(v.is_aggregate) + + def test__case_mixed_constant_is_not_aggregate(self): + v = Case().when(Field("foo") == 1, fn.Sum(Field("bar"))).when(Field("foo") == 2, fn.Sum(Field("fiz"))).else_(1) + + self.assertTrue(v.is_aggregate) + + def test__case_with_field_is_not_aggregate(self): + v = Case().when(Field("foo") == 1, 1).when(Field("foo") == 2, 2).else_(3) + + self.assertFalse(v.is_aggregate) + + def test__case_with_single_aggregate_field_in_one_criterion_is_aggregate(self): + v = Case().when(Field("foo") == 1, 1).when(fn.Sum(Field("foo")) == 2, 2).else_(3) + + self.assertTrue(v.is_aggregate) + + def test__non_aggregate_function_with_aggregated_arg(self): + t = Table("abc") + expr = fn.Sqrt(fn.Sum(t.a)) + + self.assertTrue(expr.is_aggregate) + + def test_complicated(self): + t = Table("abc") + is_placebo = t.campaign_extra_info == "placebo" + + pixel_mobile_search = Case().when(is_placebo, t.action_fb_pixel_search + t.action_fb_mobile_search) + unique_impressions = Case().when(is_placebo, t.unique_impressions) + + v = fn.Sum(pixel_mobile_search) / fn.Sum(unique_impressions) - 1.96 * fn.Sqrt( + 1 + / fn.Sum(unique_impressions) + * fn.Sum(pixel_mobile_search) + / fn.Sum(unique_impressions) + * (1 - fn.Sum(pixel_mobile_search) / fn.Sum(unique_impressions)) + ) + + self.assertTrue(v.is_aggregate) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/test_analytic_queries.py b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/test_analytic_queries.py new file mode 100644 index 0000000000000000000000000000000000000000..6a35ab854b30e3b0f91e633b3349706a22e0a2fd --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/test_analytic_queries.py @@ -0,0 +1,610 @@ +import unittest + +from pypika import Criterion, JoinType, Order, Query, Tables, analytics as an +from pypika.analytics import Lag, Lead + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + + +class RankTests(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_rank(self): + expr = an.Rank().over(self.table_abc.foo).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " "RANK() " 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_dense_rank(self): + expr = an.DenseRank().over(self.table_abc.foo).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " "DENSE_RANK() " 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_row_number(self): + expr = an.RowNumber().over(self.table_abc.foo).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " "ROW_NUMBER() " 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_rank_with_alias(self): + expr = an.Rank().over(self.table_abc.foo).orderby(self.table_abc.date).as_("rank") + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " "RANK() " 'OVER(PARTITION BY "foo" ORDER BY "date") "rank" ' 'FROM "abc"', + str(q), + ) + + def test_multiple_partitions(self): + expr = an.Rank().orderby(self.table_abc.date).over(self.table_abc.foo, self.table_abc.bar) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " "RANK() " 'OVER(PARTITION BY "foo","bar" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_ntile_no_partition_or_order_invalid_sql(self): + expr = an.NTile(5) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual("SELECT " "NTILE(5) " 'FROM "abc"', str(q)) + + def test_ntile_with_partition(self): + expr = an.NTile(5).over(self.table_abc.foo) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual("SELECT " "NTILE(5) " 'OVER(PARTITION BY "foo") ' 'FROM "abc"', str(q)) + + def test_ntile_with_order(self): + expr = an.NTile(5).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual("SELECT " "NTILE(5) " 'OVER(ORDER BY "date") ' 'FROM "abc"', str(q)) + + def test_ntile_with_partition_and_order(self): + expr = an.NTile(5).over(self.table_abc.foo).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " "NTILE(5) " 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_first_value(self): + expr = an.FirstValue(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'FIRST_VALUE("fizz") ' 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_first_value_ignore_nulls(self): + expr = an.FirstValue(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).ignore_nulls() + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'FIRST_VALUE("fizz" IGNORE NULLS) ' 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_first_value_ignore_nulls_first(self): + expr = an.FirstValue(self.table_abc.fizz).ignore_nulls().over(self.table_abc.foo).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'FIRST_VALUE("fizz" IGNORE NULLS) ' 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_first_value_multi_argument(self): + expr = ( + an.FirstValue(self.table_abc.fizz, self.table_abc.buzz) + .over(self.table_abc.foo) + .orderby(self.table_abc.date) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'FIRST_VALUE("fizz","buzz") ' 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_last_value(self): + expr = an.LastValue(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'LAST_VALUE("fizz") ' 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_filter(self): + expr = ( + an.LastValue(self.table_abc.fizz) + .filter(Criterion.all([self.table_abc.bar == True])) + .over(self.table_abc.foo) + .orderby(self.table_abc.date) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'LAST_VALUE("fizz") ' + 'FILTER(WHERE "bar"=true) ' + 'OVER(PARTITION BY "foo" ORDER BY "date") ' + 'FROM "abc"', + str(q), + ) + + def test_filter_quote_table_in_filter(self): + expr = ( + an.LastValue(self.table_efg.fizz) + .filter(self.table_efg.filed.eq('yes')) + .over(self.table_efg.foo) + .orderby(self.table_efg.date) + ) + + q = ( + Query.from_(self.table_abc) + .inner_join(self.table_efg) + .on(self.table_abc.id.eq(self.table_efg.id)) + .select(expr) + ) + + self.assertEqual( + 'SELECT ' + 'LAST_VALUE("efg"."fizz") ' + 'FILTER(WHERE "efg"."filed"=\'yes\') ' + 'OVER(PARTITION BY "efg"."foo" ORDER BY "efg"."date") ' + 'FROM "abc" ' + 'JOIN "efg" ON "abc"."id"="efg"."id"', + str(q), + ) + + def test_orderby_asc(self): + expr = an.LastValue(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date, order=Order.asc) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'LAST_VALUE("fizz") ' 'OVER(PARTITION BY "foo" ORDER BY "date" ASC) ' 'FROM "abc"', + str(q), + ) + + def test_orderby_desc(self): + expr = an.LastValue(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date, order=Order.desc) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'LAST_VALUE("fizz") ' 'OVER(PARTITION BY "foo" ORDER BY "date" DESC) ' 'FROM "abc"', + str(q), + ) + + def test_last_value_multi_argument(self): + expr = ( + an.LastValue(self.table_abc.fizz, self.table_abc.buzz).over(self.table_abc.foo).orderby(self.table_abc.date) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'LAST_VALUE("fizz","buzz") ' 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_last_value_ignore_nulls(self): + expr = an.LastValue(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).ignore_nulls() + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'LAST_VALUE("fizz" IGNORE NULLS) ' 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_median(self): + expr = an.Median(self.table_abc.fizz).over(self.table_abc.foo, self.table_abc.bar).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'MEDIAN("fizz") ' 'OVER(PARTITION BY "foo","bar" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_avg(self): + expr = an.Avg(self.table_abc.fizz).over(self.table_abc.foo, self.table_abc.bar).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'AVG("fizz") ' 'OVER(PARTITION BY "foo","bar" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_stddev(self): + expr = an.StdDev(self.table_abc.fizz).over(self.table_abc.foo, self.table_abc.bar).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'STDDEV("fizz") ' 'OVER(PARTITION BY "foo","bar" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_stddev_pop(self): + expr = ( + an.StdDevPop(self.table_abc.fizz).over(self.table_abc.foo, self.table_abc.bar).orderby(self.table_abc.date) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'STDDEV_POP("fizz") ' 'OVER(PARTITION BY "foo","bar" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_stddev_samp(self): + expr = ( + an.StdDevSamp(self.table_abc.fizz).over(self.table_abc.foo, self.table_abc.bar).orderby(self.table_abc.date) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'STDDEV_SAMP("fizz") ' 'OVER(PARTITION BY "foo","bar" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_variance(self): + expr = ( + an.Variance(self.table_abc.fizz).over(self.table_abc.foo, self.table_abc.bar).orderby(self.table_abc.date) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'VARIANCE("fizz") ' 'OVER(PARTITION BY "foo","bar" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_var_pop(self): + expr = an.VarPop(self.table_abc.fizz).over(self.table_abc.foo, self.table_abc.bar).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'VAR_POP("fizz") ' 'OVER(PARTITION BY "foo","bar" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_var_samp(self): + expr = an.VarSamp(self.table_abc.fizz).over(self.table_abc.foo, self.table_abc.bar).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'VAR_SAMP("fizz") ' 'OVER(PARTITION BY "foo","bar" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_table_prefixes_used_in_analytic_functions(self): + expr = an.Rank().over(self.table_abc.foo).orderby(self.table_efg.date) + + query = ( + Query.from_(self.table_abc) + .join(self.table_efg, how=JoinType.left) + .on(self.table_abc.foo == self.table_efg.bar) + .select("*", expr) + ) + + self.assertEqual( + 'SELECT *,RANK() OVER(PARTITION BY "abc"."foo" ORDER BY "efg"."date") ' + 'FROM "abc" LEFT JOIN "efg" ON "abc"."foo"="efg"."bar"', + str(query), + ) + + def test_sum_rows_unbounded_preceeding(self): + expr = an.Sum(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).rows(an.Preceding()) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'SUM("fizz") ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "ROWS UNBOUNDED PRECEDING" + ") " + 'FROM "abc"', + str(q), + ) + + def test_max_rows_x_preceeding(self): + expr = an.Max(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).rows(an.Preceding(5)) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'MAX("fizz") ' "OVER(" 'PARTITION BY "foo" ORDER BY "date" ' "ROWS 5 PRECEDING" ") " 'FROM "abc"', + str(q), + ) + + def test_min_rows_current_row(self): + expr = an.Min(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).rows(an.CURRENT_ROW) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'MIN("fizz") ' "OVER(" 'PARTITION BY "foo" ORDER BY "date" ' "ROWS CURRENT ROW" ") " 'FROM "abc"', + str(q), + ) + + def test_varpop_range_unbounded_preceeding(self): + expr = ( + an.VarPop(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).range(an.Preceding()) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'VAR_POP("fizz") ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "RANGE UNBOUNDED PRECEDING" + ") " + 'FROM "abc"', + str(q), + ) + + def test_max_range_x_preceeding(self): + expr = an.Max(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).range(an.Preceding(5)) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'MAX("fizz") ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "RANGE 5 PRECEDING" + ") " + 'FROM "abc"', + str(q), + ) + + def test_min_range_current_row(self): + expr = an.Min(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).range(an.CURRENT_ROW) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'MIN("fizz") ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "RANGE CURRENT ROW" + ") " + 'FROM "abc"', + str(q), + ) + + def test_variance_rows_between_unbounded_preceeding_unbounded_following(self): + expr = ( + an.Variance(self.table_abc.fizz) + .over(self.table_abc.foo) + .orderby(self.table_abc.date) + .rows(an.Preceding(), an.Following()) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'VARIANCE("fizz") ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING" + ") " + 'FROM "abc"', + str(q), + ) + + def test_first_value_range_between_x_preceeding_unbounded_following(self): + expr = ( + an.FirstValue(self.table_abc.fizz) + .over(self.table_abc.foo) + .orderby(self.table_abc.date) + .range(an.Preceding(3), an.Following()) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'FIRST_VALUE("fizz") ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "RANGE BETWEEN 3 PRECEDING AND UNBOUNDED FOLLOWING" + ") " + 'FROM "abc"', + str(q), + ) + + def test_varpop_rows_between_unbounded_preceeding_x_following(self): + expr = ( + an.VarPop(self.table_abc.fizz) + .over(self.table_abc.foo) + .orderby(self.table_abc.date) + .rows(an.Preceding(), an.Following(6)) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'VAR_POP("fizz") ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "ROWS BETWEEN UNBOUNDED PRECEDING AND 6 FOLLOWING" + ") " + 'FROM "abc"', + str(q), + ) + + def test_count_range_between_unbounded_preceeding_current_row(self): + expr = ( + an.Count(self.table_abc.fizz) + .over(self.table_abc.foo) + .orderby(self.table_abc.date) + .range(an.Preceding(), an.CURRENT_ROW) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'COUNT("fizz") ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW" + ") " + 'FROM "abc"', + str(q), + ) + + def test_last_value_rows_between_current_row_unbounded_following(self): + expr = ( + an.LastValue(self.table_abc.fizz) + .over(self.table_abc.foo) + .orderby(self.table_abc.date) + .rows(an.CURRENT_ROW, an.Following()) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'LAST_VALUE("fizz") ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING" + ") " + 'FROM "abc"', + str(q), + ) + + def test_last_value_rows_between_current_row_unbounded_following_ignore_nulls(self): + expr = ( + an.LastValue(self.table_abc.fizz) + .over(self.table_abc.foo) + .orderby(self.table_abc.date) + .ignore_nulls() + .rows(an.CURRENT_ROW, an.Following(8)) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'LAST_VALUE("fizz" IGNORE NULLS) ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "ROWS BETWEEN CURRENT ROW AND 8 FOLLOWING" + ") " + 'FROM "abc"', + str(q), + ) + + def test_empty_over(self): + query = Query.from_(self.table_abc).select(an.Sum(self.table_abc.fizz).over()) + + self.assertEqual("SELECT " 'SUM("fizz") OVER() ' 'FROM "abc"', str(query)) + + def test_rows_called_twice_raises_attribute_error(self): + with self.assertRaises(AttributeError): + an.Sum(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).rows(an.Preceding()).rows( + an.Preceding() + ) + + def test_range_called_twice_raises_attribute_error(self): + with self.assertRaises(AttributeError): + an.Sum(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).range( + an.Preceding() + ).range(an.Preceding()) + + def test_rows_then_range_raises_attribute_error(self): + with self.assertRaises(AttributeError): + an.Sum(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).rows( + an.Preceding() + ).range(an.Preceding()) + + def test_range_then_rows_raises_attribute_error(self): + with self.assertRaises(AttributeError): + an.Sum(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).range( + an.Preceding() + ).rows(an.Preceding()) + + def test_lag_generates_correct_sql(self): + with self.subTest('without partition by'): + q = Query.from_(self.table_abc).select( + Lag(self.table_abc.date, 1, '2000-01-01').orderby(self.table_abc.date) + ) + + self.assertEqual('SELECT LAG("date",1,\'2000-01-01\') OVER(ORDER BY "date") FROM "abc"', str(q)) + + with self.subTest('with partition by'): + q = Query.from_(self.table_abc).select( + Lag(self.table_abc.date, 1, '2000-01-01').over(self.table_abc.foo).orderby(self.table_abc.date) + ) + + self.assertEqual( + 'SELECT LAG("date",1,\'2000-01-01\') OVER(PARTITION BY "foo" ORDER BY "date") FROM "abc"', str(q) + ) + + def test_lead_generates_correct_sql(self): + with self.subTest('without partition by'): + q = Query.from_(self.table_abc).select( + Lead(self.table_abc.date, 1, '2000-01-01').orderby(self.table_abc.date) + ) + + self.assertEqual('SELECT LEAD("date",1,\'2000-01-01\') OVER(ORDER BY "date") FROM "abc"', str(q)) + + with self.subTest('with partition by'): + q = Query.from_(self.table_abc).select( + Lead(self.table_abc.date, 1, '2000-01-01').over(self.table_abc.foo).orderby(self.table_abc.date) + ) + + self.assertEqual( + 'SELECT LEAD("date",1,\'2000-01-01\') OVER(PARTITION BY "foo" ORDER BY "date") FROM "abc"', str(q) + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/test_create.py b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/test_create.py new file mode 100644 index 0000000000000000000000000000000000000000..325076544e3824b0d07f82f2378b88218b910dde --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/test_create.py @@ -0,0 +1,210 @@ +import unittest + +from pypika import Column, Columns, Query, Tables, Table +from pypika.terms import ValueWrapper, Index +from pypika.enums import ReferenceOption + + +class CreateTableTests(unittest.TestCase): + new_table, existing_table = Tables("abc", "efg") + foo, bar = Columns(("a", "INT"), ("b", "VARCHAR(100)")) + + def test_create_table_with_columns(self): + with self.subTest("with nullable"): + a = Column("a", "INT", True) + b = Column("b", "VARCHAR(100)", False) + q = Query.create_table(self.new_table).columns(a, b) + + self.assertEqual('CREATE TABLE "abc" ("a" INT NULL,"b" VARCHAR(100) NOT NULL)', str(q)) + + with self.subTest("with defaults"): + a = Column("a", "INT", default=ValueWrapper(42)) + b = Column("b", "VARCHAR(100)", default=ValueWrapper("foo")) + q = Query.create_table(self.new_table).columns(a, b) + + self.assertEqual('CREATE TABLE "abc" ("a" INT DEFAULT 42,"b" VARCHAR(100) DEFAULT \'foo\')', str(q)) + + with self.subTest("with unwrapped defaults"): + a = Column("a", "INT", default=42) + b = Column("b", "VARCHAR(100)", default="foo") + q = Query.create_table(self.new_table).columns(a, b) + + self.assertEqual('CREATE TABLE "abc" ("a" INT DEFAULT 42,"b" VARCHAR(100) DEFAULT \'foo\')', str(q)) + + with self.subTest("with period for"): + a = Column("id", "INT") + b = Column("valid_from", "DATETIME") + c = Column("valid_to", "DATETIME") + q = Query.create_table(self.new_table).columns(a, b, c).period_for('valid_period', b, c) + + self.assertEqual( + 'CREATE TABLE "abc" (' + '"id" INT,' + '"valid_from" DATETIME,' + '"valid_to" DATETIME,' + 'PERIOD FOR "valid_period" ("valid_from","valid_to"))', + str(q), + ) + + with self.subTest("without temporary keyword"): + q = Query.create_table(self.new_table).columns(self.foo, self.bar) + + self.assertEqual('CREATE TABLE "abc" ("a" INT,"b" VARCHAR(100))', str(q)) + + with self.subTest("with temporary keyword"): + q = Query.create_table(self.new_table).temporary().columns(self.foo, self.bar) + + self.assertEqual('CREATE TEMPORARY TABLE "abc" ("a" INT,"b" VARCHAR(100))', str(q)) + + with self.subTest("with primary key"): + q = Query.create_table(self.new_table).columns(self.foo, self.bar).primary_key(self.foo, self.bar) + + self.assertEqual('CREATE TABLE "abc" ("a" INT,"b" VARCHAR(100),PRIMARY KEY ("a","b"))', str(q)) + + with self.subTest("with simple foreign key"): + cref, dref = Columns(("c", "INT"), ("d", "VARCHAR(100)")) + q = ( + Query.create_table(self.new_table) + .columns(self.foo, self.bar) + .foreign_key([self.foo, self.bar], self.existing_table, [cref, dref]) + ) + + self.assertEqual( + 'CREATE TABLE "abc" (' + '"a" INT,' + '"b" VARCHAR(100),' + 'FOREIGN KEY ("a","b") REFERENCES "efg" ("c","d"))', + str(q), + ) + + with self.subTest("with foreign key reference options"): + cref, dref = Columns(("c", "INT"), ("d", "VARCHAR(100)")) + q = ( + Query.create_table(self.new_table) + .columns(self.foo, self.bar) + .foreign_key( + [self.foo, self.bar], + self.existing_table, + [cref, dref], + on_delete=ReferenceOption.cascade, + on_update=ReferenceOption.restrict, + ) + ) + + self.assertEqual( + 'CREATE TABLE "abc" (' + '"a" INT,' + '"b" VARCHAR(100),' + 'FOREIGN KEY ("a","b") REFERENCES "efg" ("c","d") ON DELETE CASCADE ON UPDATE RESTRICT)', + str(q), + ) + + with self.subTest("with unique keys"): + q = ( + Query.create_table(self.new_table) + .columns(self.foo, self.bar) + .unique(self.foo, self.bar) + .unique(self.foo) + ) + + self.assertEqual('CREATE TABLE "abc" ("a" INT,"b" VARCHAR(100),UNIQUE ("a","b"),UNIQUE ("a"))', str(q)) + + with self.subTest("with system versioning"): + q = Query.create_table(self.new_table).columns(self.foo, self.bar).with_system_versioning() + + self.assertEqual('CREATE TABLE "abc" ("a" INT,"b" VARCHAR(100)) WITH SYSTEM VERSIONING', str(q)) + + with self.subTest("with unlogged keyword"): + q = Query.create_table(self.new_table).unlogged().columns(self.foo, self.bar) + + self.assertEqual('CREATE UNLOGGED TABLE "abc" ("a" INT,"b" VARCHAR(100))', str(q)) + + with self.subTest("with if not exists keyword"): + q = Query.create_table(self.new_table).if_not_exists().columns(self.foo, self.bar) + + self.assertEqual('CREATE TABLE IF NOT EXISTS "abc" ("a" INT,"b" VARCHAR(100))', str(q)) + + def test_create_table_with_select(self): + select = Query.from_(self.existing_table).select(self.existing_table.foo, self.existing_table.bar) + + with self.subTest("without temporary keyword"): + q = Query.create_table(self.new_table).as_select(select) + + self.assertEqual('CREATE TABLE "abc" AS (SELECT "foo","bar" FROM "efg")', str(q)) + + with self.subTest("with temporary keyword"): + q = Query.create_table(self.new_table).temporary().as_select(select) + + self.assertEqual( + 'CREATE TEMPORARY TABLE "abc" AS (SELECT "foo","bar" FROM "efg")', + str(q), + ) + + def test_create_table_without_columns_or_select_empty(self): + q = Query.create_table(self.new_table) + + self.assertEqual("", str(q)) + + def test_create_table_with_select_and_columns_fails(self): + select = Query.from_(self.existing_table).select(self.existing_table.foo, self.existing_table.bar) + + with self.subTest("for columns before as_select"): + with self.assertRaises(AttributeError): + Query.create_table(self.new_table).columns(self.foo, self.bar).as_select(select) + + with self.subTest("for as_select before columns"): + with self.assertRaises(AttributeError): + Query.create_table(self.new_table).as_select(select).columns(self.foo, self.bar) + + with self.subTest("repeated foreign key"): + with self.assertRaises(AttributeError): + Query.create_table(self.new_table).foreign_key([self.foo], self.existing_table, [self.bar]).foreign_key( + [self.foo], self.existing_table, [self.bar] + ) + + def test_create_table_as_select_not_query_raises_error(self): + with self.assertRaises(TypeError): + Query.create_table(self.new_table).as_select("abc") + + +class CreateIndexTests(unittest.TestCase): + new_index = Index("abc") + new_table = Table("my_table") + columns = (new_table.a, new_table.b) + where = new_table.a > 1 + + def test_create_index_simple(self) -> None: + q = Query.create_index(self.new_index).on(self.new_table).columns(*self.columns) + self.assertEqual( + f'CREATE INDEX "{self.new_index.name}" ON "{self.new_table.get_table_name()}"({", ".join([c.name for c in self.columns])})', + q.get_sql(), + ) + + def test_create_index_where(self) -> None: + q = Query.create_index(self.new_index).on(self.new_table).columns(*self.columns).where(self.where) + self.assertEqual( + f'CREATE INDEX "{self.new_index.name}" ON "{self.new_table.get_table_name()}"({", ".join([c.name for c in self.columns])}) WHERE {self.where.get_sql()}', + q.get_sql(), + ) + + def test_create_index_unique(self) -> None: + q = Query.create_index(self.new_index).on(self.new_table).columns(*self.columns).unique() + self.assertEqual( + f'CREATE UNIQUE INDEX "{self.new_index.name}" ON "{self.new_table.get_table_name()}"({", ".join([c.name for c in self.columns])})', + q.get_sql(), + ) + + def test_create_index_if_not_exists(self) -> None: + q = Query.create_index(self.new_index).on(self.new_table).columns(*self.columns).if_not_exists() + self.assertEqual( + f'CREATE INDEX IF NOT EXISTS "{self.new_index.name}" ON "{self.new_table.get_table_name()}"({", ".join([c.name for c in self.columns])})', + q.get_sql(), + ) + + def test_create_index_without_columns_raises_error(self) -> None: + with self.assertRaises(AttributeError): + Query.create_index(self.new_index).on(self.new_table).get_sql() + + def test_create_index_without_table_raises_error(self) -> None: + with self.assertRaises(AttributeError): + Query.create_index(self.new_index).columns(*self.columns).get_sql() diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/test_criterions.py b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/test_criterions.py new file mode 100644 index 0000000000000000000000000000000000000000..fca2ceeeb18db88e34ebc38776f644fdcda67e93 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/test_criterions.py @@ -0,0 +1,873 @@ +import unittest +from datetime import ( + date, + datetime, +) + +from pypika import ( + Criterion, + EmptyCriterion, + Field, + Table, + functions as fn, +) +from pypika.queries import QueryBuilder +from pypika.terms import ExistsCriterion, Mod + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + + +class CriterionTests(unittest.TestCase): + t = Table("test", alias="crit") + + def test__criterion_with_alias(self): + c1 = (Field("foo") == Field("bar")).as_("criterion") + + self.assertEqual('"foo"="bar"', str(c1)) + self.assertEqual('"foo"="bar" "criterion"', c1.get_sql(with_alias=True, quote_char='"', alias_quote_char='"')) + + def test__criterion_eq_number(self): + c1 = Field("foo") == 1 + c2 = Field("foo", table=self.t).eq(0) + c3 = Field("foo", table=self.t) == -1 + + self.assertEqual('"foo"=1', str(c1)) + self.assertEqual('"crit"."foo"=0', str(c2)) + self.assertEqual('"crit"."foo"=-1', str(c3)) + + def test__criterion_eq_decimal(self): + c1 = Field("foo") == 1.0 + c2 = Field("foo", table=self.t).eq(0.5) + + self.assertEqual('"foo"=1.0', str(c1)) + self.assertEqual('"crit"."foo"=0.5', str(c2)) + + def test__criterion_eq_bool(self): + c1 = Field("foo") == True + c2 = Field("foo", table=self.t).eq(True) + c3 = Field("foo") == False + c4 = Field("foo", table=self.t).eq(False) + + self.assertEqual('"foo"=true', str(c1)) + self.assertEqual('"crit"."foo"=true', str(c2)) + self.assertEqual('"foo"=false', str(c3)) + self.assertEqual('"crit"."foo"=false', str(c4)) + + def test__criterion_eq_str(self): + c1 = Field("foo") == "abc" + c2 = Field("foo", table=self.t).eq("abc") + + self.assertEqual("\"foo\"='abc'", str(c1)) + self.assertEqual('"crit"."foo"=\'abc\'', str(c2)) + + def test__criterion_eq_date(self): + c1 = Field("foo") == date(2000, 1, 1) + c2 = Field("foo", table=self.t).eq(date(2000, 1, 1)) + + self.assertEqual("\"foo\"='2000-01-01'", str(c1)) + self.assertEqual('"crit"."foo"=\'2000-01-01\'', str(c2)) + + def test__criterion_eq_datetime(self): + c1 = Field("foo") == datetime(2000, 1, 1, 12, 30, 55) + c2 = Field("foo", table=self.t).eq(datetime(2000, 1, 1, 12, 30, 55)) + + self.assertEqual("\"foo\"='2000-01-01T12:30:55'", str(c1)) + self.assertEqual('"crit"."foo"=\'2000-01-01T12:30:55\'', str(c2)) + + def test__criterion_eq_right(self): + c1 = 1 == Field("foo") + c2 = -1 == Field("foo", table=self.t) + + self.assertEqual('"foo"=1', str(c1)) + self.assertEqual('"crit"."foo"=-1', str(c2)) + + def test__criterion_is_null(self): + c1 = Field("foo").isnull() + c2 = Field("foo", table=self.t).isnull() + + self.assertEqual('"foo" IS NULL', str(c1)) + self.assertEqual('"crit"."foo" IS NULL', str(c2)) + + def test__criterion_is_null_with_alias(self): + c1 = Field("foo").isnull().as_('alias') + c2 = Field("foo", table=self.t).isnull().as_('alias') + + self.assertEqual('"foo" IS NULL "alias"', str(c1)) + self.assertEqual('"crit"."foo" IS NULL "alias"', str(c2)) + + def test__criterion_ne_number(self): + c1 = Field("foo") != 1 + c2 = Field("foo", table=self.t).ne(0) + c3 = Field("foo") != -1 + + self.assertEqual('"foo"<>1', str(c1)) + self.assertEqual('"crit"."foo"<>0', str(c2)) + self.assertEqual('"foo"<>-1', str(c3)) + + def test__criterion_ne_str(self): + c1 = Field("foo") != "abc" + c2 = Field("foo", table=self.t).ne("abc") + + self.assertEqual("\"foo\"<>'abc'", str(c1)) + self.assertEqual('"crit"."foo"<>\'abc\'', str(c2)) + + def test__criterion_ne_date(self): + c1 = Field("foo") != date(2000, 1, 1) + c2 = Field("foo", table=self.t).ne(date(2000, 1, 1)) + + self.assertEqual("\"foo\"<>'2000-01-01'", str(c1)) + self.assertEqual('"crit"."foo"<>\'2000-01-01\'', str(c2)) + + def test__criterion_ne_datetime(self): + c1 = Field("foo") != datetime(2000, 1, 1, 12, 30, 55) + c2 = Field("foo", table=self.t).ne(datetime(2000, 1, 1, 12, 30, 55)) + + self.assertEqual("\"foo\"<>'2000-01-01T12:30:55'", str(c1)) + self.assertEqual('"crit"."foo"<>\'2000-01-01T12:30:55\'', str(c2)) + + def test__criterion_ne_right(self): + c1 = 1 != Field("foo") + c2 = -1 != Field("foo", table=self.t) + + self.assertEqual('"foo"<>1', str(c1)) + self.assertEqual('"crit"."foo"<>-1', str(c2)) + + def test__criterion_lt_number(self): + c1 = Field("foo") < 1 + c2 = Field("foo", table=self.t).lt(0) + c3 = Field("foo") < -1 + + self.assertEqual('"foo"<1', str(c1)) + self.assertEqual('"crit"."foo"<0', str(c2)) + self.assertEqual('"foo"<-1', str(c3)) + + def test__criterion_lt_date(self): + c1 = Field("foo") < date(2000, 1, 1) + c2 = Field("foo", table=self.t).lt(date(2000, 1, 1)) + + self.assertEqual("\"foo\"<'2000-01-01'", str(c1)) + self.assertEqual('"crit"."foo"<\'2000-01-01\'', str(c2)) + + def test__criterion_lt_datetime(self): + c1 = Field("foo") < datetime(2000, 1, 1, 12, 30, 55) + c2 = Field("foo", table=self.t).lt(datetime(2000, 1, 1, 12, 30, 55)) + + self.assertEqual("\"foo\"<'2000-01-01T12:30:55'", str(c1)) + self.assertEqual('"crit"."foo"<\'2000-01-01T12:30:55\'', str(c2)) + + def test__criterion_lt_right(self): + c1 = 1 > Field("foo") + c2 = -1 > Field("foo", table=self.t) + + self.assertEqual('"foo"<1', str(c1)) + self.assertEqual('"crit"."foo"<-1', str(c2)) + + def test__criterion_gt_number(self): + c1 = Field("foo") > 1 + c2 = Field("foo", table=self.t).gt(0) + c3 = Field("foo") > -1 + + self.assertEqual('"foo">1', str(c1)) + self.assertEqual('"crit"."foo">0', str(c2)) + self.assertEqual('"foo">-1', str(c3)) + + def test__criterion_gt_date(self): + c1 = Field("foo") > date(2000, 1, 1) + c2 = Field("foo", table=self.t).gt(date(2000, 1, 1)) + + self.assertEqual("\"foo\">'2000-01-01'", str(c1)) + self.assertEqual('"crit"."foo">\'2000-01-01\'', str(c2)) + + def test__criterion_gt_datetime(self): + c1 = Field("foo") > datetime(2000, 1, 1, 12, 30, 55) + c2 = Field("foo", table=self.t).gt(datetime(2000, 1, 1, 12, 30, 55)) + + self.assertEqual("\"foo\">'2000-01-01T12:30:55'", str(c1)) + self.assertEqual('"crit"."foo">\'2000-01-01T12:30:55\'', str(c2)) + + def test__criterion_gt_right(self): + c1 = 1 < Field("foo") + c2 = -1 < Field("foo", table=self.t) + + self.assertEqual('"foo">1', str(c1)) + self.assertEqual('"crit"."foo">-1', str(c2)) + + def test__criterion_lte_number(self): + c1 = Field("foo") <= 1 + c2 = Field("foo", table=self.t).lte(0) + c3 = Field("foo") <= -1 + + self.assertEqual('"foo"<=1', str(c1)) + self.assertEqual('"crit"."foo"<=0', str(c2)) + self.assertEqual('"foo"<=-1', str(c3)) + + def test__criterion_lte_date(self): + c1 = Field("foo") <= date(2000, 1, 1) + c2 = Field("foo", table=self.t).lte(date(2000, 1, 1)) + + self.assertEqual("\"foo\"<='2000-01-01'", str(c1)) + self.assertEqual('"crit"."foo"<=\'2000-01-01\'', str(c2)) + + def test__criterion_lte_datetime(self): + c1 = Field("foo") <= datetime(2000, 1, 1, 12, 30, 55) + c2 = Field("foo", table=self.t).lte(datetime(2000, 1, 1, 12, 30, 55)) + + self.assertEqual("\"foo\"<='2000-01-01T12:30:55'", str(c1)) + self.assertEqual('"crit"."foo"<=\'2000-01-01T12:30:55\'', str(c2)) + + def test__criterion_lte_right(self): + c1 = 1 >= Field("foo") + c2 = -1 >= Field("foo", table=self.t) + + self.assertEqual('"foo"<=1', str(c1)) + self.assertEqual('"crit"."foo"<=-1', str(c2)) + + def test__criterion_gte_number(self): + c1 = Field("foo") >= 1 + c2 = Field("foo", table=self.t).gte(0) + c3 = Field("foo") >= -1 + + self.assertEqual('"foo">=1', str(c1)) + self.assertEqual('"crit"."foo">=0', str(c2)) + self.assertEqual('"foo">=-1', str(c3)) + + def test__criterion_gte_date(self): + c1 = Field("foo") >= date(2000, 1, 1) + c2 = Field("foo", table=self.t).gte(date(2000, 1, 1)) + + self.assertEqual("\"foo\">='2000-01-01'", str(c1)) + self.assertEqual('"crit"."foo">=\'2000-01-01\'', str(c2)) + + def test__criterion_gte_datetime(self): + c1 = Field("foo") >= datetime(2000, 1, 1, 12, 30, 55) + c2 = Field("foo", table=self.t).gte(datetime(2000, 1, 1, 12, 30, 55)) + + self.assertEqual("\"foo\">='2000-01-01T12:30:55'", str(c1)) + self.assertEqual('"crit"."foo">=\'2000-01-01T12:30:55\'', str(c2)) + + def test__criterion_gte_right(self): + c1 = 1 <= Field("foo") + c2 = -1 <= Field("foo", table=self.t) + + self.assertEqual('"foo">=1', str(c1)) + self.assertEqual('"crit"."foo">=-1', str(c2)) + + def test__criterion_bitwise_and(self): + c1 = Field("foo").bitwiseand(2) + c2 = Field("foo", table=self.t).bitwiseand(10) == 2 + + self.assertEqual('("foo" & 2)', str(c1)) + self.assertEqual('("crit"."foo" & 10)=2', str(c2)) + + def test__criterion_bitwise_and_with_alias(self): + c1 = Field("foo").bitwiseand(2).as_('alias') + + self.assertEqual('("foo" & 2) "alias"', str(c1)) + + def test__bitwise_and_in_where_clause(self): + q = QueryBuilder().from_('items').select('abc').where(Field("foo").bitwiseand(1) == 1) + + self.assertEqual('SELECT "abc" FROM "items" WHERE ("foo" & 1)=1', str(q)) + + +class NotTests(unittest.TestCase): + table_abc, table_efg = Table("abc", alias="cx0"), Table("efg", alias="cx1") + + def test_negate(self): + c1 = Field("foo") >= 1 + c2 = c1.negate() + + self.assertEqual('"foo">=1', str(c1)) + self.assertEqual('NOT "foo">=1', str(c2)) + + def test_variable_access(self): + c1 = Field("foo").negate() + + self.assertEqual(c1.is_aggregate, False) + + def test_chained_function(self): + field1 = Field("foo").negate() + field2 = field1.eq("bar") + + self.assertEqual('NOT "foo"', str(field1)) + self.assertEqual("NOT \"foo\"='bar'", str(field2)) + self.assertIsNot(field1, field2) + + def test_not_null(self): + c1 = Field("foo").notnull() + c2 = Field("foo", table=self.table_abc).notnull() + + self.assertEqual('NOT "foo" IS NULL', str(c1)) + self.assertEqual('NOT "cx0"."foo" IS NULL', str(c2)) + + def test_is_not_null(self): + c1 = Field("foo").isnotnull() + c2 = Field("foo", table=self.table_abc).isnotnull() + + self.assertEqual('"foo" IS NOT NULL', str(c1)) + self.assertEqual('"cx0"."foo" IS NOT NULL', str(c2)) + + def test_not_null_with_alias(self): + c1 = Field("foo").notnull().as_("something") + c2 = Field("foo", table=self.table_abc).notnull().as_("something") + + self.assertEqual('NOT "foo" IS NULL "something"', str(c1)) + self.assertEqual('NOT "cx0"."foo" IS NULL "something"', str(c2)) + + def test_notnullcriterion_replace_table(self): + f = self.table_abc.foo.notnull().replace_table(self.table_abc, self.table_efg) + + self.assertEqual('NOT "cx1"."foo" IS NULL', str(f)) + + def test_not_with_or_criterion(self): + self.assertEqual('NOT ("foo" OR "bar")', str(~(Field("foo") | Field("bar")))) + + def test_not_with_and_criterion(self): + self.assertEqual('NOT ("foo" AND "bar")', str(~(Field("foo") & Field("bar")))) + + def test_not_with_complex_criterion(self): + self.assertEqual( + 'NOT ("foo" AND "bar" AND "fizz" AND "buzz")', + str(~(Field("foo") & Field("bar") & Field("fizz") & Field("buzz"))), + ) + + +class BetweenTests(unittest.TestCase): + t = Table("abc", alias="btw") + + def test__between_number(self): + c1 = Field("foo").between(0, 1) + c2 = Field("foo", table=self.t).between(0, 1) + c3 = Field("foo")[0:1] + + self.assertEqual('"foo" BETWEEN 0 AND 1', str(c1)) + self.assertEqual('"btw"."foo" BETWEEN 0 AND 1', str(c2)) + self.assertEqual('"foo" BETWEEN 0 AND 1', str(c3)) + + def test__between_with_alias(self): + c1 = Field("foo").between(0, 1).as_('alias') + c2 = Field("foo", table=self.t).between(0, 1).as_('alias') + c3 = Field("foo")[0:1].as_('alias') + + self.assertEqual('"foo" BETWEEN 0 AND 1 "alias"', str(c1)) + self.assertEqual('"btw"."foo" BETWEEN 0 AND 1 "alias"', str(c2)) + self.assertEqual('"foo" BETWEEN 0 AND 1 "alias"', str(c3)) + + def test__between_date(self): + c1 = Field("foo").between(date(2000, 1, 1), date(2000, 12, 31)) + c2 = Field("foo", table=self.t).between(date(2000, 1, 1), date(2000, 12, 31)) + c3 = Field("foo")[date(2000, 1, 1) : date(2000, 12, 31)] + + self.assertEqual("\"foo\" BETWEEN '2000-01-01' AND '2000-12-31'", str(c1)) + self.assertEqual("\"btw\".\"foo\" BETWEEN '2000-01-01' AND '2000-12-31'", str(c2)) + self.assertEqual("\"foo\" BETWEEN '2000-01-01' AND '2000-12-31'", str(c3)) + + def test__between_datetime(self): + c1 = Field("foo").between(datetime(2000, 1, 1, 0, 0, 0), datetime(2000, 12, 31, 23, 59, 59)) + c2 = Field("foo", table=self.t).between(datetime(2000, 1, 1, 0, 0, 0), datetime(2000, 12, 31, 23, 59, 59)) + c3 = Field("foo")[datetime(2000, 1, 1, 0, 0, 0) : datetime(2000, 12, 31, 23, 59, 59)] + + self.assertEqual("\"foo\" BETWEEN '2000-01-01T00:00:00' AND '2000-12-31T23:59:59'", str(c1)) + self.assertEqual( + "\"btw\".\"foo\" BETWEEN '2000-01-01T00:00:00' AND '2000-12-31T23:59:59'", + str(c2), + ) + self.assertEqual("\"foo\" BETWEEN '2000-01-01T00:00:00' AND '2000-12-31T23:59:59'", str(c3)) + + def test__function_between(self): + c1 = fn.Coalesce(Field("foo"), 0)[0:1] + c2 = fn.Coalesce(Field("foo", table=self.t), 0)[0:1] + + self.assertEqual('COALESCE("foo",0) BETWEEN 0 AND 1', str(c1)) + self.assertEqual('COALESCE("btw"."foo",0) BETWEEN 0 AND 1', str(c2)) + + def test_get_item_only_works_with_slice(self): + with self.assertRaises(TypeError): + Field("foo")[0] + + with self.assertRaises(TypeError): + Field("foo")[date(2000, 1, 1)] + + with self.assertRaises(TypeError): + Field("foo")[datetime(2000, 1, 1, 0, 0, 0)] + + +class IsInTests(unittest.TestCase): + t = Table("abc", alias="isin") + + def test__in_number(self): + c1 = Field("foo").isin([0, 1]) + c2 = Field("foo", table=self.t).isin([0, 1]) + + self.assertEqual('"foo" IN (0,1)', str(c1)) + self.assertEqual('"isin"."foo" IN (0,1)', str(c2)) + + def test__in_number_with_alias(self): + c1 = Field("foo").isin([0, 1]).as_('alias') + c2 = Field("foo", table=self.t).isin([0, 1]).as_('alias') + + self.assertEqual('"foo" IN (0,1) "alias"', str(c1)) + self.assertEqual('"isin"."foo" IN (0,1) "alias"', str(c2)) + + def test__in_character(self): + c1 = Field("foo").isin(["a", "b"]) + c2 = Field("foo", table=self.t).isin(["a", "b"]) + + self.assertEqual("\"foo\" IN ('a','b')", str(c1)) + self.assertEqual("\"isin\".\"foo\" IN ('a','b')", str(c2)) + + def test__in_date(self): + c1 = Field("foo").isin([date(2000, 1, 1), date(2000, 12, 31)]) + c2 = Field("foo", table=self.t).isin([date(2000, 1, 1), date(2000, 12, 31)]) + + self.assertEqual("\"foo\" IN ('2000-01-01','2000-12-31')", str(c1)) + self.assertEqual("\"isin\".\"foo\" IN ('2000-01-01','2000-12-31')", str(c2)) + + def test__in_datetime(self): + c1 = Field("foo").isin([datetime(2000, 1, 1, 0, 0, 0), datetime(2000, 12, 31, 23, 59, 59)]) + c2 = Field("foo", table=self.t).isin([datetime(2000, 1, 1, 0, 0, 0), datetime(2000, 12, 31, 23, 59, 59)]) + + self.assertEqual("\"foo\" IN ('2000-01-01T00:00:00','2000-12-31T23:59:59')", str(c1)) + self.assertEqual("\"isin\".\"foo\" IN ('2000-01-01T00:00:00','2000-12-31T23:59:59')", str(c2)) + + def test__function_isin(self): + c1 = fn.Coalesce(Field("foo"), 0).isin([0, 1]) + c2 = fn.Coalesce(Field("foo", table=self.t), 0).isin([0, 1]) + + self.assertEqual('COALESCE("foo",0) IN (0,1)', str(c1)) + self.assertEqual('COALESCE("isin"."foo",0) IN (0,1)', str(c2)) + + for t in (list, tuple, set, frozenset): + c_type = fn.Coalesce(Field("foo"), 0).isin(t([0, 1])) + self.assertEqual('COALESCE("foo",0) IN (0,1)', str(c_type)) + + self.assertRaises(AttributeError, lambda: str(fn.Coalesce(Field("foo"), 0).isin('SHOULD_FAIL'))) + + def test__in_unicode(self): + c1 = Field("foo").isin([u"a", u"b"]) + c2 = Field("foo", table=self.t).isin([u"a", u"b"]) + + self.assertEqual("\"foo\" IN ('a','b')", str(c1)) + self.assertEqual("\"isin\".\"foo\" IN ('a','b')", str(c2)) + + +class ArithmeticExpressionTests(unittest.TestCase): + def test__lshift(self): + c1 = Field("foo").lshift("1") + c2 = Field("foo").lshift("2") + + self.assertEqual("\"foo\"<<'1'", str(c1)) + self.assertEqual("\"foo\"<<'2'", str(c2)) + + def test__rshift(self): + c1 = Field("foo").rshift("1") + c2 = Field("foo").rshift("2") + + self.assertEqual("\"foo\">>'1'", str(c1)) + self.assertEqual("\"foo\">>'2'", str(c2)) + + +class NotInTests(unittest.TestCase): + t = Table("abc", alias="notin") + + def test__notin_number(self): + c1 = Field("foo").notin([0, 1]) + c2 = Field("foo", table=self.t).notin([0, 1]) + + self.assertEqual('"foo" NOT IN (0,1)', str(c1)) + self.assertEqual('"notin"."foo" NOT IN (0,1)', str(c2)) + + def test__notin_number_with_alias(self): + c1 = Field("foo").notin([0, 1]).as_('alias') + c2 = Field("foo", table=self.t).notin([0, 1]).as_('alias') + + self.assertEqual('"foo" NOT IN (0,1) "alias"', str(c1)) + self.assertEqual('"notin"."foo" NOT IN (0,1) "alias"', str(c2)) + + def test__notin_character(self): + c1 = Field("foo").notin(["a", "b"]) + c2 = Field("foo", table=self.t).notin(["a", "b"]) + + self.assertEqual("\"foo\" NOT IN ('a','b')", str(c1)) + self.assertEqual("\"notin\".\"foo\" NOT IN ('a','b')", str(c2)) + + def test__notin_date(self): + c1 = Field("foo").notin([date(2000, 1, 1), date(2000, 12, 31)]) + c2 = Field("foo", table=self.t).notin([date(2000, 1, 1), date(2000, 12, 31)]) + + self.assertEqual("\"foo\" NOT IN ('2000-01-01','2000-12-31')", str(c1)) + self.assertEqual("\"notin\".\"foo\" NOT IN ('2000-01-01','2000-12-31')", str(c2)) + + def test__notin_datetime(self): + c1 = Field("foo").notin([datetime(2000, 1, 1, 0, 0, 0), datetime(2000, 12, 31, 23, 59, 59)]) + c2 = Field("foo", table=self.t).notin([datetime(2000, 1, 1, 0, 0, 0), datetime(2000, 12, 31, 23, 59, 59)]) + + self.assertEqual("\"foo\" NOT IN ('2000-01-01T00:00:00','2000-12-31T23:59:59')", str(c1)) + self.assertEqual( + "\"notin\".\"foo\" NOT IN ('2000-01-01T00:00:00','2000-12-31T23:59:59')", + str(c2), + ) + + def test__function_notin(self): + c1 = fn.Coalesce(Field("foo"), 0).notin([0, 1]) + c2 = fn.Coalesce(Field("foo", table=self.t), 0).notin([0, 1]) + + self.assertEqual('COALESCE("foo",0) NOT IN (0,1)', str(c1)) + self.assertEqual('COALESCE("notin"."foo",0) NOT IN (0,1)', str(c2)) + + +class LikeTests(unittest.TestCase): + t = Table("abc", alias="like") + + def test_like_starts_with(self): + c1 = Field("foo").like("ab%") + c2 = Field("foo", table=self.t).like("ab%") + + self.assertEqual("\"foo\" LIKE 'ab%'", str(c1)) + self.assertEqual('"like"."foo" LIKE \'ab%\'', str(c2)) + + def test_like_contains(self): + c1 = Field("foo").like("%ab%") + c2 = Field("foo", table=self.t).like("%ab%") + + self.assertEqual("\"foo\" LIKE '%ab%'", str(c1)) + self.assertEqual('"like"."foo" LIKE \'%ab%\'', str(c2)) + + def test_like_ends_with(self): + c1 = Field("foo").like("%ab") + c2 = Field("foo", table=self.t).like("%ab") + + self.assertEqual("\"foo\" LIKE '%ab'", str(c1)) + self.assertEqual('"like"."foo" LIKE \'%ab\'', str(c2)) + + def test_like_n_chars_long(self): + c1 = Field("foo").like("___") + c2 = Field("foo", table=self.t).like("___") + + self.assertEqual("\"foo\" LIKE '___'", str(c1)) + self.assertEqual('"like"."foo" LIKE \'___\'', str(c2)) + + def test_like_single_chars_and_various_chars(self): + c1 = Field("foo").like("a_b%c") + c2 = Field("foo", table=self.t).like("a_b%c") + + self.assertEqual("\"foo\" LIKE 'a_b%c'", str(c1)) + self.assertEqual('"like"."foo" LIKE \'a_b%c\'', str(c2)) + + def test_not_like_single_chars_and_various_chars(self): + c1 = Field("foo").not_like("a_b%c") + c2 = Field("foo", table=self.t).not_like("a_b%c") + + self.assertEqual("\"foo\" NOT LIKE 'a_b%c'", str(c1)) + self.assertEqual('"like"."foo" NOT LIKE \'a_b%c\'', str(c2)) + + def test_ilike_starts_with(self): + c1 = Field("foo").ilike("ab%") + c2 = Field("foo", table=self.t).ilike("ab%") + + self.assertEqual("\"foo\" ILIKE 'ab%'", str(c1)) + self.assertEqual('"like"."foo" ILIKE \'ab%\'', str(c2)) + + def test_ilike_contains(self): + c1 = Field("foo").ilike("%ab%") + c2 = Field("foo", table=self.t).ilike("%ab%") + + self.assertEqual("\"foo\" ILIKE '%ab%'", str(c1)) + self.assertEqual('"like"."foo" ILIKE \'%ab%\'', str(c2)) + + def test_ilike_ends_with(self): + c1 = Field("foo").ilike("%ab") + c2 = Field("foo", table=self.t).ilike("%ab") + + self.assertEqual("\"foo\" ILIKE '%ab'", str(c1)) + self.assertEqual('"like"."foo" ILIKE \'%ab\'', str(c2)) + + def test_ilike_n_chars_long(self): + c1 = Field("foo").ilike("___") + c2 = Field("foo", table=self.t).ilike("___") + + self.assertEqual("\"foo\" ILIKE '___'", str(c1)) + self.assertEqual('"like"."foo" ILIKE \'___\'', str(c2)) + + def test_ilike_single_chars_and_various_chars(self): + c1 = Field("foo").ilike("a_b%c") + c2 = Field("foo", table=self.t).ilike("a_b%c") + + self.assertEqual("\"foo\" ILIKE 'a_b%c'", str(c1)) + self.assertEqual('"like"."foo" ILIKE \'a_b%c\'', str(c2)) + + def test_not_ilike_single_chars_and_various_chars(self): + c1 = Field("foo").not_ilike("a_b%c") + c2 = Field("foo", table=self.t).not_ilike("a_b%c") + + self.assertEqual("\"foo\" NOT ILIKE 'a_b%c'", str(c1)) + self.assertEqual('"like"."foo" NOT ILIKE \'a_b%c\'', str(c2)) + + def test_rlike_escape_chars(self): + c1 = Field("foo").rlike("\\\\d+$") + c2 = Field("foo", table=self.t).rlike("\\\\d+$") + + self.assertEqual("\"foo\" RLIKE '\\\\d+$'", str(c1)) + self.assertEqual('"like"."foo" RLIKE \'\\\\d+$\'', str(c2)) + + def test_glob_single_chars_and_various_chars(self): + c1 = Field("foo").glob("a_b*") + c2 = Field("foo", table=self.t).glob("a_b*") + + self.assertEqual("\"foo\" GLOB 'a_b*'", str(c1)) + self.assertEqual('"like"."foo" GLOB \'a_b*\'', str(c2)) + + +class ExistsCriterionTests(unittest.TestCase): + t2 = Table("abc", alias="t2") + q2 = QueryBuilder().from_(t2).select(t2.field2) + + def test_exists(self): + t1 = Table("def", alias="t1") + q1 = QueryBuilder().from_(t1).where(ExistsCriterion(self.q2)).select(t1.field1) + + self.assertEqual( + 'SELECT "t1"."field1" FROM "def" "t1" WHERE EXISTS (SELECT "t2"."field2" FROM "abc" "t2")', str(q1) + ) + + def test_not_exists(self): + t1 = Table("def", alias="t1") + q1 = QueryBuilder().from_(t1).where(ExistsCriterion(self.q2).negate()).select(t1.field1) + + self.assertEqual( + 'SELECT "t1"."field1" FROM "def" "t1" WHERE NOT EXISTS (SELECT "t2"."field2" FROM "abc" "t2")', str(q1) + ) + + +class ComplexCriterionTests(unittest.TestCase): + table_abc, table_efg = Table("abc", alias="cx0"), Table("efg", alias="cx1") + + def test_and(self): + c1 = (Field("foo") == 1) & (Field("bar") == 2) + c2 = (Field("foo", table=self.table_abc) == 1) & (Field("bar", table=self.table_efg) == 2) + + self.assertEqual('"foo"=1 AND "bar"=2', str(c1)) + self.assertEqual('"cx0"."foo"=1 AND "cx1"."bar"=2', str(c2)) + + def test_or(self): + c1 = (Field("foo") == 1) | (Field("bar") == 2) + c2 = (Field("foo", table=self.table_abc) == 1) | (Field("bar", table=self.table_efg) == 2) + + self.assertEqual('"foo"=1 OR "bar"=2', str(c1)) + self.assertEqual('"cx0"."foo"=1 OR "cx1"."bar"=2', str(c2)) + + def test_xor(self): + c1 = (Field("foo") == 1) ^ (Field("bar") == 2) + c2 = (Field("foo", table=self.table_abc) == 1) ^ (Field("bar", table=self.table_efg) == 2) + + self.assertEqual('"foo"=1 XOR "bar"=2', str(c1)) + self.assertEqual('"cx0"."foo"=1 XOR "cx1"."bar"=2', str(c2)) + + def test_function_and(self): + c1 = fn.IsNull(Field("foo")) & (Field("bar") == 2) + + self.assertEqual('ISNULL("foo") AND "bar"=2', str(c1)) + + def test_function_or(self): + c1 = fn.IsNull(Field("foo")) | (Field("bar") == 2) + + self.assertEqual('ISNULL("foo") OR "bar"=2', str(c1)) + + def test_function_xor(self): + c1 = fn.IsNull(Field("foo")) ^ (Field("bar") == 2) + + self.assertEqual('ISNULL("foo") XOR "bar"=2', str(c1)) + + def test__nested__and(self): + c = (Field("foo") == 1) & (Field("bar") == 2) & (Field("buz") == 3) + + self.assertEqual('"foo"=1 AND "bar"=2 AND "buz"=3', str(c)) + + def test__nested__or(self): + c = (Field("foo") == 1) | (Field("bar") == 2) | (Field("buz") == 3) + + self.assertEqual('"foo"=1 OR "bar"=2 OR "buz"=3', str(c)) + + def test__nested__mixed(self): + c = ((Field("foo") == 1) & (Field("bar") == 2)) | (Field("buz") == 3) + + self.assertEqual('("foo"=1 AND "bar"=2) OR "buz"=3', str(c)) + + def test__between_and_isin(self): + c = Field("foo").isin([1, 2, 3]) & Field("bar").between(0, 1) + + self.assertEqual('"foo" IN (1,2,3) AND "bar" BETWEEN 0 AND 1', str(c)) + + def test__between_and_field(self): + c1 = Field("foo").between(0, 1) + c2 = Field("bool_field") + + self.assertEqual('"foo" BETWEEN 0 AND 1 AND "bool_field"', str(c1 & c2)) + self.assertEqual('"bool_field" AND "foo" BETWEEN 0 AND 1', str(c2 & c1)) + + +class FieldsAsCriterionTests(unittest.TestCase): + def test__field_and_field(self): + c1 = Field("a") + c2 = Field("b") + + self.assertEqual('"a" AND "b"', str(c1 & c2)) + + def test__field_or_field(self): + c1 = Field("a") + c2 = Field("b") + + self.assertEqual('"a" OR "b"', str(c1 | c2)) + + def test__field_xor_field(self): + c1 = Field("a") + c2 = Field("b") + + self.assertEqual('"a" XOR "b"', str(c1 ^ c2)) + + +class CriterionOperationsTests(unittest.TestCase): + table_abc, table_efg = Table("abc", alias="cx0"), Table("efg", alias="cx1") + + def test_field_replace_table(self): + f = self.table_abc.foo.replace_table(self.table_abc, self.table_efg) + + self.assertEqual('"cx1"."foo"', str(f)) + + def test_arithmeticfunction_replace_table(self): + f = (self.table_abc.foo + self.table_abc.bar).replace_table(self.table_abc, self.table_efg) + + self.assertEqual('"cx1"."foo"+"cx1"."bar"', str(f)) + + def test_criterion_replace_table(self): + f = (self.table_abc.foo < self.table_abc.bar).replace_table(self.table_abc, self.table_efg) + + self.assertEqual('"cx1"."foo"<"cx1"."bar"', str(f)) + + def test_complexcriterion_replace_table(self): + f = (self.table_abc.foo < self.table_abc.bar) & (self.table_abc.fiz > self.table_abc.buz) + f = f.replace_table(self.table_abc, self.table_efg) + + self.assertEqual('"cx1"."foo"<"cx1"."bar" AND "cx1"."fiz">"cx1"."buz"', str(f)) + + def test_function_with_only_fields_replace_table(self): + f = fn.Sum(self.table_abc.foo).replace_table(self.table_abc, self.table_efg) + + self.assertEqual('SUM("cx1"."foo")', str(f)) + + def test_function_with_values_and_fields_replace_table(self): + f = Mod(self.table_abc.foo, 2).replace_table(self.table_abc, self.table_efg) + + self.assertEqual('MOD("cx1"."foo",2)', str(f)) + + def test_betweencriterion_replace_table(self): + f = self.table_abc.foo[0:1].replace_table(self.table_abc, self.table_efg) + + self.assertEqual('"cx1"."foo" BETWEEN 0 AND 1', str(f)) + + def test_nullcriterion_replace_table(self): + f = self.table_abc.foo.isnull().replace_table(self.table_abc, self.table_efg) + + self.assertEqual('"cx1"."foo" IS NULL', str(f)) + + +class AnyTests(unittest.TestCase): + def test_zero_args_returns_empty_criterion(self): + crit = Criterion.any() + self.assertIsInstance(crit, EmptyCriterion) + + def test_single_arg_returns_self(self): + f = Field("a") + crit = Criterion.any([f]) + self.assertEqual(str(f), str(crit)) + + def test_multiple_args_returned_in_chain_of_ors(self): + crit = Criterion.any([Field("a"), Field("b"), Field("c"), Field("d")]) + self.assertEqual(str(crit), '"a" OR "b" OR "c" OR "d"') + + def test_with_generator(self): + crit = Criterion.any(Field(letter) for letter in "abcd") + self.assertEqual(str(crit), '"a" OR "b" OR "c" OR "d"') + + +class EmptyCriterionTests(unittest.TestCase): + def test_fields_(self): + empty_criterion = EmptyCriterion() + + self.assertEqual(len(empty_criterion.fields_()), 0) + + def test_empty_criterion_on_the_left(self): + t = Table("test1") + q = EmptyCriterion() & t.f1 == "v1" + + self.assertEqual( + '"test1"."f1"=\'v1\'', + q.get_sql(with_namespace=True), + ) + + def test_empty_criterion_on_the_right(self): + t = Table("test1") + q = (t.f1 == "v1") & EmptyCriterion() + + self.assertEqual( + '"test1"."f1"=\'v1\'', + q.get_sql(with_namespace=True), + ) + + def test_invertion_of_the_empty_criterion(self): + t = Table("test1") + q = (t.f1 == "v1") & ~EmptyCriterion() + + self.assertEqual( + '"test1"."f1"=\'v1\'', + q.get_sql(with_namespace=True), + ) + + def test_different_operations_with_empty_criterion(self): + t = Table("test1") + q1 = (t.f1 == "v1") & EmptyCriterion() + q2 = (t.f1 == "v1") | EmptyCriterion() + q3 = (t.f1 == "v1") ^ EmptyCriterion() + + expected_sql = '"test1"."f1"=\'v1\'' + self.assertEqual( + expected_sql, + q1.get_sql(with_namespace=True), + ) + self.assertEqual( + expected_sql, + q2.get_sql(with_namespace=True), + ) + self.assertEqual( + expected_sql, + q3.get_sql(with_namespace=True), + ) + + def test_more_than_one_empty_criterions(self): + t = Table("test1") + q = EmptyCriterion() & ~(EmptyCriterion() | EmptyCriterion()) & (t.f1 == "v1") & ~EmptyCriterion() + + self.assertEqual( + '"test1"."f1"=\'v1\'', + q.get_sql(with_namespace=True), + ) + + +class AllTests(unittest.TestCase): + def test_zero_args_returns_empty_criterion(self): + crit = Criterion.all() + self.assertIsInstance(crit, EmptyCriterion) + + def test_single_arg_returns_self(self): + f = Field("a") + crit = Criterion.all([f]) + self.assertEqual(str(f), str(crit)) + + def test_multiple_args_returned_in_chain_of_ors(self): + crit = Criterion.all([Field("a"), Field("b"), Field("c"), Field("d")]) + self.assertEqual(str(crit), '"a" AND "b" AND "c" AND "d"') + + def test_with_generator(self): + crit = Criterion.all(Field(letter) for letter in "abcd") + self.assertEqual(str(crit), '"a" AND "b" AND "c" AND "d"') diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/test_custom_functions.py b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/test_custom_functions.py new file mode 100644 index 0000000000000000000000000000000000000000..60ffd3cd8e6191e3fc782dac003c41bfb7a78528 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/test_custom_functions.py @@ -0,0 +1,49 @@ +import unittest + +from pypika import CustomFunction, FunctionException, Query, Table + +__author__ = "Airton Zanon" +__email__ = "me@airton.dev" + + +class TestUnitCustomFunction(unittest.TestCase): + def test_should_fail_with_wrong_arguments(self): + DateDiff = CustomFunction("DATE_DIFF", ["interval", "start_date", "end_date"]) + + with self.assertRaises(FunctionException): + DateDiff("foo") + + def test_should_return_function_with_arguments(self): + DateDiff = CustomFunction("DATE_DIFF", ["interval", "start_date", "end_date"]) + + self.assertEqual( + "DATE_DIFF('day','start_date','end_date')", + str(DateDiff("day", "start_date", "end_date")), + ) + + def test_should_return_function_with_no_arguments(self): + CurrentDate = CustomFunction("CURRENT_DATE") + + self.assertEqual("CURRENT_DATE()", str(CurrentDate())) + + +class TestFunctionalCustomFunction(unittest.TestCase): + def test_should_use_custom_function_on_select(self): + service = Table("service") + + DateDiff = CustomFunction("DATE_DIFF", ["interval", "start_date", "end_date"]) + + q = Query.from_(service).select(DateDiff("day", service.created_date, service.updated_date)) + + self.assertEqual( + 'SELECT DATE_DIFF(\'day\',"created_date","updated_date") FROM "service"', + str(q), + ) + + def test_should_fail_use_custom_function_on_select_with_wrong_arguments(self): + service = Table("service") + + DateDiff = CustomFunction("DATE_DIFF", ["interval", "start_date", "end_date"]) + + with self.assertRaises(FunctionException): + Query.from_(service).select(DateDiff("day", service.created_date)) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/test_data_types.py b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/test_data_types.py new file mode 100644 index 0000000000000000000000000000000000000000..52fb4487fe7be3ae28a4e9eb08628fba89dc0f79 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/test_data_types.py @@ -0,0 +1,15 @@ +import unittest +import uuid + +from pypika.terms import ValueWrapper + + +class StringTests(unittest.TestCase): + def test_inline_string_concatentation(self): + self.assertEqual("'it''s'", ValueWrapper("it's").get_sql()) + + +class UuidTests(unittest.TestCase): + def test_uuid_string_generation(self): + id = uuid.uuid4() + self.assertEqual("'{}'".format(id), ValueWrapper(id).get_sql()) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/test_date_math.py b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/test_date_math.py new file mode 100644 index 0000000000000000000000000000000000000000..38db8ef2f8e812a97c6980a7ec6b9a3909d804fb --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/test_date_math.py @@ -0,0 +1,179 @@ +import unittest + +from pypika import ( + Field as F, + Interval, +) +from pypika.enums import Dialects + +dt = F("dt") + + +class AddIntervalTests(unittest.TestCase): + def test_add_microsecond(self): + c = dt + Interval(microseconds=1) + + self.assertEqual("\"dt\"+INTERVAL '1 MICROSECOND'", str(c)) + + def test_add_second(self): + c = dt + Interval(seconds=1) + + self.assertEqual("\"dt\"+INTERVAL '1 SECOND'", str(c)) + + def test_add_minute(self): + c = dt + Interval(minutes=1) + + self.assertEqual("\"dt\"+INTERVAL '1 MINUTE'", str(c)) + + def test_add_day(self): + c = dt + Interval(days=1) + + self.assertEqual("\"dt\"+INTERVAL '1 DAY'", str(c)) + + def test_add_week(self): + c = dt + Interval(weeks=1) + + self.assertEqual("\"dt\"+INTERVAL '1 WEEK'", str(c)) + + def test_add_month(self): + c = dt + Interval(months=1) + + self.assertEqual("\"dt\"+INTERVAL '1 MONTH'", str(c)) + + def test_add_quarter(self): + c = dt + Interval(quarters=1) + + self.assertEqual("\"dt\"+INTERVAL '1 QUARTER'", str(c)) + + def test_add_year(self): + c = dt + Interval(years=1) + + self.assertEqual("\"dt\"+INTERVAL '1 YEAR'", str(c)) + + def test_add_default(self): + c = dt + Interval(days=0) + + self.assertEqual("\"dt\"+INTERVAL '0 DAY'", str(c)) + + +class AddIntervalMultipleUnitsTests(unittest.TestCase): + def test_add_second_microsecond(self): + c = dt + Interval(seconds=1, microseconds=1) + + self.assertEqual("\"dt\"+INTERVAL '1.1 SECOND_MICROSECOND'", str(c)) + + def test_add_minute_microsecond(self): + c = dt + Interval(minutes=1, microseconds=1) + + self.assertEqual("\"dt\"+INTERVAL '1:0.1 MINUTE_MICROSECOND'", str(c)) + + def test_add_minute_second(self): + c = dt + Interval(minutes=1, seconds=1) + + self.assertEqual("\"dt\"+INTERVAL '1:1 MINUTE_SECOND'", str(c)) + + def test_add_hour_microsecond(self): + c = dt + Interval(hours=1, microseconds=1) + + self.assertEqual("\"dt\"+INTERVAL '1:0:0.1 HOUR_MICROSECOND'", str(c)) + + def test_add_hour_second(self): + c = dt + Interval(hours=1, seconds=1) + + self.assertEqual("\"dt\"+INTERVAL '1:0:1 HOUR_SECOND'", str(c)) + + def test_add_hour_minute(self): + c = dt + Interval(hours=1, minutes=1) + + self.assertEqual("\"dt\"+INTERVAL '1:1 HOUR_MINUTE'", str(c)) + + def test_add_day_microsecond(self): + c = dt + Interval(days=1, microseconds=1) + + self.assertEqual("\"dt\"+INTERVAL '1 0:0:0.1 DAY_MICROSECOND'", str(c)) + + def test_add_day_second(self): + c = dt + Interval(days=1, seconds=1) + + self.assertEqual("\"dt\"+INTERVAL '1 0:0:1 DAY_SECOND'", str(c)) + + def test_add_day_minute(self): + c = dt + Interval(days=1, minutes=1) + + self.assertEqual("\"dt\"+INTERVAL '1 0:1 DAY_MINUTE'", str(c)) + + def test_add_day_hour(self): + c = dt + Interval(days=1, hours=1) + + self.assertEqual("\"dt\"+INTERVAL '1 1 DAY_HOUR'", str(c)) + + def test_add_year_month(self): + c = dt + Interval(years=1, months=1) + + self.assertEqual("\"dt\"+INTERVAL '1-1 YEAR_MONTH'", str(c)) + + def test_add_value_right(self): + c = Interval(microseconds=1) - dt + + self.assertEqual("INTERVAL '1 MICROSECOND'-\"dt\"", str(c)) + + def test_add_value_complex_expressions(self): + c = dt + Interval(quarters=1) + Interval(weeks=1) + + self.assertEqual("\"dt\"+INTERVAL '1 QUARTER'+INTERVAL '1 WEEK'", str(c)) + + +class DialectIntervalTests(unittest.TestCase): + def test_mysql_dialect_uses_single_quotes_around_expression_in_an_interval(self): + c = Interval(days=1).get_sql(dialect=Dialects.MYSQL) + self.assertEqual("INTERVAL '1' DAY", c) + + def test_oracle_dialect_uses_single_quotes_around_expression_in_an_interval(self): + c = Interval(days=1).get_sql(dialect=Dialects.ORACLE) + self.assertEqual("INTERVAL '1' DAY", c) + + def test_vertica_dialect_uses_single_quotes_around_interval(self): + c = Interval(days=1).get_sql(dialect=Dialects.VERTICA) + self.assertEqual("INTERVAL '1 DAY'", c) + + def test_redshift_dialect_uses_single_quotes_around_interval(self): + c = Interval(days=1).get_sql(dialect=Dialects.REDSHIFT) + self.assertEqual("INTERVAL '1 DAY'", c) + + def test_postgresql_dialect_uses_single_quotes_around_interval(self): + c = Interval(days=1).get_sql(dialect=Dialects.POSTGRESQL) + self.assertEqual("INTERVAL '1 DAY'", c) + + +class TestNegativeIntervals(unittest.TestCase): + def test_day(self): + c = Interval(days=-1).get_sql() + self.assertEqual("INTERVAL '-1 DAY'", c) + + def test_week(self): + c = Interval(weeks=-1).get_sql() + self.assertEqual("INTERVAL '-1 WEEK'", c) + + def test_month(self): + c = Interval(months=-1).get_sql() + self.assertEqual("INTERVAL '-1 MONTH'", c) + + def test_year(self): + c = Interval(years=-1).get_sql() + self.assertEqual("INTERVAL '-1 YEAR'", c) + + def test_year_month(self): + c = Interval(years=-1, months=-4).get_sql() + self.assertEqual("INTERVAL '-1-4 YEAR_MONTH'", c) + + +class TruncateTrailingZerosTests(unittest.TestCase): + def test_do_not_truncate_integer_values(self): + i = Interval(seconds=10) + + self.assertEqual("INTERVAL '10 SECOND'", str(i)) + + def test_do_not_truncate_months_between_years_and_datys(self): + i = Interval(years=10, days=10) + + self.assertEqual("INTERVAL '10-0-10 YEAR_DAY'", str(i)) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/test_deletes.py b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/test_deletes.py new file mode 100644 index 0000000000000000000000000000000000000000..09df93f5331b845b0c3aed628bf1c4a3ec6b0f02 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/test_deletes.py @@ -0,0 +1,97 @@ +import unittest + +from pypika import PostgreSQLQuery, Query, SYSTEM_TIME, Table + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + +from pypika.terms import Star + + +class DeleteTests(unittest.TestCase): + @classmethod + def setUpClass(cls) -> None: + super().setUpClass() + cls.table_abc = Table("abc") + + def test_omit_where(self): + q = Query.from_("abc").delete() + + self.assertEqual('DELETE FROM "abc"', str(q)) + + def test_omit_where__table_schema(self): + q = Query.from_(Table("abc", "schema1")).delete() + + self.assertEqual('DELETE FROM "schema1"."abc"', str(q)) + + def test_where_field_equals(self): + q1 = Query.from_(self.table_abc).where(self.table_abc.foo == self.table_abc.bar).delete() + q2 = Query.from_(self.table_abc).where(self.table_abc.foo.eq(self.table_abc.bar)).delete() + + self.assertEqual('DELETE FROM "abc" WHERE "foo"="bar"', str(q1)) + self.assertEqual('DELETE FROM "abc" WHERE "foo"="bar"', str(q2)) + + def test_for_portion(self): + with self.subTest("with system time"): + q = Query.from_(self.table_abc.for_portion(SYSTEM_TIME.from_to('2020-01-01', '2020-02-01'))).delete() + + self.assertEqual( + 'DELETE FROM "abc" FOR PORTION OF SYSTEM_TIME FROM \'2020-01-01\' TO \'2020-02-01\'', str(q) + ) + + with self.subTest("with column"): + q = Query.from_( + self.table_abc.for_portion(self.table_abc.valid_period.from_to('2020-01-01', '2020-02-01')) + ).delete() + + self.assertEqual( + 'DELETE FROM "abc" FOR PORTION OF "valid_period" FROM \'2020-01-01\' TO \'2020-02-01\'', str(q) + ) + + +class PostgresDeleteTests(unittest.TestCase): + @classmethod + def setUpClass(cls) -> None: + super().setUpClass() + cls.table_abc = Table("abc") + + def test_delete_returning(self): + q1 = ( + PostgreSQLQuery.from_(self.table_abc) + .where(self.table_abc.foo == self.table_abc.bar) + .delete() + .returning(self.table_abc.id) + ) + + self.assertEqual('DELETE FROM "abc" WHERE "foo"="bar" RETURNING "id"', str(q1)) + + def test_delete_returning_str(self): + q1 = ( + PostgreSQLQuery.from_(self.table_abc) + .where(self.table_abc.foo == self.table_abc.bar) + .delete() + .returning("id") + ) + + self.assertEqual('DELETE FROM "abc" WHERE "foo"="bar" RETURNING "id"', str(q1)) + + def test_delete_returning_star(self): + q1 = ( + PostgreSQLQuery.from_(self.table_abc) + .where(self.table_abc.foo == self.table_abc.bar) + .delete() + .returning(Star()) + ) + + self.assertEqual('DELETE FROM "abc" WHERE "foo"="bar" RETURNING *', str(q1)) + + def test_delete_using(self): + table_trash = Table('trash') + q1 = ( + PostgreSQLQuery.from_(self.table_abc) + .using(table_trash) + .where(self.table_abc.id == table_trash.abc_id) + .delete() + ) + + self.assertEqual('DELETE FROM "abc" USING "trash" WHERE "abc"."id"="trash"."abc_id"', str(q1)) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/test_drop.py b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/test_drop.py new file mode 100644 index 0000000000000000000000000000000000000000..265ae7350d2054549731f9a8c4379fdac95dc580 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/test_drop.py @@ -0,0 +1,49 @@ +import unittest + +from pypika import ( + Columns, + Database, + Query, + Tables, +) + + +class DropTableTests(unittest.TestCase): + database_xyz = Database("mydb") + new_table, existing_table = Tables("abc", "efg") + foo, bar = Columns(("a", "INT"), ("b", "VARCHAR(100)")) + + def test_drop_database(self): + q1 = Query.drop_database(self.database_xyz) + q2 = Query.drop_database(self.database_xyz).if_exists() + + self.assertEqual('DROP DATABASE "mydb"', str(q1)) + self.assertEqual('DROP DATABASE IF EXISTS "mydb"', str(q2)) + + def test_drop_table(self): + q1 = Query.drop_table(self.new_table) + q2 = Query.drop_table(self.new_table).if_exists() + + self.assertEqual('DROP TABLE "abc"', str(q1)) + self.assertEqual('DROP TABLE IF EXISTS "abc"', str(q2)) + + def test_drop_user(self): + q1 = Query.drop_user("myuser") + q2 = Query.drop_user("myuser").if_exists() + + self.assertEqual('DROP USER "myuser"', str(q1)) + self.assertEqual('DROP USER IF EXISTS "myuser"', str(q2)) + + def test_drop_view(self): + q1 = Query.drop_view("myview") + q2 = Query.drop_view("myview").if_exists() + + self.assertEqual('DROP VIEW "myview"', str(q1)) + self.assertEqual('DROP VIEW IF EXISTS "myview"', str(q2)) + + def test_drop_index(self): + q1 = Query.drop_index("myindex") + q2 = Query.drop_index("myindex").if_exists() + + self.assertEqual('DROP INDEX "myindex"', str(q1)) + self.assertEqual('DROP INDEX IF EXISTS "myindex"', str(q2)) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/test_formats.py b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/test_formats.py new file mode 100644 index 0000000000000000000000000000000000000000..6a442757c6659a215661e03f1ca9c3771d394d96 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/test_formats.py @@ -0,0 +1,68 @@ +import unittest + +from pypika import Query, Tables, functions as fn + + +class QuoteTests(unittest.TestCase): + maxDiff = None + + table_abc, table_efg = Tables("abc", "efg") + + def setUp(self): + subquery1 = ( + Query.from_(self.table_abc) + .select( + self.table_abc.foo, + fn.Sum(self.table_abc.fizz + self.table_abc.buzz).as_("fizzbuzz"), + ) + .groupby(self.table_abc.foo) + ) + + subquery2 = Query.from_(self.table_efg).select( + self.table_efg.foo.as_("foo_two"), + self.table_efg.bar, + ) + + self.query = ( + Query.from_(subquery1) + .select(subquery1.foo, subquery1.fizzbuzz) + .join(subquery2) + .on(subquery1.foo == subquery2.foo_two) + .select(subquery2.foo_two, subquery2.bar) + ) + + def test_replace_quote_char_in_complex_query(self): + self.assertEqual( + "SELECT " + "`sq0`.`foo`,`sq0`.`fizzbuzz`," + "`sq1`.`foo_two`,`sq1`.`bar` " + "FROM (" + "SELECT " + "`foo`,SUM(`fizz`+`buzz`) `fizzbuzz` " + "FROM `abc` " + "GROUP BY `foo`" + ") `sq0` JOIN (" + "SELECT " + "`foo` `foo_two`,`bar` " + "FROM `efg`" + ") `sq1` ON `sq0`.`foo`=`sq1`.`foo_two`", + self.query.get_sql(quote_char="`"), + ) + + def test_no_quote_char_in_complex_query(self): + self.assertEqual( + "SELECT " + "sq0.foo,sq0.fizzbuzz," + "sq1.foo_two,sq1.bar " + "FROM (" + "SELECT " + "foo,SUM(fizz+buzz) fizzbuzz " + "FROM abc " + "GROUP BY foo" + ") sq0 JOIN (" + "SELECT " + "foo foo_two,bar " + "FROM efg" + ") sq1 ON sq0.foo=sq1.foo_two", + self.query.get_sql(quote_char=None), + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/test_functions.py b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/test_functions.py new file mode 100644 index 0000000000000000000000000000000000000000..f526966eefc554ec68d0e15fb69de7d69f1604c3 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/test_functions.py @@ -0,0 +1,847 @@ +import unittest + +from pypika import ( + Case, + CaseException, + DatePart, + Field as F, + Query, + Query as Q, + Schema, + Table as T, + VerticaQuery, + functions as fn, +) +from pypika.enums import Dialects, SqlTypes + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + + +class FunctionTests(unittest.TestCase): + def test_dialect_propagation(self): + func = fn.Function("func", ["a"], ["b"]) + self.assertEqual("func(ARRAY['a'],ARRAY['b'])", func.get_sql(dialect=Dialects.POSTGRESQL)) + + def test_is_aggregate_None_for_non_aggregate_function_or_function_with_no_aggregate_functions(self): + self.assertIsNone(fn.Coalesce('a', 0).is_aggregate) + self.assertIsNone(fn.Coalesce(fn.NullIf('a', 0), 0).is_aggregate) + + def test_is_aggregate_True_for_aggregate_function_or_function_with_aggregate_functions(self): + self.assertTrue(fn.Sum('a').is_aggregate) + self.assertTrue(fn.Coalesce(fn.Avg('a'), 0).is_aggregate) + self.assertTrue(fn.Coalesce(fn.NullIf(fn.Sum('a'), 0), 0).is_aggregate) + + +class SchemaTests(unittest.TestCase): + def test_schema_no_schema_in_sql_when_none_set(self): + func = fn.Function("my_proc", 1, 2, 3) + + self.assertEqual("my_proc(1,2,3)", func.get_sql(quote_char='"')) + + def test_schema_included_in_function_sql(self): + a = Schema("a") + func = fn.Function("my_proc", 1, 2, 3, schema=a) + + self.assertEqual('"a".my_proc(1,2,3)', func.get_sql(quote_char='"')) + + +class ArithmeticTests(unittest.TestCase): + t = T("abc") + + def test__addition__fields(self): + q1 = Q.from_("abc").select(F("a") + F("b")) + q2 = Q.from_(self.t).select(self.t.a + self.t.b) + + self.assertEqual('SELECT "a"+"b" FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"+"b" FROM "abc"', str(q2)) + + def test__addition__number(self): + q1 = Q.from_("abc").select(F("a") + 1) + q2 = Q.from_(self.t).select(self.t.a + 1) + + self.assertEqual('SELECT "a"+1 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"+1 FROM "abc"', str(q2)) + + def test__addition__decimal(self): + q1 = Q.from_("abc").select(F("a") + 1.0) + q2 = Q.from_(self.t).select(self.t.a + 1.0) + + self.assertEqual('SELECT "a"+1.0 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"+1.0 FROM "abc"', str(q2)) + + def test__addition__right(self): + q1 = Q.from_("abc").select(1 + F("a")) + q2 = Q.from_(self.t).select(1 + self.t.a) + + self.assertEqual('SELECT 1+"a" FROM "abc"', str(q1)) + self.assertEqual('SELECT 1+"a" FROM "abc"', str(q2)) + + def test__subtraction__fields(self): + q1 = Q.from_("abc").select(F("a") - F("b")) + q2 = Q.from_(self.t).select(self.t.a - self.t.b) + + self.assertEqual('SELECT "a"-"b" FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"-"b" FROM "abc"', str(q2)) + + def test__subtraction__number(self): + q1 = Q.from_("abc").select(F("a") - 1) + q2 = Q.from_(self.t).select(self.t.a - 1) + + self.assertEqual('SELECT "a"-1 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"-1 FROM "abc"', str(q2)) + + def test__subtraction__decimal(self): + q1 = Q.from_("abc").select(F("a") - 1.0) + q2 = Q.from_(self.t).select(self.t.a - 1.0) + + self.assertEqual('SELECT "a"-1.0 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"-1.0 FROM "abc"', str(q2)) + + def test__subtraction__right(self): + q1 = Q.from_("abc").select(1 - F("a")) + q2 = Q.from_(self.t).select(1 - self.t.a) + + self.assertEqual('SELECT 1-"a" FROM "abc"', str(q1)) + self.assertEqual('SELECT 1-"a" FROM "abc"', str(q2)) + + def test__multiplication__fields(self): + q1 = Q.from_("abc").select(F("a") * F("b")) + q2 = Q.from_(self.t).select(self.t.a * self.t.b) + + self.assertEqual('SELECT "a"*"b" FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"*"b" FROM "abc"', str(q2)) + + def test__multiplication__number(self): + q1 = Q.from_("abc").select(F("a") * 1) + q2 = Q.from_(self.t).select(self.t.a * 1) + + self.assertEqual('SELECT "a"*1 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"*1 FROM "abc"', str(q2)) + + def test__multiplication__decimal(self): + q1 = Q.from_("abc").select(F("a") * 1.0) + q2 = Q.from_(self.t).select(self.t.a * 1.0) + + self.assertEqual('SELECT "a"*1.0 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"*1.0 FROM "abc"', str(q2)) + + def test__multiplication__right(self): + q1 = Q.from_("abc").select(1 * F("a")) + q2 = Q.from_(self.t).select(1 * self.t.a) + + self.assertEqual('SELECT 1*"a" FROM "abc"', str(q1)) + self.assertEqual('SELECT 1*"a" FROM "abc"', str(q2)) + + def test__division__fields(self): + q1 = Q.from_("abc").select(F("a") / F("b")) + q2 = Q.from_(self.t).select(self.t.a / self.t.b) + + self.assertEqual('SELECT "a"/"b" FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"/"b" FROM "abc"', str(q2)) + + def test__division__number(self): + q1 = Q.from_("abc").select(F("a") / 1) + q2 = Q.from_(self.t).select(self.t.a / 1) + + self.assertEqual('SELECT "a"/1 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"/1 FROM "abc"', str(q2)) + + def test__division__decimal(self): + q1 = Q.from_("abc").select(F("a") / 1.0) + q2 = Q.from_(self.t).select(self.t.a / 1.0) + + self.assertEqual('SELECT "a"/1.0 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"/1.0 FROM "abc"', str(q2)) + + def test__division__right(self): + q1 = Q.from_("abc").select(1 / F("a")) + q2 = Q.from_(self.t).select(1 / self.t.a) + + self.assertEqual('SELECT 1/"a" FROM "abc"', str(q1)) + self.assertEqual('SELECT 1/"a" FROM "abc"', str(q2)) + + def test__leftshift__fields(self): + q1 = Q.from_("abc").select(F("a") << F("b")) + q2 = Q.from_(self.t).select(self.t.a << self.t.b) + + self.assertEqual('SELECT "a"<<"b" FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"<<"b" FROM "abc"', str(q2)) + + def test__leftshift__number(self): + q1 = Q.from_("abc").select(F('a') << 2) + q2 = Q.from_(self.t).select(self.t.a << 2) + + self.assertEqual('SELECT "a"<<2 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"<<2 FROM "abc"', str(q2)) + + def test__leftshift__right(self): + q1 = Q.from_("abc").select(1 << F("a")) + q2 = Q.from_(self.t).select(1 << self.t.a) + + self.assertEqual('SELECT 1<<"a" FROM "abc"', str(q1)) + self.assertEqual('SELECT 1<<"a" FROM "abc"', str(q2)) + + def test__rightshift__fields(self): + q1 = Q.from_("abc").select(F("a") >> F("b")) + q2 = Q.from_(self.t).select(self.t.a >> self.t.b) + + self.assertEqual('SELECT "a">>"b" FROM "abc"', str(q1)) + self.assertEqual('SELECT "a">>"b" FROM "abc"', str(q2)) + + def test__rightshift__number(self): + q1 = Q.from_("abc").select(F('a') >> 2) + q2 = Q.from_(self.t).select(self.t.a >> 2) + + self.assertEqual('SELECT "a">>2 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a">>2 FROM "abc"', str(q2)) + + def test__rightshift__right(self): + q1 = Q.from_("abc").select(1 >> F("a")) + q2 = Q.from_(self.t).select(1 >> self.t.a) + + self.assertEqual('SELECT 1>>"a" FROM "abc"', str(q1)) + self.assertEqual('SELECT 1>>"a" FROM "abc"', str(q2)) + + def test__complex_op(self): + q1 = Q.from_("abc").select(2 + 1 / F("a") - 5) + q2 = Q.from_(self.t).select(2 + 1 / self.t.a - 5) + + self.assertEqual('SELECT 2+1/"a"-5 FROM "abc"', str(q1)) + self.assertEqual('SELECT 2+1/"a"-5 FROM "abc"', str(q2)) + + def test__complex_op_add_parentheses(self): + q1 = Q.from_("abc").select((F("a") + 1) + (F("b") - 5)) + q2 = Q.from_(self.t).select((self.t.a + 1) + (self.t.b - 5)) + q3 = Q.from_("abc").select((F("a") / 1) + (F("b") / 5)) + q4 = Q.from_(self.t).select((self.t.a / 1) + (self.t.b / 5)) + + self.assertEqual('SELECT "a"+1+"b"-5 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"+1+"b"-5 FROM "abc"', str(q2)) + self.assertEqual('SELECT "a"/1+"b"/5 FROM "abc"', str(q3)) + self.assertEqual('SELECT "a"/1+"b"/5 FROM "abc"', str(q4)) + + def test__complex_op_sub_parentheses(self): + q1 = Q.from_("abc").select((F("a") + 1) - (F("b") - 5)) + q2 = Q.from_(self.t).select((self.t.a + 1) - (self.t.b - 5)) + q3 = Q.from_("abc").select((F("a") / 1) - (F("b") / 5)) + q4 = Q.from_(self.t).select((self.t.a / 1) - (self.t.b / 5)) + + self.assertEqual('SELECT "a"+1-("b"-5) FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"+1-("b"-5) FROM "abc"', str(q2)) + self.assertEqual('SELECT "a"/1-"b"/5 FROM "abc"', str(q3)) + self.assertEqual('SELECT "a"/1-"b"/5 FROM "abc"', str(q4)) + + def test__complex_op_mul_parentheses(self): + q1 = Q.from_("abc").select((F("a") + 1) * (F("b") - 5)) + q2 = Q.from_(self.t).select((self.t.a + 1) * (self.t.b - 5)) + q3 = Q.from_("abc").select((F("a") / 1) * (F("b") - 5)) + q4 = Q.from_(self.t).select((self.t.a / 1) * (self.t.b - 5)) + q5 = Q.from_("abc").select((F("a") + 1) * (F("b") / 5)) + q6 = Q.from_(self.t).select((self.t.a + 1) * (self.t.b / 5)) + + self.assertEqual('SELECT ("a"+1)*("b"-5) FROM "abc"', str(q1)) + self.assertEqual('SELECT ("a"+1)*("b"-5) FROM "abc"', str(q2)) + self.assertEqual('SELECT "a"/1*("b"-5) FROM "abc"', str(q3)) + self.assertEqual('SELECT "a"/1*("b"-5) FROM "abc"', str(q4)) + self.assertEqual('SELECT ("a"+1)*"b"/5 FROM "abc"', str(q5)) + self.assertEqual('SELECT ("a"+1)*"b"/5 FROM "abc"', str(q6)) + + def test__complex_op_mul_no_parentheses(self): + q = Q.from_("abc").select(F("a") + 1 * F("b") - 5) + + self.assertEqual('SELECT "a"+1*"b"-5 FROM "abc"', str(q)) + + def test__complex_op_div_parentheses(self): + q1 = Q.from_("abc").select((F("a") + 1) / (F("b") - 5)) + q2 = Q.from_(self.t).select((self.t.a + 1) / (self.t.b - 5)) + q3 = Q.from_("abc").select((F("a") / 1) / (F("b") - 5)) + q4 = Q.from_(self.t).select((self.t.a / 1) / (self.t.b - 5)) + q5 = Q.from_("abc").select((F("a") + 1) / (F("b") * 5)) + q6 = Q.from_(self.t).select((self.t.a + 1) / (self.t.b * 5)) + + self.assertEqual('SELECT ("a"+1)/("b"-5) FROM "abc"', str(q1)) + self.assertEqual('SELECT ("a"+1)/("b"-5) FROM "abc"', str(q2)) + self.assertEqual('SELECT "a"/1/("b"-5) FROM "abc"', str(q3)) + self.assertEqual('SELECT "a"/1/("b"-5) FROM "abc"', str(q4)) + self.assertEqual('SELECT ("a"+1)/("b"*5) FROM "abc"', str(q5)) + self.assertEqual('SELECT ("a"+1)/("b"*5) FROM "abc"', str(q6)) + + def test__complex_op_div_no_parentheses(self): + q = Q.from_("abc").select(F("a") + 1 / F("b") - 5) + + self.assertEqual('SELECT "a"+1/"b"-5 FROM "abc"', str(q)) + + def test__complex_op_exponent_parentheses(self): + q1 = Q.from_("abc").select(F("a") / (F("b") ** 2)) + q2 = Q.from_(self.t).select(self.t.a / (self.t.b**2)) + q3 = Q.from_("abc").select(F("a") ** (F("b") / 2)) + q4 = Q.from_(self.t).select(self.t.a ** (self.t.b / 2)) + q5 = Q.from_("abc").select((F("a") ** F("b")) ** 2) + q6 = Q.from_(self.t).select((self.t.a**self.t.b) ** 2) + + self.assertEqual('SELECT "a"/POW("b",2) FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"/POW("b",2) FROM "abc"', str(q2)) + self.assertEqual('SELECT POW("a","b"/2) FROM "abc"', str(q3)) + self.assertEqual('SELECT POW("a","b"/2) FROM "abc"', str(q4)) + self.assertEqual('SELECT POW(POW("a","b"),2) FROM "abc"', str(q5)) + self.assertEqual('SELECT POW(POW("a","b"),2) FROM "abc"', str(q6)) + + def test__complex_op_exponent_no_parentheses(self): + q1 = Q.from_("abc").select(F("a") ** F("b") ** 2) + q2 = Q.from_(self.t).select(self.t.a**self.t.b**2) + q3 = Q.from_("abc").select(F("a") / F("b") ** 2) + q4 = Q.from_(self.t).select(self.t.a / self.t.b**2) + + self.assertEqual('SELECT POW("a",POW("b",2)) FROM "abc"', str(q1)) + self.assertEqual('SELECT POW("a",POW("b",2)) FROM "abc"', str(q2)) + self.assertEqual('SELECT "a"/POW("b",2) FROM "abc"', str(q3)) + self.assertEqual('SELECT "a"/POW("b",2) FROM "abc"', str(q4)) + + def test__complex_op_function_parentheses(self): + q1 = Q.from_("abc").select(F("a") / (fn.Sum(F("b")) / 2)) + q2 = Q.from_("abc").select(self.t.a / (fn.Sum(self.t.b) / 2)) + q3 = Q.from_("abc").select(fn.Sum(F("a") / (F("b") / 2))) + q4 = Q.from_("abc").select(fn.Sum(self.t.a / (self.t.b / 2))) + + self.assertEqual('SELECT "a"/(SUM("b")/2) FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"/(SUM("b")/2) FROM "abc"', str(q2)) + self.assertEqual('SELECT SUM("a"/("b"/2)) FROM "abc"', str(q3)) + self.assertEqual('SELECT SUM("a"/("b"/2)) FROM "abc"', str(q4)) + + def test__complex_op_modulus_parentheses(self): + q1 = Q.from_("abc").select(F("a") / (F("b") % 2)) + q2 = Q.from_(self.t).select(self.t.a / (self.t.b % 2)) + q3 = Q.from_("abc").select(F("a") % (F("b") / 2)) + q4 = Q.from_(self.t).select(self.t.a % (self.t.b / 2)) + q5 = Q.from_("abc").select(F("a") % (F("b") % 2)) + q6 = Q.from_("abc").select(self.t.a % (self.t.b % 2)) + + self.assertEqual('SELECT "a"/MOD("b",2) FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"/MOD("b",2) FROM "abc"', str(q2)) + self.assertEqual('SELECT MOD("a","b"/2) FROM "abc"', str(q3)) + self.assertEqual('SELECT MOD("a","b"/2) FROM "abc"', str(q4)) + self.assertEqual('SELECT MOD("a",MOD("b",2)) FROM "abc"', str(q5)) + self.assertEqual('SELECT MOD("a",MOD("b",2)) FROM "abc"', str(q6)) + + def test__complex_op_modulus_no_parentheses(self): + q1 = Q.from_("abc").select(F("a") % F("b") % 2) + q2 = Q.from_(self.t).select(self.t.a % self.t.b % 2) + q3 = Q.from_("abc").select(F("a") / F("b") % 2) + q4 = Q.from_(self.t).select(self.t.a / self.t.b % 2) + + self.assertEqual('SELECT MOD(MOD("a","b"),2) FROM "abc"', str(q1)) + self.assertEqual('SELECT MOD(MOD("a","b"),2) FROM "abc"', str(q2)) + self.assertEqual('SELECT MOD("a"/"b",2) FROM "abc"', str(q3)) + self.assertEqual('SELECT MOD("a"/"b",2) FROM "abc"', str(q4)) + + def test__complex_op_floor_parentheses(self): + q1 = Q.from_("abc").select(F("a") / (fn.Floor(F("b")) / 2)) + q2 = Q.from_("abc").select(self.t.a / (fn.Floor(self.t.b) / 2)) + q3 = Q.from_("abc").select(fn.Floor(F("a") / (F("b") / 2))) + q4 = Q.from_("abc").select(fn.Floor(self.t.a / (self.t.b / 2))) + + self.assertEqual('SELECT "a"/(FLOOR("b")/2) FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"/(FLOOR("b")/2) FROM "abc"', str(q2)) + self.assertEqual('SELECT FLOOR("a"/("b"/2)) FROM "abc"', str(q3)) + self.assertEqual('SELECT FLOOR("a"/("b"/2)) FROM "abc"', str(q4)) + + def test__complex_op_nested_parentheses(self): + q1 = Q.from_("abc").select(F("a") / (F("b") / ((F("c") / 2)))) + q2 = Q.from_("abc").select(self.t.a / (self.t.b / ((self.t.c / 2)))) + + self.assertEqual('SELECT "a"/("b"/("c"/2)) FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"/("b"/("c"/2)) FROM "abc"', str(q2)) + + def test__arithmetic_equality(self): + q1 = Q.from_("abc").select(F("a") / 2 == 2) + q2 = Q.from_(self.t).select(self.t.a / 2 == 2) + + self.assertEqual('SELECT "a"/2=2 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"/2=2 FROM "abc"', str(q2)) + + def test__arithmetic_with_function(self): + q1 = Q.from_("abc").select(fn.Sum(F("foo")) + 1) + q2 = Q.from_(self.t).select(fn.Sum(self.t.foo) + 1) + + self.assertEqual('SELECT SUM("foo")+1 FROM "abc"', str(q1)) + self.assertEqual('SELECT SUM("foo")+1 FROM "abc"', str(q2)) + + def test__exponent__number(self): + q1 = Q.from_("abc").select(F("a") ** 2) + q2 = Q.from_(self.t).select(self.t.a**2) + + self.assertEqual('SELECT POW("a",2) FROM "abc"', str(q1)) + self.assertEqual('SELECT POW("a",2) FROM "abc"', str(q2)) + + def test__exponent__decimal(self): + q1 = Q.from_("abc").select(F("a") ** 0.5) + q2 = Q.from_(self.t).select(self.t.a**0.5) + + self.assertEqual('SELECT POW("a",0.5) FROM "abc"', str(q1)) + self.assertEqual('SELECT POW("a",0.5) FROM "abc"', str(q2)) + + def test__modulus__number(self): + q1 = Q.from_("abc").select(F("a") % 2) + q2 = Q.from_(self.t).select(self.t.a % 2) + + self.assertEqual('SELECT MOD("a",2) FROM "abc"', str(q1)) + self.assertEqual('SELECT MOD("a",2) FROM "abc"', str(q2)) + + def test__floor(self): + q1 = Q.from_("abc").select(fn.Floor(F("foo"))) + q2 = Q.from_(self.t).select(fn.Floor(self.t.foo)) + + self.assertEqual('SELECT FLOOR("foo") FROM "abc"', str(q1)) + self.assertEqual('SELECT FLOOR("foo") FROM "abc"', str(q2)) + + +class AggregationTests(unittest.TestCase): + def test__count(self): + q = Q.from_("abc").select(fn.Count(F("foo"))) + + self.assertEqual('SELECT COUNT("foo") FROM "abc"', str(q)) + + def test__count__star(self): + q = Q.from_("abc").select(fn.Count("*")) + + self.assertEqual('SELECT COUNT(*) FROM "abc"', str(q)) + + def test__sum(self): + q = Q.from_("abc").select(fn.Sum(F("foo"))) + + self.assertEqual('SELECT SUM("foo") FROM "abc"', str(q)) + + def test__avg(self): + q = Q.from_("abc").select(fn.Avg(F("foo"))) + + self.assertEqual('SELECT AVG("foo") FROM "abc"', str(q)) + + def test__first(self): + q = Q.from_("abc").select(fn.First(F("foo"))) + + self.assertEqual('SELECT FIRST("foo") FROM "abc"', str(q)) + + def test__last(self): + q = Q.from_("abc").select(fn.Last(F("foo"))) + + self.assertEqual('SELECT LAST("foo") FROM "abc"', str(q)) + + def test__min(self): + q = Q.from_("abc").select(fn.Min(F("foo"))) + + self.assertEqual('SELECT MIN("foo") FROM "abc"', str(q)) + + def test__max(self): + q = Q.from_("abc").select(fn.Max(F("foo"))) + + self.assertEqual('SELECT MAX("foo") FROM "abc"', str(q)) + + def test__std(self): + q = Q.from_("abc").select(fn.Std(F("foo"))) + + self.assertEqual('SELECT STD("foo") FROM "abc"', str(q)) + + def test__stddev(self): + q = Q.from_("abc").select(fn.StdDev(F("foo"))) + + self.assertEqual('SELECT STDDEV("foo") FROM "abc"', str(q)) + + def test__approx_percentile(self): + q = Q.from_("abc").select(fn.ApproximatePercentile(F("foo"), 0.5)) + + self.assertEqual( + 'SELECT APPROXIMATE_PERCENTILE("foo" USING PARAMETERS percentile=0.5) FROM "abc"', + str(q), + ) + + def test__subquery_in_params_functions(self): + subquery = Query.from_('table').select('id') + func = fn.Function('func', 'id', subquery) + self.assertEqual("func('id',(SELECT id FROM table))", func.get_sql()) + + +class ConditionTests(unittest.TestCase): + def test__case__raw(self): + q = Q.from_("abc").select(Case().when(F("foo") == 1, "a")) + + self.assertEqual('SELECT CASE WHEN "foo"=1 THEN \'a\' END FROM "abc"', str(q)) + + def test__case__else(self): + q = Q.from_("abc").select(Case().when(F("foo") == 1, "a").else_("b")) + + self.assertEqual("SELECT CASE WHEN \"foo\"=1 THEN 'a' ELSE 'b' END FROM \"abc\"", str(q)) + + def test__case__field(self): + q = Q.from_("abc").select(Case().when(F("foo") == 1, F("bar")).else_(F("buz"))) + + self.assertEqual('SELECT CASE WHEN "foo"=1 THEN "bar" ELSE "buz" END FROM "abc"', str(q)) + + def test__case__multi(self): + q = Q.from_("abc").select(Case().when(F("foo") > 0, F("fiz")).when(F("bar") <= 0, F("buz")).else_(1)) + + self.assertEqual( + 'SELECT CASE WHEN "foo">0 THEN "fiz" WHEN "bar"<=0 THEN "buz" ELSE 1 END FROM "abc"', + str(q), + ) + + def test__case__no_cases(self): + with self.assertRaises(CaseException): + q = Q.from_("abc").select(Case()) + + str(q) + + +class StringTests(unittest.TestCase): + t = T("abc") + + def test__ascii__str(self): + q = Q.select(fn.Ascii("2")) + + self.assertEqual("SELECT ASCII('2')", str(q)) + + def test__ascii__int(self): + q = Q.select(fn.Ascii(2)) + + self.assertEqual("SELECT ASCII(2)", str(q)) + + def test__ascii__field(self): + q = Q.from_(self.t).select(fn.Ascii(self.t.foo)) + + self.assertEqual('SELECT ASCII("foo") FROM "abc"', str(q)) + + def test__bin__str(self): + q = Q.select(fn.Bin("2")) + + self.assertEqual("SELECT BIN('2')", str(q)) + + def test__bin__int(self): + q = Q.select(fn.Bin(2)) + + self.assertEqual("SELECT BIN(2)", str(q)) + + def test__bin__field(self): + q = Q.from_(self.t).select(fn.Bin(self.t.foo)) + + self.assertEqual('SELECT BIN("foo") FROM "abc"', str(q)) + + def test__concat__str(self): + q = Q.select(fn.Concat("p", "y", "q", "b")) + + self.assertEqual("SELECT CONCAT('p','y','q','b')", str(q)) + + def test__concat__field(self): + q = Q.from_(self.t).select(fn.Concat(self.t.foo, self.t.bar)) + + self.assertEqual('SELECT CONCAT("foo","bar") FROM "abc"', str(q)) + + def test__insert__str(self): + q = Q.select(fn.Insert("Quadratic", 3, 4, "What")) + + self.assertEqual("SELECT INSERT('Quadratic',3,4,'What')", str(q)) + + def test__insert__field(self): + q = Q.from_(self.t).select(fn.Insert(self.t.foo, 3, 4, self.t.bar)) + + self.assertEqual('SELECT INSERT("foo",3,4,"bar") FROM "abc"', str(q)) + + def test__lower__str(self): + q = Q.select(fn.Lower("ABC")) + + self.assertEqual("SELECT LOWER('ABC')", str(q)) + + def test__lower__field(self): + q = Q.from_(self.t).select(fn.Lower(self.t.foo)) + + self.assertEqual('SELECT LOWER("foo") FROM "abc"', str(q)) + + def test__length__str(self): + q = Q.select(fn.Length("ABC")) + + self.assertEqual("SELECT LENGTH('ABC')", str(q)) + + def test__length__field(self): + q = Q.from_(self.t).select(fn.Length(self.t.foo)) + + self.assertEqual('SELECT LENGTH("foo") FROM "abc"', str(q)) + + def test__substring(self): + q = Q.from_(self.t).select(fn.Substring(self.t.foo, 2, 6)) + + self.assertEqual('SELECT SUBSTRING("foo",2,6) FROM "abc"', str(q)) + + def test__replace__str(self): + q = Q.select(fn.Replace("ABC_DEF", "_", " ")) + self.assertEqual("SELECT REPLACE('ABC_DEF','_',' ')", str(q)) + + def test__replace__field(self): + q = Q.from_(self.t).select(fn.Replace(self.t.foobar, self.t.foo, self.t.bar)) + self.assertEqual('SELECT REPLACE("foobar","foo","bar") FROM "abc"', str(q)) + + +class SplitPartFunctionTests(unittest.TestCase): + t = T("abc") + + def test__split_part(self): + q = VerticaQuery.from_(self.t).select(fn.SplitPart(self.t.foo, "|", 3)) + + self.assertEqual('SELECT SPLIT_PART("foo",\'|\',3) FROM "abc"', str(q)) + + +class RegexpLikeFunctionTests(unittest.TestCase): + t = T("abc") + + def test__regexp_like(self): + q = VerticaQuery.from_(self.t).select(fn.RegexpLike(self.t.foo, "^a", "x")) + + self.assertEqual("SELECT REGEXP_LIKE(\"foo\",'^a','x') FROM \"abc\"", str(q)) + + +class CastTests(unittest.TestCase): + t = T("abc") + + def test__cast__as(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.UNSIGNED)) + + self.assertEqual('SELECT CAST("foo" AS UNSIGNED) FROM "abc"', str(q)) + + def test__cast__signed(self): + q1 = Q.from_(self.t).select(fn.Signed(self.t.foo)) + q2 = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.SIGNED)) + + self.assertEqual('SELECT CAST("foo" AS SIGNED) FROM "abc"', str(q1)) + self.assertEqual('SELECT CAST("foo" AS SIGNED) FROM "abc"', str(q2)) + + def test__cast__unsigned(self): + q1 = Q.from_(self.t).select(fn.Unsigned(self.t.foo)) + q2 = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.UNSIGNED)) + + self.assertEqual('SELECT CAST("foo" AS UNSIGNED) FROM "abc"', str(q1)) + self.assertEqual('SELECT CAST("foo" AS UNSIGNED) FROM "abc"', str(q2)) + + def test__cast__date(self): + q1 = Q.from_(self.t).select(fn.Date(self.t.foo)) + q2 = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.DATE)) + + self.assertEqual('SELECT DATE("foo") FROM "abc"', str(q1)) + self.assertEqual('SELECT CAST("foo" AS DATE) FROM "abc"', str(q2)) + + def test__cast__timestamp(self): + q1 = Q.from_(self.t).select(fn.Timestamp(self.t.foo)) + q2 = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.TIMESTAMP)) + + self.assertEqual('SELECT TIMESTAMP("foo") FROM "abc"', str(q1)) + self.assertEqual('SELECT CAST("foo" AS TIMESTAMP) FROM "abc"', str(q2)) + + def test__cast__char(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.CHAR)) + + self.assertEqual('SELECT CAST("foo" AS CHAR) FROM "abc"', str(q)) + + def test__cast__char_with_arg(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.VARCHAR(24))) + + self.assertEqual('SELECT CAST("foo" AS VARCHAR(24)) FROM "abc"', str(q)) + + def test__cast__varchar(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.VARCHAR)) + + self.assertEqual('SELECT CAST("foo" AS VARCHAR) FROM "abc"', str(q)) + + def test__cast__varchar_with_arg(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.VARCHAR(24))) + + self.assertEqual('SELECT CAST("foo" AS VARCHAR(24)) FROM "abc"', str(q)) + + def test__cast__long_varchar(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.LONG_VARCHAR)) + + self.assertEqual('SELECT CAST("foo" AS LONG VARCHAR) FROM "abc"', str(q)) + + def test__cast__long_varchar_with_arg(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.LONG_VARCHAR(24))) + + self.assertEqual('SELECT CAST("foo" AS LONG VARCHAR(24)) FROM "abc"', str(q)) + + def test__cast__binary(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.BINARY)) + + self.assertEqual('SELECT CAST("foo" AS BINARY) FROM "abc"', str(q)) + + def test__cast__binary_with_arg(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.BINARY(24))) + + self.assertEqual('SELECT CAST("foo" AS BINARY(24)) FROM "abc"', str(q)) + + def test__cast__varbinary(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.VARBINARY)) + + self.assertEqual('SELECT CAST("foo" AS VARBINARY) FROM "abc"', str(q)) + + def test__cast__varbinary_with_arg(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.VARBINARY(24))) + + self.assertEqual('SELECT CAST("foo" AS VARBINARY(24)) FROM "abc"', str(q)) + + def test__cast__long_varbinary(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.LONG_VARBINARY)) + + self.assertEqual('SELECT CAST("foo" AS LONG VARBINARY) FROM "abc"', str(q)) + + def test__cast__long_varbinary_with_arg(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.LONG_VARBINARY(24))) + + self.assertEqual('SELECT CAST("foo" AS LONG VARBINARY(24)) FROM "abc"', str(q)) + + def test__cast__boolean(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.BOOLEAN)) + + self.assertEqual('SELECT CAST("foo" AS BOOLEAN) FROM "abc"', str(q)) + + def test__cast__integer(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.INTEGER)) + + self.assertEqual('SELECT CAST("foo" AS INTEGER) FROM "abc"', str(q)) + + def test__cast__float(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.FLOAT)) + + self.assertEqual('SELECT CAST("foo" AS FLOAT) FROM "abc"', str(q)) + + def test__cast__numeric(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.NUMERIC)) + + self.assertEqual('SELECT CAST("foo" AS NUMERIC) FROM "abc"', str(q)) + + def test__tochar__(self): + q = Q.from_(self.t).select(fn.ToChar(self.t.foo, "SomeFormat")) + + self.assertEqual('SELECT TO_CHAR("foo",\'SomeFormat\') FROM "abc"', str(q)) + + +class DateFunctionsTests(unittest.TestCase): + dt = F("dt") + t = T("abc") + t2 = T("efg") + + def _test_extract_datepart(self, date_part): + q = Q.from_(self.t).select(fn.Extract(date_part, self.t.foo)) + + value = getattr(date_part, 'value', date_part) + self.assertEqual('SELECT EXTRACT(%s FROM "foo") FROM "abc"' % value, str(q)) + + def test_extract_microsecond(self): + self._test_extract_datepart(DatePart.microsecond) + self._test_extract_datepart(DatePart.microsecond.value) + + def test_extract_second(self): + self._test_extract_datepart(DatePart.second) + self._test_extract_datepart(DatePart.second.value) + + def test_extract_minute(self): + self._test_extract_datepart(DatePart.minute) + self._test_extract_datepart(DatePart.minute.value) + + def test_extract_hour(self): + self._test_extract_datepart(DatePart.hour) + self._test_extract_datepart(DatePart.hour.value) + + def test_extract_day(self): + self._test_extract_datepart(DatePart.day) + self._test_extract_datepart(DatePart.day.value) + + def test_extract_week(self): + self._test_extract_datepart(DatePart.week) + self._test_extract_datepart(DatePart.week.value) + + def test_extract_month(self): + self._test_extract_datepart(DatePart.month) + self._test_extract_datepart(DatePart.month.value) + + def test_extract_quarter(self): + self._test_extract_datepart(DatePart.quarter) + self._test_extract_datepart(DatePart.quarter.value) + + def test_extract_year(self): + self._test_extract_datepart(DatePart.year) + self._test_extract_datepart(DatePart.year.value) + + def test_extract_join(self): + q = Q.from_(self.t).join(self.t2).on(self.t.id == self.t2.t_id).select(fn.Extract(DatePart.year, self.t.foo)) + + self.assertEqual( + 'SELECT EXTRACT(YEAR FROM "abc"."foo") FROM "abc" ' 'JOIN "efg" ON "abc"."id"="efg"."t_id"', str(q) + ) + + def test_timestampadd(self): + a = fn.TimestampAdd("year", 1, "2017-10-01") + self.assertEqual(str(a), "TIMESTAMPADD(year,1,'2017-10-01')") + + def test_time_diff(self): + a = fn.TimeDiff("18:00:00", "10:00:00") + self.assertEqual(str(a), "TIMEDIFF('18:00:00','10:00:00')") + + def test_date_add(self): + a = fn.DateAdd("year", 1, "2017-10-01") + self.assertEqual(str(a), "DATE_ADD(year,1,'2017-10-01')") + + def test_now(self): + query = Query.select(fn.Now()) + + self.assertEqual("SELECT NOW()", str(query)) + + def test_utc_timestamp(self): + query = Query.select(fn.UtcTimestamp()) + + self.assertEqual("SELECT UTC_TIMESTAMP()", str(query)) + + def test_current_date(self): + query = Query.select(fn.CurDate()) + + self.assertEqual("SELECT CURRENT_DATE()", str(query)) + + def test_current_time(self): + query = Query.select(fn.CurTime()) + + self.assertEqual("SELECT CURRENT_TIME()", str(query)) + + def test_current_timestamp(self): + query = Query.select(fn.CurTimestamp()) + + self.assertEqual("SELECT CURRENT_TIMESTAMP", str(query)) + + def test_current_timestamp_with_alias(self): + query = Query.select(fn.CurTimestamp("ts")) + + self.assertEqual('SELECT CURRENT_TIMESTAMP "ts"', str(query)) + + def test_to_date(self): + q1 = fn.ToDate("2019-06-21", "yyyy-mm-dd") + q2 = Query.from_(self.t).select(fn.ToDate("2019-06-21", "yyyy-mm-dd")) + q3 = Query.from_(self.t).select(fn.ToDate(F("foo"), "yyyy-mm-dd")) + + self.assertEqual(str(q1), "TO_DATE('2019-06-21','yyyy-mm-dd')") + self.assertEqual(str(q2), "SELECT TO_DATE('2019-06-21','yyyy-mm-dd') FROM \"abc\"") + self.assertEqual(str(q3), 'SELECT TO_DATE("foo",\'yyyy-mm-dd\') FROM "abc"') + + +class NullFunctionsTests(unittest.TestCase): + def test_isnull(self): + q = Q.from_("abc").select(fn.IsNull(F("foo"))) + + self.assertEqual('SELECT ISNULL("foo") FROM "abc"', str(q)) + + def test_coalesce(self): + q = Q.from_("abc").select(fn.Coalesce(F("foo"), 0)) + + self.assertEqual('SELECT COALESCE("foo",0) FROM "abc"', str(q)) + + def test_nullif(self): + q = Q.from_("abc").select(fn.NullIf(F("foo"), 0)) + + self.assertEqual('SELECT NULLIF("foo",0) FROM "abc"', str(q)) + + def test_nvl(self): + q = Q.from_("abc").select(fn.NVL(F("foo"), 0)) + + self.assertEqual('SELECT NVL("foo",0) FROM "abc"', str(q)) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/test_groupby_modifiers.py b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/test_groupby_modifiers.py new file mode 100644 index 0000000000000000000000000000000000000000..978834c2409f4b4800fedb9b1bb2538a31d0f31c --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/test_groupby_modifiers.py @@ -0,0 +1,168 @@ +import unittest + +from pypika import Query, Rollup, RollupException, Table, functions as fn + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + + +class RollupTests(unittest.TestCase): + table = Table("abc") + + def test_mysql_one_groupby(self): + q = ( + Query.from_(self.table) + .select(self.table.foo, fn.Sum(self.table.bar)) + .rollup(self.table.foo, vendor="mysql") + ) + + self.assertEqual('SELECT "foo",SUM("bar") FROM "abc" GROUP BY "foo" WITH ROLLUP', str(q)) + + def test_mysql_rollup_two_groupbys(self): + q = ( + Query.from_(self.table) + .select(self.table.foo, self.table.fiz, fn.Sum(self.table.bar)) + .rollup(self.table.foo, self.table.fiz, vendor="mysql") + ) + + self.assertEqual( + 'SELECT "foo","fiz",SUM("bar") FROM "abc" GROUP BY "foo","fiz" WITH ROLLUP', + str(q), + ) + + def test_no_rollup_before_groupby(self): + with self.assertRaises(RollupException): + Query.from_(self.table).select(self.table.foo, fn.Sum(self.table.bar)).rollup(vendor="mysql") + + def test_no_rollup_after_rollup_mysql(self): + with self.assertRaises(AttributeError): + Query.from_(self.table).select(self.table.foo, self.table.fiz, fn.Sum(self.table.bar)).rollup( + self.table.foo, vendor="mysql" + ).rollup(self.table.fiz, vendor="mysql") + + def test_verticaoracle_func_one_groupby(self): + q = Query.from_(self.table).select(self.table.foo, fn.Sum(self.table.bar)).groupby(Rollup(self.table.foo)) + + self.assertEqual('SELECT "foo",SUM("bar") FROM "abc" GROUP BY ROLLUP("foo")', str(q)) + + def test_verticaoracle_func_two_groupbys(self): + q = ( + Query.from_(self.table) + .select(self.table.foo, self.table.fiz, fn.Sum(self.table.bar)) + .groupby( + Rollup( + self.table.foo, + self.table.fiz, + ) + ) + ) + + self.assertEqual( + 'SELECT "foo","fiz",SUM("bar") FROM "abc" GROUP BY ROLLUP("foo","fiz")', + str(q), + ) + + def test_verticaoracle_func_partial(self): + q = ( + Query.from_(self.table) + .select(self.table.foo, self.table.fiz, self.table.buz, fn.Sum(self.table.bar)) + .groupby( + Rollup( + self.table.foo, + self.table.fiz, + ), + self.table.buz, + ) + ) + + self.assertEqual( + 'SELECT "foo","fiz","buz",SUM("bar") FROM "abc" GROUP BY ROLLUP("foo","fiz"),"buz"', + str(q), + ) + + def test_verticaoracle_from_groupbys(self): + q = Query.from_(self.table).select(self.table.foo, fn.Sum(self.table.bar)).rollup(self.table.foo) + + self.assertEqual('SELECT "foo",SUM("bar") FROM "abc" GROUP BY ROLLUP("foo")', str(q)) + + def test_verticaoracle_from_two_groupbys(self): + q = ( + Query.from_(self.table) + .select(self.table.foo, self.table.fiz, fn.Sum(self.table.bar)) + .rollup( + self.table.foo, + self.table.fiz, + ) + ) + + self.assertEqual( + 'SELECT "foo","fiz",SUM("bar") FROM "abc" GROUP BY ROLLUP("foo","fiz")', + str(q), + ) + + def test_verticaoracle_from_parameters(self): + q = ( + Query.from_(self.table) + .select(self.table.foo, self.table.fiz, fn.Sum(self.table.bar)) + .groupby( + self.table.foo, + ) + .rollup( + self.table.fiz, + ) + ) + + self.assertEqual( + 'SELECT "foo","fiz",SUM("bar") FROM "abc" GROUP BY "foo",ROLLUP("fiz")', + str(q), + ) + + def test_verticaoracle_multiple_rollups(self): + q = ( + Query.from_(self.table) + .select(self.table.foo, self.table.fiz, fn.Sum(self.table.bar)) + .rollup( + self.table.foo, + ) + .rollup( + self.table.fiz, + ) + ) + + self.assertEqual( + 'SELECT "foo","fiz",SUM("bar") FROM "abc" GROUP BY ROLLUP("foo","fiz")', + str(q), + ) + + def test_verticaoracle_rollups_with_parity(self): + q = ( + Query.from_(self.table) + .select( + self.table.buz, + ) + .rollup( + [self.table.foo, self.table.bar], + self.table.fiz, + ) + ) + + self.assertEqual('SELECT "buz" FROM "abc" GROUP BY ROLLUP(("foo","bar"),"fiz")', str(q)) + + def test_verticaoracle_rollups_with_multiple_rollups_and_parity(self): + q = ( + Query.from_(self.table) + .select( + self.table.buz, + ) + .rollup( + [self.table.foo, self.table.bar], + ) + .rollup( + [self.table.fiz, self.table.buz], + ) + ) + + self.assertEqual( + 'SELECT "buz" FROM "abc" GROUP BY ROLLUP(("foo","bar"),("fiz","buz"))', + str(q), + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/test_immutability.py b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/test_immutability.py new file mode 100644 index 0000000000000000000000000000000000000000..ee539bfa1e9c4509b929e7a86a03f098dd923515 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/test_immutability.py @@ -0,0 +1,99 @@ +import unittest + +from pypika import ( + AliasedQuery, + Query, + Tables, +) + + +class ImmutabilityTests(unittest.TestCase): + table_a, table_b, table_c = Tables("a", "b", "c") + + def test_select_returns_new_query_instance(self): + query_a = Query.from_(self.table_a).select(self.table_a.foo) + query_b = query_a.select(self.table_a.bar) + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_groupby_returns_new_query_instance(self): + query_a = Query.from_(self.table_a).select(self.table_a.foo).groupby(self.table_a.foo) + query_b = query_a.groupby(self.table_a.bar) + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_orderby_return_new_query_instance(self): + query_a = Query.from_(self.table_a).select(self.table_a.foo).orderby(self.table_a.foo) + query_b = query_a.orderby(self.table_a.bar) + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_join_return_new_query_instance(self): + base = Query.from_(self.table_a).select(self.table_a.foo) + query_a = base.join(self.table_b).on(self.table_a.foo == self.table_b.bar).select(self.table_b.bar) + query_b = query_a.join(self.table_c).on(self.table_a.foo == self.table_c.baz).select(self.table_c.baz) + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_use_index_return_new_query_instance(self): + query_a = Query.from_(self.table_a).select(self.table_a.foo).use_index('idx1') + query_b = query_a.use_index('idx2') + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_force_index_return_new_query_instance(self): + query_a = Query.from_(self.table_a).select(self.table_a.foo).force_index('idx1') + query_b = query_a.force_index('idx2') + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_with_return_new_query_instance(self): + alias_1 = Query.from_(self.table_a).select(self.table_a.foo) + alias_2 = Query.from_(self.table_b).select(self.table_b.bar) + query_a = Query.from_(AliasedQuery('a1')).select('foo').with_(alias_1, 'a1') + query_b = query_a.with_(alias_2, 'a2') + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_insert_into_return_new_query_instance(self): + query_a = Query.into(self.table_a).insert('foo1') + query_b = query_a.insert('foo2') + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_replace_into_return_new_query_instance(self): + query_a = Query.into(self.table_a).replace('foo') + query_b = query_a.replace('bar') + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_update_set_return_new_query_instance(self): + query_a = Query.update(self.table_a).set(self.table_a.foo, 'foo') + query_b = query_a.set(self.table_a.bar, 'bar') + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_queries_after_join(self): + query1 = Query.from_(self.table_a).select(self.table_a.foo) + query2 = query1.join(self.table_b).on(self.table_a.foo == self.table_b.bar).select(self.table_b.buz) + + self.assertEqual('SELECT "foo" FROM "a"', str(query1)) + self.assertEqual( + 'SELECT "a"."foo","b"."buz" FROM "a" JOIN "b" ON "a"."foo"="b"."bar"', + str(query2), + ) + + def test_immutable_kwarg_on_query_builder_disables_immutability(self): + query0 = Query.from_(self.table_a, immutable=False) + query1 = query0.select(self.table_a.foo) + self.assertIs(query0, query1) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/test_inserts.py b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/test_inserts.py new file mode 100644 index 0000000000000000000000000000000000000000..f86efd7a76dc498a69b61c6353951695f1933a61 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/test_inserts.py @@ -0,0 +1,885 @@ +import unittest + +from pypika import ( + AliasedQuery, + Case, + Field as F, + MySQLQuery, + PostgreSQLQuery, + Query, + Table, + Tables, + functions as fn, +) +from pypika.functions import ( + Avg, + Cast, +) +from pypika.terms import Values +from pypika.utils import QueryException + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + + +class InsertIntoTests(unittest.TestCase): + table_abc = Table("abc") + + def test_insert_one_column(self): + query = Query.into(self.table_abc).insert(1) + + self.assertEqual('INSERT INTO "abc" VALUES (1)', str(query)) + + def test_insert_one_column_single_element_array(self): + query = Query.into(self.table_abc).insert((1,)) + + self.assertEqual('INSERT INTO "abc" VALUES (1)', str(query)) + + def test_insert_one_column_multi_element_array(self): + query = Query.into(self.table_abc).insert((1,), (2,)) + + self.assertEqual('INSERT INTO "abc" VALUES (1),(2)', str(query)) + + def test_insert_single_row_with_array_value(self): + query = Query.into(self.table_abc).insert(1, ["a", "b", "c"]) + + self.assertEqual("INSERT INTO \"abc\" VALUES (1,['a','b','c'])", str(query)) + + def test_insert_multiple_rows_with_array_value(self): + query = Query.into(self.table_abc).insert( + (1, ["a", "b", "c"]), + (2, ["c", "d", "e"]), + ) + + self.assertEqual( + 'INSERT INTO "abc" ' "VALUES (1,['a','b','c']),(2,['c','d','e'])", + str(query), + ) + + def test_insert_all_columns(self): + query = Query.into(self.table_abc).insert(1, "a", True) + + self.assertEqual("INSERT INTO \"abc\" VALUES (1,'a',true)", str(query)) + + def test_insert_all_columns_single_element(self): + query = Query.into(self.table_abc).insert((1, "a", True)) + + self.assertEqual("INSERT INTO \"abc\" VALUES (1,'a',true)", str(query)) + + def test_insert_all_columns_multi_rows(self): + query = Query.into(self.table_abc).insert((1, "a", True), (2, "b", False)) + + self.assertEqual("INSERT INTO \"abc\" VALUES (1,'a',true),(2,'b',false)", str(query)) + + def test_insert_all_columns_multi_rows_chained(self): + query = Query.into(self.table_abc).insert(1, "a", True).insert(2, "b", False) + + self.assertEqual("INSERT INTO \"abc\" VALUES (1,'a',true),(2,'b',false)", str(query)) + + def test_insert_all_columns_multi_rows_chained_mixed(self): + query = Query.into(self.table_abc).insert((1, "a", True), (2, "b", False)).insert(3, "c", True) + + self.assertEqual( + 'INSERT INTO "abc" VALUES ' "(1,'a',true),(2,'b',false)," "(3,'c',true)", + str(query), + ) + + def test_insert_all_columns_multi_rows_chained_multiple_rows(self): + query = ( + Query.into(self.table_abc).insert((1, "a", True), (2, "b", False)).insert((3, "c", True), (4, "d", False)) + ) + + self.assertEqual( + 'INSERT INTO "abc" VALUES ' "(1,'a',true),(2,'b',false)," "(3,'c',true),(4,'d',false)", + str(query), + ) + + def test_insert_selected_columns(self): + query = ( + Query.into(self.table_abc) + .columns(self.table_abc.foo, self.table_abc.bar, self.table_abc.buz) + .insert(1, "a", True) + ) + + self.assertEqual('INSERT INTO "abc" ("foo","bar","buz") VALUES (1,\'a\',true)', str(query)) + + def test_insert_empty_columns(self): + query = Query.into(self.table_abc).columns().insert(1, "a", True) + + self.assertEqual('INSERT INTO "abc" VALUES (1,\'a\',true)', str(query)) + + def test_insert_selected_columns_type_list(self): + query = ( + Query.into(self.table_abc) + .columns([self.table_abc.foo, self.table_abc.bar, self.table_abc.buz]) + .insert(1, "a", True) + ) + + self.assertEqual('INSERT INTO "abc" ("foo","bar","buz") VALUES (1,\'a\',true)', str(query)) + + def test_insert_empty_columns_type_list(self): + query = Query.into(self.table_abc).columns([]).insert(1, "a", True) + + self.assertEqual('INSERT INTO "abc" VALUES (1,\'a\',true)', str(query)) + + def test_insert_selected_columns_type_tuple(self): + query = ( + Query.into(self.table_abc) + .columns((self.table_abc.foo, self.table_abc.bar, self.table_abc.buz)) + .insert(1, "a", True) + ) + + self.assertEqual('INSERT INTO "abc" ("foo","bar","buz") VALUES (1,\'a\',true)', str(query)) + + def test_insert_empty_columns_type_tuple(self): + query = Query.into(self.table_abc).columns(()).insert(1, "a", True) + + self.assertEqual('INSERT INTO "abc" VALUES (1,\'a\',true)', str(query)) + + def test_insert_none_skipped(self): + query = Query.into(self.table_abc).insert() + + self.assertEqual("", str(query)) + + def test_insert_ignore(self): + query = Query.into(self.table_abc).insert(1).ignore() + + self.assertEqual('INSERT IGNORE INTO "abc" VALUES (1)', str(query)) + + def test_insert_null(self): + query = Query.into(self.table_abc).insert(None) + + self.assertEqual('INSERT INTO "abc" VALUES (NULL)', str(query)) + + def test_insert_column_using_table_alias(self): + q = self.table_abc.insert(1) + self.assertEqual('INSERT INTO "abc" VALUES (1)', str(q)) + + def test_insert_column_using_alias_with_chain(self): + q = self.table_abc.insert(1, "a", True).insert(2, "b", False) + self.assertEqual("INSERT INTO \"abc\" VALUES (1,'a',true),(2,'b',false)", str(q)) + + def test_insert_with_statement(self): + sub_query = Query().select(self.table_abc.id).from_(self.table_abc) + aliased = AliasedQuery('sub_qs') + + q = Query().with_(sub_query, 'sub_qs').into(self.table_abc).select(aliased.id).from_(aliased) + self.assertEqual( + 'WITH sub_qs AS (SELECT "id" FROM "abc") INSERT INTO "abc" SELECT "sub_qs"."id" FROM sub_qs', str(q) + ) + + +class PostgresInsertIntoOnConflictTests(unittest.TestCase): + table_abc = Table("abc") + + def test_insert_on_conflict_do_nothing_field(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).on_conflict(self.table_abc.id).do_nothing() + + self.assertEqual('INSERT INTO "abc" VALUES (1) ON CONFLICT ("id") DO NOTHING', str(query)) + + def test_insert_on_conflict_do_nothing_multiple_fields(self): + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1) + .on_conflict(self.table_abc.id, self.table_abc.sub_id) + .do_nothing() + ) + + self.assertEqual('INSERT INTO "abc" VALUES (1) ON CONFLICT ("id", "sub_id") DO NOTHING', str(query)) + + def test_insert_on_conflict_do_nothing_field_str(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).on_conflict("id").do_nothing() + + self.assertEqual('INSERT INTO "abc" VALUES (1) ON CONFLICT ("id") DO NOTHING', str(query)) + + def test_insert_on_conflict_do_nothing_multiple_fields_str(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).on_conflict("id", "sub_id").do_nothing() + + self.assertEqual('INSERT INTO "abc" VALUES (1) ON CONFLICT ("id", "sub_id") DO NOTHING', str(query)) + + def test_insert_on_conflict_do_nothing_mixed_fields(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).on_conflict("id", self.table_abc.sub_id).do_nothing() + + self.assertEqual('INSERT INTO "abc" VALUES (1) ON CONFLICT ("id", "sub_id") DO NOTHING', str(query)) + + def test_insert_on_conflict_do_update_field(self): + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict(self.table_abc.id) + .do_update(self.table_abc.name, "m") + ) + + self.assertEqual( + "INSERT INTO \"abc\" VALUES (1,'m') ON CONFLICT (\"id\") DO UPDATE SET \"name\"='m'", + str(query), + ) + + def test_insert_on_conflict_do_update_multiple_fields(self): + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict(self.table_abc.id, self.table_abc.sub_id) + .do_update(self.table_abc.name, "m") + ) + + self.assertEqual( + "INSERT INTO \"abc\" VALUES (1,'m') ON CONFLICT (\"id\", \"sub_id\") DO UPDATE SET \"name\"='m'", + str(query), + ) + + def test_insert_on_conflict_do_update_field_str(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1, "m").on_conflict("id").do_update("name", "m") + + self.assertEqual( + "INSERT INTO \"abc\" VALUES (1,'m') ON CONFLICT (\"id\") DO UPDATE SET \"name\"='m'", + str(query), + ) + + def test_insert_on_conflict_do_update_multiple_fields_str(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1, "m").on_conflict("id", "sub_id").do_update("name", "m") + + self.assertEqual( + "INSERT INTO \"abc\" VALUES (1,'m') ON CONFLICT (\"id\", \"sub_id\") DO UPDATE SET \"name\"='m'", + str(query), + ) + + def test_insert_on_conflict_do_update_multiple_mixed_fields(self): + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict("id", self.table_abc.sub_id) + .do_update("name", "m") + ) + + self.assertEqual( + "INSERT INTO \"abc\" VALUES (1,'m') ON CONFLICT (\"id\", \"sub_id\") DO UPDATE SET \"name\"='m'", + str(query), + ) + + def test_insert_on_conflict_no_handler(self): + with self.assertRaises(QueryException): + query = str(PostgreSQLQuery.into(self.table_abc).insert(1).on_conflict(self.table_abc.id)) + + def test_insert_on_conflict_two_handlers_do_nothing(self): + with self.assertRaises(QueryException): + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1) + .on_conflict("id") + .do_nothing() + .do_update(self.table_abc.name, "m") + ) + + def test_insert_on_conflict_two_handlers_do_update(self): + with self.assertRaises(QueryException): + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1) + .on_conflict(self.table_abc.id) + .do_update(self.table_abc.name, "m") + .do_nothing() + ) + + def test_non_insert_on_conflict_do_nothing(self): + with self.assertRaises(QueryException): + query = PostgreSQLQuery.update(self.table_abc).set("foo", "bar").on_conflict("id").do_nothing() + + def test_non_insert_on_conflict_do_update(self): + with self.assertRaises(QueryException): + query = ( + PostgreSQLQuery.update(self.table_abc).set("foo", "bar").on_conflict("id").do_update(["name"], ["m"]) + ) + + def test_insert_on_fieldless_conflict_do_nothing(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).on_conflict(None).do_nothing() + + self.assertEqual('INSERT INTO "abc" VALUES (1) ON CONFLICT DO NOTHING', str(query)) + + def test_insert_on_fieldless_conflict_do_update_field(self): + with self.assertRaises(QueryException): + query = str( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict(None) + .do_update(self.table_abc.name, "m") + ) + + def test_on_conflict_from_subquery(self): + table_bcd = Table('bcd') + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(self.table_abc.fname, self.table_abc.lname) + .select(table_bcd.fname, table_bcd.lname) + .from_(table_bcd) + .on_conflict(self.table_abc.id, self.table_abc.sub_id) + .do_update(self.table_abc.fname, 1) + .do_update(self.table_abc.lname, table_bcd.lname) + .do_update( + self.table_abc.cname, + Case().when(self.table_abc.cname.eq('cname'), 'new_name').else_(self.table_abc.cname), + ) + ) + + self.assertEqual( + 'INSERT INTO "abc" VALUES ("fname","lname") ' + 'ON CONFLICT ("id", "sub_id") ' + 'DO UPDATE SET "fname"=1,"lname"="bcd"."lname",' + '"cname"=CASE WHEN "abc"."cname"=\'cname\' THEN \'new_name\' ELSE "abc"."cname" END', + str(query), + ) + + def test_on_conflict_where_empty_conflict_fields_do_nothing(self): + with self.assertRaises(QueryException): + ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict() + .where(self.table_abc.abc.eq(0)) + .where(self.table_abc.cde.eq(0)) + .do_nothing() + ) + + def test_on_conflict_where_conflict_fields_do_nothing(self): + qs = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict('id') + .where(self.table_abc.abc.eq(0)) + .where(self.table_abc.cde.eq(0)) + .do_nothing() + ) + self.assertEqual( + '''INSERT INTO "abc" VALUES (1,'m') ON CONFLICT ("id") WHERE "abc"=0 AND "cde"=0 DO NOTHING''', str(qs) + ) + + def test_on_conflict_where_empty_conflict_fields_do_update(self): + with self.assertRaises(QueryException): + ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict() + .where(self.table_abc.abc.eq(0)) + .where(self.table_abc.cde.eq(0)) + .do_update('field', 'val') + ) + + def test_on_conflict_where_conflict_fields_do_update(self): + qs = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict('id') + .where(self.table_abc.abc.eq(0)) + .where(self.table_abc.cde.eq(0)) + .do_update('field', 'val') + ) + self.assertEqual( + '''INSERT INTO "abc" VALUES (1,'m') ON CONFLICT ("id") WHERE "abc"=0 AND "cde"=0 ''' + '''DO UPDATE SET "field"='val\'''', + str(qs), + ) + + def test_where_and_on_conflict_where(self): + table_bcd = Table('bcd') + + qs = ( + PostgreSQLQuery.into(self.table_abc) + .select(table_bcd.abc) + .from_(table_bcd) + .where(table_bcd.abc.eq('1')) + .on_conflict('id') + .where(self.table_abc.abc.eq(0)) + .where(self.table_abc.cde.eq(0)) + .do_update('field', 'val') + ) + + self.assertEqual( + 'INSERT INTO "abc" SELECT "abc" FROM "bcd" WHERE "abc"=\'1\' ' + 'ON CONFLICT ("id") WHERE "abc"=0 AND "cde"=0 DO UPDATE SET "field"=\'val\'', + str(qs), + ) + + def test_on_conflict_do_nothing_where(self): + with self.assertRaises(QueryException): + ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict() + .do_nothing() + .where(self.table_abc.abc.eq(1)) + ) + + def test_empty_on_conflict_do_update_where(self): + with self.assertRaises(QueryException): + ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict() + .do_update('abc', 1) + .where(self.table_abc.abc.eq(1)) + ) + + def test_on_conflict_do_update_where(self): + qs = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict("id") + .do_update('abc', 1) + .where(self.table_abc.abc.eq(1)) + ) + self.assertEqual( + 'INSERT INTO "abc" VALUES (1,\'m\') ON CONFLICT ("id") DO UPDATE SET "abc"=1 WHERE "abc"."abc"=1', str(qs) + ) + + def test_on_conflict_do_update_with_excluded_where(self): + qs = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict("id") + .do_update('abc') + .where(self.table_abc.abc.eq(1)) + ) + self.assertEqual( + 'INSERT INTO "abc" VALUES (1,\'m\') ON CONFLICT ("id") DO UPDATE SET "abc"=EXCLUDED."abc" WHERE ' + '"abc"."abc"=1', + str(qs), + ) + + def test_on_conflict_where_complex(self): + table_bcd = Table('bcd') + + qs = ( + PostgreSQLQuery.into(self.table_abc) + .select(table_bcd.abc) + .from_(table_bcd) + .where(table_bcd.abc.eq('1')) + .on_conflict('id') + .where(self.table_abc.abc.eq(0)) + .where(self.table_abc.cde.eq(0)) + .do_update('field', 'val') + .where(self.table_abc.id.eq(2)) + .where(self.table_abc.sub_id.eq(3)) + ) + self.assertEqual( + 'INSERT INTO "abc" SELECT "abc" FROM "bcd" WHERE "abc"=\'1\' ' + 'ON CONFLICT ("id") WHERE "abc"=0 AND "cde"=0 ' + 'DO UPDATE SET "field"=\'val\' WHERE "abc"."id"=2 AND "abc"."sub_id"=3', + str(qs), + ) + + +class PostgresInsertIntoReturningTests(unittest.TestCase): + table_abc = Table("abc") + + def test_insert_returning_one_field(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).returning(self.table_abc.id) + + self.assertEqual('INSERT INTO "abc" VALUES (1) RETURNING "id"', str(query)) + + def test_insert_returning_one_field_str(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).returning("id") + + self.assertEqual('INSERT INTO "abc" VALUES (1) RETURNING "id"', str(query)) + + def test_insert_returning_all_fields(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).returning(self.table_abc.star) + + self.assertEqual('INSERT INTO "abc" VALUES (1) RETURNING *', str(query)) + + def test_insert_returning_all_fields_and_arithmetics(self): + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1) + .returning(self.table_abc.star, self.table_abc.f1 + self.table_abc.f2) + ) + + self.assertEqual('INSERT INTO "abc" VALUES (1) RETURNING *,"f1"+"f2"', str(query)) + + def test_insert_all_columns_multi_rows_chained_returning_star(self): + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "a", True) + .insert(2, "b", False) + .returning(self.table_abc.star) + ) + + self.assertEqual( + "INSERT INTO \"abc\" VALUES (1,'a',true),(2,'b',false) RETURNING *", + str(query), + ) + + def test_insert_all_columns_multi_rows_chained_returning_star_and_id(self): + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "a", True) + .insert(2, "b", False) + .returning( + self.table_abc.name, + self.table_abc.star, + self.table_abc.id, + ) + ) + + self.assertEqual( + "INSERT INTO \"abc\" VALUES (1,'a',true),(2,'b',false) RETURNING *", + str(query), + ) + + def test_insert_all_columns_multi_rows_chained_returning_star_str(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1, "a", True).insert(2, "b", False).returning("*") + + self.assertEqual( + "INSERT INTO \"abc\" VALUES (1,'a',true),(2,'b',false) RETURNING *", + str(query), + ) + + def test_insert_all_columns_single_element_arrays(self): + query = PostgreSQLQuery.into(self.table_abc).insert((1, "a", True)).returning(self.table_abc.star) + + self.assertEqual("INSERT INTO \"abc\" VALUES (1,'a',true) RETURNING *", str(query)) + + def test_insert_returning_null(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).returning(None) + + self.assertEqual('INSERT INTO "abc" VALUES (1) RETURNING NULL', str(query)) + + def test_insert_returning_tuple(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).returning((1, 2, 3)) + + self.assertEqual('INSERT INTO "abc" VALUES (1) RETURNING (1,2,3)', str(query)) + + def test_insert_returning_arithmetics(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).returning(self.table_abc.f1 + self.table_abc.f2) + + self.assertEqual('INSERT INTO "abc" VALUES (1) RETURNING "f1"+"f2"', str(query)) + + def test_insert_returning_functions(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).returning(Cast(self.table_abc.f1, "int")) + + self.assertEqual('INSERT INTO "abc" VALUES (1) RETURNING CAST("f1" AS INT)', str(query)) + + def test_insert_returning_aggregate(self): + with self.assertRaises(QueryException): + PostgreSQLQuery.into(self.table_abc).insert(1).returning(Avg(self.table_abc.views)) + + def test_insert_returning_from_other_table(self): + table_cba = Table("cba") + with self.assertRaises(QueryException): + PostgreSQLQuery.into(self.table_abc).insert(1).returning(table_cba.id) + + +class InsertIntoOnDuplicateTests(unittest.TestCase): + table_abc = Table("abc") + + def test_insert_one_column(self): + query = ( + MySQLQuery.into(self.table_abc).insert(1).on_duplicate_key_update(self.table_abc.foo, self.table_abc.foo) + ) + self.assertEqual( + "INSERT INTO `abc` VALUES (1) ON DUPLICATE KEY UPDATE `foo`=`foo`", + str(query), + ) + + def test_insert_one_column_using_values(self): + query = ( + MySQLQuery.into(self.table_abc) + .insert(1) + .on_duplicate_key_update(self.table_abc.foo, Values(self.table_abc.foo)) + ) + self.assertEqual( + "INSERT INTO `abc` VALUES (1) ON DUPLICATE KEY UPDATE `foo`=VALUES(`foo`)", + str(query), + ) + + def test_insert_one_column_single_element_array(self): + query = ( + MySQLQuery.into(self.table_abc).insert((1,)).on_duplicate_key_update(self.table_abc.foo, self.table_abc.foo) + ) + + self.assertEqual( + "INSERT INTO `abc` VALUES (1) ON DUPLICATE KEY UPDATE `foo`=`foo`", + str(query), + ) + + def test_insert_one_column_multi_element_array(self): + query = ( + MySQLQuery.into(self.table_abc) + .insert((1,), (2,)) + .on_duplicate_key_update(self.table_abc.foo, self.table_abc.foo) + ) + + self.assertEqual( + "INSERT INTO `abc` VALUES (1),(2) ON DUPLICATE KEY UPDATE `foo`=`foo`", + str(query), + ) + + def test_insert_multiple_columns_on_duplicate_update_one_with_same_value(self): + query = ( + MySQLQuery.into(self.table_abc) + .insert(1, "a") + .on_duplicate_key_update(self.table_abc.bar, Values(self.table_abc.bar)) + ) + + self.assertEqual( + "INSERT INTO `abc` VALUES (1,'a') ON DUPLICATE KEY UPDATE `bar`=VALUES(`bar`)", + str(query), + ) + + def test_insert_multiple_columns_on_duplicate_update_one_with_different_value(self): + query = MySQLQuery.into(self.table_abc).insert(1, "a").on_duplicate_key_update(self.table_abc.bar, "b") + + self.assertEqual( + "INSERT INTO `abc` VALUES (1,'a') ON DUPLICATE KEY UPDATE `bar`='b'", + str(query), + ) + + def test_insert_multiple_columns_on_duplicate_update_one_with_expression(self): + query = ( + MySQLQuery.into(self.table_abc).insert(1, 2).on_duplicate_key_update(self.table_abc.bar, 4 + F("bar")) + ) # todo sql expression? not python + + self.assertEqual( + "INSERT INTO `abc` VALUES (1,2) ON DUPLICATE KEY UPDATE `bar`=4+`bar`", + str(query), + ) + + def test_insert_multiple_columns_on_duplicate_update_one_with_expression_using_original_field_value( + self, + ): + query = ( + MySQLQuery.into(self.table_abc) + .insert(1, "a") + .on_duplicate_key_update(self.table_abc.bar, fn.Concat(self.table_abc.bar, "update")) + ) + + self.assertEqual( + "INSERT INTO `abc` VALUES (1,'a') ON DUPLICATE KEY UPDATE `bar`=CONCAT(`bar`,'update')", + str(query), + ) + + def test_insert_multiple_columns_on_duplicate_update_one_with_expression_using_values( + self, + ): + query = ( + MySQLQuery.into(self.table_abc) + .insert(1, "a") + .on_duplicate_key_update(self.table_abc.bar, fn.Concat(Values(self.table_abc.bar), "update")) + ) + + self.assertEqual( + "INSERT INTO `abc` VALUES (1,'a') ON DUPLICATE KEY UPDATE `bar`=CONCAT(VALUES(`bar`),'update')", + str(query), + ) + + def test_insert_multiple_columns_on_duplicate_update_multiple(self): + query = ( + MySQLQuery.into(self.table_abc) + .insert(1, "a", "b") + .on_duplicate_key_update(self.table_abc.bar, "b") + .on_duplicate_key_update(self.table_abc.baz, "c") + ) + + self.assertEqual( + "INSERT INTO `abc` VALUES (1,'a','b') ON DUPLICATE KEY UPDATE `bar`='b',`baz`='c'", + str(query), + ) + + def test_insert_multi_rows_chained_mixed_on_duplicate_update_multiple(self): + query = ( + MySQLQuery.into(self.table_abc) + .insert((1, "a", True), (2, "b", False)) + .insert(3, "c", True) + .on_duplicate_key_update(self.table_abc.foo, self.table_abc.foo) + .on_duplicate_key_update(self.table_abc.bar, Values(self.table_abc.bar)) + ) + + self.assertEqual( + "INSERT INTO `abc` VALUES (1,'a',true),(2,'b',false),(3,'c',true) " + "ON DUPLICATE KEY UPDATE `foo`=`foo`,`bar`=VALUES(`bar`)", + str(query), + ) + + def test_insert_selected_columns_on_duplicate_update_one(self): + query = ( + MySQLQuery.into(self.table_abc) + .columns(self.table_abc.foo, self.table_abc.bar, self.table_abc.baz) + .insert(1, "a", True) + .on_duplicate_key_update(self.table_abc.baz, False) + ) + + self.assertEqual( + "INSERT INTO `abc` (`foo`,`bar`,`baz`) VALUES (1,'a',true) ON DUPLICATE KEY UPDATE `baz`=false", + str(query), + ) + + def test_insert_selected_columns_on_duplicate_update_multiple(self): + query = ( + MySQLQuery.into(self.table_abc) + .columns(self.table_abc.foo, self.table_abc.bar, self.table_abc.baz) + .insert(1, "a", True) + .on_duplicate_key_update(self.table_abc.baz, False) + .on_duplicate_key_update(self.table_abc.bar, Values(self.table_abc.bar)) + ) + + self.assertEqual( + "INSERT INTO `abc` (`foo`,`bar`,`baz`) VALUES (1,'a',true) " + "ON DUPLICATE KEY UPDATE `baz`=false,`bar`=VALUES(`bar`)", + str(query), + ) + + def test_insert_none_skipped(self): + query = MySQLQuery.into(self.table_abc).insert().on_duplicate_key_update(self.table_abc.baz, False) + + self.assertEqual("", str(query)) + + def test_insert_ignore(self): + query = MySQLQuery.into(self.table_abc).insert(1).ignore().on_duplicate_key_update(self.table_abc.baz, False) + + self.assertEqual( + "INSERT IGNORE INTO `abc` VALUES (1) ON DUPLICATE KEY UPDATE `baz`=false", + str(query), + ) + + +class InsertSelectFromTests(unittest.TestCase): + table_abc, table_efg, table_hij = Tables("abc", "efg", "hij") + + def test_insert_star(self): + query = Query.into(self.table_abc).from_(self.table_efg).select("*") + + self.assertEqual('INSERT INTO "abc" SELECT * FROM "efg"', str(query)) + + def test_insert_ignore_star(self): + query = Query.into(self.table_abc).from_(self.table_efg).select("*").ignore() + + self.assertEqual('INSERT IGNORE INTO "abc" SELECT * FROM "efg"', str(query)) + + def test_insert_from_columns(self): + query = ( + Query.into(self.table_abc) + .from_(self.table_efg) + .select(self.table_efg.fiz, self.table_efg.buz, self.table_efg.baz) + ) + + self.assertEqual('INSERT INTO "abc" ' 'SELECT "fiz","buz","baz" FROM "efg"', str(query)) + + def test_insert_columns_from_star(self): + query = ( + Query.into(self.table_abc) + .columns( + self.table_abc.foo, + self.table_abc.bar, + self.table_abc.buz, + ) + .from_(self.table_efg) + .select("*") + ) + + self.assertEqual('INSERT INTO "abc" ("foo","bar","buz") ' 'SELECT * FROM "efg"', str(query)) + + def test_insert_columns_from_columns(self): + query = ( + Query.into(self.table_abc) + .columns(self.table_abc.foo, self.table_abc.bar, self.table_abc.buz) + .from_(self.table_efg) + .select(self.table_efg.fiz, self.table_efg.buz, self.table_efg.baz) + ) + + self.assertEqual( + 'INSERT INTO "abc" ("foo","bar","buz") ' 'SELECT "fiz","buz","baz" FROM "efg"', + str(query), + ) + + def test_insert_columns_from_columns_with_join(self): + query = ( + Query.into(self.table_abc) + .columns( + self.table_abc.c1, + self.table_abc.c2, + self.table_abc.c3, + self.table_abc.c4, + ) + .from_(self.table_efg) + .select(self.table_efg.foo, self.table_efg.bar) + .join(self.table_hij) + .on(self.table_efg.id == self.table_hij.abc_id) + .select(self.table_hij.fiz, self.table_hij.buz) + ) + + self.assertEqual( + 'INSERT INTO "abc" ("c1","c2","c3","c4") ' + 'SELECT "efg"."foo","efg"."bar","hij"."fiz","hij"."buz" FROM "efg" ' + 'JOIN "hij" ON "efg"."id"="hij"."abc_id"', + str(query), + ) + + +class InsertSubqueryTests(unittest.TestCase): + def test_insert_subquery_wrapped_in_brackets(self): + purchase_order_item, part = Tables("purchase_order_item", "part") + + q = ( + Query.into(purchase_order_item) + .columns(purchase_order_item.id_part, purchase_order_item.id_customer) + .insert( + Query.from_(part).select(part.part_id).where(part.part_number == "FOOBAR"), + 12345, + ) + ) + + self.assertEqual( + 'INSERT INTO "purchase_order_item" ' + '("id_part","id_customer") ' + "VALUES " + '((SELECT "part_id" FROM "part" WHERE "part_number"=\'FOOBAR\'),12345)', + str(q), + ) + + +class SelectIntoTests(unittest.TestCase): + table_abc, table_efg, table_hij = Tables("abc", "efg", "hij") + + def test_select_star_into(self): + query = Query.from_(self.table_abc).select("*").into(self.table_efg) + + self.assertEqual('SELECT * INTO "efg" FROM "abc"', str(query)) + + def test_select_columns_into(self): + query = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, self.table_abc.bar, self.table_abc.buz) + .into(self.table_efg) + ) + + self.assertEqual('SELECT "foo","bar","buz" INTO "efg" FROM "abc"', str(query)) + + def test_select_columns_into_with_join(self): + query = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, self.table_abc.bar) + .join(self.table_hij) + .on(self.table_abc.id == self.table_hij.abc_id) + .select(self.table_hij.fiz, self.table_hij.buz) + .into(self.table_efg) + ) + + self.assertEqual( + 'SELECT "abc"."foo","abc"."bar","hij"."fiz","hij"."buz" ' + 'INTO "efg" FROM "abc" ' + 'JOIN "hij" ON "abc"."id"="hij"."abc_id"', + str(query), + ) + + +class ReplaceTests(unittest.TestCase): + table_abc, table_def = Tables("abc", "efg") + + def test_replace_simple(self): + query = Query.into(self.table_abc).replace("v1", "v2", "v3") + expected_output = "REPLACE INTO \"abc\" VALUES ('v1','v2','v3')" + self.assertEqual(str(query), expected_output) + + def test_replace_subquery(self): + query = Query.into(self.table_abc).replace(Query.from_(self.table_def).select("f1", "f2")) + expected_output = 'REPLACE INTO "abc" VALUES ((SELECT "f1","f2" FROM "efg"))' + self.assertEqual(str(query), expected_output) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/test_internals.py b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/test_internals.py new file mode 100644 index 0000000000000000000000000000000000000000..921e381ba8613d4a83cc53bd60d111d9547e2c1f --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/test_internals.py @@ -0,0 +1,35 @@ +import unittest + +from pypika import ( + Case, + Field, + Table, +) +from pypika.terms import Star + + +class TablesTests(unittest.TestCase): + def test__criterion_replace_table_with_value(self): + table = Table("a") + + c = (Field("foo") > 1).replace_table(None, table) + self.assertEqual(c.left, table) + self.assertEqual(c.tables_, {table}) + + def test__case_tables(self): + table = Table("a") + + c = Case().when(table.a == 1, 2 * table.a) + self.assertIsInstance(c.tables_, set) + self.assertSetEqual(c.tables_, {table}) + + def test__star_tables(self): + star = Star() + + self.assertEqual(star.tables_, set()) + + def test__table_star_tables(self): + table = Table("a") + star = Star(table=table) + + self.assertEqual(star.tables_, {table}) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/test_joins.py b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/test_joins.py new file mode 100644 index 0000000000000000000000000000000000000000..03142d583921edbe966e0ae191d254e7b8bf46ba --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/test_joins.py @@ -0,0 +1,1168 @@ +import unittest + +from pypika import ( + Field, + Interval, + JoinException, + JoinType, + MySQLQuery, + Query, + SetOperationException, + Table, + Tables, + functions as fn, + SYSTEM_TIME, +) + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + + +class SelectQueryJoinTests(unittest.TestCase): + table0, table1, hij = Tables("abc", "efg", "hij") + + def test_default_join_type(self): + query = Query.from_(self.table0).join(self.table1).on(self.table0.foo == self.table1.bar).select("*") + + self.assertEqual('SELECT * FROM "abc" JOIN "efg" ON "abc"."foo"="efg"."bar"', str(query)) + + def test_inner_join(self): + expected = 'SELECT * FROM "abc" JOIN "efg" ON "abc"."foo"="efg"."bar"' + + with self.subTest("join with enum"): + query = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.inner) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + self.assertEqual(expected, str(query)) + + with self.subTest("join function"): + query = Query.from_(self.table0).inner_join(self.table1).on(self.table0.foo == self.table1.bar).select("*") + self.assertEqual(expected, str(query)) + + def test_left_join(self): + expected = 'SELECT * FROM "abc" LEFT JOIN "efg" ON "abc"."foo"="efg"."bar"' + + with self.subTest("join with enum"): + query = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.left) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + + self.assertEqual(expected, str(query)) + + with self.subTest("join function"): + query = Query.from_(self.table0).left_join(self.table1).on(self.table0.foo == self.table1.bar).select("*") + self.assertEqual(expected, str(query)) + + def test_right_join(self): + expected = 'SELECT * FROM "abc" RIGHT JOIN "efg" ON "abc"."foo"="efg"."bar"' + + with self.subTest("join with enum"): + query = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.right) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + + self.assertEqual(expected, str(query)) + + with self.subTest("join function"): + query = Query.from_(self.table0).right_join(self.table1).on(self.table0.foo == self.table1.bar).select("*") + self.assertEqual(expected, str(query)) + + def test_hash_join(self): + expected = 'SELECT * FROM "abc" HASH JOIN "efg" ON "abc"."foo"="efg"."bar"' + + with self.subTest("join with enum"): + query = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.hash) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + + self.assertEqual(expected, str(query)) + + with self.subTest("join function"): + query = Query.from_(self.table0).hash_join(self.table1).on(self.table0.foo == self.table1.bar).select("*") + self.assertEqual(expected, str(query)) + + def test_outer_join(self): + expected = 'SELECT * FROM "abc" FULL OUTER JOIN "efg" ON "abc"."foo"="efg"."bar"' + + with self.subTest("join with enum"): + query = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.outer) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + + self.assertEqual(expected, str(query)) + + with self.subTest("join function"): + query = Query.from_(self.table0).outer_join(self.table1).on(self.table0.foo == self.table1.bar).select("*") + self.assertEqual(expected, str(query)) + + def test_cross_join(self): + expected = 'SELECT * FROM "abc" CROSS JOIN "efg" ON "abc"."foo"="efg"."bar"' + + with self.subTest("join with enum"): + query = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.cross) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + + self.assertEqual(expected, str(query)) + + with self.subTest("join function"): + query = Query.from_(self.table0).cross_join(self.table1).on(self.table0.foo == self.table1.bar).select("*") + self.assertEqual(expected, str(query)) + + def test_left_outer_join(self): + expected = 'SELECT * FROM "abc" LEFT OUTER JOIN "efg" ON "abc"."foo"="efg"."bar"' + with self.subTest("join with enum"): + query = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.left_outer) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + + self.assertEqual(expected, str(query)) + + with self.subTest("join function"): + query = ( + Query.from_(self.table0).left_outer_join(self.table1).on(self.table0.foo == self.table1.bar).select("*") + ) + + self.assertEqual(expected, str(query)) + + def test_right_outer_join(self): + expected = 'SELECT * FROM "abc" RIGHT OUTER JOIN "efg" ON "abc"."foo"="efg"."bar"' + with self.subTest("join with enum"): + query = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.right_outer) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + + self.assertEqual(expected, str(query)) + + with self.subTest("join function"): + query = ( + Query.from_(self.table0) + .right_outer_join(self.table1) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + + self.assertEqual(expected, str(query)) + + def test_full_outer_join(self): + expected = 'SELECT * FROM "abc" FULL OUTER JOIN "efg" ON "abc"."foo"="efg"."bar"' + + with self.subTest("join with enum"): + query = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.full_outer) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + + self.assertEqual(expected, str(query)) + + with self.subTest("join function"): + query = ( + Query.from_(self.table0).full_outer_join(self.table1).on(self.table0.foo == self.table1.bar).select("*") + ) + + self.assertEqual(expected, str(query)) + + def test_join_on_field_single(self): + query = Query.from_(self.table0).join(self.table1).on_field("foo").select("*") + self.assertEqual('SELECT * FROM "abc" JOIN "efg" ON "abc"."foo"="efg"."foo"', str(query)) + + def test_join_on_field_multi(self): + query = Query.from_(self.table0).join(self.table1).on_field("foo", "bar").select("*") + self.assertEqual( + 'SELECT * FROM "abc" JOIN "efg" ON "abc"."foo"="efg"."foo" ' 'AND "abc"."bar"="efg"."bar"', + str(query), + ) + + def test_join_on_field_multi_with_extra_join(self): + query = ( + Query.from_(self.table0) + .join(self.hij) + .on_field("buzz") + .join(self.table1) + .on_field("foo", "bar") + .select("*") + ) + + self.assertEqual( + 'SELECT * FROM "abc" JOIN "hij" ON "abc"."buzz"="hij"."buzz" ' + 'JOIN "efg" ON "abc"."foo"="efg"."foo" AND "abc"."bar"="efg"."bar"', + str(query), + ) + + def test_join_using_string_field_name(self): + query = Query.from_(self.table0).join(self.table1).using("id").select("*") + + self.assertEqual('SELECT * FROM "abc" JOIN "efg" USING ("id")', str(query)) + + def test_join_using_multiple_fields(self): + query = Query.from_(self.table0).join(self.table1).using("foo", "bar").select("*") + + self.assertEqual('SELECT * FROM "abc" JOIN "efg" USING ("foo","bar")', str(query)) + + def test_join_using_with_quote_char(self): + query = Query.from_(self.table0).join(self.table1).using("foo", "bar").select("*") + + self.assertEqual("SELECT * FROM abc JOIN efg USING (foo,bar)", query.get_sql(quote_char="")) + + def test_join_using_without_fields_raises_exception(self): + with self.assertRaises(JoinException): + Query.from_(self.table0).join(self.table1).using() + + def test_join_on_field_without_fields_raises_exception(self): + with self.assertRaises(JoinException): + Query.from_(self.table0).join(self.table1).on_field() + + def test_join_arithmetic_field(self): + q = ( + Query.from_(self.table0) + .join(self.table1) + .on(self.table0.dt == (self.table1.dt - Interval(weeks=1))) + .select("*") + ) + + self.assertEqual( + 'SELECT * FROM "abc" ' 'JOIN "efg" ON "abc"."dt"="efg"."dt"-INTERVAL \'1 WEEK\'', + str(q), + ) + + def test_join_with_arithmetic_function_in_select(self): + q = ( + Query.from_( + self.table0, + ) + .join(self.table1) + .on(self.table0.dt == (self.table1.dt - Interval(weeks=1))) + .select(self.table0.fiz - self.table0.buz, self.table1.star) + ) + + self.assertEqual( + 'SELECT "abc"."fiz"-"abc"."buz","efg".* FROM "abc" ' + 'JOIN "efg" ON "abc"."dt"="efg"."dt"-INTERVAL \'1 WEEK\'', + str(q), + ) + + def test_join_on_complex_criteria(self): + q = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.right) + .on((self.table0.foo == self.table1.fiz) & (self.table0.bar == self.table1.buz)) + .select("*") + ) + + self.assertEqual( + 'SELECT * FROM "abc" ' 'RIGHT JOIN "efg" ON "abc"."foo"="efg"."fiz" AND "abc"."bar"="efg"."buz"', + str(q), + ) + + def test_join_on_subquery_criteria(self): + table_a, table_b, table_c = Tables("a", "b", "c") + subquery = Query.from_(table_c).select("id").limit(1) + query = ( + Query.from_(table_a).select("*").join(table_b).on((table_a.b_id == table_b.id) & (table_b.c_id == subquery)) + ) + + self.assertEqual( + "SELECT * " 'FROM "a" ' 'JOIN "b" ON "a"."b_id"="b"."id" AND "b"."c_id"=' '(SELECT "id" FROM "c" LIMIT 1)', + str(query), + ) + + def test_use_different_table_objects_for_same_table(self): + table = Table("t") + q = Query.from_(table).select("*").where(Field("id", table=table) == 1) + + self.assertEqual('SELECT * FROM "t" WHERE "id"=1', str(q)) + + def test_join_second_table_in_from_clause(self): + table_a, table_b, table_c = Tables("a", "b", "c") + q = Query.from_(table_a).from_(table_b).select("*").join(table_c).on(table_b.c_id == table_c.id) + + self.assertEqual("SELECT * " 'FROM "a","b" ' 'JOIN "c" ON "b"."c_id"="c"."id"', str(q)) + + def test_cross_join_on_table(self): + table_a, table_b = Tables("a", "b") + q = Query.from_(table_a).join(table_b).cross().select("*") + + self.assertEqual('SELECT * FROM "a" CROSS JOIN "b"', str(q)) + + def test_cross_join_on_subquery(self): + table_a, table_b = Tables("a", "b") + q_a = Query.from_(table_a).select("*") + q_b = Query.from_(table_b).select("*").join(q_a).cross().select("*") + + self.assertEqual('SELECT * FROM "b" CROSS JOIN (SELECT * FROM "a") "sq0"', str(q_b)) + + def test_join_on_collate(self): + table_a, table_b = Tables("a", "b") + + q1 = ( + Query.from_(table_a) + .select(table_b.ouch) + .join(table_b) + .on(table_a.foo == table_b.boo, collate="utf8_general_ci") + ) + q2 = Query.from_(table_a).select(table_b.ouch).join(table_b).on(table_a.foo == table_b.boo) + + self.assertEqual( + 'SELECT "b"."ouch" FROM "a" JOIN "b" ON "a"."foo"="b"."boo" COLLATE utf8_general_ci', + str(q1), + ) + self.assertEqual('SELECT "b"."ouch" FROM "a" JOIN "b" ON "a"."foo"="b"."boo"', str(q2)) + + def test_temporal_join(self): + t0 = self.table0.for_(SYSTEM_TIME.as_of('2020-01-01')) + t1 = self.table1.for_(SYSTEM_TIME.as_of('2020-01-01')) + query = Query.from_(t0).join(t1).on(t0.foo == t1.bar).select("*") + + self.assertEqual( + 'SELECT * FROM "abc" FOR SYSTEM_TIME AS OF \'2020-01-01\' ' + 'JOIN "efg" FOR SYSTEM_TIME AS OF \'2020-01-01\' ' + 'ON "abc"."foo"="efg"."bar"', + str(query), + ) + + +class JoinBehaviorTests(unittest.TestCase): + table_abc, table_efg, table_hij, table_klm = Tables("abc", "efg", "hij", "klm") + + def test_select__ordered_select_clauses(self): + q = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .select( + self.table_abc.baz, + self.table_efg.buz, + self.table_abc.fiz, + self.table_efg.bam, + ) + ) + + self.assertEqual( + 'SELECT "abc"."baz","efg"."buz","abc"."fiz","efg"."bam" FROM "abc" ' + 'JOIN "efg" ON "abc"."foo"="efg"."bar"', + str(q), + ) + + def test_select__star_for_table(self): + q = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .join(self.table_hij) + .on(self.table_abc.buz == self.table_hij.bam) + .select(self.table_abc.star) + .select(self.table_efg.star) + .select(self.table_hij.star) + ) + + self.assertEqual( + 'SELECT "abc".*,"efg".*,"hij".* FROM "abc" ' + 'JOIN "efg" ON "abc"."foo"="efg"."bar" ' + 'JOIN "hij" ON "abc"."buz"="hij"."bam"', + str(q), + ) + + def test_select__star_for_table__replacement(self): + q = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .join(self.table_hij) + .on(self.table_abc.buz == self.table_hij.bam) + .select(self.table_abc.foo, self.table_efg.bar, self.table_hij.bam) + .select(self.table_abc.star, self.table_efg.star, self.table_hij.star) + ) + + self.assertEqual( + 'SELECT "abc".*,"efg".*,"hij".* FROM "abc" ' + 'JOIN "efg" ON "abc"."foo"="efg"."bar" ' + 'JOIN "hij" ON "abc"."buz"="hij"."bam"', + str(q), + ) + + def test_select_fields_with_where(self): + q = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .join(self.table_hij) + .on(self.table_abc.buz == self.table_hij.bam) + .select(self.table_abc.foo, self.table_efg.bar, self.table_hij.bam) + .where(self.table_abc.foo > 1) + .where(self.table_efg.bar != 2) + ) + + self.assertEqual( + 'SELECT "abc"."foo","efg"."bar","hij"."bam" FROM "abc" ' + 'JOIN "efg" ON "abc"."foo"="efg"."bar" ' + 'JOIN "hij" ON "abc"."buz"="hij"."bam" ' + 'WHERE "abc"."foo">1 AND "efg"."bar"<>2', + str(q), + ) + + def test_require_condition(self): + with self.assertRaises(JoinException): + Query.from_(self.table_abc).join(self.table_efg).on(None) + + def test_require_condition_with_both_tables(self): + with self.assertRaises(JoinException): + Query.from_(self.table_abc).join(self.table_efg).on(self.table_abc.foo == self.table_hij.bar) + + with self.assertRaises(JoinException): + Query.from_(self.table_abc).join(self.table_efg).on(self.table_hij.foo == self.table_efg.bar) + + with self.assertRaises(JoinException): + Query.from_(self.table_abc).join(self.table_efg).on(self.table_hij.foo == self.table_klm.bar) + + def test_join_same_table(self): + table1 = Table("abc") + table2 = Table("abc") + q = Query.from_(table1).join(table2).on(table1.foo == table2.bar).select(table1.foo, table2.buz) + + self.assertEqual( + 'SELECT "abc"."foo","abc2"."buz" FROM "abc" ' 'JOIN "abc" "abc2" ON "abc"."foo"="abc2"."bar"', + str(q), + ) + + def test_join_same_table_with_prefixes(self): + table1 = Table("abc").as_("x") + table2 = Table("abc").as_("y") + q = Query.from_(table1).join(table2).on(table1.foo == table2.bar).select(table1.foo, table2.buz) + + self.assertEqual( + 'SELECT "x"."foo","y"."buz" FROM "abc" "x" ' 'JOIN "abc" "y" ON "x"."foo"="y"."bar"', + str(q), + ) + + def test_join_table_twice(self): + table1, table2 = Table("efg").as_("efg1"), Table("efg").as_("efg2") + q = ( + Query.from_(self.table_abc) + .join(table1) + .on(self.table_abc.foo == table1.bar) + .join(table2) + .on(self.table_abc.foo == table2.bam) + .select(self.table_abc.foo, table1.fiz, table2.buz) + ) + + self.assertEqual( + 'SELECT "abc"."foo","efg1"."fiz","efg2"."buz" FROM "abc" ' + 'JOIN "efg" "efg1" ON "abc"."foo"="efg1"."bar" ' + 'JOIN "efg" "efg2" ON "abc"."foo"="efg2"."bam"', + str(q), + ) + + def test_select__fields_after_table_star(self): + q = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .select(self.table_abc.star, self.table_efg.bar) + .select(self.table_abc.foo) + ) + + self.assertEqual( + 'SELECT "abc".*,"efg"."bar" FROM "abc" JOIN "efg" ON "abc"."foo"="efg"."bar"', + str(q), + ) + + def test_fail_when_joining_unknown_type(self): + with self.assertRaises(ValueError): + Query.from_(self.table_abc).join("this is a string") + + def test_immutable__tables(self): + query1 = Query.from_(self.table_abc).select(self.table_abc.foo) + query2 = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .select(self.table_abc.foo, self.table_efg.buz) + ) + + self.assertEqual( + 'SELECT "abc"."foo","efg"."buz" FROM "abc" ' 'JOIN "efg" ON "abc"."foo"="efg"."bar"', + str(query2), + ) + self.assertEqual('SELECT "foo" FROM "abc"', str(query1)) + + def test_select_field_from_missing_table(self): + """ + Previously we validated the select field was a member of a table + in the query (e.g. FROM clause or a JOIN). However this made + correlated subqueries awkward to write (subqueries which refer + to their parent table. So the validation was removed. + + None of the following raise an error. Previously raised JoinException + """ + Query.from_(self.table_abc).select(self.table_efg.foo) + + Query.from_(self.table_abc).where(self.table_efg.foo == 0) + + Query.from_(self.table_abc).where(fn.Sum(self.table_efg.foo) == 0) + + Query.from_(self.table_abc).select(fn.Sum(self.table_abc.bar * 2) + fn.Sum(self.table_efg.foo * 2)) + + Query.from_(self.table_abc).groupby(self.table_efg.foo) + + Query.from_(self.table_abc).groupby(self.table_abc.foo).having(self.table_efg.bar) + + subquery = ( + Query.from_(self.table_efg).select(self.table_efg.id).where(self.table_efg.abc_id == self.table_abc.id) + ) + query = Query.from_(self.table_abc).select(subquery.as_("efg_id").limit(1)) + self.assertEqual( + 'SELECT (SELECT "efg"."id" FROM "efg" WHERE "efg"."abc_id"="abc"."id" LIMIT 1) "efg_id" FROM "abc"', + str(query), + ) + + def test_ignore_table_references(self): + query = Query.from_(Table("abc")).select(Table("abc").foo) + + self.assertEqual('SELECT "foo" FROM "abc"', str(query)) + + def test_prefixes_added_to_groupby(self): + test_query = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .select(self.table_abc.foo, fn.Sum(self.table_efg.buz)) + .groupby(self.table_abc.foo) + ) + + self.assertEqual( + 'SELECT "abc"."foo",SUM("efg"."buz") FROM "abc" ' + 'JOIN "efg" ON "abc"."foo"="efg"."bar" ' + 'GROUP BY "abc"."foo"', + str(test_query), + ) + + def test_prefixes_added_to_orderby(self): + test_query = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .select(self.table_abc.foo, self.table_efg.buz) + .orderby(self.table_abc.foo) + ) + + self.assertEqual( + 'SELECT "abc"."foo","efg"."buz" FROM "abc" ' + 'JOIN "efg" ON "abc"."foo"="efg"."bar" ' + 'ORDER BY "abc"."foo"', + str(test_query), + ) + + def test_prefixes_added_to_function_in_orderby(self): + test_query = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .select(self.table_abc.foo, self.table_efg.buz) + .orderby(fn.Date(self.table_abc.foo)) + ) + + self.assertEqual( + 'SELECT "abc"."foo","efg"."buz" FROM "abc" ' + 'JOIN "efg" ON "abc"."foo"="efg"."bar" ' + 'ORDER BY DATE("abc"."foo")', + str(test_query), + ) + + def test_join_from_join(self): + test_query = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.efg_id == self.table_efg.id) + .join(self.table_hij) + .on(self.table_efg.hij_id == self.table_hij.id) + .select(self.table_abc.foo, self.table_efg.bar, self.table_hij.fizz) + ) + + self.assertEqual( + 'SELECT "abc"."foo","efg"."bar","hij"."fizz" FROM "abc" ' + 'JOIN "efg" ON "abc"."efg_id"="efg"."id" ' + 'JOIN "hij" ON "efg"."hij_id"="hij"."id"', + str(test_query), + ) + + def test_join_query_without_alias(self): + subquery = Query.from_(self.table_efg).select( + self.table_efg.base_id.as_("x"), self.table_efg.fizz, self.table_efg.buzz + ) + + test_query = ( + Query.from_(self.table_abc) + .join(subquery) + .on(subquery.x == self.table_abc.id) + .select(self.table_abc.foo, subquery.fizz, subquery.buzz) + ) + + self.assertEqual( + 'SELECT "abc"."foo","sq0"."fizz","sq0"."buzz" ' + 'FROM "abc" JOIN (' + 'SELECT "base_id" "x","fizz","buzz" FROM "efg"' + ') "sq0" ' + 'ON "sq0"."x"="abc"."id"', + str(test_query), + ) + + def test_join_query_with_column_alias(self): + subquery = ( + Query.from_(self.table_efg) + .select( + self.table_efg.base_id.as_("x"), + self.table_efg.fizz, + self.table_efg.buzz, + ) + .as_("subq") + ) + + test_query = ( + Query.from_(self.table_abc) + .join(subquery) + .on(subquery.x == self.table_abc.id) + .select(self.table_abc.foo, subquery.fizz, subquery.buzz) + ) + + self.assertEqual( + 'SELECT "abc"."foo","subq"."fizz","subq"."buzz" ' + 'FROM "abc" JOIN (' + 'SELECT "base_id" "x","fizz","buzz" FROM "efg"' + ') "subq" ' + 'ON "subq"."x"="abc"."id"', + str(test_query), + ) + + def test_join_query_with_table_alias(self): + xxx = self.table_efg.as_("xxx") + subquery = Query.from_(xxx).select(xxx.base_id, xxx.fizz, xxx.buzz).as_("subq") + + test_query = ( + Query.from_(self.table_abc) + .join(subquery) + .on(subquery.x == self.table_abc.id) + .select(self.table_abc.foo, subquery.fizz, subquery.buzz) + ) + + self.assertEqual( + 'SELECT "abc"."foo","subq"."fizz","subq"."buzz" ' + 'FROM "abc" JOIN (' + 'SELECT "xxx"."base_id","xxx"."fizz","xxx"."buzz" FROM "efg" "xxx"' + ') "subq" ' + 'ON "subq"."x"="abc"."id"', + str(test_query), + ) + + def test_join_query_with_setoperation(self): + subquery = Query.from_(self.table_abc).select("*").union(Query.from_(self.table_abc).select("*")).as_("subq") + + test_query = ( + Query.from_(self.table_abc).join(subquery).on(subquery.x == self.table_abc.id).select(self.table_abc.foo) + ) + + self.assertEqual( + 'SELECT "abc"."foo" FROM "abc" ' + 'JOIN ' + '((SELECT * FROM "abc") ' + 'UNION ' + '(SELECT * FROM "abc")) "subq" ' + 'ON "subq"."x"="abc"."id"', + str(test_query), + ) + + +class UnionTests(unittest.TestCase): + table1, table2 = Tables("abc", "efg") + + def test_union(self): + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + + self.assertEqual( + '(SELECT "foo" FROM "abc") UNION (SELECT "bar" FROM "efg")', + str(query1 + query2), + ) + self.assertEqual( + '(SELECT "foo" FROM "abc") UNION (SELECT "bar" FROM "efg")', + str(query1.union(query2)), + ) + + def test_union_multiple(self): + table3, table4 = Tables("hij", "lmn") + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + query3 = Query.from_(table3).select(table3.baz) + query4 = Query.from_(table4).select(table4.faz) + + self.assertEqual( + '(SELECT "foo" FROM "abc") UNION ' + '(SELECT "bar" FROM "efg") UNION ' + '(SELECT "baz" FROM "hij") UNION ' + '(SELECT "faz" FROM "lmn")', + str(query1 + query2 + query3 + query4), + ) + self.assertEqual( + '(SELECT "foo" FROM "abc") UNION ' + '(SELECT "bar" FROM "efg") UNION ' + '(SELECT "baz" FROM "hij") UNION ' + '(SELECT "faz" FROM "lmn")', + str(query1.union(query2).union(query3).union(query4)), + ) + + def test_union_all(self): + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + + self.assertEqual( + '(SELECT "foo" FROM "abc") UNION ALL (SELECT "bar" FROM "efg")', + str(query1 * query2), + ) + self.assertEqual( + '(SELECT "foo" FROM "abc") UNION ALL (SELECT "bar" FROM "efg")', + str(query1.union_all(query2)), + ) + + def test_union_all_multiple(self): + table3, table4 = Tables("hij", "lmn") + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + query3 = Query.from_(table3).select(table3.baz) + query4 = Query.from_(table4).select(table4.faz) + + self.assertEqual( + '(SELECT "foo" FROM "abc") UNION ALL ' + '(SELECT "bar" FROM "efg") UNION ALL ' + '(SELECT "baz" FROM "hij") UNION ALL ' + '(SELECT "faz" FROM "lmn")', + str(query1 * query2 * query3 * query4), + ) + self.assertEqual( + '(SELECT "foo" FROM "abc") UNION ALL ' + '(SELECT "bar" FROM "efg") UNION ALL ' + '(SELECT "baz" FROM "hij") UNION ALL ' + '(SELECT "faz" FROM "lmn")', + str(query1.union_all(query2).union_all(query3).union_all(query4)), + ) + + def test_union_with_order_by(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + union_query = str((query1 + query2).orderby(query1.field("a"))) + union_all_query = str((query1 * query2).orderby(query1.field("a"))) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "UNION " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "a"', + union_query, + ) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "UNION ALL " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "a"', + union_all_query, + ) + + def test_union_with_order_by_use_union_query_field(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + union_query = query1 + query2 + union_query = str(union_query.orderby(union_query.field("a"))) + union_all_query = query1 * query2 + union_all_query = str(union_all_query.orderby(union_all_query.field("a"))) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "UNION " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "a"', + union_query, + ) + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "UNION ALL " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "a"', + union_all_query, + ) + + def test_union_with_order_by_with_aliases(self): + query1 = Query.from_(self.table1.as_("a")).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2.as_("b")).select(self.table2.bar.as_("a")) + + union_all_query = str((query1 * query2).orderby(query1.field("a"))) + union_query = str((query1 + query2).orderby(query1.field("a"))) + self.assertEqual( + '(SELECT "foo" "a" FROM "abc" "a")' " UNION ALL " '(SELECT "bar" "a" FROM "efg" "b")' ' ORDER BY "a"', + union_all_query, + ) + self.assertEqual( + '(SELECT "foo" "a" FROM "abc" "a")' " UNION " '(SELECT "bar" "a" FROM "efg" "b")' ' ORDER BY "a"', + union_query, + ) + + def test_union_with_order_by_use_union_query_field_with_aliases(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + union_query = (query1 + query2).as_("x") + union_query = union_query.orderby(union_query.field("a")) + union_all_query = (query1 * query2).as_("x") + union_all_query = union_all_query.orderby(union_all_query.field("a")) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "UNION " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "x"."a"', + str(union_query), + ) + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "UNION ALL " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "x"."a"', + str(union_all_query), + ) + + def test_require_equal_number_of_fields(self): + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.fiz, self.table2.buz) + + with self.assertRaises(SetOperationException): + str(query1 + query2) + + def test_mysql_query_wraps_unioned_queries(self): + query1 = MySQLQuery.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + + self.assertEqual( + "(SELECT `foo` FROM `abc`) UNION (SELECT `bar` FROM `efg`)", + str(query1 + query2), + ) + + def test_union_as_subquery(self): + abc, efg = Tables("abc", "efg") + hij = Query.from_(abc).select(abc.t).union(Query.from_(efg).select(efg.t)) + q = Query.from_(hij).select(fn.Avg(hij.t)) + + self.assertEqual( + 'SELECT AVG("sq0"."t") FROM ((SELECT "t" FROM "abc") UNION (SELECT "t" FROM "efg")) "sq0"', + str(q), + ) + + def test_union_with_no_quote_char(self): + abc, efg = Tables("abc", "efg") + hij = Query.from_(abc).select(abc.t).union(Query.from_(efg).select(efg.t)) + q = Query.from_(hij).select(fn.Avg(hij.t)) + + self.assertEqual( + "SELECT AVG(sq0.t) FROM ((SELECT t FROM abc) UNION (SELECT t FROM efg)) sq0", + q.get_sql(quote_char=None), + ) + + +class InsertQueryJoinTests(unittest.TestCase): + def test_join_table_on_insert_query(self): + a, b, c = Tables("a", "b", "c") + q = Query.into(c).from_(a).join(b).on(a.fkey_id == b.id).where(b.foo == 1).select("a.*", "b.*") + + self.assertEqual( + 'INSERT INTO "c" ' + 'SELECT "a"."a.*","a"."b.*" ' + 'FROM "a" JOIN "b" ' + 'ON "a"."fkey_id"="b"."id" ' + 'WHERE "b"."foo"=1', + str(q), + ) + + +class UpdateQueryJoinTests(unittest.TestCase): + def test_join_table_on_update_query(self): + a, b = Tables("a", "b") + q = Query.update(a).join(b).on(a.fkey_id == b.id).where(b.foo == 1).set("adwords_batch_job_id", 1) + + self.assertEqual( + 'UPDATE "a" ' 'JOIN "b" ' 'ON "a"."fkey_id"="b"."id" ' 'SET "adwords_batch_job_id"=1 ' 'WHERE "b"."foo"=1', + str(q), + ) + + +class IntersectTests(unittest.TestCase): + table1, table2 = Tables("abc", "efg") + + def test_intersect(self): + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + + self.assertEqual( + '(SELECT "foo" FROM "abc") INTERSECT (SELECT "bar" FROM "efg")', + str(query1.intersect(query2)), + ) + + def test_intersect_multiple(self): + table3, table4 = Tables("hij", "lmn") + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + query3 = Query.from_(table3).select(table3.baz) + query4 = Query.from_(table4).select(table4.faz) + + self.assertEqual( + '(SELECT "foo" FROM "abc") INTERSECT ' + '(SELECT "bar" FROM "efg") INTERSECT ' + '(SELECT "baz" FROM "hij") INTERSECT ' + '(SELECT "faz" FROM "lmn")', + str(query1.intersect(query2).intersect(query3).intersect(query4)), + ) + + def test_intersect_with_order_by(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + intersect_query = str((query1.intersect(query2)).orderby(query1.field("a"))) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "INTERSECT " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "a"', + intersect_query, + ) + + def test_intersect_with_limit(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + intersect_query = str((query1.intersect(query2)).limit(10)) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "INTERSECT " '(SELECT "bar" "a" FROM "efg") ' 'LIMIT 10', + intersect_query, + ) + + def test_intersect_with_offset(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + intersect_query = str((query1.intersect(query2)).offset(10)) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "INTERSECT " '(SELECT "bar" "a" FROM "efg") ' 'OFFSET 10', + intersect_query, + ) + + def test_require_equal_number_of_fields_intersect(self): + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.fiz, self.table2.buz) + + with self.assertRaises(SetOperationException): + str(query1.intersect(query2)) + + def test_mysql_query_wraps_intersected_queries(self): + query1 = MySQLQuery.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + + self.assertEqual( + "(SELECT `foo` FROM `abc`) INTERSECT (SELECT `bar` FROM `efg`)", + str(query1.intersect(query2)), + ) + + def test_intersect_as_subquery(self): + abc, efg = Tables("abc", "efg") + hij = Query.from_(abc).select(abc.t).intersect(Query.from_(efg).select(efg.t)) + q = Query.from_(hij).select(fn.Avg(hij.t)) + + self.assertEqual( + 'SELECT AVG("sq0"."t") FROM ((SELECT "t" FROM "abc") INTERSECT (SELECT "t" FROM "efg")) "sq0"', + str(q), + ) + + def test_intersect_with_no_quote_char(self): + abc, efg = Tables("abc", "efg") + hij = Query.from_(abc).select(abc.t).intersect(Query.from_(efg).select(efg.t)) + q = Query.from_(hij).select(fn.Avg(hij.t)) + + self.assertEqual( + "SELECT AVG(sq0.t) FROM ((SELECT t FROM abc) INTERSECT (SELECT t FROM efg)) sq0", + q.get_sql(quote_char=None), + ) + + +class MinusTests(unittest.TestCase): + table1, table2 = Tables("abc", "efg") + + def test_minus(self): + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + + self.assertEqual('(SELECT "foo" FROM "abc") MINUS (SELECT "bar" FROM "efg")', str(query1.minus(query2))) + + self.assertEqual( + '(SELECT "foo" FROM "abc") MINUS (SELECT "bar" FROM "efg")', + str(query1 - query2), + ) + + def test_minus_multiple(self): + table3, table4 = Tables("hij", "lmn") + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + query3 = Query.from_(table3).select(table3.baz) + query4 = Query.from_(table4).select(table4.faz) + + self.assertEqual( + '(SELECT "foo" FROM "abc") MINUS ' + '(SELECT "bar" FROM "efg") MINUS ' + '(SELECT "baz" FROM "hij") MINUS ' + '(SELECT "faz" FROM "lmn")', + str(query1 - query2 - query3 - query4), + ) + + self.assertEqual( + '(SELECT "foo" FROM "abc") MINUS ' + '(SELECT "bar" FROM "efg") MINUS ' + '(SELECT "baz" FROM "hij") MINUS ' + '(SELECT "faz" FROM "lmn")', + str(query1.minus(query2).minus(query3).minus(query4)), + ) + + def test_minus_with_order_by(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + minus_query = str(query1.minus(query2).orderby(query1.field("a"))) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "MINUS " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "a"', minus_query + ) + + def test_minus_query_with_order_by_use_minus_query_field(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + minus_query = query1.minus(query2) + minus_query = str(minus_query.orderby(minus_query.field("b"))) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "MINUS " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "b"', + minus_query, + ) + + def test_require_equal_number_of_fields(self): + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.fiz, self.table2.buz) + + with self.assertRaises(SetOperationException): + str(query1.minus(query2)) + + def test_mysql_query_wraps_minus_queries(self): + query1 = MySQLQuery.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + + self.assertEqual( + "(SELECT `foo` FROM `abc`) MINUS (SELECT `bar` FROM `efg`)", + str(query1 - query2), + ) + + def test_minus_as_subquery(self): + abc, efg = Tables("abc", "efg") + hij = Query.from_(abc).select(abc.t).minus(Query.from_(efg).select(efg.t)) + q = Query.from_(hij).select(fn.Avg(hij.t)) + + self.assertEqual( + 'SELECT AVG("sq0"."t") FROM ((SELECT "t" FROM "abc") MINUS (SELECT "t" FROM "efg")) "sq0"', + str(q), + ) + + def test_minus_with_no_quote_char(self): + abc, efg = Tables("abc", "efg") + hij = Query.from_(abc).select(abc.t).minus(Query.from_(efg).select(efg.t)) + q = Query.from_(hij).select(fn.Avg(hij.t)) + + self.assertEqual( + "SELECT AVG(sq0.t) FROM ((SELECT t FROM abc) MINUS (SELECT t FROM efg)) sq0", + q.get_sql(quote_char=None), + ) + + +class ExceptOfTests(unittest.TestCase): + table1, table2 = Tables("abc", "efg") + + def test_except(self): + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + + self.assertEqual('(SELECT "foo" FROM "abc") EXCEPT (SELECT "bar" FROM "efg")', str(query1.except_of(query2))) + + def test_except_multiple(self): + table3, table4 = Tables("hij", "lmn") + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + query3 = Query.from_(table3).select(table3.baz) + query4 = Query.from_(table4).select(table4.faz) + + self.assertEqual( + '(SELECT "foo" FROM "abc") EXCEPT ' + '(SELECT "bar" FROM "efg") EXCEPT ' + '(SELECT "baz" FROM "hij") EXCEPT ' + '(SELECT "faz" FROM "lmn")', + str(query1.except_of(query2).except_of(query3).except_of(query4)), + ) + + def test_except_with_order_by(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + except_query = str(query1.except_of(query2).orderby(query1.field("a"))) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "EXCEPT " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "a"', except_query + ) + + def test_except_query_with_order_by_use_minus_query_field(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + except_query = query1.except_of(query2) + except_query = str(except_query.orderby(except_query.field("b"))) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "EXCEPT " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "b"', + except_query, + ) + + def test_require_equal_number_of_fields_except_of(self): + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.fiz, self.table2.buz) + + with self.assertRaises(SetOperationException): + str(query1.except_of(query2)) + + def test_except_as_subquery(self): + abc, efg = Tables("abc", "efg") + hij = Query.from_(abc).select(abc.t).except_of(Query.from_(efg).select(efg.t)) + q = Query.from_(hij).select(fn.Avg(hij.t)) + + self.assertEqual( + 'SELECT AVG("sq0"."t") FROM ((SELECT "t" FROM "abc") EXCEPT (SELECT "t" FROM "efg")) "sq0"', + str(q), + ) + + def test_except_with_no_quote_char(self): + abc, efg = Tables("abc", "efg") + hij = Query.from_(abc).select(abc.t).except_of(Query.from_(efg).select(efg.t)) + q = Query.from_(hij).select(fn.Avg(hij.t)) + + self.assertEqual( + "SELECT AVG(sq0.t) FROM ((SELECT t FROM abc) EXCEPT (SELECT t FROM efg)) sq0", + q.get_sql(quote_char=None), + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/test_negation.py b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/test_negation.py new file mode 100644 index 0000000000000000000000000000000000000000..9f4db83b560dbc8546ce6d384b781dfccefd319d --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/test_negation.py @@ -0,0 +1,31 @@ +import unittest + +from pypika import ( + Tables, + functions as fn, +) +from pypika.terms import ValueWrapper + + +class NegationTests(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_negate_wrapped_float(self): + q = -ValueWrapper(1.0) + + self.assertEqual("-1.0", q.get_sql()) + + def test_negate_wrapped_int(self): + q = -ValueWrapper(1) + + self.assertEqual("-1", q.get_sql()) + + def test_negate_field(self): + q = -self.table_abc.foo + + self.assertEqual('-"abc"."foo"', q.get_sql(with_namespace=True, quote_char='"')) + + def test_negate_function(self): + q = -fn.Sum(self.table_abc.foo) + + self.assertEqual('-SUM("abc"."foo")', q.get_sql(with_namespace=True, quote_char='"')) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/test_parameter.py b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/test_parameter.py new file mode 100644 index 0000000000000000000000000000000000000000..c11e9afcd9624abb0a7313306eda34ebcf4c99ba --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/test_parameter.py @@ -0,0 +1,206 @@ +import unittest +from datetime import date + +from pypika import ( + FormatParameter, + NamedParameter, + NumericParameter, + Parameter, + PyformatParameter, + QmarkParameter, + Query, + Tables, +) +from pypika.terms import ListParameter, ParameterValueWrapper + + +class ParametrizedTests(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_param_insert(self): + q = Query.into(self.table_abc).columns("a", "b", "c").insert(Parameter("?"), Parameter("?"), Parameter("?")) + + self.assertEqual('INSERT INTO "abc" ("a","b","c") VALUES (?,?,?)', q.get_sql()) + + def test_param_select_join(self): + q = ( + Query.from_(self.table_abc) + .select("*") + .where(self.table_abc.category == Parameter("%s")) + .join(self.table_efg) + .on(self.table_abc.id == self.table_efg.abc_id) + .where(self.table_efg.date >= Parameter("%s")) + .limit(10) + ) + + self.assertEqual( + 'SELECT * FROM "abc" JOIN "efg" ON "abc"."id"="efg"."abc_id" WHERE "abc"."category"=%s AND "efg"."date">=%s LIMIT 10', + q.get_sql(), + ) + + def test_param_select_subquery(self): + q = ( + Query.from_(self.table_abc) + .select("*") + .where(self.table_abc.category == Parameter("&1")) + .where( + self.table_abc.id.isin( + Query.from_(self.table_efg) + .select(self.table_efg.abc_id) + .where(self.table_efg.date >= Parameter("&2")) + ) + ) + .limit(10) + ) + + self.assertEqual( + 'SELECT * FROM "abc" WHERE "category"=&1 AND "id" IN (SELECT "abc_id" FROM "efg" WHERE "date">=&2) LIMIT 10', + q.get_sql(), + ) + + def test_join(self): + subquery = ( + Query.from_(self.table_efg) + .select(self.table_efg.fiz, self.table_efg.buz) + .where(self.table_efg.buz == Parameter(":buz")) + ) + + q = ( + Query.from_(self.table_abc) + .join(subquery) + .on(self.table_abc.bar == subquery.buz) + .select(self.table_abc.foo, subquery.fiz) + .where(self.table_abc.bar == Parameter(":bar")) + ) + + self.assertEqual( + 'SELECT "abc"."foo","sq0"."fiz" FROM "abc" JOIN (SELECT "fiz","buz" FROM "efg" WHERE "buz"=:buz)' + ' "sq0" ON "abc"."bar"="sq0"."buz" WHERE "abc"."bar"=:bar', + q.get_sql(), + ) + + def test_qmark_parameter(self): + self.assertEqual('?', QmarkParameter().get_sql()) + + def test_numeric_parameter(self): + self.assertEqual(':14', NumericParameter('14').get_sql()) + self.assertEqual(':15', NumericParameter(15).get_sql()) + + def test_named_parameter(self): + self.assertEqual(':buz', NamedParameter('buz').get_sql()) + + def test_format_parameter(self): + self.assertEqual('%s', FormatParameter().get_sql()) + + def test_pyformat_parameter(self): + self.assertEqual('%(buz)s', PyformatParameter('buz').get_sql()) + + +class ParametrizedTestsWithValues(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_param_insert(self): + q = Query.into(self.table_abc).columns("a", "b", "c").insert(1, 2.2, 'foo') + + parameter = QmarkParameter() + sql = q.get_sql(parameter=parameter) + self.assertEqual('INSERT INTO "abc" ("a","b","c") VALUES (?,?,?)', sql) + self.assertEqual([1, 2.2, 'foo'], parameter.get_parameters()) + + def test_param_select_join(self): + q = ( + Query.from_(self.table_abc) + .select("*") + .where(self.table_abc.category == 'foobar') + .join(self.table_efg) + .on(self.table_abc.id == self.table_efg.abc_id) + .where(self.table_efg.date >= date(2024, 2, 22)) + .limit(10) + ) + + parameter = FormatParameter() + sql = q.get_sql(parameter=parameter) + self.assertEqual( + 'SELECT * FROM "abc" JOIN "efg" ON "abc"."id"="efg"."abc_id" WHERE "abc"."category"=%s AND "efg"."date">=%s LIMIT 10', + sql, + ) + self.assertEqual(['foobar', '2024-02-22'], parameter.get_parameters()) + + def test_param_select_subquery(self): + q = ( + Query.from_(self.table_abc) + .select("*") + .where(self.table_abc.category == 'foobar') + .where( + self.table_abc.id.isin( + Query.from_(self.table_efg) + .select(self.table_efg.abc_id) + .where(self.table_efg.date >= date(2024, 2, 22)) + ) + ) + .limit(10) + ) + + parameter = ListParameter(placeholder=lambda idx: f'&{idx+1}') + sql = q.get_sql(parameter=parameter) + self.assertEqual( + 'SELECT * FROM "abc" WHERE "category"=&1 AND "id" IN (SELECT "abc_id" FROM "efg" WHERE "date">=&2) LIMIT 10', + sql, + ) + self.assertEqual(['foobar', '2024-02-22'], parameter.get_parameters()) + + def test_join(self): + subquery = ( + Query.from_(self.table_efg) + .select(self.table_efg.fiz, self.table_efg.buz) + .where(self.table_efg.buz == 'buz') + ) + + q = ( + Query.from_(self.table_abc) + .join(subquery) + .on(self.table_abc.bar == subquery.buz) + .select(self.table_abc.foo, subquery.fiz) + .where(self.table_abc.bar == 'bar') + ) + + parameter = NamedParameter() + sql = q.get_sql(parameter=parameter) + self.assertEqual( + 'SELECT "abc"."foo","sq0"."fiz" FROM "abc" JOIN (SELECT "fiz","buz" FROM "efg" WHERE "buz"=:param1)' + ' "sq0" ON "abc"."bar"="sq0"."buz" WHERE "abc"."bar"=:param2', + sql, + ) + self.assertEqual({'param1': 'buz', 'param2': 'bar'}, parameter.get_parameters()) + + def test_join_with_parameter_value_wrapper(self): + subquery = ( + Query.from_(self.table_efg) + .select(self.table_efg.fiz, self.table_efg.buz) + .where(self.table_efg.buz == ParameterValueWrapper(Parameter(':buz'), 'buz')) + ) + + q = ( + Query.from_(self.table_abc) + .join(subquery) + .on(self.table_abc.bar == subquery.buz) + .select(self.table_abc.foo, subquery.fiz) + .where(self.table_abc.bar == ParameterValueWrapper(NamedParameter('bar'), 'bar')) + ) + + parameter = NamedParameter() + sql = q.get_sql(parameter=parameter) + self.assertEqual( + 'SELECT "abc"."foo","sq0"."fiz" FROM "abc" JOIN (SELECT "fiz","buz" FROM "efg" WHERE "buz"=:buz)' + ' "sq0" ON "abc"."bar"="sq0"."buz" WHERE "abc"."bar"=:bar', + sql, + ) + self.assertEqual({':buz': 'buz', 'bar': 'bar'}, parameter.get_parameters()) + + def test_pyformat_parameter(self): + q = Query.into(self.table_abc).columns("a", "b", "c").insert(1, 2.2, 'foo') + + parameter = PyformatParameter() + sql = q.get_sql(parameter=parameter) + self.assertEqual('INSERT INTO "abc" ("a","b","c") VALUES (%(param1)s,%(param2)s,%(param3)s)', sql) + self.assertEqual({"param1": 1, "param2": 2.2, "param3": "foo"}, parameter.get_parameters()) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/test_pseudocolumns.py b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/test_pseudocolumns.py new file mode 100644 index 0000000000000000000000000000000000000000..6a25c70269b2ccc98ac3870ac64a43c8a32ddbe9 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/test_pseudocolumns.py @@ -0,0 +1,51 @@ +import unittest + +from pypika import Query, Table +from pypika.pseudocolumns import ( + ColumnValue, + ObjectID, + ObjectValue, + RowID, + RowNum, + SysDate, +) +from pypika.terms import PseudoColumn + + +class PseudoColumnsTest(unittest.TestCase): + @classmethod + def setUpClass(cls): + super(PseudoColumnsTest, cls).setUpClass() + cls.table1 = Table("table1") + + def test_column_value(self): + self.assertEqual("COLUMN_VALUE", ColumnValue) + + def test_object_id(self): + self.assertEqual("OBJECT_ID", ObjectID) + + def test_object_value(self): + self.assertEqual("OBJECT_VALUE", ObjectValue) + + def test_row_id(self): + self.assertEqual("ROWID", RowID) + + def test_row_num(self): + self.assertEqual("ROWNUM", RowNum) + + def test_sys_date(self): + self.assertEqual("SYSDATE", SysDate) + + def test_can_be_used_in_a_select_statement(self): + query = Query.from_(self.table1).where(self.table1.is_active == 1).select(PseudoColumn("abcde")) + + self.assertEqual(str(query), 'SELECT abcde FROM "table1" WHERE "is_active"=1') + + def test_can_be_used_in_a_where_clause(self): + query = Query.from_(self.table1).where(PseudoColumn("abcde") > 1).select(self.table1.is_active) + + self.assertEqual(str(query), 'SELECT "is_active" FROM "table1" WHERE abcde>1') + + def test_can_be_used_in_orderby(self): + query = Query.from_(self.table1).select(self.table1.abcde.as_("some_name")).orderby(PseudoColumn("some_name")) + self.assertEqual(str(query), 'SELECT "abcde" "some_name" FROM "table1" ORDER BY some_name') diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/test_query.py b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/test_query.py new file mode 100644 index 0000000000000000000000000000000000000000..ae8dc01599a6a562b591ce15391bfe9b5c87e0f9 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/test_query.py @@ -0,0 +1,242 @@ +import unittest + +from pypika import Case, Query, Tables, Tuple, functions, Field +from pypika.dialects import ( + ClickHouseQuery, + ClickHouseQueryBuilder, + MSSQLQuery, + MSSQLQueryBuilder, + MySQLLoadQueryBuilder, + MySQLQuery, + MySQLQueryBuilder, + OracleQuery, + OracleQueryBuilder, + PostgreSQLQuery, + PostgreSQLQueryBuilder, + RedShiftQueryBuilder, + RedshiftQuery, + SQLLiteQuery, + SQLLiteQueryBuilder, + SnowflakeQuery, + SnowflakeQueryBuilder, + VerticaCopyQueryBuilder, + VerticaCreateQueryBuilder, + VerticaQuery, + VerticaQueryBuilder, +) +from pypika.queries import CreateQueryBuilder, DropQueryBuilder, QueryBuilder + + +class QueryTablesTests(unittest.TestCase): + table_a, table_b, table_c, table_d = Tables("a", "b", "c", "d") + + def test_replace_table(self): + query = Query.from_(self.table_a).select(self.table_a.time) + query = query.replace_table(self.table_a, self.table_b) + + self.assertEqual('SELECT "time" FROM "b"', str(query)) + + def test_replace_only_specified_table(self): + query = Query.from_(self.table_a).select(self.table_a.time) + query = query.replace_table(self.table_b, self.table_c) + + self.assertEqual('SELECT "time" FROM "a"', str(query)) + + def test_replace_insert_table(self): + query = Query.into(self.table_a).insert(1) + query = query.replace_table(self.table_a, self.table_b) + + self.assertEqual('INSERT INTO "b" VALUES (1)', str(query)) + + def test_replace_insert_table_current_table_not_match(self): + query = Query.into(self.table_a).insert(1) + query = query.replace_table(self.table_c, self.table_b) + + self.assertEqual('INSERT INTO "a" VALUES (1)', str(query)) + + def test_replace_update_table(self): + query = Query.update(self.table_a).set("foo", "bar") + query = query.replace_table(self.table_a, self.table_b) + + self.assertEqual('UPDATE "b" SET "foo"=\'bar\'', str(query)) + + def test_replace_update_table_current_table_not_match(self): + query = Query.update(self.table_a).set("foo", "bar") + query = query.replace_table(self.table_c, self.table_b) + + self.assertEqual('UPDATE "a" SET "foo"=\'bar\'', str(query)) + + def test_replace_delete_table(self): + query = Query.from_(self.table_a).delete() + query = query.replace_table(self.table_a, self.table_b) + + self.assertEqual('DELETE FROM "b"', str(query)) + + def test_replace_join_tables(self): + query = ( + Query.from_(self.table_a) + .join(self.table_b) + .on(self.table_a.customer_id == self.table_b.id) + .join(self.table_c) + .on(self.table_b.seller_id == self.table_c.id) + .select(self.table_a.star) + ) + query = query.replace_table(self.table_a, self.table_d) + + self.assertEqual( + 'SELECT "d".* ' + 'FROM "d" ' + 'JOIN "b" ON "d"."customer_id"="b"."id" ' + 'JOIN "c" ON "b"."seller_id"="c"."id"', + str(query), + ) + + def test_replace_filter_tables(self): + query = Query.from_(self.table_a).select(self.table_a.name).where(self.table_a.name == "Mustermann") + query = query.replace_table(self.table_a, self.table_b) + + self.assertEqual('SELECT "name" FROM "b" WHERE "name"=\'Mustermann\'', str(query)) + + def test_replace_having_table(self): + query = ( + Query.from_(self.table_a) + .select(functions.Sum(self.table_a.revenue)) + .groupby(self.table_a.customer) + .having(functions.Sum(self.table_a.revenue) >= 1000) + ) + query = query.replace_table(self.table_a, self.table_b) + + self.assertEqual( + 'SELECT SUM("revenue") ' 'FROM "b" ' 'GROUP BY "customer" ' 'HAVING SUM("revenue")>=1000', + str(query), + ) + + def test_replace_case_table(self): + query = Query.from_(self.table_a).select( + Case() + .when(self.table_a.fname == "Tom", "It was Tom") + .when(self.table_a.fname == "John", "It was John") + .else_("It was someone else.") + .as_("who_was_it") + ) + query = query.replace_table(self.table_a, self.table_b) + + self.assertEqual( + "SELECT CASE " + "WHEN \"fname\"='Tom' THEN 'It was Tom' " + "WHEN \"fname\"='John' THEN 'It was John' " + "ELSE 'It was someone else.' END \"who_was_it\" " + 'FROM "b"', + str(query), + ) + + def test_replace_orderby_table(self): + query = Query.from_(self.table_a).select(self.table_a.customer).orderby(self.table_a.customer) + query = query.replace_table(self.table_a, self.table_b) + + self.assertEqual('SELECT "customer" FROM "b" ORDER BY "customer"', str(query)) + + def test_replace_tuple_table(self): + query = ( + Query.from_(self.table_a) + .select(self.table_a.cost, self.table_a.revenue) + .where((self.table_a.cost, self.table_a.revenue) == Tuple(1, 2)) + ) + + query = query.replace_table(self.table_a, self.table_b) + + # Order is reversed due to lack of right equals method + self.assertEqual( + 'SELECT "cost","revenue" FROM "b" WHERE (1,2)=("cost","revenue")', + str(query), + ) + + def test_is_joined(self): + q = Query.from_(self.table_a).join(self.table_b).on(self.table_a.foo == self.table_b.boo) + + self.assertTrue(q.is_joined(self.table_b)) + self.assertFalse(q.is_joined(self.table_c)) + + +class QueryBuilderTests(unittest.TestCase): + def test_query_builders_have_reference_to_correct_query_class(self): + with self.subTest('QueryBuilder'): + self.assertEqual(Query, QueryBuilder.QUERY_CLS) + + with self.subTest('DropQueryBuilder'): + self.assertEqual(Query, DropQueryBuilder.QUERY_CLS) + + with self.subTest('CreateQueryBuilder'): + self.assertEqual(Query, CreateQueryBuilder.QUERY_CLS) + + with self.subTest('MySQLQueryBuilder'): + self.assertEqual(MySQLQuery, MySQLQueryBuilder.QUERY_CLS) + + with self.subTest('MySQLLoadQueryBuilder'): + self.assertEqual(MySQLQuery, MySQLLoadQueryBuilder.QUERY_CLS) + + with self.subTest('VerticaQueryBuilder'): + self.assertEqual(VerticaQuery, VerticaQueryBuilder.QUERY_CLS) + + with self.subTest('VerticaCreateQueryBuilder'): + self.assertEqual(VerticaQuery, VerticaCreateQueryBuilder.QUERY_CLS) + + with self.subTest('VerticaCopyQueryBuilder'): + self.assertEqual(VerticaQuery, VerticaCopyQueryBuilder.QUERY_CLS) + + with self.subTest('PostgreSQLQueryBuilder'): + self.assertEqual(PostgreSQLQuery, PostgreSQLQueryBuilder.QUERY_CLS) + + with self.subTest('MSSQLQueryBuilder'): + self.assertEqual(MSSQLQuery, MSSQLQueryBuilder.QUERY_CLS) + + with self.subTest('SnowflakeQueryBuilder'): + self.assertEqual(SnowflakeQuery, SnowflakeQueryBuilder.QUERY_CLS) + + with self.subTest('ClickHouseQueryBuilder'): + self.assertEqual(ClickHouseQuery, ClickHouseQueryBuilder.QUERY_CLS) + + with self.subTest('RedShiftQueryBuilder'): + self.assertEqual(RedshiftQuery, RedShiftQueryBuilder.QUERY_CLS) + + with self.subTest('SQLLiteQueryBuilder'): + self.assertEqual(SQLLiteQuery, SQLLiteQueryBuilder.QUERY_CLS) + + with self.subTest('OracleQueryBuilder'): + self.assertEqual(OracleQuery, OracleQueryBuilder.QUERY_CLS) + + def test_pipe(self) -> None: + base_query = Query.from_("test") + + def select(query: QueryBuilder) -> QueryBuilder: + return query.select("test1", "test2") + + def count_group(query: QueryBuilder, *groups) -> QueryBuilder: + return query.groupby(*groups).select(*groups, functions.Count("*")) + + for func, args, kwargs, expected_str in [ + (select, [], {}, 'SELECT "test1","test2" FROM "test"'), + ( + count_group, + ["test1", "test2"], + {}, + 'SELECT "test1","test2",COUNT(*) FROM "test" GROUP BY "test1","test2"', + ), + (count_group, ["test1"], {}, 'SELECT "test1",COUNT(*) FROM "test" GROUP BY "test1"'), + ]: + result_str = str(base_query.pipe(func, *args, **kwargs)) + self.assertEqual(result_str, str(func(base_query, *args, **kwargs))) + self.assertEqual(result_str, expected_str) + + def where_clause(query: QueryBuilder, num_days: int) -> QueryBuilder: + return query.where(Field("date") > functions.Now() - num_days) + + result_str = str(base_query.pipe(select).pipe(where_clause, num_days=1)) + self.assertEqual( + result_str, + str(select(where_clause(base_query, num_days=1))), + ) + self.assertEqual( + result_str, + 'SELECT "test1","test2" FROM "test" WHERE "date">NOW()-1', + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/test_selects.py b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/test_selects.py new file mode 100644 index 0000000000000000000000000000000000000000..1ce04937492e655db362b7e2a0a6856abf22a48f --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/test_selects.py @@ -0,0 +1,1331 @@ +import unittest +from datetime import date +from enum import Enum + +from pypika import ( + AliasedQuery, + Case, + ClickHouseQuery, + EmptyCriterion, + Field as F, + Index, + MSSQLQuery, + MySQLQuery, + NullValue, + OracleQuery, + Order, + PostgreSQLQuery, + Query, + QueryException, + RedshiftQuery, + SQLLiteQuery, + Table, + Tables, + VerticaQuery, + functions as fn, + SYSTEM_TIME, +) +from pypika.terms import ValueWrapper + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + + +class SelectTests(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_empty_query(self): + q = Query.from_("abc") + + self.assertEqual("", str(q)) + + def test_select_no_from(self): + q = Query.select(1) + + self.assertEqual("SELECT 1", str(q)) + + def test_select_no_with_alias_from(self): + q = Query.select(ValueWrapper(1, "test")) + + self.assertEqual('SELECT 1 "test"', str(q)) + + def test_select_no_from_with_field_raises_exception(self): + with self.assertRaises(QueryException): + Query.select("asdf") + + def test_select__star(self): + q = Query.from_("abc").select("*") + + self.assertEqual('SELECT * FROM "abc"', str(q)) + + def test_select__table_schema(self): + q = Query.from_(Table("abc", "schema1")).select("*") + + self.assertEqual('SELECT * FROM "schema1"."abc"', str(q)) + + def test_select__table_schema_with_multiple_levels_as_tuple(self): + q = Query.from_(Table("abc", ("schema1", "schema2"))).select("*") + + self.assertEqual('SELECT * FROM "schema1"."schema2"."abc"', str(q)) + + def test_select__table_schema_with_multiple_levels_as_list(self): + q = Query.from_(Table("abc", ["schema1", "schema2"])).select("*") + + self.assertEqual('SELECT * FROM "schema1"."schema2"."abc"', str(q)) + + def test_select__star__replacement(self): + q = Query.from_("abc").select("foo").select("*") + + self.assertEqual('SELECT * FROM "abc"', str(q)) + + def test_select__distinct__single(self): + q = Query.from_("abc").select("foo").distinct() + + self.assertEqual('SELECT DISTINCT "foo" FROM "abc"', str(q)) + + def test_select__distinct__multi(self): + q = Query.from_("abc").select("foo", "bar").distinct() + + self.assertEqual('SELECT DISTINCT "foo","bar" FROM "abc"', str(q)) + + def test_select__column__single__str(self): + q = Query.from_("abc").select("foo") + + self.assertEqual('SELECT "foo" FROM "abc"', str(q)) + + def test_select__column__single__alias__str(self): + q = Query.from_(self.table_abc).select(self.table_abc.foo.as_("bar")) + + self.assertEqual('SELECT "foo" "bar" FROM "abc"', str(q)) + + def test_select__column__single__table_alias__str(self): + q = Query.from_(self.table_abc.as_("fizzbuzz")).select(self.table_abc.foo.as_("bar")) + + self.assertEqual('SELECT "foo" "bar" FROM "abc" "fizzbuzz"', str(q)) + + def test_select__column__single__field(self): + t = Table("abc") + q = Query.from_(t).select(t.foo) + + self.assertEqual('SELECT "foo" FROM "abc"', str(q)) + + def test_select__columns__multi__str(self): + q1 = Query.from_("abc").select("foo", "bar") + q2 = Query.from_("abc").select("foo").select("bar") + + self.assertEqual('SELECT "foo","bar" FROM "abc"', str(q1)) + self.assertEqual('SELECT "foo","bar" FROM "abc"', str(q2)) + + def test_select__columns__multi__field(self): + q1 = Query.from_(self.table_abc).select(self.table_abc.foo, self.table_abc.bar) + q2 = Query.from_(self.table_abc).select(self.table_abc.foo).select(self.table_abc.bar) + + self.assertEqual('SELECT "foo","bar" FROM "abc"', str(q1)) + self.assertEqual('SELECT "foo","bar" FROM "abc"', str(q2)) + + def test_select__multiple_tables(self): + q = Query.from_(self.table_abc).select(self.table_abc.foo).from_(self.table_efg).select(self.table_efg.bar) + + self.assertEqual('SELECT "abc"."foo","efg"."bar" FROM "abc","efg"', str(q)) + + def test_select__subquery(self): + subquery = Query.from_(self.table_abc).select("*") + q = Query.from_(subquery).select(subquery.foo, subquery.bar) + + self.assertEqual('SELECT "sq0"."foo","sq0"."bar" ' 'FROM (SELECT * FROM "abc") "sq0"', str(q)) + + def test_select__multiple_subqueries(self): + subquery0 = Query.from_(self.table_abc).select("foo") + subquery1 = Query.from_(self.table_efg).select("bar") + q = Query.from_(subquery0).from_(subquery1).select(subquery0.foo, subquery1.bar) + + self.assertEqual( + 'SELECT "sq0"."foo","sq1"."bar" ' 'FROM (SELECT "foo" FROM "abc") "sq0",' '(SELECT "bar" FROM "efg") "sq1"', + str(q), + ) + + def test_select__nested_subquery(self): + subquery0 = Query.from_(self.table_abc).select("*") + subquery1 = Query.from_(subquery0).select(subquery0.foo, subquery0.bar) + subquery2 = Query.from_(subquery1).select(subquery1.foo) + + q = Query.from_(subquery2).select(subquery2.foo) + + self.assertEqual( + 'SELECT "sq2"."foo" ' + 'FROM (SELECT "sq1"."foo" ' + 'FROM (SELECT "sq0"."foo","sq0"."bar" ' + 'FROM (SELECT * FROM "abc") "sq0") "sq1") "sq2"', + str(q), + ) + + def test_select__no_table(self): + q = Query.select(1, 2, 3) + + self.assertEqual("SELECT 1,2,3", str(q)) + + def test_select_then_add_table(self): + q = Query.select(1).select(2, 3).from_("abc").select("foo") + + self.assertEqual('SELECT 1,2,3,"foo" FROM "abc"', str(q)) + + def test_select_with_limit(self): + q1 = Query.from_("abc").select("foo")[:10] + + self.assertEqual('SELECT "foo" FROM "abc" LIMIT 10', str(q1)) + + def test_select_with_limit_zero(self): + with self.subTest('using python slice'): + q1 = Query.from_("abc").select("foo")[:0] + self.assertEqual('SELECT "foo" FROM "abc" LIMIT 0', str(q1)) + + with self.subTest('using limit method'): + q2 = Query.from_("abc").select("foo").limit(0) + self.assertEqual('SELECT "foo" FROM "abc" LIMIT 0', str(q2)) + + def test_select_with_limit__func(self): + q1 = Query.from_("abc").select("foo").limit(10) + + self.assertEqual('SELECT "foo" FROM "abc" LIMIT 10', str(q1)) + + def test_select_with_offset(self): + q1 = Query.from_("abc").select("foo")[10:] + + self.assertEqual('SELECT "foo" FROM "abc" OFFSET 10', str(q1)) + + def test_select_with_offset__func(self): + q1 = Query.from_("abc").select("foo").offset(10) + + self.assertEqual('SELECT "foo" FROM "abc" OFFSET 10', str(q1)) + + def test_select_with_limit_and_offset(self): + q1 = Query.from_("abc").select("foo")[10:10] + + self.assertEqual('SELECT "foo" FROM "abc" LIMIT 10 OFFSET 10', str(q1)) + + def test_select_with_force_index(self): + q = Query.from_("abc").select("foo").force_index("egg") + + self.assertEqual('SELECT "foo" FROM "abc" FORCE INDEX ("egg")', str(q)) + + def test_select_with_force_index_with_index_object(self): + index = Index("egg") + q = Query.from_("abc").select("foo").force_index(index) + + self.assertEqual('SELECT "foo" FROM "abc" FORCE INDEX ("egg")', str(q)) + + def test_select_with_force_index_multiple_indexes(self): + q = Query.from_("abc").select("foo").force_index("egg", "bacon") + + self.assertEqual('SELECT "foo" FROM "abc" FORCE INDEX ("egg","bacon")', str(q)) + + def test_select_with_force_index_multiple_calls(self): + q = ( + Query.from_("abc") + .select("foo") + .force_index( + "egg", + ) + .force_index("spam") + ) + + self.assertEqual('SELECT "foo" FROM "abc" FORCE INDEX ("egg","spam")', str(q)) + + def test_select_with_use_index(self): + q = Query.from_("abc").select("foo").use_index("egg") + + self.assertEqual('SELECT "foo" FROM "abc" USE INDEX ("egg")', str(q)) + + def test_select_with_use_index_with_index_object(self): + index = Index("egg") + q = Query.from_("abc").select("foo").use_index(index) + + self.assertEqual('SELECT "foo" FROM "abc" USE INDEX ("egg")', str(q)) + + def test_select_with_use_index_multiple_indexes(self): + q = Query.from_("abc").select("foo").use_index("egg", "bacon") + + self.assertEqual('SELECT "foo" FROM "abc" USE INDEX ("egg","bacon")', str(q)) + + def test_select_with_use_index_multiple_calls(self): + q = ( + Query.from_("abc") + .select("foo") + .use_index( + "egg", + ) + .use_index("spam") + ) + + self.assertEqual('SELECT "foo" FROM "abc" USE INDEX ("egg","spam")', str(q)) + + def test_mysql_query_uses_backtick_quote_chars(self): + q = MySQLQuery.from_("abc").select("foo", "bar") + + self.assertEqual("SELECT `foo`,`bar` FROM `abc`", str(q)) + + def test_vertica_query_uses_double_quote_chars(self): + q = VerticaQuery.from_("abc").select("foo", "bar") + + self.assertEqual('SELECT "foo","bar" FROM "abc"', str(q)) + + def test_mssql_query_uses_double_quote_chars(self): + q = MSSQLQuery.from_("abc").select("foo", "bar") + + self.assertEqual('SELECT "foo","bar" FROM "abc"', str(q)) + + def test_oracle_query_uses_no_quote_chars(self): + q = OracleQuery.from_("abc").select("foo", "bar") + + self.assertEqual('SELECT foo,bar FROM abc', str(q)) + + def test_postgresql_query_uses_double_quote_chars(self): + q = PostgreSQLQuery.from_("abc").select("foo", "bar") + + self.assertEqual('SELECT "foo","bar" FROM "abc"', str(q)) + + def test_redshift_query_uses_double_quote_chars(self): + q = RedshiftQuery.from_("abc").select("foo", "bar") + + self.assertEqual('SELECT "foo","bar" FROM "abc"', str(q)) + + def test_table_select_alias(self): + q = self.table_abc.select(1) + + self.assertEqual('SELECT 1 FROM "abc"', str(q)) + self.assertEqual(q, Query.from_("abc").select(1)) + + def test_table_select_alias_with_offset_and_limit(self): + self.assertEqual(self.table_abc.select("foo")[10:10], Query.from_("abc").select("foo")[10:10]) + self.assertEqual( + self.table_abc.select(self.table_abc.foo)[10:10], + Query.from_("abc").select("foo")[10:10], + ) + + def test_temporal_select(self): + t = Table("abc") + + with self.subTest("with system time as of"): + q = Query.from_(t.for_(SYSTEM_TIME.as_of('2020-01-01'))).select("*") + + self.assertEqual('SELECT * FROM "abc" FOR SYSTEM_TIME AS OF \'2020-01-01\'', str(q)) + + with self.subTest("with system time between"): + q = Query.from_(t.for_(SYSTEM_TIME.between('2020-01-01', '2020-02-01'))).select("*") + + self.assertEqual('SELECT * FROM "abc" FOR SYSTEM_TIME BETWEEN \'2020-01-01\' AND \'2020-02-01\'', str(q)) + + with self.subTest("with system time from to"): + q = Query.from_(t.for_(SYSTEM_TIME.from_to('2020-01-01', '2020-02-01'))).select("*") + + self.assertEqual('SELECT * FROM "abc" FOR SYSTEM_TIME FROM \'2020-01-01\' TO \'2020-02-01\'', str(q)) + + with self.subTest("with ALL"): + q = Query.from_(t.for_(SYSTEM_TIME.all_())).select("*") + + self.assertEqual('SELECT * FROM "abc" FOR SYSTEM_TIME ALL', str(q)) + + with self.subTest("with period between"): + q = Query.from_(t.for_(t.valid_period.between('2020-01-01', '2020-02-01'))).select("*") + + self.assertEqual('SELECT * FROM "abc" FOR "valid_period" BETWEEN \'2020-01-01\' AND \'2020-02-01\'', str(q)) + + with self.subTest("with period from to"): + q = Query.from_(t.for_(t.valid_period.from_to('2020-01-01', '2020-02-01'))).select("*") + + self.assertEqual('SELECT * FROM "abc" FOR "valid_period" FROM \'2020-01-01\' TO \'2020-02-01\'', str(q)) + + with self.subTest("with ALL"): + q = Query.from_(t.for_(t.valid_period.all_())).select("*") + + self.assertEqual('SELECT * FROM "abc" FOR "valid_period" ALL', str(q)) + + +class MyEnum(Enum): + STR = "foo" + INT = 0 + BOOL = True + DATE = date(2020, 2, 2) + NONE = None + + +class WhereTests(unittest.TestCase): + t = Table("abc") + t2 = Table("cba") + + def test_where_enum(self): + q1 = Query.from_(self.t).select("*").where(self.t.foo == MyEnum.STR) + q2 = Query.from_(self.t).select("*").where(self.t.foo == MyEnum.INT) + q3 = Query.from_(self.t).select("*").where(self.t.foo == MyEnum.BOOL) + q4 = Query.from_(self.t).select("*").where(self.t.foo == MyEnum.DATE) + q5 = Query.from_(self.t).select("*").where(self.t.foo == MyEnum.NONE) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo"=\'foo\'', str(q1)) + self.assertEqual('SELECT * FROM "abc" WHERE "foo"=0', str(q2)) + self.assertEqual('SELECT * FROM "abc" WHERE "foo"=true', str(q3)) + self.assertEqual('SELECT * FROM "abc" WHERE "foo"=\'2020-02-02\'', str(q4)) + self.assertEqual('SELECT * FROM "abc" WHERE "foo"=null', str(q5)) + + def test_where_field_equals(self): + q1 = Query.from_(self.t).select("*").where(self.t.foo == self.t.bar) + q2 = Query.from_(self.t).select("*").where(self.t.foo.eq(self.t.bar)) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo"="bar"', str(q1)) + self.assertEqual('SELECT * FROM "abc" WHERE "foo"="bar"', str(q2)) + q = self.t.select("*").where(self.t.foo == self.t.bar) + self.assertEqual(q, q1) + + def test_where_field_equals_for_update(self): + q = Query.from_(self.t).select("*").where(self.t.foo == self.t.bar).for_update() + self.assertEqual('SELECT * FROM "abc" WHERE "foo"="bar" FOR UPDATE', str(q)) + + def test_where_field_equals_for_update_nowait(self): + for query_cls in [ + MySQLQuery, + PostgreSQLQuery, + ]: + quote_char = query_cls._builder().QUOTE_CHAR if isinstance(query_cls._builder().QUOTE_CHAR, str) else '"' + q = query_cls.from_(self.t).select("*").where(self.t.foo == self.t.bar).for_update(nowait=True) + self.assertEqual( + 'SELECT * ' + 'FROM {quote_char}abc{quote_char} ' + 'WHERE {quote_char}foo{quote_char}={quote_char}bar{quote_char} ' + 'FOR UPDATE NOWAIT'.format( + quote_char=quote_char, + ), + str(q), + ) + + def test_where_field_equals_for_update_skip_locked(self): + for query_cls in [ + MySQLQuery, + PostgreSQLQuery, + ]: + quote_char = query_cls._builder().QUOTE_CHAR if isinstance(query_cls._builder().QUOTE_CHAR, str) else '"' + q = query_cls.from_(self.t).select("*").where(self.t.foo == self.t.bar).for_update(skip_locked=True) + self.assertEqual( + 'SELECT * ' + 'FROM {quote_char}abc{quote_char} ' + 'WHERE {quote_char}foo{quote_char}={quote_char}bar{quote_char} ' + 'FOR UPDATE SKIP LOCKED'.format( + quote_char=quote_char, + ), + str(q), + ) + + def test_where_field_equals_for_update_of(self): + for query_cls in [ + MySQLQuery, + PostgreSQLQuery, + ]: + quote_char = query_cls._builder().QUOTE_CHAR if isinstance(query_cls._builder().QUOTE_CHAR, str) else '"' + q = query_cls.from_(self.t).select("*").where(self.t.foo == self.t.bar).for_update(of=("abc",)) + self.assertEqual( + 'SELECT * ' + 'FROM {quote_char}abc{quote_char} ' + 'WHERE {quote_char}foo{quote_char}={quote_char}bar{quote_char} ' + 'FOR UPDATE OF {quote_char}abc{quote_char}'.format( + quote_char=quote_char, + ), + str(q), + ) + + def test_where_field_equals_for_update_of_multiple_tables(self): + for query_cls in [ + MySQLQuery, + PostgreSQLQuery, + ]: + q = ( + query_cls.from_(self.t) + .join(self.t2) + .on(self.t.id == self.t2.abc_id) + .select("*") + .where(self.t.foo == self.t.bar) + .for_update(of=("abc", "cba")) + ) + quote_char = query_cls._builder().QUOTE_CHAR if isinstance(query_cls._builder().QUOTE_CHAR, str) else '"' + self.assertIn( + str(q), + [ + 'SELECT * ' + 'FROM {quote_char}abc{quote_char} ' + 'JOIN {quote_char}cba{quote_char} ' + 'ON {quote_char}abc{quote_char}.{quote_char}id{quote_char}=' + '{quote_char}cba{quote_char}.{quote_char}abc_id{quote_char} ' + 'WHERE {quote_char}abc{quote_char}.{quote_char}foo{quote_char}=' + '{quote_char}abc{quote_char}.{quote_char}bar{quote_char} ' + 'FOR UPDATE OF {quote_char}cba{quote_char}, {quote_char}abc{quote_char}'.format( + quote_char=quote_char, + ), + 'SELECT * ' + 'FROM {quote_char}abc{quote_char} ' + 'JOIN {quote_char}cba{quote_char} ' + 'ON {quote_char}abc{quote_char}.{quote_char}id{quote_char}=' + '{quote_char}cba{quote_char}.{quote_char}abc_id{quote_char} ' + 'WHERE {quote_char}abc{quote_char}.{quote_char}foo{quote_char}=' + '{quote_char}abc{quote_char}.{quote_char}bar{quote_char} ' + 'FOR UPDATE OF {quote_char}abc{quote_char}, {quote_char}cba{quote_char}'.format( + quote_char=quote_char, + ), + ], + ) + + def test_where_field_equals_for_update_of_nowait(self): + for query_cls in [ + MySQLQuery, + PostgreSQLQuery, + ]: + q = query_cls.from_(self.t).select("*").where(self.t.foo == self.t.bar).for_update(of=("abc",), nowait=True) + quote_char = query_cls._builder().QUOTE_CHAR if isinstance(query_cls._builder().QUOTE_CHAR, str) else '"' + self.assertEqual( + 'SELECT * ' + 'FROM {quote_char}abc{quote_char} ' + 'WHERE {quote_char}foo{quote_char}={quote_char}bar{quote_char} ' + 'FOR UPDATE OF {quote_char}abc{quote_char} NOWAIT'.format( + quote_char=quote_char, + ), + str(q), + ) + + def test_where_field_equals_for_update_of_skip_locked(self): + for query_cls in [ + MySQLQuery, + PostgreSQLQuery, + ]: + q = ( + query_cls.from_(self.t) + .select("*") + .where(self.t.foo == self.t.bar) + .for_update(of=("abc",), skip_locked=True) + ) + quote_char = query_cls._builder().QUOTE_CHAR if isinstance(query_cls._builder().QUOTE_CHAR, str) else '"' + self.assertEqual( + 'SELECT * ' + 'FROM {quote_char}abc{quote_char} ' + 'WHERE {quote_char}foo{quote_char}={quote_char}bar{quote_char} ' + 'FOR UPDATE OF {quote_char}abc{quote_char} SKIP LOCKED'.format( + quote_char=quote_char, + ), + str(q), + ) + + def test_where_field_equals_for_update_skip_locked_and_of(self): + for query_cls in [ + MySQLQuery, + PostgreSQLQuery, + ]: + q = ( + query_cls.from_(self.t) + .select("*") + .where(self.t.foo == self.t.bar) + .for_update(nowait=False, skip_locked=True, of=("abc",)) + ) + quote_char = query_cls._builder().QUOTE_CHAR if isinstance(query_cls._builder().QUOTE_CHAR, str) else '"' + self.assertEqual( + 'SELECT * ' + 'FROM {quote_char}abc{quote_char} ' + 'WHERE {quote_char}foo{quote_char}={quote_char}bar{quote_char} ' + 'FOR UPDATE OF {quote_char}abc{quote_char} SKIP LOCKED'.format( + quote_char=quote_char, + ), + str(q), + ) + + def test_where_field_equals_where(self): + q = Query.from_(self.t).select("*").where(self.t.foo == 1).where(self.t.bar == self.t.baz) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo"=1 AND "bar"="baz"', str(q)) + + def test_where_field_equals_where_not(self): + q = Query.from_(self.t).select("*").where((self.t.foo == 1).negate()).where(self.t.bar == self.t.baz) + + self.assertEqual('SELECT * FROM "abc" WHERE NOT "foo"=1 AND "bar"="baz"', str(q)) + + def test_where_field_equals_where_two_not(self): + q = Query.from_(self.t).select("*").where((self.t.foo == 1).negate()).where((self.t.bar == self.t.baz).negate()) + + self.assertEqual('SELECT * FROM "abc" WHERE NOT "foo"=1 AND NOT "bar"="baz"', str(q)) + + def test_where_single_quote(self): + q1 = Query.from_(self.t).select("*").where(self.t.foo == "bar'foo") + + self.assertEqual("SELECT * FROM \"abc\" WHERE \"foo\"='bar''foo'", str(q1)) + + def test_where_field_equals_and(self): + q = Query.from_(self.t).select("*").where((self.t.foo == 1) & (self.t.bar == self.t.baz)) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo"=1 AND "bar"="baz"', str(q)) + + def test_where_field_equals_or(self): + q = Query.from_(self.t).select("*").where((self.t.foo == 1) | (self.t.bar == self.t.baz)) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo"=1 OR "bar"="baz"', str(q)) + + def test_where_nested_conditions(self): + q = Query.from_(self.t).select("*").where((self.t.foo == 1) | (self.t.bar == self.t.baz)).where(self.t.baz == 0) + + self.assertEqual('SELECT * FROM "abc" WHERE ("foo"=1 OR "bar"="baz") AND "baz"=0', str(q)) + + def test_where_field_starts_with(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.like("ab%")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" LIKE \'ab%\'', str(q)) + + def test_where_field_contains(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.like("%fg%")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" LIKE \'%fg%\'', str(q)) + + def test_where_field_ends_with(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.like("%yz")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" LIKE \'%yz\'', str(q)) + + def test_where_field_is_n_chars_long(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.like("___")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" LIKE \'___\'', str(q)) + + def test_where_field_does_not_start_with(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.not_like("ab%")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" NOT LIKE \'ab%\'', str(q)) + + def test_where_field_does_not_contain(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.not_like("%fg%")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" NOT LIKE \'%fg%\'', str(q)) + + def test_where_field_does_not_end_with(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.not_like("%yz")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" NOT LIKE \'%yz\'', str(q)) + + def test_where_field_is_not_n_chars_long(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.not_like("___")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" NOT LIKE \'___\'', str(q)) + + def test_where_field_matches_regex(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.regex(r"^b")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" REGEX \'^b\'', str(q)) + + def test_where_field_matches_regexp(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.regexp(r"^b")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" REGEXP \'^b\'', str(q)) + + def test_where_field_matches_rlike(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.rlike(r"^b")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" RLIKE \'^b\'', str(q)) + + def test_ignore_empty_criterion_where(self): + q1 = Query.from_(self.t).select("*").where(EmptyCriterion()) + + self.assertEqual('SELECT * FROM "abc"', str(q1)) + + def test_ignore_empty_criterion_having(self): + q1 = Query.from_(self.t).select("*").having(EmptyCriterion()) + + self.assertEqual('SELECT * FROM "abc"', str(q1)) + + def test_select_with_force_index_and_where(self): + q = Query.from_("abc").select("foo").where(self.t.foo == self.t.bar).force_index("egg") + + self.assertEqual('SELECT "foo" FROM "abc" FORCE INDEX ("egg") WHERE "foo"="bar"', str(q)) + + def test_where_with_multiple_wheres_using_and_case(self): + case_stmt = Case().when(self.t.foo == 'bar', 1).else_(0) + query = Query.from_(self.t).select(case_stmt).where(case_stmt & self.t.blah.isin(['test'])) + + self.assertEqual( + 'SELECT CASE WHEN "foo"=\'bar\' THEN 1 ELSE 0 END FROM "abc" WHERE CASE WHEN "foo"=\'bar\' THEN 1 ELSE 0 ' + 'END AND "blah" IN (\'test\')', + str(query), + ) + + def test_where_with_multiple_wheres_using_or_case(self): + case_stmt = Case().when(self.t.foo == 'bar', 1).else_(0) + query = Query.from_(self.t).select(case_stmt).where(case_stmt | self.t.blah.isin(['test'])) + + self.assertEqual( + 'SELECT CASE WHEN "foo"=\'bar\' THEN 1 ELSE 0 END FROM "abc" WHERE CASE WHEN "foo"=\'bar\' THEN 1 ELSE 0 ' + 'END OR "blah" IN (\'test\')', + str(query), + ) + + +class PreWhereTests(WhereTests): + t = Table("abc") + + def test_prewhere_field_equals(self): + q1 = Query.from_(self.t).select("*").prewhere(self.t.foo == self.t.bar) + q2 = Query.from_(self.t).select("*").prewhere(self.t.foo.eq(self.t.bar)) + + self.assertEqual('SELECT * FROM "abc" PREWHERE "foo"="bar"', str(q1)) + self.assertEqual('SELECT * FROM "abc" PREWHERE "foo"="bar"', str(q2)) + + def test_where_and_prewhere(self): + q = Query.from_(self.t).select("*").prewhere(self.t.foo == self.t.bar).where(self.t.foo == self.t.bar) + + self.assertEqual('SELECT * FROM "abc" PREWHERE "foo"="bar" WHERE "foo"="bar"', str(q)) + + +class GroupByTests(unittest.TestCase): + t = Table("abc") + maxDiff = None + + def test_groupby__single(self): + q = Query.from_(self.t).groupby(self.t.foo).select(self.t.foo) + + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo"', str(q)) + + def test_groupby__multi(self): + q = Query.from_(self.t).groupby(self.t.foo, self.t.bar).select(self.t.foo, self.t.bar) + + self.assertEqual('SELECT "foo","bar" FROM "abc" GROUP BY "foo","bar"', str(q)) + + def test_groupby__count_star(self): + q = Query.from_(self.t).groupby(self.t.foo).select(self.t.foo, fn.Count("*")) + + self.assertEqual('SELECT "foo",COUNT(*) FROM "abc" GROUP BY "foo"', str(q)) + + def test_groupby__count_field(self): + q = Query.from_(self.t).groupby(self.t.foo).select(self.t.foo, fn.Count(self.t.bar)) + + self.assertEqual('SELECT "foo",COUNT("bar") FROM "abc" GROUP BY "foo"', str(q)) + + def test_groupby__count_distinct(self): + q = Query.from_(self.t).groupby(self.t.foo).select(self.t.foo, fn.Count("*").distinct()) + + self.assertEqual('SELECT "foo",COUNT(DISTINCT *) FROM "abc" GROUP BY "foo"', str(q)) + + def test_groupby__sum_distinct(self): + q = Query.from_(self.t).groupby(self.t.foo).select(self.t.foo, fn.Sum(self.t.bar).distinct()) + + self.assertEqual('SELECT "foo",SUM(DISTINCT "bar") FROM "abc" GROUP BY "foo"', str(q)) + + def test_groupby__sum_filter(self): + q = ( + Query.from_(self.t) + .groupby(self.t.foo) + .select(self.t.foo, fn.Sum(self.t.bar).filter(self.t.id.eq(1) & self.t.cid.gt(2))) + ) + + self.assertEqual('SELECT "foo",SUM("bar") FILTER(WHERE "id"=1 AND "cid">2) FROM "abc" GROUP BY "foo"', str(q)) + + def test_groupby__str(self): + q = Query.from_("abc").groupby("foo").select("foo", fn.Count("*").distinct()) + + self.assertEqual('SELECT "foo",COUNT(DISTINCT *) FROM "abc" GROUP BY "foo"', str(q)) + + def test_groupby__int(self): + q = Query.from_("abc").groupby(1).select("foo", fn.Count("*").distinct()) + + self.assertEqual('SELECT "foo",COUNT(DISTINCT *) FROM "abc" GROUP BY 1', str(q)) + + def test_groupby__alias(self): + bar = self.t.bar.as_("bar01") + q = Query.from_(self.t).select(fn.Sum(self.t.foo), bar).groupby(bar) + + self.assertEqual('SELECT SUM("foo"),"bar" "bar01" FROM "abc" GROUP BY "bar01"', str(q)) + + def test_groupby__no_alias(self): + bar = self.t.bar.as_("bar01") + q = Query.from_(self.t).select(fn.Sum(self.t.foo), bar).groupby(bar) + + self.assertEqual( + 'SELECT SUM("foo"),"bar" "bar01" FROM "abc" GROUP BY "bar"', + q.get_sql(groupby_alias=False), + ) + + def test_groupby__no_alias_mssql(self): + bar = self.t.bar.as_("bar01") + q = MSSQLQuery.from_(self.t).select(fn.Sum(self.t.foo), bar).groupby(bar) + + self.assertEqual('SELECT SUM("foo"),"bar" "bar01" FROM "abc" GROUP BY "bar"', str(q)) + + def test_groupby__no_alias_oracle(self): + bar = self.t.bar.as_("bar01") + q = OracleQuery.from_(self.t).select(fn.Sum(self.t.foo), bar).groupby(bar) + + self.assertEqual('SELECT SUM(foo),bar bar01 FROM abc GROUP BY bar', str(q)) + + def test_groupby__alias_platforms(self): + bar = self.t.bar.as_("bar01") + + for query_cls in [ + MySQLQuery, + VerticaQuery, + PostgreSQLQuery, + RedshiftQuery, + ClickHouseQuery, + SQLLiteQuery, + ]: + q = query_cls.from_(self.t).select(fn.Sum(self.t.foo), bar).groupby(bar) + + quote_char = query_cls._builder().QUOTE_CHAR if isinstance(query_cls._builder().QUOTE_CHAR, str) else '"' + + self.assertEqual( + "SELECT " + "SUM({quote_char}foo{quote_char})," + "{quote_char}bar{quote_char}{as_keyword}{quote_char}bar01{quote_char} " + "FROM {quote_char}abc{quote_char} " + "GROUP BY {quote_char}bar01{quote_char}".format( + as_keyword=' AS ' if query_cls is ClickHouseQuery else ' ', quote_char=quote_char + ), + str(q), + ) + + def test_groupby__alias_with_join(self): + table1 = Table("table1", alias="t1") + bar = table1.bar.as_("bar01") + q = Query.from_(self.t).join(table1).on(self.t.id == table1.t_ref).select(fn.Sum(self.t.foo), bar).groupby(bar) + + self.assertEqual( + 'SELECT SUM("abc"."foo"),"t1"."bar" "bar01" FROM "abc" ' + 'JOIN "table1" "t1" ON "abc"."id"="t1"."t_ref" ' + 'GROUP BY "bar01"', + str(q), + ) + + def test_groupby_with_case_uses_the_alias(self): + q = ( + Query.from_(self.t) + .select( + fn.Sum(self.t.foo).as_("bar"), + Case().when(self.t.fname == "Tom", "It was Tom").else_("It was someone else.").as_("who_was_it"), + ) + .groupby(Case().when(self.t.fname == "Tom", "It was Tom").else_("It was someone else.").as_("who_was_it")) + ) + + self.assertEqual( + 'SELECT SUM("foo") "bar",' + "CASE WHEN \"fname\"='Tom' THEN 'It was Tom' " + "ELSE 'It was someone else.' END \"who_was_it\" " + 'FROM "abc" ' + 'GROUP BY "who_was_it"', + str(q), + ) + + def test_mysql_query_uses_backtick_quote_chars(self): + q = MySQLQuery.from_(self.t).groupby(self.t.foo).select(self.t.foo) + + self.assertEqual("SELECT `foo` FROM `abc` GROUP BY `foo`", str(q)) + + def test_vertica_query_uses_double_quote_chars(self): + q = VerticaQuery.from_(self.t).groupby(self.t.foo).select(self.t.foo) + + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo"', str(q)) + + def test_mssql_query_uses_double_quote_chars(self): + q = MSSQLQuery.from_(self.t).groupby(self.t.foo).select(self.t.foo) + + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo"', str(q)) + + def test_oracle_query_uses_no_quote_chars(self): + q = OracleQuery.from_(self.t).groupby(self.t.foo).select(self.t.foo) + + self.assertEqual('SELECT foo FROM abc GROUP BY foo', str(q)) + + def test_postgres_query_uses_double_quote_chars(self): + q = PostgreSQLQuery.from_(self.t).groupby(self.t.foo).select(self.t.foo) + + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo"', str(q)) + + def test_redshift_query_uses_double_quote_chars(self): + q = RedshiftQuery.from_(self.t).groupby(self.t.foo).select(self.t.foo) + + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo"', str(q)) + + def test_group_by__single_with_totals(self): + q = Query.from_(self.t).groupby(self.t.foo).select(self.t.foo).with_totals() + + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo" WITH TOTALS', str(q)) + + def test_groupby__multi_with_totals(self): + q = Query.from_(self.t).groupby(self.t.foo, self.t.bar).select(self.t.foo, self.t.bar).with_totals() + + self.assertEqual('SELECT "foo","bar" FROM "abc" GROUP BY "foo","bar" WITH TOTALS', str(q)) + + +class HavingTests(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_having_greater_than(self): + q = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, fn.Sum(self.table_abc.bar)) + .groupby(self.table_abc.foo) + .having(fn.Sum(self.table_abc.bar) > 1) + ) + + self.assertEqual( + 'SELECT "foo",SUM("bar") FROM "abc" GROUP BY "foo" HAVING SUM("bar")>1', + str(q), + ) + + def test_having_and(self): + q = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, fn.Sum(self.table_abc.bar)) + .groupby(self.table_abc.foo) + .having((fn.Sum(self.table_abc.bar) > 1) & (fn.Sum(self.table_abc.bar) < 100)) + ) + + self.assertEqual( + 'SELECT "foo",SUM("bar") FROM "abc" GROUP BY "foo" HAVING SUM("bar")>1 AND SUM("bar")<100', + str(q), + ) + + def test_having_join_and_equality(self): + q = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.foo) + .select(self.table_abc.foo, fn.Sum(self.table_efg.bar), self.table_abc.buz) + .groupby(self.table_abc.foo) + .having(self.table_abc.buz == "fiz") + .having(fn.Sum(self.table_efg.bar) > 100) + ) + + self.assertEqual( + 'SELECT "abc"."foo",SUM("efg"."bar"),"abc"."buz" FROM "abc" ' + 'JOIN "efg" ON "abc"."foo"="efg"."foo" ' + 'GROUP BY "abc"."foo" ' + 'HAVING "abc"."buz"=\'fiz\' AND SUM("efg"."bar")>100', + str(q), + ) + + def test_mysql_query_uses_backtick_quote_chars(self): + q = ( + MySQLQuery.from_(self.table_abc) + .select(self.table_abc.foo) + .groupby(self.table_abc.foo) + .having(self.table_abc.buz == "fiz") + ) + self.assertEqual("SELECT `foo` FROM `abc` GROUP BY `foo` HAVING `buz`='fiz'", str(q)) + + def test_vertica_query_uses_double_quote_chars(self): + q = ( + VerticaQuery.from_(self.table_abc) + .select(self.table_abc.foo) + .groupby(self.table_abc.foo) + .having(self.table_abc.buz == "fiz") + ) + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo" HAVING "buz"=\'fiz\'', str(q)) + + def test_mssql_query_uses_double_quote_chars(self): + q = ( + MSSQLQuery.from_(self.table_abc) + .select(self.table_abc.foo) + .groupby(self.table_abc.foo) + .having(self.table_abc.buz == "fiz") + ) + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo" HAVING "buz"=\'fiz\'', str(q)) + + def test_oracle_query_uses_no_quote_chars(self): + q = ( + OracleQuery.from_(self.table_abc) + .select(self.table_abc.foo) + .groupby(self.table_abc.foo) + .having(self.table_abc.buz == "fiz") + ) + self.assertEqual('SELECT foo FROM abc GROUP BY foo HAVING buz=\'fiz\'', str(q)) + + def test_postgres_query_uses_double_quote_chars(self): + q = ( + PostgreSQLQuery.from_(self.table_abc) + .select(self.table_abc.foo) + .groupby(self.table_abc.foo) + .having(self.table_abc.buz == "fiz") + ) + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo" HAVING "buz"=\'fiz\'', str(q)) + + def test_redshift_query_uses_double_quote_chars(self): + q = ( + RedshiftQuery.from_(self.table_abc) + .select(self.table_abc.foo) + .groupby(self.table_abc.foo) + .having(self.table_abc.buz == "fiz") + ) + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo" HAVING "buz"=\'fiz\'', str(q)) + + +class OrderByTests(unittest.TestCase): + t = Table("abc") + + def test_orderby_single_field(self): + q = Query.from_(self.t).orderby(self.t.foo).select(self.t.foo) + + self.assertEqual('SELECT "foo" FROM "abc" ORDER BY "foo"', str(q)) + + def test_orderby_multi_fields(self): + q = Query.from_(self.t).orderby(self.t.foo, self.t.bar).select(self.t.foo, self.t.bar) + + self.assertEqual('SELECT "foo","bar" FROM "abc" ORDER BY "foo","bar"', str(q)) + + def test_orderby_single_str(self): + q = Query.from_("abc").orderby("foo").select("foo") + + self.assertEqual('SELECT "foo" FROM "abc" ORDER BY "foo"', str(q)) + + def test_orderby_asc(self): + q = Query.from_(self.t).orderby(self.t.foo, order=Order.asc).select(self.t.foo) + + self.assertEqual('SELECT "foo" FROM "abc" ORDER BY "foo" ASC', str(q)) + + def test_orderby_desc(self): + q = Query.from_(self.t).orderby(self.t.foo, order=Order.desc).select(self.t.foo) + + self.assertEqual('SELECT "foo" FROM "abc" ORDER BY "foo" DESC', str(q)) + + def test_orderby_no_alias(self): + bar = self.t.bar.as_("bar01") + q = Query.from_(self.t).select(fn.Sum(self.t.foo), bar).orderby(bar) + + self.assertEqual( + 'SELECT SUM("foo"),"bar" "bar01" FROM "abc" ORDER BY "bar"', + q.get_sql(orderby_alias=False), + ) + + def test_orderby_alias(self): + bar = self.t.bar.as_("bar01") + q = Query.from_(self.t).select(fn.Sum(self.t.foo), bar).orderby(bar) + + self.assertEqual('SELECT SUM("foo"),"bar" "bar01" FROM "abc" ORDER BY "bar01"', q.get_sql()) + + +class AliasTests(unittest.TestCase): + t = Table("abc") + + def test_table_field(self): + q = Query.from_(self.t).select(self.t.foo.as_("bar")) + + self.assertEqual('SELECT "foo" "bar" FROM "abc"', str(q)) + + def test_table_field__multi(self): + q = Query.from_(self.t).select(self.t.foo.as_("bar"), self.t.fiz.as_("buz")) + + self.assertEqual('SELECT "foo" "bar","fiz" "buz" FROM "abc"', str(q)) + + def test_arithmetic_function(self): + q = Query.from_(self.t).select((self.t.foo + self.t.bar).as_("biz")) + + self.assertEqual('SELECT "foo"+"bar" "biz" FROM "abc"', str(q)) + + def test_functions_using_as(self): + q = Query.from_(self.t).select(fn.Count("*").as_("foo")) + + self.assertEqual('SELECT COUNT(*) "foo" FROM "abc"', str(q)) + + def test_functions_using_constructor_param(self): + q = Query.from_(self.t).select(fn.Count("*", alias="foo")) + + self.assertEqual('SELECT COUNT(*) "foo" FROM "abc"', str(q)) + + def test_function_using_as_nested(self): + """ + We don't show aliases of fields that are arguments of a function. + """ + q = Query.from_(self.t).select(fn.Sqrt(fn.Count("*").as_("foo")).as_("bar")) + + self.assertEqual('SELECT SQRT(COUNT(*)) "bar" FROM "abc"', str(q)) + + def test_functions_using_constructor_param_nested(self): + """ + We don't show aliases of fields that are arguments of a function. + """ + q = Query.from_(self.t).select(fn.Sqrt(fn.Count("*", alias="foo"), alias="bar")) + + self.assertEqual('SELECT SQRT(COUNT(*)) "bar" FROM "abc"', str(q)) + + def test_ignored_in_where(self): + q = Query.from_(self.t).select(self.t.foo).where(self.t.foo.as_("bar") == 1) + + self.assertEqual('SELECT "foo" FROM "abc" WHERE "foo"=1', str(q)) + + def test_ignored_in_groupby(self): + q = Query.from_(self.t).select(self.t.foo).groupby(self.t.foo.as_("bar")) + + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo"', str(q)) + + def test_ignored_in_orderby(self): + q = Query.from_(self.t).select(self.t.foo).orderby(self.t.foo.as_("bar")) + + self.assertEqual('SELECT "foo" FROM "abc" ORDER BY "foo"', str(q)) + + def test_ignored_in_criterion(self): + c = self.t.foo.as_("bar") == 1 + + self.assertEqual('"foo"=1', str(c)) + + def test_ignored_in_criterion_comparison(self): + c = self.t.foo.as_("bar") == self.t.fiz.as_("buz") + + self.assertEqual('"foo"="fiz"', str(c)) + + def test_ignored_in_field_inside_case(self): + q = Query.from_(self.t).select(Case().when(self.t.foo == 1, "a").else_(self.t.bar.as_('"buz"'))) + + self.assertEqual('SELECT CASE WHEN "foo"=1 THEN \'a\' ELSE "bar" END FROM "abc"', str(q)) + + def test_case_using_as(self): + q = Query.from_(self.t).select(Case().when(self.t.foo == 1, "a").else_("b").as_("bar")) + + self.assertEqual( + 'SELECT CASE WHEN "foo"=1 THEN \'a\' ELSE \'b\' END "bar" FROM "abc"', + str(q), + ) + + def test_case_using_constructor_param(self): + q = Query.from_(self.t).select(Case(alias="bar").when(self.t.foo == 1, "a").else_("b")) + + self.assertEqual( + 'SELECT CASE WHEN "foo"=1 THEN \'a\' ELSE \'b\' END "bar" FROM "abc"', + str(q), + ) + + def test_select__multiple_tables(self): + table_abc, table_efg = Table("abc", alias="q0"), Table("efg", alias="q1") + + q = Query.from_(table_abc).select(table_abc.foo).from_(table_efg).select(table_efg.bar) + + self.assertEqual('SELECT "q0"."foo","q1"."bar" FROM "abc" "q0","efg" "q1"', str(q)) + + def test_use_aliases_in_groupby_and_orderby(self): + table_abc = Table("abc", alias="q0") + + my_foo = table_abc.foo.as_("my_foo") + q = Query.from_(table_abc).select(my_foo, table_abc.bar).groupby(my_foo).orderby(my_foo) + + self.assertEqual( + 'SELECT "q0"."foo" "my_foo","q0"."bar" ' 'FROM "abc" "q0" ' 'GROUP BY "my_foo" ' 'ORDER BY "my_foo"', + str(q), + ) + + def test_table_with_schema_and_alias(self): + table = Table("abc", schema="schema", alias="alias") + self.assertEqual('"schema"."abc" "alias"', str(table)) + + def test_null_value_with_alias(self): + q = Query.select(NullValue().as_("abcdef")) + + self.assertEqual('SELECT NULL "abcdef"', str(q)) + + +class SubqueryTests(unittest.TestCase): + maxDiff = None + + table_abc, table_efg, table_hij = Tables("abc", "efg", "hij") + + def test_where__in(self): + q = ( + Query.from_(self.table_abc) + .select("*") + .where( + self.table_abc.foo.isin( + Query.from_(self.table_efg).select(self.table_efg.foo).where(self.table_efg.bar == 0) + ) + ) + ) + + self.assertEqual( + 'SELECT * FROM "abc" WHERE "foo" IN (SELECT "foo" FROM "efg" WHERE "bar"=0)', + str(q), + ) + + def test_where__in_nested(self): + q = Query.from_(self.table_abc).select("*").where(self.table_abc.foo).isin(self.table_efg.select("*")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" IN (SELECT * FROM "efg")', str(q)) + + def test_join(self): + subquery = Query.from_("efg").select("fiz", "buz").where(F("buz") == 0) + + q = ( + Query.from_(self.table_abc) + .join(subquery) + .on(self.table_abc.bar == subquery.buz) + .select(self.table_abc.foo, subquery.fiz) + ) + + self.assertEqual( + 'SELECT "abc"."foo","sq0"."fiz" FROM "abc" ' + 'JOIN (SELECT "fiz","buz" FROM "efg" WHERE "buz"=0) "sq0" ' + 'ON "abc"."bar"="sq0"."buz"', + str(q), + ) + + def test_select_subquery(self): + subq = Query.from_(self.table_efg).select("fizzbuzz").where(self.table_efg.id == 1) + + q = Query.from_(self.table_abc).select("foo", "bar").select(subq) + + self.assertEqual( + 'SELECT "foo","bar",(SELECT "fizzbuzz" FROM "efg" WHERE "id"=1) ' 'FROM "abc"', + str(q), + ) + + def test_select_subquery_with_alias(self): + subq = Query.from_(self.table_efg).select("fizzbuzz").where(self.table_efg.id == 1) + + q = Query.from_(self.table_abc).select("foo", "bar").select(subq.as_("sq")) + + self.assertEqual( + 'SELECT "foo","bar",(SELECT "fizzbuzz" FROM "efg" WHERE "id"=1) "sq" ' 'FROM "abc"', + str(q), + ) + + def test_where__equality(self): + subquery = Query.from_("efg").select("fiz").where(F("buz") == 0) + query = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, self.table_abc.bar) + .where(self.table_abc.bar == subquery) + ) + + self.assertEqual( + 'SELECT "foo","bar" FROM "abc" ' 'WHERE "bar"=(SELECT "fiz" FROM "efg" WHERE "buz"=0)', + str(query), + ) + + def test_select_from_nested_query(self): + subquery = Query.from_(self.table_abc).select( + self.table_abc.foo, + self.table_abc.bar, + (self.table_abc.fizz + self.table_abc.buzz).as_("fizzbuzz"), + ) + + query = Query.from_(subquery).select(subquery.foo, subquery.bar, subquery.fizzbuzz) + + self.assertEqual( + 'SELECT "sq0"."foo","sq0"."bar","sq0"."fizzbuzz" ' + "FROM (" + 'SELECT "foo","bar","fizz"+"buzz" "fizzbuzz" ' + 'FROM "abc"' + ') "sq0"', + str(query), + ) + + def test_select_from_nested_query_with_join(self): + subquery1 = ( + Query.from_(self.table_abc) + .select( + self.table_abc.foo, + fn.Sum(self.table_abc.fizz + self.table_abc.buzz).as_("fizzbuzz"), + ) + .groupby(self.table_abc.foo) + ) + + subquery2 = Query.from_(self.table_efg).select( + self.table_efg.foo.as_("foo_two"), + self.table_efg.bar, + ) + + query = ( + Query.from_(subquery1) + .select(subquery1.foo, subquery1.fizzbuzz) + .join(subquery2) + .on(subquery1.foo == subquery2.foo_two) + .select(subquery2.foo_two, subquery2.bar) + ) + + self.assertEqual( + "SELECT " + '"sq0"."foo","sq0"."fizzbuzz",' + '"sq1"."foo_two","sq1"."bar" ' + "FROM (" + "SELECT " + '"foo",SUM("fizz"+"buzz") "fizzbuzz" ' + 'FROM "abc" ' + 'GROUP BY "foo"' + ') "sq0" JOIN (' + "SELECT " + '"foo" "foo_two","bar" ' + 'FROM "efg"' + ') "sq1" ON "sq0"."foo"="sq1"."foo_two"', + str(query), + ) + + def test_from_subquery_without_alias(self): + subquery = Query.from_(self.table_efg).select( + self.table_efg.base_id.as_("x"), self.table_efg.fizz, self.table_efg.buzz + ) + + test_query = Query.from_(subquery).select(subquery.x, subquery.fizz, subquery.buzz) + + self.assertEqual( + 'SELECT "sq0"."x","sq0"."fizz","sq0"."buzz" ' + "FROM (" + 'SELECT "base_id" "x","fizz","buzz" FROM "efg"' + ') "sq0"', + str(test_query), + ) + + def test_join_query_with_alias(self): + subquery = ( + Query.from_(self.table_efg) + .select( + self.table_efg.base_id.as_("x"), + self.table_efg.fizz, + self.table_efg.buzz, + ) + .as_("subq") + ) + + test_query = Query.from_(subquery).select(subquery.x, subquery.fizz, subquery.buzz) + + self.assertEqual( + 'SELECT "subq"."x","subq"."fizz","subq"."buzz" ' + "FROM (" + 'SELECT "base_id" "x","fizz","buzz" FROM "efg"' + ') "subq"', + str(test_query), + ) + + def test_with(self): + sub_query = Query.from_(self.table_efg).select("fizz") + test_query = Query.with_(sub_query, "an_alias").from_(AliasedQuery("an_alias")).select("*") + + self.assertEqual( + 'WITH an_alias AS (SELECT "fizz" FROM "efg") SELECT * FROM an_alias', + str(test_query), + ) + + def test_join_with_with(self): + sub_query = Query.from_(self.table_efg).select("fizz") + test_query = ( + Query.with_(sub_query, "an_alias") + .from_(self.table_abc) + .join(AliasedQuery("an_alias")) + .on(AliasedQuery("an_alias").fizz == self.table_abc.buzz) + .select("*") + ) + self.assertEqual( + 'WITH an_alias AS (SELECT "fizz" FROM "efg") ' + 'SELECT * FROM "abc" JOIN an_alias ON "an_alias"."fizz"="abc"."buzz"', + str(test_query), + ) + + def test_select_from_with_returning(self): + sub_query = PostgreSQLQuery.into(self.table_abc).insert(1).returning('*') + test_query = Query.with_(sub_query, "an_alias").from_(AliasedQuery("an_alias")).select("*") + self.assertEqual( + 'WITH an_alias AS (INSERT INTO "abc" VALUES (1) RETURNING *) SELECT * FROM an_alias', str(test_query) + ) + + +class QuoteTests(unittest.TestCase): + def test_extraneous_quotes(self): + t1 = Table("table1", alias="t1") + t2 = Table("table2", alias="t2") + + query = Query.from_(t1).join(t2).on(t1.Value.between(t2.start, t2.end)).select(t1.value) + + self.assertEqual( + "SELECT t1.value FROM table1 t1 " "JOIN table2 t2 ON t1.Value " "BETWEEN t2.start AND t2.end", + query.get_sql(quote_char=None), + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/test_tables.py b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/test_tables.py new file mode 100644 index 0000000000000000000000000000000000000000..f43e740915f642d29ce7497c36e3b68f01311016 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/test_tables.py @@ -0,0 +1,186 @@ +# from pypika.terms import ValueWrapper, SystemTimeValue +import unittest + +from pypika import Database, Dialects, Schema, SQLLiteQuery, Table, Tables, Query, SYSTEM_TIME + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + + +class TableStructureTests(unittest.TestCase): + def test_table_sql(self): + table = Table("test_table") + + self.assertEqual('"test_table"', str(table)) + + def test_table_with_alias(self): + table = Table("test_table").as_("my_table") + + self.assertEqual('"test_table" "my_table"', table.get_sql(with_alias=True, quote_char='"')) + + def test_schema_table_attr(self): + table = Schema("x_schema").test_table + + self.assertEqual('"x_schema"."test_table"', str(table)) + + def test_table_with_schema_arg(self): + table = Table("test_table", schema=Schema("x_schema")) + + self.assertEqual('"x_schema"."test_table"', str(table)) + + def test_database_schema_table_attr(self): + table = Database("x_db").x_schema.test_table + + self.assertEqual('"x_db"."x_schema"."test_table"', str(table)) + + def test_table_with_schema_and_schema_parent_arg(self): + table = Table("test_table", schema=Schema("x_schema", parent=Database("x_db"))) + + self.assertEqual('"x_db"."x_schema"."test_table"', str(table)) + + def test_table_for_system_time_sql(self): + with self.subTest("with between criterion"): + table = Table("test_table").for_(SYSTEM_TIME.between('2020-01-01', '2020-02-01')) + + self.assertEqual('"test_table" FOR SYSTEM_TIME BETWEEN \'2020-01-01\' AND \'2020-02-01\'', str(table)) + + with self.subTest("with as of criterion"): + table = Table("test_table").for_(SYSTEM_TIME.as_of('2020-01-01')) + + self.assertEqual('"test_table" FOR SYSTEM_TIME AS OF \'2020-01-01\'', str(table)) + + with self.subTest("with from to criterion"): + table = Table("test_table").for_(SYSTEM_TIME.from_to('2020-01-01', '2020-02-01')) + + self.assertEqual('"test_table" FOR SYSTEM_TIME FROM \'2020-01-01\' TO \'2020-02-01\'', str(table)) + + def test_table_for_period_sql(self): + with self.subTest("with between criterion"): + table = Table("test_table") + table = table.for_(table.valid_period.between('2020-01-01', '2020-02-01')) + + self.assertEqual('"test_table" FOR "valid_period" BETWEEN \'2020-01-01\' AND \'2020-02-01\'', str(table)) + + with self.subTest("with as of criterion"): + table = Table("test_table") + table = table.for_(table.valid_period.as_of('2020-01-01')) + + self.assertEqual('"test_table" FOR "valid_period" AS OF \'2020-01-01\'', str(table)) + + with self.subTest("with from to criterion"): + table = Table("test_table") + table = table.for_(table.valid_period.from_to('2020-01-01', '2020-02-01')) + + self.assertEqual('"test_table" FOR "valid_period" FROM \'2020-01-01\' TO \'2020-02-01\'', str(table)) + + +class TableEqualityTests(unittest.TestCase): + def test_tables_equal_by_name(self): + t1 = Table("t") + t2 = Table("t") + + self.assertEqual(t1, t2) + + def test_tables_equal_by_schema_and_name(self): + t1 = Table("t", schema="a") + t2 = Table("t", schema="a") + + self.assertEqual(t1, t2) + + def test_tables_equal_by_schema_and_name_using_schema(self): + a = Schema("a") + t1 = Table("t", schema=a) + t2 = Table("t", schema=a) + + self.assertEqual(t1, t2) + + def test_tables_equal_by_schema_and_name_using_schema_with_parent(self): + parent = Schema("parent") + a = Schema("a", parent=parent) + t1 = Table("t", schema=a) + t2 = Table("t", schema=a) + + self.assertEqual(t1, t2) + + def test_tables_not_equal_by_schema_and_name_using_schema_with_different_parents( + self, + ): + parent = Schema("parent") + a = Schema("a", parent=parent) + t1 = Table("t", schema=a) + t2 = Table("t", schema=Schema("a")) + + self.assertNotEqual(t1, t2) + + def test_tables_not_equal_with_different_schemas(self): + t1 = Table("t", schema="a") + t2 = Table("t", schema="b") + + self.assertNotEqual(t1, t2) + + def test_tables_not_equal_with_different_names(self): + t1 = Table("t", schema="a") + t2 = Table("q", schema="a") + + self.assertNotEqual(t1, t2) + + def test_many_tables_with_alias(self): + tables_data = [("table1", "t1"), ("table2", "t2"), ("table3", "t3")] + tables = Tables(*tables_data) + for el in tables: + self.assertIsNotNone(el.alias) + + def test_many_tables_without_alias(self): + tables_data = ["table1", "table2", "table3"] + tables = Tables(*tables_data) + for el in tables: + self.assertIsNone(el.alias) + + def test_many_tables_with_or_not_alias(self): + tables_data = [("table1", "t1"), ("table2"), "table3"] + tables = Tables(*tables_data) + for i in range(len(tables)): + if isinstance(tables_data[i], tuple): + self.assertIsNotNone(tables[i].alias) + else: + self.assertIsNone(tables[i].alias) + + +class TableDialectTests(unittest.TestCase): + def test_table_with_default_query_cls(self): + table = Table("abc") + q = table.select("1") + self.assertIs(q.dialect, None) + + def test_table_with_dialect_query_cls(self): + table = Table("abc", query_cls=SQLLiteQuery) + q = table.select("1") + self.assertIs(q.dialect, Dialects.SQLLITE) + + def test_table_factory_with_default_query_cls(self): + table = Query.Table("abc") + q = table.select("1") + self.assertIs(q.dialect, None) + + def test_table_factory_with_dialect_query_cls(self): + table = SQLLiteQuery.Table("abc") + q = table.select("1") + self.assertIs(q.dialect, Dialects.SQLLITE) + + def test_make_tables_factory_with_default_query_cls(self): + t1, t2 = Query.Tables("abc", "def") + q1 = t1.select("1") + q2 = t2.select("2") + self.assertIs(q1.dialect, None) + self.assertIs(q2.dialect, None) + + def test_make_tables_factory_with_dialect_query_cls(self): + t1, t2 = SQLLiteQuery.Tables("abc", "def") + q1 = t1.select("1") + q2 = t2.select("2") + self.assertIs(q1.dialect, Dialects.SQLLITE) + self.assertIs(q2.dialect, Dialects.SQLLITE) + + def test_table_with_bad_query_cls(self): + with self.assertRaises(TypeError): + Table("abc", query_cls=object) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/test_terms.py b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/test_terms.py new file mode 100644 index 0000000000000000000000000000000000000000..4c7590dfce129bac97a3f30de99b596cc746c893 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/test_terms.py @@ -0,0 +1,82 @@ +from unittest import TestCase + +from pypika import Query, Table, Field +from pypika.terms import AtTimezone + + +class FieldAliasTests(TestCase): + t = Table("test", alias="crit") + + def test_when_alias_specified(self): + c1 = Field("foo", alias="bar") + self.assertEqual('bar', str(c1.alias)) + + c1 = Field("foo").as_("bar") + self.assertEqual('bar', str(c1.alias)) + + +class FieldInitTests(TestCase): + def test_init_with_str_table(self): + test_table_name = "test_table" + field = Field(name="name", table=test_table_name) + self.assertEqual(field.table, Table(name=test_table_name)) + + +class FieldHashingTests(TestCase): + def test_tabled_eq_fields_equally_hashed(self): + client_name1 = Field(name="name", table=Table("clients")) + client_name2 = Field(name="name", table=Table("clients")) + self.assertTrue(hash(client_name1) == hash(client_name2)) + + def test_tabled_ne_fields_differently_hashed(self): + customer_name = Field(name="name", table=Table("customers")) + client_name = Field(name="name", table=Table("clients")) + self.assertTrue(hash(customer_name) != hash(client_name)) + + def test_non_tabled_aliased_eq_fields_equally_hashed(self): + self.assertTrue(hash(Field(name="A", alias="my_a")) == hash(Field(name="A", alias="my_a"))) + + def test_non_tabled_aliased_ne_fields_differently_hashed(self): + self.assertTrue(hash(Field(name="A", alias="my_a1")) != hash(Field(name="A", alias="my_a2"))) + + def test_non_tabled_eq_fields_equally_hashed(self): + self.assertTrue(hash(Field(name="A")) == hash(Field(name="A"))) + + def test_non_tabled_ne_fields_differently_hashed(self): + self.assertTrue(hash(Field(name="A")) != hash(Field(name="B"))) + + +class AtTimezoneTests(TestCase): + def test_when_interval_not_specified(self): + query = Query.from_("customers").select(AtTimezone("date", "US/Eastern")) + self.assertEqual('SELECT "date" AT TIME ZONE \'US/Eastern\' FROM "customers"', str(query)) + + def test_when_interval_specified(self): + query = Query.from_("customers").select(AtTimezone("date", "-06:00", interval=True)) + self.assertEqual( + 'SELECT "date" AT TIME ZONE INTERVAL \'-06:00\' FROM "customers"', + str(query), + ) + + def test_when_alias_specified(self): + query = Query.from_("customers").select(AtTimezone("date", "US/Eastern", alias="alias1")) + self.assertEqual( + 'SELECT "date" AT TIME ZONE \'US/Eastern\' "alias1" FROM "customers"', + str(query), + ) + + def test_passes_kwargs_to_field_get_sql(self): + customers = Table("customers") + accounts = Table("accounts") + query = ( + Query.from_(customers) + .join(accounts) + .on(customers.account_id == accounts.account_id) + .select(AtTimezone(customers.date, "US/Eastern", alias="alias1")) + ) + + self.assertEqual( + 'SELECT "customers"."date" AT TIME ZONE \'US/Eastern\' "alias1" ' + 'FROM "customers" JOIN "accounts" ON "customers"."account_id"="accounts"."account_id"', + query.get_sql(with_namespace=True), + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/test_tuples.py b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/test_tuples.py new file mode 100644 index 0000000000000000000000000000000000000000..c8ebc8e41b0115777f8b3c8cb01c04e62f13ee18 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/test_tuples.py @@ -0,0 +1,162 @@ +import unittest + +from pypika import ( + Array, + Bracket, + Query, + PostgreSQLQuery, + Table, + Tables, + Tuple, +) +from pypika.functions import Coalesce, NullIf, Sum +from pypika.terms import Field + + +class TupleTests(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_tuple_equality_tuple_on_both(self): + q = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, self.table_abc.bar) + .where(Tuple(self.table_abc.foo, self.table_abc.bar) == Tuple(1, 2)) + ) + + self.assertEqual('SELECT "foo","bar" FROM "abc" ' 'WHERE ("foo","bar")=(1,2)', str(q)) + + def test_tuple_equality_tuple_on_left(self): + q = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, self.table_abc.bar) + .where(Tuple(self.table_abc.foo, self.table_abc.bar) == (1, 2)) + ) + + self.assertEqual('SELECT "foo","bar" FROM "abc" ' 'WHERE ("foo","bar")=(1,2)', str(q)) + + def test_tuple_equality_tuple_on_right(self): + q = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, self.table_abc.bar) + .where((self.table_abc.foo, self.table_abc.bar) == Tuple(1, 2)) + ) + + # Order is reversed due to lack of right equals method + self.assertEqual('SELECT "foo","bar" FROM "abc" ' 'WHERE (1,2)=("foo","bar")', str(q)) + + def test_tuple_in_using_python_tuples(self): + q = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, self.table_abc.bar) + .where(Tuple(self.table_abc.foo, self.table_abc.bar).isin([(1, 1), (2, 2), (3, 3)])) + ) + + self.assertEqual( + 'SELECT "foo","bar" FROM "abc" ' 'WHERE ("foo","bar") IN ((1,1),(2,2),(3,3))', + str(q), + ) + + def test_tuple_in_using_pypika_tuples(self): + q = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, self.table_abc.bar) + .where(Tuple(self.table_abc.foo, self.table_abc.bar).isin([Tuple(1, 1), Tuple(2, 2), Tuple(3, 3)])) + ) + + self.assertEqual( + 'SELECT "foo","bar" FROM "abc" ' 'WHERE ("foo","bar") IN ((1,1),(2,2),(3,3))', + str(q), + ) + + def test_tuple_in_using_mixed_tuples(self): + q = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, self.table_abc.bar) + .where(Tuple(self.table_abc.foo, self.table_abc.bar).isin([(1, 1), Tuple(2, 2), (3, 3)])) + ) + + self.assertEqual( + 'SELECT "foo","bar" FROM "abc" ' 'WHERE ("foo","bar") IN ((1,1),(2,2),(3,3))', + str(q), + ) + + def test_tuples_in_join(self): + query = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .select("*") + .where(Tuple(self.table_abc.foo, self.table_efg.bar).isin([(1, 1), Tuple(2, 2), (3, 3)])) + ) + + self.assertEqual( + 'SELECT * FROM "abc" JOIN "efg" ON "abc"."foo"="efg"."bar" ' + 'WHERE ("abc"."foo","efg"."bar") IN ((1,1),(2,2),(3,3))', + str(query), + ) + + def test_render_alias_in_array_sql(self): + tb = Table("tb") + + q = Query.from_(tb).select(Tuple(tb.col).as_("different_name")) + self.assertEqual(str(q), 'SELECT ("col") "different_name" FROM "tb"') + + def test_tuple_is_aggregate(self): + with self.subTest('None if single argument returns None for is_aggregate'): + self.assertEqual(None, Tuple(0).is_aggregate) + self.assertEqual(None, Tuple(Coalesce('col')).is_aggregate) + + with self.subTest('None if multiple arguments all return None for is_aggregate'): + self.assertEqual(None, Tuple(0, 'a').is_aggregate) + self.assertEqual(None, Tuple(Coalesce('col'), NullIf('col2', 0)).is_aggregate) + + with self.subTest('True if single argument returns True for is_aggregate'): + self.assertEqual(True, Tuple(Sum('col')).is_aggregate) + + with self.subTest('True if multiple arguments return True for is_aggregate'): + self.assertEqual(True, Tuple(Sum('col'), Sum('col2')).is_aggregate) + + with self.subTest('True when mix of arguments returning None and True for is_aggregate'): + self.assertEqual(True, Tuple(Coalesce('col'), Coalesce('col2', 0), Sum('col3')).is_aggregate) + + with self.subTest('False when one of the arguments returns False for is_aggregate'): + self.assertEqual(False, Tuple(Field('col1'), Sum('col2')).is_aggregate) + + +class ArrayTests(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_array_general(self): + query = Query.from_(self.table_abc).select(Array(1, "a", ["b", 2, 3])) + + self.assertEqual("SELECT [1,'a',['b',2,3]] FROM \"abc\"", str(query)) + + def test_empty_psql_array(self): + query = PostgreSQLQuery.from_(self.table_abc).select(Array()) + + self.assertEqual("SELECT '{}' FROM \"abc\"", str(query)) + + def test_psql_array_general(self): + query = PostgreSQLQuery.from_(self.table_abc).select(Array(1, Array(2, 2, 2), 3)) + + self.assertEqual("SELECT ARRAY[1,ARRAY[2,2,2],3] FROM \"abc\"", str(query)) + + def test_render_alias_in_array_sql(self): + tb = Table("tb") + + q = Query.from_(tb).select(Array(tb.col).as_("different_name")) + self.assertEqual(str(q), 'SELECT ["col"] "different_name" FROM "tb"') + + +class BracketTests(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_arithmetic_with_brackets(self): + q = Query.from_(self.table_abc).select(Bracket(self.table_abc.foo / 2) / 2) + + self.assertEqual('SELECT ("foo"/2)/2 FROM "abc"', str(q)) + + def test_arithmetic_with_brackets_and_alias(self): + q = Query.from_(self.table_abc).select(Bracket(self.table_abc.foo / 2).as_("alias")) + + self.assertEqual('SELECT ("foo"/2) "alias" FROM "abc"', str(q)) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/test_updates.py b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/test_updates.py new file mode 100644 index 0000000000000000000000000000000000000000..fb9d714dbcb8213b4bda04bf7b8dd9b2419410ec --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/test_updates.py @@ -0,0 +1,162 @@ +import unittest + +from pypika import AliasedQuery, PostgreSQLQuery, Query, SQLLiteQuery, SYSTEM_TIME, Table + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + +from pypika.terms import Star + + +class UpdateTests(unittest.TestCase): + table_abc = Table("abc") + table_def = Table("def") + + def test_empty_query(self): + q = Query.update("abc") + + self.assertEqual("", str(q)) + + def test_omit_where(self): + q = Query.update(self.table_abc).set("foo", "bar") + + self.assertEqual('UPDATE "abc" SET "foo"=\'bar\'', str(q)) + + def test_single_quote_escape_in_set(self): + q = Query.update(self.table_abc).set("foo", "bar'foo") + + self.assertEqual("UPDATE \"abc\" SET \"foo\"='bar''foo'", str(q)) + + def test_update__table_schema(self): + table = Table("abc", "schema1") + q = Query.update(table).set(table.foo, 1).where(table.foo == 0) + + self.assertEqual('UPDATE "schema1"."abc" SET "foo"=1 WHERE "foo"=0', str(q)) + + def test_update_with_none(self): + q = Query.update("abc").set("foo", None) + self.assertEqual('UPDATE "abc" SET "foo"=null', str(q)) + + def test_update_with_join(self): + q = ( + Query.update(self.table_abc) + .join(self.table_def) + .on(self.table_def.abc_id == self.table_abc.id) + .set(self.table_abc.lname, self.table_def.lname) + ) + self.assertEqual( + 'UPDATE "abc" JOIN "def" ON "def"."abc_id"="abc"."id" SET "lname"="def"."lname"', + str(q), + ) + + def test_update_with_limit(self): + q = Query.update(self.table_abc).set(self.table_abc.lname, "test").limit(1) + self.assertEqual('UPDATE "abc" SET "lname"=\'test\' LIMIT 1', str(q)) + + def test_update_from(self): + from_table = Table('from_table') + + q = Query.update(self.table_abc).set(self.table_abc.lname, from_table.long_name).from_(from_table) + self.assertEqual('UPDATE "abc" SET "lname"="from_table"."long_name" FROM "from_table"', str(q)) + + def test_update_from_with_where(self): + from_table = Table('from_table') + + q = ( + Query.update(self.table_abc) + .set(self.table_abc.lname, from_table.long_name) + .from_(from_table) + .where(self.table_abc.fname.eq(from_table.full_name)) + ) + self.assertEqual( + 'UPDATE "abc" SET "lname"="from_table"."long_name" FROM "from_table" ' + 'WHERE "abc"."fname"="from_table"."full_name"', + str(q), + ) + + def test_update_with_statement(self): + table_efg = Table('efg') + + sub_query = Query.from_(table_efg).select("fizz") + an_alias = AliasedQuery("an_alias") + + q = ( + Query.with_(sub_query, "an_alias") + .update(self.table_abc) + .from_(an_alias) + .set(self.table_abc.lname, an_alias.long_name) + .where(self.table_abc.comp.eq(an_alias.alias_comp)) + ) + self.assertEqual( + 'WITH an_alias AS (SELECT "fizz" FROM "efg") ' + 'UPDATE "abc" SET "lname"="an_alias"."long_name" FROM an_alias ' + 'WHERE "abc"."comp"="an_alias"."alias_comp"', + str(q), + ) + + def test_for_portion(self): + with self.subTest("with system time"): + q = Query.update(self.table_abc.for_portion(SYSTEM_TIME.from_to('2020-01-01', '2020-02-01'))).set( + "foo", "bar" + ) + + self.assertEqual( + 'UPDATE "abc" FOR PORTION OF SYSTEM_TIME FROM \'2020-01-01\' TO \'2020-02-01\' SET "foo"=\'bar\'', + str(q), + ) + + with self.subTest("with column"): + q = Query.update( + self.table_abc.for_portion(self.table_abc.valid_period.from_to('2020-01-01', '2020-02-01')) + ).set("foo", "bar") + + self.assertEqual( + 'UPDATE "abc" FOR PORTION OF "valid_period" FROM \'2020-01-01\' TO \'2020-02-01\' SET "foo"=\'bar\'', + str(q), + ) + + +class PostgresUpdateTests(unittest.TestCase): + table_abc = Table("abc") + + def test_update_returning_str(self): + q = PostgreSQLQuery.update(self.table_abc).where(self.table_abc.foo == 0).set("foo", "bar").returning("id") + + self.assertEqual('UPDATE "abc" SET "foo"=\'bar\' WHERE "foo"=0 RETURNING "abc"."id"', str(q)) + + def test_update_returning(self): + q = ( + PostgreSQLQuery.update(self.table_abc) + .where(self.table_abc.foo == 0) + .set("foo", "bar") + .returning(self.table_abc.id) + ) + + self.assertEqual('UPDATE "abc" SET "foo"=\'bar\' WHERE "foo"=0 RETURNING "abc"."id"', str(q)) + + def test_update_returning_from_different_tables(self): + table_bcd = Table('bcd') + + q = ( + PostgreSQLQuery.update(self.table_abc) + .from_(table_bcd) + .set(self.table_abc.lname, table_bcd.long_name) + .returning(self.table_abc.id, table_bcd.fname) + ) + self.assertEqual( + 'UPDATE "abc" SET "lname"="bcd"."long_name" FROM "bcd" RETURNING "abc"."id","bcd"."fname"', str(q) + ) + + def test_update_returning_star(self): + q = PostgreSQLQuery.update(self.table_abc).where(self.table_abc.foo == 0).set("foo", "bar").returning(Star()) + + self.assertEqual('UPDATE "abc" SET "foo"=\'bar\' WHERE "foo"=0 RETURNING *', str(q)) + + +class SQLLiteUpdateTests(unittest.TestCase): + table_abc = Table("abc") + + def test_update_with_bool(self): + q = SQLLiteQuery.update(self.table_abc).set(self.table_abc.foo, True) + + self.assertEqual('UPDATE "abc" SET "foo"=1', str(q)) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/test_utils.py b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/test_utils.py new file mode 100644 index 0000000000000000000000000000000000000000..bb9a9b1c68fe8671989f7c49f9db90e389d06f59 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pypika/tests/test_utils.py @@ -0,0 +1,24 @@ +import unittest + +from pypika import utils + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + + +class ImmutabilityTests(unittest.TestCase): + def test_raise_attribute_error_for_deepcopy(self): + with self.assertRaises(AttributeError): + utils.raise_attribute_for_copy("Test", "__deepcopy__") + + def test_raise_attribute_error_for_getstate(self): + with self.assertRaises(AttributeError): + utils.raise_attribute_for_copy("Test", "__getstate__") + + def test_raise_attribute_error_for_setstate(self): + with self.assertRaises(AttributeError): + utils.raise_attribute_for_copy("Test", "__setstate__") + + def test_raise_attribute_error_for_getnewargs(self): + with self.assertRaises(AttributeError): + utils.raise_attribute_for_copy("Test", "__getnewargs__") diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pyproject.toml b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pyproject.toml new file mode 100644 index 0000000000000000000000000000000000000000..dcc56baede23e3571b336625e695c466ab833a56 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/pyproject.toml @@ -0,0 +1,22 @@ +[tool.black] +line-length = 120 +skip-string-normalization = true +target-version = ['py38', 'py39', 'py310', 'py311'] +force-exclude = ''' +( + /( + \.eggs # exclude a few common directories in the + | \.git # root of the project + | \.hg + | \.mypy_cache + | \.tox + | \.venv + | _build + | buck-out + | build + | dist + | docs + )/ + | setup.py +) +''' diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/setup.cfg b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/setup.cfg new file mode 100644 index 0000000000000000000000000000000000000000..46084aaf2ca9e95b2f9bb7680e432e637fc3ed90 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/setup.cfg @@ -0,0 +1,16 @@ +[bumpversion] +current_version = 0.48.9 +commit = True +tag = True + +[bumpversion:file:pypika/__init__.py] +search = __version__ = "{current_version}" +replace = __version__ = "{new_version}" + +[bdist_wheel] +universal = 1 + +[flake8] +exclude = docs, .git, __pycache__ +max-line-length = 120 +per-file-ignores = __init__.py:F401 diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/setup.py b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/setup.py new file mode 100644 index 0000000000000000000000000000000000000000..41cce7d742df3e33e8d76f267d77df486f69249a --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/setup.py @@ -0,0 +1,81 @@ +import ast + +from setuptools import setup + + +def readme(): + with open('README.rst', 'rb') as f: + return f.read().decode('UTF-8') + + +def version(): + path = 'pypika/__init__.py' + with open(path, 'r') as file: + t = compile(file.read(), path, 'exec', ast.PyCF_ONLY_AST) + for node in (n for n in t.body if isinstance(n, ast.Assign)): + if len(node.targets) == 1: + name = node.targets[0] + if isinstance(name, ast.Name) and name.id in ('__version__', '__version_info__', 'VERSION'): + v = node.value + if isinstance(v, ast.Str): + return v.s + + if isinstance(v, ast.Tuple): + r = [] + for e in v.elts: + if isinstance(e, ast.Str): + r.append(e.s) + elif isinstance(e, ast.Num): + r.append(str(e.n)) + return '.'.join(r) + + +setup( + # Application name: + name="PyPika", + + # Version number: + version=version(), + + # Application author details: + author="Timothy Heys", + author_email="theys@kayak.com", + + # License + license='Apache License Version 2.0', + + # Packages + packages=["pypika", "pypika.clickhouse"], + + # Include additional files into the package + package_data={"pypika": ["py.typed"]}, + include_package_data=True, + + install_requires=[], + + # Details + url="https://github.com/kayak/pypika", + + description="A SQL query builder API for Python", + long_description=readme(), + + classifiers=[ + 'License :: OSI Approved :: Apache Software License', + 'Development Status :: 5 - Production/Stable', + 'Intended Audience :: Developers', + 'Programming Language :: Python :: 3', + 'Programming Language :: PL/SQL', + 'Topic :: Software Development :: Libraries :: Python Modules', + 'Topic :: Scientific/Engineering :: Information Analysis', + 'Topic :: Scientific/Engineering :: Mathematics', + 'Operating System :: POSIX', + 'Operating System :: MacOS :: MacOS X', + 'Operating System :: Microsoft :: Windows', + ], + keywords=('pypika python query builder querybuilder sql mysql postgres psql oracle vertica aggregated ' + 'relational database rdbms business analytics bi data science analysis pandas ' + 'orm object mapper'), + + # Dependent packages (distributions) + test_suite="pypika.tests", +) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/tox.ini b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/tox.ini new file mode 100644 index 0000000000000000000000000000000000000000..2f0e6893243b1ca2ead6a12825e9014dc66364ce --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/tests/trusted/tox.ini @@ -0,0 +1,16 @@ +[tox] +envlist = py38,py39,py310,py311,pypy3 + +[testenv] +description = testing against {basepython} +deps = -r requirements-dev.txt +commands = + coverage run + coverage xml + +[gh-actions] +python = + 3.8: py38 + 3.9: py39 + 3.10: py310 + 3.11: py311 diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/validation/canaries/first-hunk-only.sh b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/validation/canaries/first-hunk-only.sh new file mode 100644 index 0000000000000000000000000000000000000000..d3da3512b0625f4f16a6c2ab305b95dbc30951a3 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/validation/canaries/first-hunk-only.sh @@ -0,0 +1,33 @@ +#!/bin/bash +set -Eeuo pipefail +cd /testbed/repo +cat > /tmp/openenv-reference.diff <<'OPENENV_PARTIAL' +diff --git a/pypika/clickhouse/array.py b/pypika/clickhouse/array.py +index 8e8b68ccb1f0fd735b269b9c9e8fc4fef7dd5da8..67929f1664e8a3d63d5b1a83cdf66ae590c53ce4 100644 +--- a/pypika/clickhouse/array.py ++++ b/pypika/clickhouse/array.py +@@ -16,17 +16,17 @@ + self._converter_options = converter_options or dict() + + def get_sql(self): +- if not self._converter_cls: ++ if self._converter_cls: + converted = [] + for value in self._values: + converter = self._converter_cls(value, **self._converter_options) +- converted.append(str(value)) +- sql = "".join(["(", ",".join(converted), ")"]) ++ converted.append(converter.get_sql()) ++ sql = "".join(["[", ",".join(converted), "]"]) + + else: +- sql = repr(self._values) ++ sql = str(self._values) + +- return format_alias_sql(sql, self.alias[::-1]) ++ return format_alias_sql(sql, self.alias) + + + class HasAny(Function): +OPENENV_PARTIAL +/usr/bin/git -c core.hooksPath=/dev/null -c core.fsmonitor=false apply --whitespace=nowarn /tmp/openenv-reference.diff diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/validation/canaries/original-bug.sh b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/validation/canaries/original-bug.sh new file mode 100644 index 0000000000000000000000000000000000000000..927547df786c86ab3bb5eeb917a31e0fa1895f8b --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/validation/canaries/original-bug.sh @@ -0,0 +1,3 @@ +#!/bin/bash +set -Eeuo pipefail +: diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/validation/openenv.json b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/validation/openenv.json new file mode 100644 index 0000000000000000000000000000000000000000..a13b3c577df494f6c894584d2b608ab051ebc44f --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__q1pjmphb/validation/openenv.json @@ -0,0 +1,27 @@ +{ + "canaries": "validation/canaries", + "profile": "harbor-semantic-v1", + "requires_credentials": false, + "resources": { + "cpu": 2, + "disk_mb": 16384, + "episode_timeout_s": 1800, + "memory_mb": 8192 + }, + "reward": { + "floor_margin": 0.1, + "oracle_tolerance": 0, + "range": [ + 0, + 1 + ] + }, + "reward_key": "reward", + "types": { + "tags": [ + "swe", + "python", + "mutation-repair" + ] + } +} diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/LICENSE.source b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/LICENSE.source new file mode 100644 index 0000000000000000000000000000000000000000..9c8f3ea0871e0bfe81da0fa6e7c1d7d156dc380e --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/LICENSE.source @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. \ No newline at end of file diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/adapter.json b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/adapter.json new file mode 100644 index 0000000000000000000000000000000000000000..04611fa10b19eec3ada982c986a4542551df0193 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/adapter.json @@ -0,0 +1,135 @@ +{ + "canary_selection": "Fixed first provided gold hunk only when at least2hunks exist; strict subset, never reward-selected. Single-hunk task original-bug canary is explicitly NOP-equivalent and adds no signal beyond floor_gap.", + "collector_sha256": "352e555112f2de8a1393f939903e4971c9ace0e944843762b707a725c5c72481", + "dependency_installation_pinned": false, + "dependency_setup_sha256": "ed8673d02878e91c7ae0b51b9178d6a15792b79c6992f800c14a941d95242392", + "gold_patch_sha256": "98884393d0c5d6d37bd153f0947d86c06fb12676889b0f60a0c887a7dc85bd6a", + "hostile_code_isolation_established": false, + "known_wrong_semantic_implementations": 0, + "native_inventory_sha256": "8456d04360dab7d04305e05cf39b10774a88047202a5b8c1837ccb889c817b21", + "new_files_deletions_and_executable_modes_supported": true, + "official_profile": { + "eval_sets": [], + "profile_class": "Pypika1c9646f0", + "profile_lines": [ + 736, + 739 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "upstream_repo": "kayak/pypika" + }, + "original_bug_canary_nop_equivalent": true, + "original_bug_runtime_wrongness_established": false, + "partial_repair_canary": true, + "partial_repair_sha256": "bbe18377cedd73cd62ece0a20e76b8dadc6c6acc80a77b4c796a58562ac3b373", + "partial_repair_wrongness_established": false, + "positive_approval_policy": "All original strict presence/identity/no-skip/no-error/exit checks retained", + "private_checker_sha256": "f0a641064b725415e23a0221bb53c90446d7efcb7f9ece5ede93a220d18dd9e7", + "private_checker_version": "matched-failure-precedence-v2", + "provided_original_bug_control": true, + "repo_url": "https://github.com/swesmith/kayak__pypika.1c9646f0.git", + "runtime_image": null, + "runtime_ready": false, + "runtime_recipe": { + "dependency_installation_pinned": false, + "official_install_cmds": [ + "python -m pip install -e ." + ], + "official_pytest_argv": [ + "pytest", + "--disable-warnings", + "--color=no", + "--tb=no", + "--verbose" + ], + "official_test_command": "source /opt/miniconda3/bin/activate; conda activate testbed; pytest --disable-warnings --color=no --tb=no --verbose", + "operator_test_runner_prerequisites": [ + "python -m pip install pytest==8.4.2" + ], + "operator_test_runner_reason": "The official profile invokes pytest, but the common tools runtime does not provide it; pinned separately from source-native project requirements.", + "panel_normalization": "Override project addopts only to execute the exact frozen native panels; add JUnit output, preserve official pytest options and all selectors.", + "python_version": "3.10", + "source_bound_test_dependency_cmds": [ + "python -m pip install parameterized==0.7.0" + ], + "test_dependency_source_sha256": { + "requirements-dev.txt": "10f4ba7b19a73950d28fd7403d7e1d1b1fe2ccc4f49516974f47199d2965f23d", + "setup.py": "f8bad274588a22e65764d8cf9fb2be5aa6fcfaf3bf861d71e5f751105898845a", + "tox.ini": "c2d7205d0ac93e9c9e80dc5d24f0a826a6781f587a33ea722ea621f9e2ccd0ea" + } + }, + "runtime_resource_review_required": false, + "schema": "python-git-patch-jobs-v1", + "source_base_commit": "07559ce0cc1e9b57ef34282c9f8294eb79d960f2", + "source_completion_sha256": "a3694b4c02cc28c7a4b32f5bf57c892980d5a0da3d654a3610a1de38c9002a30", + "source_index_sha256": "e856874b9410fce9f3bfea52c8c482e84b3e43942d87517f8b55f0034bd40f6f", + "source_pr_url": null, + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:kayak__pypika.1c9646f0.combine_module__rbtcd9k8", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "6a742f12bfa386994289ec8b75824663d8ee4b15", + "instruction_sha256": "3c0e9d5bac4d3878fdb829e8a56201c4070181669738b5f00e2293f3c5da8c26", + "is_fork": true, + "learner_path": "tasks/669f7b6aa8c0c39d7bb06817/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "actual_upstream_url": "https://raw.githubusercontent.com/kayak/pypika/1c9646f0a019a167c32b649b6f5e6423c5ba2c9b/LICENSE.txt", + "reviewed": true, + "sha256": "c5accbbd8546e94c34aed24afe689a617627d18eed5a6c48277e48db57c23851", + "spdx": "Apache-2.0", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/kayak__pypika.1c9646f0/07559ce0cc1e9b57ef34282c9f8294eb79d960f2/LICENSE.txt" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "patch_sha256": "fb2c262357e344f35065aaed4f472f9e1008fe8c9bf6a84bfb2b080689916cb3", + "provenance_path": "tasks/669f7b6aa8c0c39d7bb06817/source-proof.json", + "repository_lineage": [ + "swesmith/kayak__pypika.1c9646f0", + "kayak/pypika" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "07559ce0cc1e9b57ef34282c9f8294eb79d960f2", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "58da3adb7eff81c8b75e171d2444267fba42acf4", + "source_kind": "mutation", + "source_repo": "swesmith/kayak__pypika.1c9646f0", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "kayak__pypika.1c9646f0.combine_module__rbtcd9k8", + "task_sha256": "e4e61f593cfa3446ac9953bf6481c2c91e8217f2e11fa1779a6028ab8af9da77", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "kayak/pypika", + "usage": "quarantine_only" + }, + "source_repo": "swesmith/kayak__pypika.1c9646f0", + "symlink_submodule_changes_supported": false, + "task_id": "kayak__pypika.1c9646f0.combine_module__rbtcd9k8", + "transfer": "index-independent-worktree-to-Git-binary-patch", + "transfer_path": "/testbed/submission.patch", + "upstream_repo": "kayak/pypika" +} diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/dependency-setup.sh b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/dependency-setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e1a28db070ebf088cec3ef817cf2dc8715091ac2 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/dependency-setup.sh @@ -0,0 +1,9 @@ +#!/bin/bash +set -Eeuo pipefail +source /opt/miniconda3/bin/activate +conda activate testbed +cd /testbed/repo +python -c 'import sys; assert sys.version_info[:2] == (3, 10)' +python -m pip install pytest==8.4.2 +python -m pip install -e . +python -m pip install parameterized==0.7.0 diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/environment/Dockerfile b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..a59b58c2ea8217c78c1e39b4678f93c8c0023bcd --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/environment/Dockerfile @@ -0,0 +1,3 @@ +# Runtime is selected only by an independently qualified immutable amd64 receipt. +FROM ubuntu:22.04 +RUN false diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/instruction.md b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..9a1598e50ecbf53bc823aa2e50a70c7ad0e744e8 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/instruction.md @@ -0,0 +1,47 @@ +ClickHouse functions generating incorrect SQL output + +#### Description + +The ClickHouse-specific functions `If`, `MultiIf`, `MultiSearchAny`, and `MultiMatchAny` are producing incorrect SQL output. The generated queries contain wrong function names, reversed argument order, and malformed syntax. + +#### Steps/Code to Reproduce + +```python +from pypika.clickhouse import If, MultiIf, MultiSearchAny, MultiMatchAny +from pypika import Field + +# Test If function +field = Field('test_field') +condition = Field('condition') +if_func = If(condition, 'true_value', 'false_value') +print("If function SQL:", if_func.get_sql()) +# Expected: if(condition,"true_value","false_value") +# Actual: switch("false_value","true_value",condition) + +# Test MultiIf function +multi_if = MultiIf('cond1', 'val1', 'cond2', 'val2', 'default') +print("MultiIf function SQL:", multi_if.get_sql()) +# Expected: multiIf("cond1","val1","cond2","val2","default") +# Actual: multiIf("default","val2","cond2","val1","cond1") + +# Test MultiSearchAny function +search_func = MultiSearchAny(field, ['pattern1', 'pattern2']) +print("MultiSearchAny SQL:", search_func.get_sql()) +# Expected: multiSearchAny(test_field,['pattern1','pattern2']) +# Actual: singleSearchAll(self;test_field,{patterns}) + +# Test MultiMatchAny function +match_func = MultiMatchAny(field, ['regex1', 'regex2']) +print("MultiMatchAny SQL:", match_func.get_sql()) +# Expected: multiMatchAny(test_field,['regex1','regex2']) +# Actual: multiMatchAll(self;test_field,{patterns}) +``` + +The functions are generating SQL with: +- Wrong function names (switch instead of if, singleSearchAll instead of multiSearchAny, etc.) +- Arguments in reverse order +- Malformed syntax with semicolons instead of commas and curly braces instead of square brackets + +## Environment + +The repository is at `/testbed/repo`. Its dependencies, including pytest, are installed in the `testbed` conda environment, which comes first on PATH. If `python -m pytest` reports that pytest is missing, use the full interpreter path: `/opt/miniconda3/envs/testbed/bin/python -m pytest `. Don't install packages: the tests need nothing else, and the sandbox may have no network access. diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/metadata.json b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/metadata.json new file mode 100644 index 0000000000000000000000000000000000000000..43f3f62ce81d6c6cff59a13ffb2c30622c437d14 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/metadata.json @@ -0,0 +1,1276 @@ +{ + "all_runtime_and_training_flags": false, + "official_profile": { + "eval_sets": [], + "profile_class": "Pypika1c9646f0", + "profile_lines": [ + 736, + 739 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "upstream_repo": "kayak/pypika" + }, + "source_healthy_reference_proof": { + "FAIL_TO_PASS": [ + "pypika/tests/clickhouse/test_condition.py::TestIfCondition::test_get_sql_0", + "pypika/tests/clickhouse/test_condition.py::TestIfCondition::test_get_sql_1", + "pypika/tests/clickhouse/test_condition.py::TestMultiIfCondition::test_get_sql_0", + "pypika/tests/clickhouse/test_condition.py::TestMultiIfCondition::test_get_sql_1", + "pypika/tests/clickhouse/test_search_string.py::TestMultiSearch::test_multi_search_string_0", + "pypika/tests/clickhouse/test_search_string.py::TestMultiSearch::test_multi_search_string_1" + ], + "PASS_TO_PASS": [ + "pypika/tests/clickhouse/test_array.py::TestArray::test_get_sql_0__ridley_scott_jimi_hendrix_", + "pypika/tests/clickhouse/test_array.py::TestArray::test_get_sql_1__1_2_3_4_", + "pypika/tests/clickhouse/test_array.py::TestArray::test_get_sql_2__toInt64_1_toInt64_2_toInt64_3_toInt64_4_", + "pypika/tests/clickhouse/test_array.py::TestArray::test_get_sql_3__toFixedString_mogwai_10_toFixedString_mono_10_toFixedString_bonobo_10_arr", + "pypika/tests/clickhouse/test_array.py::TestHasAny::test_get_sql_0_hasAny_mental_abilities_physical_abilities_", + "pypika/tests/clickhouse/test_array.py::TestHasAny::test_get_sql_1_hasAny_1_2_3_4_3_", + "pypika/tests/clickhouse/test_array.py::TestHasAny::test_get_sql_2_hasAny_bands_toFixedString_port_royal_20_toFixedString_hammock_20_", + "pypika/tests/clickhouse/test_array.py::TestLength::test_get_sql_0_length_tags_", + "pypika/tests/clickhouse/test_array.py::TestLength::test_get_sql_1_length_1_2_3_", + "pypika/tests/clickhouse/test_array.py::TestEmpty::test_get_sql_0_empty_tags_", + "pypika/tests/clickhouse/test_array.py::TestEmpty::test_get_sql_1_empty_1_2_3_", + "pypika/tests/clickhouse/test_array.py::TestNotEmpty::test_get_sql_0_notEmpty_tags_", + "pypika/tests/clickhouse/test_array.py::TestNotEmpty::test_get_sql_1_notEmpty_1_2_3_", + "pypika/tests/clickhouse/test_dates_and_times.py::TestFormatDateTime::test_get_sql_0", + "pypika/tests/clickhouse/test_dates_and_times.py::TestFormatDateTime::test_get_sql_1", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_00", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_01", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_02", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_03", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_04", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_05", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_06", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_07", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_08", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_09", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_10", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_11", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_12", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_13", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_14", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_15", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_16", + "pypika/tests/clickhouse/test_dates_and_times.py::TestToYYYYMM::test_get_sql", + "pypika/tests/clickhouse/test_nullable_arg.py::TestSearchString::test_get_sql_0", + "pypika/tests/clickhouse/test_nullable_arg.py::TestSearchString::test_get_sql_1", + "pypika/tests/clickhouse/test_search_string.py::TestSearchString::test_search_string_0", + "pypika/tests/clickhouse/test_search_string.py::TestSearchString::test_search_string_1", + "pypika/tests/clickhouse/test_search_string.py::TestSearchString::test_search_string_2", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_00_toString_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_01_toInt8_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_02_toInt16_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_03_toInt32_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_04_toInt64_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_05_toUInt8_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_06_toUInt16_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_07_toUInt32_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_08_toUInt64_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_09_toFloat32_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_10_toFloat64_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_11_toFloat64_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_12_toDate_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_13_toDateTime_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_14_toFixedString_field_name_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_00_toString_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_01_toInt8_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_02_toInt16_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_03_toInt32_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_04_toInt64_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_05_toUInt8_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_06_toUInt16_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_07_toUInt32_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_08_toUInt64_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_09_toFloat32_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_10_toFloat64_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_11_toFloat64_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_12_toDate_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_13_toDateTime_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_14_toFixedString_100_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestToFixedString::test_get_sql_with_table", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseQueryTests::test_use_AS_keyword_for_alias", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseQueryTests::test_use_FINAL_keyword", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseQueryTests::test_use_SAMPLE_keyword", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseQueryTests::test_use_SAMPLE_with_offset_keyword", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDeleteTests::test_omit_where", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDeleteTests::test_omit_where__table_schema", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDeleteTests::test_where_field_equals", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseUpdateTests::test_update", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDropQuery::test_drop_database", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDropQuery::test_drop_dictionary", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDropQuery::test_drop_other", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDropQuery::test_drop_table", + "pypika/tests/dialects/test_clickhouse.py::DistinctOnTests::test_distinct_on", + "pypika/tests/dialects/test_clickhouse.py::LimitByTests::test_limit_by", + "pypika/tests/dialects/test_clickhouse.py::LimitByTests::test_limit_offset0_by", + "pypika/tests/dialects/test_clickhouse.py::LimitByTests::test_limit_offset_by", + "pypika/tests/dialects/test_clickhouse.py::LimitByTests::test_rename_table", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_distinct_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_groupby_alias_False_does_not_group_by_alias_when_subqueries_are_present", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_groupby_alias_False_does_not_group_by_alias_with_standard_query", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_limit", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_limit_with_offset", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_normal_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_offset", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_distinct_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_percent_invalid_range", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_percent_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_select_non_int", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_with_ties_select", + "pypika/tests/dialects/test_mysql.py::SelectTests::test_distinct_select", + "pypika/tests/dialects/test_mysql.py::SelectTests::test_modifier_select", + "pypika/tests/dialects/test_mysql.py::SelectTests::test_multiple_modifier_select", + "pypika/tests/dialects/test_mysql.py::SelectTests::test_normal_select", + "pypika/tests/dialects/test_mysql.py::UpdateTests::test_conflict_handlers_update", + "pypika/tests/dialects/test_mysql.py::UpdateTests::test_on_duplicate_key_ignore_update", + "pypika/tests/dialects/test_mysql.py::UpdateTests::test_on_duplicate_key_update_update", + "pypika/tests/dialects/test_mysql.py::UpdateTests::test_update", + "pypika/tests/dialects/test_mysql.py::LoadCSVTests::test_load_from_file", + "pypika/tests/dialects/test_mysql.py::TableTests::test_create_table", + "pypika/tests/dialects/test_mysql.py::TableTests::test_drop_table", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_fetch_next_method_deprecated", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_groupby_alias_False_does_not_group_by_alias_when_subqueries_are_present", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_groupby_alias_False_does_not_group_by_alias_with_standard_query", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_limit_offset_query", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_limit_query", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_offset_query", + "pypika/tests/dialects/test_postgresql.py::InsertTests::test_array_keyword", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_alias_set_correctly", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_json_value_from_array_num", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_json_value_from_array_str", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_json_value_from_dict", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_json_value_from_dict_recursive", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_json_value_by_index", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_json_value_by_key", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_path_json_value", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_path_text_value", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_text_value_by_index", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_text_value_by_key", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contained_by_using_list_arg", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contained_by_using_str_arg", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contained_by_with_complex_criterion", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contains_for_field", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contains_for_json", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_has_any_keys", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_has_key", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_has_keys", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_subnet_contains_inet", + "pypika/tests/dialects/test_postgresql.py::DistinctOnTests::test_distinct_on", + "pypika/tests/dialects/test_postgresql.py::ArrayTests::test_array_syntax", + "pypika/tests/dialects/test_postgresql.py::ArrayTests::test_render_alias_in_array_sql", + "pypika/tests/dialects/test_postgresql.py::ReturningClauseTests::test_no_queryexception_if_returning_used_on_valid_query_type", + "pypika/tests/dialects/test_postgresql.py::ReturningClauseTests::test_queryexception_if_returning_used_on_invalid_query", + "pypika/tests/dialects/test_postgresql.py::ReturningClauseTests::test_return_field_from_join_table", + "pypika/tests/dialects/test_postgresql.py::ReturningClauseTests::test_returning_from_missing_table_raises_queryexception", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_dont_use_double_quotes_on_create_queries", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_dont_use_double_quotes_on_drop_queries", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_dont_use_double_quotes_on_joining_queries", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_use_double_quotes_on_alias_but_not_on_terms", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_use_double_quotes_on_alias_but_not_on_terms_with_joins", + "pypika/tests/dialects/test_sqllite.py::SelectTests::test_bool_false_as_zero", + "pypika/tests/dialects/test_sqllite.py::SelectTests::test_bool_true_as_one", + "pypika/tests/dialects/test_sqllite.py::ReplaceTests::test_insert_or_replace", + "pypika/tests/dialects/test_sqllite.py::ReplaceTests::test_normal_replace", + "pypika/tests/dialects/test_sqllite.py::ReplaceTests::test_replace_subquery", + "pypika/tests/dialects/test_vertica.py::VerticaQueryTests::test_delete_query_with_hint", + "pypika/tests/dialects/test_vertica.py::VerticaQueryTests::test_insert_query_with_hint", + "pypika/tests/dialects/test_vertica.py::VerticaQueryTests::test_select_query_with_hint", + "pypika/tests/dialects/test_vertica.py::VerticaQueryTests::test_update_query_with_hint", + "pypika/tests/dialects/test_vertica.py::CopyCSVTests::test_copy_from_file", + "pypika/tests/dialects/test_vertica.py::CreateTemporaryTableTests::test_create_local_table_without_temporary_raises_error", + "pypika/tests/dialects/test_vertica.py::CreateTemporaryTableTests::test_create_local_temporary_table", + "pypika/tests/dialects/test_vertica.py::CreateTemporaryTableTests::test_create_table_preserve_rows_without_temporary_raises_error", + "pypika/tests/dialects/test_vertica.py::CreateTemporaryTableTests::test_create_temporary_table_preserve_rows", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__agg_case_criterion_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__agg_case_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__agg_func_arithmetic_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__agg_func_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__case_mixed_constant_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__case_mixed_else_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__case_with_field_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__case_with_single_aggregate_field_in_one_criterion_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__constant_arithmetic_is_aggregate_none", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__constant_is_aggregate_none", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__field_arithmetic_constant_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__field_arithmetic_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__field_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__func_arithmetic_constant_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__mixed_case_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__mixed_func_arithmetic_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__negative_agg_func_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__non_aggregate_function_with_aggregated_arg", + "pypika/tests/test_aggregate.py::IsAggregateTests::test_complicated", + "pypika/tests/test_analytic_queries.py::RankTests::test_avg", + "pypika/tests/test_analytic_queries.py::RankTests::test_count_range_between_unbounded_preceeding_current_row", + "pypika/tests/test_analytic_queries.py::RankTests::test_dense_rank", + "pypika/tests/test_analytic_queries.py::RankTests::test_empty_over", + "pypika/tests/test_analytic_queries.py::RankTests::test_filter", + "pypika/tests/test_analytic_queries.py::RankTests::test_filter_quote_table_in_filter", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value_ignore_nulls", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value_ignore_nulls_first", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value_multi_argument", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value_range_between_x_preceeding_unbounded_following", + "pypika/tests/test_analytic_queries.py::RankTests::test_lag_generates_correct_sql", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value_ignore_nulls", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value_multi_argument", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value_rows_between_current_row_unbounded_following", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value_rows_between_current_row_unbounded_following_ignore_nulls", + "pypika/tests/test_analytic_queries.py::RankTests::test_lead_generates_correct_sql", + "pypika/tests/test_analytic_queries.py::RankTests::test_max_range_x_preceeding", + "pypika/tests/test_analytic_queries.py::RankTests::test_max_rows_x_preceeding", + "pypika/tests/test_analytic_queries.py::RankTests::test_median", + "pypika/tests/test_analytic_queries.py::RankTests::test_min_range_current_row", + "pypika/tests/test_analytic_queries.py::RankTests::test_min_rows_current_row", + "pypika/tests/test_analytic_queries.py::RankTests::test_multiple_partitions", + "pypika/tests/test_analytic_queries.py::RankTests::test_ntile_no_partition_or_order_invalid_sql", + "pypika/tests/test_analytic_queries.py::RankTests::test_ntile_with_order", + "pypika/tests/test_analytic_queries.py::RankTests::test_ntile_with_partition", + "pypika/tests/test_analytic_queries.py::RankTests::test_ntile_with_partition_and_order", + "pypika/tests/test_analytic_queries.py::RankTests::test_orderby_asc", + "pypika/tests/test_analytic_queries.py::RankTests::test_orderby_desc", + "pypika/tests/test_analytic_queries.py::RankTests::test_range_called_twice_raises_attribute_error", + "pypika/tests/test_analytic_queries.py::RankTests::test_range_then_rows_raises_attribute_error", + "pypika/tests/test_analytic_queries.py::RankTests::test_rank", + "pypika/tests/test_analytic_queries.py::RankTests::test_rank_with_alias", + "pypika/tests/test_analytic_queries.py::RankTests::test_row_number", + "pypika/tests/test_analytic_queries.py::RankTests::test_rows_called_twice_raises_attribute_error", + "pypika/tests/test_analytic_queries.py::RankTests::test_rows_then_range_raises_attribute_error", + "pypika/tests/test_analytic_queries.py::RankTests::test_stddev", + "pypika/tests/test_analytic_queries.py::RankTests::test_stddev_pop", + "pypika/tests/test_analytic_queries.py::RankTests::test_stddev_samp", + "pypika/tests/test_analytic_queries.py::RankTests::test_sum_rows_unbounded_preceeding", + "pypika/tests/test_analytic_queries.py::RankTests::test_table_prefixes_used_in_analytic_functions", + "pypika/tests/test_analytic_queries.py::RankTests::test_var_pop", + "pypika/tests/test_analytic_queries.py::RankTests::test_var_samp", + "pypika/tests/test_analytic_queries.py::RankTests::test_variance", + "pypika/tests/test_analytic_queries.py::RankTests::test_variance_rows_between_unbounded_preceeding_unbounded_following", + "pypika/tests/test_analytic_queries.py::RankTests::test_varpop_range_unbounded_preceeding", + "pypika/tests/test_analytic_queries.py::RankTests::test_varpop_rows_between_unbounded_preceeding_x_following", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_as_select_not_query_raises_error", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_with_columns", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_with_select", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_with_select_and_columns_fails", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_without_columns_or_select_empty", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_if_not_exists", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_simple", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_unique", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_where", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_without_columns_raises_error", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_without_table_raises_error", + "pypika/tests/test_criterions.py::CriterionTests::test__bitwise_and_in_where_clause", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_bitwise_and", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_bitwise_and_with_alias", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_bool", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_decimal", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_str", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gt_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gt_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gt_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gt_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gte_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gte_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gte_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gte_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_is_null", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_is_null_with_alias", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lt_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lt_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lt_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lt_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lte_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lte_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lte_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lte_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_str", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_with_alias", + "pypika/tests/test_criterions.py::NotTests::test_chained_function", + "pypika/tests/test_criterions.py::NotTests::test_is_not_null", + "pypika/tests/test_criterions.py::NotTests::test_negate", + "pypika/tests/test_criterions.py::NotTests::test_not_null", + "pypika/tests/test_criterions.py::NotTests::test_not_null_with_alias", + "pypika/tests/test_criterions.py::NotTests::test_not_with_and_criterion", + "pypika/tests/test_criterions.py::NotTests::test_not_with_complex_criterion", + "pypika/tests/test_criterions.py::NotTests::test_not_with_or_criterion", + "pypika/tests/test_criterions.py::NotTests::test_notnullcriterion_replace_table", + "pypika/tests/test_criterions.py::NotTests::test_variable_access", + "pypika/tests/test_criterions.py::BetweenTests::test__between_date", + "pypika/tests/test_criterions.py::BetweenTests::test__between_datetime", + "pypika/tests/test_criterions.py::BetweenTests::test__between_number", + "pypika/tests/test_criterions.py::BetweenTests::test__between_with_alias", + "pypika/tests/test_criterions.py::BetweenTests::test__function_between", + "pypika/tests/test_criterions.py::BetweenTests::test_get_item_only_works_with_slice", + "pypika/tests/test_criterions.py::IsInTests::test__function_isin", + "pypika/tests/test_criterions.py::IsInTests::test__in_character", + "pypika/tests/test_criterions.py::IsInTests::test__in_date", + "pypika/tests/test_criterions.py::IsInTests::test__in_datetime", + "pypika/tests/test_criterions.py::IsInTests::test__in_number", + "pypika/tests/test_criterions.py::IsInTests::test__in_number_with_alias", + "pypika/tests/test_criterions.py::IsInTests::test__in_unicode", + "pypika/tests/test_criterions.py::ArithmeticExpressionTests::test__lshift", + "pypika/tests/test_criterions.py::ArithmeticExpressionTests::test__rshift", + "pypika/tests/test_criterions.py::NotInTests::test__function_notin", + "pypika/tests/test_criterions.py::NotInTests::test__notin_character", + "pypika/tests/test_criterions.py::NotInTests::test__notin_date", + "pypika/tests/test_criterions.py::NotInTests::test__notin_datetime", + "pypika/tests/test_criterions.py::NotInTests::test__notin_number", + "pypika/tests/test_criterions.py::NotInTests::test__notin_number_with_alias", + "pypika/tests/test_criterions.py::LikeTests::test_glob_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_contains", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_ends_with", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_n_chars_long", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_starts_with", + "pypika/tests/test_criterions.py::LikeTests::test_like_contains", + "pypika/tests/test_criterions.py::LikeTests::test_like_ends_with", + "pypika/tests/test_criterions.py::LikeTests::test_like_n_chars_long", + "pypika/tests/test_criterions.py::LikeTests::test_like_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_like_starts_with", + "pypika/tests/test_criterions.py::LikeTests::test_not_ilike_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_not_like_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_rlike_escape_chars", + "pypika/tests/test_criterions.py::ExistsCriterionTests::test_exists", + "pypika/tests/test_criterions.py::ExistsCriterionTests::test_not_exists", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__between_and_field", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__between_and_isin", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__nested__and", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__nested__mixed", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__nested__or", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_and", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_function_and", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_function_or", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_function_xor", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_or", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_xor", + "pypika/tests/test_criterions.py::FieldsAsCriterionTests::test__field_and_field", + "pypika/tests/test_criterions.py::FieldsAsCriterionTests::test__field_or_field", + "pypika/tests/test_criterions.py::FieldsAsCriterionTests::test__field_xor_field", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_arithmeticfunction_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_betweencriterion_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_complexcriterion_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_criterion_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_field_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_function_with_only_fields_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_function_with_values_and_fields_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_nullcriterion_replace_table", + "pypika/tests/test_criterions.py::AnyTests::test_multiple_args_returned_in_chain_of_ors", + "pypika/tests/test_criterions.py::AnyTests::test_single_arg_returns_self", + "pypika/tests/test_criterions.py::AnyTests::test_with_generator", + "pypika/tests/test_criterions.py::AnyTests::test_zero_args_returns_empty_criterion", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_different_operations_with_empty_criterion", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_empty_criterion_on_the_left", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_empty_criterion_on_the_right", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_fields_", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_invertion_of_the_empty_criterion", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_more_than_one_empty_criterions", + "pypika/tests/test_criterions.py::AllTests::test_multiple_args_returned_in_chain_of_ors", + "pypika/tests/test_criterions.py::AllTests::test_single_arg_returns_self", + "pypika/tests/test_criterions.py::AllTests::test_with_generator", + "pypika/tests/test_criterions.py::AllTests::test_zero_args_returns_empty_criterion", + "pypika/tests/test_custom_functions.py::TestUnitCustomFunction::test_should_fail_with_wrong_arguments", + "pypika/tests/test_custom_functions.py::TestUnitCustomFunction::test_should_return_function_with_arguments", + "pypika/tests/test_custom_functions.py::TestUnitCustomFunction::test_should_return_function_with_no_arguments", + "pypika/tests/test_custom_functions.py::TestFunctionalCustomFunction::test_should_fail_use_custom_function_on_select_with_wrong_arguments", + "pypika/tests/test_custom_functions.py::TestFunctionalCustomFunction::test_should_use_custom_function_on_select", + "pypika/tests/test_data_types.py::StringTests::test_inline_string_concatentation", + "pypika/tests/test_data_types.py::UuidTests::test_uuid_string_generation", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_day", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_default", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_microsecond", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_minute", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_month", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_quarter", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_second", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_week", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_year", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_day_hour", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_day_microsecond", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_day_minute", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_day_second", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_hour_microsecond", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_hour_minute", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_hour_second", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_minute_microsecond", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_minute_second", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_second_microsecond", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_value_complex_expressions", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_value_right", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_year_month", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_mysql_dialect_uses_single_quotes_around_expression_in_an_interval", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_oracle_dialect_uses_single_quotes_around_expression_in_an_interval", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_postgresql_dialect_uses_single_quotes_around_interval", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_redshift_dialect_uses_single_quotes_around_interval", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_vertica_dialect_uses_single_quotes_around_interval", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_day", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_month", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_week", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_year", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_year_month", + "pypika/tests/test_date_math.py::TruncateTrailingZerosTests::test_do_not_truncate_integer_values", + "pypika/tests/test_date_math.py::TruncateTrailingZerosTests::test_do_not_truncate_months_between_years_and_datys", + "pypika/tests/test_deletes.py::DeleteTests::test_for_portion", + "pypika/tests/test_deletes.py::DeleteTests::test_omit_where", + "pypika/tests/test_deletes.py::DeleteTests::test_omit_where__table_schema", + "pypika/tests/test_deletes.py::DeleteTests::test_where_field_equals", + "pypika/tests/test_deletes.py::PostgresDeleteTests::test_delete_returning", + "pypika/tests/test_deletes.py::PostgresDeleteTests::test_delete_returning_star", + "pypika/tests/test_deletes.py::PostgresDeleteTests::test_delete_returning_str", + "pypika/tests/test_deletes.py::PostgresDeleteTests::test_delete_using", + "pypika/tests/test_drop.py::DropTableTests::test_drop_database", + "pypika/tests/test_drop.py::DropTableTests::test_drop_index", + "pypika/tests/test_drop.py::DropTableTests::test_drop_table", + "pypika/tests/test_drop.py::DropTableTests::test_drop_user", + "pypika/tests/test_drop.py::DropTableTests::test_drop_view", + "pypika/tests/test_formats.py::QuoteTests::test_no_quote_char_in_complex_query", + "pypika/tests/test_formats.py::QuoteTests::test_replace_quote_char_in_complex_query", + "pypika/tests/test_functions.py::FunctionTests::test_dialect_propagation", + "pypika/tests/test_functions.py::FunctionTests::test_is_aggregate_None_for_non_aggregate_function_or_function_with_no_aggregate_functions", + "pypika/tests/test_functions.py::FunctionTests::test_is_aggregate_True_for_aggregate_function_or_function_with_aggregate_functions", + "pypika/tests/test_functions.py::SchemaTests::test_schema_included_in_function_sql", + "pypika/tests/test_functions.py::SchemaTests::test_schema_no_schema_in_sql_when_none_set", + "pypika/tests/test_functions.py::ArithmeticTests::test__addition__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__addition__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__addition__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__addition__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__arithmetic_equality", + "pypika/tests/test_functions.py::ArithmeticTests::test__arithmetic_with_function", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_add_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_div_no_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_div_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_exponent_no_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_exponent_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_floor_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_function_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_modulus_no_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_modulus_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_mul_no_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_mul_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_nested_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_sub_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__division__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__division__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__division__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__division__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__exponent__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__exponent__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__floor", + "pypika/tests/test_functions.py::ArithmeticTests::test__leftshift__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__leftshift__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__leftshift__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__modulus__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__multiplication__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__multiplication__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__multiplication__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__multiplication__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__rightshift__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__rightshift__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__rightshift__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__subtraction__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__subtraction__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__subtraction__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__subtraction__right", + "pypika/tests/test_functions.py::AggregationTests::test__approx_percentile", + "pypika/tests/test_functions.py::AggregationTests::test__avg", + "pypika/tests/test_functions.py::AggregationTests::test__count", + "pypika/tests/test_functions.py::AggregationTests::test__count__star", + "pypika/tests/test_functions.py::AggregationTests::test__first", + "pypika/tests/test_functions.py::AggregationTests::test__last", + "pypika/tests/test_functions.py::AggregationTests::test__max", + "pypika/tests/test_functions.py::AggregationTests::test__min", + "pypika/tests/test_functions.py::AggregationTests::test__std", + "pypika/tests/test_functions.py::AggregationTests::test__stddev", + "pypika/tests/test_functions.py::AggregationTests::test__subquery_in_params_functions", + "pypika/tests/test_functions.py::AggregationTests::test__sum", + "pypika/tests/test_functions.py::ConditionTests::test__case__else", + "pypika/tests/test_functions.py::ConditionTests::test__case__field", + "pypika/tests/test_functions.py::ConditionTests::test__case__multi", + "pypika/tests/test_functions.py::ConditionTests::test__case__no_cases", + "pypika/tests/test_functions.py::ConditionTests::test__case__raw", + "pypika/tests/test_functions.py::StringTests::test__ascii__field", + "pypika/tests/test_functions.py::StringTests::test__ascii__int", + "pypika/tests/test_functions.py::StringTests::test__ascii__str", + "pypika/tests/test_functions.py::StringTests::test__bin__field", + "pypika/tests/test_functions.py::StringTests::test__bin__int", + "pypika/tests/test_functions.py::StringTests::test__bin__str", + "pypika/tests/test_functions.py::StringTests::test__concat__field", + "pypika/tests/test_functions.py::StringTests::test__concat__str", + "pypika/tests/test_functions.py::StringTests::test__insert__field", + "pypika/tests/test_functions.py::StringTests::test__insert__str", + "pypika/tests/test_functions.py::StringTests::test__length__field", + "pypika/tests/test_functions.py::StringTests::test__length__str", + "pypika/tests/test_functions.py::StringTests::test__lower__field", + "pypika/tests/test_functions.py::StringTests::test__lower__str", + "pypika/tests/test_functions.py::StringTests::test__replace__field", + "pypika/tests/test_functions.py::StringTests::test__replace__str", + "pypika/tests/test_functions.py::StringTests::test__substring", + "pypika/tests/test_functions.py::SplitPartFunctionTests::test__split_part", + "pypika/tests/test_functions.py::RegexpLikeFunctionTests::test__regexp_like", + "pypika/tests/test_functions.py::CastTests::test__cast__as", + "pypika/tests/test_functions.py::CastTests::test__cast__binary", + "pypika/tests/test_functions.py::CastTests::test__cast__binary_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__boolean", + "pypika/tests/test_functions.py::CastTests::test__cast__char", + "pypika/tests/test_functions.py::CastTests::test__cast__char_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__date", + "pypika/tests/test_functions.py::CastTests::test__cast__float", + "pypika/tests/test_functions.py::CastTests::test__cast__integer", + "pypika/tests/test_functions.py::CastTests::test__cast__long_varbinary", + "pypika/tests/test_functions.py::CastTests::test__cast__long_varbinary_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__long_varchar", + "pypika/tests/test_functions.py::CastTests::test__cast__long_varchar_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__numeric", + "pypika/tests/test_functions.py::CastTests::test__cast__signed", + "pypika/tests/test_functions.py::CastTests::test__cast__timestamp", + "pypika/tests/test_functions.py::CastTests::test__cast__unsigned", + "pypika/tests/test_functions.py::CastTests::test__cast__varbinary", + "pypika/tests/test_functions.py::CastTests::test__cast__varbinary_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__varchar", + "pypika/tests/test_functions.py::CastTests::test__cast__varchar_with_arg", + "pypika/tests/test_functions.py::CastTests::test__tochar__", + "pypika/tests/test_functions.py::DateFunctionsTests::test_current_date", + "pypika/tests/test_functions.py::DateFunctionsTests::test_current_time", + "pypika/tests/test_functions.py::DateFunctionsTests::test_current_timestamp", + "pypika/tests/test_functions.py::DateFunctionsTests::test_current_timestamp_with_alias", + "pypika/tests/test_functions.py::DateFunctionsTests::test_date_add", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_day", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_hour", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_join", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_microsecond", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_minute", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_month", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_quarter", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_second", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_week", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_year", + "pypika/tests/test_functions.py::DateFunctionsTests::test_now", + "pypika/tests/test_functions.py::DateFunctionsTests::test_time_diff", + "pypika/tests/test_functions.py::DateFunctionsTests::test_timestampadd", + "pypika/tests/test_functions.py::DateFunctionsTests::test_to_date", + "pypika/tests/test_functions.py::DateFunctionsTests::test_utc_timestamp", + "pypika/tests/test_functions.py::NullFunctionsTests::test_coalesce", + "pypika/tests/test_functions.py::NullFunctionsTests::test_isnull", + "pypika/tests/test_functions.py::NullFunctionsTests::test_nullif", + "pypika/tests/test_functions.py::NullFunctionsTests::test_nvl", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_mysql_one_groupby", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_mysql_rollup_two_groupbys", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_no_rollup_after_rollup_mysql", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_no_rollup_before_groupby", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_from_groupbys", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_from_parameters", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_from_two_groupbys", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_func_one_groupby", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_func_partial", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_func_two_groupbys", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_multiple_rollups", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_rollups_with_multiple_rollups_and_parity", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_rollups_with_parity", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_force_index_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_groupby_returns_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_immutable_kwarg_on_query_builder_disables_immutability", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_insert_into_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_join_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_orderby_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_queries_after_join", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_replace_into_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_select_returns_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_update_set_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_use_index_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_with_return_new_query_instance", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_multi_rows", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_multi_rows_chained", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_multi_rows_chained_mixed", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_multi_rows_chained_multiple_rows", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_single_element", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_column_using_alias_with_chain", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_column_using_table_alias", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_empty_columns", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_empty_columns_type_list", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_empty_columns_type_tuple", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_ignore", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_multiple_rows_with_array_value", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_none_skipped", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_null", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_one_column", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_one_column_multi_element_array", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_one_column_single_element_array", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_selected_columns", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_selected_columns_type_list", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_selected_columns_type_tuple", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_single_row_with_array_value", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_with_statement", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_empty_on_conflict_do_update_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_field", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_field_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_mixed_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_multiple_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_multiple_fields_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_field", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_field_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_multiple_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_multiple_fields_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_multiple_mixed_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_no_handler", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_two_handlers_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_two_handlers_do_update", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_fieldless_conflict_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_fieldless_conflict_do_update_field", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_non_insert_on_conflict_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_non_insert_on_conflict_do_update", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_do_nothing_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_do_update_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_do_update_with_excluded_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_from_subquery", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_complex", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_conflict_fields_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_conflict_fields_do_update", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_empty_conflict_fields_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_empty_conflict_fields_do_update", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_where_and_on_conflict_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_all_columns_multi_rows_chained_returning_star", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_all_columns_multi_rows_chained_returning_star_and_id", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_all_columns_multi_rows_chained_returning_star_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_all_columns_single_element_arrays", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_aggregate", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_all_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_all_fields_and_arithmetics", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_arithmetics", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_from_other_table", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_functions", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_null", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_one_field", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_one_field_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_tuple", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_ignore", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multi_rows_chained_mixed_on_duplicate_update_multiple", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_multiple", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_different_value", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_expression", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_expression_using_original_field_value", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_expression_using_values", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_same_value", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_none_skipped", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_one_column", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_one_column_multi_element_array", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_one_column_single_element_array", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_one_column_using_values", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_selected_columns_on_duplicate_update_multiple", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_selected_columns_on_duplicate_update_one", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_columns_from_columns", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_columns_from_columns_with_join", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_columns_from_star", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_from_columns", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_ignore_star", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_star", + "pypika/tests/test_inserts.py::InsertSubqueryTests::test_insert_subquery_wrapped_in_brackets", + "pypika/tests/test_inserts.py::SelectIntoTests::test_select_columns_into", + "pypika/tests/test_inserts.py::SelectIntoTests::test_select_columns_into_with_join", + "pypika/tests/test_inserts.py::SelectIntoTests::test_select_star_into", + "pypika/tests/test_inserts.py::ReplaceTests::test_replace_simple", + "pypika/tests/test_inserts.py::ReplaceTests::test_replace_subquery", + "pypika/tests/test_internals.py::TablesTests::test__case_tables", + "pypika/tests/test_internals.py::TablesTests::test__criterion_replace_table_with_value", + "pypika/tests/test_internals.py::TablesTests::test__star_tables", + "pypika/tests/test_internals.py::TablesTests::test__table_star_tables", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_cross_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_cross_join_on_subquery", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_cross_join_on_table", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_default_join_type", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_full_outer_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_hash_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_inner_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_arithmetic_field", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_collate", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_complex_criteria", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_field_multi", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_field_multi_with_extra_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_field_single", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_field_without_fields_raises_exception", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_subquery_criteria", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_second_table_in_from_clause", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_using_multiple_fields", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_using_string_field_name", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_using_with_quote_char", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_using_without_fields_raises_exception", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_with_arithmetic_function_in_select", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_left_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_left_outer_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_outer_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_right_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_right_outer_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_temporal_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_use_different_table_objects_for_same_table", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_fail_when_joining_unknown_type", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_ignore_table_references", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_immutable__tables", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_from_join", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_query_with_column_alias", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_query_with_setoperation", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_query_with_table_alias", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_query_without_alias", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_same_table", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_same_table_with_prefixes", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_table_twice", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_prefixes_added_to_function_in_orderby", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_prefixes_added_to_groupby", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_prefixes_added_to_orderby", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_require_condition", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_require_condition_with_both_tables", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select__fields_after_table_star", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select__ordered_select_clauses", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select__star_for_table", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select__star_for_table__replacement", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select_field_from_missing_table", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select_fields_with_where", + "pypika/tests/test_joins.py::UnionTests::test_mysql_query_wraps_unioned_queries", + "pypika/tests/test_joins.py::UnionTests::test_require_equal_number_of_fields", + "pypika/tests/test_joins.py::UnionTests::test_union", + "pypika/tests/test_joins.py::UnionTests::test_union_all", + "pypika/tests/test_joins.py::UnionTests::test_union_all_multiple", + "pypika/tests/test_joins.py::UnionTests::test_union_as_subquery", + "pypika/tests/test_joins.py::UnionTests::test_union_multiple", + "pypika/tests/test_joins.py::UnionTests::test_union_with_no_quote_char", + "pypika/tests/test_joins.py::UnionTests::test_union_with_order_by", + "pypika/tests/test_joins.py::UnionTests::test_union_with_order_by_use_union_query_field", + "pypika/tests/test_joins.py::UnionTests::test_union_with_order_by_use_union_query_field_with_aliases", + "pypika/tests/test_joins.py::UnionTests::test_union_with_order_by_with_aliases", + "pypika/tests/test_joins.py::InsertQueryJoinTests::test_join_table_on_insert_query", + "pypika/tests/test_joins.py::UpdateQueryJoinTests::test_join_table_on_update_query", + "pypika/tests/test_joins.py::IntersectTests::test_intersect", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_as_subquery", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_multiple", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_with_limit", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_with_no_quote_char", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_with_offset", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_with_order_by", + "pypika/tests/test_joins.py::IntersectTests::test_mysql_query_wraps_intersected_queries", + "pypika/tests/test_joins.py::IntersectTests::test_require_equal_number_of_fields_intersect", + "pypika/tests/test_joins.py::MinusTests::test_minus", + "pypika/tests/test_joins.py::MinusTests::test_minus_as_subquery", + "pypika/tests/test_joins.py::MinusTests::test_minus_multiple", + "pypika/tests/test_joins.py::MinusTests::test_minus_query_with_order_by_use_minus_query_field", + "pypika/tests/test_joins.py::MinusTests::test_minus_with_no_quote_char", + "pypika/tests/test_joins.py::MinusTests::test_minus_with_order_by", + "pypika/tests/test_joins.py::MinusTests::test_mysql_query_wraps_minus_queries", + "pypika/tests/test_joins.py::MinusTests::test_require_equal_number_of_fields", + "pypika/tests/test_joins.py::ExceptOfTests::test_except", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_as_subquery", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_multiple", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_query_with_order_by_use_minus_query_field", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_with_no_quote_char", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_with_order_by", + "pypika/tests/test_joins.py::ExceptOfTests::test_require_equal_number_of_fields_except_of", + "pypika/tests/test_negation.py::NegationTests::test_negate_field", + "pypika/tests/test_negation.py::NegationTests::test_negate_function", + "pypika/tests/test_negation.py::NegationTests::test_negate_wrapped_float", + "pypika/tests/test_negation.py::NegationTests::test_negate_wrapped_int", + "pypika/tests/test_parameter.py::ParametrizedTests::test_format_parameter", + "pypika/tests/test_parameter.py::ParametrizedTests::test_join", + "pypika/tests/test_parameter.py::ParametrizedTests::test_named_parameter", + "pypika/tests/test_parameter.py::ParametrizedTests::test_numeric_parameter", + "pypika/tests/test_parameter.py::ParametrizedTests::test_param_insert", + "pypika/tests/test_parameter.py::ParametrizedTests::test_param_select_join", + "pypika/tests/test_parameter.py::ParametrizedTests::test_param_select_subquery", + "pypika/tests/test_parameter.py::ParametrizedTests::test_pyformat_parameter", + "pypika/tests/test_parameter.py::ParametrizedTests::test_qmark_parameter", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_join", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_join_with_parameter_value_wrapper", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_param_insert", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_param_select_join", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_param_select_subquery", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_pyformat_parameter", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_can_be_used_in_a_select_statement", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_can_be_used_in_a_where_clause", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_can_be_used_in_orderby", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_column_value", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_object_id", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_object_value", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_row_id", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_row_num", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_sys_date", + "pypika/tests/test_query.py::QueryTablesTests::test_is_joined", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_case_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_delete_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_filter_tables", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_having_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_insert_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_insert_table_current_table_not_match", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_join_tables", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_only_specified_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_orderby_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_tuple_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_update_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_update_table_current_table_not_match", + "pypika/tests/test_query.py::QueryBuilderTests::test_pipe", + "pypika/tests/test_query.py::QueryBuilderTests::test_query_builders_have_reference_to_correct_query_class", + "pypika/tests/test_selects.py::SelectTests::test_empty_query", + "pypika/tests/test_selects.py::SelectTests::test_mssql_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_mysql_query_uses_backtick_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_oracle_query_uses_no_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_postgresql_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_redshift_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_select__column__single__alias__str", + "pypika/tests/test_selects.py::SelectTests::test_select__column__single__field", + "pypika/tests/test_selects.py::SelectTests::test_select__column__single__str", + "pypika/tests/test_selects.py::SelectTests::test_select__column__single__table_alias__str", + "pypika/tests/test_selects.py::SelectTests::test_select__columns__multi__field", + "pypika/tests/test_selects.py::SelectTests::test_select__columns__multi__str", + "pypika/tests/test_selects.py::SelectTests::test_select__distinct__multi", + "pypika/tests/test_selects.py::SelectTests::test_select__distinct__single", + "pypika/tests/test_selects.py::SelectTests::test_select__multiple_subqueries", + "pypika/tests/test_selects.py::SelectTests::test_select__multiple_tables", + "pypika/tests/test_selects.py::SelectTests::test_select__nested_subquery", + "pypika/tests/test_selects.py::SelectTests::test_select__no_table", + "pypika/tests/test_selects.py::SelectTests::test_select__star", + "pypika/tests/test_selects.py::SelectTests::test_select__star__replacement", + "pypika/tests/test_selects.py::SelectTests::test_select__subquery", + "pypika/tests/test_selects.py::SelectTests::test_select__table_schema", + "pypika/tests/test_selects.py::SelectTests::test_select__table_schema_with_multiple_levels_as_list", + "pypika/tests/test_selects.py::SelectTests::test_select__table_schema_with_multiple_levels_as_tuple", + "pypika/tests/test_selects.py::SelectTests::test_select_no_from", + "pypika/tests/test_selects.py::SelectTests::test_select_no_from_with_field_raises_exception", + "pypika/tests/test_selects.py::SelectTests::test_select_no_with_alias_from", + "pypika/tests/test_selects.py::SelectTests::test_select_then_add_table", + "pypika/tests/test_selects.py::SelectTests::test_select_with_force_index", + "pypika/tests/test_selects.py::SelectTests::test_select_with_force_index_multiple_calls", + "pypika/tests/test_selects.py::SelectTests::test_select_with_force_index_multiple_indexes", + "pypika/tests/test_selects.py::SelectTests::test_select_with_force_index_with_index_object", + "pypika/tests/test_selects.py::SelectTests::test_select_with_limit", + "pypika/tests/test_selects.py::SelectTests::test_select_with_limit__func", + "pypika/tests/test_selects.py::SelectTests::test_select_with_limit_and_offset", + "pypika/tests/test_selects.py::SelectTests::test_select_with_limit_zero", + "pypika/tests/test_selects.py::SelectTests::test_select_with_offset", + "pypika/tests/test_selects.py::SelectTests::test_select_with_offset__func", + "pypika/tests/test_selects.py::SelectTests::test_select_with_use_index", + "pypika/tests/test_selects.py::SelectTests::test_select_with_use_index_multiple_calls", + "pypika/tests/test_selects.py::SelectTests::test_select_with_use_index_multiple_indexes", + "pypika/tests/test_selects.py::SelectTests::test_select_with_use_index_with_index_object", + "pypika/tests/test_selects.py::SelectTests::test_table_select_alias", + "pypika/tests/test_selects.py::SelectTests::test_table_select_alias_with_offset_and_limit", + "pypika/tests/test_selects.py::SelectTests::test_temporal_select", + "pypika/tests/test_selects.py::SelectTests::test_vertica_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::WhereTests::test_ignore_empty_criterion_having", + "pypika/tests/test_selects.py::WhereTests::test_ignore_empty_criterion_where", + "pypika/tests/test_selects.py::WhereTests::test_select_with_force_index_and_where", + "pypika/tests/test_selects.py::WhereTests::test_where_enum", + "pypika/tests/test_selects.py::WhereTests::test_where_field_contains", + "pypika/tests/test_selects.py::WhereTests::test_where_field_does_not_contain", + "pypika/tests/test_selects.py::WhereTests::test_where_field_does_not_end_with", + "pypika/tests/test_selects.py::WhereTests::test_where_field_does_not_start_with", + "pypika/tests/test_selects.py::WhereTests::test_where_field_ends_with", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_and", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_nowait", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_of", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_of_multiple_tables", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_of_nowait", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_of_skip_locked", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_skip_locked", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_skip_locked_and_of", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_or", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_where", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_where_not", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_where_two_not", + "pypika/tests/test_selects.py::WhereTests::test_where_field_is_n_chars_long", + "pypika/tests/test_selects.py::WhereTests::test_where_field_is_not_n_chars_long", + "pypika/tests/test_selects.py::WhereTests::test_where_field_matches_regex", + "pypika/tests/test_selects.py::WhereTests::test_where_field_matches_regexp", + "pypika/tests/test_selects.py::WhereTests::test_where_field_matches_rlike", + "pypika/tests/test_selects.py::WhereTests::test_where_field_starts_with", + "pypika/tests/test_selects.py::WhereTests::test_where_nested_conditions", + "pypika/tests/test_selects.py::WhereTests::test_where_single_quote", + "pypika/tests/test_selects.py::WhereTests::test_where_with_multiple_wheres_using_and_case", + "pypika/tests/test_selects.py::WhereTests::test_where_with_multiple_wheres_using_or_case", + "pypika/tests/test_selects.py::PreWhereTests::test_ignore_empty_criterion_having", + "pypika/tests/test_selects.py::PreWhereTests::test_ignore_empty_criterion_where", + "pypika/tests/test_selects.py::PreWhereTests::test_prewhere_field_equals", + "pypika/tests/test_selects.py::PreWhereTests::test_select_with_force_index_and_where", + "pypika/tests/test_selects.py::PreWhereTests::test_where_and_prewhere", + "pypika/tests/test_selects.py::PreWhereTests::test_where_enum", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_contains", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_does_not_contain", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_does_not_end_with", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_does_not_start_with", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_ends_with", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_and", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_nowait", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_of", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_of_multiple_tables", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_of_nowait", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_of_skip_locked", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_skip_locked", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_skip_locked_and_of", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_or", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_where", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_where_not", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_where_two_not", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_is_n_chars_long", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_is_not_n_chars_long", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_matches_regex", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_matches_regexp", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_matches_rlike", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_starts_with", + "pypika/tests/test_selects.py::PreWhereTests::test_where_nested_conditions", + "pypika/tests/test_selects.py::PreWhereTests::test_where_single_quote", + "pypika/tests/test_selects.py::PreWhereTests::test_where_with_multiple_wheres_using_and_case", + "pypika/tests/test_selects.py::PreWhereTests::test_where_with_multiple_wheres_using_or_case", + "pypika/tests/test_selects.py::GroupByTests::test_group_by__single_with_totals", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__alias", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__alias_platforms", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__alias_with_join", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__count_distinct", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__count_field", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__count_star", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__int", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__multi", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__multi_with_totals", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__no_alias", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__no_alias_mssql", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__no_alias_oracle", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__single", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__str", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__sum_distinct", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__sum_filter", + "pypika/tests/test_selects.py::GroupByTests::test_groupby_with_case_uses_the_alias", + "pypika/tests/test_selects.py::GroupByTests::test_mssql_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_mysql_query_uses_backtick_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_oracle_query_uses_no_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_postgres_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_redshift_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_vertica_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_having_and", + "pypika/tests/test_selects.py::HavingTests::test_having_greater_than", + "pypika/tests/test_selects.py::HavingTests::test_having_join_and_equality", + "pypika/tests/test_selects.py::HavingTests::test_mssql_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_mysql_query_uses_backtick_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_oracle_query_uses_no_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_postgres_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_redshift_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_vertica_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_alias", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_asc", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_desc", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_multi_fields", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_no_alias", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_single_field", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_single_str", + "pypika/tests/test_selects.py::AliasTests::test_arithmetic_function", + "pypika/tests/test_selects.py::AliasTests::test_case_using_as", + "pypika/tests/test_selects.py::AliasTests::test_case_using_constructor_param", + "pypika/tests/test_selects.py::AliasTests::test_function_using_as_nested", + "pypika/tests/test_selects.py::AliasTests::test_functions_using_as", + "pypika/tests/test_selects.py::AliasTests::test_functions_using_constructor_param", + "pypika/tests/test_selects.py::AliasTests::test_functions_using_constructor_param_nested", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_criterion", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_criterion_comparison", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_field_inside_case", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_groupby", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_orderby", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_where", + "pypika/tests/test_selects.py::AliasTests::test_null_value_with_alias", + "pypika/tests/test_selects.py::AliasTests::test_select__multiple_tables", + "pypika/tests/test_selects.py::AliasTests::test_table_field", + "pypika/tests/test_selects.py::AliasTests::test_table_field__multi", + "pypika/tests/test_selects.py::AliasTests::test_table_with_schema_and_alias", + "pypika/tests/test_selects.py::AliasTests::test_use_aliases_in_groupby_and_orderby", + "pypika/tests/test_selects.py::SubqueryTests::test_from_subquery_without_alias", + "pypika/tests/test_selects.py::SubqueryTests::test_join", + "pypika/tests/test_selects.py::SubqueryTests::test_join_query_with_alias", + "pypika/tests/test_selects.py::SubqueryTests::test_join_with_with", + "pypika/tests/test_selects.py::SubqueryTests::test_select_from_nested_query", + "pypika/tests/test_selects.py::SubqueryTests::test_select_from_nested_query_with_join", + "pypika/tests/test_selects.py::SubqueryTests::test_select_from_with_returning", + "pypika/tests/test_selects.py::SubqueryTests::test_select_subquery", + "pypika/tests/test_selects.py::SubqueryTests::test_select_subquery_with_alias", + "pypika/tests/test_selects.py::SubqueryTests::test_where__equality", + "pypika/tests/test_selects.py::SubqueryTests::test_where__in", + "pypika/tests/test_selects.py::SubqueryTests::test_where__in_nested", + "pypika/tests/test_selects.py::SubqueryTests::test_with", + "pypika/tests/test_selects.py::QuoteTests::test_extraneous_quotes", + "pypika/tests/test_tables.py::TableStructureTests::test_database_schema_table_attr", + "pypika/tests/test_tables.py::TableStructureTests::test_schema_table_attr", + "pypika/tests/test_tables.py::TableStructureTests::test_table_for_period_sql", + "pypika/tests/test_tables.py::TableStructureTests::test_table_for_system_time_sql", + "pypika/tests/test_tables.py::TableStructureTests::test_table_sql", + "pypika/tests/test_tables.py::TableStructureTests::test_table_with_alias", + "pypika/tests/test_tables.py::TableStructureTests::test_table_with_schema_and_schema_parent_arg", + "pypika/tests/test_tables.py::TableStructureTests::test_table_with_schema_arg", + "pypika/tests/test_tables.py::TableEqualityTests::test_many_tables_with_alias", + "pypika/tests/test_tables.py::TableEqualityTests::test_many_tables_with_or_not_alias", + "pypika/tests/test_tables.py::TableEqualityTests::test_many_tables_without_alias", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_equal_by_name", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_equal_by_schema_and_name", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_equal_by_schema_and_name_using_schema", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_equal_by_schema_and_name_using_schema_with_parent", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_not_equal_by_schema_and_name_using_schema_with_different_parents", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_not_equal_with_different_names", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_not_equal_with_different_schemas", + "pypika/tests/test_tables.py::TableDialectTests::test_make_tables_factory_with_default_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_make_tables_factory_with_dialect_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_factory_with_default_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_factory_with_dialect_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_with_bad_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_with_default_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_with_dialect_query_cls", + "pypika/tests/test_terms.py::FieldAliasTests::test_when_alias_specified", + "pypika/tests/test_terms.py::FieldInitTests::test_init_with_str_table", + "pypika/tests/test_terms.py::FieldHashingTests::test_non_tabled_aliased_eq_fields_equally_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_non_tabled_aliased_ne_fields_differently_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_non_tabled_eq_fields_equally_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_non_tabled_ne_fields_differently_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_tabled_eq_fields_equally_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_tabled_ne_fields_differently_hashed", + "pypika/tests/test_terms.py::AtTimezoneTests::test_passes_kwargs_to_field_get_sql", + "pypika/tests/test_terms.py::AtTimezoneTests::test_when_alias_specified", + "pypika/tests/test_terms.py::AtTimezoneTests::test_when_interval_not_specified", + "pypika/tests/test_terms.py::AtTimezoneTests::test_when_interval_specified", + "pypika/tests/test_tuples.py::TupleTests::test_render_alias_in_array_sql", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_equality_tuple_on_both", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_equality_tuple_on_left", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_equality_tuple_on_right", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_in_using_mixed_tuples", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_in_using_pypika_tuples", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_in_using_python_tuples", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_is_aggregate", + "pypika/tests/test_tuples.py::TupleTests::test_tuples_in_join", + "pypika/tests/test_tuples.py::ArrayTests::test_array_general", + "pypika/tests/test_tuples.py::ArrayTests::test_empty_psql_array", + "pypika/tests/test_tuples.py::ArrayTests::test_psql_array_general", + "pypika/tests/test_tuples.py::ArrayTests::test_render_alias_in_array_sql", + "pypika/tests/test_tuples.py::BracketTests::test_arithmetic_with_brackets", + "pypika/tests/test_tuples.py::BracketTests::test_arithmetic_with_brackets_and_alias", + "pypika/tests/test_updates.py::UpdateTests::test_empty_query", + "pypika/tests/test_updates.py::UpdateTests::test_for_portion", + "pypika/tests/test_updates.py::UpdateTests::test_omit_where", + "pypika/tests/test_updates.py::UpdateTests::test_single_quote_escape_in_set", + "pypika/tests/test_updates.py::UpdateTests::test_update__table_schema", + "pypika/tests/test_updates.py::UpdateTests::test_update_from", + "pypika/tests/test_updates.py::UpdateTests::test_update_from_with_where", + "pypika/tests/test_updates.py::UpdateTests::test_update_with_join", + "pypika/tests/test_updates.py::UpdateTests::test_update_with_limit", + "pypika/tests/test_updates.py::UpdateTests::test_update_with_none", + "pypika/tests/test_updates.py::UpdateTests::test_update_with_statement", + "pypika/tests/test_updates.py::PostgresUpdateTests::test_update_returning", + "pypika/tests/test_updates.py::PostgresUpdateTests::test_update_returning_from_different_tables", + "pypika/tests/test_updates.py::PostgresUpdateTests::test_update_returning_star", + "pypika/tests/test_updates.py::PostgresUpdateTests::test_update_returning_str", + "pypika/tests/test_updates.py::SQLLiteUpdateTests::test_update_with_bool", + "pypika/tests/test_utils.py::ImmutabilityTests::test_raise_attribute_error_for_deepcopy", + "pypika/tests/test_utils.py::ImmutabilityTests::test_raise_attribute_error_for_getnewargs", + "pypika/tests/test_utils.py::ImmutabilityTests::test_raise_attribute_error_for_getstate", + "pypika/tests/test_utils.py::ImmutabilityTests::test_raise_attribute_error_for_setstate" + ], + "all_git_blobs_modes_verified": true, + "cloud_launch_ready": false, + "commits": { + "bug": "58da3adb7eff81c8b75e171d2444267fba42acf4", + "healthy": "6a742f12bfa386994289ec8b75824663d8ee4b15", + "learner": "07559ce0cc1e9b57ef34282c9f8294eb79d960f2" + }, + "existing_squirrel_snapshot_reused": false, + "full_transfer_allowlist": [ + "/testbed/.coveragerc", + "/testbed/.gitignore", + "/testbed/.pre-commit-config.yaml", + "/testbed/CODEOWNERS", + "/testbed/CONTRIBUTING.rst", + "/testbed/LICENSE.txt", + "/testbed/MANIFEST.in", + "/testbed/Makefile", + "/testbed/README.rst", + "/testbed/docs/1_installation.rst", + "/testbed/docs/2_tutorial.rst", + "/testbed/docs/3_advanced.rst", + "/testbed/docs/4_extending.rst", + "/testbed/docs/5_reference.rst", + "/testbed/docs/6_contributing.rst", + "/testbed/docs/Makefile", + "/testbed/docs/api/pypika.analytics.rst", + "/testbed/docs/api/pypika.dialects.rst", + "/testbed/docs/api/pypika.enums.rst", + "/testbed/docs/api/pypika.functions.rst", + "/testbed/docs/api/pypika.pseudocolumns.rst", + "/testbed/docs/api/pypika.queries.rst", + "/testbed/docs/api/pypika.rst", + "/testbed/docs/api/pypika.terms.rst", + "/testbed/docs/api/pypika.utils.rst", + "/testbed/docs/conf.py", + "/testbed/docs/index.rst", + "/testbed/pypika/__init__.py", + "/testbed/pypika/analytics.py", + "/testbed/pypika/clickhouse/__init__.py", + "/testbed/pypika/clickhouse/array.py", + "/testbed/pypika/clickhouse/condition.py", + "/testbed/pypika/clickhouse/dates_and_times.py", + "/testbed/pypika/clickhouse/nullable_arg.py", + "/testbed/pypika/clickhouse/search_string.py", + "/testbed/pypika/clickhouse/type_conversion.py", + "/testbed/pypika/dialects.py", + "/testbed/pypika/enums.py", + "/testbed/pypika/functions.py", + "/testbed/pypika/pseudocolumns.py", + "/testbed/pypika/py.typed", + "/testbed/pypika/queries.py", + "/testbed/pypika/terms.py", + "/testbed/pypika/tests/__init__.py", + "/testbed/pypika/tests/clickhouse/__init__.py", + "/testbed/pypika/tests/clickhouse/test_array.py", + "/testbed/pypika/tests/clickhouse/test_dates_and_times.py", + "/testbed/pypika/tests/clickhouse/test_nullable_arg.py", + "/testbed/pypika/tests/clickhouse/test_type_conversion.py", + "/testbed/pypika/tests/dialects/__init__.py", + "/testbed/pypika/tests/dialects/test_clickhouse.py", + "/testbed/pypika/tests/dialects/test_mssql.py", + "/testbed/pypika/tests/dialects/test_mysql.py", + "/testbed/pypika/tests/dialects/test_oracle.py", + "/testbed/pypika/tests/dialects/test_postgresql.py", + "/testbed/pypika/tests/dialects/test_snowflake.py", + "/testbed/pypika/tests/dialects/test_sqllite.py", + "/testbed/pypika/tests/dialects/test_vertica.py", + "/testbed/pypika/tests/test_aggregate.py", + "/testbed/pypika/tests/test_analytic_queries.py", + "/testbed/pypika/tests/test_create.py", + "/testbed/pypika/tests/test_criterions.py", + "/testbed/pypika/tests/test_custom_functions.py", + "/testbed/pypika/tests/test_data_types.py", + "/testbed/pypika/tests/test_date_math.py", + "/testbed/pypika/tests/test_deletes.py", + "/testbed/pypika/tests/test_drop.py", + "/testbed/pypika/tests/test_formats.py", + "/testbed/pypika/tests/test_functions.py", + "/testbed/pypika/tests/test_groupby_modifiers.py", + "/testbed/pypika/tests/test_immutability.py", + "/testbed/pypika/tests/test_inserts.py", + "/testbed/pypika/tests/test_internals.py", + "/testbed/pypika/tests/test_joins.py", + "/testbed/pypika/tests/test_negation.py", + "/testbed/pypika/tests/test_parameter.py", + "/testbed/pypika/tests/test_pseudocolumns.py", + "/testbed/pypika/tests/test_query.py", + "/testbed/pypika/tests/test_selects.py", + "/testbed/pypika/tests/test_tables.py", + "/testbed/pypika/tests/test_terms.py", + "/testbed/pypika/tests/test_tuples.py", + "/testbed/pypika/tests/test_updates.py", + "/testbed/pypika/tests/test_utils.py", + "/testbed/pypika/utils.py", + "/testbed/pyproject.toml", + "/testbed/requirements-dev.txt", + "/testbed/setup.cfg", + "/testbed/setup.py", + "/testbed/tox.ini" + ], + "healthy_stage_meaning": "Direct parent of the mutation; no source or test execution has been performed", + "mutation_matches_dataset_and_git_blobs": true, + "official_profile": { + "eval_sets": [], + "profile_class": "Pypika1c9646f0", + "profile_lines": [ + 736, + 739 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "upstream_repo": "kayak/pypika" + }, + "original_source_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "private_test_paths": [ + "pypika/tests/clickhouse/test_condition.py", + "pypika/tests/clickhouse/test_search_string.py" + ], + "private_tests_unchanged": true, + "profile_mapping_basis": "Explicit upstream repo and full commit fields parsed from pinned official Python profile AST, not basename inference", + "qwen_calibrated": false, + "runtime_qualified": false, + "source_paths": [ + "pypika/clickhouse/condition.py", + "pypika/clickhouse/search_string.py" + ], + "source_repo": "swesmith/kayak__pypika.1c9646f0", + "source_stages_bytes": 1893288, + "task_id": "kayak__pypika.1c9646f0.combine_module__rbtcd9k8", + "transfer_limitation": "Existing regular files only; new arbitrary file additions need a qualified patch adapter", + "upstream_repo": "kayak/pypika" + }, + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:kayak__pypika.1c9646f0.combine_module__rbtcd9k8", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "6a742f12bfa386994289ec8b75824663d8ee4b15", + "instruction_sha256": "3c0e9d5bac4d3878fdb829e8a56201c4070181669738b5f00e2293f3c5da8c26", + "is_fork": true, + "learner_path": "tasks/669f7b6aa8c0c39d7bb06817/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "actual_upstream_url": "https://raw.githubusercontent.com/kayak/pypika/1c9646f0a019a167c32b649b6f5e6423c5ba2c9b/LICENSE.txt", + "reviewed": true, + "sha256": "c5accbbd8546e94c34aed24afe689a617627d18eed5a6c48277e48db57c23851", + "spdx": "Apache-2.0", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/kayak__pypika.1c9646f0/07559ce0cc1e9b57ef34282c9f8294eb79d960f2/LICENSE.txt" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "patch_sha256": "fb2c262357e344f35065aaed4f472f9e1008fe8c9bf6a84bfb2b080689916cb3", + "provenance_path": "tasks/669f7b6aa8c0c39d7bb06817/source-proof.json", + "repository_lineage": [ + "swesmith/kayak__pypika.1c9646f0", + "kayak/pypika" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "07559ce0cc1e9b57ef34282c9f8294eb79d960f2", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "58da3adb7eff81c8b75e171d2444267fba42acf4", + "source_kind": "mutation", + "source_repo": "swesmith/kayak__pypika.1c9646f0", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "kayak__pypika.1c9646f0.combine_module__rbtcd9k8", + "task_sha256": "e4e61f593cfa3446ac9953bf6481c2c91e8217f2e11fa1779a6028ab8af9da77", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "kayak/pypika", + "usage": "quarantine_only" + }, + "task_kind": "original-source-mutation" +} diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/provenance.json b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/provenance.json new file mode 100644 index 0000000000000000000000000000000000000000..8eae7c0bef84cd064b5003e6c5b9a0b5537c26fc --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/provenance.json @@ -0,0 +1,88 @@ +{ + "generated_reference": false, + "healthy_reference_delta_sha256": "98884393d0c5d6d37bd153f0947d86c06fb12676889b0f60a0c887a7dc85bd6a", + "native_pytest_ids_preserved": true, + "original_source_code_license": { + "actual_upstream_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "actual_upstream_url": "https://raw.githubusercontent.com/kayak/pypika/1c9646f0a019a167c32b649b6f5e6423c5ba2c9b/LICENSE.txt", + "reviewed": true, + "sha256": "c5accbbd8546e94c34aed24afe689a617627d18eed5a6c48277e48db57c23851", + "spdx": "Apache-2.0", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/kayak__pypika.1c9646f0/07559ce0cc1e9b57ef34282c9f8294eb79d960f2/LICENSE.txt" + }, + "provided_reference": true, + "qwen_calibrated": false, + "runtime_qualified": false, + "source_completion_sha256": "a3694b4c02cc28c7a4b32f5bf57c892980d5a0da3d654a3610a1de38c9002a30", + "source_index_sha256": "e856874b9410fce9f3bfea52c8c482e84b3e43942d87517f8b55f0034bd40f6f", + "source_proof_sha256": "61deb04614e5e889308e0c0c1a28b01d9643a226d24e10fe5bb3cdfd7ec2ef26", + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:kayak__pypika.1c9646f0.combine_module__rbtcd9k8", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "6a742f12bfa386994289ec8b75824663d8ee4b15", + "instruction_sha256": "3c0e9d5bac4d3878fdb829e8a56201c4070181669738b5f00e2293f3c5da8c26", + "is_fork": true, + "learner_path": "tasks/669f7b6aa8c0c39d7bb06817/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "actual_upstream_url": "https://raw.githubusercontent.com/kayak/pypika/1c9646f0a019a167c32b649b6f5e6423c5ba2c9b/LICENSE.txt", + "reviewed": true, + "sha256": "c5accbbd8546e94c34aed24afe689a617627d18eed5a6c48277e48db57c23851", + "spdx": "Apache-2.0", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/kayak__pypika.1c9646f0/07559ce0cc1e9b57ef34282c9f8294eb79d960f2/LICENSE.txt" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "patch_sha256": "fb2c262357e344f35065aaed4f472f9e1008fe8c9bf6a84bfb2b080689916cb3", + "provenance_path": "tasks/669f7b6aa8c0c39d7bb06817/source-proof.json", + "repository_lineage": [ + "swesmith/kayak__pypika.1c9646f0", + "kayak/pypika" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "07559ce0cc1e9b57ef34282c9f8294eb79d960f2", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "58da3adb7eff81c8b75e171d2444267fba42acf4", + "source_kind": "mutation", + "source_repo": "swesmith/kayak__pypika.1c9646f0", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "kayak__pypika.1c9646f0.combine_module__rbtcd9k8", + "task_sha256": "e4e61f593cfa3446ac9953bf6481c2c91e8217f2e11fa1779a6028ab8af9da77", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "kayak/pypika", + "usage": "quarantine_only" + }, + "task_bundle_license": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + }, + "training_admissible": false, + "trusted_tests_sha256": "f2d0a1b335176a755d627907f32ef330383cf624ff3af2c5ea84ba2b6a2d7ebb" +} diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/provided-gold.diff b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/provided-gold.diff new file mode 100644 index 0000000000000000000000000000000000000000..5f600ebbc696829aec38a7bbe560372bac64ad9a --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/provided-gold.diff @@ -0,0 +1,62 @@ +diff --git a/pypika/clickhouse/condition.py b/pypika/clickhouse/condition.py +index 46e2a0b8303c07f1d6b6d77b7f6d131ad3d8da3a..ed08224e22fb27eb18876595a542dcd3ad14bffc 100644 +--- a/pypika/clickhouse/condition.py ++++ b/pypika/clickhouse/condition.py +@@ -3,9 +3,9 @@ + + class If(Function): + def __init__(self, *conditions, **kwargs): +- super().__init__("switch", *reversed(conditions), **kwargs) ++ super().__init__("if", *conditions, **kwargs) + + + class MultiIf(Function): + def __init__(self, *conditions, **kwargs): +- super().__init__("multiIf", *conditions[::-1], **kwargs) ++ super().__init__("multiIf", *conditions, **kwargs) +diff --git a/pypika/clickhouse/search_string.py b/pypika/clickhouse/search_string.py +index 6fadbced1008bb922ef4d74873b8180191f95c9f..22a03027fcaf3ca0578e63980c00f4be1b2f67e7 100644 +--- a/pypika/clickhouse/search_string.py ++++ b/pypika/clickhouse/search_string.py +@@ -51,9 +51,9 @@ + + class _AbstractMultiSearchString(Function, metaclass=abc.ABCMeta): + def __init__(self, name, patterns: list, alias: str = None): +- super(_AbstractMultiSearchString, self).__init__(self, name, alias=alias) ++ super(_AbstractMultiSearchString, self).__init__(self.clickhouse_function(), name, alias=alias) + +- self._patterns = patterns[::-1] ++ self._patterns = patterns + + @classmethod + @abc.abstractmethod +@@ -64,13 +64,13 @@ + args = [] + for p in self.args: + if hasattr(p, "get_sql"): +- args.append('toString("{arg}")'.format(arg=p.get_sql(with_alias=True, **kwargs))) ++ args.append('toString("{arg}")'.format(arg=p.get_sql(with_alias=False, **kwargs))) + else: + args.append(str(p)) + +- sql = "{name}({args},{{patterns}})".format( ++ sql = "{name}({args},[{patterns}])".format( + name=self.name, +- args=";".join(args), ++ args=",".join(args), + patterns=",".join(["'%s'" % i for i in self._patterns]), + ) + return format_alias_sql(sql, self.alias, **kwargs) +@@ -79,10 +79,10 @@ + class MultiSearchAny(_AbstractMultiSearchString): + @classmethod + def clickhouse_function(cls) -> str: +- return "singleSearchAll" ++ return "multiSearchAny" + + + class MultiMatchAny(_AbstractMultiSearchString): + @classmethod + def clickhouse_function(cls) -> str: +- return "multiMatchAll" ++ return "multiMatchAny" diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/solution/solve.sh b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..548d4003ba47fd5beec37999f5dcd182ebd4a464 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/solution/solve.sh @@ -0,0 +1,68 @@ +#!/bin/bash +set -Eeuo pipefail +cd /testbed/repo +cat > /tmp/openenv-reference.diff <<'OPENENV_REFERENCE' +diff --git a/pypika/clickhouse/condition.py b/pypika/clickhouse/condition.py +index 46e2a0b8303c07f1d6b6d77b7f6d131ad3d8da3a..ed08224e22fb27eb18876595a542dcd3ad14bffc 100644 +--- a/pypika/clickhouse/condition.py ++++ b/pypika/clickhouse/condition.py +@@ -3,9 +3,9 @@ + + class If(Function): + def __init__(self, *conditions, **kwargs): +- super().__init__("switch", *reversed(conditions), **kwargs) ++ super().__init__("if", *conditions, **kwargs) + + + class MultiIf(Function): + def __init__(self, *conditions, **kwargs): +- super().__init__("multiIf", *conditions[::-1], **kwargs) ++ super().__init__("multiIf", *conditions, **kwargs) +diff --git a/pypika/clickhouse/search_string.py b/pypika/clickhouse/search_string.py +index 6fadbced1008bb922ef4d74873b8180191f95c9f..22a03027fcaf3ca0578e63980c00f4be1b2f67e7 100644 +--- a/pypika/clickhouse/search_string.py ++++ b/pypika/clickhouse/search_string.py +@@ -51,9 +51,9 @@ + + class _AbstractMultiSearchString(Function, metaclass=abc.ABCMeta): + def __init__(self, name, patterns: list, alias: str = None): +- super(_AbstractMultiSearchString, self).__init__(self, name, alias=alias) ++ super(_AbstractMultiSearchString, self).__init__(self.clickhouse_function(), name, alias=alias) + +- self._patterns = patterns[::-1] ++ self._patterns = patterns + + @classmethod + @abc.abstractmethod +@@ -64,13 +64,13 @@ + args = [] + for p in self.args: + if hasattr(p, "get_sql"): +- args.append('toString("{arg}")'.format(arg=p.get_sql(with_alias=True, **kwargs))) ++ args.append('toString("{arg}")'.format(arg=p.get_sql(with_alias=False, **kwargs))) + else: + args.append(str(p)) + +- sql = "{name}({args},{{patterns}})".format( ++ sql = "{name}({args},[{patterns}])".format( + name=self.name, +- args=";".join(args), ++ args=",".join(args), + patterns=",".join(["'%s'" % i for i in self._patterns]), + ) + return format_alias_sql(sql, self.alias, **kwargs) +@@ -79,10 +79,10 @@ + class MultiSearchAny(_AbstractMultiSearchString): + @classmethod + def clickhouse_function(cls) -> str: +- return "singleSearchAll" ++ return "multiSearchAny" + + + class MultiMatchAny(_AbstractMultiSearchString): + @classmethod + def clickhouse_function(cls) -> str: +- return "multiMatchAll" ++ return "multiMatchAny" +OPENENV_REFERENCE +/usr/bin/git -c core.hooksPath=/dev/null -c core.fsmonitor=false apply --whitespace=nowarn /tmp/openenv-reference.diff diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/task.toml b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..6739f75415fab50ec40fb0c97b0dc0cfa7f648ae --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/task.toml @@ -0,0 +1,24 @@ +version = "1.0" + +[agent] +timeout_sec = 1800.0 + +[verifier] +timeout_sec = 900.0 + +[environment] +docker_image = "ghcr.io/younesbelkada/scale800@sha256:86a3518d920f8eb866f8aa7d05f52290e3b5f034ad9a545bca34f2faa5d41912" +build_timeout_sec = 600.0 +cpus = 2 +memory_mb = 8192 +storage_mb = 16384 + +[metadata] +author_name = "SWE-smith source adapter" +category = "bugfix" +tags = ["swe", "python", "mutation-repair"] + +[environment.env] +# The image's PATH with the testbed env first: the project and pytest are installed there, and the agent's +# non-interactive shells never run `conda activate` +PATH = "/opt/miniconda3/envs/testbed/bin:/opt/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/check_pytest.py b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/check_pytest.py new file mode 100644 index 0000000000000000000000000000000000000000..7abfdc5972f57ca7f0cecbbeeb373414670f780e --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/check_pytest.py @@ -0,0 +1,177 @@ +"""Preserve confirmed requested assertion failures; keep positive checks strict.""" + +import argparse +import hashlib +import json +import re +import xml.etree.ElementTree as ET +from pathlib import Path + +GROUPS = ("pass-to-pass", "fail-to-pass") + + +def split_nodeid(target): + prefix, bracket, parameter = target.partition("[") + parts = prefix.split("::") + if bracket: + parts[-1] += bracket + parameter + return parts + + +def matches(case, target): + parts = split_nodeid(target) + module = parts[0].removesuffix(".py").replace("/", ".") + classname, name = case.get("classname", ""), case.get("name", "") + if not (classname == module or classname.startswith(module + ".")): + return False + selector = parts[-1] if len(parts) > 1 else "" + classes = parts[1:-1] + if classes and classname != module + "." + ".".join(classes): + return False + return ( + not selector + or name == selector + or ("[" not in selector and name.startswith(selector + "[")) + ) + + +def capture_panels(root): + panels, digests = {}, {} + for group in GROUPS: + path = Path(root) / (group + ".xml") + if not path.exists(): + panels[group] = None + continue + with path.open("rb") as stream: + raw = stream.read(4 * 1024**2 + 1) + if not 0 < len(raw) <= 4 * 1024**2 or re.search( + rb" 20000: + raise ValueError("Too many pytest cases") + identities = [(case.get("classname"), case.get("name")) for case in cases] + if len(identities) != len(set(identities)): + raise ValueError("Duplicate pytest case evidence") + panels[group] = cases + digests[group] = hashlib.sha256(raw).hexdigest() + return panels, digests + + +def strict_assess(panels, expected, native_exit): + """The original positive-approval conditions, applied to captured cases.""" + all_cases, actual_failure = [], False + for group in GROUPS: + cases = panels[group] + if cases is None: + if actual_failure: + continue + raise ValueError("Missing preceding pytest panel") + if actual_failure: + raise ValueError( + "Pytest evidence continued after the native stop-on-failure" + ) + targets = expected[group] + if any(not any(matches(case, target) for target in targets) for case in cases): + raise ValueError("Unexpected pytest case") + all_cases.extend(cases) + failures = [case for case in cases if case.find("failure") is not None] + if any( + case.find("error") is not None or case.find("skipped") is not None + for case in cases + ): + raise ValueError("Pytest collection/error/skip is not a completed panel") + actual_failure = actual_failure or bool(failures) + if not failures and any( + not any(matches(case, target) for case in cases) for target in targets + ): + raise ValueError("Declared pytest target never ran") + if actual_failure: + if native_exit == 0: + raise ValueError("Native verifier exit disagrees with pytest failure") + return {"reward": 0, "valid_test_failure": True, "cases": len(all_cases)} + if native_exit != 0: + raise ValueError("Setup or native verifier failed without a real test failure") + if any(panels[group] is None for group in GROUPS): + raise ValueError("Missing completed pytest panel") + return {"reward": 1, "valid_test_failure": False, "cases": len(all_cases)} + + +def assess(root, expected, native_exit): + if type(native_exit) is not int: + raise ValueError("Native verifier exit must be an integer") + if not isinstance(expected, dict) or any( + not isinstance(expected.get(group), list) + or not expected[group] + or any(not isinstance(target, str) or not target for target in expected[group]) + for group in GROUPS + ): + raise ValueError("Complete exact native pytest targets required") + panels, digests = capture_panels(root) + counts = { + "cases": 0, + "matched_failures": 0, + "unexpected_cases": 0, + "unmatched_failures": 0, + "skipped_cases": 0, + "error_cases": 0, + "missing_panels": 0, + "missing_targets": 0, + } + for group in GROUPS: + cases = panels[group] + if cases is None: + counts["missing_panels"] += 1 + counts["missing_targets"] += len(expected[group]) + continue + counts["cases"] += len(cases) + for case in cases: + requested = any(matches(case, target) for target in expected[group]) + failure = case.find("failure") is not None + counts["matched_failures"] += int(requested and failure) + counts["unmatched_failures"] += int(not requested and failure) + counts["unexpected_cases"] += int(not requested) + counts["skipped_cases"] += int(case.find("skipped") is not None) + counts["error_cases"] += int(case.find("error") is not None) + counts["missing_targets"] += sum( + not any(matches(case, target) for case in cases) + for target in expected[group] + ) + if counts["matched_failures"]: + if native_exit == 0: + raise ValueError( + "Native verifier exit disagrees with requested pytest failure" + ) + return { + "reward": 0, + "valid_test_failure": True, + "cases": counts["cases"], + "diagnostic_counts": counts, + "panel_sha256": digests, + "decision": "confirmed_requested_failure_precedence", + } + result = strict_assess(panels, expected, native_exit) + result.update(diagnostic_counts=counts, panel_sha256=digests) + return result + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("--root", required=True) + parser.add_argument("--expected", required=True) + parser.add_argument("--native-exit", type=int, required=True) + args = parser.parse_args() + result = assess( + args.root, json.loads(Path(args.expected).read_bytes()), args.native_exit + ) + reward = Path(args.root) / "reward.txt" + if reward.read_text().strip() != str(result["reward"]): + raise ValueError("Native raw reward disagrees with pytest evidence") + (Path(args.root) / "pytest-evidence.json").write_text( + json.dumps(result, sort_keys=True) + "\n" + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/expected-panels.json b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/expected-panels.json new file mode 100644 index 0000000000000000000000000000000000000000..e54b387c14c7fad6e4204b0177d074d54bece48c --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/expected-panels.json @@ -0,0 +1,1067 @@ +{ + "fail-to-pass": [ + "pypika/tests/clickhouse/test_condition.py::TestIfCondition::test_get_sql_0", + "pypika/tests/clickhouse/test_condition.py::TestIfCondition::test_get_sql_1", + "pypika/tests/clickhouse/test_condition.py::TestMultiIfCondition::test_get_sql_0", + "pypika/tests/clickhouse/test_condition.py::TestMultiIfCondition::test_get_sql_1", + "pypika/tests/clickhouse/test_search_string.py::TestMultiSearch::test_multi_search_string_0", + "pypika/tests/clickhouse/test_search_string.py::TestMultiSearch::test_multi_search_string_1" + ], + "pass-to-pass": [ + "pypika/tests/clickhouse/test_array.py::TestArray::test_get_sql_0__ridley_scott_jimi_hendrix_", + "pypika/tests/clickhouse/test_array.py::TestArray::test_get_sql_1__1_2_3_4_", + "pypika/tests/clickhouse/test_array.py::TestArray::test_get_sql_2__toInt64_1_toInt64_2_toInt64_3_toInt64_4_", + "pypika/tests/clickhouse/test_array.py::TestArray::test_get_sql_3__toFixedString_mogwai_10_toFixedString_mono_10_toFixedString_bonobo_10_arr", + "pypika/tests/clickhouse/test_array.py::TestHasAny::test_get_sql_0_hasAny_mental_abilities_physical_abilities_", + "pypika/tests/clickhouse/test_array.py::TestHasAny::test_get_sql_1_hasAny_1_2_3_4_3_", + "pypika/tests/clickhouse/test_array.py::TestHasAny::test_get_sql_2_hasAny_bands_toFixedString_port_royal_20_toFixedString_hammock_20_", + "pypika/tests/clickhouse/test_array.py::TestLength::test_get_sql_0_length_tags_", + "pypika/tests/clickhouse/test_array.py::TestLength::test_get_sql_1_length_1_2_3_", + "pypika/tests/clickhouse/test_array.py::TestEmpty::test_get_sql_0_empty_tags_", + "pypika/tests/clickhouse/test_array.py::TestEmpty::test_get_sql_1_empty_1_2_3_", + "pypika/tests/clickhouse/test_array.py::TestNotEmpty::test_get_sql_0_notEmpty_tags_", + "pypika/tests/clickhouse/test_array.py::TestNotEmpty::test_get_sql_1_notEmpty_1_2_3_", + "pypika/tests/clickhouse/test_dates_and_times.py::TestFormatDateTime::test_get_sql_0", + "pypika/tests/clickhouse/test_dates_and_times.py::TestFormatDateTime::test_get_sql_1", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_00", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_01", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_02", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_03", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_04", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_05", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_06", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_07", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_08", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_09", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_10", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_11", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_12", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_13", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_14", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_15", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_16", + "pypika/tests/clickhouse/test_dates_and_times.py::TestToYYYYMM::test_get_sql", + "pypika/tests/clickhouse/test_nullable_arg.py::TestSearchString::test_get_sql_0", + "pypika/tests/clickhouse/test_nullable_arg.py::TestSearchString::test_get_sql_1", + "pypika/tests/clickhouse/test_search_string.py::TestSearchString::test_search_string_0", + "pypika/tests/clickhouse/test_search_string.py::TestSearchString::test_search_string_1", + "pypika/tests/clickhouse/test_search_string.py::TestSearchString::test_search_string_2", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_00_toString_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_01_toInt8_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_02_toInt16_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_03_toInt32_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_04_toInt64_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_05_toUInt8_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_06_toUInt16_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_07_toUInt32_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_08_toUInt64_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_09_toFloat32_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_10_toFloat64_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_11_toFloat64_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_12_toDate_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_13_toDateTime_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_14_toFixedString_field_name_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_00_toString_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_01_toInt8_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_02_toInt16_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_03_toInt32_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_04_toInt64_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_05_toUInt8_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_06_toUInt16_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_07_toUInt32_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_08_toUInt64_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_09_toFloat32_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_10_toFloat64_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_11_toFloat64_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_12_toDate_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_13_toDateTime_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_14_toFixedString_100_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestToFixedString::test_get_sql_with_table", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseQueryTests::test_use_AS_keyword_for_alias", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseQueryTests::test_use_FINAL_keyword", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseQueryTests::test_use_SAMPLE_keyword", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseQueryTests::test_use_SAMPLE_with_offset_keyword", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDeleteTests::test_omit_where", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDeleteTests::test_omit_where__table_schema", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDeleteTests::test_where_field_equals", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseUpdateTests::test_update", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDropQuery::test_drop_database", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDropQuery::test_drop_dictionary", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDropQuery::test_drop_other", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDropQuery::test_drop_table", + "pypika/tests/dialects/test_clickhouse.py::DistinctOnTests::test_distinct_on", + "pypika/tests/dialects/test_clickhouse.py::LimitByTests::test_limit_by", + "pypika/tests/dialects/test_clickhouse.py::LimitByTests::test_limit_offset0_by", + "pypika/tests/dialects/test_clickhouse.py::LimitByTests::test_limit_offset_by", + "pypika/tests/dialects/test_clickhouse.py::LimitByTests::test_rename_table", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_distinct_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_groupby_alias_False_does_not_group_by_alias_when_subqueries_are_present", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_groupby_alias_False_does_not_group_by_alias_with_standard_query", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_limit", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_limit_with_offset", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_normal_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_offset", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_distinct_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_percent_invalid_range", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_percent_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_select_non_int", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_with_ties_select", + "pypika/tests/dialects/test_mysql.py::SelectTests::test_distinct_select", + "pypika/tests/dialects/test_mysql.py::SelectTests::test_modifier_select", + "pypika/tests/dialects/test_mysql.py::SelectTests::test_multiple_modifier_select", + "pypika/tests/dialects/test_mysql.py::SelectTests::test_normal_select", + "pypika/tests/dialects/test_mysql.py::UpdateTests::test_conflict_handlers_update", + "pypika/tests/dialects/test_mysql.py::UpdateTests::test_on_duplicate_key_ignore_update", + "pypika/tests/dialects/test_mysql.py::UpdateTests::test_on_duplicate_key_update_update", + "pypika/tests/dialects/test_mysql.py::UpdateTests::test_update", + "pypika/tests/dialects/test_mysql.py::LoadCSVTests::test_load_from_file", + "pypika/tests/dialects/test_mysql.py::TableTests::test_create_table", + "pypika/tests/dialects/test_mysql.py::TableTests::test_drop_table", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_fetch_next_method_deprecated", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_groupby_alias_False_does_not_group_by_alias_when_subqueries_are_present", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_groupby_alias_False_does_not_group_by_alias_with_standard_query", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_limit_offset_query", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_limit_query", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_offset_query", + "pypika/tests/dialects/test_postgresql.py::InsertTests::test_array_keyword", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_alias_set_correctly", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_json_value_from_array_num", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_json_value_from_array_str", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_json_value_from_dict", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_json_value_from_dict_recursive", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_json_value_by_index", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_json_value_by_key", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_path_json_value", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_path_text_value", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_text_value_by_index", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_text_value_by_key", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contained_by_using_list_arg", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contained_by_using_str_arg", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contained_by_with_complex_criterion", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contains_for_field", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contains_for_json", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_has_any_keys", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_has_key", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_has_keys", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_subnet_contains_inet", + "pypika/tests/dialects/test_postgresql.py::DistinctOnTests::test_distinct_on", + "pypika/tests/dialects/test_postgresql.py::ArrayTests::test_array_syntax", + "pypika/tests/dialects/test_postgresql.py::ArrayTests::test_render_alias_in_array_sql", + "pypika/tests/dialects/test_postgresql.py::ReturningClauseTests::test_no_queryexception_if_returning_used_on_valid_query_type", + "pypika/tests/dialects/test_postgresql.py::ReturningClauseTests::test_queryexception_if_returning_used_on_invalid_query", + "pypika/tests/dialects/test_postgresql.py::ReturningClauseTests::test_return_field_from_join_table", + "pypika/tests/dialects/test_postgresql.py::ReturningClauseTests::test_returning_from_missing_table_raises_queryexception", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_dont_use_double_quotes_on_create_queries", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_dont_use_double_quotes_on_drop_queries", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_dont_use_double_quotes_on_joining_queries", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_use_double_quotes_on_alias_but_not_on_terms", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_use_double_quotes_on_alias_but_not_on_terms_with_joins", + "pypika/tests/dialects/test_sqllite.py::SelectTests::test_bool_false_as_zero", + "pypika/tests/dialects/test_sqllite.py::SelectTests::test_bool_true_as_one", + "pypika/tests/dialects/test_sqllite.py::ReplaceTests::test_insert_or_replace", + "pypika/tests/dialects/test_sqllite.py::ReplaceTests::test_normal_replace", + "pypika/tests/dialects/test_sqllite.py::ReplaceTests::test_replace_subquery", + "pypika/tests/dialects/test_vertica.py::VerticaQueryTests::test_delete_query_with_hint", + "pypika/tests/dialects/test_vertica.py::VerticaQueryTests::test_insert_query_with_hint", + "pypika/tests/dialects/test_vertica.py::VerticaQueryTests::test_select_query_with_hint", + "pypika/tests/dialects/test_vertica.py::VerticaQueryTests::test_update_query_with_hint", + "pypika/tests/dialects/test_vertica.py::CopyCSVTests::test_copy_from_file", + "pypika/tests/dialects/test_vertica.py::CreateTemporaryTableTests::test_create_local_table_without_temporary_raises_error", + "pypika/tests/dialects/test_vertica.py::CreateTemporaryTableTests::test_create_local_temporary_table", + "pypika/tests/dialects/test_vertica.py::CreateTemporaryTableTests::test_create_table_preserve_rows_without_temporary_raises_error", + "pypika/tests/dialects/test_vertica.py::CreateTemporaryTableTests::test_create_temporary_table_preserve_rows", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__agg_case_criterion_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__agg_case_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__agg_func_arithmetic_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__agg_func_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__case_mixed_constant_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__case_mixed_else_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__case_with_field_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__case_with_single_aggregate_field_in_one_criterion_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__constant_arithmetic_is_aggregate_none", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__constant_is_aggregate_none", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__field_arithmetic_constant_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__field_arithmetic_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__field_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__func_arithmetic_constant_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__mixed_case_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__mixed_func_arithmetic_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__negative_agg_func_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__non_aggregate_function_with_aggregated_arg", + "pypika/tests/test_aggregate.py::IsAggregateTests::test_complicated", + "pypika/tests/test_analytic_queries.py::RankTests::test_avg", + "pypika/tests/test_analytic_queries.py::RankTests::test_count_range_between_unbounded_preceeding_current_row", + "pypika/tests/test_analytic_queries.py::RankTests::test_dense_rank", + "pypika/tests/test_analytic_queries.py::RankTests::test_empty_over", + "pypika/tests/test_analytic_queries.py::RankTests::test_filter", + "pypika/tests/test_analytic_queries.py::RankTests::test_filter_quote_table_in_filter", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value_ignore_nulls", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value_ignore_nulls_first", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value_multi_argument", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value_range_between_x_preceeding_unbounded_following", + "pypika/tests/test_analytic_queries.py::RankTests::test_lag_generates_correct_sql", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value_ignore_nulls", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value_multi_argument", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value_rows_between_current_row_unbounded_following", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value_rows_between_current_row_unbounded_following_ignore_nulls", + "pypika/tests/test_analytic_queries.py::RankTests::test_lead_generates_correct_sql", + "pypika/tests/test_analytic_queries.py::RankTests::test_max_range_x_preceeding", + "pypika/tests/test_analytic_queries.py::RankTests::test_max_rows_x_preceeding", + "pypika/tests/test_analytic_queries.py::RankTests::test_median", + "pypika/tests/test_analytic_queries.py::RankTests::test_min_range_current_row", + "pypika/tests/test_analytic_queries.py::RankTests::test_min_rows_current_row", + "pypika/tests/test_analytic_queries.py::RankTests::test_multiple_partitions", + "pypika/tests/test_analytic_queries.py::RankTests::test_ntile_no_partition_or_order_invalid_sql", + "pypika/tests/test_analytic_queries.py::RankTests::test_ntile_with_order", + "pypika/tests/test_analytic_queries.py::RankTests::test_ntile_with_partition", + "pypika/tests/test_analytic_queries.py::RankTests::test_ntile_with_partition_and_order", + "pypika/tests/test_analytic_queries.py::RankTests::test_orderby_asc", + "pypika/tests/test_analytic_queries.py::RankTests::test_orderby_desc", + "pypika/tests/test_analytic_queries.py::RankTests::test_range_called_twice_raises_attribute_error", + "pypika/tests/test_analytic_queries.py::RankTests::test_range_then_rows_raises_attribute_error", + "pypika/tests/test_analytic_queries.py::RankTests::test_rank", + "pypika/tests/test_analytic_queries.py::RankTests::test_rank_with_alias", + "pypika/tests/test_analytic_queries.py::RankTests::test_row_number", + "pypika/tests/test_analytic_queries.py::RankTests::test_rows_called_twice_raises_attribute_error", + "pypika/tests/test_analytic_queries.py::RankTests::test_rows_then_range_raises_attribute_error", + "pypika/tests/test_analytic_queries.py::RankTests::test_stddev", + "pypika/tests/test_analytic_queries.py::RankTests::test_stddev_pop", + "pypika/tests/test_analytic_queries.py::RankTests::test_stddev_samp", + "pypika/tests/test_analytic_queries.py::RankTests::test_sum_rows_unbounded_preceeding", + "pypika/tests/test_analytic_queries.py::RankTests::test_table_prefixes_used_in_analytic_functions", + "pypika/tests/test_analytic_queries.py::RankTests::test_var_pop", + "pypika/tests/test_analytic_queries.py::RankTests::test_var_samp", + "pypika/tests/test_analytic_queries.py::RankTests::test_variance", + "pypika/tests/test_analytic_queries.py::RankTests::test_variance_rows_between_unbounded_preceeding_unbounded_following", + "pypika/tests/test_analytic_queries.py::RankTests::test_varpop_range_unbounded_preceeding", + "pypika/tests/test_analytic_queries.py::RankTests::test_varpop_rows_between_unbounded_preceeding_x_following", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_as_select_not_query_raises_error", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_with_columns", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_with_select", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_with_select_and_columns_fails", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_without_columns_or_select_empty", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_if_not_exists", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_simple", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_unique", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_where", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_without_columns_raises_error", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_without_table_raises_error", + "pypika/tests/test_criterions.py::CriterionTests::test__bitwise_and_in_where_clause", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_bitwise_and", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_bitwise_and_with_alias", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_bool", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_decimal", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_str", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gt_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gt_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gt_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gt_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gte_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gte_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gte_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gte_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_is_null", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_is_null_with_alias", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lt_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lt_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lt_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lt_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lte_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lte_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lte_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lte_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_str", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_with_alias", + "pypika/tests/test_criterions.py::NotTests::test_chained_function", + "pypika/tests/test_criterions.py::NotTests::test_is_not_null", + "pypika/tests/test_criterions.py::NotTests::test_negate", + "pypika/tests/test_criterions.py::NotTests::test_not_null", + "pypika/tests/test_criterions.py::NotTests::test_not_null_with_alias", + "pypika/tests/test_criterions.py::NotTests::test_not_with_and_criterion", + "pypika/tests/test_criterions.py::NotTests::test_not_with_complex_criterion", + "pypika/tests/test_criterions.py::NotTests::test_not_with_or_criterion", + "pypika/tests/test_criterions.py::NotTests::test_notnullcriterion_replace_table", + "pypika/tests/test_criterions.py::NotTests::test_variable_access", + "pypika/tests/test_criterions.py::BetweenTests::test__between_date", + "pypika/tests/test_criterions.py::BetweenTests::test__between_datetime", + "pypika/tests/test_criterions.py::BetweenTests::test__between_number", + "pypika/tests/test_criterions.py::BetweenTests::test__between_with_alias", + "pypika/tests/test_criterions.py::BetweenTests::test__function_between", + "pypika/tests/test_criterions.py::BetweenTests::test_get_item_only_works_with_slice", + "pypika/tests/test_criterions.py::IsInTests::test__function_isin", + "pypika/tests/test_criterions.py::IsInTests::test__in_character", + "pypika/tests/test_criterions.py::IsInTests::test__in_date", + "pypika/tests/test_criterions.py::IsInTests::test__in_datetime", + "pypika/tests/test_criterions.py::IsInTests::test__in_number", + "pypika/tests/test_criterions.py::IsInTests::test__in_number_with_alias", + "pypika/tests/test_criterions.py::IsInTests::test__in_unicode", + "pypika/tests/test_criterions.py::ArithmeticExpressionTests::test__lshift", + "pypika/tests/test_criterions.py::ArithmeticExpressionTests::test__rshift", + "pypika/tests/test_criterions.py::NotInTests::test__function_notin", + "pypika/tests/test_criterions.py::NotInTests::test__notin_character", + "pypika/tests/test_criterions.py::NotInTests::test__notin_date", + "pypika/tests/test_criterions.py::NotInTests::test__notin_datetime", + "pypika/tests/test_criterions.py::NotInTests::test__notin_number", + "pypika/tests/test_criterions.py::NotInTests::test__notin_number_with_alias", + "pypika/tests/test_criterions.py::LikeTests::test_glob_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_contains", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_ends_with", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_n_chars_long", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_starts_with", + "pypika/tests/test_criterions.py::LikeTests::test_like_contains", + "pypika/tests/test_criterions.py::LikeTests::test_like_ends_with", + "pypika/tests/test_criterions.py::LikeTests::test_like_n_chars_long", + "pypika/tests/test_criterions.py::LikeTests::test_like_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_like_starts_with", + "pypika/tests/test_criterions.py::LikeTests::test_not_ilike_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_not_like_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_rlike_escape_chars", + "pypika/tests/test_criterions.py::ExistsCriterionTests::test_exists", + "pypika/tests/test_criterions.py::ExistsCriterionTests::test_not_exists", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__between_and_field", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__between_and_isin", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__nested__and", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__nested__mixed", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__nested__or", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_and", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_function_and", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_function_or", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_function_xor", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_or", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_xor", + "pypika/tests/test_criterions.py::FieldsAsCriterionTests::test__field_and_field", + "pypika/tests/test_criterions.py::FieldsAsCriterionTests::test__field_or_field", + "pypika/tests/test_criterions.py::FieldsAsCriterionTests::test__field_xor_field", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_arithmeticfunction_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_betweencriterion_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_complexcriterion_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_criterion_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_field_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_function_with_only_fields_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_function_with_values_and_fields_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_nullcriterion_replace_table", + "pypika/tests/test_criterions.py::AnyTests::test_multiple_args_returned_in_chain_of_ors", + "pypika/tests/test_criterions.py::AnyTests::test_single_arg_returns_self", + "pypika/tests/test_criterions.py::AnyTests::test_with_generator", + "pypika/tests/test_criterions.py::AnyTests::test_zero_args_returns_empty_criterion", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_different_operations_with_empty_criterion", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_empty_criterion_on_the_left", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_empty_criterion_on_the_right", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_fields_", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_invertion_of_the_empty_criterion", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_more_than_one_empty_criterions", + "pypika/tests/test_criterions.py::AllTests::test_multiple_args_returned_in_chain_of_ors", + "pypika/tests/test_criterions.py::AllTests::test_single_arg_returns_self", + "pypika/tests/test_criterions.py::AllTests::test_with_generator", + "pypika/tests/test_criterions.py::AllTests::test_zero_args_returns_empty_criterion", + "pypika/tests/test_custom_functions.py::TestUnitCustomFunction::test_should_fail_with_wrong_arguments", + "pypika/tests/test_custom_functions.py::TestUnitCustomFunction::test_should_return_function_with_arguments", + "pypika/tests/test_custom_functions.py::TestUnitCustomFunction::test_should_return_function_with_no_arguments", + "pypika/tests/test_custom_functions.py::TestFunctionalCustomFunction::test_should_fail_use_custom_function_on_select_with_wrong_arguments", + "pypika/tests/test_custom_functions.py::TestFunctionalCustomFunction::test_should_use_custom_function_on_select", + "pypika/tests/test_data_types.py::StringTests::test_inline_string_concatentation", + "pypika/tests/test_data_types.py::UuidTests::test_uuid_string_generation", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_day", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_default", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_microsecond", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_minute", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_month", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_quarter", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_second", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_week", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_year", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_day_hour", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_day_microsecond", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_day_minute", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_day_second", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_hour_microsecond", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_hour_minute", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_hour_second", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_minute_microsecond", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_minute_second", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_second_microsecond", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_value_complex_expressions", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_value_right", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_year_month", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_mysql_dialect_uses_single_quotes_around_expression_in_an_interval", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_oracle_dialect_uses_single_quotes_around_expression_in_an_interval", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_postgresql_dialect_uses_single_quotes_around_interval", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_redshift_dialect_uses_single_quotes_around_interval", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_vertica_dialect_uses_single_quotes_around_interval", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_day", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_month", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_week", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_year", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_year_month", + "pypika/tests/test_date_math.py::TruncateTrailingZerosTests::test_do_not_truncate_integer_values", + "pypika/tests/test_date_math.py::TruncateTrailingZerosTests::test_do_not_truncate_months_between_years_and_datys", + "pypika/tests/test_deletes.py::DeleteTests::test_for_portion", + "pypika/tests/test_deletes.py::DeleteTests::test_omit_where", + "pypika/tests/test_deletes.py::DeleteTests::test_omit_where__table_schema", + "pypika/tests/test_deletes.py::DeleteTests::test_where_field_equals", + "pypika/tests/test_deletes.py::PostgresDeleteTests::test_delete_returning", + "pypika/tests/test_deletes.py::PostgresDeleteTests::test_delete_returning_star", + "pypika/tests/test_deletes.py::PostgresDeleteTests::test_delete_returning_str", + "pypika/tests/test_deletes.py::PostgresDeleteTests::test_delete_using", + "pypika/tests/test_drop.py::DropTableTests::test_drop_database", + "pypika/tests/test_drop.py::DropTableTests::test_drop_index", + "pypika/tests/test_drop.py::DropTableTests::test_drop_table", + "pypika/tests/test_drop.py::DropTableTests::test_drop_user", + "pypika/tests/test_drop.py::DropTableTests::test_drop_view", + "pypika/tests/test_formats.py::QuoteTests::test_no_quote_char_in_complex_query", + "pypika/tests/test_formats.py::QuoteTests::test_replace_quote_char_in_complex_query", + "pypika/tests/test_functions.py::FunctionTests::test_dialect_propagation", + "pypika/tests/test_functions.py::FunctionTests::test_is_aggregate_None_for_non_aggregate_function_or_function_with_no_aggregate_functions", + "pypika/tests/test_functions.py::FunctionTests::test_is_aggregate_True_for_aggregate_function_or_function_with_aggregate_functions", + "pypika/tests/test_functions.py::SchemaTests::test_schema_included_in_function_sql", + "pypika/tests/test_functions.py::SchemaTests::test_schema_no_schema_in_sql_when_none_set", + "pypika/tests/test_functions.py::ArithmeticTests::test__addition__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__addition__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__addition__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__addition__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__arithmetic_equality", + "pypika/tests/test_functions.py::ArithmeticTests::test__arithmetic_with_function", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_add_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_div_no_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_div_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_exponent_no_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_exponent_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_floor_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_function_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_modulus_no_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_modulus_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_mul_no_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_mul_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_nested_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_sub_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__division__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__division__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__division__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__division__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__exponent__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__exponent__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__floor", + "pypika/tests/test_functions.py::ArithmeticTests::test__leftshift__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__leftshift__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__leftshift__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__modulus__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__multiplication__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__multiplication__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__multiplication__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__multiplication__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__rightshift__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__rightshift__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__rightshift__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__subtraction__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__subtraction__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__subtraction__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__subtraction__right", + "pypika/tests/test_functions.py::AggregationTests::test__approx_percentile", + "pypika/tests/test_functions.py::AggregationTests::test__avg", + "pypika/tests/test_functions.py::AggregationTests::test__count", + "pypika/tests/test_functions.py::AggregationTests::test__count__star", + "pypika/tests/test_functions.py::AggregationTests::test__first", + "pypika/tests/test_functions.py::AggregationTests::test__last", + "pypika/tests/test_functions.py::AggregationTests::test__max", + "pypika/tests/test_functions.py::AggregationTests::test__min", + "pypika/tests/test_functions.py::AggregationTests::test__std", + "pypika/tests/test_functions.py::AggregationTests::test__stddev", + "pypika/tests/test_functions.py::AggregationTests::test__subquery_in_params_functions", + "pypika/tests/test_functions.py::AggregationTests::test__sum", + "pypika/tests/test_functions.py::ConditionTests::test__case__else", + "pypika/tests/test_functions.py::ConditionTests::test__case__field", + "pypika/tests/test_functions.py::ConditionTests::test__case__multi", + "pypika/tests/test_functions.py::ConditionTests::test__case__no_cases", + "pypika/tests/test_functions.py::ConditionTests::test__case__raw", + "pypika/tests/test_functions.py::StringTests::test__ascii__field", + "pypika/tests/test_functions.py::StringTests::test__ascii__int", + "pypika/tests/test_functions.py::StringTests::test__ascii__str", + "pypika/tests/test_functions.py::StringTests::test__bin__field", + "pypika/tests/test_functions.py::StringTests::test__bin__int", + "pypika/tests/test_functions.py::StringTests::test__bin__str", + "pypika/tests/test_functions.py::StringTests::test__concat__field", + "pypika/tests/test_functions.py::StringTests::test__concat__str", + "pypika/tests/test_functions.py::StringTests::test__insert__field", + "pypika/tests/test_functions.py::StringTests::test__insert__str", + "pypika/tests/test_functions.py::StringTests::test__length__field", + "pypika/tests/test_functions.py::StringTests::test__length__str", + "pypika/tests/test_functions.py::StringTests::test__lower__field", + "pypika/tests/test_functions.py::StringTests::test__lower__str", + "pypika/tests/test_functions.py::StringTests::test__replace__field", + "pypika/tests/test_functions.py::StringTests::test__replace__str", + "pypika/tests/test_functions.py::StringTests::test__substring", + "pypika/tests/test_functions.py::SplitPartFunctionTests::test__split_part", + "pypika/tests/test_functions.py::RegexpLikeFunctionTests::test__regexp_like", + "pypika/tests/test_functions.py::CastTests::test__cast__as", + "pypika/tests/test_functions.py::CastTests::test__cast__binary", + "pypika/tests/test_functions.py::CastTests::test__cast__binary_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__boolean", + "pypika/tests/test_functions.py::CastTests::test__cast__char", + "pypika/tests/test_functions.py::CastTests::test__cast__char_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__date", + "pypika/tests/test_functions.py::CastTests::test__cast__float", + "pypika/tests/test_functions.py::CastTests::test__cast__integer", + "pypika/tests/test_functions.py::CastTests::test__cast__long_varbinary", + "pypika/tests/test_functions.py::CastTests::test__cast__long_varbinary_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__long_varchar", + "pypika/tests/test_functions.py::CastTests::test__cast__long_varchar_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__numeric", + "pypika/tests/test_functions.py::CastTests::test__cast__signed", + "pypika/tests/test_functions.py::CastTests::test__cast__timestamp", + "pypika/tests/test_functions.py::CastTests::test__cast__unsigned", + "pypika/tests/test_functions.py::CastTests::test__cast__varbinary", + "pypika/tests/test_functions.py::CastTests::test__cast__varbinary_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__varchar", + "pypika/tests/test_functions.py::CastTests::test__cast__varchar_with_arg", + "pypika/tests/test_functions.py::CastTests::test__tochar__", + "pypika/tests/test_functions.py::DateFunctionsTests::test_current_date", + "pypika/tests/test_functions.py::DateFunctionsTests::test_current_time", + "pypika/tests/test_functions.py::DateFunctionsTests::test_current_timestamp", + "pypika/tests/test_functions.py::DateFunctionsTests::test_current_timestamp_with_alias", + "pypika/tests/test_functions.py::DateFunctionsTests::test_date_add", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_day", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_hour", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_join", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_microsecond", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_minute", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_month", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_quarter", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_second", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_week", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_year", + "pypika/tests/test_functions.py::DateFunctionsTests::test_now", + "pypika/tests/test_functions.py::DateFunctionsTests::test_time_diff", + "pypika/tests/test_functions.py::DateFunctionsTests::test_timestampadd", + "pypika/tests/test_functions.py::DateFunctionsTests::test_to_date", + "pypika/tests/test_functions.py::DateFunctionsTests::test_utc_timestamp", + "pypika/tests/test_functions.py::NullFunctionsTests::test_coalesce", + "pypika/tests/test_functions.py::NullFunctionsTests::test_isnull", + "pypika/tests/test_functions.py::NullFunctionsTests::test_nullif", + "pypika/tests/test_functions.py::NullFunctionsTests::test_nvl", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_mysql_one_groupby", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_mysql_rollup_two_groupbys", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_no_rollup_after_rollup_mysql", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_no_rollup_before_groupby", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_from_groupbys", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_from_parameters", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_from_two_groupbys", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_func_one_groupby", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_func_partial", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_func_two_groupbys", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_multiple_rollups", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_rollups_with_multiple_rollups_and_parity", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_rollups_with_parity", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_force_index_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_groupby_returns_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_immutable_kwarg_on_query_builder_disables_immutability", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_insert_into_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_join_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_orderby_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_queries_after_join", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_replace_into_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_select_returns_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_update_set_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_use_index_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_with_return_new_query_instance", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_multi_rows", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_multi_rows_chained", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_multi_rows_chained_mixed", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_multi_rows_chained_multiple_rows", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_single_element", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_column_using_alias_with_chain", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_column_using_table_alias", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_empty_columns", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_empty_columns_type_list", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_empty_columns_type_tuple", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_ignore", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_multiple_rows_with_array_value", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_none_skipped", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_null", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_one_column", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_one_column_multi_element_array", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_one_column_single_element_array", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_selected_columns", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_selected_columns_type_list", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_selected_columns_type_tuple", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_single_row_with_array_value", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_with_statement", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_empty_on_conflict_do_update_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_field", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_field_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_mixed_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_multiple_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_multiple_fields_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_field", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_field_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_multiple_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_multiple_fields_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_multiple_mixed_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_no_handler", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_two_handlers_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_two_handlers_do_update", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_fieldless_conflict_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_fieldless_conflict_do_update_field", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_non_insert_on_conflict_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_non_insert_on_conflict_do_update", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_do_nothing_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_do_update_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_do_update_with_excluded_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_from_subquery", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_complex", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_conflict_fields_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_conflict_fields_do_update", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_empty_conflict_fields_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_empty_conflict_fields_do_update", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_where_and_on_conflict_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_all_columns_multi_rows_chained_returning_star", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_all_columns_multi_rows_chained_returning_star_and_id", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_all_columns_multi_rows_chained_returning_star_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_all_columns_single_element_arrays", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_aggregate", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_all_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_all_fields_and_arithmetics", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_arithmetics", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_from_other_table", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_functions", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_null", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_one_field", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_one_field_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_tuple", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_ignore", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multi_rows_chained_mixed_on_duplicate_update_multiple", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_multiple", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_different_value", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_expression", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_expression_using_original_field_value", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_expression_using_values", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_same_value", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_none_skipped", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_one_column", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_one_column_multi_element_array", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_one_column_single_element_array", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_one_column_using_values", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_selected_columns_on_duplicate_update_multiple", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_selected_columns_on_duplicate_update_one", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_columns_from_columns", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_columns_from_columns_with_join", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_columns_from_star", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_from_columns", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_ignore_star", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_star", + "pypika/tests/test_inserts.py::InsertSubqueryTests::test_insert_subquery_wrapped_in_brackets", + "pypika/tests/test_inserts.py::SelectIntoTests::test_select_columns_into", + "pypika/tests/test_inserts.py::SelectIntoTests::test_select_columns_into_with_join", + "pypika/tests/test_inserts.py::SelectIntoTests::test_select_star_into", + "pypika/tests/test_inserts.py::ReplaceTests::test_replace_simple", + "pypika/tests/test_inserts.py::ReplaceTests::test_replace_subquery", + "pypika/tests/test_internals.py::TablesTests::test__case_tables", + "pypika/tests/test_internals.py::TablesTests::test__criterion_replace_table_with_value", + "pypika/tests/test_internals.py::TablesTests::test__star_tables", + "pypika/tests/test_internals.py::TablesTests::test__table_star_tables", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_cross_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_cross_join_on_subquery", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_cross_join_on_table", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_default_join_type", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_full_outer_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_hash_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_inner_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_arithmetic_field", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_collate", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_complex_criteria", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_field_multi", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_field_multi_with_extra_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_field_single", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_field_without_fields_raises_exception", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_subquery_criteria", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_second_table_in_from_clause", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_using_multiple_fields", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_using_string_field_name", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_using_with_quote_char", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_using_without_fields_raises_exception", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_with_arithmetic_function_in_select", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_left_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_left_outer_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_outer_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_right_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_right_outer_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_temporal_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_use_different_table_objects_for_same_table", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_fail_when_joining_unknown_type", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_ignore_table_references", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_immutable__tables", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_from_join", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_query_with_column_alias", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_query_with_setoperation", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_query_with_table_alias", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_query_without_alias", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_same_table", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_same_table_with_prefixes", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_table_twice", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_prefixes_added_to_function_in_orderby", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_prefixes_added_to_groupby", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_prefixes_added_to_orderby", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_require_condition", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_require_condition_with_both_tables", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select__fields_after_table_star", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select__ordered_select_clauses", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select__star_for_table", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select__star_for_table__replacement", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select_field_from_missing_table", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select_fields_with_where", + "pypika/tests/test_joins.py::UnionTests::test_mysql_query_wraps_unioned_queries", + "pypika/tests/test_joins.py::UnionTests::test_require_equal_number_of_fields", + "pypika/tests/test_joins.py::UnionTests::test_union", + "pypika/tests/test_joins.py::UnionTests::test_union_all", + "pypika/tests/test_joins.py::UnionTests::test_union_all_multiple", + "pypika/tests/test_joins.py::UnionTests::test_union_as_subquery", + "pypika/tests/test_joins.py::UnionTests::test_union_multiple", + "pypika/tests/test_joins.py::UnionTests::test_union_with_no_quote_char", + "pypika/tests/test_joins.py::UnionTests::test_union_with_order_by", + "pypika/tests/test_joins.py::UnionTests::test_union_with_order_by_use_union_query_field", + "pypika/tests/test_joins.py::UnionTests::test_union_with_order_by_use_union_query_field_with_aliases", + "pypika/tests/test_joins.py::UnionTests::test_union_with_order_by_with_aliases", + "pypika/tests/test_joins.py::InsertQueryJoinTests::test_join_table_on_insert_query", + "pypika/tests/test_joins.py::UpdateQueryJoinTests::test_join_table_on_update_query", + "pypika/tests/test_joins.py::IntersectTests::test_intersect", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_as_subquery", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_multiple", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_with_limit", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_with_no_quote_char", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_with_offset", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_with_order_by", + "pypika/tests/test_joins.py::IntersectTests::test_mysql_query_wraps_intersected_queries", + "pypika/tests/test_joins.py::IntersectTests::test_require_equal_number_of_fields_intersect", + "pypika/tests/test_joins.py::MinusTests::test_minus", + "pypika/tests/test_joins.py::MinusTests::test_minus_as_subquery", + "pypika/tests/test_joins.py::MinusTests::test_minus_multiple", + "pypika/tests/test_joins.py::MinusTests::test_minus_query_with_order_by_use_minus_query_field", + "pypika/tests/test_joins.py::MinusTests::test_minus_with_no_quote_char", + "pypika/tests/test_joins.py::MinusTests::test_minus_with_order_by", + "pypika/tests/test_joins.py::MinusTests::test_mysql_query_wraps_minus_queries", + "pypika/tests/test_joins.py::MinusTests::test_require_equal_number_of_fields", + "pypika/tests/test_joins.py::ExceptOfTests::test_except", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_as_subquery", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_multiple", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_query_with_order_by_use_minus_query_field", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_with_no_quote_char", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_with_order_by", + "pypika/tests/test_joins.py::ExceptOfTests::test_require_equal_number_of_fields_except_of", + "pypika/tests/test_negation.py::NegationTests::test_negate_field", + "pypika/tests/test_negation.py::NegationTests::test_negate_function", + "pypika/tests/test_negation.py::NegationTests::test_negate_wrapped_float", + "pypika/tests/test_negation.py::NegationTests::test_negate_wrapped_int", + "pypika/tests/test_parameter.py::ParametrizedTests::test_format_parameter", + "pypika/tests/test_parameter.py::ParametrizedTests::test_join", + "pypika/tests/test_parameter.py::ParametrizedTests::test_named_parameter", + "pypika/tests/test_parameter.py::ParametrizedTests::test_numeric_parameter", + "pypika/tests/test_parameter.py::ParametrizedTests::test_param_insert", + "pypika/tests/test_parameter.py::ParametrizedTests::test_param_select_join", + "pypika/tests/test_parameter.py::ParametrizedTests::test_param_select_subquery", + "pypika/tests/test_parameter.py::ParametrizedTests::test_pyformat_parameter", + "pypika/tests/test_parameter.py::ParametrizedTests::test_qmark_parameter", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_join", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_join_with_parameter_value_wrapper", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_param_insert", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_param_select_join", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_param_select_subquery", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_pyformat_parameter", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_can_be_used_in_a_select_statement", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_can_be_used_in_a_where_clause", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_can_be_used_in_orderby", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_column_value", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_object_id", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_object_value", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_row_id", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_row_num", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_sys_date", + "pypika/tests/test_query.py::QueryTablesTests::test_is_joined", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_case_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_delete_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_filter_tables", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_having_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_insert_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_insert_table_current_table_not_match", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_join_tables", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_only_specified_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_orderby_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_tuple_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_update_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_update_table_current_table_not_match", + "pypika/tests/test_query.py::QueryBuilderTests::test_pipe", + "pypika/tests/test_query.py::QueryBuilderTests::test_query_builders_have_reference_to_correct_query_class", + "pypika/tests/test_selects.py::SelectTests::test_empty_query", + "pypika/tests/test_selects.py::SelectTests::test_mssql_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_mysql_query_uses_backtick_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_oracle_query_uses_no_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_postgresql_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_redshift_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_select__column__single__alias__str", + "pypika/tests/test_selects.py::SelectTests::test_select__column__single__field", + "pypika/tests/test_selects.py::SelectTests::test_select__column__single__str", + "pypika/tests/test_selects.py::SelectTests::test_select__column__single__table_alias__str", + "pypika/tests/test_selects.py::SelectTests::test_select__columns__multi__field", + "pypika/tests/test_selects.py::SelectTests::test_select__columns__multi__str", + "pypika/tests/test_selects.py::SelectTests::test_select__distinct__multi", + "pypika/tests/test_selects.py::SelectTests::test_select__distinct__single", + "pypika/tests/test_selects.py::SelectTests::test_select__multiple_subqueries", + "pypika/tests/test_selects.py::SelectTests::test_select__multiple_tables", + "pypika/tests/test_selects.py::SelectTests::test_select__nested_subquery", + "pypika/tests/test_selects.py::SelectTests::test_select__no_table", + "pypika/tests/test_selects.py::SelectTests::test_select__star", + "pypika/tests/test_selects.py::SelectTests::test_select__star__replacement", + "pypika/tests/test_selects.py::SelectTests::test_select__subquery", + "pypika/tests/test_selects.py::SelectTests::test_select__table_schema", + "pypika/tests/test_selects.py::SelectTests::test_select__table_schema_with_multiple_levels_as_list", + "pypika/tests/test_selects.py::SelectTests::test_select__table_schema_with_multiple_levels_as_tuple", + "pypika/tests/test_selects.py::SelectTests::test_select_no_from", + "pypika/tests/test_selects.py::SelectTests::test_select_no_from_with_field_raises_exception", + "pypika/tests/test_selects.py::SelectTests::test_select_no_with_alias_from", + "pypika/tests/test_selects.py::SelectTests::test_select_then_add_table", + "pypika/tests/test_selects.py::SelectTests::test_select_with_force_index", + "pypika/tests/test_selects.py::SelectTests::test_select_with_force_index_multiple_calls", + "pypika/tests/test_selects.py::SelectTests::test_select_with_force_index_multiple_indexes", + "pypika/tests/test_selects.py::SelectTests::test_select_with_force_index_with_index_object", + "pypika/tests/test_selects.py::SelectTests::test_select_with_limit", + "pypika/tests/test_selects.py::SelectTests::test_select_with_limit__func", + "pypika/tests/test_selects.py::SelectTests::test_select_with_limit_and_offset", + "pypika/tests/test_selects.py::SelectTests::test_select_with_limit_zero", + "pypika/tests/test_selects.py::SelectTests::test_select_with_offset", + "pypika/tests/test_selects.py::SelectTests::test_select_with_offset__func", + "pypika/tests/test_selects.py::SelectTests::test_select_with_use_index", + "pypika/tests/test_selects.py::SelectTests::test_select_with_use_index_multiple_calls", + "pypika/tests/test_selects.py::SelectTests::test_select_with_use_index_multiple_indexes", + "pypika/tests/test_selects.py::SelectTests::test_select_with_use_index_with_index_object", + "pypika/tests/test_selects.py::SelectTests::test_table_select_alias", + "pypika/tests/test_selects.py::SelectTests::test_table_select_alias_with_offset_and_limit", + "pypika/tests/test_selects.py::SelectTests::test_temporal_select", + "pypika/tests/test_selects.py::SelectTests::test_vertica_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::WhereTests::test_ignore_empty_criterion_having", + "pypika/tests/test_selects.py::WhereTests::test_ignore_empty_criterion_where", + "pypika/tests/test_selects.py::WhereTests::test_select_with_force_index_and_where", + "pypika/tests/test_selects.py::WhereTests::test_where_enum", + "pypika/tests/test_selects.py::WhereTests::test_where_field_contains", + "pypika/tests/test_selects.py::WhereTests::test_where_field_does_not_contain", + "pypika/tests/test_selects.py::WhereTests::test_where_field_does_not_end_with", + "pypika/tests/test_selects.py::WhereTests::test_where_field_does_not_start_with", + "pypika/tests/test_selects.py::WhereTests::test_where_field_ends_with", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_and", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_nowait", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_of", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_of_multiple_tables", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_of_nowait", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_of_skip_locked", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_skip_locked", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_skip_locked_and_of", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_or", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_where", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_where_not", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_where_two_not", + "pypika/tests/test_selects.py::WhereTests::test_where_field_is_n_chars_long", + "pypika/tests/test_selects.py::WhereTests::test_where_field_is_not_n_chars_long", + "pypika/tests/test_selects.py::WhereTests::test_where_field_matches_regex", + "pypika/tests/test_selects.py::WhereTests::test_where_field_matches_regexp", + "pypika/tests/test_selects.py::WhereTests::test_where_field_matches_rlike", + "pypika/tests/test_selects.py::WhereTests::test_where_field_starts_with", + "pypika/tests/test_selects.py::WhereTests::test_where_nested_conditions", + "pypika/tests/test_selects.py::WhereTests::test_where_single_quote", + "pypika/tests/test_selects.py::WhereTests::test_where_with_multiple_wheres_using_and_case", + "pypika/tests/test_selects.py::WhereTests::test_where_with_multiple_wheres_using_or_case", + "pypika/tests/test_selects.py::PreWhereTests::test_ignore_empty_criterion_having", + "pypika/tests/test_selects.py::PreWhereTests::test_ignore_empty_criterion_where", + "pypika/tests/test_selects.py::PreWhereTests::test_prewhere_field_equals", + "pypika/tests/test_selects.py::PreWhereTests::test_select_with_force_index_and_where", + "pypika/tests/test_selects.py::PreWhereTests::test_where_and_prewhere", + "pypika/tests/test_selects.py::PreWhereTests::test_where_enum", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_contains", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_does_not_contain", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_does_not_end_with", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_does_not_start_with", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_ends_with", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_and", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_nowait", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_of", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_of_multiple_tables", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_of_nowait", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_of_skip_locked", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_skip_locked", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_skip_locked_and_of", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_or", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_where", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_where_not", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_where_two_not", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_is_n_chars_long", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_is_not_n_chars_long", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_matches_regex", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_matches_regexp", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_matches_rlike", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_starts_with", + "pypika/tests/test_selects.py::PreWhereTests::test_where_nested_conditions", + "pypika/tests/test_selects.py::PreWhereTests::test_where_single_quote", + "pypika/tests/test_selects.py::PreWhereTests::test_where_with_multiple_wheres_using_and_case", + "pypika/tests/test_selects.py::PreWhereTests::test_where_with_multiple_wheres_using_or_case", + "pypika/tests/test_selects.py::GroupByTests::test_group_by__single_with_totals", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__alias", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__alias_platforms", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__alias_with_join", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__count_distinct", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__count_field", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__count_star", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__int", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__multi", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__multi_with_totals", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__no_alias", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__no_alias_mssql", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__no_alias_oracle", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__single", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__str", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__sum_distinct", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__sum_filter", + "pypika/tests/test_selects.py::GroupByTests::test_groupby_with_case_uses_the_alias", + "pypika/tests/test_selects.py::GroupByTests::test_mssql_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_mysql_query_uses_backtick_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_oracle_query_uses_no_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_postgres_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_redshift_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_vertica_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_having_and", + "pypika/tests/test_selects.py::HavingTests::test_having_greater_than", + "pypika/tests/test_selects.py::HavingTests::test_having_join_and_equality", + "pypika/tests/test_selects.py::HavingTests::test_mssql_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_mysql_query_uses_backtick_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_oracle_query_uses_no_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_postgres_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_redshift_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_vertica_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_alias", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_asc", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_desc", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_multi_fields", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_no_alias", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_single_field", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_single_str", + "pypika/tests/test_selects.py::AliasTests::test_arithmetic_function", + "pypika/tests/test_selects.py::AliasTests::test_case_using_as", + "pypika/tests/test_selects.py::AliasTests::test_case_using_constructor_param", + "pypika/tests/test_selects.py::AliasTests::test_function_using_as_nested", + "pypika/tests/test_selects.py::AliasTests::test_functions_using_as", + "pypika/tests/test_selects.py::AliasTests::test_functions_using_constructor_param", + "pypika/tests/test_selects.py::AliasTests::test_functions_using_constructor_param_nested", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_criterion", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_criterion_comparison", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_field_inside_case", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_groupby", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_orderby", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_where", + "pypika/tests/test_selects.py::AliasTests::test_null_value_with_alias", + "pypika/tests/test_selects.py::AliasTests::test_select__multiple_tables", + "pypika/tests/test_selects.py::AliasTests::test_table_field", + "pypika/tests/test_selects.py::AliasTests::test_table_field__multi", + "pypika/tests/test_selects.py::AliasTests::test_table_with_schema_and_alias", + "pypika/tests/test_selects.py::AliasTests::test_use_aliases_in_groupby_and_orderby", + "pypika/tests/test_selects.py::SubqueryTests::test_from_subquery_without_alias", + "pypika/tests/test_selects.py::SubqueryTests::test_join", + "pypika/tests/test_selects.py::SubqueryTests::test_join_query_with_alias", + "pypika/tests/test_selects.py::SubqueryTests::test_join_with_with", + "pypika/tests/test_selects.py::SubqueryTests::test_select_from_nested_query", + "pypika/tests/test_selects.py::SubqueryTests::test_select_from_nested_query_with_join", + "pypika/tests/test_selects.py::SubqueryTests::test_select_from_with_returning", + "pypika/tests/test_selects.py::SubqueryTests::test_select_subquery", + "pypika/tests/test_selects.py::SubqueryTests::test_select_subquery_with_alias", + "pypika/tests/test_selects.py::SubqueryTests::test_where__equality", + "pypika/tests/test_selects.py::SubqueryTests::test_where__in", + "pypika/tests/test_selects.py::SubqueryTests::test_where__in_nested", + "pypika/tests/test_selects.py::SubqueryTests::test_with", + "pypika/tests/test_selects.py::QuoteTests::test_extraneous_quotes", + "pypika/tests/test_tables.py::TableStructureTests::test_database_schema_table_attr", + "pypika/tests/test_tables.py::TableStructureTests::test_schema_table_attr", + "pypika/tests/test_tables.py::TableStructureTests::test_table_for_period_sql", + "pypika/tests/test_tables.py::TableStructureTests::test_table_for_system_time_sql", + "pypika/tests/test_tables.py::TableStructureTests::test_table_sql", + "pypika/tests/test_tables.py::TableStructureTests::test_table_with_alias", + "pypika/tests/test_tables.py::TableStructureTests::test_table_with_schema_and_schema_parent_arg", + "pypika/tests/test_tables.py::TableStructureTests::test_table_with_schema_arg", + "pypika/tests/test_tables.py::TableEqualityTests::test_many_tables_with_alias", + "pypika/tests/test_tables.py::TableEqualityTests::test_many_tables_with_or_not_alias", + "pypika/tests/test_tables.py::TableEqualityTests::test_many_tables_without_alias", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_equal_by_name", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_equal_by_schema_and_name", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_equal_by_schema_and_name_using_schema", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_equal_by_schema_and_name_using_schema_with_parent", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_not_equal_by_schema_and_name_using_schema_with_different_parents", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_not_equal_with_different_names", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_not_equal_with_different_schemas", + "pypika/tests/test_tables.py::TableDialectTests::test_make_tables_factory_with_default_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_make_tables_factory_with_dialect_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_factory_with_default_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_factory_with_dialect_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_with_bad_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_with_default_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_with_dialect_query_cls", + "pypika/tests/test_terms.py::FieldAliasTests::test_when_alias_specified", + "pypika/tests/test_terms.py::FieldInitTests::test_init_with_str_table", + "pypika/tests/test_terms.py::FieldHashingTests::test_non_tabled_aliased_eq_fields_equally_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_non_tabled_aliased_ne_fields_differently_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_non_tabled_eq_fields_equally_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_non_tabled_ne_fields_differently_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_tabled_eq_fields_equally_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_tabled_ne_fields_differently_hashed", + "pypika/tests/test_terms.py::AtTimezoneTests::test_passes_kwargs_to_field_get_sql", + "pypika/tests/test_terms.py::AtTimezoneTests::test_when_alias_specified", + "pypika/tests/test_terms.py::AtTimezoneTests::test_when_interval_not_specified", + "pypika/tests/test_terms.py::AtTimezoneTests::test_when_interval_specified", + "pypika/tests/test_tuples.py::TupleTests::test_render_alias_in_array_sql", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_equality_tuple_on_both", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_equality_tuple_on_left", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_equality_tuple_on_right", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_in_using_mixed_tuples", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_in_using_pypika_tuples", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_in_using_python_tuples", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_is_aggregate", + "pypika/tests/test_tuples.py::TupleTests::test_tuples_in_join", + "pypika/tests/test_tuples.py::ArrayTests::test_array_general", + "pypika/tests/test_tuples.py::ArrayTests::test_empty_psql_array", + "pypika/tests/test_tuples.py::ArrayTests::test_psql_array_general", + "pypika/tests/test_tuples.py::ArrayTests::test_render_alias_in_array_sql", + "pypika/tests/test_tuples.py::BracketTests::test_arithmetic_with_brackets", + "pypika/tests/test_tuples.py::BracketTests::test_arithmetic_with_brackets_and_alias", + "pypika/tests/test_updates.py::UpdateTests::test_empty_query", + "pypika/tests/test_updates.py::UpdateTests::test_for_portion", + "pypika/tests/test_updates.py::UpdateTests::test_omit_where", + "pypika/tests/test_updates.py::UpdateTests::test_single_quote_escape_in_set", + "pypika/tests/test_updates.py::UpdateTests::test_update__table_schema", + "pypika/tests/test_updates.py::UpdateTests::test_update_from", + "pypika/tests/test_updates.py::UpdateTests::test_update_from_with_where", + "pypika/tests/test_updates.py::UpdateTests::test_update_with_join", + "pypika/tests/test_updates.py::UpdateTests::test_update_with_limit", + "pypika/tests/test_updates.py::UpdateTests::test_update_with_none", + "pypika/tests/test_updates.py::UpdateTests::test_update_with_statement", + "pypika/tests/test_updates.py::PostgresUpdateTests::test_update_returning", + "pypika/tests/test_updates.py::PostgresUpdateTests::test_update_returning_from_different_tables", + "pypika/tests/test_updates.py::PostgresUpdateTests::test_update_returning_star", + "pypika/tests/test_updates.py::PostgresUpdateTests::test_update_returning_str", + "pypika/tests/test_updates.py::SQLLiteUpdateTests::test_update_with_bool", + "pypika/tests/test_utils.py::ImmutabilityTests::test_raise_attribute_error_for_deepcopy", + "pypika/tests/test_utils.py::ImmutabilityTests::test_raise_attribute_error_for_getnewargs", + "pypika/tests/test_utils.py::ImmutabilityTests::test_raise_attribute_error_for_getstate", + "pypika/tests/test_utils.py::ImmutabilityTests::test_raise_attribute_error_for_setstate" + ] +} diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/grade.py b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/grade.py new file mode 100644 index 0000000000000000000000000000000000000000..e3b37293830e51a5c5833c93c4705e1ed9364257 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/grade.py @@ -0,0 +1,128 @@ +"""Trusted private pytest panel runner. Installed only in a fresh grader Job.""" + +import hashlib +import importlib.util +import json +import os +import shutil +import stat +import subprocess +from pathlib import Path, PurePosixPath + + +def sha(raw): + return hashlib.sha256(raw).hexdigest() + + +def safe(value): + path = PurePosixPath(value) + if ( + path.is_absolute() + or path.as_posix() != value + or not path.parts + or any(part in {".", "..", ".git"} for part in path.parts) + ): + raise ValueError("Unsafe trusted test path") + return path + + +def restore(worktree, private, manifest): + worktree, private = Path(worktree), Path(private) + captured = {} + for name, expected in manifest["files"].items(): + path = private / safe(name) + info = path.lstat() + raw = path.read_bytes() if stat.S_ISREG(info.st_mode) else b"" + if ( + not stat.S_ISREG(info.st_mode) + or len(raw) != expected["bytes"] + or sha(raw) != expected["sha256"] + or stat.S_IMODE(info.st_mode) != expected["mode"] + ): + raise ValueError("Trusted private test bytes or modes drifted") + captured[name] = (raw, expected["mode"]) + # Capture and verify every private byte before changing the submitted tree. + for name in manifest["directory_roots"]: + destination = worktree / safe(name) + if destination.is_symlink(): + raise ValueError("Submitted test directory is a symlink") + for parent in destination.parents: + if parent == worktree: + break + if parent.is_symlink(): + raise ValueError("Submitted test parent is a symlink") + if destination.exists(): + if not destination.is_dir(): + raise ValueError("Submitted test directory is not a directory") + shutil.rmtree(destination) + for name, (raw, mode) in captured.items(): + destination = worktree / safe(name) + for parent in destination.parents: + if parent == worktree: + break + if parent.is_symlink(): + raise ValueError("Submitted test parent is a symlink") + if destination.is_symlink(): + raise ValueError("Submitted trusted file is a symlink") + destination.parent.mkdir(parents=True, exist_ok=True) + destination.write_bytes(raw) + destination.chmod(mode) + + +def run(worktree, private_root, output, invoke=None): + private_root, output, worktree = Path(private_root), Path(output), Path(worktree) + expected = json.loads((private_root / "expected-panels.json").read_bytes()) + config = json.loads((private_root / "panel-config.json").read_bytes()) + manifest = json.loads((private_root / "trusted-inventory.json").read_bytes()) + restore(worktree, private_root / "trusted", manifest) + output.mkdir(parents=True, exist_ok=True) + for name in ( + "reward.txt", + "pass-to-pass.xml", + "fail-to-pass.xml", + "pytest-evidence.json", + ): + (output / name).unlink(missing_ok=True) + environment = dict(os.environ) + for key in ("PYTEST_ADDOPTS", "PYTEST_DISABLE_PLUGIN_AUTOLOAD", "PYTHONPATH"): + environment.pop(key, None) + commands, native_exit = [], 0 + invoke = invoke or subprocess.run + for group in ("pass-to-pass", "fail-to-pass"): + if ( + not isinstance(expected[group], list) + or not expected[group] + or any( + not isinstance(target, str) or not target for target in expected[group] + ) + ): + raise ValueError("Frozen native pytest selectors are incomplete") + command = [ + *config["official_pytest_argv"], + "--override-ini=addopts=", + "--junitxml=" + str(output / (group + ".xml")), + *expected[group], + ] + result = invoke(command, cwd=worktree, env=environment, check=False) + native_exit = result.returncode + commands.append({"group": group, "argv": command, "exit_code": native_exit}) + if native_exit != 0: + break + (output / "pytest-commands.json").write_text( + json.dumps(commands, sort_keys=True) + "\n" + ) + spec = importlib.util.spec_from_file_location( + "trusted_pytest_result", private_root / "check_pytest.py" + ) + checker = importlib.util.module_from_spec(spec) + spec.loader.exec_module(checker) + result = checker.assess(output, expected, native_exit) + (output / "reward.txt").write_text(str(result["reward"]) + "\n") + (output / "pytest-evidence.json").write_text( + json.dumps(result, sort_keys=True) + "\n" + ) + return result + + +if __name__ == "__main__": + run("/testbed/repo", "/tests", "/logs/verifier") diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/panel-config.json b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/panel-config.json new file mode 100644 index 0000000000000000000000000000000000000000..6417b9c92e5da5b97ee641bd54f798302af42a31 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/panel-config.json @@ -0,0 +1,28 @@ +{ + "dependency_installation_pinned": false, + "official_install_cmds": [ + "python -m pip install -e ." + ], + "official_pytest_argv": [ + "pytest", + "--disable-warnings", + "--color=no", + "--tb=no", + "--verbose" + ], + "official_test_command": "source /opt/miniconda3/bin/activate; conda activate testbed; pytest --disable-warnings --color=no --tb=no --verbose", + "operator_test_runner_prerequisites": [ + "python -m pip install pytest==8.4.2" + ], + "operator_test_runner_reason": "The official profile invokes pytest, but the common tools runtime does not provide it; pinned separately from source-native project requirements.", + "panel_normalization": "Override project addopts only to execute the exact frozen native panels; add JUnit output, preserve official pytest options and all selectors.", + "python_version": "3.10", + "source_bound_test_dependency_cmds": [ + "python -m pip install parameterized==0.7.0" + ], + "test_dependency_source_sha256": { + "requirements-dev.txt": "10f4ba7b19a73950d28fd7403d7e1d1b1fe2ccc4f49516974f47199d2965f23d", + "setup.py": "f8bad274588a22e65764d8cf9fb2be5aa6fcfaf3bf861d71e5f751105898845a", + "tox.ini": "c2d7205d0ac93e9c9e80dc5d24f0a826a6781f587a33ea722ea621f9e2ccd0ea" + } +} diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/test.sh b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..81b6d0620f05dbd3b54b4e7ea5de04ce3f8a98e2 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/test.sh @@ -0,0 +1,6 @@ +#!/bin/bash +set -Eeuo pipefail +source /opt/miniconda3/bin/activate +conda activate testbed +cd /testbed/repo +exec python -I /tests/grade.py diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted-inventory.json b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted-inventory.json new file mode 100644 index 0000000000000000000000000000000000000000..6926ef1c22ed56457101c37cd70e0fe0d1656f0c --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted-inventory.json @@ -0,0 +1,242 @@ +{ + "directory_roots": [ + "pypika/tests" + ], + "files": { + "pypika/tests/__init__.py": { + "bytes": 58, + "mode": 420, + "sha256": "7d41f44b87688bdf162e6d5cbe7b517cfba468f96eaa421f02718c17eb486a18" + }, + "pypika/tests/clickhouse/__init__.py": { + "bytes": 0, + "mode": 420, + "sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "pypika/tests/clickhouse/test_array.py": { + "bytes": 2942, + "mode": 420, + "sha256": "0f0a5b4c3daf3ddce2944b6119795e80d50b74e4687ef2e34399e5d21d3d48ae" + }, + "pypika/tests/clickhouse/test_condition.py": { + "bytes": 2533, + "mode": 420, + "sha256": "c666976d082b1d12cd57e791d1a525183246335efad96a369b58871a6f1e4fa1" + }, + "pypika/tests/clickhouse/test_dates_and_times.py": { + "bytes": 2508, + "mode": 420, + "sha256": "cb8ea84363e35ad0a00b52a8ec20cb38f2348f4cba28d026a4c32c14fd1fc56f" + }, + "pypika/tests/clickhouse/test_nullable_arg.py": { + "bytes": 672, + "mode": 420, + "sha256": "883c5161ebeb09544ce124d20a096d248bd12a0404ad77c84637be75d6738529" + }, + "pypika/tests/clickhouse/test_search_string.py": { + "bytes": 1189, + "mode": 420, + "sha256": "d5f0ed6a51cf550bdd4b261fa2e98084184dd1cbb08f5dbb8b91278b4c8f3bfd" + }, + "pypika/tests/clickhouse/test_type_conversion.py": { + "bytes": 4445, + "mode": 420, + "sha256": "7e6045b64433a8947346cfb34ac30279349f7a2e2081a2815212c8cb7d0235ab" + }, + "pypika/tests/dialects/__init__.py": { + "bytes": 0, + "mode": 420, + "sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "pypika/tests/dialects/test_clickhouse.py": { + "bytes": 5747, + "mode": 420, + "sha256": "2272538d6eeb6dfb01f9803eed328b4cd4efc8d255b6a8ab3c4e25bee74d73fa" + }, + "pypika/tests/dialects/test_mssql.py": { + "bytes": 3152, + "mode": 420, + "sha256": "0cd9b2ee6498caa9fa75a51ead30803057fb23deb2ac706d396d88329e0e91d7" + }, + "pypika/tests/dialects/test_mysql.py": { + "bytes": 2984, + "mode": 420, + "sha256": "a5f4550dd14bf4820e5d85cf06b6c7c79286e41d2d3c794f639579d20fffab92" + }, + "pypika/tests/dialects/test_oracle.py": { + "bytes": 1906, + "mode": 420, + "sha256": "67f80eb40cc9b4dabcbad355e8be6d83c54a64cbee809182ef57fa9f48d2ebc6" + }, + "pypika/tests/dialects/test_postgresql.py": { + "bytes": 9532, + "mode": 420, + "sha256": "548ee7267ca87c9e1ae82ca89a4e5bd96c7392a55cc07996f2b105f911ffa6cf" + }, + "pypika/tests/dialects/test_snowflake.py": { + "bytes": 2159, + "mode": 420, + "sha256": "e567b9dab0a5366bd11a0ef162c3a3bb492280b78bc4b397a23070563dc84468" + }, + "pypika/tests/dialects/test_sqllite.py": { + "bytes": 1243, + "mode": 420, + "sha256": "118fed7e575415f276bda390a119080bd6a767aee3d9c953e11a8c219f0f017c" + }, + "pypika/tests/dialects/test_vertica.py": { + "bytes": 3578, + "mode": 420, + "sha256": "33a027e6735ca03b7afd11394905c4193e48a15dda3efbe47cdcd85fcabf840c" + }, + "pypika/tests/test_aggregate.py": { + "bytes": 3946, + "mode": 420, + "sha256": "5b0fb549de3bb50ad88ae1d75824f12f7ab4a5f1102b06a70c7b2ebae33bea6d" + }, + "pypika/tests/test_analytic_queries.py": { + "bytes": 20611, + "mode": 420, + "sha256": "8546b7a296c8e212c349c4baff95f93934b3120f74625b3945ade3b438e3a3ed" + }, + "pypika/tests/test_create.py": { + "bytes": 9088, + "mode": 420, + "sha256": "6c57302da52ca1044be0afdafe677d5de245e44873dff1386c9a1ccb2625cc82" + }, + "pypika/tests/test_criterions.py": { + "bytes": 32014, + "mode": 420, + "sha256": "78539ccca82f9a02fad0f5a39041ac343e3a142ce52368cd4f6ada489c52516a" + }, + "pypika/tests/test_custom_functions.py": { + "bytes": 1710, + "mode": 420, + "sha256": "bfa18bc328a3577965db7cc75eb94439f0cfd95a3775d9b1cc8af1062bb202cb" + }, + "pypika/tests/test_data_types.py": { + "bytes": 403, + "mode": 420, + "sha256": "c1be6ecc621a80dd91d35b1427bdfc8b1b33bd926515198e626d6fb5e1878c8b" + }, + "pypika/tests/test_date_math.py": { + "bytes": 5544, + "mode": 420, + "sha256": "85aa54efe54fe19639f2dc2a5750647e3337ac2681768bc3fe327841f1634d9e" + }, + "pypika/tests/test_deletes.py": { + "bytes": 3204, + "mode": 420, + "sha256": "ccde6df760d76d5d499ce828f6b0e2ad3eebcb2a5553c1890f481b9160b8d51a" + }, + "pypika/tests/test_drop.py": { + "bytes": 1556, + "mode": 420, + "sha256": "a13dffa59ef8657398d5498c18977bfd702635e336ea9966b1a86137afca7926" + }, + "pypika/tests/test_formats.py": { + "bytes": 1948, + "mode": 420, + "sha256": "240458a404bb119322778893b94a12be0f98f914acd701d2b4be73eb9be96f75" + }, + "pypika/tests/test_functions.py": { + "bytes": 32769, + "mode": 420, + "sha256": "3ceaac7791bd27e50f44e1b4a1451d1e09afe6a8011052caea838e5124582154" + }, + "pypika/tests/test_groupby_modifiers.py": { + "bytes": 5227, + "mode": 420, + "sha256": "9db4497660f08e3352a9a02c34889ad1cd6bab3aebaeaa485e84390ad71c84c5" + }, + "pypika/tests/test_immutability.py": { + "bytes": 3954, + "mode": 420, + "sha256": "af537ced19f7274951cc91697eae748ef6c9cd20a8d8e492d93dc85b06f8fb50" + }, + "pypika/tests/test_inserts.py": { + "bytes": 32549, + "mode": 420, + "sha256": "652e9f7f0f425e9acc0f70e2851ae29310b378262ea30369ea0113ef428f210f" + }, + "pypika/tests/test_internals.py": { + "bytes": 828, + "mode": 420, + "sha256": "4374c2632563346d00ca4de6af397a022ef3f5022e808c8711a3f207a3a21609" + }, + "pypika/tests/test_joins.py": { + "bytes": 43895, + "mode": 420, + "sha256": "53f224815c10393382443f020cb20e313420764495a8fd30f7ea2f34fd52935d" + }, + "pypika/tests/test_negation.py": { + "bytes": 763, + "mode": 420, + "sha256": "6be105e8f39b32fb23e6ac7c7158232ee78111455d4f35638c8af60781138c79" + }, + "pypika/tests/test_parameter.py": { + "bytes": 7382, + "mode": 420, + "sha256": "aaf2a3e79c8267bdc60e218445bc2a2254b97cf37b643a44d6f1a8141cbb5104" + }, + "pypika/tests/test_pseudocolumns.py": { + "bytes": 1609, + "mode": 420, + "sha256": "b7c69f7aca41323c0e14a6a9e58697399cd7860610f07291afc6e8af26079ca2" + }, + "pypika/tests/test_query.py": { + "bytes": 9025, + "mode": 420, + "sha256": "2da9d717673912a84e86e6c0d3955dbd8f2fa7b41b7ed9a6f78089dfa28f9444" + }, + "pypika/tests/test_selects.py": { + "bytes": 50757, + "mode": 420, + "sha256": "5ac1b7ad3248d64b1e3865a72c763873514ae5cd6e03356b913e531c0c336986" + }, + "pypika/tests/test_tables.py": { + "bytes": 6568, + "mode": 420, + "sha256": "384c8e843ba56374ee92cd7b7e2fd3f89247b899e23cd9e1f6663d751ad5d884" + }, + "pypika/tests/test_terms.py": { + "bytes": 3215, + "mode": 420, + "sha256": "8598513180ddcd28cc61582618d85bd570280978b07603044dae81b2eb099f77" + }, + "pypika/tests/test_tuples.py": { + "bytes": 6033, + "mode": 420, + "sha256": "863942196a93e8939be0d03c49cfeb42a35503ad42f9f3d6c730260112811087" + }, + "pypika/tests/test_updates.py": { + "bytes": 5689, + "mode": 420, + "sha256": "0f0f2521bb8d1f5d782f8fabaea5fd1d82090cde045ba87fad65770db6c75d2f" + }, + "pypika/tests/test_utils.py": { + "bytes": 834, + "mode": 420, + "sha256": "5db6e90df5daaa70b9f35f1243db69908da1f27887f63466fc27ce20c7e14892" + }, + "pyproject.toml": { + "bytes": 390, + "mode": 420, + "sha256": "037fedacd5be5d078f398265ff97e1677e25214ad8839d17073a439695ee7a91" + }, + "setup.cfg": { + "bytes": 317, + "mode": 420, + "sha256": "c84a31de586e8385e741127b004fc1f19ebae6463cdf0b3f243991db35cdeaea" + }, + "setup.py": { + "bytes": 2638, + "mode": 420, + "sha256": "f8bad274588a22e65764d8cf9fb2be5aa6fcfaf3bf861d71e5f751105898845a" + }, + "tox.ini": { + "bytes": 257, + "mode": 420, + "sha256": "c2d7205d0ac93e9c9e80dc5d24f0a826a6781f587a33ea722ea621f9e2ccd0ea" + } + } +} diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/__init__.py b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..86d8a68101915c27b95484243dd81d55f7dba356 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/__init__.py @@ -0,0 +1,2 @@ +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/clickhouse/__init__.py b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/clickhouse/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/clickhouse/test_array.py b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/clickhouse/test_array.py new file mode 100644 index 0000000000000000000000000000000000000000..469705a9ff3c8fe9cc7f02c44a9812521eeb67f4 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/clickhouse/test_array.py @@ -0,0 +1,104 @@ +import unittest + +from parameterized import parameterized + +from pypika import Field +from pypika.clickhouse.array import ( + Array, + Empty, + HasAny, + Length, + NotEmpty, +) +from pypika.clickhouse.type_conversion import ( + ToFixedString, + ToInt64, +) + + +class TestArray(unittest.TestCase): + @parameterized.expand( + [ + ( + "['ridley', 'scott', 'jimi', 'hendrix']", + Array(["ridley", "scott", "jimi", "hendrix"]), + ), + ( + "[1, 2, 3, 4]", + Array([1, 2, 3, 4]), + ), + ( + "[toInt64('1'),toInt64('2'),toInt64('3'),toInt64('4')]", + Array(["1", "2", "3", "4"], ToInt64), + ), + ( + "[toFixedString('mogwai',10),toFixedString('mono',10),toFixedString('bonobo',10)] arr", + Array(["mogwai", "mono", "bonobo"], ToFixedString, {"length": 10}).as_('arr'), + ), + ] + ) + def test_get_sql(self, expected: str, array: Array): + self.assertEqual(expected, array.get_sql()) + + +class TestHasAny(unittest.TestCase): + @parameterized.expand( + [ + ( + 'hasAny("mental_abilities","physical_abilities")', + HasAny(Field("mental_abilities"), Field("physical_abilities")), + ), + ("hasAny([1, 2, 3, 4],[3])", HasAny(Array([1, 2, 3, 4]), Array([3]))), + ( + "hasAny(\"bands\",[toFixedString('port-royal',20),toFixedString('hammock',20)])", + HasAny( + Field("bands"), + Array(["port-royal", "hammock"], ToFixedString, {"length": 20}), + ), + ), + ] + ) + def test_get_sql(self, expected: str, func: HasAny): + self.assertEqual(expected, func.get_sql()) + + +class TestLength(unittest.TestCase): + @parameterized.expand( + [ + ( + 'length("tags")', + Length(Field("tags")), + ), + ("length([1, 2, 3])", Length(Array([1, 2, 3]))), + ] + ) + def test_get_sql(self, expected: str, func: Length): + self.assertEqual(expected, func.get_sql()) + + +class TestEmpty(unittest.TestCase): + @parameterized.expand( + [ + ( + 'empty("tags")', + Empty(Field("tags")), + ), + ("empty([1, 2, 3])", Empty(Array([1, 2, 3]))), + ] + ) + def test_get_sql(self, expected: str, func: Empty): + self.assertEqual(expected, func.get_sql()) + + +class TestNotEmpty(unittest.TestCase): + @parameterized.expand( + [ + ( + 'notEmpty("tags")', + NotEmpty(Field("tags")), + ), + ("notEmpty([1, 2, 3])", NotEmpty(Array([1, 2, 3]))), + ] + ) + def test_get_sql(self, expected: str, func: NotEmpty): + self.assertEqual(expected, func.get_sql()) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/clickhouse/test_condition.py b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/clickhouse/test_condition.py new file mode 100644 index 0000000000000000000000000000000000000000..145baeb7753dd9cbefbd6f272bd672ae5730b0c0 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/clickhouse/test_condition.py @@ -0,0 +1,72 @@ +import unittest + +from parameterized import parameterized + +from pypika import Field +from pypika.clickhouse.condition import If, MultiIf +from pypika.clickhouse.type_conversion import ToFixedString + + +class TestIfCondition(unittest.TestCase): + @parameterized.expand( + [ + ( + If( + Field("filmmaker").isnull(), + ToFixedString("Tarantino", 20), + Field("filmmaker"), + ), + "if(filmmaker IS NULL,toFixedString('Tarantino',20),filmmaker)", + ), + ( + If( + Field("created") == Field("updated"), + ToFixedString("yes", 3), + ToFixedString("no", 3), + ), + "if(created=updated,toFixedString('yes',3),toFixedString('no',3))", + ), + ] + ) + def test_get_sql(self, func, expected): + self.assertEqual(func.get_sql(), expected) + + +class TestMultiIfCondition(unittest.TestCase): + @parameterized.expand( + [ + ( + MultiIf( + Field("filmmaker").isnull(), + ToFixedString("Tarantino", 20), + Field("filmmaker") == ToFixedString("undefined", 20), + ToFixedString("Tarantino", 20), + Field("filmmaker"), + ), + "multiIf(filmmaker IS NULL," + "toFixedString('Tarantino',20)," + "filmmaker=toFixedString('undefined',20)," + "toFixedString('Tarantino',20),filmmaker)", + ), + ( + MultiIf( + Field("color") == ToFixedString("black", 20), + ToFixedString("dark", 20), + Field("color") == ToFixedString("grey", 20), + ToFixedString("dark", 20), + Field("color") == ToFixedString("white", 20), + ToFixedString("light", 20), + ToFixedString("undefined", 20), + ), + "multiIf(color=toFixedString('black',20)," + "toFixedString('dark',20)," + "color=toFixedString('grey',20)," + "toFixedString('dark',20)," + "color=toFixedString('white',20)," + "toFixedString('light',20)," + "toFixedString('undefined',20))", + ), + ] + ) + def test_get_sql(self, func, expected): + self.assertEqual(func.get_sql(), expected) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/clickhouse/test_dates_and_times.py b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/clickhouse/test_dates_and_times.py new file mode 100644 index 0000000000000000000000000000000000000000..135dd7f112131776d76748e15eead1eb81752b59 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/clickhouse/test_dates_and_times.py @@ -0,0 +1,70 @@ +import unittest + +from parameterized import parameterized + +from pypika import Field +from pypika.clickhouse.dates_and_times import ( + AddDays, + AddHours, + AddMinutes, + AddMonths, + AddQuarters, + AddSeconds, + AddWeeks, + AddYears, + FormatDateTime, + SubtractDays, + SubtractHours, + SubtractMinutes, + SubtractMonths, + SubtractQuarters, + SubtractSeconds, + SubtractWeeks, + SubtractYears, + ToYYYYMM, +) + + +class TestFormatDateTime(unittest.TestCase): + @parameterized.expand( + [ + (FormatDateTime(Field("created"), "%V"), "formatDateTime(created,'%V')"), + ( + FormatDateTime(Field("created"), "%Y-%m-%d"), + "formatDateTime(created,'%Y-%m-%d')", + ), + ] + ) + def test_get_sql(self, func, expected): + self.assertEqual(func.get_sql(), expected) + + +class TestAddSubtractDt(unittest.TestCase): + @parameterized.expand( + [ + (AddYears(Field("created"), 1), "addYears(created,1)"), + (AddMonths(Field("created"), 2), "addMonths(created,2)"), + (AddWeeks(Field("created"), 3), "addWeeks(created,3)"), + (AddDays(Field("created"), 4), "addDays(created,4)"), + (AddHours(Field("created"), 5), "addHours(created,5)"), + (AddMinutes(Field("created"), 6), "addMinutes(created,6)"), + (AddSeconds(Field("created"), 7), "addSeconds(created,7)"), + (AddQuarters(Field("created"), 8), "addQuarters(created,8)"), + (SubtractYears(Field("created"), 9), "subtractYears(created,9)"), + (SubtractMonths(Field("created"), 10), "subtractMonths(created,10)"), + (SubtractWeeks(Field("created"), 11), "subtractWeeks(created,11)"), + (SubtractDays(Field("created"), 12), "subtractDays(created,12)"), + (SubtractHours(Field("created"), 13), "subtractHours(created,13)"), + (SubtractHours(Field("created"), 13), "subtractHours(created,13)"), + (SubtractMinutes(Field("created"), 14), "subtractMinutes(created,14)"), + (SubtractSeconds(Field("created"), 15), "subtractSeconds(created,15)"), + (SubtractQuarters(Field("created"), 16), "subtractQuarters(created,16)"), + ] + ) + def test_get_sql(self, func, expected): + self.assertEqual(func.get_sql(), expected) + + +class TestToYYYYMM(unittest.TestCase): + def test_get_sql(self): + self.assertEqual(ToYYYYMM(Field("created").get_sql()), "toYYYYMM(created)") diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/clickhouse/test_nullable_arg.py b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/clickhouse/test_nullable_arg.py new file mode 100644 index 0000000000000000000000000000000000000000..3c6c86207a4d0206b5c0ba80b77fac4cc257fa17 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/clickhouse/test_nullable_arg.py @@ -0,0 +1,24 @@ +import unittest + +from parameterized import parameterized + +from pypika import Field +from pypika.clickhouse.nullable_arg import IfNull +from pypika.clickhouse.type_conversion import ToFixedString + + +class TestSearchString(unittest.TestCase): + @parameterized.expand( + [ + ( + IfNull(Field("name"), Field("login")), + "ifNull(name,login)", + ), + ( + IfNull(Field("builder"), ToFixedString("pypika", 100)), + "ifNull(builder,toFixedString('pypika',100))", + ), + ] + ) + def test_get_sql(self, func, expected): + self.assertEqual(func.get_sql(), expected) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/clickhouse/test_search_string.py b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/clickhouse/test_search_string.py new file mode 100644 index 0000000000000000000000000000000000000000..9778eb32e47d4370c0bfe36dcd875903666d30b6 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/clickhouse/test_search_string.py @@ -0,0 +1,41 @@ +import unittest + +from parameterized import parameterized + +from pypika import Field +from pypika.clickhouse.search_string import ( + Match, + Like, + NotLike, + MultiSearchAny, + MultiMatchAny, +) + + +class TestSearchString(unittest.TestCase): + @parameterized.expand( + [ + (Match(Field("name"), "twheys"), "match(toString(\"name\"),'twheys')"), + (Like(Field("name"), "twheys"), "like(toString(\"name\"),'twheys')"), + (NotLike(Field("name"), "twheys"), "notLike(toString(\"name\"),'twheys')"), + ] + ) + def test_search_string(self, func, expected): + self.assertEqual(func, expected) + + +class TestMultiSearch(unittest.TestCase): + @parameterized.expand( + [ + ( + MultiSearchAny(Field("name"), ["sarah", "connor"]), + "multiSearchAny(toString(\"name\"),['sarah','connor'])", + ), + ( + MultiMatchAny(Field("name"), ["sarah", "connor"]), + "multiMatchAny(toString(\"name\"),['sarah','connor'])", + ), + ] + ) + def test_multi_search_string(self, func, expected): + self.assertEqual(func.get_sql(), expected) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/clickhouse/test_type_conversion.py b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/clickhouse/test_type_conversion.py new file mode 100644 index 0000000000000000000000000000000000000000..9692e17bee901e2629db9a5c77111e145358e8eb --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/clickhouse/test_type_conversion.py @@ -0,0 +1,176 @@ +import unittest + +from parameterized import parameterized + +from pypika import ClickHouseQuery, Field, Table +from pypika.clickhouse.type_conversion import ( + ToDate, + ToDateTime, + ToFixedString, + ToFloat32, + ToFloat64, + ToInt16, + ToInt32, + ToInt64, + ToInt8, + ToString, + ToUInt16, + ToUInt32, + ToUInt64, + ToUInt8, +) + + +class TestBasicTypeConverters(unittest.TestCase): + @parameterized.expand( + [ + ( + 'toString("field_name")', + ToString(Field("field_name")), + ), + ( + 'toInt8("field_name")', + ToInt8(Field("field_name")), + ), + ( + 'toInt16("field_name")', + ToInt16(Field("field_name")), + ), + ( + 'toInt32("field_name")', + ToInt32(Field("field_name")), + ), + ( + 'toInt64("field_name")', + ToInt64(Field("field_name")), + ), + ( + 'toUInt8("field_name")', + ToUInt8(Field("field_name")), + ), + ( + 'toUInt16("field_name")', + ToUInt16(Field("field_name")), + ), + ( + 'toUInt32("field_name")', + ToUInt32(Field("field_name")), + ), + ( + 'toUInt64("field_name")', + ToUInt64(Field("field_name")), + ), + ( + 'toFloat32("field_name")', + ToFloat32(Field("field_name")), + ), + ( + 'toFloat64("field_name")', + ToFloat64(Field("field_name")), + ), + ( + 'toFloat64("field_name")', + ToFloat64(Field("field_name")), + ), + ( + 'toDate("field_name")', + ToDate(Field("field_name")), + ), + ( + 'toDateTime("field_name")', + ToDateTime(Field("field_name")), + ), + ( + 'toFixedString("field_name",100)', + ToFixedString(Field("field_name"), 100), + ), + ] + ) + def test_basic_types_field(self, expected, func): + self.assertEqual(func, expected) + + @parameterized.expand( + [ + ( + "toString('100')", + ToString("100"), + ), + ( + "toInt8('100')", + ToInt8("100"), + ), + ( + "toInt16('100')", + ToInt16("100"), + ), + ( + "toInt32('100')", + ToInt32("100"), + ), + ( + "toInt64('100')", + ToInt64("100"), + ), + ( + "toUInt8('100')", + ToUInt8("100"), + ), + ( + "toUInt16('100')", + ToUInt16("100"), + ), + ( + "toUInt32('100')", + ToUInt32("100"), + ), + ( + "toUInt64('100')", + ToUInt64("100"), + ), + ( + "toFloat32('100')", + ToFloat32("100"), + ), + ( + "toFloat64('100')", + ToFloat64("100"), + ), + ( + "toFloat64('100')", + ToFloat64("100"), + ), + ( + "toDate('100')", + ToDate("100"), + ), + ( + "toDateTime('100')", + ToDateTime("100"), + ), + ( + "toFixedString('100',100)", + ToFixedString("100", 100), + ), + ] + ) + def test_basic_types_value(self, expected, func): + self.assertEqual(func, expected) + + +class TestToFixedString(unittest.TestCase): + def test_get_sql_with_table(self): + table = Table("example") + query = ( + ClickHouseQuery.from_(table) + .select( + table.name, + ) + .where( + table.name == ToFixedString("name", 50), + ) + ) + + self.assertEqual( + 'SELECT "name" FROM "example" WHERE "name"=toFixedString(\'name\',50)', + query.get_sql(), + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/dialects/__init__.py b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/dialects/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/dialects/test_clickhouse.py b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/dialects/test_clickhouse.py new file mode 100644 index 0000000000000000000000000000000000000000..f319c4627bd25d7004894181906a284b8b1c64cf --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/dialects/test_clickhouse.py @@ -0,0 +1,146 @@ +from unittest import TestCase + +from pypika import ( + ClickHouseQuery, + Database, + Table, +) + + +class ClickHouseQueryTests(TestCase): + def test_use_AS_keyword_for_alias(self): + t = Table('abc') + query = ClickHouseQuery.from_(t).select(t.foo.as_('f1'), t.bar.as_('f2')) + self.assertEqual(str(query), 'SELECT "foo" AS "f1","bar" AS "f2" FROM "abc"') + + def test_use_SAMPLE_keyword(self): + t = Table('abc') + query = ClickHouseQuery.from_(t).select(t.foo).sample(10) + self.assertEqual(str(query), 'SELECT "foo" FROM "abc" SAMPLE 10') + + def test_use_SAMPLE_with_offset_keyword(self): + t = Table('abc') + query = ClickHouseQuery.from_(t).select(t.foo).sample(10, 5) + self.assertEqual(str(query), 'SELECT "foo" FROM "abc" SAMPLE 10 OFFSET 5') + + def test_use_FINAL_keyword(self): + t = Table('abc') + query = ClickHouseQuery.from_(t).select(t.foo).final() + self.assertEqual(str(query), 'SELECT "foo" FROM "abc" FINAL') + + +class ClickHouseDeleteTests(TestCase): + table_abc = Table("abc") + + def test_omit_where(self): + q = ClickHouseQuery.from_("abc").delete() + + self.assertEqual('ALTER TABLE "abc" DELETE', str(q)) + + def test_omit_where__table_schema(self): + q = ClickHouseQuery.from_(Table("abc", "schema1")).delete() + + self.assertEqual('ALTER TABLE "schema1"."abc" DELETE', str(q)) + + def test_where_field_equals(self): + q1 = ClickHouseQuery.from_(self.table_abc).where(self.table_abc.foo == self.table_abc.bar).delete() + q2 = ClickHouseQuery.from_(self.table_abc).where(self.table_abc.foo.eq(self.table_abc.bar)).delete() + + self.assertEqual('ALTER TABLE "abc" DELETE WHERE "foo"="bar"', str(q1)) + self.assertEqual('ALTER TABLE "abc" DELETE WHERE "foo"="bar"', str(q2)) + + +class ClickHouseUpdateTests(TestCase): + table_abc = Table("abc") + + def test_update(self): + q = ClickHouseQuery.update(self.table_abc).where(self.table_abc.foo == 0).set("foo", "bar") + + self.assertEqual('ALTER TABLE "abc" UPDATE "foo"=\'bar\' WHERE "foo"=0', str(q)) + + +class ClickHouseDropQuery(TestCase): + table_abc = Table("abc") + database_xyz = Database("mydb") + cluster_name = "mycluster" + + def test_drop_database(self): + q1 = ClickHouseQuery.drop_database(self.database_xyz) + q2 = ClickHouseQuery.drop_database(self.database_xyz).on_cluster(self.cluster_name) + q3 = ClickHouseQuery.drop_database(self.database_xyz).if_exists().on_cluster(self.cluster_name) + + self.assertEqual('DROP DATABASE "mydb"', str(q1)) + self.assertEqual('DROP DATABASE "mydb" ON CLUSTER "mycluster"', str(q2)) + self.assertEqual('DROP DATABASE IF EXISTS "mydb" ON CLUSTER "mycluster"', str(q3)) + + def test_drop_table(self): + q1 = ClickHouseQuery.drop_table(self.table_abc) + q2 = ClickHouseQuery.drop_table(self.table_abc).on_cluster(self.cluster_name) + q3 = ClickHouseQuery.drop_table(self.table_abc).if_exists().on_cluster(self.cluster_name) + + self.assertEqual('DROP TABLE "abc"', str(q1)) + self.assertEqual('DROP TABLE "abc" ON CLUSTER "mycluster"', str(q2)) + self.assertEqual('DROP TABLE IF EXISTS "abc" ON CLUSTER "mycluster"', str(q3)) + + def test_drop_dictionary(self): + q1 = ClickHouseQuery.drop_dictionary("dict") + q2 = ClickHouseQuery.drop_dictionary("dict").on_cluster(self.cluster_name) + q3 = ClickHouseQuery.drop_dictionary("dict").if_exists().on_cluster(self.cluster_name) + + self.assertEqual('DROP DICTIONARY "dict"', str(q1)) + self.assertEqual('DROP DICTIONARY "dict"', str(q2)) # NO CLUSTER + self.assertEqual('DROP DICTIONARY IF EXISTS "dict"', str(q3)) # NO CLUSTER + + def test_drop_other(self): + q1 = ClickHouseQuery.drop_quota("myquota") + q2 = ClickHouseQuery.drop_user("myuser") + q3 = ClickHouseQuery.drop_view("myview") + + self.assertEqual('DROP QUOTA "myquota"', str(q1)) + self.assertEqual('DROP USER "myuser"', str(q2)) + self.assertEqual('DROP VIEW "myview"', str(q3)) + + +class DistinctOnTests(TestCase): + table_abc = Table("abc") + + def test_distinct_on(self): + q = ClickHouseQuery.from_(self.table_abc).distinct_on("lname", self.table_abc.fname).select("lname", "id") + + self.assertEqual('''SELECT DISTINCT ON("lname","fname") "lname","id" FROM "abc"''', str(q)) + + +class LimitByTests(TestCase): + table_abc = Table("abc") + + def test_limit_by(self): + q = ClickHouseQuery.from_(self.table_abc).limit_by(1, "a", self.table_abc.b).select("a", "b", "c") + + self.assertEqual('''SELECT "a","b","c" FROM "abc" LIMIT 1 BY ("a","b")''', str(q)) + + def test_limit_offset_by(self): + q = ClickHouseQuery.from_(self.table_abc).limit_offset_by(1, 2, "a", self.table_abc.b).select("a", "b", "c") + + self.assertEqual('''SELECT "a","b","c" FROM "abc" LIMIT 1 OFFSET 2 BY ("a","b")''', str(q)) + + def test_limit_offset0_by(self): + q = ClickHouseQuery.from_(self.table_abc).limit_offset_by(1, 0, "a", self.table_abc.b).select("a", "b", "c") + + self.assertEqual('''SELECT "a","b","c" FROM "abc" LIMIT 1 BY ("a","b")''', str(q)) + + def test_rename_table(self): + table_join = Table("join") + + q = ( + ClickHouseQuery.from_(self.table_abc) + .join(table_join) + .using("a") + .limit_by(1, self.table_abc.a, table_join.a) + .select(self.table_abc.b, table_join.b) + ) + q = q.replace_table(self.table_abc, Table("xyz")) + + self.assertEqual( + '''SELECT "xyz"."b","join"."b" FROM "xyz" JOIN "join" USING ("a") LIMIT 1 BY ("xyz"."a","join"."a")''', + str(q), + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/dialects/test_mssql.py b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/dialects/test_mssql.py new file mode 100644 index 0000000000000000000000000000000000000000..7cf53b228f413a8c7cd3e414fef5522a82f99b29 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/dialects/test_mssql.py @@ -0,0 +1,81 @@ +import unittest + +from pypika import Table +from pypika.analytics import Count +from pypika.dialects import MSSQLQuery +from pypika.utils import QueryException + + +class SelectTests(unittest.TestCase): + def test_normal_select(self): + q = MSSQLQuery.from_("abc").select("def") + + self.assertEqual('SELECT "def" FROM "abc"', str(q)) + + def test_distinct_select(self): + q = MSSQLQuery.from_("abc").select("def").distinct() + + self.assertEqual('SELECT DISTINCT "def" FROM "abc"', str(q)) + + def test_top_distinct_select(self): + q = MSSQLQuery.from_("abc").select("def").top(10).distinct() + + self.assertEqual('SELECT DISTINCT TOP (10) "def" FROM "abc"', str(q)) + + def test_top_select(self): + q = MSSQLQuery.from_("abc").select("def").top(10) + + self.assertEqual('SELECT TOP (10) "def" FROM "abc"', str(q)) + + def test_top_with_ties_select(self): + q = MSSQLQuery.from_("abc").select("def").top(10, with_ties=True) + + self.assertEqual('SELECT TOP (10) WITH TIES "def" FROM "abc"', str(q)) + + def test_top_percent_select(self): + q = MSSQLQuery.from_("abc").select("def").top(10, percent=True) + + self.assertEqual('SELECT TOP (10) PERCENT "def" FROM "abc"', str(q)) + + def test_top_percent_invalid_range(self): + for invalid_top in [-1, 101]: + with self.assertRaisesRegex( + QueryException, "TOP value must be between 0 and 100 when `percent` is specified" + ): + MSSQLQuery.from_("abc").select("def").top(invalid_top, percent=True) + + def test_top_select_non_int(self): + with self.assertRaisesRegex(QueryException, "TOP value must be an integer"): + MSSQLQuery.from_("abc").select("def").top("a") + + def test_limit(self): + q = MSSQLQuery.from_("abc").select("def").orderby("def").limit(10) + + self.assertEqual('SELECT "def" FROM "abc" ORDER BY "def" OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY', str(q)) + + def test_offset(self): + q = MSSQLQuery.from_("abc").select("def").orderby("def").offset(10) + + self.assertEqual('SELECT "def" FROM "abc" ORDER BY "def" OFFSET 10 ROWS', str(q)) + + def test_limit_with_offset(self): + q = MSSQLQuery.from_("abc").select("def").orderby("def").limit(10).offset(10) + + self.assertEqual('SELECT "def" FROM "abc" ORDER BY "def" OFFSET 10 ROWS FETCH NEXT 10 ROWS ONLY', str(q)) + + def test_groupby_alias_False_does_not_group_by_alias_with_standard_query(self): + t = Table('table1') + col = t.abc.as_('a') + q = MSSQLQuery.from_(t).select(col, Count('*')).groupby(col) + + self.assertEqual('SELECT "abc" "a",COUNT(\'*\') FROM "table1" GROUP BY "abc"', str(q)) + + def test_groupby_alias_False_does_not_group_by_alias_when_subqueries_are_present(self): + t = Table('table1') + subquery = MSSQLQuery.from_(t).select(t.abc) + col = subquery.abc.as_('a') + q = MSSQLQuery.from_(subquery).select(col, Count('*')).groupby(col) + + self.assertEqual( + 'SELECT "sq0"."abc" "a",COUNT(\'*\') FROM (SELECT "abc" FROM "table1") "sq0" GROUP BY "sq0"."abc"', str(q) + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/dialects/test_mysql.py b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/dialects/test_mysql.py new file mode 100644 index 0000000000000000000000000000000000000000..619d064adcdf8b5ff9ecd054fa4ab00eff1d69b3 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/dialects/test_mysql.py @@ -0,0 +1,91 @@ +import unittest + +from pypika import MySQLQuery, QueryException, Table, Column + + +class SelectTests(unittest.TestCase): + table_abc = Table("abc") + + def test_normal_select(self): + q = MySQLQuery.from_("abc").select("def") + + self.assertEqual("SELECT `def` FROM `abc`", str(q)) + + def test_distinct_select(self): + q = MySQLQuery.from_("abc").select("def").distinct() + + self.assertEqual("SELECT DISTINCT `def` FROM `abc`", str(q)) + + def test_modifier_select(self): + q = MySQLQuery.from_("abc").select("def").select("ghi").modifier("SQL_CALC_FOUND_ROWS") + + self.assertEqual("SELECT SQL_CALC_FOUND_ROWS `def`,`ghi` FROM `abc`", str(q)) + + def test_multiple_modifier_select(self): + q = MySQLQuery.from_("abc").select("def").modifier("HIGH_PRIORITY").modifier("SQL_CALC_FOUND_ROWS") + + self.assertEqual("SELECT HIGH_PRIORITY SQL_CALC_FOUND_ROWS `def` FROM `abc`", str(q)) + + +class UpdateTests(unittest.TestCase): + table_abc = Table("abc") + + def test_update(self): + q = MySQLQuery.into("abc").insert(1, [1, "a", True]) + + self.assertEqual("INSERT INTO `abc` VALUES (1,[1,'a',true])", str(q)) + + def test_on_duplicate_key_ignore_update(self): + q = MySQLQuery.into("abc").insert(1, [1, "a", True]).on_duplicate_key_ignore() + + self.assertEqual("INSERT INTO `abc` VALUES (1,[1,'a',true]) ON DUPLICATE KEY IGNORE", str(q)) + + def test_on_duplicate_key_update_update(self): + q = MySQLQuery.into("abc").insert(1, [1, "a", True]).on_duplicate_key_update(self.table_abc.a, 'b') + + self.assertEqual("INSERT INTO `abc` VALUES (1,[1,'a',true]) ON DUPLICATE KEY UPDATE `a`='b'", str(q)) + + def test_conflict_handlers_update(self): + with self.assertRaises(QueryException): + ( + MySQLQuery.into("abc") + .insert(1, [1, "a", True]) + .on_duplicate_key_ignore() + .on_duplicate_key_update(self.table_abc.a, 'b') + ) + + +class LoadCSVTests(unittest.TestCase): + table_abc = Table("abc") + + def test_load_from_file(self): + q1 = MySQLQuery.load("/path/to/file").into("abc") + + q2 = MySQLQuery.load("/path/to/file").into(self.table_abc) + + self.assertEqual( + "LOAD DATA LOCAL INFILE '/path/to/file' INTO TABLE `abc` FIELDS TERMINATED BY ','", + str(q1), + ) + self.assertEqual( + "LOAD DATA LOCAL INFILE '/path/to/file' INTO TABLE `abc` FIELDS TERMINATED BY ','", + str(q2), + ) + + +class TableTests(unittest.TestCase): + table_abc = Table("abc") + + def test_create_table(self): + q = MySQLQuery.create_table(self.table_abc).columns(Column("id", "INT")) + self.assertEqual( + 'CREATE TABLE `abc` (`id` INT)', + str(q), + ) + + def test_drop_table(self): + q = MySQLQuery.drop_table(self.table_abc) + self.assertEqual( + 'DROP TABLE `abc`', + str(q), + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/dialects/test_oracle.py b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/dialects/test_oracle.py new file mode 100644 index 0000000000000000000000000000000000000000..21b54f16fd5d3518b5c767d3605068637898a73f --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/dialects/test_oracle.py @@ -0,0 +1,51 @@ +import unittest + +from pypika import OracleQuery, Table +from pypika.analytics import Count + + +class SelectTests(unittest.TestCase): + def test_groupby_alias_False_does_not_group_by_alias_with_standard_query(self): + t = Table('table1') + col = t.abc.as_('a') + q = OracleQuery.from_(t).select(col, Count('*')).groupby(col) + + self.assertEqual('SELECT abc a,COUNT(\'*\') FROM table1 GROUP BY abc', str(q)) + + def test_groupby_alias_False_does_not_group_by_alias_when_subqueries_are_present(self): + t = Table('table1') + subquery = OracleQuery.from_(t).select(t.abc) + col = subquery.abc.as_('a') + q = OracleQuery.from_(subquery).select(col, Count('*')).groupby(col) + + self.assertEqual('SELECT sq0.abc a,COUNT(\'*\') FROM (SELECT abc FROM table1) sq0 GROUP BY sq0.abc', str(q)) + + def test_limit_query(self): + t = Table('table1') + limit = 5 + q = OracleQuery.from_(t).select(t.test).limit(limit) + + self.assertEqual(f'SELECT test FROM table1 FETCH NEXT {limit} ROWS ONLY', str(q)) + + def test_offset_query(self): + t = Table('table1') + offset = 5 + q = OracleQuery.from_(t).select(t.test).offset(offset) + + self.assertEqual(f'SELECT test FROM table1 OFFSET {offset} ROWS', str(q)) + + def test_limit_offset_query(self): + t = Table('table1') + limit = 5 + offset = 5 + q = OracleQuery.from_(t).select(t.test).limit(limit).offset(offset) + + self.assertEqual(f'SELECT test FROM table1 OFFSET {offset} ROWS FETCH NEXT {limit} ROWS ONLY', str(q)) + + def test_fetch_next_method_deprecated(self): + with self.assertWarns(DeprecationWarning): + t = Table('table1') + limit = 5 + q = OracleQuery.from_(t).select(t.test).fetch_next(limit) + + self.assertEqual(f'SELECT test FROM table1 FETCH NEXT {limit} ROWS ONLY', str(q)) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/dialects/test_postgresql.py b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/dialects/test_postgresql.py new file mode 100644 index 0000000000000000000000000000000000000000..437eed03e120485ed2a357a4c2d92426f1466e14 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/dialects/test_postgresql.py @@ -0,0 +1,262 @@ +import unittest +from collections import OrderedDict + +from pypika import ( + Array, + Field, + JSON, + QueryException, + Table, +) +from pypika.dialects import PostgreSQLQuery + + +class InsertTests(unittest.TestCase): + table_abc = Table("abc") + + def test_array_keyword(self): + q = PostgreSQLQuery.into(self.table_abc).insert(1, [1, "a", True]) + + self.assertEqual("INSERT INTO \"abc\" VALUES (1,ARRAY[1,'a',true])", str(q)) + + +class JSONObjectTests(unittest.TestCase): + def test_alias_set_correctly(self): + table = Table('jsonb_table') + q = PostgreSQLQuery.from_('abc').select(table.value.get_text_value('a').as_('name')) + + self.assertEqual('''SELECT "value"->>'a' "name" FROM "abc"''', str(q)) + + def test_json_value_from_dict(self): + q = PostgreSQLQuery.select(JSON({"a": "foo"})) + + self.assertEqual('SELECT \'{"a":"foo"}\'', str(q)) + + def test_json_value_from_array_num(self): + q = PostgreSQLQuery.select(JSON([1, 2, 3])) + + self.assertEqual("SELECT '[1,2,3]'", str(q)) + + def test_json_value_from_array_str(self): + q = PostgreSQLQuery.select(JSON(["a", "b", "c"])) + + self.assertEqual('SELECT \'["a","b","c"]\'', str(q)) + + def test_json_value_from_dict_recursive(self): + q = PostgreSQLQuery.select(JSON({"a": "z", "b": {"c": "foo"}, "d": 1})) + + # gotta split this one up to avoid the indeterminate order + sql = str(q) + start, end = 9, -2 + self.assertEqual("SELECT '{}'", sql[:start] + sql[end:]) + + members_set = set(sql[start:end].split(",")) + self.assertSetEqual({'"a":"z"', '"b":{"c":"foo"}', '"d":1'}, members_set) + + +class JSONOperatorsTests(unittest.TestCase): + # reference https://www.postgresql.org/docs/9.5/functions-json.html + table_abc = Table("abc") + + def test_get_json_value_by_key(self): + q = PostgreSQLQuery.from_(self.table_abc).select("*").where(self.table_abc.json.get_json_value("dates")) + + self.assertEqual('SELECT * FROM "abc" WHERE "json"->\'dates\'', str(q)) + + def test_get_json_value_by_index(self): + q = PostgreSQLQuery.from_(self.table_abc).select("*").where(self.table_abc.json.get_json_value(1)) + + self.assertEqual('SELECT * FROM "abc" WHERE "json"->1', str(q)) + + def test_get_text_value_by_key(self): + q = PostgreSQLQuery.from_(self.table_abc).select("*").where(self.table_abc.json.get_text_value("dates")) + + self.assertEqual('SELECT * FROM "abc" WHERE "json"->>\'dates\'', str(q)) + + def test_get_text_value_by_index(self): + q = PostgreSQLQuery.from_(self.table_abc).select("*").where(self.table_abc.json.get_text_value(1)) + + self.assertEqual('SELECT * FROM "abc" WHERE "json"->>1', str(q)) + + def test_get_path_json_value(self): + q = PostgreSQLQuery.from_(self.table_abc).select("*").where(self.table_abc.json.get_path_json_value("{a,b}")) + + self.assertEqual('SELECT * FROM "abc" WHERE "json"#>\'{a,b}\'', str(q)) + + def test_get_path_text_value(self): + q = PostgreSQLQuery.from_(self.table_abc).select("*").where(self.table_abc.json.get_path_text_value("{a,b}")) + + self.assertEqual('SELECT * FROM "abc" WHERE "json"#>>\'{a,b}\'', str(q)) + + +class JSONBOperatorsTests(unittest.TestCase): + # reference https://www.postgresql.org/docs/9.5/functions-json.html + table_abc = Table("abc") + + def test_json_contains_for_json(self): + q = PostgreSQLQuery.select(JSON({"a": 1, "b": 2}).contains({"a": 1})) + + # gotta split this one up to avoid the indeterminate order + sql = str(q) + start, end = 9, -13 + self.assertEqual("SELECT '{}'@>'{\"a\":1}'", sql[:start] + sql[end:]) + + members_set = set(sql[start:end].split(",")) + self.assertSetEqual({'"a":1', '"b":2'}, members_set) + + def test_json_contains_for_field(self): + q = ( + PostgreSQLQuery.from_(self.table_abc) + .select("*") + .where(self.table_abc.json.contains({"dates": "2018-07-10 - 2018-07-17"})) + ) + + self.assertEqual( + "SELECT * " 'FROM "abc" ' 'WHERE "json"@>\'{"dates":"2018-07-10 - 2018-07-17"}\'', + str(q), + ) + + def test_json_contained_by_using_str_arg(self): + q = ( + PostgreSQLQuery.from_(self.table_abc) + .select("*") + .where( + self.table_abc.json.contained_by( + OrderedDict( + [ + ("dates", "2018-07-10 - 2018-07-17"), + ("imported", "8"), + ] + ) + ) + ) + ) + self.assertEqual( + 'SELECT * FROM "abc" ' 'WHERE "json"<@\'{"dates":"2018-07-10 - 2018-07-17","imported":"8"}\'', + str(q), + ) + + def test_json_contained_by_using_list_arg(self): + q = ( + PostgreSQLQuery.from_(self.table_abc) + .select("*") + .where(self.table_abc.json.contained_by(["One", "Two", "Three"])) + ) + + self.assertEqual('SELECT * FROM "abc" WHERE "json"<@\'["One","Two","Three"]\'', str(q)) + + def test_json_contained_by_with_complex_criterion(self): + q = ( + PostgreSQLQuery.from_(self.table_abc) + .select("*") + .where(self.table_abc.json.contained_by(["One", "Two", "Three"]) & (self.table_abc.id == 26)) + ) + + self.assertEqual( + 'SELECT * FROM "abc" WHERE "json"<@\'["One","Two","Three"]\' AND "id"=26', + str(q), + ) + + def test_json_has_key(self): + q = PostgreSQLQuery.from_(self.table_abc).select("*").where(self.table_abc.json.has_key("dates")) + + self.assertEqual('SELECT * FROM "abc" WHERE "json"?\'dates\'', str(q)) + + def test_json_has_keys(self): + q = PostgreSQLQuery.from_(self.table_abc).select("*").where(self.table_abc.json.has_keys(["dates", "imported"])) + + self.assertEqual("SELECT * FROM \"abc\" WHERE \"json\"?&ARRAY['dates','imported']", str(q)) + + def test_json_has_any_keys(self): + q = ( + PostgreSQLQuery.from_(self.table_abc) + .select("*") + .where(self.table_abc.json.has_any_keys(["dates", "imported"])) + ) + + self.assertEqual("SELECT * FROM \"abc\" WHERE \"json\"?|ARRAY['dates','imported']", str(q)) + + def test_subnet_contains_inet(self): + q = ( + PostgreSQLQuery.from_(self.table_abc) + .select(self.table_abc.a.lshift(2)) + .where(self.table_abc.cidr >> "1.1.1.1") + ) + + self.assertEqual("SELECT \"a\"<<2 FROM \"abc\" WHERE \"cidr\">>'1.1.1.1'", str(q)) + + +class DistinctOnTests(unittest.TestCase): + table_abc = Table("abc") + + def test_distinct_on(self): + q = PostgreSQLQuery.from_(self.table_abc).distinct_on("lname", self.table_abc.fname).select("lname", "id") + + self.assertEqual('''SELECT DISTINCT ON("lname","fname") "lname","id" FROM "abc"''', str(q)) + + +class ArrayTests(unittest.TestCase): + def test_array_syntax(self): + tb = Table("tb") + q = PostgreSQLQuery.from_(tb).select(Array(1, "a", ["b", 2, 3])) + + self.assertEqual(str(q), "SELECT ARRAY[1,'a',ARRAY['b',2,3]] FROM \"tb\"") + + def test_render_alias_in_array_sql(self): + tb = Table("tb") + + q = PostgreSQLQuery.from_(tb).select(Array(tb.col).as_("different_name")) + self.assertEqual(str(q), 'SELECT ARRAY["col"] "different_name" FROM "tb"') + + +class ReturningClauseTests(unittest.TestCase): + @classmethod + def setUpClass(cls) -> None: + super().setUpClass() + cls.table_abc = Table('abc') + + def test_returning_from_missing_table_raises_queryexception(self): + field_from_diff_table = Field('xyz', table=Table('other')) + + with self.assertRaisesRegex(QueryException, "You can't return from other tables"): + ( + PostgreSQLQuery.from_(self.table_abc) + .where(self.table_abc.foo == self.table_abc.bar) + .delete() + .returning(field_from_diff_table) + ) + + def test_queryexception_if_returning_used_on_invalid_query(self): + with self.assertRaisesRegex(QueryException, "Returning can't be used in this query"): + PostgreSQLQuery.from_(self.table_abc).select('abc').returning('abc') + + def test_no_queryexception_if_returning_used_on_valid_query_type(self): + # No exceptions for insert, update and delete queries + with self.subTest('DELETE'): + PostgreSQLQuery.from_(self.table_abc).where(self.table_abc.foo == self.table_abc.bar).delete().returning( + "id" + ) + with self.subTest('UPDATE'): + PostgreSQLQuery.update(self.table_abc).where(self.table_abc.foo == 0).set("foo", "bar").returning("id") + with self.subTest('INSERT'): + PostgreSQLQuery.into(self.table_abc).insert('abc').returning('abc') + + def test_return_field_from_join_table(self): + new_table = Table('xyz') + q = ( + PostgreSQLQuery.update(self.table_abc) + .join(new_table) + .on(new_table.id == self.table_abc.xyz) + .where(self.table_abc.foo == 0) + .set("foo", "bar") + .returning(new_table.a) + ) + + self.assertEqual( + 'UPDATE "abc" ' + 'JOIN "xyz" ON "xyz"."id"="abc"."xyz" ' + 'SET "foo"=\'bar\' ' + 'WHERE "abc"."foo"=0 ' + 'RETURNING "xyz"."a"', + str(q), + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/dialects/test_snowflake.py b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/dialects/test_snowflake.py new file mode 100644 index 0000000000000000000000000000000000000000..5ac08b2d8b8b5496ed6f3510acf4be1ec7893405 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/dialects/test_snowflake.py @@ -0,0 +1,58 @@ +import unittest + +from pypika import ( + Tables, + functions as fn, + Column, +) +from pypika.dialects import SnowflakeQuery + + +class QuoteTests(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_use_double_quotes_on_alias_but_not_on_terms(self): + q = SnowflakeQuery.from_(self.table_abc).select(self.table_abc.a.as_("bar")) + + self.assertEqual('SELECT a "bar" FROM abc', q.get_sql(with_namespace=True)) + + def test_use_double_quotes_on_alias_but_not_on_terms_with_joins(self): + foo = self.table_abc.as_("foo") + bar = self.table_efg.as_("bar") + + q = SnowflakeQuery.from_(foo).join(bar).on(foo.fk == bar.id).select(foo.a, bar.b) + + self.assertEqual( + "SELECT foo.a,bar.b " 'FROM abc "foo" ' 'JOIN efg "bar" ' "ON foo.fk=bar.id", + q.get_sql(with_namespace=True), + ) + + def test_use_double_quotes_on_alias_but_not_on_terms(self): + idx = self.table_abc.index.as_("idx") + val = fn.Sum(self.table_abc.value).as_("val") + q = SnowflakeQuery.from_(self.table_abc).select(idx, val).groupby(idx).orderby(idx) + + self.assertEqual( + 'SELECT index "idx",SUM(value) "val" ' "FROM abc " 'GROUP BY "idx" ' 'ORDER BY "idx"', + q.get_sql(with_namespace=True), + ) + + def test_dont_use_double_quotes_on_joining_queries(self): + foo = self.table_abc + bar = self.table_efg + q1 = SnowflakeQuery.from_(foo).select(foo.b) + q2 = SnowflakeQuery.from_(bar).select(bar.b) + q = SnowflakeQuery.from_(q1).join(q2).on(q1.b == q2.b).select("*") + + self.assertEqual( + "SELECT * " 'FROM (SELECT b FROM abc) sq0 ' 'JOIN (SELECT b FROM efg) sq1 ' "ON sq0.b=sq1.b", + q.get_sql(), + ) + + def test_dont_use_double_quotes_on_create_queries(self): + q = SnowflakeQuery.create_table(self.table_abc).columns(Column("id", "INT")) + self.assertEqual("CREATE TABLE abc (id INT)", q.get_sql()) + + def test_dont_use_double_quotes_on_drop_queries(self): + q = SnowflakeQuery.drop_table(self.table_abc) + self.assertEqual("DROP TABLE abc", q.get_sql()) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/dialects/test_sqllite.py b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/dialects/test_sqllite.py new file mode 100644 index 0000000000000000000000000000000000000000..104a7235b6ea2d46fd365989f68c5d081eb20076 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/dialects/test_sqllite.py @@ -0,0 +1,35 @@ +import unittest + +from pypika import Table +from pypika.dialects import SQLLiteQuery + + +class SelectTests(unittest.TestCase): + table_abc = Table("abc") + + def test_bool_true_as_one(self): + q = SQLLiteQuery.from_("abc").select(True) + + self.assertEqual('SELECT 1 FROM "abc"', str(q)) + + def test_bool_false_as_zero(self): + q = SQLLiteQuery.from_("abc").select(False) + + self.assertEqual('SELECT 0 FROM "abc"', str(q)) + + +class ReplaceTests(unittest.TestCase): + def test_normal_replace(self): + query = SQLLiteQuery.into("abc").replace("v1", "v2", "v3") + expected_output = "REPLACE INTO \"abc\" VALUES ('v1','v2','v3')" + self.assertEqual(expected_output, str(query)) + + def test_replace_subquery(self): + query = SQLLiteQuery.into("abc").replace(SQLLiteQuery.from_("def").select("f1", "f2")) + expected_output = 'REPLACE INTO "abc" VALUES ((SELECT "f1","f2" FROM "def"))' + self.assertEqual(expected_output, str(query)) + + def test_insert_or_replace(self): + query = SQLLiteQuery.into("abc").insert_or_replace("v1", "v2", "v3") + expected_output = "INSERT OR REPLACE INTO \"abc\" VALUES ('v1','v2','v3')" + self.assertEqual(expected_output, str(query)) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/dialects/test_vertica.py b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/dialects/test_vertica.py new file mode 100644 index 0000000000000000000000000000000000000000..61985bfc244fcd663e7d8a904b4645901f3abdfc --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/dialects/test_vertica.py @@ -0,0 +1,93 @@ +import unittest + +from pypika import Columns, Table, Tables, VerticaQuery + + +class VerticaQueryTests(unittest.TestCase): + table_abc = Table("abc") + + def test_select_query_with_hint(self): + q = VerticaQuery.from_("abc").select("*").hint("test_hint") + + self.assertEqual('SELECT /*+label(test_hint)*/ * FROM "abc"', str(q)) + + def test_insert_query_with_hint(self): + query = VerticaQuery.into(self.table_abc).insert(1).hint("test_hint") + + self.assertEqual('INSERT /*+label(test_hint)*/ INTO "abc" VALUES (1)', str(query)) + + def test_update_query_with_hint(self): + q = VerticaQuery.update(self.table_abc).set("foo", "bar").hint("test_hint") + + self.assertEqual('UPDATE /*+label(test_hint)*/ "abc" SET "foo"=\'bar\'', str(q)) + + def test_delete_query_with_hint(self): + q = VerticaQuery.from_("abc").delete().hint("test_hint") + + self.assertEqual('DELETE /*+label(test_hint)*/ FROM "abc"', str(q)) + + +class CopyCSVTests(unittest.TestCase): + table_abc = Table("abc") + + def test_copy_from_file(self): + with self.subTest("with table as string"): + q = VerticaQuery.from_file("/path/to/file").copy_("abc") + + self.assertEqual( + "COPY \"abc\" FROM LOCAL '/path/to/file' PARSER fcsvparser(header=false)", + str(q), + ) + + with self.subTest("with table"): + q = VerticaQuery.from_file("/path/to/file").copy_(self.table_abc) + + self.assertEqual( + "COPY \"abc\" FROM LOCAL '/path/to/file' PARSER fcsvparser(header=false)", + str(q), + ) + + +class CreateTemporaryTableTests(unittest.TestCase): + new_table, existing_table = Tables("abc", "efg") + foo, bar = Columns(("a", "INT"), ("b", "VARCHAR(100)")) + select = VerticaQuery.from_(existing_table).select(existing_table.foo, existing_table.bar) + + def test_create_local_temporary_table(self): + with self.subTest("with columns"): + q = VerticaQuery.create_table(self.new_table).temporary().local().columns(self.foo, self.bar) + + self.assertEqual('CREATE LOCAL TEMPORARY TABLE "abc" ("a" INT,"b" VARCHAR(100))', str(q)) + + with self.subTest("with select"): + q = VerticaQuery.create_table(self.new_table).temporary().local().as_select(self.select) + + self.assertEqual( + 'CREATE LOCAL TEMPORARY TABLE "abc" AS (SELECT "foo","bar" FROM "efg")', + str(q), + ) + + def test_create_local_table_without_temporary_raises_error(self): + with self.assertRaises(AttributeError): + VerticaQuery.create_table(self.new_table).local() + + def test_create_temporary_table_preserve_rows(self): + with self.subTest("with columns"): + q = VerticaQuery.create_table(self.new_table).temporary().preserve_rows().columns(self.foo, self.bar) + + self.assertEqual( + 'CREATE TEMPORARY TABLE "abc" ("a" INT,"b" VARCHAR(100)) ON COMMIT PRESERVE ROWS', + str(q), + ) + + with self.subTest("with select"): + q = VerticaQuery.create_table(self.new_table).temporary().preserve_rows().as_select(self.select) + + self.assertEqual( + 'CREATE TEMPORARY TABLE "abc" ON COMMIT PRESERVE ROWS AS (SELECT "foo","bar" FROM "efg")', + str(q), + ) + + def test_create_table_preserve_rows_without_temporary_raises_error(self): + with self.assertRaises(AttributeError): + VerticaQuery.create_table(self.new_table).preserve_rows() diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/test_aggregate.py b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/test_aggregate.py new file mode 100644 index 0000000000000000000000000000000000000000..1c627d8e9c2d65410c67cf2c39974949b0720a0e --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/test_aggregate.py @@ -0,0 +1,122 @@ +import unittest + +from pypika import ( + Case, + Field, + Table, + functions as fn, +) +from pypika.terms import ( + Negative, + ValueWrapper, +) + + +class IsAggregateTests(unittest.TestCase): + def test__field_is_not_aggregate(self): + v = Field("foo") + self.assertFalse(v.is_aggregate) + + def test__constant_is_aggregate_none(self): + v = ValueWrapper(100) + self.assertIsNone(v.is_aggregate) + + def test__constant_arithmetic_is_aggregate_none(self): + v = ValueWrapper(100) + ValueWrapper(100) + self.assertIsNone(v.is_aggregate) + + def test__field_arithmetic_is_not_aggregate(self): + v = Field("foo") + Field("bar") + self.assertFalse(v.is_aggregate) + + def test__field_arithmetic_constant_is_not_aggregate(self): + v = Field("foo") + 1 + self.assertFalse(v.is_aggregate) + + def test__agg_func_is_aggregate(self): + v = fn.Sum(Field("foo")) + self.assertTrue(v.is_aggregate) + + def test__negative_agg_func_is_aggregate(self): + v = Negative(fn.Sum(Field("foo"))) + self.assertTrue(v.is_aggregate) + + def test__agg_func_arithmetic_is_aggregate(self): + v = fn.Sum(Field("foo")) / fn.Sum(Field("foo")) + self.assertTrue(v.is_aggregate) + + def test__mixed_func_arithmetic_is_not_aggregate(self): + v = Field("foo") / fn.Sum(Field("foo")) + self.assertFalse(v.is_aggregate) + + def test__func_arithmetic_constant_is_not_aggregate(self): + v = 1 / fn.Sum(Field("foo")) + self.assertTrue(v.is_aggregate) + + def test__agg_case_criterion_is_aggregate(self): + v = Case().when(fn.Sum(Field("foo")) > 666, 'More than 666').else_('Less than 666') + + self.assertTrue(v.is_aggregate) + + def test__agg_case_is_aggregate(self): + v = ( + Case() + .when(Field("foo") == 1, fn.Sum(Field("bar"))) + .when(Field("foo") == 2, fn.Sum(Field("fiz"))) + .else_(fn.Sum(Field("fiz"))) + ) + + self.assertTrue(v.is_aggregate) + + def test__mixed_case_is_not_aggregate(self): + v = Case().when(Field("foo") == 1, fn.Sum(Field("bar"))).when(Field("foo") == 2, Field("fiz")) + + self.assertFalse(v.is_aggregate) + + def test__case_mixed_else_is_not_aggregate(self): + v = ( + Case() + .when(Field("foo") == 1, fn.Sum(Field("bar"))) + .when(Field("foo") == 2, fn.Sum(Field("fiz"))) + .else_(Field("fiz")) + ) + + self.assertFalse(v.is_aggregate) + + def test__case_mixed_constant_is_not_aggregate(self): + v = Case().when(Field("foo") == 1, fn.Sum(Field("bar"))).when(Field("foo") == 2, fn.Sum(Field("fiz"))).else_(1) + + self.assertTrue(v.is_aggregate) + + def test__case_with_field_is_not_aggregate(self): + v = Case().when(Field("foo") == 1, 1).when(Field("foo") == 2, 2).else_(3) + + self.assertFalse(v.is_aggregate) + + def test__case_with_single_aggregate_field_in_one_criterion_is_aggregate(self): + v = Case().when(Field("foo") == 1, 1).when(fn.Sum(Field("foo")) == 2, 2).else_(3) + + self.assertTrue(v.is_aggregate) + + def test__non_aggregate_function_with_aggregated_arg(self): + t = Table("abc") + expr = fn.Sqrt(fn.Sum(t.a)) + + self.assertTrue(expr.is_aggregate) + + def test_complicated(self): + t = Table("abc") + is_placebo = t.campaign_extra_info == "placebo" + + pixel_mobile_search = Case().when(is_placebo, t.action_fb_pixel_search + t.action_fb_mobile_search) + unique_impressions = Case().when(is_placebo, t.unique_impressions) + + v = fn.Sum(pixel_mobile_search) / fn.Sum(unique_impressions) - 1.96 * fn.Sqrt( + 1 + / fn.Sum(unique_impressions) + * fn.Sum(pixel_mobile_search) + / fn.Sum(unique_impressions) + * (1 - fn.Sum(pixel_mobile_search) / fn.Sum(unique_impressions)) + ) + + self.assertTrue(v.is_aggregate) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/test_analytic_queries.py b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/test_analytic_queries.py new file mode 100644 index 0000000000000000000000000000000000000000..6a35ab854b30e3b0f91e633b3349706a22e0a2fd --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/test_analytic_queries.py @@ -0,0 +1,610 @@ +import unittest + +from pypika import Criterion, JoinType, Order, Query, Tables, analytics as an +from pypika.analytics import Lag, Lead + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + + +class RankTests(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_rank(self): + expr = an.Rank().over(self.table_abc.foo).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " "RANK() " 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_dense_rank(self): + expr = an.DenseRank().over(self.table_abc.foo).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " "DENSE_RANK() " 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_row_number(self): + expr = an.RowNumber().over(self.table_abc.foo).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " "ROW_NUMBER() " 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_rank_with_alias(self): + expr = an.Rank().over(self.table_abc.foo).orderby(self.table_abc.date).as_("rank") + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " "RANK() " 'OVER(PARTITION BY "foo" ORDER BY "date") "rank" ' 'FROM "abc"', + str(q), + ) + + def test_multiple_partitions(self): + expr = an.Rank().orderby(self.table_abc.date).over(self.table_abc.foo, self.table_abc.bar) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " "RANK() " 'OVER(PARTITION BY "foo","bar" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_ntile_no_partition_or_order_invalid_sql(self): + expr = an.NTile(5) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual("SELECT " "NTILE(5) " 'FROM "abc"', str(q)) + + def test_ntile_with_partition(self): + expr = an.NTile(5).over(self.table_abc.foo) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual("SELECT " "NTILE(5) " 'OVER(PARTITION BY "foo") ' 'FROM "abc"', str(q)) + + def test_ntile_with_order(self): + expr = an.NTile(5).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual("SELECT " "NTILE(5) " 'OVER(ORDER BY "date") ' 'FROM "abc"', str(q)) + + def test_ntile_with_partition_and_order(self): + expr = an.NTile(5).over(self.table_abc.foo).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " "NTILE(5) " 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_first_value(self): + expr = an.FirstValue(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'FIRST_VALUE("fizz") ' 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_first_value_ignore_nulls(self): + expr = an.FirstValue(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).ignore_nulls() + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'FIRST_VALUE("fizz" IGNORE NULLS) ' 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_first_value_ignore_nulls_first(self): + expr = an.FirstValue(self.table_abc.fizz).ignore_nulls().over(self.table_abc.foo).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'FIRST_VALUE("fizz" IGNORE NULLS) ' 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_first_value_multi_argument(self): + expr = ( + an.FirstValue(self.table_abc.fizz, self.table_abc.buzz) + .over(self.table_abc.foo) + .orderby(self.table_abc.date) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'FIRST_VALUE("fizz","buzz") ' 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_last_value(self): + expr = an.LastValue(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'LAST_VALUE("fizz") ' 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_filter(self): + expr = ( + an.LastValue(self.table_abc.fizz) + .filter(Criterion.all([self.table_abc.bar == True])) + .over(self.table_abc.foo) + .orderby(self.table_abc.date) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'LAST_VALUE("fizz") ' + 'FILTER(WHERE "bar"=true) ' + 'OVER(PARTITION BY "foo" ORDER BY "date") ' + 'FROM "abc"', + str(q), + ) + + def test_filter_quote_table_in_filter(self): + expr = ( + an.LastValue(self.table_efg.fizz) + .filter(self.table_efg.filed.eq('yes')) + .over(self.table_efg.foo) + .orderby(self.table_efg.date) + ) + + q = ( + Query.from_(self.table_abc) + .inner_join(self.table_efg) + .on(self.table_abc.id.eq(self.table_efg.id)) + .select(expr) + ) + + self.assertEqual( + 'SELECT ' + 'LAST_VALUE("efg"."fizz") ' + 'FILTER(WHERE "efg"."filed"=\'yes\') ' + 'OVER(PARTITION BY "efg"."foo" ORDER BY "efg"."date") ' + 'FROM "abc" ' + 'JOIN "efg" ON "abc"."id"="efg"."id"', + str(q), + ) + + def test_orderby_asc(self): + expr = an.LastValue(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date, order=Order.asc) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'LAST_VALUE("fizz") ' 'OVER(PARTITION BY "foo" ORDER BY "date" ASC) ' 'FROM "abc"', + str(q), + ) + + def test_orderby_desc(self): + expr = an.LastValue(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date, order=Order.desc) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'LAST_VALUE("fizz") ' 'OVER(PARTITION BY "foo" ORDER BY "date" DESC) ' 'FROM "abc"', + str(q), + ) + + def test_last_value_multi_argument(self): + expr = ( + an.LastValue(self.table_abc.fizz, self.table_abc.buzz).over(self.table_abc.foo).orderby(self.table_abc.date) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'LAST_VALUE("fizz","buzz") ' 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_last_value_ignore_nulls(self): + expr = an.LastValue(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).ignore_nulls() + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'LAST_VALUE("fizz" IGNORE NULLS) ' 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_median(self): + expr = an.Median(self.table_abc.fizz).over(self.table_abc.foo, self.table_abc.bar).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'MEDIAN("fizz") ' 'OVER(PARTITION BY "foo","bar" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_avg(self): + expr = an.Avg(self.table_abc.fizz).over(self.table_abc.foo, self.table_abc.bar).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'AVG("fizz") ' 'OVER(PARTITION BY "foo","bar" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_stddev(self): + expr = an.StdDev(self.table_abc.fizz).over(self.table_abc.foo, self.table_abc.bar).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'STDDEV("fizz") ' 'OVER(PARTITION BY "foo","bar" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_stddev_pop(self): + expr = ( + an.StdDevPop(self.table_abc.fizz).over(self.table_abc.foo, self.table_abc.bar).orderby(self.table_abc.date) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'STDDEV_POP("fizz") ' 'OVER(PARTITION BY "foo","bar" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_stddev_samp(self): + expr = ( + an.StdDevSamp(self.table_abc.fizz).over(self.table_abc.foo, self.table_abc.bar).orderby(self.table_abc.date) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'STDDEV_SAMP("fizz") ' 'OVER(PARTITION BY "foo","bar" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_variance(self): + expr = ( + an.Variance(self.table_abc.fizz).over(self.table_abc.foo, self.table_abc.bar).orderby(self.table_abc.date) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'VARIANCE("fizz") ' 'OVER(PARTITION BY "foo","bar" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_var_pop(self): + expr = an.VarPop(self.table_abc.fizz).over(self.table_abc.foo, self.table_abc.bar).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'VAR_POP("fizz") ' 'OVER(PARTITION BY "foo","bar" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_var_samp(self): + expr = an.VarSamp(self.table_abc.fizz).over(self.table_abc.foo, self.table_abc.bar).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'VAR_SAMP("fizz") ' 'OVER(PARTITION BY "foo","bar" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_table_prefixes_used_in_analytic_functions(self): + expr = an.Rank().over(self.table_abc.foo).orderby(self.table_efg.date) + + query = ( + Query.from_(self.table_abc) + .join(self.table_efg, how=JoinType.left) + .on(self.table_abc.foo == self.table_efg.bar) + .select("*", expr) + ) + + self.assertEqual( + 'SELECT *,RANK() OVER(PARTITION BY "abc"."foo" ORDER BY "efg"."date") ' + 'FROM "abc" LEFT JOIN "efg" ON "abc"."foo"="efg"."bar"', + str(query), + ) + + def test_sum_rows_unbounded_preceeding(self): + expr = an.Sum(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).rows(an.Preceding()) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'SUM("fizz") ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "ROWS UNBOUNDED PRECEDING" + ") " + 'FROM "abc"', + str(q), + ) + + def test_max_rows_x_preceeding(self): + expr = an.Max(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).rows(an.Preceding(5)) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'MAX("fizz") ' "OVER(" 'PARTITION BY "foo" ORDER BY "date" ' "ROWS 5 PRECEDING" ") " 'FROM "abc"', + str(q), + ) + + def test_min_rows_current_row(self): + expr = an.Min(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).rows(an.CURRENT_ROW) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'MIN("fizz") ' "OVER(" 'PARTITION BY "foo" ORDER BY "date" ' "ROWS CURRENT ROW" ") " 'FROM "abc"', + str(q), + ) + + def test_varpop_range_unbounded_preceeding(self): + expr = ( + an.VarPop(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).range(an.Preceding()) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'VAR_POP("fizz") ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "RANGE UNBOUNDED PRECEDING" + ") " + 'FROM "abc"', + str(q), + ) + + def test_max_range_x_preceeding(self): + expr = an.Max(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).range(an.Preceding(5)) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'MAX("fizz") ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "RANGE 5 PRECEDING" + ") " + 'FROM "abc"', + str(q), + ) + + def test_min_range_current_row(self): + expr = an.Min(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).range(an.CURRENT_ROW) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'MIN("fizz") ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "RANGE CURRENT ROW" + ") " + 'FROM "abc"', + str(q), + ) + + def test_variance_rows_between_unbounded_preceeding_unbounded_following(self): + expr = ( + an.Variance(self.table_abc.fizz) + .over(self.table_abc.foo) + .orderby(self.table_abc.date) + .rows(an.Preceding(), an.Following()) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'VARIANCE("fizz") ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING" + ") " + 'FROM "abc"', + str(q), + ) + + def test_first_value_range_between_x_preceeding_unbounded_following(self): + expr = ( + an.FirstValue(self.table_abc.fizz) + .over(self.table_abc.foo) + .orderby(self.table_abc.date) + .range(an.Preceding(3), an.Following()) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'FIRST_VALUE("fizz") ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "RANGE BETWEEN 3 PRECEDING AND UNBOUNDED FOLLOWING" + ") " + 'FROM "abc"', + str(q), + ) + + def test_varpop_rows_between_unbounded_preceeding_x_following(self): + expr = ( + an.VarPop(self.table_abc.fizz) + .over(self.table_abc.foo) + .orderby(self.table_abc.date) + .rows(an.Preceding(), an.Following(6)) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'VAR_POP("fizz") ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "ROWS BETWEEN UNBOUNDED PRECEDING AND 6 FOLLOWING" + ") " + 'FROM "abc"', + str(q), + ) + + def test_count_range_between_unbounded_preceeding_current_row(self): + expr = ( + an.Count(self.table_abc.fizz) + .over(self.table_abc.foo) + .orderby(self.table_abc.date) + .range(an.Preceding(), an.CURRENT_ROW) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'COUNT("fizz") ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW" + ") " + 'FROM "abc"', + str(q), + ) + + def test_last_value_rows_between_current_row_unbounded_following(self): + expr = ( + an.LastValue(self.table_abc.fizz) + .over(self.table_abc.foo) + .orderby(self.table_abc.date) + .rows(an.CURRENT_ROW, an.Following()) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'LAST_VALUE("fizz") ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING" + ") " + 'FROM "abc"', + str(q), + ) + + def test_last_value_rows_between_current_row_unbounded_following_ignore_nulls(self): + expr = ( + an.LastValue(self.table_abc.fizz) + .over(self.table_abc.foo) + .orderby(self.table_abc.date) + .ignore_nulls() + .rows(an.CURRENT_ROW, an.Following(8)) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'LAST_VALUE("fizz" IGNORE NULLS) ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "ROWS BETWEEN CURRENT ROW AND 8 FOLLOWING" + ") " + 'FROM "abc"', + str(q), + ) + + def test_empty_over(self): + query = Query.from_(self.table_abc).select(an.Sum(self.table_abc.fizz).over()) + + self.assertEqual("SELECT " 'SUM("fizz") OVER() ' 'FROM "abc"', str(query)) + + def test_rows_called_twice_raises_attribute_error(self): + with self.assertRaises(AttributeError): + an.Sum(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).rows(an.Preceding()).rows( + an.Preceding() + ) + + def test_range_called_twice_raises_attribute_error(self): + with self.assertRaises(AttributeError): + an.Sum(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).range( + an.Preceding() + ).range(an.Preceding()) + + def test_rows_then_range_raises_attribute_error(self): + with self.assertRaises(AttributeError): + an.Sum(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).rows( + an.Preceding() + ).range(an.Preceding()) + + def test_range_then_rows_raises_attribute_error(self): + with self.assertRaises(AttributeError): + an.Sum(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).range( + an.Preceding() + ).rows(an.Preceding()) + + def test_lag_generates_correct_sql(self): + with self.subTest('without partition by'): + q = Query.from_(self.table_abc).select( + Lag(self.table_abc.date, 1, '2000-01-01').orderby(self.table_abc.date) + ) + + self.assertEqual('SELECT LAG("date",1,\'2000-01-01\') OVER(ORDER BY "date") FROM "abc"', str(q)) + + with self.subTest('with partition by'): + q = Query.from_(self.table_abc).select( + Lag(self.table_abc.date, 1, '2000-01-01').over(self.table_abc.foo).orderby(self.table_abc.date) + ) + + self.assertEqual( + 'SELECT LAG("date",1,\'2000-01-01\') OVER(PARTITION BY "foo" ORDER BY "date") FROM "abc"', str(q) + ) + + def test_lead_generates_correct_sql(self): + with self.subTest('without partition by'): + q = Query.from_(self.table_abc).select( + Lead(self.table_abc.date, 1, '2000-01-01').orderby(self.table_abc.date) + ) + + self.assertEqual('SELECT LEAD("date",1,\'2000-01-01\') OVER(ORDER BY "date") FROM "abc"', str(q)) + + with self.subTest('with partition by'): + q = Query.from_(self.table_abc).select( + Lead(self.table_abc.date, 1, '2000-01-01').over(self.table_abc.foo).orderby(self.table_abc.date) + ) + + self.assertEqual( + 'SELECT LEAD("date",1,\'2000-01-01\') OVER(PARTITION BY "foo" ORDER BY "date") FROM "abc"', str(q) + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/test_create.py b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/test_create.py new file mode 100644 index 0000000000000000000000000000000000000000..325076544e3824b0d07f82f2378b88218b910dde --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/test_create.py @@ -0,0 +1,210 @@ +import unittest + +from pypika import Column, Columns, Query, Tables, Table +from pypika.terms import ValueWrapper, Index +from pypika.enums import ReferenceOption + + +class CreateTableTests(unittest.TestCase): + new_table, existing_table = Tables("abc", "efg") + foo, bar = Columns(("a", "INT"), ("b", "VARCHAR(100)")) + + def test_create_table_with_columns(self): + with self.subTest("with nullable"): + a = Column("a", "INT", True) + b = Column("b", "VARCHAR(100)", False) + q = Query.create_table(self.new_table).columns(a, b) + + self.assertEqual('CREATE TABLE "abc" ("a" INT NULL,"b" VARCHAR(100) NOT NULL)', str(q)) + + with self.subTest("with defaults"): + a = Column("a", "INT", default=ValueWrapper(42)) + b = Column("b", "VARCHAR(100)", default=ValueWrapper("foo")) + q = Query.create_table(self.new_table).columns(a, b) + + self.assertEqual('CREATE TABLE "abc" ("a" INT DEFAULT 42,"b" VARCHAR(100) DEFAULT \'foo\')', str(q)) + + with self.subTest("with unwrapped defaults"): + a = Column("a", "INT", default=42) + b = Column("b", "VARCHAR(100)", default="foo") + q = Query.create_table(self.new_table).columns(a, b) + + self.assertEqual('CREATE TABLE "abc" ("a" INT DEFAULT 42,"b" VARCHAR(100) DEFAULT \'foo\')', str(q)) + + with self.subTest("with period for"): + a = Column("id", "INT") + b = Column("valid_from", "DATETIME") + c = Column("valid_to", "DATETIME") + q = Query.create_table(self.new_table).columns(a, b, c).period_for('valid_period', b, c) + + self.assertEqual( + 'CREATE TABLE "abc" (' + '"id" INT,' + '"valid_from" DATETIME,' + '"valid_to" DATETIME,' + 'PERIOD FOR "valid_period" ("valid_from","valid_to"))', + str(q), + ) + + with self.subTest("without temporary keyword"): + q = Query.create_table(self.new_table).columns(self.foo, self.bar) + + self.assertEqual('CREATE TABLE "abc" ("a" INT,"b" VARCHAR(100))', str(q)) + + with self.subTest("with temporary keyword"): + q = Query.create_table(self.new_table).temporary().columns(self.foo, self.bar) + + self.assertEqual('CREATE TEMPORARY TABLE "abc" ("a" INT,"b" VARCHAR(100))', str(q)) + + with self.subTest("with primary key"): + q = Query.create_table(self.new_table).columns(self.foo, self.bar).primary_key(self.foo, self.bar) + + self.assertEqual('CREATE TABLE "abc" ("a" INT,"b" VARCHAR(100),PRIMARY KEY ("a","b"))', str(q)) + + with self.subTest("with simple foreign key"): + cref, dref = Columns(("c", "INT"), ("d", "VARCHAR(100)")) + q = ( + Query.create_table(self.new_table) + .columns(self.foo, self.bar) + .foreign_key([self.foo, self.bar], self.existing_table, [cref, dref]) + ) + + self.assertEqual( + 'CREATE TABLE "abc" (' + '"a" INT,' + '"b" VARCHAR(100),' + 'FOREIGN KEY ("a","b") REFERENCES "efg" ("c","d"))', + str(q), + ) + + with self.subTest("with foreign key reference options"): + cref, dref = Columns(("c", "INT"), ("d", "VARCHAR(100)")) + q = ( + Query.create_table(self.new_table) + .columns(self.foo, self.bar) + .foreign_key( + [self.foo, self.bar], + self.existing_table, + [cref, dref], + on_delete=ReferenceOption.cascade, + on_update=ReferenceOption.restrict, + ) + ) + + self.assertEqual( + 'CREATE TABLE "abc" (' + '"a" INT,' + '"b" VARCHAR(100),' + 'FOREIGN KEY ("a","b") REFERENCES "efg" ("c","d") ON DELETE CASCADE ON UPDATE RESTRICT)', + str(q), + ) + + with self.subTest("with unique keys"): + q = ( + Query.create_table(self.new_table) + .columns(self.foo, self.bar) + .unique(self.foo, self.bar) + .unique(self.foo) + ) + + self.assertEqual('CREATE TABLE "abc" ("a" INT,"b" VARCHAR(100),UNIQUE ("a","b"),UNIQUE ("a"))', str(q)) + + with self.subTest("with system versioning"): + q = Query.create_table(self.new_table).columns(self.foo, self.bar).with_system_versioning() + + self.assertEqual('CREATE TABLE "abc" ("a" INT,"b" VARCHAR(100)) WITH SYSTEM VERSIONING', str(q)) + + with self.subTest("with unlogged keyword"): + q = Query.create_table(self.new_table).unlogged().columns(self.foo, self.bar) + + self.assertEqual('CREATE UNLOGGED TABLE "abc" ("a" INT,"b" VARCHAR(100))', str(q)) + + with self.subTest("with if not exists keyword"): + q = Query.create_table(self.new_table).if_not_exists().columns(self.foo, self.bar) + + self.assertEqual('CREATE TABLE IF NOT EXISTS "abc" ("a" INT,"b" VARCHAR(100))', str(q)) + + def test_create_table_with_select(self): + select = Query.from_(self.existing_table).select(self.existing_table.foo, self.existing_table.bar) + + with self.subTest("without temporary keyword"): + q = Query.create_table(self.new_table).as_select(select) + + self.assertEqual('CREATE TABLE "abc" AS (SELECT "foo","bar" FROM "efg")', str(q)) + + with self.subTest("with temporary keyword"): + q = Query.create_table(self.new_table).temporary().as_select(select) + + self.assertEqual( + 'CREATE TEMPORARY TABLE "abc" AS (SELECT "foo","bar" FROM "efg")', + str(q), + ) + + def test_create_table_without_columns_or_select_empty(self): + q = Query.create_table(self.new_table) + + self.assertEqual("", str(q)) + + def test_create_table_with_select_and_columns_fails(self): + select = Query.from_(self.existing_table).select(self.existing_table.foo, self.existing_table.bar) + + with self.subTest("for columns before as_select"): + with self.assertRaises(AttributeError): + Query.create_table(self.new_table).columns(self.foo, self.bar).as_select(select) + + with self.subTest("for as_select before columns"): + with self.assertRaises(AttributeError): + Query.create_table(self.new_table).as_select(select).columns(self.foo, self.bar) + + with self.subTest("repeated foreign key"): + with self.assertRaises(AttributeError): + Query.create_table(self.new_table).foreign_key([self.foo], self.existing_table, [self.bar]).foreign_key( + [self.foo], self.existing_table, [self.bar] + ) + + def test_create_table_as_select_not_query_raises_error(self): + with self.assertRaises(TypeError): + Query.create_table(self.new_table).as_select("abc") + + +class CreateIndexTests(unittest.TestCase): + new_index = Index("abc") + new_table = Table("my_table") + columns = (new_table.a, new_table.b) + where = new_table.a > 1 + + def test_create_index_simple(self) -> None: + q = Query.create_index(self.new_index).on(self.new_table).columns(*self.columns) + self.assertEqual( + f'CREATE INDEX "{self.new_index.name}" ON "{self.new_table.get_table_name()}"({", ".join([c.name for c in self.columns])})', + q.get_sql(), + ) + + def test_create_index_where(self) -> None: + q = Query.create_index(self.new_index).on(self.new_table).columns(*self.columns).where(self.where) + self.assertEqual( + f'CREATE INDEX "{self.new_index.name}" ON "{self.new_table.get_table_name()}"({", ".join([c.name for c in self.columns])}) WHERE {self.where.get_sql()}', + q.get_sql(), + ) + + def test_create_index_unique(self) -> None: + q = Query.create_index(self.new_index).on(self.new_table).columns(*self.columns).unique() + self.assertEqual( + f'CREATE UNIQUE INDEX "{self.new_index.name}" ON "{self.new_table.get_table_name()}"({", ".join([c.name for c in self.columns])})', + q.get_sql(), + ) + + def test_create_index_if_not_exists(self) -> None: + q = Query.create_index(self.new_index).on(self.new_table).columns(*self.columns).if_not_exists() + self.assertEqual( + f'CREATE INDEX IF NOT EXISTS "{self.new_index.name}" ON "{self.new_table.get_table_name()}"({", ".join([c.name for c in self.columns])})', + q.get_sql(), + ) + + def test_create_index_without_columns_raises_error(self) -> None: + with self.assertRaises(AttributeError): + Query.create_index(self.new_index).on(self.new_table).get_sql() + + def test_create_index_without_table_raises_error(self) -> None: + with self.assertRaises(AttributeError): + Query.create_index(self.new_index).columns(*self.columns).get_sql() diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/test_criterions.py b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/test_criterions.py new file mode 100644 index 0000000000000000000000000000000000000000..fca2ceeeb18db88e34ebc38776f644fdcda67e93 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/test_criterions.py @@ -0,0 +1,873 @@ +import unittest +from datetime import ( + date, + datetime, +) + +from pypika import ( + Criterion, + EmptyCriterion, + Field, + Table, + functions as fn, +) +from pypika.queries import QueryBuilder +from pypika.terms import ExistsCriterion, Mod + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + + +class CriterionTests(unittest.TestCase): + t = Table("test", alias="crit") + + def test__criterion_with_alias(self): + c1 = (Field("foo") == Field("bar")).as_("criterion") + + self.assertEqual('"foo"="bar"', str(c1)) + self.assertEqual('"foo"="bar" "criterion"', c1.get_sql(with_alias=True, quote_char='"', alias_quote_char='"')) + + def test__criterion_eq_number(self): + c1 = Field("foo") == 1 + c2 = Field("foo", table=self.t).eq(0) + c3 = Field("foo", table=self.t) == -1 + + self.assertEqual('"foo"=1', str(c1)) + self.assertEqual('"crit"."foo"=0', str(c2)) + self.assertEqual('"crit"."foo"=-1', str(c3)) + + def test__criterion_eq_decimal(self): + c1 = Field("foo") == 1.0 + c2 = Field("foo", table=self.t).eq(0.5) + + self.assertEqual('"foo"=1.0', str(c1)) + self.assertEqual('"crit"."foo"=0.5', str(c2)) + + def test__criterion_eq_bool(self): + c1 = Field("foo") == True + c2 = Field("foo", table=self.t).eq(True) + c3 = Field("foo") == False + c4 = Field("foo", table=self.t).eq(False) + + self.assertEqual('"foo"=true', str(c1)) + self.assertEqual('"crit"."foo"=true', str(c2)) + self.assertEqual('"foo"=false', str(c3)) + self.assertEqual('"crit"."foo"=false', str(c4)) + + def test__criterion_eq_str(self): + c1 = Field("foo") == "abc" + c2 = Field("foo", table=self.t).eq("abc") + + self.assertEqual("\"foo\"='abc'", str(c1)) + self.assertEqual('"crit"."foo"=\'abc\'', str(c2)) + + def test__criterion_eq_date(self): + c1 = Field("foo") == date(2000, 1, 1) + c2 = Field("foo", table=self.t).eq(date(2000, 1, 1)) + + self.assertEqual("\"foo\"='2000-01-01'", str(c1)) + self.assertEqual('"crit"."foo"=\'2000-01-01\'', str(c2)) + + def test__criterion_eq_datetime(self): + c1 = Field("foo") == datetime(2000, 1, 1, 12, 30, 55) + c2 = Field("foo", table=self.t).eq(datetime(2000, 1, 1, 12, 30, 55)) + + self.assertEqual("\"foo\"='2000-01-01T12:30:55'", str(c1)) + self.assertEqual('"crit"."foo"=\'2000-01-01T12:30:55\'', str(c2)) + + def test__criterion_eq_right(self): + c1 = 1 == Field("foo") + c2 = -1 == Field("foo", table=self.t) + + self.assertEqual('"foo"=1', str(c1)) + self.assertEqual('"crit"."foo"=-1', str(c2)) + + def test__criterion_is_null(self): + c1 = Field("foo").isnull() + c2 = Field("foo", table=self.t).isnull() + + self.assertEqual('"foo" IS NULL', str(c1)) + self.assertEqual('"crit"."foo" IS NULL', str(c2)) + + def test__criterion_is_null_with_alias(self): + c1 = Field("foo").isnull().as_('alias') + c2 = Field("foo", table=self.t).isnull().as_('alias') + + self.assertEqual('"foo" IS NULL "alias"', str(c1)) + self.assertEqual('"crit"."foo" IS NULL "alias"', str(c2)) + + def test__criterion_ne_number(self): + c1 = Field("foo") != 1 + c2 = Field("foo", table=self.t).ne(0) + c3 = Field("foo") != -1 + + self.assertEqual('"foo"<>1', str(c1)) + self.assertEqual('"crit"."foo"<>0', str(c2)) + self.assertEqual('"foo"<>-1', str(c3)) + + def test__criterion_ne_str(self): + c1 = Field("foo") != "abc" + c2 = Field("foo", table=self.t).ne("abc") + + self.assertEqual("\"foo\"<>'abc'", str(c1)) + self.assertEqual('"crit"."foo"<>\'abc\'', str(c2)) + + def test__criterion_ne_date(self): + c1 = Field("foo") != date(2000, 1, 1) + c2 = Field("foo", table=self.t).ne(date(2000, 1, 1)) + + self.assertEqual("\"foo\"<>'2000-01-01'", str(c1)) + self.assertEqual('"crit"."foo"<>\'2000-01-01\'', str(c2)) + + def test__criterion_ne_datetime(self): + c1 = Field("foo") != datetime(2000, 1, 1, 12, 30, 55) + c2 = Field("foo", table=self.t).ne(datetime(2000, 1, 1, 12, 30, 55)) + + self.assertEqual("\"foo\"<>'2000-01-01T12:30:55'", str(c1)) + self.assertEqual('"crit"."foo"<>\'2000-01-01T12:30:55\'', str(c2)) + + def test__criterion_ne_right(self): + c1 = 1 != Field("foo") + c2 = -1 != Field("foo", table=self.t) + + self.assertEqual('"foo"<>1', str(c1)) + self.assertEqual('"crit"."foo"<>-1', str(c2)) + + def test__criterion_lt_number(self): + c1 = Field("foo") < 1 + c2 = Field("foo", table=self.t).lt(0) + c3 = Field("foo") < -1 + + self.assertEqual('"foo"<1', str(c1)) + self.assertEqual('"crit"."foo"<0', str(c2)) + self.assertEqual('"foo"<-1', str(c3)) + + def test__criterion_lt_date(self): + c1 = Field("foo") < date(2000, 1, 1) + c2 = Field("foo", table=self.t).lt(date(2000, 1, 1)) + + self.assertEqual("\"foo\"<'2000-01-01'", str(c1)) + self.assertEqual('"crit"."foo"<\'2000-01-01\'', str(c2)) + + def test__criterion_lt_datetime(self): + c1 = Field("foo") < datetime(2000, 1, 1, 12, 30, 55) + c2 = Field("foo", table=self.t).lt(datetime(2000, 1, 1, 12, 30, 55)) + + self.assertEqual("\"foo\"<'2000-01-01T12:30:55'", str(c1)) + self.assertEqual('"crit"."foo"<\'2000-01-01T12:30:55\'', str(c2)) + + def test__criterion_lt_right(self): + c1 = 1 > Field("foo") + c2 = -1 > Field("foo", table=self.t) + + self.assertEqual('"foo"<1', str(c1)) + self.assertEqual('"crit"."foo"<-1', str(c2)) + + def test__criterion_gt_number(self): + c1 = Field("foo") > 1 + c2 = Field("foo", table=self.t).gt(0) + c3 = Field("foo") > -1 + + self.assertEqual('"foo">1', str(c1)) + self.assertEqual('"crit"."foo">0', str(c2)) + self.assertEqual('"foo">-1', str(c3)) + + def test__criterion_gt_date(self): + c1 = Field("foo") > date(2000, 1, 1) + c2 = Field("foo", table=self.t).gt(date(2000, 1, 1)) + + self.assertEqual("\"foo\">'2000-01-01'", str(c1)) + self.assertEqual('"crit"."foo">\'2000-01-01\'', str(c2)) + + def test__criterion_gt_datetime(self): + c1 = Field("foo") > datetime(2000, 1, 1, 12, 30, 55) + c2 = Field("foo", table=self.t).gt(datetime(2000, 1, 1, 12, 30, 55)) + + self.assertEqual("\"foo\">'2000-01-01T12:30:55'", str(c1)) + self.assertEqual('"crit"."foo">\'2000-01-01T12:30:55\'', str(c2)) + + def test__criterion_gt_right(self): + c1 = 1 < Field("foo") + c2 = -1 < Field("foo", table=self.t) + + self.assertEqual('"foo">1', str(c1)) + self.assertEqual('"crit"."foo">-1', str(c2)) + + def test__criterion_lte_number(self): + c1 = Field("foo") <= 1 + c2 = Field("foo", table=self.t).lte(0) + c3 = Field("foo") <= -1 + + self.assertEqual('"foo"<=1', str(c1)) + self.assertEqual('"crit"."foo"<=0', str(c2)) + self.assertEqual('"foo"<=-1', str(c3)) + + def test__criterion_lte_date(self): + c1 = Field("foo") <= date(2000, 1, 1) + c2 = Field("foo", table=self.t).lte(date(2000, 1, 1)) + + self.assertEqual("\"foo\"<='2000-01-01'", str(c1)) + self.assertEqual('"crit"."foo"<=\'2000-01-01\'', str(c2)) + + def test__criterion_lte_datetime(self): + c1 = Field("foo") <= datetime(2000, 1, 1, 12, 30, 55) + c2 = Field("foo", table=self.t).lte(datetime(2000, 1, 1, 12, 30, 55)) + + self.assertEqual("\"foo\"<='2000-01-01T12:30:55'", str(c1)) + self.assertEqual('"crit"."foo"<=\'2000-01-01T12:30:55\'', str(c2)) + + def test__criterion_lte_right(self): + c1 = 1 >= Field("foo") + c2 = -1 >= Field("foo", table=self.t) + + self.assertEqual('"foo"<=1', str(c1)) + self.assertEqual('"crit"."foo"<=-1', str(c2)) + + def test__criterion_gte_number(self): + c1 = Field("foo") >= 1 + c2 = Field("foo", table=self.t).gte(0) + c3 = Field("foo") >= -1 + + self.assertEqual('"foo">=1', str(c1)) + self.assertEqual('"crit"."foo">=0', str(c2)) + self.assertEqual('"foo">=-1', str(c3)) + + def test__criterion_gte_date(self): + c1 = Field("foo") >= date(2000, 1, 1) + c2 = Field("foo", table=self.t).gte(date(2000, 1, 1)) + + self.assertEqual("\"foo\">='2000-01-01'", str(c1)) + self.assertEqual('"crit"."foo">=\'2000-01-01\'', str(c2)) + + def test__criterion_gte_datetime(self): + c1 = Field("foo") >= datetime(2000, 1, 1, 12, 30, 55) + c2 = Field("foo", table=self.t).gte(datetime(2000, 1, 1, 12, 30, 55)) + + self.assertEqual("\"foo\">='2000-01-01T12:30:55'", str(c1)) + self.assertEqual('"crit"."foo">=\'2000-01-01T12:30:55\'', str(c2)) + + def test__criterion_gte_right(self): + c1 = 1 <= Field("foo") + c2 = -1 <= Field("foo", table=self.t) + + self.assertEqual('"foo">=1', str(c1)) + self.assertEqual('"crit"."foo">=-1', str(c2)) + + def test__criterion_bitwise_and(self): + c1 = Field("foo").bitwiseand(2) + c2 = Field("foo", table=self.t).bitwiseand(10) == 2 + + self.assertEqual('("foo" & 2)', str(c1)) + self.assertEqual('("crit"."foo" & 10)=2', str(c2)) + + def test__criterion_bitwise_and_with_alias(self): + c1 = Field("foo").bitwiseand(2).as_('alias') + + self.assertEqual('("foo" & 2) "alias"', str(c1)) + + def test__bitwise_and_in_where_clause(self): + q = QueryBuilder().from_('items').select('abc').where(Field("foo").bitwiseand(1) == 1) + + self.assertEqual('SELECT "abc" FROM "items" WHERE ("foo" & 1)=1', str(q)) + + +class NotTests(unittest.TestCase): + table_abc, table_efg = Table("abc", alias="cx0"), Table("efg", alias="cx1") + + def test_negate(self): + c1 = Field("foo") >= 1 + c2 = c1.negate() + + self.assertEqual('"foo">=1', str(c1)) + self.assertEqual('NOT "foo">=1', str(c2)) + + def test_variable_access(self): + c1 = Field("foo").negate() + + self.assertEqual(c1.is_aggregate, False) + + def test_chained_function(self): + field1 = Field("foo").negate() + field2 = field1.eq("bar") + + self.assertEqual('NOT "foo"', str(field1)) + self.assertEqual("NOT \"foo\"='bar'", str(field2)) + self.assertIsNot(field1, field2) + + def test_not_null(self): + c1 = Field("foo").notnull() + c2 = Field("foo", table=self.table_abc).notnull() + + self.assertEqual('NOT "foo" IS NULL', str(c1)) + self.assertEqual('NOT "cx0"."foo" IS NULL', str(c2)) + + def test_is_not_null(self): + c1 = Field("foo").isnotnull() + c2 = Field("foo", table=self.table_abc).isnotnull() + + self.assertEqual('"foo" IS NOT NULL', str(c1)) + self.assertEqual('"cx0"."foo" IS NOT NULL', str(c2)) + + def test_not_null_with_alias(self): + c1 = Field("foo").notnull().as_("something") + c2 = Field("foo", table=self.table_abc).notnull().as_("something") + + self.assertEqual('NOT "foo" IS NULL "something"', str(c1)) + self.assertEqual('NOT "cx0"."foo" IS NULL "something"', str(c2)) + + def test_notnullcriterion_replace_table(self): + f = self.table_abc.foo.notnull().replace_table(self.table_abc, self.table_efg) + + self.assertEqual('NOT "cx1"."foo" IS NULL', str(f)) + + def test_not_with_or_criterion(self): + self.assertEqual('NOT ("foo" OR "bar")', str(~(Field("foo") | Field("bar")))) + + def test_not_with_and_criterion(self): + self.assertEqual('NOT ("foo" AND "bar")', str(~(Field("foo") & Field("bar")))) + + def test_not_with_complex_criterion(self): + self.assertEqual( + 'NOT ("foo" AND "bar" AND "fizz" AND "buzz")', + str(~(Field("foo") & Field("bar") & Field("fizz") & Field("buzz"))), + ) + + +class BetweenTests(unittest.TestCase): + t = Table("abc", alias="btw") + + def test__between_number(self): + c1 = Field("foo").between(0, 1) + c2 = Field("foo", table=self.t).between(0, 1) + c3 = Field("foo")[0:1] + + self.assertEqual('"foo" BETWEEN 0 AND 1', str(c1)) + self.assertEqual('"btw"."foo" BETWEEN 0 AND 1', str(c2)) + self.assertEqual('"foo" BETWEEN 0 AND 1', str(c3)) + + def test__between_with_alias(self): + c1 = Field("foo").between(0, 1).as_('alias') + c2 = Field("foo", table=self.t).between(0, 1).as_('alias') + c3 = Field("foo")[0:1].as_('alias') + + self.assertEqual('"foo" BETWEEN 0 AND 1 "alias"', str(c1)) + self.assertEqual('"btw"."foo" BETWEEN 0 AND 1 "alias"', str(c2)) + self.assertEqual('"foo" BETWEEN 0 AND 1 "alias"', str(c3)) + + def test__between_date(self): + c1 = Field("foo").between(date(2000, 1, 1), date(2000, 12, 31)) + c2 = Field("foo", table=self.t).between(date(2000, 1, 1), date(2000, 12, 31)) + c3 = Field("foo")[date(2000, 1, 1) : date(2000, 12, 31)] + + self.assertEqual("\"foo\" BETWEEN '2000-01-01' AND '2000-12-31'", str(c1)) + self.assertEqual("\"btw\".\"foo\" BETWEEN '2000-01-01' AND '2000-12-31'", str(c2)) + self.assertEqual("\"foo\" BETWEEN '2000-01-01' AND '2000-12-31'", str(c3)) + + def test__between_datetime(self): + c1 = Field("foo").between(datetime(2000, 1, 1, 0, 0, 0), datetime(2000, 12, 31, 23, 59, 59)) + c2 = Field("foo", table=self.t).between(datetime(2000, 1, 1, 0, 0, 0), datetime(2000, 12, 31, 23, 59, 59)) + c3 = Field("foo")[datetime(2000, 1, 1, 0, 0, 0) : datetime(2000, 12, 31, 23, 59, 59)] + + self.assertEqual("\"foo\" BETWEEN '2000-01-01T00:00:00' AND '2000-12-31T23:59:59'", str(c1)) + self.assertEqual( + "\"btw\".\"foo\" BETWEEN '2000-01-01T00:00:00' AND '2000-12-31T23:59:59'", + str(c2), + ) + self.assertEqual("\"foo\" BETWEEN '2000-01-01T00:00:00' AND '2000-12-31T23:59:59'", str(c3)) + + def test__function_between(self): + c1 = fn.Coalesce(Field("foo"), 0)[0:1] + c2 = fn.Coalesce(Field("foo", table=self.t), 0)[0:1] + + self.assertEqual('COALESCE("foo",0) BETWEEN 0 AND 1', str(c1)) + self.assertEqual('COALESCE("btw"."foo",0) BETWEEN 0 AND 1', str(c2)) + + def test_get_item_only_works_with_slice(self): + with self.assertRaises(TypeError): + Field("foo")[0] + + with self.assertRaises(TypeError): + Field("foo")[date(2000, 1, 1)] + + with self.assertRaises(TypeError): + Field("foo")[datetime(2000, 1, 1, 0, 0, 0)] + + +class IsInTests(unittest.TestCase): + t = Table("abc", alias="isin") + + def test__in_number(self): + c1 = Field("foo").isin([0, 1]) + c2 = Field("foo", table=self.t).isin([0, 1]) + + self.assertEqual('"foo" IN (0,1)', str(c1)) + self.assertEqual('"isin"."foo" IN (0,1)', str(c2)) + + def test__in_number_with_alias(self): + c1 = Field("foo").isin([0, 1]).as_('alias') + c2 = Field("foo", table=self.t).isin([0, 1]).as_('alias') + + self.assertEqual('"foo" IN (0,1) "alias"', str(c1)) + self.assertEqual('"isin"."foo" IN (0,1) "alias"', str(c2)) + + def test__in_character(self): + c1 = Field("foo").isin(["a", "b"]) + c2 = Field("foo", table=self.t).isin(["a", "b"]) + + self.assertEqual("\"foo\" IN ('a','b')", str(c1)) + self.assertEqual("\"isin\".\"foo\" IN ('a','b')", str(c2)) + + def test__in_date(self): + c1 = Field("foo").isin([date(2000, 1, 1), date(2000, 12, 31)]) + c2 = Field("foo", table=self.t).isin([date(2000, 1, 1), date(2000, 12, 31)]) + + self.assertEqual("\"foo\" IN ('2000-01-01','2000-12-31')", str(c1)) + self.assertEqual("\"isin\".\"foo\" IN ('2000-01-01','2000-12-31')", str(c2)) + + def test__in_datetime(self): + c1 = Field("foo").isin([datetime(2000, 1, 1, 0, 0, 0), datetime(2000, 12, 31, 23, 59, 59)]) + c2 = Field("foo", table=self.t).isin([datetime(2000, 1, 1, 0, 0, 0), datetime(2000, 12, 31, 23, 59, 59)]) + + self.assertEqual("\"foo\" IN ('2000-01-01T00:00:00','2000-12-31T23:59:59')", str(c1)) + self.assertEqual("\"isin\".\"foo\" IN ('2000-01-01T00:00:00','2000-12-31T23:59:59')", str(c2)) + + def test__function_isin(self): + c1 = fn.Coalesce(Field("foo"), 0).isin([0, 1]) + c2 = fn.Coalesce(Field("foo", table=self.t), 0).isin([0, 1]) + + self.assertEqual('COALESCE("foo",0) IN (0,1)', str(c1)) + self.assertEqual('COALESCE("isin"."foo",0) IN (0,1)', str(c2)) + + for t in (list, tuple, set, frozenset): + c_type = fn.Coalesce(Field("foo"), 0).isin(t([0, 1])) + self.assertEqual('COALESCE("foo",0) IN (0,1)', str(c_type)) + + self.assertRaises(AttributeError, lambda: str(fn.Coalesce(Field("foo"), 0).isin('SHOULD_FAIL'))) + + def test__in_unicode(self): + c1 = Field("foo").isin([u"a", u"b"]) + c2 = Field("foo", table=self.t).isin([u"a", u"b"]) + + self.assertEqual("\"foo\" IN ('a','b')", str(c1)) + self.assertEqual("\"isin\".\"foo\" IN ('a','b')", str(c2)) + + +class ArithmeticExpressionTests(unittest.TestCase): + def test__lshift(self): + c1 = Field("foo").lshift("1") + c2 = Field("foo").lshift("2") + + self.assertEqual("\"foo\"<<'1'", str(c1)) + self.assertEqual("\"foo\"<<'2'", str(c2)) + + def test__rshift(self): + c1 = Field("foo").rshift("1") + c2 = Field("foo").rshift("2") + + self.assertEqual("\"foo\">>'1'", str(c1)) + self.assertEqual("\"foo\">>'2'", str(c2)) + + +class NotInTests(unittest.TestCase): + t = Table("abc", alias="notin") + + def test__notin_number(self): + c1 = Field("foo").notin([0, 1]) + c2 = Field("foo", table=self.t).notin([0, 1]) + + self.assertEqual('"foo" NOT IN (0,1)', str(c1)) + self.assertEqual('"notin"."foo" NOT IN (0,1)', str(c2)) + + def test__notin_number_with_alias(self): + c1 = Field("foo").notin([0, 1]).as_('alias') + c2 = Field("foo", table=self.t).notin([0, 1]).as_('alias') + + self.assertEqual('"foo" NOT IN (0,1) "alias"', str(c1)) + self.assertEqual('"notin"."foo" NOT IN (0,1) "alias"', str(c2)) + + def test__notin_character(self): + c1 = Field("foo").notin(["a", "b"]) + c2 = Field("foo", table=self.t).notin(["a", "b"]) + + self.assertEqual("\"foo\" NOT IN ('a','b')", str(c1)) + self.assertEqual("\"notin\".\"foo\" NOT IN ('a','b')", str(c2)) + + def test__notin_date(self): + c1 = Field("foo").notin([date(2000, 1, 1), date(2000, 12, 31)]) + c2 = Field("foo", table=self.t).notin([date(2000, 1, 1), date(2000, 12, 31)]) + + self.assertEqual("\"foo\" NOT IN ('2000-01-01','2000-12-31')", str(c1)) + self.assertEqual("\"notin\".\"foo\" NOT IN ('2000-01-01','2000-12-31')", str(c2)) + + def test__notin_datetime(self): + c1 = Field("foo").notin([datetime(2000, 1, 1, 0, 0, 0), datetime(2000, 12, 31, 23, 59, 59)]) + c2 = Field("foo", table=self.t).notin([datetime(2000, 1, 1, 0, 0, 0), datetime(2000, 12, 31, 23, 59, 59)]) + + self.assertEqual("\"foo\" NOT IN ('2000-01-01T00:00:00','2000-12-31T23:59:59')", str(c1)) + self.assertEqual( + "\"notin\".\"foo\" NOT IN ('2000-01-01T00:00:00','2000-12-31T23:59:59')", + str(c2), + ) + + def test__function_notin(self): + c1 = fn.Coalesce(Field("foo"), 0).notin([0, 1]) + c2 = fn.Coalesce(Field("foo", table=self.t), 0).notin([0, 1]) + + self.assertEqual('COALESCE("foo",0) NOT IN (0,1)', str(c1)) + self.assertEqual('COALESCE("notin"."foo",0) NOT IN (0,1)', str(c2)) + + +class LikeTests(unittest.TestCase): + t = Table("abc", alias="like") + + def test_like_starts_with(self): + c1 = Field("foo").like("ab%") + c2 = Field("foo", table=self.t).like("ab%") + + self.assertEqual("\"foo\" LIKE 'ab%'", str(c1)) + self.assertEqual('"like"."foo" LIKE \'ab%\'', str(c2)) + + def test_like_contains(self): + c1 = Field("foo").like("%ab%") + c2 = Field("foo", table=self.t).like("%ab%") + + self.assertEqual("\"foo\" LIKE '%ab%'", str(c1)) + self.assertEqual('"like"."foo" LIKE \'%ab%\'', str(c2)) + + def test_like_ends_with(self): + c1 = Field("foo").like("%ab") + c2 = Field("foo", table=self.t).like("%ab") + + self.assertEqual("\"foo\" LIKE '%ab'", str(c1)) + self.assertEqual('"like"."foo" LIKE \'%ab\'', str(c2)) + + def test_like_n_chars_long(self): + c1 = Field("foo").like("___") + c2 = Field("foo", table=self.t).like("___") + + self.assertEqual("\"foo\" LIKE '___'", str(c1)) + self.assertEqual('"like"."foo" LIKE \'___\'', str(c2)) + + def test_like_single_chars_and_various_chars(self): + c1 = Field("foo").like("a_b%c") + c2 = Field("foo", table=self.t).like("a_b%c") + + self.assertEqual("\"foo\" LIKE 'a_b%c'", str(c1)) + self.assertEqual('"like"."foo" LIKE \'a_b%c\'', str(c2)) + + def test_not_like_single_chars_and_various_chars(self): + c1 = Field("foo").not_like("a_b%c") + c2 = Field("foo", table=self.t).not_like("a_b%c") + + self.assertEqual("\"foo\" NOT LIKE 'a_b%c'", str(c1)) + self.assertEqual('"like"."foo" NOT LIKE \'a_b%c\'', str(c2)) + + def test_ilike_starts_with(self): + c1 = Field("foo").ilike("ab%") + c2 = Field("foo", table=self.t).ilike("ab%") + + self.assertEqual("\"foo\" ILIKE 'ab%'", str(c1)) + self.assertEqual('"like"."foo" ILIKE \'ab%\'', str(c2)) + + def test_ilike_contains(self): + c1 = Field("foo").ilike("%ab%") + c2 = Field("foo", table=self.t).ilike("%ab%") + + self.assertEqual("\"foo\" ILIKE '%ab%'", str(c1)) + self.assertEqual('"like"."foo" ILIKE \'%ab%\'', str(c2)) + + def test_ilike_ends_with(self): + c1 = Field("foo").ilike("%ab") + c2 = Field("foo", table=self.t).ilike("%ab") + + self.assertEqual("\"foo\" ILIKE '%ab'", str(c1)) + self.assertEqual('"like"."foo" ILIKE \'%ab\'', str(c2)) + + def test_ilike_n_chars_long(self): + c1 = Field("foo").ilike("___") + c2 = Field("foo", table=self.t).ilike("___") + + self.assertEqual("\"foo\" ILIKE '___'", str(c1)) + self.assertEqual('"like"."foo" ILIKE \'___\'', str(c2)) + + def test_ilike_single_chars_and_various_chars(self): + c1 = Field("foo").ilike("a_b%c") + c2 = Field("foo", table=self.t).ilike("a_b%c") + + self.assertEqual("\"foo\" ILIKE 'a_b%c'", str(c1)) + self.assertEqual('"like"."foo" ILIKE \'a_b%c\'', str(c2)) + + def test_not_ilike_single_chars_and_various_chars(self): + c1 = Field("foo").not_ilike("a_b%c") + c2 = Field("foo", table=self.t).not_ilike("a_b%c") + + self.assertEqual("\"foo\" NOT ILIKE 'a_b%c'", str(c1)) + self.assertEqual('"like"."foo" NOT ILIKE \'a_b%c\'', str(c2)) + + def test_rlike_escape_chars(self): + c1 = Field("foo").rlike("\\\\d+$") + c2 = Field("foo", table=self.t).rlike("\\\\d+$") + + self.assertEqual("\"foo\" RLIKE '\\\\d+$'", str(c1)) + self.assertEqual('"like"."foo" RLIKE \'\\\\d+$\'', str(c2)) + + def test_glob_single_chars_and_various_chars(self): + c1 = Field("foo").glob("a_b*") + c2 = Field("foo", table=self.t).glob("a_b*") + + self.assertEqual("\"foo\" GLOB 'a_b*'", str(c1)) + self.assertEqual('"like"."foo" GLOB \'a_b*\'', str(c2)) + + +class ExistsCriterionTests(unittest.TestCase): + t2 = Table("abc", alias="t2") + q2 = QueryBuilder().from_(t2).select(t2.field2) + + def test_exists(self): + t1 = Table("def", alias="t1") + q1 = QueryBuilder().from_(t1).where(ExistsCriterion(self.q2)).select(t1.field1) + + self.assertEqual( + 'SELECT "t1"."field1" FROM "def" "t1" WHERE EXISTS (SELECT "t2"."field2" FROM "abc" "t2")', str(q1) + ) + + def test_not_exists(self): + t1 = Table("def", alias="t1") + q1 = QueryBuilder().from_(t1).where(ExistsCriterion(self.q2).negate()).select(t1.field1) + + self.assertEqual( + 'SELECT "t1"."field1" FROM "def" "t1" WHERE NOT EXISTS (SELECT "t2"."field2" FROM "abc" "t2")', str(q1) + ) + + +class ComplexCriterionTests(unittest.TestCase): + table_abc, table_efg = Table("abc", alias="cx0"), Table("efg", alias="cx1") + + def test_and(self): + c1 = (Field("foo") == 1) & (Field("bar") == 2) + c2 = (Field("foo", table=self.table_abc) == 1) & (Field("bar", table=self.table_efg) == 2) + + self.assertEqual('"foo"=1 AND "bar"=2', str(c1)) + self.assertEqual('"cx0"."foo"=1 AND "cx1"."bar"=2', str(c2)) + + def test_or(self): + c1 = (Field("foo") == 1) | (Field("bar") == 2) + c2 = (Field("foo", table=self.table_abc) == 1) | (Field("bar", table=self.table_efg) == 2) + + self.assertEqual('"foo"=1 OR "bar"=2', str(c1)) + self.assertEqual('"cx0"."foo"=1 OR "cx1"."bar"=2', str(c2)) + + def test_xor(self): + c1 = (Field("foo") == 1) ^ (Field("bar") == 2) + c2 = (Field("foo", table=self.table_abc) == 1) ^ (Field("bar", table=self.table_efg) == 2) + + self.assertEqual('"foo"=1 XOR "bar"=2', str(c1)) + self.assertEqual('"cx0"."foo"=1 XOR "cx1"."bar"=2', str(c2)) + + def test_function_and(self): + c1 = fn.IsNull(Field("foo")) & (Field("bar") == 2) + + self.assertEqual('ISNULL("foo") AND "bar"=2', str(c1)) + + def test_function_or(self): + c1 = fn.IsNull(Field("foo")) | (Field("bar") == 2) + + self.assertEqual('ISNULL("foo") OR "bar"=2', str(c1)) + + def test_function_xor(self): + c1 = fn.IsNull(Field("foo")) ^ (Field("bar") == 2) + + self.assertEqual('ISNULL("foo") XOR "bar"=2', str(c1)) + + def test__nested__and(self): + c = (Field("foo") == 1) & (Field("bar") == 2) & (Field("buz") == 3) + + self.assertEqual('"foo"=1 AND "bar"=2 AND "buz"=3', str(c)) + + def test__nested__or(self): + c = (Field("foo") == 1) | (Field("bar") == 2) | (Field("buz") == 3) + + self.assertEqual('"foo"=1 OR "bar"=2 OR "buz"=3', str(c)) + + def test__nested__mixed(self): + c = ((Field("foo") == 1) & (Field("bar") == 2)) | (Field("buz") == 3) + + self.assertEqual('("foo"=1 AND "bar"=2) OR "buz"=3', str(c)) + + def test__between_and_isin(self): + c = Field("foo").isin([1, 2, 3]) & Field("bar").between(0, 1) + + self.assertEqual('"foo" IN (1,2,3) AND "bar" BETWEEN 0 AND 1', str(c)) + + def test__between_and_field(self): + c1 = Field("foo").between(0, 1) + c2 = Field("bool_field") + + self.assertEqual('"foo" BETWEEN 0 AND 1 AND "bool_field"', str(c1 & c2)) + self.assertEqual('"bool_field" AND "foo" BETWEEN 0 AND 1', str(c2 & c1)) + + +class FieldsAsCriterionTests(unittest.TestCase): + def test__field_and_field(self): + c1 = Field("a") + c2 = Field("b") + + self.assertEqual('"a" AND "b"', str(c1 & c2)) + + def test__field_or_field(self): + c1 = Field("a") + c2 = Field("b") + + self.assertEqual('"a" OR "b"', str(c1 | c2)) + + def test__field_xor_field(self): + c1 = Field("a") + c2 = Field("b") + + self.assertEqual('"a" XOR "b"', str(c1 ^ c2)) + + +class CriterionOperationsTests(unittest.TestCase): + table_abc, table_efg = Table("abc", alias="cx0"), Table("efg", alias="cx1") + + def test_field_replace_table(self): + f = self.table_abc.foo.replace_table(self.table_abc, self.table_efg) + + self.assertEqual('"cx1"."foo"', str(f)) + + def test_arithmeticfunction_replace_table(self): + f = (self.table_abc.foo + self.table_abc.bar).replace_table(self.table_abc, self.table_efg) + + self.assertEqual('"cx1"."foo"+"cx1"."bar"', str(f)) + + def test_criterion_replace_table(self): + f = (self.table_abc.foo < self.table_abc.bar).replace_table(self.table_abc, self.table_efg) + + self.assertEqual('"cx1"."foo"<"cx1"."bar"', str(f)) + + def test_complexcriterion_replace_table(self): + f = (self.table_abc.foo < self.table_abc.bar) & (self.table_abc.fiz > self.table_abc.buz) + f = f.replace_table(self.table_abc, self.table_efg) + + self.assertEqual('"cx1"."foo"<"cx1"."bar" AND "cx1"."fiz">"cx1"."buz"', str(f)) + + def test_function_with_only_fields_replace_table(self): + f = fn.Sum(self.table_abc.foo).replace_table(self.table_abc, self.table_efg) + + self.assertEqual('SUM("cx1"."foo")', str(f)) + + def test_function_with_values_and_fields_replace_table(self): + f = Mod(self.table_abc.foo, 2).replace_table(self.table_abc, self.table_efg) + + self.assertEqual('MOD("cx1"."foo",2)', str(f)) + + def test_betweencriterion_replace_table(self): + f = self.table_abc.foo[0:1].replace_table(self.table_abc, self.table_efg) + + self.assertEqual('"cx1"."foo" BETWEEN 0 AND 1', str(f)) + + def test_nullcriterion_replace_table(self): + f = self.table_abc.foo.isnull().replace_table(self.table_abc, self.table_efg) + + self.assertEqual('"cx1"."foo" IS NULL', str(f)) + + +class AnyTests(unittest.TestCase): + def test_zero_args_returns_empty_criterion(self): + crit = Criterion.any() + self.assertIsInstance(crit, EmptyCriterion) + + def test_single_arg_returns_self(self): + f = Field("a") + crit = Criterion.any([f]) + self.assertEqual(str(f), str(crit)) + + def test_multiple_args_returned_in_chain_of_ors(self): + crit = Criterion.any([Field("a"), Field("b"), Field("c"), Field("d")]) + self.assertEqual(str(crit), '"a" OR "b" OR "c" OR "d"') + + def test_with_generator(self): + crit = Criterion.any(Field(letter) for letter in "abcd") + self.assertEqual(str(crit), '"a" OR "b" OR "c" OR "d"') + + +class EmptyCriterionTests(unittest.TestCase): + def test_fields_(self): + empty_criterion = EmptyCriterion() + + self.assertEqual(len(empty_criterion.fields_()), 0) + + def test_empty_criterion_on_the_left(self): + t = Table("test1") + q = EmptyCriterion() & t.f1 == "v1" + + self.assertEqual( + '"test1"."f1"=\'v1\'', + q.get_sql(with_namespace=True), + ) + + def test_empty_criterion_on_the_right(self): + t = Table("test1") + q = (t.f1 == "v1") & EmptyCriterion() + + self.assertEqual( + '"test1"."f1"=\'v1\'', + q.get_sql(with_namespace=True), + ) + + def test_invertion_of_the_empty_criterion(self): + t = Table("test1") + q = (t.f1 == "v1") & ~EmptyCriterion() + + self.assertEqual( + '"test1"."f1"=\'v1\'', + q.get_sql(with_namespace=True), + ) + + def test_different_operations_with_empty_criterion(self): + t = Table("test1") + q1 = (t.f1 == "v1") & EmptyCriterion() + q2 = (t.f1 == "v1") | EmptyCriterion() + q3 = (t.f1 == "v1") ^ EmptyCriterion() + + expected_sql = '"test1"."f1"=\'v1\'' + self.assertEqual( + expected_sql, + q1.get_sql(with_namespace=True), + ) + self.assertEqual( + expected_sql, + q2.get_sql(with_namespace=True), + ) + self.assertEqual( + expected_sql, + q3.get_sql(with_namespace=True), + ) + + def test_more_than_one_empty_criterions(self): + t = Table("test1") + q = EmptyCriterion() & ~(EmptyCriterion() | EmptyCriterion()) & (t.f1 == "v1") & ~EmptyCriterion() + + self.assertEqual( + '"test1"."f1"=\'v1\'', + q.get_sql(with_namespace=True), + ) + + +class AllTests(unittest.TestCase): + def test_zero_args_returns_empty_criterion(self): + crit = Criterion.all() + self.assertIsInstance(crit, EmptyCriterion) + + def test_single_arg_returns_self(self): + f = Field("a") + crit = Criterion.all([f]) + self.assertEqual(str(f), str(crit)) + + def test_multiple_args_returned_in_chain_of_ors(self): + crit = Criterion.all([Field("a"), Field("b"), Field("c"), Field("d")]) + self.assertEqual(str(crit), '"a" AND "b" AND "c" AND "d"') + + def test_with_generator(self): + crit = Criterion.all(Field(letter) for letter in "abcd") + self.assertEqual(str(crit), '"a" AND "b" AND "c" AND "d"') diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/test_custom_functions.py b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/test_custom_functions.py new file mode 100644 index 0000000000000000000000000000000000000000..60ffd3cd8e6191e3fc782dac003c41bfb7a78528 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/test_custom_functions.py @@ -0,0 +1,49 @@ +import unittest + +from pypika import CustomFunction, FunctionException, Query, Table + +__author__ = "Airton Zanon" +__email__ = "me@airton.dev" + + +class TestUnitCustomFunction(unittest.TestCase): + def test_should_fail_with_wrong_arguments(self): + DateDiff = CustomFunction("DATE_DIFF", ["interval", "start_date", "end_date"]) + + with self.assertRaises(FunctionException): + DateDiff("foo") + + def test_should_return_function_with_arguments(self): + DateDiff = CustomFunction("DATE_DIFF", ["interval", "start_date", "end_date"]) + + self.assertEqual( + "DATE_DIFF('day','start_date','end_date')", + str(DateDiff("day", "start_date", "end_date")), + ) + + def test_should_return_function_with_no_arguments(self): + CurrentDate = CustomFunction("CURRENT_DATE") + + self.assertEqual("CURRENT_DATE()", str(CurrentDate())) + + +class TestFunctionalCustomFunction(unittest.TestCase): + def test_should_use_custom_function_on_select(self): + service = Table("service") + + DateDiff = CustomFunction("DATE_DIFF", ["interval", "start_date", "end_date"]) + + q = Query.from_(service).select(DateDiff("day", service.created_date, service.updated_date)) + + self.assertEqual( + 'SELECT DATE_DIFF(\'day\',"created_date","updated_date") FROM "service"', + str(q), + ) + + def test_should_fail_use_custom_function_on_select_with_wrong_arguments(self): + service = Table("service") + + DateDiff = CustomFunction("DATE_DIFF", ["interval", "start_date", "end_date"]) + + with self.assertRaises(FunctionException): + Query.from_(service).select(DateDiff("day", service.created_date)) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/test_data_types.py b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/test_data_types.py new file mode 100644 index 0000000000000000000000000000000000000000..52fb4487fe7be3ae28a4e9eb08628fba89dc0f79 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/test_data_types.py @@ -0,0 +1,15 @@ +import unittest +import uuid + +from pypika.terms import ValueWrapper + + +class StringTests(unittest.TestCase): + def test_inline_string_concatentation(self): + self.assertEqual("'it''s'", ValueWrapper("it's").get_sql()) + + +class UuidTests(unittest.TestCase): + def test_uuid_string_generation(self): + id = uuid.uuid4() + self.assertEqual("'{}'".format(id), ValueWrapper(id).get_sql()) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/test_date_math.py b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/test_date_math.py new file mode 100644 index 0000000000000000000000000000000000000000..38db8ef2f8e812a97c6980a7ec6b9a3909d804fb --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/test_date_math.py @@ -0,0 +1,179 @@ +import unittest + +from pypika import ( + Field as F, + Interval, +) +from pypika.enums import Dialects + +dt = F("dt") + + +class AddIntervalTests(unittest.TestCase): + def test_add_microsecond(self): + c = dt + Interval(microseconds=1) + + self.assertEqual("\"dt\"+INTERVAL '1 MICROSECOND'", str(c)) + + def test_add_second(self): + c = dt + Interval(seconds=1) + + self.assertEqual("\"dt\"+INTERVAL '1 SECOND'", str(c)) + + def test_add_minute(self): + c = dt + Interval(minutes=1) + + self.assertEqual("\"dt\"+INTERVAL '1 MINUTE'", str(c)) + + def test_add_day(self): + c = dt + Interval(days=1) + + self.assertEqual("\"dt\"+INTERVAL '1 DAY'", str(c)) + + def test_add_week(self): + c = dt + Interval(weeks=1) + + self.assertEqual("\"dt\"+INTERVAL '1 WEEK'", str(c)) + + def test_add_month(self): + c = dt + Interval(months=1) + + self.assertEqual("\"dt\"+INTERVAL '1 MONTH'", str(c)) + + def test_add_quarter(self): + c = dt + Interval(quarters=1) + + self.assertEqual("\"dt\"+INTERVAL '1 QUARTER'", str(c)) + + def test_add_year(self): + c = dt + Interval(years=1) + + self.assertEqual("\"dt\"+INTERVAL '1 YEAR'", str(c)) + + def test_add_default(self): + c = dt + Interval(days=0) + + self.assertEqual("\"dt\"+INTERVAL '0 DAY'", str(c)) + + +class AddIntervalMultipleUnitsTests(unittest.TestCase): + def test_add_second_microsecond(self): + c = dt + Interval(seconds=1, microseconds=1) + + self.assertEqual("\"dt\"+INTERVAL '1.1 SECOND_MICROSECOND'", str(c)) + + def test_add_minute_microsecond(self): + c = dt + Interval(minutes=1, microseconds=1) + + self.assertEqual("\"dt\"+INTERVAL '1:0.1 MINUTE_MICROSECOND'", str(c)) + + def test_add_minute_second(self): + c = dt + Interval(minutes=1, seconds=1) + + self.assertEqual("\"dt\"+INTERVAL '1:1 MINUTE_SECOND'", str(c)) + + def test_add_hour_microsecond(self): + c = dt + Interval(hours=1, microseconds=1) + + self.assertEqual("\"dt\"+INTERVAL '1:0:0.1 HOUR_MICROSECOND'", str(c)) + + def test_add_hour_second(self): + c = dt + Interval(hours=1, seconds=1) + + self.assertEqual("\"dt\"+INTERVAL '1:0:1 HOUR_SECOND'", str(c)) + + def test_add_hour_minute(self): + c = dt + Interval(hours=1, minutes=1) + + self.assertEqual("\"dt\"+INTERVAL '1:1 HOUR_MINUTE'", str(c)) + + def test_add_day_microsecond(self): + c = dt + Interval(days=1, microseconds=1) + + self.assertEqual("\"dt\"+INTERVAL '1 0:0:0.1 DAY_MICROSECOND'", str(c)) + + def test_add_day_second(self): + c = dt + Interval(days=1, seconds=1) + + self.assertEqual("\"dt\"+INTERVAL '1 0:0:1 DAY_SECOND'", str(c)) + + def test_add_day_minute(self): + c = dt + Interval(days=1, minutes=1) + + self.assertEqual("\"dt\"+INTERVAL '1 0:1 DAY_MINUTE'", str(c)) + + def test_add_day_hour(self): + c = dt + Interval(days=1, hours=1) + + self.assertEqual("\"dt\"+INTERVAL '1 1 DAY_HOUR'", str(c)) + + def test_add_year_month(self): + c = dt + Interval(years=1, months=1) + + self.assertEqual("\"dt\"+INTERVAL '1-1 YEAR_MONTH'", str(c)) + + def test_add_value_right(self): + c = Interval(microseconds=1) - dt + + self.assertEqual("INTERVAL '1 MICROSECOND'-\"dt\"", str(c)) + + def test_add_value_complex_expressions(self): + c = dt + Interval(quarters=1) + Interval(weeks=1) + + self.assertEqual("\"dt\"+INTERVAL '1 QUARTER'+INTERVAL '1 WEEK'", str(c)) + + +class DialectIntervalTests(unittest.TestCase): + def test_mysql_dialect_uses_single_quotes_around_expression_in_an_interval(self): + c = Interval(days=1).get_sql(dialect=Dialects.MYSQL) + self.assertEqual("INTERVAL '1' DAY", c) + + def test_oracle_dialect_uses_single_quotes_around_expression_in_an_interval(self): + c = Interval(days=1).get_sql(dialect=Dialects.ORACLE) + self.assertEqual("INTERVAL '1' DAY", c) + + def test_vertica_dialect_uses_single_quotes_around_interval(self): + c = Interval(days=1).get_sql(dialect=Dialects.VERTICA) + self.assertEqual("INTERVAL '1 DAY'", c) + + def test_redshift_dialect_uses_single_quotes_around_interval(self): + c = Interval(days=1).get_sql(dialect=Dialects.REDSHIFT) + self.assertEqual("INTERVAL '1 DAY'", c) + + def test_postgresql_dialect_uses_single_quotes_around_interval(self): + c = Interval(days=1).get_sql(dialect=Dialects.POSTGRESQL) + self.assertEqual("INTERVAL '1 DAY'", c) + + +class TestNegativeIntervals(unittest.TestCase): + def test_day(self): + c = Interval(days=-1).get_sql() + self.assertEqual("INTERVAL '-1 DAY'", c) + + def test_week(self): + c = Interval(weeks=-1).get_sql() + self.assertEqual("INTERVAL '-1 WEEK'", c) + + def test_month(self): + c = Interval(months=-1).get_sql() + self.assertEqual("INTERVAL '-1 MONTH'", c) + + def test_year(self): + c = Interval(years=-1).get_sql() + self.assertEqual("INTERVAL '-1 YEAR'", c) + + def test_year_month(self): + c = Interval(years=-1, months=-4).get_sql() + self.assertEqual("INTERVAL '-1-4 YEAR_MONTH'", c) + + +class TruncateTrailingZerosTests(unittest.TestCase): + def test_do_not_truncate_integer_values(self): + i = Interval(seconds=10) + + self.assertEqual("INTERVAL '10 SECOND'", str(i)) + + def test_do_not_truncate_months_between_years_and_datys(self): + i = Interval(years=10, days=10) + + self.assertEqual("INTERVAL '10-0-10 YEAR_DAY'", str(i)) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/test_deletes.py b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/test_deletes.py new file mode 100644 index 0000000000000000000000000000000000000000..09df93f5331b845b0c3aed628bf1c4a3ec6b0f02 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/test_deletes.py @@ -0,0 +1,97 @@ +import unittest + +from pypika import PostgreSQLQuery, Query, SYSTEM_TIME, Table + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + +from pypika.terms import Star + + +class DeleteTests(unittest.TestCase): + @classmethod + def setUpClass(cls) -> None: + super().setUpClass() + cls.table_abc = Table("abc") + + def test_omit_where(self): + q = Query.from_("abc").delete() + + self.assertEqual('DELETE FROM "abc"', str(q)) + + def test_omit_where__table_schema(self): + q = Query.from_(Table("abc", "schema1")).delete() + + self.assertEqual('DELETE FROM "schema1"."abc"', str(q)) + + def test_where_field_equals(self): + q1 = Query.from_(self.table_abc).where(self.table_abc.foo == self.table_abc.bar).delete() + q2 = Query.from_(self.table_abc).where(self.table_abc.foo.eq(self.table_abc.bar)).delete() + + self.assertEqual('DELETE FROM "abc" WHERE "foo"="bar"', str(q1)) + self.assertEqual('DELETE FROM "abc" WHERE "foo"="bar"', str(q2)) + + def test_for_portion(self): + with self.subTest("with system time"): + q = Query.from_(self.table_abc.for_portion(SYSTEM_TIME.from_to('2020-01-01', '2020-02-01'))).delete() + + self.assertEqual( + 'DELETE FROM "abc" FOR PORTION OF SYSTEM_TIME FROM \'2020-01-01\' TO \'2020-02-01\'', str(q) + ) + + with self.subTest("with column"): + q = Query.from_( + self.table_abc.for_portion(self.table_abc.valid_period.from_to('2020-01-01', '2020-02-01')) + ).delete() + + self.assertEqual( + 'DELETE FROM "abc" FOR PORTION OF "valid_period" FROM \'2020-01-01\' TO \'2020-02-01\'', str(q) + ) + + +class PostgresDeleteTests(unittest.TestCase): + @classmethod + def setUpClass(cls) -> None: + super().setUpClass() + cls.table_abc = Table("abc") + + def test_delete_returning(self): + q1 = ( + PostgreSQLQuery.from_(self.table_abc) + .where(self.table_abc.foo == self.table_abc.bar) + .delete() + .returning(self.table_abc.id) + ) + + self.assertEqual('DELETE FROM "abc" WHERE "foo"="bar" RETURNING "id"', str(q1)) + + def test_delete_returning_str(self): + q1 = ( + PostgreSQLQuery.from_(self.table_abc) + .where(self.table_abc.foo == self.table_abc.bar) + .delete() + .returning("id") + ) + + self.assertEqual('DELETE FROM "abc" WHERE "foo"="bar" RETURNING "id"', str(q1)) + + def test_delete_returning_star(self): + q1 = ( + PostgreSQLQuery.from_(self.table_abc) + .where(self.table_abc.foo == self.table_abc.bar) + .delete() + .returning(Star()) + ) + + self.assertEqual('DELETE FROM "abc" WHERE "foo"="bar" RETURNING *', str(q1)) + + def test_delete_using(self): + table_trash = Table('trash') + q1 = ( + PostgreSQLQuery.from_(self.table_abc) + .using(table_trash) + .where(self.table_abc.id == table_trash.abc_id) + .delete() + ) + + self.assertEqual('DELETE FROM "abc" USING "trash" WHERE "abc"."id"="trash"."abc_id"', str(q1)) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/test_drop.py b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/test_drop.py new file mode 100644 index 0000000000000000000000000000000000000000..265ae7350d2054549731f9a8c4379fdac95dc580 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/test_drop.py @@ -0,0 +1,49 @@ +import unittest + +from pypika import ( + Columns, + Database, + Query, + Tables, +) + + +class DropTableTests(unittest.TestCase): + database_xyz = Database("mydb") + new_table, existing_table = Tables("abc", "efg") + foo, bar = Columns(("a", "INT"), ("b", "VARCHAR(100)")) + + def test_drop_database(self): + q1 = Query.drop_database(self.database_xyz) + q2 = Query.drop_database(self.database_xyz).if_exists() + + self.assertEqual('DROP DATABASE "mydb"', str(q1)) + self.assertEqual('DROP DATABASE IF EXISTS "mydb"', str(q2)) + + def test_drop_table(self): + q1 = Query.drop_table(self.new_table) + q2 = Query.drop_table(self.new_table).if_exists() + + self.assertEqual('DROP TABLE "abc"', str(q1)) + self.assertEqual('DROP TABLE IF EXISTS "abc"', str(q2)) + + def test_drop_user(self): + q1 = Query.drop_user("myuser") + q2 = Query.drop_user("myuser").if_exists() + + self.assertEqual('DROP USER "myuser"', str(q1)) + self.assertEqual('DROP USER IF EXISTS "myuser"', str(q2)) + + def test_drop_view(self): + q1 = Query.drop_view("myview") + q2 = Query.drop_view("myview").if_exists() + + self.assertEqual('DROP VIEW "myview"', str(q1)) + self.assertEqual('DROP VIEW IF EXISTS "myview"', str(q2)) + + def test_drop_index(self): + q1 = Query.drop_index("myindex") + q2 = Query.drop_index("myindex").if_exists() + + self.assertEqual('DROP INDEX "myindex"', str(q1)) + self.assertEqual('DROP INDEX IF EXISTS "myindex"', str(q2)) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/test_formats.py b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/test_formats.py new file mode 100644 index 0000000000000000000000000000000000000000..6a442757c6659a215661e03f1ca9c3771d394d96 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/test_formats.py @@ -0,0 +1,68 @@ +import unittest + +from pypika import Query, Tables, functions as fn + + +class QuoteTests(unittest.TestCase): + maxDiff = None + + table_abc, table_efg = Tables("abc", "efg") + + def setUp(self): + subquery1 = ( + Query.from_(self.table_abc) + .select( + self.table_abc.foo, + fn.Sum(self.table_abc.fizz + self.table_abc.buzz).as_("fizzbuzz"), + ) + .groupby(self.table_abc.foo) + ) + + subquery2 = Query.from_(self.table_efg).select( + self.table_efg.foo.as_("foo_two"), + self.table_efg.bar, + ) + + self.query = ( + Query.from_(subquery1) + .select(subquery1.foo, subquery1.fizzbuzz) + .join(subquery2) + .on(subquery1.foo == subquery2.foo_two) + .select(subquery2.foo_two, subquery2.bar) + ) + + def test_replace_quote_char_in_complex_query(self): + self.assertEqual( + "SELECT " + "`sq0`.`foo`,`sq0`.`fizzbuzz`," + "`sq1`.`foo_two`,`sq1`.`bar` " + "FROM (" + "SELECT " + "`foo`,SUM(`fizz`+`buzz`) `fizzbuzz` " + "FROM `abc` " + "GROUP BY `foo`" + ") `sq0` JOIN (" + "SELECT " + "`foo` `foo_two`,`bar` " + "FROM `efg`" + ") `sq1` ON `sq0`.`foo`=`sq1`.`foo_two`", + self.query.get_sql(quote_char="`"), + ) + + def test_no_quote_char_in_complex_query(self): + self.assertEqual( + "SELECT " + "sq0.foo,sq0.fizzbuzz," + "sq1.foo_two,sq1.bar " + "FROM (" + "SELECT " + "foo,SUM(fizz+buzz) fizzbuzz " + "FROM abc " + "GROUP BY foo" + ") sq0 JOIN (" + "SELECT " + "foo foo_two,bar " + "FROM efg" + ") sq1 ON sq0.foo=sq1.foo_two", + self.query.get_sql(quote_char=None), + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/test_functions.py b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/test_functions.py new file mode 100644 index 0000000000000000000000000000000000000000..f526966eefc554ec68d0e15fb69de7d69f1604c3 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/test_functions.py @@ -0,0 +1,847 @@ +import unittest + +from pypika import ( + Case, + CaseException, + DatePart, + Field as F, + Query, + Query as Q, + Schema, + Table as T, + VerticaQuery, + functions as fn, +) +from pypika.enums import Dialects, SqlTypes + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + + +class FunctionTests(unittest.TestCase): + def test_dialect_propagation(self): + func = fn.Function("func", ["a"], ["b"]) + self.assertEqual("func(ARRAY['a'],ARRAY['b'])", func.get_sql(dialect=Dialects.POSTGRESQL)) + + def test_is_aggregate_None_for_non_aggregate_function_or_function_with_no_aggregate_functions(self): + self.assertIsNone(fn.Coalesce('a', 0).is_aggregate) + self.assertIsNone(fn.Coalesce(fn.NullIf('a', 0), 0).is_aggregate) + + def test_is_aggregate_True_for_aggregate_function_or_function_with_aggregate_functions(self): + self.assertTrue(fn.Sum('a').is_aggregate) + self.assertTrue(fn.Coalesce(fn.Avg('a'), 0).is_aggregate) + self.assertTrue(fn.Coalesce(fn.NullIf(fn.Sum('a'), 0), 0).is_aggregate) + + +class SchemaTests(unittest.TestCase): + def test_schema_no_schema_in_sql_when_none_set(self): + func = fn.Function("my_proc", 1, 2, 3) + + self.assertEqual("my_proc(1,2,3)", func.get_sql(quote_char='"')) + + def test_schema_included_in_function_sql(self): + a = Schema("a") + func = fn.Function("my_proc", 1, 2, 3, schema=a) + + self.assertEqual('"a".my_proc(1,2,3)', func.get_sql(quote_char='"')) + + +class ArithmeticTests(unittest.TestCase): + t = T("abc") + + def test__addition__fields(self): + q1 = Q.from_("abc").select(F("a") + F("b")) + q2 = Q.from_(self.t).select(self.t.a + self.t.b) + + self.assertEqual('SELECT "a"+"b" FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"+"b" FROM "abc"', str(q2)) + + def test__addition__number(self): + q1 = Q.from_("abc").select(F("a") + 1) + q2 = Q.from_(self.t).select(self.t.a + 1) + + self.assertEqual('SELECT "a"+1 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"+1 FROM "abc"', str(q2)) + + def test__addition__decimal(self): + q1 = Q.from_("abc").select(F("a") + 1.0) + q2 = Q.from_(self.t).select(self.t.a + 1.0) + + self.assertEqual('SELECT "a"+1.0 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"+1.0 FROM "abc"', str(q2)) + + def test__addition__right(self): + q1 = Q.from_("abc").select(1 + F("a")) + q2 = Q.from_(self.t).select(1 + self.t.a) + + self.assertEqual('SELECT 1+"a" FROM "abc"', str(q1)) + self.assertEqual('SELECT 1+"a" FROM "abc"', str(q2)) + + def test__subtraction__fields(self): + q1 = Q.from_("abc").select(F("a") - F("b")) + q2 = Q.from_(self.t).select(self.t.a - self.t.b) + + self.assertEqual('SELECT "a"-"b" FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"-"b" FROM "abc"', str(q2)) + + def test__subtraction__number(self): + q1 = Q.from_("abc").select(F("a") - 1) + q2 = Q.from_(self.t).select(self.t.a - 1) + + self.assertEqual('SELECT "a"-1 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"-1 FROM "abc"', str(q2)) + + def test__subtraction__decimal(self): + q1 = Q.from_("abc").select(F("a") - 1.0) + q2 = Q.from_(self.t).select(self.t.a - 1.0) + + self.assertEqual('SELECT "a"-1.0 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"-1.0 FROM "abc"', str(q2)) + + def test__subtraction__right(self): + q1 = Q.from_("abc").select(1 - F("a")) + q2 = Q.from_(self.t).select(1 - self.t.a) + + self.assertEqual('SELECT 1-"a" FROM "abc"', str(q1)) + self.assertEqual('SELECT 1-"a" FROM "abc"', str(q2)) + + def test__multiplication__fields(self): + q1 = Q.from_("abc").select(F("a") * F("b")) + q2 = Q.from_(self.t).select(self.t.a * self.t.b) + + self.assertEqual('SELECT "a"*"b" FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"*"b" FROM "abc"', str(q2)) + + def test__multiplication__number(self): + q1 = Q.from_("abc").select(F("a") * 1) + q2 = Q.from_(self.t).select(self.t.a * 1) + + self.assertEqual('SELECT "a"*1 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"*1 FROM "abc"', str(q2)) + + def test__multiplication__decimal(self): + q1 = Q.from_("abc").select(F("a") * 1.0) + q2 = Q.from_(self.t).select(self.t.a * 1.0) + + self.assertEqual('SELECT "a"*1.0 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"*1.0 FROM "abc"', str(q2)) + + def test__multiplication__right(self): + q1 = Q.from_("abc").select(1 * F("a")) + q2 = Q.from_(self.t).select(1 * self.t.a) + + self.assertEqual('SELECT 1*"a" FROM "abc"', str(q1)) + self.assertEqual('SELECT 1*"a" FROM "abc"', str(q2)) + + def test__division__fields(self): + q1 = Q.from_("abc").select(F("a") / F("b")) + q2 = Q.from_(self.t).select(self.t.a / self.t.b) + + self.assertEqual('SELECT "a"/"b" FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"/"b" FROM "abc"', str(q2)) + + def test__division__number(self): + q1 = Q.from_("abc").select(F("a") / 1) + q2 = Q.from_(self.t).select(self.t.a / 1) + + self.assertEqual('SELECT "a"/1 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"/1 FROM "abc"', str(q2)) + + def test__division__decimal(self): + q1 = Q.from_("abc").select(F("a") / 1.0) + q2 = Q.from_(self.t).select(self.t.a / 1.0) + + self.assertEqual('SELECT "a"/1.0 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"/1.0 FROM "abc"', str(q2)) + + def test__division__right(self): + q1 = Q.from_("abc").select(1 / F("a")) + q2 = Q.from_(self.t).select(1 / self.t.a) + + self.assertEqual('SELECT 1/"a" FROM "abc"', str(q1)) + self.assertEqual('SELECT 1/"a" FROM "abc"', str(q2)) + + def test__leftshift__fields(self): + q1 = Q.from_("abc").select(F("a") << F("b")) + q2 = Q.from_(self.t).select(self.t.a << self.t.b) + + self.assertEqual('SELECT "a"<<"b" FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"<<"b" FROM "abc"', str(q2)) + + def test__leftshift__number(self): + q1 = Q.from_("abc").select(F('a') << 2) + q2 = Q.from_(self.t).select(self.t.a << 2) + + self.assertEqual('SELECT "a"<<2 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"<<2 FROM "abc"', str(q2)) + + def test__leftshift__right(self): + q1 = Q.from_("abc").select(1 << F("a")) + q2 = Q.from_(self.t).select(1 << self.t.a) + + self.assertEqual('SELECT 1<<"a" FROM "abc"', str(q1)) + self.assertEqual('SELECT 1<<"a" FROM "abc"', str(q2)) + + def test__rightshift__fields(self): + q1 = Q.from_("abc").select(F("a") >> F("b")) + q2 = Q.from_(self.t).select(self.t.a >> self.t.b) + + self.assertEqual('SELECT "a">>"b" FROM "abc"', str(q1)) + self.assertEqual('SELECT "a">>"b" FROM "abc"', str(q2)) + + def test__rightshift__number(self): + q1 = Q.from_("abc").select(F('a') >> 2) + q2 = Q.from_(self.t).select(self.t.a >> 2) + + self.assertEqual('SELECT "a">>2 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a">>2 FROM "abc"', str(q2)) + + def test__rightshift__right(self): + q1 = Q.from_("abc").select(1 >> F("a")) + q2 = Q.from_(self.t).select(1 >> self.t.a) + + self.assertEqual('SELECT 1>>"a" FROM "abc"', str(q1)) + self.assertEqual('SELECT 1>>"a" FROM "abc"', str(q2)) + + def test__complex_op(self): + q1 = Q.from_("abc").select(2 + 1 / F("a") - 5) + q2 = Q.from_(self.t).select(2 + 1 / self.t.a - 5) + + self.assertEqual('SELECT 2+1/"a"-5 FROM "abc"', str(q1)) + self.assertEqual('SELECT 2+1/"a"-5 FROM "abc"', str(q2)) + + def test__complex_op_add_parentheses(self): + q1 = Q.from_("abc").select((F("a") + 1) + (F("b") - 5)) + q2 = Q.from_(self.t).select((self.t.a + 1) + (self.t.b - 5)) + q3 = Q.from_("abc").select((F("a") / 1) + (F("b") / 5)) + q4 = Q.from_(self.t).select((self.t.a / 1) + (self.t.b / 5)) + + self.assertEqual('SELECT "a"+1+"b"-5 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"+1+"b"-5 FROM "abc"', str(q2)) + self.assertEqual('SELECT "a"/1+"b"/5 FROM "abc"', str(q3)) + self.assertEqual('SELECT "a"/1+"b"/5 FROM "abc"', str(q4)) + + def test__complex_op_sub_parentheses(self): + q1 = Q.from_("abc").select((F("a") + 1) - (F("b") - 5)) + q2 = Q.from_(self.t).select((self.t.a + 1) - (self.t.b - 5)) + q3 = Q.from_("abc").select((F("a") / 1) - (F("b") / 5)) + q4 = Q.from_(self.t).select((self.t.a / 1) - (self.t.b / 5)) + + self.assertEqual('SELECT "a"+1-("b"-5) FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"+1-("b"-5) FROM "abc"', str(q2)) + self.assertEqual('SELECT "a"/1-"b"/5 FROM "abc"', str(q3)) + self.assertEqual('SELECT "a"/1-"b"/5 FROM "abc"', str(q4)) + + def test__complex_op_mul_parentheses(self): + q1 = Q.from_("abc").select((F("a") + 1) * (F("b") - 5)) + q2 = Q.from_(self.t).select((self.t.a + 1) * (self.t.b - 5)) + q3 = Q.from_("abc").select((F("a") / 1) * (F("b") - 5)) + q4 = Q.from_(self.t).select((self.t.a / 1) * (self.t.b - 5)) + q5 = Q.from_("abc").select((F("a") + 1) * (F("b") / 5)) + q6 = Q.from_(self.t).select((self.t.a + 1) * (self.t.b / 5)) + + self.assertEqual('SELECT ("a"+1)*("b"-5) FROM "abc"', str(q1)) + self.assertEqual('SELECT ("a"+1)*("b"-5) FROM "abc"', str(q2)) + self.assertEqual('SELECT "a"/1*("b"-5) FROM "abc"', str(q3)) + self.assertEqual('SELECT "a"/1*("b"-5) FROM "abc"', str(q4)) + self.assertEqual('SELECT ("a"+1)*"b"/5 FROM "abc"', str(q5)) + self.assertEqual('SELECT ("a"+1)*"b"/5 FROM "abc"', str(q6)) + + def test__complex_op_mul_no_parentheses(self): + q = Q.from_("abc").select(F("a") + 1 * F("b") - 5) + + self.assertEqual('SELECT "a"+1*"b"-5 FROM "abc"', str(q)) + + def test__complex_op_div_parentheses(self): + q1 = Q.from_("abc").select((F("a") + 1) / (F("b") - 5)) + q2 = Q.from_(self.t).select((self.t.a + 1) / (self.t.b - 5)) + q3 = Q.from_("abc").select((F("a") / 1) / (F("b") - 5)) + q4 = Q.from_(self.t).select((self.t.a / 1) / (self.t.b - 5)) + q5 = Q.from_("abc").select((F("a") + 1) / (F("b") * 5)) + q6 = Q.from_(self.t).select((self.t.a + 1) / (self.t.b * 5)) + + self.assertEqual('SELECT ("a"+1)/("b"-5) FROM "abc"', str(q1)) + self.assertEqual('SELECT ("a"+1)/("b"-5) FROM "abc"', str(q2)) + self.assertEqual('SELECT "a"/1/("b"-5) FROM "abc"', str(q3)) + self.assertEqual('SELECT "a"/1/("b"-5) FROM "abc"', str(q4)) + self.assertEqual('SELECT ("a"+1)/("b"*5) FROM "abc"', str(q5)) + self.assertEqual('SELECT ("a"+1)/("b"*5) FROM "abc"', str(q6)) + + def test__complex_op_div_no_parentheses(self): + q = Q.from_("abc").select(F("a") + 1 / F("b") - 5) + + self.assertEqual('SELECT "a"+1/"b"-5 FROM "abc"', str(q)) + + def test__complex_op_exponent_parentheses(self): + q1 = Q.from_("abc").select(F("a") / (F("b") ** 2)) + q2 = Q.from_(self.t).select(self.t.a / (self.t.b**2)) + q3 = Q.from_("abc").select(F("a") ** (F("b") / 2)) + q4 = Q.from_(self.t).select(self.t.a ** (self.t.b / 2)) + q5 = Q.from_("abc").select((F("a") ** F("b")) ** 2) + q6 = Q.from_(self.t).select((self.t.a**self.t.b) ** 2) + + self.assertEqual('SELECT "a"/POW("b",2) FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"/POW("b",2) FROM "abc"', str(q2)) + self.assertEqual('SELECT POW("a","b"/2) FROM "abc"', str(q3)) + self.assertEqual('SELECT POW("a","b"/2) FROM "abc"', str(q4)) + self.assertEqual('SELECT POW(POW("a","b"),2) FROM "abc"', str(q5)) + self.assertEqual('SELECT POW(POW("a","b"),2) FROM "abc"', str(q6)) + + def test__complex_op_exponent_no_parentheses(self): + q1 = Q.from_("abc").select(F("a") ** F("b") ** 2) + q2 = Q.from_(self.t).select(self.t.a**self.t.b**2) + q3 = Q.from_("abc").select(F("a") / F("b") ** 2) + q4 = Q.from_(self.t).select(self.t.a / self.t.b**2) + + self.assertEqual('SELECT POW("a",POW("b",2)) FROM "abc"', str(q1)) + self.assertEqual('SELECT POW("a",POW("b",2)) FROM "abc"', str(q2)) + self.assertEqual('SELECT "a"/POW("b",2) FROM "abc"', str(q3)) + self.assertEqual('SELECT "a"/POW("b",2) FROM "abc"', str(q4)) + + def test__complex_op_function_parentheses(self): + q1 = Q.from_("abc").select(F("a") / (fn.Sum(F("b")) / 2)) + q2 = Q.from_("abc").select(self.t.a / (fn.Sum(self.t.b) / 2)) + q3 = Q.from_("abc").select(fn.Sum(F("a") / (F("b") / 2))) + q4 = Q.from_("abc").select(fn.Sum(self.t.a / (self.t.b / 2))) + + self.assertEqual('SELECT "a"/(SUM("b")/2) FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"/(SUM("b")/2) FROM "abc"', str(q2)) + self.assertEqual('SELECT SUM("a"/("b"/2)) FROM "abc"', str(q3)) + self.assertEqual('SELECT SUM("a"/("b"/2)) FROM "abc"', str(q4)) + + def test__complex_op_modulus_parentheses(self): + q1 = Q.from_("abc").select(F("a") / (F("b") % 2)) + q2 = Q.from_(self.t).select(self.t.a / (self.t.b % 2)) + q3 = Q.from_("abc").select(F("a") % (F("b") / 2)) + q4 = Q.from_(self.t).select(self.t.a % (self.t.b / 2)) + q5 = Q.from_("abc").select(F("a") % (F("b") % 2)) + q6 = Q.from_("abc").select(self.t.a % (self.t.b % 2)) + + self.assertEqual('SELECT "a"/MOD("b",2) FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"/MOD("b",2) FROM "abc"', str(q2)) + self.assertEqual('SELECT MOD("a","b"/2) FROM "abc"', str(q3)) + self.assertEqual('SELECT MOD("a","b"/2) FROM "abc"', str(q4)) + self.assertEqual('SELECT MOD("a",MOD("b",2)) FROM "abc"', str(q5)) + self.assertEqual('SELECT MOD("a",MOD("b",2)) FROM "abc"', str(q6)) + + def test__complex_op_modulus_no_parentheses(self): + q1 = Q.from_("abc").select(F("a") % F("b") % 2) + q2 = Q.from_(self.t).select(self.t.a % self.t.b % 2) + q3 = Q.from_("abc").select(F("a") / F("b") % 2) + q4 = Q.from_(self.t).select(self.t.a / self.t.b % 2) + + self.assertEqual('SELECT MOD(MOD("a","b"),2) FROM "abc"', str(q1)) + self.assertEqual('SELECT MOD(MOD("a","b"),2) FROM "abc"', str(q2)) + self.assertEqual('SELECT MOD("a"/"b",2) FROM "abc"', str(q3)) + self.assertEqual('SELECT MOD("a"/"b",2) FROM "abc"', str(q4)) + + def test__complex_op_floor_parentheses(self): + q1 = Q.from_("abc").select(F("a") / (fn.Floor(F("b")) / 2)) + q2 = Q.from_("abc").select(self.t.a / (fn.Floor(self.t.b) / 2)) + q3 = Q.from_("abc").select(fn.Floor(F("a") / (F("b") / 2))) + q4 = Q.from_("abc").select(fn.Floor(self.t.a / (self.t.b / 2))) + + self.assertEqual('SELECT "a"/(FLOOR("b")/2) FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"/(FLOOR("b")/2) FROM "abc"', str(q2)) + self.assertEqual('SELECT FLOOR("a"/("b"/2)) FROM "abc"', str(q3)) + self.assertEqual('SELECT FLOOR("a"/("b"/2)) FROM "abc"', str(q4)) + + def test__complex_op_nested_parentheses(self): + q1 = Q.from_("abc").select(F("a") / (F("b") / ((F("c") / 2)))) + q2 = Q.from_("abc").select(self.t.a / (self.t.b / ((self.t.c / 2)))) + + self.assertEqual('SELECT "a"/("b"/("c"/2)) FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"/("b"/("c"/2)) FROM "abc"', str(q2)) + + def test__arithmetic_equality(self): + q1 = Q.from_("abc").select(F("a") / 2 == 2) + q2 = Q.from_(self.t).select(self.t.a / 2 == 2) + + self.assertEqual('SELECT "a"/2=2 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"/2=2 FROM "abc"', str(q2)) + + def test__arithmetic_with_function(self): + q1 = Q.from_("abc").select(fn.Sum(F("foo")) + 1) + q2 = Q.from_(self.t).select(fn.Sum(self.t.foo) + 1) + + self.assertEqual('SELECT SUM("foo")+1 FROM "abc"', str(q1)) + self.assertEqual('SELECT SUM("foo")+1 FROM "abc"', str(q2)) + + def test__exponent__number(self): + q1 = Q.from_("abc").select(F("a") ** 2) + q2 = Q.from_(self.t).select(self.t.a**2) + + self.assertEqual('SELECT POW("a",2) FROM "abc"', str(q1)) + self.assertEqual('SELECT POW("a",2) FROM "abc"', str(q2)) + + def test__exponent__decimal(self): + q1 = Q.from_("abc").select(F("a") ** 0.5) + q2 = Q.from_(self.t).select(self.t.a**0.5) + + self.assertEqual('SELECT POW("a",0.5) FROM "abc"', str(q1)) + self.assertEqual('SELECT POW("a",0.5) FROM "abc"', str(q2)) + + def test__modulus__number(self): + q1 = Q.from_("abc").select(F("a") % 2) + q2 = Q.from_(self.t).select(self.t.a % 2) + + self.assertEqual('SELECT MOD("a",2) FROM "abc"', str(q1)) + self.assertEqual('SELECT MOD("a",2) FROM "abc"', str(q2)) + + def test__floor(self): + q1 = Q.from_("abc").select(fn.Floor(F("foo"))) + q2 = Q.from_(self.t).select(fn.Floor(self.t.foo)) + + self.assertEqual('SELECT FLOOR("foo") FROM "abc"', str(q1)) + self.assertEqual('SELECT FLOOR("foo") FROM "abc"', str(q2)) + + +class AggregationTests(unittest.TestCase): + def test__count(self): + q = Q.from_("abc").select(fn.Count(F("foo"))) + + self.assertEqual('SELECT COUNT("foo") FROM "abc"', str(q)) + + def test__count__star(self): + q = Q.from_("abc").select(fn.Count("*")) + + self.assertEqual('SELECT COUNT(*) FROM "abc"', str(q)) + + def test__sum(self): + q = Q.from_("abc").select(fn.Sum(F("foo"))) + + self.assertEqual('SELECT SUM("foo") FROM "abc"', str(q)) + + def test__avg(self): + q = Q.from_("abc").select(fn.Avg(F("foo"))) + + self.assertEqual('SELECT AVG("foo") FROM "abc"', str(q)) + + def test__first(self): + q = Q.from_("abc").select(fn.First(F("foo"))) + + self.assertEqual('SELECT FIRST("foo") FROM "abc"', str(q)) + + def test__last(self): + q = Q.from_("abc").select(fn.Last(F("foo"))) + + self.assertEqual('SELECT LAST("foo") FROM "abc"', str(q)) + + def test__min(self): + q = Q.from_("abc").select(fn.Min(F("foo"))) + + self.assertEqual('SELECT MIN("foo") FROM "abc"', str(q)) + + def test__max(self): + q = Q.from_("abc").select(fn.Max(F("foo"))) + + self.assertEqual('SELECT MAX("foo") FROM "abc"', str(q)) + + def test__std(self): + q = Q.from_("abc").select(fn.Std(F("foo"))) + + self.assertEqual('SELECT STD("foo") FROM "abc"', str(q)) + + def test__stddev(self): + q = Q.from_("abc").select(fn.StdDev(F("foo"))) + + self.assertEqual('SELECT STDDEV("foo") FROM "abc"', str(q)) + + def test__approx_percentile(self): + q = Q.from_("abc").select(fn.ApproximatePercentile(F("foo"), 0.5)) + + self.assertEqual( + 'SELECT APPROXIMATE_PERCENTILE("foo" USING PARAMETERS percentile=0.5) FROM "abc"', + str(q), + ) + + def test__subquery_in_params_functions(self): + subquery = Query.from_('table').select('id') + func = fn.Function('func', 'id', subquery) + self.assertEqual("func('id',(SELECT id FROM table))", func.get_sql()) + + +class ConditionTests(unittest.TestCase): + def test__case__raw(self): + q = Q.from_("abc").select(Case().when(F("foo") == 1, "a")) + + self.assertEqual('SELECT CASE WHEN "foo"=1 THEN \'a\' END FROM "abc"', str(q)) + + def test__case__else(self): + q = Q.from_("abc").select(Case().when(F("foo") == 1, "a").else_("b")) + + self.assertEqual("SELECT CASE WHEN \"foo\"=1 THEN 'a' ELSE 'b' END FROM \"abc\"", str(q)) + + def test__case__field(self): + q = Q.from_("abc").select(Case().when(F("foo") == 1, F("bar")).else_(F("buz"))) + + self.assertEqual('SELECT CASE WHEN "foo"=1 THEN "bar" ELSE "buz" END FROM "abc"', str(q)) + + def test__case__multi(self): + q = Q.from_("abc").select(Case().when(F("foo") > 0, F("fiz")).when(F("bar") <= 0, F("buz")).else_(1)) + + self.assertEqual( + 'SELECT CASE WHEN "foo">0 THEN "fiz" WHEN "bar"<=0 THEN "buz" ELSE 1 END FROM "abc"', + str(q), + ) + + def test__case__no_cases(self): + with self.assertRaises(CaseException): + q = Q.from_("abc").select(Case()) + + str(q) + + +class StringTests(unittest.TestCase): + t = T("abc") + + def test__ascii__str(self): + q = Q.select(fn.Ascii("2")) + + self.assertEqual("SELECT ASCII('2')", str(q)) + + def test__ascii__int(self): + q = Q.select(fn.Ascii(2)) + + self.assertEqual("SELECT ASCII(2)", str(q)) + + def test__ascii__field(self): + q = Q.from_(self.t).select(fn.Ascii(self.t.foo)) + + self.assertEqual('SELECT ASCII("foo") FROM "abc"', str(q)) + + def test__bin__str(self): + q = Q.select(fn.Bin("2")) + + self.assertEqual("SELECT BIN('2')", str(q)) + + def test__bin__int(self): + q = Q.select(fn.Bin(2)) + + self.assertEqual("SELECT BIN(2)", str(q)) + + def test__bin__field(self): + q = Q.from_(self.t).select(fn.Bin(self.t.foo)) + + self.assertEqual('SELECT BIN("foo") FROM "abc"', str(q)) + + def test__concat__str(self): + q = Q.select(fn.Concat("p", "y", "q", "b")) + + self.assertEqual("SELECT CONCAT('p','y','q','b')", str(q)) + + def test__concat__field(self): + q = Q.from_(self.t).select(fn.Concat(self.t.foo, self.t.bar)) + + self.assertEqual('SELECT CONCAT("foo","bar") FROM "abc"', str(q)) + + def test__insert__str(self): + q = Q.select(fn.Insert("Quadratic", 3, 4, "What")) + + self.assertEqual("SELECT INSERT('Quadratic',3,4,'What')", str(q)) + + def test__insert__field(self): + q = Q.from_(self.t).select(fn.Insert(self.t.foo, 3, 4, self.t.bar)) + + self.assertEqual('SELECT INSERT("foo",3,4,"bar") FROM "abc"', str(q)) + + def test__lower__str(self): + q = Q.select(fn.Lower("ABC")) + + self.assertEqual("SELECT LOWER('ABC')", str(q)) + + def test__lower__field(self): + q = Q.from_(self.t).select(fn.Lower(self.t.foo)) + + self.assertEqual('SELECT LOWER("foo") FROM "abc"', str(q)) + + def test__length__str(self): + q = Q.select(fn.Length("ABC")) + + self.assertEqual("SELECT LENGTH('ABC')", str(q)) + + def test__length__field(self): + q = Q.from_(self.t).select(fn.Length(self.t.foo)) + + self.assertEqual('SELECT LENGTH("foo") FROM "abc"', str(q)) + + def test__substring(self): + q = Q.from_(self.t).select(fn.Substring(self.t.foo, 2, 6)) + + self.assertEqual('SELECT SUBSTRING("foo",2,6) FROM "abc"', str(q)) + + def test__replace__str(self): + q = Q.select(fn.Replace("ABC_DEF", "_", " ")) + self.assertEqual("SELECT REPLACE('ABC_DEF','_',' ')", str(q)) + + def test__replace__field(self): + q = Q.from_(self.t).select(fn.Replace(self.t.foobar, self.t.foo, self.t.bar)) + self.assertEqual('SELECT REPLACE("foobar","foo","bar") FROM "abc"', str(q)) + + +class SplitPartFunctionTests(unittest.TestCase): + t = T("abc") + + def test__split_part(self): + q = VerticaQuery.from_(self.t).select(fn.SplitPart(self.t.foo, "|", 3)) + + self.assertEqual('SELECT SPLIT_PART("foo",\'|\',3) FROM "abc"', str(q)) + + +class RegexpLikeFunctionTests(unittest.TestCase): + t = T("abc") + + def test__regexp_like(self): + q = VerticaQuery.from_(self.t).select(fn.RegexpLike(self.t.foo, "^a", "x")) + + self.assertEqual("SELECT REGEXP_LIKE(\"foo\",'^a','x') FROM \"abc\"", str(q)) + + +class CastTests(unittest.TestCase): + t = T("abc") + + def test__cast__as(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.UNSIGNED)) + + self.assertEqual('SELECT CAST("foo" AS UNSIGNED) FROM "abc"', str(q)) + + def test__cast__signed(self): + q1 = Q.from_(self.t).select(fn.Signed(self.t.foo)) + q2 = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.SIGNED)) + + self.assertEqual('SELECT CAST("foo" AS SIGNED) FROM "abc"', str(q1)) + self.assertEqual('SELECT CAST("foo" AS SIGNED) FROM "abc"', str(q2)) + + def test__cast__unsigned(self): + q1 = Q.from_(self.t).select(fn.Unsigned(self.t.foo)) + q2 = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.UNSIGNED)) + + self.assertEqual('SELECT CAST("foo" AS UNSIGNED) FROM "abc"', str(q1)) + self.assertEqual('SELECT CAST("foo" AS UNSIGNED) FROM "abc"', str(q2)) + + def test__cast__date(self): + q1 = Q.from_(self.t).select(fn.Date(self.t.foo)) + q2 = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.DATE)) + + self.assertEqual('SELECT DATE("foo") FROM "abc"', str(q1)) + self.assertEqual('SELECT CAST("foo" AS DATE) FROM "abc"', str(q2)) + + def test__cast__timestamp(self): + q1 = Q.from_(self.t).select(fn.Timestamp(self.t.foo)) + q2 = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.TIMESTAMP)) + + self.assertEqual('SELECT TIMESTAMP("foo") FROM "abc"', str(q1)) + self.assertEqual('SELECT CAST("foo" AS TIMESTAMP) FROM "abc"', str(q2)) + + def test__cast__char(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.CHAR)) + + self.assertEqual('SELECT CAST("foo" AS CHAR) FROM "abc"', str(q)) + + def test__cast__char_with_arg(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.VARCHAR(24))) + + self.assertEqual('SELECT CAST("foo" AS VARCHAR(24)) FROM "abc"', str(q)) + + def test__cast__varchar(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.VARCHAR)) + + self.assertEqual('SELECT CAST("foo" AS VARCHAR) FROM "abc"', str(q)) + + def test__cast__varchar_with_arg(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.VARCHAR(24))) + + self.assertEqual('SELECT CAST("foo" AS VARCHAR(24)) FROM "abc"', str(q)) + + def test__cast__long_varchar(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.LONG_VARCHAR)) + + self.assertEqual('SELECT CAST("foo" AS LONG VARCHAR) FROM "abc"', str(q)) + + def test__cast__long_varchar_with_arg(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.LONG_VARCHAR(24))) + + self.assertEqual('SELECT CAST("foo" AS LONG VARCHAR(24)) FROM "abc"', str(q)) + + def test__cast__binary(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.BINARY)) + + self.assertEqual('SELECT CAST("foo" AS BINARY) FROM "abc"', str(q)) + + def test__cast__binary_with_arg(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.BINARY(24))) + + self.assertEqual('SELECT CAST("foo" AS BINARY(24)) FROM "abc"', str(q)) + + def test__cast__varbinary(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.VARBINARY)) + + self.assertEqual('SELECT CAST("foo" AS VARBINARY) FROM "abc"', str(q)) + + def test__cast__varbinary_with_arg(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.VARBINARY(24))) + + self.assertEqual('SELECT CAST("foo" AS VARBINARY(24)) FROM "abc"', str(q)) + + def test__cast__long_varbinary(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.LONG_VARBINARY)) + + self.assertEqual('SELECT CAST("foo" AS LONG VARBINARY) FROM "abc"', str(q)) + + def test__cast__long_varbinary_with_arg(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.LONG_VARBINARY(24))) + + self.assertEqual('SELECT CAST("foo" AS LONG VARBINARY(24)) FROM "abc"', str(q)) + + def test__cast__boolean(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.BOOLEAN)) + + self.assertEqual('SELECT CAST("foo" AS BOOLEAN) FROM "abc"', str(q)) + + def test__cast__integer(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.INTEGER)) + + self.assertEqual('SELECT CAST("foo" AS INTEGER) FROM "abc"', str(q)) + + def test__cast__float(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.FLOAT)) + + self.assertEqual('SELECT CAST("foo" AS FLOAT) FROM "abc"', str(q)) + + def test__cast__numeric(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.NUMERIC)) + + self.assertEqual('SELECT CAST("foo" AS NUMERIC) FROM "abc"', str(q)) + + def test__tochar__(self): + q = Q.from_(self.t).select(fn.ToChar(self.t.foo, "SomeFormat")) + + self.assertEqual('SELECT TO_CHAR("foo",\'SomeFormat\') FROM "abc"', str(q)) + + +class DateFunctionsTests(unittest.TestCase): + dt = F("dt") + t = T("abc") + t2 = T("efg") + + def _test_extract_datepart(self, date_part): + q = Q.from_(self.t).select(fn.Extract(date_part, self.t.foo)) + + value = getattr(date_part, 'value', date_part) + self.assertEqual('SELECT EXTRACT(%s FROM "foo") FROM "abc"' % value, str(q)) + + def test_extract_microsecond(self): + self._test_extract_datepart(DatePart.microsecond) + self._test_extract_datepart(DatePart.microsecond.value) + + def test_extract_second(self): + self._test_extract_datepart(DatePart.second) + self._test_extract_datepart(DatePart.second.value) + + def test_extract_minute(self): + self._test_extract_datepart(DatePart.minute) + self._test_extract_datepart(DatePart.minute.value) + + def test_extract_hour(self): + self._test_extract_datepart(DatePart.hour) + self._test_extract_datepart(DatePart.hour.value) + + def test_extract_day(self): + self._test_extract_datepart(DatePart.day) + self._test_extract_datepart(DatePart.day.value) + + def test_extract_week(self): + self._test_extract_datepart(DatePart.week) + self._test_extract_datepart(DatePart.week.value) + + def test_extract_month(self): + self._test_extract_datepart(DatePart.month) + self._test_extract_datepart(DatePart.month.value) + + def test_extract_quarter(self): + self._test_extract_datepart(DatePart.quarter) + self._test_extract_datepart(DatePart.quarter.value) + + def test_extract_year(self): + self._test_extract_datepart(DatePart.year) + self._test_extract_datepart(DatePart.year.value) + + def test_extract_join(self): + q = Q.from_(self.t).join(self.t2).on(self.t.id == self.t2.t_id).select(fn.Extract(DatePart.year, self.t.foo)) + + self.assertEqual( + 'SELECT EXTRACT(YEAR FROM "abc"."foo") FROM "abc" ' 'JOIN "efg" ON "abc"."id"="efg"."t_id"', str(q) + ) + + def test_timestampadd(self): + a = fn.TimestampAdd("year", 1, "2017-10-01") + self.assertEqual(str(a), "TIMESTAMPADD(year,1,'2017-10-01')") + + def test_time_diff(self): + a = fn.TimeDiff("18:00:00", "10:00:00") + self.assertEqual(str(a), "TIMEDIFF('18:00:00','10:00:00')") + + def test_date_add(self): + a = fn.DateAdd("year", 1, "2017-10-01") + self.assertEqual(str(a), "DATE_ADD(year,1,'2017-10-01')") + + def test_now(self): + query = Query.select(fn.Now()) + + self.assertEqual("SELECT NOW()", str(query)) + + def test_utc_timestamp(self): + query = Query.select(fn.UtcTimestamp()) + + self.assertEqual("SELECT UTC_TIMESTAMP()", str(query)) + + def test_current_date(self): + query = Query.select(fn.CurDate()) + + self.assertEqual("SELECT CURRENT_DATE()", str(query)) + + def test_current_time(self): + query = Query.select(fn.CurTime()) + + self.assertEqual("SELECT CURRENT_TIME()", str(query)) + + def test_current_timestamp(self): + query = Query.select(fn.CurTimestamp()) + + self.assertEqual("SELECT CURRENT_TIMESTAMP", str(query)) + + def test_current_timestamp_with_alias(self): + query = Query.select(fn.CurTimestamp("ts")) + + self.assertEqual('SELECT CURRENT_TIMESTAMP "ts"', str(query)) + + def test_to_date(self): + q1 = fn.ToDate("2019-06-21", "yyyy-mm-dd") + q2 = Query.from_(self.t).select(fn.ToDate("2019-06-21", "yyyy-mm-dd")) + q3 = Query.from_(self.t).select(fn.ToDate(F("foo"), "yyyy-mm-dd")) + + self.assertEqual(str(q1), "TO_DATE('2019-06-21','yyyy-mm-dd')") + self.assertEqual(str(q2), "SELECT TO_DATE('2019-06-21','yyyy-mm-dd') FROM \"abc\"") + self.assertEqual(str(q3), 'SELECT TO_DATE("foo",\'yyyy-mm-dd\') FROM "abc"') + + +class NullFunctionsTests(unittest.TestCase): + def test_isnull(self): + q = Q.from_("abc").select(fn.IsNull(F("foo"))) + + self.assertEqual('SELECT ISNULL("foo") FROM "abc"', str(q)) + + def test_coalesce(self): + q = Q.from_("abc").select(fn.Coalesce(F("foo"), 0)) + + self.assertEqual('SELECT COALESCE("foo",0) FROM "abc"', str(q)) + + def test_nullif(self): + q = Q.from_("abc").select(fn.NullIf(F("foo"), 0)) + + self.assertEqual('SELECT NULLIF("foo",0) FROM "abc"', str(q)) + + def test_nvl(self): + q = Q.from_("abc").select(fn.NVL(F("foo"), 0)) + + self.assertEqual('SELECT NVL("foo",0) FROM "abc"', str(q)) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/test_groupby_modifiers.py b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/test_groupby_modifiers.py new file mode 100644 index 0000000000000000000000000000000000000000..978834c2409f4b4800fedb9b1bb2538a31d0f31c --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/test_groupby_modifiers.py @@ -0,0 +1,168 @@ +import unittest + +from pypika import Query, Rollup, RollupException, Table, functions as fn + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + + +class RollupTests(unittest.TestCase): + table = Table("abc") + + def test_mysql_one_groupby(self): + q = ( + Query.from_(self.table) + .select(self.table.foo, fn.Sum(self.table.bar)) + .rollup(self.table.foo, vendor="mysql") + ) + + self.assertEqual('SELECT "foo",SUM("bar") FROM "abc" GROUP BY "foo" WITH ROLLUP', str(q)) + + def test_mysql_rollup_two_groupbys(self): + q = ( + Query.from_(self.table) + .select(self.table.foo, self.table.fiz, fn.Sum(self.table.bar)) + .rollup(self.table.foo, self.table.fiz, vendor="mysql") + ) + + self.assertEqual( + 'SELECT "foo","fiz",SUM("bar") FROM "abc" GROUP BY "foo","fiz" WITH ROLLUP', + str(q), + ) + + def test_no_rollup_before_groupby(self): + with self.assertRaises(RollupException): + Query.from_(self.table).select(self.table.foo, fn.Sum(self.table.bar)).rollup(vendor="mysql") + + def test_no_rollup_after_rollup_mysql(self): + with self.assertRaises(AttributeError): + Query.from_(self.table).select(self.table.foo, self.table.fiz, fn.Sum(self.table.bar)).rollup( + self.table.foo, vendor="mysql" + ).rollup(self.table.fiz, vendor="mysql") + + def test_verticaoracle_func_one_groupby(self): + q = Query.from_(self.table).select(self.table.foo, fn.Sum(self.table.bar)).groupby(Rollup(self.table.foo)) + + self.assertEqual('SELECT "foo",SUM("bar") FROM "abc" GROUP BY ROLLUP("foo")', str(q)) + + def test_verticaoracle_func_two_groupbys(self): + q = ( + Query.from_(self.table) + .select(self.table.foo, self.table.fiz, fn.Sum(self.table.bar)) + .groupby( + Rollup( + self.table.foo, + self.table.fiz, + ) + ) + ) + + self.assertEqual( + 'SELECT "foo","fiz",SUM("bar") FROM "abc" GROUP BY ROLLUP("foo","fiz")', + str(q), + ) + + def test_verticaoracle_func_partial(self): + q = ( + Query.from_(self.table) + .select(self.table.foo, self.table.fiz, self.table.buz, fn.Sum(self.table.bar)) + .groupby( + Rollup( + self.table.foo, + self.table.fiz, + ), + self.table.buz, + ) + ) + + self.assertEqual( + 'SELECT "foo","fiz","buz",SUM("bar") FROM "abc" GROUP BY ROLLUP("foo","fiz"),"buz"', + str(q), + ) + + def test_verticaoracle_from_groupbys(self): + q = Query.from_(self.table).select(self.table.foo, fn.Sum(self.table.bar)).rollup(self.table.foo) + + self.assertEqual('SELECT "foo",SUM("bar") FROM "abc" GROUP BY ROLLUP("foo")', str(q)) + + def test_verticaoracle_from_two_groupbys(self): + q = ( + Query.from_(self.table) + .select(self.table.foo, self.table.fiz, fn.Sum(self.table.bar)) + .rollup( + self.table.foo, + self.table.fiz, + ) + ) + + self.assertEqual( + 'SELECT "foo","fiz",SUM("bar") FROM "abc" GROUP BY ROLLUP("foo","fiz")', + str(q), + ) + + def test_verticaoracle_from_parameters(self): + q = ( + Query.from_(self.table) + .select(self.table.foo, self.table.fiz, fn.Sum(self.table.bar)) + .groupby( + self.table.foo, + ) + .rollup( + self.table.fiz, + ) + ) + + self.assertEqual( + 'SELECT "foo","fiz",SUM("bar") FROM "abc" GROUP BY "foo",ROLLUP("fiz")', + str(q), + ) + + def test_verticaoracle_multiple_rollups(self): + q = ( + Query.from_(self.table) + .select(self.table.foo, self.table.fiz, fn.Sum(self.table.bar)) + .rollup( + self.table.foo, + ) + .rollup( + self.table.fiz, + ) + ) + + self.assertEqual( + 'SELECT "foo","fiz",SUM("bar") FROM "abc" GROUP BY ROLLUP("foo","fiz")', + str(q), + ) + + def test_verticaoracle_rollups_with_parity(self): + q = ( + Query.from_(self.table) + .select( + self.table.buz, + ) + .rollup( + [self.table.foo, self.table.bar], + self.table.fiz, + ) + ) + + self.assertEqual('SELECT "buz" FROM "abc" GROUP BY ROLLUP(("foo","bar"),"fiz")', str(q)) + + def test_verticaoracle_rollups_with_multiple_rollups_and_parity(self): + q = ( + Query.from_(self.table) + .select( + self.table.buz, + ) + .rollup( + [self.table.foo, self.table.bar], + ) + .rollup( + [self.table.fiz, self.table.buz], + ) + ) + + self.assertEqual( + 'SELECT "buz" FROM "abc" GROUP BY ROLLUP(("foo","bar"),("fiz","buz"))', + str(q), + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/test_immutability.py b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/test_immutability.py new file mode 100644 index 0000000000000000000000000000000000000000..ee539bfa1e9c4509b929e7a86a03f098dd923515 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/test_immutability.py @@ -0,0 +1,99 @@ +import unittest + +from pypika import ( + AliasedQuery, + Query, + Tables, +) + + +class ImmutabilityTests(unittest.TestCase): + table_a, table_b, table_c = Tables("a", "b", "c") + + def test_select_returns_new_query_instance(self): + query_a = Query.from_(self.table_a).select(self.table_a.foo) + query_b = query_a.select(self.table_a.bar) + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_groupby_returns_new_query_instance(self): + query_a = Query.from_(self.table_a).select(self.table_a.foo).groupby(self.table_a.foo) + query_b = query_a.groupby(self.table_a.bar) + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_orderby_return_new_query_instance(self): + query_a = Query.from_(self.table_a).select(self.table_a.foo).orderby(self.table_a.foo) + query_b = query_a.orderby(self.table_a.bar) + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_join_return_new_query_instance(self): + base = Query.from_(self.table_a).select(self.table_a.foo) + query_a = base.join(self.table_b).on(self.table_a.foo == self.table_b.bar).select(self.table_b.bar) + query_b = query_a.join(self.table_c).on(self.table_a.foo == self.table_c.baz).select(self.table_c.baz) + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_use_index_return_new_query_instance(self): + query_a = Query.from_(self.table_a).select(self.table_a.foo).use_index('idx1') + query_b = query_a.use_index('idx2') + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_force_index_return_new_query_instance(self): + query_a = Query.from_(self.table_a).select(self.table_a.foo).force_index('idx1') + query_b = query_a.force_index('idx2') + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_with_return_new_query_instance(self): + alias_1 = Query.from_(self.table_a).select(self.table_a.foo) + alias_2 = Query.from_(self.table_b).select(self.table_b.bar) + query_a = Query.from_(AliasedQuery('a1')).select('foo').with_(alias_1, 'a1') + query_b = query_a.with_(alias_2, 'a2') + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_insert_into_return_new_query_instance(self): + query_a = Query.into(self.table_a).insert('foo1') + query_b = query_a.insert('foo2') + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_replace_into_return_new_query_instance(self): + query_a = Query.into(self.table_a).replace('foo') + query_b = query_a.replace('bar') + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_update_set_return_new_query_instance(self): + query_a = Query.update(self.table_a).set(self.table_a.foo, 'foo') + query_b = query_a.set(self.table_a.bar, 'bar') + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_queries_after_join(self): + query1 = Query.from_(self.table_a).select(self.table_a.foo) + query2 = query1.join(self.table_b).on(self.table_a.foo == self.table_b.bar).select(self.table_b.buz) + + self.assertEqual('SELECT "foo" FROM "a"', str(query1)) + self.assertEqual( + 'SELECT "a"."foo","b"."buz" FROM "a" JOIN "b" ON "a"."foo"="b"."bar"', + str(query2), + ) + + def test_immutable_kwarg_on_query_builder_disables_immutability(self): + query0 = Query.from_(self.table_a, immutable=False) + query1 = query0.select(self.table_a.foo) + self.assertIs(query0, query1) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/test_inserts.py b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/test_inserts.py new file mode 100644 index 0000000000000000000000000000000000000000..f86efd7a76dc498a69b61c6353951695f1933a61 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/test_inserts.py @@ -0,0 +1,885 @@ +import unittest + +from pypika import ( + AliasedQuery, + Case, + Field as F, + MySQLQuery, + PostgreSQLQuery, + Query, + Table, + Tables, + functions as fn, +) +from pypika.functions import ( + Avg, + Cast, +) +from pypika.terms import Values +from pypika.utils import QueryException + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + + +class InsertIntoTests(unittest.TestCase): + table_abc = Table("abc") + + def test_insert_one_column(self): + query = Query.into(self.table_abc).insert(1) + + self.assertEqual('INSERT INTO "abc" VALUES (1)', str(query)) + + def test_insert_one_column_single_element_array(self): + query = Query.into(self.table_abc).insert((1,)) + + self.assertEqual('INSERT INTO "abc" VALUES (1)', str(query)) + + def test_insert_one_column_multi_element_array(self): + query = Query.into(self.table_abc).insert((1,), (2,)) + + self.assertEqual('INSERT INTO "abc" VALUES (1),(2)', str(query)) + + def test_insert_single_row_with_array_value(self): + query = Query.into(self.table_abc).insert(1, ["a", "b", "c"]) + + self.assertEqual("INSERT INTO \"abc\" VALUES (1,['a','b','c'])", str(query)) + + def test_insert_multiple_rows_with_array_value(self): + query = Query.into(self.table_abc).insert( + (1, ["a", "b", "c"]), + (2, ["c", "d", "e"]), + ) + + self.assertEqual( + 'INSERT INTO "abc" ' "VALUES (1,['a','b','c']),(2,['c','d','e'])", + str(query), + ) + + def test_insert_all_columns(self): + query = Query.into(self.table_abc).insert(1, "a", True) + + self.assertEqual("INSERT INTO \"abc\" VALUES (1,'a',true)", str(query)) + + def test_insert_all_columns_single_element(self): + query = Query.into(self.table_abc).insert((1, "a", True)) + + self.assertEqual("INSERT INTO \"abc\" VALUES (1,'a',true)", str(query)) + + def test_insert_all_columns_multi_rows(self): + query = Query.into(self.table_abc).insert((1, "a", True), (2, "b", False)) + + self.assertEqual("INSERT INTO \"abc\" VALUES (1,'a',true),(2,'b',false)", str(query)) + + def test_insert_all_columns_multi_rows_chained(self): + query = Query.into(self.table_abc).insert(1, "a", True).insert(2, "b", False) + + self.assertEqual("INSERT INTO \"abc\" VALUES (1,'a',true),(2,'b',false)", str(query)) + + def test_insert_all_columns_multi_rows_chained_mixed(self): + query = Query.into(self.table_abc).insert((1, "a", True), (2, "b", False)).insert(3, "c", True) + + self.assertEqual( + 'INSERT INTO "abc" VALUES ' "(1,'a',true),(2,'b',false)," "(3,'c',true)", + str(query), + ) + + def test_insert_all_columns_multi_rows_chained_multiple_rows(self): + query = ( + Query.into(self.table_abc).insert((1, "a", True), (2, "b", False)).insert((3, "c", True), (4, "d", False)) + ) + + self.assertEqual( + 'INSERT INTO "abc" VALUES ' "(1,'a',true),(2,'b',false)," "(3,'c',true),(4,'d',false)", + str(query), + ) + + def test_insert_selected_columns(self): + query = ( + Query.into(self.table_abc) + .columns(self.table_abc.foo, self.table_abc.bar, self.table_abc.buz) + .insert(1, "a", True) + ) + + self.assertEqual('INSERT INTO "abc" ("foo","bar","buz") VALUES (1,\'a\',true)', str(query)) + + def test_insert_empty_columns(self): + query = Query.into(self.table_abc).columns().insert(1, "a", True) + + self.assertEqual('INSERT INTO "abc" VALUES (1,\'a\',true)', str(query)) + + def test_insert_selected_columns_type_list(self): + query = ( + Query.into(self.table_abc) + .columns([self.table_abc.foo, self.table_abc.bar, self.table_abc.buz]) + .insert(1, "a", True) + ) + + self.assertEqual('INSERT INTO "abc" ("foo","bar","buz") VALUES (1,\'a\',true)', str(query)) + + def test_insert_empty_columns_type_list(self): + query = Query.into(self.table_abc).columns([]).insert(1, "a", True) + + self.assertEqual('INSERT INTO "abc" VALUES (1,\'a\',true)', str(query)) + + def test_insert_selected_columns_type_tuple(self): + query = ( + Query.into(self.table_abc) + .columns((self.table_abc.foo, self.table_abc.bar, self.table_abc.buz)) + .insert(1, "a", True) + ) + + self.assertEqual('INSERT INTO "abc" ("foo","bar","buz") VALUES (1,\'a\',true)', str(query)) + + def test_insert_empty_columns_type_tuple(self): + query = Query.into(self.table_abc).columns(()).insert(1, "a", True) + + self.assertEqual('INSERT INTO "abc" VALUES (1,\'a\',true)', str(query)) + + def test_insert_none_skipped(self): + query = Query.into(self.table_abc).insert() + + self.assertEqual("", str(query)) + + def test_insert_ignore(self): + query = Query.into(self.table_abc).insert(1).ignore() + + self.assertEqual('INSERT IGNORE INTO "abc" VALUES (1)', str(query)) + + def test_insert_null(self): + query = Query.into(self.table_abc).insert(None) + + self.assertEqual('INSERT INTO "abc" VALUES (NULL)', str(query)) + + def test_insert_column_using_table_alias(self): + q = self.table_abc.insert(1) + self.assertEqual('INSERT INTO "abc" VALUES (1)', str(q)) + + def test_insert_column_using_alias_with_chain(self): + q = self.table_abc.insert(1, "a", True).insert(2, "b", False) + self.assertEqual("INSERT INTO \"abc\" VALUES (1,'a',true),(2,'b',false)", str(q)) + + def test_insert_with_statement(self): + sub_query = Query().select(self.table_abc.id).from_(self.table_abc) + aliased = AliasedQuery('sub_qs') + + q = Query().with_(sub_query, 'sub_qs').into(self.table_abc).select(aliased.id).from_(aliased) + self.assertEqual( + 'WITH sub_qs AS (SELECT "id" FROM "abc") INSERT INTO "abc" SELECT "sub_qs"."id" FROM sub_qs', str(q) + ) + + +class PostgresInsertIntoOnConflictTests(unittest.TestCase): + table_abc = Table("abc") + + def test_insert_on_conflict_do_nothing_field(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).on_conflict(self.table_abc.id).do_nothing() + + self.assertEqual('INSERT INTO "abc" VALUES (1) ON CONFLICT ("id") DO NOTHING', str(query)) + + def test_insert_on_conflict_do_nothing_multiple_fields(self): + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1) + .on_conflict(self.table_abc.id, self.table_abc.sub_id) + .do_nothing() + ) + + self.assertEqual('INSERT INTO "abc" VALUES (1) ON CONFLICT ("id", "sub_id") DO NOTHING', str(query)) + + def test_insert_on_conflict_do_nothing_field_str(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).on_conflict("id").do_nothing() + + self.assertEqual('INSERT INTO "abc" VALUES (1) ON CONFLICT ("id") DO NOTHING', str(query)) + + def test_insert_on_conflict_do_nothing_multiple_fields_str(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).on_conflict("id", "sub_id").do_nothing() + + self.assertEqual('INSERT INTO "abc" VALUES (1) ON CONFLICT ("id", "sub_id") DO NOTHING', str(query)) + + def test_insert_on_conflict_do_nothing_mixed_fields(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).on_conflict("id", self.table_abc.sub_id).do_nothing() + + self.assertEqual('INSERT INTO "abc" VALUES (1) ON CONFLICT ("id", "sub_id") DO NOTHING', str(query)) + + def test_insert_on_conflict_do_update_field(self): + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict(self.table_abc.id) + .do_update(self.table_abc.name, "m") + ) + + self.assertEqual( + "INSERT INTO \"abc\" VALUES (1,'m') ON CONFLICT (\"id\") DO UPDATE SET \"name\"='m'", + str(query), + ) + + def test_insert_on_conflict_do_update_multiple_fields(self): + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict(self.table_abc.id, self.table_abc.sub_id) + .do_update(self.table_abc.name, "m") + ) + + self.assertEqual( + "INSERT INTO \"abc\" VALUES (1,'m') ON CONFLICT (\"id\", \"sub_id\") DO UPDATE SET \"name\"='m'", + str(query), + ) + + def test_insert_on_conflict_do_update_field_str(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1, "m").on_conflict("id").do_update("name", "m") + + self.assertEqual( + "INSERT INTO \"abc\" VALUES (1,'m') ON CONFLICT (\"id\") DO UPDATE SET \"name\"='m'", + str(query), + ) + + def test_insert_on_conflict_do_update_multiple_fields_str(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1, "m").on_conflict("id", "sub_id").do_update("name", "m") + + self.assertEqual( + "INSERT INTO \"abc\" VALUES (1,'m') ON CONFLICT (\"id\", \"sub_id\") DO UPDATE SET \"name\"='m'", + str(query), + ) + + def test_insert_on_conflict_do_update_multiple_mixed_fields(self): + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict("id", self.table_abc.sub_id) + .do_update("name", "m") + ) + + self.assertEqual( + "INSERT INTO \"abc\" VALUES (1,'m') ON CONFLICT (\"id\", \"sub_id\") DO UPDATE SET \"name\"='m'", + str(query), + ) + + def test_insert_on_conflict_no_handler(self): + with self.assertRaises(QueryException): + query = str(PostgreSQLQuery.into(self.table_abc).insert(1).on_conflict(self.table_abc.id)) + + def test_insert_on_conflict_two_handlers_do_nothing(self): + with self.assertRaises(QueryException): + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1) + .on_conflict("id") + .do_nothing() + .do_update(self.table_abc.name, "m") + ) + + def test_insert_on_conflict_two_handlers_do_update(self): + with self.assertRaises(QueryException): + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1) + .on_conflict(self.table_abc.id) + .do_update(self.table_abc.name, "m") + .do_nothing() + ) + + def test_non_insert_on_conflict_do_nothing(self): + with self.assertRaises(QueryException): + query = PostgreSQLQuery.update(self.table_abc).set("foo", "bar").on_conflict("id").do_nothing() + + def test_non_insert_on_conflict_do_update(self): + with self.assertRaises(QueryException): + query = ( + PostgreSQLQuery.update(self.table_abc).set("foo", "bar").on_conflict("id").do_update(["name"], ["m"]) + ) + + def test_insert_on_fieldless_conflict_do_nothing(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).on_conflict(None).do_nothing() + + self.assertEqual('INSERT INTO "abc" VALUES (1) ON CONFLICT DO NOTHING', str(query)) + + def test_insert_on_fieldless_conflict_do_update_field(self): + with self.assertRaises(QueryException): + query = str( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict(None) + .do_update(self.table_abc.name, "m") + ) + + def test_on_conflict_from_subquery(self): + table_bcd = Table('bcd') + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(self.table_abc.fname, self.table_abc.lname) + .select(table_bcd.fname, table_bcd.lname) + .from_(table_bcd) + .on_conflict(self.table_abc.id, self.table_abc.sub_id) + .do_update(self.table_abc.fname, 1) + .do_update(self.table_abc.lname, table_bcd.lname) + .do_update( + self.table_abc.cname, + Case().when(self.table_abc.cname.eq('cname'), 'new_name').else_(self.table_abc.cname), + ) + ) + + self.assertEqual( + 'INSERT INTO "abc" VALUES ("fname","lname") ' + 'ON CONFLICT ("id", "sub_id") ' + 'DO UPDATE SET "fname"=1,"lname"="bcd"."lname",' + '"cname"=CASE WHEN "abc"."cname"=\'cname\' THEN \'new_name\' ELSE "abc"."cname" END', + str(query), + ) + + def test_on_conflict_where_empty_conflict_fields_do_nothing(self): + with self.assertRaises(QueryException): + ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict() + .where(self.table_abc.abc.eq(0)) + .where(self.table_abc.cde.eq(0)) + .do_nothing() + ) + + def test_on_conflict_where_conflict_fields_do_nothing(self): + qs = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict('id') + .where(self.table_abc.abc.eq(0)) + .where(self.table_abc.cde.eq(0)) + .do_nothing() + ) + self.assertEqual( + '''INSERT INTO "abc" VALUES (1,'m') ON CONFLICT ("id") WHERE "abc"=0 AND "cde"=0 DO NOTHING''', str(qs) + ) + + def test_on_conflict_where_empty_conflict_fields_do_update(self): + with self.assertRaises(QueryException): + ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict() + .where(self.table_abc.abc.eq(0)) + .where(self.table_abc.cde.eq(0)) + .do_update('field', 'val') + ) + + def test_on_conflict_where_conflict_fields_do_update(self): + qs = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict('id') + .where(self.table_abc.abc.eq(0)) + .where(self.table_abc.cde.eq(0)) + .do_update('field', 'val') + ) + self.assertEqual( + '''INSERT INTO "abc" VALUES (1,'m') ON CONFLICT ("id") WHERE "abc"=0 AND "cde"=0 ''' + '''DO UPDATE SET "field"='val\'''', + str(qs), + ) + + def test_where_and_on_conflict_where(self): + table_bcd = Table('bcd') + + qs = ( + PostgreSQLQuery.into(self.table_abc) + .select(table_bcd.abc) + .from_(table_bcd) + .where(table_bcd.abc.eq('1')) + .on_conflict('id') + .where(self.table_abc.abc.eq(0)) + .where(self.table_abc.cde.eq(0)) + .do_update('field', 'val') + ) + + self.assertEqual( + 'INSERT INTO "abc" SELECT "abc" FROM "bcd" WHERE "abc"=\'1\' ' + 'ON CONFLICT ("id") WHERE "abc"=0 AND "cde"=0 DO UPDATE SET "field"=\'val\'', + str(qs), + ) + + def test_on_conflict_do_nothing_where(self): + with self.assertRaises(QueryException): + ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict() + .do_nothing() + .where(self.table_abc.abc.eq(1)) + ) + + def test_empty_on_conflict_do_update_where(self): + with self.assertRaises(QueryException): + ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict() + .do_update('abc', 1) + .where(self.table_abc.abc.eq(1)) + ) + + def test_on_conflict_do_update_where(self): + qs = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict("id") + .do_update('abc', 1) + .where(self.table_abc.abc.eq(1)) + ) + self.assertEqual( + 'INSERT INTO "abc" VALUES (1,\'m\') ON CONFLICT ("id") DO UPDATE SET "abc"=1 WHERE "abc"."abc"=1', str(qs) + ) + + def test_on_conflict_do_update_with_excluded_where(self): + qs = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict("id") + .do_update('abc') + .where(self.table_abc.abc.eq(1)) + ) + self.assertEqual( + 'INSERT INTO "abc" VALUES (1,\'m\') ON CONFLICT ("id") DO UPDATE SET "abc"=EXCLUDED."abc" WHERE ' + '"abc"."abc"=1', + str(qs), + ) + + def test_on_conflict_where_complex(self): + table_bcd = Table('bcd') + + qs = ( + PostgreSQLQuery.into(self.table_abc) + .select(table_bcd.abc) + .from_(table_bcd) + .where(table_bcd.abc.eq('1')) + .on_conflict('id') + .where(self.table_abc.abc.eq(0)) + .where(self.table_abc.cde.eq(0)) + .do_update('field', 'val') + .where(self.table_abc.id.eq(2)) + .where(self.table_abc.sub_id.eq(3)) + ) + self.assertEqual( + 'INSERT INTO "abc" SELECT "abc" FROM "bcd" WHERE "abc"=\'1\' ' + 'ON CONFLICT ("id") WHERE "abc"=0 AND "cde"=0 ' + 'DO UPDATE SET "field"=\'val\' WHERE "abc"."id"=2 AND "abc"."sub_id"=3', + str(qs), + ) + + +class PostgresInsertIntoReturningTests(unittest.TestCase): + table_abc = Table("abc") + + def test_insert_returning_one_field(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).returning(self.table_abc.id) + + self.assertEqual('INSERT INTO "abc" VALUES (1) RETURNING "id"', str(query)) + + def test_insert_returning_one_field_str(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).returning("id") + + self.assertEqual('INSERT INTO "abc" VALUES (1) RETURNING "id"', str(query)) + + def test_insert_returning_all_fields(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).returning(self.table_abc.star) + + self.assertEqual('INSERT INTO "abc" VALUES (1) RETURNING *', str(query)) + + def test_insert_returning_all_fields_and_arithmetics(self): + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1) + .returning(self.table_abc.star, self.table_abc.f1 + self.table_abc.f2) + ) + + self.assertEqual('INSERT INTO "abc" VALUES (1) RETURNING *,"f1"+"f2"', str(query)) + + def test_insert_all_columns_multi_rows_chained_returning_star(self): + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "a", True) + .insert(2, "b", False) + .returning(self.table_abc.star) + ) + + self.assertEqual( + "INSERT INTO \"abc\" VALUES (1,'a',true),(2,'b',false) RETURNING *", + str(query), + ) + + def test_insert_all_columns_multi_rows_chained_returning_star_and_id(self): + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "a", True) + .insert(2, "b", False) + .returning( + self.table_abc.name, + self.table_abc.star, + self.table_abc.id, + ) + ) + + self.assertEqual( + "INSERT INTO \"abc\" VALUES (1,'a',true),(2,'b',false) RETURNING *", + str(query), + ) + + def test_insert_all_columns_multi_rows_chained_returning_star_str(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1, "a", True).insert(2, "b", False).returning("*") + + self.assertEqual( + "INSERT INTO \"abc\" VALUES (1,'a',true),(2,'b',false) RETURNING *", + str(query), + ) + + def test_insert_all_columns_single_element_arrays(self): + query = PostgreSQLQuery.into(self.table_abc).insert((1, "a", True)).returning(self.table_abc.star) + + self.assertEqual("INSERT INTO \"abc\" VALUES (1,'a',true) RETURNING *", str(query)) + + def test_insert_returning_null(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).returning(None) + + self.assertEqual('INSERT INTO "abc" VALUES (1) RETURNING NULL', str(query)) + + def test_insert_returning_tuple(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).returning((1, 2, 3)) + + self.assertEqual('INSERT INTO "abc" VALUES (1) RETURNING (1,2,3)', str(query)) + + def test_insert_returning_arithmetics(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).returning(self.table_abc.f1 + self.table_abc.f2) + + self.assertEqual('INSERT INTO "abc" VALUES (1) RETURNING "f1"+"f2"', str(query)) + + def test_insert_returning_functions(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).returning(Cast(self.table_abc.f1, "int")) + + self.assertEqual('INSERT INTO "abc" VALUES (1) RETURNING CAST("f1" AS INT)', str(query)) + + def test_insert_returning_aggregate(self): + with self.assertRaises(QueryException): + PostgreSQLQuery.into(self.table_abc).insert(1).returning(Avg(self.table_abc.views)) + + def test_insert_returning_from_other_table(self): + table_cba = Table("cba") + with self.assertRaises(QueryException): + PostgreSQLQuery.into(self.table_abc).insert(1).returning(table_cba.id) + + +class InsertIntoOnDuplicateTests(unittest.TestCase): + table_abc = Table("abc") + + def test_insert_one_column(self): + query = ( + MySQLQuery.into(self.table_abc).insert(1).on_duplicate_key_update(self.table_abc.foo, self.table_abc.foo) + ) + self.assertEqual( + "INSERT INTO `abc` VALUES (1) ON DUPLICATE KEY UPDATE `foo`=`foo`", + str(query), + ) + + def test_insert_one_column_using_values(self): + query = ( + MySQLQuery.into(self.table_abc) + .insert(1) + .on_duplicate_key_update(self.table_abc.foo, Values(self.table_abc.foo)) + ) + self.assertEqual( + "INSERT INTO `abc` VALUES (1) ON DUPLICATE KEY UPDATE `foo`=VALUES(`foo`)", + str(query), + ) + + def test_insert_one_column_single_element_array(self): + query = ( + MySQLQuery.into(self.table_abc).insert((1,)).on_duplicate_key_update(self.table_abc.foo, self.table_abc.foo) + ) + + self.assertEqual( + "INSERT INTO `abc` VALUES (1) ON DUPLICATE KEY UPDATE `foo`=`foo`", + str(query), + ) + + def test_insert_one_column_multi_element_array(self): + query = ( + MySQLQuery.into(self.table_abc) + .insert((1,), (2,)) + .on_duplicate_key_update(self.table_abc.foo, self.table_abc.foo) + ) + + self.assertEqual( + "INSERT INTO `abc` VALUES (1),(2) ON DUPLICATE KEY UPDATE `foo`=`foo`", + str(query), + ) + + def test_insert_multiple_columns_on_duplicate_update_one_with_same_value(self): + query = ( + MySQLQuery.into(self.table_abc) + .insert(1, "a") + .on_duplicate_key_update(self.table_abc.bar, Values(self.table_abc.bar)) + ) + + self.assertEqual( + "INSERT INTO `abc` VALUES (1,'a') ON DUPLICATE KEY UPDATE `bar`=VALUES(`bar`)", + str(query), + ) + + def test_insert_multiple_columns_on_duplicate_update_one_with_different_value(self): + query = MySQLQuery.into(self.table_abc).insert(1, "a").on_duplicate_key_update(self.table_abc.bar, "b") + + self.assertEqual( + "INSERT INTO `abc` VALUES (1,'a') ON DUPLICATE KEY UPDATE `bar`='b'", + str(query), + ) + + def test_insert_multiple_columns_on_duplicate_update_one_with_expression(self): + query = ( + MySQLQuery.into(self.table_abc).insert(1, 2).on_duplicate_key_update(self.table_abc.bar, 4 + F("bar")) + ) # todo sql expression? not python + + self.assertEqual( + "INSERT INTO `abc` VALUES (1,2) ON DUPLICATE KEY UPDATE `bar`=4+`bar`", + str(query), + ) + + def test_insert_multiple_columns_on_duplicate_update_one_with_expression_using_original_field_value( + self, + ): + query = ( + MySQLQuery.into(self.table_abc) + .insert(1, "a") + .on_duplicate_key_update(self.table_abc.bar, fn.Concat(self.table_abc.bar, "update")) + ) + + self.assertEqual( + "INSERT INTO `abc` VALUES (1,'a') ON DUPLICATE KEY UPDATE `bar`=CONCAT(`bar`,'update')", + str(query), + ) + + def test_insert_multiple_columns_on_duplicate_update_one_with_expression_using_values( + self, + ): + query = ( + MySQLQuery.into(self.table_abc) + .insert(1, "a") + .on_duplicate_key_update(self.table_abc.bar, fn.Concat(Values(self.table_abc.bar), "update")) + ) + + self.assertEqual( + "INSERT INTO `abc` VALUES (1,'a') ON DUPLICATE KEY UPDATE `bar`=CONCAT(VALUES(`bar`),'update')", + str(query), + ) + + def test_insert_multiple_columns_on_duplicate_update_multiple(self): + query = ( + MySQLQuery.into(self.table_abc) + .insert(1, "a", "b") + .on_duplicate_key_update(self.table_abc.bar, "b") + .on_duplicate_key_update(self.table_abc.baz, "c") + ) + + self.assertEqual( + "INSERT INTO `abc` VALUES (1,'a','b') ON DUPLICATE KEY UPDATE `bar`='b',`baz`='c'", + str(query), + ) + + def test_insert_multi_rows_chained_mixed_on_duplicate_update_multiple(self): + query = ( + MySQLQuery.into(self.table_abc) + .insert((1, "a", True), (2, "b", False)) + .insert(3, "c", True) + .on_duplicate_key_update(self.table_abc.foo, self.table_abc.foo) + .on_duplicate_key_update(self.table_abc.bar, Values(self.table_abc.bar)) + ) + + self.assertEqual( + "INSERT INTO `abc` VALUES (1,'a',true),(2,'b',false),(3,'c',true) " + "ON DUPLICATE KEY UPDATE `foo`=`foo`,`bar`=VALUES(`bar`)", + str(query), + ) + + def test_insert_selected_columns_on_duplicate_update_one(self): + query = ( + MySQLQuery.into(self.table_abc) + .columns(self.table_abc.foo, self.table_abc.bar, self.table_abc.baz) + .insert(1, "a", True) + .on_duplicate_key_update(self.table_abc.baz, False) + ) + + self.assertEqual( + "INSERT INTO `abc` (`foo`,`bar`,`baz`) VALUES (1,'a',true) ON DUPLICATE KEY UPDATE `baz`=false", + str(query), + ) + + def test_insert_selected_columns_on_duplicate_update_multiple(self): + query = ( + MySQLQuery.into(self.table_abc) + .columns(self.table_abc.foo, self.table_abc.bar, self.table_abc.baz) + .insert(1, "a", True) + .on_duplicate_key_update(self.table_abc.baz, False) + .on_duplicate_key_update(self.table_abc.bar, Values(self.table_abc.bar)) + ) + + self.assertEqual( + "INSERT INTO `abc` (`foo`,`bar`,`baz`) VALUES (1,'a',true) " + "ON DUPLICATE KEY UPDATE `baz`=false,`bar`=VALUES(`bar`)", + str(query), + ) + + def test_insert_none_skipped(self): + query = MySQLQuery.into(self.table_abc).insert().on_duplicate_key_update(self.table_abc.baz, False) + + self.assertEqual("", str(query)) + + def test_insert_ignore(self): + query = MySQLQuery.into(self.table_abc).insert(1).ignore().on_duplicate_key_update(self.table_abc.baz, False) + + self.assertEqual( + "INSERT IGNORE INTO `abc` VALUES (1) ON DUPLICATE KEY UPDATE `baz`=false", + str(query), + ) + + +class InsertSelectFromTests(unittest.TestCase): + table_abc, table_efg, table_hij = Tables("abc", "efg", "hij") + + def test_insert_star(self): + query = Query.into(self.table_abc).from_(self.table_efg).select("*") + + self.assertEqual('INSERT INTO "abc" SELECT * FROM "efg"', str(query)) + + def test_insert_ignore_star(self): + query = Query.into(self.table_abc).from_(self.table_efg).select("*").ignore() + + self.assertEqual('INSERT IGNORE INTO "abc" SELECT * FROM "efg"', str(query)) + + def test_insert_from_columns(self): + query = ( + Query.into(self.table_abc) + .from_(self.table_efg) + .select(self.table_efg.fiz, self.table_efg.buz, self.table_efg.baz) + ) + + self.assertEqual('INSERT INTO "abc" ' 'SELECT "fiz","buz","baz" FROM "efg"', str(query)) + + def test_insert_columns_from_star(self): + query = ( + Query.into(self.table_abc) + .columns( + self.table_abc.foo, + self.table_abc.bar, + self.table_abc.buz, + ) + .from_(self.table_efg) + .select("*") + ) + + self.assertEqual('INSERT INTO "abc" ("foo","bar","buz") ' 'SELECT * FROM "efg"', str(query)) + + def test_insert_columns_from_columns(self): + query = ( + Query.into(self.table_abc) + .columns(self.table_abc.foo, self.table_abc.bar, self.table_abc.buz) + .from_(self.table_efg) + .select(self.table_efg.fiz, self.table_efg.buz, self.table_efg.baz) + ) + + self.assertEqual( + 'INSERT INTO "abc" ("foo","bar","buz") ' 'SELECT "fiz","buz","baz" FROM "efg"', + str(query), + ) + + def test_insert_columns_from_columns_with_join(self): + query = ( + Query.into(self.table_abc) + .columns( + self.table_abc.c1, + self.table_abc.c2, + self.table_abc.c3, + self.table_abc.c4, + ) + .from_(self.table_efg) + .select(self.table_efg.foo, self.table_efg.bar) + .join(self.table_hij) + .on(self.table_efg.id == self.table_hij.abc_id) + .select(self.table_hij.fiz, self.table_hij.buz) + ) + + self.assertEqual( + 'INSERT INTO "abc" ("c1","c2","c3","c4") ' + 'SELECT "efg"."foo","efg"."bar","hij"."fiz","hij"."buz" FROM "efg" ' + 'JOIN "hij" ON "efg"."id"="hij"."abc_id"', + str(query), + ) + + +class InsertSubqueryTests(unittest.TestCase): + def test_insert_subquery_wrapped_in_brackets(self): + purchase_order_item, part = Tables("purchase_order_item", "part") + + q = ( + Query.into(purchase_order_item) + .columns(purchase_order_item.id_part, purchase_order_item.id_customer) + .insert( + Query.from_(part).select(part.part_id).where(part.part_number == "FOOBAR"), + 12345, + ) + ) + + self.assertEqual( + 'INSERT INTO "purchase_order_item" ' + '("id_part","id_customer") ' + "VALUES " + '((SELECT "part_id" FROM "part" WHERE "part_number"=\'FOOBAR\'),12345)', + str(q), + ) + + +class SelectIntoTests(unittest.TestCase): + table_abc, table_efg, table_hij = Tables("abc", "efg", "hij") + + def test_select_star_into(self): + query = Query.from_(self.table_abc).select("*").into(self.table_efg) + + self.assertEqual('SELECT * INTO "efg" FROM "abc"', str(query)) + + def test_select_columns_into(self): + query = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, self.table_abc.bar, self.table_abc.buz) + .into(self.table_efg) + ) + + self.assertEqual('SELECT "foo","bar","buz" INTO "efg" FROM "abc"', str(query)) + + def test_select_columns_into_with_join(self): + query = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, self.table_abc.bar) + .join(self.table_hij) + .on(self.table_abc.id == self.table_hij.abc_id) + .select(self.table_hij.fiz, self.table_hij.buz) + .into(self.table_efg) + ) + + self.assertEqual( + 'SELECT "abc"."foo","abc"."bar","hij"."fiz","hij"."buz" ' + 'INTO "efg" FROM "abc" ' + 'JOIN "hij" ON "abc"."id"="hij"."abc_id"', + str(query), + ) + + +class ReplaceTests(unittest.TestCase): + table_abc, table_def = Tables("abc", "efg") + + def test_replace_simple(self): + query = Query.into(self.table_abc).replace("v1", "v2", "v3") + expected_output = "REPLACE INTO \"abc\" VALUES ('v1','v2','v3')" + self.assertEqual(str(query), expected_output) + + def test_replace_subquery(self): + query = Query.into(self.table_abc).replace(Query.from_(self.table_def).select("f1", "f2")) + expected_output = 'REPLACE INTO "abc" VALUES ((SELECT "f1","f2" FROM "efg"))' + self.assertEqual(str(query), expected_output) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/test_internals.py b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/test_internals.py new file mode 100644 index 0000000000000000000000000000000000000000..921e381ba8613d4a83cc53bd60d111d9547e2c1f --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/test_internals.py @@ -0,0 +1,35 @@ +import unittest + +from pypika import ( + Case, + Field, + Table, +) +from pypika.terms import Star + + +class TablesTests(unittest.TestCase): + def test__criterion_replace_table_with_value(self): + table = Table("a") + + c = (Field("foo") > 1).replace_table(None, table) + self.assertEqual(c.left, table) + self.assertEqual(c.tables_, {table}) + + def test__case_tables(self): + table = Table("a") + + c = Case().when(table.a == 1, 2 * table.a) + self.assertIsInstance(c.tables_, set) + self.assertSetEqual(c.tables_, {table}) + + def test__star_tables(self): + star = Star() + + self.assertEqual(star.tables_, set()) + + def test__table_star_tables(self): + table = Table("a") + star = Star(table=table) + + self.assertEqual(star.tables_, {table}) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/test_joins.py b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/test_joins.py new file mode 100644 index 0000000000000000000000000000000000000000..03142d583921edbe966e0ae191d254e7b8bf46ba --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/test_joins.py @@ -0,0 +1,1168 @@ +import unittest + +from pypika import ( + Field, + Interval, + JoinException, + JoinType, + MySQLQuery, + Query, + SetOperationException, + Table, + Tables, + functions as fn, + SYSTEM_TIME, +) + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + + +class SelectQueryJoinTests(unittest.TestCase): + table0, table1, hij = Tables("abc", "efg", "hij") + + def test_default_join_type(self): + query = Query.from_(self.table0).join(self.table1).on(self.table0.foo == self.table1.bar).select("*") + + self.assertEqual('SELECT * FROM "abc" JOIN "efg" ON "abc"."foo"="efg"."bar"', str(query)) + + def test_inner_join(self): + expected = 'SELECT * FROM "abc" JOIN "efg" ON "abc"."foo"="efg"."bar"' + + with self.subTest("join with enum"): + query = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.inner) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + self.assertEqual(expected, str(query)) + + with self.subTest("join function"): + query = Query.from_(self.table0).inner_join(self.table1).on(self.table0.foo == self.table1.bar).select("*") + self.assertEqual(expected, str(query)) + + def test_left_join(self): + expected = 'SELECT * FROM "abc" LEFT JOIN "efg" ON "abc"."foo"="efg"."bar"' + + with self.subTest("join with enum"): + query = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.left) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + + self.assertEqual(expected, str(query)) + + with self.subTest("join function"): + query = Query.from_(self.table0).left_join(self.table1).on(self.table0.foo == self.table1.bar).select("*") + self.assertEqual(expected, str(query)) + + def test_right_join(self): + expected = 'SELECT * FROM "abc" RIGHT JOIN "efg" ON "abc"."foo"="efg"."bar"' + + with self.subTest("join with enum"): + query = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.right) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + + self.assertEqual(expected, str(query)) + + with self.subTest("join function"): + query = Query.from_(self.table0).right_join(self.table1).on(self.table0.foo == self.table1.bar).select("*") + self.assertEqual(expected, str(query)) + + def test_hash_join(self): + expected = 'SELECT * FROM "abc" HASH JOIN "efg" ON "abc"."foo"="efg"."bar"' + + with self.subTest("join with enum"): + query = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.hash) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + + self.assertEqual(expected, str(query)) + + with self.subTest("join function"): + query = Query.from_(self.table0).hash_join(self.table1).on(self.table0.foo == self.table1.bar).select("*") + self.assertEqual(expected, str(query)) + + def test_outer_join(self): + expected = 'SELECT * FROM "abc" FULL OUTER JOIN "efg" ON "abc"."foo"="efg"."bar"' + + with self.subTest("join with enum"): + query = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.outer) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + + self.assertEqual(expected, str(query)) + + with self.subTest("join function"): + query = Query.from_(self.table0).outer_join(self.table1).on(self.table0.foo == self.table1.bar).select("*") + self.assertEqual(expected, str(query)) + + def test_cross_join(self): + expected = 'SELECT * FROM "abc" CROSS JOIN "efg" ON "abc"."foo"="efg"."bar"' + + with self.subTest("join with enum"): + query = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.cross) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + + self.assertEqual(expected, str(query)) + + with self.subTest("join function"): + query = Query.from_(self.table0).cross_join(self.table1).on(self.table0.foo == self.table1.bar).select("*") + self.assertEqual(expected, str(query)) + + def test_left_outer_join(self): + expected = 'SELECT * FROM "abc" LEFT OUTER JOIN "efg" ON "abc"."foo"="efg"."bar"' + with self.subTest("join with enum"): + query = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.left_outer) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + + self.assertEqual(expected, str(query)) + + with self.subTest("join function"): + query = ( + Query.from_(self.table0).left_outer_join(self.table1).on(self.table0.foo == self.table1.bar).select("*") + ) + + self.assertEqual(expected, str(query)) + + def test_right_outer_join(self): + expected = 'SELECT * FROM "abc" RIGHT OUTER JOIN "efg" ON "abc"."foo"="efg"."bar"' + with self.subTest("join with enum"): + query = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.right_outer) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + + self.assertEqual(expected, str(query)) + + with self.subTest("join function"): + query = ( + Query.from_(self.table0) + .right_outer_join(self.table1) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + + self.assertEqual(expected, str(query)) + + def test_full_outer_join(self): + expected = 'SELECT * FROM "abc" FULL OUTER JOIN "efg" ON "abc"."foo"="efg"."bar"' + + with self.subTest("join with enum"): + query = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.full_outer) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + + self.assertEqual(expected, str(query)) + + with self.subTest("join function"): + query = ( + Query.from_(self.table0).full_outer_join(self.table1).on(self.table0.foo == self.table1.bar).select("*") + ) + + self.assertEqual(expected, str(query)) + + def test_join_on_field_single(self): + query = Query.from_(self.table0).join(self.table1).on_field("foo").select("*") + self.assertEqual('SELECT * FROM "abc" JOIN "efg" ON "abc"."foo"="efg"."foo"', str(query)) + + def test_join_on_field_multi(self): + query = Query.from_(self.table0).join(self.table1).on_field("foo", "bar").select("*") + self.assertEqual( + 'SELECT * FROM "abc" JOIN "efg" ON "abc"."foo"="efg"."foo" ' 'AND "abc"."bar"="efg"."bar"', + str(query), + ) + + def test_join_on_field_multi_with_extra_join(self): + query = ( + Query.from_(self.table0) + .join(self.hij) + .on_field("buzz") + .join(self.table1) + .on_field("foo", "bar") + .select("*") + ) + + self.assertEqual( + 'SELECT * FROM "abc" JOIN "hij" ON "abc"."buzz"="hij"."buzz" ' + 'JOIN "efg" ON "abc"."foo"="efg"."foo" AND "abc"."bar"="efg"."bar"', + str(query), + ) + + def test_join_using_string_field_name(self): + query = Query.from_(self.table0).join(self.table1).using("id").select("*") + + self.assertEqual('SELECT * FROM "abc" JOIN "efg" USING ("id")', str(query)) + + def test_join_using_multiple_fields(self): + query = Query.from_(self.table0).join(self.table1).using("foo", "bar").select("*") + + self.assertEqual('SELECT * FROM "abc" JOIN "efg" USING ("foo","bar")', str(query)) + + def test_join_using_with_quote_char(self): + query = Query.from_(self.table0).join(self.table1).using("foo", "bar").select("*") + + self.assertEqual("SELECT * FROM abc JOIN efg USING (foo,bar)", query.get_sql(quote_char="")) + + def test_join_using_without_fields_raises_exception(self): + with self.assertRaises(JoinException): + Query.from_(self.table0).join(self.table1).using() + + def test_join_on_field_without_fields_raises_exception(self): + with self.assertRaises(JoinException): + Query.from_(self.table0).join(self.table1).on_field() + + def test_join_arithmetic_field(self): + q = ( + Query.from_(self.table0) + .join(self.table1) + .on(self.table0.dt == (self.table1.dt - Interval(weeks=1))) + .select("*") + ) + + self.assertEqual( + 'SELECT * FROM "abc" ' 'JOIN "efg" ON "abc"."dt"="efg"."dt"-INTERVAL \'1 WEEK\'', + str(q), + ) + + def test_join_with_arithmetic_function_in_select(self): + q = ( + Query.from_( + self.table0, + ) + .join(self.table1) + .on(self.table0.dt == (self.table1.dt - Interval(weeks=1))) + .select(self.table0.fiz - self.table0.buz, self.table1.star) + ) + + self.assertEqual( + 'SELECT "abc"."fiz"-"abc"."buz","efg".* FROM "abc" ' + 'JOIN "efg" ON "abc"."dt"="efg"."dt"-INTERVAL \'1 WEEK\'', + str(q), + ) + + def test_join_on_complex_criteria(self): + q = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.right) + .on((self.table0.foo == self.table1.fiz) & (self.table0.bar == self.table1.buz)) + .select("*") + ) + + self.assertEqual( + 'SELECT * FROM "abc" ' 'RIGHT JOIN "efg" ON "abc"."foo"="efg"."fiz" AND "abc"."bar"="efg"."buz"', + str(q), + ) + + def test_join_on_subquery_criteria(self): + table_a, table_b, table_c = Tables("a", "b", "c") + subquery = Query.from_(table_c).select("id").limit(1) + query = ( + Query.from_(table_a).select("*").join(table_b).on((table_a.b_id == table_b.id) & (table_b.c_id == subquery)) + ) + + self.assertEqual( + "SELECT * " 'FROM "a" ' 'JOIN "b" ON "a"."b_id"="b"."id" AND "b"."c_id"=' '(SELECT "id" FROM "c" LIMIT 1)', + str(query), + ) + + def test_use_different_table_objects_for_same_table(self): + table = Table("t") + q = Query.from_(table).select("*").where(Field("id", table=table) == 1) + + self.assertEqual('SELECT * FROM "t" WHERE "id"=1', str(q)) + + def test_join_second_table_in_from_clause(self): + table_a, table_b, table_c = Tables("a", "b", "c") + q = Query.from_(table_a).from_(table_b).select("*").join(table_c).on(table_b.c_id == table_c.id) + + self.assertEqual("SELECT * " 'FROM "a","b" ' 'JOIN "c" ON "b"."c_id"="c"."id"', str(q)) + + def test_cross_join_on_table(self): + table_a, table_b = Tables("a", "b") + q = Query.from_(table_a).join(table_b).cross().select("*") + + self.assertEqual('SELECT * FROM "a" CROSS JOIN "b"', str(q)) + + def test_cross_join_on_subquery(self): + table_a, table_b = Tables("a", "b") + q_a = Query.from_(table_a).select("*") + q_b = Query.from_(table_b).select("*").join(q_a).cross().select("*") + + self.assertEqual('SELECT * FROM "b" CROSS JOIN (SELECT * FROM "a") "sq0"', str(q_b)) + + def test_join_on_collate(self): + table_a, table_b = Tables("a", "b") + + q1 = ( + Query.from_(table_a) + .select(table_b.ouch) + .join(table_b) + .on(table_a.foo == table_b.boo, collate="utf8_general_ci") + ) + q2 = Query.from_(table_a).select(table_b.ouch).join(table_b).on(table_a.foo == table_b.boo) + + self.assertEqual( + 'SELECT "b"."ouch" FROM "a" JOIN "b" ON "a"."foo"="b"."boo" COLLATE utf8_general_ci', + str(q1), + ) + self.assertEqual('SELECT "b"."ouch" FROM "a" JOIN "b" ON "a"."foo"="b"."boo"', str(q2)) + + def test_temporal_join(self): + t0 = self.table0.for_(SYSTEM_TIME.as_of('2020-01-01')) + t1 = self.table1.for_(SYSTEM_TIME.as_of('2020-01-01')) + query = Query.from_(t0).join(t1).on(t0.foo == t1.bar).select("*") + + self.assertEqual( + 'SELECT * FROM "abc" FOR SYSTEM_TIME AS OF \'2020-01-01\' ' + 'JOIN "efg" FOR SYSTEM_TIME AS OF \'2020-01-01\' ' + 'ON "abc"."foo"="efg"."bar"', + str(query), + ) + + +class JoinBehaviorTests(unittest.TestCase): + table_abc, table_efg, table_hij, table_klm = Tables("abc", "efg", "hij", "klm") + + def test_select__ordered_select_clauses(self): + q = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .select( + self.table_abc.baz, + self.table_efg.buz, + self.table_abc.fiz, + self.table_efg.bam, + ) + ) + + self.assertEqual( + 'SELECT "abc"."baz","efg"."buz","abc"."fiz","efg"."bam" FROM "abc" ' + 'JOIN "efg" ON "abc"."foo"="efg"."bar"', + str(q), + ) + + def test_select__star_for_table(self): + q = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .join(self.table_hij) + .on(self.table_abc.buz == self.table_hij.bam) + .select(self.table_abc.star) + .select(self.table_efg.star) + .select(self.table_hij.star) + ) + + self.assertEqual( + 'SELECT "abc".*,"efg".*,"hij".* FROM "abc" ' + 'JOIN "efg" ON "abc"."foo"="efg"."bar" ' + 'JOIN "hij" ON "abc"."buz"="hij"."bam"', + str(q), + ) + + def test_select__star_for_table__replacement(self): + q = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .join(self.table_hij) + .on(self.table_abc.buz == self.table_hij.bam) + .select(self.table_abc.foo, self.table_efg.bar, self.table_hij.bam) + .select(self.table_abc.star, self.table_efg.star, self.table_hij.star) + ) + + self.assertEqual( + 'SELECT "abc".*,"efg".*,"hij".* FROM "abc" ' + 'JOIN "efg" ON "abc"."foo"="efg"."bar" ' + 'JOIN "hij" ON "abc"."buz"="hij"."bam"', + str(q), + ) + + def test_select_fields_with_where(self): + q = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .join(self.table_hij) + .on(self.table_abc.buz == self.table_hij.bam) + .select(self.table_abc.foo, self.table_efg.bar, self.table_hij.bam) + .where(self.table_abc.foo > 1) + .where(self.table_efg.bar != 2) + ) + + self.assertEqual( + 'SELECT "abc"."foo","efg"."bar","hij"."bam" FROM "abc" ' + 'JOIN "efg" ON "abc"."foo"="efg"."bar" ' + 'JOIN "hij" ON "abc"."buz"="hij"."bam" ' + 'WHERE "abc"."foo">1 AND "efg"."bar"<>2', + str(q), + ) + + def test_require_condition(self): + with self.assertRaises(JoinException): + Query.from_(self.table_abc).join(self.table_efg).on(None) + + def test_require_condition_with_both_tables(self): + with self.assertRaises(JoinException): + Query.from_(self.table_abc).join(self.table_efg).on(self.table_abc.foo == self.table_hij.bar) + + with self.assertRaises(JoinException): + Query.from_(self.table_abc).join(self.table_efg).on(self.table_hij.foo == self.table_efg.bar) + + with self.assertRaises(JoinException): + Query.from_(self.table_abc).join(self.table_efg).on(self.table_hij.foo == self.table_klm.bar) + + def test_join_same_table(self): + table1 = Table("abc") + table2 = Table("abc") + q = Query.from_(table1).join(table2).on(table1.foo == table2.bar).select(table1.foo, table2.buz) + + self.assertEqual( + 'SELECT "abc"."foo","abc2"."buz" FROM "abc" ' 'JOIN "abc" "abc2" ON "abc"."foo"="abc2"."bar"', + str(q), + ) + + def test_join_same_table_with_prefixes(self): + table1 = Table("abc").as_("x") + table2 = Table("abc").as_("y") + q = Query.from_(table1).join(table2).on(table1.foo == table2.bar).select(table1.foo, table2.buz) + + self.assertEqual( + 'SELECT "x"."foo","y"."buz" FROM "abc" "x" ' 'JOIN "abc" "y" ON "x"."foo"="y"."bar"', + str(q), + ) + + def test_join_table_twice(self): + table1, table2 = Table("efg").as_("efg1"), Table("efg").as_("efg2") + q = ( + Query.from_(self.table_abc) + .join(table1) + .on(self.table_abc.foo == table1.bar) + .join(table2) + .on(self.table_abc.foo == table2.bam) + .select(self.table_abc.foo, table1.fiz, table2.buz) + ) + + self.assertEqual( + 'SELECT "abc"."foo","efg1"."fiz","efg2"."buz" FROM "abc" ' + 'JOIN "efg" "efg1" ON "abc"."foo"="efg1"."bar" ' + 'JOIN "efg" "efg2" ON "abc"."foo"="efg2"."bam"', + str(q), + ) + + def test_select__fields_after_table_star(self): + q = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .select(self.table_abc.star, self.table_efg.bar) + .select(self.table_abc.foo) + ) + + self.assertEqual( + 'SELECT "abc".*,"efg"."bar" FROM "abc" JOIN "efg" ON "abc"."foo"="efg"."bar"', + str(q), + ) + + def test_fail_when_joining_unknown_type(self): + with self.assertRaises(ValueError): + Query.from_(self.table_abc).join("this is a string") + + def test_immutable__tables(self): + query1 = Query.from_(self.table_abc).select(self.table_abc.foo) + query2 = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .select(self.table_abc.foo, self.table_efg.buz) + ) + + self.assertEqual( + 'SELECT "abc"."foo","efg"."buz" FROM "abc" ' 'JOIN "efg" ON "abc"."foo"="efg"."bar"', + str(query2), + ) + self.assertEqual('SELECT "foo" FROM "abc"', str(query1)) + + def test_select_field_from_missing_table(self): + """ + Previously we validated the select field was a member of a table + in the query (e.g. FROM clause or a JOIN). However this made + correlated subqueries awkward to write (subqueries which refer + to their parent table. So the validation was removed. + + None of the following raise an error. Previously raised JoinException + """ + Query.from_(self.table_abc).select(self.table_efg.foo) + + Query.from_(self.table_abc).where(self.table_efg.foo == 0) + + Query.from_(self.table_abc).where(fn.Sum(self.table_efg.foo) == 0) + + Query.from_(self.table_abc).select(fn.Sum(self.table_abc.bar * 2) + fn.Sum(self.table_efg.foo * 2)) + + Query.from_(self.table_abc).groupby(self.table_efg.foo) + + Query.from_(self.table_abc).groupby(self.table_abc.foo).having(self.table_efg.bar) + + subquery = ( + Query.from_(self.table_efg).select(self.table_efg.id).where(self.table_efg.abc_id == self.table_abc.id) + ) + query = Query.from_(self.table_abc).select(subquery.as_("efg_id").limit(1)) + self.assertEqual( + 'SELECT (SELECT "efg"."id" FROM "efg" WHERE "efg"."abc_id"="abc"."id" LIMIT 1) "efg_id" FROM "abc"', + str(query), + ) + + def test_ignore_table_references(self): + query = Query.from_(Table("abc")).select(Table("abc").foo) + + self.assertEqual('SELECT "foo" FROM "abc"', str(query)) + + def test_prefixes_added_to_groupby(self): + test_query = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .select(self.table_abc.foo, fn.Sum(self.table_efg.buz)) + .groupby(self.table_abc.foo) + ) + + self.assertEqual( + 'SELECT "abc"."foo",SUM("efg"."buz") FROM "abc" ' + 'JOIN "efg" ON "abc"."foo"="efg"."bar" ' + 'GROUP BY "abc"."foo"', + str(test_query), + ) + + def test_prefixes_added_to_orderby(self): + test_query = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .select(self.table_abc.foo, self.table_efg.buz) + .orderby(self.table_abc.foo) + ) + + self.assertEqual( + 'SELECT "abc"."foo","efg"."buz" FROM "abc" ' + 'JOIN "efg" ON "abc"."foo"="efg"."bar" ' + 'ORDER BY "abc"."foo"', + str(test_query), + ) + + def test_prefixes_added_to_function_in_orderby(self): + test_query = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .select(self.table_abc.foo, self.table_efg.buz) + .orderby(fn.Date(self.table_abc.foo)) + ) + + self.assertEqual( + 'SELECT "abc"."foo","efg"."buz" FROM "abc" ' + 'JOIN "efg" ON "abc"."foo"="efg"."bar" ' + 'ORDER BY DATE("abc"."foo")', + str(test_query), + ) + + def test_join_from_join(self): + test_query = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.efg_id == self.table_efg.id) + .join(self.table_hij) + .on(self.table_efg.hij_id == self.table_hij.id) + .select(self.table_abc.foo, self.table_efg.bar, self.table_hij.fizz) + ) + + self.assertEqual( + 'SELECT "abc"."foo","efg"."bar","hij"."fizz" FROM "abc" ' + 'JOIN "efg" ON "abc"."efg_id"="efg"."id" ' + 'JOIN "hij" ON "efg"."hij_id"="hij"."id"', + str(test_query), + ) + + def test_join_query_without_alias(self): + subquery = Query.from_(self.table_efg).select( + self.table_efg.base_id.as_("x"), self.table_efg.fizz, self.table_efg.buzz + ) + + test_query = ( + Query.from_(self.table_abc) + .join(subquery) + .on(subquery.x == self.table_abc.id) + .select(self.table_abc.foo, subquery.fizz, subquery.buzz) + ) + + self.assertEqual( + 'SELECT "abc"."foo","sq0"."fizz","sq0"."buzz" ' + 'FROM "abc" JOIN (' + 'SELECT "base_id" "x","fizz","buzz" FROM "efg"' + ') "sq0" ' + 'ON "sq0"."x"="abc"."id"', + str(test_query), + ) + + def test_join_query_with_column_alias(self): + subquery = ( + Query.from_(self.table_efg) + .select( + self.table_efg.base_id.as_("x"), + self.table_efg.fizz, + self.table_efg.buzz, + ) + .as_("subq") + ) + + test_query = ( + Query.from_(self.table_abc) + .join(subquery) + .on(subquery.x == self.table_abc.id) + .select(self.table_abc.foo, subquery.fizz, subquery.buzz) + ) + + self.assertEqual( + 'SELECT "abc"."foo","subq"."fizz","subq"."buzz" ' + 'FROM "abc" JOIN (' + 'SELECT "base_id" "x","fizz","buzz" FROM "efg"' + ') "subq" ' + 'ON "subq"."x"="abc"."id"', + str(test_query), + ) + + def test_join_query_with_table_alias(self): + xxx = self.table_efg.as_("xxx") + subquery = Query.from_(xxx).select(xxx.base_id, xxx.fizz, xxx.buzz).as_("subq") + + test_query = ( + Query.from_(self.table_abc) + .join(subquery) + .on(subquery.x == self.table_abc.id) + .select(self.table_abc.foo, subquery.fizz, subquery.buzz) + ) + + self.assertEqual( + 'SELECT "abc"."foo","subq"."fizz","subq"."buzz" ' + 'FROM "abc" JOIN (' + 'SELECT "xxx"."base_id","xxx"."fizz","xxx"."buzz" FROM "efg" "xxx"' + ') "subq" ' + 'ON "subq"."x"="abc"."id"', + str(test_query), + ) + + def test_join_query_with_setoperation(self): + subquery = Query.from_(self.table_abc).select("*").union(Query.from_(self.table_abc).select("*")).as_("subq") + + test_query = ( + Query.from_(self.table_abc).join(subquery).on(subquery.x == self.table_abc.id).select(self.table_abc.foo) + ) + + self.assertEqual( + 'SELECT "abc"."foo" FROM "abc" ' + 'JOIN ' + '((SELECT * FROM "abc") ' + 'UNION ' + '(SELECT * FROM "abc")) "subq" ' + 'ON "subq"."x"="abc"."id"', + str(test_query), + ) + + +class UnionTests(unittest.TestCase): + table1, table2 = Tables("abc", "efg") + + def test_union(self): + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + + self.assertEqual( + '(SELECT "foo" FROM "abc") UNION (SELECT "bar" FROM "efg")', + str(query1 + query2), + ) + self.assertEqual( + '(SELECT "foo" FROM "abc") UNION (SELECT "bar" FROM "efg")', + str(query1.union(query2)), + ) + + def test_union_multiple(self): + table3, table4 = Tables("hij", "lmn") + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + query3 = Query.from_(table3).select(table3.baz) + query4 = Query.from_(table4).select(table4.faz) + + self.assertEqual( + '(SELECT "foo" FROM "abc") UNION ' + '(SELECT "bar" FROM "efg") UNION ' + '(SELECT "baz" FROM "hij") UNION ' + '(SELECT "faz" FROM "lmn")', + str(query1 + query2 + query3 + query4), + ) + self.assertEqual( + '(SELECT "foo" FROM "abc") UNION ' + '(SELECT "bar" FROM "efg") UNION ' + '(SELECT "baz" FROM "hij") UNION ' + '(SELECT "faz" FROM "lmn")', + str(query1.union(query2).union(query3).union(query4)), + ) + + def test_union_all(self): + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + + self.assertEqual( + '(SELECT "foo" FROM "abc") UNION ALL (SELECT "bar" FROM "efg")', + str(query1 * query2), + ) + self.assertEqual( + '(SELECT "foo" FROM "abc") UNION ALL (SELECT "bar" FROM "efg")', + str(query1.union_all(query2)), + ) + + def test_union_all_multiple(self): + table3, table4 = Tables("hij", "lmn") + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + query3 = Query.from_(table3).select(table3.baz) + query4 = Query.from_(table4).select(table4.faz) + + self.assertEqual( + '(SELECT "foo" FROM "abc") UNION ALL ' + '(SELECT "bar" FROM "efg") UNION ALL ' + '(SELECT "baz" FROM "hij") UNION ALL ' + '(SELECT "faz" FROM "lmn")', + str(query1 * query2 * query3 * query4), + ) + self.assertEqual( + '(SELECT "foo" FROM "abc") UNION ALL ' + '(SELECT "bar" FROM "efg") UNION ALL ' + '(SELECT "baz" FROM "hij") UNION ALL ' + '(SELECT "faz" FROM "lmn")', + str(query1.union_all(query2).union_all(query3).union_all(query4)), + ) + + def test_union_with_order_by(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + union_query = str((query1 + query2).orderby(query1.field("a"))) + union_all_query = str((query1 * query2).orderby(query1.field("a"))) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "UNION " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "a"', + union_query, + ) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "UNION ALL " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "a"', + union_all_query, + ) + + def test_union_with_order_by_use_union_query_field(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + union_query = query1 + query2 + union_query = str(union_query.orderby(union_query.field("a"))) + union_all_query = query1 * query2 + union_all_query = str(union_all_query.orderby(union_all_query.field("a"))) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "UNION " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "a"', + union_query, + ) + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "UNION ALL " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "a"', + union_all_query, + ) + + def test_union_with_order_by_with_aliases(self): + query1 = Query.from_(self.table1.as_("a")).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2.as_("b")).select(self.table2.bar.as_("a")) + + union_all_query = str((query1 * query2).orderby(query1.field("a"))) + union_query = str((query1 + query2).orderby(query1.field("a"))) + self.assertEqual( + '(SELECT "foo" "a" FROM "abc" "a")' " UNION ALL " '(SELECT "bar" "a" FROM "efg" "b")' ' ORDER BY "a"', + union_all_query, + ) + self.assertEqual( + '(SELECT "foo" "a" FROM "abc" "a")' " UNION " '(SELECT "bar" "a" FROM "efg" "b")' ' ORDER BY "a"', + union_query, + ) + + def test_union_with_order_by_use_union_query_field_with_aliases(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + union_query = (query1 + query2).as_("x") + union_query = union_query.orderby(union_query.field("a")) + union_all_query = (query1 * query2).as_("x") + union_all_query = union_all_query.orderby(union_all_query.field("a")) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "UNION " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "x"."a"', + str(union_query), + ) + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "UNION ALL " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "x"."a"', + str(union_all_query), + ) + + def test_require_equal_number_of_fields(self): + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.fiz, self.table2.buz) + + with self.assertRaises(SetOperationException): + str(query1 + query2) + + def test_mysql_query_wraps_unioned_queries(self): + query1 = MySQLQuery.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + + self.assertEqual( + "(SELECT `foo` FROM `abc`) UNION (SELECT `bar` FROM `efg`)", + str(query1 + query2), + ) + + def test_union_as_subquery(self): + abc, efg = Tables("abc", "efg") + hij = Query.from_(abc).select(abc.t).union(Query.from_(efg).select(efg.t)) + q = Query.from_(hij).select(fn.Avg(hij.t)) + + self.assertEqual( + 'SELECT AVG("sq0"."t") FROM ((SELECT "t" FROM "abc") UNION (SELECT "t" FROM "efg")) "sq0"', + str(q), + ) + + def test_union_with_no_quote_char(self): + abc, efg = Tables("abc", "efg") + hij = Query.from_(abc).select(abc.t).union(Query.from_(efg).select(efg.t)) + q = Query.from_(hij).select(fn.Avg(hij.t)) + + self.assertEqual( + "SELECT AVG(sq0.t) FROM ((SELECT t FROM abc) UNION (SELECT t FROM efg)) sq0", + q.get_sql(quote_char=None), + ) + + +class InsertQueryJoinTests(unittest.TestCase): + def test_join_table_on_insert_query(self): + a, b, c = Tables("a", "b", "c") + q = Query.into(c).from_(a).join(b).on(a.fkey_id == b.id).where(b.foo == 1).select("a.*", "b.*") + + self.assertEqual( + 'INSERT INTO "c" ' + 'SELECT "a"."a.*","a"."b.*" ' + 'FROM "a" JOIN "b" ' + 'ON "a"."fkey_id"="b"."id" ' + 'WHERE "b"."foo"=1', + str(q), + ) + + +class UpdateQueryJoinTests(unittest.TestCase): + def test_join_table_on_update_query(self): + a, b = Tables("a", "b") + q = Query.update(a).join(b).on(a.fkey_id == b.id).where(b.foo == 1).set("adwords_batch_job_id", 1) + + self.assertEqual( + 'UPDATE "a" ' 'JOIN "b" ' 'ON "a"."fkey_id"="b"."id" ' 'SET "adwords_batch_job_id"=1 ' 'WHERE "b"."foo"=1', + str(q), + ) + + +class IntersectTests(unittest.TestCase): + table1, table2 = Tables("abc", "efg") + + def test_intersect(self): + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + + self.assertEqual( + '(SELECT "foo" FROM "abc") INTERSECT (SELECT "bar" FROM "efg")', + str(query1.intersect(query2)), + ) + + def test_intersect_multiple(self): + table3, table4 = Tables("hij", "lmn") + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + query3 = Query.from_(table3).select(table3.baz) + query4 = Query.from_(table4).select(table4.faz) + + self.assertEqual( + '(SELECT "foo" FROM "abc") INTERSECT ' + '(SELECT "bar" FROM "efg") INTERSECT ' + '(SELECT "baz" FROM "hij") INTERSECT ' + '(SELECT "faz" FROM "lmn")', + str(query1.intersect(query2).intersect(query3).intersect(query4)), + ) + + def test_intersect_with_order_by(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + intersect_query = str((query1.intersect(query2)).orderby(query1.field("a"))) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "INTERSECT " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "a"', + intersect_query, + ) + + def test_intersect_with_limit(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + intersect_query = str((query1.intersect(query2)).limit(10)) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "INTERSECT " '(SELECT "bar" "a" FROM "efg") ' 'LIMIT 10', + intersect_query, + ) + + def test_intersect_with_offset(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + intersect_query = str((query1.intersect(query2)).offset(10)) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "INTERSECT " '(SELECT "bar" "a" FROM "efg") ' 'OFFSET 10', + intersect_query, + ) + + def test_require_equal_number_of_fields_intersect(self): + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.fiz, self.table2.buz) + + with self.assertRaises(SetOperationException): + str(query1.intersect(query2)) + + def test_mysql_query_wraps_intersected_queries(self): + query1 = MySQLQuery.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + + self.assertEqual( + "(SELECT `foo` FROM `abc`) INTERSECT (SELECT `bar` FROM `efg`)", + str(query1.intersect(query2)), + ) + + def test_intersect_as_subquery(self): + abc, efg = Tables("abc", "efg") + hij = Query.from_(abc).select(abc.t).intersect(Query.from_(efg).select(efg.t)) + q = Query.from_(hij).select(fn.Avg(hij.t)) + + self.assertEqual( + 'SELECT AVG("sq0"."t") FROM ((SELECT "t" FROM "abc") INTERSECT (SELECT "t" FROM "efg")) "sq0"', + str(q), + ) + + def test_intersect_with_no_quote_char(self): + abc, efg = Tables("abc", "efg") + hij = Query.from_(abc).select(abc.t).intersect(Query.from_(efg).select(efg.t)) + q = Query.from_(hij).select(fn.Avg(hij.t)) + + self.assertEqual( + "SELECT AVG(sq0.t) FROM ((SELECT t FROM abc) INTERSECT (SELECT t FROM efg)) sq0", + q.get_sql(quote_char=None), + ) + + +class MinusTests(unittest.TestCase): + table1, table2 = Tables("abc", "efg") + + def test_minus(self): + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + + self.assertEqual('(SELECT "foo" FROM "abc") MINUS (SELECT "bar" FROM "efg")', str(query1.minus(query2))) + + self.assertEqual( + '(SELECT "foo" FROM "abc") MINUS (SELECT "bar" FROM "efg")', + str(query1 - query2), + ) + + def test_minus_multiple(self): + table3, table4 = Tables("hij", "lmn") + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + query3 = Query.from_(table3).select(table3.baz) + query4 = Query.from_(table4).select(table4.faz) + + self.assertEqual( + '(SELECT "foo" FROM "abc") MINUS ' + '(SELECT "bar" FROM "efg") MINUS ' + '(SELECT "baz" FROM "hij") MINUS ' + '(SELECT "faz" FROM "lmn")', + str(query1 - query2 - query3 - query4), + ) + + self.assertEqual( + '(SELECT "foo" FROM "abc") MINUS ' + '(SELECT "bar" FROM "efg") MINUS ' + '(SELECT "baz" FROM "hij") MINUS ' + '(SELECT "faz" FROM "lmn")', + str(query1.minus(query2).minus(query3).minus(query4)), + ) + + def test_minus_with_order_by(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + minus_query = str(query1.minus(query2).orderby(query1.field("a"))) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "MINUS " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "a"', minus_query + ) + + def test_minus_query_with_order_by_use_minus_query_field(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + minus_query = query1.minus(query2) + minus_query = str(minus_query.orderby(minus_query.field("b"))) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "MINUS " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "b"', + minus_query, + ) + + def test_require_equal_number_of_fields(self): + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.fiz, self.table2.buz) + + with self.assertRaises(SetOperationException): + str(query1.minus(query2)) + + def test_mysql_query_wraps_minus_queries(self): + query1 = MySQLQuery.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + + self.assertEqual( + "(SELECT `foo` FROM `abc`) MINUS (SELECT `bar` FROM `efg`)", + str(query1 - query2), + ) + + def test_minus_as_subquery(self): + abc, efg = Tables("abc", "efg") + hij = Query.from_(abc).select(abc.t).minus(Query.from_(efg).select(efg.t)) + q = Query.from_(hij).select(fn.Avg(hij.t)) + + self.assertEqual( + 'SELECT AVG("sq0"."t") FROM ((SELECT "t" FROM "abc") MINUS (SELECT "t" FROM "efg")) "sq0"', + str(q), + ) + + def test_minus_with_no_quote_char(self): + abc, efg = Tables("abc", "efg") + hij = Query.from_(abc).select(abc.t).minus(Query.from_(efg).select(efg.t)) + q = Query.from_(hij).select(fn.Avg(hij.t)) + + self.assertEqual( + "SELECT AVG(sq0.t) FROM ((SELECT t FROM abc) MINUS (SELECT t FROM efg)) sq0", + q.get_sql(quote_char=None), + ) + + +class ExceptOfTests(unittest.TestCase): + table1, table2 = Tables("abc", "efg") + + def test_except(self): + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + + self.assertEqual('(SELECT "foo" FROM "abc") EXCEPT (SELECT "bar" FROM "efg")', str(query1.except_of(query2))) + + def test_except_multiple(self): + table3, table4 = Tables("hij", "lmn") + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + query3 = Query.from_(table3).select(table3.baz) + query4 = Query.from_(table4).select(table4.faz) + + self.assertEqual( + '(SELECT "foo" FROM "abc") EXCEPT ' + '(SELECT "bar" FROM "efg") EXCEPT ' + '(SELECT "baz" FROM "hij") EXCEPT ' + '(SELECT "faz" FROM "lmn")', + str(query1.except_of(query2).except_of(query3).except_of(query4)), + ) + + def test_except_with_order_by(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + except_query = str(query1.except_of(query2).orderby(query1.field("a"))) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "EXCEPT " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "a"', except_query + ) + + def test_except_query_with_order_by_use_minus_query_field(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + except_query = query1.except_of(query2) + except_query = str(except_query.orderby(except_query.field("b"))) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "EXCEPT " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "b"', + except_query, + ) + + def test_require_equal_number_of_fields_except_of(self): + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.fiz, self.table2.buz) + + with self.assertRaises(SetOperationException): + str(query1.except_of(query2)) + + def test_except_as_subquery(self): + abc, efg = Tables("abc", "efg") + hij = Query.from_(abc).select(abc.t).except_of(Query.from_(efg).select(efg.t)) + q = Query.from_(hij).select(fn.Avg(hij.t)) + + self.assertEqual( + 'SELECT AVG("sq0"."t") FROM ((SELECT "t" FROM "abc") EXCEPT (SELECT "t" FROM "efg")) "sq0"', + str(q), + ) + + def test_except_with_no_quote_char(self): + abc, efg = Tables("abc", "efg") + hij = Query.from_(abc).select(abc.t).except_of(Query.from_(efg).select(efg.t)) + q = Query.from_(hij).select(fn.Avg(hij.t)) + + self.assertEqual( + "SELECT AVG(sq0.t) FROM ((SELECT t FROM abc) EXCEPT (SELECT t FROM efg)) sq0", + q.get_sql(quote_char=None), + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/test_negation.py b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/test_negation.py new file mode 100644 index 0000000000000000000000000000000000000000..9f4db83b560dbc8546ce6d384b781dfccefd319d --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/test_negation.py @@ -0,0 +1,31 @@ +import unittest + +from pypika import ( + Tables, + functions as fn, +) +from pypika.terms import ValueWrapper + + +class NegationTests(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_negate_wrapped_float(self): + q = -ValueWrapper(1.0) + + self.assertEqual("-1.0", q.get_sql()) + + def test_negate_wrapped_int(self): + q = -ValueWrapper(1) + + self.assertEqual("-1", q.get_sql()) + + def test_negate_field(self): + q = -self.table_abc.foo + + self.assertEqual('-"abc"."foo"', q.get_sql(with_namespace=True, quote_char='"')) + + def test_negate_function(self): + q = -fn.Sum(self.table_abc.foo) + + self.assertEqual('-SUM("abc"."foo")', q.get_sql(with_namespace=True, quote_char='"')) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/test_parameter.py b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/test_parameter.py new file mode 100644 index 0000000000000000000000000000000000000000..c11e9afcd9624abb0a7313306eda34ebcf4c99ba --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/test_parameter.py @@ -0,0 +1,206 @@ +import unittest +from datetime import date + +from pypika import ( + FormatParameter, + NamedParameter, + NumericParameter, + Parameter, + PyformatParameter, + QmarkParameter, + Query, + Tables, +) +from pypika.terms import ListParameter, ParameterValueWrapper + + +class ParametrizedTests(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_param_insert(self): + q = Query.into(self.table_abc).columns("a", "b", "c").insert(Parameter("?"), Parameter("?"), Parameter("?")) + + self.assertEqual('INSERT INTO "abc" ("a","b","c") VALUES (?,?,?)', q.get_sql()) + + def test_param_select_join(self): + q = ( + Query.from_(self.table_abc) + .select("*") + .where(self.table_abc.category == Parameter("%s")) + .join(self.table_efg) + .on(self.table_abc.id == self.table_efg.abc_id) + .where(self.table_efg.date >= Parameter("%s")) + .limit(10) + ) + + self.assertEqual( + 'SELECT * FROM "abc" JOIN "efg" ON "abc"."id"="efg"."abc_id" WHERE "abc"."category"=%s AND "efg"."date">=%s LIMIT 10', + q.get_sql(), + ) + + def test_param_select_subquery(self): + q = ( + Query.from_(self.table_abc) + .select("*") + .where(self.table_abc.category == Parameter("&1")) + .where( + self.table_abc.id.isin( + Query.from_(self.table_efg) + .select(self.table_efg.abc_id) + .where(self.table_efg.date >= Parameter("&2")) + ) + ) + .limit(10) + ) + + self.assertEqual( + 'SELECT * FROM "abc" WHERE "category"=&1 AND "id" IN (SELECT "abc_id" FROM "efg" WHERE "date">=&2) LIMIT 10', + q.get_sql(), + ) + + def test_join(self): + subquery = ( + Query.from_(self.table_efg) + .select(self.table_efg.fiz, self.table_efg.buz) + .where(self.table_efg.buz == Parameter(":buz")) + ) + + q = ( + Query.from_(self.table_abc) + .join(subquery) + .on(self.table_abc.bar == subquery.buz) + .select(self.table_abc.foo, subquery.fiz) + .where(self.table_abc.bar == Parameter(":bar")) + ) + + self.assertEqual( + 'SELECT "abc"."foo","sq0"."fiz" FROM "abc" JOIN (SELECT "fiz","buz" FROM "efg" WHERE "buz"=:buz)' + ' "sq0" ON "abc"."bar"="sq0"."buz" WHERE "abc"."bar"=:bar', + q.get_sql(), + ) + + def test_qmark_parameter(self): + self.assertEqual('?', QmarkParameter().get_sql()) + + def test_numeric_parameter(self): + self.assertEqual(':14', NumericParameter('14').get_sql()) + self.assertEqual(':15', NumericParameter(15).get_sql()) + + def test_named_parameter(self): + self.assertEqual(':buz', NamedParameter('buz').get_sql()) + + def test_format_parameter(self): + self.assertEqual('%s', FormatParameter().get_sql()) + + def test_pyformat_parameter(self): + self.assertEqual('%(buz)s', PyformatParameter('buz').get_sql()) + + +class ParametrizedTestsWithValues(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_param_insert(self): + q = Query.into(self.table_abc).columns("a", "b", "c").insert(1, 2.2, 'foo') + + parameter = QmarkParameter() + sql = q.get_sql(parameter=parameter) + self.assertEqual('INSERT INTO "abc" ("a","b","c") VALUES (?,?,?)', sql) + self.assertEqual([1, 2.2, 'foo'], parameter.get_parameters()) + + def test_param_select_join(self): + q = ( + Query.from_(self.table_abc) + .select("*") + .where(self.table_abc.category == 'foobar') + .join(self.table_efg) + .on(self.table_abc.id == self.table_efg.abc_id) + .where(self.table_efg.date >= date(2024, 2, 22)) + .limit(10) + ) + + parameter = FormatParameter() + sql = q.get_sql(parameter=parameter) + self.assertEqual( + 'SELECT * FROM "abc" JOIN "efg" ON "abc"."id"="efg"."abc_id" WHERE "abc"."category"=%s AND "efg"."date">=%s LIMIT 10', + sql, + ) + self.assertEqual(['foobar', '2024-02-22'], parameter.get_parameters()) + + def test_param_select_subquery(self): + q = ( + Query.from_(self.table_abc) + .select("*") + .where(self.table_abc.category == 'foobar') + .where( + self.table_abc.id.isin( + Query.from_(self.table_efg) + .select(self.table_efg.abc_id) + .where(self.table_efg.date >= date(2024, 2, 22)) + ) + ) + .limit(10) + ) + + parameter = ListParameter(placeholder=lambda idx: f'&{idx+1}') + sql = q.get_sql(parameter=parameter) + self.assertEqual( + 'SELECT * FROM "abc" WHERE "category"=&1 AND "id" IN (SELECT "abc_id" FROM "efg" WHERE "date">=&2) LIMIT 10', + sql, + ) + self.assertEqual(['foobar', '2024-02-22'], parameter.get_parameters()) + + def test_join(self): + subquery = ( + Query.from_(self.table_efg) + .select(self.table_efg.fiz, self.table_efg.buz) + .where(self.table_efg.buz == 'buz') + ) + + q = ( + Query.from_(self.table_abc) + .join(subquery) + .on(self.table_abc.bar == subquery.buz) + .select(self.table_abc.foo, subquery.fiz) + .where(self.table_abc.bar == 'bar') + ) + + parameter = NamedParameter() + sql = q.get_sql(parameter=parameter) + self.assertEqual( + 'SELECT "abc"."foo","sq0"."fiz" FROM "abc" JOIN (SELECT "fiz","buz" FROM "efg" WHERE "buz"=:param1)' + ' "sq0" ON "abc"."bar"="sq0"."buz" WHERE "abc"."bar"=:param2', + sql, + ) + self.assertEqual({'param1': 'buz', 'param2': 'bar'}, parameter.get_parameters()) + + def test_join_with_parameter_value_wrapper(self): + subquery = ( + Query.from_(self.table_efg) + .select(self.table_efg.fiz, self.table_efg.buz) + .where(self.table_efg.buz == ParameterValueWrapper(Parameter(':buz'), 'buz')) + ) + + q = ( + Query.from_(self.table_abc) + .join(subquery) + .on(self.table_abc.bar == subquery.buz) + .select(self.table_abc.foo, subquery.fiz) + .where(self.table_abc.bar == ParameterValueWrapper(NamedParameter('bar'), 'bar')) + ) + + parameter = NamedParameter() + sql = q.get_sql(parameter=parameter) + self.assertEqual( + 'SELECT "abc"."foo","sq0"."fiz" FROM "abc" JOIN (SELECT "fiz","buz" FROM "efg" WHERE "buz"=:buz)' + ' "sq0" ON "abc"."bar"="sq0"."buz" WHERE "abc"."bar"=:bar', + sql, + ) + self.assertEqual({':buz': 'buz', 'bar': 'bar'}, parameter.get_parameters()) + + def test_pyformat_parameter(self): + q = Query.into(self.table_abc).columns("a", "b", "c").insert(1, 2.2, 'foo') + + parameter = PyformatParameter() + sql = q.get_sql(parameter=parameter) + self.assertEqual('INSERT INTO "abc" ("a","b","c") VALUES (%(param1)s,%(param2)s,%(param3)s)', sql) + self.assertEqual({"param1": 1, "param2": 2.2, "param3": "foo"}, parameter.get_parameters()) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/test_pseudocolumns.py b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/test_pseudocolumns.py new file mode 100644 index 0000000000000000000000000000000000000000..6a25c70269b2ccc98ac3870ac64a43c8a32ddbe9 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/test_pseudocolumns.py @@ -0,0 +1,51 @@ +import unittest + +from pypika import Query, Table +from pypika.pseudocolumns import ( + ColumnValue, + ObjectID, + ObjectValue, + RowID, + RowNum, + SysDate, +) +from pypika.terms import PseudoColumn + + +class PseudoColumnsTest(unittest.TestCase): + @classmethod + def setUpClass(cls): + super(PseudoColumnsTest, cls).setUpClass() + cls.table1 = Table("table1") + + def test_column_value(self): + self.assertEqual("COLUMN_VALUE", ColumnValue) + + def test_object_id(self): + self.assertEqual("OBJECT_ID", ObjectID) + + def test_object_value(self): + self.assertEqual("OBJECT_VALUE", ObjectValue) + + def test_row_id(self): + self.assertEqual("ROWID", RowID) + + def test_row_num(self): + self.assertEqual("ROWNUM", RowNum) + + def test_sys_date(self): + self.assertEqual("SYSDATE", SysDate) + + def test_can_be_used_in_a_select_statement(self): + query = Query.from_(self.table1).where(self.table1.is_active == 1).select(PseudoColumn("abcde")) + + self.assertEqual(str(query), 'SELECT abcde FROM "table1" WHERE "is_active"=1') + + def test_can_be_used_in_a_where_clause(self): + query = Query.from_(self.table1).where(PseudoColumn("abcde") > 1).select(self.table1.is_active) + + self.assertEqual(str(query), 'SELECT "is_active" FROM "table1" WHERE abcde>1') + + def test_can_be_used_in_orderby(self): + query = Query.from_(self.table1).select(self.table1.abcde.as_("some_name")).orderby(PseudoColumn("some_name")) + self.assertEqual(str(query), 'SELECT "abcde" "some_name" FROM "table1" ORDER BY some_name') diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/test_query.py b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/test_query.py new file mode 100644 index 0000000000000000000000000000000000000000..ae8dc01599a6a562b591ce15391bfe9b5c87e0f9 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/test_query.py @@ -0,0 +1,242 @@ +import unittest + +from pypika import Case, Query, Tables, Tuple, functions, Field +from pypika.dialects import ( + ClickHouseQuery, + ClickHouseQueryBuilder, + MSSQLQuery, + MSSQLQueryBuilder, + MySQLLoadQueryBuilder, + MySQLQuery, + MySQLQueryBuilder, + OracleQuery, + OracleQueryBuilder, + PostgreSQLQuery, + PostgreSQLQueryBuilder, + RedShiftQueryBuilder, + RedshiftQuery, + SQLLiteQuery, + SQLLiteQueryBuilder, + SnowflakeQuery, + SnowflakeQueryBuilder, + VerticaCopyQueryBuilder, + VerticaCreateQueryBuilder, + VerticaQuery, + VerticaQueryBuilder, +) +from pypika.queries import CreateQueryBuilder, DropQueryBuilder, QueryBuilder + + +class QueryTablesTests(unittest.TestCase): + table_a, table_b, table_c, table_d = Tables("a", "b", "c", "d") + + def test_replace_table(self): + query = Query.from_(self.table_a).select(self.table_a.time) + query = query.replace_table(self.table_a, self.table_b) + + self.assertEqual('SELECT "time" FROM "b"', str(query)) + + def test_replace_only_specified_table(self): + query = Query.from_(self.table_a).select(self.table_a.time) + query = query.replace_table(self.table_b, self.table_c) + + self.assertEqual('SELECT "time" FROM "a"', str(query)) + + def test_replace_insert_table(self): + query = Query.into(self.table_a).insert(1) + query = query.replace_table(self.table_a, self.table_b) + + self.assertEqual('INSERT INTO "b" VALUES (1)', str(query)) + + def test_replace_insert_table_current_table_not_match(self): + query = Query.into(self.table_a).insert(1) + query = query.replace_table(self.table_c, self.table_b) + + self.assertEqual('INSERT INTO "a" VALUES (1)', str(query)) + + def test_replace_update_table(self): + query = Query.update(self.table_a).set("foo", "bar") + query = query.replace_table(self.table_a, self.table_b) + + self.assertEqual('UPDATE "b" SET "foo"=\'bar\'', str(query)) + + def test_replace_update_table_current_table_not_match(self): + query = Query.update(self.table_a).set("foo", "bar") + query = query.replace_table(self.table_c, self.table_b) + + self.assertEqual('UPDATE "a" SET "foo"=\'bar\'', str(query)) + + def test_replace_delete_table(self): + query = Query.from_(self.table_a).delete() + query = query.replace_table(self.table_a, self.table_b) + + self.assertEqual('DELETE FROM "b"', str(query)) + + def test_replace_join_tables(self): + query = ( + Query.from_(self.table_a) + .join(self.table_b) + .on(self.table_a.customer_id == self.table_b.id) + .join(self.table_c) + .on(self.table_b.seller_id == self.table_c.id) + .select(self.table_a.star) + ) + query = query.replace_table(self.table_a, self.table_d) + + self.assertEqual( + 'SELECT "d".* ' + 'FROM "d" ' + 'JOIN "b" ON "d"."customer_id"="b"."id" ' + 'JOIN "c" ON "b"."seller_id"="c"."id"', + str(query), + ) + + def test_replace_filter_tables(self): + query = Query.from_(self.table_a).select(self.table_a.name).where(self.table_a.name == "Mustermann") + query = query.replace_table(self.table_a, self.table_b) + + self.assertEqual('SELECT "name" FROM "b" WHERE "name"=\'Mustermann\'', str(query)) + + def test_replace_having_table(self): + query = ( + Query.from_(self.table_a) + .select(functions.Sum(self.table_a.revenue)) + .groupby(self.table_a.customer) + .having(functions.Sum(self.table_a.revenue) >= 1000) + ) + query = query.replace_table(self.table_a, self.table_b) + + self.assertEqual( + 'SELECT SUM("revenue") ' 'FROM "b" ' 'GROUP BY "customer" ' 'HAVING SUM("revenue")>=1000', + str(query), + ) + + def test_replace_case_table(self): + query = Query.from_(self.table_a).select( + Case() + .when(self.table_a.fname == "Tom", "It was Tom") + .when(self.table_a.fname == "John", "It was John") + .else_("It was someone else.") + .as_("who_was_it") + ) + query = query.replace_table(self.table_a, self.table_b) + + self.assertEqual( + "SELECT CASE " + "WHEN \"fname\"='Tom' THEN 'It was Tom' " + "WHEN \"fname\"='John' THEN 'It was John' " + "ELSE 'It was someone else.' END \"who_was_it\" " + 'FROM "b"', + str(query), + ) + + def test_replace_orderby_table(self): + query = Query.from_(self.table_a).select(self.table_a.customer).orderby(self.table_a.customer) + query = query.replace_table(self.table_a, self.table_b) + + self.assertEqual('SELECT "customer" FROM "b" ORDER BY "customer"', str(query)) + + def test_replace_tuple_table(self): + query = ( + Query.from_(self.table_a) + .select(self.table_a.cost, self.table_a.revenue) + .where((self.table_a.cost, self.table_a.revenue) == Tuple(1, 2)) + ) + + query = query.replace_table(self.table_a, self.table_b) + + # Order is reversed due to lack of right equals method + self.assertEqual( + 'SELECT "cost","revenue" FROM "b" WHERE (1,2)=("cost","revenue")', + str(query), + ) + + def test_is_joined(self): + q = Query.from_(self.table_a).join(self.table_b).on(self.table_a.foo == self.table_b.boo) + + self.assertTrue(q.is_joined(self.table_b)) + self.assertFalse(q.is_joined(self.table_c)) + + +class QueryBuilderTests(unittest.TestCase): + def test_query_builders_have_reference_to_correct_query_class(self): + with self.subTest('QueryBuilder'): + self.assertEqual(Query, QueryBuilder.QUERY_CLS) + + with self.subTest('DropQueryBuilder'): + self.assertEqual(Query, DropQueryBuilder.QUERY_CLS) + + with self.subTest('CreateQueryBuilder'): + self.assertEqual(Query, CreateQueryBuilder.QUERY_CLS) + + with self.subTest('MySQLQueryBuilder'): + self.assertEqual(MySQLQuery, MySQLQueryBuilder.QUERY_CLS) + + with self.subTest('MySQLLoadQueryBuilder'): + self.assertEqual(MySQLQuery, MySQLLoadQueryBuilder.QUERY_CLS) + + with self.subTest('VerticaQueryBuilder'): + self.assertEqual(VerticaQuery, VerticaQueryBuilder.QUERY_CLS) + + with self.subTest('VerticaCreateQueryBuilder'): + self.assertEqual(VerticaQuery, VerticaCreateQueryBuilder.QUERY_CLS) + + with self.subTest('VerticaCopyQueryBuilder'): + self.assertEqual(VerticaQuery, VerticaCopyQueryBuilder.QUERY_CLS) + + with self.subTest('PostgreSQLQueryBuilder'): + self.assertEqual(PostgreSQLQuery, PostgreSQLQueryBuilder.QUERY_CLS) + + with self.subTest('MSSQLQueryBuilder'): + self.assertEqual(MSSQLQuery, MSSQLQueryBuilder.QUERY_CLS) + + with self.subTest('SnowflakeQueryBuilder'): + self.assertEqual(SnowflakeQuery, SnowflakeQueryBuilder.QUERY_CLS) + + with self.subTest('ClickHouseQueryBuilder'): + self.assertEqual(ClickHouseQuery, ClickHouseQueryBuilder.QUERY_CLS) + + with self.subTest('RedShiftQueryBuilder'): + self.assertEqual(RedshiftQuery, RedShiftQueryBuilder.QUERY_CLS) + + with self.subTest('SQLLiteQueryBuilder'): + self.assertEqual(SQLLiteQuery, SQLLiteQueryBuilder.QUERY_CLS) + + with self.subTest('OracleQueryBuilder'): + self.assertEqual(OracleQuery, OracleQueryBuilder.QUERY_CLS) + + def test_pipe(self) -> None: + base_query = Query.from_("test") + + def select(query: QueryBuilder) -> QueryBuilder: + return query.select("test1", "test2") + + def count_group(query: QueryBuilder, *groups) -> QueryBuilder: + return query.groupby(*groups).select(*groups, functions.Count("*")) + + for func, args, kwargs, expected_str in [ + (select, [], {}, 'SELECT "test1","test2" FROM "test"'), + ( + count_group, + ["test1", "test2"], + {}, + 'SELECT "test1","test2",COUNT(*) FROM "test" GROUP BY "test1","test2"', + ), + (count_group, ["test1"], {}, 'SELECT "test1",COUNT(*) FROM "test" GROUP BY "test1"'), + ]: + result_str = str(base_query.pipe(func, *args, **kwargs)) + self.assertEqual(result_str, str(func(base_query, *args, **kwargs))) + self.assertEqual(result_str, expected_str) + + def where_clause(query: QueryBuilder, num_days: int) -> QueryBuilder: + return query.where(Field("date") > functions.Now() - num_days) + + result_str = str(base_query.pipe(select).pipe(where_clause, num_days=1)) + self.assertEqual( + result_str, + str(select(where_clause(base_query, num_days=1))), + ) + self.assertEqual( + result_str, + 'SELECT "test1","test2" FROM "test" WHERE "date">NOW()-1', + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/test_selects.py b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/test_selects.py new file mode 100644 index 0000000000000000000000000000000000000000..1ce04937492e655db362b7e2a0a6856abf22a48f --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/test_selects.py @@ -0,0 +1,1331 @@ +import unittest +from datetime import date +from enum import Enum + +from pypika import ( + AliasedQuery, + Case, + ClickHouseQuery, + EmptyCriterion, + Field as F, + Index, + MSSQLQuery, + MySQLQuery, + NullValue, + OracleQuery, + Order, + PostgreSQLQuery, + Query, + QueryException, + RedshiftQuery, + SQLLiteQuery, + Table, + Tables, + VerticaQuery, + functions as fn, + SYSTEM_TIME, +) +from pypika.terms import ValueWrapper + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + + +class SelectTests(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_empty_query(self): + q = Query.from_("abc") + + self.assertEqual("", str(q)) + + def test_select_no_from(self): + q = Query.select(1) + + self.assertEqual("SELECT 1", str(q)) + + def test_select_no_with_alias_from(self): + q = Query.select(ValueWrapper(1, "test")) + + self.assertEqual('SELECT 1 "test"', str(q)) + + def test_select_no_from_with_field_raises_exception(self): + with self.assertRaises(QueryException): + Query.select("asdf") + + def test_select__star(self): + q = Query.from_("abc").select("*") + + self.assertEqual('SELECT * FROM "abc"', str(q)) + + def test_select__table_schema(self): + q = Query.from_(Table("abc", "schema1")).select("*") + + self.assertEqual('SELECT * FROM "schema1"."abc"', str(q)) + + def test_select__table_schema_with_multiple_levels_as_tuple(self): + q = Query.from_(Table("abc", ("schema1", "schema2"))).select("*") + + self.assertEqual('SELECT * FROM "schema1"."schema2"."abc"', str(q)) + + def test_select__table_schema_with_multiple_levels_as_list(self): + q = Query.from_(Table("abc", ["schema1", "schema2"])).select("*") + + self.assertEqual('SELECT * FROM "schema1"."schema2"."abc"', str(q)) + + def test_select__star__replacement(self): + q = Query.from_("abc").select("foo").select("*") + + self.assertEqual('SELECT * FROM "abc"', str(q)) + + def test_select__distinct__single(self): + q = Query.from_("abc").select("foo").distinct() + + self.assertEqual('SELECT DISTINCT "foo" FROM "abc"', str(q)) + + def test_select__distinct__multi(self): + q = Query.from_("abc").select("foo", "bar").distinct() + + self.assertEqual('SELECT DISTINCT "foo","bar" FROM "abc"', str(q)) + + def test_select__column__single__str(self): + q = Query.from_("abc").select("foo") + + self.assertEqual('SELECT "foo" FROM "abc"', str(q)) + + def test_select__column__single__alias__str(self): + q = Query.from_(self.table_abc).select(self.table_abc.foo.as_("bar")) + + self.assertEqual('SELECT "foo" "bar" FROM "abc"', str(q)) + + def test_select__column__single__table_alias__str(self): + q = Query.from_(self.table_abc.as_("fizzbuzz")).select(self.table_abc.foo.as_("bar")) + + self.assertEqual('SELECT "foo" "bar" FROM "abc" "fizzbuzz"', str(q)) + + def test_select__column__single__field(self): + t = Table("abc") + q = Query.from_(t).select(t.foo) + + self.assertEqual('SELECT "foo" FROM "abc"', str(q)) + + def test_select__columns__multi__str(self): + q1 = Query.from_("abc").select("foo", "bar") + q2 = Query.from_("abc").select("foo").select("bar") + + self.assertEqual('SELECT "foo","bar" FROM "abc"', str(q1)) + self.assertEqual('SELECT "foo","bar" FROM "abc"', str(q2)) + + def test_select__columns__multi__field(self): + q1 = Query.from_(self.table_abc).select(self.table_abc.foo, self.table_abc.bar) + q2 = Query.from_(self.table_abc).select(self.table_abc.foo).select(self.table_abc.bar) + + self.assertEqual('SELECT "foo","bar" FROM "abc"', str(q1)) + self.assertEqual('SELECT "foo","bar" FROM "abc"', str(q2)) + + def test_select__multiple_tables(self): + q = Query.from_(self.table_abc).select(self.table_abc.foo).from_(self.table_efg).select(self.table_efg.bar) + + self.assertEqual('SELECT "abc"."foo","efg"."bar" FROM "abc","efg"', str(q)) + + def test_select__subquery(self): + subquery = Query.from_(self.table_abc).select("*") + q = Query.from_(subquery).select(subquery.foo, subquery.bar) + + self.assertEqual('SELECT "sq0"."foo","sq0"."bar" ' 'FROM (SELECT * FROM "abc") "sq0"', str(q)) + + def test_select__multiple_subqueries(self): + subquery0 = Query.from_(self.table_abc).select("foo") + subquery1 = Query.from_(self.table_efg).select("bar") + q = Query.from_(subquery0).from_(subquery1).select(subquery0.foo, subquery1.bar) + + self.assertEqual( + 'SELECT "sq0"."foo","sq1"."bar" ' 'FROM (SELECT "foo" FROM "abc") "sq0",' '(SELECT "bar" FROM "efg") "sq1"', + str(q), + ) + + def test_select__nested_subquery(self): + subquery0 = Query.from_(self.table_abc).select("*") + subquery1 = Query.from_(subquery0).select(subquery0.foo, subquery0.bar) + subquery2 = Query.from_(subquery1).select(subquery1.foo) + + q = Query.from_(subquery2).select(subquery2.foo) + + self.assertEqual( + 'SELECT "sq2"."foo" ' + 'FROM (SELECT "sq1"."foo" ' + 'FROM (SELECT "sq0"."foo","sq0"."bar" ' + 'FROM (SELECT * FROM "abc") "sq0") "sq1") "sq2"', + str(q), + ) + + def test_select__no_table(self): + q = Query.select(1, 2, 3) + + self.assertEqual("SELECT 1,2,3", str(q)) + + def test_select_then_add_table(self): + q = Query.select(1).select(2, 3).from_("abc").select("foo") + + self.assertEqual('SELECT 1,2,3,"foo" FROM "abc"', str(q)) + + def test_select_with_limit(self): + q1 = Query.from_("abc").select("foo")[:10] + + self.assertEqual('SELECT "foo" FROM "abc" LIMIT 10', str(q1)) + + def test_select_with_limit_zero(self): + with self.subTest('using python slice'): + q1 = Query.from_("abc").select("foo")[:0] + self.assertEqual('SELECT "foo" FROM "abc" LIMIT 0', str(q1)) + + with self.subTest('using limit method'): + q2 = Query.from_("abc").select("foo").limit(0) + self.assertEqual('SELECT "foo" FROM "abc" LIMIT 0', str(q2)) + + def test_select_with_limit__func(self): + q1 = Query.from_("abc").select("foo").limit(10) + + self.assertEqual('SELECT "foo" FROM "abc" LIMIT 10', str(q1)) + + def test_select_with_offset(self): + q1 = Query.from_("abc").select("foo")[10:] + + self.assertEqual('SELECT "foo" FROM "abc" OFFSET 10', str(q1)) + + def test_select_with_offset__func(self): + q1 = Query.from_("abc").select("foo").offset(10) + + self.assertEqual('SELECT "foo" FROM "abc" OFFSET 10', str(q1)) + + def test_select_with_limit_and_offset(self): + q1 = Query.from_("abc").select("foo")[10:10] + + self.assertEqual('SELECT "foo" FROM "abc" LIMIT 10 OFFSET 10', str(q1)) + + def test_select_with_force_index(self): + q = Query.from_("abc").select("foo").force_index("egg") + + self.assertEqual('SELECT "foo" FROM "abc" FORCE INDEX ("egg")', str(q)) + + def test_select_with_force_index_with_index_object(self): + index = Index("egg") + q = Query.from_("abc").select("foo").force_index(index) + + self.assertEqual('SELECT "foo" FROM "abc" FORCE INDEX ("egg")', str(q)) + + def test_select_with_force_index_multiple_indexes(self): + q = Query.from_("abc").select("foo").force_index("egg", "bacon") + + self.assertEqual('SELECT "foo" FROM "abc" FORCE INDEX ("egg","bacon")', str(q)) + + def test_select_with_force_index_multiple_calls(self): + q = ( + Query.from_("abc") + .select("foo") + .force_index( + "egg", + ) + .force_index("spam") + ) + + self.assertEqual('SELECT "foo" FROM "abc" FORCE INDEX ("egg","spam")', str(q)) + + def test_select_with_use_index(self): + q = Query.from_("abc").select("foo").use_index("egg") + + self.assertEqual('SELECT "foo" FROM "abc" USE INDEX ("egg")', str(q)) + + def test_select_with_use_index_with_index_object(self): + index = Index("egg") + q = Query.from_("abc").select("foo").use_index(index) + + self.assertEqual('SELECT "foo" FROM "abc" USE INDEX ("egg")', str(q)) + + def test_select_with_use_index_multiple_indexes(self): + q = Query.from_("abc").select("foo").use_index("egg", "bacon") + + self.assertEqual('SELECT "foo" FROM "abc" USE INDEX ("egg","bacon")', str(q)) + + def test_select_with_use_index_multiple_calls(self): + q = ( + Query.from_("abc") + .select("foo") + .use_index( + "egg", + ) + .use_index("spam") + ) + + self.assertEqual('SELECT "foo" FROM "abc" USE INDEX ("egg","spam")', str(q)) + + def test_mysql_query_uses_backtick_quote_chars(self): + q = MySQLQuery.from_("abc").select("foo", "bar") + + self.assertEqual("SELECT `foo`,`bar` FROM `abc`", str(q)) + + def test_vertica_query_uses_double_quote_chars(self): + q = VerticaQuery.from_("abc").select("foo", "bar") + + self.assertEqual('SELECT "foo","bar" FROM "abc"', str(q)) + + def test_mssql_query_uses_double_quote_chars(self): + q = MSSQLQuery.from_("abc").select("foo", "bar") + + self.assertEqual('SELECT "foo","bar" FROM "abc"', str(q)) + + def test_oracle_query_uses_no_quote_chars(self): + q = OracleQuery.from_("abc").select("foo", "bar") + + self.assertEqual('SELECT foo,bar FROM abc', str(q)) + + def test_postgresql_query_uses_double_quote_chars(self): + q = PostgreSQLQuery.from_("abc").select("foo", "bar") + + self.assertEqual('SELECT "foo","bar" FROM "abc"', str(q)) + + def test_redshift_query_uses_double_quote_chars(self): + q = RedshiftQuery.from_("abc").select("foo", "bar") + + self.assertEqual('SELECT "foo","bar" FROM "abc"', str(q)) + + def test_table_select_alias(self): + q = self.table_abc.select(1) + + self.assertEqual('SELECT 1 FROM "abc"', str(q)) + self.assertEqual(q, Query.from_("abc").select(1)) + + def test_table_select_alias_with_offset_and_limit(self): + self.assertEqual(self.table_abc.select("foo")[10:10], Query.from_("abc").select("foo")[10:10]) + self.assertEqual( + self.table_abc.select(self.table_abc.foo)[10:10], + Query.from_("abc").select("foo")[10:10], + ) + + def test_temporal_select(self): + t = Table("abc") + + with self.subTest("with system time as of"): + q = Query.from_(t.for_(SYSTEM_TIME.as_of('2020-01-01'))).select("*") + + self.assertEqual('SELECT * FROM "abc" FOR SYSTEM_TIME AS OF \'2020-01-01\'', str(q)) + + with self.subTest("with system time between"): + q = Query.from_(t.for_(SYSTEM_TIME.between('2020-01-01', '2020-02-01'))).select("*") + + self.assertEqual('SELECT * FROM "abc" FOR SYSTEM_TIME BETWEEN \'2020-01-01\' AND \'2020-02-01\'', str(q)) + + with self.subTest("with system time from to"): + q = Query.from_(t.for_(SYSTEM_TIME.from_to('2020-01-01', '2020-02-01'))).select("*") + + self.assertEqual('SELECT * FROM "abc" FOR SYSTEM_TIME FROM \'2020-01-01\' TO \'2020-02-01\'', str(q)) + + with self.subTest("with ALL"): + q = Query.from_(t.for_(SYSTEM_TIME.all_())).select("*") + + self.assertEqual('SELECT * FROM "abc" FOR SYSTEM_TIME ALL', str(q)) + + with self.subTest("with period between"): + q = Query.from_(t.for_(t.valid_period.between('2020-01-01', '2020-02-01'))).select("*") + + self.assertEqual('SELECT * FROM "abc" FOR "valid_period" BETWEEN \'2020-01-01\' AND \'2020-02-01\'', str(q)) + + with self.subTest("with period from to"): + q = Query.from_(t.for_(t.valid_period.from_to('2020-01-01', '2020-02-01'))).select("*") + + self.assertEqual('SELECT * FROM "abc" FOR "valid_period" FROM \'2020-01-01\' TO \'2020-02-01\'', str(q)) + + with self.subTest("with ALL"): + q = Query.from_(t.for_(t.valid_period.all_())).select("*") + + self.assertEqual('SELECT * FROM "abc" FOR "valid_period" ALL', str(q)) + + +class MyEnum(Enum): + STR = "foo" + INT = 0 + BOOL = True + DATE = date(2020, 2, 2) + NONE = None + + +class WhereTests(unittest.TestCase): + t = Table("abc") + t2 = Table("cba") + + def test_where_enum(self): + q1 = Query.from_(self.t).select("*").where(self.t.foo == MyEnum.STR) + q2 = Query.from_(self.t).select("*").where(self.t.foo == MyEnum.INT) + q3 = Query.from_(self.t).select("*").where(self.t.foo == MyEnum.BOOL) + q4 = Query.from_(self.t).select("*").where(self.t.foo == MyEnum.DATE) + q5 = Query.from_(self.t).select("*").where(self.t.foo == MyEnum.NONE) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo"=\'foo\'', str(q1)) + self.assertEqual('SELECT * FROM "abc" WHERE "foo"=0', str(q2)) + self.assertEqual('SELECT * FROM "abc" WHERE "foo"=true', str(q3)) + self.assertEqual('SELECT * FROM "abc" WHERE "foo"=\'2020-02-02\'', str(q4)) + self.assertEqual('SELECT * FROM "abc" WHERE "foo"=null', str(q5)) + + def test_where_field_equals(self): + q1 = Query.from_(self.t).select("*").where(self.t.foo == self.t.bar) + q2 = Query.from_(self.t).select("*").where(self.t.foo.eq(self.t.bar)) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo"="bar"', str(q1)) + self.assertEqual('SELECT * FROM "abc" WHERE "foo"="bar"', str(q2)) + q = self.t.select("*").where(self.t.foo == self.t.bar) + self.assertEqual(q, q1) + + def test_where_field_equals_for_update(self): + q = Query.from_(self.t).select("*").where(self.t.foo == self.t.bar).for_update() + self.assertEqual('SELECT * FROM "abc" WHERE "foo"="bar" FOR UPDATE', str(q)) + + def test_where_field_equals_for_update_nowait(self): + for query_cls in [ + MySQLQuery, + PostgreSQLQuery, + ]: + quote_char = query_cls._builder().QUOTE_CHAR if isinstance(query_cls._builder().QUOTE_CHAR, str) else '"' + q = query_cls.from_(self.t).select("*").where(self.t.foo == self.t.bar).for_update(nowait=True) + self.assertEqual( + 'SELECT * ' + 'FROM {quote_char}abc{quote_char} ' + 'WHERE {quote_char}foo{quote_char}={quote_char}bar{quote_char} ' + 'FOR UPDATE NOWAIT'.format( + quote_char=quote_char, + ), + str(q), + ) + + def test_where_field_equals_for_update_skip_locked(self): + for query_cls in [ + MySQLQuery, + PostgreSQLQuery, + ]: + quote_char = query_cls._builder().QUOTE_CHAR if isinstance(query_cls._builder().QUOTE_CHAR, str) else '"' + q = query_cls.from_(self.t).select("*").where(self.t.foo == self.t.bar).for_update(skip_locked=True) + self.assertEqual( + 'SELECT * ' + 'FROM {quote_char}abc{quote_char} ' + 'WHERE {quote_char}foo{quote_char}={quote_char}bar{quote_char} ' + 'FOR UPDATE SKIP LOCKED'.format( + quote_char=quote_char, + ), + str(q), + ) + + def test_where_field_equals_for_update_of(self): + for query_cls in [ + MySQLQuery, + PostgreSQLQuery, + ]: + quote_char = query_cls._builder().QUOTE_CHAR if isinstance(query_cls._builder().QUOTE_CHAR, str) else '"' + q = query_cls.from_(self.t).select("*").where(self.t.foo == self.t.bar).for_update(of=("abc",)) + self.assertEqual( + 'SELECT * ' + 'FROM {quote_char}abc{quote_char} ' + 'WHERE {quote_char}foo{quote_char}={quote_char}bar{quote_char} ' + 'FOR UPDATE OF {quote_char}abc{quote_char}'.format( + quote_char=quote_char, + ), + str(q), + ) + + def test_where_field_equals_for_update_of_multiple_tables(self): + for query_cls in [ + MySQLQuery, + PostgreSQLQuery, + ]: + q = ( + query_cls.from_(self.t) + .join(self.t2) + .on(self.t.id == self.t2.abc_id) + .select("*") + .where(self.t.foo == self.t.bar) + .for_update(of=("abc", "cba")) + ) + quote_char = query_cls._builder().QUOTE_CHAR if isinstance(query_cls._builder().QUOTE_CHAR, str) else '"' + self.assertIn( + str(q), + [ + 'SELECT * ' + 'FROM {quote_char}abc{quote_char} ' + 'JOIN {quote_char}cba{quote_char} ' + 'ON {quote_char}abc{quote_char}.{quote_char}id{quote_char}=' + '{quote_char}cba{quote_char}.{quote_char}abc_id{quote_char} ' + 'WHERE {quote_char}abc{quote_char}.{quote_char}foo{quote_char}=' + '{quote_char}abc{quote_char}.{quote_char}bar{quote_char} ' + 'FOR UPDATE OF {quote_char}cba{quote_char}, {quote_char}abc{quote_char}'.format( + quote_char=quote_char, + ), + 'SELECT * ' + 'FROM {quote_char}abc{quote_char} ' + 'JOIN {quote_char}cba{quote_char} ' + 'ON {quote_char}abc{quote_char}.{quote_char}id{quote_char}=' + '{quote_char}cba{quote_char}.{quote_char}abc_id{quote_char} ' + 'WHERE {quote_char}abc{quote_char}.{quote_char}foo{quote_char}=' + '{quote_char}abc{quote_char}.{quote_char}bar{quote_char} ' + 'FOR UPDATE OF {quote_char}abc{quote_char}, {quote_char}cba{quote_char}'.format( + quote_char=quote_char, + ), + ], + ) + + def test_where_field_equals_for_update_of_nowait(self): + for query_cls in [ + MySQLQuery, + PostgreSQLQuery, + ]: + q = query_cls.from_(self.t).select("*").where(self.t.foo == self.t.bar).for_update(of=("abc",), nowait=True) + quote_char = query_cls._builder().QUOTE_CHAR if isinstance(query_cls._builder().QUOTE_CHAR, str) else '"' + self.assertEqual( + 'SELECT * ' + 'FROM {quote_char}abc{quote_char} ' + 'WHERE {quote_char}foo{quote_char}={quote_char}bar{quote_char} ' + 'FOR UPDATE OF {quote_char}abc{quote_char} NOWAIT'.format( + quote_char=quote_char, + ), + str(q), + ) + + def test_where_field_equals_for_update_of_skip_locked(self): + for query_cls in [ + MySQLQuery, + PostgreSQLQuery, + ]: + q = ( + query_cls.from_(self.t) + .select("*") + .where(self.t.foo == self.t.bar) + .for_update(of=("abc",), skip_locked=True) + ) + quote_char = query_cls._builder().QUOTE_CHAR if isinstance(query_cls._builder().QUOTE_CHAR, str) else '"' + self.assertEqual( + 'SELECT * ' + 'FROM {quote_char}abc{quote_char} ' + 'WHERE {quote_char}foo{quote_char}={quote_char}bar{quote_char} ' + 'FOR UPDATE OF {quote_char}abc{quote_char} SKIP LOCKED'.format( + quote_char=quote_char, + ), + str(q), + ) + + def test_where_field_equals_for_update_skip_locked_and_of(self): + for query_cls in [ + MySQLQuery, + PostgreSQLQuery, + ]: + q = ( + query_cls.from_(self.t) + .select("*") + .where(self.t.foo == self.t.bar) + .for_update(nowait=False, skip_locked=True, of=("abc",)) + ) + quote_char = query_cls._builder().QUOTE_CHAR if isinstance(query_cls._builder().QUOTE_CHAR, str) else '"' + self.assertEqual( + 'SELECT * ' + 'FROM {quote_char}abc{quote_char} ' + 'WHERE {quote_char}foo{quote_char}={quote_char}bar{quote_char} ' + 'FOR UPDATE OF {quote_char}abc{quote_char} SKIP LOCKED'.format( + quote_char=quote_char, + ), + str(q), + ) + + def test_where_field_equals_where(self): + q = Query.from_(self.t).select("*").where(self.t.foo == 1).where(self.t.bar == self.t.baz) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo"=1 AND "bar"="baz"', str(q)) + + def test_where_field_equals_where_not(self): + q = Query.from_(self.t).select("*").where((self.t.foo == 1).negate()).where(self.t.bar == self.t.baz) + + self.assertEqual('SELECT * FROM "abc" WHERE NOT "foo"=1 AND "bar"="baz"', str(q)) + + def test_where_field_equals_where_two_not(self): + q = Query.from_(self.t).select("*").where((self.t.foo == 1).negate()).where((self.t.bar == self.t.baz).negate()) + + self.assertEqual('SELECT * FROM "abc" WHERE NOT "foo"=1 AND NOT "bar"="baz"', str(q)) + + def test_where_single_quote(self): + q1 = Query.from_(self.t).select("*").where(self.t.foo == "bar'foo") + + self.assertEqual("SELECT * FROM \"abc\" WHERE \"foo\"='bar''foo'", str(q1)) + + def test_where_field_equals_and(self): + q = Query.from_(self.t).select("*").where((self.t.foo == 1) & (self.t.bar == self.t.baz)) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo"=1 AND "bar"="baz"', str(q)) + + def test_where_field_equals_or(self): + q = Query.from_(self.t).select("*").where((self.t.foo == 1) | (self.t.bar == self.t.baz)) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo"=1 OR "bar"="baz"', str(q)) + + def test_where_nested_conditions(self): + q = Query.from_(self.t).select("*").where((self.t.foo == 1) | (self.t.bar == self.t.baz)).where(self.t.baz == 0) + + self.assertEqual('SELECT * FROM "abc" WHERE ("foo"=1 OR "bar"="baz") AND "baz"=0', str(q)) + + def test_where_field_starts_with(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.like("ab%")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" LIKE \'ab%\'', str(q)) + + def test_where_field_contains(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.like("%fg%")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" LIKE \'%fg%\'', str(q)) + + def test_where_field_ends_with(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.like("%yz")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" LIKE \'%yz\'', str(q)) + + def test_where_field_is_n_chars_long(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.like("___")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" LIKE \'___\'', str(q)) + + def test_where_field_does_not_start_with(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.not_like("ab%")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" NOT LIKE \'ab%\'', str(q)) + + def test_where_field_does_not_contain(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.not_like("%fg%")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" NOT LIKE \'%fg%\'', str(q)) + + def test_where_field_does_not_end_with(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.not_like("%yz")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" NOT LIKE \'%yz\'', str(q)) + + def test_where_field_is_not_n_chars_long(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.not_like("___")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" NOT LIKE \'___\'', str(q)) + + def test_where_field_matches_regex(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.regex(r"^b")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" REGEX \'^b\'', str(q)) + + def test_where_field_matches_regexp(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.regexp(r"^b")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" REGEXP \'^b\'', str(q)) + + def test_where_field_matches_rlike(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.rlike(r"^b")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" RLIKE \'^b\'', str(q)) + + def test_ignore_empty_criterion_where(self): + q1 = Query.from_(self.t).select("*").where(EmptyCriterion()) + + self.assertEqual('SELECT * FROM "abc"', str(q1)) + + def test_ignore_empty_criterion_having(self): + q1 = Query.from_(self.t).select("*").having(EmptyCriterion()) + + self.assertEqual('SELECT * FROM "abc"', str(q1)) + + def test_select_with_force_index_and_where(self): + q = Query.from_("abc").select("foo").where(self.t.foo == self.t.bar).force_index("egg") + + self.assertEqual('SELECT "foo" FROM "abc" FORCE INDEX ("egg") WHERE "foo"="bar"', str(q)) + + def test_where_with_multiple_wheres_using_and_case(self): + case_stmt = Case().when(self.t.foo == 'bar', 1).else_(0) + query = Query.from_(self.t).select(case_stmt).where(case_stmt & self.t.blah.isin(['test'])) + + self.assertEqual( + 'SELECT CASE WHEN "foo"=\'bar\' THEN 1 ELSE 0 END FROM "abc" WHERE CASE WHEN "foo"=\'bar\' THEN 1 ELSE 0 ' + 'END AND "blah" IN (\'test\')', + str(query), + ) + + def test_where_with_multiple_wheres_using_or_case(self): + case_stmt = Case().when(self.t.foo == 'bar', 1).else_(0) + query = Query.from_(self.t).select(case_stmt).where(case_stmt | self.t.blah.isin(['test'])) + + self.assertEqual( + 'SELECT CASE WHEN "foo"=\'bar\' THEN 1 ELSE 0 END FROM "abc" WHERE CASE WHEN "foo"=\'bar\' THEN 1 ELSE 0 ' + 'END OR "blah" IN (\'test\')', + str(query), + ) + + +class PreWhereTests(WhereTests): + t = Table("abc") + + def test_prewhere_field_equals(self): + q1 = Query.from_(self.t).select("*").prewhere(self.t.foo == self.t.bar) + q2 = Query.from_(self.t).select("*").prewhere(self.t.foo.eq(self.t.bar)) + + self.assertEqual('SELECT * FROM "abc" PREWHERE "foo"="bar"', str(q1)) + self.assertEqual('SELECT * FROM "abc" PREWHERE "foo"="bar"', str(q2)) + + def test_where_and_prewhere(self): + q = Query.from_(self.t).select("*").prewhere(self.t.foo == self.t.bar).where(self.t.foo == self.t.bar) + + self.assertEqual('SELECT * FROM "abc" PREWHERE "foo"="bar" WHERE "foo"="bar"', str(q)) + + +class GroupByTests(unittest.TestCase): + t = Table("abc") + maxDiff = None + + def test_groupby__single(self): + q = Query.from_(self.t).groupby(self.t.foo).select(self.t.foo) + + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo"', str(q)) + + def test_groupby__multi(self): + q = Query.from_(self.t).groupby(self.t.foo, self.t.bar).select(self.t.foo, self.t.bar) + + self.assertEqual('SELECT "foo","bar" FROM "abc" GROUP BY "foo","bar"', str(q)) + + def test_groupby__count_star(self): + q = Query.from_(self.t).groupby(self.t.foo).select(self.t.foo, fn.Count("*")) + + self.assertEqual('SELECT "foo",COUNT(*) FROM "abc" GROUP BY "foo"', str(q)) + + def test_groupby__count_field(self): + q = Query.from_(self.t).groupby(self.t.foo).select(self.t.foo, fn.Count(self.t.bar)) + + self.assertEqual('SELECT "foo",COUNT("bar") FROM "abc" GROUP BY "foo"', str(q)) + + def test_groupby__count_distinct(self): + q = Query.from_(self.t).groupby(self.t.foo).select(self.t.foo, fn.Count("*").distinct()) + + self.assertEqual('SELECT "foo",COUNT(DISTINCT *) FROM "abc" GROUP BY "foo"', str(q)) + + def test_groupby__sum_distinct(self): + q = Query.from_(self.t).groupby(self.t.foo).select(self.t.foo, fn.Sum(self.t.bar).distinct()) + + self.assertEqual('SELECT "foo",SUM(DISTINCT "bar") FROM "abc" GROUP BY "foo"', str(q)) + + def test_groupby__sum_filter(self): + q = ( + Query.from_(self.t) + .groupby(self.t.foo) + .select(self.t.foo, fn.Sum(self.t.bar).filter(self.t.id.eq(1) & self.t.cid.gt(2))) + ) + + self.assertEqual('SELECT "foo",SUM("bar") FILTER(WHERE "id"=1 AND "cid">2) FROM "abc" GROUP BY "foo"', str(q)) + + def test_groupby__str(self): + q = Query.from_("abc").groupby("foo").select("foo", fn.Count("*").distinct()) + + self.assertEqual('SELECT "foo",COUNT(DISTINCT *) FROM "abc" GROUP BY "foo"', str(q)) + + def test_groupby__int(self): + q = Query.from_("abc").groupby(1).select("foo", fn.Count("*").distinct()) + + self.assertEqual('SELECT "foo",COUNT(DISTINCT *) FROM "abc" GROUP BY 1', str(q)) + + def test_groupby__alias(self): + bar = self.t.bar.as_("bar01") + q = Query.from_(self.t).select(fn.Sum(self.t.foo), bar).groupby(bar) + + self.assertEqual('SELECT SUM("foo"),"bar" "bar01" FROM "abc" GROUP BY "bar01"', str(q)) + + def test_groupby__no_alias(self): + bar = self.t.bar.as_("bar01") + q = Query.from_(self.t).select(fn.Sum(self.t.foo), bar).groupby(bar) + + self.assertEqual( + 'SELECT SUM("foo"),"bar" "bar01" FROM "abc" GROUP BY "bar"', + q.get_sql(groupby_alias=False), + ) + + def test_groupby__no_alias_mssql(self): + bar = self.t.bar.as_("bar01") + q = MSSQLQuery.from_(self.t).select(fn.Sum(self.t.foo), bar).groupby(bar) + + self.assertEqual('SELECT SUM("foo"),"bar" "bar01" FROM "abc" GROUP BY "bar"', str(q)) + + def test_groupby__no_alias_oracle(self): + bar = self.t.bar.as_("bar01") + q = OracleQuery.from_(self.t).select(fn.Sum(self.t.foo), bar).groupby(bar) + + self.assertEqual('SELECT SUM(foo),bar bar01 FROM abc GROUP BY bar', str(q)) + + def test_groupby__alias_platforms(self): + bar = self.t.bar.as_("bar01") + + for query_cls in [ + MySQLQuery, + VerticaQuery, + PostgreSQLQuery, + RedshiftQuery, + ClickHouseQuery, + SQLLiteQuery, + ]: + q = query_cls.from_(self.t).select(fn.Sum(self.t.foo), bar).groupby(bar) + + quote_char = query_cls._builder().QUOTE_CHAR if isinstance(query_cls._builder().QUOTE_CHAR, str) else '"' + + self.assertEqual( + "SELECT " + "SUM({quote_char}foo{quote_char})," + "{quote_char}bar{quote_char}{as_keyword}{quote_char}bar01{quote_char} " + "FROM {quote_char}abc{quote_char} " + "GROUP BY {quote_char}bar01{quote_char}".format( + as_keyword=' AS ' if query_cls is ClickHouseQuery else ' ', quote_char=quote_char + ), + str(q), + ) + + def test_groupby__alias_with_join(self): + table1 = Table("table1", alias="t1") + bar = table1.bar.as_("bar01") + q = Query.from_(self.t).join(table1).on(self.t.id == table1.t_ref).select(fn.Sum(self.t.foo), bar).groupby(bar) + + self.assertEqual( + 'SELECT SUM("abc"."foo"),"t1"."bar" "bar01" FROM "abc" ' + 'JOIN "table1" "t1" ON "abc"."id"="t1"."t_ref" ' + 'GROUP BY "bar01"', + str(q), + ) + + def test_groupby_with_case_uses_the_alias(self): + q = ( + Query.from_(self.t) + .select( + fn.Sum(self.t.foo).as_("bar"), + Case().when(self.t.fname == "Tom", "It was Tom").else_("It was someone else.").as_("who_was_it"), + ) + .groupby(Case().when(self.t.fname == "Tom", "It was Tom").else_("It was someone else.").as_("who_was_it")) + ) + + self.assertEqual( + 'SELECT SUM("foo") "bar",' + "CASE WHEN \"fname\"='Tom' THEN 'It was Tom' " + "ELSE 'It was someone else.' END \"who_was_it\" " + 'FROM "abc" ' + 'GROUP BY "who_was_it"', + str(q), + ) + + def test_mysql_query_uses_backtick_quote_chars(self): + q = MySQLQuery.from_(self.t).groupby(self.t.foo).select(self.t.foo) + + self.assertEqual("SELECT `foo` FROM `abc` GROUP BY `foo`", str(q)) + + def test_vertica_query_uses_double_quote_chars(self): + q = VerticaQuery.from_(self.t).groupby(self.t.foo).select(self.t.foo) + + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo"', str(q)) + + def test_mssql_query_uses_double_quote_chars(self): + q = MSSQLQuery.from_(self.t).groupby(self.t.foo).select(self.t.foo) + + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo"', str(q)) + + def test_oracle_query_uses_no_quote_chars(self): + q = OracleQuery.from_(self.t).groupby(self.t.foo).select(self.t.foo) + + self.assertEqual('SELECT foo FROM abc GROUP BY foo', str(q)) + + def test_postgres_query_uses_double_quote_chars(self): + q = PostgreSQLQuery.from_(self.t).groupby(self.t.foo).select(self.t.foo) + + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo"', str(q)) + + def test_redshift_query_uses_double_quote_chars(self): + q = RedshiftQuery.from_(self.t).groupby(self.t.foo).select(self.t.foo) + + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo"', str(q)) + + def test_group_by__single_with_totals(self): + q = Query.from_(self.t).groupby(self.t.foo).select(self.t.foo).with_totals() + + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo" WITH TOTALS', str(q)) + + def test_groupby__multi_with_totals(self): + q = Query.from_(self.t).groupby(self.t.foo, self.t.bar).select(self.t.foo, self.t.bar).with_totals() + + self.assertEqual('SELECT "foo","bar" FROM "abc" GROUP BY "foo","bar" WITH TOTALS', str(q)) + + +class HavingTests(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_having_greater_than(self): + q = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, fn.Sum(self.table_abc.bar)) + .groupby(self.table_abc.foo) + .having(fn.Sum(self.table_abc.bar) > 1) + ) + + self.assertEqual( + 'SELECT "foo",SUM("bar") FROM "abc" GROUP BY "foo" HAVING SUM("bar")>1', + str(q), + ) + + def test_having_and(self): + q = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, fn.Sum(self.table_abc.bar)) + .groupby(self.table_abc.foo) + .having((fn.Sum(self.table_abc.bar) > 1) & (fn.Sum(self.table_abc.bar) < 100)) + ) + + self.assertEqual( + 'SELECT "foo",SUM("bar") FROM "abc" GROUP BY "foo" HAVING SUM("bar")>1 AND SUM("bar")<100', + str(q), + ) + + def test_having_join_and_equality(self): + q = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.foo) + .select(self.table_abc.foo, fn.Sum(self.table_efg.bar), self.table_abc.buz) + .groupby(self.table_abc.foo) + .having(self.table_abc.buz == "fiz") + .having(fn.Sum(self.table_efg.bar) > 100) + ) + + self.assertEqual( + 'SELECT "abc"."foo",SUM("efg"."bar"),"abc"."buz" FROM "abc" ' + 'JOIN "efg" ON "abc"."foo"="efg"."foo" ' + 'GROUP BY "abc"."foo" ' + 'HAVING "abc"."buz"=\'fiz\' AND SUM("efg"."bar")>100', + str(q), + ) + + def test_mysql_query_uses_backtick_quote_chars(self): + q = ( + MySQLQuery.from_(self.table_abc) + .select(self.table_abc.foo) + .groupby(self.table_abc.foo) + .having(self.table_abc.buz == "fiz") + ) + self.assertEqual("SELECT `foo` FROM `abc` GROUP BY `foo` HAVING `buz`='fiz'", str(q)) + + def test_vertica_query_uses_double_quote_chars(self): + q = ( + VerticaQuery.from_(self.table_abc) + .select(self.table_abc.foo) + .groupby(self.table_abc.foo) + .having(self.table_abc.buz == "fiz") + ) + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo" HAVING "buz"=\'fiz\'', str(q)) + + def test_mssql_query_uses_double_quote_chars(self): + q = ( + MSSQLQuery.from_(self.table_abc) + .select(self.table_abc.foo) + .groupby(self.table_abc.foo) + .having(self.table_abc.buz == "fiz") + ) + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo" HAVING "buz"=\'fiz\'', str(q)) + + def test_oracle_query_uses_no_quote_chars(self): + q = ( + OracleQuery.from_(self.table_abc) + .select(self.table_abc.foo) + .groupby(self.table_abc.foo) + .having(self.table_abc.buz == "fiz") + ) + self.assertEqual('SELECT foo FROM abc GROUP BY foo HAVING buz=\'fiz\'', str(q)) + + def test_postgres_query_uses_double_quote_chars(self): + q = ( + PostgreSQLQuery.from_(self.table_abc) + .select(self.table_abc.foo) + .groupby(self.table_abc.foo) + .having(self.table_abc.buz == "fiz") + ) + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo" HAVING "buz"=\'fiz\'', str(q)) + + def test_redshift_query_uses_double_quote_chars(self): + q = ( + RedshiftQuery.from_(self.table_abc) + .select(self.table_abc.foo) + .groupby(self.table_abc.foo) + .having(self.table_abc.buz == "fiz") + ) + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo" HAVING "buz"=\'fiz\'', str(q)) + + +class OrderByTests(unittest.TestCase): + t = Table("abc") + + def test_orderby_single_field(self): + q = Query.from_(self.t).orderby(self.t.foo).select(self.t.foo) + + self.assertEqual('SELECT "foo" FROM "abc" ORDER BY "foo"', str(q)) + + def test_orderby_multi_fields(self): + q = Query.from_(self.t).orderby(self.t.foo, self.t.bar).select(self.t.foo, self.t.bar) + + self.assertEqual('SELECT "foo","bar" FROM "abc" ORDER BY "foo","bar"', str(q)) + + def test_orderby_single_str(self): + q = Query.from_("abc").orderby("foo").select("foo") + + self.assertEqual('SELECT "foo" FROM "abc" ORDER BY "foo"', str(q)) + + def test_orderby_asc(self): + q = Query.from_(self.t).orderby(self.t.foo, order=Order.asc).select(self.t.foo) + + self.assertEqual('SELECT "foo" FROM "abc" ORDER BY "foo" ASC', str(q)) + + def test_orderby_desc(self): + q = Query.from_(self.t).orderby(self.t.foo, order=Order.desc).select(self.t.foo) + + self.assertEqual('SELECT "foo" FROM "abc" ORDER BY "foo" DESC', str(q)) + + def test_orderby_no_alias(self): + bar = self.t.bar.as_("bar01") + q = Query.from_(self.t).select(fn.Sum(self.t.foo), bar).orderby(bar) + + self.assertEqual( + 'SELECT SUM("foo"),"bar" "bar01" FROM "abc" ORDER BY "bar"', + q.get_sql(orderby_alias=False), + ) + + def test_orderby_alias(self): + bar = self.t.bar.as_("bar01") + q = Query.from_(self.t).select(fn.Sum(self.t.foo), bar).orderby(bar) + + self.assertEqual('SELECT SUM("foo"),"bar" "bar01" FROM "abc" ORDER BY "bar01"', q.get_sql()) + + +class AliasTests(unittest.TestCase): + t = Table("abc") + + def test_table_field(self): + q = Query.from_(self.t).select(self.t.foo.as_("bar")) + + self.assertEqual('SELECT "foo" "bar" FROM "abc"', str(q)) + + def test_table_field__multi(self): + q = Query.from_(self.t).select(self.t.foo.as_("bar"), self.t.fiz.as_("buz")) + + self.assertEqual('SELECT "foo" "bar","fiz" "buz" FROM "abc"', str(q)) + + def test_arithmetic_function(self): + q = Query.from_(self.t).select((self.t.foo + self.t.bar).as_("biz")) + + self.assertEqual('SELECT "foo"+"bar" "biz" FROM "abc"', str(q)) + + def test_functions_using_as(self): + q = Query.from_(self.t).select(fn.Count("*").as_("foo")) + + self.assertEqual('SELECT COUNT(*) "foo" FROM "abc"', str(q)) + + def test_functions_using_constructor_param(self): + q = Query.from_(self.t).select(fn.Count("*", alias="foo")) + + self.assertEqual('SELECT COUNT(*) "foo" FROM "abc"', str(q)) + + def test_function_using_as_nested(self): + """ + We don't show aliases of fields that are arguments of a function. + """ + q = Query.from_(self.t).select(fn.Sqrt(fn.Count("*").as_("foo")).as_("bar")) + + self.assertEqual('SELECT SQRT(COUNT(*)) "bar" FROM "abc"', str(q)) + + def test_functions_using_constructor_param_nested(self): + """ + We don't show aliases of fields that are arguments of a function. + """ + q = Query.from_(self.t).select(fn.Sqrt(fn.Count("*", alias="foo"), alias="bar")) + + self.assertEqual('SELECT SQRT(COUNT(*)) "bar" FROM "abc"', str(q)) + + def test_ignored_in_where(self): + q = Query.from_(self.t).select(self.t.foo).where(self.t.foo.as_("bar") == 1) + + self.assertEqual('SELECT "foo" FROM "abc" WHERE "foo"=1', str(q)) + + def test_ignored_in_groupby(self): + q = Query.from_(self.t).select(self.t.foo).groupby(self.t.foo.as_("bar")) + + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo"', str(q)) + + def test_ignored_in_orderby(self): + q = Query.from_(self.t).select(self.t.foo).orderby(self.t.foo.as_("bar")) + + self.assertEqual('SELECT "foo" FROM "abc" ORDER BY "foo"', str(q)) + + def test_ignored_in_criterion(self): + c = self.t.foo.as_("bar") == 1 + + self.assertEqual('"foo"=1', str(c)) + + def test_ignored_in_criterion_comparison(self): + c = self.t.foo.as_("bar") == self.t.fiz.as_("buz") + + self.assertEqual('"foo"="fiz"', str(c)) + + def test_ignored_in_field_inside_case(self): + q = Query.from_(self.t).select(Case().when(self.t.foo == 1, "a").else_(self.t.bar.as_('"buz"'))) + + self.assertEqual('SELECT CASE WHEN "foo"=1 THEN \'a\' ELSE "bar" END FROM "abc"', str(q)) + + def test_case_using_as(self): + q = Query.from_(self.t).select(Case().when(self.t.foo == 1, "a").else_("b").as_("bar")) + + self.assertEqual( + 'SELECT CASE WHEN "foo"=1 THEN \'a\' ELSE \'b\' END "bar" FROM "abc"', + str(q), + ) + + def test_case_using_constructor_param(self): + q = Query.from_(self.t).select(Case(alias="bar").when(self.t.foo == 1, "a").else_("b")) + + self.assertEqual( + 'SELECT CASE WHEN "foo"=1 THEN \'a\' ELSE \'b\' END "bar" FROM "abc"', + str(q), + ) + + def test_select__multiple_tables(self): + table_abc, table_efg = Table("abc", alias="q0"), Table("efg", alias="q1") + + q = Query.from_(table_abc).select(table_abc.foo).from_(table_efg).select(table_efg.bar) + + self.assertEqual('SELECT "q0"."foo","q1"."bar" FROM "abc" "q0","efg" "q1"', str(q)) + + def test_use_aliases_in_groupby_and_orderby(self): + table_abc = Table("abc", alias="q0") + + my_foo = table_abc.foo.as_("my_foo") + q = Query.from_(table_abc).select(my_foo, table_abc.bar).groupby(my_foo).orderby(my_foo) + + self.assertEqual( + 'SELECT "q0"."foo" "my_foo","q0"."bar" ' 'FROM "abc" "q0" ' 'GROUP BY "my_foo" ' 'ORDER BY "my_foo"', + str(q), + ) + + def test_table_with_schema_and_alias(self): + table = Table("abc", schema="schema", alias="alias") + self.assertEqual('"schema"."abc" "alias"', str(table)) + + def test_null_value_with_alias(self): + q = Query.select(NullValue().as_("abcdef")) + + self.assertEqual('SELECT NULL "abcdef"', str(q)) + + +class SubqueryTests(unittest.TestCase): + maxDiff = None + + table_abc, table_efg, table_hij = Tables("abc", "efg", "hij") + + def test_where__in(self): + q = ( + Query.from_(self.table_abc) + .select("*") + .where( + self.table_abc.foo.isin( + Query.from_(self.table_efg).select(self.table_efg.foo).where(self.table_efg.bar == 0) + ) + ) + ) + + self.assertEqual( + 'SELECT * FROM "abc" WHERE "foo" IN (SELECT "foo" FROM "efg" WHERE "bar"=0)', + str(q), + ) + + def test_where__in_nested(self): + q = Query.from_(self.table_abc).select("*").where(self.table_abc.foo).isin(self.table_efg.select("*")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" IN (SELECT * FROM "efg")', str(q)) + + def test_join(self): + subquery = Query.from_("efg").select("fiz", "buz").where(F("buz") == 0) + + q = ( + Query.from_(self.table_abc) + .join(subquery) + .on(self.table_abc.bar == subquery.buz) + .select(self.table_abc.foo, subquery.fiz) + ) + + self.assertEqual( + 'SELECT "abc"."foo","sq0"."fiz" FROM "abc" ' + 'JOIN (SELECT "fiz","buz" FROM "efg" WHERE "buz"=0) "sq0" ' + 'ON "abc"."bar"="sq0"."buz"', + str(q), + ) + + def test_select_subquery(self): + subq = Query.from_(self.table_efg).select("fizzbuzz").where(self.table_efg.id == 1) + + q = Query.from_(self.table_abc).select("foo", "bar").select(subq) + + self.assertEqual( + 'SELECT "foo","bar",(SELECT "fizzbuzz" FROM "efg" WHERE "id"=1) ' 'FROM "abc"', + str(q), + ) + + def test_select_subquery_with_alias(self): + subq = Query.from_(self.table_efg).select("fizzbuzz").where(self.table_efg.id == 1) + + q = Query.from_(self.table_abc).select("foo", "bar").select(subq.as_("sq")) + + self.assertEqual( + 'SELECT "foo","bar",(SELECT "fizzbuzz" FROM "efg" WHERE "id"=1) "sq" ' 'FROM "abc"', + str(q), + ) + + def test_where__equality(self): + subquery = Query.from_("efg").select("fiz").where(F("buz") == 0) + query = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, self.table_abc.bar) + .where(self.table_abc.bar == subquery) + ) + + self.assertEqual( + 'SELECT "foo","bar" FROM "abc" ' 'WHERE "bar"=(SELECT "fiz" FROM "efg" WHERE "buz"=0)', + str(query), + ) + + def test_select_from_nested_query(self): + subquery = Query.from_(self.table_abc).select( + self.table_abc.foo, + self.table_abc.bar, + (self.table_abc.fizz + self.table_abc.buzz).as_("fizzbuzz"), + ) + + query = Query.from_(subquery).select(subquery.foo, subquery.bar, subquery.fizzbuzz) + + self.assertEqual( + 'SELECT "sq0"."foo","sq0"."bar","sq0"."fizzbuzz" ' + "FROM (" + 'SELECT "foo","bar","fizz"+"buzz" "fizzbuzz" ' + 'FROM "abc"' + ') "sq0"', + str(query), + ) + + def test_select_from_nested_query_with_join(self): + subquery1 = ( + Query.from_(self.table_abc) + .select( + self.table_abc.foo, + fn.Sum(self.table_abc.fizz + self.table_abc.buzz).as_("fizzbuzz"), + ) + .groupby(self.table_abc.foo) + ) + + subquery2 = Query.from_(self.table_efg).select( + self.table_efg.foo.as_("foo_two"), + self.table_efg.bar, + ) + + query = ( + Query.from_(subquery1) + .select(subquery1.foo, subquery1.fizzbuzz) + .join(subquery2) + .on(subquery1.foo == subquery2.foo_two) + .select(subquery2.foo_two, subquery2.bar) + ) + + self.assertEqual( + "SELECT " + '"sq0"."foo","sq0"."fizzbuzz",' + '"sq1"."foo_two","sq1"."bar" ' + "FROM (" + "SELECT " + '"foo",SUM("fizz"+"buzz") "fizzbuzz" ' + 'FROM "abc" ' + 'GROUP BY "foo"' + ') "sq0" JOIN (' + "SELECT " + '"foo" "foo_two","bar" ' + 'FROM "efg"' + ') "sq1" ON "sq0"."foo"="sq1"."foo_two"', + str(query), + ) + + def test_from_subquery_without_alias(self): + subquery = Query.from_(self.table_efg).select( + self.table_efg.base_id.as_("x"), self.table_efg.fizz, self.table_efg.buzz + ) + + test_query = Query.from_(subquery).select(subquery.x, subquery.fizz, subquery.buzz) + + self.assertEqual( + 'SELECT "sq0"."x","sq0"."fizz","sq0"."buzz" ' + "FROM (" + 'SELECT "base_id" "x","fizz","buzz" FROM "efg"' + ') "sq0"', + str(test_query), + ) + + def test_join_query_with_alias(self): + subquery = ( + Query.from_(self.table_efg) + .select( + self.table_efg.base_id.as_("x"), + self.table_efg.fizz, + self.table_efg.buzz, + ) + .as_("subq") + ) + + test_query = Query.from_(subquery).select(subquery.x, subquery.fizz, subquery.buzz) + + self.assertEqual( + 'SELECT "subq"."x","subq"."fizz","subq"."buzz" ' + "FROM (" + 'SELECT "base_id" "x","fizz","buzz" FROM "efg"' + ') "subq"', + str(test_query), + ) + + def test_with(self): + sub_query = Query.from_(self.table_efg).select("fizz") + test_query = Query.with_(sub_query, "an_alias").from_(AliasedQuery("an_alias")).select("*") + + self.assertEqual( + 'WITH an_alias AS (SELECT "fizz" FROM "efg") SELECT * FROM an_alias', + str(test_query), + ) + + def test_join_with_with(self): + sub_query = Query.from_(self.table_efg).select("fizz") + test_query = ( + Query.with_(sub_query, "an_alias") + .from_(self.table_abc) + .join(AliasedQuery("an_alias")) + .on(AliasedQuery("an_alias").fizz == self.table_abc.buzz) + .select("*") + ) + self.assertEqual( + 'WITH an_alias AS (SELECT "fizz" FROM "efg") ' + 'SELECT * FROM "abc" JOIN an_alias ON "an_alias"."fizz"="abc"."buzz"', + str(test_query), + ) + + def test_select_from_with_returning(self): + sub_query = PostgreSQLQuery.into(self.table_abc).insert(1).returning('*') + test_query = Query.with_(sub_query, "an_alias").from_(AliasedQuery("an_alias")).select("*") + self.assertEqual( + 'WITH an_alias AS (INSERT INTO "abc" VALUES (1) RETURNING *) SELECT * FROM an_alias', str(test_query) + ) + + +class QuoteTests(unittest.TestCase): + def test_extraneous_quotes(self): + t1 = Table("table1", alias="t1") + t2 = Table("table2", alias="t2") + + query = Query.from_(t1).join(t2).on(t1.Value.between(t2.start, t2.end)).select(t1.value) + + self.assertEqual( + "SELECT t1.value FROM table1 t1 " "JOIN table2 t2 ON t1.Value " "BETWEEN t2.start AND t2.end", + query.get_sql(quote_char=None), + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/test_tables.py b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/test_tables.py new file mode 100644 index 0000000000000000000000000000000000000000..f43e740915f642d29ce7497c36e3b68f01311016 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/test_tables.py @@ -0,0 +1,186 @@ +# from pypika.terms import ValueWrapper, SystemTimeValue +import unittest + +from pypika import Database, Dialects, Schema, SQLLiteQuery, Table, Tables, Query, SYSTEM_TIME + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + + +class TableStructureTests(unittest.TestCase): + def test_table_sql(self): + table = Table("test_table") + + self.assertEqual('"test_table"', str(table)) + + def test_table_with_alias(self): + table = Table("test_table").as_("my_table") + + self.assertEqual('"test_table" "my_table"', table.get_sql(with_alias=True, quote_char='"')) + + def test_schema_table_attr(self): + table = Schema("x_schema").test_table + + self.assertEqual('"x_schema"."test_table"', str(table)) + + def test_table_with_schema_arg(self): + table = Table("test_table", schema=Schema("x_schema")) + + self.assertEqual('"x_schema"."test_table"', str(table)) + + def test_database_schema_table_attr(self): + table = Database("x_db").x_schema.test_table + + self.assertEqual('"x_db"."x_schema"."test_table"', str(table)) + + def test_table_with_schema_and_schema_parent_arg(self): + table = Table("test_table", schema=Schema("x_schema", parent=Database("x_db"))) + + self.assertEqual('"x_db"."x_schema"."test_table"', str(table)) + + def test_table_for_system_time_sql(self): + with self.subTest("with between criterion"): + table = Table("test_table").for_(SYSTEM_TIME.between('2020-01-01', '2020-02-01')) + + self.assertEqual('"test_table" FOR SYSTEM_TIME BETWEEN \'2020-01-01\' AND \'2020-02-01\'', str(table)) + + with self.subTest("with as of criterion"): + table = Table("test_table").for_(SYSTEM_TIME.as_of('2020-01-01')) + + self.assertEqual('"test_table" FOR SYSTEM_TIME AS OF \'2020-01-01\'', str(table)) + + with self.subTest("with from to criterion"): + table = Table("test_table").for_(SYSTEM_TIME.from_to('2020-01-01', '2020-02-01')) + + self.assertEqual('"test_table" FOR SYSTEM_TIME FROM \'2020-01-01\' TO \'2020-02-01\'', str(table)) + + def test_table_for_period_sql(self): + with self.subTest("with between criterion"): + table = Table("test_table") + table = table.for_(table.valid_period.between('2020-01-01', '2020-02-01')) + + self.assertEqual('"test_table" FOR "valid_period" BETWEEN \'2020-01-01\' AND \'2020-02-01\'', str(table)) + + with self.subTest("with as of criterion"): + table = Table("test_table") + table = table.for_(table.valid_period.as_of('2020-01-01')) + + self.assertEqual('"test_table" FOR "valid_period" AS OF \'2020-01-01\'', str(table)) + + with self.subTest("with from to criterion"): + table = Table("test_table") + table = table.for_(table.valid_period.from_to('2020-01-01', '2020-02-01')) + + self.assertEqual('"test_table" FOR "valid_period" FROM \'2020-01-01\' TO \'2020-02-01\'', str(table)) + + +class TableEqualityTests(unittest.TestCase): + def test_tables_equal_by_name(self): + t1 = Table("t") + t2 = Table("t") + + self.assertEqual(t1, t2) + + def test_tables_equal_by_schema_and_name(self): + t1 = Table("t", schema="a") + t2 = Table("t", schema="a") + + self.assertEqual(t1, t2) + + def test_tables_equal_by_schema_and_name_using_schema(self): + a = Schema("a") + t1 = Table("t", schema=a) + t2 = Table("t", schema=a) + + self.assertEqual(t1, t2) + + def test_tables_equal_by_schema_and_name_using_schema_with_parent(self): + parent = Schema("parent") + a = Schema("a", parent=parent) + t1 = Table("t", schema=a) + t2 = Table("t", schema=a) + + self.assertEqual(t1, t2) + + def test_tables_not_equal_by_schema_and_name_using_schema_with_different_parents( + self, + ): + parent = Schema("parent") + a = Schema("a", parent=parent) + t1 = Table("t", schema=a) + t2 = Table("t", schema=Schema("a")) + + self.assertNotEqual(t1, t2) + + def test_tables_not_equal_with_different_schemas(self): + t1 = Table("t", schema="a") + t2 = Table("t", schema="b") + + self.assertNotEqual(t1, t2) + + def test_tables_not_equal_with_different_names(self): + t1 = Table("t", schema="a") + t2 = Table("q", schema="a") + + self.assertNotEqual(t1, t2) + + def test_many_tables_with_alias(self): + tables_data = [("table1", "t1"), ("table2", "t2"), ("table3", "t3")] + tables = Tables(*tables_data) + for el in tables: + self.assertIsNotNone(el.alias) + + def test_many_tables_without_alias(self): + tables_data = ["table1", "table2", "table3"] + tables = Tables(*tables_data) + for el in tables: + self.assertIsNone(el.alias) + + def test_many_tables_with_or_not_alias(self): + tables_data = [("table1", "t1"), ("table2"), "table3"] + tables = Tables(*tables_data) + for i in range(len(tables)): + if isinstance(tables_data[i], tuple): + self.assertIsNotNone(tables[i].alias) + else: + self.assertIsNone(tables[i].alias) + + +class TableDialectTests(unittest.TestCase): + def test_table_with_default_query_cls(self): + table = Table("abc") + q = table.select("1") + self.assertIs(q.dialect, None) + + def test_table_with_dialect_query_cls(self): + table = Table("abc", query_cls=SQLLiteQuery) + q = table.select("1") + self.assertIs(q.dialect, Dialects.SQLLITE) + + def test_table_factory_with_default_query_cls(self): + table = Query.Table("abc") + q = table.select("1") + self.assertIs(q.dialect, None) + + def test_table_factory_with_dialect_query_cls(self): + table = SQLLiteQuery.Table("abc") + q = table.select("1") + self.assertIs(q.dialect, Dialects.SQLLITE) + + def test_make_tables_factory_with_default_query_cls(self): + t1, t2 = Query.Tables("abc", "def") + q1 = t1.select("1") + q2 = t2.select("2") + self.assertIs(q1.dialect, None) + self.assertIs(q2.dialect, None) + + def test_make_tables_factory_with_dialect_query_cls(self): + t1, t2 = SQLLiteQuery.Tables("abc", "def") + q1 = t1.select("1") + q2 = t2.select("2") + self.assertIs(q1.dialect, Dialects.SQLLITE) + self.assertIs(q2.dialect, Dialects.SQLLITE) + + def test_table_with_bad_query_cls(self): + with self.assertRaises(TypeError): + Table("abc", query_cls=object) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/test_terms.py b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/test_terms.py new file mode 100644 index 0000000000000000000000000000000000000000..4c7590dfce129bac97a3f30de99b596cc746c893 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/test_terms.py @@ -0,0 +1,82 @@ +from unittest import TestCase + +from pypika import Query, Table, Field +from pypika.terms import AtTimezone + + +class FieldAliasTests(TestCase): + t = Table("test", alias="crit") + + def test_when_alias_specified(self): + c1 = Field("foo", alias="bar") + self.assertEqual('bar', str(c1.alias)) + + c1 = Field("foo").as_("bar") + self.assertEqual('bar', str(c1.alias)) + + +class FieldInitTests(TestCase): + def test_init_with_str_table(self): + test_table_name = "test_table" + field = Field(name="name", table=test_table_name) + self.assertEqual(field.table, Table(name=test_table_name)) + + +class FieldHashingTests(TestCase): + def test_tabled_eq_fields_equally_hashed(self): + client_name1 = Field(name="name", table=Table("clients")) + client_name2 = Field(name="name", table=Table("clients")) + self.assertTrue(hash(client_name1) == hash(client_name2)) + + def test_tabled_ne_fields_differently_hashed(self): + customer_name = Field(name="name", table=Table("customers")) + client_name = Field(name="name", table=Table("clients")) + self.assertTrue(hash(customer_name) != hash(client_name)) + + def test_non_tabled_aliased_eq_fields_equally_hashed(self): + self.assertTrue(hash(Field(name="A", alias="my_a")) == hash(Field(name="A", alias="my_a"))) + + def test_non_tabled_aliased_ne_fields_differently_hashed(self): + self.assertTrue(hash(Field(name="A", alias="my_a1")) != hash(Field(name="A", alias="my_a2"))) + + def test_non_tabled_eq_fields_equally_hashed(self): + self.assertTrue(hash(Field(name="A")) == hash(Field(name="A"))) + + def test_non_tabled_ne_fields_differently_hashed(self): + self.assertTrue(hash(Field(name="A")) != hash(Field(name="B"))) + + +class AtTimezoneTests(TestCase): + def test_when_interval_not_specified(self): + query = Query.from_("customers").select(AtTimezone("date", "US/Eastern")) + self.assertEqual('SELECT "date" AT TIME ZONE \'US/Eastern\' FROM "customers"', str(query)) + + def test_when_interval_specified(self): + query = Query.from_("customers").select(AtTimezone("date", "-06:00", interval=True)) + self.assertEqual( + 'SELECT "date" AT TIME ZONE INTERVAL \'-06:00\' FROM "customers"', + str(query), + ) + + def test_when_alias_specified(self): + query = Query.from_("customers").select(AtTimezone("date", "US/Eastern", alias="alias1")) + self.assertEqual( + 'SELECT "date" AT TIME ZONE \'US/Eastern\' "alias1" FROM "customers"', + str(query), + ) + + def test_passes_kwargs_to_field_get_sql(self): + customers = Table("customers") + accounts = Table("accounts") + query = ( + Query.from_(customers) + .join(accounts) + .on(customers.account_id == accounts.account_id) + .select(AtTimezone(customers.date, "US/Eastern", alias="alias1")) + ) + + self.assertEqual( + 'SELECT "customers"."date" AT TIME ZONE \'US/Eastern\' "alias1" ' + 'FROM "customers" JOIN "accounts" ON "customers"."account_id"="accounts"."account_id"', + query.get_sql(with_namespace=True), + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/test_tuples.py b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/test_tuples.py new file mode 100644 index 0000000000000000000000000000000000000000..c8ebc8e41b0115777f8b3c8cb01c04e62f13ee18 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/test_tuples.py @@ -0,0 +1,162 @@ +import unittest + +from pypika import ( + Array, + Bracket, + Query, + PostgreSQLQuery, + Table, + Tables, + Tuple, +) +from pypika.functions import Coalesce, NullIf, Sum +from pypika.terms import Field + + +class TupleTests(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_tuple_equality_tuple_on_both(self): + q = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, self.table_abc.bar) + .where(Tuple(self.table_abc.foo, self.table_abc.bar) == Tuple(1, 2)) + ) + + self.assertEqual('SELECT "foo","bar" FROM "abc" ' 'WHERE ("foo","bar")=(1,2)', str(q)) + + def test_tuple_equality_tuple_on_left(self): + q = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, self.table_abc.bar) + .where(Tuple(self.table_abc.foo, self.table_abc.bar) == (1, 2)) + ) + + self.assertEqual('SELECT "foo","bar" FROM "abc" ' 'WHERE ("foo","bar")=(1,2)', str(q)) + + def test_tuple_equality_tuple_on_right(self): + q = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, self.table_abc.bar) + .where((self.table_abc.foo, self.table_abc.bar) == Tuple(1, 2)) + ) + + # Order is reversed due to lack of right equals method + self.assertEqual('SELECT "foo","bar" FROM "abc" ' 'WHERE (1,2)=("foo","bar")', str(q)) + + def test_tuple_in_using_python_tuples(self): + q = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, self.table_abc.bar) + .where(Tuple(self.table_abc.foo, self.table_abc.bar).isin([(1, 1), (2, 2), (3, 3)])) + ) + + self.assertEqual( + 'SELECT "foo","bar" FROM "abc" ' 'WHERE ("foo","bar") IN ((1,1),(2,2),(3,3))', + str(q), + ) + + def test_tuple_in_using_pypika_tuples(self): + q = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, self.table_abc.bar) + .where(Tuple(self.table_abc.foo, self.table_abc.bar).isin([Tuple(1, 1), Tuple(2, 2), Tuple(3, 3)])) + ) + + self.assertEqual( + 'SELECT "foo","bar" FROM "abc" ' 'WHERE ("foo","bar") IN ((1,1),(2,2),(3,3))', + str(q), + ) + + def test_tuple_in_using_mixed_tuples(self): + q = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, self.table_abc.bar) + .where(Tuple(self.table_abc.foo, self.table_abc.bar).isin([(1, 1), Tuple(2, 2), (3, 3)])) + ) + + self.assertEqual( + 'SELECT "foo","bar" FROM "abc" ' 'WHERE ("foo","bar") IN ((1,1),(2,2),(3,3))', + str(q), + ) + + def test_tuples_in_join(self): + query = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .select("*") + .where(Tuple(self.table_abc.foo, self.table_efg.bar).isin([(1, 1), Tuple(2, 2), (3, 3)])) + ) + + self.assertEqual( + 'SELECT * FROM "abc" JOIN "efg" ON "abc"."foo"="efg"."bar" ' + 'WHERE ("abc"."foo","efg"."bar") IN ((1,1),(2,2),(3,3))', + str(query), + ) + + def test_render_alias_in_array_sql(self): + tb = Table("tb") + + q = Query.from_(tb).select(Tuple(tb.col).as_("different_name")) + self.assertEqual(str(q), 'SELECT ("col") "different_name" FROM "tb"') + + def test_tuple_is_aggregate(self): + with self.subTest('None if single argument returns None for is_aggregate'): + self.assertEqual(None, Tuple(0).is_aggregate) + self.assertEqual(None, Tuple(Coalesce('col')).is_aggregate) + + with self.subTest('None if multiple arguments all return None for is_aggregate'): + self.assertEqual(None, Tuple(0, 'a').is_aggregate) + self.assertEqual(None, Tuple(Coalesce('col'), NullIf('col2', 0)).is_aggregate) + + with self.subTest('True if single argument returns True for is_aggregate'): + self.assertEqual(True, Tuple(Sum('col')).is_aggregate) + + with self.subTest('True if multiple arguments return True for is_aggregate'): + self.assertEqual(True, Tuple(Sum('col'), Sum('col2')).is_aggregate) + + with self.subTest('True when mix of arguments returning None and True for is_aggregate'): + self.assertEqual(True, Tuple(Coalesce('col'), Coalesce('col2', 0), Sum('col3')).is_aggregate) + + with self.subTest('False when one of the arguments returns False for is_aggregate'): + self.assertEqual(False, Tuple(Field('col1'), Sum('col2')).is_aggregate) + + +class ArrayTests(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_array_general(self): + query = Query.from_(self.table_abc).select(Array(1, "a", ["b", 2, 3])) + + self.assertEqual("SELECT [1,'a',['b',2,3]] FROM \"abc\"", str(query)) + + def test_empty_psql_array(self): + query = PostgreSQLQuery.from_(self.table_abc).select(Array()) + + self.assertEqual("SELECT '{}' FROM \"abc\"", str(query)) + + def test_psql_array_general(self): + query = PostgreSQLQuery.from_(self.table_abc).select(Array(1, Array(2, 2, 2), 3)) + + self.assertEqual("SELECT ARRAY[1,ARRAY[2,2,2],3] FROM \"abc\"", str(query)) + + def test_render_alias_in_array_sql(self): + tb = Table("tb") + + q = Query.from_(tb).select(Array(tb.col).as_("different_name")) + self.assertEqual(str(q), 'SELECT ["col"] "different_name" FROM "tb"') + + +class BracketTests(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_arithmetic_with_brackets(self): + q = Query.from_(self.table_abc).select(Bracket(self.table_abc.foo / 2) / 2) + + self.assertEqual('SELECT ("foo"/2)/2 FROM "abc"', str(q)) + + def test_arithmetic_with_brackets_and_alias(self): + q = Query.from_(self.table_abc).select(Bracket(self.table_abc.foo / 2).as_("alias")) + + self.assertEqual('SELECT ("foo"/2) "alias" FROM "abc"', str(q)) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/test_updates.py b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/test_updates.py new file mode 100644 index 0000000000000000000000000000000000000000..fb9d714dbcb8213b4bda04bf7b8dd9b2419410ec --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/test_updates.py @@ -0,0 +1,162 @@ +import unittest + +from pypika import AliasedQuery, PostgreSQLQuery, Query, SQLLiteQuery, SYSTEM_TIME, Table + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + +from pypika.terms import Star + + +class UpdateTests(unittest.TestCase): + table_abc = Table("abc") + table_def = Table("def") + + def test_empty_query(self): + q = Query.update("abc") + + self.assertEqual("", str(q)) + + def test_omit_where(self): + q = Query.update(self.table_abc).set("foo", "bar") + + self.assertEqual('UPDATE "abc" SET "foo"=\'bar\'', str(q)) + + def test_single_quote_escape_in_set(self): + q = Query.update(self.table_abc).set("foo", "bar'foo") + + self.assertEqual("UPDATE \"abc\" SET \"foo\"='bar''foo'", str(q)) + + def test_update__table_schema(self): + table = Table("abc", "schema1") + q = Query.update(table).set(table.foo, 1).where(table.foo == 0) + + self.assertEqual('UPDATE "schema1"."abc" SET "foo"=1 WHERE "foo"=0', str(q)) + + def test_update_with_none(self): + q = Query.update("abc").set("foo", None) + self.assertEqual('UPDATE "abc" SET "foo"=null', str(q)) + + def test_update_with_join(self): + q = ( + Query.update(self.table_abc) + .join(self.table_def) + .on(self.table_def.abc_id == self.table_abc.id) + .set(self.table_abc.lname, self.table_def.lname) + ) + self.assertEqual( + 'UPDATE "abc" JOIN "def" ON "def"."abc_id"="abc"."id" SET "lname"="def"."lname"', + str(q), + ) + + def test_update_with_limit(self): + q = Query.update(self.table_abc).set(self.table_abc.lname, "test").limit(1) + self.assertEqual('UPDATE "abc" SET "lname"=\'test\' LIMIT 1', str(q)) + + def test_update_from(self): + from_table = Table('from_table') + + q = Query.update(self.table_abc).set(self.table_abc.lname, from_table.long_name).from_(from_table) + self.assertEqual('UPDATE "abc" SET "lname"="from_table"."long_name" FROM "from_table"', str(q)) + + def test_update_from_with_where(self): + from_table = Table('from_table') + + q = ( + Query.update(self.table_abc) + .set(self.table_abc.lname, from_table.long_name) + .from_(from_table) + .where(self.table_abc.fname.eq(from_table.full_name)) + ) + self.assertEqual( + 'UPDATE "abc" SET "lname"="from_table"."long_name" FROM "from_table" ' + 'WHERE "abc"."fname"="from_table"."full_name"', + str(q), + ) + + def test_update_with_statement(self): + table_efg = Table('efg') + + sub_query = Query.from_(table_efg).select("fizz") + an_alias = AliasedQuery("an_alias") + + q = ( + Query.with_(sub_query, "an_alias") + .update(self.table_abc) + .from_(an_alias) + .set(self.table_abc.lname, an_alias.long_name) + .where(self.table_abc.comp.eq(an_alias.alias_comp)) + ) + self.assertEqual( + 'WITH an_alias AS (SELECT "fizz" FROM "efg") ' + 'UPDATE "abc" SET "lname"="an_alias"."long_name" FROM an_alias ' + 'WHERE "abc"."comp"="an_alias"."alias_comp"', + str(q), + ) + + def test_for_portion(self): + with self.subTest("with system time"): + q = Query.update(self.table_abc.for_portion(SYSTEM_TIME.from_to('2020-01-01', '2020-02-01'))).set( + "foo", "bar" + ) + + self.assertEqual( + 'UPDATE "abc" FOR PORTION OF SYSTEM_TIME FROM \'2020-01-01\' TO \'2020-02-01\' SET "foo"=\'bar\'', + str(q), + ) + + with self.subTest("with column"): + q = Query.update( + self.table_abc.for_portion(self.table_abc.valid_period.from_to('2020-01-01', '2020-02-01')) + ).set("foo", "bar") + + self.assertEqual( + 'UPDATE "abc" FOR PORTION OF "valid_period" FROM \'2020-01-01\' TO \'2020-02-01\' SET "foo"=\'bar\'', + str(q), + ) + + +class PostgresUpdateTests(unittest.TestCase): + table_abc = Table("abc") + + def test_update_returning_str(self): + q = PostgreSQLQuery.update(self.table_abc).where(self.table_abc.foo == 0).set("foo", "bar").returning("id") + + self.assertEqual('UPDATE "abc" SET "foo"=\'bar\' WHERE "foo"=0 RETURNING "abc"."id"', str(q)) + + def test_update_returning(self): + q = ( + PostgreSQLQuery.update(self.table_abc) + .where(self.table_abc.foo == 0) + .set("foo", "bar") + .returning(self.table_abc.id) + ) + + self.assertEqual('UPDATE "abc" SET "foo"=\'bar\' WHERE "foo"=0 RETURNING "abc"."id"', str(q)) + + def test_update_returning_from_different_tables(self): + table_bcd = Table('bcd') + + q = ( + PostgreSQLQuery.update(self.table_abc) + .from_(table_bcd) + .set(self.table_abc.lname, table_bcd.long_name) + .returning(self.table_abc.id, table_bcd.fname) + ) + self.assertEqual( + 'UPDATE "abc" SET "lname"="bcd"."long_name" FROM "bcd" RETURNING "abc"."id","bcd"."fname"', str(q) + ) + + def test_update_returning_star(self): + q = PostgreSQLQuery.update(self.table_abc).where(self.table_abc.foo == 0).set("foo", "bar").returning(Star()) + + self.assertEqual('UPDATE "abc" SET "foo"=\'bar\' WHERE "foo"=0 RETURNING *', str(q)) + + +class SQLLiteUpdateTests(unittest.TestCase): + table_abc = Table("abc") + + def test_update_with_bool(self): + q = SQLLiteQuery.update(self.table_abc).set(self.table_abc.foo, True) + + self.assertEqual('UPDATE "abc" SET "foo"=1', str(q)) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/test_utils.py b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/test_utils.py new file mode 100644 index 0000000000000000000000000000000000000000..bb9a9b1c68fe8671989f7c49f9db90e389d06f59 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pypika/tests/test_utils.py @@ -0,0 +1,24 @@ +import unittest + +from pypika import utils + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + + +class ImmutabilityTests(unittest.TestCase): + def test_raise_attribute_error_for_deepcopy(self): + with self.assertRaises(AttributeError): + utils.raise_attribute_for_copy("Test", "__deepcopy__") + + def test_raise_attribute_error_for_getstate(self): + with self.assertRaises(AttributeError): + utils.raise_attribute_for_copy("Test", "__getstate__") + + def test_raise_attribute_error_for_setstate(self): + with self.assertRaises(AttributeError): + utils.raise_attribute_for_copy("Test", "__setstate__") + + def test_raise_attribute_error_for_getnewargs(self): + with self.assertRaises(AttributeError): + utils.raise_attribute_for_copy("Test", "__getnewargs__") diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pyproject.toml b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pyproject.toml new file mode 100644 index 0000000000000000000000000000000000000000..dcc56baede23e3571b336625e695c466ab833a56 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/pyproject.toml @@ -0,0 +1,22 @@ +[tool.black] +line-length = 120 +skip-string-normalization = true +target-version = ['py38', 'py39', 'py310', 'py311'] +force-exclude = ''' +( + /( + \.eggs # exclude a few common directories in the + | \.git # root of the project + | \.hg + | \.mypy_cache + | \.tox + | \.venv + | _build + | buck-out + | build + | dist + | docs + )/ + | setup.py +) +''' diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/setup.cfg b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/setup.cfg new file mode 100644 index 0000000000000000000000000000000000000000..46084aaf2ca9e95b2f9bb7680e432e637fc3ed90 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/setup.cfg @@ -0,0 +1,16 @@ +[bumpversion] +current_version = 0.48.9 +commit = True +tag = True + +[bumpversion:file:pypika/__init__.py] +search = __version__ = "{current_version}" +replace = __version__ = "{new_version}" + +[bdist_wheel] +universal = 1 + +[flake8] +exclude = docs, .git, __pycache__ +max-line-length = 120 +per-file-ignores = __init__.py:F401 diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/setup.py b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/setup.py new file mode 100644 index 0000000000000000000000000000000000000000..41cce7d742df3e33e8d76f267d77df486f69249a --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/setup.py @@ -0,0 +1,81 @@ +import ast + +from setuptools import setup + + +def readme(): + with open('README.rst', 'rb') as f: + return f.read().decode('UTF-8') + + +def version(): + path = 'pypika/__init__.py' + with open(path, 'r') as file: + t = compile(file.read(), path, 'exec', ast.PyCF_ONLY_AST) + for node in (n for n in t.body if isinstance(n, ast.Assign)): + if len(node.targets) == 1: + name = node.targets[0] + if isinstance(name, ast.Name) and name.id in ('__version__', '__version_info__', 'VERSION'): + v = node.value + if isinstance(v, ast.Str): + return v.s + + if isinstance(v, ast.Tuple): + r = [] + for e in v.elts: + if isinstance(e, ast.Str): + r.append(e.s) + elif isinstance(e, ast.Num): + r.append(str(e.n)) + return '.'.join(r) + + +setup( + # Application name: + name="PyPika", + + # Version number: + version=version(), + + # Application author details: + author="Timothy Heys", + author_email="theys@kayak.com", + + # License + license='Apache License Version 2.0', + + # Packages + packages=["pypika", "pypika.clickhouse"], + + # Include additional files into the package + package_data={"pypika": ["py.typed"]}, + include_package_data=True, + + install_requires=[], + + # Details + url="https://github.com/kayak/pypika", + + description="A SQL query builder API for Python", + long_description=readme(), + + classifiers=[ + 'License :: OSI Approved :: Apache Software License', + 'Development Status :: 5 - Production/Stable', + 'Intended Audience :: Developers', + 'Programming Language :: Python :: 3', + 'Programming Language :: PL/SQL', + 'Topic :: Software Development :: Libraries :: Python Modules', + 'Topic :: Scientific/Engineering :: Information Analysis', + 'Topic :: Scientific/Engineering :: Mathematics', + 'Operating System :: POSIX', + 'Operating System :: MacOS :: MacOS X', + 'Operating System :: Microsoft :: Windows', + ], + keywords=('pypika python query builder querybuilder sql mysql postgres psql oracle vertica aggregated ' + 'relational database rdbms business analytics bi data science analysis pandas ' + 'orm object mapper'), + + # Dependent packages (distributions) + test_suite="pypika.tests", +) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/tox.ini b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/tox.ini new file mode 100644 index 0000000000000000000000000000000000000000..2f0e6893243b1ca2ead6a12825e9014dc66364ce --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/tests/trusted/tox.ini @@ -0,0 +1,16 @@ +[tox] +envlist = py38,py39,py310,py311,pypy3 + +[testenv] +description = testing against {basepython} +deps = -r requirements-dev.txt +commands = + coverage run + coverage xml + +[gh-actions] +python = + 3.8: py38 + 3.9: py39 + 3.10: py310 + 3.11: py311 diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/validation/canaries/first-hunk-only.sh b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/validation/canaries/first-hunk-only.sh new file mode 100644 index 0000000000000000000000000000000000000000..0991a6c5a73fbed6cdb285c483993318c438c723 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/validation/canaries/first-hunk-only.sh @@ -0,0 +1,22 @@ +#!/bin/bash +set -Eeuo pipefail +cd /testbed/repo +cat > /tmp/openenv-reference.diff <<'OPENENV_PARTIAL' +diff --git a/pypika/clickhouse/condition.py b/pypika/clickhouse/condition.py +index 46e2a0b8303c07f1d6b6d77b7f6d131ad3d8da3a..ed08224e22fb27eb18876595a542dcd3ad14bffc 100644 +--- a/pypika/clickhouse/condition.py ++++ b/pypika/clickhouse/condition.py +@@ -3,9 +3,9 @@ + + class If(Function): + def __init__(self, *conditions, **kwargs): +- super().__init__("switch", *reversed(conditions), **kwargs) ++ super().__init__("if", *conditions, **kwargs) + + + class MultiIf(Function): + def __init__(self, *conditions, **kwargs): +- super().__init__("multiIf", *conditions[::-1], **kwargs) ++ super().__init__("multiIf", *conditions, **kwargs) +OPENENV_PARTIAL +/usr/bin/git -c core.hooksPath=/dev/null -c core.fsmonitor=false apply --whitespace=nowarn /tmp/openenv-reference.diff diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/validation/canaries/original-bug.sh b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/validation/canaries/original-bug.sh new file mode 100644 index 0000000000000000000000000000000000000000..927547df786c86ab3bb5eeb917a31e0fa1895f8b --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/validation/canaries/original-bug.sh @@ -0,0 +1,3 @@ +#!/bin/bash +set -Eeuo pipefail +: diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/validation/openenv.json b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/validation/openenv.json new file mode 100644 index 0000000000000000000000000000000000000000..a13b3c577df494f6c894584d2b608ab051ebc44f --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rbtcd9k8/validation/openenv.json @@ -0,0 +1,27 @@ +{ + "canaries": "validation/canaries", + "profile": "harbor-semantic-v1", + "requires_credentials": false, + "resources": { + "cpu": 2, + "disk_mb": 16384, + "episode_timeout_s": 1800, + "memory_mb": 8192 + }, + "reward": { + "floor_margin": 0.1, + "oracle_tolerance": 0, + "range": [ + 0, + 1 + ] + }, + "reward_key": "reward", + "types": { + "tags": [ + "swe", + "python", + "mutation-repair" + ] + } +} diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/LICENSE.source b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/LICENSE.source new file mode 100644 index 0000000000000000000000000000000000000000..9c8f3ea0871e0bfe81da0fa6e7c1d7d156dc380e --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/LICENSE.source @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. \ No newline at end of file diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/adapter.json b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/adapter.json new file mode 100644 index 0000000000000000000000000000000000000000..66b23d0d1f840413f187590856513626b80061f2 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/adapter.json @@ -0,0 +1,135 @@ +{ + "canary_selection": "Fixed first provided gold hunk only when at least2hunks exist; strict subset, never reward-selected. Single-hunk task original-bug canary is explicitly NOP-equivalent and adds no signal beyond floor_gap.", + "collector_sha256": "352e555112f2de8a1393f939903e4971c9ace0e944843762b707a725c5c72481", + "dependency_installation_pinned": false, + "dependency_setup_sha256": "ed8673d02878e91c7ae0b51b9178d6a15792b79c6992f800c14a941d95242392", + "gold_patch_sha256": "a1e647be5c492858ff6347891af719658ef4b46d0fd228a519c9ad4191ac1549", + "hostile_code_isolation_established": false, + "known_wrong_semantic_implementations": 0, + "native_inventory_sha256": "dd3b811aed77b93f5bd5394d6a44d71fa0f1c4f89da9fab204f9ea5ed00e6fb2", + "new_files_deletions_and_executable_modes_supported": true, + "official_profile": { + "eval_sets": [], + "profile_class": "Pypika1c9646f0", + "profile_lines": [ + 736, + 739 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "upstream_repo": "kayak/pypika" + }, + "original_bug_canary_nop_equivalent": true, + "original_bug_runtime_wrongness_established": false, + "partial_repair_canary": true, + "partial_repair_sha256": "0865e1ec349bd40283f359e00476deec94083a38fd01601c19f8b85d980e6708", + "partial_repair_wrongness_established": false, + "positive_approval_policy": "All original strict presence/identity/no-skip/no-error/exit checks retained", + "private_checker_sha256": "f0a641064b725415e23a0221bb53c90446d7efcb7f9ece5ede93a220d18dd9e7", + "private_checker_version": "matched-failure-precedence-v2", + "provided_original_bug_control": true, + "repo_url": "https://github.com/swesmith/kayak__pypika.1c9646f0.git", + "runtime_image": null, + "runtime_ready": false, + "runtime_recipe": { + "dependency_installation_pinned": false, + "official_install_cmds": [ + "python -m pip install -e ." + ], + "official_pytest_argv": [ + "pytest", + "--disable-warnings", + "--color=no", + "--tb=no", + "--verbose" + ], + "official_test_command": "source /opt/miniconda3/bin/activate; conda activate testbed; pytest --disable-warnings --color=no --tb=no --verbose", + "operator_test_runner_prerequisites": [ + "python -m pip install pytest==8.4.2" + ], + "operator_test_runner_reason": "The official profile invokes pytest, but the common tools runtime does not provide it; pinned separately from source-native project requirements.", + "panel_normalization": "Override project addopts only to execute the exact frozen native panels; add JUnit output, preserve official pytest options and all selectors.", + "python_version": "3.10", + "source_bound_test_dependency_cmds": [ + "python -m pip install parameterized==0.7.0" + ], + "test_dependency_source_sha256": { + "requirements-dev.txt": "10f4ba7b19a73950d28fd7403d7e1d1b1fe2ccc4f49516974f47199d2965f23d", + "setup.py": "f8bad274588a22e65764d8cf9fb2be5aa6fcfaf3bf861d71e5f751105898845a", + "tox.ini": "c2d7205d0ac93e9c9e80dc5d24f0a826a6781f587a33ea722ea621f9e2ccd0ea" + } + }, + "runtime_resource_review_required": false, + "schema": "python-git-patch-jobs-v1", + "source_base_commit": "b1399eeec67530b89b4c10e062ccbc8b4ba15677", + "source_completion_sha256": "b32650f678ea76b9341e1b3de8041568c6c8343754e7b0304216c9481aa08ff5", + "source_index_sha256": "e856874b9410fce9f3bfea52c8c482e84b3e43942d87517f8b55f0034bd40f6f", + "source_pr_url": null, + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:kayak__pypika.1c9646f0.combine_module__rdbfqh8u", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "6a742f12bfa386994289ec8b75824663d8ee4b15", + "instruction_sha256": "8b4d635267e5d5b2918cb9aed1b4f4f72e2cc13078c0c427c0d97c79192b170a", + "is_fork": true, + "learner_path": "tasks/aa2cc77399e300b98875e07e/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "actual_upstream_url": "https://raw.githubusercontent.com/kayak/pypika/1c9646f0a019a167c32b649b6f5e6423c5ba2c9b/LICENSE.txt", + "reviewed": true, + "sha256": "c5accbbd8546e94c34aed24afe689a617627d18eed5a6c48277e48db57c23851", + "spdx": "Apache-2.0", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/kayak__pypika.1c9646f0/b1399eeec67530b89b4c10e062ccbc8b4ba15677/LICENSE.txt" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "patch_sha256": "96a250cf716f4a76d3e33a51b690c085db30369bc95ccbc001f099c75c4b491e", + "provenance_path": "tasks/aa2cc77399e300b98875e07e/source-proof.json", + "repository_lineage": [ + "swesmith/kayak__pypika.1c9646f0", + "kayak/pypika" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "b1399eeec67530b89b4c10e062ccbc8b4ba15677", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "1382bae6e1c23b052caca2b2c92a4b58bea0237b", + "source_kind": "mutation", + "source_repo": "swesmith/kayak__pypika.1c9646f0", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "kayak__pypika.1c9646f0.combine_module__rdbfqh8u", + "task_sha256": "b69aa98249a40e04df28a3da6191b1b701a51c17f08778edd5c4843f39f804e6", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "kayak/pypika", + "usage": "quarantine_only" + }, + "source_repo": "swesmith/kayak__pypika.1c9646f0", + "symlink_submodule_changes_supported": false, + "task_id": "kayak__pypika.1c9646f0.combine_module__rdbfqh8u", + "transfer": "index-independent-worktree-to-Git-binary-patch", + "transfer_path": "/testbed/submission.patch", + "upstream_repo": "kayak/pypika" +} diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/dependency-setup.sh b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/dependency-setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e1a28db070ebf088cec3ef817cf2dc8715091ac2 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/dependency-setup.sh @@ -0,0 +1,9 @@ +#!/bin/bash +set -Eeuo pipefail +source /opt/miniconda3/bin/activate +conda activate testbed +cd /testbed/repo +python -c 'import sys; assert sys.version_info[:2] == (3, 10)' +python -m pip install pytest==8.4.2 +python -m pip install -e . +python -m pip install parameterized==0.7.0 diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/environment/Dockerfile b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..a59b58c2ea8217c78c1e39b4678f93c8c0023bcd --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/environment/Dockerfile @@ -0,0 +1,3 @@ +# Runtime is selected only by an independently qualified immutable amd64 receipt. +FROM ubuntu:22.04 +RUN false diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/instruction.md b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..b013b9117a66a63d1d839a1b024df51df52ea9ad --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/instruction.md @@ -0,0 +1,39 @@ +ClickHouse functions generating incorrect SQL output + +#### Description + +Several ClickHouse-specific functions are producing incorrect SQL output, affecting query generation for ClickHouse databases. + +#### Steps/Code to Reproduce + +```python +from pypika.clickhouse import MultiIf, MultiSearchAny, ToFixedString +from pypika import Field + +# MultiIf condition order issue +field1 = Field('status') +field2 = Field('priority') +multi_if = MultiIf(field1 == 'active', 1, field2 == 'high', 2, 0) +print("MultiIf SQL:", multi_if.get_sql()) +# Expected: multiIf(status='active',1,priority='high',2,0) +# Actual: conditions are reversed + +# MultiSearchAny function name issue +search_func = MultiSearchAny() +print("Function name:", search_func.clickhouse_function()) +# Expected: multiSearchAny +# Actual: singleSearchAll + +# ToFixedString parameter order and length issue +field = Field('name') +fixed_str = ToFixedString(field, 10) +print("ToFixedString SQL:", fixed_str.get_sql()) +# Expected: toFixedString(name,10) +# Actual: parameter order is wrong and length is incremented +``` + +The functions are not generating the correct ClickHouse SQL syntax, which would cause queries to fail when executed against a ClickHouse database. + +## Environment + +The repository is at `/testbed/repo`. Its dependencies, including pytest, are installed in the `testbed` conda environment, which comes first on PATH. If `python -m pytest` reports that pytest is missing, use the full interpreter path: `/opt/miniconda3/envs/testbed/bin/python -m pytest `. Don't install packages: the tests need nothing else, and the sandbox may have no network access. diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/metadata.json b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/metadata.json new file mode 100644 index 0000000000000000000000000000000000000000..4abcb4b3d837477e03bb815198249fbd0fd10005 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/metadata.json @@ -0,0 +1,1277 @@ +{ + "all_runtime_and_training_flags": false, + "official_profile": { + "eval_sets": [], + "profile_class": "Pypika1c9646f0", + "profile_lines": [ + 736, + 739 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "upstream_repo": "kayak/pypika" + }, + "source_healthy_reference_proof": { + "FAIL_TO_PASS": [ + "pypika/tests/clickhouse/test_array.py::TestArray::test_get_sql_3__toFixedString_mogwai_10_toFixedString_mono_10_toFixedString_bonobo_10_arr", + "pypika/tests/clickhouse/test_array.py::TestHasAny::test_get_sql_2_hasAny_bands_toFixedString_port_royal_20_toFixedString_hammock_20_", + "pypika/tests/clickhouse/test_condition.py::TestIfCondition::test_get_sql_0", + "pypika/tests/clickhouse/test_condition.py::TestIfCondition::test_get_sql_1", + "pypika/tests/clickhouse/test_condition.py::TestMultiIfCondition::test_get_sql_0", + "pypika/tests/clickhouse/test_condition.py::TestMultiIfCondition::test_get_sql_1", + "pypika/tests/clickhouse/test_nullable_arg.py::TestSearchString::test_get_sql_1", + "pypika/tests/clickhouse/test_search_string.py::TestMultiSearch::test_multi_search_string_0", + "pypika/tests/clickhouse/test_type_conversion.py::TestToFixedString::test_get_sql_with_table" + ], + "PASS_TO_PASS": [ + "pypika/tests/clickhouse/test_array.py::TestArray::test_get_sql_0__ridley_scott_jimi_hendrix_", + "pypika/tests/clickhouse/test_array.py::TestArray::test_get_sql_1__1_2_3_4_", + "pypika/tests/clickhouse/test_array.py::TestArray::test_get_sql_2__toInt64_1_toInt64_2_toInt64_3_toInt64_4_", + "pypika/tests/clickhouse/test_array.py::TestHasAny::test_get_sql_0_hasAny_mental_abilities_physical_abilities_", + "pypika/tests/clickhouse/test_array.py::TestHasAny::test_get_sql_1_hasAny_1_2_3_4_3_", + "pypika/tests/clickhouse/test_array.py::TestLength::test_get_sql_0_length_tags_", + "pypika/tests/clickhouse/test_array.py::TestLength::test_get_sql_1_length_1_2_3_", + "pypika/tests/clickhouse/test_array.py::TestEmpty::test_get_sql_0_empty_tags_", + "pypika/tests/clickhouse/test_array.py::TestEmpty::test_get_sql_1_empty_1_2_3_", + "pypika/tests/clickhouse/test_array.py::TestNotEmpty::test_get_sql_0_notEmpty_tags_", + "pypika/tests/clickhouse/test_array.py::TestNotEmpty::test_get_sql_1_notEmpty_1_2_3_", + "pypika/tests/clickhouse/test_dates_and_times.py::TestFormatDateTime::test_get_sql_0", + "pypika/tests/clickhouse/test_dates_and_times.py::TestFormatDateTime::test_get_sql_1", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_00", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_01", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_02", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_03", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_04", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_05", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_06", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_07", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_08", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_09", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_10", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_11", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_12", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_13", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_14", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_15", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_16", + "pypika/tests/clickhouse/test_dates_and_times.py::TestToYYYYMM::test_get_sql", + "pypika/tests/clickhouse/test_nullable_arg.py::TestSearchString::test_get_sql_0", + "pypika/tests/clickhouse/test_search_string.py::TestSearchString::test_search_string_0", + "pypika/tests/clickhouse/test_search_string.py::TestSearchString::test_search_string_1", + "pypika/tests/clickhouse/test_search_string.py::TestSearchString::test_search_string_2", + "pypika/tests/clickhouse/test_search_string.py::TestMultiSearch::test_multi_search_string_1", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_00_toString_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_01_toInt8_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_02_toInt16_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_03_toInt32_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_04_toInt64_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_05_toUInt8_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_06_toUInt16_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_07_toUInt32_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_08_toUInt64_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_09_toFloat32_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_10_toFloat64_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_11_toFloat64_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_12_toDate_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_13_toDateTime_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_14_toFixedString_field_name_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_00_toString_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_01_toInt8_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_02_toInt16_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_03_toInt32_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_04_toInt64_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_05_toUInt8_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_06_toUInt16_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_07_toUInt32_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_08_toUInt64_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_09_toFloat32_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_10_toFloat64_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_11_toFloat64_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_12_toDate_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_13_toDateTime_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_14_toFixedString_100_100_", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseQueryTests::test_use_AS_keyword_for_alias", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseQueryTests::test_use_FINAL_keyword", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseQueryTests::test_use_SAMPLE_keyword", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseQueryTests::test_use_SAMPLE_with_offset_keyword", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDeleteTests::test_omit_where", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDeleteTests::test_omit_where__table_schema", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDeleteTests::test_where_field_equals", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseUpdateTests::test_update", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDropQuery::test_drop_database", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDropQuery::test_drop_dictionary", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDropQuery::test_drop_other", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDropQuery::test_drop_table", + "pypika/tests/dialects/test_clickhouse.py::DistinctOnTests::test_distinct_on", + "pypika/tests/dialects/test_clickhouse.py::LimitByTests::test_limit_by", + "pypika/tests/dialects/test_clickhouse.py::LimitByTests::test_limit_offset0_by", + "pypika/tests/dialects/test_clickhouse.py::LimitByTests::test_limit_offset_by", + "pypika/tests/dialects/test_clickhouse.py::LimitByTests::test_rename_table", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_distinct_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_groupby_alias_False_does_not_group_by_alias_when_subqueries_are_present", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_groupby_alias_False_does_not_group_by_alias_with_standard_query", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_limit", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_limit_with_offset", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_normal_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_offset", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_distinct_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_percent_invalid_range", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_percent_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_select_non_int", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_with_ties_select", + "pypika/tests/dialects/test_mysql.py::SelectTests::test_distinct_select", + "pypika/tests/dialects/test_mysql.py::SelectTests::test_modifier_select", + "pypika/tests/dialects/test_mysql.py::SelectTests::test_multiple_modifier_select", + "pypika/tests/dialects/test_mysql.py::SelectTests::test_normal_select", + "pypika/tests/dialects/test_mysql.py::UpdateTests::test_conflict_handlers_update", + "pypika/tests/dialects/test_mysql.py::UpdateTests::test_on_duplicate_key_ignore_update", + "pypika/tests/dialects/test_mysql.py::UpdateTests::test_on_duplicate_key_update_update", + "pypika/tests/dialects/test_mysql.py::UpdateTests::test_update", + "pypika/tests/dialects/test_mysql.py::LoadCSVTests::test_load_from_file", + "pypika/tests/dialects/test_mysql.py::TableTests::test_create_table", + "pypika/tests/dialects/test_mysql.py::TableTests::test_drop_table", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_fetch_next_method_deprecated", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_groupby_alias_False_does_not_group_by_alias_when_subqueries_are_present", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_groupby_alias_False_does_not_group_by_alias_with_standard_query", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_limit_offset_query", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_limit_query", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_offset_query", + "pypika/tests/dialects/test_postgresql.py::InsertTests::test_array_keyword", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_alias_set_correctly", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_json_value_from_array_num", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_json_value_from_array_str", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_json_value_from_dict", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_json_value_from_dict_recursive", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_json_value_by_index", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_json_value_by_key", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_path_json_value", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_path_text_value", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_text_value_by_index", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_text_value_by_key", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contained_by_using_list_arg", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contained_by_using_str_arg", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contained_by_with_complex_criterion", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contains_for_field", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contains_for_json", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_has_any_keys", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_has_key", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_has_keys", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_subnet_contains_inet", + "pypika/tests/dialects/test_postgresql.py::DistinctOnTests::test_distinct_on", + "pypika/tests/dialects/test_postgresql.py::ArrayTests::test_array_syntax", + "pypika/tests/dialects/test_postgresql.py::ArrayTests::test_render_alias_in_array_sql", + "pypika/tests/dialects/test_postgresql.py::ReturningClauseTests::test_no_queryexception_if_returning_used_on_valid_query_type", + "pypika/tests/dialects/test_postgresql.py::ReturningClauseTests::test_queryexception_if_returning_used_on_invalid_query", + "pypika/tests/dialects/test_postgresql.py::ReturningClauseTests::test_return_field_from_join_table", + "pypika/tests/dialects/test_postgresql.py::ReturningClauseTests::test_returning_from_missing_table_raises_queryexception", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_dont_use_double_quotes_on_create_queries", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_dont_use_double_quotes_on_drop_queries", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_dont_use_double_quotes_on_joining_queries", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_use_double_quotes_on_alias_but_not_on_terms", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_use_double_quotes_on_alias_but_not_on_terms_with_joins", + "pypika/tests/dialects/test_sqllite.py::SelectTests::test_bool_false_as_zero", + "pypika/tests/dialects/test_sqllite.py::SelectTests::test_bool_true_as_one", + "pypika/tests/dialects/test_sqllite.py::ReplaceTests::test_insert_or_replace", + "pypika/tests/dialects/test_sqllite.py::ReplaceTests::test_normal_replace", + "pypika/tests/dialects/test_sqllite.py::ReplaceTests::test_replace_subquery", + "pypika/tests/dialects/test_vertica.py::VerticaQueryTests::test_delete_query_with_hint", + "pypika/tests/dialects/test_vertica.py::VerticaQueryTests::test_insert_query_with_hint", + "pypika/tests/dialects/test_vertica.py::VerticaQueryTests::test_select_query_with_hint", + "pypika/tests/dialects/test_vertica.py::VerticaQueryTests::test_update_query_with_hint", + "pypika/tests/dialects/test_vertica.py::CopyCSVTests::test_copy_from_file", + "pypika/tests/dialects/test_vertica.py::CreateTemporaryTableTests::test_create_local_table_without_temporary_raises_error", + "pypika/tests/dialects/test_vertica.py::CreateTemporaryTableTests::test_create_local_temporary_table", + "pypika/tests/dialects/test_vertica.py::CreateTemporaryTableTests::test_create_table_preserve_rows_without_temporary_raises_error", + "pypika/tests/dialects/test_vertica.py::CreateTemporaryTableTests::test_create_temporary_table_preserve_rows", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__agg_case_criterion_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__agg_case_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__agg_func_arithmetic_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__agg_func_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__case_mixed_constant_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__case_mixed_else_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__case_with_field_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__case_with_single_aggregate_field_in_one_criterion_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__constant_arithmetic_is_aggregate_none", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__constant_is_aggregate_none", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__field_arithmetic_constant_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__field_arithmetic_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__field_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__func_arithmetic_constant_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__mixed_case_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__mixed_func_arithmetic_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__negative_agg_func_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__non_aggregate_function_with_aggregated_arg", + "pypika/tests/test_aggregate.py::IsAggregateTests::test_complicated", + "pypika/tests/test_analytic_queries.py::RankTests::test_avg", + "pypika/tests/test_analytic_queries.py::RankTests::test_count_range_between_unbounded_preceeding_current_row", + "pypika/tests/test_analytic_queries.py::RankTests::test_dense_rank", + "pypika/tests/test_analytic_queries.py::RankTests::test_empty_over", + "pypika/tests/test_analytic_queries.py::RankTests::test_filter", + "pypika/tests/test_analytic_queries.py::RankTests::test_filter_quote_table_in_filter", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value_ignore_nulls", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value_ignore_nulls_first", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value_multi_argument", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value_range_between_x_preceeding_unbounded_following", + "pypika/tests/test_analytic_queries.py::RankTests::test_lag_generates_correct_sql", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value_ignore_nulls", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value_multi_argument", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value_rows_between_current_row_unbounded_following", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value_rows_between_current_row_unbounded_following_ignore_nulls", + "pypika/tests/test_analytic_queries.py::RankTests::test_lead_generates_correct_sql", + "pypika/tests/test_analytic_queries.py::RankTests::test_max_range_x_preceeding", + "pypika/tests/test_analytic_queries.py::RankTests::test_max_rows_x_preceeding", + "pypika/tests/test_analytic_queries.py::RankTests::test_median", + "pypika/tests/test_analytic_queries.py::RankTests::test_min_range_current_row", + "pypika/tests/test_analytic_queries.py::RankTests::test_min_rows_current_row", + "pypika/tests/test_analytic_queries.py::RankTests::test_multiple_partitions", + "pypika/tests/test_analytic_queries.py::RankTests::test_ntile_no_partition_or_order_invalid_sql", + "pypika/tests/test_analytic_queries.py::RankTests::test_ntile_with_order", + "pypika/tests/test_analytic_queries.py::RankTests::test_ntile_with_partition", + "pypika/tests/test_analytic_queries.py::RankTests::test_ntile_with_partition_and_order", + "pypika/tests/test_analytic_queries.py::RankTests::test_orderby_asc", + "pypika/tests/test_analytic_queries.py::RankTests::test_orderby_desc", + "pypika/tests/test_analytic_queries.py::RankTests::test_range_called_twice_raises_attribute_error", + "pypika/tests/test_analytic_queries.py::RankTests::test_range_then_rows_raises_attribute_error", + "pypika/tests/test_analytic_queries.py::RankTests::test_rank", + "pypika/tests/test_analytic_queries.py::RankTests::test_rank_with_alias", + "pypika/tests/test_analytic_queries.py::RankTests::test_row_number", + "pypika/tests/test_analytic_queries.py::RankTests::test_rows_called_twice_raises_attribute_error", + "pypika/tests/test_analytic_queries.py::RankTests::test_rows_then_range_raises_attribute_error", + "pypika/tests/test_analytic_queries.py::RankTests::test_stddev", + "pypika/tests/test_analytic_queries.py::RankTests::test_stddev_pop", + "pypika/tests/test_analytic_queries.py::RankTests::test_stddev_samp", + "pypika/tests/test_analytic_queries.py::RankTests::test_sum_rows_unbounded_preceeding", + "pypika/tests/test_analytic_queries.py::RankTests::test_table_prefixes_used_in_analytic_functions", + "pypika/tests/test_analytic_queries.py::RankTests::test_var_pop", + "pypika/tests/test_analytic_queries.py::RankTests::test_var_samp", + "pypika/tests/test_analytic_queries.py::RankTests::test_variance", + "pypika/tests/test_analytic_queries.py::RankTests::test_variance_rows_between_unbounded_preceeding_unbounded_following", + "pypika/tests/test_analytic_queries.py::RankTests::test_varpop_range_unbounded_preceeding", + "pypika/tests/test_analytic_queries.py::RankTests::test_varpop_rows_between_unbounded_preceeding_x_following", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_as_select_not_query_raises_error", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_with_columns", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_with_select", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_with_select_and_columns_fails", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_without_columns_or_select_empty", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_if_not_exists", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_simple", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_unique", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_where", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_without_columns_raises_error", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_without_table_raises_error", + "pypika/tests/test_criterions.py::CriterionTests::test__bitwise_and_in_where_clause", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_bitwise_and", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_bitwise_and_with_alias", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_bool", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_decimal", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_str", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gt_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gt_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gt_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gt_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gte_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gte_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gte_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gte_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_is_null", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_is_null_with_alias", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lt_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lt_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lt_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lt_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lte_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lte_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lte_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lte_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_str", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_with_alias", + "pypika/tests/test_criterions.py::NotTests::test_chained_function", + "pypika/tests/test_criterions.py::NotTests::test_is_not_null", + "pypika/tests/test_criterions.py::NotTests::test_negate", + "pypika/tests/test_criterions.py::NotTests::test_not_null", + "pypika/tests/test_criterions.py::NotTests::test_not_null_with_alias", + "pypika/tests/test_criterions.py::NotTests::test_not_with_and_criterion", + "pypika/tests/test_criterions.py::NotTests::test_not_with_complex_criterion", + "pypika/tests/test_criterions.py::NotTests::test_not_with_or_criterion", + "pypika/tests/test_criterions.py::NotTests::test_notnullcriterion_replace_table", + "pypika/tests/test_criterions.py::NotTests::test_variable_access", + "pypika/tests/test_criterions.py::BetweenTests::test__between_date", + "pypika/tests/test_criterions.py::BetweenTests::test__between_datetime", + "pypika/tests/test_criterions.py::BetweenTests::test__between_number", + "pypika/tests/test_criterions.py::BetweenTests::test__between_with_alias", + "pypika/tests/test_criterions.py::BetweenTests::test__function_between", + "pypika/tests/test_criterions.py::BetweenTests::test_get_item_only_works_with_slice", + "pypika/tests/test_criterions.py::IsInTests::test__function_isin", + "pypika/tests/test_criterions.py::IsInTests::test__in_character", + "pypika/tests/test_criterions.py::IsInTests::test__in_date", + "pypika/tests/test_criterions.py::IsInTests::test__in_datetime", + "pypika/tests/test_criterions.py::IsInTests::test__in_number", + "pypika/tests/test_criterions.py::IsInTests::test__in_number_with_alias", + "pypika/tests/test_criterions.py::IsInTests::test__in_unicode", + "pypika/tests/test_criterions.py::ArithmeticExpressionTests::test__lshift", + "pypika/tests/test_criterions.py::ArithmeticExpressionTests::test__rshift", + "pypika/tests/test_criterions.py::NotInTests::test__function_notin", + "pypika/tests/test_criterions.py::NotInTests::test__notin_character", + "pypika/tests/test_criterions.py::NotInTests::test__notin_date", + "pypika/tests/test_criterions.py::NotInTests::test__notin_datetime", + "pypika/tests/test_criterions.py::NotInTests::test__notin_number", + "pypika/tests/test_criterions.py::NotInTests::test__notin_number_with_alias", + "pypika/tests/test_criterions.py::LikeTests::test_glob_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_contains", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_ends_with", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_n_chars_long", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_starts_with", + "pypika/tests/test_criterions.py::LikeTests::test_like_contains", + "pypika/tests/test_criterions.py::LikeTests::test_like_ends_with", + "pypika/tests/test_criterions.py::LikeTests::test_like_n_chars_long", + "pypika/tests/test_criterions.py::LikeTests::test_like_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_like_starts_with", + "pypika/tests/test_criterions.py::LikeTests::test_not_ilike_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_not_like_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_rlike_escape_chars", + "pypika/tests/test_criterions.py::ExistsCriterionTests::test_exists", + "pypika/tests/test_criterions.py::ExistsCriterionTests::test_not_exists", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__between_and_field", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__between_and_isin", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__nested__and", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__nested__mixed", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__nested__or", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_and", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_function_and", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_function_or", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_function_xor", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_or", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_xor", + "pypika/tests/test_criterions.py::FieldsAsCriterionTests::test__field_and_field", + "pypika/tests/test_criterions.py::FieldsAsCriterionTests::test__field_or_field", + "pypika/tests/test_criterions.py::FieldsAsCriterionTests::test__field_xor_field", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_arithmeticfunction_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_betweencriterion_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_complexcriterion_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_criterion_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_field_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_function_with_only_fields_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_function_with_values_and_fields_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_nullcriterion_replace_table", + "pypika/tests/test_criterions.py::AnyTests::test_multiple_args_returned_in_chain_of_ors", + "pypika/tests/test_criterions.py::AnyTests::test_single_arg_returns_self", + "pypika/tests/test_criterions.py::AnyTests::test_with_generator", + "pypika/tests/test_criterions.py::AnyTests::test_zero_args_returns_empty_criterion", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_different_operations_with_empty_criterion", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_empty_criterion_on_the_left", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_empty_criterion_on_the_right", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_fields_", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_invertion_of_the_empty_criterion", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_more_than_one_empty_criterions", + "pypika/tests/test_criterions.py::AllTests::test_multiple_args_returned_in_chain_of_ors", + "pypika/tests/test_criterions.py::AllTests::test_single_arg_returns_self", + "pypika/tests/test_criterions.py::AllTests::test_with_generator", + "pypika/tests/test_criterions.py::AllTests::test_zero_args_returns_empty_criterion", + "pypika/tests/test_custom_functions.py::TestUnitCustomFunction::test_should_fail_with_wrong_arguments", + "pypika/tests/test_custom_functions.py::TestUnitCustomFunction::test_should_return_function_with_arguments", + "pypika/tests/test_custom_functions.py::TestUnitCustomFunction::test_should_return_function_with_no_arguments", + "pypika/tests/test_custom_functions.py::TestFunctionalCustomFunction::test_should_fail_use_custom_function_on_select_with_wrong_arguments", + "pypika/tests/test_custom_functions.py::TestFunctionalCustomFunction::test_should_use_custom_function_on_select", + "pypika/tests/test_data_types.py::StringTests::test_inline_string_concatentation", + "pypika/tests/test_data_types.py::UuidTests::test_uuid_string_generation", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_day", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_default", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_microsecond", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_minute", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_month", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_quarter", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_second", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_week", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_year", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_day_hour", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_day_microsecond", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_day_minute", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_day_second", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_hour_microsecond", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_hour_minute", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_hour_second", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_minute_microsecond", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_minute_second", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_second_microsecond", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_value_complex_expressions", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_value_right", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_year_month", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_mysql_dialect_uses_single_quotes_around_expression_in_an_interval", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_oracle_dialect_uses_single_quotes_around_expression_in_an_interval", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_postgresql_dialect_uses_single_quotes_around_interval", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_redshift_dialect_uses_single_quotes_around_interval", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_vertica_dialect_uses_single_quotes_around_interval", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_day", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_month", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_week", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_year", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_year_month", + "pypika/tests/test_date_math.py::TruncateTrailingZerosTests::test_do_not_truncate_integer_values", + "pypika/tests/test_date_math.py::TruncateTrailingZerosTests::test_do_not_truncate_months_between_years_and_datys", + "pypika/tests/test_deletes.py::DeleteTests::test_for_portion", + "pypika/tests/test_deletes.py::DeleteTests::test_omit_where", + "pypika/tests/test_deletes.py::DeleteTests::test_omit_where__table_schema", + "pypika/tests/test_deletes.py::DeleteTests::test_where_field_equals", + "pypika/tests/test_deletes.py::PostgresDeleteTests::test_delete_returning", + "pypika/tests/test_deletes.py::PostgresDeleteTests::test_delete_returning_star", + "pypika/tests/test_deletes.py::PostgresDeleteTests::test_delete_returning_str", + "pypika/tests/test_deletes.py::PostgresDeleteTests::test_delete_using", + "pypika/tests/test_drop.py::DropTableTests::test_drop_database", + "pypika/tests/test_drop.py::DropTableTests::test_drop_index", + "pypika/tests/test_drop.py::DropTableTests::test_drop_table", + "pypika/tests/test_drop.py::DropTableTests::test_drop_user", + "pypika/tests/test_drop.py::DropTableTests::test_drop_view", + "pypika/tests/test_formats.py::QuoteTests::test_no_quote_char_in_complex_query", + "pypika/tests/test_formats.py::QuoteTests::test_replace_quote_char_in_complex_query", + "pypika/tests/test_functions.py::FunctionTests::test_dialect_propagation", + "pypika/tests/test_functions.py::FunctionTests::test_is_aggregate_None_for_non_aggregate_function_or_function_with_no_aggregate_functions", + "pypika/tests/test_functions.py::FunctionTests::test_is_aggregate_True_for_aggregate_function_or_function_with_aggregate_functions", + "pypika/tests/test_functions.py::SchemaTests::test_schema_included_in_function_sql", + "pypika/tests/test_functions.py::SchemaTests::test_schema_no_schema_in_sql_when_none_set", + "pypika/tests/test_functions.py::ArithmeticTests::test__addition__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__addition__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__addition__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__addition__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__arithmetic_equality", + "pypika/tests/test_functions.py::ArithmeticTests::test__arithmetic_with_function", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_add_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_div_no_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_div_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_exponent_no_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_exponent_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_floor_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_function_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_modulus_no_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_modulus_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_mul_no_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_mul_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_nested_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_sub_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__division__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__division__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__division__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__division__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__exponent__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__exponent__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__floor", + "pypika/tests/test_functions.py::ArithmeticTests::test__leftshift__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__leftshift__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__leftshift__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__modulus__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__multiplication__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__multiplication__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__multiplication__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__multiplication__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__rightshift__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__rightshift__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__rightshift__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__subtraction__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__subtraction__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__subtraction__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__subtraction__right", + "pypika/tests/test_functions.py::AggregationTests::test__approx_percentile", + "pypika/tests/test_functions.py::AggregationTests::test__avg", + "pypika/tests/test_functions.py::AggregationTests::test__count", + "pypika/tests/test_functions.py::AggregationTests::test__count__star", + "pypika/tests/test_functions.py::AggregationTests::test__first", + "pypika/tests/test_functions.py::AggregationTests::test__last", + "pypika/tests/test_functions.py::AggregationTests::test__max", + "pypika/tests/test_functions.py::AggregationTests::test__min", + "pypika/tests/test_functions.py::AggregationTests::test__std", + "pypika/tests/test_functions.py::AggregationTests::test__stddev", + "pypika/tests/test_functions.py::AggregationTests::test__subquery_in_params_functions", + "pypika/tests/test_functions.py::AggregationTests::test__sum", + "pypika/tests/test_functions.py::ConditionTests::test__case__else", + "pypika/tests/test_functions.py::ConditionTests::test__case__field", + "pypika/tests/test_functions.py::ConditionTests::test__case__multi", + "pypika/tests/test_functions.py::ConditionTests::test__case__no_cases", + "pypika/tests/test_functions.py::ConditionTests::test__case__raw", + "pypika/tests/test_functions.py::StringTests::test__ascii__field", + "pypika/tests/test_functions.py::StringTests::test__ascii__int", + "pypika/tests/test_functions.py::StringTests::test__ascii__str", + "pypika/tests/test_functions.py::StringTests::test__bin__field", + "pypika/tests/test_functions.py::StringTests::test__bin__int", + "pypika/tests/test_functions.py::StringTests::test__bin__str", + "pypika/tests/test_functions.py::StringTests::test__concat__field", + "pypika/tests/test_functions.py::StringTests::test__concat__str", + "pypika/tests/test_functions.py::StringTests::test__insert__field", + "pypika/tests/test_functions.py::StringTests::test__insert__str", + "pypika/tests/test_functions.py::StringTests::test__length__field", + "pypika/tests/test_functions.py::StringTests::test__length__str", + "pypika/tests/test_functions.py::StringTests::test__lower__field", + "pypika/tests/test_functions.py::StringTests::test__lower__str", + "pypika/tests/test_functions.py::StringTests::test__replace__field", + "pypika/tests/test_functions.py::StringTests::test__replace__str", + "pypika/tests/test_functions.py::StringTests::test__substring", + "pypika/tests/test_functions.py::SplitPartFunctionTests::test__split_part", + "pypika/tests/test_functions.py::RegexpLikeFunctionTests::test__regexp_like", + "pypika/tests/test_functions.py::CastTests::test__cast__as", + "pypika/tests/test_functions.py::CastTests::test__cast__binary", + "pypika/tests/test_functions.py::CastTests::test__cast__binary_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__boolean", + "pypika/tests/test_functions.py::CastTests::test__cast__char", + "pypika/tests/test_functions.py::CastTests::test__cast__char_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__date", + "pypika/tests/test_functions.py::CastTests::test__cast__float", + "pypika/tests/test_functions.py::CastTests::test__cast__integer", + "pypika/tests/test_functions.py::CastTests::test__cast__long_varbinary", + "pypika/tests/test_functions.py::CastTests::test__cast__long_varbinary_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__long_varchar", + "pypika/tests/test_functions.py::CastTests::test__cast__long_varchar_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__numeric", + "pypika/tests/test_functions.py::CastTests::test__cast__signed", + "pypika/tests/test_functions.py::CastTests::test__cast__timestamp", + "pypika/tests/test_functions.py::CastTests::test__cast__unsigned", + "pypika/tests/test_functions.py::CastTests::test__cast__varbinary", + "pypika/tests/test_functions.py::CastTests::test__cast__varbinary_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__varchar", + "pypika/tests/test_functions.py::CastTests::test__cast__varchar_with_arg", + "pypika/tests/test_functions.py::CastTests::test__tochar__", + "pypika/tests/test_functions.py::DateFunctionsTests::test_current_date", + "pypika/tests/test_functions.py::DateFunctionsTests::test_current_time", + "pypika/tests/test_functions.py::DateFunctionsTests::test_current_timestamp", + "pypika/tests/test_functions.py::DateFunctionsTests::test_current_timestamp_with_alias", + "pypika/tests/test_functions.py::DateFunctionsTests::test_date_add", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_day", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_hour", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_join", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_microsecond", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_minute", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_month", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_quarter", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_second", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_week", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_year", + "pypika/tests/test_functions.py::DateFunctionsTests::test_now", + "pypika/tests/test_functions.py::DateFunctionsTests::test_time_diff", + "pypika/tests/test_functions.py::DateFunctionsTests::test_timestampadd", + "pypika/tests/test_functions.py::DateFunctionsTests::test_to_date", + "pypika/tests/test_functions.py::DateFunctionsTests::test_utc_timestamp", + "pypika/tests/test_functions.py::NullFunctionsTests::test_coalesce", + "pypika/tests/test_functions.py::NullFunctionsTests::test_isnull", + "pypika/tests/test_functions.py::NullFunctionsTests::test_nullif", + "pypika/tests/test_functions.py::NullFunctionsTests::test_nvl", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_mysql_one_groupby", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_mysql_rollup_two_groupbys", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_no_rollup_after_rollup_mysql", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_no_rollup_before_groupby", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_from_groupbys", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_from_parameters", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_from_two_groupbys", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_func_one_groupby", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_func_partial", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_func_two_groupbys", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_multiple_rollups", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_rollups_with_multiple_rollups_and_parity", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_rollups_with_parity", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_force_index_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_groupby_returns_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_immutable_kwarg_on_query_builder_disables_immutability", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_insert_into_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_join_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_orderby_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_queries_after_join", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_replace_into_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_select_returns_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_update_set_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_use_index_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_with_return_new_query_instance", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_multi_rows", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_multi_rows_chained", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_multi_rows_chained_mixed", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_multi_rows_chained_multiple_rows", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_single_element", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_column_using_alias_with_chain", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_column_using_table_alias", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_empty_columns", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_empty_columns_type_list", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_empty_columns_type_tuple", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_ignore", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_multiple_rows_with_array_value", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_none_skipped", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_null", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_one_column", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_one_column_multi_element_array", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_one_column_single_element_array", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_selected_columns", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_selected_columns_type_list", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_selected_columns_type_tuple", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_single_row_with_array_value", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_with_statement", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_empty_on_conflict_do_update_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_field", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_field_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_mixed_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_multiple_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_multiple_fields_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_field", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_field_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_multiple_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_multiple_fields_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_multiple_mixed_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_no_handler", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_two_handlers_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_two_handlers_do_update", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_fieldless_conflict_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_fieldless_conflict_do_update_field", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_non_insert_on_conflict_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_non_insert_on_conflict_do_update", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_do_nothing_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_do_update_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_do_update_with_excluded_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_from_subquery", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_complex", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_conflict_fields_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_conflict_fields_do_update", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_empty_conflict_fields_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_empty_conflict_fields_do_update", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_where_and_on_conflict_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_all_columns_multi_rows_chained_returning_star", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_all_columns_multi_rows_chained_returning_star_and_id", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_all_columns_multi_rows_chained_returning_star_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_all_columns_single_element_arrays", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_aggregate", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_all_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_all_fields_and_arithmetics", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_arithmetics", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_from_other_table", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_functions", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_null", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_one_field", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_one_field_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_tuple", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_ignore", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multi_rows_chained_mixed_on_duplicate_update_multiple", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_multiple", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_different_value", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_expression", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_expression_using_original_field_value", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_expression_using_values", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_same_value", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_none_skipped", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_one_column", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_one_column_multi_element_array", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_one_column_single_element_array", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_one_column_using_values", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_selected_columns_on_duplicate_update_multiple", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_selected_columns_on_duplicate_update_one", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_columns_from_columns", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_columns_from_columns_with_join", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_columns_from_star", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_from_columns", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_ignore_star", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_star", + "pypika/tests/test_inserts.py::InsertSubqueryTests::test_insert_subquery_wrapped_in_brackets", + "pypika/tests/test_inserts.py::SelectIntoTests::test_select_columns_into", + "pypika/tests/test_inserts.py::SelectIntoTests::test_select_columns_into_with_join", + "pypika/tests/test_inserts.py::SelectIntoTests::test_select_star_into", + "pypika/tests/test_inserts.py::ReplaceTests::test_replace_simple", + "pypika/tests/test_inserts.py::ReplaceTests::test_replace_subquery", + "pypika/tests/test_internals.py::TablesTests::test__case_tables", + "pypika/tests/test_internals.py::TablesTests::test__criterion_replace_table_with_value", + "pypika/tests/test_internals.py::TablesTests::test__star_tables", + "pypika/tests/test_internals.py::TablesTests::test__table_star_tables", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_cross_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_cross_join_on_subquery", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_cross_join_on_table", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_default_join_type", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_full_outer_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_hash_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_inner_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_arithmetic_field", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_collate", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_complex_criteria", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_field_multi", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_field_multi_with_extra_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_field_single", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_field_without_fields_raises_exception", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_subquery_criteria", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_second_table_in_from_clause", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_using_multiple_fields", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_using_string_field_name", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_using_with_quote_char", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_using_without_fields_raises_exception", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_with_arithmetic_function_in_select", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_left_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_left_outer_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_outer_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_right_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_right_outer_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_temporal_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_use_different_table_objects_for_same_table", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_fail_when_joining_unknown_type", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_ignore_table_references", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_immutable__tables", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_from_join", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_query_with_column_alias", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_query_with_setoperation", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_query_with_table_alias", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_query_without_alias", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_same_table", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_same_table_with_prefixes", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_table_twice", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_prefixes_added_to_function_in_orderby", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_prefixes_added_to_groupby", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_prefixes_added_to_orderby", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_require_condition", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_require_condition_with_both_tables", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select__fields_after_table_star", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select__ordered_select_clauses", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select__star_for_table", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select__star_for_table__replacement", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select_field_from_missing_table", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select_fields_with_where", + "pypika/tests/test_joins.py::UnionTests::test_mysql_query_wraps_unioned_queries", + "pypika/tests/test_joins.py::UnionTests::test_require_equal_number_of_fields", + "pypika/tests/test_joins.py::UnionTests::test_union", + "pypika/tests/test_joins.py::UnionTests::test_union_all", + "pypika/tests/test_joins.py::UnionTests::test_union_all_multiple", + "pypika/tests/test_joins.py::UnionTests::test_union_as_subquery", + "pypika/tests/test_joins.py::UnionTests::test_union_multiple", + "pypika/tests/test_joins.py::UnionTests::test_union_with_no_quote_char", + "pypika/tests/test_joins.py::UnionTests::test_union_with_order_by", + "pypika/tests/test_joins.py::UnionTests::test_union_with_order_by_use_union_query_field", + "pypika/tests/test_joins.py::UnionTests::test_union_with_order_by_use_union_query_field_with_aliases", + "pypika/tests/test_joins.py::UnionTests::test_union_with_order_by_with_aliases", + "pypika/tests/test_joins.py::InsertQueryJoinTests::test_join_table_on_insert_query", + "pypika/tests/test_joins.py::UpdateQueryJoinTests::test_join_table_on_update_query", + "pypika/tests/test_joins.py::IntersectTests::test_intersect", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_as_subquery", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_multiple", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_with_limit", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_with_no_quote_char", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_with_offset", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_with_order_by", + "pypika/tests/test_joins.py::IntersectTests::test_mysql_query_wraps_intersected_queries", + "pypika/tests/test_joins.py::IntersectTests::test_require_equal_number_of_fields_intersect", + "pypika/tests/test_joins.py::MinusTests::test_minus", + "pypika/tests/test_joins.py::MinusTests::test_minus_as_subquery", + "pypika/tests/test_joins.py::MinusTests::test_minus_multiple", + "pypika/tests/test_joins.py::MinusTests::test_minus_query_with_order_by_use_minus_query_field", + "pypika/tests/test_joins.py::MinusTests::test_minus_with_no_quote_char", + "pypika/tests/test_joins.py::MinusTests::test_minus_with_order_by", + "pypika/tests/test_joins.py::MinusTests::test_mysql_query_wraps_minus_queries", + "pypika/tests/test_joins.py::MinusTests::test_require_equal_number_of_fields", + "pypika/tests/test_joins.py::ExceptOfTests::test_except", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_as_subquery", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_multiple", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_query_with_order_by_use_minus_query_field", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_with_no_quote_char", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_with_order_by", + "pypika/tests/test_joins.py::ExceptOfTests::test_require_equal_number_of_fields_except_of", + "pypika/tests/test_negation.py::NegationTests::test_negate_field", + "pypika/tests/test_negation.py::NegationTests::test_negate_function", + "pypika/tests/test_negation.py::NegationTests::test_negate_wrapped_float", + "pypika/tests/test_negation.py::NegationTests::test_negate_wrapped_int", + "pypika/tests/test_parameter.py::ParametrizedTests::test_format_parameter", + "pypika/tests/test_parameter.py::ParametrizedTests::test_join", + "pypika/tests/test_parameter.py::ParametrizedTests::test_named_parameter", + "pypika/tests/test_parameter.py::ParametrizedTests::test_numeric_parameter", + "pypika/tests/test_parameter.py::ParametrizedTests::test_param_insert", + "pypika/tests/test_parameter.py::ParametrizedTests::test_param_select_join", + "pypika/tests/test_parameter.py::ParametrizedTests::test_param_select_subquery", + "pypika/tests/test_parameter.py::ParametrizedTests::test_pyformat_parameter", + "pypika/tests/test_parameter.py::ParametrizedTests::test_qmark_parameter", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_join", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_join_with_parameter_value_wrapper", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_param_insert", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_param_select_join", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_param_select_subquery", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_pyformat_parameter", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_can_be_used_in_a_select_statement", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_can_be_used_in_a_where_clause", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_can_be_used_in_orderby", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_column_value", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_object_id", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_object_value", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_row_id", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_row_num", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_sys_date", + "pypika/tests/test_query.py::QueryTablesTests::test_is_joined", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_case_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_delete_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_filter_tables", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_having_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_insert_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_insert_table_current_table_not_match", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_join_tables", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_only_specified_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_orderby_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_tuple_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_update_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_update_table_current_table_not_match", + "pypika/tests/test_query.py::QueryBuilderTests::test_pipe", + "pypika/tests/test_query.py::QueryBuilderTests::test_query_builders_have_reference_to_correct_query_class", + "pypika/tests/test_selects.py::SelectTests::test_empty_query", + "pypika/tests/test_selects.py::SelectTests::test_mssql_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_mysql_query_uses_backtick_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_oracle_query_uses_no_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_postgresql_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_redshift_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_select__column__single__alias__str", + "pypika/tests/test_selects.py::SelectTests::test_select__column__single__field", + "pypika/tests/test_selects.py::SelectTests::test_select__column__single__str", + "pypika/tests/test_selects.py::SelectTests::test_select__column__single__table_alias__str", + "pypika/tests/test_selects.py::SelectTests::test_select__columns__multi__field", + "pypika/tests/test_selects.py::SelectTests::test_select__columns__multi__str", + "pypika/tests/test_selects.py::SelectTests::test_select__distinct__multi", + "pypika/tests/test_selects.py::SelectTests::test_select__distinct__single", + "pypika/tests/test_selects.py::SelectTests::test_select__multiple_subqueries", + "pypika/tests/test_selects.py::SelectTests::test_select__multiple_tables", + "pypika/tests/test_selects.py::SelectTests::test_select__nested_subquery", + "pypika/tests/test_selects.py::SelectTests::test_select__no_table", + "pypika/tests/test_selects.py::SelectTests::test_select__star", + "pypika/tests/test_selects.py::SelectTests::test_select__star__replacement", + "pypika/tests/test_selects.py::SelectTests::test_select__subquery", + "pypika/tests/test_selects.py::SelectTests::test_select__table_schema", + "pypika/tests/test_selects.py::SelectTests::test_select__table_schema_with_multiple_levels_as_list", + "pypika/tests/test_selects.py::SelectTests::test_select__table_schema_with_multiple_levels_as_tuple", + "pypika/tests/test_selects.py::SelectTests::test_select_no_from", + "pypika/tests/test_selects.py::SelectTests::test_select_no_from_with_field_raises_exception", + "pypika/tests/test_selects.py::SelectTests::test_select_no_with_alias_from", + "pypika/tests/test_selects.py::SelectTests::test_select_then_add_table", + "pypika/tests/test_selects.py::SelectTests::test_select_with_force_index", + "pypika/tests/test_selects.py::SelectTests::test_select_with_force_index_multiple_calls", + "pypika/tests/test_selects.py::SelectTests::test_select_with_force_index_multiple_indexes", + "pypika/tests/test_selects.py::SelectTests::test_select_with_force_index_with_index_object", + "pypika/tests/test_selects.py::SelectTests::test_select_with_limit", + "pypika/tests/test_selects.py::SelectTests::test_select_with_limit__func", + "pypika/tests/test_selects.py::SelectTests::test_select_with_limit_and_offset", + "pypika/tests/test_selects.py::SelectTests::test_select_with_limit_zero", + "pypika/tests/test_selects.py::SelectTests::test_select_with_offset", + "pypika/tests/test_selects.py::SelectTests::test_select_with_offset__func", + "pypika/tests/test_selects.py::SelectTests::test_select_with_use_index", + "pypika/tests/test_selects.py::SelectTests::test_select_with_use_index_multiple_calls", + "pypika/tests/test_selects.py::SelectTests::test_select_with_use_index_multiple_indexes", + "pypika/tests/test_selects.py::SelectTests::test_select_with_use_index_with_index_object", + "pypika/tests/test_selects.py::SelectTests::test_table_select_alias", + "pypika/tests/test_selects.py::SelectTests::test_table_select_alias_with_offset_and_limit", + "pypika/tests/test_selects.py::SelectTests::test_temporal_select", + "pypika/tests/test_selects.py::SelectTests::test_vertica_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::WhereTests::test_ignore_empty_criterion_having", + "pypika/tests/test_selects.py::WhereTests::test_ignore_empty_criterion_where", + "pypika/tests/test_selects.py::WhereTests::test_select_with_force_index_and_where", + "pypika/tests/test_selects.py::WhereTests::test_where_enum", + "pypika/tests/test_selects.py::WhereTests::test_where_field_contains", + "pypika/tests/test_selects.py::WhereTests::test_where_field_does_not_contain", + "pypika/tests/test_selects.py::WhereTests::test_where_field_does_not_end_with", + "pypika/tests/test_selects.py::WhereTests::test_where_field_does_not_start_with", + "pypika/tests/test_selects.py::WhereTests::test_where_field_ends_with", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_and", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_nowait", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_of", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_of_multiple_tables", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_of_nowait", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_of_skip_locked", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_skip_locked", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_skip_locked_and_of", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_or", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_where", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_where_not", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_where_two_not", + "pypika/tests/test_selects.py::WhereTests::test_where_field_is_n_chars_long", + "pypika/tests/test_selects.py::WhereTests::test_where_field_is_not_n_chars_long", + "pypika/tests/test_selects.py::WhereTests::test_where_field_matches_regex", + "pypika/tests/test_selects.py::WhereTests::test_where_field_matches_regexp", + "pypika/tests/test_selects.py::WhereTests::test_where_field_matches_rlike", + "pypika/tests/test_selects.py::WhereTests::test_where_field_starts_with", + "pypika/tests/test_selects.py::WhereTests::test_where_nested_conditions", + "pypika/tests/test_selects.py::WhereTests::test_where_single_quote", + "pypika/tests/test_selects.py::WhereTests::test_where_with_multiple_wheres_using_and_case", + "pypika/tests/test_selects.py::WhereTests::test_where_with_multiple_wheres_using_or_case", + "pypika/tests/test_selects.py::PreWhereTests::test_ignore_empty_criterion_having", + "pypika/tests/test_selects.py::PreWhereTests::test_ignore_empty_criterion_where", + "pypika/tests/test_selects.py::PreWhereTests::test_prewhere_field_equals", + "pypika/tests/test_selects.py::PreWhereTests::test_select_with_force_index_and_where", + "pypika/tests/test_selects.py::PreWhereTests::test_where_and_prewhere", + "pypika/tests/test_selects.py::PreWhereTests::test_where_enum", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_contains", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_does_not_contain", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_does_not_end_with", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_does_not_start_with", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_ends_with", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_and", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_nowait", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_of", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_of_multiple_tables", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_of_nowait", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_of_skip_locked", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_skip_locked", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_skip_locked_and_of", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_or", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_where", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_where_not", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_where_two_not", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_is_n_chars_long", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_is_not_n_chars_long", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_matches_regex", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_matches_regexp", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_matches_rlike", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_starts_with", + "pypika/tests/test_selects.py::PreWhereTests::test_where_nested_conditions", + "pypika/tests/test_selects.py::PreWhereTests::test_where_single_quote", + "pypika/tests/test_selects.py::PreWhereTests::test_where_with_multiple_wheres_using_and_case", + "pypika/tests/test_selects.py::PreWhereTests::test_where_with_multiple_wheres_using_or_case", + "pypika/tests/test_selects.py::GroupByTests::test_group_by__single_with_totals", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__alias", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__alias_platforms", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__alias_with_join", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__count_distinct", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__count_field", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__count_star", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__int", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__multi", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__multi_with_totals", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__no_alias", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__no_alias_mssql", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__no_alias_oracle", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__single", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__str", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__sum_distinct", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__sum_filter", + "pypika/tests/test_selects.py::GroupByTests::test_groupby_with_case_uses_the_alias", + "pypika/tests/test_selects.py::GroupByTests::test_mssql_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_mysql_query_uses_backtick_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_oracle_query_uses_no_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_postgres_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_redshift_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_vertica_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_having_and", + "pypika/tests/test_selects.py::HavingTests::test_having_greater_than", + "pypika/tests/test_selects.py::HavingTests::test_having_join_and_equality", + "pypika/tests/test_selects.py::HavingTests::test_mssql_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_mysql_query_uses_backtick_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_oracle_query_uses_no_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_postgres_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_redshift_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_vertica_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_alias", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_asc", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_desc", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_multi_fields", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_no_alias", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_single_field", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_single_str", + "pypika/tests/test_selects.py::AliasTests::test_arithmetic_function", + "pypika/tests/test_selects.py::AliasTests::test_case_using_as", + "pypika/tests/test_selects.py::AliasTests::test_case_using_constructor_param", + "pypika/tests/test_selects.py::AliasTests::test_function_using_as_nested", + "pypika/tests/test_selects.py::AliasTests::test_functions_using_as", + "pypika/tests/test_selects.py::AliasTests::test_functions_using_constructor_param", + "pypika/tests/test_selects.py::AliasTests::test_functions_using_constructor_param_nested", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_criterion", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_criterion_comparison", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_field_inside_case", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_groupby", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_orderby", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_where", + "pypika/tests/test_selects.py::AliasTests::test_null_value_with_alias", + "pypika/tests/test_selects.py::AliasTests::test_select__multiple_tables", + "pypika/tests/test_selects.py::AliasTests::test_table_field", + "pypika/tests/test_selects.py::AliasTests::test_table_field__multi", + "pypika/tests/test_selects.py::AliasTests::test_table_with_schema_and_alias", + "pypika/tests/test_selects.py::AliasTests::test_use_aliases_in_groupby_and_orderby", + "pypika/tests/test_selects.py::SubqueryTests::test_from_subquery_without_alias", + "pypika/tests/test_selects.py::SubqueryTests::test_join", + "pypika/tests/test_selects.py::SubqueryTests::test_join_query_with_alias", + "pypika/tests/test_selects.py::SubqueryTests::test_join_with_with", + "pypika/tests/test_selects.py::SubqueryTests::test_select_from_nested_query", + "pypika/tests/test_selects.py::SubqueryTests::test_select_from_nested_query_with_join", + "pypika/tests/test_selects.py::SubqueryTests::test_select_from_with_returning", + "pypika/tests/test_selects.py::SubqueryTests::test_select_subquery", + "pypika/tests/test_selects.py::SubqueryTests::test_select_subquery_with_alias", + "pypika/tests/test_selects.py::SubqueryTests::test_where__equality", + "pypika/tests/test_selects.py::SubqueryTests::test_where__in", + "pypika/tests/test_selects.py::SubqueryTests::test_where__in_nested", + "pypika/tests/test_selects.py::SubqueryTests::test_with", + "pypika/tests/test_selects.py::QuoteTests::test_extraneous_quotes", + "pypika/tests/test_tables.py::TableStructureTests::test_database_schema_table_attr", + "pypika/tests/test_tables.py::TableStructureTests::test_schema_table_attr", + "pypika/tests/test_tables.py::TableStructureTests::test_table_for_period_sql", + "pypika/tests/test_tables.py::TableStructureTests::test_table_for_system_time_sql", + "pypika/tests/test_tables.py::TableStructureTests::test_table_sql", + "pypika/tests/test_tables.py::TableStructureTests::test_table_with_alias", + "pypika/tests/test_tables.py::TableStructureTests::test_table_with_schema_and_schema_parent_arg", + "pypika/tests/test_tables.py::TableStructureTests::test_table_with_schema_arg", + "pypika/tests/test_tables.py::TableEqualityTests::test_many_tables_with_alias", + "pypika/tests/test_tables.py::TableEqualityTests::test_many_tables_with_or_not_alias", + "pypika/tests/test_tables.py::TableEqualityTests::test_many_tables_without_alias", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_equal_by_name", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_equal_by_schema_and_name", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_equal_by_schema_and_name_using_schema", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_equal_by_schema_and_name_using_schema_with_parent", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_not_equal_by_schema_and_name_using_schema_with_different_parents", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_not_equal_with_different_names", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_not_equal_with_different_schemas", + "pypika/tests/test_tables.py::TableDialectTests::test_make_tables_factory_with_default_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_make_tables_factory_with_dialect_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_factory_with_default_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_factory_with_dialect_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_with_bad_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_with_default_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_with_dialect_query_cls", + "pypika/tests/test_terms.py::FieldAliasTests::test_when_alias_specified", + "pypika/tests/test_terms.py::FieldInitTests::test_init_with_str_table", + "pypika/tests/test_terms.py::FieldHashingTests::test_non_tabled_aliased_eq_fields_equally_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_non_tabled_aliased_ne_fields_differently_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_non_tabled_eq_fields_equally_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_non_tabled_ne_fields_differently_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_tabled_eq_fields_equally_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_tabled_ne_fields_differently_hashed", + "pypika/tests/test_terms.py::AtTimezoneTests::test_passes_kwargs_to_field_get_sql", + "pypika/tests/test_terms.py::AtTimezoneTests::test_when_alias_specified", + "pypika/tests/test_terms.py::AtTimezoneTests::test_when_interval_not_specified", + "pypika/tests/test_terms.py::AtTimezoneTests::test_when_interval_specified", + "pypika/tests/test_tuples.py::TupleTests::test_render_alias_in_array_sql", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_equality_tuple_on_both", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_equality_tuple_on_left", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_equality_tuple_on_right", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_in_using_mixed_tuples", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_in_using_pypika_tuples", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_in_using_python_tuples", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_is_aggregate", + "pypika/tests/test_tuples.py::TupleTests::test_tuples_in_join", + "pypika/tests/test_tuples.py::ArrayTests::test_array_general", + "pypika/tests/test_tuples.py::ArrayTests::test_empty_psql_array", + "pypika/tests/test_tuples.py::ArrayTests::test_psql_array_general", + "pypika/tests/test_tuples.py::ArrayTests::test_render_alias_in_array_sql", + "pypika/tests/test_tuples.py::BracketTests::test_arithmetic_with_brackets", + "pypika/tests/test_tuples.py::BracketTests::test_arithmetic_with_brackets_and_alias", + "pypika/tests/test_updates.py::UpdateTests::test_empty_query", + "pypika/tests/test_updates.py::UpdateTests::test_for_portion", + "pypika/tests/test_updates.py::UpdateTests::test_omit_where", + "pypika/tests/test_updates.py::UpdateTests::test_single_quote_escape_in_set", + "pypika/tests/test_updates.py::UpdateTests::test_update__table_schema", + "pypika/tests/test_updates.py::UpdateTests::test_update_from", + "pypika/tests/test_updates.py::UpdateTests::test_update_from_with_where", + "pypika/tests/test_updates.py::UpdateTests::test_update_with_join", + "pypika/tests/test_updates.py::UpdateTests::test_update_with_limit", + "pypika/tests/test_updates.py::UpdateTests::test_update_with_none", + "pypika/tests/test_updates.py::UpdateTests::test_update_with_statement", + "pypika/tests/test_updates.py::PostgresUpdateTests::test_update_returning", + "pypika/tests/test_updates.py::PostgresUpdateTests::test_update_returning_from_different_tables", + "pypika/tests/test_updates.py::PostgresUpdateTests::test_update_returning_star", + "pypika/tests/test_updates.py::PostgresUpdateTests::test_update_returning_str", + "pypika/tests/test_updates.py::SQLLiteUpdateTests::test_update_with_bool", + "pypika/tests/test_utils.py::ImmutabilityTests::test_raise_attribute_error_for_deepcopy", + "pypika/tests/test_utils.py::ImmutabilityTests::test_raise_attribute_error_for_getnewargs", + "pypika/tests/test_utils.py::ImmutabilityTests::test_raise_attribute_error_for_getstate", + "pypika/tests/test_utils.py::ImmutabilityTests::test_raise_attribute_error_for_setstate" + ], + "all_git_blobs_modes_verified": true, + "cloud_launch_ready": false, + "commits": { + "bug": "1382bae6e1c23b052caca2b2c92a4b58bea0237b", + "healthy": "6a742f12bfa386994289ec8b75824663d8ee4b15", + "learner": "b1399eeec67530b89b4c10e062ccbc8b4ba15677" + }, + "existing_squirrel_snapshot_reused": false, + "full_transfer_allowlist": [ + "/testbed/.coveragerc", + "/testbed/.gitignore", + "/testbed/.pre-commit-config.yaml", + "/testbed/CODEOWNERS", + "/testbed/CONTRIBUTING.rst", + "/testbed/LICENSE.txt", + "/testbed/MANIFEST.in", + "/testbed/Makefile", + "/testbed/README.rst", + "/testbed/docs/1_installation.rst", + "/testbed/docs/2_tutorial.rst", + "/testbed/docs/3_advanced.rst", + "/testbed/docs/4_extending.rst", + "/testbed/docs/5_reference.rst", + "/testbed/docs/6_contributing.rst", + "/testbed/docs/Makefile", + "/testbed/docs/api/pypika.analytics.rst", + "/testbed/docs/api/pypika.dialects.rst", + "/testbed/docs/api/pypika.enums.rst", + "/testbed/docs/api/pypika.functions.rst", + "/testbed/docs/api/pypika.pseudocolumns.rst", + "/testbed/docs/api/pypika.queries.rst", + "/testbed/docs/api/pypika.rst", + "/testbed/docs/api/pypika.terms.rst", + "/testbed/docs/api/pypika.utils.rst", + "/testbed/docs/conf.py", + "/testbed/docs/index.rst", + "/testbed/pypika/__init__.py", + "/testbed/pypika/analytics.py", + "/testbed/pypika/clickhouse/__init__.py", + "/testbed/pypika/clickhouse/array.py", + "/testbed/pypika/clickhouse/condition.py", + "/testbed/pypika/clickhouse/dates_and_times.py", + "/testbed/pypika/clickhouse/nullable_arg.py", + "/testbed/pypika/clickhouse/search_string.py", + "/testbed/pypika/clickhouse/type_conversion.py", + "/testbed/pypika/dialects.py", + "/testbed/pypika/enums.py", + "/testbed/pypika/functions.py", + "/testbed/pypika/pseudocolumns.py", + "/testbed/pypika/py.typed", + "/testbed/pypika/queries.py", + "/testbed/pypika/terms.py", + "/testbed/pypika/tests/__init__.py", + "/testbed/pypika/tests/clickhouse/__init__.py", + "/testbed/pypika/tests/clickhouse/test_dates_and_times.py", + "/testbed/pypika/tests/dialects/__init__.py", + "/testbed/pypika/tests/dialects/test_clickhouse.py", + "/testbed/pypika/tests/dialects/test_mssql.py", + "/testbed/pypika/tests/dialects/test_mysql.py", + "/testbed/pypika/tests/dialects/test_oracle.py", + "/testbed/pypika/tests/dialects/test_postgresql.py", + "/testbed/pypika/tests/dialects/test_snowflake.py", + "/testbed/pypika/tests/dialects/test_sqllite.py", + "/testbed/pypika/tests/dialects/test_vertica.py", + "/testbed/pypika/tests/test_aggregate.py", + "/testbed/pypika/tests/test_analytic_queries.py", + "/testbed/pypika/tests/test_create.py", + "/testbed/pypika/tests/test_criterions.py", + "/testbed/pypika/tests/test_custom_functions.py", + "/testbed/pypika/tests/test_data_types.py", + "/testbed/pypika/tests/test_date_math.py", + "/testbed/pypika/tests/test_deletes.py", + "/testbed/pypika/tests/test_drop.py", + "/testbed/pypika/tests/test_formats.py", + "/testbed/pypika/tests/test_functions.py", + "/testbed/pypika/tests/test_groupby_modifiers.py", + "/testbed/pypika/tests/test_immutability.py", + "/testbed/pypika/tests/test_inserts.py", + "/testbed/pypika/tests/test_internals.py", + "/testbed/pypika/tests/test_joins.py", + "/testbed/pypika/tests/test_negation.py", + "/testbed/pypika/tests/test_parameter.py", + "/testbed/pypika/tests/test_pseudocolumns.py", + "/testbed/pypika/tests/test_query.py", + "/testbed/pypika/tests/test_selects.py", + "/testbed/pypika/tests/test_tables.py", + "/testbed/pypika/tests/test_terms.py", + "/testbed/pypika/tests/test_tuples.py", + "/testbed/pypika/tests/test_updates.py", + "/testbed/pypika/tests/test_utils.py", + "/testbed/pypika/utils.py", + "/testbed/pyproject.toml", + "/testbed/requirements-dev.txt", + "/testbed/setup.cfg", + "/testbed/setup.py", + "/testbed/tox.ini" + ], + "healthy_stage_meaning": "Direct parent of the mutation; no source or test execution has been performed", + "mutation_matches_dataset_and_git_blobs": true, + "official_profile": { + "eval_sets": [], + "profile_class": "Pypika1c9646f0", + "profile_lines": [ + 736, + 739 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "upstream_repo": "kayak/pypika" + }, + "original_source_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "private_test_paths": [ + "pypika/tests/clickhouse/test_array.py", + "pypika/tests/clickhouse/test_condition.py", + "pypika/tests/clickhouse/test_nullable_arg.py", + "pypika/tests/clickhouse/test_search_string.py", + "pypika/tests/clickhouse/test_type_conversion.py" + ], + "private_tests_unchanged": true, + "profile_mapping_basis": "Explicit upstream repo and full commit fields parsed from pinned official Python profile AST, not basename inference", + "qwen_calibrated": false, + "runtime_qualified": false, + "source_paths": [ + "pypika/clickhouse/condition.py", + "pypika/clickhouse/search_string.py", + "pypika/clickhouse/type_conversion.py" + ], + "source_repo": "swesmith/kayak__pypika.1c9646f0", + "source_stages_bytes": 1885213, + "task_id": "kayak__pypika.1c9646f0.combine_module__rdbfqh8u", + "transfer_limitation": "Existing regular files only; new arbitrary file additions need a qualified patch adapter", + "upstream_repo": "kayak/pypika" + }, + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:kayak__pypika.1c9646f0.combine_module__rdbfqh8u", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "6a742f12bfa386994289ec8b75824663d8ee4b15", + "instruction_sha256": "8b4d635267e5d5b2918cb9aed1b4f4f72e2cc13078c0c427c0d97c79192b170a", + "is_fork": true, + "learner_path": "tasks/aa2cc77399e300b98875e07e/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "actual_upstream_url": "https://raw.githubusercontent.com/kayak/pypika/1c9646f0a019a167c32b649b6f5e6423c5ba2c9b/LICENSE.txt", + "reviewed": true, + "sha256": "c5accbbd8546e94c34aed24afe689a617627d18eed5a6c48277e48db57c23851", + "spdx": "Apache-2.0", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/kayak__pypika.1c9646f0/b1399eeec67530b89b4c10e062ccbc8b4ba15677/LICENSE.txt" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "patch_sha256": "96a250cf716f4a76d3e33a51b690c085db30369bc95ccbc001f099c75c4b491e", + "provenance_path": "tasks/aa2cc77399e300b98875e07e/source-proof.json", + "repository_lineage": [ + "swesmith/kayak__pypika.1c9646f0", + "kayak/pypika" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "b1399eeec67530b89b4c10e062ccbc8b4ba15677", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "1382bae6e1c23b052caca2b2c92a4b58bea0237b", + "source_kind": "mutation", + "source_repo": "swesmith/kayak__pypika.1c9646f0", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "kayak__pypika.1c9646f0.combine_module__rdbfqh8u", + "task_sha256": "b69aa98249a40e04df28a3da6191b1b701a51c17f08778edd5c4843f39f804e6", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "kayak/pypika", + "usage": "quarantine_only" + }, + "task_kind": "original-source-mutation" +} diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/provenance.json b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/provenance.json new file mode 100644 index 0000000000000000000000000000000000000000..8900b915753a8a95329a7e17c636d41be1047362 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/provenance.json @@ -0,0 +1,88 @@ +{ + "generated_reference": false, + "healthy_reference_delta_sha256": "a1e647be5c492858ff6347891af719658ef4b46d0fd228a519c9ad4191ac1549", + "native_pytest_ids_preserved": true, + "original_source_code_license": { + "actual_upstream_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "actual_upstream_url": "https://raw.githubusercontent.com/kayak/pypika/1c9646f0a019a167c32b649b6f5e6423c5ba2c9b/LICENSE.txt", + "reviewed": true, + "sha256": "c5accbbd8546e94c34aed24afe689a617627d18eed5a6c48277e48db57c23851", + "spdx": "Apache-2.0", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/kayak__pypika.1c9646f0/b1399eeec67530b89b4c10e062ccbc8b4ba15677/LICENSE.txt" + }, + "provided_reference": true, + "qwen_calibrated": false, + "runtime_qualified": false, + "source_completion_sha256": "b32650f678ea76b9341e1b3de8041568c6c8343754e7b0304216c9481aa08ff5", + "source_index_sha256": "e856874b9410fce9f3bfea52c8c482e84b3e43942d87517f8b55f0034bd40f6f", + "source_proof_sha256": "b5bbed2996702142e5d1191c97873970d6c31da9b8e6955f4183a423d0164f60", + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:kayak__pypika.1c9646f0.combine_module__rdbfqh8u", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "6a742f12bfa386994289ec8b75824663d8ee4b15", + "instruction_sha256": "8b4d635267e5d5b2918cb9aed1b4f4f72e2cc13078c0c427c0d97c79192b170a", + "is_fork": true, + "learner_path": "tasks/aa2cc77399e300b98875e07e/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "actual_upstream_url": "https://raw.githubusercontent.com/kayak/pypika/1c9646f0a019a167c32b649b6f5e6423c5ba2c9b/LICENSE.txt", + "reviewed": true, + "sha256": "c5accbbd8546e94c34aed24afe689a617627d18eed5a6c48277e48db57c23851", + "spdx": "Apache-2.0", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/kayak__pypika.1c9646f0/b1399eeec67530b89b4c10e062ccbc8b4ba15677/LICENSE.txt" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "patch_sha256": "96a250cf716f4a76d3e33a51b690c085db30369bc95ccbc001f099c75c4b491e", + "provenance_path": "tasks/aa2cc77399e300b98875e07e/source-proof.json", + "repository_lineage": [ + "swesmith/kayak__pypika.1c9646f0", + "kayak/pypika" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "b1399eeec67530b89b4c10e062ccbc8b4ba15677", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "1382bae6e1c23b052caca2b2c92a4b58bea0237b", + "source_kind": "mutation", + "source_repo": "swesmith/kayak__pypika.1c9646f0", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "kayak__pypika.1c9646f0.combine_module__rdbfqh8u", + "task_sha256": "b69aa98249a40e04df28a3da6191b1b701a51c17f08778edd5c4843f39f804e6", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "kayak/pypika", + "usage": "quarantine_only" + }, + "task_bundle_license": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + }, + "training_admissible": false, + "trusted_tests_sha256": "f2d0a1b335176a755d627907f32ef330383cf624ff3af2c5ea84ba2b6a2d7ebb" +} diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/provided-gold.diff b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/provided-gold.diff new file mode 100644 index 0000000000000000000000000000000000000000..c6f75984b4433367b3b79ce1786213c090b89c5a --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/provided-gold.diff @@ -0,0 +1,44 @@ +diff --git a/pypika/clickhouse/condition.py b/pypika/clickhouse/condition.py +index 5fa9a18c9e95d1f5e7f56f011d03e7aa11f1ddd6..ed08224e22fb27eb18876595a542dcd3ad14bffc 100644 +--- a/pypika/clickhouse/condition.py ++++ b/pypika/clickhouse/condition.py +@@ -8,4 +8,4 @@ + + class MultiIf(Function): + def __init__(self, *conditions, **kwargs): +- super().__init__("multiIf", *conditions[::-1], **kwargs) ++ super().__init__("multiIf", *conditions, **kwargs) +diff --git a/pypika/clickhouse/search_string.py b/pypika/clickhouse/search_string.py +index 8c3ed88129ccb3d2384ab2e23795d90bc92f15f2..22a03027fcaf3ca0578e63980c00f4be1b2f67e7 100644 +--- a/pypika/clickhouse/search_string.py ++++ b/pypika/clickhouse/search_string.py +@@ -79,7 +79,7 @@ + class MultiSearchAny(_AbstractMultiSearchString): + @classmethod + def clickhouse_function(cls) -> str: +- return "singleSearchAll" ++ return "multiSearchAny" + + + class MultiMatchAny(_AbstractMultiSearchString): +diff --git a/pypika/clickhouse/type_conversion.py b/pypika/clickhouse/type_conversion.py +index ee28252228f5b43310805950fd5e0702fc489e93..80229b7e755dfb25bba5c4e65828a5d3cf42d988 100644 +--- a/pypika/clickhouse/type_conversion.py ++++ b/pypika/clickhouse/type_conversion.py +@@ -20,12 +20,12 @@ + self.args = () + + def get_sql(self, with_alias=False, with_namespace=False, quote_char=None, dialect=None, **kwargs): +- sql = "{name}({length},{field})".format( ++ sql = "{name}({field},{length})".format( + name=self.name, +- field=str(self._field) if isinstance(self._field, Field) else self._field, +- length=self._length + 1, ++ field=self._field if isinstance(self._field, Field) else "'%s'" % str(self._field), ++ length=self._length, + ) +- return format_alias_sql(sql, None, **kwargs) ++ return format_alias_sql(sql, self.alias, **kwargs) + + + class ToInt8(Function): diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/solution/solve.sh b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..3825f3b420bbffbf47fdb8374a796a4a6998b9ec --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/solution/solve.sh @@ -0,0 +1,50 @@ +#!/bin/bash +set -Eeuo pipefail +cd /testbed/repo +cat > /tmp/openenv-reference.diff <<'OPENENV_REFERENCE' +diff --git a/pypika/clickhouse/condition.py b/pypika/clickhouse/condition.py +index 5fa9a18c9e95d1f5e7f56f011d03e7aa11f1ddd6..ed08224e22fb27eb18876595a542dcd3ad14bffc 100644 +--- a/pypika/clickhouse/condition.py ++++ b/pypika/clickhouse/condition.py +@@ -8,4 +8,4 @@ + + class MultiIf(Function): + def __init__(self, *conditions, **kwargs): +- super().__init__("multiIf", *conditions[::-1], **kwargs) ++ super().__init__("multiIf", *conditions, **kwargs) +diff --git a/pypika/clickhouse/search_string.py b/pypika/clickhouse/search_string.py +index 8c3ed88129ccb3d2384ab2e23795d90bc92f15f2..22a03027fcaf3ca0578e63980c00f4be1b2f67e7 100644 +--- a/pypika/clickhouse/search_string.py ++++ b/pypika/clickhouse/search_string.py +@@ -79,7 +79,7 @@ + class MultiSearchAny(_AbstractMultiSearchString): + @classmethod + def clickhouse_function(cls) -> str: +- return "singleSearchAll" ++ return "multiSearchAny" + + + class MultiMatchAny(_AbstractMultiSearchString): +diff --git a/pypika/clickhouse/type_conversion.py b/pypika/clickhouse/type_conversion.py +index ee28252228f5b43310805950fd5e0702fc489e93..80229b7e755dfb25bba5c4e65828a5d3cf42d988 100644 +--- a/pypika/clickhouse/type_conversion.py ++++ b/pypika/clickhouse/type_conversion.py +@@ -20,12 +20,12 @@ + self.args = () + + def get_sql(self, with_alias=False, with_namespace=False, quote_char=None, dialect=None, **kwargs): +- sql = "{name}({length},{field})".format( ++ sql = "{name}({field},{length})".format( + name=self.name, +- field=str(self._field) if isinstance(self._field, Field) else self._field, +- length=self._length + 1, ++ field=self._field if isinstance(self._field, Field) else "'%s'" % str(self._field), ++ length=self._length, + ) +- return format_alias_sql(sql, None, **kwargs) ++ return format_alias_sql(sql, self.alias, **kwargs) + + + class ToInt8(Function): +OPENENV_REFERENCE +/usr/bin/git -c core.hooksPath=/dev/null -c core.fsmonitor=false apply --whitespace=nowarn /tmp/openenv-reference.diff diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/task.toml b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..7a5a43978449b1f453ca12939f3c3d3351cfe0ec --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/task.toml @@ -0,0 +1,24 @@ +version = "1.0" + +[agent] +timeout_sec = 1800.0 + +[verifier] +timeout_sec = 900.0 + +[environment] +docker_image = "ghcr.io/younesbelkada/scale800@sha256:cf09d05eee511077e4fdb5de965b2d25e8b2cecce69ac78318c837dee1212c99" +build_timeout_sec = 600.0 +cpus = 2 +memory_mb = 8192 +storage_mb = 16384 + +[metadata] +author_name = "SWE-smith source adapter" +category = "bugfix" +tags = ["swe", "python", "mutation-repair"] + +[environment.env] +# The image's PATH with the testbed env first: the project and pytest are installed there, and the agent's +# non-interactive shells never run `conda activate` +PATH = "/opt/miniconda3/envs/testbed/bin:/opt/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/check_pytest.py b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/check_pytest.py new file mode 100644 index 0000000000000000000000000000000000000000..7abfdc5972f57ca7f0cecbbeeb373414670f780e --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/check_pytest.py @@ -0,0 +1,177 @@ +"""Preserve confirmed requested assertion failures; keep positive checks strict.""" + +import argparse +import hashlib +import json +import re +import xml.etree.ElementTree as ET +from pathlib import Path + +GROUPS = ("pass-to-pass", "fail-to-pass") + + +def split_nodeid(target): + prefix, bracket, parameter = target.partition("[") + parts = prefix.split("::") + if bracket: + parts[-1] += bracket + parameter + return parts + + +def matches(case, target): + parts = split_nodeid(target) + module = parts[0].removesuffix(".py").replace("/", ".") + classname, name = case.get("classname", ""), case.get("name", "") + if not (classname == module or classname.startswith(module + ".")): + return False + selector = parts[-1] if len(parts) > 1 else "" + classes = parts[1:-1] + if classes and classname != module + "." + ".".join(classes): + return False + return ( + not selector + or name == selector + or ("[" not in selector and name.startswith(selector + "[")) + ) + + +def capture_panels(root): + panels, digests = {}, {} + for group in GROUPS: + path = Path(root) / (group + ".xml") + if not path.exists(): + panels[group] = None + continue + with path.open("rb") as stream: + raw = stream.read(4 * 1024**2 + 1) + if not 0 < len(raw) <= 4 * 1024**2 or re.search( + rb" 20000: + raise ValueError("Too many pytest cases") + identities = [(case.get("classname"), case.get("name")) for case in cases] + if len(identities) != len(set(identities)): + raise ValueError("Duplicate pytest case evidence") + panels[group] = cases + digests[group] = hashlib.sha256(raw).hexdigest() + return panels, digests + + +def strict_assess(panels, expected, native_exit): + """The original positive-approval conditions, applied to captured cases.""" + all_cases, actual_failure = [], False + for group in GROUPS: + cases = panels[group] + if cases is None: + if actual_failure: + continue + raise ValueError("Missing preceding pytest panel") + if actual_failure: + raise ValueError( + "Pytest evidence continued after the native stop-on-failure" + ) + targets = expected[group] + if any(not any(matches(case, target) for target in targets) for case in cases): + raise ValueError("Unexpected pytest case") + all_cases.extend(cases) + failures = [case for case in cases if case.find("failure") is not None] + if any( + case.find("error") is not None or case.find("skipped") is not None + for case in cases + ): + raise ValueError("Pytest collection/error/skip is not a completed panel") + actual_failure = actual_failure or bool(failures) + if not failures and any( + not any(matches(case, target) for case in cases) for target in targets + ): + raise ValueError("Declared pytest target never ran") + if actual_failure: + if native_exit == 0: + raise ValueError("Native verifier exit disagrees with pytest failure") + return {"reward": 0, "valid_test_failure": True, "cases": len(all_cases)} + if native_exit != 0: + raise ValueError("Setup or native verifier failed without a real test failure") + if any(panels[group] is None for group in GROUPS): + raise ValueError("Missing completed pytest panel") + return {"reward": 1, "valid_test_failure": False, "cases": len(all_cases)} + + +def assess(root, expected, native_exit): + if type(native_exit) is not int: + raise ValueError("Native verifier exit must be an integer") + if not isinstance(expected, dict) or any( + not isinstance(expected.get(group), list) + or not expected[group] + or any(not isinstance(target, str) or not target for target in expected[group]) + for group in GROUPS + ): + raise ValueError("Complete exact native pytest targets required") + panels, digests = capture_panels(root) + counts = { + "cases": 0, + "matched_failures": 0, + "unexpected_cases": 0, + "unmatched_failures": 0, + "skipped_cases": 0, + "error_cases": 0, + "missing_panels": 0, + "missing_targets": 0, + } + for group in GROUPS: + cases = panels[group] + if cases is None: + counts["missing_panels"] += 1 + counts["missing_targets"] += len(expected[group]) + continue + counts["cases"] += len(cases) + for case in cases: + requested = any(matches(case, target) for target in expected[group]) + failure = case.find("failure") is not None + counts["matched_failures"] += int(requested and failure) + counts["unmatched_failures"] += int(not requested and failure) + counts["unexpected_cases"] += int(not requested) + counts["skipped_cases"] += int(case.find("skipped") is not None) + counts["error_cases"] += int(case.find("error") is not None) + counts["missing_targets"] += sum( + not any(matches(case, target) for case in cases) + for target in expected[group] + ) + if counts["matched_failures"]: + if native_exit == 0: + raise ValueError( + "Native verifier exit disagrees with requested pytest failure" + ) + return { + "reward": 0, + "valid_test_failure": True, + "cases": counts["cases"], + "diagnostic_counts": counts, + "panel_sha256": digests, + "decision": "confirmed_requested_failure_precedence", + } + result = strict_assess(panels, expected, native_exit) + result.update(diagnostic_counts=counts, panel_sha256=digests) + return result + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("--root", required=True) + parser.add_argument("--expected", required=True) + parser.add_argument("--native-exit", type=int, required=True) + args = parser.parse_args() + result = assess( + args.root, json.loads(Path(args.expected).read_bytes()), args.native_exit + ) + reward = Path(args.root) / "reward.txt" + if reward.read_text().strip() != str(result["reward"]): + raise ValueError("Native raw reward disagrees with pytest evidence") + (Path(args.root) / "pytest-evidence.json").write_text( + json.dumps(result, sort_keys=True) + "\n" + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/expected-panels.json b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/expected-panels.json new file mode 100644 index 0000000000000000000000000000000000000000..094cf06501e0510ae190a98fd04bac22abdb749f --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/expected-panels.json @@ -0,0 +1,1067 @@ +{ + "fail-to-pass": [ + "pypika/tests/clickhouse/test_array.py::TestArray::test_get_sql_3__toFixedString_mogwai_10_toFixedString_mono_10_toFixedString_bonobo_10_arr", + "pypika/tests/clickhouse/test_array.py::TestHasAny::test_get_sql_2_hasAny_bands_toFixedString_port_royal_20_toFixedString_hammock_20_", + "pypika/tests/clickhouse/test_condition.py::TestIfCondition::test_get_sql_0", + "pypika/tests/clickhouse/test_condition.py::TestIfCondition::test_get_sql_1", + "pypika/tests/clickhouse/test_condition.py::TestMultiIfCondition::test_get_sql_0", + "pypika/tests/clickhouse/test_condition.py::TestMultiIfCondition::test_get_sql_1", + "pypika/tests/clickhouse/test_nullable_arg.py::TestSearchString::test_get_sql_1", + "pypika/tests/clickhouse/test_search_string.py::TestMultiSearch::test_multi_search_string_0", + "pypika/tests/clickhouse/test_type_conversion.py::TestToFixedString::test_get_sql_with_table" + ], + "pass-to-pass": [ + "pypika/tests/clickhouse/test_array.py::TestArray::test_get_sql_0__ridley_scott_jimi_hendrix_", + "pypika/tests/clickhouse/test_array.py::TestArray::test_get_sql_1__1_2_3_4_", + "pypika/tests/clickhouse/test_array.py::TestArray::test_get_sql_2__toInt64_1_toInt64_2_toInt64_3_toInt64_4_", + "pypika/tests/clickhouse/test_array.py::TestHasAny::test_get_sql_0_hasAny_mental_abilities_physical_abilities_", + "pypika/tests/clickhouse/test_array.py::TestHasAny::test_get_sql_1_hasAny_1_2_3_4_3_", + "pypika/tests/clickhouse/test_array.py::TestLength::test_get_sql_0_length_tags_", + "pypika/tests/clickhouse/test_array.py::TestLength::test_get_sql_1_length_1_2_3_", + "pypika/tests/clickhouse/test_array.py::TestEmpty::test_get_sql_0_empty_tags_", + "pypika/tests/clickhouse/test_array.py::TestEmpty::test_get_sql_1_empty_1_2_3_", + "pypika/tests/clickhouse/test_array.py::TestNotEmpty::test_get_sql_0_notEmpty_tags_", + "pypika/tests/clickhouse/test_array.py::TestNotEmpty::test_get_sql_1_notEmpty_1_2_3_", + "pypika/tests/clickhouse/test_dates_and_times.py::TestFormatDateTime::test_get_sql_0", + "pypika/tests/clickhouse/test_dates_and_times.py::TestFormatDateTime::test_get_sql_1", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_00", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_01", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_02", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_03", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_04", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_05", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_06", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_07", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_08", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_09", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_10", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_11", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_12", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_13", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_14", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_15", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_16", + "pypika/tests/clickhouse/test_dates_and_times.py::TestToYYYYMM::test_get_sql", + "pypika/tests/clickhouse/test_nullable_arg.py::TestSearchString::test_get_sql_0", + "pypika/tests/clickhouse/test_search_string.py::TestSearchString::test_search_string_0", + "pypika/tests/clickhouse/test_search_string.py::TestSearchString::test_search_string_1", + "pypika/tests/clickhouse/test_search_string.py::TestSearchString::test_search_string_2", + "pypika/tests/clickhouse/test_search_string.py::TestMultiSearch::test_multi_search_string_1", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_00_toString_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_01_toInt8_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_02_toInt16_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_03_toInt32_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_04_toInt64_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_05_toUInt8_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_06_toUInt16_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_07_toUInt32_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_08_toUInt64_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_09_toFloat32_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_10_toFloat64_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_11_toFloat64_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_12_toDate_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_13_toDateTime_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_14_toFixedString_field_name_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_00_toString_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_01_toInt8_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_02_toInt16_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_03_toInt32_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_04_toInt64_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_05_toUInt8_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_06_toUInt16_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_07_toUInt32_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_08_toUInt64_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_09_toFloat32_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_10_toFloat64_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_11_toFloat64_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_12_toDate_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_13_toDateTime_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_14_toFixedString_100_100_", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseQueryTests::test_use_AS_keyword_for_alias", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseQueryTests::test_use_FINAL_keyword", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseQueryTests::test_use_SAMPLE_keyword", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseQueryTests::test_use_SAMPLE_with_offset_keyword", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDeleteTests::test_omit_where", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDeleteTests::test_omit_where__table_schema", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDeleteTests::test_where_field_equals", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseUpdateTests::test_update", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDropQuery::test_drop_database", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDropQuery::test_drop_dictionary", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDropQuery::test_drop_other", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDropQuery::test_drop_table", + "pypika/tests/dialects/test_clickhouse.py::DistinctOnTests::test_distinct_on", + "pypika/tests/dialects/test_clickhouse.py::LimitByTests::test_limit_by", + "pypika/tests/dialects/test_clickhouse.py::LimitByTests::test_limit_offset0_by", + "pypika/tests/dialects/test_clickhouse.py::LimitByTests::test_limit_offset_by", + "pypika/tests/dialects/test_clickhouse.py::LimitByTests::test_rename_table", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_distinct_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_groupby_alias_False_does_not_group_by_alias_when_subqueries_are_present", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_groupby_alias_False_does_not_group_by_alias_with_standard_query", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_limit", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_limit_with_offset", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_normal_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_offset", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_distinct_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_percent_invalid_range", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_percent_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_select_non_int", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_with_ties_select", + "pypika/tests/dialects/test_mysql.py::SelectTests::test_distinct_select", + "pypika/tests/dialects/test_mysql.py::SelectTests::test_modifier_select", + "pypika/tests/dialects/test_mysql.py::SelectTests::test_multiple_modifier_select", + "pypika/tests/dialects/test_mysql.py::SelectTests::test_normal_select", + "pypika/tests/dialects/test_mysql.py::UpdateTests::test_conflict_handlers_update", + "pypika/tests/dialects/test_mysql.py::UpdateTests::test_on_duplicate_key_ignore_update", + "pypika/tests/dialects/test_mysql.py::UpdateTests::test_on_duplicate_key_update_update", + "pypika/tests/dialects/test_mysql.py::UpdateTests::test_update", + "pypika/tests/dialects/test_mysql.py::LoadCSVTests::test_load_from_file", + "pypika/tests/dialects/test_mysql.py::TableTests::test_create_table", + "pypika/tests/dialects/test_mysql.py::TableTests::test_drop_table", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_fetch_next_method_deprecated", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_groupby_alias_False_does_not_group_by_alias_when_subqueries_are_present", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_groupby_alias_False_does_not_group_by_alias_with_standard_query", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_limit_offset_query", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_limit_query", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_offset_query", + "pypika/tests/dialects/test_postgresql.py::InsertTests::test_array_keyword", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_alias_set_correctly", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_json_value_from_array_num", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_json_value_from_array_str", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_json_value_from_dict", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_json_value_from_dict_recursive", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_json_value_by_index", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_json_value_by_key", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_path_json_value", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_path_text_value", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_text_value_by_index", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_text_value_by_key", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contained_by_using_list_arg", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contained_by_using_str_arg", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contained_by_with_complex_criterion", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contains_for_field", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contains_for_json", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_has_any_keys", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_has_key", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_has_keys", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_subnet_contains_inet", + "pypika/tests/dialects/test_postgresql.py::DistinctOnTests::test_distinct_on", + "pypika/tests/dialects/test_postgresql.py::ArrayTests::test_array_syntax", + "pypika/tests/dialects/test_postgresql.py::ArrayTests::test_render_alias_in_array_sql", + "pypika/tests/dialects/test_postgresql.py::ReturningClauseTests::test_no_queryexception_if_returning_used_on_valid_query_type", + "pypika/tests/dialects/test_postgresql.py::ReturningClauseTests::test_queryexception_if_returning_used_on_invalid_query", + "pypika/tests/dialects/test_postgresql.py::ReturningClauseTests::test_return_field_from_join_table", + "pypika/tests/dialects/test_postgresql.py::ReturningClauseTests::test_returning_from_missing_table_raises_queryexception", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_dont_use_double_quotes_on_create_queries", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_dont_use_double_quotes_on_drop_queries", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_dont_use_double_quotes_on_joining_queries", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_use_double_quotes_on_alias_but_not_on_terms", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_use_double_quotes_on_alias_but_not_on_terms_with_joins", + "pypika/tests/dialects/test_sqllite.py::SelectTests::test_bool_false_as_zero", + "pypika/tests/dialects/test_sqllite.py::SelectTests::test_bool_true_as_one", + "pypika/tests/dialects/test_sqllite.py::ReplaceTests::test_insert_or_replace", + "pypika/tests/dialects/test_sqllite.py::ReplaceTests::test_normal_replace", + "pypika/tests/dialects/test_sqllite.py::ReplaceTests::test_replace_subquery", + "pypika/tests/dialects/test_vertica.py::VerticaQueryTests::test_delete_query_with_hint", + "pypika/tests/dialects/test_vertica.py::VerticaQueryTests::test_insert_query_with_hint", + "pypika/tests/dialects/test_vertica.py::VerticaQueryTests::test_select_query_with_hint", + "pypika/tests/dialects/test_vertica.py::VerticaQueryTests::test_update_query_with_hint", + "pypika/tests/dialects/test_vertica.py::CopyCSVTests::test_copy_from_file", + "pypika/tests/dialects/test_vertica.py::CreateTemporaryTableTests::test_create_local_table_without_temporary_raises_error", + "pypika/tests/dialects/test_vertica.py::CreateTemporaryTableTests::test_create_local_temporary_table", + "pypika/tests/dialects/test_vertica.py::CreateTemporaryTableTests::test_create_table_preserve_rows_without_temporary_raises_error", + "pypika/tests/dialects/test_vertica.py::CreateTemporaryTableTests::test_create_temporary_table_preserve_rows", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__agg_case_criterion_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__agg_case_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__agg_func_arithmetic_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__agg_func_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__case_mixed_constant_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__case_mixed_else_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__case_with_field_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__case_with_single_aggregate_field_in_one_criterion_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__constant_arithmetic_is_aggregate_none", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__constant_is_aggregate_none", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__field_arithmetic_constant_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__field_arithmetic_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__field_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__func_arithmetic_constant_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__mixed_case_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__mixed_func_arithmetic_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__negative_agg_func_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__non_aggregate_function_with_aggregated_arg", + "pypika/tests/test_aggregate.py::IsAggregateTests::test_complicated", + "pypika/tests/test_analytic_queries.py::RankTests::test_avg", + "pypika/tests/test_analytic_queries.py::RankTests::test_count_range_between_unbounded_preceeding_current_row", + "pypika/tests/test_analytic_queries.py::RankTests::test_dense_rank", + "pypika/tests/test_analytic_queries.py::RankTests::test_empty_over", + "pypika/tests/test_analytic_queries.py::RankTests::test_filter", + "pypika/tests/test_analytic_queries.py::RankTests::test_filter_quote_table_in_filter", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value_ignore_nulls", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value_ignore_nulls_first", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value_multi_argument", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value_range_between_x_preceeding_unbounded_following", + "pypika/tests/test_analytic_queries.py::RankTests::test_lag_generates_correct_sql", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value_ignore_nulls", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value_multi_argument", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value_rows_between_current_row_unbounded_following", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value_rows_between_current_row_unbounded_following_ignore_nulls", + "pypika/tests/test_analytic_queries.py::RankTests::test_lead_generates_correct_sql", + "pypika/tests/test_analytic_queries.py::RankTests::test_max_range_x_preceeding", + "pypika/tests/test_analytic_queries.py::RankTests::test_max_rows_x_preceeding", + "pypika/tests/test_analytic_queries.py::RankTests::test_median", + "pypika/tests/test_analytic_queries.py::RankTests::test_min_range_current_row", + "pypika/tests/test_analytic_queries.py::RankTests::test_min_rows_current_row", + "pypika/tests/test_analytic_queries.py::RankTests::test_multiple_partitions", + "pypika/tests/test_analytic_queries.py::RankTests::test_ntile_no_partition_or_order_invalid_sql", + "pypika/tests/test_analytic_queries.py::RankTests::test_ntile_with_order", + "pypika/tests/test_analytic_queries.py::RankTests::test_ntile_with_partition", + "pypika/tests/test_analytic_queries.py::RankTests::test_ntile_with_partition_and_order", + "pypika/tests/test_analytic_queries.py::RankTests::test_orderby_asc", + "pypika/tests/test_analytic_queries.py::RankTests::test_orderby_desc", + "pypika/tests/test_analytic_queries.py::RankTests::test_range_called_twice_raises_attribute_error", + "pypika/tests/test_analytic_queries.py::RankTests::test_range_then_rows_raises_attribute_error", + "pypika/tests/test_analytic_queries.py::RankTests::test_rank", + "pypika/tests/test_analytic_queries.py::RankTests::test_rank_with_alias", + "pypika/tests/test_analytic_queries.py::RankTests::test_row_number", + "pypika/tests/test_analytic_queries.py::RankTests::test_rows_called_twice_raises_attribute_error", + "pypika/tests/test_analytic_queries.py::RankTests::test_rows_then_range_raises_attribute_error", + "pypika/tests/test_analytic_queries.py::RankTests::test_stddev", + "pypika/tests/test_analytic_queries.py::RankTests::test_stddev_pop", + "pypika/tests/test_analytic_queries.py::RankTests::test_stddev_samp", + "pypika/tests/test_analytic_queries.py::RankTests::test_sum_rows_unbounded_preceeding", + "pypika/tests/test_analytic_queries.py::RankTests::test_table_prefixes_used_in_analytic_functions", + "pypika/tests/test_analytic_queries.py::RankTests::test_var_pop", + "pypika/tests/test_analytic_queries.py::RankTests::test_var_samp", + "pypika/tests/test_analytic_queries.py::RankTests::test_variance", + "pypika/tests/test_analytic_queries.py::RankTests::test_variance_rows_between_unbounded_preceeding_unbounded_following", + "pypika/tests/test_analytic_queries.py::RankTests::test_varpop_range_unbounded_preceeding", + "pypika/tests/test_analytic_queries.py::RankTests::test_varpop_rows_between_unbounded_preceeding_x_following", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_as_select_not_query_raises_error", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_with_columns", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_with_select", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_with_select_and_columns_fails", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_without_columns_or_select_empty", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_if_not_exists", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_simple", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_unique", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_where", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_without_columns_raises_error", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_without_table_raises_error", + "pypika/tests/test_criterions.py::CriterionTests::test__bitwise_and_in_where_clause", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_bitwise_and", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_bitwise_and_with_alias", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_bool", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_decimal", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_str", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gt_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gt_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gt_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gt_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gte_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gte_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gte_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gte_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_is_null", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_is_null_with_alias", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lt_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lt_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lt_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lt_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lte_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lte_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lte_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lte_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_str", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_with_alias", + "pypika/tests/test_criterions.py::NotTests::test_chained_function", + "pypika/tests/test_criterions.py::NotTests::test_is_not_null", + "pypika/tests/test_criterions.py::NotTests::test_negate", + "pypika/tests/test_criterions.py::NotTests::test_not_null", + "pypika/tests/test_criterions.py::NotTests::test_not_null_with_alias", + "pypika/tests/test_criterions.py::NotTests::test_not_with_and_criterion", + "pypika/tests/test_criterions.py::NotTests::test_not_with_complex_criterion", + "pypika/tests/test_criterions.py::NotTests::test_not_with_or_criterion", + "pypika/tests/test_criterions.py::NotTests::test_notnullcriterion_replace_table", + "pypika/tests/test_criterions.py::NotTests::test_variable_access", + "pypika/tests/test_criterions.py::BetweenTests::test__between_date", + "pypika/tests/test_criterions.py::BetweenTests::test__between_datetime", + "pypika/tests/test_criterions.py::BetweenTests::test__between_number", + "pypika/tests/test_criterions.py::BetweenTests::test__between_with_alias", + "pypika/tests/test_criterions.py::BetweenTests::test__function_between", + "pypika/tests/test_criterions.py::BetweenTests::test_get_item_only_works_with_slice", + "pypika/tests/test_criterions.py::IsInTests::test__function_isin", + "pypika/tests/test_criterions.py::IsInTests::test__in_character", + "pypika/tests/test_criterions.py::IsInTests::test__in_date", + "pypika/tests/test_criterions.py::IsInTests::test__in_datetime", + "pypika/tests/test_criterions.py::IsInTests::test__in_number", + "pypika/tests/test_criterions.py::IsInTests::test__in_number_with_alias", + "pypika/tests/test_criterions.py::IsInTests::test__in_unicode", + "pypika/tests/test_criterions.py::ArithmeticExpressionTests::test__lshift", + "pypika/tests/test_criterions.py::ArithmeticExpressionTests::test__rshift", + "pypika/tests/test_criterions.py::NotInTests::test__function_notin", + "pypika/tests/test_criterions.py::NotInTests::test__notin_character", + "pypika/tests/test_criterions.py::NotInTests::test__notin_date", + "pypika/tests/test_criterions.py::NotInTests::test__notin_datetime", + "pypika/tests/test_criterions.py::NotInTests::test__notin_number", + "pypika/tests/test_criterions.py::NotInTests::test__notin_number_with_alias", + "pypika/tests/test_criterions.py::LikeTests::test_glob_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_contains", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_ends_with", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_n_chars_long", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_starts_with", + "pypika/tests/test_criterions.py::LikeTests::test_like_contains", + "pypika/tests/test_criterions.py::LikeTests::test_like_ends_with", + "pypika/tests/test_criterions.py::LikeTests::test_like_n_chars_long", + "pypika/tests/test_criterions.py::LikeTests::test_like_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_like_starts_with", + "pypika/tests/test_criterions.py::LikeTests::test_not_ilike_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_not_like_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_rlike_escape_chars", + "pypika/tests/test_criterions.py::ExistsCriterionTests::test_exists", + "pypika/tests/test_criterions.py::ExistsCriterionTests::test_not_exists", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__between_and_field", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__between_and_isin", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__nested__and", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__nested__mixed", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__nested__or", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_and", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_function_and", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_function_or", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_function_xor", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_or", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_xor", + "pypika/tests/test_criterions.py::FieldsAsCriterionTests::test__field_and_field", + "pypika/tests/test_criterions.py::FieldsAsCriterionTests::test__field_or_field", + "pypika/tests/test_criterions.py::FieldsAsCriterionTests::test__field_xor_field", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_arithmeticfunction_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_betweencriterion_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_complexcriterion_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_criterion_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_field_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_function_with_only_fields_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_function_with_values_and_fields_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_nullcriterion_replace_table", + "pypika/tests/test_criterions.py::AnyTests::test_multiple_args_returned_in_chain_of_ors", + "pypika/tests/test_criterions.py::AnyTests::test_single_arg_returns_self", + "pypika/tests/test_criterions.py::AnyTests::test_with_generator", + "pypika/tests/test_criterions.py::AnyTests::test_zero_args_returns_empty_criterion", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_different_operations_with_empty_criterion", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_empty_criterion_on_the_left", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_empty_criterion_on_the_right", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_fields_", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_invertion_of_the_empty_criterion", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_more_than_one_empty_criterions", + "pypika/tests/test_criterions.py::AllTests::test_multiple_args_returned_in_chain_of_ors", + "pypika/tests/test_criterions.py::AllTests::test_single_arg_returns_self", + "pypika/tests/test_criterions.py::AllTests::test_with_generator", + "pypika/tests/test_criterions.py::AllTests::test_zero_args_returns_empty_criterion", + "pypika/tests/test_custom_functions.py::TestUnitCustomFunction::test_should_fail_with_wrong_arguments", + "pypika/tests/test_custom_functions.py::TestUnitCustomFunction::test_should_return_function_with_arguments", + "pypika/tests/test_custom_functions.py::TestUnitCustomFunction::test_should_return_function_with_no_arguments", + "pypika/tests/test_custom_functions.py::TestFunctionalCustomFunction::test_should_fail_use_custom_function_on_select_with_wrong_arguments", + "pypika/tests/test_custom_functions.py::TestFunctionalCustomFunction::test_should_use_custom_function_on_select", + "pypika/tests/test_data_types.py::StringTests::test_inline_string_concatentation", + "pypika/tests/test_data_types.py::UuidTests::test_uuid_string_generation", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_day", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_default", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_microsecond", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_minute", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_month", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_quarter", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_second", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_week", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_year", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_day_hour", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_day_microsecond", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_day_minute", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_day_second", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_hour_microsecond", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_hour_minute", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_hour_second", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_minute_microsecond", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_minute_second", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_second_microsecond", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_value_complex_expressions", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_value_right", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_year_month", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_mysql_dialect_uses_single_quotes_around_expression_in_an_interval", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_oracle_dialect_uses_single_quotes_around_expression_in_an_interval", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_postgresql_dialect_uses_single_quotes_around_interval", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_redshift_dialect_uses_single_quotes_around_interval", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_vertica_dialect_uses_single_quotes_around_interval", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_day", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_month", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_week", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_year", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_year_month", + "pypika/tests/test_date_math.py::TruncateTrailingZerosTests::test_do_not_truncate_integer_values", + "pypika/tests/test_date_math.py::TruncateTrailingZerosTests::test_do_not_truncate_months_between_years_and_datys", + "pypika/tests/test_deletes.py::DeleteTests::test_for_portion", + "pypika/tests/test_deletes.py::DeleteTests::test_omit_where", + "pypika/tests/test_deletes.py::DeleteTests::test_omit_where__table_schema", + "pypika/tests/test_deletes.py::DeleteTests::test_where_field_equals", + "pypika/tests/test_deletes.py::PostgresDeleteTests::test_delete_returning", + "pypika/tests/test_deletes.py::PostgresDeleteTests::test_delete_returning_star", + "pypika/tests/test_deletes.py::PostgresDeleteTests::test_delete_returning_str", + "pypika/tests/test_deletes.py::PostgresDeleteTests::test_delete_using", + "pypika/tests/test_drop.py::DropTableTests::test_drop_database", + "pypika/tests/test_drop.py::DropTableTests::test_drop_index", + "pypika/tests/test_drop.py::DropTableTests::test_drop_table", + "pypika/tests/test_drop.py::DropTableTests::test_drop_user", + "pypika/tests/test_drop.py::DropTableTests::test_drop_view", + "pypika/tests/test_formats.py::QuoteTests::test_no_quote_char_in_complex_query", + "pypika/tests/test_formats.py::QuoteTests::test_replace_quote_char_in_complex_query", + "pypika/tests/test_functions.py::FunctionTests::test_dialect_propagation", + "pypika/tests/test_functions.py::FunctionTests::test_is_aggregate_None_for_non_aggregate_function_or_function_with_no_aggregate_functions", + "pypika/tests/test_functions.py::FunctionTests::test_is_aggregate_True_for_aggregate_function_or_function_with_aggregate_functions", + "pypika/tests/test_functions.py::SchemaTests::test_schema_included_in_function_sql", + "pypika/tests/test_functions.py::SchemaTests::test_schema_no_schema_in_sql_when_none_set", + "pypika/tests/test_functions.py::ArithmeticTests::test__addition__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__addition__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__addition__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__addition__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__arithmetic_equality", + "pypika/tests/test_functions.py::ArithmeticTests::test__arithmetic_with_function", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_add_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_div_no_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_div_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_exponent_no_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_exponent_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_floor_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_function_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_modulus_no_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_modulus_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_mul_no_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_mul_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_nested_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_sub_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__division__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__division__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__division__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__division__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__exponent__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__exponent__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__floor", + "pypika/tests/test_functions.py::ArithmeticTests::test__leftshift__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__leftshift__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__leftshift__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__modulus__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__multiplication__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__multiplication__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__multiplication__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__multiplication__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__rightshift__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__rightshift__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__rightshift__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__subtraction__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__subtraction__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__subtraction__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__subtraction__right", + "pypika/tests/test_functions.py::AggregationTests::test__approx_percentile", + "pypika/tests/test_functions.py::AggregationTests::test__avg", + "pypika/tests/test_functions.py::AggregationTests::test__count", + "pypika/tests/test_functions.py::AggregationTests::test__count__star", + "pypika/tests/test_functions.py::AggregationTests::test__first", + "pypika/tests/test_functions.py::AggregationTests::test__last", + "pypika/tests/test_functions.py::AggregationTests::test__max", + "pypika/tests/test_functions.py::AggregationTests::test__min", + "pypika/tests/test_functions.py::AggregationTests::test__std", + "pypika/tests/test_functions.py::AggregationTests::test__stddev", + "pypika/tests/test_functions.py::AggregationTests::test__subquery_in_params_functions", + "pypika/tests/test_functions.py::AggregationTests::test__sum", + "pypika/tests/test_functions.py::ConditionTests::test__case__else", + "pypika/tests/test_functions.py::ConditionTests::test__case__field", + "pypika/tests/test_functions.py::ConditionTests::test__case__multi", + "pypika/tests/test_functions.py::ConditionTests::test__case__no_cases", + "pypika/tests/test_functions.py::ConditionTests::test__case__raw", + "pypika/tests/test_functions.py::StringTests::test__ascii__field", + "pypika/tests/test_functions.py::StringTests::test__ascii__int", + "pypika/tests/test_functions.py::StringTests::test__ascii__str", + "pypika/tests/test_functions.py::StringTests::test__bin__field", + "pypika/tests/test_functions.py::StringTests::test__bin__int", + "pypika/tests/test_functions.py::StringTests::test__bin__str", + "pypika/tests/test_functions.py::StringTests::test__concat__field", + "pypika/tests/test_functions.py::StringTests::test__concat__str", + "pypika/tests/test_functions.py::StringTests::test__insert__field", + "pypika/tests/test_functions.py::StringTests::test__insert__str", + "pypika/tests/test_functions.py::StringTests::test__length__field", + "pypika/tests/test_functions.py::StringTests::test__length__str", + "pypika/tests/test_functions.py::StringTests::test__lower__field", + "pypika/tests/test_functions.py::StringTests::test__lower__str", + "pypika/tests/test_functions.py::StringTests::test__replace__field", + "pypika/tests/test_functions.py::StringTests::test__replace__str", + "pypika/tests/test_functions.py::StringTests::test__substring", + "pypika/tests/test_functions.py::SplitPartFunctionTests::test__split_part", + "pypika/tests/test_functions.py::RegexpLikeFunctionTests::test__regexp_like", + "pypika/tests/test_functions.py::CastTests::test__cast__as", + "pypika/tests/test_functions.py::CastTests::test__cast__binary", + "pypika/tests/test_functions.py::CastTests::test__cast__binary_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__boolean", + "pypika/tests/test_functions.py::CastTests::test__cast__char", + "pypika/tests/test_functions.py::CastTests::test__cast__char_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__date", + "pypika/tests/test_functions.py::CastTests::test__cast__float", + "pypika/tests/test_functions.py::CastTests::test__cast__integer", + "pypika/tests/test_functions.py::CastTests::test__cast__long_varbinary", + "pypika/tests/test_functions.py::CastTests::test__cast__long_varbinary_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__long_varchar", + "pypika/tests/test_functions.py::CastTests::test__cast__long_varchar_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__numeric", + "pypika/tests/test_functions.py::CastTests::test__cast__signed", + "pypika/tests/test_functions.py::CastTests::test__cast__timestamp", + "pypika/tests/test_functions.py::CastTests::test__cast__unsigned", + "pypika/tests/test_functions.py::CastTests::test__cast__varbinary", + "pypika/tests/test_functions.py::CastTests::test__cast__varbinary_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__varchar", + "pypika/tests/test_functions.py::CastTests::test__cast__varchar_with_arg", + "pypika/tests/test_functions.py::CastTests::test__tochar__", + "pypika/tests/test_functions.py::DateFunctionsTests::test_current_date", + "pypika/tests/test_functions.py::DateFunctionsTests::test_current_time", + "pypika/tests/test_functions.py::DateFunctionsTests::test_current_timestamp", + "pypika/tests/test_functions.py::DateFunctionsTests::test_current_timestamp_with_alias", + "pypika/tests/test_functions.py::DateFunctionsTests::test_date_add", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_day", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_hour", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_join", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_microsecond", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_minute", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_month", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_quarter", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_second", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_week", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_year", + "pypika/tests/test_functions.py::DateFunctionsTests::test_now", + "pypika/tests/test_functions.py::DateFunctionsTests::test_time_diff", + "pypika/tests/test_functions.py::DateFunctionsTests::test_timestampadd", + "pypika/tests/test_functions.py::DateFunctionsTests::test_to_date", + "pypika/tests/test_functions.py::DateFunctionsTests::test_utc_timestamp", + "pypika/tests/test_functions.py::NullFunctionsTests::test_coalesce", + "pypika/tests/test_functions.py::NullFunctionsTests::test_isnull", + "pypika/tests/test_functions.py::NullFunctionsTests::test_nullif", + "pypika/tests/test_functions.py::NullFunctionsTests::test_nvl", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_mysql_one_groupby", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_mysql_rollup_two_groupbys", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_no_rollup_after_rollup_mysql", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_no_rollup_before_groupby", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_from_groupbys", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_from_parameters", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_from_two_groupbys", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_func_one_groupby", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_func_partial", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_func_two_groupbys", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_multiple_rollups", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_rollups_with_multiple_rollups_and_parity", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_rollups_with_parity", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_force_index_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_groupby_returns_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_immutable_kwarg_on_query_builder_disables_immutability", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_insert_into_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_join_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_orderby_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_queries_after_join", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_replace_into_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_select_returns_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_update_set_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_use_index_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_with_return_new_query_instance", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_multi_rows", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_multi_rows_chained", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_multi_rows_chained_mixed", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_multi_rows_chained_multiple_rows", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_single_element", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_column_using_alias_with_chain", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_column_using_table_alias", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_empty_columns", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_empty_columns_type_list", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_empty_columns_type_tuple", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_ignore", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_multiple_rows_with_array_value", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_none_skipped", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_null", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_one_column", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_one_column_multi_element_array", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_one_column_single_element_array", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_selected_columns", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_selected_columns_type_list", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_selected_columns_type_tuple", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_single_row_with_array_value", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_with_statement", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_empty_on_conflict_do_update_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_field", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_field_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_mixed_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_multiple_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_multiple_fields_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_field", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_field_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_multiple_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_multiple_fields_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_multiple_mixed_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_no_handler", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_two_handlers_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_two_handlers_do_update", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_fieldless_conflict_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_fieldless_conflict_do_update_field", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_non_insert_on_conflict_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_non_insert_on_conflict_do_update", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_do_nothing_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_do_update_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_do_update_with_excluded_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_from_subquery", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_complex", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_conflict_fields_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_conflict_fields_do_update", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_empty_conflict_fields_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_empty_conflict_fields_do_update", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_where_and_on_conflict_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_all_columns_multi_rows_chained_returning_star", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_all_columns_multi_rows_chained_returning_star_and_id", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_all_columns_multi_rows_chained_returning_star_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_all_columns_single_element_arrays", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_aggregate", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_all_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_all_fields_and_arithmetics", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_arithmetics", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_from_other_table", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_functions", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_null", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_one_field", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_one_field_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_tuple", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_ignore", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multi_rows_chained_mixed_on_duplicate_update_multiple", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_multiple", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_different_value", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_expression", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_expression_using_original_field_value", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_expression_using_values", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_same_value", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_none_skipped", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_one_column", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_one_column_multi_element_array", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_one_column_single_element_array", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_one_column_using_values", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_selected_columns_on_duplicate_update_multiple", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_selected_columns_on_duplicate_update_one", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_columns_from_columns", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_columns_from_columns_with_join", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_columns_from_star", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_from_columns", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_ignore_star", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_star", + "pypika/tests/test_inserts.py::InsertSubqueryTests::test_insert_subquery_wrapped_in_brackets", + "pypika/tests/test_inserts.py::SelectIntoTests::test_select_columns_into", + "pypika/tests/test_inserts.py::SelectIntoTests::test_select_columns_into_with_join", + "pypika/tests/test_inserts.py::SelectIntoTests::test_select_star_into", + "pypika/tests/test_inserts.py::ReplaceTests::test_replace_simple", + "pypika/tests/test_inserts.py::ReplaceTests::test_replace_subquery", + "pypika/tests/test_internals.py::TablesTests::test__case_tables", + "pypika/tests/test_internals.py::TablesTests::test__criterion_replace_table_with_value", + "pypika/tests/test_internals.py::TablesTests::test__star_tables", + "pypika/tests/test_internals.py::TablesTests::test__table_star_tables", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_cross_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_cross_join_on_subquery", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_cross_join_on_table", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_default_join_type", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_full_outer_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_hash_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_inner_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_arithmetic_field", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_collate", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_complex_criteria", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_field_multi", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_field_multi_with_extra_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_field_single", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_field_without_fields_raises_exception", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_subquery_criteria", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_second_table_in_from_clause", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_using_multiple_fields", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_using_string_field_name", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_using_with_quote_char", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_using_without_fields_raises_exception", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_with_arithmetic_function_in_select", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_left_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_left_outer_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_outer_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_right_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_right_outer_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_temporal_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_use_different_table_objects_for_same_table", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_fail_when_joining_unknown_type", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_ignore_table_references", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_immutable__tables", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_from_join", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_query_with_column_alias", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_query_with_setoperation", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_query_with_table_alias", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_query_without_alias", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_same_table", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_same_table_with_prefixes", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_table_twice", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_prefixes_added_to_function_in_orderby", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_prefixes_added_to_groupby", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_prefixes_added_to_orderby", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_require_condition", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_require_condition_with_both_tables", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select__fields_after_table_star", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select__ordered_select_clauses", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select__star_for_table", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select__star_for_table__replacement", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select_field_from_missing_table", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select_fields_with_where", + "pypika/tests/test_joins.py::UnionTests::test_mysql_query_wraps_unioned_queries", + "pypika/tests/test_joins.py::UnionTests::test_require_equal_number_of_fields", + "pypika/tests/test_joins.py::UnionTests::test_union", + "pypika/tests/test_joins.py::UnionTests::test_union_all", + "pypika/tests/test_joins.py::UnionTests::test_union_all_multiple", + "pypika/tests/test_joins.py::UnionTests::test_union_as_subquery", + "pypika/tests/test_joins.py::UnionTests::test_union_multiple", + "pypika/tests/test_joins.py::UnionTests::test_union_with_no_quote_char", + "pypika/tests/test_joins.py::UnionTests::test_union_with_order_by", + "pypika/tests/test_joins.py::UnionTests::test_union_with_order_by_use_union_query_field", + "pypika/tests/test_joins.py::UnionTests::test_union_with_order_by_use_union_query_field_with_aliases", + "pypika/tests/test_joins.py::UnionTests::test_union_with_order_by_with_aliases", + "pypika/tests/test_joins.py::InsertQueryJoinTests::test_join_table_on_insert_query", + "pypika/tests/test_joins.py::UpdateQueryJoinTests::test_join_table_on_update_query", + "pypika/tests/test_joins.py::IntersectTests::test_intersect", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_as_subquery", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_multiple", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_with_limit", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_with_no_quote_char", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_with_offset", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_with_order_by", + "pypika/tests/test_joins.py::IntersectTests::test_mysql_query_wraps_intersected_queries", + "pypika/tests/test_joins.py::IntersectTests::test_require_equal_number_of_fields_intersect", + "pypika/tests/test_joins.py::MinusTests::test_minus", + "pypika/tests/test_joins.py::MinusTests::test_minus_as_subquery", + "pypika/tests/test_joins.py::MinusTests::test_minus_multiple", + "pypika/tests/test_joins.py::MinusTests::test_minus_query_with_order_by_use_minus_query_field", + "pypika/tests/test_joins.py::MinusTests::test_minus_with_no_quote_char", + "pypika/tests/test_joins.py::MinusTests::test_minus_with_order_by", + "pypika/tests/test_joins.py::MinusTests::test_mysql_query_wraps_minus_queries", + "pypika/tests/test_joins.py::MinusTests::test_require_equal_number_of_fields", + "pypika/tests/test_joins.py::ExceptOfTests::test_except", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_as_subquery", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_multiple", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_query_with_order_by_use_minus_query_field", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_with_no_quote_char", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_with_order_by", + "pypika/tests/test_joins.py::ExceptOfTests::test_require_equal_number_of_fields_except_of", + "pypika/tests/test_negation.py::NegationTests::test_negate_field", + "pypika/tests/test_negation.py::NegationTests::test_negate_function", + "pypika/tests/test_negation.py::NegationTests::test_negate_wrapped_float", + "pypika/tests/test_negation.py::NegationTests::test_negate_wrapped_int", + "pypika/tests/test_parameter.py::ParametrizedTests::test_format_parameter", + "pypika/tests/test_parameter.py::ParametrizedTests::test_join", + "pypika/tests/test_parameter.py::ParametrizedTests::test_named_parameter", + "pypika/tests/test_parameter.py::ParametrizedTests::test_numeric_parameter", + "pypika/tests/test_parameter.py::ParametrizedTests::test_param_insert", + "pypika/tests/test_parameter.py::ParametrizedTests::test_param_select_join", + "pypika/tests/test_parameter.py::ParametrizedTests::test_param_select_subquery", + "pypika/tests/test_parameter.py::ParametrizedTests::test_pyformat_parameter", + "pypika/tests/test_parameter.py::ParametrizedTests::test_qmark_parameter", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_join", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_join_with_parameter_value_wrapper", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_param_insert", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_param_select_join", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_param_select_subquery", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_pyformat_parameter", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_can_be_used_in_a_select_statement", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_can_be_used_in_a_where_clause", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_can_be_used_in_orderby", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_column_value", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_object_id", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_object_value", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_row_id", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_row_num", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_sys_date", + "pypika/tests/test_query.py::QueryTablesTests::test_is_joined", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_case_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_delete_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_filter_tables", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_having_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_insert_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_insert_table_current_table_not_match", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_join_tables", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_only_specified_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_orderby_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_tuple_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_update_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_update_table_current_table_not_match", + "pypika/tests/test_query.py::QueryBuilderTests::test_pipe", + "pypika/tests/test_query.py::QueryBuilderTests::test_query_builders_have_reference_to_correct_query_class", + "pypika/tests/test_selects.py::SelectTests::test_empty_query", + "pypika/tests/test_selects.py::SelectTests::test_mssql_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_mysql_query_uses_backtick_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_oracle_query_uses_no_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_postgresql_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_redshift_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_select__column__single__alias__str", + "pypika/tests/test_selects.py::SelectTests::test_select__column__single__field", + "pypika/tests/test_selects.py::SelectTests::test_select__column__single__str", + "pypika/tests/test_selects.py::SelectTests::test_select__column__single__table_alias__str", + "pypika/tests/test_selects.py::SelectTests::test_select__columns__multi__field", + "pypika/tests/test_selects.py::SelectTests::test_select__columns__multi__str", + "pypika/tests/test_selects.py::SelectTests::test_select__distinct__multi", + "pypika/tests/test_selects.py::SelectTests::test_select__distinct__single", + "pypika/tests/test_selects.py::SelectTests::test_select__multiple_subqueries", + "pypika/tests/test_selects.py::SelectTests::test_select__multiple_tables", + "pypika/tests/test_selects.py::SelectTests::test_select__nested_subquery", + "pypika/tests/test_selects.py::SelectTests::test_select__no_table", + "pypika/tests/test_selects.py::SelectTests::test_select__star", + "pypika/tests/test_selects.py::SelectTests::test_select__star__replacement", + "pypika/tests/test_selects.py::SelectTests::test_select__subquery", + "pypika/tests/test_selects.py::SelectTests::test_select__table_schema", + "pypika/tests/test_selects.py::SelectTests::test_select__table_schema_with_multiple_levels_as_list", + "pypika/tests/test_selects.py::SelectTests::test_select__table_schema_with_multiple_levels_as_tuple", + "pypika/tests/test_selects.py::SelectTests::test_select_no_from", + "pypika/tests/test_selects.py::SelectTests::test_select_no_from_with_field_raises_exception", + "pypika/tests/test_selects.py::SelectTests::test_select_no_with_alias_from", + "pypika/tests/test_selects.py::SelectTests::test_select_then_add_table", + "pypika/tests/test_selects.py::SelectTests::test_select_with_force_index", + "pypika/tests/test_selects.py::SelectTests::test_select_with_force_index_multiple_calls", + "pypika/tests/test_selects.py::SelectTests::test_select_with_force_index_multiple_indexes", + "pypika/tests/test_selects.py::SelectTests::test_select_with_force_index_with_index_object", + "pypika/tests/test_selects.py::SelectTests::test_select_with_limit", + "pypika/tests/test_selects.py::SelectTests::test_select_with_limit__func", + "pypika/tests/test_selects.py::SelectTests::test_select_with_limit_and_offset", + "pypika/tests/test_selects.py::SelectTests::test_select_with_limit_zero", + "pypika/tests/test_selects.py::SelectTests::test_select_with_offset", + "pypika/tests/test_selects.py::SelectTests::test_select_with_offset__func", + "pypika/tests/test_selects.py::SelectTests::test_select_with_use_index", + "pypika/tests/test_selects.py::SelectTests::test_select_with_use_index_multiple_calls", + "pypika/tests/test_selects.py::SelectTests::test_select_with_use_index_multiple_indexes", + "pypika/tests/test_selects.py::SelectTests::test_select_with_use_index_with_index_object", + "pypika/tests/test_selects.py::SelectTests::test_table_select_alias", + "pypika/tests/test_selects.py::SelectTests::test_table_select_alias_with_offset_and_limit", + "pypika/tests/test_selects.py::SelectTests::test_temporal_select", + "pypika/tests/test_selects.py::SelectTests::test_vertica_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::WhereTests::test_ignore_empty_criterion_having", + "pypika/tests/test_selects.py::WhereTests::test_ignore_empty_criterion_where", + "pypika/tests/test_selects.py::WhereTests::test_select_with_force_index_and_where", + "pypika/tests/test_selects.py::WhereTests::test_where_enum", + "pypika/tests/test_selects.py::WhereTests::test_where_field_contains", + "pypika/tests/test_selects.py::WhereTests::test_where_field_does_not_contain", + "pypika/tests/test_selects.py::WhereTests::test_where_field_does_not_end_with", + "pypika/tests/test_selects.py::WhereTests::test_where_field_does_not_start_with", + "pypika/tests/test_selects.py::WhereTests::test_where_field_ends_with", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_and", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_nowait", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_of", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_of_multiple_tables", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_of_nowait", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_of_skip_locked", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_skip_locked", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_skip_locked_and_of", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_or", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_where", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_where_not", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_where_two_not", + "pypika/tests/test_selects.py::WhereTests::test_where_field_is_n_chars_long", + "pypika/tests/test_selects.py::WhereTests::test_where_field_is_not_n_chars_long", + "pypika/tests/test_selects.py::WhereTests::test_where_field_matches_regex", + "pypika/tests/test_selects.py::WhereTests::test_where_field_matches_regexp", + "pypika/tests/test_selects.py::WhereTests::test_where_field_matches_rlike", + "pypika/tests/test_selects.py::WhereTests::test_where_field_starts_with", + "pypika/tests/test_selects.py::WhereTests::test_where_nested_conditions", + "pypika/tests/test_selects.py::WhereTests::test_where_single_quote", + "pypika/tests/test_selects.py::WhereTests::test_where_with_multiple_wheres_using_and_case", + "pypika/tests/test_selects.py::WhereTests::test_where_with_multiple_wheres_using_or_case", + "pypika/tests/test_selects.py::PreWhereTests::test_ignore_empty_criterion_having", + "pypika/tests/test_selects.py::PreWhereTests::test_ignore_empty_criterion_where", + "pypika/tests/test_selects.py::PreWhereTests::test_prewhere_field_equals", + "pypika/tests/test_selects.py::PreWhereTests::test_select_with_force_index_and_where", + "pypika/tests/test_selects.py::PreWhereTests::test_where_and_prewhere", + "pypika/tests/test_selects.py::PreWhereTests::test_where_enum", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_contains", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_does_not_contain", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_does_not_end_with", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_does_not_start_with", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_ends_with", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_and", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_nowait", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_of", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_of_multiple_tables", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_of_nowait", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_of_skip_locked", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_skip_locked", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_skip_locked_and_of", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_or", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_where", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_where_not", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_where_two_not", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_is_n_chars_long", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_is_not_n_chars_long", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_matches_regex", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_matches_regexp", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_matches_rlike", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_starts_with", + "pypika/tests/test_selects.py::PreWhereTests::test_where_nested_conditions", + "pypika/tests/test_selects.py::PreWhereTests::test_where_single_quote", + "pypika/tests/test_selects.py::PreWhereTests::test_where_with_multiple_wheres_using_and_case", + "pypika/tests/test_selects.py::PreWhereTests::test_where_with_multiple_wheres_using_or_case", + "pypika/tests/test_selects.py::GroupByTests::test_group_by__single_with_totals", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__alias", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__alias_platforms", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__alias_with_join", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__count_distinct", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__count_field", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__count_star", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__int", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__multi", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__multi_with_totals", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__no_alias", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__no_alias_mssql", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__no_alias_oracle", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__single", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__str", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__sum_distinct", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__sum_filter", + "pypika/tests/test_selects.py::GroupByTests::test_groupby_with_case_uses_the_alias", + "pypika/tests/test_selects.py::GroupByTests::test_mssql_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_mysql_query_uses_backtick_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_oracle_query_uses_no_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_postgres_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_redshift_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_vertica_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_having_and", + "pypika/tests/test_selects.py::HavingTests::test_having_greater_than", + "pypika/tests/test_selects.py::HavingTests::test_having_join_and_equality", + "pypika/tests/test_selects.py::HavingTests::test_mssql_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_mysql_query_uses_backtick_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_oracle_query_uses_no_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_postgres_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_redshift_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_vertica_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_alias", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_asc", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_desc", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_multi_fields", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_no_alias", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_single_field", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_single_str", + "pypika/tests/test_selects.py::AliasTests::test_arithmetic_function", + "pypika/tests/test_selects.py::AliasTests::test_case_using_as", + "pypika/tests/test_selects.py::AliasTests::test_case_using_constructor_param", + "pypika/tests/test_selects.py::AliasTests::test_function_using_as_nested", + "pypika/tests/test_selects.py::AliasTests::test_functions_using_as", + "pypika/tests/test_selects.py::AliasTests::test_functions_using_constructor_param", + "pypika/tests/test_selects.py::AliasTests::test_functions_using_constructor_param_nested", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_criterion", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_criterion_comparison", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_field_inside_case", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_groupby", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_orderby", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_where", + "pypika/tests/test_selects.py::AliasTests::test_null_value_with_alias", + "pypika/tests/test_selects.py::AliasTests::test_select__multiple_tables", + "pypika/tests/test_selects.py::AliasTests::test_table_field", + "pypika/tests/test_selects.py::AliasTests::test_table_field__multi", + "pypika/tests/test_selects.py::AliasTests::test_table_with_schema_and_alias", + "pypika/tests/test_selects.py::AliasTests::test_use_aliases_in_groupby_and_orderby", + "pypika/tests/test_selects.py::SubqueryTests::test_from_subquery_without_alias", + "pypika/tests/test_selects.py::SubqueryTests::test_join", + "pypika/tests/test_selects.py::SubqueryTests::test_join_query_with_alias", + "pypika/tests/test_selects.py::SubqueryTests::test_join_with_with", + "pypika/tests/test_selects.py::SubqueryTests::test_select_from_nested_query", + "pypika/tests/test_selects.py::SubqueryTests::test_select_from_nested_query_with_join", + "pypika/tests/test_selects.py::SubqueryTests::test_select_from_with_returning", + "pypika/tests/test_selects.py::SubqueryTests::test_select_subquery", + "pypika/tests/test_selects.py::SubqueryTests::test_select_subquery_with_alias", + "pypika/tests/test_selects.py::SubqueryTests::test_where__equality", + "pypika/tests/test_selects.py::SubqueryTests::test_where__in", + "pypika/tests/test_selects.py::SubqueryTests::test_where__in_nested", + "pypika/tests/test_selects.py::SubqueryTests::test_with", + "pypika/tests/test_selects.py::QuoteTests::test_extraneous_quotes", + "pypika/tests/test_tables.py::TableStructureTests::test_database_schema_table_attr", + "pypika/tests/test_tables.py::TableStructureTests::test_schema_table_attr", + "pypika/tests/test_tables.py::TableStructureTests::test_table_for_period_sql", + "pypika/tests/test_tables.py::TableStructureTests::test_table_for_system_time_sql", + "pypika/tests/test_tables.py::TableStructureTests::test_table_sql", + "pypika/tests/test_tables.py::TableStructureTests::test_table_with_alias", + "pypika/tests/test_tables.py::TableStructureTests::test_table_with_schema_and_schema_parent_arg", + "pypika/tests/test_tables.py::TableStructureTests::test_table_with_schema_arg", + "pypika/tests/test_tables.py::TableEqualityTests::test_many_tables_with_alias", + "pypika/tests/test_tables.py::TableEqualityTests::test_many_tables_with_or_not_alias", + "pypika/tests/test_tables.py::TableEqualityTests::test_many_tables_without_alias", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_equal_by_name", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_equal_by_schema_and_name", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_equal_by_schema_and_name_using_schema", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_equal_by_schema_and_name_using_schema_with_parent", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_not_equal_by_schema_and_name_using_schema_with_different_parents", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_not_equal_with_different_names", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_not_equal_with_different_schemas", + "pypika/tests/test_tables.py::TableDialectTests::test_make_tables_factory_with_default_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_make_tables_factory_with_dialect_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_factory_with_default_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_factory_with_dialect_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_with_bad_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_with_default_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_with_dialect_query_cls", + "pypika/tests/test_terms.py::FieldAliasTests::test_when_alias_specified", + "pypika/tests/test_terms.py::FieldInitTests::test_init_with_str_table", + "pypika/tests/test_terms.py::FieldHashingTests::test_non_tabled_aliased_eq_fields_equally_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_non_tabled_aliased_ne_fields_differently_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_non_tabled_eq_fields_equally_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_non_tabled_ne_fields_differently_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_tabled_eq_fields_equally_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_tabled_ne_fields_differently_hashed", + "pypika/tests/test_terms.py::AtTimezoneTests::test_passes_kwargs_to_field_get_sql", + "pypika/tests/test_terms.py::AtTimezoneTests::test_when_alias_specified", + "pypika/tests/test_terms.py::AtTimezoneTests::test_when_interval_not_specified", + "pypika/tests/test_terms.py::AtTimezoneTests::test_when_interval_specified", + "pypika/tests/test_tuples.py::TupleTests::test_render_alias_in_array_sql", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_equality_tuple_on_both", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_equality_tuple_on_left", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_equality_tuple_on_right", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_in_using_mixed_tuples", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_in_using_pypika_tuples", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_in_using_python_tuples", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_is_aggregate", + "pypika/tests/test_tuples.py::TupleTests::test_tuples_in_join", + "pypika/tests/test_tuples.py::ArrayTests::test_array_general", + "pypika/tests/test_tuples.py::ArrayTests::test_empty_psql_array", + "pypika/tests/test_tuples.py::ArrayTests::test_psql_array_general", + "pypika/tests/test_tuples.py::ArrayTests::test_render_alias_in_array_sql", + "pypika/tests/test_tuples.py::BracketTests::test_arithmetic_with_brackets", + "pypika/tests/test_tuples.py::BracketTests::test_arithmetic_with_brackets_and_alias", + "pypika/tests/test_updates.py::UpdateTests::test_empty_query", + "pypika/tests/test_updates.py::UpdateTests::test_for_portion", + "pypika/tests/test_updates.py::UpdateTests::test_omit_where", + "pypika/tests/test_updates.py::UpdateTests::test_single_quote_escape_in_set", + "pypika/tests/test_updates.py::UpdateTests::test_update__table_schema", + "pypika/tests/test_updates.py::UpdateTests::test_update_from", + "pypika/tests/test_updates.py::UpdateTests::test_update_from_with_where", + "pypika/tests/test_updates.py::UpdateTests::test_update_with_join", + "pypika/tests/test_updates.py::UpdateTests::test_update_with_limit", + "pypika/tests/test_updates.py::UpdateTests::test_update_with_none", + "pypika/tests/test_updates.py::UpdateTests::test_update_with_statement", + "pypika/tests/test_updates.py::PostgresUpdateTests::test_update_returning", + "pypika/tests/test_updates.py::PostgresUpdateTests::test_update_returning_from_different_tables", + "pypika/tests/test_updates.py::PostgresUpdateTests::test_update_returning_star", + "pypika/tests/test_updates.py::PostgresUpdateTests::test_update_returning_str", + "pypika/tests/test_updates.py::SQLLiteUpdateTests::test_update_with_bool", + "pypika/tests/test_utils.py::ImmutabilityTests::test_raise_attribute_error_for_deepcopy", + "pypika/tests/test_utils.py::ImmutabilityTests::test_raise_attribute_error_for_getnewargs", + "pypika/tests/test_utils.py::ImmutabilityTests::test_raise_attribute_error_for_getstate", + "pypika/tests/test_utils.py::ImmutabilityTests::test_raise_attribute_error_for_setstate" + ] +} diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/grade.py b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/grade.py new file mode 100644 index 0000000000000000000000000000000000000000..e3b37293830e51a5c5833c93c4705e1ed9364257 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/grade.py @@ -0,0 +1,128 @@ +"""Trusted private pytest panel runner. Installed only in a fresh grader Job.""" + +import hashlib +import importlib.util +import json +import os +import shutil +import stat +import subprocess +from pathlib import Path, PurePosixPath + + +def sha(raw): + return hashlib.sha256(raw).hexdigest() + + +def safe(value): + path = PurePosixPath(value) + if ( + path.is_absolute() + or path.as_posix() != value + or not path.parts + or any(part in {".", "..", ".git"} for part in path.parts) + ): + raise ValueError("Unsafe trusted test path") + return path + + +def restore(worktree, private, manifest): + worktree, private = Path(worktree), Path(private) + captured = {} + for name, expected in manifest["files"].items(): + path = private / safe(name) + info = path.lstat() + raw = path.read_bytes() if stat.S_ISREG(info.st_mode) else b"" + if ( + not stat.S_ISREG(info.st_mode) + or len(raw) != expected["bytes"] + or sha(raw) != expected["sha256"] + or stat.S_IMODE(info.st_mode) != expected["mode"] + ): + raise ValueError("Trusted private test bytes or modes drifted") + captured[name] = (raw, expected["mode"]) + # Capture and verify every private byte before changing the submitted tree. + for name in manifest["directory_roots"]: + destination = worktree / safe(name) + if destination.is_symlink(): + raise ValueError("Submitted test directory is a symlink") + for parent in destination.parents: + if parent == worktree: + break + if parent.is_symlink(): + raise ValueError("Submitted test parent is a symlink") + if destination.exists(): + if not destination.is_dir(): + raise ValueError("Submitted test directory is not a directory") + shutil.rmtree(destination) + for name, (raw, mode) in captured.items(): + destination = worktree / safe(name) + for parent in destination.parents: + if parent == worktree: + break + if parent.is_symlink(): + raise ValueError("Submitted test parent is a symlink") + if destination.is_symlink(): + raise ValueError("Submitted trusted file is a symlink") + destination.parent.mkdir(parents=True, exist_ok=True) + destination.write_bytes(raw) + destination.chmod(mode) + + +def run(worktree, private_root, output, invoke=None): + private_root, output, worktree = Path(private_root), Path(output), Path(worktree) + expected = json.loads((private_root / "expected-panels.json").read_bytes()) + config = json.loads((private_root / "panel-config.json").read_bytes()) + manifest = json.loads((private_root / "trusted-inventory.json").read_bytes()) + restore(worktree, private_root / "trusted", manifest) + output.mkdir(parents=True, exist_ok=True) + for name in ( + "reward.txt", + "pass-to-pass.xml", + "fail-to-pass.xml", + "pytest-evidence.json", + ): + (output / name).unlink(missing_ok=True) + environment = dict(os.environ) + for key in ("PYTEST_ADDOPTS", "PYTEST_DISABLE_PLUGIN_AUTOLOAD", "PYTHONPATH"): + environment.pop(key, None) + commands, native_exit = [], 0 + invoke = invoke or subprocess.run + for group in ("pass-to-pass", "fail-to-pass"): + if ( + not isinstance(expected[group], list) + or not expected[group] + or any( + not isinstance(target, str) or not target for target in expected[group] + ) + ): + raise ValueError("Frozen native pytest selectors are incomplete") + command = [ + *config["official_pytest_argv"], + "--override-ini=addopts=", + "--junitxml=" + str(output / (group + ".xml")), + *expected[group], + ] + result = invoke(command, cwd=worktree, env=environment, check=False) + native_exit = result.returncode + commands.append({"group": group, "argv": command, "exit_code": native_exit}) + if native_exit != 0: + break + (output / "pytest-commands.json").write_text( + json.dumps(commands, sort_keys=True) + "\n" + ) + spec = importlib.util.spec_from_file_location( + "trusted_pytest_result", private_root / "check_pytest.py" + ) + checker = importlib.util.module_from_spec(spec) + spec.loader.exec_module(checker) + result = checker.assess(output, expected, native_exit) + (output / "reward.txt").write_text(str(result["reward"]) + "\n") + (output / "pytest-evidence.json").write_text( + json.dumps(result, sort_keys=True) + "\n" + ) + return result + + +if __name__ == "__main__": + run("/testbed/repo", "/tests", "/logs/verifier") diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/panel-config.json b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/panel-config.json new file mode 100644 index 0000000000000000000000000000000000000000..6417b9c92e5da5b97ee641bd54f798302af42a31 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/panel-config.json @@ -0,0 +1,28 @@ +{ + "dependency_installation_pinned": false, + "official_install_cmds": [ + "python -m pip install -e ." + ], + "official_pytest_argv": [ + "pytest", + "--disable-warnings", + "--color=no", + "--tb=no", + "--verbose" + ], + "official_test_command": "source /opt/miniconda3/bin/activate; conda activate testbed; pytest --disable-warnings --color=no --tb=no --verbose", + "operator_test_runner_prerequisites": [ + "python -m pip install pytest==8.4.2" + ], + "operator_test_runner_reason": "The official profile invokes pytest, but the common tools runtime does not provide it; pinned separately from source-native project requirements.", + "panel_normalization": "Override project addopts only to execute the exact frozen native panels; add JUnit output, preserve official pytest options and all selectors.", + "python_version": "3.10", + "source_bound_test_dependency_cmds": [ + "python -m pip install parameterized==0.7.0" + ], + "test_dependency_source_sha256": { + "requirements-dev.txt": "10f4ba7b19a73950d28fd7403d7e1d1b1fe2ccc4f49516974f47199d2965f23d", + "setup.py": "f8bad274588a22e65764d8cf9fb2be5aa6fcfaf3bf861d71e5f751105898845a", + "tox.ini": "c2d7205d0ac93e9c9e80dc5d24f0a826a6781f587a33ea722ea621f9e2ccd0ea" + } +} diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/test.sh b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..81b6d0620f05dbd3b54b4e7ea5de04ce3f8a98e2 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/test.sh @@ -0,0 +1,6 @@ +#!/bin/bash +set -Eeuo pipefail +source /opt/miniconda3/bin/activate +conda activate testbed +cd /testbed/repo +exec python -I /tests/grade.py diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted-inventory.json b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted-inventory.json new file mode 100644 index 0000000000000000000000000000000000000000..6926ef1c22ed56457101c37cd70e0fe0d1656f0c --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted-inventory.json @@ -0,0 +1,242 @@ +{ + "directory_roots": [ + "pypika/tests" + ], + "files": { + "pypika/tests/__init__.py": { + "bytes": 58, + "mode": 420, + "sha256": "7d41f44b87688bdf162e6d5cbe7b517cfba468f96eaa421f02718c17eb486a18" + }, + "pypika/tests/clickhouse/__init__.py": { + "bytes": 0, + "mode": 420, + "sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "pypika/tests/clickhouse/test_array.py": { + "bytes": 2942, + "mode": 420, + "sha256": "0f0a5b4c3daf3ddce2944b6119795e80d50b74e4687ef2e34399e5d21d3d48ae" + }, + "pypika/tests/clickhouse/test_condition.py": { + "bytes": 2533, + "mode": 420, + "sha256": "c666976d082b1d12cd57e791d1a525183246335efad96a369b58871a6f1e4fa1" + }, + "pypika/tests/clickhouse/test_dates_and_times.py": { + "bytes": 2508, + "mode": 420, + "sha256": "cb8ea84363e35ad0a00b52a8ec20cb38f2348f4cba28d026a4c32c14fd1fc56f" + }, + "pypika/tests/clickhouse/test_nullable_arg.py": { + "bytes": 672, + "mode": 420, + "sha256": "883c5161ebeb09544ce124d20a096d248bd12a0404ad77c84637be75d6738529" + }, + "pypika/tests/clickhouse/test_search_string.py": { + "bytes": 1189, + "mode": 420, + "sha256": "d5f0ed6a51cf550bdd4b261fa2e98084184dd1cbb08f5dbb8b91278b4c8f3bfd" + }, + "pypika/tests/clickhouse/test_type_conversion.py": { + "bytes": 4445, + "mode": 420, + "sha256": "7e6045b64433a8947346cfb34ac30279349f7a2e2081a2815212c8cb7d0235ab" + }, + "pypika/tests/dialects/__init__.py": { + "bytes": 0, + "mode": 420, + "sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "pypika/tests/dialects/test_clickhouse.py": { + "bytes": 5747, + "mode": 420, + "sha256": "2272538d6eeb6dfb01f9803eed328b4cd4efc8d255b6a8ab3c4e25bee74d73fa" + }, + "pypika/tests/dialects/test_mssql.py": { + "bytes": 3152, + "mode": 420, + "sha256": "0cd9b2ee6498caa9fa75a51ead30803057fb23deb2ac706d396d88329e0e91d7" + }, + "pypika/tests/dialects/test_mysql.py": { + "bytes": 2984, + "mode": 420, + "sha256": "a5f4550dd14bf4820e5d85cf06b6c7c79286e41d2d3c794f639579d20fffab92" + }, + "pypika/tests/dialects/test_oracle.py": { + "bytes": 1906, + "mode": 420, + "sha256": "67f80eb40cc9b4dabcbad355e8be6d83c54a64cbee809182ef57fa9f48d2ebc6" + }, + "pypika/tests/dialects/test_postgresql.py": { + "bytes": 9532, + "mode": 420, + "sha256": "548ee7267ca87c9e1ae82ca89a4e5bd96c7392a55cc07996f2b105f911ffa6cf" + }, + "pypika/tests/dialects/test_snowflake.py": { + "bytes": 2159, + "mode": 420, + "sha256": "e567b9dab0a5366bd11a0ef162c3a3bb492280b78bc4b397a23070563dc84468" + }, + "pypika/tests/dialects/test_sqllite.py": { + "bytes": 1243, + "mode": 420, + "sha256": "118fed7e575415f276bda390a119080bd6a767aee3d9c953e11a8c219f0f017c" + }, + "pypika/tests/dialects/test_vertica.py": { + "bytes": 3578, + "mode": 420, + "sha256": "33a027e6735ca03b7afd11394905c4193e48a15dda3efbe47cdcd85fcabf840c" + }, + "pypika/tests/test_aggregate.py": { + "bytes": 3946, + "mode": 420, + "sha256": "5b0fb549de3bb50ad88ae1d75824f12f7ab4a5f1102b06a70c7b2ebae33bea6d" + }, + "pypika/tests/test_analytic_queries.py": { + "bytes": 20611, + "mode": 420, + "sha256": "8546b7a296c8e212c349c4baff95f93934b3120f74625b3945ade3b438e3a3ed" + }, + "pypika/tests/test_create.py": { + "bytes": 9088, + "mode": 420, + "sha256": "6c57302da52ca1044be0afdafe677d5de245e44873dff1386c9a1ccb2625cc82" + }, + "pypika/tests/test_criterions.py": { + "bytes": 32014, + "mode": 420, + "sha256": "78539ccca82f9a02fad0f5a39041ac343e3a142ce52368cd4f6ada489c52516a" + }, + "pypika/tests/test_custom_functions.py": { + "bytes": 1710, + "mode": 420, + "sha256": "bfa18bc328a3577965db7cc75eb94439f0cfd95a3775d9b1cc8af1062bb202cb" + }, + "pypika/tests/test_data_types.py": { + "bytes": 403, + "mode": 420, + "sha256": "c1be6ecc621a80dd91d35b1427bdfc8b1b33bd926515198e626d6fb5e1878c8b" + }, + "pypika/tests/test_date_math.py": { + "bytes": 5544, + "mode": 420, + "sha256": "85aa54efe54fe19639f2dc2a5750647e3337ac2681768bc3fe327841f1634d9e" + }, + "pypika/tests/test_deletes.py": { + "bytes": 3204, + "mode": 420, + "sha256": "ccde6df760d76d5d499ce828f6b0e2ad3eebcb2a5553c1890f481b9160b8d51a" + }, + "pypika/tests/test_drop.py": { + "bytes": 1556, + "mode": 420, + "sha256": "a13dffa59ef8657398d5498c18977bfd702635e336ea9966b1a86137afca7926" + }, + "pypika/tests/test_formats.py": { + "bytes": 1948, + "mode": 420, + "sha256": "240458a404bb119322778893b94a12be0f98f914acd701d2b4be73eb9be96f75" + }, + "pypika/tests/test_functions.py": { + "bytes": 32769, + "mode": 420, + "sha256": "3ceaac7791bd27e50f44e1b4a1451d1e09afe6a8011052caea838e5124582154" + }, + "pypika/tests/test_groupby_modifiers.py": { + "bytes": 5227, + "mode": 420, + "sha256": "9db4497660f08e3352a9a02c34889ad1cd6bab3aebaeaa485e84390ad71c84c5" + }, + "pypika/tests/test_immutability.py": { + "bytes": 3954, + "mode": 420, + "sha256": "af537ced19f7274951cc91697eae748ef6c9cd20a8d8e492d93dc85b06f8fb50" + }, + "pypika/tests/test_inserts.py": { + "bytes": 32549, + "mode": 420, + "sha256": "652e9f7f0f425e9acc0f70e2851ae29310b378262ea30369ea0113ef428f210f" + }, + "pypika/tests/test_internals.py": { + "bytes": 828, + "mode": 420, + "sha256": "4374c2632563346d00ca4de6af397a022ef3f5022e808c8711a3f207a3a21609" + }, + "pypika/tests/test_joins.py": { + "bytes": 43895, + "mode": 420, + "sha256": "53f224815c10393382443f020cb20e313420764495a8fd30f7ea2f34fd52935d" + }, + "pypika/tests/test_negation.py": { + "bytes": 763, + "mode": 420, + "sha256": "6be105e8f39b32fb23e6ac7c7158232ee78111455d4f35638c8af60781138c79" + }, + "pypika/tests/test_parameter.py": { + "bytes": 7382, + "mode": 420, + "sha256": "aaf2a3e79c8267bdc60e218445bc2a2254b97cf37b643a44d6f1a8141cbb5104" + }, + "pypika/tests/test_pseudocolumns.py": { + "bytes": 1609, + "mode": 420, + "sha256": "b7c69f7aca41323c0e14a6a9e58697399cd7860610f07291afc6e8af26079ca2" + }, + "pypika/tests/test_query.py": { + "bytes": 9025, + "mode": 420, + "sha256": "2da9d717673912a84e86e6c0d3955dbd8f2fa7b41b7ed9a6f78089dfa28f9444" + }, + "pypika/tests/test_selects.py": { + "bytes": 50757, + "mode": 420, + "sha256": "5ac1b7ad3248d64b1e3865a72c763873514ae5cd6e03356b913e531c0c336986" + }, + "pypika/tests/test_tables.py": { + "bytes": 6568, + "mode": 420, + "sha256": "384c8e843ba56374ee92cd7b7e2fd3f89247b899e23cd9e1f6663d751ad5d884" + }, + "pypika/tests/test_terms.py": { + "bytes": 3215, + "mode": 420, + "sha256": "8598513180ddcd28cc61582618d85bd570280978b07603044dae81b2eb099f77" + }, + "pypika/tests/test_tuples.py": { + "bytes": 6033, + "mode": 420, + "sha256": "863942196a93e8939be0d03c49cfeb42a35503ad42f9f3d6c730260112811087" + }, + "pypika/tests/test_updates.py": { + "bytes": 5689, + "mode": 420, + "sha256": "0f0f2521bb8d1f5d782f8fabaea5fd1d82090cde045ba87fad65770db6c75d2f" + }, + "pypika/tests/test_utils.py": { + "bytes": 834, + "mode": 420, + "sha256": "5db6e90df5daaa70b9f35f1243db69908da1f27887f63466fc27ce20c7e14892" + }, + "pyproject.toml": { + "bytes": 390, + "mode": 420, + "sha256": "037fedacd5be5d078f398265ff97e1677e25214ad8839d17073a439695ee7a91" + }, + "setup.cfg": { + "bytes": 317, + "mode": 420, + "sha256": "c84a31de586e8385e741127b004fc1f19ebae6463cdf0b3f243991db35cdeaea" + }, + "setup.py": { + "bytes": 2638, + "mode": 420, + "sha256": "f8bad274588a22e65764d8cf9fb2be5aa6fcfaf3bf861d71e5f751105898845a" + }, + "tox.ini": { + "bytes": 257, + "mode": 420, + "sha256": "c2d7205d0ac93e9c9e80dc5d24f0a826a6781f587a33ea722ea621f9e2ccd0ea" + } + } +} diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/__init__.py b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..86d8a68101915c27b95484243dd81d55f7dba356 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/__init__.py @@ -0,0 +1,2 @@ +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/clickhouse/__init__.py b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/clickhouse/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/clickhouse/test_array.py b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/clickhouse/test_array.py new file mode 100644 index 0000000000000000000000000000000000000000..469705a9ff3c8fe9cc7f02c44a9812521eeb67f4 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/clickhouse/test_array.py @@ -0,0 +1,104 @@ +import unittest + +from parameterized import parameterized + +from pypika import Field +from pypika.clickhouse.array import ( + Array, + Empty, + HasAny, + Length, + NotEmpty, +) +from pypika.clickhouse.type_conversion import ( + ToFixedString, + ToInt64, +) + + +class TestArray(unittest.TestCase): + @parameterized.expand( + [ + ( + "['ridley', 'scott', 'jimi', 'hendrix']", + Array(["ridley", "scott", "jimi", "hendrix"]), + ), + ( + "[1, 2, 3, 4]", + Array([1, 2, 3, 4]), + ), + ( + "[toInt64('1'),toInt64('2'),toInt64('3'),toInt64('4')]", + Array(["1", "2", "3", "4"], ToInt64), + ), + ( + "[toFixedString('mogwai',10),toFixedString('mono',10),toFixedString('bonobo',10)] arr", + Array(["mogwai", "mono", "bonobo"], ToFixedString, {"length": 10}).as_('arr'), + ), + ] + ) + def test_get_sql(self, expected: str, array: Array): + self.assertEqual(expected, array.get_sql()) + + +class TestHasAny(unittest.TestCase): + @parameterized.expand( + [ + ( + 'hasAny("mental_abilities","physical_abilities")', + HasAny(Field("mental_abilities"), Field("physical_abilities")), + ), + ("hasAny([1, 2, 3, 4],[3])", HasAny(Array([1, 2, 3, 4]), Array([3]))), + ( + "hasAny(\"bands\",[toFixedString('port-royal',20),toFixedString('hammock',20)])", + HasAny( + Field("bands"), + Array(["port-royal", "hammock"], ToFixedString, {"length": 20}), + ), + ), + ] + ) + def test_get_sql(self, expected: str, func: HasAny): + self.assertEqual(expected, func.get_sql()) + + +class TestLength(unittest.TestCase): + @parameterized.expand( + [ + ( + 'length("tags")', + Length(Field("tags")), + ), + ("length([1, 2, 3])", Length(Array([1, 2, 3]))), + ] + ) + def test_get_sql(self, expected: str, func: Length): + self.assertEqual(expected, func.get_sql()) + + +class TestEmpty(unittest.TestCase): + @parameterized.expand( + [ + ( + 'empty("tags")', + Empty(Field("tags")), + ), + ("empty([1, 2, 3])", Empty(Array([1, 2, 3]))), + ] + ) + def test_get_sql(self, expected: str, func: Empty): + self.assertEqual(expected, func.get_sql()) + + +class TestNotEmpty(unittest.TestCase): + @parameterized.expand( + [ + ( + 'notEmpty("tags")', + NotEmpty(Field("tags")), + ), + ("notEmpty([1, 2, 3])", NotEmpty(Array([1, 2, 3]))), + ] + ) + def test_get_sql(self, expected: str, func: NotEmpty): + self.assertEqual(expected, func.get_sql()) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/clickhouse/test_condition.py b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/clickhouse/test_condition.py new file mode 100644 index 0000000000000000000000000000000000000000..145baeb7753dd9cbefbd6f272bd672ae5730b0c0 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/clickhouse/test_condition.py @@ -0,0 +1,72 @@ +import unittest + +from parameterized import parameterized + +from pypika import Field +from pypika.clickhouse.condition import If, MultiIf +from pypika.clickhouse.type_conversion import ToFixedString + + +class TestIfCondition(unittest.TestCase): + @parameterized.expand( + [ + ( + If( + Field("filmmaker").isnull(), + ToFixedString("Tarantino", 20), + Field("filmmaker"), + ), + "if(filmmaker IS NULL,toFixedString('Tarantino',20),filmmaker)", + ), + ( + If( + Field("created") == Field("updated"), + ToFixedString("yes", 3), + ToFixedString("no", 3), + ), + "if(created=updated,toFixedString('yes',3),toFixedString('no',3))", + ), + ] + ) + def test_get_sql(self, func, expected): + self.assertEqual(func.get_sql(), expected) + + +class TestMultiIfCondition(unittest.TestCase): + @parameterized.expand( + [ + ( + MultiIf( + Field("filmmaker").isnull(), + ToFixedString("Tarantino", 20), + Field("filmmaker") == ToFixedString("undefined", 20), + ToFixedString("Tarantino", 20), + Field("filmmaker"), + ), + "multiIf(filmmaker IS NULL," + "toFixedString('Tarantino',20)," + "filmmaker=toFixedString('undefined',20)," + "toFixedString('Tarantino',20),filmmaker)", + ), + ( + MultiIf( + Field("color") == ToFixedString("black", 20), + ToFixedString("dark", 20), + Field("color") == ToFixedString("grey", 20), + ToFixedString("dark", 20), + Field("color") == ToFixedString("white", 20), + ToFixedString("light", 20), + ToFixedString("undefined", 20), + ), + "multiIf(color=toFixedString('black',20)," + "toFixedString('dark',20)," + "color=toFixedString('grey',20)," + "toFixedString('dark',20)," + "color=toFixedString('white',20)," + "toFixedString('light',20)," + "toFixedString('undefined',20))", + ), + ] + ) + def test_get_sql(self, func, expected): + self.assertEqual(func.get_sql(), expected) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/clickhouse/test_dates_and_times.py b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/clickhouse/test_dates_and_times.py new file mode 100644 index 0000000000000000000000000000000000000000..135dd7f112131776d76748e15eead1eb81752b59 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/clickhouse/test_dates_and_times.py @@ -0,0 +1,70 @@ +import unittest + +from parameterized import parameterized + +from pypika import Field +from pypika.clickhouse.dates_and_times import ( + AddDays, + AddHours, + AddMinutes, + AddMonths, + AddQuarters, + AddSeconds, + AddWeeks, + AddYears, + FormatDateTime, + SubtractDays, + SubtractHours, + SubtractMinutes, + SubtractMonths, + SubtractQuarters, + SubtractSeconds, + SubtractWeeks, + SubtractYears, + ToYYYYMM, +) + + +class TestFormatDateTime(unittest.TestCase): + @parameterized.expand( + [ + (FormatDateTime(Field("created"), "%V"), "formatDateTime(created,'%V')"), + ( + FormatDateTime(Field("created"), "%Y-%m-%d"), + "formatDateTime(created,'%Y-%m-%d')", + ), + ] + ) + def test_get_sql(self, func, expected): + self.assertEqual(func.get_sql(), expected) + + +class TestAddSubtractDt(unittest.TestCase): + @parameterized.expand( + [ + (AddYears(Field("created"), 1), "addYears(created,1)"), + (AddMonths(Field("created"), 2), "addMonths(created,2)"), + (AddWeeks(Field("created"), 3), "addWeeks(created,3)"), + (AddDays(Field("created"), 4), "addDays(created,4)"), + (AddHours(Field("created"), 5), "addHours(created,5)"), + (AddMinutes(Field("created"), 6), "addMinutes(created,6)"), + (AddSeconds(Field("created"), 7), "addSeconds(created,7)"), + (AddQuarters(Field("created"), 8), "addQuarters(created,8)"), + (SubtractYears(Field("created"), 9), "subtractYears(created,9)"), + (SubtractMonths(Field("created"), 10), "subtractMonths(created,10)"), + (SubtractWeeks(Field("created"), 11), "subtractWeeks(created,11)"), + (SubtractDays(Field("created"), 12), "subtractDays(created,12)"), + (SubtractHours(Field("created"), 13), "subtractHours(created,13)"), + (SubtractHours(Field("created"), 13), "subtractHours(created,13)"), + (SubtractMinutes(Field("created"), 14), "subtractMinutes(created,14)"), + (SubtractSeconds(Field("created"), 15), "subtractSeconds(created,15)"), + (SubtractQuarters(Field("created"), 16), "subtractQuarters(created,16)"), + ] + ) + def test_get_sql(self, func, expected): + self.assertEqual(func.get_sql(), expected) + + +class TestToYYYYMM(unittest.TestCase): + def test_get_sql(self): + self.assertEqual(ToYYYYMM(Field("created").get_sql()), "toYYYYMM(created)") diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/clickhouse/test_nullable_arg.py b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/clickhouse/test_nullable_arg.py new file mode 100644 index 0000000000000000000000000000000000000000..3c6c86207a4d0206b5c0ba80b77fac4cc257fa17 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/clickhouse/test_nullable_arg.py @@ -0,0 +1,24 @@ +import unittest + +from parameterized import parameterized + +from pypika import Field +from pypika.clickhouse.nullable_arg import IfNull +from pypika.clickhouse.type_conversion import ToFixedString + + +class TestSearchString(unittest.TestCase): + @parameterized.expand( + [ + ( + IfNull(Field("name"), Field("login")), + "ifNull(name,login)", + ), + ( + IfNull(Field("builder"), ToFixedString("pypika", 100)), + "ifNull(builder,toFixedString('pypika',100))", + ), + ] + ) + def test_get_sql(self, func, expected): + self.assertEqual(func.get_sql(), expected) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/clickhouse/test_search_string.py b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/clickhouse/test_search_string.py new file mode 100644 index 0000000000000000000000000000000000000000..9778eb32e47d4370c0bfe36dcd875903666d30b6 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/clickhouse/test_search_string.py @@ -0,0 +1,41 @@ +import unittest + +from parameterized import parameterized + +from pypika import Field +from pypika.clickhouse.search_string import ( + Match, + Like, + NotLike, + MultiSearchAny, + MultiMatchAny, +) + + +class TestSearchString(unittest.TestCase): + @parameterized.expand( + [ + (Match(Field("name"), "twheys"), "match(toString(\"name\"),'twheys')"), + (Like(Field("name"), "twheys"), "like(toString(\"name\"),'twheys')"), + (NotLike(Field("name"), "twheys"), "notLike(toString(\"name\"),'twheys')"), + ] + ) + def test_search_string(self, func, expected): + self.assertEqual(func, expected) + + +class TestMultiSearch(unittest.TestCase): + @parameterized.expand( + [ + ( + MultiSearchAny(Field("name"), ["sarah", "connor"]), + "multiSearchAny(toString(\"name\"),['sarah','connor'])", + ), + ( + MultiMatchAny(Field("name"), ["sarah", "connor"]), + "multiMatchAny(toString(\"name\"),['sarah','connor'])", + ), + ] + ) + def test_multi_search_string(self, func, expected): + self.assertEqual(func.get_sql(), expected) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/clickhouse/test_type_conversion.py b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/clickhouse/test_type_conversion.py new file mode 100644 index 0000000000000000000000000000000000000000..9692e17bee901e2629db9a5c77111e145358e8eb --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/clickhouse/test_type_conversion.py @@ -0,0 +1,176 @@ +import unittest + +from parameterized import parameterized + +from pypika import ClickHouseQuery, Field, Table +from pypika.clickhouse.type_conversion import ( + ToDate, + ToDateTime, + ToFixedString, + ToFloat32, + ToFloat64, + ToInt16, + ToInt32, + ToInt64, + ToInt8, + ToString, + ToUInt16, + ToUInt32, + ToUInt64, + ToUInt8, +) + + +class TestBasicTypeConverters(unittest.TestCase): + @parameterized.expand( + [ + ( + 'toString("field_name")', + ToString(Field("field_name")), + ), + ( + 'toInt8("field_name")', + ToInt8(Field("field_name")), + ), + ( + 'toInt16("field_name")', + ToInt16(Field("field_name")), + ), + ( + 'toInt32("field_name")', + ToInt32(Field("field_name")), + ), + ( + 'toInt64("field_name")', + ToInt64(Field("field_name")), + ), + ( + 'toUInt8("field_name")', + ToUInt8(Field("field_name")), + ), + ( + 'toUInt16("field_name")', + ToUInt16(Field("field_name")), + ), + ( + 'toUInt32("field_name")', + ToUInt32(Field("field_name")), + ), + ( + 'toUInt64("field_name")', + ToUInt64(Field("field_name")), + ), + ( + 'toFloat32("field_name")', + ToFloat32(Field("field_name")), + ), + ( + 'toFloat64("field_name")', + ToFloat64(Field("field_name")), + ), + ( + 'toFloat64("field_name")', + ToFloat64(Field("field_name")), + ), + ( + 'toDate("field_name")', + ToDate(Field("field_name")), + ), + ( + 'toDateTime("field_name")', + ToDateTime(Field("field_name")), + ), + ( + 'toFixedString("field_name",100)', + ToFixedString(Field("field_name"), 100), + ), + ] + ) + def test_basic_types_field(self, expected, func): + self.assertEqual(func, expected) + + @parameterized.expand( + [ + ( + "toString('100')", + ToString("100"), + ), + ( + "toInt8('100')", + ToInt8("100"), + ), + ( + "toInt16('100')", + ToInt16("100"), + ), + ( + "toInt32('100')", + ToInt32("100"), + ), + ( + "toInt64('100')", + ToInt64("100"), + ), + ( + "toUInt8('100')", + ToUInt8("100"), + ), + ( + "toUInt16('100')", + ToUInt16("100"), + ), + ( + "toUInt32('100')", + ToUInt32("100"), + ), + ( + "toUInt64('100')", + ToUInt64("100"), + ), + ( + "toFloat32('100')", + ToFloat32("100"), + ), + ( + "toFloat64('100')", + ToFloat64("100"), + ), + ( + "toFloat64('100')", + ToFloat64("100"), + ), + ( + "toDate('100')", + ToDate("100"), + ), + ( + "toDateTime('100')", + ToDateTime("100"), + ), + ( + "toFixedString('100',100)", + ToFixedString("100", 100), + ), + ] + ) + def test_basic_types_value(self, expected, func): + self.assertEqual(func, expected) + + +class TestToFixedString(unittest.TestCase): + def test_get_sql_with_table(self): + table = Table("example") + query = ( + ClickHouseQuery.from_(table) + .select( + table.name, + ) + .where( + table.name == ToFixedString("name", 50), + ) + ) + + self.assertEqual( + 'SELECT "name" FROM "example" WHERE "name"=toFixedString(\'name\',50)', + query.get_sql(), + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/dialects/__init__.py b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/dialects/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/dialects/test_clickhouse.py b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/dialects/test_clickhouse.py new file mode 100644 index 0000000000000000000000000000000000000000..f319c4627bd25d7004894181906a284b8b1c64cf --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/dialects/test_clickhouse.py @@ -0,0 +1,146 @@ +from unittest import TestCase + +from pypika import ( + ClickHouseQuery, + Database, + Table, +) + + +class ClickHouseQueryTests(TestCase): + def test_use_AS_keyword_for_alias(self): + t = Table('abc') + query = ClickHouseQuery.from_(t).select(t.foo.as_('f1'), t.bar.as_('f2')) + self.assertEqual(str(query), 'SELECT "foo" AS "f1","bar" AS "f2" FROM "abc"') + + def test_use_SAMPLE_keyword(self): + t = Table('abc') + query = ClickHouseQuery.from_(t).select(t.foo).sample(10) + self.assertEqual(str(query), 'SELECT "foo" FROM "abc" SAMPLE 10') + + def test_use_SAMPLE_with_offset_keyword(self): + t = Table('abc') + query = ClickHouseQuery.from_(t).select(t.foo).sample(10, 5) + self.assertEqual(str(query), 'SELECT "foo" FROM "abc" SAMPLE 10 OFFSET 5') + + def test_use_FINAL_keyword(self): + t = Table('abc') + query = ClickHouseQuery.from_(t).select(t.foo).final() + self.assertEqual(str(query), 'SELECT "foo" FROM "abc" FINAL') + + +class ClickHouseDeleteTests(TestCase): + table_abc = Table("abc") + + def test_omit_where(self): + q = ClickHouseQuery.from_("abc").delete() + + self.assertEqual('ALTER TABLE "abc" DELETE', str(q)) + + def test_omit_where__table_schema(self): + q = ClickHouseQuery.from_(Table("abc", "schema1")).delete() + + self.assertEqual('ALTER TABLE "schema1"."abc" DELETE', str(q)) + + def test_where_field_equals(self): + q1 = ClickHouseQuery.from_(self.table_abc).where(self.table_abc.foo == self.table_abc.bar).delete() + q2 = ClickHouseQuery.from_(self.table_abc).where(self.table_abc.foo.eq(self.table_abc.bar)).delete() + + self.assertEqual('ALTER TABLE "abc" DELETE WHERE "foo"="bar"', str(q1)) + self.assertEqual('ALTER TABLE "abc" DELETE WHERE "foo"="bar"', str(q2)) + + +class ClickHouseUpdateTests(TestCase): + table_abc = Table("abc") + + def test_update(self): + q = ClickHouseQuery.update(self.table_abc).where(self.table_abc.foo == 0).set("foo", "bar") + + self.assertEqual('ALTER TABLE "abc" UPDATE "foo"=\'bar\' WHERE "foo"=0', str(q)) + + +class ClickHouseDropQuery(TestCase): + table_abc = Table("abc") + database_xyz = Database("mydb") + cluster_name = "mycluster" + + def test_drop_database(self): + q1 = ClickHouseQuery.drop_database(self.database_xyz) + q2 = ClickHouseQuery.drop_database(self.database_xyz).on_cluster(self.cluster_name) + q3 = ClickHouseQuery.drop_database(self.database_xyz).if_exists().on_cluster(self.cluster_name) + + self.assertEqual('DROP DATABASE "mydb"', str(q1)) + self.assertEqual('DROP DATABASE "mydb" ON CLUSTER "mycluster"', str(q2)) + self.assertEqual('DROP DATABASE IF EXISTS "mydb" ON CLUSTER "mycluster"', str(q3)) + + def test_drop_table(self): + q1 = ClickHouseQuery.drop_table(self.table_abc) + q2 = ClickHouseQuery.drop_table(self.table_abc).on_cluster(self.cluster_name) + q3 = ClickHouseQuery.drop_table(self.table_abc).if_exists().on_cluster(self.cluster_name) + + self.assertEqual('DROP TABLE "abc"', str(q1)) + self.assertEqual('DROP TABLE "abc" ON CLUSTER "mycluster"', str(q2)) + self.assertEqual('DROP TABLE IF EXISTS "abc" ON CLUSTER "mycluster"', str(q3)) + + def test_drop_dictionary(self): + q1 = ClickHouseQuery.drop_dictionary("dict") + q2 = ClickHouseQuery.drop_dictionary("dict").on_cluster(self.cluster_name) + q3 = ClickHouseQuery.drop_dictionary("dict").if_exists().on_cluster(self.cluster_name) + + self.assertEqual('DROP DICTIONARY "dict"', str(q1)) + self.assertEqual('DROP DICTIONARY "dict"', str(q2)) # NO CLUSTER + self.assertEqual('DROP DICTIONARY IF EXISTS "dict"', str(q3)) # NO CLUSTER + + def test_drop_other(self): + q1 = ClickHouseQuery.drop_quota("myquota") + q2 = ClickHouseQuery.drop_user("myuser") + q3 = ClickHouseQuery.drop_view("myview") + + self.assertEqual('DROP QUOTA "myquota"', str(q1)) + self.assertEqual('DROP USER "myuser"', str(q2)) + self.assertEqual('DROP VIEW "myview"', str(q3)) + + +class DistinctOnTests(TestCase): + table_abc = Table("abc") + + def test_distinct_on(self): + q = ClickHouseQuery.from_(self.table_abc).distinct_on("lname", self.table_abc.fname).select("lname", "id") + + self.assertEqual('''SELECT DISTINCT ON("lname","fname") "lname","id" FROM "abc"''', str(q)) + + +class LimitByTests(TestCase): + table_abc = Table("abc") + + def test_limit_by(self): + q = ClickHouseQuery.from_(self.table_abc).limit_by(1, "a", self.table_abc.b).select("a", "b", "c") + + self.assertEqual('''SELECT "a","b","c" FROM "abc" LIMIT 1 BY ("a","b")''', str(q)) + + def test_limit_offset_by(self): + q = ClickHouseQuery.from_(self.table_abc).limit_offset_by(1, 2, "a", self.table_abc.b).select("a", "b", "c") + + self.assertEqual('''SELECT "a","b","c" FROM "abc" LIMIT 1 OFFSET 2 BY ("a","b")''', str(q)) + + def test_limit_offset0_by(self): + q = ClickHouseQuery.from_(self.table_abc).limit_offset_by(1, 0, "a", self.table_abc.b).select("a", "b", "c") + + self.assertEqual('''SELECT "a","b","c" FROM "abc" LIMIT 1 BY ("a","b")''', str(q)) + + def test_rename_table(self): + table_join = Table("join") + + q = ( + ClickHouseQuery.from_(self.table_abc) + .join(table_join) + .using("a") + .limit_by(1, self.table_abc.a, table_join.a) + .select(self.table_abc.b, table_join.b) + ) + q = q.replace_table(self.table_abc, Table("xyz")) + + self.assertEqual( + '''SELECT "xyz"."b","join"."b" FROM "xyz" JOIN "join" USING ("a") LIMIT 1 BY ("xyz"."a","join"."a")''', + str(q), + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/dialects/test_mssql.py b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/dialects/test_mssql.py new file mode 100644 index 0000000000000000000000000000000000000000..7cf53b228f413a8c7cd3e414fef5522a82f99b29 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/dialects/test_mssql.py @@ -0,0 +1,81 @@ +import unittest + +from pypika import Table +from pypika.analytics import Count +from pypika.dialects import MSSQLQuery +from pypika.utils import QueryException + + +class SelectTests(unittest.TestCase): + def test_normal_select(self): + q = MSSQLQuery.from_("abc").select("def") + + self.assertEqual('SELECT "def" FROM "abc"', str(q)) + + def test_distinct_select(self): + q = MSSQLQuery.from_("abc").select("def").distinct() + + self.assertEqual('SELECT DISTINCT "def" FROM "abc"', str(q)) + + def test_top_distinct_select(self): + q = MSSQLQuery.from_("abc").select("def").top(10).distinct() + + self.assertEqual('SELECT DISTINCT TOP (10) "def" FROM "abc"', str(q)) + + def test_top_select(self): + q = MSSQLQuery.from_("abc").select("def").top(10) + + self.assertEqual('SELECT TOP (10) "def" FROM "abc"', str(q)) + + def test_top_with_ties_select(self): + q = MSSQLQuery.from_("abc").select("def").top(10, with_ties=True) + + self.assertEqual('SELECT TOP (10) WITH TIES "def" FROM "abc"', str(q)) + + def test_top_percent_select(self): + q = MSSQLQuery.from_("abc").select("def").top(10, percent=True) + + self.assertEqual('SELECT TOP (10) PERCENT "def" FROM "abc"', str(q)) + + def test_top_percent_invalid_range(self): + for invalid_top in [-1, 101]: + with self.assertRaisesRegex( + QueryException, "TOP value must be between 0 and 100 when `percent` is specified" + ): + MSSQLQuery.from_("abc").select("def").top(invalid_top, percent=True) + + def test_top_select_non_int(self): + with self.assertRaisesRegex(QueryException, "TOP value must be an integer"): + MSSQLQuery.from_("abc").select("def").top("a") + + def test_limit(self): + q = MSSQLQuery.from_("abc").select("def").orderby("def").limit(10) + + self.assertEqual('SELECT "def" FROM "abc" ORDER BY "def" OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY', str(q)) + + def test_offset(self): + q = MSSQLQuery.from_("abc").select("def").orderby("def").offset(10) + + self.assertEqual('SELECT "def" FROM "abc" ORDER BY "def" OFFSET 10 ROWS', str(q)) + + def test_limit_with_offset(self): + q = MSSQLQuery.from_("abc").select("def").orderby("def").limit(10).offset(10) + + self.assertEqual('SELECT "def" FROM "abc" ORDER BY "def" OFFSET 10 ROWS FETCH NEXT 10 ROWS ONLY', str(q)) + + def test_groupby_alias_False_does_not_group_by_alias_with_standard_query(self): + t = Table('table1') + col = t.abc.as_('a') + q = MSSQLQuery.from_(t).select(col, Count('*')).groupby(col) + + self.assertEqual('SELECT "abc" "a",COUNT(\'*\') FROM "table1" GROUP BY "abc"', str(q)) + + def test_groupby_alias_False_does_not_group_by_alias_when_subqueries_are_present(self): + t = Table('table1') + subquery = MSSQLQuery.from_(t).select(t.abc) + col = subquery.abc.as_('a') + q = MSSQLQuery.from_(subquery).select(col, Count('*')).groupby(col) + + self.assertEqual( + 'SELECT "sq0"."abc" "a",COUNT(\'*\') FROM (SELECT "abc" FROM "table1") "sq0" GROUP BY "sq0"."abc"', str(q) + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/dialects/test_mysql.py b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/dialects/test_mysql.py new file mode 100644 index 0000000000000000000000000000000000000000..619d064adcdf8b5ff9ecd054fa4ab00eff1d69b3 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/dialects/test_mysql.py @@ -0,0 +1,91 @@ +import unittest + +from pypika import MySQLQuery, QueryException, Table, Column + + +class SelectTests(unittest.TestCase): + table_abc = Table("abc") + + def test_normal_select(self): + q = MySQLQuery.from_("abc").select("def") + + self.assertEqual("SELECT `def` FROM `abc`", str(q)) + + def test_distinct_select(self): + q = MySQLQuery.from_("abc").select("def").distinct() + + self.assertEqual("SELECT DISTINCT `def` FROM `abc`", str(q)) + + def test_modifier_select(self): + q = MySQLQuery.from_("abc").select("def").select("ghi").modifier("SQL_CALC_FOUND_ROWS") + + self.assertEqual("SELECT SQL_CALC_FOUND_ROWS `def`,`ghi` FROM `abc`", str(q)) + + def test_multiple_modifier_select(self): + q = MySQLQuery.from_("abc").select("def").modifier("HIGH_PRIORITY").modifier("SQL_CALC_FOUND_ROWS") + + self.assertEqual("SELECT HIGH_PRIORITY SQL_CALC_FOUND_ROWS `def` FROM `abc`", str(q)) + + +class UpdateTests(unittest.TestCase): + table_abc = Table("abc") + + def test_update(self): + q = MySQLQuery.into("abc").insert(1, [1, "a", True]) + + self.assertEqual("INSERT INTO `abc` VALUES (1,[1,'a',true])", str(q)) + + def test_on_duplicate_key_ignore_update(self): + q = MySQLQuery.into("abc").insert(1, [1, "a", True]).on_duplicate_key_ignore() + + self.assertEqual("INSERT INTO `abc` VALUES (1,[1,'a',true]) ON DUPLICATE KEY IGNORE", str(q)) + + def test_on_duplicate_key_update_update(self): + q = MySQLQuery.into("abc").insert(1, [1, "a", True]).on_duplicate_key_update(self.table_abc.a, 'b') + + self.assertEqual("INSERT INTO `abc` VALUES (1,[1,'a',true]) ON DUPLICATE KEY UPDATE `a`='b'", str(q)) + + def test_conflict_handlers_update(self): + with self.assertRaises(QueryException): + ( + MySQLQuery.into("abc") + .insert(1, [1, "a", True]) + .on_duplicate_key_ignore() + .on_duplicate_key_update(self.table_abc.a, 'b') + ) + + +class LoadCSVTests(unittest.TestCase): + table_abc = Table("abc") + + def test_load_from_file(self): + q1 = MySQLQuery.load("/path/to/file").into("abc") + + q2 = MySQLQuery.load("/path/to/file").into(self.table_abc) + + self.assertEqual( + "LOAD DATA LOCAL INFILE '/path/to/file' INTO TABLE `abc` FIELDS TERMINATED BY ','", + str(q1), + ) + self.assertEqual( + "LOAD DATA LOCAL INFILE '/path/to/file' INTO TABLE `abc` FIELDS TERMINATED BY ','", + str(q2), + ) + + +class TableTests(unittest.TestCase): + table_abc = Table("abc") + + def test_create_table(self): + q = MySQLQuery.create_table(self.table_abc).columns(Column("id", "INT")) + self.assertEqual( + 'CREATE TABLE `abc` (`id` INT)', + str(q), + ) + + def test_drop_table(self): + q = MySQLQuery.drop_table(self.table_abc) + self.assertEqual( + 'DROP TABLE `abc`', + str(q), + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/dialects/test_oracle.py b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/dialects/test_oracle.py new file mode 100644 index 0000000000000000000000000000000000000000..21b54f16fd5d3518b5c767d3605068637898a73f --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/dialects/test_oracle.py @@ -0,0 +1,51 @@ +import unittest + +from pypika import OracleQuery, Table +from pypika.analytics import Count + + +class SelectTests(unittest.TestCase): + def test_groupby_alias_False_does_not_group_by_alias_with_standard_query(self): + t = Table('table1') + col = t.abc.as_('a') + q = OracleQuery.from_(t).select(col, Count('*')).groupby(col) + + self.assertEqual('SELECT abc a,COUNT(\'*\') FROM table1 GROUP BY abc', str(q)) + + def test_groupby_alias_False_does_not_group_by_alias_when_subqueries_are_present(self): + t = Table('table1') + subquery = OracleQuery.from_(t).select(t.abc) + col = subquery.abc.as_('a') + q = OracleQuery.from_(subquery).select(col, Count('*')).groupby(col) + + self.assertEqual('SELECT sq0.abc a,COUNT(\'*\') FROM (SELECT abc FROM table1) sq0 GROUP BY sq0.abc', str(q)) + + def test_limit_query(self): + t = Table('table1') + limit = 5 + q = OracleQuery.from_(t).select(t.test).limit(limit) + + self.assertEqual(f'SELECT test FROM table1 FETCH NEXT {limit} ROWS ONLY', str(q)) + + def test_offset_query(self): + t = Table('table1') + offset = 5 + q = OracleQuery.from_(t).select(t.test).offset(offset) + + self.assertEqual(f'SELECT test FROM table1 OFFSET {offset} ROWS', str(q)) + + def test_limit_offset_query(self): + t = Table('table1') + limit = 5 + offset = 5 + q = OracleQuery.from_(t).select(t.test).limit(limit).offset(offset) + + self.assertEqual(f'SELECT test FROM table1 OFFSET {offset} ROWS FETCH NEXT {limit} ROWS ONLY', str(q)) + + def test_fetch_next_method_deprecated(self): + with self.assertWarns(DeprecationWarning): + t = Table('table1') + limit = 5 + q = OracleQuery.from_(t).select(t.test).fetch_next(limit) + + self.assertEqual(f'SELECT test FROM table1 FETCH NEXT {limit} ROWS ONLY', str(q)) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/dialects/test_postgresql.py b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/dialects/test_postgresql.py new file mode 100644 index 0000000000000000000000000000000000000000..437eed03e120485ed2a357a4c2d92426f1466e14 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/dialects/test_postgresql.py @@ -0,0 +1,262 @@ +import unittest +from collections import OrderedDict + +from pypika import ( + Array, + Field, + JSON, + QueryException, + Table, +) +from pypika.dialects import PostgreSQLQuery + + +class InsertTests(unittest.TestCase): + table_abc = Table("abc") + + def test_array_keyword(self): + q = PostgreSQLQuery.into(self.table_abc).insert(1, [1, "a", True]) + + self.assertEqual("INSERT INTO \"abc\" VALUES (1,ARRAY[1,'a',true])", str(q)) + + +class JSONObjectTests(unittest.TestCase): + def test_alias_set_correctly(self): + table = Table('jsonb_table') + q = PostgreSQLQuery.from_('abc').select(table.value.get_text_value('a').as_('name')) + + self.assertEqual('''SELECT "value"->>'a' "name" FROM "abc"''', str(q)) + + def test_json_value_from_dict(self): + q = PostgreSQLQuery.select(JSON({"a": "foo"})) + + self.assertEqual('SELECT \'{"a":"foo"}\'', str(q)) + + def test_json_value_from_array_num(self): + q = PostgreSQLQuery.select(JSON([1, 2, 3])) + + self.assertEqual("SELECT '[1,2,3]'", str(q)) + + def test_json_value_from_array_str(self): + q = PostgreSQLQuery.select(JSON(["a", "b", "c"])) + + self.assertEqual('SELECT \'["a","b","c"]\'', str(q)) + + def test_json_value_from_dict_recursive(self): + q = PostgreSQLQuery.select(JSON({"a": "z", "b": {"c": "foo"}, "d": 1})) + + # gotta split this one up to avoid the indeterminate order + sql = str(q) + start, end = 9, -2 + self.assertEqual("SELECT '{}'", sql[:start] + sql[end:]) + + members_set = set(sql[start:end].split(",")) + self.assertSetEqual({'"a":"z"', '"b":{"c":"foo"}', '"d":1'}, members_set) + + +class JSONOperatorsTests(unittest.TestCase): + # reference https://www.postgresql.org/docs/9.5/functions-json.html + table_abc = Table("abc") + + def test_get_json_value_by_key(self): + q = PostgreSQLQuery.from_(self.table_abc).select("*").where(self.table_abc.json.get_json_value("dates")) + + self.assertEqual('SELECT * FROM "abc" WHERE "json"->\'dates\'', str(q)) + + def test_get_json_value_by_index(self): + q = PostgreSQLQuery.from_(self.table_abc).select("*").where(self.table_abc.json.get_json_value(1)) + + self.assertEqual('SELECT * FROM "abc" WHERE "json"->1', str(q)) + + def test_get_text_value_by_key(self): + q = PostgreSQLQuery.from_(self.table_abc).select("*").where(self.table_abc.json.get_text_value("dates")) + + self.assertEqual('SELECT * FROM "abc" WHERE "json"->>\'dates\'', str(q)) + + def test_get_text_value_by_index(self): + q = PostgreSQLQuery.from_(self.table_abc).select("*").where(self.table_abc.json.get_text_value(1)) + + self.assertEqual('SELECT * FROM "abc" WHERE "json"->>1', str(q)) + + def test_get_path_json_value(self): + q = PostgreSQLQuery.from_(self.table_abc).select("*").where(self.table_abc.json.get_path_json_value("{a,b}")) + + self.assertEqual('SELECT * FROM "abc" WHERE "json"#>\'{a,b}\'', str(q)) + + def test_get_path_text_value(self): + q = PostgreSQLQuery.from_(self.table_abc).select("*").where(self.table_abc.json.get_path_text_value("{a,b}")) + + self.assertEqual('SELECT * FROM "abc" WHERE "json"#>>\'{a,b}\'', str(q)) + + +class JSONBOperatorsTests(unittest.TestCase): + # reference https://www.postgresql.org/docs/9.5/functions-json.html + table_abc = Table("abc") + + def test_json_contains_for_json(self): + q = PostgreSQLQuery.select(JSON({"a": 1, "b": 2}).contains({"a": 1})) + + # gotta split this one up to avoid the indeterminate order + sql = str(q) + start, end = 9, -13 + self.assertEqual("SELECT '{}'@>'{\"a\":1}'", sql[:start] + sql[end:]) + + members_set = set(sql[start:end].split(",")) + self.assertSetEqual({'"a":1', '"b":2'}, members_set) + + def test_json_contains_for_field(self): + q = ( + PostgreSQLQuery.from_(self.table_abc) + .select("*") + .where(self.table_abc.json.contains({"dates": "2018-07-10 - 2018-07-17"})) + ) + + self.assertEqual( + "SELECT * " 'FROM "abc" ' 'WHERE "json"@>\'{"dates":"2018-07-10 - 2018-07-17"}\'', + str(q), + ) + + def test_json_contained_by_using_str_arg(self): + q = ( + PostgreSQLQuery.from_(self.table_abc) + .select("*") + .where( + self.table_abc.json.contained_by( + OrderedDict( + [ + ("dates", "2018-07-10 - 2018-07-17"), + ("imported", "8"), + ] + ) + ) + ) + ) + self.assertEqual( + 'SELECT * FROM "abc" ' 'WHERE "json"<@\'{"dates":"2018-07-10 - 2018-07-17","imported":"8"}\'', + str(q), + ) + + def test_json_contained_by_using_list_arg(self): + q = ( + PostgreSQLQuery.from_(self.table_abc) + .select("*") + .where(self.table_abc.json.contained_by(["One", "Two", "Three"])) + ) + + self.assertEqual('SELECT * FROM "abc" WHERE "json"<@\'["One","Two","Three"]\'', str(q)) + + def test_json_contained_by_with_complex_criterion(self): + q = ( + PostgreSQLQuery.from_(self.table_abc) + .select("*") + .where(self.table_abc.json.contained_by(["One", "Two", "Three"]) & (self.table_abc.id == 26)) + ) + + self.assertEqual( + 'SELECT * FROM "abc" WHERE "json"<@\'["One","Two","Three"]\' AND "id"=26', + str(q), + ) + + def test_json_has_key(self): + q = PostgreSQLQuery.from_(self.table_abc).select("*").where(self.table_abc.json.has_key("dates")) + + self.assertEqual('SELECT * FROM "abc" WHERE "json"?\'dates\'', str(q)) + + def test_json_has_keys(self): + q = PostgreSQLQuery.from_(self.table_abc).select("*").where(self.table_abc.json.has_keys(["dates", "imported"])) + + self.assertEqual("SELECT * FROM \"abc\" WHERE \"json\"?&ARRAY['dates','imported']", str(q)) + + def test_json_has_any_keys(self): + q = ( + PostgreSQLQuery.from_(self.table_abc) + .select("*") + .where(self.table_abc.json.has_any_keys(["dates", "imported"])) + ) + + self.assertEqual("SELECT * FROM \"abc\" WHERE \"json\"?|ARRAY['dates','imported']", str(q)) + + def test_subnet_contains_inet(self): + q = ( + PostgreSQLQuery.from_(self.table_abc) + .select(self.table_abc.a.lshift(2)) + .where(self.table_abc.cidr >> "1.1.1.1") + ) + + self.assertEqual("SELECT \"a\"<<2 FROM \"abc\" WHERE \"cidr\">>'1.1.1.1'", str(q)) + + +class DistinctOnTests(unittest.TestCase): + table_abc = Table("abc") + + def test_distinct_on(self): + q = PostgreSQLQuery.from_(self.table_abc).distinct_on("lname", self.table_abc.fname).select("lname", "id") + + self.assertEqual('''SELECT DISTINCT ON("lname","fname") "lname","id" FROM "abc"''', str(q)) + + +class ArrayTests(unittest.TestCase): + def test_array_syntax(self): + tb = Table("tb") + q = PostgreSQLQuery.from_(tb).select(Array(1, "a", ["b", 2, 3])) + + self.assertEqual(str(q), "SELECT ARRAY[1,'a',ARRAY['b',2,3]] FROM \"tb\"") + + def test_render_alias_in_array_sql(self): + tb = Table("tb") + + q = PostgreSQLQuery.from_(tb).select(Array(tb.col).as_("different_name")) + self.assertEqual(str(q), 'SELECT ARRAY["col"] "different_name" FROM "tb"') + + +class ReturningClauseTests(unittest.TestCase): + @classmethod + def setUpClass(cls) -> None: + super().setUpClass() + cls.table_abc = Table('abc') + + def test_returning_from_missing_table_raises_queryexception(self): + field_from_diff_table = Field('xyz', table=Table('other')) + + with self.assertRaisesRegex(QueryException, "You can't return from other tables"): + ( + PostgreSQLQuery.from_(self.table_abc) + .where(self.table_abc.foo == self.table_abc.bar) + .delete() + .returning(field_from_diff_table) + ) + + def test_queryexception_if_returning_used_on_invalid_query(self): + with self.assertRaisesRegex(QueryException, "Returning can't be used in this query"): + PostgreSQLQuery.from_(self.table_abc).select('abc').returning('abc') + + def test_no_queryexception_if_returning_used_on_valid_query_type(self): + # No exceptions for insert, update and delete queries + with self.subTest('DELETE'): + PostgreSQLQuery.from_(self.table_abc).where(self.table_abc.foo == self.table_abc.bar).delete().returning( + "id" + ) + with self.subTest('UPDATE'): + PostgreSQLQuery.update(self.table_abc).where(self.table_abc.foo == 0).set("foo", "bar").returning("id") + with self.subTest('INSERT'): + PostgreSQLQuery.into(self.table_abc).insert('abc').returning('abc') + + def test_return_field_from_join_table(self): + new_table = Table('xyz') + q = ( + PostgreSQLQuery.update(self.table_abc) + .join(new_table) + .on(new_table.id == self.table_abc.xyz) + .where(self.table_abc.foo == 0) + .set("foo", "bar") + .returning(new_table.a) + ) + + self.assertEqual( + 'UPDATE "abc" ' + 'JOIN "xyz" ON "xyz"."id"="abc"."xyz" ' + 'SET "foo"=\'bar\' ' + 'WHERE "abc"."foo"=0 ' + 'RETURNING "xyz"."a"', + str(q), + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/dialects/test_snowflake.py b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/dialects/test_snowflake.py new file mode 100644 index 0000000000000000000000000000000000000000..5ac08b2d8b8b5496ed6f3510acf4be1ec7893405 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/dialects/test_snowflake.py @@ -0,0 +1,58 @@ +import unittest + +from pypika import ( + Tables, + functions as fn, + Column, +) +from pypika.dialects import SnowflakeQuery + + +class QuoteTests(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_use_double_quotes_on_alias_but_not_on_terms(self): + q = SnowflakeQuery.from_(self.table_abc).select(self.table_abc.a.as_("bar")) + + self.assertEqual('SELECT a "bar" FROM abc', q.get_sql(with_namespace=True)) + + def test_use_double_quotes_on_alias_but_not_on_terms_with_joins(self): + foo = self.table_abc.as_("foo") + bar = self.table_efg.as_("bar") + + q = SnowflakeQuery.from_(foo).join(bar).on(foo.fk == bar.id).select(foo.a, bar.b) + + self.assertEqual( + "SELECT foo.a,bar.b " 'FROM abc "foo" ' 'JOIN efg "bar" ' "ON foo.fk=bar.id", + q.get_sql(with_namespace=True), + ) + + def test_use_double_quotes_on_alias_but_not_on_terms(self): + idx = self.table_abc.index.as_("idx") + val = fn.Sum(self.table_abc.value).as_("val") + q = SnowflakeQuery.from_(self.table_abc).select(idx, val).groupby(idx).orderby(idx) + + self.assertEqual( + 'SELECT index "idx",SUM(value) "val" ' "FROM abc " 'GROUP BY "idx" ' 'ORDER BY "idx"', + q.get_sql(with_namespace=True), + ) + + def test_dont_use_double_quotes_on_joining_queries(self): + foo = self.table_abc + bar = self.table_efg + q1 = SnowflakeQuery.from_(foo).select(foo.b) + q2 = SnowflakeQuery.from_(bar).select(bar.b) + q = SnowflakeQuery.from_(q1).join(q2).on(q1.b == q2.b).select("*") + + self.assertEqual( + "SELECT * " 'FROM (SELECT b FROM abc) sq0 ' 'JOIN (SELECT b FROM efg) sq1 ' "ON sq0.b=sq1.b", + q.get_sql(), + ) + + def test_dont_use_double_quotes_on_create_queries(self): + q = SnowflakeQuery.create_table(self.table_abc).columns(Column("id", "INT")) + self.assertEqual("CREATE TABLE abc (id INT)", q.get_sql()) + + def test_dont_use_double_quotes_on_drop_queries(self): + q = SnowflakeQuery.drop_table(self.table_abc) + self.assertEqual("DROP TABLE abc", q.get_sql()) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/dialects/test_sqllite.py b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/dialects/test_sqllite.py new file mode 100644 index 0000000000000000000000000000000000000000..104a7235b6ea2d46fd365989f68c5d081eb20076 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/dialects/test_sqllite.py @@ -0,0 +1,35 @@ +import unittest + +from pypika import Table +from pypika.dialects import SQLLiteQuery + + +class SelectTests(unittest.TestCase): + table_abc = Table("abc") + + def test_bool_true_as_one(self): + q = SQLLiteQuery.from_("abc").select(True) + + self.assertEqual('SELECT 1 FROM "abc"', str(q)) + + def test_bool_false_as_zero(self): + q = SQLLiteQuery.from_("abc").select(False) + + self.assertEqual('SELECT 0 FROM "abc"', str(q)) + + +class ReplaceTests(unittest.TestCase): + def test_normal_replace(self): + query = SQLLiteQuery.into("abc").replace("v1", "v2", "v3") + expected_output = "REPLACE INTO \"abc\" VALUES ('v1','v2','v3')" + self.assertEqual(expected_output, str(query)) + + def test_replace_subquery(self): + query = SQLLiteQuery.into("abc").replace(SQLLiteQuery.from_("def").select("f1", "f2")) + expected_output = 'REPLACE INTO "abc" VALUES ((SELECT "f1","f2" FROM "def"))' + self.assertEqual(expected_output, str(query)) + + def test_insert_or_replace(self): + query = SQLLiteQuery.into("abc").insert_or_replace("v1", "v2", "v3") + expected_output = "INSERT OR REPLACE INTO \"abc\" VALUES ('v1','v2','v3')" + self.assertEqual(expected_output, str(query)) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/dialects/test_vertica.py b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/dialects/test_vertica.py new file mode 100644 index 0000000000000000000000000000000000000000..61985bfc244fcd663e7d8a904b4645901f3abdfc --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/dialects/test_vertica.py @@ -0,0 +1,93 @@ +import unittest + +from pypika import Columns, Table, Tables, VerticaQuery + + +class VerticaQueryTests(unittest.TestCase): + table_abc = Table("abc") + + def test_select_query_with_hint(self): + q = VerticaQuery.from_("abc").select("*").hint("test_hint") + + self.assertEqual('SELECT /*+label(test_hint)*/ * FROM "abc"', str(q)) + + def test_insert_query_with_hint(self): + query = VerticaQuery.into(self.table_abc).insert(1).hint("test_hint") + + self.assertEqual('INSERT /*+label(test_hint)*/ INTO "abc" VALUES (1)', str(query)) + + def test_update_query_with_hint(self): + q = VerticaQuery.update(self.table_abc).set("foo", "bar").hint("test_hint") + + self.assertEqual('UPDATE /*+label(test_hint)*/ "abc" SET "foo"=\'bar\'', str(q)) + + def test_delete_query_with_hint(self): + q = VerticaQuery.from_("abc").delete().hint("test_hint") + + self.assertEqual('DELETE /*+label(test_hint)*/ FROM "abc"', str(q)) + + +class CopyCSVTests(unittest.TestCase): + table_abc = Table("abc") + + def test_copy_from_file(self): + with self.subTest("with table as string"): + q = VerticaQuery.from_file("/path/to/file").copy_("abc") + + self.assertEqual( + "COPY \"abc\" FROM LOCAL '/path/to/file' PARSER fcsvparser(header=false)", + str(q), + ) + + with self.subTest("with table"): + q = VerticaQuery.from_file("/path/to/file").copy_(self.table_abc) + + self.assertEqual( + "COPY \"abc\" FROM LOCAL '/path/to/file' PARSER fcsvparser(header=false)", + str(q), + ) + + +class CreateTemporaryTableTests(unittest.TestCase): + new_table, existing_table = Tables("abc", "efg") + foo, bar = Columns(("a", "INT"), ("b", "VARCHAR(100)")) + select = VerticaQuery.from_(existing_table).select(existing_table.foo, existing_table.bar) + + def test_create_local_temporary_table(self): + with self.subTest("with columns"): + q = VerticaQuery.create_table(self.new_table).temporary().local().columns(self.foo, self.bar) + + self.assertEqual('CREATE LOCAL TEMPORARY TABLE "abc" ("a" INT,"b" VARCHAR(100))', str(q)) + + with self.subTest("with select"): + q = VerticaQuery.create_table(self.new_table).temporary().local().as_select(self.select) + + self.assertEqual( + 'CREATE LOCAL TEMPORARY TABLE "abc" AS (SELECT "foo","bar" FROM "efg")', + str(q), + ) + + def test_create_local_table_without_temporary_raises_error(self): + with self.assertRaises(AttributeError): + VerticaQuery.create_table(self.new_table).local() + + def test_create_temporary_table_preserve_rows(self): + with self.subTest("with columns"): + q = VerticaQuery.create_table(self.new_table).temporary().preserve_rows().columns(self.foo, self.bar) + + self.assertEqual( + 'CREATE TEMPORARY TABLE "abc" ("a" INT,"b" VARCHAR(100)) ON COMMIT PRESERVE ROWS', + str(q), + ) + + with self.subTest("with select"): + q = VerticaQuery.create_table(self.new_table).temporary().preserve_rows().as_select(self.select) + + self.assertEqual( + 'CREATE TEMPORARY TABLE "abc" ON COMMIT PRESERVE ROWS AS (SELECT "foo","bar" FROM "efg")', + str(q), + ) + + def test_create_table_preserve_rows_without_temporary_raises_error(self): + with self.assertRaises(AttributeError): + VerticaQuery.create_table(self.new_table).preserve_rows() diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/test_aggregate.py b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/test_aggregate.py new file mode 100644 index 0000000000000000000000000000000000000000..1c627d8e9c2d65410c67cf2c39974949b0720a0e --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/test_aggregate.py @@ -0,0 +1,122 @@ +import unittest + +from pypika import ( + Case, + Field, + Table, + functions as fn, +) +from pypika.terms import ( + Negative, + ValueWrapper, +) + + +class IsAggregateTests(unittest.TestCase): + def test__field_is_not_aggregate(self): + v = Field("foo") + self.assertFalse(v.is_aggregate) + + def test__constant_is_aggregate_none(self): + v = ValueWrapper(100) + self.assertIsNone(v.is_aggregate) + + def test__constant_arithmetic_is_aggregate_none(self): + v = ValueWrapper(100) + ValueWrapper(100) + self.assertIsNone(v.is_aggregate) + + def test__field_arithmetic_is_not_aggregate(self): + v = Field("foo") + Field("bar") + self.assertFalse(v.is_aggregate) + + def test__field_arithmetic_constant_is_not_aggregate(self): + v = Field("foo") + 1 + self.assertFalse(v.is_aggregate) + + def test__agg_func_is_aggregate(self): + v = fn.Sum(Field("foo")) + self.assertTrue(v.is_aggregate) + + def test__negative_agg_func_is_aggregate(self): + v = Negative(fn.Sum(Field("foo"))) + self.assertTrue(v.is_aggregate) + + def test__agg_func_arithmetic_is_aggregate(self): + v = fn.Sum(Field("foo")) / fn.Sum(Field("foo")) + self.assertTrue(v.is_aggregate) + + def test__mixed_func_arithmetic_is_not_aggregate(self): + v = Field("foo") / fn.Sum(Field("foo")) + self.assertFalse(v.is_aggregate) + + def test__func_arithmetic_constant_is_not_aggregate(self): + v = 1 / fn.Sum(Field("foo")) + self.assertTrue(v.is_aggregate) + + def test__agg_case_criterion_is_aggregate(self): + v = Case().when(fn.Sum(Field("foo")) > 666, 'More than 666').else_('Less than 666') + + self.assertTrue(v.is_aggregate) + + def test__agg_case_is_aggregate(self): + v = ( + Case() + .when(Field("foo") == 1, fn.Sum(Field("bar"))) + .when(Field("foo") == 2, fn.Sum(Field("fiz"))) + .else_(fn.Sum(Field("fiz"))) + ) + + self.assertTrue(v.is_aggregate) + + def test__mixed_case_is_not_aggregate(self): + v = Case().when(Field("foo") == 1, fn.Sum(Field("bar"))).when(Field("foo") == 2, Field("fiz")) + + self.assertFalse(v.is_aggregate) + + def test__case_mixed_else_is_not_aggregate(self): + v = ( + Case() + .when(Field("foo") == 1, fn.Sum(Field("bar"))) + .when(Field("foo") == 2, fn.Sum(Field("fiz"))) + .else_(Field("fiz")) + ) + + self.assertFalse(v.is_aggregate) + + def test__case_mixed_constant_is_not_aggregate(self): + v = Case().when(Field("foo") == 1, fn.Sum(Field("bar"))).when(Field("foo") == 2, fn.Sum(Field("fiz"))).else_(1) + + self.assertTrue(v.is_aggregate) + + def test__case_with_field_is_not_aggregate(self): + v = Case().when(Field("foo") == 1, 1).when(Field("foo") == 2, 2).else_(3) + + self.assertFalse(v.is_aggregate) + + def test__case_with_single_aggregate_field_in_one_criterion_is_aggregate(self): + v = Case().when(Field("foo") == 1, 1).when(fn.Sum(Field("foo")) == 2, 2).else_(3) + + self.assertTrue(v.is_aggregate) + + def test__non_aggregate_function_with_aggregated_arg(self): + t = Table("abc") + expr = fn.Sqrt(fn.Sum(t.a)) + + self.assertTrue(expr.is_aggregate) + + def test_complicated(self): + t = Table("abc") + is_placebo = t.campaign_extra_info == "placebo" + + pixel_mobile_search = Case().when(is_placebo, t.action_fb_pixel_search + t.action_fb_mobile_search) + unique_impressions = Case().when(is_placebo, t.unique_impressions) + + v = fn.Sum(pixel_mobile_search) / fn.Sum(unique_impressions) - 1.96 * fn.Sqrt( + 1 + / fn.Sum(unique_impressions) + * fn.Sum(pixel_mobile_search) + / fn.Sum(unique_impressions) + * (1 - fn.Sum(pixel_mobile_search) / fn.Sum(unique_impressions)) + ) + + self.assertTrue(v.is_aggregate) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/test_analytic_queries.py b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/test_analytic_queries.py new file mode 100644 index 0000000000000000000000000000000000000000..6a35ab854b30e3b0f91e633b3349706a22e0a2fd --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/test_analytic_queries.py @@ -0,0 +1,610 @@ +import unittest + +from pypika import Criterion, JoinType, Order, Query, Tables, analytics as an +from pypika.analytics import Lag, Lead + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + + +class RankTests(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_rank(self): + expr = an.Rank().over(self.table_abc.foo).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " "RANK() " 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_dense_rank(self): + expr = an.DenseRank().over(self.table_abc.foo).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " "DENSE_RANK() " 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_row_number(self): + expr = an.RowNumber().over(self.table_abc.foo).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " "ROW_NUMBER() " 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_rank_with_alias(self): + expr = an.Rank().over(self.table_abc.foo).orderby(self.table_abc.date).as_("rank") + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " "RANK() " 'OVER(PARTITION BY "foo" ORDER BY "date") "rank" ' 'FROM "abc"', + str(q), + ) + + def test_multiple_partitions(self): + expr = an.Rank().orderby(self.table_abc.date).over(self.table_abc.foo, self.table_abc.bar) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " "RANK() " 'OVER(PARTITION BY "foo","bar" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_ntile_no_partition_or_order_invalid_sql(self): + expr = an.NTile(5) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual("SELECT " "NTILE(5) " 'FROM "abc"', str(q)) + + def test_ntile_with_partition(self): + expr = an.NTile(5).over(self.table_abc.foo) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual("SELECT " "NTILE(5) " 'OVER(PARTITION BY "foo") ' 'FROM "abc"', str(q)) + + def test_ntile_with_order(self): + expr = an.NTile(5).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual("SELECT " "NTILE(5) " 'OVER(ORDER BY "date") ' 'FROM "abc"', str(q)) + + def test_ntile_with_partition_and_order(self): + expr = an.NTile(5).over(self.table_abc.foo).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " "NTILE(5) " 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_first_value(self): + expr = an.FirstValue(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'FIRST_VALUE("fizz") ' 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_first_value_ignore_nulls(self): + expr = an.FirstValue(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).ignore_nulls() + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'FIRST_VALUE("fizz" IGNORE NULLS) ' 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_first_value_ignore_nulls_first(self): + expr = an.FirstValue(self.table_abc.fizz).ignore_nulls().over(self.table_abc.foo).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'FIRST_VALUE("fizz" IGNORE NULLS) ' 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_first_value_multi_argument(self): + expr = ( + an.FirstValue(self.table_abc.fizz, self.table_abc.buzz) + .over(self.table_abc.foo) + .orderby(self.table_abc.date) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'FIRST_VALUE("fizz","buzz") ' 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_last_value(self): + expr = an.LastValue(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'LAST_VALUE("fizz") ' 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_filter(self): + expr = ( + an.LastValue(self.table_abc.fizz) + .filter(Criterion.all([self.table_abc.bar == True])) + .over(self.table_abc.foo) + .orderby(self.table_abc.date) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'LAST_VALUE("fizz") ' + 'FILTER(WHERE "bar"=true) ' + 'OVER(PARTITION BY "foo" ORDER BY "date") ' + 'FROM "abc"', + str(q), + ) + + def test_filter_quote_table_in_filter(self): + expr = ( + an.LastValue(self.table_efg.fizz) + .filter(self.table_efg.filed.eq('yes')) + .over(self.table_efg.foo) + .orderby(self.table_efg.date) + ) + + q = ( + Query.from_(self.table_abc) + .inner_join(self.table_efg) + .on(self.table_abc.id.eq(self.table_efg.id)) + .select(expr) + ) + + self.assertEqual( + 'SELECT ' + 'LAST_VALUE("efg"."fizz") ' + 'FILTER(WHERE "efg"."filed"=\'yes\') ' + 'OVER(PARTITION BY "efg"."foo" ORDER BY "efg"."date") ' + 'FROM "abc" ' + 'JOIN "efg" ON "abc"."id"="efg"."id"', + str(q), + ) + + def test_orderby_asc(self): + expr = an.LastValue(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date, order=Order.asc) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'LAST_VALUE("fizz") ' 'OVER(PARTITION BY "foo" ORDER BY "date" ASC) ' 'FROM "abc"', + str(q), + ) + + def test_orderby_desc(self): + expr = an.LastValue(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date, order=Order.desc) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'LAST_VALUE("fizz") ' 'OVER(PARTITION BY "foo" ORDER BY "date" DESC) ' 'FROM "abc"', + str(q), + ) + + def test_last_value_multi_argument(self): + expr = ( + an.LastValue(self.table_abc.fizz, self.table_abc.buzz).over(self.table_abc.foo).orderby(self.table_abc.date) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'LAST_VALUE("fizz","buzz") ' 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_last_value_ignore_nulls(self): + expr = an.LastValue(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).ignore_nulls() + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'LAST_VALUE("fizz" IGNORE NULLS) ' 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_median(self): + expr = an.Median(self.table_abc.fizz).over(self.table_abc.foo, self.table_abc.bar).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'MEDIAN("fizz") ' 'OVER(PARTITION BY "foo","bar" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_avg(self): + expr = an.Avg(self.table_abc.fizz).over(self.table_abc.foo, self.table_abc.bar).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'AVG("fizz") ' 'OVER(PARTITION BY "foo","bar" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_stddev(self): + expr = an.StdDev(self.table_abc.fizz).over(self.table_abc.foo, self.table_abc.bar).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'STDDEV("fizz") ' 'OVER(PARTITION BY "foo","bar" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_stddev_pop(self): + expr = ( + an.StdDevPop(self.table_abc.fizz).over(self.table_abc.foo, self.table_abc.bar).orderby(self.table_abc.date) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'STDDEV_POP("fizz") ' 'OVER(PARTITION BY "foo","bar" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_stddev_samp(self): + expr = ( + an.StdDevSamp(self.table_abc.fizz).over(self.table_abc.foo, self.table_abc.bar).orderby(self.table_abc.date) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'STDDEV_SAMP("fizz") ' 'OVER(PARTITION BY "foo","bar" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_variance(self): + expr = ( + an.Variance(self.table_abc.fizz).over(self.table_abc.foo, self.table_abc.bar).orderby(self.table_abc.date) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'VARIANCE("fizz") ' 'OVER(PARTITION BY "foo","bar" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_var_pop(self): + expr = an.VarPop(self.table_abc.fizz).over(self.table_abc.foo, self.table_abc.bar).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'VAR_POP("fizz") ' 'OVER(PARTITION BY "foo","bar" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_var_samp(self): + expr = an.VarSamp(self.table_abc.fizz).over(self.table_abc.foo, self.table_abc.bar).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'VAR_SAMP("fizz") ' 'OVER(PARTITION BY "foo","bar" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_table_prefixes_used_in_analytic_functions(self): + expr = an.Rank().over(self.table_abc.foo).orderby(self.table_efg.date) + + query = ( + Query.from_(self.table_abc) + .join(self.table_efg, how=JoinType.left) + .on(self.table_abc.foo == self.table_efg.bar) + .select("*", expr) + ) + + self.assertEqual( + 'SELECT *,RANK() OVER(PARTITION BY "abc"."foo" ORDER BY "efg"."date") ' + 'FROM "abc" LEFT JOIN "efg" ON "abc"."foo"="efg"."bar"', + str(query), + ) + + def test_sum_rows_unbounded_preceeding(self): + expr = an.Sum(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).rows(an.Preceding()) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'SUM("fizz") ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "ROWS UNBOUNDED PRECEDING" + ") " + 'FROM "abc"', + str(q), + ) + + def test_max_rows_x_preceeding(self): + expr = an.Max(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).rows(an.Preceding(5)) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'MAX("fizz") ' "OVER(" 'PARTITION BY "foo" ORDER BY "date" ' "ROWS 5 PRECEDING" ") " 'FROM "abc"', + str(q), + ) + + def test_min_rows_current_row(self): + expr = an.Min(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).rows(an.CURRENT_ROW) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'MIN("fizz") ' "OVER(" 'PARTITION BY "foo" ORDER BY "date" ' "ROWS CURRENT ROW" ") " 'FROM "abc"', + str(q), + ) + + def test_varpop_range_unbounded_preceeding(self): + expr = ( + an.VarPop(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).range(an.Preceding()) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'VAR_POP("fizz") ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "RANGE UNBOUNDED PRECEDING" + ") " + 'FROM "abc"', + str(q), + ) + + def test_max_range_x_preceeding(self): + expr = an.Max(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).range(an.Preceding(5)) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'MAX("fizz") ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "RANGE 5 PRECEDING" + ") " + 'FROM "abc"', + str(q), + ) + + def test_min_range_current_row(self): + expr = an.Min(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).range(an.CURRENT_ROW) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'MIN("fizz") ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "RANGE CURRENT ROW" + ") " + 'FROM "abc"', + str(q), + ) + + def test_variance_rows_between_unbounded_preceeding_unbounded_following(self): + expr = ( + an.Variance(self.table_abc.fizz) + .over(self.table_abc.foo) + .orderby(self.table_abc.date) + .rows(an.Preceding(), an.Following()) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'VARIANCE("fizz") ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING" + ") " + 'FROM "abc"', + str(q), + ) + + def test_first_value_range_between_x_preceeding_unbounded_following(self): + expr = ( + an.FirstValue(self.table_abc.fizz) + .over(self.table_abc.foo) + .orderby(self.table_abc.date) + .range(an.Preceding(3), an.Following()) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'FIRST_VALUE("fizz") ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "RANGE BETWEEN 3 PRECEDING AND UNBOUNDED FOLLOWING" + ") " + 'FROM "abc"', + str(q), + ) + + def test_varpop_rows_between_unbounded_preceeding_x_following(self): + expr = ( + an.VarPop(self.table_abc.fizz) + .over(self.table_abc.foo) + .orderby(self.table_abc.date) + .rows(an.Preceding(), an.Following(6)) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'VAR_POP("fizz") ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "ROWS BETWEEN UNBOUNDED PRECEDING AND 6 FOLLOWING" + ") " + 'FROM "abc"', + str(q), + ) + + def test_count_range_between_unbounded_preceeding_current_row(self): + expr = ( + an.Count(self.table_abc.fizz) + .over(self.table_abc.foo) + .orderby(self.table_abc.date) + .range(an.Preceding(), an.CURRENT_ROW) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'COUNT("fizz") ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW" + ") " + 'FROM "abc"', + str(q), + ) + + def test_last_value_rows_between_current_row_unbounded_following(self): + expr = ( + an.LastValue(self.table_abc.fizz) + .over(self.table_abc.foo) + .orderby(self.table_abc.date) + .rows(an.CURRENT_ROW, an.Following()) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'LAST_VALUE("fizz") ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING" + ") " + 'FROM "abc"', + str(q), + ) + + def test_last_value_rows_between_current_row_unbounded_following_ignore_nulls(self): + expr = ( + an.LastValue(self.table_abc.fizz) + .over(self.table_abc.foo) + .orderby(self.table_abc.date) + .ignore_nulls() + .rows(an.CURRENT_ROW, an.Following(8)) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'LAST_VALUE("fizz" IGNORE NULLS) ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "ROWS BETWEEN CURRENT ROW AND 8 FOLLOWING" + ") " + 'FROM "abc"', + str(q), + ) + + def test_empty_over(self): + query = Query.from_(self.table_abc).select(an.Sum(self.table_abc.fizz).over()) + + self.assertEqual("SELECT " 'SUM("fizz") OVER() ' 'FROM "abc"', str(query)) + + def test_rows_called_twice_raises_attribute_error(self): + with self.assertRaises(AttributeError): + an.Sum(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).rows(an.Preceding()).rows( + an.Preceding() + ) + + def test_range_called_twice_raises_attribute_error(self): + with self.assertRaises(AttributeError): + an.Sum(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).range( + an.Preceding() + ).range(an.Preceding()) + + def test_rows_then_range_raises_attribute_error(self): + with self.assertRaises(AttributeError): + an.Sum(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).rows( + an.Preceding() + ).range(an.Preceding()) + + def test_range_then_rows_raises_attribute_error(self): + with self.assertRaises(AttributeError): + an.Sum(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).range( + an.Preceding() + ).rows(an.Preceding()) + + def test_lag_generates_correct_sql(self): + with self.subTest('without partition by'): + q = Query.from_(self.table_abc).select( + Lag(self.table_abc.date, 1, '2000-01-01').orderby(self.table_abc.date) + ) + + self.assertEqual('SELECT LAG("date",1,\'2000-01-01\') OVER(ORDER BY "date") FROM "abc"', str(q)) + + with self.subTest('with partition by'): + q = Query.from_(self.table_abc).select( + Lag(self.table_abc.date, 1, '2000-01-01').over(self.table_abc.foo).orderby(self.table_abc.date) + ) + + self.assertEqual( + 'SELECT LAG("date",1,\'2000-01-01\') OVER(PARTITION BY "foo" ORDER BY "date") FROM "abc"', str(q) + ) + + def test_lead_generates_correct_sql(self): + with self.subTest('without partition by'): + q = Query.from_(self.table_abc).select( + Lead(self.table_abc.date, 1, '2000-01-01').orderby(self.table_abc.date) + ) + + self.assertEqual('SELECT LEAD("date",1,\'2000-01-01\') OVER(ORDER BY "date") FROM "abc"', str(q)) + + with self.subTest('with partition by'): + q = Query.from_(self.table_abc).select( + Lead(self.table_abc.date, 1, '2000-01-01').over(self.table_abc.foo).orderby(self.table_abc.date) + ) + + self.assertEqual( + 'SELECT LEAD("date",1,\'2000-01-01\') OVER(PARTITION BY "foo" ORDER BY "date") FROM "abc"', str(q) + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/test_create.py b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/test_create.py new file mode 100644 index 0000000000000000000000000000000000000000..325076544e3824b0d07f82f2378b88218b910dde --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/test_create.py @@ -0,0 +1,210 @@ +import unittest + +from pypika import Column, Columns, Query, Tables, Table +from pypika.terms import ValueWrapper, Index +from pypika.enums import ReferenceOption + + +class CreateTableTests(unittest.TestCase): + new_table, existing_table = Tables("abc", "efg") + foo, bar = Columns(("a", "INT"), ("b", "VARCHAR(100)")) + + def test_create_table_with_columns(self): + with self.subTest("with nullable"): + a = Column("a", "INT", True) + b = Column("b", "VARCHAR(100)", False) + q = Query.create_table(self.new_table).columns(a, b) + + self.assertEqual('CREATE TABLE "abc" ("a" INT NULL,"b" VARCHAR(100) NOT NULL)', str(q)) + + with self.subTest("with defaults"): + a = Column("a", "INT", default=ValueWrapper(42)) + b = Column("b", "VARCHAR(100)", default=ValueWrapper("foo")) + q = Query.create_table(self.new_table).columns(a, b) + + self.assertEqual('CREATE TABLE "abc" ("a" INT DEFAULT 42,"b" VARCHAR(100) DEFAULT \'foo\')', str(q)) + + with self.subTest("with unwrapped defaults"): + a = Column("a", "INT", default=42) + b = Column("b", "VARCHAR(100)", default="foo") + q = Query.create_table(self.new_table).columns(a, b) + + self.assertEqual('CREATE TABLE "abc" ("a" INT DEFAULT 42,"b" VARCHAR(100) DEFAULT \'foo\')', str(q)) + + with self.subTest("with period for"): + a = Column("id", "INT") + b = Column("valid_from", "DATETIME") + c = Column("valid_to", "DATETIME") + q = Query.create_table(self.new_table).columns(a, b, c).period_for('valid_period', b, c) + + self.assertEqual( + 'CREATE TABLE "abc" (' + '"id" INT,' + '"valid_from" DATETIME,' + '"valid_to" DATETIME,' + 'PERIOD FOR "valid_period" ("valid_from","valid_to"))', + str(q), + ) + + with self.subTest("without temporary keyword"): + q = Query.create_table(self.new_table).columns(self.foo, self.bar) + + self.assertEqual('CREATE TABLE "abc" ("a" INT,"b" VARCHAR(100))', str(q)) + + with self.subTest("with temporary keyword"): + q = Query.create_table(self.new_table).temporary().columns(self.foo, self.bar) + + self.assertEqual('CREATE TEMPORARY TABLE "abc" ("a" INT,"b" VARCHAR(100))', str(q)) + + with self.subTest("with primary key"): + q = Query.create_table(self.new_table).columns(self.foo, self.bar).primary_key(self.foo, self.bar) + + self.assertEqual('CREATE TABLE "abc" ("a" INT,"b" VARCHAR(100),PRIMARY KEY ("a","b"))', str(q)) + + with self.subTest("with simple foreign key"): + cref, dref = Columns(("c", "INT"), ("d", "VARCHAR(100)")) + q = ( + Query.create_table(self.new_table) + .columns(self.foo, self.bar) + .foreign_key([self.foo, self.bar], self.existing_table, [cref, dref]) + ) + + self.assertEqual( + 'CREATE TABLE "abc" (' + '"a" INT,' + '"b" VARCHAR(100),' + 'FOREIGN KEY ("a","b") REFERENCES "efg" ("c","d"))', + str(q), + ) + + with self.subTest("with foreign key reference options"): + cref, dref = Columns(("c", "INT"), ("d", "VARCHAR(100)")) + q = ( + Query.create_table(self.new_table) + .columns(self.foo, self.bar) + .foreign_key( + [self.foo, self.bar], + self.existing_table, + [cref, dref], + on_delete=ReferenceOption.cascade, + on_update=ReferenceOption.restrict, + ) + ) + + self.assertEqual( + 'CREATE TABLE "abc" (' + '"a" INT,' + '"b" VARCHAR(100),' + 'FOREIGN KEY ("a","b") REFERENCES "efg" ("c","d") ON DELETE CASCADE ON UPDATE RESTRICT)', + str(q), + ) + + with self.subTest("with unique keys"): + q = ( + Query.create_table(self.new_table) + .columns(self.foo, self.bar) + .unique(self.foo, self.bar) + .unique(self.foo) + ) + + self.assertEqual('CREATE TABLE "abc" ("a" INT,"b" VARCHAR(100),UNIQUE ("a","b"),UNIQUE ("a"))', str(q)) + + with self.subTest("with system versioning"): + q = Query.create_table(self.new_table).columns(self.foo, self.bar).with_system_versioning() + + self.assertEqual('CREATE TABLE "abc" ("a" INT,"b" VARCHAR(100)) WITH SYSTEM VERSIONING', str(q)) + + with self.subTest("with unlogged keyword"): + q = Query.create_table(self.new_table).unlogged().columns(self.foo, self.bar) + + self.assertEqual('CREATE UNLOGGED TABLE "abc" ("a" INT,"b" VARCHAR(100))', str(q)) + + with self.subTest("with if not exists keyword"): + q = Query.create_table(self.new_table).if_not_exists().columns(self.foo, self.bar) + + self.assertEqual('CREATE TABLE IF NOT EXISTS "abc" ("a" INT,"b" VARCHAR(100))', str(q)) + + def test_create_table_with_select(self): + select = Query.from_(self.existing_table).select(self.existing_table.foo, self.existing_table.bar) + + with self.subTest("without temporary keyword"): + q = Query.create_table(self.new_table).as_select(select) + + self.assertEqual('CREATE TABLE "abc" AS (SELECT "foo","bar" FROM "efg")', str(q)) + + with self.subTest("with temporary keyword"): + q = Query.create_table(self.new_table).temporary().as_select(select) + + self.assertEqual( + 'CREATE TEMPORARY TABLE "abc" AS (SELECT "foo","bar" FROM "efg")', + str(q), + ) + + def test_create_table_without_columns_or_select_empty(self): + q = Query.create_table(self.new_table) + + self.assertEqual("", str(q)) + + def test_create_table_with_select_and_columns_fails(self): + select = Query.from_(self.existing_table).select(self.existing_table.foo, self.existing_table.bar) + + with self.subTest("for columns before as_select"): + with self.assertRaises(AttributeError): + Query.create_table(self.new_table).columns(self.foo, self.bar).as_select(select) + + with self.subTest("for as_select before columns"): + with self.assertRaises(AttributeError): + Query.create_table(self.new_table).as_select(select).columns(self.foo, self.bar) + + with self.subTest("repeated foreign key"): + with self.assertRaises(AttributeError): + Query.create_table(self.new_table).foreign_key([self.foo], self.existing_table, [self.bar]).foreign_key( + [self.foo], self.existing_table, [self.bar] + ) + + def test_create_table_as_select_not_query_raises_error(self): + with self.assertRaises(TypeError): + Query.create_table(self.new_table).as_select("abc") + + +class CreateIndexTests(unittest.TestCase): + new_index = Index("abc") + new_table = Table("my_table") + columns = (new_table.a, new_table.b) + where = new_table.a > 1 + + def test_create_index_simple(self) -> None: + q = Query.create_index(self.new_index).on(self.new_table).columns(*self.columns) + self.assertEqual( + f'CREATE INDEX "{self.new_index.name}" ON "{self.new_table.get_table_name()}"({", ".join([c.name for c in self.columns])})', + q.get_sql(), + ) + + def test_create_index_where(self) -> None: + q = Query.create_index(self.new_index).on(self.new_table).columns(*self.columns).where(self.where) + self.assertEqual( + f'CREATE INDEX "{self.new_index.name}" ON "{self.new_table.get_table_name()}"({", ".join([c.name for c in self.columns])}) WHERE {self.where.get_sql()}', + q.get_sql(), + ) + + def test_create_index_unique(self) -> None: + q = Query.create_index(self.new_index).on(self.new_table).columns(*self.columns).unique() + self.assertEqual( + f'CREATE UNIQUE INDEX "{self.new_index.name}" ON "{self.new_table.get_table_name()}"({", ".join([c.name for c in self.columns])})', + q.get_sql(), + ) + + def test_create_index_if_not_exists(self) -> None: + q = Query.create_index(self.new_index).on(self.new_table).columns(*self.columns).if_not_exists() + self.assertEqual( + f'CREATE INDEX IF NOT EXISTS "{self.new_index.name}" ON "{self.new_table.get_table_name()}"({", ".join([c.name for c in self.columns])})', + q.get_sql(), + ) + + def test_create_index_without_columns_raises_error(self) -> None: + with self.assertRaises(AttributeError): + Query.create_index(self.new_index).on(self.new_table).get_sql() + + def test_create_index_without_table_raises_error(self) -> None: + with self.assertRaises(AttributeError): + Query.create_index(self.new_index).columns(*self.columns).get_sql() diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/test_criterions.py b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/test_criterions.py new file mode 100644 index 0000000000000000000000000000000000000000..fca2ceeeb18db88e34ebc38776f644fdcda67e93 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/test_criterions.py @@ -0,0 +1,873 @@ +import unittest +from datetime import ( + date, + datetime, +) + +from pypika import ( + Criterion, + EmptyCriterion, + Field, + Table, + functions as fn, +) +from pypika.queries import QueryBuilder +from pypika.terms import ExistsCriterion, Mod + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + + +class CriterionTests(unittest.TestCase): + t = Table("test", alias="crit") + + def test__criterion_with_alias(self): + c1 = (Field("foo") == Field("bar")).as_("criterion") + + self.assertEqual('"foo"="bar"', str(c1)) + self.assertEqual('"foo"="bar" "criterion"', c1.get_sql(with_alias=True, quote_char='"', alias_quote_char='"')) + + def test__criterion_eq_number(self): + c1 = Field("foo") == 1 + c2 = Field("foo", table=self.t).eq(0) + c3 = Field("foo", table=self.t) == -1 + + self.assertEqual('"foo"=1', str(c1)) + self.assertEqual('"crit"."foo"=0', str(c2)) + self.assertEqual('"crit"."foo"=-1', str(c3)) + + def test__criterion_eq_decimal(self): + c1 = Field("foo") == 1.0 + c2 = Field("foo", table=self.t).eq(0.5) + + self.assertEqual('"foo"=1.0', str(c1)) + self.assertEqual('"crit"."foo"=0.5', str(c2)) + + def test__criterion_eq_bool(self): + c1 = Field("foo") == True + c2 = Field("foo", table=self.t).eq(True) + c3 = Field("foo") == False + c4 = Field("foo", table=self.t).eq(False) + + self.assertEqual('"foo"=true', str(c1)) + self.assertEqual('"crit"."foo"=true', str(c2)) + self.assertEqual('"foo"=false', str(c3)) + self.assertEqual('"crit"."foo"=false', str(c4)) + + def test__criterion_eq_str(self): + c1 = Field("foo") == "abc" + c2 = Field("foo", table=self.t).eq("abc") + + self.assertEqual("\"foo\"='abc'", str(c1)) + self.assertEqual('"crit"."foo"=\'abc\'', str(c2)) + + def test__criterion_eq_date(self): + c1 = Field("foo") == date(2000, 1, 1) + c2 = Field("foo", table=self.t).eq(date(2000, 1, 1)) + + self.assertEqual("\"foo\"='2000-01-01'", str(c1)) + self.assertEqual('"crit"."foo"=\'2000-01-01\'', str(c2)) + + def test__criterion_eq_datetime(self): + c1 = Field("foo") == datetime(2000, 1, 1, 12, 30, 55) + c2 = Field("foo", table=self.t).eq(datetime(2000, 1, 1, 12, 30, 55)) + + self.assertEqual("\"foo\"='2000-01-01T12:30:55'", str(c1)) + self.assertEqual('"crit"."foo"=\'2000-01-01T12:30:55\'', str(c2)) + + def test__criterion_eq_right(self): + c1 = 1 == Field("foo") + c2 = -1 == Field("foo", table=self.t) + + self.assertEqual('"foo"=1', str(c1)) + self.assertEqual('"crit"."foo"=-1', str(c2)) + + def test__criterion_is_null(self): + c1 = Field("foo").isnull() + c2 = Field("foo", table=self.t).isnull() + + self.assertEqual('"foo" IS NULL', str(c1)) + self.assertEqual('"crit"."foo" IS NULL', str(c2)) + + def test__criterion_is_null_with_alias(self): + c1 = Field("foo").isnull().as_('alias') + c2 = Field("foo", table=self.t).isnull().as_('alias') + + self.assertEqual('"foo" IS NULL "alias"', str(c1)) + self.assertEqual('"crit"."foo" IS NULL "alias"', str(c2)) + + def test__criterion_ne_number(self): + c1 = Field("foo") != 1 + c2 = Field("foo", table=self.t).ne(0) + c3 = Field("foo") != -1 + + self.assertEqual('"foo"<>1', str(c1)) + self.assertEqual('"crit"."foo"<>0', str(c2)) + self.assertEqual('"foo"<>-1', str(c3)) + + def test__criterion_ne_str(self): + c1 = Field("foo") != "abc" + c2 = Field("foo", table=self.t).ne("abc") + + self.assertEqual("\"foo\"<>'abc'", str(c1)) + self.assertEqual('"crit"."foo"<>\'abc\'', str(c2)) + + def test__criterion_ne_date(self): + c1 = Field("foo") != date(2000, 1, 1) + c2 = Field("foo", table=self.t).ne(date(2000, 1, 1)) + + self.assertEqual("\"foo\"<>'2000-01-01'", str(c1)) + self.assertEqual('"crit"."foo"<>\'2000-01-01\'', str(c2)) + + def test__criterion_ne_datetime(self): + c1 = Field("foo") != datetime(2000, 1, 1, 12, 30, 55) + c2 = Field("foo", table=self.t).ne(datetime(2000, 1, 1, 12, 30, 55)) + + self.assertEqual("\"foo\"<>'2000-01-01T12:30:55'", str(c1)) + self.assertEqual('"crit"."foo"<>\'2000-01-01T12:30:55\'', str(c2)) + + def test__criterion_ne_right(self): + c1 = 1 != Field("foo") + c2 = -1 != Field("foo", table=self.t) + + self.assertEqual('"foo"<>1', str(c1)) + self.assertEqual('"crit"."foo"<>-1', str(c2)) + + def test__criterion_lt_number(self): + c1 = Field("foo") < 1 + c2 = Field("foo", table=self.t).lt(0) + c3 = Field("foo") < -1 + + self.assertEqual('"foo"<1', str(c1)) + self.assertEqual('"crit"."foo"<0', str(c2)) + self.assertEqual('"foo"<-1', str(c3)) + + def test__criterion_lt_date(self): + c1 = Field("foo") < date(2000, 1, 1) + c2 = Field("foo", table=self.t).lt(date(2000, 1, 1)) + + self.assertEqual("\"foo\"<'2000-01-01'", str(c1)) + self.assertEqual('"crit"."foo"<\'2000-01-01\'', str(c2)) + + def test__criterion_lt_datetime(self): + c1 = Field("foo") < datetime(2000, 1, 1, 12, 30, 55) + c2 = Field("foo", table=self.t).lt(datetime(2000, 1, 1, 12, 30, 55)) + + self.assertEqual("\"foo\"<'2000-01-01T12:30:55'", str(c1)) + self.assertEqual('"crit"."foo"<\'2000-01-01T12:30:55\'', str(c2)) + + def test__criterion_lt_right(self): + c1 = 1 > Field("foo") + c2 = -1 > Field("foo", table=self.t) + + self.assertEqual('"foo"<1', str(c1)) + self.assertEqual('"crit"."foo"<-1', str(c2)) + + def test__criterion_gt_number(self): + c1 = Field("foo") > 1 + c2 = Field("foo", table=self.t).gt(0) + c3 = Field("foo") > -1 + + self.assertEqual('"foo">1', str(c1)) + self.assertEqual('"crit"."foo">0', str(c2)) + self.assertEqual('"foo">-1', str(c3)) + + def test__criterion_gt_date(self): + c1 = Field("foo") > date(2000, 1, 1) + c2 = Field("foo", table=self.t).gt(date(2000, 1, 1)) + + self.assertEqual("\"foo\">'2000-01-01'", str(c1)) + self.assertEqual('"crit"."foo">\'2000-01-01\'', str(c2)) + + def test__criterion_gt_datetime(self): + c1 = Field("foo") > datetime(2000, 1, 1, 12, 30, 55) + c2 = Field("foo", table=self.t).gt(datetime(2000, 1, 1, 12, 30, 55)) + + self.assertEqual("\"foo\">'2000-01-01T12:30:55'", str(c1)) + self.assertEqual('"crit"."foo">\'2000-01-01T12:30:55\'', str(c2)) + + def test__criterion_gt_right(self): + c1 = 1 < Field("foo") + c2 = -1 < Field("foo", table=self.t) + + self.assertEqual('"foo">1', str(c1)) + self.assertEqual('"crit"."foo">-1', str(c2)) + + def test__criterion_lte_number(self): + c1 = Field("foo") <= 1 + c2 = Field("foo", table=self.t).lte(0) + c3 = Field("foo") <= -1 + + self.assertEqual('"foo"<=1', str(c1)) + self.assertEqual('"crit"."foo"<=0', str(c2)) + self.assertEqual('"foo"<=-1', str(c3)) + + def test__criterion_lte_date(self): + c1 = Field("foo") <= date(2000, 1, 1) + c2 = Field("foo", table=self.t).lte(date(2000, 1, 1)) + + self.assertEqual("\"foo\"<='2000-01-01'", str(c1)) + self.assertEqual('"crit"."foo"<=\'2000-01-01\'', str(c2)) + + def test__criterion_lte_datetime(self): + c1 = Field("foo") <= datetime(2000, 1, 1, 12, 30, 55) + c2 = Field("foo", table=self.t).lte(datetime(2000, 1, 1, 12, 30, 55)) + + self.assertEqual("\"foo\"<='2000-01-01T12:30:55'", str(c1)) + self.assertEqual('"crit"."foo"<=\'2000-01-01T12:30:55\'', str(c2)) + + def test__criterion_lte_right(self): + c1 = 1 >= Field("foo") + c2 = -1 >= Field("foo", table=self.t) + + self.assertEqual('"foo"<=1', str(c1)) + self.assertEqual('"crit"."foo"<=-1', str(c2)) + + def test__criterion_gte_number(self): + c1 = Field("foo") >= 1 + c2 = Field("foo", table=self.t).gte(0) + c3 = Field("foo") >= -1 + + self.assertEqual('"foo">=1', str(c1)) + self.assertEqual('"crit"."foo">=0', str(c2)) + self.assertEqual('"foo">=-1', str(c3)) + + def test__criterion_gte_date(self): + c1 = Field("foo") >= date(2000, 1, 1) + c2 = Field("foo", table=self.t).gte(date(2000, 1, 1)) + + self.assertEqual("\"foo\">='2000-01-01'", str(c1)) + self.assertEqual('"crit"."foo">=\'2000-01-01\'', str(c2)) + + def test__criterion_gte_datetime(self): + c1 = Field("foo") >= datetime(2000, 1, 1, 12, 30, 55) + c2 = Field("foo", table=self.t).gte(datetime(2000, 1, 1, 12, 30, 55)) + + self.assertEqual("\"foo\">='2000-01-01T12:30:55'", str(c1)) + self.assertEqual('"crit"."foo">=\'2000-01-01T12:30:55\'', str(c2)) + + def test__criterion_gte_right(self): + c1 = 1 <= Field("foo") + c2 = -1 <= Field("foo", table=self.t) + + self.assertEqual('"foo">=1', str(c1)) + self.assertEqual('"crit"."foo">=-1', str(c2)) + + def test__criterion_bitwise_and(self): + c1 = Field("foo").bitwiseand(2) + c2 = Field("foo", table=self.t).bitwiseand(10) == 2 + + self.assertEqual('("foo" & 2)', str(c1)) + self.assertEqual('("crit"."foo" & 10)=2', str(c2)) + + def test__criterion_bitwise_and_with_alias(self): + c1 = Field("foo").bitwiseand(2).as_('alias') + + self.assertEqual('("foo" & 2) "alias"', str(c1)) + + def test__bitwise_and_in_where_clause(self): + q = QueryBuilder().from_('items').select('abc').where(Field("foo").bitwiseand(1) == 1) + + self.assertEqual('SELECT "abc" FROM "items" WHERE ("foo" & 1)=1', str(q)) + + +class NotTests(unittest.TestCase): + table_abc, table_efg = Table("abc", alias="cx0"), Table("efg", alias="cx1") + + def test_negate(self): + c1 = Field("foo") >= 1 + c2 = c1.negate() + + self.assertEqual('"foo">=1', str(c1)) + self.assertEqual('NOT "foo">=1', str(c2)) + + def test_variable_access(self): + c1 = Field("foo").negate() + + self.assertEqual(c1.is_aggregate, False) + + def test_chained_function(self): + field1 = Field("foo").negate() + field2 = field1.eq("bar") + + self.assertEqual('NOT "foo"', str(field1)) + self.assertEqual("NOT \"foo\"='bar'", str(field2)) + self.assertIsNot(field1, field2) + + def test_not_null(self): + c1 = Field("foo").notnull() + c2 = Field("foo", table=self.table_abc).notnull() + + self.assertEqual('NOT "foo" IS NULL', str(c1)) + self.assertEqual('NOT "cx0"."foo" IS NULL', str(c2)) + + def test_is_not_null(self): + c1 = Field("foo").isnotnull() + c2 = Field("foo", table=self.table_abc).isnotnull() + + self.assertEqual('"foo" IS NOT NULL', str(c1)) + self.assertEqual('"cx0"."foo" IS NOT NULL', str(c2)) + + def test_not_null_with_alias(self): + c1 = Field("foo").notnull().as_("something") + c2 = Field("foo", table=self.table_abc).notnull().as_("something") + + self.assertEqual('NOT "foo" IS NULL "something"', str(c1)) + self.assertEqual('NOT "cx0"."foo" IS NULL "something"', str(c2)) + + def test_notnullcriterion_replace_table(self): + f = self.table_abc.foo.notnull().replace_table(self.table_abc, self.table_efg) + + self.assertEqual('NOT "cx1"."foo" IS NULL', str(f)) + + def test_not_with_or_criterion(self): + self.assertEqual('NOT ("foo" OR "bar")', str(~(Field("foo") | Field("bar")))) + + def test_not_with_and_criterion(self): + self.assertEqual('NOT ("foo" AND "bar")', str(~(Field("foo") & Field("bar")))) + + def test_not_with_complex_criterion(self): + self.assertEqual( + 'NOT ("foo" AND "bar" AND "fizz" AND "buzz")', + str(~(Field("foo") & Field("bar") & Field("fizz") & Field("buzz"))), + ) + + +class BetweenTests(unittest.TestCase): + t = Table("abc", alias="btw") + + def test__between_number(self): + c1 = Field("foo").between(0, 1) + c2 = Field("foo", table=self.t).between(0, 1) + c3 = Field("foo")[0:1] + + self.assertEqual('"foo" BETWEEN 0 AND 1', str(c1)) + self.assertEqual('"btw"."foo" BETWEEN 0 AND 1', str(c2)) + self.assertEqual('"foo" BETWEEN 0 AND 1', str(c3)) + + def test__between_with_alias(self): + c1 = Field("foo").between(0, 1).as_('alias') + c2 = Field("foo", table=self.t).between(0, 1).as_('alias') + c3 = Field("foo")[0:1].as_('alias') + + self.assertEqual('"foo" BETWEEN 0 AND 1 "alias"', str(c1)) + self.assertEqual('"btw"."foo" BETWEEN 0 AND 1 "alias"', str(c2)) + self.assertEqual('"foo" BETWEEN 0 AND 1 "alias"', str(c3)) + + def test__between_date(self): + c1 = Field("foo").between(date(2000, 1, 1), date(2000, 12, 31)) + c2 = Field("foo", table=self.t).between(date(2000, 1, 1), date(2000, 12, 31)) + c3 = Field("foo")[date(2000, 1, 1) : date(2000, 12, 31)] + + self.assertEqual("\"foo\" BETWEEN '2000-01-01' AND '2000-12-31'", str(c1)) + self.assertEqual("\"btw\".\"foo\" BETWEEN '2000-01-01' AND '2000-12-31'", str(c2)) + self.assertEqual("\"foo\" BETWEEN '2000-01-01' AND '2000-12-31'", str(c3)) + + def test__between_datetime(self): + c1 = Field("foo").between(datetime(2000, 1, 1, 0, 0, 0), datetime(2000, 12, 31, 23, 59, 59)) + c2 = Field("foo", table=self.t).between(datetime(2000, 1, 1, 0, 0, 0), datetime(2000, 12, 31, 23, 59, 59)) + c3 = Field("foo")[datetime(2000, 1, 1, 0, 0, 0) : datetime(2000, 12, 31, 23, 59, 59)] + + self.assertEqual("\"foo\" BETWEEN '2000-01-01T00:00:00' AND '2000-12-31T23:59:59'", str(c1)) + self.assertEqual( + "\"btw\".\"foo\" BETWEEN '2000-01-01T00:00:00' AND '2000-12-31T23:59:59'", + str(c2), + ) + self.assertEqual("\"foo\" BETWEEN '2000-01-01T00:00:00' AND '2000-12-31T23:59:59'", str(c3)) + + def test__function_between(self): + c1 = fn.Coalesce(Field("foo"), 0)[0:1] + c2 = fn.Coalesce(Field("foo", table=self.t), 0)[0:1] + + self.assertEqual('COALESCE("foo",0) BETWEEN 0 AND 1', str(c1)) + self.assertEqual('COALESCE("btw"."foo",0) BETWEEN 0 AND 1', str(c2)) + + def test_get_item_only_works_with_slice(self): + with self.assertRaises(TypeError): + Field("foo")[0] + + with self.assertRaises(TypeError): + Field("foo")[date(2000, 1, 1)] + + with self.assertRaises(TypeError): + Field("foo")[datetime(2000, 1, 1, 0, 0, 0)] + + +class IsInTests(unittest.TestCase): + t = Table("abc", alias="isin") + + def test__in_number(self): + c1 = Field("foo").isin([0, 1]) + c2 = Field("foo", table=self.t).isin([0, 1]) + + self.assertEqual('"foo" IN (0,1)', str(c1)) + self.assertEqual('"isin"."foo" IN (0,1)', str(c2)) + + def test__in_number_with_alias(self): + c1 = Field("foo").isin([0, 1]).as_('alias') + c2 = Field("foo", table=self.t).isin([0, 1]).as_('alias') + + self.assertEqual('"foo" IN (0,1) "alias"', str(c1)) + self.assertEqual('"isin"."foo" IN (0,1) "alias"', str(c2)) + + def test__in_character(self): + c1 = Field("foo").isin(["a", "b"]) + c2 = Field("foo", table=self.t).isin(["a", "b"]) + + self.assertEqual("\"foo\" IN ('a','b')", str(c1)) + self.assertEqual("\"isin\".\"foo\" IN ('a','b')", str(c2)) + + def test__in_date(self): + c1 = Field("foo").isin([date(2000, 1, 1), date(2000, 12, 31)]) + c2 = Field("foo", table=self.t).isin([date(2000, 1, 1), date(2000, 12, 31)]) + + self.assertEqual("\"foo\" IN ('2000-01-01','2000-12-31')", str(c1)) + self.assertEqual("\"isin\".\"foo\" IN ('2000-01-01','2000-12-31')", str(c2)) + + def test__in_datetime(self): + c1 = Field("foo").isin([datetime(2000, 1, 1, 0, 0, 0), datetime(2000, 12, 31, 23, 59, 59)]) + c2 = Field("foo", table=self.t).isin([datetime(2000, 1, 1, 0, 0, 0), datetime(2000, 12, 31, 23, 59, 59)]) + + self.assertEqual("\"foo\" IN ('2000-01-01T00:00:00','2000-12-31T23:59:59')", str(c1)) + self.assertEqual("\"isin\".\"foo\" IN ('2000-01-01T00:00:00','2000-12-31T23:59:59')", str(c2)) + + def test__function_isin(self): + c1 = fn.Coalesce(Field("foo"), 0).isin([0, 1]) + c2 = fn.Coalesce(Field("foo", table=self.t), 0).isin([0, 1]) + + self.assertEqual('COALESCE("foo",0) IN (0,1)', str(c1)) + self.assertEqual('COALESCE("isin"."foo",0) IN (0,1)', str(c2)) + + for t in (list, tuple, set, frozenset): + c_type = fn.Coalesce(Field("foo"), 0).isin(t([0, 1])) + self.assertEqual('COALESCE("foo",0) IN (0,1)', str(c_type)) + + self.assertRaises(AttributeError, lambda: str(fn.Coalesce(Field("foo"), 0).isin('SHOULD_FAIL'))) + + def test__in_unicode(self): + c1 = Field("foo").isin([u"a", u"b"]) + c2 = Field("foo", table=self.t).isin([u"a", u"b"]) + + self.assertEqual("\"foo\" IN ('a','b')", str(c1)) + self.assertEqual("\"isin\".\"foo\" IN ('a','b')", str(c2)) + + +class ArithmeticExpressionTests(unittest.TestCase): + def test__lshift(self): + c1 = Field("foo").lshift("1") + c2 = Field("foo").lshift("2") + + self.assertEqual("\"foo\"<<'1'", str(c1)) + self.assertEqual("\"foo\"<<'2'", str(c2)) + + def test__rshift(self): + c1 = Field("foo").rshift("1") + c2 = Field("foo").rshift("2") + + self.assertEqual("\"foo\">>'1'", str(c1)) + self.assertEqual("\"foo\">>'2'", str(c2)) + + +class NotInTests(unittest.TestCase): + t = Table("abc", alias="notin") + + def test__notin_number(self): + c1 = Field("foo").notin([0, 1]) + c2 = Field("foo", table=self.t).notin([0, 1]) + + self.assertEqual('"foo" NOT IN (0,1)', str(c1)) + self.assertEqual('"notin"."foo" NOT IN (0,1)', str(c2)) + + def test__notin_number_with_alias(self): + c1 = Field("foo").notin([0, 1]).as_('alias') + c2 = Field("foo", table=self.t).notin([0, 1]).as_('alias') + + self.assertEqual('"foo" NOT IN (0,1) "alias"', str(c1)) + self.assertEqual('"notin"."foo" NOT IN (0,1) "alias"', str(c2)) + + def test__notin_character(self): + c1 = Field("foo").notin(["a", "b"]) + c2 = Field("foo", table=self.t).notin(["a", "b"]) + + self.assertEqual("\"foo\" NOT IN ('a','b')", str(c1)) + self.assertEqual("\"notin\".\"foo\" NOT IN ('a','b')", str(c2)) + + def test__notin_date(self): + c1 = Field("foo").notin([date(2000, 1, 1), date(2000, 12, 31)]) + c2 = Field("foo", table=self.t).notin([date(2000, 1, 1), date(2000, 12, 31)]) + + self.assertEqual("\"foo\" NOT IN ('2000-01-01','2000-12-31')", str(c1)) + self.assertEqual("\"notin\".\"foo\" NOT IN ('2000-01-01','2000-12-31')", str(c2)) + + def test__notin_datetime(self): + c1 = Field("foo").notin([datetime(2000, 1, 1, 0, 0, 0), datetime(2000, 12, 31, 23, 59, 59)]) + c2 = Field("foo", table=self.t).notin([datetime(2000, 1, 1, 0, 0, 0), datetime(2000, 12, 31, 23, 59, 59)]) + + self.assertEqual("\"foo\" NOT IN ('2000-01-01T00:00:00','2000-12-31T23:59:59')", str(c1)) + self.assertEqual( + "\"notin\".\"foo\" NOT IN ('2000-01-01T00:00:00','2000-12-31T23:59:59')", + str(c2), + ) + + def test__function_notin(self): + c1 = fn.Coalesce(Field("foo"), 0).notin([0, 1]) + c2 = fn.Coalesce(Field("foo", table=self.t), 0).notin([0, 1]) + + self.assertEqual('COALESCE("foo",0) NOT IN (0,1)', str(c1)) + self.assertEqual('COALESCE("notin"."foo",0) NOT IN (0,1)', str(c2)) + + +class LikeTests(unittest.TestCase): + t = Table("abc", alias="like") + + def test_like_starts_with(self): + c1 = Field("foo").like("ab%") + c2 = Field("foo", table=self.t).like("ab%") + + self.assertEqual("\"foo\" LIKE 'ab%'", str(c1)) + self.assertEqual('"like"."foo" LIKE \'ab%\'', str(c2)) + + def test_like_contains(self): + c1 = Field("foo").like("%ab%") + c2 = Field("foo", table=self.t).like("%ab%") + + self.assertEqual("\"foo\" LIKE '%ab%'", str(c1)) + self.assertEqual('"like"."foo" LIKE \'%ab%\'', str(c2)) + + def test_like_ends_with(self): + c1 = Field("foo").like("%ab") + c2 = Field("foo", table=self.t).like("%ab") + + self.assertEqual("\"foo\" LIKE '%ab'", str(c1)) + self.assertEqual('"like"."foo" LIKE \'%ab\'', str(c2)) + + def test_like_n_chars_long(self): + c1 = Field("foo").like("___") + c2 = Field("foo", table=self.t).like("___") + + self.assertEqual("\"foo\" LIKE '___'", str(c1)) + self.assertEqual('"like"."foo" LIKE \'___\'', str(c2)) + + def test_like_single_chars_and_various_chars(self): + c1 = Field("foo").like("a_b%c") + c2 = Field("foo", table=self.t).like("a_b%c") + + self.assertEqual("\"foo\" LIKE 'a_b%c'", str(c1)) + self.assertEqual('"like"."foo" LIKE \'a_b%c\'', str(c2)) + + def test_not_like_single_chars_and_various_chars(self): + c1 = Field("foo").not_like("a_b%c") + c2 = Field("foo", table=self.t).not_like("a_b%c") + + self.assertEqual("\"foo\" NOT LIKE 'a_b%c'", str(c1)) + self.assertEqual('"like"."foo" NOT LIKE \'a_b%c\'', str(c2)) + + def test_ilike_starts_with(self): + c1 = Field("foo").ilike("ab%") + c2 = Field("foo", table=self.t).ilike("ab%") + + self.assertEqual("\"foo\" ILIKE 'ab%'", str(c1)) + self.assertEqual('"like"."foo" ILIKE \'ab%\'', str(c2)) + + def test_ilike_contains(self): + c1 = Field("foo").ilike("%ab%") + c2 = Field("foo", table=self.t).ilike("%ab%") + + self.assertEqual("\"foo\" ILIKE '%ab%'", str(c1)) + self.assertEqual('"like"."foo" ILIKE \'%ab%\'', str(c2)) + + def test_ilike_ends_with(self): + c1 = Field("foo").ilike("%ab") + c2 = Field("foo", table=self.t).ilike("%ab") + + self.assertEqual("\"foo\" ILIKE '%ab'", str(c1)) + self.assertEqual('"like"."foo" ILIKE \'%ab\'', str(c2)) + + def test_ilike_n_chars_long(self): + c1 = Field("foo").ilike("___") + c2 = Field("foo", table=self.t).ilike("___") + + self.assertEqual("\"foo\" ILIKE '___'", str(c1)) + self.assertEqual('"like"."foo" ILIKE \'___\'', str(c2)) + + def test_ilike_single_chars_and_various_chars(self): + c1 = Field("foo").ilike("a_b%c") + c2 = Field("foo", table=self.t).ilike("a_b%c") + + self.assertEqual("\"foo\" ILIKE 'a_b%c'", str(c1)) + self.assertEqual('"like"."foo" ILIKE \'a_b%c\'', str(c2)) + + def test_not_ilike_single_chars_and_various_chars(self): + c1 = Field("foo").not_ilike("a_b%c") + c2 = Field("foo", table=self.t).not_ilike("a_b%c") + + self.assertEqual("\"foo\" NOT ILIKE 'a_b%c'", str(c1)) + self.assertEqual('"like"."foo" NOT ILIKE \'a_b%c\'', str(c2)) + + def test_rlike_escape_chars(self): + c1 = Field("foo").rlike("\\\\d+$") + c2 = Field("foo", table=self.t).rlike("\\\\d+$") + + self.assertEqual("\"foo\" RLIKE '\\\\d+$'", str(c1)) + self.assertEqual('"like"."foo" RLIKE \'\\\\d+$\'', str(c2)) + + def test_glob_single_chars_and_various_chars(self): + c1 = Field("foo").glob("a_b*") + c2 = Field("foo", table=self.t).glob("a_b*") + + self.assertEqual("\"foo\" GLOB 'a_b*'", str(c1)) + self.assertEqual('"like"."foo" GLOB \'a_b*\'', str(c2)) + + +class ExistsCriterionTests(unittest.TestCase): + t2 = Table("abc", alias="t2") + q2 = QueryBuilder().from_(t2).select(t2.field2) + + def test_exists(self): + t1 = Table("def", alias="t1") + q1 = QueryBuilder().from_(t1).where(ExistsCriterion(self.q2)).select(t1.field1) + + self.assertEqual( + 'SELECT "t1"."field1" FROM "def" "t1" WHERE EXISTS (SELECT "t2"."field2" FROM "abc" "t2")', str(q1) + ) + + def test_not_exists(self): + t1 = Table("def", alias="t1") + q1 = QueryBuilder().from_(t1).where(ExistsCriterion(self.q2).negate()).select(t1.field1) + + self.assertEqual( + 'SELECT "t1"."field1" FROM "def" "t1" WHERE NOT EXISTS (SELECT "t2"."field2" FROM "abc" "t2")', str(q1) + ) + + +class ComplexCriterionTests(unittest.TestCase): + table_abc, table_efg = Table("abc", alias="cx0"), Table("efg", alias="cx1") + + def test_and(self): + c1 = (Field("foo") == 1) & (Field("bar") == 2) + c2 = (Field("foo", table=self.table_abc) == 1) & (Field("bar", table=self.table_efg) == 2) + + self.assertEqual('"foo"=1 AND "bar"=2', str(c1)) + self.assertEqual('"cx0"."foo"=1 AND "cx1"."bar"=2', str(c2)) + + def test_or(self): + c1 = (Field("foo") == 1) | (Field("bar") == 2) + c2 = (Field("foo", table=self.table_abc) == 1) | (Field("bar", table=self.table_efg) == 2) + + self.assertEqual('"foo"=1 OR "bar"=2', str(c1)) + self.assertEqual('"cx0"."foo"=1 OR "cx1"."bar"=2', str(c2)) + + def test_xor(self): + c1 = (Field("foo") == 1) ^ (Field("bar") == 2) + c2 = (Field("foo", table=self.table_abc) == 1) ^ (Field("bar", table=self.table_efg) == 2) + + self.assertEqual('"foo"=1 XOR "bar"=2', str(c1)) + self.assertEqual('"cx0"."foo"=1 XOR "cx1"."bar"=2', str(c2)) + + def test_function_and(self): + c1 = fn.IsNull(Field("foo")) & (Field("bar") == 2) + + self.assertEqual('ISNULL("foo") AND "bar"=2', str(c1)) + + def test_function_or(self): + c1 = fn.IsNull(Field("foo")) | (Field("bar") == 2) + + self.assertEqual('ISNULL("foo") OR "bar"=2', str(c1)) + + def test_function_xor(self): + c1 = fn.IsNull(Field("foo")) ^ (Field("bar") == 2) + + self.assertEqual('ISNULL("foo") XOR "bar"=2', str(c1)) + + def test__nested__and(self): + c = (Field("foo") == 1) & (Field("bar") == 2) & (Field("buz") == 3) + + self.assertEqual('"foo"=1 AND "bar"=2 AND "buz"=3', str(c)) + + def test__nested__or(self): + c = (Field("foo") == 1) | (Field("bar") == 2) | (Field("buz") == 3) + + self.assertEqual('"foo"=1 OR "bar"=2 OR "buz"=3', str(c)) + + def test__nested__mixed(self): + c = ((Field("foo") == 1) & (Field("bar") == 2)) | (Field("buz") == 3) + + self.assertEqual('("foo"=1 AND "bar"=2) OR "buz"=3', str(c)) + + def test__between_and_isin(self): + c = Field("foo").isin([1, 2, 3]) & Field("bar").between(0, 1) + + self.assertEqual('"foo" IN (1,2,3) AND "bar" BETWEEN 0 AND 1', str(c)) + + def test__between_and_field(self): + c1 = Field("foo").between(0, 1) + c2 = Field("bool_field") + + self.assertEqual('"foo" BETWEEN 0 AND 1 AND "bool_field"', str(c1 & c2)) + self.assertEqual('"bool_field" AND "foo" BETWEEN 0 AND 1', str(c2 & c1)) + + +class FieldsAsCriterionTests(unittest.TestCase): + def test__field_and_field(self): + c1 = Field("a") + c2 = Field("b") + + self.assertEqual('"a" AND "b"', str(c1 & c2)) + + def test__field_or_field(self): + c1 = Field("a") + c2 = Field("b") + + self.assertEqual('"a" OR "b"', str(c1 | c2)) + + def test__field_xor_field(self): + c1 = Field("a") + c2 = Field("b") + + self.assertEqual('"a" XOR "b"', str(c1 ^ c2)) + + +class CriterionOperationsTests(unittest.TestCase): + table_abc, table_efg = Table("abc", alias="cx0"), Table("efg", alias="cx1") + + def test_field_replace_table(self): + f = self.table_abc.foo.replace_table(self.table_abc, self.table_efg) + + self.assertEqual('"cx1"."foo"', str(f)) + + def test_arithmeticfunction_replace_table(self): + f = (self.table_abc.foo + self.table_abc.bar).replace_table(self.table_abc, self.table_efg) + + self.assertEqual('"cx1"."foo"+"cx1"."bar"', str(f)) + + def test_criterion_replace_table(self): + f = (self.table_abc.foo < self.table_abc.bar).replace_table(self.table_abc, self.table_efg) + + self.assertEqual('"cx1"."foo"<"cx1"."bar"', str(f)) + + def test_complexcriterion_replace_table(self): + f = (self.table_abc.foo < self.table_abc.bar) & (self.table_abc.fiz > self.table_abc.buz) + f = f.replace_table(self.table_abc, self.table_efg) + + self.assertEqual('"cx1"."foo"<"cx1"."bar" AND "cx1"."fiz">"cx1"."buz"', str(f)) + + def test_function_with_only_fields_replace_table(self): + f = fn.Sum(self.table_abc.foo).replace_table(self.table_abc, self.table_efg) + + self.assertEqual('SUM("cx1"."foo")', str(f)) + + def test_function_with_values_and_fields_replace_table(self): + f = Mod(self.table_abc.foo, 2).replace_table(self.table_abc, self.table_efg) + + self.assertEqual('MOD("cx1"."foo",2)', str(f)) + + def test_betweencriterion_replace_table(self): + f = self.table_abc.foo[0:1].replace_table(self.table_abc, self.table_efg) + + self.assertEqual('"cx1"."foo" BETWEEN 0 AND 1', str(f)) + + def test_nullcriterion_replace_table(self): + f = self.table_abc.foo.isnull().replace_table(self.table_abc, self.table_efg) + + self.assertEqual('"cx1"."foo" IS NULL', str(f)) + + +class AnyTests(unittest.TestCase): + def test_zero_args_returns_empty_criterion(self): + crit = Criterion.any() + self.assertIsInstance(crit, EmptyCriterion) + + def test_single_arg_returns_self(self): + f = Field("a") + crit = Criterion.any([f]) + self.assertEqual(str(f), str(crit)) + + def test_multiple_args_returned_in_chain_of_ors(self): + crit = Criterion.any([Field("a"), Field("b"), Field("c"), Field("d")]) + self.assertEqual(str(crit), '"a" OR "b" OR "c" OR "d"') + + def test_with_generator(self): + crit = Criterion.any(Field(letter) for letter in "abcd") + self.assertEqual(str(crit), '"a" OR "b" OR "c" OR "d"') + + +class EmptyCriterionTests(unittest.TestCase): + def test_fields_(self): + empty_criterion = EmptyCriterion() + + self.assertEqual(len(empty_criterion.fields_()), 0) + + def test_empty_criterion_on_the_left(self): + t = Table("test1") + q = EmptyCriterion() & t.f1 == "v1" + + self.assertEqual( + '"test1"."f1"=\'v1\'', + q.get_sql(with_namespace=True), + ) + + def test_empty_criterion_on_the_right(self): + t = Table("test1") + q = (t.f1 == "v1") & EmptyCriterion() + + self.assertEqual( + '"test1"."f1"=\'v1\'', + q.get_sql(with_namespace=True), + ) + + def test_invertion_of_the_empty_criterion(self): + t = Table("test1") + q = (t.f1 == "v1") & ~EmptyCriterion() + + self.assertEqual( + '"test1"."f1"=\'v1\'', + q.get_sql(with_namespace=True), + ) + + def test_different_operations_with_empty_criterion(self): + t = Table("test1") + q1 = (t.f1 == "v1") & EmptyCriterion() + q2 = (t.f1 == "v1") | EmptyCriterion() + q3 = (t.f1 == "v1") ^ EmptyCriterion() + + expected_sql = '"test1"."f1"=\'v1\'' + self.assertEqual( + expected_sql, + q1.get_sql(with_namespace=True), + ) + self.assertEqual( + expected_sql, + q2.get_sql(with_namespace=True), + ) + self.assertEqual( + expected_sql, + q3.get_sql(with_namespace=True), + ) + + def test_more_than_one_empty_criterions(self): + t = Table("test1") + q = EmptyCriterion() & ~(EmptyCriterion() | EmptyCriterion()) & (t.f1 == "v1") & ~EmptyCriterion() + + self.assertEqual( + '"test1"."f1"=\'v1\'', + q.get_sql(with_namespace=True), + ) + + +class AllTests(unittest.TestCase): + def test_zero_args_returns_empty_criterion(self): + crit = Criterion.all() + self.assertIsInstance(crit, EmptyCriterion) + + def test_single_arg_returns_self(self): + f = Field("a") + crit = Criterion.all([f]) + self.assertEqual(str(f), str(crit)) + + def test_multiple_args_returned_in_chain_of_ors(self): + crit = Criterion.all([Field("a"), Field("b"), Field("c"), Field("d")]) + self.assertEqual(str(crit), '"a" AND "b" AND "c" AND "d"') + + def test_with_generator(self): + crit = Criterion.all(Field(letter) for letter in "abcd") + self.assertEqual(str(crit), '"a" AND "b" AND "c" AND "d"') diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/test_custom_functions.py b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/test_custom_functions.py new file mode 100644 index 0000000000000000000000000000000000000000..60ffd3cd8e6191e3fc782dac003c41bfb7a78528 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/test_custom_functions.py @@ -0,0 +1,49 @@ +import unittest + +from pypika import CustomFunction, FunctionException, Query, Table + +__author__ = "Airton Zanon" +__email__ = "me@airton.dev" + + +class TestUnitCustomFunction(unittest.TestCase): + def test_should_fail_with_wrong_arguments(self): + DateDiff = CustomFunction("DATE_DIFF", ["interval", "start_date", "end_date"]) + + with self.assertRaises(FunctionException): + DateDiff("foo") + + def test_should_return_function_with_arguments(self): + DateDiff = CustomFunction("DATE_DIFF", ["interval", "start_date", "end_date"]) + + self.assertEqual( + "DATE_DIFF('day','start_date','end_date')", + str(DateDiff("day", "start_date", "end_date")), + ) + + def test_should_return_function_with_no_arguments(self): + CurrentDate = CustomFunction("CURRENT_DATE") + + self.assertEqual("CURRENT_DATE()", str(CurrentDate())) + + +class TestFunctionalCustomFunction(unittest.TestCase): + def test_should_use_custom_function_on_select(self): + service = Table("service") + + DateDiff = CustomFunction("DATE_DIFF", ["interval", "start_date", "end_date"]) + + q = Query.from_(service).select(DateDiff("day", service.created_date, service.updated_date)) + + self.assertEqual( + 'SELECT DATE_DIFF(\'day\',"created_date","updated_date") FROM "service"', + str(q), + ) + + def test_should_fail_use_custom_function_on_select_with_wrong_arguments(self): + service = Table("service") + + DateDiff = CustomFunction("DATE_DIFF", ["interval", "start_date", "end_date"]) + + with self.assertRaises(FunctionException): + Query.from_(service).select(DateDiff("day", service.created_date)) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/test_data_types.py b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/test_data_types.py new file mode 100644 index 0000000000000000000000000000000000000000..52fb4487fe7be3ae28a4e9eb08628fba89dc0f79 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/test_data_types.py @@ -0,0 +1,15 @@ +import unittest +import uuid + +from pypika.terms import ValueWrapper + + +class StringTests(unittest.TestCase): + def test_inline_string_concatentation(self): + self.assertEqual("'it''s'", ValueWrapper("it's").get_sql()) + + +class UuidTests(unittest.TestCase): + def test_uuid_string_generation(self): + id = uuid.uuid4() + self.assertEqual("'{}'".format(id), ValueWrapper(id).get_sql()) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/test_date_math.py b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/test_date_math.py new file mode 100644 index 0000000000000000000000000000000000000000..38db8ef2f8e812a97c6980a7ec6b9a3909d804fb --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/test_date_math.py @@ -0,0 +1,179 @@ +import unittest + +from pypika import ( + Field as F, + Interval, +) +from pypika.enums import Dialects + +dt = F("dt") + + +class AddIntervalTests(unittest.TestCase): + def test_add_microsecond(self): + c = dt + Interval(microseconds=1) + + self.assertEqual("\"dt\"+INTERVAL '1 MICROSECOND'", str(c)) + + def test_add_second(self): + c = dt + Interval(seconds=1) + + self.assertEqual("\"dt\"+INTERVAL '1 SECOND'", str(c)) + + def test_add_minute(self): + c = dt + Interval(minutes=1) + + self.assertEqual("\"dt\"+INTERVAL '1 MINUTE'", str(c)) + + def test_add_day(self): + c = dt + Interval(days=1) + + self.assertEqual("\"dt\"+INTERVAL '1 DAY'", str(c)) + + def test_add_week(self): + c = dt + Interval(weeks=1) + + self.assertEqual("\"dt\"+INTERVAL '1 WEEK'", str(c)) + + def test_add_month(self): + c = dt + Interval(months=1) + + self.assertEqual("\"dt\"+INTERVAL '1 MONTH'", str(c)) + + def test_add_quarter(self): + c = dt + Interval(quarters=1) + + self.assertEqual("\"dt\"+INTERVAL '1 QUARTER'", str(c)) + + def test_add_year(self): + c = dt + Interval(years=1) + + self.assertEqual("\"dt\"+INTERVAL '1 YEAR'", str(c)) + + def test_add_default(self): + c = dt + Interval(days=0) + + self.assertEqual("\"dt\"+INTERVAL '0 DAY'", str(c)) + + +class AddIntervalMultipleUnitsTests(unittest.TestCase): + def test_add_second_microsecond(self): + c = dt + Interval(seconds=1, microseconds=1) + + self.assertEqual("\"dt\"+INTERVAL '1.1 SECOND_MICROSECOND'", str(c)) + + def test_add_minute_microsecond(self): + c = dt + Interval(minutes=1, microseconds=1) + + self.assertEqual("\"dt\"+INTERVAL '1:0.1 MINUTE_MICROSECOND'", str(c)) + + def test_add_minute_second(self): + c = dt + Interval(minutes=1, seconds=1) + + self.assertEqual("\"dt\"+INTERVAL '1:1 MINUTE_SECOND'", str(c)) + + def test_add_hour_microsecond(self): + c = dt + Interval(hours=1, microseconds=1) + + self.assertEqual("\"dt\"+INTERVAL '1:0:0.1 HOUR_MICROSECOND'", str(c)) + + def test_add_hour_second(self): + c = dt + Interval(hours=1, seconds=1) + + self.assertEqual("\"dt\"+INTERVAL '1:0:1 HOUR_SECOND'", str(c)) + + def test_add_hour_minute(self): + c = dt + Interval(hours=1, minutes=1) + + self.assertEqual("\"dt\"+INTERVAL '1:1 HOUR_MINUTE'", str(c)) + + def test_add_day_microsecond(self): + c = dt + Interval(days=1, microseconds=1) + + self.assertEqual("\"dt\"+INTERVAL '1 0:0:0.1 DAY_MICROSECOND'", str(c)) + + def test_add_day_second(self): + c = dt + Interval(days=1, seconds=1) + + self.assertEqual("\"dt\"+INTERVAL '1 0:0:1 DAY_SECOND'", str(c)) + + def test_add_day_minute(self): + c = dt + Interval(days=1, minutes=1) + + self.assertEqual("\"dt\"+INTERVAL '1 0:1 DAY_MINUTE'", str(c)) + + def test_add_day_hour(self): + c = dt + Interval(days=1, hours=1) + + self.assertEqual("\"dt\"+INTERVAL '1 1 DAY_HOUR'", str(c)) + + def test_add_year_month(self): + c = dt + Interval(years=1, months=1) + + self.assertEqual("\"dt\"+INTERVAL '1-1 YEAR_MONTH'", str(c)) + + def test_add_value_right(self): + c = Interval(microseconds=1) - dt + + self.assertEqual("INTERVAL '1 MICROSECOND'-\"dt\"", str(c)) + + def test_add_value_complex_expressions(self): + c = dt + Interval(quarters=1) + Interval(weeks=1) + + self.assertEqual("\"dt\"+INTERVAL '1 QUARTER'+INTERVAL '1 WEEK'", str(c)) + + +class DialectIntervalTests(unittest.TestCase): + def test_mysql_dialect_uses_single_quotes_around_expression_in_an_interval(self): + c = Interval(days=1).get_sql(dialect=Dialects.MYSQL) + self.assertEqual("INTERVAL '1' DAY", c) + + def test_oracle_dialect_uses_single_quotes_around_expression_in_an_interval(self): + c = Interval(days=1).get_sql(dialect=Dialects.ORACLE) + self.assertEqual("INTERVAL '1' DAY", c) + + def test_vertica_dialect_uses_single_quotes_around_interval(self): + c = Interval(days=1).get_sql(dialect=Dialects.VERTICA) + self.assertEqual("INTERVAL '1 DAY'", c) + + def test_redshift_dialect_uses_single_quotes_around_interval(self): + c = Interval(days=1).get_sql(dialect=Dialects.REDSHIFT) + self.assertEqual("INTERVAL '1 DAY'", c) + + def test_postgresql_dialect_uses_single_quotes_around_interval(self): + c = Interval(days=1).get_sql(dialect=Dialects.POSTGRESQL) + self.assertEqual("INTERVAL '1 DAY'", c) + + +class TestNegativeIntervals(unittest.TestCase): + def test_day(self): + c = Interval(days=-1).get_sql() + self.assertEqual("INTERVAL '-1 DAY'", c) + + def test_week(self): + c = Interval(weeks=-1).get_sql() + self.assertEqual("INTERVAL '-1 WEEK'", c) + + def test_month(self): + c = Interval(months=-1).get_sql() + self.assertEqual("INTERVAL '-1 MONTH'", c) + + def test_year(self): + c = Interval(years=-1).get_sql() + self.assertEqual("INTERVAL '-1 YEAR'", c) + + def test_year_month(self): + c = Interval(years=-1, months=-4).get_sql() + self.assertEqual("INTERVAL '-1-4 YEAR_MONTH'", c) + + +class TruncateTrailingZerosTests(unittest.TestCase): + def test_do_not_truncate_integer_values(self): + i = Interval(seconds=10) + + self.assertEqual("INTERVAL '10 SECOND'", str(i)) + + def test_do_not_truncate_months_between_years_and_datys(self): + i = Interval(years=10, days=10) + + self.assertEqual("INTERVAL '10-0-10 YEAR_DAY'", str(i)) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/test_deletes.py b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/test_deletes.py new file mode 100644 index 0000000000000000000000000000000000000000..09df93f5331b845b0c3aed628bf1c4a3ec6b0f02 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/test_deletes.py @@ -0,0 +1,97 @@ +import unittest + +from pypika import PostgreSQLQuery, Query, SYSTEM_TIME, Table + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + +from pypika.terms import Star + + +class DeleteTests(unittest.TestCase): + @classmethod + def setUpClass(cls) -> None: + super().setUpClass() + cls.table_abc = Table("abc") + + def test_omit_where(self): + q = Query.from_("abc").delete() + + self.assertEqual('DELETE FROM "abc"', str(q)) + + def test_omit_where__table_schema(self): + q = Query.from_(Table("abc", "schema1")).delete() + + self.assertEqual('DELETE FROM "schema1"."abc"', str(q)) + + def test_where_field_equals(self): + q1 = Query.from_(self.table_abc).where(self.table_abc.foo == self.table_abc.bar).delete() + q2 = Query.from_(self.table_abc).where(self.table_abc.foo.eq(self.table_abc.bar)).delete() + + self.assertEqual('DELETE FROM "abc" WHERE "foo"="bar"', str(q1)) + self.assertEqual('DELETE FROM "abc" WHERE "foo"="bar"', str(q2)) + + def test_for_portion(self): + with self.subTest("with system time"): + q = Query.from_(self.table_abc.for_portion(SYSTEM_TIME.from_to('2020-01-01', '2020-02-01'))).delete() + + self.assertEqual( + 'DELETE FROM "abc" FOR PORTION OF SYSTEM_TIME FROM \'2020-01-01\' TO \'2020-02-01\'', str(q) + ) + + with self.subTest("with column"): + q = Query.from_( + self.table_abc.for_portion(self.table_abc.valid_period.from_to('2020-01-01', '2020-02-01')) + ).delete() + + self.assertEqual( + 'DELETE FROM "abc" FOR PORTION OF "valid_period" FROM \'2020-01-01\' TO \'2020-02-01\'', str(q) + ) + + +class PostgresDeleteTests(unittest.TestCase): + @classmethod + def setUpClass(cls) -> None: + super().setUpClass() + cls.table_abc = Table("abc") + + def test_delete_returning(self): + q1 = ( + PostgreSQLQuery.from_(self.table_abc) + .where(self.table_abc.foo == self.table_abc.bar) + .delete() + .returning(self.table_abc.id) + ) + + self.assertEqual('DELETE FROM "abc" WHERE "foo"="bar" RETURNING "id"', str(q1)) + + def test_delete_returning_str(self): + q1 = ( + PostgreSQLQuery.from_(self.table_abc) + .where(self.table_abc.foo == self.table_abc.bar) + .delete() + .returning("id") + ) + + self.assertEqual('DELETE FROM "abc" WHERE "foo"="bar" RETURNING "id"', str(q1)) + + def test_delete_returning_star(self): + q1 = ( + PostgreSQLQuery.from_(self.table_abc) + .where(self.table_abc.foo == self.table_abc.bar) + .delete() + .returning(Star()) + ) + + self.assertEqual('DELETE FROM "abc" WHERE "foo"="bar" RETURNING *', str(q1)) + + def test_delete_using(self): + table_trash = Table('trash') + q1 = ( + PostgreSQLQuery.from_(self.table_abc) + .using(table_trash) + .where(self.table_abc.id == table_trash.abc_id) + .delete() + ) + + self.assertEqual('DELETE FROM "abc" USING "trash" WHERE "abc"."id"="trash"."abc_id"', str(q1)) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/test_drop.py b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/test_drop.py new file mode 100644 index 0000000000000000000000000000000000000000..265ae7350d2054549731f9a8c4379fdac95dc580 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/test_drop.py @@ -0,0 +1,49 @@ +import unittest + +from pypika import ( + Columns, + Database, + Query, + Tables, +) + + +class DropTableTests(unittest.TestCase): + database_xyz = Database("mydb") + new_table, existing_table = Tables("abc", "efg") + foo, bar = Columns(("a", "INT"), ("b", "VARCHAR(100)")) + + def test_drop_database(self): + q1 = Query.drop_database(self.database_xyz) + q2 = Query.drop_database(self.database_xyz).if_exists() + + self.assertEqual('DROP DATABASE "mydb"', str(q1)) + self.assertEqual('DROP DATABASE IF EXISTS "mydb"', str(q2)) + + def test_drop_table(self): + q1 = Query.drop_table(self.new_table) + q2 = Query.drop_table(self.new_table).if_exists() + + self.assertEqual('DROP TABLE "abc"', str(q1)) + self.assertEqual('DROP TABLE IF EXISTS "abc"', str(q2)) + + def test_drop_user(self): + q1 = Query.drop_user("myuser") + q2 = Query.drop_user("myuser").if_exists() + + self.assertEqual('DROP USER "myuser"', str(q1)) + self.assertEqual('DROP USER IF EXISTS "myuser"', str(q2)) + + def test_drop_view(self): + q1 = Query.drop_view("myview") + q2 = Query.drop_view("myview").if_exists() + + self.assertEqual('DROP VIEW "myview"', str(q1)) + self.assertEqual('DROP VIEW IF EXISTS "myview"', str(q2)) + + def test_drop_index(self): + q1 = Query.drop_index("myindex") + q2 = Query.drop_index("myindex").if_exists() + + self.assertEqual('DROP INDEX "myindex"', str(q1)) + self.assertEqual('DROP INDEX IF EXISTS "myindex"', str(q2)) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/test_formats.py b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/test_formats.py new file mode 100644 index 0000000000000000000000000000000000000000..6a442757c6659a215661e03f1ca9c3771d394d96 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/test_formats.py @@ -0,0 +1,68 @@ +import unittest + +from pypika import Query, Tables, functions as fn + + +class QuoteTests(unittest.TestCase): + maxDiff = None + + table_abc, table_efg = Tables("abc", "efg") + + def setUp(self): + subquery1 = ( + Query.from_(self.table_abc) + .select( + self.table_abc.foo, + fn.Sum(self.table_abc.fizz + self.table_abc.buzz).as_("fizzbuzz"), + ) + .groupby(self.table_abc.foo) + ) + + subquery2 = Query.from_(self.table_efg).select( + self.table_efg.foo.as_("foo_two"), + self.table_efg.bar, + ) + + self.query = ( + Query.from_(subquery1) + .select(subquery1.foo, subquery1.fizzbuzz) + .join(subquery2) + .on(subquery1.foo == subquery2.foo_two) + .select(subquery2.foo_two, subquery2.bar) + ) + + def test_replace_quote_char_in_complex_query(self): + self.assertEqual( + "SELECT " + "`sq0`.`foo`,`sq0`.`fizzbuzz`," + "`sq1`.`foo_two`,`sq1`.`bar` " + "FROM (" + "SELECT " + "`foo`,SUM(`fizz`+`buzz`) `fizzbuzz` " + "FROM `abc` " + "GROUP BY `foo`" + ") `sq0` JOIN (" + "SELECT " + "`foo` `foo_two`,`bar` " + "FROM `efg`" + ") `sq1` ON `sq0`.`foo`=`sq1`.`foo_two`", + self.query.get_sql(quote_char="`"), + ) + + def test_no_quote_char_in_complex_query(self): + self.assertEqual( + "SELECT " + "sq0.foo,sq0.fizzbuzz," + "sq1.foo_two,sq1.bar " + "FROM (" + "SELECT " + "foo,SUM(fizz+buzz) fizzbuzz " + "FROM abc " + "GROUP BY foo" + ") sq0 JOIN (" + "SELECT " + "foo foo_two,bar " + "FROM efg" + ") sq1 ON sq0.foo=sq1.foo_two", + self.query.get_sql(quote_char=None), + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/test_functions.py b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/test_functions.py new file mode 100644 index 0000000000000000000000000000000000000000..f526966eefc554ec68d0e15fb69de7d69f1604c3 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/test_functions.py @@ -0,0 +1,847 @@ +import unittest + +from pypika import ( + Case, + CaseException, + DatePart, + Field as F, + Query, + Query as Q, + Schema, + Table as T, + VerticaQuery, + functions as fn, +) +from pypika.enums import Dialects, SqlTypes + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + + +class FunctionTests(unittest.TestCase): + def test_dialect_propagation(self): + func = fn.Function("func", ["a"], ["b"]) + self.assertEqual("func(ARRAY['a'],ARRAY['b'])", func.get_sql(dialect=Dialects.POSTGRESQL)) + + def test_is_aggregate_None_for_non_aggregate_function_or_function_with_no_aggregate_functions(self): + self.assertIsNone(fn.Coalesce('a', 0).is_aggregate) + self.assertIsNone(fn.Coalesce(fn.NullIf('a', 0), 0).is_aggregate) + + def test_is_aggregate_True_for_aggregate_function_or_function_with_aggregate_functions(self): + self.assertTrue(fn.Sum('a').is_aggregate) + self.assertTrue(fn.Coalesce(fn.Avg('a'), 0).is_aggregate) + self.assertTrue(fn.Coalesce(fn.NullIf(fn.Sum('a'), 0), 0).is_aggregate) + + +class SchemaTests(unittest.TestCase): + def test_schema_no_schema_in_sql_when_none_set(self): + func = fn.Function("my_proc", 1, 2, 3) + + self.assertEqual("my_proc(1,2,3)", func.get_sql(quote_char='"')) + + def test_schema_included_in_function_sql(self): + a = Schema("a") + func = fn.Function("my_proc", 1, 2, 3, schema=a) + + self.assertEqual('"a".my_proc(1,2,3)', func.get_sql(quote_char='"')) + + +class ArithmeticTests(unittest.TestCase): + t = T("abc") + + def test__addition__fields(self): + q1 = Q.from_("abc").select(F("a") + F("b")) + q2 = Q.from_(self.t).select(self.t.a + self.t.b) + + self.assertEqual('SELECT "a"+"b" FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"+"b" FROM "abc"', str(q2)) + + def test__addition__number(self): + q1 = Q.from_("abc").select(F("a") + 1) + q2 = Q.from_(self.t).select(self.t.a + 1) + + self.assertEqual('SELECT "a"+1 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"+1 FROM "abc"', str(q2)) + + def test__addition__decimal(self): + q1 = Q.from_("abc").select(F("a") + 1.0) + q2 = Q.from_(self.t).select(self.t.a + 1.0) + + self.assertEqual('SELECT "a"+1.0 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"+1.0 FROM "abc"', str(q2)) + + def test__addition__right(self): + q1 = Q.from_("abc").select(1 + F("a")) + q2 = Q.from_(self.t).select(1 + self.t.a) + + self.assertEqual('SELECT 1+"a" FROM "abc"', str(q1)) + self.assertEqual('SELECT 1+"a" FROM "abc"', str(q2)) + + def test__subtraction__fields(self): + q1 = Q.from_("abc").select(F("a") - F("b")) + q2 = Q.from_(self.t).select(self.t.a - self.t.b) + + self.assertEqual('SELECT "a"-"b" FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"-"b" FROM "abc"', str(q2)) + + def test__subtraction__number(self): + q1 = Q.from_("abc").select(F("a") - 1) + q2 = Q.from_(self.t).select(self.t.a - 1) + + self.assertEqual('SELECT "a"-1 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"-1 FROM "abc"', str(q2)) + + def test__subtraction__decimal(self): + q1 = Q.from_("abc").select(F("a") - 1.0) + q2 = Q.from_(self.t).select(self.t.a - 1.0) + + self.assertEqual('SELECT "a"-1.0 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"-1.0 FROM "abc"', str(q2)) + + def test__subtraction__right(self): + q1 = Q.from_("abc").select(1 - F("a")) + q2 = Q.from_(self.t).select(1 - self.t.a) + + self.assertEqual('SELECT 1-"a" FROM "abc"', str(q1)) + self.assertEqual('SELECT 1-"a" FROM "abc"', str(q2)) + + def test__multiplication__fields(self): + q1 = Q.from_("abc").select(F("a") * F("b")) + q2 = Q.from_(self.t).select(self.t.a * self.t.b) + + self.assertEqual('SELECT "a"*"b" FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"*"b" FROM "abc"', str(q2)) + + def test__multiplication__number(self): + q1 = Q.from_("abc").select(F("a") * 1) + q2 = Q.from_(self.t).select(self.t.a * 1) + + self.assertEqual('SELECT "a"*1 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"*1 FROM "abc"', str(q2)) + + def test__multiplication__decimal(self): + q1 = Q.from_("abc").select(F("a") * 1.0) + q2 = Q.from_(self.t).select(self.t.a * 1.0) + + self.assertEqual('SELECT "a"*1.0 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"*1.0 FROM "abc"', str(q2)) + + def test__multiplication__right(self): + q1 = Q.from_("abc").select(1 * F("a")) + q2 = Q.from_(self.t).select(1 * self.t.a) + + self.assertEqual('SELECT 1*"a" FROM "abc"', str(q1)) + self.assertEqual('SELECT 1*"a" FROM "abc"', str(q2)) + + def test__division__fields(self): + q1 = Q.from_("abc").select(F("a") / F("b")) + q2 = Q.from_(self.t).select(self.t.a / self.t.b) + + self.assertEqual('SELECT "a"/"b" FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"/"b" FROM "abc"', str(q2)) + + def test__division__number(self): + q1 = Q.from_("abc").select(F("a") / 1) + q2 = Q.from_(self.t).select(self.t.a / 1) + + self.assertEqual('SELECT "a"/1 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"/1 FROM "abc"', str(q2)) + + def test__division__decimal(self): + q1 = Q.from_("abc").select(F("a") / 1.0) + q2 = Q.from_(self.t).select(self.t.a / 1.0) + + self.assertEqual('SELECT "a"/1.0 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"/1.0 FROM "abc"', str(q2)) + + def test__division__right(self): + q1 = Q.from_("abc").select(1 / F("a")) + q2 = Q.from_(self.t).select(1 / self.t.a) + + self.assertEqual('SELECT 1/"a" FROM "abc"', str(q1)) + self.assertEqual('SELECT 1/"a" FROM "abc"', str(q2)) + + def test__leftshift__fields(self): + q1 = Q.from_("abc").select(F("a") << F("b")) + q2 = Q.from_(self.t).select(self.t.a << self.t.b) + + self.assertEqual('SELECT "a"<<"b" FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"<<"b" FROM "abc"', str(q2)) + + def test__leftshift__number(self): + q1 = Q.from_("abc").select(F('a') << 2) + q2 = Q.from_(self.t).select(self.t.a << 2) + + self.assertEqual('SELECT "a"<<2 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"<<2 FROM "abc"', str(q2)) + + def test__leftshift__right(self): + q1 = Q.from_("abc").select(1 << F("a")) + q2 = Q.from_(self.t).select(1 << self.t.a) + + self.assertEqual('SELECT 1<<"a" FROM "abc"', str(q1)) + self.assertEqual('SELECT 1<<"a" FROM "abc"', str(q2)) + + def test__rightshift__fields(self): + q1 = Q.from_("abc").select(F("a") >> F("b")) + q2 = Q.from_(self.t).select(self.t.a >> self.t.b) + + self.assertEqual('SELECT "a">>"b" FROM "abc"', str(q1)) + self.assertEqual('SELECT "a">>"b" FROM "abc"', str(q2)) + + def test__rightshift__number(self): + q1 = Q.from_("abc").select(F('a') >> 2) + q2 = Q.from_(self.t).select(self.t.a >> 2) + + self.assertEqual('SELECT "a">>2 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a">>2 FROM "abc"', str(q2)) + + def test__rightshift__right(self): + q1 = Q.from_("abc").select(1 >> F("a")) + q2 = Q.from_(self.t).select(1 >> self.t.a) + + self.assertEqual('SELECT 1>>"a" FROM "abc"', str(q1)) + self.assertEqual('SELECT 1>>"a" FROM "abc"', str(q2)) + + def test__complex_op(self): + q1 = Q.from_("abc").select(2 + 1 / F("a") - 5) + q2 = Q.from_(self.t).select(2 + 1 / self.t.a - 5) + + self.assertEqual('SELECT 2+1/"a"-5 FROM "abc"', str(q1)) + self.assertEqual('SELECT 2+1/"a"-5 FROM "abc"', str(q2)) + + def test__complex_op_add_parentheses(self): + q1 = Q.from_("abc").select((F("a") + 1) + (F("b") - 5)) + q2 = Q.from_(self.t).select((self.t.a + 1) + (self.t.b - 5)) + q3 = Q.from_("abc").select((F("a") / 1) + (F("b") / 5)) + q4 = Q.from_(self.t).select((self.t.a / 1) + (self.t.b / 5)) + + self.assertEqual('SELECT "a"+1+"b"-5 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"+1+"b"-5 FROM "abc"', str(q2)) + self.assertEqual('SELECT "a"/1+"b"/5 FROM "abc"', str(q3)) + self.assertEqual('SELECT "a"/1+"b"/5 FROM "abc"', str(q4)) + + def test__complex_op_sub_parentheses(self): + q1 = Q.from_("abc").select((F("a") + 1) - (F("b") - 5)) + q2 = Q.from_(self.t).select((self.t.a + 1) - (self.t.b - 5)) + q3 = Q.from_("abc").select((F("a") / 1) - (F("b") / 5)) + q4 = Q.from_(self.t).select((self.t.a / 1) - (self.t.b / 5)) + + self.assertEqual('SELECT "a"+1-("b"-5) FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"+1-("b"-5) FROM "abc"', str(q2)) + self.assertEqual('SELECT "a"/1-"b"/5 FROM "abc"', str(q3)) + self.assertEqual('SELECT "a"/1-"b"/5 FROM "abc"', str(q4)) + + def test__complex_op_mul_parentheses(self): + q1 = Q.from_("abc").select((F("a") + 1) * (F("b") - 5)) + q2 = Q.from_(self.t).select((self.t.a + 1) * (self.t.b - 5)) + q3 = Q.from_("abc").select((F("a") / 1) * (F("b") - 5)) + q4 = Q.from_(self.t).select((self.t.a / 1) * (self.t.b - 5)) + q5 = Q.from_("abc").select((F("a") + 1) * (F("b") / 5)) + q6 = Q.from_(self.t).select((self.t.a + 1) * (self.t.b / 5)) + + self.assertEqual('SELECT ("a"+1)*("b"-5) FROM "abc"', str(q1)) + self.assertEqual('SELECT ("a"+1)*("b"-5) FROM "abc"', str(q2)) + self.assertEqual('SELECT "a"/1*("b"-5) FROM "abc"', str(q3)) + self.assertEqual('SELECT "a"/1*("b"-5) FROM "abc"', str(q4)) + self.assertEqual('SELECT ("a"+1)*"b"/5 FROM "abc"', str(q5)) + self.assertEqual('SELECT ("a"+1)*"b"/5 FROM "abc"', str(q6)) + + def test__complex_op_mul_no_parentheses(self): + q = Q.from_("abc").select(F("a") + 1 * F("b") - 5) + + self.assertEqual('SELECT "a"+1*"b"-5 FROM "abc"', str(q)) + + def test__complex_op_div_parentheses(self): + q1 = Q.from_("abc").select((F("a") + 1) / (F("b") - 5)) + q2 = Q.from_(self.t).select((self.t.a + 1) / (self.t.b - 5)) + q3 = Q.from_("abc").select((F("a") / 1) / (F("b") - 5)) + q4 = Q.from_(self.t).select((self.t.a / 1) / (self.t.b - 5)) + q5 = Q.from_("abc").select((F("a") + 1) / (F("b") * 5)) + q6 = Q.from_(self.t).select((self.t.a + 1) / (self.t.b * 5)) + + self.assertEqual('SELECT ("a"+1)/("b"-5) FROM "abc"', str(q1)) + self.assertEqual('SELECT ("a"+1)/("b"-5) FROM "abc"', str(q2)) + self.assertEqual('SELECT "a"/1/("b"-5) FROM "abc"', str(q3)) + self.assertEqual('SELECT "a"/1/("b"-5) FROM "abc"', str(q4)) + self.assertEqual('SELECT ("a"+1)/("b"*5) FROM "abc"', str(q5)) + self.assertEqual('SELECT ("a"+1)/("b"*5) FROM "abc"', str(q6)) + + def test__complex_op_div_no_parentheses(self): + q = Q.from_("abc").select(F("a") + 1 / F("b") - 5) + + self.assertEqual('SELECT "a"+1/"b"-5 FROM "abc"', str(q)) + + def test__complex_op_exponent_parentheses(self): + q1 = Q.from_("abc").select(F("a") / (F("b") ** 2)) + q2 = Q.from_(self.t).select(self.t.a / (self.t.b**2)) + q3 = Q.from_("abc").select(F("a") ** (F("b") / 2)) + q4 = Q.from_(self.t).select(self.t.a ** (self.t.b / 2)) + q5 = Q.from_("abc").select((F("a") ** F("b")) ** 2) + q6 = Q.from_(self.t).select((self.t.a**self.t.b) ** 2) + + self.assertEqual('SELECT "a"/POW("b",2) FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"/POW("b",2) FROM "abc"', str(q2)) + self.assertEqual('SELECT POW("a","b"/2) FROM "abc"', str(q3)) + self.assertEqual('SELECT POW("a","b"/2) FROM "abc"', str(q4)) + self.assertEqual('SELECT POW(POW("a","b"),2) FROM "abc"', str(q5)) + self.assertEqual('SELECT POW(POW("a","b"),2) FROM "abc"', str(q6)) + + def test__complex_op_exponent_no_parentheses(self): + q1 = Q.from_("abc").select(F("a") ** F("b") ** 2) + q2 = Q.from_(self.t).select(self.t.a**self.t.b**2) + q3 = Q.from_("abc").select(F("a") / F("b") ** 2) + q4 = Q.from_(self.t).select(self.t.a / self.t.b**2) + + self.assertEqual('SELECT POW("a",POW("b",2)) FROM "abc"', str(q1)) + self.assertEqual('SELECT POW("a",POW("b",2)) FROM "abc"', str(q2)) + self.assertEqual('SELECT "a"/POW("b",2) FROM "abc"', str(q3)) + self.assertEqual('SELECT "a"/POW("b",2) FROM "abc"', str(q4)) + + def test__complex_op_function_parentheses(self): + q1 = Q.from_("abc").select(F("a") / (fn.Sum(F("b")) / 2)) + q2 = Q.from_("abc").select(self.t.a / (fn.Sum(self.t.b) / 2)) + q3 = Q.from_("abc").select(fn.Sum(F("a") / (F("b") / 2))) + q4 = Q.from_("abc").select(fn.Sum(self.t.a / (self.t.b / 2))) + + self.assertEqual('SELECT "a"/(SUM("b")/2) FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"/(SUM("b")/2) FROM "abc"', str(q2)) + self.assertEqual('SELECT SUM("a"/("b"/2)) FROM "abc"', str(q3)) + self.assertEqual('SELECT SUM("a"/("b"/2)) FROM "abc"', str(q4)) + + def test__complex_op_modulus_parentheses(self): + q1 = Q.from_("abc").select(F("a") / (F("b") % 2)) + q2 = Q.from_(self.t).select(self.t.a / (self.t.b % 2)) + q3 = Q.from_("abc").select(F("a") % (F("b") / 2)) + q4 = Q.from_(self.t).select(self.t.a % (self.t.b / 2)) + q5 = Q.from_("abc").select(F("a") % (F("b") % 2)) + q6 = Q.from_("abc").select(self.t.a % (self.t.b % 2)) + + self.assertEqual('SELECT "a"/MOD("b",2) FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"/MOD("b",2) FROM "abc"', str(q2)) + self.assertEqual('SELECT MOD("a","b"/2) FROM "abc"', str(q3)) + self.assertEqual('SELECT MOD("a","b"/2) FROM "abc"', str(q4)) + self.assertEqual('SELECT MOD("a",MOD("b",2)) FROM "abc"', str(q5)) + self.assertEqual('SELECT MOD("a",MOD("b",2)) FROM "abc"', str(q6)) + + def test__complex_op_modulus_no_parentheses(self): + q1 = Q.from_("abc").select(F("a") % F("b") % 2) + q2 = Q.from_(self.t).select(self.t.a % self.t.b % 2) + q3 = Q.from_("abc").select(F("a") / F("b") % 2) + q4 = Q.from_(self.t).select(self.t.a / self.t.b % 2) + + self.assertEqual('SELECT MOD(MOD("a","b"),2) FROM "abc"', str(q1)) + self.assertEqual('SELECT MOD(MOD("a","b"),2) FROM "abc"', str(q2)) + self.assertEqual('SELECT MOD("a"/"b",2) FROM "abc"', str(q3)) + self.assertEqual('SELECT MOD("a"/"b",2) FROM "abc"', str(q4)) + + def test__complex_op_floor_parentheses(self): + q1 = Q.from_("abc").select(F("a") / (fn.Floor(F("b")) / 2)) + q2 = Q.from_("abc").select(self.t.a / (fn.Floor(self.t.b) / 2)) + q3 = Q.from_("abc").select(fn.Floor(F("a") / (F("b") / 2))) + q4 = Q.from_("abc").select(fn.Floor(self.t.a / (self.t.b / 2))) + + self.assertEqual('SELECT "a"/(FLOOR("b")/2) FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"/(FLOOR("b")/2) FROM "abc"', str(q2)) + self.assertEqual('SELECT FLOOR("a"/("b"/2)) FROM "abc"', str(q3)) + self.assertEqual('SELECT FLOOR("a"/("b"/2)) FROM "abc"', str(q4)) + + def test__complex_op_nested_parentheses(self): + q1 = Q.from_("abc").select(F("a") / (F("b") / ((F("c") / 2)))) + q2 = Q.from_("abc").select(self.t.a / (self.t.b / ((self.t.c / 2)))) + + self.assertEqual('SELECT "a"/("b"/("c"/2)) FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"/("b"/("c"/2)) FROM "abc"', str(q2)) + + def test__arithmetic_equality(self): + q1 = Q.from_("abc").select(F("a") / 2 == 2) + q2 = Q.from_(self.t).select(self.t.a / 2 == 2) + + self.assertEqual('SELECT "a"/2=2 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"/2=2 FROM "abc"', str(q2)) + + def test__arithmetic_with_function(self): + q1 = Q.from_("abc").select(fn.Sum(F("foo")) + 1) + q2 = Q.from_(self.t).select(fn.Sum(self.t.foo) + 1) + + self.assertEqual('SELECT SUM("foo")+1 FROM "abc"', str(q1)) + self.assertEqual('SELECT SUM("foo")+1 FROM "abc"', str(q2)) + + def test__exponent__number(self): + q1 = Q.from_("abc").select(F("a") ** 2) + q2 = Q.from_(self.t).select(self.t.a**2) + + self.assertEqual('SELECT POW("a",2) FROM "abc"', str(q1)) + self.assertEqual('SELECT POW("a",2) FROM "abc"', str(q2)) + + def test__exponent__decimal(self): + q1 = Q.from_("abc").select(F("a") ** 0.5) + q2 = Q.from_(self.t).select(self.t.a**0.5) + + self.assertEqual('SELECT POW("a",0.5) FROM "abc"', str(q1)) + self.assertEqual('SELECT POW("a",0.5) FROM "abc"', str(q2)) + + def test__modulus__number(self): + q1 = Q.from_("abc").select(F("a") % 2) + q2 = Q.from_(self.t).select(self.t.a % 2) + + self.assertEqual('SELECT MOD("a",2) FROM "abc"', str(q1)) + self.assertEqual('SELECT MOD("a",2) FROM "abc"', str(q2)) + + def test__floor(self): + q1 = Q.from_("abc").select(fn.Floor(F("foo"))) + q2 = Q.from_(self.t).select(fn.Floor(self.t.foo)) + + self.assertEqual('SELECT FLOOR("foo") FROM "abc"', str(q1)) + self.assertEqual('SELECT FLOOR("foo") FROM "abc"', str(q2)) + + +class AggregationTests(unittest.TestCase): + def test__count(self): + q = Q.from_("abc").select(fn.Count(F("foo"))) + + self.assertEqual('SELECT COUNT("foo") FROM "abc"', str(q)) + + def test__count__star(self): + q = Q.from_("abc").select(fn.Count("*")) + + self.assertEqual('SELECT COUNT(*) FROM "abc"', str(q)) + + def test__sum(self): + q = Q.from_("abc").select(fn.Sum(F("foo"))) + + self.assertEqual('SELECT SUM("foo") FROM "abc"', str(q)) + + def test__avg(self): + q = Q.from_("abc").select(fn.Avg(F("foo"))) + + self.assertEqual('SELECT AVG("foo") FROM "abc"', str(q)) + + def test__first(self): + q = Q.from_("abc").select(fn.First(F("foo"))) + + self.assertEqual('SELECT FIRST("foo") FROM "abc"', str(q)) + + def test__last(self): + q = Q.from_("abc").select(fn.Last(F("foo"))) + + self.assertEqual('SELECT LAST("foo") FROM "abc"', str(q)) + + def test__min(self): + q = Q.from_("abc").select(fn.Min(F("foo"))) + + self.assertEqual('SELECT MIN("foo") FROM "abc"', str(q)) + + def test__max(self): + q = Q.from_("abc").select(fn.Max(F("foo"))) + + self.assertEqual('SELECT MAX("foo") FROM "abc"', str(q)) + + def test__std(self): + q = Q.from_("abc").select(fn.Std(F("foo"))) + + self.assertEqual('SELECT STD("foo") FROM "abc"', str(q)) + + def test__stddev(self): + q = Q.from_("abc").select(fn.StdDev(F("foo"))) + + self.assertEqual('SELECT STDDEV("foo") FROM "abc"', str(q)) + + def test__approx_percentile(self): + q = Q.from_("abc").select(fn.ApproximatePercentile(F("foo"), 0.5)) + + self.assertEqual( + 'SELECT APPROXIMATE_PERCENTILE("foo" USING PARAMETERS percentile=0.5) FROM "abc"', + str(q), + ) + + def test__subquery_in_params_functions(self): + subquery = Query.from_('table').select('id') + func = fn.Function('func', 'id', subquery) + self.assertEqual("func('id',(SELECT id FROM table))", func.get_sql()) + + +class ConditionTests(unittest.TestCase): + def test__case__raw(self): + q = Q.from_("abc").select(Case().when(F("foo") == 1, "a")) + + self.assertEqual('SELECT CASE WHEN "foo"=1 THEN \'a\' END FROM "abc"', str(q)) + + def test__case__else(self): + q = Q.from_("abc").select(Case().when(F("foo") == 1, "a").else_("b")) + + self.assertEqual("SELECT CASE WHEN \"foo\"=1 THEN 'a' ELSE 'b' END FROM \"abc\"", str(q)) + + def test__case__field(self): + q = Q.from_("abc").select(Case().when(F("foo") == 1, F("bar")).else_(F("buz"))) + + self.assertEqual('SELECT CASE WHEN "foo"=1 THEN "bar" ELSE "buz" END FROM "abc"', str(q)) + + def test__case__multi(self): + q = Q.from_("abc").select(Case().when(F("foo") > 0, F("fiz")).when(F("bar") <= 0, F("buz")).else_(1)) + + self.assertEqual( + 'SELECT CASE WHEN "foo">0 THEN "fiz" WHEN "bar"<=0 THEN "buz" ELSE 1 END FROM "abc"', + str(q), + ) + + def test__case__no_cases(self): + with self.assertRaises(CaseException): + q = Q.from_("abc").select(Case()) + + str(q) + + +class StringTests(unittest.TestCase): + t = T("abc") + + def test__ascii__str(self): + q = Q.select(fn.Ascii("2")) + + self.assertEqual("SELECT ASCII('2')", str(q)) + + def test__ascii__int(self): + q = Q.select(fn.Ascii(2)) + + self.assertEqual("SELECT ASCII(2)", str(q)) + + def test__ascii__field(self): + q = Q.from_(self.t).select(fn.Ascii(self.t.foo)) + + self.assertEqual('SELECT ASCII("foo") FROM "abc"', str(q)) + + def test__bin__str(self): + q = Q.select(fn.Bin("2")) + + self.assertEqual("SELECT BIN('2')", str(q)) + + def test__bin__int(self): + q = Q.select(fn.Bin(2)) + + self.assertEqual("SELECT BIN(2)", str(q)) + + def test__bin__field(self): + q = Q.from_(self.t).select(fn.Bin(self.t.foo)) + + self.assertEqual('SELECT BIN("foo") FROM "abc"', str(q)) + + def test__concat__str(self): + q = Q.select(fn.Concat("p", "y", "q", "b")) + + self.assertEqual("SELECT CONCAT('p','y','q','b')", str(q)) + + def test__concat__field(self): + q = Q.from_(self.t).select(fn.Concat(self.t.foo, self.t.bar)) + + self.assertEqual('SELECT CONCAT("foo","bar") FROM "abc"', str(q)) + + def test__insert__str(self): + q = Q.select(fn.Insert("Quadratic", 3, 4, "What")) + + self.assertEqual("SELECT INSERT('Quadratic',3,4,'What')", str(q)) + + def test__insert__field(self): + q = Q.from_(self.t).select(fn.Insert(self.t.foo, 3, 4, self.t.bar)) + + self.assertEqual('SELECT INSERT("foo",3,4,"bar") FROM "abc"', str(q)) + + def test__lower__str(self): + q = Q.select(fn.Lower("ABC")) + + self.assertEqual("SELECT LOWER('ABC')", str(q)) + + def test__lower__field(self): + q = Q.from_(self.t).select(fn.Lower(self.t.foo)) + + self.assertEqual('SELECT LOWER("foo") FROM "abc"', str(q)) + + def test__length__str(self): + q = Q.select(fn.Length("ABC")) + + self.assertEqual("SELECT LENGTH('ABC')", str(q)) + + def test__length__field(self): + q = Q.from_(self.t).select(fn.Length(self.t.foo)) + + self.assertEqual('SELECT LENGTH("foo") FROM "abc"', str(q)) + + def test__substring(self): + q = Q.from_(self.t).select(fn.Substring(self.t.foo, 2, 6)) + + self.assertEqual('SELECT SUBSTRING("foo",2,6) FROM "abc"', str(q)) + + def test__replace__str(self): + q = Q.select(fn.Replace("ABC_DEF", "_", " ")) + self.assertEqual("SELECT REPLACE('ABC_DEF','_',' ')", str(q)) + + def test__replace__field(self): + q = Q.from_(self.t).select(fn.Replace(self.t.foobar, self.t.foo, self.t.bar)) + self.assertEqual('SELECT REPLACE("foobar","foo","bar") FROM "abc"', str(q)) + + +class SplitPartFunctionTests(unittest.TestCase): + t = T("abc") + + def test__split_part(self): + q = VerticaQuery.from_(self.t).select(fn.SplitPart(self.t.foo, "|", 3)) + + self.assertEqual('SELECT SPLIT_PART("foo",\'|\',3) FROM "abc"', str(q)) + + +class RegexpLikeFunctionTests(unittest.TestCase): + t = T("abc") + + def test__regexp_like(self): + q = VerticaQuery.from_(self.t).select(fn.RegexpLike(self.t.foo, "^a", "x")) + + self.assertEqual("SELECT REGEXP_LIKE(\"foo\",'^a','x') FROM \"abc\"", str(q)) + + +class CastTests(unittest.TestCase): + t = T("abc") + + def test__cast__as(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.UNSIGNED)) + + self.assertEqual('SELECT CAST("foo" AS UNSIGNED) FROM "abc"', str(q)) + + def test__cast__signed(self): + q1 = Q.from_(self.t).select(fn.Signed(self.t.foo)) + q2 = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.SIGNED)) + + self.assertEqual('SELECT CAST("foo" AS SIGNED) FROM "abc"', str(q1)) + self.assertEqual('SELECT CAST("foo" AS SIGNED) FROM "abc"', str(q2)) + + def test__cast__unsigned(self): + q1 = Q.from_(self.t).select(fn.Unsigned(self.t.foo)) + q2 = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.UNSIGNED)) + + self.assertEqual('SELECT CAST("foo" AS UNSIGNED) FROM "abc"', str(q1)) + self.assertEqual('SELECT CAST("foo" AS UNSIGNED) FROM "abc"', str(q2)) + + def test__cast__date(self): + q1 = Q.from_(self.t).select(fn.Date(self.t.foo)) + q2 = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.DATE)) + + self.assertEqual('SELECT DATE("foo") FROM "abc"', str(q1)) + self.assertEqual('SELECT CAST("foo" AS DATE) FROM "abc"', str(q2)) + + def test__cast__timestamp(self): + q1 = Q.from_(self.t).select(fn.Timestamp(self.t.foo)) + q2 = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.TIMESTAMP)) + + self.assertEqual('SELECT TIMESTAMP("foo") FROM "abc"', str(q1)) + self.assertEqual('SELECT CAST("foo" AS TIMESTAMP) FROM "abc"', str(q2)) + + def test__cast__char(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.CHAR)) + + self.assertEqual('SELECT CAST("foo" AS CHAR) FROM "abc"', str(q)) + + def test__cast__char_with_arg(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.VARCHAR(24))) + + self.assertEqual('SELECT CAST("foo" AS VARCHAR(24)) FROM "abc"', str(q)) + + def test__cast__varchar(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.VARCHAR)) + + self.assertEqual('SELECT CAST("foo" AS VARCHAR) FROM "abc"', str(q)) + + def test__cast__varchar_with_arg(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.VARCHAR(24))) + + self.assertEqual('SELECT CAST("foo" AS VARCHAR(24)) FROM "abc"', str(q)) + + def test__cast__long_varchar(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.LONG_VARCHAR)) + + self.assertEqual('SELECT CAST("foo" AS LONG VARCHAR) FROM "abc"', str(q)) + + def test__cast__long_varchar_with_arg(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.LONG_VARCHAR(24))) + + self.assertEqual('SELECT CAST("foo" AS LONG VARCHAR(24)) FROM "abc"', str(q)) + + def test__cast__binary(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.BINARY)) + + self.assertEqual('SELECT CAST("foo" AS BINARY) FROM "abc"', str(q)) + + def test__cast__binary_with_arg(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.BINARY(24))) + + self.assertEqual('SELECT CAST("foo" AS BINARY(24)) FROM "abc"', str(q)) + + def test__cast__varbinary(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.VARBINARY)) + + self.assertEqual('SELECT CAST("foo" AS VARBINARY) FROM "abc"', str(q)) + + def test__cast__varbinary_with_arg(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.VARBINARY(24))) + + self.assertEqual('SELECT CAST("foo" AS VARBINARY(24)) FROM "abc"', str(q)) + + def test__cast__long_varbinary(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.LONG_VARBINARY)) + + self.assertEqual('SELECT CAST("foo" AS LONG VARBINARY) FROM "abc"', str(q)) + + def test__cast__long_varbinary_with_arg(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.LONG_VARBINARY(24))) + + self.assertEqual('SELECT CAST("foo" AS LONG VARBINARY(24)) FROM "abc"', str(q)) + + def test__cast__boolean(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.BOOLEAN)) + + self.assertEqual('SELECT CAST("foo" AS BOOLEAN) FROM "abc"', str(q)) + + def test__cast__integer(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.INTEGER)) + + self.assertEqual('SELECT CAST("foo" AS INTEGER) FROM "abc"', str(q)) + + def test__cast__float(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.FLOAT)) + + self.assertEqual('SELECT CAST("foo" AS FLOAT) FROM "abc"', str(q)) + + def test__cast__numeric(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.NUMERIC)) + + self.assertEqual('SELECT CAST("foo" AS NUMERIC) FROM "abc"', str(q)) + + def test__tochar__(self): + q = Q.from_(self.t).select(fn.ToChar(self.t.foo, "SomeFormat")) + + self.assertEqual('SELECT TO_CHAR("foo",\'SomeFormat\') FROM "abc"', str(q)) + + +class DateFunctionsTests(unittest.TestCase): + dt = F("dt") + t = T("abc") + t2 = T("efg") + + def _test_extract_datepart(self, date_part): + q = Q.from_(self.t).select(fn.Extract(date_part, self.t.foo)) + + value = getattr(date_part, 'value', date_part) + self.assertEqual('SELECT EXTRACT(%s FROM "foo") FROM "abc"' % value, str(q)) + + def test_extract_microsecond(self): + self._test_extract_datepart(DatePart.microsecond) + self._test_extract_datepart(DatePart.microsecond.value) + + def test_extract_second(self): + self._test_extract_datepart(DatePart.second) + self._test_extract_datepart(DatePart.second.value) + + def test_extract_minute(self): + self._test_extract_datepart(DatePart.minute) + self._test_extract_datepart(DatePart.minute.value) + + def test_extract_hour(self): + self._test_extract_datepart(DatePart.hour) + self._test_extract_datepart(DatePart.hour.value) + + def test_extract_day(self): + self._test_extract_datepart(DatePart.day) + self._test_extract_datepart(DatePart.day.value) + + def test_extract_week(self): + self._test_extract_datepart(DatePart.week) + self._test_extract_datepart(DatePart.week.value) + + def test_extract_month(self): + self._test_extract_datepart(DatePart.month) + self._test_extract_datepart(DatePart.month.value) + + def test_extract_quarter(self): + self._test_extract_datepart(DatePart.quarter) + self._test_extract_datepart(DatePart.quarter.value) + + def test_extract_year(self): + self._test_extract_datepart(DatePart.year) + self._test_extract_datepart(DatePart.year.value) + + def test_extract_join(self): + q = Q.from_(self.t).join(self.t2).on(self.t.id == self.t2.t_id).select(fn.Extract(DatePart.year, self.t.foo)) + + self.assertEqual( + 'SELECT EXTRACT(YEAR FROM "abc"."foo") FROM "abc" ' 'JOIN "efg" ON "abc"."id"="efg"."t_id"', str(q) + ) + + def test_timestampadd(self): + a = fn.TimestampAdd("year", 1, "2017-10-01") + self.assertEqual(str(a), "TIMESTAMPADD(year,1,'2017-10-01')") + + def test_time_diff(self): + a = fn.TimeDiff("18:00:00", "10:00:00") + self.assertEqual(str(a), "TIMEDIFF('18:00:00','10:00:00')") + + def test_date_add(self): + a = fn.DateAdd("year", 1, "2017-10-01") + self.assertEqual(str(a), "DATE_ADD(year,1,'2017-10-01')") + + def test_now(self): + query = Query.select(fn.Now()) + + self.assertEqual("SELECT NOW()", str(query)) + + def test_utc_timestamp(self): + query = Query.select(fn.UtcTimestamp()) + + self.assertEqual("SELECT UTC_TIMESTAMP()", str(query)) + + def test_current_date(self): + query = Query.select(fn.CurDate()) + + self.assertEqual("SELECT CURRENT_DATE()", str(query)) + + def test_current_time(self): + query = Query.select(fn.CurTime()) + + self.assertEqual("SELECT CURRENT_TIME()", str(query)) + + def test_current_timestamp(self): + query = Query.select(fn.CurTimestamp()) + + self.assertEqual("SELECT CURRENT_TIMESTAMP", str(query)) + + def test_current_timestamp_with_alias(self): + query = Query.select(fn.CurTimestamp("ts")) + + self.assertEqual('SELECT CURRENT_TIMESTAMP "ts"', str(query)) + + def test_to_date(self): + q1 = fn.ToDate("2019-06-21", "yyyy-mm-dd") + q2 = Query.from_(self.t).select(fn.ToDate("2019-06-21", "yyyy-mm-dd")) + q3 = Query.from_(self.t).select(fn.ToDate(F("foo"), "yyyy-mm-dd")) + + self.assertEqual(str(q1), "TO_DATE('2019-06-21','yyyy-mm-dd')") + self.assertEqual(str(q2), "SELECT TO_DATE('2019-06-21','yyyy-mm-dd') FROM \"abc\"") + self.assertEqual(str(q3), 'SELECT TO_DATE("foo",\'yyyy-mm-dd\') FROM "abc"') + + +class NullFunctionsTests(unittest.TestCase): + def test_isnull(self): + q = Q.from_("abc").select(fn.IsNull(F("foo"))) + + self.assertEqual('SELECT ISNULL("foo") FROM "abc"', str(q)) + + def test_coalesce(self): + q = Q.from_("abc").select(fn.Coalesce(F("foo"), 0)) + + self.assertEqual('SELECT COALESCE("foo",0) FROM "abc"', str(q)) + + def test_nullif(self): + q = Q.from_("abc").select(fn.NullIf(F("foo"), 0)) + + self.assertEqual('SELECT NULLIF("foo",0) FROM "abc"', str(q)) + + def test_nvl(self): + q = Q.from_("abc").select(fn.NVL(F("foo"), 0)) + + self.assertEqual('SELECT NVL("foo",0) FROM "abc"', str(q)) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/test_groupby_modifiers.py b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/test_groupby_modifiers.py new file mode 100644 index 0000000000000000000000000000000000000000..978834c2409f4b4800fedb9b1bb2538a31d0f31c --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/test_groupby_modifiers.py @@ -0,0 +1,168 @@ +import unittest + +from pypika import Query, Rollup, RollupException, Table, functions as fn + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + + +class RollupTests(unittest.TestCase): + table = Table("abc") + + def test_mysql_one_groupby(self): + q = ( + Query.from_(self.table) + .select(self.table.foo, fn.Sum(self.table.bar)) + .rollup(self.table.foo, vendor="mysql") + ) + + self.assertEqual('SELECT "foo",SUM("bar") FROM "abc" GROUP BY "foo" WITH ROLLUP', str(q)) + + def test_mysql_rollup_two_groupbys(self): + q = ( + Query.from_(self.table) + .select(self.table.foo, self.table.fiz, fn.Sum(self.table.bar)) + .rollup(self.table.foo, self.table.fiz, vendor="mysql") + ) + + self.assertEqual( + 'SELECT "foo","fiz",SUM("bar") FROM "abc" GROUP BY "foo","fiz" WITH ROLLUP', + str(q), + ) + + def test_no_rollup_before_groupby(self): + with self.assertRaises(RollupException): + Query.from_(self.table).select(self.table.foo, fn.Sum(self.table.bar)).rollup(vendor="mysql") + + def test_no_rollup_after_rollup_mysql(self): + with self.assertRaises(AttributeError): + Query.from_(self.table).select(self.table.foo, self.table.fiz, fn.Sum(self.table.bar)).rollup( + self.table.foo, vendor="mysql" + ).rollup(self.table.fiz, vendor="mysql") + + def test_verticaoracle_func_one_groupby(self): + q = Query.from_(self.table).select(self.table.foo, fn.Sum(self.table.bar)).groupby(Rollup(self.table.foo)) + + self.assertEqual('SELECT "foo",SUM("bar") FROM "abc" GROUP BY ROLLUP("foo")', str(q)) + + def test_verticaoracle_func_two_groupbys(self): + q = ( + Query.from_(self.table) + .select(self.table.foo, self.table.fiz, fn.Sum(self.table.bar)) + .groupby( + Rollup( + self.table.foo, + self.table.fiz, + ) + ) + ) + + self.assertEqual( + 'SELECT "foo","fiz",SUM("bar") FROM "abc" GROUP BY ROLLUP("foo","fiz")', + str(q), + ) + + def test_verticaoracle_func_partial(self): + q = ( + Query.from_(self.table) + .select(self.table.foo, self.table.fiz, self.table.buz, fn.Sum(self.table.bar)) + .groupby( + Rollup( + self.table.foo, + self.table.fiz, + ), + self.table.buz, + ) + ) + + self.assertEqual( + 'SELECT "foo","fiz","buz",SUM("bar") FROM "abc" GROUP BY ROLLUP("foo","fiz"),"buz"', + str(q), + ) + + def test_verticaoracle_from_groupbys(self): + q = Query.from_(self.table).select(self.table.foo, fn.Sum(self.table.bar)).rollup(self.table.foo) + + self.assertEqual('SELECT "foo",SUM("bar") FROM "abc" GROUP BY ROLLUP("foo")', str(q)) + + def test_verticaoracle_from_two_groupbys(self): + q = ( + Query.from_(self.table) + .select(self.table.foo, self.table.fiz, fn.Sum(self.table.bar)) + .rollup( + self.table.foo, + self.table.fiz, + ) + ) + + self.assertEqual( + 'SELECT "foo","fiz",SUM("bar") FROM "abc" GROUP BY ROLLUP("foo","fiz")', + str(q), + ) + + def test_verticaoracle_from_parameters(self): + q = ( + Query.from_(self.table) + .select(self.table.foo, self.table.fiz, fn.Sum(self.table.bar)) + .groupby( + self.table.foo, + ) + .rollup( + self.table.fiz, + ) + ) + + self.assertEqual( + 'SELECT "foo","fiz",SUM("bar") FROM "abc" GROUP BY "foo",ROLLUP("fiz")', + str(q), + ) + + def test_verticaoracle_multiple_rollups(self): + q = ( + Query.from_(self.table) + .select(self.table.foo, self.table.fiz, fn.Sum(self.table.bar)) + .rollup( + self.table.foo, + ) + .rollup( + self.table.fiz, + ) + ) + + self.assertEqual( + 'SELECT "foo","fiz",SUM("bar") FROM "abc" GROUP BY ROLLUP("foo","fiz")', + str(q), + ) + + def test_verticaoracle_rollups_with_parity(self): + q = ( + Query.from_(self.table) + .select( + self.table.buz, + ) + .rollup( + [self.table.foo, self.table.bar], + self.table.fiz, + ) + ) + + self.assertEqual('SELECT "buz" FROM "abc" GROUP BY ROLLUP(("foo","bar"),"fiz")', str(q)) + + def test_verticaoracle_rollups_with_multiple_rollups_and_parity(self): + q = ( + Query.from_(self.table) + .select( + self.table.buz, + ) + .rollup( + [self.table.foo, self.table.bar], + ) + .rollup( + [self.table.fiz, self.table.buz], + ) + ) + + self.assertEqual( + 'SELECT "buz" FROM "abc" GROUP BY ROLLUP(("foo","bar"),("fiz","buz"))', + str(q), + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/test_immutability.py b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/test_immutability.py new file mode 100644 index 0000000000000000000000000000000000000000..ee539bfa1e9c4509b929e7a86a03f098dd923515 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/test_immutability.py @@ -0,0 +1,99 @@ +import unittest + +from pypika import ( + AliasedQuery, + Query, + Tables, +) + + +class ImmutabilityTests(unittest.TestCase): + table_a, table_b, table_c = Tables("a", "b", "c") + + def test_select_returns_new_query_instance(self): + query_a = Query.from_(self.table_a).select(self.table_a.foo) + query_b = query_a.select(self.table_a.bar) + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_groupby_returns_new_query_instance(self): + query_a = Query.from_(self.table_a).select(self.table_a.foo).groupby(self.table_a.foo) + query_b = query_a.groupby(self.table_a.bar) + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_orderby_return_new_query_instance(self): + query_a = Query.from_(self.table_a).select(self.table_a.foo).orderby(self.table_a.foo) + query_b = query_a.orderby(self.table_a.bar) + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_join_return_new_query_instance(self): + base = Query.from_(self.table_a).select(self.table_a.foo) + query_a = base.join(self.table_b).on(self.table_a.foo == self.table_b.bar).select(self.table_b.bar) + query_b = query_a.join(self.table_c).on(self.table_a.foo == self.table_c.baz).select(self.table_c.baz) + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_use_index_return_new_query_instance(self): + query_a = Query.from_(self.table_a).select(self.table_a.foo).use_index('idx1') + query_b = query_a.use_index('idx2') + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_force_index_return_new_query_instance(self): + query_a = Query.from_(self.table_a).select(self.table_a.foo).force_index('idx1') + query_b = query_a.force_index('idx2') + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_with_return_new_query_instance(self): + alias_1 = Query.from_(self.table_a).select(self.table_a.foo) + alias_2 = Query.from_(self.table_b).select(self.table_b.bar) + query_a = Query.from_(AliasedQuery('a1')).select('foo').with_(alias_1, 'a1') + query_b = query_a.with_(alias_2, 'a2') + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_insert_into_return_new_query_instance(self): + query_a = Query.into(self.table_a).insert('foo1') + query_b = query_a.insert('foo2') + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_replace_into_return_new_query_instance(self): + query_a = Query.into(self.table_a).replace('foo') + query_b = query_a.replace('bar') + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_update_set_return_new_query_instance(self): + query_a = Query.update(self.table_a).set(self.table_a.foo, 'foo') + query_b = query_a.set(self.table_a.bar, 'bar') + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_queries_after_join(self): + query1 = Query.from_(self.table_a).select(self.table_a.foo) + query2 = query1.join(self.table_b).on(self.table_a.foo == self.table_b.bar).select(self.table_b.buz) + + self.assertEqual('SELECT "foo" FROM "a"', str(query1)) + self.assertEqual( + 'SELECT "a"."foo","b"."buz" FROM "a" JOIN "b" ON "a"."foo"="b"."bar"', + str(query2), + ) + + def test_immutable_kwarg_on_query_builder_disables_immutability(self): + query0 = Query.from_(self.table_a, immutable=False) + query1 = query0.select(self.table_a.foo) + self.assertIs(query0, query1) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/test_inserts.py b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/test_inserts.py new file mode 100644 index 0000000000000000000000000000000000000000..f86efd7a76dc498a69b61c6353951695f1933a61 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/test_inserts.py @@ -0,0 +1,885 @@ +import unittest + +from pypika import ( + AliasedQuery, + Case, + Field as F, + MySQLQuery, + PostgreSQLQuery, + Query, + Table, + Tables, + functions as fn, +) +from pypika.functions import ( + Avg, + Cast, +) +from pypika.terms import Values +from pypika.utils import QueryException + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + + +class InsertIntoTests(unittest.TestCase): + table_abc = Table("abc") + + def test_insert_one_column(self): + query = Query.into(self.table_abc).insert(1) + + self.assertEqual('INSERT INTO "abc" VALUES (1)', str(query)) + + def test_insert_one_column_single_element_array(self): + query = Query.into(self.table_abc).insert((1,)) + + self.assertEqual('INSERT INTO "abc" VALUES (1)', str(query)) + + def test_insert_one_column_multi_element_array(self): + query = Query.into(self.table_abc).insert((1,), (2,)) + + self.assertEqual('INSERT INTO "abc" VALUES (1),(2)', str(query)) + + def test_insert_single_row_with_array_value(self): + query = Query.into(self.table_abc).insert(1, ["a", "b", "c"]) + + self.assertEqual("INSERT INTO \"abc\" VALUES (1,['a','b','c'])", str(query)) + + def test_insert_multiple_rows_with_array_value(self): + query = Query.into(self.table_abc).insert( + (1, ["a", "b", "c"]), + (2, ["c", "d", "e"]), + ) + + self.assertEqual( + 'INSERT INTO "abc" ' "VALUES (1,['a','b','c']),(2,['c','d','e'])", + str(query), + ) + + def test_insert_all_columns(self): + query = Query.into(self.table_abc).insert(1, "a", True) + + self.assertEqual("INSERT INTO \"abc\" VALUES (1,'a',true)", str(query)) + + def test_insert_all_columns_single_element(self): + query = Query.into(self.table_abc).insert((1, "a", True)) + + self.assertEqual("INSERT INTO \"abc\" VALUES (1,'a',true)", str(query)) + + def test_insert_all_columns_multi_rows(self): + query = Query.into(self.table_abc).insert((1, "a", True), (2, "b", False)) + + self.assertEqual("INSERT INTO \"abc\" VALUES (1,'a',true),(2,'b',false)", str(query)) + + def test_insert_all_columns_multi_rows_chained(self): + query = Query.into(self.table_abc).insert(1, "a", True).insert(2, "b", False) + + self.assertEqual("INSERT INTO \"abc\" VALUES (1,'a',true),(2,'b',false)", str(query)) + + def test_insert_all_columns_multi_rows_chained_mixed(self): + query = Query.into(self.table_abc).insert((1, "a", True), (2, "b", False)).insert(3, "c", True) + + self.assertEqual( + 'INSERT INTO "abc" VALUES ' "(1,'a',true),(2,'b',false)," "(3,'c',true)", + str(query), + ) + + def test_insert_all_columns_multi_rows_chained_multiple_rows(self): + query = ( + Query.into(self.table_abc).insert((1, "a", True), (2, "b", False)).insert((3, "c", True), (4, "d", False)) + ) + + self.assertEqual( + 'INSERT INTO "abc" VALUES ' "(1,'a',true),(2,'b',false)," "(3,'c',true),(4,'d',false)", + str(query), + ) + + def test_insert_selected_columns(self): + query = ( + Query.into(self.table_abc) + .columns(self.table_abc.foo, self.table_abc.bar, self.table_abc.buz) + .insert(1, "a", True) + ) + + self.assertEqual('INSERT INTO "abc" ("foo","bar","buz") VALUES (1,\'a\',true)', str(query)) + + def test_insert_empty_columns(self): + query = Query.into(self.table_abc).columns().insert(1, "a", True) + + self.assertEqual('INSERT INTO "abc" VALUES (1,\'a\',true)', str(query)) + + def test_insert_selected_columns_type_list(self): + query = ( + Query.into(self.table_abc) + .columns([self.table_abc.foo, self.table_abc.bar, self.table_abc.buz]) + .insert(1, "a", True) + ) + + self.assertEqual('INSERT INTO "abc" ("foo","bar","buz") VALUES (1,\'a\',true)', str(query)) + + def test_insert_empty_columns_type_list(self): + query = Query.into(self.table_abc).columns([]).insert(1, "a", True) + + self.assertEqual('INSERT INTO "abc" VALUES (1,\'a\',true)', str(query)) + + def test_insert_selected_columns_type_tuple(self): + query = ( + Query.into(self.table_abc) + .columns((self.table_abc.foo, self.table_abc.bar, self.table_abc.buz)) + .insert(1, "a", True) + ) + + self.assertEqual('INSERT INTO "abc" ("foo","bar","buz") VALUES (1,\'a\',true)', str(query)) + + def test_insert_empty_columns_type_tuple(self): + query = Query.into(self.table_abc).columns(()).insert(1, "a", True) + + self.assertEqual('INSERT INTO "abc" VALUES (1,\'a\',true)', str(query)) + + def test_insert_none_skipped(self): + query = Query.into(self.table_abc).insert() + + self.assertEqual("", str(query)) + + def test_insert_ignore(self): + query = Query.into(self.table_abc).insert(1).ignore() + + self.assertEqual('INSERT IGNORE INTO "abc" VALUES (1)', str(query)) + + def test_insert_null(self): + query = Query.into(self.table_abc).insert(None) + + self.assertEqual('INSERT INTO "abc" VALUES (NULL)', str(query)) + + def test_insert_column_using_table_alias(self): + q = self.table_abc.insert(1) + self.assertEqual('INSERT INTO "abc" VALUES (1)', str(q)) + + def test_insert_column_using_alias_with_chain(self): + q = self.table_abc.insert(1, "a", True).insert(2, "b", False) + self.assertEqual("INSERT INTO \"abc\" VALUES (1,'a',true),(2,'b',false)", str(q)) + + def test_insert_with_statement(self): + sub_query = Query().select(self.table_abc.id).from_(self.table_abc) + aliased = AliasedQuery('sub_qs') + + q = Query().with_(sub_query, 'sub_qs').into(self.table_abc).select(aliased.id).from_(aliased) + self.assertEqual( + 'WITH sub_qs AS (SELECT "id" FROM "abc") INSERT INTO "abc" SELECT "sub_qs"."id" FROM sub_qs', str(q) + ) + + +class PostgresInsertIntoOnConflictTests(unittest.TestCase): + table_abc = Table("abc") + + def test_insert_on_conflict_do_nothing_field(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).on_conflict(self.table_abc.id).do_nothing() + + self.assertEqual('INSERT INTO "abc" VALUES (1) ON CONFLICT ("id") DO NOTHING', str(query)) + + def test_insert_on_conflict_do_nothing_multiple_fields(self): + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1) + .on_conflict(self.table_abc.id, self.table_abc.sub_id) + .do_nothing() + ) + + self.assertEqual('INSERT INTO "abc" VALUES (1) ON CONFLICT ("id", "sub_id") DO NOTHING', str(query)) + + def test_insert_on_conflict_do_nothing_field_str(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).on_conflict("id").do_nothing() + + self.assertEqual('INSERT INTO "abc" VALUES (1) ON CONFLICT ("id") DO NOTHING', str(query)) + + def test_insert_on_conflict_do_nothing_multiple_fields_str(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).on_conflict("id", "sub_id").do_nothing() + + self.assertEqual('INSERT INTO "abc" VALUES (1) ON CONFLICT ("id", "sub_id") DO NOTHING', str(query)) + + def test_insert_on_conflict_do_nothing_mixed_fields(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).on_conflict("id", self.table_abc.sub_id).do_nothing() + + self.assertEqual('INSERT INTO "abc" VALUES (1) ON CONFLICT ("id", "sub_id") DO NOTHING', str(query)) + + def test_insert_on_conflict_do_update_field(self): + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict(self.table_abc.id) + .do_update(self.table_abc.name, "m") + ) + + self.assertEqual( + "INSERT INTO \"abc\" VALUES (1,'m') ON CONFLICT (\"id\") DO UPDATE SET \"name\"='m'", + str(query), + ) + + def test_insert_on_conflict_do_update_multiple_fields(self): + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict(self.table_abc.id, self.table_abc.sub_id) + .do_update(self.table_abc.name, "m") + ) + + self.assertEqual( + "INSERT INTO \"abc\" VALUES (1,'m') ON CONFLICT (\"id\", \"sub_id\") DO UPDATE SET \"name\"='m'", + str(query), + ) + + def test_insert_on_conflict_do_update_field_str(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1, "m").on_conflict("id").do_update("name", "m") + + self.assertEqual( + "INSERT INTO \"abc\" VALUES (1,'m') ON CONFLICT (\"id\") DO UPDATE SET \"name\"='m'", + str(query), + ) + + def test_insert_on_conflict_do_update_multiple_fields_str(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1, "m").on_conflict("id", "sub_id").do_update("name", "m") + + self.assertEqual( + "INSERT INTO \"abc\" VALUES (1,'m') ON CONFLICT (\"id\", \"sub_id\") DO UPDATE SET \"name\"='m'", + str(query), + ) + + def test_insert_on_conflict_do_update_multiple_mixed_fields(self): + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict("id", self.table_abc.sub_id) + .do_update("name", "m") + ) + + self.assertEqual( + "INSERT INTO \"abc\" VALUES (1,'m') ON CONFLICT (\"id\", \"sub_id\") DO UPDATE SET \"name\"='m'", + str(query), + ) + + def test_insert_on_conflict_no_handler(self): + with self.assertRaises(QueryException): + query = str(PostgreSQLQuery.into(self.table_abc).insert(1).on_conflict(self.table_abc.id)) + + def test_insert_on_conflict_two_handlers_do_nothing(self): + with self.assertRaises(QueryException): + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1) + .on_conflict("id") + .do_nothing() + .do_update(self.table_abc.name, "m") + ) + + def test_insert_on_conflict_two_handlers_do_update(self): + with self.assertRaises(QueryException): + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1) + .on_conflict(self.table_abc.id) + .do_update(self.table_abc.name, "m") + .do_nothing() + ) + + def test_non_insert_on_conflict_do_nothing(self): + with self.assertRaises(QueryException): + query = PostgreSQLQuery.update(self.table_abc).set("foo", "bar").on_conflict("id").do_nothing() + + def test_non_insert_on_conflict_do_update(self): + with self.assertRaises(QueryException): + query = ( + PostgreSQLQuery.update(self.table_abc).set("foo", "bar").on_conflict("id").do_update(["name"], ["m"]) + ) + + def test_insert_on_fieldless_conflict_do_nothing(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).on_conflict(None).do_nothing() + + self.assertEqual('INSERT INTO "abc" VALUES (1) ON CONFLICT DO NOTHING', str(query)) + + def test_insert_on_fieldless_conflict_do_update_field(self): + with self.assertRaises(QueryException): + query = str( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict(None) + .do_update(self.table_abc.name, "m") + ) + + def test_on_conflict_from_subquery(self): + table_bcd = Table('bcd') + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(self.table_abc.fname, self.table_abc.lname) + .select(table_bcd.fname, table_bcd.lname) + .from_(table_bcd) + .on_conflict(self.table_abc.id, self.table_abc.sub_id) + .do_update(self.table_abc.fname, 1) + .do_update(self.table_abc.lname, table_bcd.lname) + .do_update( + self.table_abc.cname, + Case().when(self.table_abc.cname.eq('cname'), 'new_name').else_(self.table_abc.cname), + ) + ) + + self.assertEqual( + 'INSERT INTO "abc" VALUES ("fname","lname") ' + 'ON CONFLICT ("id", "sub_id") ' + 'DO UPDATE SET "fname"=1,"lname"="bcd"."lname",' + '"cname"=CASE WHEN "abc"."cname"=\'cname\' THEN \'new_name\' ELSE "abc"."cname" END', + str(query), + ) + + def test_on_conflict_where_empty_conflict_fields_do_nothing(self): + with self.assertRaises(QueryException): + ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict() + .where(self.table_abc.abc.eq(0)) + .where(self.table_abc.cde.eq(0)) + .do_nothing() + ) + + def test_on_conflict_where_conflict_fields_do_nothing(self): + qs = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict('id') + .where(self.table_abc.abc.eq(0)) + .where(self.table_abc.cde.eq(0)) + .do_nothing() + ) + self.assertEqual( + '''INSERT INTO "abc" VALUES (1,'m') ON CONFLICT ("id") WHERE "abc"=0 AND "cde"=0 DO NOTHING''', str(qs) + ) + + def test_on_conflict_where_empty_conflict_fields_do_update(self): + with self.assertRaises(QueryException): + ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict() + .where(self.table_abc.abc.eq(0)) + .where(self.table_abc.cde.eq(0)) + .do_update('field', 'val') + ) + + def test_on_conflict_where_conflict_fields_do_update(self): + qs = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict('id') + .where(self.table_abc.abc.eq(0)) + .where(self.table_abc.cde.eq(0)) + .do_update('field', 'val') + ) + self.assertEqual( + '''INSERT INTO "abc" VALUES (1,'m') ON CONFLICT ("id") WHERE "abc"=0 AND "cde"=0 ''' + '''DO UPDATE SET "field"='val\'''', + str(qs), + ) + + def test_where_and_on_conflict_where(self): + table_bcd = Table('bcd') + + qs = ( + PostgreSQLQuery.into(self.table_abc) + .select(table_bcd.abc) + .from_(table_bcd) + .where(table_bcd.abc.eq('1')) + .on_conflict('id') + .where(self.table_abc.abc.eq(0)) + .where(self.table_abc.cde.eq(0)) + .do_update('field', 'val') + ) + + self.assertEqual( + 'INSERT INTO "abc" SELECT "abc" FROM "bcd" WHERE "abc"=\'1\' ' + 'ON CONFLICT ("id") WHERE "abc"=0 AND "cde"=0 DO UPDATE SET "field"=\'val\'', + str(qs), + ) + + def test_on_conflict_do_nothing_where(self): + with self.assertRaises(QueryException): + ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict() + .do_nothing() + .where(self.table_abc.abc.eq(1)) + ) + + def test_empty_on_conflict_do_update_where(self): + with self.assertRaises(QueryException): + ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict() + .do_update('abc', 1) + .where(self.table_abc.abc.eq(1)) + ) + + def test_on_conflict_do_update_where(self): + qs = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict("id") + .do_update('abc', 1) + .where(self.table_abc.abc.eq(1)) + ) + self.assertEqual( + 'INSERT INTO "abc" VALUES (1,\'m\') ON CONFLICT ("id") DO UPDATE SET "abc"=1 WHERE "abc"."abc"=1', str(qs) + ) + + def test_on_conflict_do_update_with_excluded_where(self): + qs = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict("id") + .do_update('abc') + .where(self.table_abc.abc.eq(1)) + ) + self.assertEqual( + 'INSERT INTO "abc" VALUES (1,\'m\') ON CONFLICT ("id") DO UPDATE SET "abc"=EXCLUDED."abc" WHERE ' + '"abc"."abc"=1', + str(qs), + ) + + def test_on_conflict_where_complex(self): + table_bcd = Table('bcd') + + qs = ( + PostgreSQLQuery.into(self.table_abc) + .select(table_bcd.abc) + .from_(table_bcd) + .where(table_bcd.abc.eq('1')) + .on_conflict('id') + .where(self.table_abc.abc.eq(0)) + .where(self.table_abc.cde.eq(0)) + .do_update('field', 'val') + .where(self.table_abc.id.eq(2)) + .where(self.table_abc.sub_id.eq(3)) + ) + self.assertEqual( + 'INSERT INTO "abc" SELECT "abc" FROM "bcd" WHERE "abc"=\'1\' ' + 'ON CONFLICT ("id") WHERE "abc"=0 AND "cde"=0 ' + 'DO UPDATE SET "field"=\'val\' WHERE "abc"."id"=2 AND "abc"."sub_id"=3', + str(qs), + ) + + +class PostgresInsertIntoReturningTests(unittest.TestCase): + table_abc = Table("abc") + + def test_insert_returning_one_field(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).returning(self.table_abc.id) + + self.assertEqual('INSERT INTO "abc" VALUES (1) RETURNING "id"', str(query)) + + def test_insert_returning_one_field_str(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).returning("id") + + self.assertEqual('INSERT INTO "abc" VALUES (1) RETURNING "id"', str(query)) + + def test_insert_returning_all_fields(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).returning(self.table_abc.star) + + self.assertEqual('INSERT INTO "abc" VALUES (1) RETURNING *', str(query)) + + def test_insert_returning_all_fields_and_arithmetics(self): + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1) + .returning(self.table_abc.star, self.table_abc.f1 + self.table_abc.f2) + ) + + self.assertEqual('INSERT INTO "abc" VALUES (1) RETURNING *,"f1"+"f2"', str(query)) + + def test_insert_all_columns_multi_rows_chained_returning_star(self): + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "a", True) + .insert(2, "b", False) + .returning(self.table_abc.star) + ) + + self.assertEqual( + "INSERT INTO \"abc\" VALUES (1,'a',true),(2,'b',false) RETURNING *", + str(query), + ) + + def test_insert_all_columns_multi_rows_chained_returning_star_and_id(self): + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "a", True) + .insert(2, "b", False) + .returning( + self.table_abc.name, + self.table_abc.star, + self.table_abc.id, + ) + ) + + self.assertEqual( + "INSERT INTO \"abc\" VALUES (1,'a',true),(2,'b',false) RETURNING *", + str(query), + ) + + def test_insert_all_columns_multi_rows_chained_returning_star_str(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1, "a", True).insert(2, "b", False).returning("*") + + self.assertEqual( + "INSERT INTO \"abc\" VALUES (1,'a',true),(2,'b',false) RETURNING *", + str(query), + ) + + def test_insert_all_columns_single_element_arrays(self): + query = PostgreSQLQuery.into(self.table_abc).insert((1, "a", True)).returning(self.table_abc.star) + + self.assertEqual("INSERT INTO \"abc\" VALUES (1,'a',true) RETURNING *", str(query)) + + def test_insert_returning_null(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).returning(None) + + self.assertEqual('INSERT INTO "abc" VALUES (1) RETURNING NULL', str(query)) + + def test_insert_returning_tuple(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).returning((1, 2, 3)) + + self.assertEqual('INSERT INTO "abc" VALUES (1) RETURNING (1,2,3)', str(query)) + + def test_insert_returning_arithmetics(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).returning(self.table_abc.f1 + self.table_abc.f2) + + self.assertEqual('INSERT INTO "abc" VALUES (1) RETURNING "f1"+"f2"', str(query)) + + def test_insert_returning_functions(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).returning(Cast(self.table_abc.f1, "int")) + + self.assertEqual('INSERT INTO "abc" VALUES (1) RETURNING CAST("f1" AS INT)', str(query)) + + def test_insert_returning_aggregate(self): + with self.assertRaises(QueryException): + PostgreSQLQuery.into(self.table_abc).insert(1).returning(Avg(self.table_abc.views)) + + def test_insert_returning_from_other_table(self): + table_cba = Table("cba") + with self.assertRaises(QueryException): + PostgreSQLQuery.into(self.table_abc).insert(1).returning(table_cba.id) + + +class InsertIntoOnDuplicateTests(unittest.TestCase): + table_abc = Table("abc") + + def test_insert_one_column(self): + query = ( + MySQLQuery.into(self.table_abc).insert(1).on_duplicate_key_update(self.table_abc.foo, self.table_abc.foo) + ) + self.assertEqual( + "INSERT INTO `abc` VALUES (1) ON DUPLICATE KEY UPDATE `foo`=`foo`", + str(query), + ) + + def test_insert_one_column_using_values(self): + query = ( + MySQLQuery.into(self.table_abc) + .insert(1) + .on_duplicate_key_update(self.table_abc.foo, Values(self.table_abc.foo)) + ) + self.assertEqual( + "INSERT INTO `abc` VALUES (1) ON DUPLICATE KEY UPDATE `foo`=VALUES(`foo`)", + str(query), + ) + + def test_insert_one_column_single_element_array(self): + query = ( + MySQLQuery.into(self.table_abc).insert((1,)).on_duplicate_key_update(self.table_abc.foo, self.table_abc.foo) + ) + + self.assertEqual( + "INSERT INTO `abc` VALUES (1) ON DUPLICATE KEY UPDATE `foo`=`foo`", + str(query), + ) + + def test_insert_one_column_multi_element_array(self): + query = ( + MySQLQuery.into(self.table_abc) + .insert((1,), (2,)) + .on_duplicate_key_update(self.table_abc.foo, self.table_abc.foo) + ) + + self.assertEqual( + "INSERT INTO `abc` VALUES (1),(2) ON DUPLICATE KEY UPDATE `foo`=`foo`", + str(query), + ) + + def test_insert_multiple_columns_on_duplicate_update_one_with_same_value(self): + query = ( + MySQLQuery.into(self.table_abc) + .insert(1, "a") + .on_duplicate_key_update(self.table_abc.bar, Values(self.table_abc.bar)) + ) + + self.assertEqual( + "INSERT INTO `abc` VALUES (1,'a') ON DUPLICATE KEY UPDATE `bar`=VALUES(`bar`)", + str(query), + ) + + def test_insert_multiple_columns_on_duplicate_update_one_with_different_value(self): + query = MySQLQuery.into(self.table_abc).insert(1, "a").on_duplicate_key_update(self.table_abc.bar, "b") + + self.assertEqual( + "INSERT INTO `abc` VALUES (1,'a') ON DUPLICATE KEY UPDATE `bar`='b'", + str(query), + ) + + def test_insert_multiple_columns_on_duplicate_update_one_with_expression(self): + query = ( + MySQLQuery.into(self.table_abc).insert(1, 2).on_duplicate_key_update(self.table_abc.bar, 4 + F("bar")) + ) # todo sql expression? not python + + self.assertEqual( + "INSERT INTO `abc` VALUES (1,2) ON DUPLICATE KEY UPDATE `bar`=4+`bar`", + str(query), + ) + + def test_insert_multiple_columns_on_duplicate_update_one_with_expression_using_original_field_value( + self, + ): + query = ( + MySQLQuery.into(self.table_abc) + .insert(1, "a") + .on_duplicate_key_update(self.table_abc.bar, fn.Concat(self.table_abc.bar, "update")) + ) + + self.assertEqual( + "INSERT INTO `abc` VALUES (1,'a') ON DUPLICATE KEY UPDATE `bar`=CONCAT(`bar`,'update')", + str(query), + ) + + def test_insert_multiple_columns_on_duplicate_update_one_with_expression_using_values( + self, + ): + query = ( + MySQLQuery.into(self.table_abc) + .insert(1, "a") + .on_duplicate_key_update(self.table_abc.bar, fn.Concat(Values(self.table_abc.bar), "update")) + ) + + self.assertEqual( + "INSERT INTO `abc` VALUES (1,'a') ON DUPLICATE KEY UPDATE `bar`=CONCAT(VALUES(`bar`),'update')", + str(query), + ) + + def test_insert_multiple_columns_on_duplicate_update_multiple(self): + query = ( + MySQLQuery.into(self.table_abc) + .insert(1, "a", "b") + .on_duplicate_key_update(self.table_abc.bar, "b") + .on_duplicate_key_update(self.table_abc.baz, "c") + ) + + self.assertEqual( + "INSERT INTO `abc` VALUES (1,'a','b') ON DUPLICATE KEY UPDATE `bar`='b',`baz`='c'", + str(query), + ) + + def test_insert_multi_rows_chained_mixed_on_duplicate_update_multiple(self): + query = ( + MySQLQuery.into(self.table_abc) + .insert((1, "a", True), (2, "b", False)) + .insert(3, "c", True) + .on_duplicate_key_update(self.table_abc.foo, self.table_abc.foo) + .on_duplicate_key_update(self.table_abc.bar, Values(self.table_abc.bar)) + ) + + self.assertEqual( + "INSERT INTO `abc` VALUES (1,'a',true),(2,'b',false),(3,'c',true) " + "ON DUPLICATE KEY UPDATE `foo`=`foo`,`bar`=VALUES(`bar`)", + str(query), + ) + + def test_insert_selected_columns_on_duplicate_update_one(self): + query = ( + MySQLQuery.into(self.table_abc) + .columns(self.table_abc.foo, self.table_abc.bar, self.table_abc.baz) + .insert(1, "a", True) + .on_duplicate_key_update(self.table_abc.baz, False) + ) + + self.assertEqual( + "INSERT INTO `abc` (`foo`,`bar`,`baz`) VALUES (1,'a',true) ON DUPLICATE KEY UPDATE `baz`=false", + str(query), + ) + + def test_insert_selected_columns_on_duplicate_update_multiple(self): + query = ( + MySQLQuery.into(self.table_abc) + .columns(self.table_abc.foo, self.table_abc.bar, self.table_abc.baz) + .insert(1, "a", True) + .on_duplicate_key_update(self.table_abc.baz, False) + .on_duplicate_key_update(self.table_abc.bar, Values(self.table_abc.bar)) + ) + + self.assertEqual( + "INSERT INTO `abc` (`foo`,`bar`,`baz`) VALUES (1,'a',true) " + "ON DUPLICATE KEY UPDATE `baz`=false,`bar`=VALUES(`bar`)", + str(query), + ) + + def test_insert_none_skipped(self): + query = MySQLQuery.into(self.table_abc).insert().on_duplicate_key_update(self.table_abc.baz, False) + + self.assertEqual("", str(query)) + + def test_insert_ignore(self): + query = MySQLQuery.into(self.table_abc).insert(1).ignore().on_duplicate_key_update(self.table_abc.baz, False) + + self.assertEqual( + "INSERT IGNORE INTO `abc` VALUES (1) ON DUPLICATE KEY UPDATE `baz`=false", + str(query), + ) + + +class InsertSelectFromTests(unittest.TestCase): + table_abc, table_efg, table_hij = Tables("abc", "efg", "hij") + + def test_insert_star(self): + query = Query.into(self.table_abc).from_(self.table_efg).select("*") + + self.assertEqual('INSERT INTO "abc" SELECT * FROM "efg"', str(query)) + + def test_insert_ignore_star(self): + query = Query.into(self.table_abc).from_(self.table_efg).select("*").ignore() + + self.assertEqual('INSERT IGNORE INTO "abc" SELECT * FROM "efg"', str(query)) + + def test_insert_from_columns(self): + query = ( + Query.into(self.table_abc) + .from_(self.table_efg) + .select(self.table_efg.fiz, self.table_efg.buz, self.table_efg.baz) + ) + + self.assertEqual('INSERT INTO "abc" ' 'SELECT "fiz","buz","baz" FROM "efg"', str(query)) + + def test_insert_columns_from_star(self): + query = ( + Query.into(self.table_abc) + .columns( + self.table_abc.foo, + self.table_abc.bar, + self.table_abc.buz, + ) + .from_(self.table_efg) + .select("*") + ) + + self.assertEqual('INSERT INTO "abc" ("foo","bar","buz") ' 'SELECT * FROM "efg"', str(query)) + + def test_insert_columns_from_columns(self): + query = ( + Query.into(self.table_abc) + .columns(self.table_abc.foo, self.table_abc.bar, self.table_abc.buz) + .from_(self.table_efg) + .select(self.table_efg.fiz, self.table_efg.buz, self.table_efg.baz) + ) + + self.assertEqual( + 'INSERT INTO "abc" ("foo","bar","buz") ' 'SELECT "fiz","buz","baz" FROM "efg"', + str(query), + ) + + def test_insert_columns_from_columns_with_join(self): + query = ( + Query.into(self.table_abc) + .columns( + self.table_abc.c1, + self.table_abc.c2, + self.table_abc.c3, + self.table_abc.c4, + ) + .from_(self.table_efg) + .select(self.table_efg.foo, self.table_efg.bar) + .join(self.table_hij) + .on(self.table_efg.id == self.table_hij.abc_id) + .select(self.table_hij.fiz, self.table_hij.buz) + ) + + self.assertEqual( + 'INSERT INTO "abc" ("c1","c2","c3","c4") ' + 'SELECT "efg"."foo","efg"."bar","hij"."fiz","hij"."buz" FROM "efg" ' + 'JOIN "hij" ON "efg"."id"="hij"."abc_id"', + str(query), + ) + + +class InsertSubqueryTests(unittest.TestCase): + def test_insert_subquery_wrapped_in_brackets(self): + purchase_order_item, part = Tables("purchase_order_item", "part") + + q = ( + Query.into(purchase_order_item) + .columns(purchase_order_item.id_part, purchase_order_item.id_customer) + .insert( + Query.from_(part).select(part.part_id).where(part.part_number == "FOOBAR"), + 12345, + ) + ) + + self.assertEqual( + 'INSERT INTO "purchase_order_item" ' + '("id_part","id_customer") ' + "VALUES " + '((SELECT "part_id" FROM "part" WHERE "part_number"=\'FOOBAR\'),12345)', + str(q), + ) + + +class SelectIntoTests(unittest.TestCase): + table_abc, table_efg, table_hij = Tables("abc", "efg", "hij") + + def test_select_star_into(self): + query = Query.from_(self.table_abc).select("*").into(self.table_efg) + + self.assertEqual('SELECT * INTO "efg" FROM "abc"', str(query)) + + def test_select_columns_into(self): + query = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, self.table_abc.bar, self.table_abc.buz) + .into(self.table_efg) + ) + + self.assertEqual('SELECT "foo","bar","buz" INTO "efg" FROM "abc"', str(query)) + + def test_select_columns_into_with_join(self): + query = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, self.table_abc.bar) + .join(self.table_hij) + .on(self.table_abc.id == self.table_hij.abc_id) + .select(self.table_hij.fiz, self.table_hij.buz) + .into(self.table_efg) + ) + + self.assertEqual( + 'SELECT "abc"."foo","abc"."bar","hij"."fiz","hij"."buz" ' + 'INTO "efg" FROM "abc" ' + 'JOIN "hij" ON "abc"."id"="hij"."abc_id"', + str(query), + ) + + +class ReplaceTests(unittest.TestCase): + table_abc, table_def = Tables("abc", "efg") + + def test_replace_simple(self): + query = Query.into(self.table_abc).replace("v1", "v2", "v3") + expected_output = "REPLACE INTO \"abc\" VALUES ('v1','v2','v3')" + self.assertEqual(str(query), expected_output) + + def test_replace_subquery(self): + query = Query.into(self.table_abc).replace(Query.from_(self.table_def).select("f1", "f2")) + expected_output = 'REPLACE INTO "abc" VALUES ((SELECT "f1","f2" FROM "efg"))' + self.assertEqual(str(query), expected_output) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/test_internals.py b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/test_internals.py new file mode 100644 index 0000000000000000000000000000000000000000..921e381ba8613d4a83cc53bd60d111d9547e2c1f --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/test_internals.py @@ -0,0 +1,35 @@ +import unittest + +from pypika import ( + Case, + Field, + Table, +) +from pypika.terms import Star + + +class TablesTests(unittest.TestCase): + def test__criterion_replace_table_with_value(self): + table = Table("a") + + c = (Field("foo") > 1).replace_table(None, table) + self.assertEqual(c.left, table) + self.assertEqual(c.tables_, {table}) + + def test__case_tables(self): + table = Table("a") + + c = Case().when(table.a == 1, 2 * table.a) + self.assertIsInstance(c.tables_, set) + self.assertSetEqual(c.tables_, {table}) + + def test__star_tables(self): + star = Star() + + self.assertEqual(star.tables_, set()) + + def test__table_star_tables(self): + table = Table("a") + star = Star(table=table) + + self.assertEqual(star.tables_, {table}) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/test_joins.py b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/test_joins.py new file mode 100644 index 0000000000000000000000000000000000000000..03142d583921edbe966e0ae191d254e7b8bf46ba --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/test_joins.py @@ -0,0 +1,1168 @@ +import unittest + +from pypika import ( + Field, + Interval, + JoinException, + JoinType, + MySQLQuery, + Query, + SetOperationException, + Table, + Tables, + functions as fn, + SYSTEM_TIME, +) + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + + +class SelectQueryJoinTests(unittest.TestCase): + table0, table1, hij = Tables("abc", "efg", "hij") + + def test_default_join_type(self): + query = Query.from_(self.table0).join(self.table1).on(self.table0.foo == self.table1.bar).select("*") + + self.assertEqual('SELECT * FROM "abc" JOIN "efg" ON "abc"."foo"="efg"."bar"', str(query)) + + def test_inner_join(self): + expected = 'SELECT * FROM "abc" JOIN "efg" ON "abc"."foo"="efg"."bar"' + + with self.subTest("join with enum"): + query = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.inner) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + self.assertEqual(expected, str(query)) + + with self.subTest("join function"): + query = Query.from_(self.table0).inner_join(self.table1).on(self.table0.foo == self.table1.bar).select("*") + self.assertEqual(expected, str(query)) + + def test_left_join(self): + expected = 'SELECT * FROM "abc" LEFT JOIN "efg" ON "abc"."foo"="efg"."bar"' + + with self.subTest("join with enum"): + query = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.left) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + + self.assertEqual(expected, str(query)) + + with self.subTest("join function"): + query = Query.from_(self.table0).left_join(self.table1).on(self.table0.foo == self.table1.bar).select("*") + self.assertEqual(expected, str(query)) + + def test_right_join(self): + expected = 'SELECT * FROM "abc" RIGHT JOIN "efg" ON "abc"."foo"="efg"."bar"' + + with self.subTest("join with enum"): + query = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.right) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + + self.assertEqual(expected, str(query)) + + with self.subTest("join function"): + query = Query.from_(self.table0).right_join(self.table1).on(self.table0.foo == self.table1.bar).select("*") + self.assertEqual(expected, str(query)) + + def test_hash_join(self): + expected = 'SELECT * FROM "abc" HASH JOIN "efg" ON "abc"."foo"="efg"."bar"' + + with self.subTest("join with enum"): + query = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.hash) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + + self.assertEqual(expected, str(query)) + + with self.subTest("join function"): + query = Query.from_(self.table0).hash_join(self.table1).on(self.table0.foo == self.table1.bar).select("*") + self.assertEqual(expected, str(query)) + + def test_outer_join(self): + expected = 'SELECT * FROM "abc" FULL OUTER JOIN "efg" ON "abc"."foo"="efg"."bar"' + + with self.subTest("join with enum"): + query = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.outer) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + + self.assertEqual(expected, str(query)) + + with self.subTest("join function"): + query = Query.from_(self.table0).outer_join(self.table1).on(self.table0.foo == self.table1.bar).select("*") + self.assertEqual(expected, str(query)) + + def test_cross_join(self): + expected = 'SELECT * FROM "abc" CROSS JOIN "efg" ON "abc"."foo"="efg"."bar"' + + with self.subTest("join with enum"): + query = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.cross) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + + self.assertEqual(expected, str(query)) + + with self.subTest("join function"): + query = Query.from_(self.table0).cross_join(self.table1).on(self.table0.foo == self.table1.bar).select("*") + self.assertEqual(expected, str(query)) + + def test_left_outer_join(self): + expected = 'SELECT * FROM "abc" LEFT OUTER JOIN "efg" ON "abc"."foo"="efg"."bar"' + with self.subTest("join with enum"): + query = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.left_outer) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + + self.assertEqual(expected, str(query)) + + with self.subTest("join function"): + query = ( + Query.from_(self.table0).left_outer_join(self.table1).on(self.table0.foo == self.table1.bar).select("*") + ) + + self.assertEqual(expected, str(query)) + + def test_right_outer_join(self): + expected = 'SELECT * FROM "abc" RIGHT OUTER JOIN "efg" ON "abc"."foo"="efg"."bar"' + with self.subTest("join with enum"): + query = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.right_outer) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + + self.assertEqual(expected, str(query)) + + with self.subTest("join function"): + query = ( + Query.from_(self.table0) + .right_outer_join(self.table1) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + + self.assertEqual(expected, str(query)) + + def test_full_outer_join(self): + expected = 'SELECT * FROM "abc" FULL OUTER JOIN "efg" ON "abc"."foo"="efg"."bar"' + + with self.subTest("join with enum"): + query = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.full_outer) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + + self.assertEqual(expected, str(query)) + + with self.subTest("join function"): + query = ( + Query.from_(self.table0).full_outer_join(self.table1).on(self.table0.foo == self.table1.bar).select("*") + ) + + self.assertEqual(expected, str(query)) + + def test_join_on_field_single(self): + query = Query.from_(self.table0).join(self.table1).on_field("foo").select("*") + self.assertEqual('SELECT * FROM "abc" JOIN "efg" ON "abc"."foo"="efg"."foo"', str(query)) + + def test_join_on_field_multi(self): + query = Query.from_(self.table0).join(self.table1).on_field("foo", "bar").select("*") + self.assertEqual( + 'SELECT * FROM "abc" JOIN "efg" ON "abc"."foo"="efg"."foo" ' 'AND "abc"."bar"="efg"."bar"', + str(query), + ) + + def test_join_on_field_multi_with_extra_join(self): + query = ( + Query.from_(self.table0) + .join(self.hij) + .on_field("buzz") + .join(self.table1) + .on_field("foo", "bar") + .select("*") + ) + + self.assertEqual( + 'SELECT * FROM "abc" JOIN "hij" ON "abc"."buzz"="hij"."buzz" ' + 'JOIN "efg" ON "abc"."foo"="efg"."foo" AND "abc"."bar"="efg"."bar"', + str(query), + ) + + def test_join_using_string_field_name(self): + query = Query.from_(self.table0).join(self.table1).using("id").select("*") + + self.assertEqual('SELECT * FROM "abc" JOIN "efg" USING ("id")', str(query)) + + def test_join_using_multiple_fields(self): + query = Query.from_(self.table0).join(self.table1).using("foo", "bar").select("*") + + self.assertEqual('SELECT * FROM "abc" JOIN "efg" USING ("foo","bar")', str(query)) + + def test_join_using_with_quote_char(self): + query = Query.from_(self.table0).join(self.table1).using("foo", "bar").select("*") + + self.assertEqual("SELECT * FROM abc JOIN efg USING (foo,bar)", query.get_sql(quote_char="")) + + def test_join_using_without_fields_raises_exception(self): + with self.assertRaises(JoinException): + Query.from_(self.table0).join(self.table1).using() + + def test_join_on_field_without_fields_raises_exception(self): + with self.assertRaises(JoinException): + Query.from_(self.table0).join(self.table1).on_field() + + def test_join_arithmetic_field(self): + q = ( + Query.from_(self.table0) + .join(self.table1) + .on(self.table0.dt == (self.table1.dt - Interval(weeks=1))) + .select("*") + ) + + self.assertEqual( + 'SELECT * FROM "abc" ' 'JOIN "efg" ON "abc"."dt"="efg"."dt"-INTERVAL \'1 WEEK\'', + str(q), + ) + + def test_join_with_arithmetic_function_in_select(self): + q = ( + Query.from_( + self.table0, + ) + .join(self.table1) + .on(self.table0.dt == (self.table1.dt - Interval(weeks=1))) + .select(self.table0.fiz - self.table0.buz, self.table1.star) + ) + + self.assertEqual( + 'SELECT "abc"."fiz"-"abc"."buz","efg".* FROM "abc" ' + 'JOIN "efg" ON "abc"."dt"="efg"."dt"-INTERVAL \'1 WEEK\'', + str(q), + ) + + def test_join_on_complex_criteria(self): + q = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.right) + .on((self.table0.foo == self.table1.fiz) & (self.table0.bar == self.table1.buz)) + .select("*") + ) + + self.assertEqual( + 'SELECT * FROM "abc" ' 'RIGHT JOIN "efg" ON "abc"."foo"="efg"."fiz" AND "abc"."bar"="efg"."buz"', + str(q), + ) + + def test_join_on_subquery_criteria(self): + table_a, table_b, table_c = Tables("a", "b", "c") + subquery = Query.from_(table_c).select("id").limit(1) + query = ( + Query.from_(table_a).select("*").join(table_b).on((table_a.b_id == table_b.id) & (table_b.c_id == subquery)) + ) + + self.assertEqual( + "SELECT * " 'FROM "a" ' 'JOIN "b" ON "a"."b_id"="b"."id" AND "b"."c_id"=' '(SELECT "id" FROM "c" LIMIT 1)', + str(query), + ) + + def test_use_different_table_objects_for_same_table(self): + table = Table("t") + q = Query.from_(table).select("*").where(Field("id", table=table) == 1) + + self.assertEqual('SELECT * FROM "t" WHERE "id"=1', str(q)) + + def test_join_second_table_in_from_clause(self): + table_a, table_b, table_c = Tables("a", "b", "c") + q = Query.from_(table_a).from_(table_b).select("*").join(table_c).on(table_b.c_id == table_c.id) + + self.assertEqual("SELECT * " 'FROM "a","b" ' 'JOIN "c" ON "b"."c_id"="c"."id"', str(q)) + + def test_cross_join_on_table(self): + table_a, table_b = Tables("a", "b") + q = Query.from_(table_a).join(table_b).cross().select("*") + + self.assertEqual('SELECT * FROM "a" CROSS JOIN "b"', str(q)) + + def test_cross_join_on_subquery(self): + table_a, table_b = Tables("a", "b") + q_a = Query.from_(table_a).select("*") + q_b = Query.from_(table_b).select("*").join(q_a).cross().select("*") + + self.assertEqual('SELECT * FROM "b" CROSS JOIN (SELECT * FROM "a") "sq0"', str(q_b)) + + def test_join_on_collate(self): + table_a, table_b = Tables("a", "b") + + q1 = ( + Query.from_(table_a) + .select(table_b.ouch) + .join(table_b) + .on(table_a.foo == table_b.boo, collate="utf8_general_ci") + ) + q2 = Query.from_(table_a).select(table_b.ouch).join(table_b).on(table_a.foo == table_b.boo) + + self.assertEqual( + 'SELECT "b"."ouch" FROM "a" JOIN "b" ON "a"."foo"="b"."boo" COLLATE utf8_general_ci', + str(q1), + ) + self.assertEqual('SELECT "b"."ouch" FROM "a" JOIN "b" ON "a"."foo"="b"."boo"', str(q2)) + + def test_temporal_join(self): + t0 = self.table0.for_(SYSTEM_TIME.as_of('2020-01-01')) + t1 = self.table1.for_(SYSTEM_TIME.as_of('2020-01-01')) + query = Query.from_(t0).join(t1).on(t0.foo == t1.bar).select("*") + + self.assertEqual( + 'SELECT * FROM "abc" FOR SYSTEM_TIME AS OF \'2020-01-01\' ' + 'JOIN "efg" FOR SYSTEM_TIME AS OF \'2020-01-01\' ' + 'ON "abc"."foo"="efg"."bar"', + str(query), + ) + + +class JoinBehaviorTests(unittest.TestCase): + table_abc, table_efg, table_hij, table_klm = Tables("abc", "efg", "hij", "klm") + + def test_select__ordered_select_clauses(self): + q = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .select( + self.table_abc.baz, + self.table_efg.buz, + self.table_abc.fiz, + self.table_efg.bam, + ) + ) + + self.assertEqual( + 'SELECT "abc"."baz","efg"."buz","abc"."fiz","efg"."bam" FROM "abc" ' + 'JOIN "efg" ON "abc"."foo"="efg"."bar"', + str(q), + ) + + def test_select__star_for_table(self): + q = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .join(self.table_hij) + .on(self.table_abc.buz == self.table_hij.bam) + .select(self.table_abc.star) + .select(self.table_efg.star) + .select(self.table_hij.star) + ) + + self.assertEqual( + 'SELECT "abc".*,"efg".*,"hij".* FROM "abc" ' + 'JOIN "efg" ON "abc"."foo"="efg"."bar" ' + 'JOIN "hij" ON "abc"."buz"="hij"."bam"', + str(q), + ) + + def test_select__star_for_table__replacement(self): + q = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .join(self.table_hij) + .on(self.table_abc.buz == self.table_hij.bam) + .select(self.table_abc.foo, self.table_efg.bar, self.table_hij.bam) + .select(self.table_abc.star, self.table_efg.star, self.table_hij.star) + ) + + self.assertEqual( + 'SELECT "abc".*,"efg".*,"hij".* FROM "abc" ' + 'JOIN "efg" ON "abc"."foo"="efg"."bar" ' + 'JOIN "hij" ON "abc"."buz"="hij"."bam"', + str(q), + ) + + def test_select_fields_with_where(self): + q = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .join(self.table_hij) + .on(self.table_abc.buz == self.table_hij.bam) + .select(self.table_abc.foo, self.table_efg.bar, self.table_hij.bam) + .where(self.table_abc.foo > 1) + .where(self.table_efg.bar != 2) + ) + + self.assertEqual( + 'SELECT "abc"."foo","efg"."bar","hij"."bam" FROM "abc" ' + 'JOIN "efg" ON "abc"."foo"="efg"."bar" ' + 'JOIN "hij" ON "abc"."buz"="hij"."bam" ' + 'WHERE "abc"."foo">1 AND "efg"."bar"<>2', + str(q), + ) + + def test_require_condition(self): + with self.assertRaises(JoinException): + Query.from_(self.table_abc).join(self.table_efg).on(None) + + def test_require_condition_with_both_tables(self): + with self.assertRaises(JoinException): + Query.from_(self.table_abc).join(self.table_efg).on(self.table_abc.foo == self.table_hij.bar) + + with self.assertRaises(JoinException): + Query.from_(self.table_abc).join(self.table_efg).on(self.table_hij.foo == self.table_efg.bar) + + with self.assertRaises(JoinException): + Query.from_(self.table_abc).join(self.table_efg).on(self.table_hij.foo == self.table_klm.bar) + + def test_join_same_table(self): + table1 = Table("abc") + table2 = Table("abc") + q = Query.from_(table1).join(table2).on(table1.foo == table2.bar).select(table1.foo, table2.buz) + + self.assertEqual( + 'SELECT "abc"."foo","abc2"."buz" FROM "abc" ' 'JOIN "abc" "abc2" ON "abc"."foo"="abc2"."bar"', + str(q), + ) + + def test_join_same_table_with_prefixes(self): + table1 = Table("abc").as_("x") + table2 = Table("abc").as_("y") + q = Query.from_(table1).join(table2).on(table1.foo == table2.bar).select(table1.foo, table2.buz) + + self.assertEqual( + 'SELECT "x"."foo","y"."buz" FROM "abc" "x" ' 'JOIN "abc" "y" ON "x"."foo"="y"."bar"', + str(q), + ) + + def test_join_table_twice(self): + table1, table2 = Table("efg").as_("efg1"), Table("efg").as_("efg2") + q = ( + Query.from_(self.table_abc) + .join(table1) + .on(self.table_abc.foo == table1.bar) + .join(table2) + .on(self.table_abc.foo == table2.bam) + .select(self.table_abc.foo, table1.fiz, table2.buz) + ) + + self.assertEqual( + 'SELECT "abc"."foo","efg1"."fiz","efg2"."buz" FROM "abc" ' + 'JOIN "efg" "efg1" ON "abc"."foo"="efg1"."bar" ' + 'JOIN "efg" "efg2" ON "abc"."foo"="efg2"."bam"', + str(q), + ) + + def test_select__fields_after_table_star(self): + q = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .select(self.table_abc.star, self.table_efg.bar) + .select(self.table_abc.foo) + ) + + self.assertEqual( + 'SELECT "abc".*,"efg"."bar" FROM "abc" JOIN "efg" ON "abc"."foo"="efg"."bar"', + str(q), + ) + + def test_fail_when_joining_unknown_type(self): + with self.assertRaises(ValueError): + Query.from_(self.table_abc).join("this is a string") + + def test_immutable__tables(self): + query1 = Query.from_(self.table_abc).select(self.table_abc.foo) + query2 = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .select(self.table_abc.foo, self.table_efg.buz) + ) + + self.assertEqual( + 'SELECT "abc"."foo","efg"."buz" FROM "abc" ' 'JOIN "efg" ON "abc"."foo"="efg"."bar"', + str(query2), + ) + self.assertEqual('SELECT "foo" FROM "abc"', str(query1)) + + def test_select_field_from_missing_table(self): + """ + Previously we validated the select field was a member of a table + in the query (e.g. FROM clause or a JOIN). However this made + correlated subqueries awkward to write (subqueries which refer + to their parent table. So the validation was removed. + + None of the following raise an error. Previously raised JoinException + """ + Query.from_(self.table_abc).select(self.table_efg.foo) + + Query.from_(self.table_abc).where(self.table_efg.foo == 0) + + Query.from_(self.table_abc).where(fn.Sum(self.table_efg.foo) == 0) + + Query.from_(self.table_abc).select(fn.Sum(self.table_abc.bar * 2) + fn.Sum(self.table_efg.foo * 2)) + + Query.from_(self.table_abc).groupby(self.table_efg.foo) + + Query.from_(self.table_abc).groupby(self.table_abc.foo).having(self.table_efg.bar) + + subquery = ( + Query.from_(self.table_efg).select(self.table_efg.id).where(self.table_efg.abc_id == self.table_abc.id) + ) + query = Query.from_(self.table_abc).select(subquery.as_("efg_id").limit(1)) + self.assertEqual( + 'SELECT (SELECT "efg"."id" FROM "efg" WHERE "efg"."abc_id"="abc"."id" LIMIT 1) "efg_id" FROM "abc"', + str(query), + ) + + def test_ignore_table_references(self): + query = Query.from_(Table("abc")).select(Table("abc").foo) + + self.assertEqual('SELECT "foo" FROM "abc"', str(query)) + + def test_prefixes_added_to_groupby(self): + test_query = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .select(self.table_abc.foo, fn.Sum(self.table_efg.buz)) + .groupby(self.table_abc.foo) + ) + + self.assertEqual( + 'SELECT "abc"."foo",SUM("efg"."buz") FROM "abc" ' + 'JOIN "efg" ON "abc"."foo"="efg"."bar" ' + 'GROUP BY "abc"."foo"', + str(test_query), + ) + + def test_prefixes_added_to_orderby(self): + test_query = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .select(self.table_abc.foo, self.table_efg.buz) + .orderby(self.table_abc.foo) + ) + + self.assertEqual( + 'SELECT "abc"."foo","efg"."buz" FROM "abc" ' + 'JOIN "efg" ON "abc"."foo"="efg"."bar" ' + 'ORDER BY "abc"."foo"', + str(test_query), + ) + + def test_prefixes_added_to_function_in_orderby(self): + test_query = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .select(self.table_abc.foo, self.table_efg.buz) + .orderby(fn.Date(self.table_abc.foo)) + ) + + self.assertEqual( + 'SELECT "abc"."foo","efg"."buz" FROM "abc" ' + 'JOIN "efg" ON "abc"."foo"="efg"."bar" ' + 'ORDER BY DATE("abc"."foo")', + str(test_query), + ) + + def test_join_from_join(self): + test_query = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.efg_id == self.table_efg.id) + .join(self.table_hij) + .on(self.table_efg.hij_id == self.table_hij.id) + .select(self.table_abc.foo, self.table_efg.bar, self.table_hij.fizz) + ) + + self.assertEqual( + 'SELECT "abc"."foo","efg"."bar","hij"."fizz" FROM "abc" ' + 'JOIN "efg" ON "abc"."efg_id"="efg"."id" ' + 'JOIN "hij" ON "efg"."hij_id"="hij"."id"', + str(test_query), + ) + + def test_join_query_without_alias(self): + subquery = Query.from_(self.table_efg).select( + self.table_efg.base_id.as_("x"), self.table_efg.fizz, self.table_efg.buzz + ) + + test_query = ( + Query.from_(self.table_abc) + .join(subquery) + .on(subquery.x == self.table_abc.id) + .select(self.table_abc.foo, subquery.fizz, subquery.buzz) + ) + + self.assertEqual( + 'SELECT "abc"."foo","sq0"."fizz","sq0"."buzz" ' + 'FROM "abc" JOIN (' + 'SELECT "base_id" "x","fizz","buzz" FROM "efg"' + ') "sq0" ' + 'ON "sq0"."x"="abc"."id"', + str(test_query), + ) + + def test_join_query_with_column_alias(self): + subquery = ( + Query.from_(self.table_efg) + .select( + self.table_efg.base_id.as_("x"), + self.table_efg.fizz, + self.table_efg.buzz, + ) + .as_("subq") + ) + + test_query = ( + Query.from_(self.table_abc) + .join(subquery) + .on(subquery.x == self.table_abc.id) + .select(self.table_abc.foo, subquery.fizz, subquery.buzz) + ) + + self.assertEqual( + 'SELECT "abc"."foo","subq"."fizz","subq"."buzz" ' + 'FROM "abc" JOIN (' + 'SELECT "base_id" "x","fizz","buzz" FROM "efg"' + ') "subq" ' + 'ON "subq"."x"="abc"."id"', + str(test_query), + ) + + def test_join_query_with_table_alias(self): + xxx = self.table_efg.as_("xxx") + subquery = Query.from_(xxx).select(xxx.base_id, xxx.fizz, xxx.buzz).as_("subq") + + test_query = ( + Query.from_(self.table_abc) + .join(subquery) + .on(subquery.x == self.table_abc.id) + .select(self.table_abc.foo, subquery.fizz, subquery.buzz) + ) + + self.assertEqual( + 'SELECT "abc"."foo","subq"."fizz","subq"."buzz" ' + 'FROM "abc" JOIN (' + 'SELECT "xxx"."base_id","xxx"."fizz","xxx"."buzz" FROM "efg" "xxx"' + ') "subq" ' + 'ON "subq"."x"="abc"."id"', + str(test_query), + ) + + def test_join_query_with_setoperation(self): + subquery = Query.from_(self.table_abc).select("*").union(Query.from_(self.table_abc).select("*")).as_("subq") + + test_query = ( + Query.from_(self.table_abc).join(subquery).on(subquery.x == self.table_abc.id).select(self.table_abc.foo) + ) + + self.assertEqual( + 'SELECT "abc"."foo" FROM "abc" ' + 'JOIN ' + '((SELECT * FROM "abc") ' + 'UNION ' + '(SELECT * FROM "abc")) "subq" ' + 'ON "subq"."x"="abc"."id"', + str(test_query), + ) + + +class UnionTests(unittest.TestCase): + table1, table2 = Tables("abc", "efg") + + def test_union(self): + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + + self.assertEqual( + '(SELECT "foo" FROM "abc") UNION (SELECT "bar" FROM "efg")', + str(query1 + query2), + ) + self.assertEqual( + '(SELECT "foo" FROM "abc") UNION (SELECT "bar" FROM "efg")', + str(query1.union(query2)), + ) + + def test_union_multiple(self): + table3, table4 = Tables("hij", "lmn") + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + query3 = Query.from_(table3).select(table3.baz) + query4 = Query.from_(table4).select(table4.faz) + + self.assertEqual( + '(SELECT "foo" FROM "abc") UNION ' + '(SELECT "bar" FROM "efg") UNION ' + '(SELECT "baz" FROM "hij") UNION ' + '(SELECT "faz" FROM "lmn")', + str(query1 + query2 + query3 + query4), + ) + self.assertEqual( + '(SELECT "foo" FROM "abc") UNION ' + '(SELECT "bar" FROM "efg") UNION ' + '(SELECT "baz" FROM "hij") UNION ' + '(SELECT "faz" FROM "lmn")', + str(query1.union(query2).union(query3).union(query4)), + ) + + def test_union_all(self): + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + + self.assertEqual( + '(SELECT "foo" FROM "abc") UNION ALL (SELECT "bar" FROM "efg")', + str(query1 * query2), + ) + self.assertEqual( + '(SELECT "foo" FROM "abc") UNION ALL (SELECT "bar" FROM "efg")', + str(query1.union_all(query2)), + ) + + def test_union_all_multiple(self): + table3, table4 = Tables("hij", "lmn") + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + query3 = Query.from_(table3).select(table3.baz) + query4 = Query.from_(table4).select(table4.faz) + + self.assertEqual( + '(SELECT "foo" FROM "abc") UNION ALL ' + '(SELECT "bar" FROM "efg") UNION ALL ' + '(SELECT "baz" FROM "hij") UNION ALL ' + '(SELECT "faz" FROM "lmn")', + str(query1 * query2 * query3 * query4), + ) + self.assertEqual( + '(SELECT "foo" FROM "abc") UNION ALL ' + '(SELECT "bar" FROM "efg") UNION ALL ' + '(SELECT "baz" FROM "hij") UNION ALL ' + '(SELECT "faz" FROM "lmn")', + str(query1.union_all(query2).union_all(query3).union_all(query4)), + ) + + def test_union_with_order_by(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + union_query = str((query1 + query2).orderby(query1.field("a"))) + union_all_query = str((query1 * query2).orderby(query1.field("a"))) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "UNION " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "a"', + union_query, + ) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "UNION ALL " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "a"', + union_all_query, + ) + + def test_union_with_order_by_use_union_query_field(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + union_query = query1 + query2 + union_query = str(union_query.orderby(union_query.field("a"))) + union_all_query = query1 * query2 + union_all_query = str(union_all_query.orderby(union_all_query.field("a"))) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "UNION " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "a"', + union_query, + ) + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "UNION ALL " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "a"', + union_all_query, + ) + + def test_union_with_order_by_with_aliases(self): + query1 = Query.from_(self.table1.as_("a")).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2.as_("b")).select(self.table2.bar.as_("a")) + + union_all_query = str((query1 * query2).orderby(query1.field("a"))) + union_query = str((query1 + query2).orderby(query1.field("a"))) + self.assertEqual( + '(SELECT "foo" "a" FROM "abc" "a")' " UNION ALL " '(SELECT "bar" "a" FROM "efg" "b")' ' ORDER BY "a"', + union_all_query, + ) + self.assertEqual( + '(SELECT "foo" "a" FROM "abc" "a")' " UNION " '(SELECT "bar" "a" FROM "efg" "b")' ' ORDER BY "a"', + union_query, + ) + + def test_union_with_order_by_use_union_query_field_with_aliases(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + union_query = (query1 + query2).as_("x") + union_query = union_query.orderby(union_query.field("a")) + union_all_query = (query1 * query2).as_("x") + union_all_query = union_all_query.orderby(union_all_query.field("a")) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "UNION " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "x"."a"', + str(union_query), + ) + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "UNION ALL " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "x"."a"', + str(union_all_query), + ) + + def test_require_equal_number_of_fields(self): + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.fiz, self.table2.buz) + + with self.assertRaises(SetOperationException): + str(query1 + query2) + + def test_mysql_query_wraps_unioned_queries(self): + query1 = MySQLQuery.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + + self.assertEqual( + "(SELECT `foo` FROM `abc`) UNION (SELECT `bar` FROM `efg`)", + str(query1 + query2), + ) + + def test_union_as_subquery(self): + abc, efg = Tables("abc", "efg") + hij = Query.from_(abc).select(abc.t).union(Query.from_(efg).select(efg.t)) + q = Query.from_(hij).select(fn.Avg(hij.t)) + + self.assertEqual( + 'SELECT AVG("sq0"."t") FROM ((SELECT "t" FROM "abc") UNION (SELECT "t" FROM "efg")) "sq0"', + str(q), + ) + + def test_union_with_no_quote_char(self): + abc, efg = Tables("abc", "efg") + hij = Query.from_(abc).select(abc.t).union(Query.from_(efg).select(efg.t)) + q = Query.from_(hij).select(fn.Avg(hij.t)) + + self.assertEqual( + "SELECT AVG(sq0.t) FROM ((SELECT t FROM abc) UNION (SELECT t FROM efg)) sq0", + q.get_sql(quote_char=None), + ) + + +class InsertQueryJoinTests(unittest.TestCase): + def test_join_table_on_insert_query(self): + a, b, c = Tables("a", "b", "c") + q = Query.into(c).from_(a).join(b).on(a.fkey_id == b.id).where(b.foo == 1).select("a.*", "b.*") + + self.assertEqual( + 'INSERT INTO "c" ' + 'SELECT "a"."a.*","a"."b.*" ' + 'FROM "a" JOIN "b" ' + 'ON "a"."fkey_id"="b"."id" ' + 'WHERE "b"."foo"=1', + str(q), + ) + + +class UpdateQueryJoinTests(unittest.TestCase): + def test_join_table_on_update_query(self): + a, b = Tables("a", "b") + q = Query.update(a).join(b).on(a.fkey_id == b.id).where(b.foo == 1).set("adwords_batch_job_id", 1) + + self.assertEqual( + 'UPDATE "a" ' 'JOIN "b" ' 'ON "a"."fkey_id"="b"."id" ' 'SET "adwords_batch_job_id"=1 ' 'WHERE "b"."foo"=1', + str(q), + ) + + +class IntersectTests(unittest.TestCase): + table1, table2 = Tables("abc", "efg") + + def test_intersect(self): + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + + self.assertEqual( + '(SELECT "foo" FROM "abc") INTERSECT (SELECT "bar" FROM "efg")', + str(query1.intersect(query2)), + ) + + def test_intersect_multiple(self): + table3, table4 = Tables("hij", "lmn") + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + query3 = Query.from_(table3).select(table3.baz) + query4 = Query.from_(table4).select(table4.faz) + + self.assertEqual( + '(SELECT "foo" FROM "abc") INTERSECT ' + '(SELECT "bar" FROM "efg") INTERSECT ' + '(SELECT "baz" FROM "hij") INTERSECT ' + '(SELECT "faz" FROM "lmn")', + str(query1.intersect(query2).intersect(query3).intersect(query4)), + ) + + def test_intersect_with_order_by(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + intersect_query = str((query1.intersect(query2)).orderby(query1.field("a"))) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "INTERSECT " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "a"', + intersect_query, + ) + + def test_intersect_with_limit(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + intersect_query = str((query1.intersect(query2)).limit(10)) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "INTERSECT " '(SELECT "bar" "a" FROM "efg") ' 'LIMIT 10', + intersect_query, + ) + + def test_intersect_with_offset(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + intersect_query = str((query1.intersect(query2)).offset(10)) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "INTERSECT " '(SELECT "bar" "a" FROM "efg") ' 'OFFSET 10', + intersect_query, + ) + + def test_require_equal_number_of_fields_intersect(self): + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.fiz, self.table2.buz) + + with self.assertRaises(SetOperationException): + str(query1.intersect(query2)) + + def test_mysql_query_wraps_intersected_queries(self): + query1 = MySQLQuery.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + + self.assertEqual( + "(SELECT `foo` FROM `abc`) INTERSECT (SELECT `bar` FROM `efg`)", + str(query1.intersect(query2)), + ) + + def test_intersect_as_subquery(self): + abc, efg = Tables("abc", "efg") + hij = Query.from_(abc).select(abc.t).intersect(Query.from_(efg).select(efg.t)) + q = Query.from_(hij).select(fn.Avg(hij.t)) + + self.assertEqual( + 'SELECT AVG("sq0"."t") FROM ((SELECT "t" FROM "abc") INTERSECT (SELECT "t" FROM "efg")) "sq0"', + str(q), + ) + + def test_intersect_with_no_quote_char(self): + abc, efg = Tables("abc", "efg") + hij = Query.from_(abc).select(abc.t).intersect(Query.from_(efg).select(efg.t)) + q = Query.from_(hij).select(fn.Avg(hij.t)) + + self.assertEqual( + "SELECT AVG(sq0.t) FROM ((SELECT t FROM abc) INTERSECT (SELECT t FROM efg)) sq0", + q.get_sql(quote_char=None), + ) + + +class MinusTests(unittest.TestCase): + table1, table2 = Tables("abc", "efg") + + def test_minus(self): + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + + self.assertEqual('(SELECT "foo" FROM "abc") MINUS (SELECT "bar" FROM "efg")', str(query1.minus(query2))) + + self.assertEqual( + '(SELECT "foo" FROM "abc") MINUS (SELECT "bar" FROM "efg")', + str(query1 - query2), + ) + + def test_minus_multiple(self): + table3, table4 = Tables("hij", "lmn") + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + query3 = Query.from_(table3).select(table3.baz) + query4 = Query.from_(table4).select(table4.faz) + + self.assertEqual( + '(SELECT "foo" FROM "abc") MINUS ' + '(SELECT "bar" FROM "efg") MINUS ' + '(SELECT "baz" FROM "hij") MINUS ' + '(SELECT "faz" FROM "lmn")', + str(query1 - query2 - query3 - query4), + ) + + self.assertEqual( + '(SELECT "foo" FROM "abc") MINUS ' + '(SELECT "bar" FROM "efg") MINUS ' + '(SELECT "baz" FROM "hij") MINUS ' + '(SELECT "faz" FROM "lmn")', + str(query1.minus(query2).minus(query3).minus(query4)), + ) + + def test_minus_with_order_by(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + minus_query = str(query1.minus(query2).orderby(query1.field("a"))) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "MINUS " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "a"', minus_query + ) + + def test_minus_query_with_order_by_use_minus_query_field(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + minus_query = query1.minus(query2) + minus_query = str(minus_query.orderby(minus_query.field("b"))) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "MINUS " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "b"', + minus_query, + ) + + def test_require_equal_number_of_fields(self): + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.fiz, self.table2.buz) + + with self.assertRaises(SetOperationException): + str(query1.minus(query2)) + + def test_mysql_query_wraps_minus_queries(self): + query1 = MySQLQuery.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + + self.assertEqual( + "(SELECT `foo` FROM `abc`) MINUS (SELECT `bar` FROM `efg`)", + str(query1 - query2), + ) + + def test_minus_as_subquery(self): + abc, efg = Tables("abc", "efg") + hij = Query.from_(abc).select(abc.t).minus(Query.from_(efg).select(efg.t)) + q = Query.from_(hij).select(fn.Avg(hij.t)) + + self.assertEqual( + 'SELECT AVG("sq0"."t") FROM ((SELECT "t" FROM "abc") MINUS (SELECT "t" FROM "efg")) "sq0"', + str(q), + ) + + def test_minus_with_no_quote_char(self): + abc, efg = Tables("abc", "efg") + hij = Query.from_(abc).select(abc.t).minus(Query.from_(efg).select(efg.t)) + q = Query.from_(hij).select(fn.Avg(hij.t)) + + self.assertEqual( + "SELECT AVG(sq0.t) FROM ((SELECT t FROM abc) MINUS (SELECT t FROM efg)) sq0", + q.get_sql(quote_char=None), + ) + + +class ExceptOfTests(unittest.TestCase): + table1, table2 = Tables("abc", "efg") + + def test_except(self): + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + + self.assertEqual('(SELECT "foo" FROM "abc") EXCEPT (SELECT "bar" FROM "efg")', str(query1.except_of(query2))) + + def test_except_multiple(self): + table3, table4 = Tables("hij", "lmn") + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + query3 = Query.from_(table3).select(table3.baz) + query4 = Query.from_(table4).select(table4.faz) + + self.assertEqual( + '(SELECT "foo" FROM "abc") EXCEPT ' + '(SELECT "bar" FROM "efg") EXCEPT ' + '(SELECT "baz" FROM "hij") EXCEPT ' + '(SELECT "faz" FROM "lmn")', + str(query1.except_of(query2).except_of(query3).except_of(query4)), + ) + + def test_except_with_order_by(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + except_query = str(query1.except_of(query2).orderby(query1.field("a"))) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "EXCEPT " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "a"', except_query + ) + + def test_except_query_with_order_by_use_minus_query_field(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + except_query = query1.except_of(query2) + except_query = str(except_query.orderby(except_query.field("b"))) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "EXCEPT " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "b"', + except_query, + ) + + def test_require_equal_number_of_fields_except_of(self): + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.fiz, self.table2.buz) + + with self.assertRaises(SetOperationException): + str(query1.except_of(query2)) + + def test_except_as_subquery(self): + abc, efg = Tables("abc", "efg") + hij = Query.from_(abc).select(abc.t).except_of(Query.from_(efg).select(efg.t)) + q = Query.from_(hij).select(fn.Avg(hij.t)) + + self.assertEqual( + 'SELECT AVG("sq0"."t") FROM ((SELECT "t" FROM "abc") EXCEPT (SELECT "t" FROM "efg")) "sq0"', + str(q), + ) + + def test_except_with_no_quote_char(self): + abc, efg = Tables("abc", "efg") + hij = Query.from_(abc).select(abc.t).except_of(Query.from_(efg).select(efg.t)) + q = Query.from_(hij).select(fn.Avg(hij.t)) + + self.assertEqual( + "SELECT AVG(sq0.t) FROM ((SELECT t FROM abc) EXCEPT (SELECT t FROM efg)) sq0", + q.get_sql(quote_char=None), + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/test_negation.py b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/test_negation.py new file mode 100644 index 0000000000000000000000000000000000000000..9f4db83b560dbc8546ce6d384b781dfccefd319d --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/test_negation.py @@ -0,0 +1,31 @@ +import unittest + +from pypika import ( + Tables, + functions as fn, +) +from pypika.terms import ValueWrapper + + +class NegationTests(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_negate_wrapped_float(self): + q = -ValueWrapper(1.0) + + self.assertEqual("-1.0", q.get_sql()) + + def test_negate_wrapped_int(self): + q = -ValueWrapper(1) + + self.assertEqual("-1", q.get_sql()) + + def test_negate_field(self): + q = -self.table_abc.foo + + self.assertEqual('-"abc"."foo"', q.get_sql(with_namespace=True, quote_char='"')) + + def test_negate_function(self): + q = -fn.Sum(self.table_abc.foo) + + self.assertEqual('-SUM("abc"."foo")', q.get_sql(with_namespace=True, quote_char='"')) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/test_parameter.py b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/test_parameter.py new file mode 100644 index 0000000000000000000000000000000000000000..c11e9afcd9624abb0a7313306eda34ebcf4c99ba --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/test_parameter.py @@ -0,0 +1,206 @@ +import unittest +from datetime import date + +from pypika import ( + FormatParameter, + NamedParameter, + NumericParameter, + Parameter, + PyformatParameter, + QmarkParameter, + Query, + Tables, +) +from pypika.terms import ListParameter, ParameterValueWrapper + + +class ParametrizedTests(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_param_insert(self): + q = Query.into(self.table_abc).columns("a", "b", "c").insert(Parameter("?"), Parameter("?"), Parameter("?")) + + self.assertEqual('INSERT INTO "abc" ("a","b","c") VALUES (?,?,?)', q.get_sql()) + + def test_param_select_join(self): + q = ( + Query.from_(self.table_abc) + .select("*") + .where(self.table_abc.category == Parameter("%s")) + .join(self.table_efg) + .on(self.table_abc.id == self.table_efg.abc_id) + .where(self.table_efg.date >= Parameter("%s")) + .limit(10) + ) + + self.assertEqual( + 'SELECT * FROM "abc" JOIN "efg" ON "abc"."id"="efg"."abc_id" WHERE "abc"."category"=%s AND "efg"."date">=%s LIMIT 10', + q.get_sql(), + ) + + def test_param_select_subquery(self): + q = ( + Query.from_(self.table_abc) + .select("*") + .where(self.table_abc.category == Parameter("&1")) + .where( + self.table_abc.id.isin( + Query.from_(self.table_efg) + .select(self.table_efg.abc_id) + .where(self.table_efg.date >= Parameter("&2")) + ) + ) + .limit(10) + ) + + self.assertEqual( + 'SELECT * FROM "abc" WHERE "category"=&1 AND "id" IN (SELECT "abc_id" FROM "efg" WHERE "date">=&2) LIMIT 10', + q.get_sql(), + ) + + def test_join(self): + subquery = ( + Query.from_(self.table_efg) + .select(self.table_efg.fiz, self.table_efg.buz) + .where(self.table_efg.buz == Parameter(":buz")) + ) + + q = ( + Query.from_(self.table_abc) + .join(subquery) + .on(self.table_abc.bar == subquery.buz) + .select(self.table_abc.foo, subquery.fiz) + .where(self.table_abc.bar == Parameter(":bar")) + ) + + self.assertEqual( + 'SELECT "abc"."foo","sq0"."fiz" FROM "abc" JOIN (SELECT "fiz","buz" FROM "efg" WHERE "buz"=:buz)' + ' "sq0" ON "abc"."bar"="sq0"."buz" WHERE "abc"."bar"=:bar', + q.get_sql(), + ) + + def test_qmark_parameter(self): + self.assertEqual('?', QmarkParameter().get_sql()) + + def test_numeric_parameter(self): + self.assertEqual(':14', NumericParameter('14').get_sql()) + self.assertEqual(':15', NumericParameter(15).get_sql()) + + def test_named_parameter(self): + self.assertEqual(':buz', NamedParameter('buz').get_sql()) + + def test_format_parameter(self): + self.assertEqual('%s', FormatParameter().get_sql()) + + def test_pyformat_parameter(self): + self.assertEqual('%(buz)s', PyformatParameter('buz').get_sql()) + + +class ParametrizedTestsWithValues(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_param_insert(self): + q = Query.into(self.table_abc).columns("a", "b", "c").insert(1, 2.2, 'foo') + + parameter = QmarkParameter() + sql = q.get_sql(parameter=parameter) + self.assertEqual('INSERT INTO "abc" ("a","b","c") VALUES (?,?,?)', sql) + self.assertEqual([1, 2.2, 'foo'], parameter.get_parameters()) + + def test_param_select_join(self): + q = ( + Query.from_(self.table_abc) + .select("*") + .where(self.table_abc.category == 'foobar') + .join(self.table_efg) + .on(self.table_abc.id == self.table_efg.abc_id) + .where(self.table_efg.date >= date(2024, 2, 22)) + .limit(10) + ) + + parameter = FormatParameter() + sql = q.get_sql(parameter=parameter) + self.assertEqual( + 'SELECT * FROM "abc" JOIN "efg" ON "abc"."id"="efg"."abc_id" WHERE "abc"."category"=%s AND "efg"."date">=%s LIMIT 10', + sql, + ) + self.assertEqual(['foobar', '2024-02-22'], parameter.get_parameters()) + + def test_param_select_subquery(self): + q = ( + Query.from_(self.table_abc) + .select("*") + .where(self.table_abc.category == 'foobar') + .where( + self.table_abc.id.isin( + Query.from_(self.table_efg) + .select(self.table_efg.abc_id) + .where(self.table_efg.date >= date(2024, 2, 22)) + ) + ) + .limit(10) + ) + + parameter = ListParameter(placeholder=lambda idx: f'&{idx+1}') + sql = q.get_sql(parameter=parameter) + self.assertEqual( + 'SELECT * FROM "abc" WHERE "category"=&1 AND "id" IN (SELECT "abc_id" FROM "efg" WHERE "date">=&2) LIMIT 10', + sql, + ) + self.assertEqual(['foobar', '2024-02-22'], parameter.get_parameters()) + + def test_join(self): + subquery = ( + Query.from_(self.table_efg) + .select(self.table_efg.fiz, self.table_efg.buz) + .where(self.table_efg.buz == 'buz') + ) + + q = ( + Query.from_(self.table_abc) + .join(subquery) + .on(self.table_abc.bar == subquery.buz) + .select(self.table_abc.foo, subquery.fiz) + .where(self.table_abc.bar == 'bar') + ) + + parameter = NamedParameter() + sql = q.get_sql(parameter=parameter) + self.assertEqual( + 'SELECT "abc"."foo","sq0"."fiz" FROM "abc" JOIN (SELECT "fiz","buz" FROM "efg" WHERE "buz"=:param1)' + ' "sq0" ON "abc"."bar"="sq0"."buz" WHERE "abc"."bar"=:param2', + sql, + ) + self.assertEqual({'param1': 'buz', 'param2': 'bar'}, parameter.get_parameters()) + + def test_join_with_parameter_value_wrapper(self): + subquery = ( + Query.from_(self.table_efg) + .select(self.table_efg.fiz, self.table_efg.buz) + .where(self.table_efg.buz == ParameterValueWrapper(Parameter(':buz'), 'buz')) + ) + + q = ( + Query.from_(self.table_abc) + .join(subquery) + .on(self.table_abc.bar == subquery.buz) + .select(self.table_abc.foo, subquery.fiz) + .where(self.table_abc.bar == ParameterValueWrapper(NamedParameter('bar'), 'bar')) + ) + + parameter = NamedParameter() + sql = q.get_sql(parameter=parameter) + self.assertEqual( + 'SELECT "abc"."foo","sq0"."fiz" FROM "abc" JOIN (SELECT "fiz","buz" FROM "efg" WHERE "buz"=:buz)' + ' "sq0" ON "abc"."bar"="sq0"."buz" WHERE "abc"."bar"=:bar', + sql, + ) + self.assertEqual({':buz': 'buz', 'bar': 'bar'}, parameter.get_parameters()) + + def test_pyformat_parameter(self): + q = Query.into(self.table_abc).columns("a", "b", "c").insert(1, 2.2, 'foo') + + parameter = PyformatParameter() + sql = q.get_sql(parameter=parameter) + self.assertEqual('INSERT INTO "abc" ("a","b","c") VALUES (%(param1)s,%(param2)s,%(param3)s)', sql) + self.assertEqual({"param1": 1, "param2": 2.2, "param3": "foo"}, parameter.get_parameters()) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/test_pseudocolumns.py b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/test_pseudocolumns.py new file mode 100644 index 0000000000000000000000000000000000000000..6a25c70269b2ccc98ac3870ac64a43c8a32ddbe9 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/test_pseudocolumns.py @@ -0,0 +1,51 @@ +import unittest + +from pypika import Query, Table +from pypika.pseudocolumns import ( + ColumnValue, + ObjectID, + ObjectValue, + RowID, + RowNum, + SysDate, +) +from pypika.terms import PseudoColumn + + +class PseudoColumnsTest(unittest.TestCase): + @classmethod + def setUpClass(cls): + super(PseudoColumnsTest, cls).setUpClass() + cls.table1 = Table("table1") + + def test_column_value(self): + self.assertEqual("COLUMN_VALUE", ColumnValue) + + def test_object_id(self): + self.assertEqual("OBJECT_ID", ObjectID) + + def test_object_value(self): + self.assertEqual("OBJECT_VALUE", ObjectValue) + + def test_row_id(self): + self.assertEqual("ROWID", RowID) + + def test_row_num(self): + self.assertEqual("ROWNUM", RowNum) + + def test_sys_date(self): + self.assertEqual("SYSDATE", SysDate) + + def test_can_be_used_in_a_select_statement(self): + query = Query.from_(self.table1).where(self.table1.is_active == 1).select(PseudoColumn("abcde")) + + self.assertEqual(str(query), 'SELECT abcde FROM "table1" WHERE "is_active"=1') + + def test_can_be_used_in_a_where_clause(self): + query = Query.from_(self.table1).where(PseudoColumn("abcde") > 1).select(self.table1.is_active) + + self.assertEqual(str(query), 'SELECT "is_active" FROM "table1" WHERE abcde>1') + + def test_can_be_used_in_orderby(self): + query = Query.from_(self.table1).select(self.table1.abcde.as_("some_name")).orderby(PseudoColumn("some_name")) + self.assertEqual(str(query), 'SELECT "abcde" "some_name" FROM "table1" ORDER BY some_name') diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/test_query.py b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/test_query.py new file mode 100644 index 0000000000000000000000000000000000000000..ae8dc01599a6a562b591ce15391bfe9b5c87e0f9 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/test_query.py @@ -0,0 +1,242 @@ +import unittest + +from pypika import Case, Query, Tables, Tuple, functions, Field +from pypika.dialects import ( + ClickHouseQuery, + ClickHouseQueryBuilder, + MSSQLQuery, + MSSQLQueryBuilder, + MySQLLoadQueryBuilder, + MySQLQuery, + MySQLQueryBuilder, + OracleQuery, + OracleQueryBuilder, + PostgreSQLQuery, + PostgreSQLQueryBuilder, + RedShiftQueryBuilder, + RedshiftQuery, + SQLLiteQuery, + SQLLiteQueryBuilder, + SnowflakeQuery, + SnowflakeQueryBuilder, + VerticaCopyQueryBuilder, + VerticaCreateQueryBuilder, + VerticaQuery, + VerticaQueryBuilder, +) +from pypika.queries import CreateQueryBuilder, DropQueryBuilder, QueryBuilder + + +class QueryTablesTests(unittest.TestCase): + table_a, table_b, table_c, table_d = Tables("a", "b", "c", "d") + + def test_replace_table(self): + query = Query.from_(self.table_a).select(self.table_a.time) + query = query.replace_table(self.table_a, self.table_b) + + self.assertEqual('SELECT "time" FROM "b"', str(query)) + + def test_replace_only_specified_table(self): + query = Query.from_(self.table_a).select(self.table_a.time) + query = query.replace_table(self.table_b, self.table_c) + + self.assertEqual('SELECT "time" FROM "a"', str(query)) + + def test_replace_insert_table(self): + query = Query.into(self.table_a).insert(1) + query = query.replace_table(self.table_a, self.table_b) + + self.assertEqual('INSERT INTO "b" VALUES (1)', str(query)) + + def test_replace_insert_table_current_table_not_match(self): + query = Query.into(self.table_a).insert(1) + query = query.replace_table(self.table_c, self.table_b) + + self.assertEqual('INSERT INTO "a" VALUES (1)', str(query)) + + def test_replace_update_table(self): + query = Query.update(self.table_a).set("foo", "bar") + query = query.replace_table(self.table_a, self.table_b) + + self.assertEqual('UPDATE "b" SET "foo"=\'bar\'', str(query)) + + def test_replace_update_table_current_table_not_match(self): + query = Query.update(self.table_a).set("foo", "bar") + query = query.replace_table(self.table_c, self.table_b) + + self.assertEqual('UPDATE "a" SET "foo"=\'bar\'', str(query)) + + def test_replace_delete_table(self): + query = Query.from_(self.table_a).delete() + query = query.replace_table(self.table_a, self.table_b) + + self.assertEqual('DELETE FROM "b"', str(query)) + + def test_replace_join_tables(self): + query = ( + Query.from_(self.table_a) + .join(self.table_b) + .on(self.table_a.customer_id == self.table_b.id) + .join(self.table_c) + .on(self.table_b.seller_id == self.table_c.id) + .select(self.table_a.star) + ) + query = query.replace_table(self.table_a, self.table_d) + + self.assertEqual( + 'SELECT "d".* ' + 'FROM "d" ' + 'JOIN "b" ON "d"."customer_id"="b"."id" ' + 'JOIN "c" ON "b"."seller_id"="c"."id"', + str(query), + ) + + def test_replace_filter_tables(self): + query = Query.from_(self.table_a).select(self.table_a.name).where(self.table_a.name == "Mustermann") + query = query.replace_table(self.table_a, self.table_b) + + self.assertEqual('SELECT "name" FROM "b" WHERE "name"=\'Mustermann\'', str(query)) + + def test_replace_having_table(self): + query = ( + Query.from_(self.table_a) + .select(functions.Sum(self.table_a.revenue)) + .groupby(self.table_a.customer) + .having(functions.Sum(self.table_a.revenue) >= 1000) + ) + query = query.replace_table(self.table_a, self.table_b) + + self.assertEqual( + 'SELECT SUM("revenue") ' 'FROM "b" ' 'GROUP BY "customer" ' 'HAVING SUM("revenue")>=1000', + str(query), + ) + + def test_replace_case_table(self): + query = Query.from_(self.table_a).select( + Case() + .when(self.table_a.fname == "Tom", "It was Tom") + .when(self.table_a.fname == "John", "It was John") + .else_("It was someone else.") + .as_("who_was_it") + ) + query = query.replace_table(self.table_a, self.table_b) + + self.assertEqual( + "SELECT CASE " + "WHEN \"fname\"='Tom' THEN 'It was Tom' " + "WHEN \"fname\"='John' THEN 'It was John' " + "ELSE 'It was someone else.' END \"who_was_it\" " + 'FROM "b"', + str(query), + ) + + def test_replace_orderby_table(self): + query = Query.from_(self.table_a).select(self.table_a.customer).orderby(self.table_a.customer) + query = query.replace_table(self.table_a, self.table_b) + + self.assertEqual('SELECT "customer" FROM "b" ORDER BY "customer"', str(query)) + + def test_replace_tuple_table(self): + query = ( + Query.from_(self.table_a) + .select(self.table_a.cost, self.table_a.revenue) + .where((self.table_a.cost, self.table_a.revenue) == Tuple(1, 2)) + ) + + query = query.replace_table(self.table_a, self.table_b) + + # Order is reversed due to lack of right equals method + self.assertEqual( + 'SELECT "cost","revenue" FROM "b" WHERE (1,2)=("cost","revenue")', + str(query), + ) + + def test_is_joined(self): + q = Query.from_(self.table_a).join(self.table_b).on(self.table_a.foo == self.table_b.boo) + + self.assertTrue(q.is_joined(self.table_b)) + self.assertFalse(q.is_joined(self.table_c)) + + +class QueryBuilderTests(unittest.TestCase): + def test_query_builders_have_reference_to_correct_query_class(self): + with self.subTest('QueryBuilder'): + self.assertEqual(Query, QueryBuilder.QUERY_CLS) + + with self.subTest('DropQueryBuilder'): + self.assertEqual(Query, DropQueryBuilder.QUERY_CLS) + + with self.subTest('CreateQueryBuilder'): + self.assertEqual(Query, CreateQueryBuilder.QUERY_CLS) + + with self.subTest('MySQLQueryBuilder'): + self.assertEqual(MySQLQuery, MySQLQueryBuilder.QUERY_CLS) + + with self.subTest('MySQLLoadQueryBuilder'): + self.assertEqual(MySQLQuery, MySQLLoadQueryBuilder.QUERY_CLS) + + with self.subTest('VerticaQueryBuilder'): + self.assertEqual(VerticaQuery, VerticaQueryBuilder.QUERY_CLS) + + with self.subTest('VerticaCreateQueryBuilder'): + self.assertEqual(VerticaQuery, VerticaCreateQueryBuilder.QUERY_CLS) + + with self.subTest('VerticaCopyQueryBuilder'): + self.assertEqual(VerticaQuery, VerticaCopyQueryBuilder.QUERY_CLS) + + with self.subTest('PostgreSQLQueryBuilder'): + self.assertEqual(PostgreSQLQuery, PostgreSQLQueryBuilder.QUERY_CLS) + + with self.subTest('MSSQLQueryBuilder'): + self.assertEqual(MSSQLQuery, MSSQLQueryBuilder.QUERY_CLS) + + with self.subTest('SnowflakeQueryBuilder'): + self.assertEqual(SnowflakeQuery, SnowflakeQueryBuilder.QUERY_CLS) + + with self.subTest('ClickHouseQueryBuilder'): + self.assertEqual(ClickHouseQuery, ClickHouseQueryBuilder.QUERY_CLS) + + with self.subTest('RedShiftQueryBuilder'): + self.assertEqual(RedshiftQuery, RedShiftQueryBuilder.QUERY_CLS) + + with self.subTest('SQLLiteQueryBuilder'): + self.assertEqual(SQLLiteQuery, SQLLiteQueryBuilder.QUERY_CLS) + + with self.subTest('OracleQueryBuilder'): + self.assertEqual(OracleQuery, OracleQueryBuilder.QUERY_CLS) + + def test_pipe(self) -> None: + base_query = Query.from_("test") + + def select(query: QueryBuilder) -> QueryBuilder: + return query.select("test1", "test2") + + def count_group(query: QueryBuilder, *groups) -> QueryBuilder: + return query.groupby(*groups).select(*groups, functions.Count("*")) + + for func, args, kwargs, expected_str in [ + (select, [], {}, 'SELECT "test1","test2" FROM "test"'), + ( + count_group, + ["test1", "test2"], + {}, + 'SELECT "test1","test2",COUNT(*) FROM "test" GROUP BY "test1","test2"', + ), + (count_group, ["test1"], {}, 'SELECT "test1",COUNT(*) FROM "test" GROUP BY "test1"'), + ]: + result_str = str(base_query.pipe(func, *args, **kwargs)) + self.assertEqual(result_str, str(func(base_query, *args, **kwargs))) + self.assertEqual(result_str, expected_str) + + def where_clause(query: QueryBuilder, num_days: int) -> QueryBuilder: + return query.where(Field("date") > functions.Now() - num_days) + + result_str = str(base_query.pipe(select).pipe(where_clause, num_days=1)) + self.assertEqual( + result_str, + str(select(where_clause(base_query, num_days=1))), + ) + self.assertEqual( + result_str, + 'SELECT "test1","test2" FROM "test" WHERE "date">NOW()-1', + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/test_selects.py b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/test_selects.py new file mode 100644 index 0000000000000000000000000000000000000000..1ce04937492e655db362b7e2a0a6856abf22a48f --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/test_selects.py @@ -0,0 +1,1331 @@ +import unittest +from datetime import date +from enum import Enum + +from pypika import ( + AliasedQuery, + Case, + ClickHouseQuery, + EmptyCriterion, + Field as F, + Index, + MSSQLQuery, + MySQLQuery, + NullValue, + OracleQuery, + Order, + PostgreSQLQuery, + Query, + QueryException, + RedshiftQuery, + SQLLiteQuery, + Table, + Tables, + VerticaQuery, + functions as fn, + SYSTEM_TIME, +) +from pypika.terms import ValueWrapper + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + + +class SelectTests(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_empty_query(self): + q = Query.from_("abc") + + self.assertEqual("", str(q)) + + def test_select_no_from(self): + q = Query.select(1) + + self.assertEqual("SELECT 1", str(q)) + + def test_select_no_with_alias_from(self): + q = Query.select(ValueWrapper(1, "test")) + + self.assertEqual('SELECT 1 "test"', str(q)) + + def test_select_no_from_with_field_raises_exception(self): + with self.assertRaises(QueryException): + Query.select("asdf") + + def test_select__star(self): + q = Query.from_("abc").select("*") + + self.assertEqual('SELECT * FROM "abc"', str(q)) + + def test_select__table_schema(self): + q = Query.from_(Table("abc", "schema1")).select("*") + + self.assertEqual('SELECT * FROM "schema1"."abc"', str(q)) + + def test_select__table_schema_with_multiple_levels_as_tuple(self): + q = Query.from_(Table("abc", ("schema1", "schema2"))).select("*") + + self.assertEqual('SELECT * FROM "schema1"."schema2"."abc"', str(q)) + + def test_select__table_schema_with_multiple_levels_as_list(self): + q = Query.from_(Table("abc", ["schema1", "schema2"])).select("*") + + self.assertEqual('SELECT * FROM "schema1"."schema2"."abc"', str(q)) + + def test_select__star__replacement(self): + q = Query.from_("abc").select("foo").select("*") + + self.assertEqual('SELECT * FROM "abc"', str(q)) + + def test_select__distinct__single(self): + q = Query.from_("abc").select("foo").distinct() + + self.assertEqual('SELECT DISTINCT "foo" FROM "abc"', str(q)) + + def test_select__distinct__multi(self): + q = Query.from_("abc").select("foo", "bar").distinct() + + self.assertEqual('SELECT DISTINCT "foo","bar" FROM "abc"', str(q)) + + def test_select__column__single__str(self): + q = Query.from_("abc").select("foo") + + self.assertEqual('SELECT "foo" FROM "abc"', str(q)) + + def test_select__column__single__alias__str(self): + q = Query.from_(self.table_abc).select(self.table_abc.foo.as_("bar")) + + self.assertEqual('SELECT "foo" "bar" FROM "abc"', str(q)) + + def test_select__column__single__table_alias__str(self): + q = Query.from_(self.table_abc.as_("fizzbuzz")).select(self.table_abc.foo.as_("bar")) + + self.assertEqual('SELECT "foo" "bar" FROM "abc" "fizzbuzz"', str(q)) + + def test_select__column__single__field(self): + t = Table("abc") + q = Query.from_(t).select(t.foo) + + self.assertEqual('SELECT "foo" FROM "abc"', str(q)) + + def test_select__columns__multi__str(self): + q1 = Query.from_("abc").select("foo", "bar") + q2 = Query.from_("abc").select("foo").select("bar") + + self.assertEqual('SELECT "foo","bar" FROM "abc"', str(q1)) + self.assertEqual('SELECT "foo","bar" FROM "abc"', str(q2)) + + def test_select__columns__multi__field(self): + q1 = Query.from_(self.table_abc).select(self.table_abc.foo, self.table_abc.bar) + q2 = Query.from_(self.table_abc).select(self.table_abc.foo).select(self.table_abc.bar) + + self.assertEqual('SELECT "foo","bar" FROM "abc"', str(q1)) + self.assertEqual('SELECT "foo","bar" FROM "abc"', str(q2)) + + def test_select__multiple_tables(self): + q = Query.from_(self.table_abc).select(self.table_abc.foo).from_(self.table_efg).select(self.table_efg.bar) + + self.assertEqual('SELECT "abc"."foo","efg"."bar" FROM "abc","efg"', str(q)) + + def test_select__subquery(self): + subquery = Query.from_(self.table_abc).select("*") + q = Query.from_(subquery).select(subquery.foo, subquery.bar) + + self.assertEqual('SELECT "sq0"."foo","sq0"."bar" ' 'FROM (SELECT * FROM "abc") "sq0"', str(q)) + + def test_select__multiple_subqueries(self): + subquery0 = Query.from_(self.table_abc).select("foo") + subquery1 = Query.from_(self.table_efg).select("bar") + q = Query.from_(subquery0).from_(subquery1).select(subquery0.foo, subquery1.bar) + + self.assertEqual( + 'SELECT "sq0"."foo","sq1"."bar" ' 'FROM (SELECT "foo" FROM "abc") "sq0",' '(SELECT "bar" FROM "efg") "sq1"', + str(q), + ) + + def test_select__nested_subquery(self): + subquery0 = Query.from_(self.table_abc).select("*") + subquery1 = Query.from_(subquery0).select(subquery0.foo, subquery0.bar) + subquery2 = Query.from_(subquery1).select(subquery1.foo) + + q = Query.from_(subquery2).select(subquery2.foo) + + self.assertEqual( + 'SELECT "sq2"."foo" ' + 'FROM (SELECT "sq1"."foo" ' + 'FROM (SELECT "sq0"."foo","sq0"."bar" ' + 'FROM (SELECT * FROM "abc") "sq0") "sq1") "sq2"', + str(q), + ) + + def test_select__no_table(self): + q = Query.select(1, 2, 3) + + self.assertEqual("SELECT 1,2,3", str(q)) + + def test_select_then_add_table(self): + q = Query.select(1).select(2, 3).from_("abc").select("foo") + + self.assertEqual('SELECT 1,2,3,"foo" FROM "abc"', str(q)) + + def test_select_with_limit(self): + q1 = Query.from_("abc").select("foo")[:10] + + self.assertEqual('SELECT "foo" FROM "abc" LIMIT 10', str(q1)) + + def test_select_with_limit_zero(self): + with self.subTest('using python slice'): + q1 = Query.from_("abc").select("foo")[:0] + self.assertEqual('SELECT "foo" FROM "abc" LIMIT 0', str(q1)) + + with self.subTest('using limit method'): + q2 = Query.from_("abc").select("foo").limit(0) + self.assertEqual('SELECT "foo" FROM "abc" LIMIT 0', str(q2)) + + def test_select_with_limit__func(self): + q1 = Query.from_("abc").select("foo").limit(10) + + self.assertEqual('SELECT "foo" FROM "abc" LIMIT 10', str(q1)) + + def test_select_with_offset(self): + q1 = Query.from_("abc").select("foo")[10:] + + self.assertEqual('SELECT "foo" FROM "abc" OFFSET 10', str(q1)) + + def test_select_with_offset__func(self): + q1 = Query.from_("abc").select("foo").offset(10) + + self.assertEqual('SELECT "foo" FROM "abc" OFFSET 10', str(q1)) + + def test_select_with_limit_and_offset(self): + q1 = Query.from_("abc").select("foo")[10:10] + + self.assertEqual('SELECT "foo" FROM "abc" LIMIT 10 OFFSET 10', str(q1)) + + def test_select_with_force_index(self): + q = Query.from_("abc").select("foo").force_index("egg") + + self.assertEqual('SELECT "foo" FROM "abc" FORCE INDEX ("egg")', str(q)) + + def test_select_with_force_index_with_index_object(self): + index = Index("egg") + q = Query.from_("abc").select("foo").force_index(index) + + self.assertEqual('SELECT "foo" FROM "abc" FORCE INDEX ("egg")', str(q)) + + def test_select_with_force_index_multiple_indexes(self): + q = Query.from_("abc").select("foo").force_index("egg", "bacon") + + self.assertEqual('SELECT "foo" FROM "abc" FORCE INDEX ("egg","bacon")', str(q)) + + def test_select_with_force_index_multiple_calls(self): + q = ( + Query.from_("abc") + .select("foo") + .force_index( + "egg", + ) + .force_index("spam") + ) + + self.assertEqual('SELECT "foo" FROM "abc" FORCE INDEX ("egg","spam")', str(q)) + + def test_select_with_use_index(self): + q = Query.from_("abc").select("foo").use_index("egg") + + self.assertEqual('SELECT "foo" FROM "abc" USE INDEX ("egg")', str(q)) + + def test_select_with_use_index_with_index_object(self): + index = Index("egg") + q = Query.from_("abc").select("foo").use_index(index) + + self.assertEqual('SELECT "foo" FROM "abc" USE INDEX ("egg")', str(q)) + + def test_select_with_use_index_multiple_indexes(self): + q = Query.from_("abc").select("foo").use_index("egg", "bacon") + + self.assertEqual('SELECT "foo" FROM "abc" USE INDEX ("egg","bacon")', str(q)) + + def test_select_with_use_index_multiple_calls(self): + q = ( + Query.from_("abc") + .select("foo") + .use_index( + "egg", + ) + .use_index("spam") + ) + + self.assertEqual('SELECT "foo" FROM "abc" USE INDEX ("egg","spam")', str(q)) + + def test_mysql_query_uses_backtick_quote_chars(self): + q = MySQLQuery.from_("abc").select("foo", "bar") + + self.assertEqual("SELECT `foo`,`bar` FROM `abc`", str(q)) + + def test_vertica_query_uses_double_quote_chars(self): + q = VerticaQuery.from_("abc").select("foo", "bar") + + self.assertEqual('SELECT "foo","bar" FROM "abc"', str(q)) + + def test_mssql_query_uses_double_quote_chars(self): + q = MSSQLQuery.from_("abc").select("foo", "bar") + + self.assertEqual('SELECT "foo","bar" FROM "abc"', str(q)) + + def test_oracle_query_uses_no_quote_chars(self): + q = OracleQuery.from_("abc").select("foo", "bar") + + self.assertEqual('SELECT foo,bar FROM abc', str(q)) + + def test_postgresql_query_uses_double_quote_chars(self): + q = PostgreSQLQuery.from_("abc").select("foo", "bar") + + self.assertEqual('SELECT "foo","bar" FROM "abc"', str(q)) + + def test_redshift_query_uses_double_quote_chars(self): + q = RedshiftQuery.from_("abc").select("foo", "bar") + + self.assertEqual('SELECT "foo","bar" FROM "abc"', str(q)) + + def test_table_select_alias(self): + q = self.table_abc.select(1) + + self.assertEqual('SELECT 1 FROM "abc"', str(q)) + self.assertEqual(q, Query.from_("abc").select(1)) + + def test_table_select_alias_with_offset_and_limit(self): + self.assertEqual(self.table_abc.select("foo")[10:10], Query.from_("abc").select("foo")[10:10]) + self.assertEqual( + self.table_abc.select(self.table_abc.foo)[10:10], + Query.from_("abc").select("foo")[10:10], + ) + + def test_temporal_select(self): + t = Table("abc") + + with self.subTest("with system time as of"): + q = Query.from_(t.for_(SYSTEM_TIME.as_of('2020-01-01'))).select("*") + + self.assertEqual('SELECT * FROM "abc" FOR SYSTEM_TIME AS OF \'2020-01-01\'', str(q)) + + with self.subTest("with system time between"): + q = Query.from_(t.for_(SYSTEM_TIME.between('2020-01-01', '2020-02-01'))).select("*") + + self.assertEqual('SELECT * FROM "abc" FOR SYSTEM_TIME BETWEEN \'2020-01-01\' AND \'2020-02-01\'', str(q)) + + with self.subTest("with system time from to"): + q = Query.from_(t.for_(SYSTEM_TIME.from_to('2020-01-01', '2020-02-01'))).select("*") + + self.assertEqual('SELECT * FROM "abc" FOR SYSTEM_TIME FROM \'2020-01-01\' TO \'2020-02-01\'', str(q)) + + with self.subTest("with ALL"): + q = Query.from_(t.for_(SYSTEM_TIME.all_())).select("*") + + self.assertEqual('SELECT * FROM "abc" FOR SYSTEM_TIME ALL', str(q)) + + with self.subTest("with period between"): + q = Query.from_(t.for_(t.valid_period.between('2020-01-01', '2020-02-01'))).select("*") + + self.assertEqual('SELECT * FROM "abc" FOR "valid_period" BETWEEN \'2020-01-01\' AND \'2020-02-01\'', str(q)) + + with self.subTest("with period from to"): + q = Query.from_(t.for_(t.valid_period.from_to('2020-01-01', '2020-02-01'))).select("*") + + self.assertEqual('SELECT * FROM "abc" FOR "valid_period" FROM \'2020-01-01\' TO \'2020-02-01\'', str(q)) + + with self.subTest("with ALL"): + q = Query.from_(t.for_(t.valid_period.all_())).select("*") + + self.assertEqual('SELECT * FROM "abc" FOR "valid_period" ALL', str(q)) + + +class MyEnum(Enum): + STR = "foo" + INT = 0 + BOOL = True + DATE = date(2020, 2, 2) + NONE = None + + +class WhereTests(unittest.TestCase): + t = Table("abc") + t2 = Table("cba") + + def test_where_enum(self): + q1 = Query.from_(self.t).select("*").where(self.t.foo == MyEnum.STR) + q2 = Query.from_(self.t).select("*").where(self.t.foo == MyEnum.INT) + q3 = Query.from_(self.t).select("*").where(self.t.foo == MyEnum.BOOL) + q4 = Query.from_(self.t).select("*").where(self.t.foo == MyEnum.DATE) + q5 = Query.from_(self.t).select("*").where(self.t.foo == MyEnum.NONE) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo"=\'foo\'', str(q1)) + self.assertEqual('SELECT * FROM "abc" WHERE "foo"=0', str(q2)) + self.assertEqual('SELECT * FROM "abc" WHERE "foo"=true', str(q3)) + self.assertEqual('SELECT * FROM "abc" WHERE "foo"=\'2020-02-02\'', str(q4)) + self.assertEqual('SELECT * FROM "abc" WHERE "foo"=null', str(q5)) + + def test_where_field_equals(self): + q1 = Query.from_(self.t).select("*").where(self.t.foo == self.t.bar) + q2 = Query.from_(self.t).select("*").where(self.t.foo.eq(self.t.bar)) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo"="bar"', str(q1)) + self.assertEqual('SELECT * FROM "abc" WHERE "foo"="bar"', str(q2)) + q = self.t.select("*").where(self.t.foo == self.t.bar) + self.assertEqual(q, q1) + + def test_where_field_equals_for_update(self): + q = Query.from_(self.t).select("*").where(self.t.foo == self.t.bar).for_update() + self.assertEqual('SELECT * FROM "abc" WHERE "foo"="bar" FOR UPDATE', str(q)) + + def test_where_field_equals_for_update_nowait(self): + for query_cls in [ + MySQLQuery, + PostgreSQLQuery, + ]: + quote_char = query_cls._builder().QUOTE_CHAR if isinstance(query_cls._builder().QUOTE_CHAR, str) else '"' + q = query_cls.from_(self.t).select("*").where(self.t.foo == self.t.bar).for_update(nowait=True) + self.assertEqual( + 'SELECT * ' + 'FROM {quote_char}abc{quote_char} ' + 'WHERE {quote_char}foo{quote_char}={quote_char}bar{quote_char} ' + 'FOR UPDATE NOWAIT'.format( + quote_char=quote_char, + ), + str(q), + ) + + def test_where_field_equals_for_update_skip_locked(self): + for query_cls in [ + MySQLQuery, + PostgreSQLQuery, + ]: + quote_char = query_cls._builder().QUOTE_CHAR if isinstance(query_cls._builder().QUOTE_CHAR, str) else '"' + q = query_cls.from_(self.t).select("*").where(self.t.foo == self.t.bar).for_update(skip_locked=True) + self.assertEqual( + 'SELECT * ' + 'FROM {quote_char}abc{quote_char} ' + 'WHERE {quote_char}foo{quote_char}={quote_char}bar{quote_char} ' + 'FOR UPDATE SKIP LOCKED'.format( + quote_char=quote_char, + ), + str(q), + ) + + def test_where_field_equals_for_update_of(self): + for query_cls in [ + MySQLQuery, + PostgreSQLQuery, + ]: + quote_char = query_cls._builder().QUOTE_CHAR if isinstance(query_cls._builder().QUOTE_CHAR, str) else '"' + q = query_cls.from_(self.t).select("*").where(self.t.foo == self.t.bar).for_update(of=("abc",)) + self.assertEqual( + 'SELECT * ' + 'FROM {quote_char}abc{quote_char} ' + 'WHERE {quote_char}foo{quote_char}={quote_char}bar{quote_char} ' + 'FOR UPDATE OF {quote_char}abc{quote_char}'.format( + quote_char=quote_char, + ), + str(q), + ) + + def test_where_field_equals_for_update_of_multiple_tables(self): + for query_cls in [ + MySQLQuery, + PostgreSQLQuery, + ]: + q = ( + query_cls.from_(self.t) + .join(self.t2) + .on(self.t.id == self.t2.abc_id) + .select("*") + .where(self.t.foo == self.t.bar) + .for_update(of=("abc", "cba")) + ) + quote_char = query_cls._builder().QUOTE_CHAR if isinstance(query_cls._builder().QUOTE_CHAR, str) else '"' + self.assertIn( + str(q), + [ + 'SELECT * ' + 'FROM {quote_char}abc{quote_char} ' + 'JOIN {quote_char}cba{quote_char} ' + 'ON {quote_char}abc{quote_char}.{quote_char}id{quote_char}=' + '{quote_char}cba{quote_char}.{quote_char}abc_id{quote_char} ' + 'WHERE {quote_char}abc{quote_char}.{quote_char}foo{quote_char}=' + '{quote_char}abc{quote_char}.{quote_char}bar{quote_char} ' + 'FOR UPDATE OF {quote_char}cba{quote_char}, {quote_char}abc{quote_char}'.format( + quote_char=quote_char, + ), + 'SELECT * ' + 'FROM {quote_char}abc{quote_char} ' + 'JOIN {quote_char}cba{quote_char} ' + 'ON {quote_char}abc{quote_char}.{quote_char}id{quote_char}=' + '{quote_char}cba{quote_char}.{quote_char}abc_id{quote_char} ' + 'WHERE {quote_char}abc{quote_char}.{quote_char}foo{quote_char}=' + '{quote_char}abc{quote_char}.{quote_char}bar{quote_char} ' + 'FOR UPDATE OF {quote_char}abc{quote_char}, {quote_char}cba{quote_char}'.format( + quote_char=quote_char, + ), + ], + ) + + def test_where_field_equals_for_update_of_nowait(self): + for query_cls in [ + MySQLQuery, + PostgreSQLQuery, + ]: + q = query_cls.from_(self.t).select("*").where(self.t.foo == self.t.bar).for_update(of=("abc",), nowait=True) + quote_char = query_cls._builder().QUOTE_CHAR if isinstance(query_cls._builder().QUOTE_CHAR, str) else '"' + self.assertEqual( + 'SELECT * ' + 'FROM {quote_char}abc{quote_char} ' + 'WHERE {quote_char}foo{quote_char}={quote_char}bar{quote_char} ' + 'FOR UPDATE OF {quote_char}abc{quote_char} NOWAIT'.format( + quote_char=quote_char, + ), + str(q), + ) + + def test_where_field_equals_for_update_of_skip_locked(self): + for query_cls in [ + MySQLQuery, + PostgreSQLQuery, + ]: + q = ( + query_cls.from_(self.t) + .select("*") + .where(self.t.foo == self.t.bar) + .for_update(of=("abc",), skip_locked=True) + ) + quote_char = query_cls._builder().QUOTE_CHAR if isinstance(query_cls._builder().QUOTE_CHAR, str) else '"' + self.assertEqual( + 'SELECT * ' + 'FROM {quote_char}abc{quote_char} ' + 'WHERE {quote_char}foo{quote_char}={quote_char}bar{quote_char} ' + 'FOR UPDATE OF {quote_char}abc{quote_char} SKIP LOCKED'.format( + quote_char=quote_char, + ), + str(q), + ) + + def test_where_field_equals_for_update_skip_locked_and_of(self): + for query_cls in [ + MySQLQuery, + PostgreSQLQuery, + ]: + q = ( + query_cls.from_(self.t) + .select("*") + .where(self.t.foo == self.t.bar) + .for_update(nowait=False, skip_locked=True, of=("abc",)) + ) + quote_char = query_cls._builder().QUOTE_CHAR if isinstance(query_cls._builder().QUOTE_CHAR, str) else '"' + self.assertEqual( + 'SELECT * ' + 'FROM {quote_char}abc{quote_char} ' + 'WHERE {quote_char}foo{quote_char}={quote_char}bar{quote_char} ' + 'FOR UPDATE OF {quote_char}abc{quote_char} SKIP LOCKED'.format( + quote_char=quote_char, + ), + str(q), + ) + + def test_where_field_equals_where(self): + q = Query.from_(self.t).select("*").where(self.t.foo == 1).where(self.t.bar == self.t.baz) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo"=1 AND "bar"="baz"', str(q)) + + def test_where_field_equals_where_not(self): + q = Query.from_(self.t).select("*").where((self.t.foo == 1).negate()).where(self.t.bar == self.t.baz) + + self.assertEqual('SELECT * FROM "abc" WHERE NOT "foo"=1 AND "bar"="baz"', str(q)) + + def test_where_field_equals_where_two_not(self): + q = Query.from_(self.t).select("*").where((self.t.foo == 1).negate()).where((self.t.bar == self.t.baz).negate()) + + self.assertEqual('SELECT * FROM "abc" WHERE NOT "foo"=1 AND NOT "bar"="baz"', str(q)) + + def test_where_single_quote(self): + q1 = Query.from_(self.t).select("*").where(self.t.foo == "bar'foo") + + self.assertEqual("SELECT * FROM \"abc\" WHERE \"foo\"='bar''foo'", str(q1)) + + def test_where_field_equals_and(self): + q = Query.from_(self.t).select("*").where((self.t.foo == 1) & (self.t.bar == self.t.baz)) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo"=1 AND "bar"="baz"', str(q)) + + def test_where_field_equals_or(self): + q = Query.from_(self.t).select("*").where((self.t.foo == 1) | (self.t.bar == self.t.baz)) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo"=1 OR "bar"="baz"', str(q)) + + def test_where_nested_conditions(self): + q = Query.from_(self.t).select("*").where((self.t.foo == 1) | (self.t.bar == self.t.baz)).where(self.t.baz == 0) + + self.assertEqual('SELECT * FROM "abc" WHERE ("foo"=1 OR "bar"="baz") AND "baz"=0', str(q)) + + def test_where_field_starts_with(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.like("ab%")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" LIKE \'ab%\'', str(q)) + + def test_where_field_contains(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.like("%fg%")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" LIKE \'%fg%\'', str(q)) + + def test_where_field_ends_with(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.like("%yz")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" LIKE \'%yz\'', str(q)) + + def test_where_field_is_n_chars_long(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.like("___")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" LIKE \'___\'', str(q)) + + def test_where_field_does_not_start_with(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.not_like("ab%")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" NOT LIKE \'ab%\'', str(q)) + + def test_where_field_does_not_contain(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.not_like("%fg%")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" NOT LIKE \'%fg%\'', str(q)) + + def test_where_field_does_not_end_with(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.not_like("%yz")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" NOT LIKE \'%yz\'', str(q)) + + def test_where_field_is_not_n_chars_long(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.not_like("___")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" NOT LIKE \'___\'', str(q)) + + def test_where_field_matches_regex(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.regex(r"^b")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" REGEX \'^b\'', str(q)) + + def test_where_field_matches_regexp(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.regexp(r"^b")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" REGEXP \'^b\'', str(q)) + + def test_where_field_matches_rlike(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.rlike(r"^b")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" RLIKE \'^b\'', str(q)) + + def test_ignore_empty_criterion_where(self): + q1 = Query.from_(self.t).select("*").where(EmptyCriterion()) + + self.assertEqual('SELECT * FROM "abc"', str(q1)) + + def test_ignore_empty_criterion_having(self): + q1 = Query.from_(self.t).select("*").having(EmptyCriterion()) + + self.assertEqual('SELECT * FROM "abc"', str(q1)) + + def test_select_with_force_index_and_where(self): + q = Query.from_("abc").select("foo").where(self.t.foo == self.t.bar).force_index("egg") + + self.assertEqual('SELECT "foo" FROM "abc" FORCE INDEX ("egg") WHERE "foo"="bar"', str(q)) + + def test_where_with_multiple_wheres_using_and_case(self): + case_stmt = Case().when(self.t.foo == 'bar', 1).else_(0) + query = Query.from_(self.t).select(case_stmt).where(case_stmt & self.t.blah.isin(['test'])) + + self.assertEqual( + 'SELECT CASE WHEN "foo"=\'bar\' THEN 1 ELSE 0 END FROM "abc" WHERE CASE WHEN "foo"=\'bar\' THEN 1 ELSE 0 ' + 'END AND "blah" IN (\'test\')', + str(query), + ) + + def test_where_with_multiple_wheres_using_or_case(self): + case_stmt = Case().when(self.t.foo == 'bar', 1).else_(0) + query = Query.from_(self.t).select(case_stmt).where(case_stmt | self.t.blah.isin(['test'])) + + self.assertEqual( + 'SELECT CASE WHEN "foo"=\'bar\' THEN 1 ELSE 0 END FROM "abc" WHERE CASE WHEN "foo"=\'bar\' THEN 1 ELSE 0 ' + 'END OR "blah" IN (\'test\')', + str(query), + ) + + +class PreWhereTests(WhereTests): + t = Table("abc") + + def test_prewhere_field_equals(self): + q1 = Query.from_(self.t).select("*").prewhere(self.t.foo == self.t.bar) + q2 = Query.from_(self.t).select("*").prewhere(self.t.foo.eq(self.t.bar)) + + self.assertEqual('SELECT * FROM "abc" PREWHERE "foo"="bar"', str(q1)) + self.assertEqual('SELECT * FROM "abc" PREWHERE "foo"="bar"', str(q2)) + + def test_where_and_prewhere(self): + q = Query.from_(self.t).select("*").prewhere(self.t.foo == self.t.bar).where(self.t.foo == self.t.bar) + + self.assertEqual('SELECT * FROM "abc" PREWHERE "foo"="bar" WHERE "foo"="bar"', str(q)) + + +class GroupByTests(unittest.TestCase): + t = Table("abc") + maxDiff = None + + def test_groupby__single(self): + q = Query.from_(self.t).groupby(self.t.foo).select(self.t.foo) + + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo"', str(q)) + + def test_groupby__multi(self): + q = Query.from_(self.t).groupby(self.t.foo, self.t.bar).select(self.t.foo, self.t.bar) + + self.assertEqual('SELECT "foo","bar" FROM "abc" GROUP BY "foo","bar"', str(q)) + + def test_groupby__count_star(self): + q = Query.from_(self.t).groupby(self.t.foo).select(self.t.foo, fn.Count("*")) + + self.assertEqual('SELECT "foo",COUNT(*) FROM "abc" GROUP BY "foo"', str(q)) + + def test_groupby__count_field(self): + q = Query.from_(self.t).groupby(self.t.foo).select(self.t.foo, fn.Count(self.t.bar)) + + self.assertEqual('SELECT "foo",COUNT("bar") FROM "abc" GROUP BY "foo"', str(q)) + + def test_groupby__count_distinct(self): + q = Query.from_(self.t).groupby(self.t.foo).select(self.t.foo, fn.Count("*").distinct()) + + self.assertEqual('SELECT "foo",COUNT(DISTINCT *) FROM "abc" GROUP BY "foo"', str(q)) + + def test_groupby__sum_distinct(self): + q = Query.from_(self.t).groupby(self.t.foo).select(self.t.foo, fn.Sum(self.t.bar).distinct()) + + self.assertEqual('SELECT "foo",SUM(DISTINCT "bar") FROM "abc" GROUP BY "foo"', str(q)) + + def test_groupby__sum_filter(self): + q = ( + Query.from_(self.t) + .groupby(self.t.foo) + .select(self.t.foo, fn.Sum(self.t.bar).filter(self.t.id.eq(1) & self.t.cid.gt(2))) + ) + + self.assertEqual('SELECT "foo",SUM("bar") FILTER(WHERE "id"=1 AND "cid">2) FROM "abc" GROUP BY "foo"', str(q)) + + def test_groupby__str(self): + q = Query.from_("abc").groupby("foo").select("foo", fn.Count("*").distinct()) + + self.assertEqual('SELECT "foo",COUNT(DISTINCT *) FROM "abc" GROUP BY "foo"', str(q)) + + def test_groupby__int(self): + q = Query.from_("abc").groupby(1).select("foo", fn.Count("*").distinct()) + + self.assertEqual('SELECT "foo",COUNT(DISTINCT *) FROM "abc" GROUP BY 1', str(q)) + + def test_groupby__alias(self): + bar = self.t.bar.as_("bar01") + q = Query.from_(self.t).select(fn.Sum(self.t.foo), bar).groupby(bar) + + self.assertEqual('SELECT SUM("foo"),"bar" "bar01" FROM "abc" GROUP BY "bar01"', str(q)) + + def test_groupby__no_alias(self): + bar = self.t.bar.as_("bar01") + q = Query.from_(self.t).select(fn.Sum(self.t.foo), bar).groupby(bar) + + self.assertEqual( + 'SELECT SUM("foo"),"bar" "bar01" FROM "abc" GROUP BY "bar"', + q.get_sql(groupby_alias=False), + ) + + def test_groupby__no_alias_mssql(self): + bar = self.t.bar.as_("bar01") + q = MSSQLQuery.from_(self.t).select(fn.Sum(self.t.foo), bar).groupby(bar) + + self.assertEqual('SELECT SUM("foo"),"bar" "bar01" FROM "abc" GROUP BY "bar"', str(q)) + + def test_groupby__no_alias_oracle(self): + bar = self.t.bar.as_("bar01") + q = OracleQuery.from_(self.t).select(fn.Sum(self.t.foo), bar).groupby(bar) + + self.assertEqual('SELECT SUM(foo),bar bar01 FROM abc GROUP BY bar', str(q)) + + def test_groupby__alias_platforms(self): + bar = self.t.bar.as_("bar01") + + for query_cls in [ + MySQLQuery, + VerticaQuery, + PostgreSQLQuery, + RedshiftQuery, + ClickHouseQuery, + SQLLiteQuery, + ]: + q = query_cls.from_(self.t).select(fn.Sum(self.t.foo), bar).groupby(bar) + + quote_char = query_cls._builder().QUOTE_CHAR if isinstance(query_cls._builder().QUOTE_CHAR, str) else '"' + + self.assertEqual( + "SELECT " + "SUM({quote_char}foo{quote_char})," + "{quote_char}bar{quote_char}{as_keyword}{quote_char}bar01{quote_char} " + "FROM {quote_char}abc{quote_char} " + "GROUP BY {quote_char}bar01{quote_char}".format( + as_keyword=' AS ' if query_cls is ClickHouseQuery else ' ', quote_char=quote_char + ), + str(q), + ) + + def test_groupby__alias_with_join(self): + table1 = Table("table1", alias="t1") + bar = table1.bar.as_("bar01") + q = Query.from_(self.t).join(table1).on(self.t.id == table1.t_ref).select(fn.Sum(self.t.foo), bar).groupby(bar) + + self.assertEqual( + 'SELECT SUM("abc"."foo"),"t1"."bar" "bar01" FROM "abc" ' + 'JOIN "table1" "t1" ON "abc"."id"="t1"."t_ref" ' + 'GROUP BY "bar01"', + str(q), + ) + + def test_groupby_with_case_uses_the_alias(self): + q = ( + Query.from_(self.t) + .select( + fn.Sum(self.t.foo).as_("bar"), + Case().when(self.t.fname == "Tom", "It was Tom").else_("It was someone else.").as_("who_was_it"), + ) + .groupby(Case().when(self.t.fname == "Tom", "It was Tom").else_("It was someone else.").as_("who_was_it")) + ) + + self.assertEqual( + 'SELECT SUM("foo") "bar",' + "CASE WHEN \"fname\"='Tom' THEN 'It was Tom' " + "ELSE 'It was someone else.' END \"who_was_it\" " + 'FROM "abc" ' + 'GROUP BY "who_was_it"', + str(q), + ) + + def test_mysql_query_uses_backtick_quote_chars(self): + q = MySQLQuery.from_(self.t).groupby(self.t.foo).select(self.t.foo) + + self.assertEqual("SELECT `foo` FROM `abc` GROUP BY `foo`", str(q)) + + def test_vertica_query_uses_double_quote_chars(self): + q = VerticaQuery.from_(self.t).groupby(self.t.foo).select(self.t.foo) + + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo"', str(q)) + + def test_mssql_query_uses_double_quote_chars(self): + q = MSSQLQuery.from_(self.t).groupby(self.t.foo).select(self.t.foo) + + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo"', str(q)) + + def test_oracle_query_uses_no_quote_chars(self): + q = OracleQuery.from_(self.t).groupby(self.t.foo).select(self.t.foo) + + self.assertEqual('SELECT foo FROM abc GROUP BY foo', str(q)) + + def test_postgres_query_uses_double_quote_chars(self): + q = PostgreSQLQuery.from_(self.t).groupby(self.t.foo).select(self.t.foo) + + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo"', str(q)) + + def test_redshift_query_uses_double_quote_chars(self): + q = RedshiftQuery.from_(self.t).groupby(self.t.foo).select(self.t.foo) + + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo"', str(q)) + + def test_group_by__single_with_totals(self): + q = Query.from_(self.t).groupby(self.t.foo).select(self.t.foo).with_totals() + + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo" WITH TOTALS', str(q)) + + def test_groupby__multi_with_totals(self): + q = Query.from_(self.t).groupby(self.t.foo, self.t.bar).select(self.t.foo, self.t.bar).with_totals() + + self.assertEqual('SELECT "foo","bar" FROM "abc" GROUP BY "foo","bar" WITH TOTALS', str(q)) + + +class HavingTests(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_having_greater_than(self): + q = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, fn.Sum(self.table_abc.bar)) + .groupby(self.table_abc.foo) + .having(fn.Sum(self.table_abc.bar) > 1) + ) + + self.assertEqual( + 'SELECT "foo",SUM("bar") FROM "abc" GROUP BY "foo" HAVING SUM("bar")>1', + str(q), + ) + + def test_having_and(self): + q = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, fn.Sum(self.table_abc.bar)) + .groupby(self.table_abc.foo) + .having((fn.Sum(self.table_abc.bar) > 1) & (fn.Sum(self.table_abc.bar) < 100)) + ) + + self.assertEqual( + 'SELECT "foo",SUM("bar") FROM "abc" GROUP BY "foo" HAVING SUM("bar")>1 AND SUM("bar")<100', + str(q), + ) + + def test_having_join_and_equality(self): + q = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.foo) + .select(self.table_abc.foo, fn.Sum(self.table_efg.bar), self.table_abc.buz) + .groupby(self.table_abc.foo) + .having(self.table_abc.buz == "fiz") + .having(fn.Sum(self.table_efg.bar) > 100) + ) + + self.assertEqual( + 'SELECT "abc"."foo",SUM("efg"."bar"),"abc"."buz" FROM "abc" ' + 'JOIN "efg" ON "abc"."foo"="efg"."foo" ' + 'GROUP BY "abc"."foo" ' + 'HAVING "abc"."buz"=\'fiz\' AND SUM("efg"."bar")>100', + str(q), + ) + + def test_mysql_query_uses_backtick_quote_chars(self): + q = ( + MySQLQuery.from_(self.table_abc) + .select(self.table_abc.foo) + .groupby(self.table_abc.foo) + .having(self.table_abc.buz == "fiz") + ) + self.assertEqual("SELECT `foo` FROM `abc` GROUP BY `foo` HAVING `buz`='fiz'", str(q)) + + def test_vertica_query_uses_double_quote_chars(self): + q = ( + VerticaQuery.from_(self.table_abc) + .select(self.table_abc.foo) + .groupby(self.table_abc.foo) + .having(self.table_abc.buz == "fiz") + ) + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo" HAVING "buz"=\'fiz\'', str(q)) + + def test_mssql_query_uses_double_quote_chars(self): + q = ( + MSSQLQuery.from_(self.table_abc) + .select(self.table_abc.foo) + .groupby(self.table_abc.foo) + .having(self.table_abc.buz == "fiz") + ) + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo" HAVING "buz"=\'fiz\'', str(q)) + + def test_oracle_query_uses_no_quote_chars(self): + q = ( + OracleQuery.from_(self.table_abc) + .select(self.table_abc.foo) + .groupby(self.table_abc.foo) + .having(self.table_abc.buz == "fiz") + ) + self.assertEqual('SELECT foo FROM abc GROUP BY foo HAVING buz=\'fiz\'', str(q)) + + def test_postgres_query_uses_double_quote_chars(self): + q = ( + PostgreSQLQuery.from_(self.table_abc) + .select(self.table_abc.foo) + .groupby(self.table_abc.foo) + .having(self.table_abc.buz == "fiz") + ) + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo" HAVING "buz"=\'fiz\'', str(q)) + + def test_redshift_query_uses_double_quote_chars(self): + q = ( + RedshiftQuery.from_(self.table_abc) + .select(self.table_abc.foo) + .groupby(self.table_abc.foo) + .having(self.table_abc.buz == "fiz") + ) + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo" HAVING "buz"=\'fiz\'', str(q)) + + +class OrderByTests(unittest.TestCase): + t = Table("abc") + + def test_orderby_single_field(self): + q = Query.from_(self.t).orderby(self.t.foo).select(self.t.foo) + + self.assertEqual('SELECT "foo" FROM "abc" ORDER BY "foo"', str(q)) + + def test_orderby_multi_fields(self): + q = Query.from_(self.t).orderby(self.t.foo, self.t.bar).select(self.t.foo, self.t.bar) + + self.assertEqual('SELECT "foo","bar" FROM "abc" ORDER BY "foo","bar"', str(q)) + + def test_orderby_single_str(self): + q = Query.from_("abc").orderby("foo").select("foo") + + self.assertEqual('SELECT "foo" FROM "abc" ORDER BY "foo"', str(q)) + + def test_orderby_asc(self): + q = Query.from_(self.t).orderby(self.t.foo, order=Order.asc).select(self.t.foo) + + self.assertEqual('SELECT "foo" FROM "abc" ORDER BY "foo" ASC', str(q)) + + def test_orderby_desc(self): + q = Query.from_(self.t).orderby(self.t.foo, order=Order.desc).select(self.t.foo) + + self.assertEqual('SELECT "foo" FROM "abc" ORDER BY "foo" DESC', str(q)) + + def test_orderby_no_alias(self): + bar = self.t.bar.as_("bar01") + q = Query.from_(self.t).select(fn.Sum(self.t.foo), bar).orderby(bar) + + self.assertEqual( + 'SELECT SUM("foo"),"bar" "bar01" FROM "abc" ORDER BY "bar"', + q.get_sql(orderby_alias=False), + ) + + def test_orderby_alias(self): + bar = self.t.bar.as_("bar01") + q = Query.from_(self.t).select(fn.Sum(self.t.foo), bar).orderby(bar) + + self.assertEqual('SELECT SUM("foo"),"bar" "bar01" FROM "abc" ORDER BY "bar01"', q.get_sql()) + + +class AliasTests(unittest.TestCase): + t = Table("abc") + + def test_table_field(self): + q = Query.from_(self.t).select(self.t.foo.as_("bar")) + + self.assertEqual('SELECT "foo" "bar" FROM "abc"', str(q)) + + def test_table_field__multi(self): + q = Query.from_(self.t).select(self.t.foo.as_("bar"), self.t.fiz.as_("buz")) + + self.assertEqual('SELECT "foo" "bar","fiz" "buz" FROM "abc"', str(q)) + + def test_arithmetic_function(self): + q = Query.from_(self.t).select((self.t.foo + self.t.bar).as_("biz")) + + self.assertEqual('SELECT "foo"+"bar" "biz" FROM "abc"', str(q)) + + def test_functions_using_as(self): + q = Query.from_(self.t).select(fn.Count("*").as_("foo")) + + self.assertEqual('SELECT COUNT(*) "foo" FROM "abc"', str(q)) + + def test_functions_using_constructor_param(self): + q = Query.from_(self.t).select(fn.Count("*", alias="foo")) + + self.assertEqual('SELECT COUNT(*) "foo" FROM "abc"', str(q)) + + def test_function_using_as_nested(self): + """ + We don't show aliases of fields that are arguments of a function. + """ + q = Query.from_(self.t).select(fn.Sqrt(fn.Count("*").as_("foo")).as_("bar")) + + self.assertEqual('SELECT SQRT(COUNT(*)) "bar" FROM "abc"', str(q)) + + def test_functions_using_constructor_param_nested(self): + """ + We don't show aliases of fields that are arguments of a function. + """ + q = Query.from_(self.t).select(fn.Sqrt(fn.Count("*", alias="foo"), alias="bar")) + + self.assertEqual('SELECT SQRT(COUNT(*)) "bar" FROM "abc"', str(q)) + + def test_ignored_in_where(self): + q = Query.from_(self.t).select(self.t.foo).where(self.t.foo.as_("bar") == 1) + + self.assertEqual('SELECT "foo" FROM "abc" WHERE "foo"=1', str(q)) + + def test_ignored_in_groupby(self): + q = Query.from_(self.t).select(self.t.foo).groupby(self.t.foo.as_("bar")) + + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo"', str(q)) + + def test_ignored_in_orderby(self): + q = Query.from_(self.t).select(self.t.foo).orderby(self.t.foo.as_("bar")) + + self.assertEqual('SELECT "foo" FROM "abc" ORDER BY "foo"', str(q)) + + def test_ignored_in_criterion(self): + c = self.t.foo.as_("bar") == 1 + + self.assertEqual('"foo"=1', str(c)) + + def test_ignored_in_criterion_comparison(self): + c = self.t.foo.as_("bar") == self.t.fiz.as_("buz") + + self.assertEqual('"foo"="fiz"', str(c)) + + def test_ignored_in_field_inside_case(self): + q = Query.from_(self.t).select(Case().when(self.t.foo == 1, "a").else_(self.t.bar.as_('"buz"'))) + + self.assertEqual('SELECT CASE WHEN "foo"=1 THEN \'a\' ELSE "bar" END FROM "abc"', str(q)) + + def test_case_using_as(self): + q = Query.from_(self.t).select(Case().when(self.t.foo == 1, "a").else_("b").as_("bar")) + + self.assertEqual( + 'SELECT CASE WHEN "foo"=1 THEN \'a\' ELSE \'b\' END "bar" FROM "abc"', + str(q), + ) + + def test_case_using_constructor_param(self): + q = Query.from_(self.t).select(Case(alias="bar").when(self.t.foo == 1, "a").else_("b")) + + self.assertEqual( + 'SELECT CASE WHEN "foo"=1 THEN \'a\' ELSE \'b\' END "bar" FROM "abc"', + str(q), + ) + + def test_select__multiple_tables(self): + table_abc, table_efg = Table("abc", alias="q0"), Table("efg", alias="q1") + + q = Query.from_(table_abc).select(table_abc.foo).from_(table_efg).select(table_efg.bar) + + self.assertEqual('SELECT "q0"."foo","q1"."bar" FROM "abc" "q0","efg" "q1"', str(q)) + + def test_use_aliases_in_groupby_and_orderby(self): + table_abc = Table("abc", alias="q0") + + my_foo = table_abc.foo.as_("my_foo") + q = Query.from_(table_abc).select(my_foo, table_abc.bar).groupby(my_foo).orderby(my_foo) + + self.assertEqual( + 'SELECT "q0"."foo" "my_foo","q0"."bar" ' 'FROM "abc" "q0" ' 'GROUP BY "my_foo" ' 'ORDER BY "my_foo"', + str(q), + ) + + def test_table_with_schema_and_alias(self): + table = Table("abc", schema="schema", alias="alias") + self.assertEqual('"schema"."abc" "alias"', str(table)) + + def test_null_value_with_alias(self): + q = Query.select(NullValue().as_("abcdef")) + + self.assertEqual('SELECT NULL "abcdef"', str(q)) + + +class SubqueryTests(unittest.TestCase): + maxDiff = None + + table_abc, table_efg, table_hij = Tables("abc", "efg", "hij") + + def test_where__in(self): + q = ( + Query.from_(self.table_abc) + .select("*") + .where( + self.table_abc.foo.isin( + Query.from_(self.table_efg).select(self.table_efg.foo).where(self.table_efg.bar == 0) + ) + ) + ) + + self.assertEqual( + 'SELECT * FROM "abc" WHERE "foo" IN (SELECT "foo" FROM "efg" WHERE "bar"=0)', + str(q), + ) + + def test_where__in_nested(self): + q = Query.from_(self.table_abc).select("*").where(self.table_abc.foo).isin(self.table_efg.select("*")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" IN (SELECT * FROM "efg")', str(q)) + + def test_join(self): + subquery = Query.from_("efg").select("fiz", "buz").where(F("buz") == 0) + + q = ( + Query.from_(self.table_abc) + .join(subquery) + .on(self.table_abc.bar == subquery.buz) + .select(self.table_abc.foo, subquery.fiz) + ) + + self.assertEqual( + 'SELECT "abc"."foo","sq0"."fiz" FROM "abc" ' + 'JOIN (SELECT "fiz","buz" FROM "efg" WHERE "buz"=0) "sq0" ' + 'ON "abc"."bar"="sq0"."buz"', + str(q), + ) + + def test_select_subquery(self): + subq = Query.from_(self.table_efg).select("fizzbuzz").where(self.table_efg.id == 1) + + q = Query.from_(self.table_abc).select("foo", "bar").select(subq) + + self.assertEqual( + 'SELECT "foo","bar",(SELECT "fizzbuzz" FROM "efg" WHERE "id"=1) ' 'FROM "abc"', + str(q), + ) + + def test_select_subquery_with_alias(self): + subq = Query.from_(self.table_efg).select("fizzbuzz").where(self.table_efg.id == 1) + + q = Query.from_(self.table_abc).select("foo", "bar").select(subq.as_("sq")) + + self.assertEqual( + 'SELECT "foo","bar",(SELECT "fizzbuzz" FROM "efg" WHERE "id"=1) "sq" ' 'FROM "abc"', + str(q), + ) + + def test_where__equality(self): + subquery = Query.from_("efg").select("fiz").where(F("buz") == 0) + query = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, self.table_abc.bar) + .where(self.table_abc.bar == subquery) + ) + + self.assertEqual( + 'SELECT "foo","bar" FROM "abc" ' 'WHERE "bar"=(SELECT "fiz" FROM "efg" WHERE "buz"=0)', + str(query), + ) + + def test_select_from_nested_query(self): + subquery = Query.from_(self.table_abc).select( + self.table_abc.foo, + self.table_abc.bar, + (self.table_abc.fizz + self.table_abc.buzz).as_("fizzbuzz"), + ) + + query = Query.from_(subquery).select(subquery.foo, subquery.bar, subquery.fizzbuzz) + + self.assertEqual( + 'SELECT "sq0"."foo","sq0"."bar","sq0"."fizzbuzz" ' + "FROM (" + 'SELECT "foo","bar","fizz"+"buzz" "fizzbuzz" ' + 'FROM "abc"' + ') "sq0"', + str(query), + ) + + def test_select_from_nested_query_with_join(self): + subquery1 = ( + Query.from_(self.table_abc) + .select( + self.table_abc.foo, + fn.Sum(self.table_abc.fizz + self.table_abc.buzz).as_("fizzbuzz"), + ) + .groupby(self.table_abc.foo) + ) + + subquery2 = Query.from_(self.table_efg).select( + self.table_efg.foo.as_("foo_two"), + self.table_efg.bar, + ) + + query = ( + Query.from_(subquery1) + .select(subquery1.foo, subquery1.fizzbuzz) + .join(subquery2) + .on(subquery1.foo == subquery2.foo_two) + .select(subquery2.foo_two, subquery2.bar) + ) + + self.assertEqual( + "SELECT " + '"sq0"."foo","sq0"."fizzbuzz",' + '"sq1"."foo_two","sq1"."bar" ' + "FROM (" + "SELECT " + '"foo",SUM("fizz"+"buzz") "fizzbuzz" ' + 'FROM "abc" ' + 'GROUP BY "foo"' + ') "sq0" JOIN (' + "SELECT " + '"foo" "foo_two","bar" ' + 'FROM "efg"' + ') "sq1" ON "sq0"."foo"="sq1"."foo_two"', + str(query), + ) + + def test_from_subquery_without_alias(self): + subquery = Query.from_(self.table_efg).select( + self.table_efg.base_id.as_("x"), self.table_efg.fizz, self.table_efg.buzz + ) + + test_query = Query.from_(subquery).select(subquery.x, subquery.fizz, subquery.buzz) + + self.assertEqual( + 'SELECT "sq0"."x","sq0"."fizz","sq0"."buzz" ' + "FROM (" + 'SELECT "base_id" "x","fizz","buzz" FROM "efg"' + ') "sq0"', + str(test_query), + ) + + def test_join_query_with_alias(self): + subquery = ( + Query.from_(self.table_efg) + .select( + self.table_efg.base_id.as_("x"), + self.table_efg.fizz, + self.table_efg.buzz, + ) + .as_("subq") + ) + + test_query = Query.from_(subquery).select(subquery.x, subquery.fizz, subquery.buzz) + + self.assertEqual( + 'SELECT "subq"."x","subq"."fizz","subq"."buzz" ' + "FROM (" + 'SELECT "base_id" "x","fizz","buzz" FROM "efg"' + ') "subq"', + str(test_query), + ) + + def test_with(self): + sub_query = Query.from_(self.table_efg).select("fizz") + test_query = Query.with_(sub_query, "an_alias").from_(AliasedQuery("an_alias")).select("*") + + self.assertEqual( + 'WITH an_alias AS (SELECT "fizz" FROM "efg") SELECT * FROM an_alias', + str(test_query), + ) + + def test_join_with_with(self): + sub_query = Query.from_(self.table_efg).select("fizz") + test_query = ( + Query.with_(sub_query, "an_alias") + .from_(self.table_abc) + .join(AliasedQuery("an_alias")) + .on(AliasedQuery("an_alias").fizz == self.table_abc.buzz) + .select("*") + ) + self.assertEqual( + 'WITH an_alias AS (SELECT "fizz" FROM "efg") ' + 'SELECT * FROM "abc" JOIN an_alias ON "an_alias"."fizz"="abc"."buzz"', + str(test_query), + ) + + def test_select_from_with_returning(self): + sub_query = PostgreSQLQuery.into(self.table_abc).insert(1).returning('*') + test_query = Query.with_(sub_query, "an_alias").from_(AliasedQuery("an_alias")).select("*") + self.assertEqual( + 'WITH an_alias AS (INSERT INTO "abc" VALUES (1) RETURNING *) SELECT * FROM an_alias', str(test_query) + ) + + +class QuoteTests(unittest.TestCase): + def test_extraneous_quotes(self): + t1 = Table("table1", alias="t1") + t2 = Table("table2", alias="t2") + + query = Query.from_(t1).join(t2).on(t1.Value.between(t2.start, t2.end)).select(t1.value) + + self.assertEqual( + "SELECT t1.value FROM table1 t1 " "JOIN table2 t2 ON t1.Value " "BETWEEN t2.start AND t2.end", + query.get_sql(quote_char=None), + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/test_tables.py b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/test_tables.py new file mode 100644 index 0000000000000000000000000000000000000000..f43e740915f642d29ce7497c36e3b68f01311016 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/test_tables.py @@ -0,0 +1,186 @@ +# from pypika.terms import ValueWrapper, SystemTimeValue +import unittest + +from pypika import Database, Dialects, Schema, SQLLiteQuery, Table, Tables, Query, SYSTEM_TIME + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + + +class TableStructureTests(unittest.TestCase): + def test_table_sql(self): + table = Table("test_table") + + self.assertEqual('"test_table"', str(table)) + + def test_table_with_alias(self): + table = Table("test_table").as_("my_table") + + self.assertEqual('"test_table" "my_table"', table.get_sql(with_alias=True, quote_char='"')) + + def test_schema_table_attr(self): + table = Schema("x_schema").test_table + + self.assertEqual('"x_schema"."test_table"', str(table)) + + def test_table_with_schema_arg(self): + table = Table("test_table", schema=Schema("x_schema")) + + self.assertEqual('"x_schema"."test_table"', str(table)) + + def test_database_schema_table_attr(self): + table = Database("x_db").x_schema.test_table + + self.assertEqual('"x_db"."x_schema"."test_table"', str(table)) + + def test_table_with_schema_and_schema_parent_arg(self): + table = Table("test_table", schema=Schema("x_schema", parent=Database("x_db"))) + + self.assertEqual('"x_db"."x_schema"."test_table"', str(table)) + + def test_table_for_system_time_sql(self): + with self.subTest("with between criterion"): + table = Table("test_table").for_(SYSTEM_TIME.between('2020-01-01', '2020-02-01')) + + self.assertEqual('"test_table" FOR SYSTEM_TIME BETWEEN \'2020-01-01\' AND \'2020-02-01\'', str(table)) + + with self.subTest("with as of criterion"): + table = Table("test_table").for_(SYSTEM_TIME.as_of('2020-01-01')) + + self.assertEqual('"test_table" FOR SYSTEM_TIME AS OF \'2020-01-01\'', str(table)) + + with self.subTest("with from to criterion"): + table = Table("test_table").for_(SYSTEM_TIME.from_to('2020-01-01', '2020-02-01')) + + self.assertEqual('"test_table" FOR SYSTEM_TIME FROM \'2020-01-01\' TO \'2020-02-01\'', str(table)) + + def test_table_for_period_sql(self): + with self.subTest("with between criterion"): + table = Table("test_table") + table = table.for_(table.valid_period.between('2020-01-01', '2020-02-01')) + + self.assertEqual('"test_table" FOR "valid_period" BETWEEN \'2020-01-01\' AND \'2020-02-01\'', str(table)) + + with self.subTest("with as of criterion"): + table = Table("test_table") + table = table.for_(table.valid_period.as_of('2020-01-01')) + + self.assertEqual('"test_table" FOR "valid_period" AS OF \'2020-01-01\'', str(table)) + + with self.subTest("with from to criterion"): + table = Table("test_table") + table = table.for_(table.valid_period.from_to('2020-01-01', '2020-02-01')) + + self.assertEqual('"test_table" FOR "valid_period" FROM \'2020-01-01\' TO \'2020-02-01\'', str(table)) + + +class TableEqualityTests(unittest.TestCase): + def test_tables_equal_by_name(self): + t1 = Table("t") + t2 = Table("t") + + self.assertEqual(t1, t2) + + def test_tables_equal_by_schema_and_name(self): + t1 = Table("t", schema="a") + t2 = Table("t", schema="a") + + self.assertEqual(t1, t2) + + def test_tables_equal_by_schema_and_name_using_schema(self): + a = Schema("a") + t1 = Table("t", schema=a) + t2 = Table("t", schema=a) + + self.assertEqual(t1, t2) + + def test_tables_equal_by_schema_and_name_using_schema_with_parent(self): + parent = Schema("parent") + a = Schema("a", parent=parent) + t1 = Table("t", schema=a) + t2 = Table("t", schema=a) + + self.assertEqual(t1, t2) + + def test_tables_not_equal_by_schema_and_name_using_schema_with_different_parents( + self, + ): + parent = Schema("parent") + a = Schema("a", parent=parent) + t1 = Table("t", schema=a) + t2 = Table("t", schema=Schema("a")) + + self.assertNotEqual(t1, t2) + + def test_tables_not_equal_with_different_schemas(self): + t1 = Table("t", schema="a") + t2 = Table("t", schema="b") + + self.assertNotEqual(t1, t2) + + def test_tables_not_equal_with_different_names(self): + t1 = Table("t", schema="a") + t2 = Table("q", schema="a") + + self.assertNotEqual(t1, t2) + + def test_many_tables_with_alias(self): + tables_data = [("table1", "t1"), ("table2", "t2"), ("table3", "t3")] + tables = Tables(*tables_data) + for el in tables: + self.assertIsNotNone(el.alias) + + def test_many_tables_without_alias(self): + tables_data = ["table1", "table2", "table3"] + tables = Tables(*tables_data) + for el in tables: + self.assertIsNone(el.alias) + + def test_many_tables_with_or_not_alias(self): + tables_data = [("table1", "t1"), ("table2"), "table3"] + tables = Tables(*tables_data) + for i in range(len(tables)): + if isinstance(tables_data[i], tuple): + self.assertIsNotNone(tables[i].alias) + else: + self.assertIsNone(tables[i].alias) + + +class TableDialectTests(unittest.TestCase): + def test_table_with_default_query_cls(self): + table = Table("abc") + q = table.select("1") + self.assertIs(q.dialect, None) + + def test_table_with_dialect_query_cls(self): + table = Table("abc", query_cls=SQLLiteQuery) + q = table.select("1") + self.assertIs(q.dialect, Dialects.SQLLITE) + + def test_table_factory_with_default_query_cls(self): + table = Query.Table("abc") + q = table.select("1") + self.assertIs(q.dialect, None) + + def test_table_factory_with_dialect_query_cls(self): + table = SQLLiteQuery.Table("abc") + q = table.select("1") + self.assertIs(q.dialect, Dialects.SQLLITE) + + def test_make_tables_factory_with_default_query_cls(self): + t1, t2 = Query.Tables("abc", "def") + q1 = t1.select("1") + q2 = t2.select("2") + self.assertIs(q1.dialect, None) + self.assertIs(q2.dialect, None) + + def test_make_tables_factory_with_dialect_query_cls(self): + t1, t2 = SQLLiteQuery.Tables("abc", "def") + q1 = t1.select("1") + q2 = t2.select("2") + self.assertIs(q1.dialect, Dialects.SQLLITE) + self.assertIs(q2.dialect, Dialects.SQLLITE) + + def test_table_with_bad_query_cls(self): + with self.assertRaises(TypeError): + Table("abc", query_cls=object) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/test_terms.py b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/test_terms.py new file mode 100644 index 0000000000000000000000000000000000000000..4c7590dfce129bac97a3f30de99b596cc746c893 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/test_terms.py @@ -0,0 +1,82 @@ +from unittest import TestCase + +from pypika import Query, Table, Field +from pypika.terms import AtTimezone + + +class FieldAliasTests(TestCase): + t = Table("test", alias="crit") + + def test_when_alias_specified(self): + c1 = Field("foo", alias="bar") + self.assertEqual('bar', str(c1.alias)) + + c1 = Field("foo").as_("bar") + self.assertEqual('bar', str(c1.alias)) + + +class FieldInitTests(TestCase): + def test_init_with_str_table(self): + test_table_name = "test_table" + field = Field(name="name", table=test_table_name) + self.assertEqual(field.table, Table(name=test_table_name)) + + +class FieldHashingTests(TestCase): + def test_tabled_eq_fields_equally_hashed(self): + client_name1 = Field(name="name", table=Table("clients")) + client_name2 = Field(name="name", table=Table("clients")) + self.assertTrue(hash(client_name1) == hash(client_name2)) + + def test_tabled_ne_fields_differently_hashed(self): + customer_name = Field(name="name", table=Table("customers")) + client_name = Field(name="name", table=Table("clients")) + self.assertTrue(hash(customer_name) != hash(client_name)) + + def test_non_tabled_aliased_eq_fields_equally_hashed(self): + self.assertTrue(hash(Field(name="A", alias="my_a")) == hash(Field(name="A", alias="my_a"))) + + def test_non_tabled_aliased_ne_fields_differently_hashed(self): + self.assertTrue(hash(Field(name="A", alias="my_a1")) != hash(Field(name="A", alias="my_a2"))) + + def test_non_tabled_eq_fields_equally_hashed(self): + self.assertTrue(hash(Field(name="A")) == hash(Field(name="A"))) + + def test_non_tabled_ne_fields_differently_hashed(self): + self.assertTrue(hash(Field(name="A")) != hash(Field(name="B"))) + + +class AtTimezoneTests(TestCase): + def test_when_interval_not_specified(self): + query = Query.from_("customers").select(AtTimezone("date", "US/Eastern")) + self.assertEqual('SELECT "date" AT TIME ZONE \'US/Eastern\' FROM "customers"', str(query)) + + def test_when_interval_specified(self): + query = Query.from_("customers").select(AtTimezone("date", "-06:00", interval=True)) + self.assertEqual( + 'SELECT "date" AT TIME ZONE INTERVAL \'-06:00\' FROM "customers"', + str(query), + ) + + def test_when_alias_specified(self): + query = Query.from_("customers").select(AtTimezone("date", "US/Eastern", alias="alias1")) + self.assertEqual( + 'SELECT "date" AT TIME ZONE \'US/Eastern\' "alias1" FROM "customers"', + str(query), + ) + + def test_passes_kwargs_to_field_get_sql(self): + customers = Table("customers") + accounts = Table("accounts") + query = ( + Query.from_(customers) + .join(accounts) + .on(customers.account_id == accounts.account_id) + .select(AtTimezone(customers.date, "US/Eastern", alias="alias1")) + ) + + self.assertEqual( + 'SELECT "customers"."date" AT TIME ZONE \'US/Eastern\' "alias1" ' + 'FROM "customers" JOIN "accounts" ON "customers"."account_id"="accounts"."account_id"', + query.get_sql(with_namespace=True), + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/test_tuples.py b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/test_tuples.py new file mode 100644 index 0000000000000000000000000000000000000000..c8ebc8e41b0115777f8b3c8cb01c04e62f13ee18 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/test_tuples.py @@ -0,0 +1,162 @@ +import unittest + +from pypika import ( + Array, + Bracket, + Query, + PostgreSQLQuery, + Table, + Tables, + Tuple, +) +from pypika.functions import Coalesce, NullIf, Sum +from pypika.terms import Field + + +class TupleTests(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_tuple_equality_tuple_on_both(self): + q = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, self.table_abc.bar) + .where(Tuple(self.table_abc.foo, self.table_abc.bar) == Tuple(1, 2)) + ) + + self.assertEqual('SELECT "foo","bar" FROM "abc" ' 'WHERE ("foo","bar")=(1,2)', str(q)) + + def test_tuple_equality_tuple_on_left(self): + q = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, self.table_abc.bar) + .where(Tuple(self.table_abc.foo, self.table_abc.bar) == (1, 2)) + ) + + self.assertEqual('SELECT "foo","bar" FROM "abc" ' 'WHERE ("foo","bar")=(1,2)', str(q)) + + def test_tuple_equality_tuple_on_right(self): + q = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, self.table_abc.bar) + .where((self.table_abc.foo, self.table_abc.bar) == Tuple(1, 2)) + ) + + # Order is reversed due to lack of right equals method + self.assertEqual('SELECT "foo","bar" FROM "abc" ' 'WHERE (1,2)=("foo","bar")', str(q)) + + def test_tuple_in_using_python_tuples(self): + q = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, self.table_abc.bar) + .where(Tuple(self.table_abc.foo, self.table_abc.bar).isin([(1, 1), (2, 2), (3, 3)])) + ) + + self.assertEqual( + 'SELECT "foo","bar" FROM "abc" ' 'WHERE ("foo","bar") IN ((1,1),(2,2),(3,3))', + str(q), + ) + + def test_tuple_in_using_pypika_tuples(self): + q = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, self.table_abc.bar) + .where(Tuple(self.table_abc.foo, self.table_abc.bar).isin([Tuple(1, 1), Tuple(2, 2), Tuple(3, 3)])) + ) + + self.assertEqual( + 'SELECT "foo","bar" FROM "abc" ' 'WHERE ("foo","bar") IN ((1,1),(2,2),(3,3))', + str(q), + ) + + def test_tuple_in_using_mixed_tuples(self): + q = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, self.table_abc.bar) + .where(Tuple(self.table_abc.foo, self.table_abc.bar).isin([(1, 1), Tuple(2, 2), (3, 3)])) + ) + + self.assertEqual( + 'SELECT "foo","bar" FROM "abc" ' 'WHERE ("foo","bar") IN ((1,1),(2,2),(3,3))', + str(q), + ) + + def test_tuples_in_join(self): + query = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .select("*") + .where(Tuple(self.table_abc.foo, self.table_efg.bar).isin([(1, 1), Tuple(2, 2), (3, 3)])) + ) + + self.assertEqual( + 'SELECT * FROM "abc" JOIN "efg" ON "abc"."foo"="efg"."bar" ' + 'WHERE ("abc"."foo","efg"."bar") IN ((1,1),(2,2),(3,3))', + str(query), + ) + + def test_render_alias_in_array_sql(self): + tb = Table("tb") + + q = Query.from_(tb).select(Tuple(tb.col).as_("different_name")) + self.assertEqual(str(q), 'SELECT ("col") "different_name" FROM "tb"') + + def test_tuple_is_aggregate(self): + with self.subTest('None if single argument returns None for is_aggregate'): + self.assertEqual(None, Tuple(0).is_aggregate) + self.assertEqual(None, Tuple(Coalesce('col')).is_aggregate) + + with self.subTest('None if multiple arguments all return None for is_aggregate'): + self.assertEqual(None, Tuple(0, 'a').is_aggregate) + self.assertEqual(None, Tuple(Coalesce('col'), NullIf('col2', 0)).is_aggregate) + + with self.subTest('True if single argument returns True for is_aggregate'): + self.assertEqual(True, Tuple(Sum('col')).is_aggregate) + + with self.subTest('True if multiple arguments return True for is_aggregate'): + self.assertEqual(True, Tuple(Sum('col'), Sum('col2')).is_aggregate) + + with self.subTest('True when mix of arguments returning None and True for is_aggregate'): + self.assertEqual(True, Tuple(Coalesce('col'), Coalesce('col2', 0), Sum('col3')).is_aggregate) + + with self.subTest('False when one of the arguments returns False for is_aggregate'): + self.assertEqual(False, Tuple(Field('col1'), Sum('col2')).is_aggregate) + + +class ArrayTests(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_array_general(self): + query = Query.from_(self.table_abc).select(Array(1, "a", ["b", 2, 3])) + + self.assertEqual("SELECT [1,'a',['b',2,3]] FROM \"abc\"", str(query)) + + def test_empty_psql_array(self): + query = PostgreSQLQuery.from_(self.table_abc).select(Array()) + + self.assertEqual("SELECT '{}' FROM \"abc\"", str(query)) + + def test_psql_array_general(self): + query = PostgreSQLQuery.from_(self.table_abc).select(Array(1, Array(2, 2, 2), 3)) + + self.assertEqual("SELECT ARRAY[1,ARRAY[2,2,2],3] FROM \"abc\"", str(query)) + + def test_render_alias_in_array_sql(self): + tb = Table("tb") + + q = Query.from_(tb).select(Array(tb.col).as_("different_name")) + self.assertEqual(str(q), 'SELECT ["col"] "different_name" FROM "tb"') + + +class BracketTests(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_arithmetic_with_brackets(self): + q = Query.from_(self.table_abc).select(Bracket(self.table_abc.foo / 2) / 2) + + self.assertEqual('SELECT ("foo"/2)/2 FROM "abc"', str(q)) + + def test_arithmetic_with_brackets_and_alias(self): + q = Query.from_(self.table_abc).select(Bracket(self.table_abc.foo / 2).as_("alias")) + + self.assertEqual('SELECT ("foo"/2) "alias" FROM "abc"', str(q)) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/test_updates.py b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/test_updates.py new file mode 100644 index 0000000000000000000000000000000000000000..fb9d714dbcb8213b4bda04bf7b8dd9b2419410ec --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/test_updates.py @@ -0,0 +1,162 @@ +import unittest + +from pypika import AliasedQuery, PostgreSQLQuery, Query, SQLLiteQuery, SYSTEM_TIME, Table + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + +from pypika.terms import Star + + +class UpdateTests(unittest.TestCase): + table_abc = Table("abc") + table_def = Table("def") + + def test_empty_query(self): + q = Query.update("abc") + + self.assertEqual("", str(q)) + + def test_omit_where(self): + q = Query.update(self.table_abc).set("foo", "bar") + + self.assertEqual('UPDATE "abc" SET "foo"=\'bar\'', str(q)) + + def test_single_quote_escape_in_set(self): + q = Query.update(self.table_abc).set("foo", "bar'foo") + + self.assertEqual("UPDATE \"abc\" SET \"foo\"='bar''foo'", str(q)) + + def test_update__table_schema(self): + table = Table("abc", "schema1") + q = Query.update(table).set(table.foo, 1).where(table.foo == 0) + + self.assertEqual('UPDATE "schema1"."abc" SET "foo"=1 WHERE "foo"=0', str(q)) + + def test_update_with_none(self): + q = Query.update("abc").set("foo", None) + self.assertEqual('UPDATE "abc" SET "foo"=null', str(q)) + + def test_update_with_join(self): + q = ( + Query.update(self.table_abc) + .join(self.table_def) + .on(self.table_def.abc_id == self.table_abc.id) + .set(self.table_abc.lname, self.table_def.lname) + ) + self.assertEqual( + 'UPDATE "abc" JOIN "def" ON "def"."abc_id"="abc"."id" SET "lname"="def"."lname"', + str(q), + ) + + def test_update_with_limit(self): + q = Query.update(self.table_abc).set(self.table_abc.lname, "test").limit(1) + self.assertEqual('UPDATE "abc" SET "lname"=\'test\' LIMIT 1', str(q)) + + def test_update_from(self): + from_table = Table('from_table') + + q = Query.update(self.table_abc).set(self.table_abc.lname, from_table.long_name).from_(from_table) + self.assertEqual('UPDATE "abc" SET "lname"="from_table"."long_name" FROM "from_table"', str(q)) + + def test_update_from_with_where(self): + from_table = Table('from_table') + + q = ( + Query.update(self.table_abc) + .set(self.table_abc.lname, from_table.long_name) + .from_(from_table) + .where(self.table_abc.fname.eq(from_table.full_name)) + ) + self.assertEqual( + 'UPDATE "abc" SET "lname"="from_table"."long_name" FROM "from_table" ' + 'WHERE "abc"."fname"="from_table"."full_name"', + str(q), + ) + + def test_update_with_statement(self): + table_efg = Table('efg') + + sub_query = Query.from_(table_efg).select("fizz") + an_alias = AliasedQuery("an_alias") + + q = ( + Query.with_(sub_query, "an_alias") + .update(self.table_abc) + .from_(an_alias) + .set(self.table_abc.lname, an_alias.long_name) + .where(self.table_abc.comp.eq(an_alias.alias_comp)) + ) + self.assertEqual( + 'WITH an_alias AS (SELECT "fizz" FROM "efg") ' + 'UPDATE "abc" SET "lname"="an_alias"."long_name" FROM an_alias ' + 'WHERE "abc"."comp"="an_alias"."alias_comp"', + str(q), + ) + + def test_for_portion(self): + with self.subTest("with system time"): + q = Query.update(self.table_abc.for_portion(SYSTEM_TIME.from_to('2020-01-01', '2020-02-01'))).set( + "foo", "bar" + ) + + self.assertEqual( + 'UPDATE "abc" FOR PORTION OF SYSTEM_TIME FROM \'2020-01-01\' TO \'2020-02-01\' SET "foo"=\'bar\'', + str(q), + ) + + with self.subTest("with column"): + q = Query.update( + self.table_abc.for_portion(self.table_abc.valid_period.from_to('2020-01-01', '2020-02-01')) + ).set("foo", "bar") + + self.assertEqual( + 'UPDATE "abc" FOR PORTION OF "valid_period" FROM \'2020-01-01\' TO \'2020-02-01\' SET "foo"=\'bar\'', + str(q), + ) + + +class PostgresUpdateTests(unittest.TestCase): + table_abc = Table("abc") + + def test_update_returning_str(self): + q = PostgreSQLQuery.update(self.table_abc).where(self.table_abc.foo == 0).set("foo", "bar").returning("id") + + self.assertEqual('UPDATE "abc" SET "foo"=\'bar\' WHERE "foo"=0 RETURNING "abc"."id"', str(q)) + + def test_update_returning(self): + q = ( + PostgreSQLQuery.update(self.table_abc) + .where(self.table_abc.foo == 0) + .set("foo", "bar") + .returning(self.table_abc.id) + ) + + self.assertEqual('UPDATE "abc" SET "foo"=\'bar\' WHERE "foo"=0 RETURNING "abc"."id"', str(q)) + + def test_update_returning_from_different_tables(self): + table_bcd = Table('bcd') + + q = ( + PostgreSQLQuery.update(self.table_abc) + .from_(table_bcd) + .set(self.table_abc.lname, table_bcd.long_name) + .returning(self.table_abc.id, table_bcd.fname) + ) + self.assertEqual( + 'UPDATE "abc" SET "lname"="bcd"."long_name" FROM "bcd" RETURNING "abc"."id","bcd"."fname"', str(q) + ) + + def test_update_returning_star(self): + q = PostgreSQLQuery.update(self.table_abc).where(self.table_abc.foo == 0).set("foo", "bar").returning(Star()) + + self.assertEqual('UPDATE "abc" SET "foo"=\'bar\' WHERE "foo"=0 RETURNING *', str(q)) + + +class SQLLiteUpdateTests(unittest.TestCase): + table_abc = Table("abc") + + def test_update_with_bool(self): + q = SQLLiteQuery.update(self.table_abc).set(self.table_abc.foo, True) + + self.assertEqual('UPDATE "abc" SET "foo"=1', str(q)) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/test_utils.py b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/test_utils.py new file mode 100644 index 0000000000000000000000000000000000000000..bb9a9b1c68fe8671989f7c49f9db90e389d06f59 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pypika/tests/test_utils.py @@ -0,0 +1,24 @@ +import unittest + +from pypika import utils + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + + +class ImmutabilityTests(unittest.TestCase): + def test_raise_attribute_error_for_deepcopy(self): + with self.assertRaises(AttributeError): + utils.raise_attribute_for_copy("Test", "__deepcopy__") + + def test_raise_attribute_error_for_getstate(self): + with self.assertRaises(AttributeError): + utils.raise_attribute_for_copy("Test", "__getstate__") + + def test_raise_attribute_error_for_setstate(self): + with self.assertRaises(AttributeError): + utils.raise_attribute_for_copy("Test", "__setstate__") + + def test_raise_attribute_error_for_getnewargs(self): + with self.assertRaises(AttributeError): + utils.raise_attribute_for_copy("Test", "__getnewargs__") diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pyproject.toml b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pyproject.toml new file mode 100644 index 0000000000000000000000000000000000000000..dcc56baede23e3571b336625e695c466ab833a56 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/pyproject.toml @@ -0,0 +1,22 @@ +[tool.black] +line-length = 120 +skip-string-normalization = true +target-version = ['py38', 'py39', 'py310', 'py311'] +force-exclude = ''' +( + /( + \.eggs # exclude a few common directories in the + | \.git # root of the project + | \.hg + | \.mypy_cache + | \.tox + | \.venv + | _build + | buck-out + | build + | dist + | docs + )/ + | setup.py +) +''' diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/setup.cfg b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/setup.cfg new file mode 100644 index 0000000000000000000000000000000000000000..46084aaf2ca9e95b2f9bb7680e432e637fc3ed90 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/setup.cfg @@ -0,0 +1,16 @@ +[bumpversion] +current_version = 0.48.9 +commit = True +tag = True + +[bumpversion:file:pypika/__init__.py] +search = __version__ = "{current_version}" +replace = __version__ = "{new_version}" + +[bdist_wheel] +universal = 1 + +[flake8] +exclude = docs, .git, __pycache__ +max-line-length = 120 +per-file-ignores = __init__.py:F401 diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/setup.py b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/setup.py new file mode 100644 index 0000000000000000000000000000000000000000..41cce7d742df3e33e8d76f267d77df486f69249a --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/setup.py @@ -0,0 +1,81 @@ +import ast + +from setuptools import setup + + +def readme(): + with open('README.rst', 'rb') as f: + return f.read().decode('UTF-8') + + +def version(): + path = 'pypika/__init__.py' + with open(path, 'r') as file: + t = compile(file.read(), path, 'exec', ast.PyCF_ONLY_AST) + for node in (n for n in t.body if isinstance(n, ast.Assign)): + if len(node.targets) == 1: + name = node.targets[0] + if isinstance(name, ast.Name) and name.id in ('__version__', '__version_info__', 'VERSION'): + v = node.value + if isinstance(v, ast.Str): + return v.s + + if isinstance(v, ast.Tuple): + r = [] + for e in v.elts: + if isinstance(e, ast.Str): + r.append(e.s) + elif isinstance(e, ast.Num): + r.append(str(e.n)) + return '.'.join(r) + + +setup( + # Application name: + name="PyPika", + + # Version number: + version=version(), + + # Application author details: + author="Timothy Heys", + author_email="theys@kayak.com", + + # License + license='Apache License Version 2.0', + + # Packages + packages=["pypika", "pypika.clickhouse"], + + # Include additional files into the package + package_data={"pypika": ["py.typed"]}, + include_package_data=True, + + install_requires=[], + + # Details + url="https://github.com/kayak/pypika", + + description="A SQL query builder API for Python", + long_description=readme(), + + classifiers=[ + 'License :: OSI Approved :: Apache Software License', + 'Development Status :: 5 - Production/Stable', + 'Intended Audience :: Developers', + 'Programming Language :: Python :: 3', + 'Programming Language :: PL/SQL', + 'Topic :: Software Development :: Libraries :: Python Modules', + 'Topic :: Scientific/Engineering :: Information Analysis', + 'Topic :: Scientific/Engineering :: Mathematics', + 'Operating System :: POSIX', + 'Operating System :: MacOS :: MacOS X', + 'Operating System :: Microsoft :: Windows', + ], + keywords=('pypika python query builder querybuilder sql mysql postgres psql oracle vertica aggregated ' + 'relational database rdbms business analytics bi data science analysis pandas ' + 'orm object mapper'), + + # Dependent packages (distributions) + test_suite="pypika.tests", +) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/tox.ini b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/tox.ini new file mode 100644 index 0000000000000000000000000000000000000000..2f0e6893243b1ca2ead6a12825e9014dc66364ce --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/tests/trusted/tox.ini @@ -0,0 +1,16 @@ +[tox] +envlist = py38,py39,py310,py311,pypy3 + +[testenv] +description = testing against {basepython} +deps = -r requirements-dev.txt +commands = + coverage run + coverage xml + +[gh-actions] +python = + 3.8: py38 + 3.9: py39 + 3.10: py310 + 3.11: py311 diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/validation/canaries/first-hunk-only.sh b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/validation/canaries/first-hunk-only.sh new file mode 100644 index 0000000000000000000000000000000000000000..8563214730da693b1ea6ae1c3d228aecfac09cb5 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/validation/canaries/first-hunk-only.sh @@ -0,0 +1,16 @@ +#!/bin/bash +set -Eeuo pipefail +cd /testbed/repo +cat > /tmp/openenv-reference.diff <<'OPENENV_PARTIAL' +diff --git a/pypika/clickhouse/condition.py b/pypika/clickhouse/condition.py +index 5fa9a18c9e95d1f5e7f56f011d03e7aa11f1ddd6..ed08224e22fb27eb18876595a542dcd3ad14bffc 100644 +--- a/pypika/clickhouse/condition.py ++++ b/pypika/clickhouse/condition.py +@@ -8,4 +8,4 @@ + + class MultiIf(Function): + def __init__(self, *conditions, **kwargs): +- super().__init__("multiIf", *conditions[::-1], **kwargs) ++ super().__init__("multiIf", *conditions, **kwargs) +OPENENV_PARTIAL +/usr/bin/git -c core.hooksPath=/dev/null -c core.fsmonitor=false apply --whitespace=nowarn /tmp/openenv-reference.diff diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/validation/canaries/original-bug.sh b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/validation/canaries/original-bug.sh new file mode 100644 index 0000000000000000000000000000000000000000..927547df786c86ab3bb5eeb917a31e0fa1895f8b --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/validation/canaries/original-bug.sh @@ -0,0 +1,3 @@ +#!/bin/bash +set -Eeuo pipefail +: diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/validation/openenv.json b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/validation/openenv.json new file mode 100644 index 0000000000000000000000000000000000000000..a13b3c577df494f6c894584d2b608ab051ebc44f --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__rdbfqh8u/validation/openenv.json @@ -0,0 +1,27 @@ +{ + "canaries": "validation/canaries", + "profile": "harbor-semantic-v1", + "requires_credentials": false, + "resources": { + "cpu": 2, + "disk_mb": 16384, + "episode_timeout_s": 1800, + "memory_mb": 8192 + }, + "reward": { + "floor_margin": 0.1, + "oracle_tolerance": 0, + "range": [ + 0, + 1 + ] + }, + "reward_key": "reward", + "types": { + "tags": [ + "swe", + "python", + "mutation-repair" + ] + } +} diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/LICENSE.source b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/LICENSE.source new file mode 100644 index 0000000000000000000000000000000000000000..9c8f3ea0871e0bfe81da0fa6e7c1d7d156dc380e --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/LICENSE.source @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. \ No newline at end of file diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/adapter.json b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/adapter.json new file mode 100644 index 0000000000000000000000000000000000000000..fdc9ac7161dd9b1e626cd9ca9ef1cbc2538dfd79 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/adapter.json @@ -0,0 +1,135 @@ +{ + "canary_selection": "Fixed first provided gold hunk only when at least2hunks exist; strict subset, never reward-selected. Single-hunk task original-bug canary is explicitly NOP-equivalent and adds no signal beyond floor_gap.", + "collector_sha256": "352e555112f2de8a1393f939903e4971c9ace0e944843762b707a725c5c72481", + "dependency_installation_pinned": false, + "dependency_setup_sha256": "ed8673d02878e91c7ae0b51b9178d6a15792b79c6992f800c14a941d95242392", + "gold_patch_sha256": "e720ccc33a6f435f1289869b56ce79d7eba71f32121b73bc6c3090e9381ddf9f", + "hostile_code_isolation_established": false, + "known_wrong_semantic_implementations": 0, + "native_inventory_sha256": "00d9ef120837485677775624d992e473bf878c1cd1351c47f6d1faef5028ab8f", + "new_files_deletions_and_executable_modes_supported": true, + "official_profile": { + "eval_sets": [], + "profile_class": "Pypika1c9646f0", + "profile_lines": [ + 736, + 739 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "upstream_repo": "kayak/pypika" + }, + "original_bug_canary_nop_equivalent": true, + "original_bug_runtime_wrongness_established": false, + "partial_repair_canary": true, + "partial_repair_sha256": "aa9717f3c0b2330582e7fbbfb0cf20babe0597404511b5b30af3415bcdf0d465", + "partial_repair_wrongness_established": false, + "positive_approval_policy": "All original strict presence/identity/no-skip/no-error/exit checks retained", + "private_checker_sha256": "f0a641064b725415e23a0221bb53c90446d7efcb7f9ece5ede93a220d18dd9e7", + "private_checker_version": "matched-failure-precedence-v2", + "provided_original_bug_control": true, + "repo_url": "https://github.com/swesmith/kayak__pypika.1c9646f0.git", + "runtime_image": null, + "runtime_ready": false, + "runtime_recipe": { + "dependency_installation_pinned": false, + "official_install_cmds": [ + "python -m pip install -e ." + ], + "official_pytest_argv": [ + "pytest", + "--disable-warnings", + "--color=no", + "--tb=no", + "--verbose" + ], + "official_test_command": "source /opt/miniconda3/bin/activate; conda activate testbed; pytest --disable-warnings --color=no --tb=no --verbose", + "operator_test_runner_prerequisites": [ + "python -m pip install pytest==8.4.2" + ], + "operator_test_runner_reason": "The official profile invokes pytest, but the common tools runtime does not provide it; pinned separately from source-native project requirements.", + "panel_normalization": "Override project addopts only to execute the exact frozen native panels; add JUnit output, preserve official pytest options and all selectors.", + "python_version": "3.10", + "source_bound_test_dependency_cmds": [ + "python -m pip install parameterized==0.7.0" + ], + "test_dependency_source_sha256": { + "requirements-dev.txt": "10f4ba7b19a73950d28fd7403d7e1d1b1fe2ccc4f49516974f47199d2965f23d", + "setup.py": "f8bad274588a22e65764d8cf9fb2be5aa6fcfaf3bf861d71e5f751105898845a", + "tox.ini": "c2d7205d0ac93e9c9e80dc5d24f0a826a6781f587a33ea722ea621f9e2ccd0ea" + } + }, + "runtime_resource_review_required": false, + "schema": "python-git-patch-jobs-v1", + "source_base_commit": "3b8d73253919a1647d8e192311249f2f5a29fa55", + "source_completion_sha256": "d28469008a6aadedfb30084c1c6568321db9107c6276171d25bc580e370137ba", + "source_index_sha256": "e856874b9410fce9f3bfea52c8c482e84b3e43942d87517f8b55f0034bd40f6f", + "source_pr_url": null, + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:kayak__pypika.1c9646f0.combine_module__smsizxe7", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "6a742f12bfa386994289ec8b75824663d8ee4b15", + "instruction_sha256": "b03474f35aca7b541059df6286c82d5dfd926b2b71a6a15473ff5832ee62318b", + "is_fork": true, + "learner_path": "tasks/6da2a9ea7c1b6d1504489fe2/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "actual_upstream_url": "https://raw.githubusercontent.com/kayak/pypika/1c9646f0a019a167c32b649b6f5e6423c5ba2c9b/LICENSE.txt", + "reviewed": true, + "sha256": "c5accbbd8546e94c34aed24afe689a617627d18eed5a6c48277e48db57c23851", + "spdx": "Apache-2.0", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/kayak__pypika.1c9646f0/3b8d73253919a1647d8e192311249f2f5a29fa55/LICENSE.txt" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "patch_sha256": "bb661925f1bdeab91276c03b6898e8d652987c159fa1a6232bbe9cedf67f4e85", + "provenance_path": "tasks/6da2a9ea7c1b6d1504489fe2/source-proof.json", + "repository_lineage": [ + "swesmith/kayak__pypika.1c9646f0", + "kayak/pypika" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "3b8d73253919a1647d8e192311249f2f5a29fa55", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "83545379f77dfce769867f8ae105f1cc43efd878", + "source_kind": "mutation", + "source_repo": "swesmith/kayak__pypika.1c9646f0", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "kayak__pypika.1c9646f0.combine_module__smsizxe7", + "task_sha256": "c91fbb64d58f5b00eecf8f6cac0b210a3315010f4a1ec78e3a66493d1938cc13", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "kayak/pypika", + "usage": "quarantine_only" + }, + "source_repo": "swesmith/kayak__pypika.1c9646f0", + "symlink_submodule_changes_supported": false, + "task_id": "kayak__pypika.1c9646f0.combine_module__smsizxe7", + "transfer": "index-independent-worktree-to-Git-binary-patch", + "transfer_path": "/testbed/submission.patch", + "upstream_repo": "kayak/pypika" +} diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/dependency-setup.sh b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/dependency-setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e1a28db070ebf088cec3ef817cf2dc8715091ac2 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/dependency-setup.sh @@ -0,0 +1,9 @@ +#!/bin/bash +set -Eeuo pipefail +source /opt/miniconda3/bin/activate +conda activate testbed +cd /testbed/repo +python -c 'import sys; assert sys.version_info[:2] == (3, 10)' +python -m pip install pytest==8.4.2 +python -m pip install -e . +python -m pip install parameterized==0.7.0 diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/environment/Dockerfile b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..a59b58c2ea8217c78c1e39b4678f93c8c0023bcd --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/environment/Dockerfile @@ -0,0 +1,3 @@ +# Runtime is selected only by an independently qualified immutable amd64 receipt. +FROM ubuntu:22.04 +RUN false diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/instruction.md b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..b6bf89142a43f2f088ac411bedfd9981d1fa1bcb --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/instruction.md @@ -0,0 +1,52 @@ +# ClickHouse function parameters swapped and incorrect function name + +### What happened? + +I discovered two issues with the ClickHouse functions in PyPika: + +1. The `IfNull` function has its parameters in the wrong order. The parameters `term` and `alt` are swapped when passed to the parent constructor. + +2. The `MultiSearchAny` class is returning the wrong function name. It's returning "singleSearchAll" instead of "multiSearchAny". + +### What did you expect to happen? + +1. For `IfNull`, I expected the parameters to be passed in the correct order to match ClickHouse's function signature: `ifNull(term, alt)`. + +2. For `MultiSearchAny`, I expected the function name to be "multiSearchAny" as per ClickHouse's documentation. + +### Minimal Complete Verifiable Example + +```Python +from pypika.clickhouse.nullable_arg import IfNull +from pypika.clickhouse.search_string import MultiSearchAny +from pypika.terms import Field + +# Example showing the IfNull issue +field = Field('column') +alt_value = 'default' +ifnull_expr = IfNull(field, alt_value) +print(f"IfNull SQL: {ifnull_expr.get_sql()}") +# Outputs: ifNull('default', "column") - parameters are swapped! + +# Example showing the MultiSearchAny issue +haystack = Field('text') +needles = ['word1', 'word2'] +search_expr = MultiSearchAny(haystack, needles) +print(f"MultiSearchAny SQL: {search_expr.get_sql()}") +# Outputs: singleSearchAll("text", ['word1', 'word2']) - wrong function name! +``` + +### MVCE confirmation + +- [X] Minimal example — the example is as focused as reasonably possible to demonstrate the underlying issue in PyPika. +- [X] Complete example — the example is self-contained, including all data and the text of any traceback. +- [X] Verifiable example — the example copy & pastes into an IPython prompt, returning the result. +- [X] New issue — a search of GitHub Issues suggests this is not a duplicate. + +### Anything else we need to know? + +These issues cause incorrect SQL to be generated when using PyPika with ClickHouse, which will result in either syntax errors or unexpected behavior when the queries are executed. + +## Environment + +The repository is at `/testbed/repo`. Its dependencies, including pytest, are installed in the `testbed` conda environment, which comes first on PATH. If `python -m pytest` reports that pytest is missing, use the full interpreter path: `/opt/miniconda3/envs/testbed/bin/python -m pytest `. Don't install packages: the tests need nothing else, and the sandbox may have no network access. diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/metadata.json b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/metadata.json new file mode 100644 index 0000000000000000000000000000000000000000..6128d78417de061842c5672473b3fc754000e69c --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/metadata.json @@ -0,0 +1,1276 @@ +{ + "all_runtime_and_training_flags": false, + "official_profile": { + "eval_sets": [], + "profile_class": "Pypika1c9646f0", + "profile_lines": [ + 736, + 739 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "upstream_repo": "kayak/pypika" + }, + "source_healthy_reference_proof": { + "FAIL_TO_PASS": [ + "pypika/tests/clickhouse/test_nullable_arg.py::TestSearchString::test_get_sql_0", + "pypika/tests/clickhouse/test_nullable_arg.py::TestSearchString::test_get_sql_1", + "pypika/tests/clickhouse/test_search_string.py::TestMultiSearch::test_multi_search_string_0" + ], + "PASS_TO_PASS": [ + "pypika/tests/clickhouse/test_array.py::TestArray::test_get_sql_0__ridley_scott_jimi_hendrix_", + "pypika/tests/clickhouse/test_array.py::TestArray::test_get_sql_1__1_2_3_4_", + "pypika/tests/clickhouse/test_array.py::TestArray::test_get_sql_2__toInt64_1_toInt64_2_toInt64_3_toInt64_4_", + "pypika/tests/clickhouse/test_array.py::TestArray::test_get_sql_3__toFixedString_mogwai_10_toFixedString_mono_10_toFixedString_bonobo_10_arr", + "pypika/tests/clickhouse/test_array.py::TestHasAny::test_get_sql_0_hasAny_mental_abilities_physical_abilities_", + "pypika/tests/clickhouse/test_array.py::TestHasAny::test_get_sql_1_hasAny_1_2_3_4_3_", + "pypika/tests/clickhouse/test_array.py::TestHasAny::test_get_sql_2_hasAny_bands_toFixedString_port_royal_20_toFixedString_hammock_20_", + "pypika/tests/clickhouse/test_array.py::TestLength::test_get_sql_0_length_tags_", + "pypika/tests/clickhouse/test_array.py::TestLength::test_get_sql_1_length_1_2_3_", + "pypika/tests/clickhouse/test_array.py::TestEmpty::test_get_sql_0_empty_tags_", + "pypika/tests/clickhouse/test_array.py::TestEmpty::test_get_sql_1_empty_1_2_3_", + "pypika/tests/clickhouse/test_array.py::TestNotEmpty::test_get_sql_0_notEmpty_tags_", + "pypika/tests/clickhouse/test_array.py::TestNotEmpty::test_get_sql_1_notEmpty_1_2_3_", + "pypika/tests/clickhouse/test_condition.py::TestIfCondition::test_get_sql_0", + "pypika/tests/clickhouse/test_condition.py::TestIfCondition::test_get_sql_1", + "pypika/tests/clickhouse/test_condition.py::TestMultiIfCondition::test_get_sql_0", + "pypika/tests/clickhouse/test_condition.py::TestMultiIfCondition::test_get_sql_1", + "pypika/tests/clickhouse/test_dates_and_times.py::TestFormatDateTime::test_get_sql_0", + "pypika/tests/clickhouse/test_dates_and_times.py::TestFormatDateTime::test_get_sql_1", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_00", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_01", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_02", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_03", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_04", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_05", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_06", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_07", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_08", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_09", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_10", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_11", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_12", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_13", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_14", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_15", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_16", + "pypika/tests/clickhouse/test_dates_and_times.py::TestToYYYYMM::test_get_sql", + "pypika/tests/clickhouse/test_search_string.py::TestSearchString::test_search_string_0", + "pypika/tests/clickhouse/test_search_string.py::TestSearchString::test_search_string_1", + "pypika/tests/clickhouse/test_search_string.py::TestSearchString::test_search_string_2", + "pypika/tests/clickhouse/test_search_string.py::TestMultiSearch::test_multi_search_string_1", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_00_toString_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_01_toInt8_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_02_toInt16_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_03_toInt32_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_04_toInt64_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_05_toUInt8_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_06_toUInt16_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_07_toUInt32_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_08_toUInt64_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_09_toFloat32_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_10_toFloat64_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_11_toFloat64_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_12_toDate_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_13_toDateTime_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_14_toFixedString_field_name_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_00_toString_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_01_toInt8_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_02_toInt16_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_03_toInt32_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_04_toInt64_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_05_toUInt8_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_06_toUInt16_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_07_toUInt32_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_08_toUInt64_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_09_toFloat32_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_10_toFloat64_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_11_toFloat64_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_12_toDate_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_13_toDateTime_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_14_toFixedString_100_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestToFixedString::test_get_sql_with_table", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseQueryTests::test_use_AS_keyword_for_alias", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseQueryTests::test_use_FINAL_keyword", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseQueryTests::test_use_SAMPLE_keyword", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseQueryTests::test_use_SAMPLE_with_offset_keyword", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDeleteTests::test_omit_where", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDeleteTests::test_omit_where__table_schema", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDeleteTests::test_where_field_equals", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseUpdateTests::test_update", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDropQuery::test_drop_database", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDropQuery::test_drop_dictionary", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDropQuery::test_drop_other", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDropQuery::test_drop_table", + "pypika/tests/dialects/test_clickhouse.py::DistinctOnTests::test_distinct_on", + "pypika/tests/dialects/test_clickhouse.py::LimitByTests::test_limit_by", + "pypika/tests/dialects/test_clickhouse.py::LimitByTests::test_limit_offset0_by", + "pypika/tests/dialects/test_clickhouse.py::LimitByTests::test_limit_offset_by", + "pypika/tests/dialects/test_clickhouse.py::LimitByTests::test_rename_table", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_distinct_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_groupby_alias_False_does_not_group_by_alias_when_subqueries_are_present", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_groupby_alias_False_does_not_group_by_alias_with_standard_query", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_limit", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_limit_with_offset", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_normal_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_offset", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_distinct_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_percent_invalid_range", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_percent_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_select_non_int", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_with_ties_select", + "pypika/tests/dialects/test_mysql.py::SelectTests::test_distinct_select", + "pypika/tests/dialects/test_mysql.py::SelectTests::test_modifier_select", + "pypika/tests/dialects/test_mysql.py::SelectTests::test_multiple_modifier_select", + "pypika/tests/dialects/test_mysql.py::SelectTests::test_normal_select", + "pypika/tests/dialects/test_mysql.py::UpdateTests::test_conflict_handlers_update", + "pypika/tests/dialects/test_mysql.py::UpdateTests::test_on_duplicate_key_ignore_update", + "pypika/tests/dialects/test_mysql.py::UpdateTests::test_on_duplicate_key_update_update", + "pypika/tests/dialects/test_mysql.py::UpdateTests::test_update", + "pypika/tests/dialects/test_mysql.py::LoadCSVTests::test_load_from_file", + "pypika/tests/dialects/test_mysql.py::TableTests::test_create_table", + "pypika/tests/dialects/test_mysql.py::TableTests::test_drop_table", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_fetch_next_method_deprecated", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_groupby_alias_False_does_not_group_by_alias_when_subqueries_are_present", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_groupby_alias_False_does_not_group_by_alias_with_standard_query", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_limit_offset_query", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_limit_query", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_offset_query", + "pypika/tests/dialects/test_postgresql.py::InsertTests::test_array_keyword", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_alias_set_correctly", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_json_value_from_array_num", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_json_value_from_array_str", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_json_value_from_dict", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_json_value_from_dict_recursive", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_json_value_by_index", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_json_value_by_key", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_path_json_value", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_path_text_value", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_text_value_by_index", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_text_value_by_key", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contained_by_using_list_arg", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contained_by_using_str_arg", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contained_by_with_complex_criterion", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contains_for_field", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contains_for_json", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_has_any_keys", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_has_key", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_has_keys", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_subnet_contains_inet", + "pypika/tests/dialects/test_postgresql.py::DistinctOnTests::test_distinct_on", + "pypika/tests/dialects/test_postgresql.py::ArrayTests::test_array_syntax", + "pypika/tests/dialects/test_postgresql.py::ArrayTests::test_render_alias_in_array_sql", + "pypika/tests/dialects/test_postgresql.py::ReturningClauseTests::test_no_queryexception_if_returning_used_on_valid_query_type", + "pypika/tests/dialects/test_postgresql.py::ReturningClauseTests::test_queryexception_if_returning_used_on_invalid_query", + "pypika/tests/dialects/test_postgresql.py::ReturningClauseTests::test_return_field_from_join_table", + "pypika/tests/dialects/test_postgresql.py::ReturningClauseTests::test_returning_from_missing_table_raises_queryexception", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_dont_use_double_quotes_on_create_queries", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_dont_use_double_quotes_on_drop_queries", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_dont_use_double_quotes_on_joining_queries", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_use_double_quotes_on_alias_but_not_on_terms", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_use_double_quotes_on_alias_but_not_on_terms_with_joins", + "pypika/tests/dialects/test_sqllite.py::SelectTests::test_bool_false_as_zero", + "pypika/tests/dialects/test_sqllite.py::SelectTests::test_bool_true_as_one", + "pypika/tests/dialects/test_sqllite.py::ReplaceTests::test_insert_or_replace", + "pypika/tests/dialects/test_sqllite.py::ReplaceTests::test_normal_replace", + "pypika/tests/dialects/test_sqllite.py::ReplaceTests::test_replace_subquery", + "pypika/tests/dialects/test_vertica.py::VerticaQueryTests::test_delete_query_with_hint", + "pypika/tests/dialects/test_vertica.py::VerticaQueryTests::test_insert_query_with_hint", + "pypika/tests/dialects/test_vertica.py::VerticaQueryTests::test_select_query_with_hint", + "pypika/tests/dialects/test_vertica.py::VerticaQueryTests::test_update_query_with_hint", + "pypika/tests/dialects/test_vertica.py::CopyCSVTests::test_copy_from_file", + "pypika/tests/dialects/test_vertica.py::CreateTemporaryTableTests::test_create_local_table_without_temporary_raises_error", + "pypika/tests/dialects/test_vertica.py::CreateTemporaryTableTests::test_create_local_temporary_table", + "pypika/tests/dialects/test_vertica.py::CreateTemporaryTableTests::test_create_table_preserve_rows_without_temporary_raises_error", + "pypika/tests/dialects/test_vertica.py::CreateTemporaryTableTests::test_create_temporary_table_preserve_rows", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__agg_case_criterion_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__agg_case_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__agg_func_arithmetic_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__agg_func_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__case_mixed_constant_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__case_mixed_else_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__case_with_field_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__case_with_single_aggregate_field_in_one_criterion_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__constant_arithmetic_is_aggregate_none", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__constant_is_aggregate_none", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__field_arithmetic_constant_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__field_arithmetic_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__field_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__func_arithmetic_constant_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__mixed_case_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__mixed_func_arithmetic_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__negative_agg_func_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__non_aggregate_function_with_aggregated_arg", + "pypika/tests/test_aggregate.py::IsAggregateTests::test_complicated", + "pypika/tests/test_analytic_queries.py::RankTests::test_avg", + "pypika/tests/test_analytic_queries.py::RankTests::test_count_range_between_unbounded_preceeding_current_row", + "pypika/tests/test_analytic_queries.py::RankTests::test_dense_rank", + "pypika/tests/test_analytic_queries.py::RankTests::test_empty_over", + "pypika/tests/test_analytic_queries.py::RankTests::test_filter", + "pypika/tests/test_analytic_queries.py::RankTests::test_filter_quote_table_in_filter", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value_ignore_nulls", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value_ignore_nulls_first", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value_multi_argument", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value_range_between_x_preceeding_unbounded_following", + "pypika/tests/test_analytic_queries.py::RankTests::test_lag_generates_correct_sql", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value_ignore_nulls", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value_multi_argument", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value_rows_between_current_row_unbounded_following", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value_rows_between_current_row_unbounded_following_ignore_nulls", + "pypika/tests/test_analytic_queries.py::RankTests::test_lead_generates_correct_sql", + "pypika/tests/test_analytic_queries.py::RankTests::test_max_range_x_preceeding", + "pypika/tests/test_analytic_queries.py::RankTests::test_max_rows_x_preceeding", + "pypika/tests/test_analytic_queries.py::RankTests::test_median", + "pypika/tests/test_analytic_queries.py::RankTests::test_min_range_current_row", + "pypika/tests/test_analytic_queries.py::RankTests::test_min_rows_current_row", + "pypika/tests/test_analytic_queries.py::RankTests::test_multiple_partitions", + "pypika/tests/test_analytic_queries.py::RankTests::test_ntile_no_partition_or_order_invalid_sql", + "pypika/tests/test_analytic_queries.py::RankTests::test_ntile_with_order", + "pypika/tests/test_analytic_queries.py::RankTests::test_ntile_with_partition", + "pypika/tests/test_analytic_queries.py::RankTests::test_ntile_with_partition_and_order", + "pypika/tests/test_analytic_queries.py::RankTests::test_orderby_asc", + "pypika/tests/test_analytic_queries.py::RankTests::test_orderby_desc", + "pypika/tests/test_analytic_queries.py::RankTests::test_range_called_twice_raises_attribute_error", + "pypika/tests/test_analytic_queries.py::RankTests::test_range_then_rows_raises_attribute_error", + "pypika/tests/test_analytic_queries.py::RankTests::test_rank", + "pypika/tests/test_analytic_queries.py::RankTests::test_rank_with_alias", + "pypika/tests/test_analytic_queries.py::RankTests::test_row_number", + "pypika/tests/test_analytic_queries.py::RankTests::test_rows_called_twice_raises_attribute_error", + "pypika/tests/test_analytic_queries.py::RankTests::test_rows_then_range_raises_attribute_error", + "pypika/tests/test_analytic_queries.py::RankTests::test_stddev", + "pypika/tests/test_analytic_queries.py::RankTests::test_stddev_pop", + "pypika/tests/test_analytic_queries.py::RankTests::test_stddev_samp", + "pypika/tests/test_analytic_queries.py::RankTests::test_sum_rows_unbounded_preceeding", + "pypika/tests/test_analytic_queries.py::RankTests::test_table_prefixes_used_in_analytic_functions", + "pypika/tests/test_analytic_queries.py::RankTests::test_var_pop", + "pypika/tests/test_analytic_queries.py::RankTests::test_var_samp", + "pypika/tests/test_analytic_queries.py::RankTests::test_variance", + "pypika/tests/test_analytic_queries.py::RankTests::test_variance_rows_between_unbounded_preceeding_unbounded_following", + "pypika/tests/test_analytic_queries.py::RankTests::test_varpop_range_unbounded_preceeding", + "pypika/tests/test_analytic_queries.py::RankTests::test_varpop_rows_between_unbounded_preceeding_x_following", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_as_select_not_query_raises_error", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_with_columns", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_with_select", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_with_select_and_columns_fails", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_without_columns_or_select_empty", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_if_not_exists", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_simple", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_unique", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_where", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_without_columns_raises_error", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_without_table_raises_error", + "pypika/tests/test_criterions.py::CriterionTests::test__bitwise_and_in_where_clause", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_bitwise_and", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_bitwise_and_with_alias", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_bool", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_decimal", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_str", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gt_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gt_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gt_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gt_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gte_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gte_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gte_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gte_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_is_null", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_is_null_with_alias", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lt_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lt_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lt_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lt_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lte_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lte_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lte_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lte_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_str", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_with_alias", + "pypika/tests/test_criterions.py::NotTests::test_chained_function", + "pypika/tests/test_criterions.py::NotTests::test_is_not_null", + "pypika/tests/test_criterions.py::NotTests::test_negate", + "pypika/tests/test_criterions.py::NotTests::test_not_null", + "pypika/tests/test_criterions.py::NotTests::test_not_null_with_alias", + "pypika/tests/test_criterions.py::NotTests::test_not_with_and_criterion", + "pypika/tests/test_criterions.py::NotTests::test_not_with_complex_criterion", + "pypika/tests/test_criterions.py::NotTests::test_not_with_or_criterion", + "pypika/tests/test_criterions.py::NotTests::test_notnullcriterion_replace_table", + "pypika/tests/test_criterions.py::NotTests::test_variable_access", + "pypika/tests/test_criterions.py::BetweenTests::test__between_date", + "pypika/tests/test_criterions.py::BetweenTests::test__between_datetime", + "pypika/tests/test_criterions.py::BetweenTests::test__between_number", + "pypika/tests/test_criterions.py::BetweenTests::test__between_with_alias", + "pypika/tests/test_criterions.py::BetweenTests::test__function_between", + "pypika/tests/test_criterions.py::BetweenTests::test_get_item_only_works_with_slice", + "pypika/tests/test_criterions.py::IsInTests::test__function_isin", + "pypika/tests/test_criterions.py::IsInTests::test__in_character", + "pypika/tests/test_criterions.py::IsInTests::test__in_date", + "pypika/tests/test_criterions.py::IsInTests::test__in_datetime", + "pypika/tests/test_criterions.py::IsInTests::test__in_number", + "pypika/tests/test_criterions.py::IsInTests::test__in_number_with_alias", + "pypika/tests/test_criterions.py::IsInTests::test__in_unicode", + "pypika/tests/test_criterions.py::ArithmeticExpressionTests::test__lshift", + "pypika/tests/test_criterions.py::ArithmeticExpressionTests::test__rshift", + "pypika/tests/test_criterions.py::NotInTests::test__function_notin", + "pypika/tests/test_criterions.py::NotInTests::test__notin_character", + "pypika/tests/test_criterions.py::NotInTests::test__notin_date", + "pypika/tests/test_criterions.py::NotInTests::test__notin_datetime", + "pypika/tests/test_criterions.py::NotInTests::test__notin_number", + "pypika/tests/test_criterions.py::NotInTests::test__notin_number_with_alias", + "pypika/tests/test_criterions.py::LikeTests::test_glob_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_contains", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_ends_with", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_n_chars_long", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_starts_with", + "pypika/tests/test_criterions.py::LikeTests::test_like_contains", + "pypika/tests/test_criterions.py::LikeTests::test_like_ends_with", + "pypika/tests/test_criterions.py::LikeTests::test_like_n_chars_long", + "pypika/tests/test_criterions.py::LikeTests::test_like_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_like_starts_with", + "pypika/tests/test_criterions.py::LikeTests::test_not_ilike_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_not_like_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_rlike_escape_chars", + "pypika/tests/test_criterions.py::ExistsCriterionTests::test_exists", + "pypika/tests/test_criterions.py::ExistsCriterionTests::test_not_exists", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__between_and_field", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__between_and_isin", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__nested__and", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__nested__mixed", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__nested__or", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_and", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_function_and", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_function_or", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_function_xor", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_or", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_xor", + "pypika/tests/test_criterions.py::FieldsAsCriterionTests::test__field_and_field", + "pypika/tests/test_criterions.py::FieldsAsCriterionTests::test__field_or_field", + "pypika/tests/test_criterions.py::FieldsAsCriterionTests::test__field_xor_field", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_arithmeticfunction_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_betweencriterion_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_complexcriterion_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_criterion_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_field_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_function_with_only_fields_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_function_with_values_and_fields_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_nullcriterion_replace_table", + "pypika/tests/test_criterions.py::AnyTests::test_multiple_args_returned_in_chain_of_ors", + "pypika/tests/test_criterions.py::AnyTests::test_single_arg_returns_self", + "pypika/tests/test_criterions.py::AnyTests::test_with_generator", + "pypika/tests/test_criterions.py::AnyTests::test_zero_args_returns_empty_criterion", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_different_operations_with_empty_criterion", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_empty_criterion_on_the_left", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_empty_criterion_on_the_right", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_fields_", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_invertion_of_the_empty_criterion", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_more_than_one_empty_criterions", + "pypika/tests/test_criterions.py::AllTests::test_multiple_args_returned_in_chain_of_ors", + "pypika/tests/test_criterions.py::AllTests::test_single_arg_returns_self", + "pypika/tests/test_criterions.py::AllTests::test_with_generator", + "pypika/tests/test_criterions.py::AllTests::test_zero_args_returns_empty_criterion", + "pypika/tests/test_custom_functions.py::TestUnitCustomFunction::test_should_fail_with_wrong_arguments", + "pypika/tests/test_custom_functions.py::TestUnitCustomFunction::test_should_return_function_with_arguments", + "pypika/tests/test_custom_functions.py::TestUnitCustomFunction::test_should_return_function_with_no_arguments", + "pypika/tests/test_custom_functions.py::TestFunctionalCustomFunction::test_should_fail_use_custom_function_on_select_with_wrong_arguments", + "pypika/tests/test_custom_functions.py::TestFunctionalCustomFunction::test_should_use_custom_function_on_select", + "pypika/tests/test_data_types.py::StringTests::test_inline_string_concatentation", + "pypika/tests/test_data_types.py::UuidTests::test_uuid_string_generation", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_day", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_default", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_microsecond", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_minute", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_month", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_quarter", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_second", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_week", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_year", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_day_hour", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_day_microsecond", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_day_minute", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_day_second", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_hour_microsecond", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_hour_minute", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_hour_second", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_minute_microsecond", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_minute_second", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_second_microsecond", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_value_complex_expressions", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_value_right", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_year_month", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_mysql_dialect_uses_single_quotes_around_expression_in_an_interval", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_oracle_dialect_uses_single_quotes_around_expression_in_an_interval", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_postgresql_dialect_uses_single_quotes_around_interval", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_redshift_dialect_uses_single_quotes_around_interval", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_vertica_dialect_uses_single_quotes_around_interval", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_day", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_month", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_week", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_year", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_year_month", + "pypika/tests/test_date_math.py::TruncateTrailingZerosTests::test_do_not_truncate_integer_values", + "pypika/tests/test_date_math.py::TruncateTrailingZerosTests::test_do_not_truncate_months_between_years_and_datys", + "pypika/tests/test_deletes.py::DeleteTests::test_for_portion", + "pypika/tests/test_deletes.py::DeleteTests::test_omit_where", + "pypika/tests/test_deletes.py::DeleteTests::test_omit_where__table_schema", + "pypika/tests/test_deletes.py::DeleteTests::test_where_field_equals", + "pypika/tests/test_deletes.py::PostgresDeleteTests::test_delete_returning", + "pypika/tests/test_deletes.py::PostgresDeleteTests::test_delete_returning_star", + "pypika/tests/test_deletes.py::PostgresDeleteTests::test_delete_returning_str", + "pypika/tests/test_deletes.py::PostgresDeleteTests::test_delete_using", + "pypika/tests/test_drop.py::DropTableTests::test_drop_database", + "pypika/tests/test_drop.py::DropTableTests::test_drop_index", + "pypika/tests/test_drop.py::DropTableTests::test_drop_table", + "pypika/tests/test_drop.py::DropTableTests::test_drop_user", + "pypika/tests/test_drop.py::DropTableTests::test_drop_view", + "pypika/tests/test_formats.py::QuoteTests::test_no_quote_char_in_complex_query", + "pypika/tests/test_formats.py::QuoteTests::test_replace_quote_char_in_complex_query", + "pypika/tests/test_functions.py::FunctionTests::test_dialect_propagation", + "pypika/tests/test_functions.py::FunctionTests::test_is_aggregate_None_for_non_aggregate_function_or_function_with_no_aggregate_functions", + "pypika/tests/test_functions.py::FunctionTests::test_is_aggregate_True_for_aggregate_function_or_function_with_aggregate_functions", + "pypika/tests/test_functions.py::SchemaTests::test_schema_included_in_function_sql", + "pypika/tests/test_functions.py::SchemaTests::test_schema_no_schema_in_sql_when_none_set", + "pypika/tests/test_functions.py::ArithmeticTests::test__addition__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__addition__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__addition__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__addition__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__arithmetic_equality", + "pypika/tests/test_functions.py::ArithmeticTests::test__arithmetic_with_function", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_add_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_div_no_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_div_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_exponent_no_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_exponent_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_floor_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_function_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_modulus_no_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_modulus_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_mul_no_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_mul_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_nested_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_sub_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__division__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__division__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__division__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__division__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__exponent__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__exponent__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__floor", + "pypika/tests/test_functions.py::ArithmeticTests::test__leftshift__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__leftshift__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__leftshift__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__modulus__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__multiplication__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__multiplication__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__multiplication__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__multiplication__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__rightshift__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__rightshift__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__rightshift__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__subtraction__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__subtraction__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__subtraction__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__subtraction__right", + "pypika/tests/test_functions.py::AggregationTests::test__approx_percentile", + "pypika/tests/test_functions.py::AggregationTests::test__avg", + "pypika/tests/test_functions.py::AggregationTests::test__count", + "pypika/tests/test_functions.py::AggregationTests::test__count__star", + "pypika/tests/test_functions.py::AggregationTests::test__first", + "pypika/tests/test_functions.py::AggregationTests::test__last", + "pypika/tests/test_functions.py::AggregationTests::test__max", + "pypika/tests/test_functions.py::AggregationTests::test__min", + "pypika/tests/test_functions.py::AggregationTests::test__std", + "pypika/tests/test_functions.py::AggregationTests::test__stddev", + "pypika/tests/test_functions.py::AggregationTests::test__subquery_in_params_functions", + "pypika/tests/test_functions.py::AggregationTests::test__sum", + "pypika/tests/test_functions.py::ConditionTests::test__case__else", + "pypika/tests/test_functions.py::ConditionTests::test__case__field", + "pypika/tests/test_functions.py::ConditionTests::test__case__multi", + "pypika/tests/test_functions.py::ConditionTests::test__case__no_cases", + "pypika/tests/test_functions.py::ConditionTests::test__case__raw", + "pypika/tests/test_functions.py::StringTests::test__ascii__field", + "pypika/tests/test_functions.py::StringTests::test__ascii__int", + "pypika/tests/test_functions.py::StringTests::test__ascii__str", + "pypika/tests/test_functions.py::StringTests::test__bin__field", + "pypika/tests/test_functions.py::StringTests::test__bin__int", + "pypika/tests/test_functions.py::StringTests::test__bin__str", + "pypika/tests/test_functions.py::StringTests::test__concat__field", + "pypika/tests/test_functions.py::StringTests::test__concat__str", + "pypika/tests/test_functions.py::StringTests::test__insert__field", + "pypika/tests/test_functions.py::StringTests::test__insert__str", + "pypika/tests/test_functions.py::StringTests::test__length__field", + "pypika/tests/test_functions.py::StringTests::test__length__str", + "pypika/tests/test_functions.py::StringTests::test__lower__field", + "pypika/tests/test_functions.py::StringTests::test__lower__str", + "pypika/tests/test_functions.py::StringTests::test__replace__field", + "pypika/tests/test_functions.py::StringTests::test__replace__str", + "pypika/tests/test_functions.py::StringTests::test__substring", + "pypika/tests/test_functions.py::SplitPartFunctionTests::test__split_part", + "pypika/tests/test_functions.py::RegexpLikeFunctionTests::test__regexp_like", + "pypika/tests/test_functions.py::CastTests::test__cast__as", + "pypika/tests/test_functions.py::CastTests::test__cast__binary", + "pypika/tests/test_functions.py::CastTests::test__cast__binary_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__boolean", + "pypika/tests/test_functions.py::CastTests::test__cast__char", + "pypika/tests/test_functions.py::CastTests::test__cast__char_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__date", + "pypika/tests/test_functions.py::CastTests::test__cast__float", + "pypika/tests/test_functions.py::CastTests::test__cast__integer", + "pypika/tests/test_functions.py::CastTests::test__cast__long_varbinary", + "pypika/tests/test_functions.py::CastTests::test__cast__long_varbinary_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__long_varchar", + "pypika/tests/test_functions.py::CastTests::test__cast__long_varchar_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__numeric", + "pypika/tests/test_functions.py::CastTests::test__cast__signed", + "pypika/tests/test_functions.py::CastTests::test__cast__timestamp", + "pypika/tests/test_functions.py::CastTests::test__cast__unsigned", + "pypika/tests/test_functions.py::CastTests::test__cast__varbinary", + "pypika/tests/test_functions.py::CastTests::test__cast__varbinary_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__varchar", + "pypika/tests/test_functions.py::CastTests::test__cast__varchar_with_arg", + "pypika/tests/test_functions.py::CastTests::test__tochar__", + "pypika/tests/test_functions.py::DateFunctionsTests::test_current_date", + "pypika/tests/test_functions.py::DateFunctionsTests::test_current_time", + "pypika/tests/test_functions.py::DateFunctionsTests::test_current_timestamp", + "pypika/tests/test_functions.py::DateFunctionsTests::test_current_timestamp_with_alias", + "pypika/tests/test_functions.py::DateFunctionsTests::test_date_add", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_day", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_hour", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_join", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_microsecond", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_minute", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_month", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_quarter", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_second", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_week", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_year", + "pypika/tests/test_functions.py::DateFunctionsTests::test_now", + "pypika/tests/test_functions.py::DateFunctionsTests::test_time_diff", + "pypika/tests/test_functions.py::DateFunctionsTests::test_timestampadd", + "pypika/tests/test_functions.py::DateFunctionsTests::test_to_date", + "pypika/tests/test_functions.py::DateFunctionsTests::test_utc_timestamp", + "pypika/tests/test_functions.py::NullFunctionsTests::test_coalesce", + "pypika/tests/test_functions.py::NullFunctionsTests::test_isnull", + "pypika/tests/test_functions.py::NullFunctionsTests::test_nullif", + "pypika/tests/test_functions.py::NullFunctionsTests::test_nvl", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_mysql_one_groupby", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_mysql_rollup_two_groupbys", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_no_rollup_after_rollup_mysql", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_no_rollup_before_groupby", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_from_groupbys", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_from_parameters", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_from_two_groupbys", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_func_one_groupby", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_func_partial", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_func_two_groupbys", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_multiple_rollups", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_rollups_with_multiple_rollups_and_parity", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_rollups_with_parity", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_force_index_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_groupby_returns_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_immutable_kwarg_on_query_builder_disables_immutability", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_insert_into_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_join_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_orderby_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_queries_after_join", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_replace_into_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_select_returns_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_update_set_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_use_index_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_with_return_new_query_instance", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_multi_rows", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_multi_rows_chained", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_multi_rows_chained_mixed", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_multi_rows_chained_multiple_rows", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_single_element", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_column_using_alias_with_chain", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_column_using_table_alias", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_empty_columns", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_empty_columns_type_list", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_empty_columns_type_tuple", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_ignore", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_multiple_rows_with_array_value", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_none_skipped", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_null", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_one_column", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_one_column_multi_element_array", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_one_column_single_element_array", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_selected_columns", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_selected_columns_type_list", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_selected_columns_type_tuple", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_single_row_with_array_value", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_with_statement", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_empty_on_conflict_do_update_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_field", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_field_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_mixed_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_multiple_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_multiple_fields_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_field", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_field_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_multiple_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_multiple_fields_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_multiple_mixed_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_no_handler", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_two_handlers_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_two_handlers_do_update", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_fieldless_conflict_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_fieldless_conflict_do_update_field", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_non_insert_on_conflict_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_non_insert_on_conflict_do_update", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_do_nothing_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_do_update_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_do_update_with_excluded_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_from_subquery", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_complex", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_conflict_fields_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_conflict_fields_do_update", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_empty_conflict_fields_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_empty_conflict_fields_do_update", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_where_and_on_conflict_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_all_columns_multi_rows_chained_returning_star", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_all_columns_multi_rows_chained_returning_star_and_id", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_all_columns_multi_rows_chained_returning_star_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_all_columns_single_element_arrays", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_aggregate", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_all_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_all_fields_and_arithmetics", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_arithmetics", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_from_other_table", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_functions", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_null", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_one_field", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_one_field_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_tuple", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_ignore", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multi_rows_chained_mixed_on_duplicate_update_multiple", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_multiple", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_different_value", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_expression", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_expression_using_original_field_value", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_expression_using_values", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_same_value", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_none_skipped", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_one_column", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_one_column_multi_element_array", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_one_column_single_element_array", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_one_column_using_values", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_selected_columns_on_duplicate_update_multiple", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_selected_columns_on_duplicate_update_one", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_columns_from_columns", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_columns_from_columns_with_join", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_columns_from_star", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_from_columns", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_ignore_star", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_star", + "pypika/tests/test_inserts.py::InsertSubqueryTests::test_insert_subquery_wrapped_in_brackets", + "pypika/tests/test_inserts.py::SelectIntoTests::test_select_columns_into", + "pypika/tests/test_inserts.py::SelectIntoTests::test_select_columns_into_with_join", + "pypika/tests/test_inserts.py::SelectIntoTests::test_select_star_into", + "pypika/tests/test_inserts.py::ReplaceTests::test_replace_simple", + "pypika/tests/test_inserts.py::ReplaceTests::test_replace_subquery", + "pypika/tests/test_internals.py::TablesTests::test__case_tables", + "pypika/tests/test_internals.py::TablesTests::test__criterion_replace_table_with_value", + "pypika/tests/test_internals.py::TablesTests::test__star_tables", + "pypika/tests/test_internals.py::TablesTests::test__table_star_tables", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_cross_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_cross_join_on_subquery", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_cross_join_on_table", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_default_join_type", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_full_outer_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_hash_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_inner_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_arithmetic_field", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_collate", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_complex_criteria", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_field_multi", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_field_multi_with_extra_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_field_single", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_field_without_fields_raises_exception", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_subquery_criteria", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_second_table_in_from_clause", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_using_multiple_fields", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_using_string_field_name", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_using_with_quote_char", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_using_without_fields_raises_exception", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_with_arithmetic_function_in_select", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_left_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_left_outer_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_outer_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_right_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_right_outer_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_temporal_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_use_different_table_objects_for_same_table", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_fail_when_joining_unknown_type", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_ignore_table_references", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_immutable__tables", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_from_join", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_query_with_column_alias", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_query_with_setoperation", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_query_with_table_alias", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_query_without_alias", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_same_table", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_same_table_with_prefixes", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_table_twice", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_prefixes_added_to_function_in_orderby", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_prefixes_added_to_groupby", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_prefixes_added_to_orderby", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_require_condition", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_require_condition_with_both_tables", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select__fields_after_table_star", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select__ordered_select_clauses", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select__star_for_table", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select__star_for_table__replacement", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select_field_from_missing_table", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select_fields_with_where", + "pypika/tests/test_joins.py::UnionTests::test_mysql_query_wraps_unioned_queries", + "pypika/tests/test_joins.py::UnionTests::test_require_equal_number_of_fields", + "pypika/tests/test_joins.py::UnionTests::test_union", + "pypika/tests/test_joins.py::UnionTests::test_union_all", + "pypika/tests/test_joins.py::UnionTests::test_union_all_multiple", + "pypika/tests/test_joins.py::UnionTests::test_union_as_subquery", + "pypika/tests/test_joins.py::UnionTests::test_union_multiple", + "pypika/tests/test_joins.py::UnionTests::test_union_with_no_quote_char", + "pypika/tests/test_joins.py::UnionTests::test_union_with_order_by", + "pypika/tests/test_joins.py::UnionTests::test_union_with_order_by_use_union_query_field", + "pypika/tests/test_joins.py::UnionTests::test_union_with_order_by_use_union_query_field_with_aliases", + "pypika/tests/test_joins.py::UnionTests::test_union_with_order_by_with_aliases", + "pypika/tests/test_joins.py::InsertQueryJoinTests::test_join_table_on_insert_query", + "pypika/tests/test_joins.py::UpdateQueryJoinTests::test_join_table_on_update_query", + "pypika/tests/test_joins.py::IntersectTests::test_intersect", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_as_subquery", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_multiple", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_with_limit", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_with_no_quote_char", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_with_offset", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_with_order_by", + "pypika/tests/test_joins.py::IntersectTests::test_mysql_query_wraps_intersected_queries", + "pypika/tests/test_joins.py::IntersectTests::test_require_equal_number_of_fields_intersect", + "pypika/tests/test_joins.py::MinusTests::test_minus", + "pypika/tests/test_joins.py::MinusTests::test_minus_as_subquery", + "pypika/tests/test_joins.py::MinusTests::test_minus_multiple", + "pypika/tests/test_joins.py::MinusTests::test_minus_query_with_order_by_use_minus_query_field", + "pypika/tests/test_joins.py::MinusTests::test_minus_with_no_quote_char", + "pypika/tests/test_joins.py::MinusTests::test_minus_with_order_by", + "pypika/tests/test_joins.py::MinusTests::test_mysql_query_wraps_minus_queries", + "pypika/tests/test_joins.py::MinusTests::test_require_equal_number_of_fields", + "pypika/tests/test_joins.py::ExceptOfTests::test_except", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_as_subquery", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_multiple", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_query_with_order_by_use_minus_query_field", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_with_no_quote_char", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_with_order_by", + "pypika/tests/test_joins.py::ExceptOfTests::test_require_equal_number_of_fields_except_of", + "pypika/tests/test_negation.py::NegationTests::test_negate_field", + "pypika/tests/test_negation.py::NegationTests::test_negate_function", + "pypika/tests/test_negation.py::NegationTests::test_negate_wrapped_float", + "pypika/tests/test_negation.py::NegationTests::test_negate_wrapped_int", + "pypika/tests/test_parameter.py::ParametrizedTests::test_format_parameter", + "pypika/tests/test_parameter.py::ParametrizedTests::test_join", + "pypika/tests/test_parameter.py::ParametrizedTests::test_named_parameter", + "pypika/tests/test_parameter.py::ParametrizedTests::test_numeric_parameter", + "pypika/tests/test_parameter.py::ParametrizedTests::test_param_insert", + "pypika/tests/test_parameter.py::ParametrizedTests::test_param_select_join", + "pypika/tests/test_parameter.py::ParametrizedTests::test_param_select_subquery", + "pypika/tests/test_parameter.py::ParametrizedTests::test_pyformat_parameter", + "pypika/tests/test_parameter.py::ParametrizedTests::test_qmark_parameter", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_join", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_join_with_parameter_value_wrapper", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_param_insert", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_param_select_join", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_param_select_subquery", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_pyformat_parameter", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_can_be_used_in_a_select_statement", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_can_be_used_in_a_where_clause", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_can_be_used_in_orderby", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_column_value", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_object_id", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_object_value", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_row_id", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_row_num", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_sys_date", + "pypika/tests/test_query.py::QueryTablesTests::test_is_joined", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_case_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_delete_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_filter_tables", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_having_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_insert_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_insert_table_current_table_not_match", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_join_tables", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_only_specified_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_orderby_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_tuple_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_update_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_update_table_current_table_not_match", + "pypika/tests/test_query.py::QueryBuilderTests::test_pipe", + "pypika/tests/test_query.py::QueryBuilderTests::test_query_builders_have_reference_to_correct_query_class", + "pypika/tests/test_selects.py::SelectTests::test_empty_query", + "pypika/tests/test_selects.py::SelectTests::test_mssql_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_mysql_query_uses_backtick_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_oracle_query_uses_no_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_postgresql_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_redshift_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_select__column__single__alias__str", + "pypika/tests/test_selects.py::SelectTests::test_select__column__single__field", + "pypika/tests/test_selects.py::SelectTests::test_select__column__single__str", + "pypika/tests/test_selects.py::SelectTests::test_select__column__single__table_alias__str", + "pypika/tests/test_selects.py::SelectTests::test_select__columns__multi__field", + "pypika/tests/test_selects.py::SelectTests::test_select__columns__multi__str", + "pypika/tests/test_selects.py::SelectTests::test_select__distinct__multi", + "pypika/tests/test_selects.py::SelectTests::test_select__distinct__single", + "pypika/tests/test_selects.py::SelectTests::test_select__multiple_subqueries", + "pypika/tests/test_selects.py::SelectTests::test_select__multiple_tables", + "pypika/tests/test_selects.py::SelectTests::test_select__nested_subquery", + "pypika/tests/test_selects.py::SelectTests::test_select__no_table", + "pypika/tests/test_selects.py::SelectTests::test_select__star", + "pypika/tests/test_selects.py::SelectTests::test_select__star__replacement", + "pypika/tests/test_selects.py::SelectTests::test_select__subquery", + "pypika/tests/test_selects.py::SelectTests::test_select__table_schema", + "pypika/tests/test_selects.py::SelectTests::test_select__table_schema_with_multiple_levels_as_list", + "pypika/tests/test_selects.py::SelectTests::test_select__table_schema_with_multiple_levels_as_tuple", + "pypika/tests/test_selects.py::SelectTests::test_select_no_from", + "pypika/tests/test_selects.py::SelectTests::test_select_no_from_with_field_raises_exception", + "pypika/tests/test_selects.py::SelectTests::test_select_no_with_alias_from", + "pypika/tests/test_selects.py::SelectTests::test_select_then_add_table", + "pypika/tests/test_selects.py::SelectTests::test_select_with_force_index", + "pypika/tests/test_selects.py::SelectTests::test_select_with_force_index_multiple_calls", + "pypika/tests/test_selects.py::SelectTests::test_select_with_force_index_multiple_indexes", + "pypika/tests/test_selects.py::SelectTests::test_select_with_force_index_with_index_object", + "pypika/tests/test_selects.py::SelectTests::test_select_with_limit", + "pypika/tests/test_selects.py::SelectTests::test_select_with_limit__func", + "pypika/tests/test_selects.py::SelectTests::test_select_with_limit_and_offset", + "pypika/tests/test_selects.py::SelectTests::test_select_with_limit_zero", + "pypika/tests/test_selects.py::SelectTests::test_select_with_offset", + "pypika/tests/test_selects.py::SelectTests::test_select_with_offset__func", + "pypika/tests/test_selects.py::SelectTests::test_select_with_use_index", + "pypika/tests/test_selects.py::SelectTests::test_select_with_use_index_multiple_calls", + "pypika/tests/test_selects.py::SelectTests::test_select_with_use_index_multiple_indexes", + "pypika/tests/test_selects.py::SelectTests::test_select_with_use_index_with_index_object", + "pypika/tests/test_selects.py::SelectTests::test_table_select_alias", + "pypika/tests/test_selects.py::SelectTests::test_table_select_alias_with_offset_and_limit", + "pypika/tests/test_selects.py::SelectTests::test_temporal_select", + "pypika/tests/test_selects.py::SelectTests::test_vertica_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::WhereTests::test_ignore_empty_criterion_having", + "pypika/tests/test_selects.py::WhereTests::test_ignore_empty_criterion_where", + "pypika/tests/test_selects.py::WhereTests::test_select_with_force_index_and_where", + "pypika/tests/test_selects.py::WhereTests::test_where_enum", + "pypika/tests/test_selects.py::WhereTests::test_where_field_contains", + "pypika/tests/test_selects.py::WhereTests::test_where_field_does_not_contain", + "pypika/tests/test_selects.py::WhereTests::test_where_field_does_not_end_with", + "pypika/tests/test_selects.py::WhereTests::test_where_field_does_not_start_with", + "pypika/tests/test_selects.py::WhereTests::test_where_field_ends_with", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_and", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_nowait", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_of", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_of_multiple_tables", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_of_nowait", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_of_skip_locked", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_skip_locked", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_skip_locked_and_of", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_or", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_where", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_where_not", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_where_two_not", + "pypika/tests/test_selects.py::WhereTests::test_where_field_is_n_chars_long", + "pypika/tests/test_selects.py::WhereTests::test_where_field_is_not_n_chars_long", + "pypika/tests/test_selects.py::WhereTests::test_where_field_matches_regex", + "pypika/tests/test_selects.py::WhereTests::test_where_field_matches_regexp", + "pypika/tests/test_selects.py::WhereTests::test_where_field_matches_rlike", + "pypika/tests/test_selects.py::WhereTests::test_where_field_starts_with", + "pypika/tests/test_selects.py::WhereTests::test_where_nested_conditions", + "pypika/tests/test_selects.py::WhereTests::test_where_single_quote", + "pypika/tests/test_selects.py::WhereTests::test_where_with_multiple_wheres_using_and_case", + "pypika/tests/test_selects.py::WhereTests::test_where_with_multiple_wheres_using_or_case", + "pypika/tests/test_selects.py::PreWhereTests::test_ignore_empty_criterion_having", + "pypika/tests/test_selects.py::PreWhereTests::test_ignore_empty_criterion_where", + "pypika/tests/test_selects.py::PreWhereTests::test_prewhere_field_equals", + "pypika/tests/test_selects.py::PreWhereTests::test_select_with_force_index_and_where", + "pypika/tests/test_selects.py::PreWhereTests::test_where_and_prewhere", + "pypika/tests/test_selects.py::PreWhereTests::test_where_enum", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_contains", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_does_not_contain", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_does_not_end_with", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_does_not_start_with", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_ends_with", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_and", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_nowait", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_of", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_of_multiple_tables", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_of_nowait", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_of_skip_locked", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_skip_locked", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_skip_locked_and_of", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_or", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_where", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_where_not", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_where_two_not", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_is_n_chars_long", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_is_not_n_chars_long", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_matches_regex", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_matches_regexp", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_matches_rlike", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_starts_with", + "pypika/tests/test_selects.py::PreWhereTests::test_where_nested_conditions", + "pypika/tests/test_selects.py::PreWhereTests::test_where_single_quote", + "pypika/tests/test_selects.py::PreWhereTests::test_where_with_multiple_wheres_using_and_case", + "pypika/tests/test_selects.py::PreWhereTests::test_where_with_multiple_wheres_using_or_case", + "pypika/tests/test_selects.py::GroupByTests::test_group_by__single_with_totals", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__alias", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__alias_platforms", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__alias_with_join", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__count_distinct", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__count_field", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__count_star", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__int", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__multi", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__multi_with_totals", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__no_alias", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__no_alias_mssql", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__no_alias_oracle", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__single", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__str", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__sum_distinct", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__sum_filter", + "pypika/tests/test_selects.py::GroupByTests::test_groupby_with_case_uses_the_alias", + "pypika/tests/test_selects.py::GroupByTests::test_mssql_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_mysql_query_uses_backtick_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_oracle_query_uses_no_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_postgres_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_redshift_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_vertica_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_having_and", + "pypika/tests/test_selects.py::HavingTests::test_having_greater_than", + "pypika/tests/test_selects.py::HavingTests::test_having_join_and_equality", + "pypika/tests/test_selects.py::HavingTests::test_mssql_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_mysql_query_uses_backtick_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_oracle_query_uses_no_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_postgres_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_redshift_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_vertica_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_alias", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_asc", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_desc", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_multi_fields", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_no_alias", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_single_field", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_single_str", + "pypika/tests/test_selects.py::AliasTests::test_arithmetic_function", + "pypika/tests/test_selects.py::AliasTests::test_case_using_as", + "pypika/tests/test_selects.py::AliasTests::test_case_using_constructor_param", + "pypika/tests/test_selects.py::AliasTests::test_function_using_as_nested", + "pypika/tests/test_selects.py::AliasTests::test_functions_using_as", + "pypika/tests/test_selects.py::AliasTests::test_functions_using_constructor_param", + "pypika/tests/test_selects.py::AliasTests::test_functions_using_constructor_param_nested", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_criterion", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_criterion_comparison", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_field_inside_case", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_groupby", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_orderby", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_where", + "pypika/tests/test_selects.py::AliasTests::test_null_value_with_alias", + "pypika/tests/test_selects.py::AliasTests::test_select__multiple_tables", + "pypika/tests/test_selects.py::AliasTests::test_table_field", + "pypika/tests/test_selects.py::AliasTests::test_table_field__multi", + "pypika/tests/test_selects.py::AliasTests::test_table_with_schema_and_alias", + "pypika/tests/test_selects.py::AliasTests::test_use_aliases_in_groupby_and_orderby", + "pypika/tests/test_selects.py::SubqueryTests::test_from_subquery_without_alias", + "pypika/tests/test_selects.py::SubqueryTests::test_join", + "pypika/tests/test_selects.py::SubqueryTests::test_join_query_with_alias", + "pypika/tests/test_selects.py::SubqueryTests::test_join_with_with", + "pypika/tests/test_selects.py::SubqueryTests::test_select_from_nested_query", + "pypika/tests/test_selects.py::SubqueryTests::test_select_from_nested_query_with_join", + "pypika/tests/test_selects.py::SubqueryTests::test_select_from_with_returning", + "pypika/tests/test_selects.py::SubqueryTests::test_select_subquery", + "pypika/tests/test_selects.py::SubqueryTests::test_select_subquery_with_alias", + "pypika/tests/test_selects.py::SubqueryTests::test_where__equality", + "pypika/tests/test_selects.py::SubqueryTests::test_where__in", + "pypika/tests/test_selects.py::SubqueryTests::test_where__in_nested", + "pypika/tests/test_selects.py::SubqueryTests::test_with", + "pypika/tests/test_selects.py::QuoteTests::test_extraneous_quotes", + "pypika/tests/test_tables.py::TableStructureTests::test_database_schema_table_attr", + "pypika/tests/test_tables.py::TableStructureTests::test_schema_table_attr", + "pypika/tests/test_tables.py::TableStructureTests::test_table_for_period_sql", + "pypika/tests/test_tables.py::TableStructureTests::test_table_for_system_time_sql", + "pypika/tests/test_tables.py::TableStructureTests::test_table_sql", + "pypika/tests/test_tables.py::TableStructureTests::test_table_with_alias", + "pypika/tests/test_tables.py::TableStructureTests::test_table_with_schema_and_schema_parent_arg", + "pypika/tests/test_tables.py::TableStructureTests::test_table_with_schema_arg", + "pypika/tests/test_tables.py::TableEqualityTests::test_many_tables_with_alias", + "pypika/tests/test_tables.py::TableEqualityTests::test_many_tables_with_or_not_alias", + "pypika/tests/test_tables.py::TableEqualityTests::test_many_tables_without_alias", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_equal_by_name", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_equal_by_schema_and_name", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_equal_by_schema_and_name_using_schema", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_equal_by_schema_and_name_using_schema_with_parent", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_not_equal_by_schema_and_name_using_schema_with_different_parents", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_not_equal_with_different_names", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_not_equal_with_different_schemas", + "pypika/tests/test_tables.py::TableDialectTests::test_make_tables_factory_with_default_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_make_tables_factory_with_dialect_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_factory_with_default_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_factory_with_dialect_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_with_bad_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_with_default_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_with_dialect_query_cls", + "pypika/tests/test_terms.py::FieldAliasTests::test_when_alias_specified", + "pypika/tests/test_terms.py::FieldInitTests::test_init_with_str_table", + "pypika/tests/test_terms.py::FieldHashingTests::test_non_tabled_aliased_eq_fields_equally_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_non_tabled_aliased_ne_fields_differently_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_non_tabled_eq_fields_equally_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_non_tabled_ne_fields_differently_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_tabled_eq_fields_equally_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_tabled_ne_fields_differently_hashed", + "pypika/tests/test_terms.py::AtTimezoneTests::test_passes_kwargs_to_field_get_sql", + "pypika/tests/test_terms.py::AtTimezoneTests::test_when_alias_specified", + "pypika/tests/test_terms.py::AtTimezoneTests::test_when_interval_not_specified", + "pypika/tests/test_terms.py::AtTimezoneTests::test_when_interval_specified", + "pypika/tests/test_tuples.py::TupleTests::test_render_alias_in_array_sql", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_equality_tuple_on_both", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_equality_tuple_on_left", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_equality_tuple_on_right", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_in_using_mixed_tuples", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_in_using_pypika_tuples", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_in_using_python_tuples", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_is_aggregate", + "pypika/tests/test_tuples.py::TupleTests::test_tuples_in_join", + "pypika/tests/test_tuples.py::ArrayTests::test_array_general", + "pypika/tests/test_tuples.py::ArrayTests::test_empty_psql_array", + "pypika/tests/test_tuples.py::ArrayTests::test_psql_array_general", + "pypika/tests/test_tuples.py::ArrayTests::test_render_alias_in_array_sql", + "pypika/tests/test_tuples.py::BracketTests::test_arithmetic_with_brackets", + "pypika/tests/test_tuples.py::BracketTests::test_arithmetic_with_brackets_and_alias", + "pypika/tests/test_updates.py::UpdateTests::test_empty_query", + "pypika/tests/test_updates.py::UpdateTests::test_for_portion", + "pypika/tests/test_updates.py::UpdateTests::test_omit_where", + "pypika/tests/test_updates.py::UpdateTests::test_single_quote_escape_in_set", + "pypika/tests/test_updates.py::UpdateTests::test_update__table_schema", + "pypika/tests/test_updates.py::UpdateTests::test_update_from", + "pypika/tests/test_updates.py::UpdateTests::test_update_from_with_where", + "pypika/tests/test_updates.py::UpdateTests::test_update_with_join", + "pypika/tests/test_updates.py::UpdateTests::test_update_with_limit", + "pypika/tests/test_updates.py::UpdateTests::test_update_with_none", + "pypika/tests/test_updates.py::UpdateTests::test_update_with_statement", + "pypika/tests/test_updates.py::PostgresUpdateTests::test_update_returning", + "pypika/tests/test_updates.py::PostgresUpdateTests::test_update_returning_from_different_tables", + "pypika/tests/test_updates.py::PostgresUpdateTests::test_update_returning_star", + "pypika/tests/test_updates.py::PostgresUpdateTests::test_update_returning_str", + "pypika/tests/test_updates.py::SQLLiteUpdateTests::test_update_with_bool", + "pypika/tests/test_utils.py::ImmutabilityTests::test_raise_attribute_error_for_deepcopy", + "pypika/tests/test_utils.py::ImmutabilityTests::test_raise_attribute_error_for_getnewargs", + "pypika/tests/test_utils.py::ImmutabilityTests::test_raise_attribute_error_for_getstate", + "pypika/tests/test_utils.py::ImmutabilityTests::test_raise_attribute_error_for_setstate" + ], + "all_git_blobs_modes_verified": true, + "cloud_launch_ready": false, + "commits": { + "bug": "83545379f77dfce769867f8ae105f1cc43efd878", + "healthy": "6a742f12bfa386994289ec8b75824663d8ee4b15", + "learner": "3b8d73253919a1647d8e192311249f2f5a29fa55" + }, + "existing_squirrel_snapshot_reused": false, + "full_transfer_allowlist": [ + "/testbed/.coveragerc", + "/testbed/.gitignore", + "/testbed/.pre-commit-config.yaml", + "/testbed/CODEOWNERS", + "/testbed/CONTRIBUTING.rst", + "/testbed/LICENSE.txt", + "/testbed/MANIFEST.in", + "/testbed/Makefile", + "/testbed/README.rst", + "/testbed/docs/1_installation.rst", + "/testbed/docs/2_tutorial.rst", + "/testbed/docs/3_advanced.rst", + "/testbed/docs/4_extending.rst", + "/testbed/docs/5_reference.rst", + "/testbed/docs/6_contributing.rst", + "/testbed/docs/Makefile", + "/testbed/docs/api/pypika.analytics.rst", + "/testbed/docs/api/pypika.dialects.rst", + "/testbed/docs/api/pypika.enums.rst", + "/testbed/docs/api/pypika.functions.rst", + "/testbed/docs/api/pypika.pseudocolumns.rst", + "/testbed/docs/api/pypika.queries.rst", + "/testbed/docs/api/pypika.rst", + "/testbed/docs/api/pypika.terms.rst", + "/testbed/docs/api/pypika.utils.rst", + "/testbed/docs/conf.py", + "/testbed/docs/index.rst", + "/testbed/pypika/__init__.py", + "/testbed/pypika/analytics.py", + "/testbed/pypika/clickhouse/__init__.py", + "/testbed/pypika/clickhouse/array.py", + "/testbed/pypika/clickhouse/condition.py", + "/testbed/pypika/clickhouse/dates_and_times.py", + "/testbed/pypika/clickhouse/nullable_arg.py", + "/testbed/pypika/clickhouse/search_string.py", + "/testbed/pypika/clickhouse/type_conversion.py", + "/testbed/pypika/dialects.py", + "/testbed/pypika/enums.py", + "/testbed/pypika/functions.py", + "/testbed/pypika/pseudocolumns.py", + "/testbed/pypika/py.typed", + "/testbed/pypika/queries.py", + "/testbed/pypika/terms.py", + "/testbed/pypika/tests/__init__.py", + "/testbed/pypika/tests/clickhouse/__init__.py", + "/testbed/pypika/tests/clickhouse/test_array.py", + "/testbed/pypika/tests/clickhouse/test_condition.py", + "/testbed/pypika/tests/clickhouse/test_dates_and_times.py", + "/testbed/pypika/tests/clickhouse/test_type_conversion.py", + "/testbed/pypika/tests/dialects/__init__.py", + "/testbed/pypika/tests/dialects/test_clickhouse.py", + "/testbed/pypika/tests/dialects/test_mssql.py", + "/testbed/pypika/tests/dialects/test_mysql.py", + "/testbed/pypika/tests/dialects/test_oracle.py", + "/testbed/pypika/tests/dialects/test_postgresql.py", + "/testbed/pypika/tests/dialects/test_snowflake.py", + "/testbed/pypika/tests/dialects/test_sqllite.py", + "/testbed/pypika/tests/dialects/test_vertica.py", + "/testbed/pypika/tests/test_aggregate.py", + "/testbed/pypika/tests/test_analytic_queries.py", + "/testbed/pypika/tests/test_create.py", + "/testbed/pypika/tests/test_criterions.py", + "/testbed/pypika/tests/test_custom_functions.py", + "/testbed/pypika/tests/test_data_types.py", + "/testbed/pypika/tests/test_date_math.py", + "/testbed/pypika/tests/test_deletes.py", + "/testbed/pypika/tests/test_drop.py", + "/testbed/pypika/tests/test_formats.py", + "/testbed/pypika/tests/test_functions.py", + "/testbed/pypika/tests/test_groupby_modifiers.py", + "/testbed/pypika/tests/test_immutability.py", + "/testbed/pypika/tests/test_inserts.py", + "/testbed/pypika/tests/test_internals.py", + "/testbed/pypika/tests/test_joins.py", + "/testbed/pypika/tests/test_negation.py", + "/testbed/pypika/tests/test_parameter.py", + "/testbed/pypika/tests/test_pseudocolumns.py", + "/testbed/pypika/tests/test_query.py", + "/testbed/pypika/tests/test_selects.py", + "/testbed/pypika/tests/test_tables.py", + "/testbed/pypika/tests/test_terms.py", + "/testbed/pypika/tests/test_tuples.py", + "/testbed/pypika/tests/test_updates.py", + "/testbed/pypika/tests/test_utils.py", + "/testbed/pypika/utils.py", + "/testbed/pyproject.toml", + "/testbed/requirements-dev.txt", + "/testbed/setup.cfg", + "/testbed/setup.py", + "/testbed/tox.ini" + ], + "healthy_stage_meaning": "Direct parent of the mutation; no source or test execution has been performed", + "mutation_matches_dataset_and_git_blobs": true, + "official_profile": { + "eval_sets": [], + "profile_class": "Pypika1c9646f0", + "profile_lines": [ + 736, + 739 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "upstream_repo": "kayak/pypika" + }, + "original_source_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "private_test_paths": [ + "pypika/tests/clickhouse/test_nullable_arg.py", + "pypika/tests/clickhouse/test_search_string.py" + ], + "private_tests_unchanged": true, + "profile_mapping_basis": "Explicit upstream repo and full commit fields parsed from pinned official Python profile AST, not basename inference", + "qwen_calibrated": false, + "runtime_qualified": false, + "source_paths": [ + "pypika/clickhouse/nullable_arg.py", + "pypika/clickhouse/search_string.py" + ], + "source_repo": "swesmith/kayak__pypika.1c9646f0", + "source_stages_bytes": 1895143, + "task_id": "kayak__pypika.1c9646f0.combine_module__smsizxe7", + "transfer_limitation": "Existing regular files only; new arbitrary file additions need a qualified patch adapter", + "upstream_repo": "kayak/pypika" + }, + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:kayak__pypika.1c9646f0.combine_module__smsizxe7", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "6a742f12bfa386994289ec8b75824663d8ee4b15", + "instruction_sha256": "b03474f35aca7b541059df6286c82d5dfd926b2b71a6a15473ff5832ee62318b", + "is_fork": true, + "learner_path": "tasks/6da2a9ea7c1b6d1504489fe2/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "actual_upstream_url": "https://raw.githubusercontent.com/kayak/pypika/1c9646f0a019a167c32b649b6f5e6423c5ba2c9b/LICENSE.txt", + "reviewed": true, + "sha256": "c5accbbd8546e94c34aed24afe689a617627d18eed5a6c48277e48db57c23851", + "spdx": "Apache-2.0", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/kayak__pypika.1c9646f0/3b8d73253919a1647d8e192311249f2f5a29fa55/LICENSE.txt" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "patch_sha256": "bb661925f1bdeab91276c03b6898e8d652987c159fa1a6232bbe9cedf67f4e85", + "provenance_path": "tasks/6da2a9ea7c1b6d1504489fe2/source-proof.json", + "repository_lineage": [ + "swesmith/kayak__pypika.1c9646f0", + "kayak/pypika" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "3b8d73253919a1647d8e192311249f2f5a29fa55", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "83545379f77dfce769867f8ae105f1cc43efd878", + "source_kind": "mutation", + "source_repo": "swesmith/kayak__pypika.1c9646f0", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "kayak__pypika.1c9646f0.combine_module__smsizxe7", + "task_sha256": "c91fbb64d58f5b00eecf8f6cac0b210a3315010f4a1ec78e3a66493d1938cc13", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "kayak/pypika", + "usage": "quarantine_only" + }, + "task_kind": "original-source-mutation" +} diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/provenance.json b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/provenance.json new file mode 100644 index 0000000000000000000000000000000000000000..eb8bddaa34001f490e858a3c0e2268a3fad8786c --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/provenance.json @@ -0,0 +1,88 @@ +{ + "generated_reference": false, + "healthy_reference_delta_sha256": "e720ccc33a6f435f1289869b56ce79d7eba71f32121b73bc6c3090e9381ddf9f", + "native_pytest_ids_preserved": true, + "original_source_code_license": { + "actual_upstream_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "actual_upstream_url": "https://raw.githubusercontent.com/kayak/pypika/1c9646f0a019a167c32b649b6f5e6423c5ba2c9b/LICENSE.txt", + "reviewed": true, + "sha256": "c5accbbd8546e94c34aed24afe689a617627d18eed5a6c48277e48db57c23851", + "spdx": "Apache-2.0", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/kayak__pypika.1c9646f0/3b8d73253919a1647d8e192311249f2f5a29fa55/LICENSE.txt" + }, + "provided_reference": true, + "qwen_calibrated": false, + "runtime_qualified": false, + "source_completion_sha256": "d28469008a6aadedfb30084c1c6568321db9107c6276171d25bc580e370137ba", + "source_index_sha256": "e856874b9410fce9f3bfea52c8c482e84b3e43942d87517f8b55f0034bd40f6f", + "source_proof_sha256": "307b862f21fe3c4e62d1fdafd8fa762f572b015f3cf80e10a17736109dac189c", + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:kayak__pypika.1c9646f0.combine_module__smsizxe7", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "6a742f12bfa386994289ec8b75824663d8ee4b15", + "instruction_sha256": "b03474f35aca7b541059df6286c82d5dfd926b2b71a6a15473ff5832ee62318b", + "is_fork": true, + "learner_path": "tasks/6da2a9ea7c1b6d1504489fe2/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "actual_upstream_url": "https://raw.githubusercontent.com/kayak/pypika/1c9646f0a019a167c32b649b6f5e6423c5ba2c9b/LICENSE.txt", + "reviewed": true, + "sha256": "c5accbbd8546e94c34aed24afe689a617627d18eed5a6c48277e48db57c23851", + "spdx": "Apache-2.0", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/kayak__pypika.1c9646f0/3b8d73253919a1647d8e192311249f2f5a29fa55/LICENSE.txt" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "patch_sha256": "bb661925f1bdeab91276c03b6898e8d652987c159fa1a6232bbe9cedf67f4e85", + "provenance_path": "tasks/6da2a9ea7c1b6d1504489fe2/source-proof.json", + "repository_lineage": [ + "swesmith/kayak__pypika.1c9646f0", + "kayak/pypika" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "3b8d73253919a1647d8e192311249f2f5a29fa55", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "83545379f77dfce769867f8ae105f1cc43efd878", + "source_kind": "mutation", + "source_repo": "swesmith/kayak__pypika.1c9646f0", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "kayak__pypika.1c9646f0.combine_module__smsizxe7", + "task_sha256": "c91fbb64d58f5b00eecf8f6cac0b210a3315010f4a1ec78e3a66493d1938cc13", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "kayak/pypika", + "usage": "quarantine_only" + }, + "task_bundle_license": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + }, + "training_admissible": false, + "trusted_tests_sha256": "f2d0a1b335176a755d627907f32ef330383cf624ff3af2c5ea84ba2b6a2d7ebb" +} diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/provided-gold.diff b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/provided-gold.diff new file mode 100644 index 0000000000000000000000000000000000000000..d89945eb8a92c1f962c3404cfde42e022a9db248 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/provided-gold.diff @@ -0,0 +1,23 @@ +diff --git a/pypika/clickhouse/nullable_arg.py b/pypika/clickhouse/nullable_arg.py +index 14f7b0f07fc2a03b93391dd57a15b28a5b2a7bf7..a3f23fe53af3174a33b002f6965e2d1ca06d2790 100644 +--- a/pypika/clickhouse/nullable_arg.py ++++ b/pypika/clickhouse/nullable_arg.py +@@ -3,4 +3,4 @@ + + class IfNull(Function): + def __init__(self, term, alt, **kwargs): +- super().__init__("ifNull", alt, term, **kwargs) ++ super().__init__("ifNull", term, alt, **kwargs) +diff --git a/pypika/clickhouse/search_string.py b/pypika/clickhouse/search_string.py +index 8c3ed88129ccb3d2384ab2e23795d90bc92f15f2..22a03027fcaf3ca0578e63980c00f4be1b2f67e7 100644 +--- a/pypika/clickhouse/search_string.py ++++ b/pypika/clickhouse/search_string.py +@@ -79,7 +79,7 @@ + class MultiSearchAny(_AbstractMultiSearchString): + @classmethod + def clickhouse_function(cls) -> str: +- return "singleSearchAll" ++ return "multiSearchAny" + + + class MultiMatchAny(_AbstractMultiSearchString): diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/solution/solve.sh b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..df22a3127c3dcfe3a1422e9adbc66ffbe4e3d499 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/solution/solve.sh @@ -0,0 +1,29 @@ +#!/bin/bash +set -Eeuo pipefail +cd /testbed/repo +cat > /tmp/openenv-reference.diff <<'OPENENV_REFERENCE' +diff --git a/pypika/clickhouse/nullable_arg.py b/pypika/clickhouse/nullable_arg.py +index 14f7b0f07fc2a03b93391dd57a15b28a5b2a7bf7..a3f23fe53af3174a33b002f6965e2d1ca06d2790 100644 +--- a/pypika/clickhouse/nullable_arg.py ++++ b/pypika/clickhouse/nullable_arg.py +@@ -3,4 +3,4 @@ + + class IfNull(Function): + def __init__(self, term, alt, **kwargs): +- super().__init__("ifNull", alt, term, **kwargs) ++ super().__init__("ifNull", term, alt, **kwargs) +diff --git a/pypika/clickhouse/search_string.py b/pypika/clickhouse/search_string.py +index 8c3ed88129ccb3d2384ab2e23795d90bc92f15f2..22a03027fcaf3ca0578e63980c00f4be1b2f67e7 100644 +--- a/pypika/clickhouse/search_string.py ++++ b/pypika/clickhouse/search_string.py +@@ -79,7 +79,7 @@ + class MultiSearchAny(_AbstractMultiSearchString): + @classmethod + def clickhouse_function(cls) -> str: +- return "singleSearchAll" ++ return "multiSearchAny" + + + class MultiMatchAny(_AbstractMultiSearchString): +OPENENV_REFERENCE +/usr/bin/git -c core.hooksPath=/dev/null -c core.fsmonitor=false apply --whitespace=nowarn /tmp/openenv-reference.diff diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/task.toml b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..638aa0bbf97d2b059bd4761c664fceaaddd89d12 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/task.toml @@ -0,0 +1,24 @@ +version = "1.0" + +[agent] +timeout_sec = 1800.0 + +[verifier] +timeout_sec = 900.0 + +[environment] +docker_image = "ghcr.io/younesbelkada/scale800@sha256:ad01e30499c06570f3a172221ff000bc4cdfe96a24b7b7bcef6faf9bd6cbec30" +build_timeout_sec = 600.0 +cpus = 2 +memory_mb = 8192 +storage_mb = 16384 + +[metadata] +author_name = "SWE-smith source adapter" +category = "bugfix" +tags = ["swe", "python", "mutation-repair"] + +[environment.env] +# The image's PATH with the testbed env first: the project and pytest are installed there, and the agent's +# non-interactive shells never run `conda activate` +PATH = "/opt/miniconda3/envs/testbed/bin:/opt/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/check_pytest.py b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/check_pytest.py new file mode 100644 index 0000000000000000000000000000000000000000..7abfdc5972f57ca7f0cecbbeeb373414670f780e --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/check_pytest.py @@ -0,0 +1,177 @@ +"""Preserve confirmed requested assertion failures; keep positive checks strict.""" + +import argparse +import hashlib +import json +import re +import xml.etree.ElementTree as ET +from pathlib import Path + +GROUPS = ("pass-to-pass", "fail-to-pass") + + +def split_nodeid(target): + prefix, bracket, parameter = target.partition("[") + parts = prefix.split("::") + if bracket: + parts[-1] += bracket + parameter + return parts + + +def matches(case, target): + parts = split_nodeid(target) + module = parts[0].removesuffix(".py").replace("/", ".") + classname, name = case.get("classname", ""), case.get("name", "") + if not (classname == module or classname.startswith(module + ".")): + return False + selector = parts[-1] if len(parts) > 1 else "" + classes = parts[1:-1] + if classes and classname != module + "." + ".".join(classes): + return False + return ( + not selector + or name == selector + or ("[" not in selector and name.startswith(selector + "[")) + ) + + +def capture_panels(root): + panels, digests = {}, {} + for group in GROUPS: + path = Path(root) / (group + ".xml") + if not path.exists(): + panels[group] = None + continue + with path.open("rb") as stream: + raw = stream.read(4 * 1024**2 + 1) + if not 0 < len(raw) <= 4 * 1024**2 or re.search( + rb" 20000: + raise ValueError("Too many pytest cases") + identities = [(case.get("classname"), case.get("name")) for case in cases] + if len(identities) != len(set(identities)): + raise ValueError("Duplicate pytest case evidence") + panels[group] = cases + digests[group] = hashlib.sha256(raw).hexdigest() + return panels, digests + + +def strict_assess(panels, expected, native_exit): + """The original positive-approval conditions, applied to captured cases.""" + all_cases, actual_failure = [], False + for group in GROUPS: + cases = panels[group] + if cases is None: + if actual_failure: + continue + raise ValueError("Missing preceding pytest panel") + if actual_failure: + raise ValueError( + "Pytest evidence continued after the native stop-on-failure" + ) + targets = expected[group] + if any(not any(matches(case, target) for target in targets) for case in cases): + raise ValueError("Unexpected pytest case") + all_cases.extend(cases) + failures = [case for case in cases if case.find("failure") is not None] + if any( + case.find("error") is not None or case.find("skipped") is not None + for case in cases + ): + raise ValueError("Pytest collection/error/skip is not a completed panel") + actual_failure = actual_failure or bool(failures) + if not failures and any( + not any(matches(case, target) for case in cases) for target in targets + ): + raise ValueError("Declared pytest target never ran") + if actual_failure: + if native_exit == 0: + raise ValueError("Native verifier exit disagrees with pytest failure") + return {"reward": 0, "valid_test_failure": True, "cases": len(all_cases)} + if native_exit != 0: + raise ValueError("Setup or native verifier failed without a real test failure") + if any(panels[group] is None for group in GROUPS): + raise ValueError("Missing completed pytest panel") + return {"reward": 1, "valid_test_failure": False, "cases": len(all_cases)} + + +def assess(root, expected, native_exit): + if type(native_exit) is not int: + raise ValueError("Native verifier exit must be an integer") + if not isinstance(expected, dict) or any( + not isinstance(expected.get(group), list) + or not expected[group] + or any(not isinstance(target, str) or not target for target in expected[group]) + for group in GROUPS + ): + raise ValueError("Complete exact native pytest targets required") + panels, digests = capture_panels(root) + counts = { + "cases": 0, + "matched_failures": 0, + "unexpected_cases": 0, + "unmatched_failures": 0, + "skipped_cases": 0, + "error_cases": 0, + "missing_panels": 0, + "missing_targets": 0, + } + for group in GROUPS: + cases = panels[group] + if cases is None: + counts["missing_panels"] += 1 + counts["missing_targets"] += len(expected[group]) + continue + counts["cases"] += len(cases) + for case in cases: + requested = any(matches(case, target) for target in expected[group]) + failure = case.find("failure") is not None + counts["matched_failures"] += int(requested and failure) + counts["unmatched_failures"] += int(not requested and failure) + counts["unexpected_cases"] += int(not requested) + counts["skipped_cases"] += int(case.find("skipped") is not None) + counts["error_cases"] += int(case.find("error") is not None) + counts["missing_targets"] += sum( + not any(matches(case, target) for case in cases) + for target in expected[group] + ) + if counts["matched_failures"]: + if native_exit == 0: + raise ValueError( + "Native verifier exit disagrees with requested pytest failure" + ) + return { + "reward": 0, + "valid_test_failure": True, + "cases": counts["cases"], + "diagnostic_counts": counts, + "panel_sha256": digests, + "decision": "confirmed_requested_failure_precedence", + } + result = strict_assess(panels, expected, native_exit) + result.update(diagnostic_counts=counts, panel_sha256=digests) + return result + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("--root", required=True) + parser.add_argument("--expected", required=True) + parser.add_argument("--native-exit", type=int, required=True) + args = parser.parse_args() + result = assess( + args.root, json.loads(Path(args.expected).read_bytes()), args.native_exit + ) + reward = Path(args.root) / "reward.txt" + if reward.read_text().strip() != str(result["reward"]): + raise ValueError("Native raw reward disagrees with pytest evidence") + (Path(args.root) / "pytest-evidence.json").write_text( + json.dumps(result, sort_keys=True) + "\n" + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/expected-panels.json b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/expected-panels.json new file mode 100644 index 0000000000000000000000000000000000000000..1ba6a010530d54a7cc844d22c0d80c39b35cd872 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/expected-panels.json @@ -0,0 +1,1067 @@ +{ + "fail-to-pass": [ + "pypika/tests/clickhouse/test_nullable_arg.py::TestSearchString::test_get_sql_0", + "pypika/tests/clickhouse/test_nullable_arg.py::TestSearchString::test_get_sql_1", + "pypika/tests/clickhouse/test_search_string.py::TestMultiSearch::test_multi_search_string_0" + ], + "pass-to-pass": [ + "pypika/tests/clickhouse/test_array.py::TestArray::test_get_sql_0__ridley_scott_jimi_hendrix_", + "pypika/tests/clickhouse/test_array.py::TestArray::test_get_sql_1__1_2_3_4_", + "pypika/tests/clickhouse/test_array.py::TestArray::test_get_sql_2__toInt64_1_toInt64_2_toInt64_3_toInt64_4_", + "pypika/tests/clickhouse/test_array.py::TestArray::test_get_sql_3__toFixedString_mogwai_10_toFixedString_mono_10_toFixedString_bonobo_10_arr", + "pypika/tests/clickhouse/test_array.py::TestHasAny::test_get_sql_0_hasAny_mental_abilities_physical_abilities_", + "pypika/tests/clickhouse/test_array.py::TestHasAny::test_get_sql_1_hasAny_1_2_3_4_3_", + "pypika/tests/clickhouse/test_array.py::TestHasAny::test_get_sql_2_hasAny_bands_toFixedString_port_royal_20_toFixedString_hammock_20_", + "pypika/tests/clickhouse/test_array.py::TestLength::test_get_sql_0_length_tags_", + "pypika/tests/clickhouse/test_array.py::TestLength::test_get_sql_1_length_1_2_3_", + "pypika/tests/clickhouse/test_array.py::TestEmpty::test_get_sql_0_empty_tags_", + "pypika/tests/clickhouse/test_array.py::TestEmpty::test_get_sql_1_empty_1_2_3_", + "pypika/tests/clickhouse/test_array.py::TestNotEmpty::test_get_sql_0_notEmpty_tags_", + "pypika/tests/clickhouse/test_array.py::TestNotEmpty::test_get_sql_1_notEmpty_1_2_3_", + "pypika/tests/clickhouse/test_condition.py::TestIfCondition::test_get_sql_0", + "pypika/tests/clickhouse/test_condition.py::TestIfCondition::test_get_sql_1", + "pypika/tests/clickhouse/test_condition.py::TestMultiIfCondition::test_get_sql_0", + "pypika/tests/clickhouse/test_condition.py::TestMultiIfCondition::test_get_sql_1", + "pypika/tests/clickhouse/test_dates_and_times.py::TestFormatDateTime::test_get_sql_0", + "pypika/tests/clickhouse/test_dates_and_times.py::TestFormatDateTime::test_get_sql_1", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_00", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_01", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_02", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_03", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_04", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_05", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_06", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_07", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_08", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_09", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_10", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_11", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_12", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_13", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_14", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_15", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_16", + "pypika/tests/clickhouse/test_dates_and_times.py::TestToYYYYMM::test_get_sql", + "pypika/tests/clickhouse/test_search_string.py::TestSearchString::test_search_string_0", + "pypika/tests/clickhouse/test_search_string.py::TestSearchString::test_search_string_1", + "pypika/tests/clickhouse/test_search_string.py::TestSearchString::test_search_string_2", + "pypika/tests/clickhouse/test_search_string.py::TestMultiSearch::test_multi_search_string_1", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_00_toString_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_01_toInt8_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_02_toInt16_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_03_toInt32_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_04_toInt64_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_05_toUInt8_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_06_toUInt16_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_07_toUInt32_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_08_toUInt64_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_09_toFloat32_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_10_toFloat64_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_11_toFloat64_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_12_toDate_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_13_toDateTime_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_14_toFixedString_field_name_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_00_toString_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_01_toInt8_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_02_toInt16_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_03_toInt32_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_04_toInt64_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_05_toUInt8_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_06_toUInt16_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_07_toUInt32_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_08_toUInt64_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_09_toFloat32_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_10_toFloat64_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_11_toFloat64_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_12_toDate_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_13_toDateTime_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_14_toFixedString_100_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestToFixedString::test_get_sql_with_table", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseQueryTests::test_use_AS_keyword_for_alias", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseQueryTests::test_use_FINAL_keyword", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseQueryTests::test_use_SAMPLE_keyword", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseQueryTests::test_use_SAMPLE_with_offset_keyword", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDeleteTests::test_omit_where", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDeleteTests::test_omit_where__table_schema", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDeleteTests::test_where_field_equals", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseUpdateTests::test_update", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDropQuery::test_drop_database", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDropQuery::test_drop_dictionary", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDropQuery::test_drop_other", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDropQuery::test_drop_table", + "pypika/tests/dialects/test_clickhouse.py::DistinctOnTests::test_distinct_on", + "pypika/tests/dialects/test_clickhouse.py::LimitByTests::test_limit_by", + "pypika/tests/dialects/test_clickhouse.py::LimitByTests::test_limit_offset0_by", + "pypika/tests/dialects/test_clickhouse.py::LimitByTests::test_limit_offset_by", + "pypika/tests/dialects/test_clickhouse.py::LimitByTests::test_rename_table", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_distinct_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_groupby_alias_False_does_not_group_by_alias_when_subqueries_are_present", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_groupby_alias_False_does_not_group_by_alias_with_standard_query", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_limit", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_limit_with_offset", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_normal_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_offset", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_distinct_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_percent_invalid_range", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_percent_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_select_non_int", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_with_ties_select", + "pypika/tests/dialects/test_mysql.py::SelectTests::test_distinct_select", + "pypika/tests/dialects/test_mysql.py::SelectTests::test_modifier_select", + "pypika/tests/dialects/test_mysql.py::SelectTests::test_multiple_modifier_select", + "pypika/tests/dialects/test_mysql.py::SelectTests::test_normal_select", + "pypika/tests/dialects/test_mysql.py::UpdateTests::test_conflict_handlers_update", + "pypika/tests/dialects/test_mysql.py::UpdateTests::test_on_duplicate_key_ignore_update", + "pypika/tests/dialects/test_mysql.py::UpdateTests::test_on_duplicate_key_update_update", + "pypika/tests/dialects/test_mysql.py::UpdateTests::test_update", + "pypika/tests/dialects/test_mysql.py::LoadCSVTests::test_load_from_file", + "pypika/tests/dialects/test_mysql.py::TableTests::test_create_table", + "pypika/tests/dialects/test_mysql.py::TableTests::test_drop_table", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_fetch_next_method_deprecated", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_groupby_alias_False_does_not_group_by_alias_when_subqueries_are_present", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_groupby_alias_False_does_not_group_by_alias_with_standard_query", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_limit_offset_query", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_limit_query", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_offset_query", + "pypika/tests/dialects/test_postgresql.py::InsertTests::test_array_keyword", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_alias_set_correctly", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_json_value_from_array_num", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_json_value_from_array_str", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_json_value_from_dict", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_json_value_from_dict_recursive", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_json_value_by_index", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_json_value_by_key", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_path_json_value", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_path_text_value", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_text_value_by_index", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_text_value_by_key", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contained_by_using_list_arg", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contained_by_using_str_arg", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contained_by_with_complex_criterion", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contains_for_field", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contains_for_json", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_has_any_keys", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_has_key", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_has_keys", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_subnet_contains_inet", + "pypika/tests/dialects/test_postgresql.py::DistinctOnTests::test_distinct_on", + "pypika/tests/dialects/test_postgresql.py::ArrayTests::test_array_syntax", + "pypika/tests/dialects/test_postgresql.py::ArrayTests::test_render_alias_in_array_sql", + "pypika/tests/dialects/test_postgresql.py::ReturningClauseTests::test_no_queryexception_if_returning_used_on_valid_query_type", + "pypika/tests/dialects/test_postgresql.py::ReturningClauseTests::test_queryexception_if_returning_used_on_invalid_query", + "pypika/tests/dialects/test_postgresql.py::ReturningClauseTests::test_return_field_from_join_table", + "pypika/tests/dialects/test_postgresql.py::ReturningClauseTests::test_returning_from_missing_table_raises_queryexception", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_dont_use_double_quotes_on_create_queries", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_dont_use_double_quotes_on_drop_queries", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_dont_use_double_quotes_on_joining_queries", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_use_double_quotes_on_alias_but_not_on_terms", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_use_double_quotes_on_alias_but_not_on_terms_with_joins", + "pypika/tests/dialects/test_sqllite.py::SelectTests::test_bool_false_as_zero", + "pypika/tests/dialects/test_sqllite.py::SelectTests::test_bool_true_as_one", + "pypika/tests/dialects/test_sqllite.py::ReplaceTests::test_insert_or_replace", + "pypika/tests/dialects/test_sqllite.py::ReplaceTests::test_normal_replace", + "pypika/tests/dialects/test_sqllite.py::ReplaceTests::test_replace_subquery", + "pypika/tests/dialects/test_vertica.py::VerticaQueryTests::test_delete_query_with_hint", + "pypika/tests/dialects/test_vertica.py::VerticaQueryTests::test_insert_query_with_hint", + "pypika/tests/dialects/test_vertica.py::VerticaQueryTests::test_select_query_with_hint", + "pypika/tests/dialects/test_vertica.py::VerticaQueryTests::test_update_query_with_hint", + "pypika/tests/dialects/test_vertica.py::CopyCSVTests::test_copy_from_file", + "pypika/tests/dialects/test_vertica.py::CreateTemporaryTableTests::test_create_local_table_without_temporary_raises_error", + "pypika/tests/dialects/test_vertica.py::CreateTemporaryTableTests::test_create_local_temporary_table", + "pypika/tests/dialects/test_vertica.py::CreateTemporaryTableTests::test_create_table_preserve_rows_without_temporary_raises_error", + "pypika/tests/dialects/test_vertica.py::CreateTemporaryTableTests::test_create_temporary_table_preserve_rows", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__agg_case_criterion_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__agg_case_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__agg_func_arithmetic_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__agg_func_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__case_mixed_constant_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__case_mixed_else_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__case_with_field_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__case_with_single_aggregate_field_in_one_criterion_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__constant_arithmetic_is_aggregate_none", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__constant_is_aggregate_none", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__field_arithmetic_constant_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__field_arithmetic_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__field_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__func_arithmetic_constant_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__mixed_case_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__mixed_func_arithmetic_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__negative_agg_func_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__non_aggregate_function_with_aggregated_arg", + "pypika/tests/test_aggregate.py::IsAggregateTests::test_complicated", + "pypika/tests/test_analytic_queries.py::RankTests::test_avg", + "pypika/tests/test_analytic_queries.py::RankTests::test_count_range_between_unbounded_preceeding_current_row", + "pypika/tests/test_analytic_queries.py::RankTests::test_dense_rank", + "pypika/tests/test_analytic_queries.py::RankTests::test_empty_over", + "pypika/tests/test_analytic_queries.py::RankTests::test_filter", + "pypika/tests/test_analytic_queries.py::RankTests::test_filter_quote_table_in_filter", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value_ignore_nulls", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value_ignore_nulls_first", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value_multi_argument", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value_range_between_x_preceeding_unbounded_following", + "pypika/tests/test_analytic_queries.py::RankTests::test_lag_generates_correct_sql", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value_ignore_nulls", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value_multi_argument", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value_rows_between_current_row_unbounded_following", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value_rows_between_current_row_unbounded_following_ignore_nulls", + "pypika/tests/test_analytic_queries.py::RankTests::test_lead_generates_correct_sql", + "pypika/tests/test_analytic_queries.py::RankTests::test_max_range_x_preceeding", + "pypika/tests/test_analytic_queries.py::RankTests::test_max_rows_x_preceeding", + "pypika/tests/test_analytic_queries.py::RankTests::test_median", + "pypika/tests/test_analytic_queries.py::RankTests::test_min_range_current_row", + "pypika/tests/test_analytic_queries.py::RankTests::test_min_rows_current_row", + "pypika/tests/test_analytic_queries.py::RankTests::test_multiple_partitions", + "pypika/tests/test_analytic_queries.py::RankTests::test_ntile_no_partition_or_order_invalid_sql", + "pypika/tests/test_analytic_queries.py::RankTests::test_ntile_with_order", + "pypika/tests/test_analytic_queries.py::RankTests::test_ntile_with_partition", + "pypika/tests/test_analytic_queries.py::RankTests::test_ntile_with_partition_and_order", + "pypika/tests/test_analytic_queries.py::RankTests::test_orderby_asc", + "pypika/tests/test_analytic_queries.py::RankTests::test_orderby_desc", + "pypika/tests/test_analytic_queries.py::RankTests::test_range_called_twice_raises_attribute_error", + "pypika/tests/test_analytic_queries.py::RankTests::test_range_then_rows_raises_attribute_error", + "pypika/tests/test_analytic_queries.py::RankTests::test_rank", + "pypika/tests/test_analytic_queries.py::RankTests::test_rank_with_alias", + "pypika/tests/test_analytic_queries.py::RankTests::test_row_number", + "pypika/tests/test_analytic_queries.py::RankTests::test_rows_called_twice_raises_attribute_error", + "pypika/tests/test_analytic_queries.py::RankTests::test_rows_then_range_raises_attribute_error", + "pypika/tests/test_analytic_queries.py::RankTests::test_stddev", + "pypika/tests/test_analytic_queries.py::RankTests::test_stddev_pop", + "pypika/tests/test_analytic_queries.py::RankTests::test_stddev_samp", + "pypika/tests/test_analytic_queries.py::RankTests::test_sum_rows_unbounded_preceeding", + "pypika/tests/test_analytic_queries.py::RankTests::test_table_prefixes_used_in_analytic_functions", + "pypika/tests/test_analytic_queries.py::RankTests::test_var_pop", + "pypika/tests/test_analytic_queries.py::RankTests::test_var_samp", + "pypika/tests/test_analytic_queries.py::RankTests::test_variance", + "pypika/tests/test_analytic_queries.py::RankTests::test_variance_rows_between_unbounded_preceeding_unbounded_following", + "pypika/tests/test_analytic_queries.py::RankTests::test_varpop_range_unbounded_preceeding", + "pypika/tests/test_analytic_queries.py::RankTests::test_varpop_rows_between_unbounded_preceeding_x_following", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_as_select_not_query_raises_error", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_with_columns", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_with_select", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_with_select_and_columns_fails", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_without_columns_or_select_empty", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_if_not_exists", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_simple", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_unique", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_where", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_without_columns_raises_error", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_without_table_raises_error", + "pypika/tests/test_criterions.py::CriterionTests::test__bitwise_and_in_where_clause", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_bitwise_and", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_bitwise_and_with_alias", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_bool", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_decimal", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_str", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gt_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gt_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gt_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gt_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gte_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gte_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gte_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gte_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_is_null", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_is_null_with_alias", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lt_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lt_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lt_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lt_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lte_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lte_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lte_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lte_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_str", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_with_alias", + "pypika/tests/test_criterions.py::NotTests::test_chained_function", + "pypika/tests/test_criterions.py::NotTests::test_is_not_null", + "pypika/tests/test_criterions.py::NotTests::test_negate", + "pypika/tests/test_criterions.py::NotTests::test_not_null", + "pypika/tests/test_criterions.py::NotTests::test_not_null_with_alias", + "pypika/tests/test_criterions.py::NotTests::test_not_with_and_criterion", + "pypika/tests/test_criterions.py::NotTests::test_not_with_complex_criterion", + "pypika/tests/test_criterions.py::NotTests::test_not_with_or_criterion", + "pypika/tests/test_criterions.py::NotTests::test_notnullcriterion_replace_table", + "pypika/tests/test_criterions.py::NotTests::test_variable_access", + "pypika/tests/test_criterions.py::BetweenTests::test__between_date", + "pypika/tests/test_criterions.py::BetweenTests::test__between_datetime", + "pypika/tests/test_criterions.py::BetweenTests::test__between_number", + "pypika/tests/test_criterions.py::BetweenTests::test__between_with_alias", + "pypika/tests/test_criterions.py::BetweenTests::test__function_between", + "pypika/tests/test_criterions.py::BetweenTests::test_get_item_only_works_with_slice", + "pypika/tests/test_criterions.py::IsInTests::test__function_isin", + "pypika/tests/test_criterions.py::IsInTests::test__in_character", + "pypika/tests/test_criterions.py::IsInTests::test__in_date", + "pypika/tests/test_criterions.py::IsInTests::test__in_datetime", + "pypika/tests/test_criterions.py::IsInTests::test__in_number", + "pypika/tests/test_criterions.py::IsInTests::test__in_number_with_alias", + "pypika/tests/test_criterions.py::IsInTests::test__in_unicode", + "pypika/tests/test_criterions.py::ArithmeticExpressionTests::test__lshift", + "pypika/tests/test_criterions.py::ArithmeticExpressionTests::test__rshift", + "pypika/tests/test_criterions.py::NotInTests::test__function_notin", + "pypika/tests/test_criterions.py::NotInTests::test__notin_character", + "pypika/tests/test_criterions.py::NotInTests::test__notin_date", + "pypika/tests/test_criterions.py::NotInTests::test__notin_datetime", + "pypika/tests/test_criterions.py::NotInTests::test__notin_number", + "pypika/tests/test_criterions.py::NotInTests::test__notin_number_with_alias", + "pypika/tests/test_criterions.py::LikeTests::test_glob_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_contains", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_ends_with", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_n_chars_long", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_starts_with", + "pypika/tests/test_criterions.py::LikeTests::test_like_contains", + "pypika/tests/test_criterions.py::LikeTests::test_like_ends_with", + "pypika/tests/test_criterions.py::LikeTests::test_like_n_chars_long", + "pypika/tests/test_criterions.py::LikeTests::test_like_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_like_starts_with", + "pypika/tests/test_criterions.py::LikeTests::test_not_ilike_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_not_like_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_rlike_escape_chars", + "pypika/tests/test_criterions.py::ExistsCriterionTests::test_exists", + "pypika/tests/test_criterions.py::ExistsCriterionTests::test_not_exists", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__between_and_field", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__between_and_isin", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__nested__and", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__nested__mixed", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__nested__or", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_and", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_function_and", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_function_or", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_function_xor", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_or", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_xor", + "pypika/tests/test_criterions.py::FieldsAsCriterionTests::test__field_and_field", + "pypika/tests/test_criterions.py::FieldsAsCriterionTests::test__field_or_field", + "pypika/tests/test_criterions.py::FieldsAsCriterionTests::test__field_xor_field", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_arithmeticfunction_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_betweencriterion_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_complexcriterion_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_criterion_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_field_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_function_with_only_fields_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_function_with_values_and_fields_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_nullcriterion_replace_table", + "pypika/tests/test_criterions.py::AnyTests::test_multiple_args_returned_in_chain_of_ors", + "pypika/tests/test_criterions.py::AnyTests::test_single_arg_returns_self", + "pypika/tests/test_criterions.py::AnyTests::test_with_generator", + "pypika/tests/test_criterions.py::AnyTests::test_zero_args_returns_empty_criterion", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_different_operations_with_empty_criterion", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_empty_criterion_on_the_left", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_empty_criterion_on_the_right", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_fields_", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_invertion_of_the_empty_criterion", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_more_than_one_empty_criterions", + "pypika/tests/test_criterions.py::AllTests::test_multiple_args_returned_in_chain_of_ors", + "pypika/tests/test_criterions.py::AllTests::test_single_arg_returns_self", + "pypika/tests/test_criterions.py::AllTests::test_with_generator", + "pypika/tests/test_criterions.py::AllTests::test_zero_args_returns_empty_criterion", + "pypika/tests/test_custom_functions.py::TestUnitCustomFunction::test_should_fail_with_wrong_arguments", + "pypika/tests/test_custom_functions.py::TestUnitCustomFunction::test_should_return_function_with_arguments", + "pypika/tests/test_custom_functions.py::TestUnitCustomFunction::test_should_return_function_with_no_arguments", + "pypika/tests/test_custom_functions.py::TestFunctionalCustomFunction::test_should_fail_use_custom_function_on_select_with_wrong_arguments", + "pypika/tests/test_custom_functions.py::TestFunctionalCustomFunction::test_should_use_custom_function_on_select", + "pypika/tests/test_data_types.py::StringTests::test_inline_string_concatentation", + "pypika/tests/test_data_types.py::UuidTests::test_uuid_string_generation", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_day", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_default", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_microsecond", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_minute", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_month", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_quarter", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_second", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_week", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_year", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_day_hour", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_day_microsecond", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_day_minute", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_day_second", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_hour_microsecond", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_hour_minute", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_hour_second", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_minute_microsecond", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_minute_second", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_second_microsecond", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_value_complex_expressions", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_value_right", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_year_month", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_mysql_dialect_uses_single_quotes_around_expression_in_an_interval", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_oracle_dialect_uses_single_quotes_around_expression_in_an_interval", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_postgresql_dialect_uses_single_quotes_around_interval", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_redshift_dialect_uses_single_quotes_around_interval", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_vertica_dialect_uses_single_quotes_around_interval", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_day", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_month", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_week", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_year", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_year_month", + "pypika/tests/test_date_math.py::TruncateTrailingZerosTests::test_do_not_truncate_integer_values", + "pypika/tests/test_date_math.py::TruncateTrailingZerosTests::test_do_not_truncate_months_between_years_and_datys", + "pypika/tests/test_deletes.py::DeleteTests::test_for_portion", + "pypika/tests/test_deletes.py::DeleteTests::test_omit_where", + "pypika/tests/test_deletes.py::DeleteTests::test_omit_where__table_schema", + "pypika/tests/test_deletes.py::DeleteTests::test_where_field_equals", + "pypika/tests/test_deletes.py::PostgresDeleteTests::test_delete_returning", + "pypika/tests/test_deletes.py::PostgresDeleteTests::test_delete_returning_star", + "pypika/tests/test_deletes.py::PostgresDeleteTests::test_delete_returning_str", + "pypika/tests/test_deletes.py::PostgresDeleteTests::test_delete_using", + "pypika/tests/test_drop.py::DropTableTests::test_drop_database", + "pypika/tests/test_drop.py::DropTableTests::test_drop_index", + "pypika/tests/test_drop.py::DropTableTests::test_drop_table", + "pypika/tests/test_drop.py::DropTableTests::test_drop_user", + "pypika/tests/test_drop.py::DropTableTests::test_drop_view", + "pypika/tests/test_formats.py::QuoteTests::test_no_quote_char_in_complex_query", + "pypika/tests/test_formats.py::QuoteTests::test_replace_quote_char_in_complex_query", + "pypika/tests/test_functions.py::FunctionTests::test_dialect_propagation", + "pypika/tests/test_functions.py::FunctionTests::test_is_aggregate_None_for_non_aggregate_function_or_function_with_no_aggregate_functions", + "pypika/tests/test_functions.py::FunctionTests::test_is_aggregate_True_for_aggregate_function_or_function_with_aggregate_functions", + "pypika/tests/test_functions.py::SchemaTests::test_schema_included_in_function_sql", + "pypika/tests/test_functions.py::SchemaTests::test_schema_no_schema_in_sql_when_none_set", + "pypika/tests/test_functions.py::ArithmeticTests::test__addition__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__addition__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__addition__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__addition__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__arithmetic_equality", + "pypika/tests/test_functions.py::ArithmeticTests::test__arithmetic_with_function", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_add_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_div_no_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_div_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_exponent_no_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_exponent_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_floor_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_function_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_modulus_no_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_modulus_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_mul_no_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_mul_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_nested_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_sub_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__division__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__division__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__division__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__division__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__exponent__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__exponent__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__floor", + "pypika/tests/test_functions.py::ArithmeticTests::test__leftshift__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__leftshift__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__leftshift__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__modulus__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__multiplication__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__multiplication__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__multiplication__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__multiplication__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__rightshift__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__rightshift__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__rightshift__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__subtraction__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__subtraction__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__subtraction__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__subtraction__right", + "pypika/tests/test_functions.py::AggregationTests::test__approx_percentile", + "pypika/tests/test_functions.py::AggregationTests::test__avg", + "pypika/tests/test_functions.py::AggregationTests::test__count", + "pypika/tests/test_functions.py::AggregationTests::test__count__star", + "pypika/tests/test_functions.py::AggregationTests::test__first", + "pypika/tests/test_functions.py::AggregationTests::test__last", + "pypika/tests/test_functions.py::AggregationTests::test__max", + "pypika/tests/test_functions.py::AggregationTests::test__min", + "pypika/tests/test_functions.py::AggregationTests::test__std", + "pypika/tests/test_functions.py::AggregationTests::test__stddev", + "pypika/tests/test_functions.py::AggregationTests::test__subquery_in_params_functions", + "pypika/tests/test_functions.py::AggregationTests::test__sum", + "pypika/tests/test_functions.py::ConditionTests::test__case__else", + "pypika/tests/test_functions.py::ConditionTests::test__case__field", + "pypika/tests/test_functions.py::ConditionTests::test__case__multi", + "pypika/tests/test_functions.py::ConditionTests::test__case__no_cases", + "pypika/tests/test_functions.py::ConditionTests::test__case__raw", + "pypika/tests/test_functions.py::StringTests::test__ascii__field", + "pypika/tests/test_functions.py::StringTests::test__ascii__int", + "pypika/tests/test_functions.py::StringTests::test__ascii__str", + "pypika/tests/test_functions.py::StringTests::test__bin__field", + "pypika/tests/test_functions.py::StringTests::test__bin__int", + "pypika/tests/test_functions.py::StringTests::test__bin__str", + "pypika/tests/test_functions.py::StringTests::test__concat__field", + "pypika/tests/test_functions.py::StringTests::test__concat__str", + "pypika/tests/test_functions.py::StringTests::test__insert__field", + "pypika/tests/test_functions.py::StringTests::test__insert__str", + "pypika/tests/test_functions.py::StringTests::test__length__field", + "pypika/tests/test_functions.py::StringTests::test__length__str", + "pypika/tests/test_functions.py::StringTests::test__lower__field", + "pypika/tests/test_functions.py::StringTests::test__lower__str", + "pypika/tests/test_functions.py::StringTests::test__replace__field", + "pypika/tests/test_functions.py::StringTests::test__replace__str", + "pypika/tests/test_functions.py::StringTests::test__substring", + "pypika/tests/test_functions.py::SplitPartFunctionTests::test__split_part", + "pypika/tests/test_functions.py::RegexpLikeFunctionTests::test__regexp_like", + "pypika/tests/test_functions.py::CastTests::test__cast__as", + "pypika/tests/test_functions.py::CastTests::test__cast__binary", + "pypika/tests/test_functions.py::CastTests::test__cast__binary_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__boolean", + "pypika/tests/test_functions.py::CastTests::test__cast__char", + "pypika/tests/test_functions.py::CastTests::test__cast__char_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__date", + "pypika/tests/test_functions.py::CastTests::test__cast__float", + "pypika/tests/test_functions.py::CastTests::test__cast__integer", + "pypika/tests/test_functions.py::CastTests::test__cast__long_varbinary", + "pypika/tests/test_functions.py::CastTests::test__cast__long_varbinary_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__long_varchar", + "pypika/tests/test_functions.py::CastTests::test__cast__long_varchar_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__numeric", + "pypika/tests/test_functions.py::CastTests::test__cast__signed", + "pypika/tests/test_functions.py::CastTests::test__cast__timestamp", + "pypika/tests/test_functions.py::CastTests::test__cast__unsigned", + "pypika/tests/test_functions.py::CastTests::test__cast__varbinary", + "pypika/tests/test_functions.py::CastTests::test__cast__varbinary_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__varchar", + "pypika/tests/test_functions.py::CastTests::test__cast__varchar_with_arg", + "pypika/tests/test_functions.py::CastTests::test__tochar__", + "pypika/tests/test_functions.py::DateFunctionsTests::test_current_date", + "pypika/tests/test_functions.py::DateFunctionsTests::test_current_time", + "pypika/tests/test_functions.py::DateFunctionsTests::test_current_timestamp", + "pypika/tests/test_functions.py::DateFunctionsTests::test_current_timestamp_with_alias", + "pypika/tests/test_functions.py::DateFunctionsTests::test_date_add", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_day", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_hour", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_join", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_microsecond", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_minute", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_month", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_quarter", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_second", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_week", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_year", + "pypika/tests/test_functions.py::DateFunctionsTests::test_now", + "pypika/tests/test_functions.py::DateFunctionsTests::test_time_diff", + "pypika/tests/test_functions.py::DateFunctionsTests::test_timestampadd", + "pypika/tests/test_functions.py::DateFunctionsTests::test_to_date", + "pypika/tests/test_functions.py::DateFunctionsTests::test_utc_timestamp", + "pypika/tests/test_functions.py::NullFunctionsTests::test_coalesce", + "pypika/tests/test_functions.py::NullFunctionsTests::test_isnull", + "pypika/tests/test_functions.py::NullFunctionsTests::test_nullif", + "pypika/tests/test_functions.py::NullFunctionsTests::test_nvl", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_mysql_one_groupby", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_mysql_rollup_two_groupbys", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_no_rollup_after_rollup_mysql", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_no_rollup_before_groupby", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_from_groupbys", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_from_parameters", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_from_two_groupbys", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_func_one_groupby", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_func_partial", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_func_two_groupbys", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_multiple_rollups", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_rollups_with_multiple_rollups_and_parity", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_rollups_with_parity", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_force_index_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_groupby_returns_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_immutable_kwarg_on_query_builder_disables_immutability", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_insert_into_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_join_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_orderby_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_queries_after_join", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_replace_into_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_select_returns_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_update_set_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_use_index_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_with_return_new_query_instance", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_multi_rows", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_multi_rows_chained", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_multi_rows_chained_mixed", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_multi_rows_chained_multiple_rows", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_single_element", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_column_using_alias_with_chain", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_column_using_table_alias", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_empty_columns", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_empty_columns_type_list", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_empty_columns_type_tuple", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_ignore", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_multiple_rows_with_array_value", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_none_skipped", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_null", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_one_column", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_one_column_multi_element_array", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_one_column_single_element_array", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_selected_columns", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_selected_columns_type_list", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_selected_columns_type_tuple", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_single_row_with_array_value", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_with_statement", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_empty_on_conflict_do_update_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_field", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_field_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_mixed_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_multiple_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_multiple_fields_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_field", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_field_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_multiple_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_multiple_fields_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_multiple_mixed_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_no_handler", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_two_handlers_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_two_handlers_do_update", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_fieldless_conflict_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_fieldless_conflict_do_update_field", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_non_insert_on_conflict_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_non_insert_on_conflict_do_update", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_do_nothing_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_do_update_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_do_update_with_excluded_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_from_subquery", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_complex", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_conflict_fields_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_conflict_fields_do_update", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_empty_conflict_fields_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_empty_conflict_fields_do_update", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_where_and_on_conflict_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_all_columns_multi_rows_chained_returning_star", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_all_columns_multi_rows_chained_returning_star_and_id", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_all_columns_multi_rows_chained_returning_star_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_all_columns_single_element_arrays", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_aggregate", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_all_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_all_fields_and_arithmetics", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_arithmetics", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_from_other_table", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_functions", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_null", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_one_field", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_one_field_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_tuple", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_ignore", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multi_rows_chained_mixed_on_duplicate_update_multiple", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_multiple", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_different_value", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_expression", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_expression_using_original_field_value", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_expression_using_values", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_same_value", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_none_skipped", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_one_column", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_one_column_multi_element_array", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_one_column_single_element_array", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_one_column_using_values", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_selected_columns_on_duplicate_update_multiple", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_selected_columns_on_duplicate_update_one", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_columns_from_columns", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_columns_from_columns_with_join", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_columns_from_star", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_from_columns", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_ignore_star", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_star", + "pypika/tests/test_inserts.py::InsertSubqueryTests::test_insert_subquery_wrapped_in_brackets", + "pypika/tests/test_inserts.py::SelectIntoTests::test_select_columns_into", + "pypika/tests/test_inserts.py::SelectIntoTests::test_select_columns_into_with_join", + "pypika/tests/test_inserts.py::SelectIntoTests::test_select_star_into", + "pypika/tests/test_inserts.py::ReplaceTests::test_replace_simple", + "pypika/tests/test_inserts.py::ReplaceTests::test_replace_subquery", + "pypika/tests/test_internals.py::TablesTests::test__case_tables", + "pypika/tests/test_internals.py::TablesTests::test__criterion_replace_table_with_value", + "pypika/tests/test_internals.py::TablesTests::test__star_tables", + "pypika/tests/test_internals.py::TablesTests::test__table_star_tables", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_cross_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_cross_join_on_subquery", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_cross_join_on_table", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_default_join_type", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_full_outer_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_hash_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_inner_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_arithmetic_field", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_collate", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_complex_criteria", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_field_multi", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_field_multi_with_extra_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_field_single", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_field_without_fields_raises_exception", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_subquery_criteria", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_second_table_in_from_clause", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_using_multiple_fields", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_using_string_field_name", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_using_with_quote_char", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_using_without_fields_raises_exception", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_with_arithmetic_function_in_select", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_left_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_left_outer_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_outer_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_right_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_right_outer_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_temporal_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_use_different_table_objects_for_same_table", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_fail_when_joining_unknown_type", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_ignore_table_references", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_immutable__tables", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_from_join", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_query_with_column_alias", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_query_with_setoperation", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_query_with_table_alias", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_query_without_alias", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_same_table", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_same_table_with_prefixes", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_table_twice", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_prefixes_added_to_function_in_orderby", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_prefixes_added_to_groupby", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_prefixes_added_to_orderby", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_require_condition", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_require_condition_with_both_tables", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select__fields_after_table_star", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select__ordered_select_clauses", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select__star_for_table", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select__star_for_table__replacement", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select_field_from_missing_table", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select_fields_with_where", + "pypika/tests/test_joins.py::UnionTests::test_mysql_query_wraps_unioned_queries", + "pypika/tests/test_joins.py::UnionTests::test_require_equal_number_of_fields", + "pypika/tests/test_joins.py::UnionTests::test_union", + "pypika/tests/test_joins.py::UnionTests::test_union_all", + "pypika/tests/test_joins.py::UnionTests::test_union_all_multiple", + "pypika/tests/test_joins.py::UnionTests::test_union_as_subquery", + "pypika/tests/test_joins.py::UnionTests::test_union_multiple", + "pypika/tests/test_joins.py::UnionTests::test_union_with_no_quote_char", + "pypika/tests/test_joins.py::UnionTests::test_union_with_order_by", + "pypika/tests/test_joins.py::UnionTests::test_union_with_order_by_use_union_query_field", + "pypika/tests/test_joins.py::UnionTests::test_union_with_order_by_use_union_query_field_with_aliases", + "pypika/tests/test_joins.py::UnionTests::test_union_with_order_by_with_aliases", + "pypika/tests/test_joins.py::InsertQueryJoinTests::test_join_table_on_insert_query", + "pypika/tests/test_joins.py::UpdateQueryJoinTests::test_join_table_on_update_query", + "pypika/tests/test_joins.py::IntersectTests::test_intersect", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_as_subquery", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_multiple", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_with_limit", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_with_no_quote_char", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_with_offset", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_with_order_by", + "pypika/tests/test_joins.py::IntersectTests::test_mysql_query_wraps_intersected_queries", + "pypika/tests/test_joins.py::IntersectTests::test_require_equal_number_of_fields_intersect", + "pypika/tests/test_joins.py::MinusTests::test_minus", + "pypika/tests/test_joins.py::MinusTests::test_minus_as_subquery", + "pypika/tests/test_joins.py::MinusTests::test_minus_multiple", + "pypika/tests/test_joins.py::MinusTests::test_minus_query_with_order_by_use_minus_query_field", + "pypika/tests/test_joins.py::MinusTests::test_minus_with_no_quote_char", + "pypika/tests/test_joins.py::MinusTests::test_minus_with_order_by", + "pypika/tests/test_joins.py::MinusTests::test_mysql_query_wraps_minus_queries", + "pypika/tests/test_joins.py::MinusTests::test_require_equal_number_of_fields", + "pypika/tests/test_joins.py::ExceptOfTests::test_except", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_as_subquery", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_multiple", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_query_with_order_by_use_minus_query_field", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_with_no_quote_char", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_with_order_by", + "pypika/tests/test_joins.py::ExceptOfTests::test_require_equal_number_of_fields_except_of", + "pypika/tests/test_negation.py::NegationTests::test_negate_field", + "pypika/tests/test_negation.py::NegationTests::test_negate_function", + "pypika/tests/test_negation.py::NegationTests::test_negate_wrapped_float", + "pypika/tests/test_negation.py::NegationTests::test_negate_wrapped_int", + "pypika/tests/test_parameter.py::ParametrizedTests::test_format_parameter", + "pypika/tests/test_parameter.py::ParametrizedTests::test_join", + "pypika/tests/test_parameter.py::ParametrizedTests::test_named_parameter", + "pypika/tests/test_parameter.py::ParametrizedTests::test_numeric_parameter", + "pypika/tests/test_parameter.py::ParametrizedTests::test_param_insert", + "pypika/tests/test_parameter.py::ParametrizedTests::test_param_select_join", + "pypika/tests/test_parameter.py::ParametrizedTests::test_param_select_subquery", + "pypika/tests/test_parameter.py::ParametrizedTests::test_pyformat_parameter", + "pypika/tests/test_parameter.py::ParametrizedTests::test_qmark_parameter", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_join", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_join_with_parameter_value_wrapper", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_param_insert", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_param_select_join", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_param_select_subquery", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_pyformat_parameter", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_can_be_used_in_a_select_statement", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_can_be_used_in_a_where_clause", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_can_be_used_in_orderby", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_column_value", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_object_id", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_object_value", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_row_id", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_row_num", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_sys_date", + "pypika/tests/test_query.py::QueryTablesTests::test_is_joined", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_case_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_delete_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_filter_tables", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_having_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_insert_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_insert_table_current_table_not_match", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_join_tables", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_only_specified_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_orderby_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_tuple_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_update_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_update_table_current_table_not_match", + "pypika/tests/test_query.py::QueryBuilderTests::test_pipe", + "pypika/tests/test_query.py::QueryBuilderTests::test_query_builders_have_reference_to_correct_query_class", + "pypika/tests/test_selects.py::SelectTests::test_empty_query", + "pypika/tests/test_selects.py::SelectTests::test_mssql_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_mysql_query_uses_backtick_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_oracle_query_uses_no_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_postgresql_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_redshift_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_select__column__single__alias__str", + "pypika/tests/test_selects.py::SelectTests::test_select__column__single__field", + "pypika/tests/test_selects.py::SelectTests::test_select__column__single__str", + "pypika/tests/test_selects.py::SelectTests::test_select__column__single__table_alias__str", + "pypika/tests/test_selects.py::SelectTests::test_select__columns__multi__field", + "pypika/tests/test_selects.py::SelectTests::test_select__columns__multi__str", + "pypika/tests/test_selects.py::SelectTests::test_select__distinct__multi", + "pypika/tests/test_selects.py::SelectTests::test_select__distinct__single", + "pypika/tests/test_selects.py::SelectTests::test_select__multiple_subqueries", + "pypika/tests/test_selects.py::SelectTests::test_select__multiple_tables", + "pypika/tests/test_selects.py::SelectTests::test_select__nested_subquery", + "pypika/tests/test_selects.py::SelectTests::test_select__no_table", + "pypika/tests/test_selects.py::SelectTests::test_select__star", + "pypika/tests/test_selects.py::SelectTests::test_select__star__replacement", + "pypika/tests/test_selects.py::SelectTests::test_select__subquery", + "pypika/tests/test_selects.py::SelectTests::test_select__table_schema", + "pypika/tests/test_selects.py::SelectTests::test_select__table_schema_with_multiple_levels_as_list", + "pypika/tests/test_selects.py::SelectTests::test_select__table_schema_with_multiple_levels_as_tuple", + "pypika/tests/test_selects.py::SelectTests::test_select_no_from", + "pypika/tests/test_selects.py::SelectTests::test_select_no_from_with_field_raises_exception", + "pypika/tests/test_selects.py::SelectTests::test_select_no_with_alias_from", + "pypika/tests/test_selects.py::SelectTests::test_select_then_add_table", + "pypika/tests/test_selects.py::SelectTests::test_select_with_force_index", + "pypika/tests/test_selects.py::SelectTests::test_select_with_force_index_multiple_calls", + "pypika/tests/test_selects.py::SelectTests::test_select_with_force_index_multiple_indexes", + "pypika/tests/test_selects.py::SelectTests::test_select_with_force_index_with_index_object", + "pypika/tests/test_selects.py::SelectTests::test_select_with_limit", + "pypika/tests/test_selects.py::SelectTests::test_select_with_limit__func", + "pypika/tests/test_selects.py::SelectTests::test_select_with_limit_and_offset", + "pypika/tests/test_selects.py::SelectTests::test_select_with_limit_zero", + "pypika/tests/test_selects.py::SelectTests::test_select_with_offset", + "pypika/tests/test_selects.py::SelectTests::test_select_with_offset__func", + "pypika/tests/test_selects.py::SelectTests::test_select_with_use_index", + "pypika/tests/test_selects.py::SelectTests::test_select_with_use_index_multiple_calls", + "pypika/tests/test_selects.py::SelectTests::test_select_with_use_index_multiple_indexes", + "pypika/tests/test_selects.py::SelectTests::test_select_with_use_index_with_index_object", + "pypika/tests/test_selects.py::SelectTests::test_table_select_alias", + "pypika/tests/test_selects.py::SelectTests::test_table_select_alias_with_offset_and_limit", + "pypika/tests/test_selects.py::SelectTests::test_temporal_select", + "pypika/tests/test_selects.py::SelectTests::test_vertica_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::WhereTests::test_ignore_empty_criterion_having", + "pypika/tests/test_selects.py::WhereTests::test_ignore_empty_criterion_where", + "pypika/tests/test_selects.py::WhereTests::test_select_with_force_index_and_where", + "pypika/tests/test_selects.py::WhereTests::test_where_enum", + "pypika/tests/test_selects.py::WhereTests::test_where_field_contains", + "pypika/tests/test_selects.py::WhereTests::test_where_field_does_not_contain", + "pypika/tests/test_selects.py::WhereTests::test_where_field_does_not_end_with", + "pypika/tests/test_selects.py::WhereTests::test_where_field_does_not_start_with", + "pypika/tests/test_selects.py::WhereTests::test_where_field_ends_with", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_and", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_nowait", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_of", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_of_multiple_tables", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_of_nowait", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_of_skip_locked", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_skip_locked", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_skip_locked_and_of", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_or", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_where", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_where_not", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_where_two_not", + "pypika/tests/test_selects.py::WhereTests::test_where_field_is_n_chars_long", + "pypika/tests/test_selects.py::WhereTests::test_where_field_is_not_n_chars_long", + "pypika/tests/test_selects.py::WhereTests::test_where_field_matches_regex", + "pypika/tests/test_selects.py::WhereTests::test_where_field_matches_regexp", + "pypika/tests/test_selects.py::WhereTests::test_where_field_matches_rlike", + "pypika/tests/test_selects.py::WhereTests::test_where_field_starts_with", + "pypika/tests/test_selects.py::WhereTests::test_where_nested_conditions", + "pypika/tests/test_selects.py::WhereTests::test_where_single_quote", + "pypika/tests/test_selects.py::WhereTests::test_where_with_multiple_wheres_using_and_case", + "pypika/tests/test_selects.py::WhereTests::test_where_with_multiple_wheres_using_or_case", + "pypika/tests/test_selects.py::PreWhereTests::test_ignore_empty_criterion_having", + "pypika/tests/test_selects.py::PreWhereTests::test_ignore_empty_criterion_where", + "pypika/tests/test_selects.py::PreWhereTests::test_prewhere_field_equals", + "pypika/tests/test_selects.py::PreWhereTests::test_select_with_force_index_and_where", + "pypika/tests/test_selects.py::PreWhereTests::test_where_and_prewhere", + "pypika/tests/test_selects.py::PreWhereTests::test_where_enum", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_contains", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_does_not_contain", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_does_not_end_with", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_does_not_start_with", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_ends_with", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_and", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_nowait", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_of", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_of_multiple_tables", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_of_nowait", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_of_skip_locked", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_skip_locked", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_skip_locked_and_of", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_or", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_where", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_where_not", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_where_two_not", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_is_n_chars_long", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_is_not_n_chars_long", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_matches_regex", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_matches_regexp", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_matches_rlike", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_starts_with", + "pypika/tests/test_selects.py::PreWhereTests::test_where_nested_conditions", + "pypika/tests/test_selects.py::PreWhereTests::test_where_single_quote", + "pypika/tests/test_selects.py::PreWhereTests::test_where_with_multiple_wheres_using_and_case", + "pypika/tests/test_selects.py::PreWhereTests::test_where_with_multiple_wheres_using_or_case", + "pypika/tests/test_selects.py::GroupByTests::test_group_by__single_with_totals", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__alias", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__alias_platforms", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__alias_with_join", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__count_distinct", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__count_field", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__count_star", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__int", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__multi", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__multi_with_totals", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__no_alias", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__no_alias_mssql", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__no_alias_oracle", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__single", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__str", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__sum_distinct", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__sum_filter", + "pypika/tests/test_selects.py::GroupByTests::test_groupby_with_case_uses_the_alias", + "pypika/tests/test_selects.py::GroupByTests::test_mssql_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_mysql_query_uses_backtick_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_oracle_query_uses_no_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_postgres_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_redshift_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_vertica_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_having_and", + "pypika/tests/test_selects.py::HavingTests::test_having_greater_than", + "pypika/tests/test_selects.py::HavingTests::test_having_join_and_equality", + "pypika/tests/test_selects.py::HavingTests::test_mssql_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_mysql_query_uses_backtick_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_oracle_query_uses_no_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_postgres_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_redshift_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_vertica_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_alias", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_asc", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_desc", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_multi_fields", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_no_alias", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_single_field", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_single_str", + "pypika/tests/test_selects.py::AliasTests::test_arithmetic_function", + "pypika/tests/test_selects.py::AliasTests::test_case_using_as", + "pypika/tests/test_selects.py::AliasTests::test_case_using_constructor_param", + "pypika/tests/test_selects.py::AliasTests::test_function_using_as_nested", + "pypika/tests/test_selects.py::AliasTests::test_functions_using_as", + "pypika/tests/test_selects.py::AliasTests::test_functions_using_constructor_param", + "pypika/tests/test_selects.py::AliasTests::test_functions_using_constructor_param_nested", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_criterion", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_criterion_comparison", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_field_inside_case", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_groupby", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_orderby", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_where", + "pypika/tests/test_selects.py::AliasTests::test_null_value_with_alias", + "pypika/tests/test_selects.py::AliasTests::test_select__multiple_tables", + "pypika/tests/test_selects.py::AliasTests::test_table_field", + "pypika/tests/test_selects.py::AliasTests::test_table_field__multi", + "pypika/tests/test_selects.py::AliasTests::test_table_with_schema_and_alias", + "pypika/tests/test_selects.py::AliasTests::test_use_aliases_in_groupby_and_orderby", + "pypika/tests/test_selects.py::SubqueryTests::test_from_subquery_without_alias", + "pypika/tests/test_selects.py::SubqueryTests::test_join", + "pypika/tests/test_selects.py::SubqueryTests::test_join_query_with_alias", + "pypika/tests/test_selects.py::SubqueryTests::test_join_with_with", + "pypika/tests/test_selects.py::SubqueryTests::test_select_from_nested_query", + "pypika/tests/test_selects.py::SubqueryTests::test_select_from_nested_query_with_join", + "pypika/tests/test_selects.py::SubqueryTests::test_select_from_with_returning", + "pypika/tests/test_selects.py::SubqueryTests::test_select_subquery", + "pypika/tests/test_selects.py::SubqueryTests::test_select_subquery_with_alias", + "pypika/tests/test_selects.py::SubqueryTests::test_where__equality", + "pypika/tests/test_selects.py::SubqueryTests::test_where__in", + "pypika/tests/test_selects.py::SubqueryTests::test_where__in_nested", + "pypika/tests/test_selects.py::SubqueryTests::test_with", + "pypika/tests/test_selects.py::QuoteTests::test_extraneous_quotes", + "pypika/tests/test_tables.py::TableStructureTests::test_database_schema_table_attr", + "pypika/tests/test_tables.py::TableStructureTests::test_schema_table_attr", + "pypika/tests/test_tables.py::TableStructureTests::test_table_for_period_sql", + "pypika/tests/test_tables.py::TableStructureTests::test_table_for_system_time_sql", + "pypika/tests/test_tables.py::TableStructureTests::test_table_sql", + "pypika/tests/test_tables.py::TableStructureTests::test_table_with_alias", + "pypika/tests/test_tables.py::TableStructureTests::test_table_with_schema_and_schema_parent_arg", + "pypika/tests/test_tables.py::TableStructureTests::test_table_with_schema_arg", + "pypika/tests/test_tables.py::TableEqualityTests::test_many_tables_with_alias", + "pypika/tests/test_tables.py::TableEqualityTests::test_many_tables_with_or_not_alias", + "pypika/tests/test_tables.py::TableEqualityTests::test_many_tables_without_alias", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_equal_by_name", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_equal_by_schema_and_name", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_equal_by_schema_and_name_using_schema", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_equal_by_schema_and_name_using_schema_with_parent", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_not_equal_by_schema_and_name_using_schema_with_different_parents", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_not_equal_with_different_names", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_not_equal_with_different_schemas", + "pypika/tests/test_tables.py::TableDialectTests::test_make_tables_factory_with_default_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_make_tables_factory_with_dialect_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_factory_with_default_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_factory_with_dialect_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_with_bad_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_with_default_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_with_dialect_query_cls", + "pypika/tests/test_terms.py::FieldAliasTests::test_when_alias_specified", + "pypika/tests/test_terms.py::FieldInitTests::test_init_with_str_table", + "pypika/tests/test_terms.py::FieldHashingTests::test_non_tabled_aliased_eq_fields_equally_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_non_tabled_aliased_ne_fields_differently_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_non_tabled_eq_fields_equally_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_non_tabled_ne_fields_differently_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_tabled_eq_fields_equally_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_tabled_ne_fields_differently_hashed", + "pypika/tests/test_terms.py::AtTimezoneTests::test_passes_kwargs_to_field_get_sql", + "pypika/tests/test_terms.py::AtTimezoneTests::test_when_alias_specified", + "pypika/tests/test_terms.py::AtTimezoneTests::test_when_interval_not_specified", + "pypika/tests/test_terms.py::AtTimezoneTests::test_when_interval_specified", + "pypika/tests/test_tuples.py::TupleTests::test_render_alias_in_array_sql", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_equality_tuple_on_both", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_equality_tuple_on_left", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_equality_tuple_on_right", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_in_using_mixed_tuples", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_in_using_pypika_tuples", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_in_using_python_tuples", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_is_aggregate", + "pypika/tests/test_tuples.py::TupleTests::test_tuples_in_join", + "pypika/tests/test_tuples.py::ArrayTests::test_array_general", + "pypika/tests/test_tuples.py::ArrayTests::test_empty_psql_array", + "pypika/tests/test_tuples.py::ArrayTests::test_psql_array_general", + "pypika/tests/test_tuples.py::ArrayTests::test_render_alias_in_array_sql", + "pypika/tests/test_tuples.py::BracketTests::test_arithmetic_with_brackets", + "pypika/tests/test_tuples.py::BracketTests::test_arithmetic_with_brackets_and_alias", + "pypika/tests/test_updates.py::UpdateTests::test_empty_query", + "pypika/tests/test_updates.py::UpdateTests::test_for_portion", + "pypika/tests/test_updates.py::UpdateTests::test_omit_where", + "pypika/tests/test_updates.py::UpdateTests::test_single_quote_escape_in_set", + "pypika/tests/test_updates.py::UpdateTests::test_update__table_schema", + "pypika/tests/test_updates.py::UpdateTests::test_update_from", + "pypika/tests/test_updates.py::UpdateTests::test_update_from_with_where", + "pypika/tests/test_updates.py::UpdateTests::test_update_with_join", + "pypika/tests/test_updates.py::UpdateTests::test_update_with_limit", + "pypika/tests/test_updates.py::UpdateTests::test_update_with_none", + "pypika/tests/test_updates.py::UpdateTests::test_update_with_statement", + "pypika/tests/test_updates.py::PostgresUpdateTests::test_update_returning", + "pypika/tests/test_updates.py::PostgresUpdateTests::test_update_returning_from_different_tables", + "pypika/tests/test_updates.py::PostgresUpdateTests::test_update_returning_star", + "pypika/tests/test_updates.py::PostgresUpdateTests::test_update_returning_str", + "pypika/tests/test_updates.py::SQLLiteUpdateTests::test_update_with_bool", + "pypika/tests/test_utils.py::ImmutabilityTests::test_raise_attribute_error_for_deepcopy", + "pypika/tests/test_utils.py::ImmutabilityTests::test_raise_attribute_error_for_getnewargs", + "pypika/tests/test_utils.py::ImmutabilityTests::test_raise_attribute_error_for_getstate", + "pypika/tests/test_utils.py::ImmutabilityTests::test_raise_attribute_error_for_setstate" + ] +} diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/grade.py b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/grade.py new file mode 100644 index 0000000000000000000000000000000000000000..e3b37293830e51a5c5833c93c4705e1ed9364257 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/grade.py @@ -0,0 +1,128 @@ +"""Trusted private pytest panel runner. Installed only in a fresh grader Job.""" + +import hashlib +import importlib.util +import json +import os +import shutil +import stat +import subprocess +from pathlib import Path, PurePosixPath + + +def sha(raw): + return hashlib.sha256(raw).hexdigest() + + +def safe(value): + path = PurePosixPath(value) + if ( + path.is_absolute() + or path.as_posix() != value + or not path.parts + or any(part in {".", "..", ".git"} for part in path.parts) + ): + raise ValueError("Unsafe trusted test path") + return path + + +def restore(worktree, private, manifest): + worktree, private = Path(worktree), Path(private) + captured = {} + for name, expected in manifest["files"].items(): + path = private / safe(name) + info = path.lstat() + raw = path.read_bytes() if stat.S_ISREG(info.st_mode) else b"" + if ( + not stat.S_ISREG(info.st_mode) + or len(raw) != expected["bytes"] + or sha(raw) != expected["sha256"] + or stat.S_IMODE(info.st_mode) != expected["mode"] + ): + raise ValueError("Trusted private test bytes or modes drifted") + captured[name] = (raw, expected["mode"]) + # Capture and verify every private byte before changing the submitted tree. + for name in manifest["directory_roots"]: + destination = worktree / safe(name) + if destination.is_symlink(): + raise ValueError("Submitted test directory is a symlink") + for parent in destination.parents: + if parent == worktree: + break + if parent.is_symlink(): + raise ValueError("Submitted test parent is a symlink") + if destination.exists(): + if not destination.is_dir(): + raise ValueError("Submitted test directory is not a directory") + shutil.rmtree(destination) + for name, (raw, mode) in captured.items(): + destination = worktree / safe(name) + for parent in destination.parents: + if parent == worktree: + break + if parent.is_symlink(): + raise ValueError("Submitted test parent is a symlink") + if destination.is_symlink(): + raise ValueError("Submitted trusted file is a symlink") + destination.parent.mkdir(parents=True, exist_ok=True) + destination.write_bytes(raw) + destination.chmod(mode) + + +def run(worktree, private_root, output, invoke=None): + private_root, output, worktree = Path(private_root), Path(output), Path(worktree) + expected = json.loads((private_root / "expected-panels.json").read_bytes()) + config = json.loads((private_root / "panel-config.json").read_bytes()) + manifest = json.loads((private_root / "trusted-inventory.json").read_bytes()) + restore(worktree, private_root / "trusted", manifest) + output.mkdir(parents=True, exist_ok=True) + for name in ( + "reward.txt", + "pass-to-pass.xml", + "fail-to-pass.xml", + "pytest-evidence.json", + ): + (output / name).unlink(missing_ok=True) + environment = dict(os.environ) + for key in ("PYTEST_ADDOPTS", "PYTEST_DISABLE_PLUGIN_AUTOLOAD", "PYTHONPATH"): + environment.pop(key, None) + commands, native_exit = [], 0 + invoke = invoke or subprocess.run + for group in ("pass-to-pass", "fail-to-pass"): + if ( + not isinstance(expected[group], list) + or not expected[group] + or any( + not isinstance(target, str) or not target for target in expected[group] + ) + ): + raise ValueError("Frozen native pytest selectors are incomplete") + command = [ + *config["official_pytest_argv"], + "--override-ini=addopts=", + "--junitxml=" + str(output / (group + ".xml")), + *expected[group], + ] + result = invoke(command, cwd=worktree, env=environment, check=False) + native_exit = result.returncode + commands.append({"group": group, "argv": command, "exit_code": native_exit}) + if native_exit != 0: + break + (output / "pytest-commands.json").write_text( + json.dumps(commands, sort_keys=True) + "\n" + ) + spec = importlib.util.spec_from_file_location( + "trusted_pytest_result", private_root / "check_pytest.py" + ) + checker = importlib.util.module_from_spec(spec) + spec.loader.exec_module(checker) + result = checker.assess(output, expected, native_exit) + (output / "reward.txt").write_text(str(result["reward"]) + "\n") + (output / "pytest-evidence.json").write_text( + json.dumps(result, sort_keys=True) + "\n" + ) + return result + + +if __name__ == "__main__": + run("/testbed/repo", "/tests", "/logs/verifier") diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/panel-config.json b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/panel-config.json new file mode 100644 index 0000000000000000000000000000000000000000..6417b9c92e5da5b97ee641bd54f798302af42a31 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/panel-config.json @@ -0,0 +1,28 @@ +{ + "dependency_installation_pinned": false, + "official_install_cmds": [ + "python -m pip install -e ." + ], + "official_pytest_argv": [ + "pytest", + "--disable-warnings", + "--color=no", + "--tb=no", + "--verbose" + ], + "official_test_command": "source /opt/miniconda3/bin/activate; conda activate testbed; pytest --disable-warnings --color=no --tb=no --verbose", + "operator_test_runner_prerequisites": [ + "python -m pip install pytest==8.4.2" + ], + "operator_test_runner_reason": "The official profile invokes pytest, but the common tools runtime does not provide it; pinned separately from source-native project requirements.", + "panel_normalization": "Override project addopts only to execute the exact frozen native panels; add JUnit output, preserve official pytest options and all selectors.", + "python_version": "3.10", + "source_bound_test_dependency_cmds": [ + "python -m pip install parameterized==0.7.0" + ], + "test_dependency_source_sha256": { + "requirements-dev.txt": "10f4ba7b19a73950d28fd7403d7e1d1b1fe2ccc4f49516974f47199d2965f23d", + "setup.py": "f8bad274588a22e65764d8cf9fb2be5aa6fcfaf3bf861d71e5f751105898845a", + "tox.ini": "c2d7205d0ac93e9c9e80dc5d24f0a826a6781f587a33ea722ea621f9e2ccd0ea" + } +} diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/test.sh b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..81b6d0620f05dbd3b54b4e7ea5de04ce3f8a98e2 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/test.sh @@ -0,0 +1,6 @@ +#!/bin/bash +set -Eeuo pipefail +source /opt/miniconda3/bin/activate +conda activate testbed +cd /testbed/repo +exec python -I /tests/grade.py diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted-inventory.json b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted-inventory.json new file mode 100644 index 0000000000000000000000000000000000000000..6926ef1c22ed56457101c37cd70e0fe0d1656f0c --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted-inventory.json @@ -0,0 +1,242 @@ +{ + "directory_roots": [ + "pypika/tests" + ], + "files": { + "pypika/tests/__init__.py": { + "bytes": 58, + "mode": 420, + "sha256": "7d41f44b87688bdf162e6d5cbe7b517cfba468f96eaa421f02718c17eb486a18" + }, + "pypika/tests/clickhouse/__init__.py": { + "bytes": 0, + "mode": 420, + "sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "pypika/tests/clickhouse/test_array.py": { + "bytes": 2942, + "mode": 420, + "sha256": "0f0a5b4c3daf3ddce2944b6119795e80d50b74e4687ef2e34399e5d21d3d48ae" + }, + "pypika/tests/clickhouse/test_condition.py": { + "bytes": 2533, + "mode": 420, + "sha256": "c666976d082b1d12cd57e791d1a525183246335efad96a369b58871a6f1e4fa1" + }, + "pypika/tests/clickhouse/test_dates_and_times.py": { + "bytes": 2508, + "mode": 420, + "sha256": "cb8ea84363e35ad0a00b52a8ec20cb38f2348f4cba28d026a4c32c14fd1fc56f" + }, + "pypika/tests/clickhouse/test_nullable_arg.py": { + "bytes": 672, + "mode": 420, + "sha256": "883c5161ebeb09544ce124d20a096d248bd12a0404ad77c84637be75d6738529" + }, + "pypika/tests/clickhouse/test_search_string.py": { + "bytes": 1189, + "mode": 420, + "sha256": "d5f0ed6a51cf550bdd4b261fa2e98084184dd1cbb08f5dbb8b91278b4c8f3bfd" + }, + "pypika/tests/clickhouse/test_type_conversion.py": { + "bytes": 4445, + "mode": 420, + "sha256": "7e6045b64433a8947346cfb34ac30279349f7a2e2081a2815212c8cb7d0235ab" + }, + "pypika/tests/dialects/__init__.py": { + "bytes": 0, + "mode": 420, + "sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "pypika/tests/dialects/test_clickhouse.py": { + "bytes": 5747, + "mode": 420, + "sha256": "2272538d6eeb6dfb01f9803eed328b4cd4efc8d255b6a8ab3c4e25bee74d73fa" + }, + "pypika/tests/dialects/test_mssql.py": { + "bytes": 3152, + "mode": 420, + "sha256": "0cd9b2ee6498caa9fa75a51ead30803057fb23deb2ac706d396d88329e0e91d7" + }, + "pypika/tests/dialects/test_mysql.py": { + "bytes": 2984, + "mode": 420, + "sha256": "a5f4550dd14bf4820e5d85cf06b6c7c79286e41d2d3c794f639579d20fffab92" + }, + "pypika/tests/dialects/test_oracle.py": { + "bytes": 1906, + "mode": 420, + "sha256": "67f80eb40cc9b4dabcbad355e8be6d83c54a64cbee809182ef57fa9f48d2ebc6" + }, + "pypika/tests/dialects/test_postgresql.py": { + "bytes": 9532, + "mode": 420, + "sha256": "548ee7267ca87c9e1ae82ca89a4e5bd96c7392a55cc07996f2b105f911ffa6cf" + }, + "pypika/tests/dialects/test_snowflake.py": { + "bytes": 2159, + "mode": 420, + "sha256": "e567b9dab0a5366bd11a0ef162c3a3bb492280b78bc4b397a23070563dc84468" + }, + "pypika/tests/dialects/test_sqllite.py": { + "bytes": 1243, + "mode": 420, + "sha256": "118fed7e575415f276bda390a119080bd6a767aee3d9c953e11a8c219f0f017c" + }, + "pypika/tests/dialects/test_vertica.py": { + "bytes": 3578, + "mode": 420, + "sha256": "33a027e6735ca03b7afd11394905c4193e48a15dda3efbe47cdcd85fcabf840c" + }, + "pypika/tests/test_aggregate.py": { + "bytes": 3946, + "mode": 420, + "sha256": "5b0fb549de3bb50ad88ae1d75824f12f7ab4a5f1102b06a70c7b2ebae33bea6d" + }, + "pypika/tests/test_analytic_queries.py": { + "bytes": 20611, + "mode": 420, + "sha256": "8546b7a296c8e212c349c4baff95f93934b3120f74625b3945ade3b438e3a3ed" + }, + "pypika/tests/test_create.py": { + "bytes": 9088, + "mode": 420, + "sha256": "6c57302da52ca1044be0afdafe677d5de245e44873dff1386c9a1ccb2625cc82" + }, + "pypika/tests/test_criterions.py": { + "bytes": 32014, + "mode": 420, + "sha256": "78539ccca82f9a02fad0f5a39041ac343e3a142ce52368cd4f6ada489c52516a" + }, + "pypika/tests/test_custom_functions.py": { + "bytes": 1710, + "mode": 420, + "sha256": "bfa18bc328a3577965db7cc75eb94439f0cfd95a3775d9b1cc8af1062bb202cb" + }, + "pypika/tests/test_data_types.py": { + "bytes": 403, + "mode": 420, + "sha256": "c1be6ecc621a80dd91d35b1427bdfc8b1b33bd926515198e626d6fb5e1878c8b" + }, + "pypika/tests/test_date_math.py": { + "bytes": 5544, + "mode": 420, + "sha256": "85aa54efe54fe19639f2dc2a5750647e3337ac2681768bc3fe327841f1634d9e" + }, + "pypika/tests/test_deletes.py": { + "bytes": 3204, + "mode": 420, + "sha256": "ccde6df760d76d5d499ce828f6b0e2ad3eebcb2a5553c1890f481b9160b8d51a" + }, + "pypika/tests/test_drop.py": { + "bytes": 1556, + "mode": 420, + "sha256": "a13dffa59ef8657398d5498c18977bfd702635e336ea9966b1a86137afca7926" + }, + "pypika/tests/test_formats.py": { + "bytes": 1948, + "mode": 420, + "sha256": "240458a404bb119322778893b94a12be0f98f914acd701d2b4be73eb9be96f75" + }, + "pypika/tests/test_functions.py": { + "bytes": 32769, + "mode": 420, + "sha256": "3ceaac7791bd27e50f44e1b4a1451d1e09afe6a8011052caea838e5124582154" + }, + "pypika/tests/test_groupby_modifiers.py": { + "bytes": 5227, + "mode": 420, + "sha256": "9db4497660f08e3352a9a02c34889ad1cd6bab3aebaeaa485e84390ad71c84c5" + }, + "pypika/tests/test_immutability.py": { + "bytes": 3954, + "mode": 420, + "sha256": "af537ced19f7274951cc91697eae748ef6c9cd20a8d8e492d93dc85b06f8fb50" + }, + "pypika/tests/test_inserts.py": { + "bytes": 32549, + "mode": 420, + "sha256": "652e9f7f0f425e9acc0f70e2851ae29310b378262ea30369ea0113ef428f210f" + }, + "pypika/tests/test_internals.py": { + "bytes": 828, + "mode": 420, + "sha256": "4374c2632563346d00ca4de6af397a022ef3f5022e808c8711a3f207a3a21609" + }, + "pypika/tests/test_joins.py": { + "bytes": 43895, + "mode": 420, + "sha256": "53f224815c10393382443f020cb20e313420764495a8fd30f7ea2f34fd52935d" + }, + "pypika/tests/test_negation.py": { + "bytes": 763, + "mode": 420, + "sha256": "6be105e8f39b32fb23e6ac7c7158232ee78111455d4f35638c8af60781138c79" + }, + "pypika/tests/test_parameter.py": { + "bytes": 7382, + "mode": 420, + "sha256": "aaf2a3e79c8267bdc60e218445bc2a2254b97cf37b643a44d6f1a8141cbb5104" + }, + "pypika/tests/test_pseudocolumns.py": { + "bytes": 1609, + "mode": 420, + "sha256": "b7c69f7aca41323c0e14a6a9e58697399cd7860610f07291afc6e8af26079ca2" + }, + "pypika/tests/test_query.py": { + "bytes": 9025, + "mode": 420, + "sha256": "2da9d717673912a84e86e6c0d3955dbd8f2fa7b41b7ed9a6f78089dfa28f9444" + }, + "pypika/tests/test_selects.py": { + "bytes": 50757, + "mode": 420, + "sha256": "5ac1b7ad3248d64b1e3865a72c763873514ae5cd6e03356b913e531c0c336986" + }, + "pypika/tests/test_tables.py": { + "bytes": 6568, + "mode": 420, + "sha256": "384c8e843ba56374ee92cd7b7e2fd3f89247b899e23cd9e1f6663d751ad5d884" + }, + "pypika/tests/test_terms.py": { + "bytes": 3215, + "mode": 420, + "sha256": "8598513180ddcd28cc61582618d85bd570280978b07603044dae81b2eb099f77" + }, + "pypika/tests/test_tuples.py": { + "bytes": 6033, + "mode": 420, + "sha256": "863942196a93e8939be0d03c49cfeb42a35503ad42f9f3d6c730260112811087" + }, + "pypika/tests/test_updates.py": { + "bytes": 5689, + "mode": 420, + "sha256": "0f0f2521bb8d1f5d782f8fabaea5fd1d82090cde045ba87fad65770db6c75d2f" + }, + "pypika/tests/test_utils.py": { + "bytes": 834, + "mode": 420, + "sha256": "5db6e90df5daaa70b9f35f1243db69908da1f27887f63466fc27ce20c7e14892" + }, + "pyproject.toml": { + "bytes": 390, + "mode": 420, + "sha256": "037fedacd5be5d078f398265ff97e1677e25214ad8839d17073a439695ee7a91" + }, + "setup.cfg": { + "bytes": 317, + "mode": 420, + "sha256": "c84a31de586e8385e741127b004fc1f19ebae6463cdf0b3f243991db35cdeaea" + }, + "setup.py": { + "bytes": 2638, + "mode": 420, + "sha256": "f8bad274588a22e65764d8cf9fb2be5aa6fcfaf3bf861d71e5f751105898845a" + }, + "tox.ini": { + "bytes": 257, + "mode": 420, + "sha256": "c2d7205d0ac93e9c9e80dc5d24f0a826a6781f587a33ea722ea621f9e2ccd0ea" + } + } +} diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/__init__.py b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..86d8a68101915c27b95484243dd81d55f7dba356 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/__init__.py @@ -0,0 +1,2 @@ +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/clickhouse/__init__.py b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/clickhouse/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/clickhouse/test_array.py b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/clickhouse/test_array.py new file mode 100644 index 0000000000000000000000000000000000000000..469705a9ff3c8fe9cc7f02c44a9812521eeb67f4 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/clickhouse/test_array.py @@ -0,0 +1,104 @@ +import unittest + +from parameterized import parameterized + +from pypika import Field +from pypika.clickhouse.array import ( + Array, + Empty, + HasAny, + Length, + NotEmpty, +) +from pypika.clickhouse.type_conversion import ( + ToFixedString, + ToInt64, +) + + +class TestArray(unittest.TestCase): + @parameterized.expand( + [ + ( + "['ridley', 'scott', 'jimi', 'hendrix']", + Array(["ridley", "scott", "jimi", "hendrix"]), + ), + ( + "[1, 2, 3, 4]", + Array([1, 2, 3, 4]), + ), + ( + "[toInt64('1'),toInt64('2'),toInt64('3'),toInt64('4')]", + Array(["1", "2", "3", "4"], ToInt64), + ), + ( + "[toFixedString('mogwai',10),toFixedString('mono',10),toFixedString('bonobo',10)] arr", + Array(["mogwai", "mono", "bonobo"], ToFixedString, {"length": 10}).as_('arr'), + ), + ] + ) + def test_get_sql(self, expected: str, array: Array): + self.assertEqual(expected, array.get_sql()) + + +class TestHasAny(unittest.TestCase): + @parameterized.expand( + [ + ( + 'hasAny("mental_abilities","physical_abilities")', + HasAny(Field("mental_abilities"), Field("physical_abilities")), + ), + ("hasAny([1, 2, 3, 4],[3])", HasAny(Array([1, 2, 3, 4]), Array([3]))), + ( + "hasAny(\"bands\",[toFixedString('port-royal',20),toFixedString('hammock',20)])", + HasAny( + Field("bands"), + Array(["port-royal", "hammock"], ToFixedString, {"length": 20}), + ), + ), + ] + ) + def test_get_sql(self, expected: str, func: HasAny): + self.assertEqual(expected, func.get_sql()) + + +class TestLength(unittest.TestCase): + @parameterized.expand( + [ + ( + 'length("tags")', + Length(Field("tags")), + ), + ("length([1, 2, 3])", Length(Array([1, 2, 3]))), + ] + ) + def test_get_sql(self, expected: str, func: Length): + self.assertEqual(expected, func.get_sql()) + + +class TestEmpty(unittest.TestCase): + @parameterized.expand( + [ + ( + 'empty("tags")', + Empty(Field("tags")), + ), + ("empty([1, 2, 3])", Empty(Array([1, 2, 3]))), + ] + ) + def test_get_sql(self, expected: str, func: Empty): + self.assertEqual(expected, func.get_sql()) + + +class TestNotEmpty(unittest.TestCase): + @parameterized.expand( + [ + ( + 'notEmpty("tags")', + NotEmpty(Field("tags")), + ), + ("notEmpty([1, 2, 3])", NotEmpty(Array([1, 2, 3]))), + ] + ) + def test_get_sql(self, expected: str, func: NotEmpty): + self.assertEqual(expected, func.get_sql()) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/clickhouse/test_condition.py b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/clickhouse/test_condition.py new file mode 100644 index 0000000000000000000000000000000000000000..145baeb7753dd9cbefbd6f272bd672ae5730b0c0 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/clickhouse/test_condition.py @@ -0,0 +1,72 @@ +import unittest + +from parameterized import parameterized + +from pypika import Field +from pypika.clickhouse.condition import If, MultiIf +from pypika.clickhouse.type_conversion import ToFixedString + + +class TestIfCondition(unittest.TestCase): + @parameterized.expand( + [ + ( + If( + Field("filmmaker").isnull(), + ToFixedString("Tarantino", 20), + Field("filmmaker"), + ), + "if(filmmaker IS NULL,toFixedString('Tarantino',20),filmmaker)", + ), + ( + If( + Field("created") == Field("updated"), + ToFixedString("yes", 3), + ToFixedString("no", 3), + ), + "if(created=updated,toFixedString('yes',3),toFixedString('no',3))", + ), + ] + ) + def test_get_sql(self, func, expected): + self.assertEqual(func.get_sql(), expected) + + +class TestMultiIfCondition(unittest.TestCase): + @parameterized.expand( + [ + ( + MultiIf( + Field("filmmaker").isnull(), + ToFixedString("Tarantino", 20), + Field("filmmaker") == ToFixedString("undefined", 20), + ToFixedString("Tarantino", 20), + Field("filmmaker"), + ), + "multiIf(filmmaker IS NULL," + "toFixedString('Tarantino',20)," + "filmmaker=toFixedString('undefined',20)," + "toFixedString('Tarantino',20),filmmaker)", + ), + ( + MultiIf( + Field("color") == ToFixedString("black", 20), + ToFixedString("dark", 20), + Field("color") == ToFixedString("grey", 20), + ToFixedString("dark", 20), + Field("color") == ToFixedString("white", 20), + ToFixedString("light", 20), + ToFixedString("undefined", 20), + ), + "multiIf(color=toFixedString('black',20)," + "toFixedString('dark',20)," + "color=toFixedString('grey',20)," + "toFixedString('dark',20)," + "color=toFixedString('white',20)," + "toFixedString('light',20)," + "toFixedString('undefined',20))", + ), + ] + ) + def test_get_sql(self, func, expected): + self.assertEqual(func.get_sql(), expected) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/clickhouse/test_dates_and_times.py b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/clickhouse/test_dates_and_times.py new file mode 100644 index 0000000000000000000000000000000000000000..135dd7f112131776d76748e15eead1eb81752b59 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/clickhouse/test_dates_and_times.py @@ -0,0 +1,70 @@ +import unittest + +from parameterized import parameterized + +from pypika import Field +from pypika.clickhouse.dates_and_times import ( + AddDays, + AddHours, + AddMinutes, + AddMonths, + AddQuarters, + AddSeconds, + AddWeeks, + AddYears, + FormatDateTime, + SubtractDays, + SubtractHours, + SubtractMinutes, + SubtractMonths, + SubtractQuarters, + SubtractSeconds, + SubtractWeeks, + SubtractYears, + ToYYYYMM, +) + + +class TestFormatDateTime(unittest.TestCase): + @parameterized.expand( + [ + (FormatDateTime(Field("created"), "%V"), "formatDateTime(created,'%V')"), + ( + FormatDateTime(Field("created"), "%Y-%m-%d"), + "formatDateTime(created,'%Y-%m-%d')", + ), + ] + ) + def test_get_sql(self, func, expected): + self.assertEqual(func.get_sql(), expected) + + +class TestAddSubtractDt(unittest.TestCase): + @parameterized.expand( + [ + (AddYears(Field("created"), 1), "addYears(created,1)"), + (AddMonths(Field("created"), 2), "addMonths(created,2)"), + (AddWeeks(Field("created"), 3), "addWeeks(created,3)"), + (AddDays(Field("created"), 4), "addDays(created,4)"), + (AddHours(Field("created"), 5), "addHours(created,5)"), + (AddMinutes(Field("created"), 6), "addMinutes(created,6)"), + (AddSeconds(Field("created"), 7), "addSeconds(created,7)"), + (AddQuarters(Field("created"), 8), "addQuarters(created,8)"), + (SubtractYears(Field("created"), 9), "subtractYears(created,9)"), + (SubtractMonths(Field("created"), 10), "subtractMonths(created,10)"), + (SubtractWeeks(Field("created"), 11), "subtractWeeks(created,11)"), + (SubtractDays(Field("created"), 12), "subtractDays(created,12)"), + (SubtractHours(Field("created"), 13), "subtractHours(created,13)"), + (SubtractHours(Field("created"), 13), "subtractHours(created,13)"), + (SubtractMinutes(Field("created"), 14), "subtractMinutes(created,14)"), + (SubtractSeconds(Field("created"), 15), "subtractSeconds(created,15)"), + (SubtractQuarters(Field("created"), 16), "subtractQuarters(created,16)"), + ] + ) + def test_get_sql(self, func, expected): + self.assertEqual(func.get_sql(), expected) + + +class TestToYYYYMM(unittest.TestCase): + def test_get_sql(self): + self.assertEqual(ToYYYYMM(Field("created").get_sql()), "toYYYYMM(created)") diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/clickhouse/test_nullable_arg.py b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/clickhouse/test_nullable_arg.py new file mode 100644 index 0000000000000000000000000000000000000000..3c6c86207a4d0206b5c0ba80b77fac4cc257fa17 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/clickhouse/test_nullable_arg.py @@ -0,0 +1,24 @@ +import unittest + +from parameterized import parameterized + +from pypika import Field +from pypika.clickhouse.nullable_arg import IfNull +from pypika.clickhouse.type_conversion import ToFixedString + + +class TestSearchString(unittest.TestCase): + @parameterized.expand( + [ + ( + IfNull(Field("name"), Field("login")), + "ifNull(name,login)", + ), + ( + IfNull(Field("builder"), ToFixedString("pypika", 100)), + "ifNull(builder,toFixedString('pypika',100))", + ), + ] + ) + def test_get_sql(self, func, expected): + self.assertEqual(func.get_sql(), expected) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/clickhouse/test_search_string.py b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/clickhouse/test_search_string.py new file mode 100644 index 0000000000000000000000000000000000000000..9778eb32e47d4370c0bfe36dcd875903666d30b6 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/clickhouse/test_search_string.py @@ -0,0 +1,41 @@ +import unittest + +from parameterized import parameterized + +from pypika import Field +from pypika.clickhouse.search_string import ( + Match, + Like, + NotLike, + MultiSearchAny, + MultiMatchAny, +) + + +class TestSearchString(unittest.TestCase): + @parameterized.expand( + [ + (Match(Field("name"), "twheys"), "match(toString(\"name\"),'twheys')"), + (Like(Field("name"), "twheys"), "like(toString(\"name\"),'twheys')"), + (NotLike(Field("name"), "twheys"), "notLike(toString(\"name\"),'twheys')"), + ] + ) + def test_search_string(self, func, expected): + self.assertEqual(func, expected) + + +class TestMultiSearch(unittest.TestCase): + @parameterized.expand( + [ + ( + MultiSearchAny(Field("name"), ["sarah", "connor"]), + "multiSearchAny(toString(\"name\"),['sarah','connor'])", + ), + ( + MultiMatchAny(Field("name"), ["sarah", "connor"]), + "multiMatchAny(toString(\"name\"),['sarah','connor'])", + ), + ] + ) + def test_multi_search_string(self, func, expected): + self.assertEqual(func.get_sql(), expected) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/clickhouse/test_type_conversion.py b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/clickhouse/test_type_conversion.py new file mode 100644 index 0000000000000000000000000000000000000000..9692e17bee901e2629db9a5c77111e145358e8eb --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/clickhouse/test_type_conversion.py @@ -0,0 +1,176 @@ +import unittest + +from parameterized import parameterized + +from pypika import ClickHouseQuery, Field, Table +from pypika.clickhouse.type_conversion import ( + ToDate, + ToDateTime, + ToFixedString, + ToFloat32, + ToFloat64, + ToInt16, + ToInt32, + ToInt64, + ToInt8, + ToString, + ToUInt16, + ToUInt32, + ToUInt64, + ToUInt8, +) + + +class TestBasicTypeConverters(unittest.TestCase): + @parameterized.expand( + [ + ( + 'toString("field_name")', + ToString(Field("field_name")), + ), + ( + 'toInt8("field_name")', + ToInt8(Field("field_name")), + ), + ( + 'toInt16("field_name")', + ToInt16(Field("field_name")), + ), + ( + 'toInt32("field_name")', + ToInt32(Field("field_name")), + ), + ( + 'toInt64("field_name")', + ToInt64(Field("field_name")), + ), + ( + 'toUInt8("field_name")', + ToUInt8(Field("field_name")), + ), + ( + 'toUInt16("field_name")', + ToUInt16(Field("field_name")), + ), + ( + 'toUInt32("field_name")', + ToUInt32(Field("field_name")), + ), + ( + 'toUInt64("field_name")', + ToUInt64(Field("field_name")), + ), + ( + 'toFloat32("field_name")', + ToFloat32(Field("field_name")), + ), + ( + 'toFloat64("field_name")', + ToFloat64(Field("field_name")), + ), + ( + 'toFloat64("field_name")', + ToFloat64(Field("field_name")), + ), + ( + 'toDate("field_name")', + ToDate(Field("field_name")), + ), + ( + 'toDateTime("field_name")', + ToDateTime(Field("field_name")), + ), + ( + 'toFixedString("field_name",100)', + ToFixedString(Field("field_name"), 100), + ), + ] + ) + def test_basic_types_field(self, expected, func): + self.assertEqual(func, expected) + + @parameterized.expand( + [ + ( + "toString('100')", + ToString("100"), + ), + ( + "toInt8('100')", + ToInt8("100"), + ), + ( + "toInt16('100')", + ToInt16("100"), + ), + ( + "toInt32('100')", + ToInt32("100"), + ), + ( + "toInt64('100')", + ToInt64("100"), + ), + ( + "toUInt8('100')", + ToUInt8("100"), + ), + ( + "toUInt16('100')", + ToUInt16("100"), + ), + ( + "toUInt32('100')", + ToUInt32("100"), + ), + ( + "toUInt64('100')", + ToUInt64("100"), + ), + ( + "toFloat32('100')", + ToFloat32("100"), + ), + ( + "toFloat64('100')", + ToFloat64("100"), + ), + ( + "toFloat64('100')", + ToFloat64("100"), + ), + ( + "toDate('100')", + ToDate("100"), + ), + ( + "toDateTime('100')", + ToDateTime("100"), + ), + ( + "toFixedString('100',100)", + ToFixedString("100", 100), + ), + ] + ) + def test_basic_types_value(self, expected, func): + self.assertEqual(func, expected) + + +class TestToFixedString(unittest.TestCase): + def test_get_sql_with_table(self): + table = Table("example") + query = ( + ClickHouseQuery.from_(table) + .select( + table.name, + ) + .where( + table.name == ToFixedString("name", 50), + ) + ) + + self.assertEqual( + 'SELECT "name" FROM "example" WHERE "name"=toFixedString(\'name\',50)', + query.get_sql(), + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/dialects/__init__.py b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/dialects/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/dialects/test_clickhouse.py b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/dialects/test_clickhouse.py new file mode 100644 index 0000000000000000000000000000000000000000..f319c4627bd25d7004894181906a284b8b1c64cf --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/dialects/test_clickhouse.py @@ -0,0 +1,146 @@ +from unittest import TestCase + +from pypika import ( + ClickHouseQuery, + Database, + Table, +) + + +class ClickHouseQueryTests(TestCase): + def test_use_AS_keyword_for_alias(self): + t = Table('abc') + query = ClickHouseQuery.from_(t).select(t.foo.as_('f1'), t.bar.as_('f2')) + self.assertEqual(str(query), 'SELECT "foo" AS "f1","bar" AS "f2" FROM "abc"') + + def test_use_SAMPLE_keyword(self): + t = Table('abc') + query = ClickHouseQuery.from_(t).select(t.foo).sample(10) + self.assertEqual(str(query), 'SELECT "foo" FROM "abc" SAMPLE 10') + + def test_use_SAMPLE_with_offset_keyword(self): + t = Table('abc') + query = ClickHouseQuery.from_(t).select(t.foo).sample(10, 5) + self.assertEqual(str(query), 'SELECT "foo" FROM "abc" SAMPLE 10 OFFSET 5') + + def test_use_FINAL_keyword(self): + t = Table('abc') + query = ClickHouseQuery.from_(t).select(t.foo).final() + self.assertEqual(str(query), 'SELECT "foo" FROM "abc" FINAL') + + +class ClickHouseDeleteTests(TestCase): + table_abc = Table("abc") + + def test_omit_where(self): + q = ClickHouseQuery.from_("abc").delete() + + self.assertEqual('ALTER TABLE "abc" DELETE', str(q)) + + def test_omit_where__table_schema(self): + q = ClickHouseQuery.from_(Table("abc", "schema1")).delete() + + self.assertEqual('ALTER TABLE "schema1"."abc" DELETE', str(q)) + + def test_where_field_equals(self): + q1 = ClickHouseQuery.from_(self.table_abc).where(self.table_abc.foo == self.table_abc.bar).delete() + q2 = ClickHouseQuery.from_(self.table_abc).where(self.table_abc.foo.eq(self.table_abc.bar)).delete() + + self.assertEqual('ALTER TABLE "abc" DELETE WHERE "foo"="bar"', str(q1)) + self.assertEqual('ALTER TABLE "abc" DELETE WHERE "foo"="bar"', str(q2)) + + +class ClickHouseUpdateTests(TestCase): + table_abc = Table("abc") + + def test_update(self): + q = ClickHouseQuery.update(self.table_abc).where(self.table_abc.foo == 0).set("foo", "bar") + + self.assertEqual('ALTER TABLE "abc" UPDATE "foo"=\'bar\' WHERE "foo"=0', str(q)) + + +class ClickHouseDropQuery(TestCase): + table_abc = Table("abc") + database_xyz = Database("mydb") + cluster_name = "mycluster" + + def test_drop_database(self): + q1 = ClickHouseQuery.drop_database(self.database_xyz) + q2 = ClickHouseQuery.drop_database(self.database_xyz).on_cluster(self.cluster_name) + q3 = ClickHouseQuery.drop_database(self.database_xyz).if_exists().on_cluster(self.cluster_name) + + self.assertEqual('DROP DATABASE "mydb"', str(q1)) + self.assertEqual('DROP DATABASE "mydb" ON CLUSTER "mycluster"', str(q2)) + self.assertEqual('DROP DATABASE IF EXISTS "mydb" ON CLUSTER "mycluster"', str(q3)) + + def test_drop_table(self): + q1 = ClickHouseQuery.drop_table(self.table_abc) + q2 = ClickHouseQuery.drop_table(self.table_abc).on_cluster(self.cluster_name) + q3 = ClickHouseQuery.drop_table(self.table_abc).if_exists().on_cluster(self.cluster_name) + + self.assertEqual('DROP TABLE "abc"', str(q1)) + self.assertEqual('DROP TABLE "abc" ON CLUSTER "mycluster"', str(q2)) + self.assertEqual('DROP TABLE IF EXISTS "abc" ON CLUSTER "mycluster"', str(q3)) + + def test_drop_dictionary(self): + q1 = ClickHouseQuery.drop_dictionary("dict") + q2 = ClickHouseQuery.drop_dictionary("dict").on_cluster(self.cluster_name) + q3 = ClickHouseQuery.drop_dictionary("dict").if_exists().on_cluster(self.cluster_name) + + self.assertEqual('DROP DICTIONARY "dict"', str(q1)) + self.assertEqual('DROP DICTIONARY "dict"', str(q2)) # NO CLUSTER + self.assertEqual('DROP DICTIONARY IF EXISTS "dict"', str(q3)) # NO CLUSTER + + def test_drop_other(self): + q1 = ClickHouseQuery.drop_quota("myquota") + q2 = ClickHouseQuery.drop_user("myuser") + q3 = ClickHouseQuery.drop_view("myview") + + self.assertEqual('DROP QUOTA "myquota"', str(q1)) + self.assertEqual('DROP USER "myuser"', str(q2)) + self.assertEqual('DROP VIEW "myview"', str(q3)) + + +class DistinctOnTests(TestCase): + table_abc = Table("abc") + + def test_distinct_on(self): + q = ClickHouseQuery.from_(self.table_abc).distinct_on("lname", self.table_abc.fname).select("lname", "id") + + self.assertEqual('''SELECT DISTINCT ON("lname","fname") "lname","id" FROM "abc"''', str(q)) + + +class LimitByTests(TestCase): + table_abc = Table("abc") + + def test_limit_by(self): + q = ClickHouseQuery.from_(self.table_abc).limit_by(1, "a", self.table_abc.b).select("a", "b", "c") + + self.assertEqual('''SELECT "a","b","c" FROM "abc" LIMIT 1 BY ("a","b")''', str(q)) + + def test_limit_offset_by(self): + q = ClickHouseQuery.from_(self.table_abc).limit_offset_by(1, 2, "a", self.table_abc.b).select("a", "b", "c") + + self.assertEqual('''SELECT "a","b","c" FROM "abc" LIMIT 1 OFFSET 2 BY ("a","b")''', str(q)) + + def test_limit_offset0_by(self): + q = ClickHouseQuery.from_(self.table_abc).limit_offset_by(1, 0, "a", self.table_abc.b).select("a", "b", "c") + + self.assertEqual('''SELECT "a","b","c" FROM "abc" LIMIT 1 BY ("a","b")''', str(q)) + + def test_rename_table(self): + table_join = Table("join") + + q = ( + ClickHouseQuery.from_(self.table_abc) + .join(table_join) + .using("a") + .limit_by(1, self.table_abc.a, table_join.a) + .select(self.table_abc.b, table_join.b) + ) + q = q.replace_table(self.table_abc, Table("xyz")) + + self.assertEqual( + '''SELECT "xyz"."b","join"."b" FROM "xyz" JOIN "join" USING ("a") LIMIT 1 BY ("xyz"."a","join"."a")''', + str(q), + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/dialects/test_mssql.py b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/dialects/test_mssql.py new file mode 100644 index 0000000000000000000000000000000000000000..7cf53b228f413a8c7cd3e414fef5522a82f99b29 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/dialects/test_mssql.py @@ -0,0 +1,81 @@ +import unittest + +from pypika import Table +from pypika.analytics import Count +from pypika.dialects import MSSQLQuery +from pypika.utils import QueryException + + +class SelectTests(unittest.TestCase): + def test_normal_select(self): + q = MSSQLQuery.from_("abc").select("def") + + self.assertEqual('SELECT "def" FROM "abc"', str(q)) + + def test_distinct_select(self): + q = MSSQLQuery.from_("abc").select("def").distinct() + + self.assertEqual('SELECT DISTINCT "def" FROM "abc"', str(q)) + + def test_top_distinct_select(self): + q = MSSQLQuery.from_("abc").select("def").top(10).distinct() + + self.assertEqual('SELECT DISTINCT TOP (10) "def" FROM "abc"', str(q)) + + def test_top_select(self): + q = MSSQLQuery.from_("abc").select("def").top(10) + + self.assertEqual('SELECT TOP (10) "def" FROM "abc"', str(q)) + + def test_top_with_ties_select(self): + q = MSSQLQuery.from_("abc").select("def").top(10, with_ties=True) + + self.assertEqual('SELECT TOP (10) WITH TIES "def" FROM "abc"', str(q)) + + def test_top_percent_select(self): + q = MSSQLQuery.from_("abc").select("def").top(10, percent=True) + + self.assertEqual('SELECT TOP (10) PERCENT "def" FROM "abc"', str(q)) + + def test_top_percent_invalid_range(self): + for invalid_top in [-1, 101]: + with self.assertRaisesRegex( + QueryException, "TOP value must be between 0 and 100 when `percent` is specified" + ): + MSSQLQuery.from_("abc").select("def").top(invalid_top, percent=True) + + def test_top_select_non_int(self): + with self.assertRaisesRegex(QueryException, "TOP value must be an integer"): + MSSQLQuery.from_("abc").select("def").top("a") + + def test_limit(self): + q = MSSQLQuery.from_("abc").select("def").orderby("def").limit(10) + + self.assertEqual('SELECT "def" FROM "abc" ORDER BY "def" OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY', str(q)) + + def test_offset(self): + q = MSSQLQuery.from_("abc").select("def").orderby("def").offset(10) + + self.assertEqual('SELECT "def" FROM "abc" ORDER BY "def" OFFSET 10 ROWS', str(q)) + + def test_limit_with_offset(self): + q = MSSQLQuery.from_("abc").select("def").orderby("def").limit(10).offset(10) + + self.assertEqual('SELECT "def" FROM "abc" ORDER BY "def" OFFSET 10 ROWS FETCH NEXT 10 ROWS ONLY', str(q)) + + def test_groupby_alias_False_does_not_group_by_alias_with_standard_query(self): + t = Table('table1') + col = t.abc.as_('a') + q = MSSQLQuery.from_(t).select(col, Count('*')).groupby(col) + + self.assertEqual('SELECT "abc" "a",COUNT(\'*\') FROM "table1" GROUP BY "abc"', str(q)) + + def test_groupby_alias_False_does_not_group_by_alias_when_subqueries_are_present(self): + t = Table('table1') + subquery = MSSQLQuery.from_(t).select(t.abc) + col = subquery.abc.as_('a') + q = MSSQLQuery.from_(subquery).select(col, Count('*')).groupby(col) + + self.assertEqual( + 'SELECT "sq0"."abc" "a",COUNT(\'*\') FROM (SELECT "abc" FROM "table1") "sq0" GROUP BY "sq0"."abc"', str(q) + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/dialects/test_mysql.py b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/dialects/test_mysql.py new file mode 100644 index 0000000000000000000000000000000000000000..619d064adcdf8b5ff9ecd054fa4ab00eff1d69b3 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/dialects/test_mysql.py @@ -0,0 +1,91 @@ +import unittest + +from pypika import MySQLQuery, QueryException, Table, Column + + +class SelectTests(unittest.TestCase): + table_abc = Table("abc") + + def test_normal_select(self): + q = MySQLQuery.from_("abc").select("def") + + self.assertEqual("SELECT `def` FROM `abc`", str(q)) + + def test_distinct_select(self): + q = MySQLQuery.from_("abc").select("def").distinct() + + self.assertEqual("SELECT DISTINCT `def` FROM `abc`", str(q)) + + def test_modifier_select(self): + q = MySQLQuery.from_("abc").select("def").select("ghi").modifier("SQL_CALC_FOUND_ROWS") + + self.assertEqual("SELECT SQL_CALC_FOUND_ROWS `def`,`ghi` FROM `abc`", str(q)) + + def test_multiple_modifier_select(self): + q = MySQLQuery.from_("abc").select("def").modifier("HIGH_PRIORITY").modifier("SQL_CALC_FOUND_ROWS") + + self.assertEqual("SELECT HIGH_PRIORITY SQL_CALC_FOUND_ROWS `def` FROM `abc`", str(q)) + + +class UpdateTests(unittest.TestCase): + table_abc = Table("abc") + + def test_update(self): + q = MySQLQuery.into("abc").insert(1, [1, "a", True]) + + self.assertEqual("INSERT INTO `abc` VALUES (1,[1,'a',true])", str(q)) + + def test_on_duplicate_key_ignore_update(self): + q = MySQLQuery.into("abc").insert(1, [1, "a", True]).on_duplicate_key_ignore() + + self.assertEqual("INSERT INTO `abc` VALUES (1,[1,'a',true]) ON DUPLICATE KEY IGNORE", str(q)) + + def test_on_duplicate_key_update_update(self): + q = MySQLQuery.into("abc").insert(1, [1, "a", True]).on_duplicate_key_update(self.table_abc.a, 'b') + + self.assertEqual("INSERT INTO `abc` VALUES (1,[1,'a',true]) ON DUPLICATE KEY UPDATE `a`='b'", str(q)) + + def test_conflict_handlers_update(self): + with self.assertRaises(QueryException): + ( + MySQLQuery.into("abc") + .insert(1, [1, "a", True]) + .on_duplicate_key_ignore() + .on_duplicate_key_update(self.table_abc.a, 'b') + ) + + +class LoadCSVTests(unittest.TestCase): + table_abc = Table("abc") + + def test_load_from_file(self): + q1 = MySQLQuery.load("/path/to/file").into("abc") + + q2 = MySQLQuery.load("/path/to/file").into(self.table_abc) + + self.assertEqual( + "LOAD DATA LOCAL INFILE '/path/to/file' INTO TABLE `abc` FIELDS TERMINATED BY ','", + str(q1), + ) + self.assertEqual( + "LOAD DATA LOCAL INFILE '/path/to/file' INTO TABLE `abc` FIELDS TERMINATED BY ','", + str(q2), + ) + + +class TableTests(unittest.TestCase): + table_abc = Table("abc") + + def test_create_table(self): + q = MySQLQuery.create_table(self.table_abc).columns(Column("id", "INT")) + self.assertEqual( + 'CREATE TABLE `abc` (`id` INT)', + str(q), + ) + + def test_drop_table(self): + q = MySQLQuery.drop_table(self.table_abc) + self.assertEqual( + 'DROP TABLE `abc`', + str(q), + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/dialects/test_oracle.py b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/dialects/test_oracle.py new file mode 100644 index 0000000000000000000000000000000000000000..21b54f16fd5d3518b5c767d3605068637898a73f --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/dialects/test_oracle.py @@ -0,0 +1,51 @@ +import unittest + +from pypika import OracleQuery, Table +from pypika.analytics import Count + + +class SelectTests(unittest.TestCase): + def test_groupby_alias_False_does_not_group_by_alias_with_standard_query(self): + t = Table('table1') + col = t.abc.as_('a') + q = OracleQuery.from_(t).select(col, Count('*')).groupby(col) + + self.assertEqual('SELECT abc a,COUNT(\'*\') FROM table1 GROUP BY abc', str(q)) + + def test_groupby_alias_False_does_not_group_by_alias_when_subqueries_are_present(self): + t = Table('table1') + subquery = OracleQuery.from_(t).select(t.abc) + col = subquery.abc.as_('a') + q = OracleQuery.from_(subquery).select(col, Count('*')).groupby(col) + + self.assertEqual('SELECT sq0.abc a,COUNT(\'*\') FROM (SELECT abc FROM table1) sq0 GROUP BY sq0.abc', str(q)) + + def test_limit_query(self): + t = Table('table1') + limit = 5 + q = OracleQuery.from_(t).select(t.test).limit(limit) + + self.assertEqual(f'SELECT test FROM table1 FETCH NEXT {limit} ROWS ONLY', str(q)) + + def test_offset_query(self): + t = Table('table1') + offset = 5 + q = OracleQuery.from_(t).select(t.test).offset(offset) + + self.assertEqual(f'SELECT test FROM table1 OFFSET {offset} ROWS', str(q)) + + def test_limit_offset_query(self): + t = Table('table1') + limit = 5 + offset = 5 + q = OracleQuery.from_(t).select(t.test).limit(limit).offset(offset) + + self.assertEqual(f'SELECT test FROM table1 OFFSET {offset} ROWS FETCH NEXT {limit} ROWS ONLY', str(q)) + + def test_fetch_next_method_deprecated(self): + with self.assertWarns(DeprecationWarning): + t = Table('table1') + limit = 5 + q = OracleQuery.from_(t).select(t.test).fetch_next(limit) + + self.assertEqual(f'SELECT test FROM table1 FETCH NEXT {limit} ROWS ONLY', str(q)) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/dialects/test_postgresql.py b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/dialects/test_postgresql.py new file mode 100644 index 0000000000000000000000000000000000000000..437eed03e120485ed2a357a4c2d92426f1466e14 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/dialects/test_postgresql.py @@ -0,0 +1,262 @@ +import unittest +from collections import OrderedDict + +from pypika import ( + Array, + Field, + JSON, + QueryException, + Table, +) +from pypika.dialects import PostgreSQLQuery + + +class InsertTests(unittest.TestCase): + table_abc = Table("abc") + + def test_array_keyword(self): + q = PostgreSQLQuery.into(self.table_abc).insert(1, [1, "a", True]) + + self.assertEqual("INSERT INTO \"abc\" VALUES (1,ARRAY[1,'a',true])", str(q)) + + +class JSONObjectTests(unittest.TestCase): + def test_alias_set_correctly(self): + table = Table('jsonb_table') + q = PostgreSQLQuery.from_('abc').select(table.value.get_text_value('a').as_('name')) + + self.assertEqual('''SELECT "value"->>'a' "name" FROM "abc"''', str(q)) + + def test_json_value_from_dict(self): + q = PostgreSQLQuery.select(JSON({"a": "foo"})) + + self.assertEqual('SELECT \'{"a":"foo"}\'', str(q)) + + def test_json_value_from_array_num(self): + q = PostgreSQLQuery.select(JSON([1, 2, 3])) + + self.assertEqual("SELECT '[1,2,3]'", str(q)) + + def test_json_value_from_array_str(self): + q = PostgreSQLQuery.select(JSON(["a", "b", "c"])) + + self.assertEqual('SELECT \'["a","b","c"]\'', str(q)) + + def test_json_value_from_dict_recursive(self): + q = PostgreSQLQuery.select(JSON({"a": "z", "b": {"c": "foo"}, "d": 1})) + + # gotta split this one up to avoid the indeterminate order + sql = str(q) + start, end = 9, -2 + self.assertEqual("SELECT '{}'", sql[:start] + sql[end:]) + + members_set = set(sql[start:end].split(",")) + self.assertSetEqual({'"a":"z"', '"b":{"c":"foo"}', '"d":1'}, members_set) + + +class JSONOperatorsTests(unittest.TestCase): + # reference https://www.postgresql.org/docs/9.5/functions-json.html + table_abc = Table("abc") + + def test_get_json_value_by_key(self): + q = PostgreSQLQuery.from_(self.table_abc).select("*").where(self.table_abc.json.get_json_value("dates")) + + self.assertEqual('SELECT * FROM "abc" WHERE "json"->\'dates\'', str(q)) + + def test_get_json_value_by_index(self): + q = PostgreSQLQuery.from_(self.table_abc).select("*").where(self.table_abc.json.get_json_value(1)) + + self.assertEqual('SELECT * FROM "abc" WHERE "json"->1', str(q)) + + def test_get_text_value_by_key(self): + q = PostgreSQLQuery.from_(self.table_abc).select("*").where(self.table_abc.json.get_text_value("dates")) + + self.assertEqual('SELECT * FROM "abc" WHERE "json"->>\'dates\'', str(q)) + + def test_get_text_value_by_index(self): + q = PostgreSQLQuery.from_(self.table_abc).select("*").where(self.table_abc.json.get_text_value(1)) + + self.assertEqual('SELECT * FROM "abc" WHERE "json"->>1', str(q)) + + def test_get_path_json_value(self): + q = PostgreSQLQuery.from_(self.table_abc).select("*").where(self.table_abc.json.get_path_json_value("{a,b}")) + + self.assertEqual('SELECT * FROM "abc" WHERE "json"#>\'{a,b}\'', str(q)) + + def test_get_path_text_value(self): + q = PostgreSQLQuery.from_(self.table_abc).select("*").where(self.table_abc.json.get_path_text_value("{a,b}")) + + self.assertEqual('SELECT * FROM "abc" WHERE "json"#>>\'{a,b}\'', str(q)) + + +class JSONBOperatorsTests(unittest.TestCase): + # reference https://www.postgresql.org/docs/9.5/functions-json.html + table_abc = Table("abc") + + def test_json_contains_for_json(self): + q = PostgreSQLQuery.select(JSON({"a": 1, "b": 2}).contains({"a": 1})) + + # gotta split this one up to avoid the indeterminate order + sql = str(q) + start, end = 9, -13 + self.assertEqual("SELECT '{}'@>'{\"a\":1}'", sql[:start] + sql[end:]) + + members_set = set(sql[start:end].split(",")) + self.assertSetEqual({'"a":1', '"b":2'}, members_set) + + def test_json_contains_for_field(self): + q = ( + PostgreSQLQuery.from_(self.table_abc) + .select("*") + .where(self.table_abc.json.contains({"dates": "2018-07-10 - 2018-07-17"})) + ) + + self.assertEqual( + "SELECT * " 'FROM "abc" ' 'WHERE "json"@>\'{"dates":"2018-07-10 - 2018-07-17"}\'', + str(q), + ) + + def test_json_contained_by_using_str_arg(self): + q = ( + PostgreSQLQuery.from_(self.table_abc) + .select("*") + .where( + self.table_abc.json.contained_by( + OrderedDict( + [ + ("dates", "2018-07-10 - 2018-07-17"), + ("imported", "8"), + ] + ) + ) + ) + ) + self.assertEqual( + 'SELECT * FROM "abc" ' 'WHERE "json"<@\'{"dates":"2018-07-10 - 2018-07-17","imported":"8"}\'', + str(q), + ) + + def test_json_contained_by_using_list_arg(self): + q = ( + PostgreSQLQuery.from_(self.table_abc) + .select("*") + .where(self.table_abc.json.contained_by(["One", "Two", "Three"])) + ) + + self.assertEqual('SELECT * FROM "abc" WHERE "json"<@\'["One","Two","Three"]\'', str(q)) + + def test_json_contained_by_with_complex_criterion(self): + q = ( + PostgreSQLQuery.from_(self.table_abc) + .select("*") + .where(self.table_abc.json.contained_by(["One", "Two", "Three"]) & (self.table_abc.id == 26)) + ) + + self.assertEqual( + 'SELECT * FROM "abc" WHERE "json"<@\'["One","Two","Three"]\' AND "id"=26', + str(q), + ) + + def test_json_has_key(self): + q = PostgreSQLQuery.from_(self.table_abc).select("*").where(self.table_abc.json.has_key("dates")) + + self.assertEqual('SELECT * FROM "abc" WHERE "json"?\'dates\'', str(q)) + + def test_json_has_keys(self): + q = PostgreSQLQuery.from_(self.table_abc).select("*").where(self.table_abc.json.has_keys(["dates", "imported"])) + + self.assertEqual("SELECT * FROM \"abc\" WHERE \"json\"?&ARRAY['dates','imported']", str(q)) + + def test_json_has_any_keys(self): + q = ( + PostgreSQLQuery.from_(self.table_abc) + .select("*") + .where(self.table_abc.json.has_any_keys(["dates", "imported"])) + ) + + self.assertEqual("SELECT * FROM \"abc\" WHERE \"json\"?|ARRAY['dates','imported']", str(q)) + + def test_subnet_contains_inet(self): + q = ( + PostgreSQLQuery.from_(self.table_abc) + .select(self.table_abc.a.lshift(2)) + .where(self.table_abc.cidr >> "1.1.1.1") + ) + + self.assertEqual("SELECT \"a\"<<2 FROM \"abc\" WHERE \"cidr\">>'1.1.1.1'", str(q)) + + +class DistinctOnTests(unittest.TestCase): + table_abc = Table("abc") + + def test_distinct_on(self): + q = PostgreSQLQuery.from_(self.table_abc).distinct_on("lname", self.table_abc.fname).select("lname", "id") + + self.assertEqual('''SELECT DISTINCT ON("lname","fname") "lname","id" FROM "abc"''', str(q)) + + +class ArrayTests(unittest.TestCase): + def test_array_syntax(self): + tb = Table("tb") + q = PostgreSQLQuery.from_(tb).select(Array(1, "a", ["b", 2, 3])) + + self.assertEqual(str(q), "SELECT ARRAY[1,'a',ARRAY['b',2,3]] FROM \"tb\"") + + def test_render_alias_in_array_sql(self): + tb = Table("tb") + + q = PostgreSQLQuery.from_(tb).select(Array(tb.col).as_("different_name")) + self.assertEqual(str(q), 'SELECT ARRAY["col"] "different_name" FROM "tb"') + + +class ReturningClauseTests(unittest.TestCase): + @classmethod + def setUpClass(cls) -> None: + super().setUpClass() + cls.table_abc = Table('abc') + + def test_returning_from_missing_table_raises_queryexception(self): + field_from_diff_table = Field('xyz', table=Table('other')) + + with self.assertRaisesRegex(QueryException, "You can't return from other tables"): + ( + PostgreSQLQuery.from_(self.table_abc) + .where(self.table_abc.foo == self.table_abc.bar) + .delete() + .returning(field_from_diff_table) + ) + + def test_queryexception_if_returning_used_on_invalid_query(self): + with self.assertRaisesRegex(QueryException, "Returning can't be used in this query"): + PostgreSQLQuery.from_(self.table_abc).select('abc').returning('abc') + + def test_no_queryexception_if_returning_used_on_valid_query_type(self): + # No exceptions for insert, update and delete queries + with self.subTest('DELETE'): + PostgreSQLQuery.from_(self.table_abc).where(self.table_abc.foo == self.table_abc.bar).delete().returning( + "id" + ) + with self.subTest('UPDATE'): + PostgreSQLQuery.update(self.table_abc).where(self.table_abc.foo == 0).set("foo", "bar").returning("id") + with self.subTest('INSERT'): + PostgreSQLQuery.into(self.table_abc).insert('abc').returning('abc') + + def test_return_field_from_join_table(self): + new_table = Table('xyz') + q = ( + PostgreSQLQuery.update(self.table_abc) + .join(new_table) + .on(new_table.id == self.table_abc.xyz) + .where(self.table_abc.foo == 0) + .set("foo", "bar") + .returning(new_table.a) + ) + + self.assertEqual( + 'UPDATE "abc" ' + 'JOIN "xyz" ON "xyz"."id"="abc"."xyz" ' + 'SET "foo"=\'bar\' ' + 'WHERE "abc"."foo"=0 ' + 'RETURNING "xyz"."a"', + str(q), + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/dialects/test_snowflake.py b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/dialects/test_snowflake.py new file mode 100644 index 0000000000000000000000000000000000000000..5ac08b2d8b8b5496ed6f3510acf4be1ec7893405 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/dialects/test_snowflake.py @@ -0,0 +1,58 @@ +import unittest + +from pypika import ( + Tables, + functions as fn, + Column, +) +from pypika.dialects import SnowflakeQuery + + +class QuoteTests(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_use_double_quotes_on_alias_but_not_on_terms(self): + q = SnowflakeQuery.from_(self.table_abc).select(self.table_abc.a.as_("bar")) + + self.assertEqual('SELECT a "bar" FROM abc', q.get_sql(with_namespace=True)) + + def test_use_double_quotes_on_alias_but_not_on_terms_with_joins(self): + foo = self.table_abc.as_("foo") + bar = self.table_efg.as_("bar") + + q = SnowflakeQuery.from_(foo).join(bar).on(foo.fk == bar.id).select(foo.a, bar.b) + + self.assertEqual( + "SELECT foo.a,bar.b " 'FROM abc "foo" ' 'JOIN efg "bar" ' "ON foo.fk=bar.id", + q.get_sql(with_namespace=True), + ) + + def test_use_double_quotes_on_alias_but_not_on_terms(self): + idx = self.table_abc.index.as_("idx") + val = fn.Sum(self.table_abc.value).as_("val") + q = SnowflakeQuery.from_(self.table_abc).select(idx, val).groupby(idx).orderby(idx) + + self.assertEqual( + 'SELECT index "idx",SUM(value) "val" ' "FROM abc " 'GROUP BY "idx" ' 'ORDER BY "idx"', + q.get_sql(with_namespace=True), + ) + + def test_dont_use_double_quotes_on_joining_queries(self): + foo = self.table_abc + bar = self.table_efg + q1 = SnowflakeQuery.from_(foo).select(foo.b) + q2 = SnowflakeQuery.from_(bar).select(bar.b) + q = SnowflakeQuery.from_(q1).join(q2).on(q1.b == q2.b).select("*") + + self.assertEqual( + "SELECT * " 'FROM (SELECT b FROM abc) sq0 ' 'JOIN (SELECT b FROM efg) sq1 ' "ON sq0.b=sq1.b", + q.get_sql(), + ) + + def test_dont_use_double_quotes_on_create_queries(self): + q = SnowflakeQuery.create_table(self.table_abc).columns(Column("id", "INT")) + self.assertEqual("CREATE TABLE abc (id INT)", q.get_sql()) + + def test_dont_use_double_quotes_on_drop_queries(self): + q = SnowflakeQuery.drop_table(self.table_abc) + self.assertEqual("DROP TABLE abc", q.get_sql()) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/dialects/test_sqllite.py b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/dialects/test_sqllite.py new file mode 100644 index 0000000000000000000000000000000000000000..104a7235b6ea2d46fd365989f68c5d081eb20076 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/dialects/test_sqllite.py @@ -0,0 +1,35 @@ +import unittest + +from pypika import Table +from pypika.dialects import SQLLiteQuery + + +class SelectTests(unittest.TestCase): + table_abc = Table("abc") + + def test_bool_true_as_one(self): + q = SQLLiteQuery.from_("abc").select(True) + + self.assertEqual('SELECT 1 FROM "abc"', str(q)) + + def test_bool_false_as_zero(self): + q = SQLLiteQuery.from_("abc").select(False) + + self.assertEqual('SELECT 0 FROM "abc"', str(q)) + + +class ReplaceTests(unittest.TestCase): + def test_normal_replace(self): + query = SQLLiteQuery.into("abc").replace("v1", "v2", "v3") + expected_output = "REPLACE INTO \"abc\" VALUES ('v1','v2','v3')" + self.assertEqual(expected_output, str(query)) + + def test_replace_subquery(self): + query = SQLLiteQuery.into("abc").replace(SQLLiteQuery.from_("def").select("f1", "f2")) + expected_output = 'REPLACE INTO "abc" VALUES ((SELECT "f1","f2" FROM "def"))' + self.assertEqual(expected_output, str(query)) + + def test_insert_or_replace(self): + query = SQLLiteQuery.into("abc").insert_or_replace("v1", "v2", "v3") + expected_output = "INSERT OR REPLACE INTO \"abc\" VALUES ('v1','v2','v3')" + self.assertEqual(expected_output, str(query)) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/dialects/test_vertica.py b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/dialects/test_vertica.py new file mode 100644 index 0000000000000000000000000000000000000000..61985bfc244fcd663e7d8a904b4645901f3abdfc --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/dialects/test_vertica.py @@ -0,0 +1,93 @@ +import unittest + +from pypika import Columns, Table, Tables, VerticaQuery + + +class VerticaQueryTests(unittest.TestCase): + table_abc = Table("abc") + + def test_select_query_with_hint(self): + q = VerticaQuery.from_("abc").select("*").hint("test_hint") + + self.assertEqual('SELECT /*+label(test_hint)*/ * FROM "abc"', str(q)) + + def test_insert_query_with_hint(self): + query = VerticaQuery.into(self.table_abc).insert(1).hint("test_hint") + + self.assertEqual('INSERT /*+label(test_hint)*/ INTO "abc" VALUES (1)', str(query)) + + def test_update_query_with_hint(self): + q = VerticaQuery.update(self.table_abc).set("foo", "bar").hint("test_hint") + + self.assertEqual('UPDATE /*+label(test_hint)*/ "abc" SET "foo"=\'bar\'', str(q)) + + def test_delete_query_with_hint(self): + q = VerticaQuery.from_("abc").delete().hint("test_hint") + + self.assertEqual('DELETE /*+label(test_hint)*/ FROM "abc"', str(q)) + + +class CopyCSVTests(unittest.TestCase): + table_abc = Table("abc") + + def test_copy_from_file(self): + with self.subTest("with table as string"): + q = VerticaQuery.from_file("/path/to/file").copy_("abc") + + self.assertEqual( + "COPY \"abc\" FROM LOCAL '/path/to/file' PARSER fcsvparser(header=false)", + str(q), + ) + + with self.subTest("with table"): + q = VerticaQuery.from_file("/path/to/file").copy_(self.table_abc) + + self.assertEqual( + "COPY \"abc\" FROM LOCAL '/path/to/file' PARSER fcsvparser(header=false)", + str(q), + ) + + +class CreateTemporaryTableTests(unittest.TestCase): + new_table, existing_table = Tables("abc", "efg") + foo, bar = Columns(("a", "INT"), ("b", "VARCHAR(100)")) + select = VerticaQuery.from_(existing_table).select(existing_table.foo, existing_table.bar) + + def test_create_local_temporary_table(self): + with self.subTest("with columns"): + q = VerticaQuery.create_table(self.new_table).temporary().local().columns(self.foo, self.bar) + + self.assertEqual('CREATE LOCAL TEMPORARY TABLE "abc" ("a" INT,"b" VARCHAR(100))', str(q)) + + with self.subTest("with select"): + q = VerticaQuery.create_table(self.new_table).temporary().local().as_select(self.select) + + self.assertEqual( + 'CREATE LOCAL TEMPORARY TABLE "abc" AS (SELECT "foo","bar" FROM "efg")', + str(q), + ) + + def test_create_local_table_without_temporary_raises_error(self): + with self.assertRaises(AttributeError): + VerticaQuery.create_table(self.new_table).local() + + def test_create_temporary_table_preserve_rows(self): + with self.subTest("with columns"): + q = VerticaQuery.create_table(self.new_table).temporary().preserve_rows().columns(self.foo, self.bar) + + self.assertEqual( + 'CREATE TEMPORARY TABLE "abc" ("a" INT,"b" VARCHAR(100)) ON COMMIT PRESERVE ROWS', + str(q), + ) + + with self.subTest("with select"): + q = VerticaQuery.create_table(self.new_table).temporary().preserve_rows().as_select(self.select) + + self.assertEqual( + 'CREATE TEMPORARY TABLE "abc" ON COMMIT PRESERVE ROWS AS (SELECT "foo","bar" FROM "efg")', + str(q), + ) + + def test_create_table_preserve_rows_without_temporary_raises_error(self): + with self.assertRaises(AttributeError): + VerticaQuery.create_table(self.new_table).preserve_rows() diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/test_aggregate.py b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/test_aggregate.py new file mode 100644 index 0000000000000000000000000000000000000000..1c627d8e9c2d65410c67cf2c39974949b0720a0e --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/test_aggregate.py @@ -0,0 +1,122 @@ +import unittest + +from pypika import ( + Case, + Field, + Table, + functions as fn, +) +from pypika.terms import ( + Negative, + ValueWrapper, +) + + +class IsAggregateTests(unittest.TestCase): + def test__field_is_not_aggregate(self): + v = Field("foo") + self.assertFalse(v.is_aggregate) + + def test__constant_is_aggregate_none(self): + v = ValueWrapper(100) + self.assertIsNone(v.is_aggregate) + + def test__constant_arithmetic_is_aggregate_none(self): + v = ValueWrapper(100) + ValueWrapper(100) + self.assertIsNone(v.is_aggregate) + + def test__field_arithmetic_is_not_aggregate(self): + v = Field("foo") + Field("bar") + self.assertFalse(v.is_aggregate) + + def test__field_arithmetic_constant_is_not_aggregate(self): + v = Field("foo") + 1 + self.assertFalse(v.is_aggregate) + + def test__agg_func_is_aggregate(self): + v = fn.Sum(Field("foo")) + self.assertTrue(v.is_aggregate) + + def test__negative_agg_func_is_aggregate(self): + v = Negative(fn.Sum(Field("foo"))) + self.assertTrue(v.is_aggregate) + + def test__agg_func_arithmetic_is_aggregate(self): + v = fn.Sum(Field("foo")) / fn.Sum(Field("foo")) + self.assertTrue(v.is_aggregate) + + def test__mixed_func_arithmetic_is_not_aggregate(self): + v = Field("foo") / fn.Sum(Field("foo")) + self.assertFalse(v.is_aggregate) + + def test__func_arithmetic_constant_is_not_aggregate(self): + v = 1 / fn.Sum(Field("foo")) + self.assertTrue(v.is_aggregate) + + def test__agg_case_criterion_is_aggregate(self): + v = Case().when(fn.Sum(Field("foo")) > 666, 'More than 666').else_('Less than 666') + + self.assertTrue(v.is_aggregate) + + def test__agg_case_is_aggregate(self): + v = ( + Case() + .when(Field("foo") == 1, fn.Sum(Field("bar"))) + .when(Field("foo") == 2, fn.Sum(Field("fiz"))) + .else_(fn.Sum(Field("fiz"))) + ) + + self.assertTrue(v.is_aggregate) + + def test__mixed_case_is_not_aggregate(self): + v = Case().when(Field("foo") == 1, fn.Sum(Field("bar"))).when(Field("foo") == 2, Field("fiz")) + + self.assertFalse(v.is_aggregate) + + def test__case_mixed_else_is_not_aggregate(self): + v = ( + Case() + .when(Field("foo") == 1, fn.Sum(Field("bar"))) + .when(Field("foo") == 2, fn.Sum(Field("fiz"))) + .else_(Field("fiz")) + ) + + self.assertFalse(v.is_aggregate) + + def test__case_mixed_constant_is_not_aggregate(self): + v = Case().when(Field("foo") == 1, fn.Sum(Field("bar"))).when(Field("foo") == 2, fn.Sum(Field("fiz"))).else_(1) + + self.assertTrue(v.is_aggregate) + + def test__case_with_field_is_not_aggregate(self): + v = Case().when(Field("foo") == 1, 1).when(Field("foo") == 2, 2).else_(3) + + self.assertFalse(v.is_aggregate) + + def test__case_with_single_aggregate_field_in_one_criterion_is_aggregate(self): + v = Case().when(Field("foo") == 1, 1).when(fn.Sum(Field("foo")) == 2, 2).else_(3) + + self.assertTrue(v.is_aggregate) + + def test__non_aggregate_function_with_aggregated_arg(self): + t = Table("abc") + expr = fn.Sqrt(fn.Sum(t.a)) + + self.assertTrue(expr.is_aggregate) + + def test_complicated(self): + t = Table("abc") + is_placebo = t.campaign_extra_info == "placebo" + + pixel_mobile_search = Case().when(is_placebo, t.action_fb_pixel_search + t.action_fb_mobile_search) + unique_impressions = Case().when(is_placebo, t.unique_impressions) + + v = fn.Sum(pixel_mobile_search) / fn.Sum(unique_impressions) - 1.96 * fn.Sqrt( + 1 + / fn.Sum(unique_impressions) + * fn.Sum(pixel_mobile_search) + / fn.Sum(unique_impressions) + * (1 - fn.Sum(pixel_mobile_search) / fn.Sum(unique_impressions)) + ) + + self.assertTrue(v.is_aggregate) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/test_analytic_queries.py b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/test_analytic_queries.py new file mode 100644 index 0000000000000000000000000000000000000000..6a35ab854b30e3b0f91e633b3349706a22e0a2fd --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/test_analytic_queries.py @@ -0,0 +1,610 @@ +import unittest + +from pypika import Criterion, JoinType, Order, Query, Tables, analytics as an +from pypika.analytics import Lag, Lead + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + + +class RankTests(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_rank(self): + expr = an.Rank().over(self.table_abc.foo).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " "RANK() " 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_dense_rank(self): + expr = an.DenseRank().over(self.table_abc.foo).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " "DENSE_RANK() " 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_row_number(self): + expr = an.RowNumber().over(self.table_abc.foo).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " "ROW_NUMBER() " 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_rank_with_alias(self): + expr = an.Rank().over(self.table_abc.foo).orderby(self.table_abc.date).as_("rank") + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " "RANK() " 'OVER(PARTITION BY "foo" ORDER BY "date") "rank" ' 'FROM "abc"', + str(q), + ) + + def test_multiple_partitions(self): + expr = an.Rank().orderby(self.table_abc.date).over(self.table_abc.foo, self.table_abc.bar) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " "RANK() " 'OVER(PARTITION BY "foo","bar" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_ntile_no_partition_or_order_invalid_sql(self): + expr = an.NTile(5) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual("SELECT " "NTILE(5) " 'FROM "abc"', str(q)) + + def test_ntile_with_partition(self): + expr = an.NTile(5).over(self.table_abc.foo) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual("SELECT " "NTILE(5) " 'OVER(PARTITION BY "foo") ' 'FROM "abc"', str(q)) + + def test_ntile_with_order(self): + expr = an.NTile(5).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual("SELECT " "NTILE(5) " 'OVER(ORDER BY "date") ' 'FROM "abc"', str(q)) + + def test_ntile_with_partition_and_order(self): + expr = an.NTile(5).over(self.table_abc.foo).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " "NTILE(5) " 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_first_value(self): + expr = an.FirstValue(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'FIRST_VALUE("fizz") ' 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_first_value_ignore_nulls(self): + expr = an.FirstValue(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).ignore_nulls() + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'FIRST_VALUE("fizz" IGNORE NULLS) ' 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_first_value_ignore_nulls_first(self): + expr = an.FirstValue(self.table_abc.fizz).ignore_nulls().over(self.table_abc.foo).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'FIRST_VALUE("fizz" IGNORE NULLS) ' 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_first_value_multi_argument(self): + expr = ( + an.FirstValue(self.table_abc.fizz, self.table_abc.buzz) + .over(self.table_abc.foo) + .orderby(self.table_abc.date) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'FIRST_VALUE("fizz","buzz") ' 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_last_value(self): + expr = an.LastValue(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'LAST_VALUE("fizz") ' 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_filter(self): + expr = ( + an.LastValue(self.table_abc.fizz) + .filter(Criterion.all([self.table_abc.bar == True])) + .over(self.table_abc.foo) + .orderby(self.table_abc.date) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'LAST_VALUE("fizz") ' + 'FILTER(WHERE "bar"=true) ' + 'OVER(PARTITION BY "foo" ORDER BY "date") ' + 'FROM "abc"', + str(q), + ) + + def test_filter_quote_table_in_filter(self): + expr = ( + an.LastValue(self.table_efg.fizz) + .filter(self.table_efg.filed.eq('yes')) + .over(self.table_efg.foo) + .orderby(self.table_efg.date) + ) + + q = ( + Query.from_(self.table_abc) + .inner_join(self.table_efg) + .on(self.table_abc.id.eq(self.table_efg.id)) + .select(expr) + ) + + self.assertEqual( + 'SELECT ' + 'LAST_VALUE("efg"."fizz") ' + 'FILTER(WHERE "efg"."filed"=\'yes\') ' + 'OVER(PARTITION BY "efg"."foo" ORDER BY "efg"."date") ' + 'FROM "abc" ' + 'JOIN "efg" ON "abc"."id"="efg"."id"', + str(q), + ) + + def test_orderby_asc(self): + expr = an.LastValue(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date, order=Order.asc) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'LAST_VALUE("fizz") ' 'OVER(PARTITION BY "foo" ORDER BY "date" ASC) ' 'FROM "abc"', + str(q), + ) + + def test_orderby_desc(self): + expr = an.LastValue(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date, order=Order.desc) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'LAST_VALUE("fizz") ' 'OVER(PARTITION BY "foo" ORDER BY "date" DESC) ' 'FROM "abc"', + str(q), + ) + + def test_last_value_multi_argument(self): + expr = ( + an.LastValue(self.table_abc.fizz, self.table_abc.buzz).over(self.table_abc.foo).orderby(self.table_abc.date) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'LAST_VALUE("fizz","buzz") ' 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_last_value_ignore_nulls(self): + expr = an.LastValue(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).ignore_nulls() + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'LAST_VALUE("fizz" IGNORE NULLS) ' 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_median(self): + expr = an.Median(self.table_abc.fizz).over(self.table_abc.foo, self.table_abc.bar).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'MEDIAN("fizz") ' 'OVER(PARTITION BY "foo","bar" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_avg(self): + expr = an.Avg(self.table_abc.fizz).over(self.table_abc.foo, self.table_abc.bar).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'AVG("fizz") ' 'OVER(PARTITION BY "foo","bar" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_stddev(self): + expr = an.StdDev(self.table_abc.fizz).over(self.table_abc.foo, self.table_abc.bar).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'STDDEV("fizz") ' 'OVER(PARTITION BY "foo","bar" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_stddev_pop(self): + expr = ( + an.StdDevPop(self.table_abc.fizz).over(self.table_abc.foo, self.table_abc.bar).orderby(self.table_abc.date) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'STDDEV_POP("fizz") ' 'OVER(PARTITION BY "foo","bar" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_stddev_samp(self): + expr = ( + an.StdDevSamp(self.table_abc.fizz).over(self.table_abc.foo, self.table_abc.bar).orderby(self.table_abc.date) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'STDDEV_SAMP("fizz") ' 'OVER(PARTITION BY "foo","bar" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_variance(self): + expr = ( + an.Variance(self.table_abc.fizz).over(self.table_abc.foo, self.table_abc.bar).orderby(self.table_abc.date) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'VARIANCE("fizz") ' 'OVER(PARTITION BY "foo","bar" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_var_pop(self): + expr = an.VarPop(self.table_abc.fizz).over(self.table_abc.foo, self.table_abc.bar).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'VAR_POP("fizz") ' 'OVER(PARTITION BY "foo","bar" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_var_samp(self): + expr = an.VarSamp(self.table_abc.fizz).over(self.table_abc.foo, self.table_abc.bar).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'VAR_SAMP("fizz") ' 'OVER(PARTITION BY "foo","bar" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_table_prefixes_used_in_analytic_functions(self): + expr = an.Rank().over(self.table_abc.foo).orderby(self.table_efg.date) + + query = ( + Query.from_(self.table_abc) + .join(self.table_efg, how=JoinType.left) + .on(self.table_abc.foo == self.table_efg.bar) + .select("*", expr) + ) + + self.assertEqual( + 'SELECT *,RANK() OVER(PARTITION BY "abc"."foo" ORDER BY "efg"."date") ' + 'FROM "abc" LEFT JOIN "efg" ON "abc"."foo"="efg"."bar"', + str(query), + ) + + def test_sum_rows_unbounded_preceeding(self): + expr = an.Sum(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).rows(an.Preceding()) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'SUM("fizz") ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "ROWS UNBOUNDED PRECEDING" + ") " + 'FROM "abc"', + str(q), + ) + + def test_max_rows_x_preceeding(self): + expr = an.Max(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).rows(an.Preceding(5)) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'MAX("fizz") ' "OVER(" 'PARTITION BY "foo" ORDER BY "date" ' "ROWS 5 PRECEDING" ") " 'FROM "abc"', + str(q), + ) + + def test_min_rows_current_row(self): + expr = an.Min(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).rows(an.CURRENT_ROW) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'MIN("fizz") ' "OVER(" 'PARTITION BY "foo" ORDER BY "date" ' "ROWS CURRENT ROW" ") " 'FROM "abc"', + str(q), + ) + + def test_varpop_range_unbounded_preceeding(self): + expr = ( + an.VarPop(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).range(an.Preceding()) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'VAR_POP("fizz") ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "RANGE UNBOUNDED PRECEDING" + ") " + 'FROM "abc"', + str(q), + ) + + def test_max_range_x_preceeding(self): + expr = an.Max(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).range(an.Preceding(5)) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'MAX("fizz") ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "RANGE 5 PRECEDING" + ") " + 'FROM "abc"', + str(q), + ) + + def test_min_range_current_row(self): + expr = an.Min(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).range(an.CURRENT_ROW) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'MIN("fizz") ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "RANGE CURRENT ROW" + ") " + 'FROM "abc"', + str(q), + ) + + def test_variance_rows_between_unbounded_preceeding_unbounded_following(self): + expr = ( + an.Variance(self.table_abc.fizz) + .over(self.table_abc.foo) + .orderby(self.table_abc.date) + .rows(an.Preceding(), an.Following()) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'VARIANCE("fizz") ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING" + ") " + 'FROM "abc"', + str(q), + ) + + def test_first_value_range_between_x_preceeding_unbounded_following(self): + expr = ( + an.FirstValue(self.table_abc.fizz) + .over(self.table_abc.foo) + .orderby(self.table_abc.date) + .range(an.Preceding(3), an.Following()) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'FIRST_VALUE("fizz") ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "RANGE BETWEEN 3 PRECEDING AND UNBOUNDED FOLLOWING" + ") " + 'FROM "abc"', + str(q), + ) + + def test_varpop_rows_between_unbounded_preceeding_x_following(self): + expr = ( + an.VarPop(self.table_abc.fizz) + .over(self.table_abc.foo) + .orderby(self.table_abc.date) + .rows(an.Preceding(), an.Following(6)) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'VAR_POP("fizz") ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "ROWS BETWEEN UNBOUNDED PRECEDING AND 6 FOLLOWING" + ") " + 'FROM "abc"', + str(q), + ) + + def test_count_range_between_unbounded_preceeding_current_row(self): + expr = ( + an.Count(self.table_abc.fizz) + .over(self.table_abc.foo) + .orderby(self.table_abc.date) + .range(an.Preceding(), an.CURRENT_ROW) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'COUNT("fizz") ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW" + ") " + 'FROM "abc"', + str(q), + ) + + def test_last_value_rows_between_current_row_unbounded_following(self): + expr = ( + an.LastValue(self.table_abc.fizz) + .over(self.table_abc.foo) + .orderby(self.table_abc.date) + .rows(an.CURRENT_ROW, an.Following()) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'LAST_VALUE("fizz") ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING" + ") " + 'FROM "abc"', + str(q), + ) + + def test_last_value_rows_between_current_row_unbounded_following_ignore_nulls(self): + expr = ( + an.LastValue(self.table_abc.fizz) + .over(self.table_abc.foo) + .orderby(self.table_abc.date) + .ignore_nulls() + .rows(an.CURRENT_ROW, an.Following(8)) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'LAST_VALUE("fizz" IGNORE NULLS) ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "ROWS BETWEEN CURRENT ROW AND 8 FOLLOWING" + ") " + 'FROM "abc"', + str(q), + ) + + def test_empty_over(self): + query = Query.from_(self.table_abc).select(an.Sum(self.table_abc.fizz).over()) + + self.assertEqual("SELECT " 'SUM("fizz") OVER() ' 'FROM "abc"', str(query)) + + def test_rows_called_twice_raises_attribute_error(self): + with self.assertRaises(AttributeError): + an.Sum(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).rows(an.Preceding()).rows( + an.Preceding() + ) + + def test_range_called_twice_raises_attribute_error(self): + with self.assertRaises(AttributeError): + an.Sum(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).range( + an.Preceding() + ).range(an.Preceding()) + + def test_rows_then_range_raises_attribute_error(self): + with self.assertRaises(AttributeError): + an.Sum(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).rows( + an.Preceding() + ).range(an.Preceding()) + + def test_range_then_rows_raises_attribute_error(self): + with self.assertRaises(AttributeError): + an.Sum(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).range( + an.Preceding() + ).rows(an.Preceding()) + + def test_lag_generates_correct_sql(self): + with self.subTest('without partition by'): + q = Query.from_(self.table_abc).select( + Lag(self.table_abc.date, 1, '2000-01-01').orderby(self.table_abc.date) + ) + + self.assertEqual('SELECT LAG("date",1,\'2000-01-01\') OVER(ORDER BY "date") FROM "abc"', str(q)) + + with self.subTest('with partition by'): + q = Query.from_(self.table_abc).select( + Lag(self.table_abc.date, 1, '2000-01-01').over(self.table_abc.foo).orderby(self.table_abc.date) + ) + + self.assertEqual( + 'SELECT LAG("date",1,\'2000-01-01\') OVER(PARTITION BY "foo" ORDER BY "date") FROM "abc"', str(q) + ) + + def test_lead_generates_correct_sql(self): + with self.subTest('without partition by'): + q = Query.from_(self.table_abc).select( + Lead(self.table_abc.date, 1, '2000-01-01').orderby(self.table_abc.date) + ) + + self.assertEqual('SELECT LEAD("date",1,\'2000-01-01\') OVER(ORDER BY "date") FROM "abc"', str(q)) + + with self.subTest('with partition by'): + q = Query.from_(self.table_abc).select( + Lead(self.table_abc.date, 1, '2000-01-01').over(self.table_abc.foo).orderby(self.table_abc.date) + ) + + self.assertEqual( + 'SELECT LEAD("date",1,\'2000-01-01\') OVER(PARTITION BY "foo" ORDER BY "date") FROM "abc"', str(q) + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/test_create.py b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/test_create.py new file mode 100644 index 0000000000000000000000000000000000000000..325076544e3824b0d07f82f2378b88218b910dde --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/test_create.py @@ -0,0 +1,210 @@ +import unittest + +from pypika import Column, Columns, Query, Tables, Table +from pypika.terms import ValueWrapper, Index +from pypika.enums import ReferenceOption + + +class CreateTableTests(unittest.TestCase): + new_table, existing_table = Tables("abc", "efg") + foo, bar = Columns(("a", "INT"), ("b", "VARCHAR(100)")) + + def test_create_table_with_columns(self): + with self.subTest("with nullable"): + a = Column("a", "INT", True) + b = Column("b", "VARCHAR(100)", False) + q = Query.create_table(self.new_table).columns(a, b) + + self.assertEqual('CREATE TABLE "abc" ("a" INT NULL,"b" VARCHAR(100) NOT NULL)', str(q)) + + with self.subTest("with defaults"): + a = Column("a", "INT", default=ValueWrapper(42)) + b = Column("b", "VARCHAR(100)", default=ValueWrapper("foo")) + q = Query.create_table(self.new_table).columns(a, b) + + self.assertEqual('CREATE TABLE "abc" ("a" INT DEFAULT 42,"b" VARCHAR(100) DEFAULT \'foo\')', str(q)) + + with self.subTest("with unwrapped defaults"): + a = Column("a", "INT", default=42) + b = Column("b", "VARCHAR(100)", default="foo") + q = Query.create_table(self.new_table).columns(a, b) + + self.assertEqual('CREATE TABLE "abc" ("a" INT DEFAULT 42,"b" VARCHAR(100) DEFAULT \'foo\')', str(q)) + + with self.subTest("with period for"): + a = Column("id", "INT") + b = Column("valid_from", "DATETIME") + c = Column("valid_to", "DATETIME") + q = Query.create_table(self.new_table).columns(a, b, c).period_for('valid_period', b, c) + + self.assertEqual( + 'CREATE TABLE "abc" (' + '"id" INT,' + '"valid_from" DATETIME,' + '"valid_to" DATETIME,' + 'PERIOD FOR "valid_period" ("valid_from","valid_to"))', + str(q), + ) + + with self.subTest("without temporary keyword"): + q = Query.create_table(self.new_table).columns(self.foo, self.bar) + + self.assertEqual('CREATE TABLE "abc" ("a" INT,"b" VARCHAR(100))', str(q)) + + with self.subTest("with temporary keyword"): + q = Query.create_table(self.new_table).temporary().columns(self.foo, self.bar) + + self.assertEqual('CREATE TEMPORARY TABLE "abc" ("a" INT,"b" VARCHAR(100))', str(q)) + + with self.subTest("with primary key"): + q = Query.create_table(self.new_table).columns(self.foo, self.bar).primary_key(self.foo, self.bar) + + self.assertEqual('CREATE TABLE "abc" ("a" INT,"b" VARCHAR(100),PRIMARY KEY ("a","b"))', str(q)) + + with self.subTest("with simple foreign key"): + cref, dref = Columns(("c", "INT"), ("d", "VARCHAR(100)")) + q = ( + Query.create_table(self.new_table) + .columns(self.foo, self.bar) + .foreign_key([self.foo, self.bar], self.existing_table, [cref, dref]) + ) + + self.assertEqual( + 'CREATE TABLE "abc" (' + '"a" INT,' + '"b" VARCHAR(100),' + 'FOREIGN KEY ("a","b") REFERENCES "efg" ("c","d"))', + str(q), + ) + + with self.subTest("with foreign key reference options"): + cref, dref = Columns(("c", "INT"), ("d", "VARCHAR(100)")) + q = ( + Query.create_table(self.new_table) + .columns(self.foo, self.bar) + .foreign_key( + [self.foo, self.bar], + self.existing_table, + [cref, dref], + on_delete=ReferenceOption.cascade, + on_update=ReferenceOption.restrict, + ) + ) + + self.assertEqual( + 'CREATE TABLE "abc" (' + '"a" INT,' + '"b" VARCHAR(100),' + 'FOREIGN KEY ("a","b") REFERENCES "efg" ("c","d") ON DELETE CASCADE ON UPDATE RESTRICT)', + str(q), + ) + + with self.subTest("with unique keys"): + q = ( + Query.create_table(self.new_table) + .columns(self.foo, self.bar) + .unique(self.foo, self.bar) + .unique(self.foo) + ) + + self.assertEqual('CREATE TABLE "abc" ("a" INT,"b" VARCHAR(100),UNIQUE ("a","b"),UNIQUE ("a"))', str(q)) + + with self.subTest("with system versioning"): + q = Query.create_table(self.new_table).columns(self.foo, self.bar).with_system_versioning() + + self.assertEqual('CREATE TABLE "abc" ("a" INT,"b" VARCHAR(100)) WITH SYSTEM VERSIONING', str(q)) + + with self.subTest("with unlogged keyword"): + q = Query.create_table(self.new_table).unlogged().columns(self.foo, self.bar) + + self.assertEqual('CREATE UNLOGGED TABLE "abc" ("a" INT,"b" VARCHAR(100))', str(q)) + + with self.subTest("with if not exists keyword"): + q = Query.create_table(self.new_table).if_not_exists().columns(self.foo, self.bar) + + self.assertEqual('CREATE TABLE IF NOT EXISTS "abc" ("a" INT,"b" VARCHAR(100))', str(q)) + + def test_create_table_with_select(self): + select = Query.from_(self.existing_table).select(self.existing_table.foo, self.existing_table.bar) + + with self.subTest("without temporary keyword"): + q = Query.create_table(self.new_table).as_select(select) + + self.assertEqual('CREATE TABLE "abc" AS (SELECT "foo","bar" FROM "efg")', str(q)) + + with self.subTest("with temporary keyword"): + q = Query.create_table(self.new_table).temporary().as_select(select) + + self.assertEqual( + 'CREATE TEMPORARY TABLE "abc" AS (SELECT "foo","bar" FROM "efg")', + str(q), + ) + + def test_create_table_without_columns_or_select_empty(self): + q = Query.create_table(self.new_table) + + self.assertEqual("", str(q)) + + def test_create_table_with_select_and_columns_fails(self): + select = Query.from_(self.existing_table).select(self.existing_table.foo, self.existing_table.bar) + + with self.subTest("for columns before as_select"): + with self.assertRaises(AttributeError): + Query.create_table(self.new_table).columns(self.foo, self.bar).as_select(select) + + with self.subTest("for as_select before columns"): + with self.assertRaises(AttributeError): + Query.create_table(self.new_table).as_select(select).columns(self.foo, self.bar) + + with self.subTest("repeated foreign key"): + with self.assertRaises(AttributeError): + Query.create_table(self.new_table).foreign_key([self.foo], self.existing_table, [self.bar]).foreign_key( + [self.foo], self.existing_table, [self.bar] + ) + + def test_create_table_as_select_not_query_raises_error(self): + with self.assertRaises(TypeError): + Query.create_table(self.new_table).as_select("abc") + + +class CreateIndexTests(unittest.TestCase): + new_index = Index("abc") + new_table = Table("my_table") + columns = (new_table.a, new_table.b) + where = new_table.a > 1 + + def test_create_index_simple(self) -> None: + q = Query.create_index(self.new_index).on(self.new_table).columns(*self.columns) + self.assertEqual( + f'CREATE INDEX "{self.new_index.name}" ON "{self.new_table.get_table_name()}"({", ".join([c.name for c in self.columns])})', + q.get_sql(), + ) + + def test_create_index_where(self) -> None: + q = Query.create_index(self.new_index).on(self.new_table).columns(*self.columns).where(self.where) + self.assertEqual( + f'CREATE INDEX "{self.new_index.name}" ON "{self.new_table.get_table_name()}"({", ".join([c.name for c in self.columns])}) WHERE {self.where.get_sql()}', + q.get_sql(), + ) + + def test_create_index_unique(self) -> None: + q = Query.create_index(self.new_index).on(self.new_table).columns(*self.columns).unique() + self.assertEqual( + f'CREATE UNIQUE INDEX "{self.new_index.name}" ON "{self.new_table.get_table_name()}"({", ".join([c.name for c in self.columns])})', + q.get_sql(), + ) + + def test_create_index_if_not_exists(self) -> None: + q = Query.create_index(self.new_index).on(self.new_table).columns(*self.columns).if_not_exists() + self.assertEqual( + f'CREATE INDEX IF NOT EXISTS "{self.new_index.name}" ON "{self.new_table.get_table_name()}"({", ".join([c.name for c in self.columns])})', + q.get_sql(), + ) + + def test_create_index_without_columns_raises_error(self) -> None: + with self.assertRaises(AttributeError): + Query.create_index(self.new_index).on(self.new_table).get_sql() + + def test_create_index_without_table_raises_error(self) -> None: + with self.assertRaises(AttributeError): + Query.create_index(self.new_index).columns(*self.columns).get_sql() diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/test_criterions.py b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/test_criterions.py new file mode 100644 index 0000000000000000000000000000000000000000..fca2ceeeb18db88e34ebc38776f644fdcda67e93 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/test_criterions.py @@ -0,0 +1,873 @@ +import unittest +from datetime import ( + date, + datetime, +) + +from pypika import ( + Criterion, + EmptyCriterion, + Field, + Table, + functions as fn, +) +from pypika.queries import QueryBuilder +from pypika.terms import ExistsCriterion, Mod + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + + +class CriterionTests(unittest.TestCase): + t = Table("test", alias="crit") + + def test__criterion_with_alias(self): + c1 = (Field("foo") == Field("bar")).as_("criterion") + + self.assertEqual('"foo"="bar"', str(c1)) + self.assertEqual('"foo"="bar" "criterion"', c1.get_sql(with_alias=True, quote_char='"', alias_quote_char='"')) + + def test__criterion_eq_number(self): + c1 = Field("foo") == 1 + c2 = Field("foo", table=self.t).eq(0) + c3 = Field("foo", table=self.t) == -1 + + self.assertEqual('"foo"=1', str(c1)) + self.assertEqual('"crit"."foo"=0', str(c2)) + self.assertEqual('"crit"."foo"=-1', str(c3)) + + def test__criterion_eq_decimal(self): + c1 = Field("foo") == 1.0 + c2 = Field("foo", table=self.t).eq(0.5) + + self.assertEqual('"foo"=1.0', str(c1)) + self.assertEqual('"crit"."foo"=0.5', str(c2)) + + def test__criterion_eq_bool(self): + c1 = Field("foo") == True + c2 = Field("foo", table=self.t).eq(True) + c3 = Field("foo") == False + c4 = Field("foo", table=self.t).eq(False) + + self.assertEqual('"foo"=true', str(c1)) + self.assertEqual('"crit"."foo"=true', str(c2)) + self.assertEqual('"foo"=false', str(c3)) + self.assertEqual('"crit"."foo"=false', str(c4)) + + def test__criterion_eq_str(self): + c1 = Field("foo") == "abc" + c2 = Field("foo", table=self.t).eq("abc") + + self.assertEqual("\"foo\"='abc'", str(c1)) + self.assertEqual('"crit"."foo"=\'abc\'', str(c2)) + + def test__criterion_eq_date(self): + c1 = Field("foo") == date(2000, 1, 1) + c2 = Field("foo", table=self.t).eq(date(2000, 1, 1)) + + self.assertEqual("\"foo\"='2000-01-01'", str(c1)) + self.assertEqual('"crit"."foo"=\'2000-01-01\'', str(c2)) + + def test__criterion_eq_datetime(self): + c1 = Field("foo") == datetime(2000, 1, 1, 12, 30, 55) + c2 = Field("foo", table=self.t).eq(datetime(2000, 1, 1, 12, 30, 55)) + + self.assertEqual("\"foo\"='2000-01-01T12:30:55'", str(c1)) + self.assertEqual('"crit"."foo"=\'2000-01-01T12:30:55\'', str(c2)) + + def test__criterion_eq_right(self): + c1 = 1 == Field("foo") + c2 = -1 == Field("foo", table=self.t) + + self.assertEqual('"foo"=1', str(c1)) + self.assertEqual('"crit"."foo"=-1', str(c2)) + + def test__criterion_is_null(self): + c1 = Field("foo").isnull() + c2 = Field("foo", table=self.t).isnull() + + self.assertEqual('"foo" IS NULL', str(c1)) + self.assertEqual('"crit"."foo" IS NULL', str(c2)) + + def test__criterion_is_null_with_alias(self): + c1 = Field("foo").isnull().as_('alias') + c2 = Field("foo", table=self.t).isnull().as_('alias') + + self.assertEqual('"foo" IS NULL "alias"', str(c1)) + self.assertEqual('"crit"."foo" IS NULL "alias"', str(c2)) + + def test__criterion_ne_number(self): + c1 = Field("foo") != 1 + c2 = Field("foo", table=self.t).ne(0) + c3 = Field("foo") != -1 + + self.assertEqual('"foo"<>1', str(c1)) + self.assertEqual('"crit"."foo"<>0', str(c2)) + self.assertEqual('"foo"<>-1', str(c3)) + + def test__criterion_ne_str(self): + c1 = Field("foo") != "abc" + c2 = Field("foo", table=self.t).ne("abc") + + self.assertEqual("\"foo\"<>'abc'", str(c1)) + self.assertEqual('"crit"."foo"<>\'abc\'', str(c2)) + + def test__criterion_ne_date(self): + c1 = Field("foo") != date(2000, 1, 1) + c2 = Field("foo", table=self.t).ne(date(2000, 1, 1)) + + self.assertEqual("\"foo\"<>'2000-01-01'", str(c1)) + self.assertEqual('"crit"."foo"<>\'2000-01-01\'', str(c2)) + + def test__criterion_ne_datetime(self): + c1 = Field("foo") != datetime(2000, 1, 1, 12, 30, 55) + c2 = Field("foo", table=self.t).ne(datetime(2000, 1, 1, 12, 30, 55)) + + self.assertEqual("\"foo\"<>'2000-01-01T12:30:55'", str(c1)) + self.assertEqual('"crit"."foo"<>\'2000-01-01T12:30:55\'', str(c2)) + + def test__criterion_ne_right(self): + c1 = 1 != Field("foo") + c2 = -1 != Field("foo", table=self.t) + + self.assertEqual('"foo"<>1', str(c1)) + self.assertEqual('"crit"."foo"<>-1', str(c2)) + + def test__criterion_lt_number(self): + c1 = Field("foo") < 1 + c2 = Field("foo", table=self.t).lt(0) + c3 = Field("foo") < -1 + + self.assertEqual('"foo"<1', str(c1)) + self.assertEqual('"crit"."foo"<0', str(c2)) + self.assertEqual('"foo"<-1', str(c3)) + + def test__criterion_lt_date(self): + c1 = Field("foo") < date(2000, 1, 1) + c2 = Field("foo", table=self.t).lt(date(2000, 1, 1)) + + self.assertEqual("\"foo\"<'2000-01-01'", str(c1)) + self.assertEqual('"crit"."foo"<\'2000-01-01\'', str(c2)) + + def test__criterion_lt_datetime(self): + c1 = Field("foo") < datetime(2000, 1, 1, 12, 30, 55) + c2 = Field("foo", table=self.t).lt(datetime(2000, 1, 1, 12, 30, 55)) + + self.assertEqual("\"foo\"<'2000-01-01T12:30:55'", str(c1)) + self.assertEqual('"crit"."foo"<\'2000-01-01T12:30:55\'', str(c2)) + + def test__criterion_lt_right(self): + c1 = 1 > Field("foo") + c2 = -1 > Field("foo", table=self.t) + + self.assertEqual('"foo"<1', str(c1)) + self.assertEqual('"crit"."foo"<-1', str(c2)) + + def test__criterion_gt_number(self): + c1 = Field("foo") > 1 + c2 = Field("foo", table=self.t).gt(0) + c3 = Field("foo") > -1 + + self.assertEqual('"foo">1', str(c1)) + self.assertEqual('"crit"."foo">0', str(c2)) + self.assertEqual('"foo">-1', str(c3)) + + def test__criterion_gt_date(self): + c1 = Field("foo") > date(2000, 1, 1) + c2 = Field("foo", table=self.t).gt(date(2000, 1, 1)) + + self.assertEqual("\"foo\">'2000-01-01'", str(c1)) + self.assertEqual('"crit"."foo">\'2000-01-01\'', str(c2)) + + def test__criterion_gt_datetime(self): + c1 = Field("foo") > datetime(2000, 1, 1, 12, 30, 55) + c2 = Field("foo", table=self.t).gt(datetime(2000, 1, 1, 12, 30, 55)) + + self.assertEqual("\"foo\">'2000-01-01T12:30:55'", str(c1)) + self.assertEqual('"crit"."foo">\'2000-01-01T12:30:55\'', str(c2)) + + def test__criterion_gt_right(self): + c1 = 1 < Field("foo") + c2 = -1 < Field("foo", table=self.t) + + self.assertEqual('"foo">1', str(c1)) + self.assertEqual('"crit"."foo">-1', str(c2)) + + def test__criterion_lte_number(self): + c1 = Field("foo") <= 1 + c2 = Field("foo", table=self.t).lte(0) + c3 = Field("foo") <= -1 + + self.assertEqual('"foo"<=1', str(c1)) + self.assertEqual('"crit"."foo"<=0', str(c2)) + self.assertEqual('"foo"<=-1', str(c3)) + + def test__criterion_lte_date(self): + c1 = Field("foo") <= date(2000, 1, 1) + c2 = Field("foo", table=self.t).lte(date(2000, 1, 1)) + + self.assertEqual("\"foo\"<='2000-01-01'", str(c1)) + self.assertEqual('"crit"."foo"<=\'2000-01-01\'', str(c2)) + + def test__criterion_lte_datetime(self): + c1 = Field("foo") <= datetime(2000, 1, 1, 12, 30, 55) + c2 = Field("foo", table=self.t).lte(datetime(2000, 1, 1, 12, 30, 55)) + + self.assertEqual("\"foo\"<='2000-01-01T12:30:55'", str(c1)) + self.assertEqual('"crit"."foo"<=\'2000-01-01T12:30:55\'', str(c2)) + + def test__criterion_lte_right(self): + c1 = 1 >= Field("foo") + c2 = -1 >= Field("foo", table=self.t) + + self.assertEqual('"foo"<=1', str(c1)) + self.assertEqual('"crit"."foo"<=-1', str(c2)) + + def test__criterion_gte_number(self): + c1 = Field("foo") >= 1 + c2 = Field("foo", table=self.t).gte(0) + c3 = Field("foo") >= -1 + + self.assertEqual('"foo">=1', str(c1)) + self.assertEqual('"crit"."foo">=0', str(c2)) + self.assertEqual('"foo">=-1', str(c3)) + + def test__criterion_gte_date(self): + c1 = Field("foo") >= date(2000, 1, 1) + c2 = Field("foo", table=self.t).gte(date(2000, 1, 1)) + + self.assertEqual("\"foo\">='2000-01-01'", str(c1)) + self.assertEqual('"crit"."foo">=\'2000-01-01\'', str(c2)) + + def test__criterion_gte_datetime(self): + c1 = Field("foo") >= datetime(2000, 1, 1, 12, 30, 55) + c2 = Field("foo", table=self.t).gte(datetime(2000, 1, 1, 12, 30, 55)) + + self.assertEqual("\"foo\">='2000-01-01T12:30:55'", str(c1)) + self.assertEqual('"crit"."foo">=\'2000-01-01T12:30:55\'', str(c2)) + + def test__criterion_gte_right(self): + c1 = 1 <= Field("foo") + c2 = -1 <= Field("foo", table=self.t) + + self.assertEqual('"foo">=1', str(c1)) + self.assertEqual('"crit"."foo">=-1', str(c2)) + + def test__criterion_bitwise_and(self): + c1 = Field("foo").bitwiseand(2) + c2 = Field("foo", table=self.t).bitwiseand(10) == 2 + + self.assertEqual('("foo" & 2)', str(c1)) + self.assertEqual('("crit"."foo" & 10)=2', str(c2)) + + def test__criterion_bitwise_and_with_alias(self): + c1 = Field("foo").bitwiseand(2).as_('alias') + + self.assertEqual('("foo" & 2) "alias"', str(c1)) + + def test__bitwise_and_in_where_clause(self): + q = QueryBuilder().from_('items').select('abc').where(Field("foo").bitwiseand(1) == 1) + + self.assertEqual('SELECT "abc" FROM "items" WHERE ("foo" & 1)=1', str(q)) + + +class NotTests(unittest.TestCase): + table_abc, table_efg = Table("abc", alias="cx0"), Table("efg", alias="cx1") + + def test_negate(self): + c1 = Field("foo") >= 1 + c2 = c1.negate() + + self.assertEqual('"foo">=1', str(c1)) + self.assertEqual('NOT "foo">=1', str(c2)) + + def test_variable_access(self): + c1 = Field("foo").negate() + + self.assertEqual(c1.is_aggregate, False) + + def test_chained_function(self): + field1 = Field("foo").negate() + field2 = field1.eq("bar") + + self.assertEqual('NOT "foo"', str(field1)) + self.assertEqual("NOT \"foo\"='bar'", str(field2)) + self.assertIsNot(field1, field2) + + def test_not_null(self): + c1 = Field("foo").notnull() + c2 = Field("foo", table=self.table_abc).notnull() + + self.assertEqual('NOT "foo" IS NULL', str(c1)) + self.assertEqual('NOT "cx0"."foo" IS NULL', str(c2)) + + def test_is_not_null(self): + c1 = Field("foo").isnotnull() + c2 = Field("foo", table=self.table_abc).isnotnull() + + self.assertEqual('"foo" IS NOT NULL', str(c1)) + self.assertEqual('"cx0"."foo" IS NOT NULL', str(c2)) + + def test_not_null_with_alias(self): + c1 = Field("foo").notnull().as_("something") + c2 = Field("foo", table=self.table_abc).notnull().as_("something") + + self.assertEqual('NOT "foo" IS NULL "something"', str(c1)) + self.assertEqual('NOT "cx0"."foo" IS NULL "something"', str(c2)) + + def test_notnullcriterion_replace_table(self): + f = self.table_abc.foo.notnull().replace_table(self.table_abc, self.table_efg) + + self.assertEqual('NOT "cx1"."foo" IS NULL', str(f)) + + def test_not_with_or_criterion(self): + self.assertEqual('NOT ("foo" OR "bar")', str(~(Field("foo") | Field("bar")))) + + def test_not_with_and_criterion(self): + self.assertEqual('NOT ("foo" AND "bar")', str(~(Field("foo") & Field("bar")))) + + def test_not_with_complex_criterion(self): + self.assertEqual( + 'NOT ("foo" AND "bar" AND "fizz" AND "buzz")', + str(~(Field("foo") & Field("bar") & Field("fizz") & Field("buzz"))), + ) + + +class BetweenTests(unittest.TestCase): + t = Table("abc", alias="btw") + + def test__between_number(self): + c1 = Field("foo").between(0, 1) + c2 = Field("foo", table=self.t).between(0, 1) + c3 = Field("foo")[0:1] + + self.assertEqual('"foo" BETWEEN 0 AND 1', str(c1)) + self.assertEqual('"btw"."foo" BETWEEN 0 AND 1', str(c2)) + self.assertEqual('"foo" BETWEEN 0 AND 1', str(c3)) + + def test__between_with_alias(self): + c1 = Field("foo").between(0, 1).as_('alias') + c2 = Field("foo", table=self.t).between(0, 1).as_('alias') + c3 = Field("foo")[0:1].as_('alias') + + self.assertEqual('"foo" BETWEEN 0 AND 1 "alias"', str(c1)) + self.assertEqual('"btw"."foo" BETWEEN 0 AND 1 "alias"', str(c2)) + self.assertEqual('"foo" BETWEEN 0 AND 1 "alias"', str(c3)) + + def test__between_date(self): + c1 = Field("foo").between(date(2000, 1, 1), date(2000, 12, 31)) + c2 = Field("foo", table=self.t).between(date(2000, 1, 1), date(2000, 12, 31)) + c3 = Field("foo")[date(2000, 1, 1) : date(2000, 12, 31)] + + self.assertEqual("\"foo\" BETWEEN '2000-01-01' AND '2000-12-31'", str(c1)) + self.assertEqual("\"btw\".\"foo\" BETWEEN '2000-01-01' AND '2000-12-31'", str(c2)) + self.assertEqual("\"foo\" BETWEEN '2000-01-01' AND '2000-12-31'", str(c3)) + + def test__between_datetime(self): + c1 = Field("foo").between(datetime(2000, 1, 1, 0, 0, 0), datetime(2000, 12, 31, 23, 59, 59)) + c2 = Field("foo", table=self.t).between(datetime(2000, 1, 1, 0, 0, 0), datetime(2000, 12, 31, 23, 59, 59)) + c3 = Field("foo")[datetime(2000, 1, 1, 0, 0, 0) : datetime(2000, 12, 31, 23, 59, 59)] + + self.assertEqual("\"foo\" BETWEEN '2000-01-01T00:00:00' AND '2000-12-31T23:59:59'", str(c1)) + self.assertEqual( + "\"btw\".\"foo\" BETWEEN '2000-01-01T00:00:00' AND '2000-12-31T23:59:59'", + str(c2), + ) + self.assertEqual("\"foo\" BETWEEN '2000-01-01T00:00:00' AND '2000-12-31T23:59:59'", str(c3)) + + def test__function_between(self): + c1 = fn.Coalesce(Field("foo"), 0)[0:1] + c2 = fn.Coalesce(Field("foo", table=self.t), 0)[0:1] + + self.assertEqual('COALESCE("foo",0) BETWEEN 0 AND 1', str(c1)) + self.assertEqual('COALESCE("btw"."foo",0) BETWEEN 0 AND 1', str(c2)) + + def test_get_item_only_works_with_slice(self): + with self.assertRaises(TypeError): + Field("foo")[0] + + with self.assertRaises(TypeError): + Field("foo")[date(2000, 1, 1)] + + with self.assertRaises(TypeError): + Field("foo")[datetime(2000, 1, 1, 0, 0, 0)] + + +class IsInTests(unittest.TestCase): + t = Table("abc", alias="isin") + + def test__in_number(self): + c1 = Field("foo").isin([0, 1]) + c2 = Field("foo", table=self.t).isin([0, 1]) + + self.assertEqual('"foo" IN (0,1)', str(c1)) + self.assertEqual('"isin"."foo" IN (0,1)', str(c2)) + + def test__in_number_with_alias(self): + c1 = Field("foo").isin([0, 1]).as_('alias') + c2 = Field("foo", table=self.t).isin([0, 1]).as_('alias') + + self.assertEqual('"foo" IN (0,1) "alias"', str(c1)) + self.assertEqual('"isin"."foo" IN (0,1) "alias"', str(c2)) + + def test__in_character(self): + c1 = Field("foo").isin(["a", "b"]) + c2 = Field("foo", table=self.t).isin(["a", "b"]) + + self.assertEqual("\"foo\" IN ('a','b')", str(c1)) + self.assertEqual("\"isin\".\"foo\" IN ('a','b')", str(c2)) + + def test__in_date(self): + c1 = Field("foo").isin([date(2000, 1, 1), date(2000, 12, 31)]) + c2 = Field("foo", table=self.t).isin([date(2000, 1, 1), date(2000, 12, 31)]) + + self.assertEqual("\"foo\" IN ('2000-01-01','2000-12-31')", str(c1)) + self.assertEqual("\"isin\".\"foo\" IN ('2000-01-01','2000-12-31')", str(c2)) + + def test__in_datetime(self): + c1 = Field("foo").isin([datetime(2000, 1, 1, 0, 0, 0), datetime(2000, 12, 31, 23, 59, 59)]) + c2 = Field("foo", table=self.t).isin([datetime(2000, 1, 1, 0, 0, 0), datetime(2000, 12, 31, 23, 59, 59)]) + + self.assertEqual("\"foo\" IN ('2000-01-01T00:00:00','2000-12-31T23:59:59')", str(c1)) + self.assertEqual("\"isin\".\"foo\" IN ('2000-01-01T00:00:00','2000-12-31T23:59:59')", str(c2)) + + def test__function_isin(self): + c1 = fn.Coalesce(Field("foo"), 0).isin([0, 1]) + c2 = fn.Coalesce(Field("foo", table=self.t), 0).isin([0, 1]) + + self.assertEqual('COALESCE("foo",0) IN (0,1)', str(c1)) + self.assertEqual('COALESCE("isin"."foo",0) IN (0,1)', str(c2)) + + for t in (list, tuple, set, frozenset): + c_type = fn.Coalesce(Field("foo"), 0).isin(t([0, 1])) + self.assertEqual('COALESCE("foo",0) IN (0,1)', str(c_type)) + + self.assertRaises(AttributeError, lambda: str(fn.Coalesce(Field("foo"), 0).isin('SHOULD_FAIL'))) + + def test__in_unicode(self): + c1 = Field("foo").isin([u"a", u"b"]) + c2 = Field("foo", table=self.t).isin([u"a", u"b"]) + + self.assertEqual("\"foo\" IN ('a','b')", str(c1)) + self.assertEqual("\"isin\".\"foo\" IN ('a','b')", str(c2)) + + +class ArithmeticExpressionTests(unittest.TestCase): + def test__lshift(self): + c1 = Field("foo").lshift("1") + c2 = Field("foo").lshift("2") + + self.assertEqual("\"foo\"<<'1'", str(c1)) + self.assertEqual("\"foo\"<<'2'", str(c2)) + + def test__rshift(self): + c1 = Field("foo").rshift("1") + c2 = Field("foo").rshift("2") + + self.assertEqual("\"foo\">>'1'", str(c1)) + self.assertEqual("\"foo\">>'2'", str(c2)) + + +class NotInTests(unittest.TestCase): + t = Table("abc", alias="notin") + + def test__notin_number(self): + c1 = Field("foo").notin([0, 1]) + c2 = Field("foo", table=self.t).notin([0, 1]) + + self.assertEqual('"foo" NOT IN (0,1)', str(c1)) + self.assertEqual('"notin"."foo" NOT IN (0,1)', str(c2)) + + def test__notin_number_with_alias(self): + c1 = Field("foo").notin([0, 1]).as_('alias') + c2 = Field("foo", table=self.t).notin([0, 1]).as_('alias') + + self.assertEqual('"foo" NOT IN (0,1) "alias"', str(c1)) + self.assertEqual('"notin"."foo" NOT IN (0,1) "alias"', str(c2)) + + def test__notin_character(self): + c1 = Field("foo").notin(["a", "b"]) + c2 = Field("foo", table=self.t).notin(["a", "b"]) + + self.assertEqual("\"foo\" NOT IN ('a','b')", str(c1)) + self.assertEqual("\"notin\".\"foo\" NOT IN ('a','b')", str(c2)) + + def test__notin_date(self): + c1 = Field("foo").notin([date(2000, 1, 1), date(2000, 12, 31)]) + c2 = Field("foo", table=self.t).notin([date(2000, 1, 1), date(2000, 12, 31)]) + + self.assertEqual("\"foo\" NOT IN ('2000-01-01','2000-12-31')", str(c1)) + self.assertEqual("\"notin\".\"foo\" NOT IN ('2000-01-01','2000-12-31')", str(c2)) + + def test__notin_datetime(self): + c1 = Field("foo").notin([datetime(2000, 1, 1, 0, 0, 0), datetime(2000, 12, 31, 23, 59, 59)]) + c2 = Field("foo", table=self.t).notin([datetime(2000, 1, 1, 0, 0, 0), datetime(2000, 12, 31, 23, 59, 59)]) + + self.assertEqual("\"foo\" NOT IN ('2000-01-01T00:00:00','2000-12-31T23:59:59')", str(c1)) + self.assertEqual( + "\"notin\".\"foo\" NOT IN ('2000-01-01T00:00:00','2000-12-31T23:59:59')", + str(c2), + ) + + def test__function_notin(self): + c1 = fn.Coalesce(Field("foo"), 0).notin([0, 1]) + c2 = fn.Coalesce(Field("foo", table=self.t), 0).notin([0, 1]) + + self.assertEqual('COALESCE("foo",0) NOT IN (0,1)', str(c1)) + self.assertEqual('COALESCE("notin"."foo",0) NOT IN (0,1)', str(c2)) + + +class LikeTests(unittest.TestCase): + t = Table("abc", alias="like") + + def test_like_starts_with(self): + c1 = Field("foo").like("ab%") + c2 = Field("foo", table=self.t).like("ab%") + + self.assertEqual("\"foo\" LIKE 'ab%'", str(c1)) + self.assertEqual('"like"."foo" LIKE \'ab%\'', str(c2)) + + def test_like_contains(self): + c1 = Field("foo").like("%ab%") + c2 = Field("foo", table=self.t).like("%ab%") + + self.assertEqual("\"foo\" LIKE '%ab%'", str(c1)) + self.assertEqual('"like"."foo" LIKE \'%ab%\'', str(c2)) + + def test_like_ends_with(self): + c1 = Field("foo").like("%ab") + c2 = Field("foo", table=self.t).like("%ab") + + self.assertEqual("\"foo\" LIKE '%ab'", str(c1)) + self.assertEqual('"like"."foo" LIKE \'%ab\'', str(c2)) + + def test_like_n_chars_long(self): + c1 = Field("foo").like("___") + c2 = Field("foo", table=self.t).like("___") + + self.assertEqual("\"foo\" LIKE '___'", str(c1)) + self.assertEqual('"like"."foo" LIKE \'___\'', str(c2)) + + def test_like_single_chars_and_various_chars(self): + c1 = Field("foo").like("a_b%c") + c2 = Field("foo", table=self.t).like("a_b%c") + + self.assertEqual("\"foo\" LIKE 'a_b%c'", str(c1)) + self.assertEqual('"like"."foo" LIKE \'a_b%c\'', str(c2)) + + def test_not_like_single_chars_and_various_chars(self): + c1 = Field("foo").not_like("a_b%c") + c2 = Field("foo", table=self.t).not_like("a_b%c") + + self.assertEqual("\"foo\" NOT LIKE 'a_b%c'", str(c1)) + self.assertEqual('"like"."foo" NOT LIKE \'a_b%c\'', str(c2)) + + def test_ilike_starts_with(self): + c1 = Field("foo").ilike("ab%") + c2 = Field("foo", table=self.t).ilike("ab%") + + self.assertEqual("\"foo\" ILIKE 'ab%'", str(c1)) + self.assertEqual('"like"."foo" ILIKE \'ab%\'', str(c2)) + + def test_ilike_contains(self): + c1 = Field("foo").ilike("%ab%") + c2 = Field("foo", table=self.t).ilike("%ab%") + + self.assertEqual("\"foo\" ILIKE '%ab%'", str(c1)) + self.assertEqual('"like"."foo" ILIKE \'%ab%\'', str(c2)) + + def test_ilike_ends_with(self): + c1 = Field("foo").ilike("%ab") + c2 = Field("foo", table=self.t).ilike("%ab") + + self.assertEqual("\"foo\" ILIKE '%ab'", str(c1)) + self.assertEqual('"like"."foo" ILIKE \'%ab\'', str(c2)) + + def test_ilike_n_chars_long(self): + c1 = Field("foo").ilike("___") + c2 = Field("foo", table=self.t).ilike("___") + + self.assertEqual("\"foo\" ILIKE '___'", str(c1)) + self.assertEqual('"like"."foo" ILIKE \'___\'', str(c2)) + + def test_ilike_single_chars_and_various_chars(self): + c1 = Field("foo").ilike("a_b%c") + c2 = Field("foo", table=self.t).ilike("a_b%c") + + self.assertEqual("\"foo\" ILIKE 'a_b%c'", str(c1)) + self.assertEqual('"like"."foo" ILIKE \'a_b%c\'', str(c2)) + + def test_not_ilike_single_chars_and_various_chars(self): + c1 = Field("foo").not_ilike("a_b%c") + c2 = Field("foo", table=self.t).not_ilike("a_b%c") + + self.assertEqual("\"foo\" NOT ILIKE 'a_b%c'", str(c1)) + self.assertEqual('"like"."foo" NOT ILIKE \'a_b%c\'', str(c2)) + + def test_rlike_escape_chars(self): + c1 = Field("foo").rlike("\\\\d+$") + c2 = Field("foo", table=self.t).rlike("\\\\d+$") + + self.assertEqual("\"foo\" RLIKE '\\\\d+$'", str(c1)) + self.assertEqual('"like"."foo" RLIKE \'\\\\d+$\'', str(c2)) + + def test_glob_single_chars_and_various_chars(self): + c1 = Field("foo").glob("a_b*") + c2 = Field("foo", table=self.t).glob("a_b*") + + self.assertEqual("\"foo\" GLOB 'a_b*'", str(c1)) + self.assertEqual('"like"."foo" GLOB \'a_b*\'', str(c2)) + + +class ExistsCriterionTests(unittest.TestCase): + t2 = Table("abc", alias="t2") + q2 = QueryBuilder().from_(t2).select(t2.field2) + + def test_exists(self): + t1 = Table("def", alias="t1") + q1 = QueryBuilder().from_(t1).where(ExistsCriterion(self.q2)).select(t1.field1) + + self.assertEqual( + 'SELECT "t1"."field1" FROM "def" "t1" WHERE EXISTS (SELECT "t2"."field2" FROM "abc" "t2")', str(q1) + ) + + def test_not_exists(self): + t1 = Table("def", alias="t1") + q1 = QueryBuilder().from_(t1).where(ExistsCriterion(self.q2).negate()).select(t1.field1) + + self.assertEqual( + 'SELECT "t1"."field1" FROM "def" "t1" WHERE NOT EXISTS (SELECT "t2"."field2" FROM "abc" "t2")', str(q1) + ) + + +class ComplexCriterionTests(unittest.TestCase): + table_abc, table_efg = Table("abc", alias="cx0"), Table("efg", alias="cx1") + + def test_and(self): + c1 = (Field("foo") == 1) & (Field("bar") == 2) + c2 = (Field("foo", table=self.table_abc) == 1) & (Field("bar", table=self.table_efg) == 2) + + self.assertEqual('"foo"=1 AND "bar"=2', str(c1)) + self.assertEqual('"cx0"."foo"=1 AND "cx1"."bar"=2', str(c2)) + + def test_or(self): + c1 = (Field("foo") == 1) | (Field("bar") == 2) + c2 = (Field("foo", table=self.table_abc) == 1) | (Field("bar", table=self.table_efg) == 2) + + self.assertEqual('"foo"=1 OR "bar"=2', str(c1)) + self.assertEqual('"cx0"."foo"=1 OR "cx1"."bar"=2', str(c2)) + + def test_xor(self): + c1 = (Field("foo") == 1) ^ (Field("bar") == 2) + c2 = (Field("foo", table=self.table_abc) == 1) ^ (Field("bar", table=self.table_efg) == 2) + + self.assertEqual('"foo"=1 XOR "bar"=2', str(c1)) + self.assertEqual('"cx0"."foo"=1 XOR "cx1"."bar"=2', str(c2)) + + def test_function_and(self): + c1 = fn.IsNull(Field("foo")) & (Field("bar") == 2) + + self.assertEqual('ISNULL("foo") AND "bar"=2', str(c1)) + + def test_function_or(self): + c1 = fn.IsNull(Field("foo")) | (Field("bar") == 2) + + self.assertEqual('ISNULL("foo") OR "bar"=2', str(c1)) + + def test_function_xor(self): + c1 = fn.IsNull(Field("foo")) ^ (Field("bar") == 2) + + self.assertEqual('ISNULL("foo") XOR "bar"=2', str(c1)) + + def test__nested__and(self): + c = (Field("foo") == 1) & (Field("bar") == 2) & (Field("buz") == 3) + + self.assertEqual('"foo"=1 AND "bar"=2 AND "buz"=3', str(c)) + + def test__nested__or(self): + c = (Field("foo") == 1) | (Field("bar") == 2) | (Field("buz") == 3) + + self.assertEqual('"foo"=1 OR "bar"=2 OR "buz"=3', str(c)) + + def test__nested__mixed(self): + c = ((Field("foo") == 1) & (Field("bar") == 2)) | (Field("buz") == 3) + + self.assertEqual('("foo"=1 AND "bar"=2) OR "buz"=3', str(c)) + + def test__between_and_isin(self): + c = Field("foo").isin([1, 2, 3]) & Field("bar").between(0, 1) + + self.assertEqual('"foo" IN (1,2,3) AND "bar" BETWEEN 0 AND 1', str(c)) + + def test__between_and_field(self): + c1 = Field("foo").between(0, 1) + c2 = Field("bool_field") + + self.assertEqual('"foo" BETWEEN 0 AND 1 AND "bool_field"', str(c1 & c2)) + self.assertEqual('"bool_field" AND "foo" BETWEEN 0 AND 1', str(c2 & c1)) + + +class FieldsAsCriterionTests(unittest.TestCase): + def test__field_and_field(self): + c1 = Field("a") + c2 = Field("b") + + self.assertEqual('"a" AND "b"', str(c1 & c2)) + + def test__field_or_field(self): + c1 = Field("a") + c2 = Field("b") + + self.assertEqual('"a" OR "b"', str(c1 | c2)) + + def test__field_xor_field(self): + c1 = Field("a") + c2 = Field("b") + + self.assertEqual('"a" XOR "b"', str(c1 ^ c2)) + + +class CriterionOperationsTests(unittest.TestCase): + table_abc, table_efg = Table("abc", alias="cx0"), Table("efg", alias="cx1") + + def test_field_replace_table(self): + f = self.table_abc.foo.replace_table(self.table_abc, self.table_efg) + + self.assertEqual('"cx1"."foo"', str(f)) + + def test_arithmeticfunction_replace_table(self): + f = (self.table_abc.foo + self.table_abc.bar).replace_table(self.table_abc, self.table_efg) + + self.assertEqual('"cx1"."foo"+"cx1"."bar"', str(f)) + + def test_criterion_replace_table(self): + f = (self.table_abc.foo < self.table_abc.bar).replace_table(self.table_abc, self.table_efg) + + self.assertEqual('"cx1"."foo"<"cx1"."bar"', str(f)) + + def test_complexcriterion_replace_table(self): + f = (self.table_abc.foo < self.table_abc.bar) & (self.table_abc.fiz > self.table_abc.buz) + f = f.replace_table(self.table_abc, self.table_efg) + + self.assertEqual('"cx1"."foo"<"cx1"."bar" AND "cx1"."fiz">"cx1"."buz"', str(f)) + + def test_function_with_only_fields_replace_table(self): + f = fn.Sum(self.table_abc.foo).replace_table(self.table_abc, self.table_efg) + + self.assertEqual('SUM("cx1"."foo")', str(f)) + + def test_function_with_values_and_fields_replace_table(self): + f = Mod(self.table_abc.foo, 2).replace_table(self.table_abc, self.table_efg) + + self.assertEqual('MOD("cx1"."foo",2)', str(f)) + + def test_betweencriterion_replace_table(self): + f = self.table_abc.foo[0:1].replace_table(self.table_abc, self.table_efg) + + self.assertEqual('"cx1"."foo" BETWEEN 0 AND 1', str(f)) + + def test_nullcriterion_replace_table(self): + f = self.table_abc.foo.isnull().replace_table(self.table_abc, self.table_efg) + + self.assertEqual('"cx1"."foo" IS NULL', str(f)) + + +class AnyTests(unittest.TestCase): + def test_zero_args_returns_empty_criterion(self): + crit = Criterion.any() + self.assertIsInstance(crit, EmptyCriterion) + + def test_single_arg_returns_self(self): + f = Field("a") + crit = Criterion.any([f]) + self.assertEqual(str(f), str(crit)) + + def test_multiple_args_returned_in_chain_of_ors(self): + crit = Criterion.any([Field("a"), Field("b"), Field("c"), Field("d")]) + self.assertEqual(str(crit), '"a" OR "b" OR "c" OR "d"') + + def test_with_generator(self): + crit = Criterion.any(Field(letter) for letter in "abcd") + self.assertEqual(str(crit), '"a" OR "b" OR "c" OR "d"') + + +class EmptyCriterionTests(unittest.TestCase): + def test_fields_(self): + empty_criterion = EmptyCriterion() + + self.assertEqual(len(empty_criterion.fields_()), 0) + + def test_empty_criterion_on_the_left(self): + t = Table("test1") + q = EmptyCriterion() & t.f1 == "v1" + + self.assertEqual( + '"test1"."f1"=\'v1\'', + q.get_sql(with_namespace=True), + ) + + def test_empty_criterion_on_the_right(self): + t = Table("test1") + q = (t.f1 == "v1") & EmptyCriterion() + + self.assertEqual( + '"test1"."f1"=\'v1\'', + q.get_sql(with_namespace=True), + ) + + def test_invertion_of_the_empty_criterion(self): + t = Table("test1") + q = (t.f1 == "v1") & ~EmptyCriterion() + + self.assertEqual( + '"test1"."f1"=\'v1\'', + q.get_sql(with_namespace=True), + ) + + def test_different_operations_with_empty_criterion(self): + t = Table("test1") + q1 = (t.f1 == "v1") & EmptyCriterion() + q2 = (t.f1 == "v1") | EmptyCriterion() + q3 = (t.f1 == "v1") ^ EmptyCriterion() + + expected_sql = '"test1"."f1"=\'v1\'' + self.assertEqual( + expected_sql, + q1.get_sql(with_namespace=True), + ) + self.assertEqual( + expected_sql, + q2.get_sql(with_namespace=True), + ) + self.assertEqual( + expected_sql, + q3.get_sql(with_namespace=True), + ) + + def test_more_than_one_empty_criterions(self): + t = Table("test1") + q = EmptyCriterion() & ~(EmptyCriterion() | EmptyCriterion()) & (t.f1 == "v1") & ~EmptyCriterion() + + self.assertEqual( + '"test1"."f1"=\'v1\'', + q.get_sql(with_namespace=True), + ) + + +class AllTests(unittest.TestCase): + def test_zero_args_returns_empty_criterion(self): + crit = Criterion.all() + self.assertIsInstance(crit, EmptyCriterion) + + def test_single_arg_returns_self(self): + f = Field("a") + crit = Criterion.all([f]) + self.assertEqual(str(f), str(crit)) + + def test_multiple_args_returned_in_chain_of_ors(self): + crit = Criterion.all([Field("a"), Field("b"), Field("c"), Field("d")]) + self.assertEqual(str(crit), '"a" AND "b" AND "c" AND "d"') + + def test_with_generator(self): + crit = Criterion.all(Field(letter) for letter in "abcd") + self.assertEqual(str(crit), '"a" AND "b" AND "c" AND "d"') diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/test_custom_functions.py b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/test_custom_functions.py new file mode 100644 index 0000000000000000000000000000000000000000..60ffd3cd8e6191e3fc782dac003c41bfb7a78528 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/test_custom_functions.py @@ -0,0 +1,49 @@ +import unittest + +from pypika import CustomFunction, FunctionException, Query, Table + +__author__ = "Airton Zanon" +__email__ = "me@airton.dev" + + +class TestUnitCustomFunction(unittest.TestCase): + def test_should_fail_with_wrong_arguments(self): + DateDiff = CustomFunction("DATE_DIFF", ["interval", "start_date", "end_date"]) + + with self.assertRaises(FunctionException): + DateDiff("foo") + + def test_should_return_function_with_arguments(self): + DateDiff = CustomFunction("DATE_DIFF", ["interval", "start_date", "end_date"]) + + self.assertEqual( + "DATE_DIFF('day','start_date','end_date')", + str(DateDiff("day", "start_date", "end_date")), + ) + + def test_should_return_function_with_no_arguments(self): + CurrentDate = CustomFunction("CURRENT_DATE") + + self.assertEqual("CURRENT_DATE()", str(CurrentDate())) + + +class TestFunctionalCustomFunction(unittest.TestCase): + def test_should_use_custom_function_on_select(self): + service = Table("service") + + DateDiff = CustomFunction("DATE_DIFF", ["interval", "start_date", "end_date"]) + + q = Query.from_(service).select(DateDiff("day", service.created_date, service.updated_date)) + + self.assertEqual( + 'SELECT DATE_DIFF(\'day\',"created_date","updated_date") FROM "service"', + str(q), + ) + + def test_should_fail_use_custom_function_on_select_with_wrong_arguments(self): + service = Table("service") + + DateDiff = CustomFunction("DATE_DIFF", ["interval", "start_date", "end_date"]) + + with self.assertRaises(FunctionException): + Query.from_(service).select(DateDiff("day", service.created_date)) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/test_data_types.py b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/test_data_types.py new file mode 100644 index 0000000000000000000000000000000000000000..52fb4487fe7be3ae28a4e9eb08628fba89dc0f79 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/test_data_types.py @@ -0,0 +1,15 @@ +import unittest +import uuid + +from pypika.terms import ValueWrapper + + +class StringTests(unittest.TestCase): + def test_inline_string_concatentation(self): + self.assertEqual("'it''s'", ValueWrapper("it's").get_sql()) + + +class UuidTests(unittest.TestCase): + def test_uuid_string_generation(self): + id = uuid.uuid4() + self.assertEqual("'{}'".format(id), ValueWrapper(id).get_sql()) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/test_date_math.py b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/test_date_math.py new file mode 100644 index 0000000000000000000000000000000000000000..38db8ef2f8e812a97c6980a7ec6b9a3909d804fb --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/test_date_math.py @@ -0,0 +1,179 @@ +import unittest + +from pypika import ( + Field as F, + Interval, +) +from pypika.enums import Dialects + +dt = F("dt") + + +class AddIntervalTests(unittest.TestCase): + def test_add_microsecond(self): + c = dt + Interval(microseconds=1) + + self.assertEqual("\"dt\"+INTERVAL '1 MICROSECOND'", str(c)) + + def test_add_second(self): + c = dt + Interval(seconds=1) + + self.assertEqual("\"dt\"+INTERVAL '1 SECOND'", str(c)) + + def test_add_minute(self): + c = dt + Interval(minutes=1) + + self.assertEqual("\"dt\"+INTERVAL '1 MINUTE'", str(c)) + + def test_add_day(self): + c = dt + Interval(days=1) + + self.assertEqual("\"dt\"+INTERVAL '1 DAY'", str(c)) + + def test_add_week(self): + c = dt + Interval(weeks=1) + + self.assertEqual("\"dt\"+INTERVAL '1 WEEK'", str(c)) + + def test_add_month(self): + c = dt + Interval(months=1) + + self.assertEqual("\"dt\"+INTERVAL '1 MONTH'", str(c)) + + def test_add_quarter(self): + c = dt + Interval(quarters=1) + + self.assertEqual("\"dt\"+INTERVAL '1 QUARTER'", str(c)) + + def test_add_year(self): + c = dt + Interval(years=1) + + self.assertEqual("\"dt\"+INTERVAL '1 YEAR'", str(c)) + + def test_add_default(self): + c = dt + Interval(days=0) + + self.assertEqual("\"dt\"+INTERVAL '0 DAY'", str(c)) + + +class AddIntervalMultipleUnitsTests(unittest.TestCase): + def test_add_second_microsecond(self): + c = dt + Interval(seconds=1, microseconds=1) + + self.assertEqual("\"dt\"+INTERVAL '1.1 SECOND_MICROSECOND'", str(c)) + + def test_add_minute_microsecond(self): + c = dt + Interval(minutes=1, microseconds=1) + + self.assertEqual("\"dt\"+INTERVAL '1:0.1 MINUTE_MICROSECOND'", str(c)) + + def test_add_minute_second(self): + c = dt + Interval(minutes=1, seconds=1) + + self.assertEqual("\"dt\"+INTERVAL '1:1 MINUTE_SECOND'", str(c)) + + def test_add_hour_microsecond(self): + c = dt + Interval(hours=1, microseconds=1) + + self.assertEqual("\"dt\"+INTERVAL '1:0:0.1 HOUR_MICROSECOND'", str(c)) + + def test_add_hour_second(self): + c = dt + Interval(hours=1, seconds=1) + + self.assertEqual("\"dt\"+INTERVAL '1:0:1 HOUR_SECOND'", str(c)) + + def test_add_hour_minute(self): + c = dt + Interval(hours=1, minutes=1) + + self.assertEqual("\"dt\"+INTERVAL '1:1 HOUR_MINUTE'", str(c)) + + def test_add_day_microsecond(self): + c = dt + Interval(days=1, microseconds=1) + + self.assertEqual("\"dt\"+INTERVAL '1 0:0:0.1 DAY_MICROSECOND'", str(c)) + + def test_add_day_second(self): + c = dt + Interval(days=1, seconds=1) + + self.assertEqual("\"dt\"+INTERVAL '1 0:0:1 DAY_SECOND'", str(c)) + + def test_add_day_minute(self): + c = dt + Interval(days=1, minutes=1) + + self.assertEqual("\"dt\"+INTERVAL '1 0:1 DAY_MINUTE'", str(c)) + + def test_add_day_hour(self): + c = dt + Interval(days=1, hours=1) + + self.assertEqual("\"dt\"+INTERVAL '1 1 DAY_HOUR'", str(c)) + + def test_add_year_month(self): + c = dt + Interval(years=1, months=1) + + self.assertEqual("\"dt\"+INTERVAL '1-1 YEAR_MONTH'", str(c)) + + def test_add_value_right(self): + c = Interval(microseconds=1) - dt + + self.assertEqual("INTERVAL '1 MICROSECOND'-\"dt\"", str(c)) + + def test_add_value_complex_expressions(self): + c = dt + Interval(quarters=1) + Interval(weeks=1) + + self.assertEqual("\"dt\"+INTERVAL '1 QUARTER'+INTERVAL '1 WEEK'", str(c)) + + +class DialectIntervalTests(unittest.TestCase): + def test_mysql_dialect_uses_single_quotes_around_expression_in_an_interval(self): + c = Interval(days=1).get_sql(dialect=Dialects.MYSQL) + self.assertEqual("INTERVAL '1' DAY", c) + + def test_oracle_dialect_uses_single_quotes_around_expression_in_an_interval(self): + c = Interval(days=1).get_sql(dialect=Dialects.ORACLE) + self.assertEqual("INTERVAL '1' DAY", c) + + def test_vertica_dialect_uses_single_quotes_around_interval(self): + c = Interval(days=1).get_sql(dialect=Dialects.VERTICA) + self.assertEqual("INTERVAL '1 DAY'", c) + + def test_redshift_dialect_uses_single_quotes_around_interval(self): + c = Interval(days=1).get_sql(dialect=Dialects.REDSHIFT) + self.assertEqual("INTERVAL '1 DAY'", c) + + def test_postgresql_dialect_uses_single_quotes_around_interval(self): + c = Interval(days=1).get_sql(dialect=Dialects.POSTGRESQL) + self.assertEqual("INTERVAL '1 DAY'", c) + + +class TestNegativeIntervals(unittest.TestCase): + def test_day(self): + c = Interval(days=-1).get_sql() + self.assertEqual("INTERVAL '-1 DAY'", c) + + def test_week(self): + c = Interval(weeks=-1).get_sql() + self.assertEqual("INTERVAL '-1 WEEK'", c) + + def test_month(self): + c = Interval(months=-1).get_sql() + self.assertEqual("INTERVAL '-1 MONTH'", c) + + def test_year(self): + c = Interval(years=-1).get_sql() + self.assertEqual("INTERVAL '-1 YEAR'", c) + + def test_year_month(self): + c = Interval(years=-1, months=-4).get_sql() + self.assertEqual("INTERVAL '-1-4 YEAR_MONTH'", c) + + +class TruncateTrailingZerosTests(unittest.TestCase): + def test_do_not_truncate_integer_values(self): + i = Interval(seconds=10) + + self.assertEqual("INTERVAL '10 SECOND'", str(i)) + + def test_do_not_truncate_months_between_years_and_datys(self): + i = Interval(years=10, days=10) + + self.assertEqual("INTERVAL '10-0-10 YEAR_DAY'", str(i)) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/test_deletes.py b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/test_deletes.py new file mode 100644 index 0000000000000000000000000000000000000000..09df93f5331b845b0c3aed628bf1c4a3ec6b0f02 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/test_deletes.py @@ -0,0 +1,97 @@ +import unittest + +from pypika import PostgreSQLQuery, Query, SYSTEM_TIME, Table + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + +from pypika.terms import Star + + +class DeleteTests(unittest.TestCase): + @classmethod + def setUpClass(cls) -> None: + super().setUpClass() + cls.table_abc = Table("abc") + + def test_omit_where(self): + q = Query.from_("abc").delete() + + self.assertEqual('DELETE FROM "abc"', str(q)) + + def test_omit_where__table_schema(self): + q = Query.from_(Table("abc", "schema1")).delete() + + self.assertEqual('DELETE FROM "schema1"."abc"', str(q)) + + def test_where_field_equals(self): + q1 = Query.from_(self.table_abc).where(self.table_abc.foo == self.table_abc.bar).delete() + q2 = Query.from_(self.table_abc).where(self.table_abc.foo.eq(self.table_abc.bar)).delete() + + self.assertEqual('DELETE FROM "abc" WHERE "foo"="bar"', str(q1)) + self.assertEqual('DELETE FROM "abc" WHERE "foo"="bar"', str(q2)) + + def test_for_portion(self): + with self.subTest("with system time"): + q = Query.from_(self.table_abc.for_portion(SYSTEM_TIME.from_to('2020-01-01', '2020-02-01'))).delete() + + self.assertEqual( + 'DELETE FROM "abc" FOR PORTION OF SYSTEM_TIME FROM \'2020-01-01\' TO \'2020-02-01\'', str(q) + ) + + with self.subTest("with column"): + q = Query.from_( + self.table_abc.for_portion(self.table_abc.valid_period.from_to('2020-01-01', '2020-02-01')) + ).delete() + + self.assertEqual( + 'DELETE FROM "abc" FOR PORTION OF "valid_period" FROM \'2020-01-01\' TO \'2020-02-01\'', str(q) + ) + + +class PostgresDeleteTests(unittest.TestCase): + @classmethod + def setUpClass(cls) -> None: + super().setUpClass() + cls.table_abc = Table("abc") + + def test_delete_returning(self): + q1 = ( + PostgreSQLQuery.from_(self.table_abc) + .where(self.table_abc.foo == self.table_abc.bar) + .delete() + .returning(self.table_abc.id) + ) + + self.assertEqual('DELETE FROM "abc" WHERE "foo"="bar" RETURNING "id"', str(q1)) + + def test_delete_returning_str(self): + q1 = ( + PostgreSQLQuery.from_(self.table_abc) + .where(self.table_abc.foo == self.table_abc.bar) + .delete() + .returning("id") + ) + + self.assertEqual('DELETE FROM "abc" WHERE "foo"="bar" RETURNING "id"', str(q1)) + + def test_delete_returning_star(self): + q1 = ( + PostgreSQLQuery.from_(self.table_abc) + .where(self.table_abc.foo == self.table_abc.bar) + .delete() + .returning(Star()) + ) + + self.assertEqual('DELETE FROM "abc" WHERE "foo"="bar" RETURNING *', str(q1)) + + def test_delete_using(self): + table_trash = Table('trash') + q1 = ( + PostgreSQLQuery.from_(self.table_abc) + .using(table_trash) + .where(self.table_abc.id == table_trash.abc_id) + .delete() + ) + + self.assertEqual('DELETE FROM "abc" USING "trash" WHERE "abc"."id"="trash"."abc_id"', str(q1)) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/test_drop.py b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/test_drop.py new file mode 100644 index 0000000000000000000000000000000000000000..265ae7350d2054549731f9a8c4379fdac95dc580 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/test_drop.py @@ -0,0 +1,49 @@ +import unittest + +from pypika import ( + Columns, + Database, + Query, + Tables, +) + + +class DropTableTests(unittest.TestCase): + database_xyz = Database("mydb") + new_table, existing_table = Tables("abc", "efg") + foo, bar = Columns(("a", "INT"), ("b", "VARCHAR(100)")) + + def test_drop_database(self): + q1 = Query.drop_database(self.database_xyz) + q2 = Query.drop_database(self.database_xyz).if_exists() + + self.assertEqual('DROP DATABASE "mydb"', str(q1)) + self.assertEqual('DROP DATABASE IF EXISTS "mydb"', str(q2)) + + def test_drop_table(self): + q1 = Query.drop_table(self.new_table) + q2 = Query.drop_table(self.new_table).if_exists() + + self.assertEqual('DROP TABLE "abc"', str(q1)) + self.assertEqual('DROP TABLE IF EXISTS "abc"', str(q2)) + + def test_drop_user(self): + q1 = Query.drop_user("myuser") + q2 = Query.drop_user("myuser").if_exists() + + self.assertEqual('DROP USER "myuser"', str(q1)) + self.assertEqual('DROP USER IF EXISTS "myuser"', str(q2)) + + def test_drop_view(self): + q1 = Query.drop_view("myview") + q2 = Query.drop_view("myview").if_exists() + + self.assertEqual('DROP VIEW "myview"', str(q1)) + self.assertEqual('DROP VIEW IF EXISTS "myview"', str(q2)) + + def test_drop_index(self): + q1 = Query.drop_index("myindex") + q2 = Query.drop_index("myindex").if_exists() + + self.assertEqual('DROP INDEX "myindex"', str(q1)) + self.assertEqual('DROP INDEX IF EXISTS "myindex"', str(q2)) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/test_formats.py b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/test_formats.py new file mode 100644 index 0000000000000000000000000000000000000000..6a442757c6659a215661e03f1ca9c3771d394d96 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/test_formats.py @@ -0,0 +1,68 @@ +import unittest + +from pypika import Query, Tables, functions as fn + + +class QuoteTests(unittest.TestCase): + maxDiff = None + + table_abc, table_efg = Tables("abc", "efg") + + def setUp(self): + subquery1 = ( + Query.from_(self.table_abc) + .select( + self.table_abc.foo, + fn.Sum(self.table_abc.fizz + self.table_abc.buzz).as_("fizzbuzz"), + ) + .groupby(self.table_abc.foo) + ) + + subquery2 = Query.from_(self.table_efg).select( + self.table_efg.foo.as_("foo_two"), + self.table_efg.bar, + ) + + self.query = ( + Query.from_(subquery1) + .select(subquery1.foo, subquery1.fizzbuzz) + .join(subquery2) + .on(subquery1.foo == subquery2.foo_two) + .select(subquery2.foo_two, subquery2.bar) + ) + + def test_replace_quote_char_in_complex_query(self): + self.assertEqual( + "SELECT " + "`sq0`.`foo`,`sq0`.`fizzbuzz`," + "`sq1`.`foo_two`,`sq1`.`bar` " + "FROM (" + "SELECT " + "`foo`,SUM(`fizz`+`buzz`) `fizzbuzz` " + "FROM `abc` " + "GROUP BY `foo`" + ") `sq0` JOIN (" + "SELECT " + "`foo` `foo_two`,`bar` " + "FROM `efg`" + ") `sq1` ON `sq0`.`foo`=`sq1`.`foo_two`", + self.query.get_sql(quote_char="`"), + ) + + def test_no_quote_char_in_complex_query(self): + self.assertEqual( + "SELECT " + "sq0.foo,sq0.fizzbuzz," + "sq1.foo_two,sq1.bar " + "FROM (" + "SELECT " + "foo,SUM(fizz+buzz) fizzbuzz " + "FROM abc " + "GROUP BY foo" + ") sq0 JOIN (" + "SELECT " + "foo foo_two,bar " + "FROM efg" + ") sq1 ON sq0.foo=sq1.foo_two", + self.query.get_sql(quote_char=None), + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/test_functions.py b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/test_functions.py new file mode 100644 index 0000000000000000000000000000000000000000..f526966eefc554ec68d0e15fb69de7d69f1604c3 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/test_functions.py @@ -0,0 +1,847 @@ +import unittest + +from pypika import ( + Case, + CaseException, + DatePart, + Field as F, + Query, + Query as Q, + Schema, + Table as T, + VerticaQuery, + functions as fn, +) +from pypika.enums import Dialects, SqlTypes + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + + +class FunctionTests(unittest.TestCase): + def test_dialect_propagation(self): + func = fn.Function("func", ["a"], ["b"]) + self.assertEqual("func(ARRAY['a'],ARRAY['b'])", func.get_sql(dialect=Dialects.POSTGRESQL)) + + def test_is_aggregate_None_for_non_aggregate_function_or_function_with_no_aggregate_functions(self): + self.assertIsNone(fn.Coalesce('a', 0).is_aggregate) + self.assertIsNone(fn.Coalesce(fn.NullIf('a', 0), 0).is_aggregate) + + def test_is_aggregate_True_for_aggregate_function_or_function_with_aggregate_functions(self): + self.assertTrue(fn.Sum('a').is_aggregate) + self.assertTrue(fn.Coalesce(fn.Avg('a'), 0).is_aggregate) + self.assertTrue(fn.Coalesce(fn.NullIf(fn.Sum('a'), 0), 0).is_aggregate) + + +class SchemaTests(unittest.TestCase): + def test_schema_no_schema_in_sql_when_none_set(self): + func = fn.Function("my_proc", 1, 2, 3) + + self.assertEqual("my_proc(1,2,3)", func.get_sql(quote_char='"')) + + def test_schema_included_in_function_sql(self): + a = Schema("a") + func = fn.Function("my_proc", 1, 2, 3, schema=a) + + self.assertEqual('"a".my_proc(1,2,3)', func.get_sql(quote_char='"')) + + +class ArithmeticTests(unittest.TestCase): + t = T("abc") + + def test__addition__fields(self): + q1 = Q.from_("abc").select(F("a") + F("b")) + q2 = Q.from_(self.t).select(self.t.a + self.t.b) + + self.assertEqual('SELECT "a"+"b" FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"+"b" FROM "abc"', str(q2)) + + def test__addition__number(self): + q1 = Q.from_("abc").select(F("a") + 1) + q2 = Q.from_(self.t).select(self.t.a + 1) + + self.assertEqual('SELECT "a"+1 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"+1 FROM "abc"', str(q2)) + + def test__addition__decimal(self): + q1 = Q.from_("abc").select(F("a") + 1.0) + q2 = Q.from_(self.t).select(self.t.a + 1.0) + + self.assertEqual('SELECT "a"+1.0 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"+1.0 FROM "abc"', str(q2)) + + def test__addition__right(self): + q1 = Q.from_("abc").select(1 + F("a")) + q2 = Q.from_(self.t).select(1 + self.t.a) + + self.assertEqual('SELECT 1+"a" FROM "abc"', str(q1)) + self.assertEqual('SELECT 1+"a" FROM "abc"', str(q2)) + + def test__subtraction__fields(self): + q1 = Q.from_("abc").select(F("a") - F("b")) + q2 = Q.from_(self.t).select(self.t.a - self.t.b) + + self.assertEqual('SELECT "a"-"b" FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"-"b" FROM "abc"', str(q2)) + + def test__subtraction__number(self): + q1 = Q.from_("abc").select(F("a") - 1) + q2 = Q.from_(self.t).select(self.t.a - 1) + + self.assertEqual('SELECT "a"-1 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"-1 FROM "abc"', str(q2)) + + def test__subtraction__decimal(self): + q1 = Q.from_("abc").select(F("a") - 1.0) + q2 = Q.from_(self.t).select(self.t.a - 1.0) + + self.assertEqual('SELECT "a"-1.0 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"-1.0 FROM "abc"', str(q2)) + + def test__subtraction__right(self): + q1 = Q.from_("abc").select(1 - F("a")) + q2 = Q.from_(self.t).select(1 - self.t.a) + + self.assertEqual('SELECT 1-"a" FROM "abc"', str(q1)) + self.assertEqual('SELECT 1-"a" FROM "abc"', str(q2)) + + def test__multiplication__fields(self): + q1 = Q.from_("abc").select(F("a") * F("b")) + q2 = Q.from_(self.t).select(self.t.a * self.t.b) + + self.assertEqual('SELECT "a"*"b" FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"*"b" FROM "abc"', str(q2)) + + def test__multiplication__number(self): + q1 = Q.from_("abc").select(F("a") * 1) + q2 = Q.from_(self.t).select(self.t.a * 1) + + self.assertEqual('SELECT "a"*1 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"*1 FROM "abc"', str(q2)) + + def test__multiplication__decimal(self): + q1 = Q.from_("abc").select(F("a") * 1.0) + q2 = Q.from_(self.t).select(self.t.a * 1.0) + + self.assertEqual('SELECT "a"*1.0 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"*1.0 FROM "abc"', str(q2)) + + def test__multiplication__right(self): + q1 = Q.from_("abc").select(1 * F("a")) + q2 = Q.from_(self.t).select(1 * self.t.a) + + self.assertEqual('SELECT 1*"a" FROM "abc"', str(q1)) + self.assertEqual('SELECT 1*"a" FROM "abc"', str(q2)) + + def test__division__fields(self): + q1 = Q.from_("abc").select(F("a") / F("b")) + q2 = Q.from_(self.t).select(self.t.a / self.t.b) + + self.assertEqual('SELECT "a"/"b" FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"/"b" FROM "abc"', str(q2)) + + def test__division__number(self): + q1 = Q.from_("abc").select(F("a") / 1) + q2 = Q.from_(self.t).select(self.t.a / 1) + + self.assertEqual('SELECT "a"/1 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"/1 FROM "abc"', str(q2)) + + def test__division__decimal(self): + q1 = Q.from_("abc").select(F("a") / 1.0) + q2 = Q.from_(self.t).select(self.t.a / 1.0) + + self.assertEqual('SELECT "a"/1.0 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"/1.0 FROM "abc"', str(q2)) + + def test__division__right(self): + q1 = Q.from_("abc").select(1 / F("a")) + q2 = Q.from_(self.t).select(1 / self.t.a) + + self.assertEqual('SELECT 1/"a" FROM "abc"', str(q1)) + self.assertEqual('SELECT 1/"a" FROM "abc"', str(q2)) + + def test__leftshift__fields(self): + q1 = Q.from_("abc").select(F("a") << F("b")) + q2 = Q.from_(self.t).select(self.t.a << self.t.b) + + self.assertEqual('SELECT "a"<<"b" FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"<<"b" FROM "abc"', str(q2)) + + def test__leftshift__number(self): + q1 = Q.from_("abc").select(F('a') << 2) + q2 = Q.from_(self.t).select(self.t.a << 2) + + self.assertEqual('SELECT "a"<<2 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"<<2 FROM "abc"', str(q2)) + + def test__leftshift__right(self): + q1 = Q.from_("abc").select(1 << F("a")) + q2 = Q.from_(self.t).select(1 << self.t.a) + + self.assertEqual('SELECT 1<<"a" FROM "abc"', str(q1)) + self.assertEqual('SELECT 1<<"a" FROM "abc"', str(q2)) + + def test__rightshift__fields(self): + q1 = Q.from_("abc").select(F("a") >> F("b")) + q2 = Q.from_(self.t).select(self.t.a >> self.t.b) + + self.assertEqual('SELECT "a">>"b" FROM "abc"', str(q1)) + self.assertEqual('SELECT "a">>"b" FROM "abc"', str(q2)) + + def test__rightshift__number(self): + q1 = Q.from_("abc").select(F('a') >> 2) + q2 = Q.from_(self.t).select(self.t.a >> 2) + + self.assertEqual('SELECT "a">>2 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a">>2 FROM "abc"', str(q2)) + + def test__rightshift__right(self): + q1 = Q.from_("abc").select(1 >> F("a")) + q2 = Q.from_(self.t).select(1 >> self.t.a) + + self.assertEqual('SELECT 1>>"a" FROM "abc"', str(q1)) + self.assertEqual('SELECT 1>>"a" FROM "abc"', str(q2)) + + def test__complex_op(self): + q1 = Q.from_("abc").select(2 + 1 / F("a") - 5) + q2 = Q.from_(self.t).select(2 + 1 / self.t.a - 5) + + self.assertEqual('SELECT 2+1/"a"-5 FROM "abc"', str(q1)) + self.assertEqual('SELECT 2+1/"a"-5 FROM "abc"', str(q2)) + + def test__complex_op_add_parentheses(self): + q1 = Q.from_("abc").select((F("a") + 1) + (F("b") - 5)) + q2 = Q.from_(self.t).select((self.t.a + 1) + (self.t.b - 5)) + q3 = Q.from_("abc").select((F("a") / 1) + (F("b") / 5)) + q4 = Q.from_(self.t).select((self.t.a / 1) + (self.t.b / 5)) + + self.assertEqual('SELECT "a"+1+"b"-5 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"+1+"b"-5 FROM "abc"', str(q2)) + self.assertEqual('SELECT "a"/1+"b"/5 FROM "abc"', str(q3)) + self.assertEqual('SELECT "a"/1+"b"/5 FROM "abc"', str(q4)) + + def test__complex_op_sub_parentheses(self): + q1 = Q.from_("abc").select((F("a") + 1) - (F("b") - 5)) + q2 = Q.from_(self.t).select((self.t.a + 1) - (self.t.b - 5)) + q3 = Q.from_("abc").select((F("a") / 1) - (F("b") / 5)) + q4 = Q.from_(self.t).select((self.t.a / 1) - (self.t.b / 5)) + + self.assertEqual('SELECT "a"+1-("b"-5) FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"+1-("b"-5) FROM "abc"', str(q2)) + self.assertEqual('SELECT "a"/1-"b"/5 FROM "abc"', str(q3)) + self.assertEqual('SELECT "a"/1-"b"/5 FROM "abc"', str(q4)) + + def test__complex_op_mul_parentheses(self): + q1 = Q.from_("abc").select((F("a") + 1) * (F("b") - 5)) + q2 = Q.from_(self.t).select((self.t.a + 1) * (self.t.b - 5)) + q3 = Q.from_("abc").select((F("a") / 1) * (F("b") - 5)) + q4 = Q.from_(self.t).select((self.t.a / 1) * (self.t.b - 5)) + q5 = Q.from_("abc").select((F("a") + 1) * (F("b") / 5)) + q6 = Q.from_(self.t).select((self.t.a + 1) * (self.t.b / 5)) + + self.assertEqual('SELECT ("a"+1)*("b"-5) FROM "abc"', str(q1)) + self.assertEqual('SELECT ("a"+1)*("b"-5) FROM "abc"', str(q2)) + self.assertEqual('SELECT "a"/1*("b"-5) FROM "abc"', str(q3)) + self.assertEqual('SELECT "a"/1*("b"-5) FROM "abc"', str(q4)) + self.assertEqual('SELECT ("a"+1)*"b"/5 FROM "abc"', str(q5)) + self.assertEqual('SELECT ("a"+1)*"b"/5 FROM "abc"', str(q6)) + + def test__complex_op_mul_no_parentheses(self): + q = Q.from_("abc").select(F("a") + 1 * F("b") - 5) + + self.assertEqual('SELECT "a"+1*"b"-5 FROM "abc"', str(q)) + + def test__complex_op_div_parentheses(self): + q1 = Q.from_("abc").select((F("a") + 1) / (F("b") - 5)) + q2 = Q.from_(self.t).select((self.t.a + 1) / (self.t.b - 5)) + q3 = Q.from_("abc").select((F("a") / 1) / (F("b") - 5)) + q4 = Q.from_(self.t).select((self.t.a / 1) / (self.t.b - 5)) + q5 = Q.from_("abc").select((F("a") + 1) / (F("b") * 5)) + q6 = Q.from_(self.t).select((self.t.a + 1) / (self.t.b * 5)) + + self.assertEqual('SELECT ("a"+1)/("b"-5) FROM "abc"', str(q1)) + self.assertEqual('SELECT ("a"+1)/("b"-5) FROM "abc"', str(q2)) + self.assertEqual('SELECT "a"/1/("b"-5) FROM "abc"', str(q3)) + self.assertEqual('SELECT "a"/1/("b"-5) FROM "abc"', str(q4)) + self.assertEqual('SELECT ("a"+1)/("b"*5) FROM "abc"', str(q5)) + self.assertEqual('SELECT ("a"+1)/("b"*5) FROM "abc"', str(q6)) + + def test__complex_op_div_no_parentheses(self): + q = Q.from_("abc").select(F("a") + 1 / F("b") - 5) + + self.assertEqual('SELECT "a"+1/"b"-5 FROM "abc"', str(q)) + + def test__complex_op_exponent_parentheses(self): + q1 = Q.from_("abc").select(F("a") / (F("b") ** 2)) + q2 = Q.from_(self.t).select(self.t.a / (self.t.b**2)) + q3 = Q.from_("abc").select(F("a") ** (F("b") / 2)) + q4 = Q.from_(self.t).select(self.t.a ** (self.t.b / 2)) + q5 = Q.from_("abc").select((F("a") ** F("b")) ** 2) + q6 = Q.from_(self.t).select((self.t.a**self.t.b) ** 2) + + self.assertEqual('SELECT "a"/POW("b",2) FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"/POW("b",2) FROM "abc"', str(q2)) + self.assertEqual('SELECT POW("a","b"/2) FROM "abc"', str(q3)) + self.assertEqual('SELECT POW("a","b"/2) FROM "abc"', str(q4)) + self.assertEqual('SELECT POW(POW("a","b"),2) FROM "abc"', str(q5)) + self.assertEqual('SELECT POW(POW("a","b"),2) FROM "abc"', str(q6)) + + def test__complex_op_exponent_no_parentheses(self): + q1 = Q.from_("abc").select(F("a") ** F("b") ** 2) + q2 = Q.from_(self.t).select(self.t.a**self.t.b**2) + q3 = Q.from_("abc").select(F("a") / F("b") ** 2) + q4 = Q.from_(self.t).select(self.t.a / self.t.b**2) + + self.assertEqual('SELECT POW("a",POW("b",2)) FROM "abc"', str(q1)) + self.assertEqual('SELECT POW("a",POW("b",2)) FROM "abc"', str(q2)) + self.assertEqual('SELECT "a"/POW("b",2) FROM "abc"', str(q3)) + self.assertEqual('SELECT "a"/POW("b",2) FROM "abc"', str(q4)) + + def test__complex_op_function_parentheses(self): + q1 = Q.from_("abc").select(F("a") / (fn.Sum(F("b")) / 2)) + q2 = Q.from_("abc").select(self.t.a / (fn.Sum(self.t.b) / 2)) + q3 = Q.from_("abc").select(fn.Sum(F("a") / (F("b") / 2))) + q4 = Q.from_("abc").select(fn.Sum(self.t.a / (self.t.b / 2))) + + self.assertEqual('SELECT "a"/(SUM("b")/2) FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"/(SUM("b")/2) FROM "abc"', str(q2)) + self.assertEqual('SELECT SUM("a"/("b"/2)) FROM "abc"', str(q3)) + self.assertEqual('SELECT SUM("a"/("b"/2)) FROM "abc"', str(q4)) + + def test__complex_op_modulus_parentheses(self): + q1 = Q.from_("abc").select(F("a") / (F("b") % 2)) + q2 = Q.from_(self.t).select(self.t.a / (self.t.b % 2)) + q3 = Q.from_("abc").select(F("a") % (F("b") / 2)) + q4 = Q.from_(self.t).select(self.t.a % (self.t.b / 2)) + q5 = Q.from_("abc").select(F("a") % (F("b") % 2)) + q6 = Q.from_("abc").select(self.t.a % (self.t.b % 2)) + + self.assertEqual('SELECT "a"/MOD("b",2) FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"/MOD("b",2) FROM "abc"', str(q2)) + self.assertEqual('SELECT MOD("a","b"/2) FROM "abc"', str(q3)) + self.assertEqual('SELECT MOD("a","b"/2) FROM "abc"', str(q4)) + self.assertEqual('SELECT MOD("a",MOD("b",2)) FROM "abc"', str(q5)) + self.assertEqual('SELECT MOD("a",MOD("b",2)) FROM "abc"', str(q6)) + + def test__complex_op_modulus_no_parentheses(self): + q1 = Q.from_("abc").select(F("a") % F("b") % 2) + q2 = Q.from_(self.t).select(self.t.a % self.t.b % 2) + q3 = Q.from_("abc").select(F("a") / F("b") % 2) + q4 = Q.from_(self.t).select(self.t.a / self.t.b % 2) + + self.assertEqual('SELECT MOD(MOD("a","b"),2) FROM "abc"', str(q1)) + self.assertEqual('SELECT MOD(MOD("a","b"),2) FROM "abc"', str(q2)) + self.assertEqual('SELECT MOD("a"/"b",2) FROM "abc"', str(q3)) + self.assertEqual('SELECT MOD("a"/"b",2) FROM "abc"', str(q4)) + + def test__complex_op_floor_parentheses(self): + q1 = Q.from_("abc").select(F("a") / (fn.Floor(F("b")) / 2)) + q2 = Q.from_("abc").select(self.t.a / (fn.Floor(self.t.b) / 2)) + q3 = Q.from_("abc").select(fn.Floor(F("a") / (F("b") / 2))) + q4 = Q.from_("abc").select(fn.Floor(self.t.a / (self.t.b / 2))) + + self.assertEqual('SELECT "a"/(FLOOR("b")/2) FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"/(FLOOR("b")/2) FROM "abc"', str(q2)) + self.assertEqual('SELECT FLOOR("a"/("b"/2)) FROM "abc"', str(q3)) + self.assertEqual('SELECT FLOOR("a"/("b"/2)) FROM "abc"', str(q4)) + + def test__complex_op_nested_parentheses(self): + q1 = Q.from_("abc").select(F("a") / (F("b") / ((F("c") / 2)))) + q2 = Q.from_("abc").select(self.t.a / (self.t.b / ((self.t.c / 2)))) + + self.assertEqual('SELECT "a"/("b"/("c"/2)) FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"/("b"/("c"/2)) FROM "abc"', str(q2)) + + def test__arithmetic_equality(self): + q1 = Q.from_("abc").select(F("a") / 2 == 2) + q2 = Q.from_(self.t).select(self.t.a / 2 == 2) + + self.assertEqual('SELECT "a"/2=2 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"/2=2 FROM "abc"', str(q2)) + + def test__arithmetic_with_function(self): + q1 = Q.from_("abc").select(fn.Sum(F("foo")) + 1) + q2 = Q.from_(self.t).select(fn.Sum(self.t.foo) + 1) + + self.assertEqual('SELECT SUM("foo")+1 FROM "abc"', str(q1)) + self.assertEqual('SELECT SUM("foo")+1 FROM "abc"', str(q2)) + + def test__exponent__number(self): + q1 = Q.from_("abc").select(F("a") ** 2) + q2 = Q.from_(self.t).select(self.t.a**2) + + self.assertEqual('SELECT POW("a",2) FROM "abc"', str(q1)) + self.assertEqual('SELECT POW("a",2) FROM "abc"', str(q2)) + + def test__exponent__decimal(self): + q1 = Q.from_("abc").select(F("a") ** 0.5) + q2 = Q.from_(self.t).select(self.t.a**0.5) + + self.assertEqual('SELECT POW("a",0.5) FROM "abc"', str(q1)) + self.assertEqual('SELECT POW("a",0.5) FROM "abc"', str(q2)) + + def test__modulus__number(self): + q1 = Q.from_("abc").select(F("a") % 2) + q2 = Q.from_(self.t).select(self.t.a % 2) + + self.assertEqual('SELECT MOD("a",2) FROM "abc"', str(q1)) + self.assertEqual('SELECT MOD("a",2) FROM "abc"', str(q2)) + + def test__floor(self): + q1 = Q.from_("abc").select(fn.Floor(F("foo"))) + q2 = Q.from_(self.t).select(fn.Floor(self.t.foo)) + + self.assertEqual('SELECT FLOOR("foo") FROM "abc"', str(q1)) + self.assertEqual('SELECT FLOOR("foo") FROM "abc"', str(q2)) + + +class AggregationTests(unittest.TestCase): + def test__count(self): + q = Q.from_("abc").select(fn.Count(F("foo"))) + + self.assertEqual('SELECT COUNT("foo") FROM "abc"', str(q)) + + def test__count__star(self): + q = Q.from_("abc").select(fn.Count("*")) + + self.assertEqual('SELECT COUNT(*) FROM "abc"', str(q)) + + def test__sum(self): + q = Q.from_("abc").select(fn.Sum(F("foo"))) + + self.assertEqual('SELECT SUM("foo") FROM "abc"', str(q)) + + def test__avg(self): + q = Q.from_("abc").select(fn.Avg(F("foo"))) + + self.assertEqual('SELECT AVG("foo") FROM "abc"', str(q)) + + def test__first(self): + q = Q.from_("abc").select(fn.First(F("foo"))) + + self.assertEqual('SELECT FIRST("foo") FROM "abc"', str(q)) + + def test__last(self): + q = Q.from_("abc").select(fn.Last(F("foo"))) + + self.assertEqual('SELECT LAST("foo") FROM "abc"', str(q)) + + def test__min(self): + q = Q.from_("abc").select(fn.Min(F("foo"))) + + self.assertEqual('SELECT MIN("foo") FROM "abc"', str(q)) + + def test__max(self): + q = Q.from_("abc").select(fn.Max(F("foo"))) + + self.assertEqual('SELECT MAX("foo") FROM "abc"', str(q)) + + def test__std(self): + q = Q.from_("abc").select(fn.Std(F("foo"))) + + self.assertEqual('SELECT STD("foo") FROM "abc"', str(q)) + + def test__stddev(self): + q = Q.from_("abc").select(fn.StdDev(F("foo"))) + + self.assertEqual('SELECT STDDEV("foo") FROM "abc"', str(q)) + + def test__approx_percentile(self): + q = Q.from_("abc").select(fn.ApproximatePercentile(F("foo"), 0.5)) + + self.assertEqual( + 'SELECT APPROXIMATE_PERCENTILE("foo" USING PARAMETERS percentile=0.5) FROM "abc"', + str(q), + ) + + def test__subquery_in_params_functions(self): + subquery = Query.from_('table').select('id') + func = fn.Function('func', 'id', subquery) + self.assertEqual("func('id',(SELECT id FROM table))", func.get_sql()) + + +class ConditionTests(unittest.TestCase): + def test__case__raw(self): + q = Q.from_("abc").select(Case().when(F("foo") == 1, "a")) + + self.assertEqual('SELECT CASE WHEN "foo"=1 THEN \'a\' END FROM "abc"', str(q)) + + def test__case__else(self): + q = Q.from_("abc").select(Case().when(F("foo") == 1, "a").else_("b")) + + self.assertEqual("SELECT CASE WHEN \"foo\"=1 THEN 'a' ELSE 'b' END FROM \"abc\"", str(q)) + + def test__case__field(self): + q = Q.from_("abc").select(Case().when(F("foo") == 1, F("bar")).else_(F("buz"))) + + self.assertEqual('SELECT CASE WHEN "foo"=1 THEN "bar" ELSE "buz" END FROM "abc"', str(q)) + + def test__case__multi(self): + q = Q.from_("abc").select(Case().when(F("foo") > 0, F("fiz")).when(F("bar") <= 0, F("buz")).else_(1)) + + self.assertEqual( + 'SELECT CASE WHEN "foo">0 THEN "fiz" WHEN "bar"<=0 THEN "buz" ELSE 1 END FROM "abc"', + str(q), + ) + + def test__case__no_cases(self): + with self.assertRaises(CaseException): + q = Q.from_("abc").select(Case()) + + str(q) + + +class StringTests(unittest.TestCase): + t = T("abc") + + def test__ascii__str(self): + q = Q.select(fn.Ascii("2")) + + self.assertEqual("SELECT ASCII('2')", str(q)) + + def test__ascii__int(self): + q = Q.select(fn.Ascii(2)) + + self.assertEqual("SELECT ASCII(2)", str(q)) + + def test__ascii__field(self): + q = Q.from_(self.t).select(fn.Ascii(self.t.foo)) + + self.assertEqual('SELECT ASCII("foo") FROM "abc"', str(q)) + + def test__bin__str(self): + q = Q.select(fn.Bin("2")) + + self.assertEqual("SELECT BIN('2')", str(q)) + + def test__bin__int(self): + q = Q.select(fn.Bin(2)) + + self.assertEqual("SELECT BIN(2)", str(q)) + + def test__bin__field(self): + q = Q.from_(self.t).select(fn.Bin(self.t.foo)) + + self.assertEqual('SELECT BIN("foo") FROM "abc"', str(q)) + + def test__concat__str(self): + q = Q.select(fn.Concat("p", "y", "q", "b")) + + self.assertEqual("SELECT CONCAT('p','y','q','b')", str(q)) + + def test__concat__field(self): + q = Q.from_(self.t).select(fn.Concat(self.t.foo, self.t.bar)) + + self.assertEqual('SELECT CONCAT("foo","bar") FROM "abc"', str(q)) + + def test__insert__str(self): + q = Q.select(fn.Insert("Quadratic", 3, 4, "What")) + + self.assertEqual("SELECT INSERT('Quadratic',3,4,'What')", str(q)) + + def test__insert__field(self): + q = Q.from_(self.t).select(fn.Insert(self.t.foo, 3, 4, self.t.bar)) + + self.assertEqual('SELECT INSERT("foo",3,4,"bar") FROM "abc"', str(q)) + + def test__lower__str(self): + q = Q.select(fn.Lower("ABC")) + + self.assertEqual("SELECT LOWER('ABC')", str(q)) + + def test__lower__field(self): + q = Q.from_(self.t).select(fn.Lower(self.t.foo)) + + self.assertEqual('SELECT LOWER("foo") FROM "abc"', str(q)) + + def test__length__str(self): + q = Q.select(fn.Length("ABC")) + + self.assertEqual("SELECT LENGTH('ABC')", str(q)) + + def test__length__field(self): + q = Q.from_(self.t).select(fn.Length(self.t.foo)) + + self.assertEqual('SELECT LENGTH("foo") FROM "abc"', str(q)) + + def test__substring(self): + q = Q.from_(self.t).select(fn.Substring(self.t.foo, 2, 6)) + + self.assertEqual('SELECT SUBSTRING("foo",2,6) FROM "abc"', str(q)) + + def test__replace__str(self): + q = Q.select(fn.Replace("ABC_DEF", "_", " ")) + self.assertEqual("SELECT REPLACE('ABC_DEF','_',' ')", str(q)) + + def test__replace__field(self): + q = Q.from_(self.t).select(fn.Replace(self.t.foobar, self.t.foo, self.t.bar)) + self.assertEqual('SELECT REPLACE("foobar","foo","bar") FROM "abc"', str(q)) + + +class SplitPartFunctionTests(unittest.TestCase): + t = T("abc") + + def test__split_part(self): + q = VerticaQuery.from_(self.t).select(fn.SplitPart(self.t.foo, "|", 3)) + + self.assertEqual('SELECT SPLIT_PART("foo",\'|\',3) FROM "abc"', str(q)) + + +class RegexpLikeFunctionTests(unittest.TestCase): + t = T("abc") + + def test__regexp_like(self): + q = VerticaQuery.from_(self.t).select(fn.RegexpLike(self.t.foo, "^a", "x")) + + self.assertEqual("SELECT REGEXP_LIKE(\"foo\",'^a','x') FROM \"abc\"", str(q)) + + +class CastTests(unittest.TestCase): + t = T("abc") + + def test__cast__as(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.UNSIGNED)) + + self.assertEqual('SELECT CAST("foo" AS UNSIGNED) FROM "abc"', str(q)) + + def test__cast__signed(self): + q1 = Q.from_(self.t).select(fn.Signed(self.t.foo)) + q2 = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.SIGNED)) + + self.assertEqual('SELECT CAST("foo" AS SIGNED) FROM "abc"', str(q1)) + self.assertEqual('SELECT CAST("foo" AS SIGNED) FROM "abc"', str(q2)) + + def test__cast__unsigned(self): + q1 = Q.from_(self.t).select(fn.Unsigned(self.t.foo)) + q2 = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.UNSIGNED)) + + self.assertEqual('SELECT CAST("foo" AS UNSIGNED) FROM "abc"', str(q1)) + self.assertEqual('SELECT CAST("foo" AS UNSIGNED) FROM "abc"', str(q2)) + + def test__cast__date(self): + q1 = Q.from_(self.t).select(fn.Date(self.t.foo)) + q2 = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.DATE)) + + self.assertEqual('SELECT DATE("foo") FROM "abc"', str(q1)) + self.assertEqual('SELECT CAST("foo" AS DATE) FROM "abc"', str(q2)) + + def test__cast__timestamp(self): + q1 = Q.from_(self.t).select(fn.Timestamp(self.t.foo)) + q2 = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.TIMESTAMP)) + + self.assertEqual('SELECT TIMESTAMP("foo") FROM "abc"', str(q1)) + self.assertEqual('SELECT CAST("foo" AS TIMESTAMP) FROM "abc"', str(q2)) + + def test__cast__char(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.CHAR)) + + self.assertEqual('SELECT CAST("foo" AS CHAR) FROM "abc"', str(q)) + + def test__cast__char_with_arg(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.VARCHAR(24))) + + self.assertEqual('SELECT CAST("foo" AS VARCHAR(24)) FROM "abc"', str(q)) + + def test__cast__varchar(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.VARCHAR)) + + self.assertEqual('SELECT CAST("foo" AS VARCHAR) FROM "abc"', str(q)) + + def test__cast__varchar_with_arg(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.VARCHAR(24))) + + self.assertEqual('SELECT CAST("foo" AS VARCHAR(24)) FROM "abc"', str(q)) + + def test__cast__long_varchar(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.LONG_VARCHAR)) + + self.assertEqual('SELECT CAST("foo" AS LONG VARCHAR) FROM "abc"', str(q)) + + def test__cast__long_varchar_with_arg(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.LONG_VARCHAR(24))) + + self.assertEqual('SELECT CAST("foo" AS LONG VARCHAR(24)) FROM "abc"', str(q)) + + def test__cast__binary(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.BINARY)) + + self.assertEqual('SELECT CAST("foo" AS BINARY) FROM "abc"', str(q)) + + def test__cast__binary_with_arg(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.BINARY(24))) + + self.assertEqual('SELECT CAST("foo" AS BINARY(24)) FROM "abc"', str(q)) + + def test__cast__varbinary(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.VARBINARY)) + + self.assertEqual('SELECT CAST("foo" AS VARBINARY) FROM "abc"', str(q)) + + def test__cast__varbinary_with_arg(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.VARBINARY(24))) + + self.assertEqual('SELECT CAST("foo" AS VARBINARY(24)) FROM "abc"', str(q)) + + def test__cast__long_varbinary(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.LONG_VARBINARY)) + + self.assertEqual('SELECT CAST("foo" AS LONG VARBINARY) FROM "abc"', str(q)) + + def test__cast__long_varbinary_with_arg(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.LONG_VARBINARY(24))) + + self.assertEqual('SELECT CAST("foo" AS LONG VARBINARY(24)) FROM "abc"', str(q)) + + def test__cast__boolean(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.BOOLEAN)) + + self.assertEqual('SELECT CAST("foo" AS BOOLEAN) FROM "abc"', str(q)) + + def test__cast__integer(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.INTEGER)) + + self.assertEqual('SELECT CAST("foo" AS INTEGER) FROM "abc"', str(q)) + + def test__cast__float(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.FLOAT)) + + self.assertEqual('SELECT CAST("foo" AS FLOAT) FROM "abc"', str(q)) + + def test__cast__numeric(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.NUMERIC)) + + self.assertEqual('SELECT CAST("foo" AS NUMERIC) FROM "abc"', str(q)) + + def test__tochar__(self): + q = Q.from_(self.t).select(fn.ToChar(self.t.foo, "SomeFormat")) + + self.assertEqual('SELECT TO_CHAR("foo",\'SomeFormat\') FROM "abc"', str(q)) + + +class DateFunctionsTests(unittest.TestCase): + dt = F("dt") + t = T("abc") + t2 = T("efg") + + def _test_extract_datepart(self, date_part): + q = Q.from_(self.t).select(fn.Extract(date_part, self.t.foo)) + + value = getattr(date_part, 'value', date_part) + self.assertEqual('SELECT EXTRACT(%s FROM "foo") FROM "abc"' % value, str(q)) + + def test_extract_microsecond(self): + self._test_extract_datepart(DatePart.microsecond) + self._test_extract_datepart(DatePart.microsecond.value) + + def test_extract_second(self): + self._test_extract_datepart(DatePart.second) + self._test_extract_datepart(DatePart.second.value) + + def test_extract_minute(self): + self._test_extract_datepart(DatePart.minute) + self._test_extract_datepart(DatePart.minute.value) + + def test_extract_hour(self): + self._test_extract_datepart(DatePart.hour) + self._test_extract_datepart(DatePart.hour.value) + + def test_extract_day(self): + self._test_extract_datepart(DatePart.day) + self._test_extract_datepart(DatePart.day.value) + + def test_extract_week(self): + self._test_extract_datepart(DatePart.week) + self._test_extract_datepart(DatePart.week.value) + + def test_extract_month(self): + self._test_extract_datepart(DatePart.month) + self._test_extract_datepart(DatePart.month.value) + + def test_extract_quarter(self): + self._test_extract_datepart(DatePart.quarter) + self._test_extract_datepart(DatePart.quarter.value) + + def test_extract_year(self): + self._test_extract_datepart(DatePart.year) + self._test_extract_datepart(DatePart.year.value) + + def test_extract_join(self): + q = Q.from_(self.t).join(self.t2).on(self.t.id == self.t2.t_id).select(fn.Extract(DatePart.year, self.t.foo)) + + self.assertEqual( + 'SELECT EXTRACT(YEAR FROM "abc"."foo") FROM "abc" ' 'JOIN "efg" ON "abc"."id"="efg"."t_id"', str(q) + ) + + def test_timestampadd(self): + a = fn.TimestampAdd("year", 1, "2017-10-01") + self.assertEqual(str(a), "TIMESTAMPADD(year,1,'2017-10-01')") + + def test_time_diff(self): + a = fn.TimeDiff("18:00:00", "10:00:00") + self.assertEqual(str(a), "TIMEDIFF('18:00:00','10:00:00')") + + def test_date_add(self): + a = fn.DateAdd("year", 1, "2017-10-01") + self.assertEqual(str(a), "DATE_ADD(year,1,'2017-10-01')") + + def test_now(self): + query = Query.select(fn.Now()) + + self.assertEqual("SELECT NOW()", str(query)) + + def test_utc_timestamp(self): + query = Query.select(fn.UtcTimestamp()) + + self.assertEqual("SELECT UTC_TIMESTAMP()", str(query)) + + def test_current_date(self): + query = Query.select(fn.CurDate()) + + self.assertEqual("SELECT CURRENT_DATE()", str(query)) + + def test_current_time(self): + query = Query.select(fn.CurTime()) + + self.assertEqual("SELECT CURRENT_TIME()", str(query)) + + def test_current_timestamp(self): + query = Query.select(fn.CurTimestamp()) + + self.assertEqual("SELECT CURRENT_TIMESTAMP", str(query)) + + def test_current_timestamp_with_alias(self): + query = Query.select(fn.CurTimestamp("ts")) + + self.assertEqual('SELECT CURRENT_TIMESTAMP "ts"', str(query)) + + def test_to_date(self): + q1 = fn.ToDate("2019-06-21", "yyyy-mm-dd") + q2 = Query.from_(self.t).select(fn.ToDate("2019-06-21", "yyyy-mm-dd")) + q3 = Query.from_(self.t).select(fn.ToDate(F("foo"), "yyyy-mm-dd")) + + self.assertEqual(str(q1), "TO_DATE('2019-06-21','yyyy-mm-dd')") + self.assertEqual(str(q2), "SELECT TO_DATE('2019-06-21','yyyy-mm-dd') FROM \"abc\"") + self.assertEqual(str(q3), 'SELECT TO_DATE("foo",\'yyyy-mm-dd\') FROM "abc"') + + +class NullFunctionsTests(unittest.TestCase): + def test_isnull(self): + q = Q.from_("abc").select(fn.IsNull(F("foo"))) + + self.assertEqual('SELECT ISNULL("foo") FROM "abc"', str(q)) + + def test_coalesce(self): + q = Q.from_("abc").select(fn.Coalesce(F("foo"), 0)) + + self.assertEqual('SELECT COALESCE("foo",0) FROM "abc"', str(q)) + + def test_nullif(self): + q = Q.from_("abc").select(fn.NullIf(F("foo"), 0)) + + self.assertEqual('SELECT NULLIF("foo",0) FROM "abc"', str(q)) + + def test_nvl(self): + q = Q.from_("abc").select(fn.NVL(F("foo"), 0)) + + self.assertEqual('SELECT NVL("foo",0) FROM "abc"', str(q)) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/test_groupby_modifiers.py b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/test_groupby_modifiers.py new file mode 100644 index 0000000000000000000000000000000000000000..978834c2409f4b4800fedb9b1bb2538a31d0f31c --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/test_groupby_modifiers.py @@ -0,0 +1,168 @@ +import unittest + +from pypika import Query, Rollup, RollupException, Table, functions as fn + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + + +class RollupTests(unittest.TestCase): + table = Table("abc") + + def test_mysql_one_groupby(self): + q = ( + Query.from_(self.table) + .select(self.table.foo, fn.Sum(self.table.bar)) + .rollup(self.table.foo, vendor="mysql") + ) + + self.assertEqual('SELECT "foo",SUM("bar") FROM "abc" GROUP BY "foo" WITH ROLLUP', str(q)) + + def test_mysql_rollup_two_groupbys(self): + q = ( + Query.from_(self.table) + .select(self.table.foo, self.table.fiz, fn.Sum(self.table.bar)) + .rollup(self.table.foo, self.table.fiz, vendor="mysql") + ) + + self.assertEqual( + 'SELECT "foo","fiz",SUM("bar") FROM "abc" GROUP BY "foo","fiz" WITH ROLLUP', + str(q), + ) + + def test_no_rollup_before_groupby(self): + with self.assertRaises(RollupException): + Query.from_(self.table).select(self.table.foo, fn.Sum(self.table.bar)).rollup(vendor="mysql") + + def test_no_rollup_after_rollup_mysql(self): + with self.assertRaises(AttributeError): + Query.from_(self.table).select(self.table.foo, self.table.fiz, fn.Sum(self.table.bar)).rollup( + self.table.foo, vendor="mysql" + ).rollup(self.table.fiz, vendor="mysql") + + def test_verticaoracle_func_one_groupby(self): + q = Query.from_(self.table).select(self.table.foo, fn.Sum(self.table.bar)).groupby(Rollup(self.table.foo)) + + self.assertEqual('SELECT "foo",SUM("bar") FROM "abc" GROUP BY ROLLUP("foo")', str(q)) + + def test_verticaoracle_func_two_groupbys(self): + q = ( + Query.from_(self.table) + .select(self.table.foo, self.table.fiz, fn.Sum(self.table.bar)) + .groupby( + Rollup( + self.table.foo, + self.table.fiz, + ) + ) + ) + + self.assertEqual( + 'SELECT "foo","fiz",SUM("bar") FROM "abc" GROUP BY ROLLUP("foo","fiz")', + str(q), + ) + + def test_verticaoracle_func_partial(self): + q = ( + Query.from_(self.table) + .select(self.table.foo, self.table.fiz, self.table.buz, fn.Sum(self.table.bar)) + .groupby( + Rollup( + self.table.foo, + self.table.fiz, + ), + self.table.buz, + ) + ) + + self.assertEqual( + 'SELECT "foo","fiz","buz",SUM("bar") FROM "abc" GROUP BY ROLLUP("foo","fiz"),"buz"', + str(q), + ) + + def test_verticaoracle_from_groupbys(self): + q = Query.from_(self.table).select(self.table.foo, fn.Sum(self.table.bar)).rollup(self.table.foo) + + self.assertEqual('SELECT "foo",SUM("bar") FROM "abc" GROUP BY ROLLUP("foo")', str(q)) + + def test_verticaoracle_from_two_groupbys(self): + q = ( + Query.from_(self.table) + .select(self.table.foo, self.table.fiz, fn.Sum(self.table.bar)) + .rollup( + self.table.foo, + self.table.fiz, + ) + ) + + self.assertEqual( + 'SELECT "foo","fiz",SUM("bar") FROM "abc" GROUP BY ROLLUP("foo","fiz")', + str(q), + ) + + def test_verticaoracle_from_parameters(self): + q = ( + Query.from_(self.table) + .select(self.table.foo, self.table.fiz, fn.Sum(self.table.bar)) + .groupby( + self.table.foo, + ) + .rollup( + self.table.fiz, + ) + ) + + self.assertEqual( + 'SELECT "foo","fiz",SUM("bar") FROM "abc" GROUP BY "foo",ROLLUP("fiz")', + str(q), + ) + + def test_verticaoracle_multiple_rollups(self): + q = ( + Query.from_(self.table) + .select(self.table.foo, self.table.fiz, fn.Sum(self.table.bar)) + .rollup( + self.table.foo, + ) + .rollup( + self.table.fiz, + ) + ) + + self.assertEqual( + 'SELECT "foo","fiz",SUM("bar") FROM "abc" GROUP BY ROLLUP("foo","fiz")', + str(q), + ) + + def test_verticaoracle_rollups_with_parity(self): + q = ( + Query.from_(self.table) + .select( + self.table.buz, + ) + .rollup( + [self.table.foo, self.table.bar], + self.table.fiz, + ) + ) + + self.assertEqual('SELECT "buz" FROM "abc" GROUP BY ROLLUP(("foo","bar"),"fiz")', str(q)) + + def test_verticaoracle_rollups_with_multiple_rollups_and_parity(self): + q = ( + Query.from_(self.table) + .select( + self.table.buz, + ) + .rollup( + [self.table.foo, self.table.bar], + ) + .rollup( + [self.table.fiz, self.table.buz], + ) + ) + + self.assertEqual( + 'SELECT "buz" FROM "abc" GROUP BY ROLLUP(("foo","bar"),("fiz","buz"))', + str(q), + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/test_immutability.py b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/test_immutability.py new file mode 100644 index 0000000000000000000000000000000000000000..ee539bfa1e9c4509b929e7a86a03f098dd923515 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/test_immutability.py @@ -0,0 +1,99 @@ +import unittest + +from pypika import ( + AliasedQuery, + Query, + Tables, +) + + +class ImmutabilityTests(unittest.TestCase): + table_a, table_b, table_c = Tables("a", "b", "c") + + def test_select_returns_new_query_instance(self): + query_a = Query.from_(self.table_a).select(self.table_a.foo) + query_b = query_a.select(self.table_a.bar) + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_groupby_returns_new_query_instance(self): + query_a = Query.from_(self.table_a).select(self.table_a.foo).groupby(self.table_a.foo) + query_b = query_a.groupby(self.table_a.bar) + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_orderby_return_new_query_instance(self): + query_a = Query.from_(self.table_a).select(self.table_a.foo).orderby(self.table_a.foo) + query_b = query_a.orderby(self.table_a.bar) + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_join_return_new_query_instance(self): + base = Query.from_(self.table_a).select(self.table_a.foo) + query_a = base.join(self.table_b).on(self.table_a.foo == self.table_b.bar).select(self.table_b.bar) + query_b = query_a.join(self.table_c).on(self.table_a.foo == self.table_c.baz).select(self.table_c.baz) + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_use_index_return_new_query_instance(self): + query_a = Query.from_(self.table_a).select(self.table_a.foo).use_index('idx1') + query_b = query_a.use_index('idx2') + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_force_index_return_new_query_instance(self): + query_a = Query.from_(self.table_a).select(self.table_a.foo).force_index('idx1') + query_b = query_a.force_index('idx2') + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_with_return_new_query_instance(self): + alias_1 = Query.from_(self.table_a).select(self.table_a.foo) + alias_2 = Query.from_(self.table_b).select(self.table_b.bar) + query_a = Query.from_(AliasedQuery('a1')).select('foo').with_(alias_1, 'a1') + query_b = query_a.with_(alias_2, 'a2') + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_insert_into_return_new_query_instance(self): + query_a = Query.into(self.table_a).insert('foo1') + query_b = query_a.insert('foo2') + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_replace_into_return_new_query_instance(self): + query_a = Query.into(self.table_a).replace('foo') + query_b = query_a.replace('bar') + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_update_set_return_new_query_instance(self): + query_a = Query.update(self.table_a).set(self.table_a.foo, 'foo') + query_b = query_a.set(self.table_a.bar, 'bar') + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_queries_after_join(self): + query1 = Query.from_(self.table_a).select(self.table_a.foo) + query2 = query1.join(self.table_b).on(self.table_a.foo == self.table_b.bar).select(self.table_b.buz) + + self.assertEqual('SELECT "foo" FROM "a"', str(query1)) + self.assertEqual( + 'SELECT "a"."foo","b"."buz" FROM "a" JOIN "b" ON "a"."foo"="b"."bar"', + str(query2), + ) + + def test_immutable_kwarg_on_query_builder_disables_immutability(self): + query0 = Query.from_(self.table_a, immutable=False) + query1 = query0.select(self.table_a.foo) + self.assertIs(query0, query1) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/test_inserts.py b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/test_inserts.py new file mode 100644 index 0000000000000000000000000000000000000000..f86efd7a76dc498a69b61c6353951695f1933a61 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/test_inserts.py @@ -0,0 +1,885 @@ +import unittest + +from pypika import ( + AliasedQuery, + Case, + Field as F, + MySQLQuery, + PostgreSQLQuery, + Query, + Table, + Tables, + functions as fn, +) +from pypika.functions import ( + Avg, + Cast, +) +from pypika.terms import Values +from pypika.utils import QueryException + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + + +class InsertIntoTests(unittest.TestCase): + table_abc = Table("abc") + + def test_insert_one_column(self): + query = Query.into(self.table_abc).insert(1) + + self.assertEqual('INSERT INTO "abc" VALUES (1)', str(query)) + + def test_insert_one_column_single_element_array(self): + query = Query.into(self.table_abc).insert((1,)) + + self.assertEqual('INSERT INTO "abc" VALUES (1)', str(query)) + + def test_insert_one_column_multi_element_array(self): + query = Query.into(self.table_abc).insert((1,), (2,)) + + self.assertEqual('INSERT INTO "abc" VALUES (1),(2)', str(query)) + + def test_insert_single_row_with_array_value(self): + query = Query.into(self.table_abc).insert(1, ["a", "b", "c"]) + + self.assertEqual("INSERT INTO \"abc\" VALUES (1,['a','b','c'])", str(query)) + + def test_insert_multiple_rows_with_array_value(self): + query = Query.into(self.table_abc).insert( + (1, ["a", "b", "c"]), + (2, ["c", "d", "e"]), + ) + + self.assertEqual( + 'INSERT INTO "abc" ' "VALUES (1,['a','b','c']),(2,['c','d','e'])", + str(query), + ) + + def test_insert_all_columns(self): + query = Query.into(self.table_abc).insert(1, "a", True) + + self.assertEqual("INSERT INTO \"abc\" VALUES (1,'a',true)", str(query)) + + def test_insert_all_columns_single_element(self): + query = Query.into(self.table_abc).insert((1, "a", True)) + + self.assertEqual("INSERT INTO \"abc\" VALUES (1,'a',true)", str(query)) + + def test_insert_all_columns_multi_rows(self): + query = Query.into(self.table_abc).insert((1, "a", True), (2, "b", False)) + + self.assertEqual("INSERT INTO \"abc\" VALUES (1,'a',true),(2,'b',false)", str(query)) + + def test_insert_all_columns_multi_rows_chained(self): + query = Query.into(self.table_abc).insert(1, "a", True).insert(2, "b", False) + + self.assertEqual("INSERT INTO \"abc\" VALUES (1,'a',true),(2,'b',false)", str(query)) + + def test_insert_all_columns_multi_rows_chained_mixed(self): + query = Query.into(self.table_abc).insert((1, "a", True), (2, "b", False)).insert(3, "c", True) + + self.assertEqual( + 'INSERT INTO "abc" VALUES ' "(1,'a',true),(2,'b',false)," "(3,'c',true)", + str(query), + ) + + def test_insert_all_columns_multi_rows_chained_multiple_rows(self): + query = ( + Query.into(self.table_abc).insert((1, "a", True), (2, "b", False)).insert((3, "c", True), (4, "d", False)) + ) + + self.assertEqual( + 'INSERT INTO "abc" VALUES ' "(1,'a',true),(2,'b',false)," "(3,'c',true),(4,'d',false)", + str(query), + ) + + def test_insert_selected_columns(self): + query = ( + Query.into(self.table_abc) + .columns(self.table_abc.foo, self.table_abc.bar, self.table_abc.buz) + .insert(1, "a", True) + ) + + self.assertEqual('INSERT INTO "abc" ("foo","bar","buz") VALUES (1,\'a\',true)', str(query)) + + def test_insert_empty_columns(self): + query = Query.into(self.table_abc).columns().insert(1, "a", True) + + self.assertEqual('INSERT INTO "abc" VALUES (1,\'a\',true)', str(query)) + + def test_insert_selected_columns_type_list(self): + query = ( + Query.into(self.table_abc) + .columns([self.table_abc.foo, self.table_abc.bar, self.table_abc.buz]) + .insert(1, "a", True) + ) + + self.assertEqual('INSERT INTO "abc" ("foo","bar","buz") VALUES (1,\'a\',true)', str(query)) + + def test_insert_empty_columns_type_list(self): + query = Query.into(self.table_abc).columns([]).insert(1, "a", True) + + self.assertEqual('INSERT INTO "abc" VALUES (1,\'a\',true)', str(query)) + + def test_insert_selected_columns_type_tuple(self): + query = ( + Query.into(self.table_abc) + .columns((self.table_abc.foo, self.table_abc.bar, self.table_abc.buz)) + .insert(1, "a", True) + ) + + self.assertEqual('INSERT INTO "abc" ("foo","bar","buz") VALUES (1,\'a\',true)', str(query)) + + def test_insert_empty_columns_type_tuple(self): + query = Query.into(self.table_abc).columns(()).insert(1, "a", True) + + self.assertEqual('INSERT INTO "abc" VALUES (1,\'a\',true)', str(query)) + + def test_insert_none_skipped(self): + query = Query.into(self.table_abc).insert() + + self.assertEqual("", str(query)) + + def test_insert_ignore(self): + query = Query.into(self.table_abc).insert(1).ignore() + + self.assertEqual('INSERT IGNORE INTO "abc" VALUES (1)', str(query)) + + def test_insert_null(self): + query = Query.into(self.table_abc).insert(None) + + self.assertEqual('INSERT INTO "abc" VALUES (NULL)', str(query)) + + def test_insert_column_using_table_alias(self): + q = self.table_abc.insert(1) + self.assertEqual('INSERT INTO "abc" VALUES (1)', str(q)) + + def test_insert_column_using_alias_with_chain(self): + q = self.table_abc.insert(1, "a", True).insert(2, "b", False) + self.assertEqual("INSERT INTO \"abc\" VALUES (1,'a',true),(2,'b',false)", str(q)) + + def test_insert_with_statement(self): + sub_query = Query().select(self.table_abc.id).from_(self.table_abc) + aliased = AliasedQuery('sub_qs') + + q = Query().with_(sub_query, 'sub_qs').into(self.table_abc).select(aliased.id).from_(aliased) + self.assertEqual( + 'WITH sub_qs AS (SELECT "id" FROM "abc") INSERT INTO "abc" SELECT "sub_qs"."id" FROM sub_qs', str(q) + ) + + +class PostgresInsertIntoOnConflictTests(unittest.TestCase): + table_abc = Table("abc") + + def test_insert_on_conflict_do_nothing_field(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).on_conflict(self.table_abc.id).do_nothing() + + self.assertEqual('INSERT INTO "abc" VALUES (1) ON CONFLICT ("id") DO NOTHING', str(query)) + + def test_insert_on_conflict_do_nothing_multiple_fields(self): + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1) + .on_conflict(self.table_abc.id, self.table_abc.sub_id) + .do_nothing() + ) + + self.assertEqual('INSERT INTO "abc" VALUES (1) ON CONFLICT ("id", "sub_id") DO NOTHING', str(query)) + + def test_insert_on_conflict_do_nothing_field_str(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).on_conflict("id").do_nothing() + + self.assertEqual('INSERT INTO "abc" VALUES (1) ON CONFLICT ("id") DO NOTHING', str(query)) + + def test_insert_on_conflict_do_nothing_multiple_fields_str(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).on_conflict("id", "sub_id").do_nothing() + + self.assertEqual('INSERT INTO "abc" VALUES (1) ON CONFLICT ("id", "sub_id") DO NOTHING', str(query)) + + def test_insert_on_conflict_do_nothing_mixed_fields(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).on_conflict("id", self.table_abc.sub_id).do_nothing() + + self.assertEqual('INSERT INTO "abc" VALUES (1) ON CONFLICT ("id", "sub_id") DO NOTHING', str(query)) + + def test_insert_on_conflict_do_update_field(self): + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict(self.table_abc.id) + .do_update(self.table_abc.name, "m") + ) + + self.assertEqual( + "INSERT INTO \"abc\" VALUES (1,'m') ON CONFLICT (\"id\") DO UPDATE SET \"name\"='m'", + str(query), + ) + + def test_insert_on_conflict_do_update_multiple_fields(self): + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict(self.table_abc.id, self.table_abc.sub_id) + .do_update(self.table_abc.name, "m") + ) + + self.assertEqual( + "INSERT INTO \"abc\" VALUES (1,'m') ON CONFLICT (\"id\", \"sub_id\") DO UPDATE SET \"name\"='m'", + str(query), + ) + + def test_insert_on_conflict_do_update_field_str(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1, "m").on_conflict("id").do_update("name", "m") + + self.assertEqual( + "INSERT INTO \"abc\" VALUES (1,'m') ON CONFLICT (\"id\") DO UPDATE SET \"name\"='m'", + str(query), + ) + + def test_insert_on_conflict_do_update_multiple_fields_str(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1, "m").on_conflict("id", "sub_id").do_update("name", "m") + + self.assertEqual( + "INSERT INTO \"abc\" VALUES (1,'m') ON CONFLICT (\"id\", \"sub_id\") DO UPDATE SET \"name\"='m'", + str(query), + ) + + def test_insert_on_conflict_do_update_multiple_mixed_fields(self): + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict("id", self.table_abc.sub_id) + .do_update("name", "m") + ) + + self.assertEqual( + "INSERT INTO \"abc\" VALUES (1,'m') ON CONFLICT (\"id\", \"sub_id\") DO UPDATE SET \"name\"='m'", + str(query), + ) + + def test_insert_on_conflict_no_handler(self): + with self.assertRaises(QueryException): + query = str(PostgreSQLQuery.into(self.table_abc).insert(1).on_conflict(self.table_abc.id)) + + def test_insert_on_conflict_two_handlers_do_nothing(self): + with self.assertRaises(QueryException): + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1) + .on_conflict("id") + .do_nothing() + .do_update(self.table_abc.name, "m") + ) + + def test_insert_on_conflict_two_handlers_do_update(self): + with self.assertRaises(QueryException): + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1) + .on_conflict(self.table_abc.id) + .do_update(self.table_abc.name, "m") + .do_nothing() + ) + + def test_non_insert_on_conflict_do_nothing(self): + with self.assertRaises(QueryException): + query = PostgreSQLQuery.update(self.table_abc).set("foo", "bar").on_conflict("id").do_nothing() + + def test_non_insert_on_conflict_do_update(self): + with self.assertRaises(QueryException): + query = ( + PostgreSQLQuery.update(self.table_abc).set("foo", "bar").on_conflict("id").do_update(["name"], ["m"]) + ) + + def test_insert_on_fieldless_conflict_do_nothing(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).on_conflict(None).do_nothing() + + self.assertEqual('INSERT INTO "abc" VALUES (1) ON CONFLICT DO NOTHING', str(query)) + + def test_insert_on_fieldless_conflict_do_update_field(self): + with self.assertRaises(QueryException): + query = str( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict(None) + .do_update(self.table_abc.name, "m") + ) + + def test_on_conflict_from_subquery(self): + table_bcd = Table('bcd') + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(self.table_abc.fname, self.table_abc.lname) + .select(table_bcd.fname, table_bcd.lname) + .from_(table_bcd) + .on_conflict(self.table_abc.id, self.table_abc.sub_id) + .do_update(self.table_abc.fname, 1) + .do_update(self.table_abc.lname, table_bcd.lname) + .do_update( + self.table_abc.cname, + Case().when(self.table_abc.cname.eq('cname'), 'new_name').else_(self.table_abc.cname), + ) + ) + + self.assertEqual( + 'INSERT INTO "abc" VALUES ("fname","lname") ' + 'ON CONFLICT ("id", "sub_id") ' + 'DO UPDATE SET "fname"=1,"lname"="bcd"."lname",' + '"cname"=CASE WHEN "abc"."cname"=\'cname\' THEN \'new_name\' ELSE "abc"."cname" END', + str(query), + ) + + def test_on_conflict_where_empty_conflict_fields_do_nothing(self): + with self.assertRaises(QueryException): + ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict() + .where(self.table_abc.abc.eq(0)) + .where(self.table_abc.cde.eq(0)) + .do_nothing() + ) + + def test_on_conflict_where_conflict_fields_do_nothing(self): + qs = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict('id') + .where(self.table_abc.abc.eq(0)) + .where(self.table_abc.cde.eq(0)) + .do_nothing() + ) + self.assertEqual( + '''INSERT INTO "abc" VALUES (1,'m') ON CONFLICT ("id") WHERE "abc"=0 AND "cde"=0 DO NOTHING''', str(qs) + ) + + def test_on_conflict_where_empty_conflict_fields_do_update(self): + with self.assertRaises(QueryException): + ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict() + .where(self.table_abc.abc.eq(0)) + .where(self.table_abc.cde.eq(0)) + .do_update('field', 'val') + ) + + def test_on_conflict_where_conflict_fields_do_update(self): + qs = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict('id') + .where(self.table_abc.abc.eq(0)) + .where(self.table_abc.cde.eq(0)) + .do_update('field', 'val') + ) + self.assertEqual( + '''INSERT INTO "abc" VALUES (1,'m') ON CONFLICT ("id") WHERE "abc"=0 AND "cde"=0 ''' + '''DO UPDATE SET "field"='val\'''', + str(qs), + ) + + def test_where_and_on_conflict_where(self): + table_bcd = Table('bcd') + + qs = ( + PostgreSQLQuery.into(self.table_abc) + .select(table_bcd.abc) + .from_(table_bcd) + .where(table_bcd.abc.eq('1')) + .on_conflict('id') + .where(self.table_abc.abc.eq(0)) + .where(self.table_abc.cde.eq(0)) + .do_update('field', 'val') + ) + + self.assertEqual( + 'INSERT INTO "abc" SELECT "abc" FROM "bcd" WHERE "abc"=\'1\' ' + 'ON CONFLICT ("id") WHERE "abc"=0 AND "cde"=0 DO UPDATE SET "field"=\'val\'', + str(qs), + ) + + def test_on_conflict_do_nothing_where(self): + with self.assertRaises(QueryException): + ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict() + .do_nothing() + .where(self.table_abc.abc.eq(1)) + ) + + def test_empty_on_conflict_do_update_where(self): + with self.assertRaises(QueryException): + ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict() + .do_update('abc', 1) + .where(self.table_abc.abc.eq(1)) + ) + + def test_on_conflict_do_update_where(self): + qs = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict("id") + .do_update('abc', 1) + .where(self.table_abc.abc.eq(1)) + ) + self.assertEqual( + 'INSERT INTO "abc" VALUES (1,\'m\') ON CONFLICT ("id") DO UPDATE SET "abc"=1 WHERE "abc"."abc"=1', str(qs) + ) + + def test_on_conflict_do_update_with_excluded_where(self): + qs = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict("id") + .do_update('abc') + .where(self.table_abc.abc.eq(1)) + ) + self.assertEqual( + 'INSERT INTO "abc" VALUES (1,\'m\') ON CONFLICT ("id") DO UPDATE SET "abc"=EXCLUDED."abc" WHERE ' + '"abc"."abc"=1', + str(qs), + ) + + def test_on_conflict_where_complex(self): + table_bcd = Table('bcd') + + qs = ( + PostgreSQLQuery.into(self.table_abc) + .select(table_bcd.abc) + .from_(table_bcd) + .where(table_bcd.abc.eq('1')) + .on_conflict('id') + .where(self.table_abc.abc.eq(0)) + .where(self.table_abc.cde.eq(0)) + .do_update('field', 'val') + .where(self.table_abc.id.eq(2)) + .where(self.table_abc.sub_id.eq(3)) + ) + self.assertEqual( + 'INSERT INTO "abc" SELECT "abc" FROM "bcd" WHERE "abc"=\'1\' ' + 'ON CONFLICT ("id") WHERE "abc"=0 AND "cde"=0 ' + 'DO UPDATE SET "field"=\'val\' WHERE "abc"."id"=2 AND "abc"."sub_id"=3', + str(qs), + ) + + +class PostgresInsertIntoReturningTests(unittest.TestCase): + table_abc = Table("abc") + + def test_insert_returning_one_field(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).returning(self.table_abc.id) + + self.assertEqual('INSERT INTO "abc" VALUES (1) RETURNING "id"', str(query)) + + def test_insert_returning_one_field_str(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).returning("id") + + self.assertEqual('INSERT INTO "abc" VALUES (1) RETURNING "id"', str(query)) + + def test_insert_returning_all_fields(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).returning(self.table_abc.star) + + self.assertEqual('INSERT INTO "abc" VALUES (1) RETURNING *', str(query)) + + def test_insert_returning_all_fields_and_arithmetics(self): + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1) + .returning(self.table_abc.star, self.table_abc.f1 + self.table_abc.f2) + ) + + self.assertEqual('INSERT INTO "abc" VALUES (1) RETURNING *,"f1"+"f2"', str(query)) + + def test_insert_all_columns_multi_rows_chained_returning_star(self): + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "a", True) + .insert(2, "b", False) + .returning(self.table_abc.star) + ) + + self.assertEqual( + "INSERT INTO \"abc\" VALUES (1,'a',true),(2,'b',false) RETURNING *", + str(query), + ) + + def test_insert_all_columns_multi_rows_chained_returning_star_and_id(self): + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "a", True) + .insert(2, "b", False) + .returning( + self.table_abc.name, + self.table_abc.star, + self.table_abc.id, + ) + ) + + self.assertEqual( + "INSERT INTO \"abc\" VALUES (1,'a',true),(2,'b',false) RETURNING *", + str(query), + ) + + def test_insert_all_columns_multi_rows_chained_returning_star_str(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1, "a", True).insert(2, "b", False).returning("*") + + self.assertEqual( + "INSERT INTO \"abc\" VALUES (1,'a',true),(2,'b',false) RETURNING *", + str(query), + ) + + def test_insert_all_columns_single_element_arrays(self): + query = PostgreSQLQuery.into(self.table_abc).insert((1, "a", True)).returning(self.table_abc.star) + + self.assertEqual("INSERT INTO \"abc\" VALUES (1,'a',true) RETURNING *", str(query)) + + def test_insert_returning_null(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).returning(None) + + self.assertEqual('INSERT INTO "abc" VALUES (1) RETURNING NULL', str(query)) + + def test_insert_returning_tuple(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).returning((1, 2, 3)) + + self.assertEqual('INSERT INTO "abc" VALUES (1) RETURNING (1,2,3)', str(query)) + + def test_insert_returning_arithmetics(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).returning(self.table_abc.f1 + self.table_abc.f2) + + self.assertEqual('INSERT INTO "abc" VALUES (1) RETURNING "f1"+"f2"', str(query)) + + def test_insert_returning_functions(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).returning(Cast(self.table_abc.f1, "int")) + + self.assertEqual('INSERT INTO "abc" VALUES (1) RETURNING CAST("f1" AS INT)', str(query)) + + def test_insert_returning_aggregate(self): + with self.assertRaises(QueryException): + PostgreSQLQuery.into(self.table_abc).insert(1).returning(Avg(self.table_abc.views)) + + def test_insert_returning_from_other_table(self): + table_cba = Table("cba") + with self.assertRaises(QueryException): + PostgreSQLQuery.into(self.table_abc).insert(1).returning(table_cba.id) + + +class InsertIntoOnDuplicateTests(unittest.TestCase): + table_abc = Table("abc") + + def test_insert_one_column(self): + query = ( + MySQLQuery.into(self.table_abc).insert(1).on_duplicate_key_update(self.table_abc.foo, self.table_abc.foo) + ) + self.assertEqual( + "INSERT INTO `abc` VALUES (1) ON DUPLICATE KEY UPDATE `foo`=`foo`", + str(query), + ) + + def test_insert_one_column_using_values(self): + query = ( + MySQLQuery.into(self.table_abc) + .insert(1) + .on_duplicate_key_update(self.table_abc.foo, Values(self.table_abc.foo)) + ) + self.assertEqual( + "INSERT INTO `abc` VALUES (1) ON DUPLICATE KEY UPDATE `foo`=VALUES(`foo`)", + str(query), + ) + + def test_insert_one_column_single_element_array(self): + query = ( + MySQLQuery.into(self.table_abc).insert((1,)).on_duplicate_key_update(self.table_abc.foo, self.table_abc.foo) + ) + + self.assertEqual( + "INSERT INTO `abc` VALUES (1) ON DUPLICATE KEY UPDATE `foo`=`foo`", + str(query), + ) + + def test_insert_one_column_multi_element_array(self): + query = ( + MySQLQuery.into(self.table_abc) + .insert((1,), (2,)) + .on_duplicate_key_update(self.table_abc.foo, self.table_abc.foo) + ) + + self.assertEqual( + "INSERT INTO `abc` VALUES (1),(2) ON DUPLICATE KEY UPDATE `foo`=`foo`", + str(query), + ) + + def test_insert_multiple_columns_on_duplicate_update_one_with_same_value(self): + query = ( + MySQLQuery.into(self.table_abc) + .insert(1, "a") + .on_duplicate_key_update(self.table_abc.bar, Values(self.table_abc.bar)) + ) + + self.assertEqual( + "INSERT INTO `abc` VALUES (1,'a') ON DUPLICATE KEY UPDATE `bar`=VALUES(`bar`)", + str(query), + ) + + def test_insert_multiple_columns_on_duplicate_update_one_with_different_value(self): + query = MySQLQuery.into(self.table_abc).insert(1, "a").on_duplicate_key_update(self.table_abc.bar, "b") + + self.assertEqual( + "INSERT INTO `abc` VALUES (1,'a') ON DUPLICATE KEY UPDATE `bar`='b'", + str(query), + ) + + def test_insert_multiple_columns_on_duplicate_update_one_with_expression(self): + query = ( + MySQLQuery.into(self.table_abc).insert(1, 2).on_duplicate_key_update(self.table_abc.bar, 4 + F("bar")) + ) # todo sql expression? not python + + self.assertEqual( + "INSERT INTO `abc` VALUES (1,2) ON DUPLICATE KEY UPDATE `bar`=4+`bar`", + str(query), + ) + + def test_insert_multiple_columns_on_duplicate_update_one_with_expression_using_original_field_value( + self, + ): + query = ( + MySQLQuery.into(self.table_abc) + .insert(1, "a") + .on_duplicate_key_update(self.table_abc.bar, fn.Concat(self.table_abc.bar, "update")) + ) + + self.assertEqual( + "INSERT INTO `abc` VALUES (1,'a') ON DUPLICATE KEY UPDATE `bar`=CONCAT(`bar`,'update')", + str(query), + ) + + def test_insert_multiple_columns_on_duplicate_update_one_with_expression_using_values( + self, + ): + query = ( + MySQLQuery.into(self.table_abc) + .insert(1, "a") + .on_duplicate_key_update(self.table_abc.bar, fn.Concat(Values(self.table_abc.bar), "update")) + ) + + self.assertEqual( + "INSERT INTO `abc` VALUES (1,'a') ON DUPLICATE KEY UPDATE `bar`=CONCAT(VALUES(`bar`),'update')", + str(query), + ) + + def test_insert_multiple_columns_on_duplicate_update_multiple(self): + query = ( + MySQLQuery.into(self.table_abc) + .insert(1, "a", "b") + .on_duplicate_key_update(self.table_abc.bar, "b") + .on_duplicate_key_update(self.table_abc.baz, "c") + ) + + self.assertEqual( + "INSERT INTO `abc` VALUES (1,'a','b') ON DUPLICATE KEY UPDATE `bar`='b',`baz`='c'", + str(query), + ) + + def test_insert_multi_rows_chained_mixed_on_duplicate_update_multiple(self): + query = ( + MySQLQuery.into(self.table_abc) + .insert((1, "a", True), (2, "b", False)) + .insert(3, "c", True) + .on_duplicate_key_update(self.table_abc.foo, self.table_abc.foo) + .on_duplicate_key_update(self.table_abc.bar, Values(self.table_abc.bar)) + ) + + self.assertEqual( + "INSERT INTO `abc` VALUES (1,'a',true),(2,'b',false),(3,'c',true) " + "ON DUPLICATE KEY UPDATE `foo`=`foo`,`bar`=VALUES(`bar`)", + str(query), + ) + + def test_insert_selected_columns_on_duplicate_update_one(self): + query = ( + MySQLQuery.into(self.table_abc) + .columns(self.table_abc.foo, self.table_abc.bar, self.table_abc.baz) + .insert(1, "a", True) + .on_duplicate_key_update(self.table_abc.baz, False) + ) + + self.assertEqual( + "INSERT INTO `abc` (`foo`,`bar`,`baz`) VALUES (1,'a',true) ON DUPLICATE KEY UPDATE `baz`=false", + str(query), + ) + + def test_insert_selected_columns_on_duplicate_update_multiple(self): + query = ( + MySQLQuery.into(self.table_abc) + .columns(self.table_abc.foo, self.table_abc.bar, self.table_abc.baz) + .insert(1, "a", True) + .on_duplicate_key_update(self.table_abc.baz, False) + .on_duplicate_key_update(self.table_abc.bar, Values(self.table_abc.bar)) + ) + + self.assertEqual( + "INSERT INTO `abc` (`foo`,`bar`,`baz`) VALUES (1,'a',true) " + "ON DUPLICATE KEY UPDATE `baz`=false,`bar`=VALUES(`bar`)", + str(query), + ) + + def test_insert_none_skipped(self): + query = MySQLQuery.into(self.table_abc).insert().on_duplicate_key_update(self.table_abc.baz, False) + + self.assertEqual("", str(query)) + + def test_insert_ignore(self): + query = MySQLQuery.into(self.table_abc).insert(1).ignore().on_duplicate_key_update(self.table_abc.baz, False) + + self.assertEqual( + "INSERT IGNORE INTO `abc` VALUES (1) ON DUPLICATE KEY UPDATE `baz`=false", + str(query), + ) + + +class InsertSelectFromTests(unittest.TestCase): + table_abc, table_efg, table_hij = Tables("abc", "efg", "hij") + + def test_insert_star(self): + query = Query.into(self.table_abc).from_(self.table_efg).select("*") + + self.assertEqual('INSERT INTO "abc" SELECT * FROM "efg"', str(query)) + + def test_insert_ignore_star(self): + query = Query.into(self.table_abc).from_(self.table_efg).select("*").ignore() + + self.assertEqual('INSERT IGNORE INTO "abc" SELECT * FROM "efg"', str(query)) + + def test_insert_from_columns(self): + query = ( + Query.into(self.table_abc) + .from_(self.table_efg) + .select(self.table_efg.fiz, self.table_efg.buz, self.table_efg.baz) + ) + + self.assertEqual('INSERT INTO "abc" ' 'SELECT "fiz","buz","baz" FROM "efg"', str(query)) + + def test_insert_columns_from_star(self): + query = ( + Query.into(self.table_abc) + .columns( + self.table_abc.foo, + self.table_abc.bar, + self.table_abc.buz, + ) + .from_(self.table_efg) + .select("*") + ) + + self.assertEqual('INSERT INTO "abc" ("foo","bar","buz") ' 'SELECT * FROM "efg"', str(query)) + + def test_insert_columns_from_columns(self): + query = ( + Query.into(self.table_abc) + .columns(self.table_abc.foo, self.table_abc.bar, self.table_abc.buz) + .from_(self.table_efg) + .select(self.table_efg.fiz, self.table_efg.buz, self.table_efg.baz) + ) + + self.assertEqual( + 'INSERT INTO "abc" ("foo","bar","buz") ' 'SELECT "fiz","buz","baz" FROM "efg"', + str(query), + ) + + def test_insert_columns_from_columns_with_join(self): + query = ( + Query.into(self.table_abc) + .columns( + self.table_abc.c1, + self.table_abc.c2, + self.table_abc.c3, + self.table_abc.c4, + ) + .from_(self.table_efg) + .select(self.table_efg.foo, self.table_efg.bar) + .join(self.table_hij) + .on(self.table_efg.id == self.table_hij.abc_id) + .select(self.table_hij.fiz, self.table_hij.buz) + ) + + self.assertEqual( + 'INSERT INTO "abc" ("c1","c2","c3","c4") ' + 'SELECT "efg"."foo","efg"."bar","hij"."fiz","hij"."buz" FROM "efg" ' + 'JOIN "hij" ON "efg"."id"="hij"."abc_id"', + str(query), + ) + + +class InsertSubqueryTests(unittest.TestCase): + def test_insert_subquery_wrapped_in_brackets(self): + purchase_order_item, part = Tables("purchase_order_item", "part") + + q = ( + Query.into(purchase_order_item) + .columns(purchase_order_item.id_part, purchase_order_item.id_customer) + .insert( + Query.from_(part).select(part.part_id).where(part.part_number == "FOOBAR"), + 12345, + ) + ) + + self.assertEqual( + 'INSERT INTO "purchase_order_item" ' + '("id_part","id_customer") ' + "VALUES " + '((SELECT "part_id" FROM "part" WHERE "part_number"=\'FOOBAR\'),12345)', + str(q), + ) + + +class SelectIntoTests(unittest.TestCase): + table_abc, table_efg, table_hij = Tables("abc", "efg", "hij") + + def test_select_star_into(self): + query = Query.from_(self.table_abc).select("*").into(self.table_efg) + + self.assertEqual('SELECT * INTO "efg" FROM "abc"', str(query)) + + def test_select_columns_into(self): + query = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, self.table_abc.bar, self.table_abc.buz) + .into(self.table_efg) + ) + + self.assertEqual('SELECT "foo","bar","buz" INTO "efg" FROM "abc"', str(query)) + + def test_select_columns_into_with_join(self): + query = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, self.table_abc.bar) + .join(self.table_hij) + .on(self.table_abc.id == self.table_hij.abc_id) + .select(self.table_hij.fiz, self.table_hij.buz) + .into(self.table_efg) + ) + + self.assertEqual( + 'SELECT "abc"."foo","abc"."bar","hij"."fiz","hij"."buz" ' + 'INTO "efg" FROM "abc" ' + 'JOIN "hij" ON "abc"."id"="hij"."abc_id"', + str(query), + ) + + +class ReplaceTests(unittest.TestCase): + table_abc, table_def = Tables("abc", "efg") + + def test_replace_simple(self): + query = Query.into(self.table_abc).replace("v1", "v2", "v3") + expected_output = "REPLACE INTO \"abc\" VALUES ('v1','v2','v3')" + self.assertEqual(str(query), expected_output) + + def test_replace_subquery(self): + query = Query.into(self.table_abc).replace(Query.from_(self.table_def).select("f1", "f2")) + expected_output = 'REPLACE INTO "abc" VALUES ((SELECT "f1","f2" FROM "efg"))' + self.assertEqual(str(query), expected_output) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/test_internals.py b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/test_internals.py new file mode 100644 index 0000000000000000000000000000000000000000..921e381ba8613d4a83cc53bd60d111d9547e2c1f --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/test_internals.py @@ -0,0 +1,35 @@ +import unittest + +from pypika import ( + Case, + Field, + Table, +) +from pypika.terms import Star + + +class TablesTests(unittest.TestCase): + def test__criterion_replace_table_with_value(self): + table = Table("a") + + c = (Field("foo") > 1).replace_table(None, table) + self.assertEqual(c.left, table) + self.assertEqual(c.tables_, {table}) + + def test__case_tables(self): + table = Table("a") + + c = Case().when(table.a == 1, 2 * table.a) + self.assertIsInstance(c.tables_, set) + self.assertSetEqual(c.tables_, {table}) + + def test__star_tables(self): + star = Star() + + self.assertEqual(star.tables_, set()) + + def test__table_star_tables(self): + table = Table("a") + star = Star(table=table) + + self.assertEqual(star.tables_, {table}) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/test_joins.py b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/test_joins.py new file mode 100644 index 0000000000000000000000000000000000000000..03142d583921edbe966e0ae191d254e7b8bf46ba --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/test_joins.py @@ -0,0 +1,1168 @@ +import unittest + +from pypika import ( + Field, + Interval, + JoinException, + JoinType, + MySQLQuery, + Query, + SetOperationException, + Table, + Tables, + functions as fn, + SYSTEM_TIME, +) + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + + +class SelectQueryJoinTests(unittest.TestCase): + table0, table1, hij = Tables("abc", "efg", "hij") + + def test_default_join_type(self): + query = Query.from_(self.table0).join(self.table1).on(self.table0.foo == self.table1.bar).select("*") + + self.assertEqual('SELECT * FROM "abc" JOIN "efg" ON "abc"."foo"="efg"."bar"', str(query)) + + def test_inner_join(self): + expected = 'SELECT * FROM "abc" JOIN "efg" ON "abc"."foo"="efg"."bar"' + + with self.subTest("join with enum"): + query = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.inner) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + self.assertEqual(expected, str(query)) + + with self.subTest("join function"): + query = Query.from_(self.table0).inner_join(self.table1).on(self.table0.foo == self.table1.bar).select("*") + self.assertEqual(expected, str(query)) + + def test_left_join(self): + expected = 'SELECT * FROM "abc" LEFT JOIN "efg" ON "abc"."foo"="efg"."bar"' + + with self.subTest("join with enum"): + query = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.left) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + + self.assertEqual(expected, str(query)) + + with self.subTest("join function"): + query = Query.from_(self.table0).left_join(self.table1).on(self.table0.foo == self.table1.bar).select("*") + self.assertEqual(expected, str(query)) + + def test_right_join(self): + expected = 'SELECT * FROM "abc" RIGHT JOIN "efg" ON "abc"."foo"="efg"."bar"' + + with self.subTest("join with enum"): + query = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.right) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + + self.assertEqual(expected, str(query)) + + with self.subTest("join function"): + query = Query.from_(self.table0).right_join(self.table1).on(self.table0.foo == self.table1.bar).select("*") + self.assertEqual(expected, str(query)) + + def test_hash_join(self): + expected = 'SELECT * FROM "abc" HASH JOIN "efg" ON "abc"."foo"="efg"."bar"' + + with self.subTest("join with enum"): + query = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.hash) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + + self.assertEqual(expected, str(query)) + + with self.subTest("join function"): + query = Query.from_(self.table0).hash_join(self.table1).on(self.table0.foo == self.table1.bar).select("*") + self.assertEqual(expected, str(query)) + + def test_outer_join(self): + expected = 'SELECT * FROM "abc" FULL OUTER JOIN "efg" ON "abc"."foo"="efg"."bar"' + + with self.subTest("join with enum"): + query = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.outer) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + + self.assertEqual(expected, str(query)) + + with self.subTest("join function"): + query = Query.from_(self.table0).outer_join(self.table1).on(self.table0.foo == self.table1.bar).select("*") + self.assertEqual(expected, str(query)) + + def test_cross_join(self): + expected = 'SELECT * FROM "abc" CROSS JOIN "efg" ON "abc"."foo"="efg"."bar"' + + with self.subTest("join with enum"): + query = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.cross) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + + self.assertEqual(expected, str(query)) + + with self.subTest("join function"): + query = Query.from_(self.table0).cross_join(self.table1).on(self.table0.foo == self.table1.bar).select("*") + self.assertEqual(expected, str(query)) + + def test_left_outer_join(self): + expected = 'SELECT * FROM "abc" LEFT OUTER JOIN "efg" ON "abc"."foo"="efg"."bar"' + with self.subTest("join with enum"): + query = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.left_outer) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + + self.assertEqual(expected, str(query)) + + with self.subTest("join function"): + query = ( + Query.from_(self.table0).left_outer_join(self.table1).on(self.table0.foo == self.table1.bar).select("*") + ) + + self.assertEqual(expected, str(query)) + + def test_right_outer_join(self): + expected = 'SELECT * FROM "abc" RIGHT OUTER JOIN "efg" ON "abc"."foo"="efg"."bar"' + with self.subTest("join with enum"): + query = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.right_outer) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + + self.assertEqual(expected, str(query)) + + with self.subTest("join function"): + query = ( + Query.from_(self.table0) + .right_outer_join(self.table1) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + + self.assertEqual(expected, str(query)) + + def test_full_outer_join(self): + expected = 'SELECT * FROM "abc" FULL OUTER JOIN "efg" ON "abc"."foo"="efg"."bar"' + + with self.subTest("join with enum"): + query = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.full_outer) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + + self.assertEqual(expected, str(query)) + + with self.subTest("join function"): + query = ( + Query.from_(self.table0).full_outer_join(self.table1).on(self.table0.foo == self.table1.bar).select("*") + ) + + self.assertEqual(expected, str(query)) + + def test_join_on_field_single(self): + query = Query.from_(self.table0).join(self.table1).on_field("foo").select("*") + self.assertEqual('SELECT * FROM "abc" JOIN "efg" ON "abc"."foo"="efg"."foo"', str(query)) + + def test_join_on_field_multi(self): + query = Query.from_(self.table0).join(self.table1).on_field("foo", "bar").select("*") + self.assertEqual( + 'SELECT * FROM "abc" JOIN "efg" ON "abc"."foo"="efg"."foo" ' 'AND "abc"."bar"="efg"."bar"', + str(query), + ) + + def test_join_on_field_multi_with_extra_join(self): + query = ( + Query.from_(self.table0) + .join(self.hij) + .on_field("buzz") + .join(self.table1) + .on_field("foo", "bar") + .select("*") + ) + + self.assertEqual( + 'SELECT * FROM "abc" JOIN "hij" ON "abc"."buzz"="hij"."buzz" ' + 'JOIN "efg" ON "abc"."foo"="efg"."foo" AND "abc"."bar"="efg"."bar"', + str(query), + ) + + def test_join_using_string_field_name(self): + query = Query.from_(self.table0).join(self.table1).using("id").select("*") + + self.assertEqual('SELECT * FROM "abc" JOIN "efg" USING ("id")', str(query)) + + def test_join_using_multiple_fields(self): + query = Query.from_(self.table0).join(self.table1).using("foo", "bar").select("*") + + self.assertEqual('SELECT * FROM "abc" JOIN "efg" USING ("foo","bar")', str(query)) + + def test_join_using_with_quote_char(self): + query = Query.from_(self.table0).join(self.table1).using("foo", "bar").select("*") + + self.assertEqual("SELECT * FROM abc JOIN efg USING (foo,bar)", query.get_sql(quote_char="")) + + def test_join_using_without_fields_raises_exception(self): + with self.assertRaises(JoinException): + Query.from_(self.table0).join(self.table1).using() + + def test_join_on_field_without_fields_raises_exception(self): + with self.assertRaises(JoinException): + Query.from_(self.table0).join(self.table1).on_field() + + def test_join_arithmetic_field(self): + q = ( + Query.from_(self.table0) + .join(self.table1) + .on(self.table0.dt == (self.table1.dt - Interval(weeks=1))) + .select("*") + ) + + self.assertEqual( + 'SELECT * FROM "abc" ' 'JOIN "efg" ON "abc"."dt"="efg"."dt"-INTERVAL \'1 WEEK\'', + str(q), + ) + + def test_join_with_arithmetic_function_in_select(self): + q = ( + Query.from_( + self.table0, + ) + .join(self.table1) + .on(self.table0.dt == (self.table1.dt - Interval(weeks=1))) + .select(self.table0.fiz - self.table0.buz, self.table1.star) + ) + + self.assertEqual( + 'SELECT "abc"."fiz"-"abc"."buz","efg".* FROM "abc" ' + 'JOIN "efg" ON "abc"."dt"="efg"."dt"-INTERVAL \'1 WEEK\'', + str(q), + ) + + def test_join_on_complex_criteria(self): + q = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.right) + .on((self.table0.foo == self.table1.fiz) & (self.table0.bar == self.table1.buz)) + .select("*") + ) + + self.assertEqual( + 'SELECT * FROM "abc" ' 'RIGHT JOIN "efg" ON "abc"."foo"="efg"."fiz" AND "abc"."bar"="efg"."buz"', + str(q), + ) + + def test_join_on_subquery_criteria(self): + table_a, table_b, table_c = Tables("a", "b", "c") + subquery = Query.from_(table_c).select("id").limit(1) + query = ( + Query.from_(table_a).select("*").join(table_b).on((table_a.b_id == table_b.id) & (table_b.c_id == subquery)) + ) + + self.assertEqual( + "SELECT * " 'FROM "a" ' 'JOIN "b" ON "a"."b_id"="b"."id" AND "b"."c_id"=' '(SELECT "id" FROM "c" LIMIT 1)', + str(query), + ) + + def test_use_different_table_objects_for_same_table(self): + table = Table("t") + q = Query.from_(table).select("*").where(Field("id", table=table) == 1) + + self.assertEqual('SELECT * FROM "t" WHERE "id"=1', str(q)) + + def test_join_second_table_in_from_clause(self): + table_a, table_b, table_c = Tables("a", "b", "c") + q = Query.from_(table_a).from_(table_b).select("*").join(table_c).on(table_b.c_id == table_c.id) + + self.assertEqual("SELECT * " 'FROM "a","b" ' 'JOIN "c" ON "b"."c_id"="c"."id"', str(q)) + + def test_cross_join_on_table(self): + table_a, table_b = Tables("a", "b") + q = Query.from_(table_a).join(table_b).cross().select("*") + + self.assertEqual('SELECT * FROM "a" CROSS JOIN "b"', str(q)) + + def test_cross_join_on_subquery(self): + table_a, table_b = Tables("a", "b") + q_a = Query.from_(table_a).select("*") + q_b = Query.from_(table_b).select("*").join(q_a).cross().select("*") + + self.assertEqual('SELECT * FROM "b" CROSS JOIN (SELECT * FROM "a") "sq0"', str(q_b)) + + def test_join_on_collate(self): + table_a, table_b = Tables("a", "b") + + q1 = ( + Query.from_(table_a) + .select(table_b.ouch) + .join(table_b) + .on(table_a.foo == table_b.boo, collate="utf8_general_ci") + ) + q2 = Query.from_(table_a).select(table_b.ouch).join(table_b).on(table_a.foo == table_b.boo) + + self.assertEqual( + 'SELECT "b"."ouch" FROM "a" JOIN "b" ON "a"."foo"="b"."boo" COLLATE utf8_general_ci', + str(q1), + ) + self.assertEqual('SELECT "b"."ouch" FROM "a" JOIN "b" ON "a"."foo"="b"."boo"', str(q2)) + + def test_temporal_join(self): + t0 = self.table0.for_(SYSTEM_TIME.as_of('2020-01-01')) + t1 = self.table1.for_(SYSTEM_TIME.as_of('2020-01-01')) + query = Query.from_(t0).join(t1).on(t0.foo == t1.bar).select("*") + + self.assertEqual( + 'SELECT * FROM "abc" FOR SYSTEM_TIME AS OF \'2020-01-01\' ' + 'JOIN "efg" FOR SYSTEM_TIME AS OF \'2020-01-01\' ' + 'ON "abc"."foo"="efg"."bar"', + str(query), + ) + + +class JoinBehaviorTests(unittest.TestCase): + table_abc, table_efg, table_hij, table_klm = Tables("abc", "efg", "hij", "klm") + + def test_select__ordered_select_clauses(self): + q = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .select( + self.table_abc.baz, + self.table_efg.buz, + self.table_abc.fiz, + self.table_efg.bam, + ) + ) + + self.assertEqual( + 'SELECT "abc"."baz","efg"."buz","abc"."fiz","efg"."bam" FROM "abc" ' + 'JOIN "efg" ON "abc"."foo"="efg"."bar"', + str(q), + ) + + def test_select__star_for_table(self): + q = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .join(self.table_hij) + .on(self.table_abc.buz == self.table_hij.bam) + .select(self.table_abc.star) + .select(self.table_efg.star) + .select(self.table_hij.star) + ) + + self.assertEqual( + 'SELECT "abc".*,"efg".*,"hij".* FROM "abc" ' + 'JOIN "efg" ON "abc"."foo"="efg"."bar" ' + 'JOIN "hij" ON "abc"."buz"="hij"."bam"', + str(q), + ) + + def test_select__star_for_table__replacement(self): + q = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .join(self.table_hij) + .on(self.table_abc.buz == self.table_hij.bam) + .select(self.table_abc.foo, self.table_efg.bar, self.table_hij.bam) + .select(self.table_abc.star, self.table_efg.star, self.table_hij.star) + ) + + self.assertEqual( + 'SELECT "abc".*,"efg".*,"hij".* FROM "abc" ' + 'JOIN "efg" ON "abc"."foo"="efg"."bar" ' + 'JOIN "hij" ON "abc"."buz"="hij"."bam"', + str(q), + ) + + def test_select_fields_with_where(self): + q = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .join(self.table_hij) + .on(self.table_abc.buz == self.table_hij.bam) + .select(self.table_abc.foo, self.table_efg.bar, self.table_hij.bam) + .where(self.table_abc.foo > 1) + .where(self.table_efg.bar != 2) + ) + + self.assertEqual( + 'SELECT "abc"."foo","efg"."bar","hij"."bam" FROM "abc" ' + 'JOIN "efg" ON "abc"."foo"="efg"."bar" ' + 'JOIN "hij" ON "abc"."buz"="hij"."bam" ' + 'WHERE "abc"."foo">1 AND "efg"."bar"<>2', + str(q), + ) + + def test_require_condition(self): + with self.assertRaises(JoinException): + Query.from_(self.table_abc).join(self.table_efg).on(None) + + def test_require_condition_with_both_tables(self): + with self.assertRaises(JoinException): + Query.from_(self.table_abc).join(self.table_efg).on(self.table_abc.foo == self.table_hij.bar) + + with self.assertRaises(JoinException): + Query.from_(self.table_abc).join(self.table_efg).on(self.table_hij.foo == self.table_efg.bar) + + with self.assertRaises(JoinException): + Query.from_(self.table_abc).join(self.table_efg).on(self.table_hij.foo == self.table_klm.bar) + + def test_join_same_table(self): + table1 = Table("abc") + table2 = Table("abc") + q = Query.from_(table1).join(table2).on(table1.foo == table2.bar).select(table1.foo, table2.buz) + + self.assertEqual( + 'SELECT "abc"."foo","abc2"."buz" FROM "abc" ' 'JOIN "abc" "abc2" ON "abc"."foo"="abc2"."bar"', + str(q), + ) + + def test_join_same_table_with_prefixes(self): + table1 = Table("abc").as_("x") + table2 = Table("abc").as_("y") + q = Query.from_(table1).join(table2).on(table1.foo == table2.bar).select(table1.foo, table2.buz) + + self.assertEqual( + 'SELECT "x"."foo","y"."buz" FROM "abc" "x" ' 'JOIN "abc" "y" ON "x"."foo"="y"."bar"', + str(q), + ) + + def test_join_table_twice(self): + table1, table2 = Table("efg").as_("efg1"), Table("efg").as_("efg2") + q = ( + Query.from_(self.table_abc) + .join(table1) + .on(self.table_abc.foo == table1.bar) + .join(table2) + .on(self.table_abc.foo == table2.bam) + .select(self.table_abc.foo, table1.fiz, table2.buz) + ) + + self.assertEqual( + 'SELECT "abc"."foo","efg1"."fiz","efg2"."buz" FROM "abc" ' + 'JOIN "efg" "efg1" ON "abc"."foo"="efg1"."bar" ' + 'JOIN "efg" "efg2" ON "abc"."foo"="efg2"."bam"', + str(q), + ) + + def test_select__fields_after_table_star(self): + q = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .select(self.table_abc.star, self.table_efg.bar) + .select(self.table_abc.foo) + ) + + self.assertEqual( + 'SELECT "abc".*,"efg"."bar" FROM "abc" JOIN "efg" ON "abc"."foo"="efg"."bar"', + str(q), + ) + + def test_fail_when_joining_unknown_type(self): + with self.assertRaises(ValueError): + Query.from_(self.table_abc).join("this is a string") + + def test_immutable__tables(self): + query1 = Query.from_(self.table_abc).select(self.table_abc.foo) + query2 = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .select(self.table_abc.foo, self.table_efg.buz) + ) + + self.assertEqual( + 'SELECT "abc"."foo","efg"."buz" FROM "abc" ' 'JOIN "efg" ON "abc"."foo"="efg"."bar"', + str(query2), + ) + self.assertEqual('SELECT "foo" FROM "abc"', str(query1)) + + def test_select_field_from_missing_table(self): + """ + Previously we validated the select field was a member of a table + in the query (e.g. FROM clause or a JOIN). However this made + correlated subqueries awkward to write (subqueries which refer + to their parent table. So the validation was removed. + + None of the following raise an error. Previously raised JoinException + """ + Query.from_(self.table_abc).select(self.table_efg.foo) + + Query.from_(self.table_abc).where(self.table_efg.foo == 0) + + Query.from_(self.table_abc).where(fn.Sum(self.table_efg.foo) == 0) + + Query.from_(self.table_abc).select(fn.Sum(self.table_abc.bar * 2) + fn.Sum(self.table_efg.foo * 2)) + + Query.from_(self.table_abc).groupby(self.table_efg.foo) + + Query.from_(self.table_abc).groupby(self.table_abc.foo).having(self.table_efg.bar) + + subquery = ( + Query.from_(self.table_efg).select(self.table_efg.id).where(self.table_efg.abc_id == self.table_abc.id) + ) + query = Query.from_(self.table_abc).select(subquery.as_("efg_id").limit(1)) + self.assertEqual( + 'SELECT (SELECT "efg"."id" FROM "efg" WHERE "efg"."abc_id"="abc"."id" LIMIT 1) "efg_id" FROM "abc"', + str(query), + ) + + def test_ignore_table_references(self): + query = Query.from_(Table("abc")).select(Table("abc").foo) + + self.assertEqual('SELECT "foo" FROM "abc"', str(query)) + + def test_prefixes_added_to_groupby(self): + test_query = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .select(self.table_abc.foo, fn.Sum(self.table_efg.buz)) + .groupby(self.table_abc.foo) + ) + + self.assertEqual( + 'SELECT "abc"."foo",SUM("efg"."buz") FROM "abc" ' + 'JOIN "efg" ON "abc"."foo"="efg"."bar" ' + 'GROUP BY "abc"."foo"', + str(test_query), + ) + + def test_prefixes_added_to_orderby(self): + test_query = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .select(self.table_abc.foo, self.table_efg.buz) + .orderby(self.table_abc.foo) + ) + + self.assertEqual( + 'SELECT "abc"."foo","efg"."buz" FROM "abc" ' + 'JOIN "efg" ON "abc"."foo"="efg"."bar" ' + 'ORDER BY "abc"."foo"', + str(test_query), + ) + + def test_prefixes_added_to_function_in_orderby(self): + test_query = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .select(self.table_abc.foo, self.table_efg.buz) + .orderby(fn.Date(self.table_abc.foo)) + ) + + self.assertEqual( + 'SELECT "abc"."foo","efg"."buz" FROM "abc" ' + 'JOIN "efg" ON "abc"."foo"="efg"."bar" ' + 'ORDER BY DATE("abc"."foo")', + str(test_query), + ) + + def test_join_from_join(self): + test_query = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.efg_id == self.table_efg.id) + .join(self.table_hij) + .on(self.table_efg.hij_id == self.table_hij.id) + .select(self.table_abc.foo, self.table_efg.bar, self.table_hij.fizz) + ) + + self.assertEqual( + 'SELECT "abc"."foo","efg"."bar","hij"."fizz" FROM "abc" ' + 'JOIN "efg" ON "abc"."efg_id"="efg"."id" ' + 'JOIN "hij" ON "efg"."hij_id"="hij"."id"', + str(test_query), + ) + + def test_join_query_without_alias(self): + subquery = Query.from_(self.table_efg).select( + self.table_efg.base_id.as_("x"), self.table_efg.fizz, self.table_efg.buzz + ) + + test_query = ( + Query.from_(self.table_abc) + .join(subquery) + .on(subquery.x == self.table_abc.id) + .select(self.table_abc.foo, subquery.fizz, subquery.buzz) + ) + + self.assertEqual( + 'SELECT "abc"."foo","sq0"."fizz","sq0"."buzz" ' + 'FROM "abc" JOIN (' + 'SELECT "base_id" "x","fizz","buzz" FROM "efg"' + ') "sq0" ' + 'ON "sq0"."x"="abc"."id"', + str(test_query), + ) + + def test_join_query_with_column_alias(self): + subquery = ( + Query.from_(self.table_efg) + .select( + self.table_efg.base_id.as_("x"), + self.table_efg.fizz, + self.table_efg.buzz, + ) + .as_("subq") + ) + + test_query = ( + Query.from_(self.table_abc) + .join(subquery) + .on(subquery.x == self.table_abc.id) + .select(self.table_abc.foo, subquery.fizz, subquery.buzz) + ) + + self.assertEqual( + 'SELECT "abc"."foo","subq"."fizz","subq"."buzz" ' + 'FROM "abc" JOIN (' + 'SELECT "base_id" "x","fizz","buzz" FROM "efg"' + ') "subq" ' + 'ON "subq"."x"="abc"."id"', + str(test_query), + ) + + def test_join_query_with_table_alias(self): + xxx = self.table_efg.as_("xxx") + subquery = Query.from_(xxx).select(xxx.base_id, xxx.fizz, xxx.buzz).as_("subq") + + test_query = ( + Query.from_(self.table_abc) + .join(subquery) + .on(subquery.x == self.table_abc.id) + .select(self.table_abc.foo, subquery.fizz, subquery.buzz) + ) + + self.assertEqual( + 'SELECT "abc"."foo","subq"."fizz","subq"."buzz" ' + 'FROM "abc" JOIN (' + 'SELECT "xxx"."base_id","xxx"."fizz","xxx"."buzz" FROM "efg" "xxx"' + ') "subq" ' + 'ON "subq"."x"="abc"."id"', + str(test_query), + ) + + def test_join_query_with_setoperation(self): + subquery = Query.from_(self.table_abc).select("*").union(Query.from_(self.table_abc).select("*")).as_("subq") + + test_query = ( + Query.from_(self.table_abc).join(subquery).on(subquery.x == self.table_abc.id).select(self.table_abc.foo) + ) + + self.assertEqual( + 'SELECT "abc"."foo" FROM "abc" ' + 'JOIN ' + '((SELECT * FROM "abc") ' + 'UNION ' + '(SELECT * FROM "abc")) "subq" ' + 'ON "subq"."x"="abc"."id"', + str(test_query), + ) + + +class UnionTests(unittest.TestCase): + table1, table2 = Tables("abc", "efg") + + def test_union(self): + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + + self.assertEqual( + '(SELECT "foo" FROM "abc") UNION (SELECT "bar" FROM "efg")', + str(query1 + query2), + ) + self.assertEqual( + '(SELECT "foo" FROM "abc") UNION (SELECT "bar" FROM "efg")', + str(query1.union(query2)), + ) + + def test_union_multiple(self): + table3, table4 = Tables("hij", "lmn") + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + query3 = Query.from_(table3).select(table3.baz) + query4 = Query.from_(table4).select(table4.faz) + + self.assertEqual( + '(SELECT "foo" FROM "abc") UNION ' + '(SELECT "bar" FROM "efg") UNION ' + '(SELECT "baz" FROM "hij") UNION ' + '(SELECT "faz" FROM "lmn")', + str(query1 + query2 + query3 + query4), + ) + self.assertEqual( + '(SELECT "foo" FROM "abc") UNION ' + '(SELECT "bar" FROM "efg") UNION ' + '(SELECT "baz" FROM "hij") UNION ' + '(SELECT "faz" FROM "lmn")', + str(query1.union(query2).union(query3).union(query4)), + ) + + def test_union_all(self): + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + + self.assertEqual( + '(SELECT "foo" FROM "abc") UNION ALL (SELECT "bar" FROM "efg")', + str(query1 * query2), + ) + self.assertEqual( + '(SELECT "foo" FROM "abc") UNION ALL (SELECT "bar" FROM "efg")', + str(query1.union_all(query2)), + ) + + def test_union_all_multiple(self): + table3, table4 = Tables("hij", "lmn") + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + query3 = Query.from_(table3).select(table3.baz) + query4 = Query.from_(table4).select(table4.faz) + + self.assertEqual( + '(SELECT "foo" FROM "abc") UNION ALL ' + '(SELECT "bar" FROM "efg") UNION ALL ' + '(SELECT "baz" FROM "hij") UNION ALL ' + '(SELECT "faz" FROM "lmn")', + str(query1 * query2 * query3 * query4), + ) + self.assertEqual( + '(SELECT "foo" FROM "abc") UNION ALL ' + '(SELECT "bar" FROM "efg") UNION ALL ' + '(SELECT "baz" FROM "hij") UNION ALL ' + '(SELECT "faz" FROM "lmn")', + str(query1.union_all(query2).union_all(query3).union_all(query4)), + ) + + def test_union_with_order_by(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + union_query = str((query1 + query2).orderby(query1.field("a"))) + union_all_query = str((query1 * query2).orderby(query1.field("a"))) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "UNION " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "a"', + union_query, + ) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "UNION ALL " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "a"', + union_all_query, + ) + + def test_union_with_order_by_use_union_query_field(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + union_query = query1 + query2 + union_query = str(union_query.orderby(union_query.field("a"))) + union_all_query = query1 * query2 + union_all_query = str(union_all_query.orderby(union_all_query.field("a"))) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "UNION " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "a"', + union_query, + ) + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "UNION ALL " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "a"', + union_all_query, + ) + + def test_union_with_order_by_with_aliases(self): + query1 = Query.from_(self.table1.as_("a")).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2.as_("b")).select(self.table2.bar.as_("a")) + + union_all_query = str((query1 * query2).orderby(query1.field("a"))) + union_query = str((query1 + query2).orderby(query1.field("a"))) + self.assertEqual( + '(SELECT "foo" "a" FROM "abc" "a")' " UNION ALL " '(SELECT "bar" "a" FROM "efg" "b")' ' ORDER BY "a"', + union_all_query, + ) + self.assertEqual( + '(SELECT "foo" "a" FROM "abc" "a")' " UNION " '(SELECT "bar" "a" FROM "efg" "b")' ' ORDER BY "a"', + union_query, + ) + + def test_union_with_order_by_use_union_query_field_with_aliases(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + union_query = (query1 + query2).as_("x") + union_query = union_query.orderby(union_query.field("a")) + union_all_query = (query1 * query2).as_("x") + union_all_query = union_all_query.orderby(union_all_query.field("a")) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "UNION " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "x"."a"', + str(union_query), + ) + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "UNION ALL " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "x"."a"', + str(union_all_query), + ) + + def test_require_equal_number_of_fields(self): + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.fiz, self.table2.buz) + + with self.assertRaises(SetOperationException): + str(query1 + query2) + + def test_mysql_query_wraps_unioned_queries(self): + query1 = MySQLQuery.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + + self.assertEqual( + "(SELECT `foo` FROM `abc`) UNION (SELECT `bar` FROM `efg`)", + str(query1 + query2), + ) + + def test_union_as_subquery(self): + abc, efg = Tables("abc", "efg") + hij = Query.from_(abc).select(abc.t).union(Query.from_(efg).select(efg.t)) + q = Query.from_(hij).select(fn.Avg(hij.t)) + + self.assertEqual( + 'SELECT AVG("sq0"."t") FROM ((SELECT "t" FROM "abc") UNION (SELECT "t" FROM "efg")) "sq0"', + str(q), + ) + + def test_union_with_no_quote_char(self): + abc, efg = Tables("abc", "efg") + hij = Query.from_(abc).select(abc.t).union(Query.from_(efg).select(efg.t)) + q = Query.from_(hij).select(fn.Avg(hij.t)) + + self.assertEqual( + "SELECT AVG(sq0.t) FROM ((SELECT t FROM abc) UNION (SELECT t FROM efg)) sq0", + q.get_sql(quote_char=None), + ) + + +class InsertQueryJoinTests(unittest.TestCase): + def test_join_table_on_insert_query(self): + a, b, c = Tables("a", "b", "c") + q = Query.into(c).from_(a).join(b).on(a.fkey_id == b.id).where(b.foo == 1).select("a.*", "b.*") + + self.assertEqual( + 'INSERT INTO "c" ' + 'SELECT "a"."a.*","a"."b.*" ' + 'FROM "a" JOIN "b" ' + 'ON "a"."fkey_id"="b"."id" ' + 'WHERE "b"."foo"=1', + str(q), + ) + + +class UpdateQueryJoinTests(unittest.TestCase): + def test_join_table_on_update_query(self): + a, b = Tables("a", "b") + q = Query.update(a).join(b).on(a.fkey_id == b.id).where(b.foo == 1).set("adwords_batch_job_id", 1) + + self.assertEqual( + 'UPDATE "a" ' 'JOIN "b" ' 'ON "a"."fkey_id"="b"."id" ' 'SET "adwords_batch_job_id"=1 ' 'WHERE "b"."foo"=1', + str(q), + ) + + +class IntersectTests(unittest.TestCase): + table1, table2 = Tables("abc", "efg") + + def test_intersect(self): + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + + self.assertEqual( + '(SELECT "foo" FROM "abc") INTERSECT (SELECT "bar" FROM "efg")', + str(query1.intersect(query2)), + ) + + def test_intersect_multiple(self): + table3, table4 = Tables("hij", "lmn") + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + query3 = Query.from_(table3).select(table3.baz) + query4 = Query.from_(table4).select(table4.faz) + + self.assertEqual( + '(SELECT "foo" FROM "abc") INTERSECT ' + '(SELECT "bar" FROM "efg") INTERSECT ' + '(SELECT "baz" FROM "hij") INTERSECT ' + '(SELECT "faz" FROM "lmn")', + str(query1.intersect(query2).intersect(query3).intersect(query4)), + ) + + def test_intersect_with_order_by(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + intersect_query = str((query1.intersect(query2)).orderby(query1.field("a"))) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "INTERSECT " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "a"', + intersect_query, + ) + + def test_intersect_with_limit(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + intersect_query = str((query1.intersect(query2)).limit(10)) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "INTERSECT " '(SELECT "bar" "a" FROM "efg") ' 'LIMIT 10', + intersect_query, + ) + + def test_intersect_with_offset(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + intersect_query = str((query1.intersect(query2)).offset(10)) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "INTERSECT " '(SELECT "bar" "a" FROM "efg") ' 'OFFSET 10', + intersect_query, + ) + + def test_require_equal_number_of_fields_intersect(self): + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.fiz, self.table2.buz) + + with self.assertRaises(SetOperationException): + str(query1.intersect(query2)) + + def test_mysql_query_wraps_intersected_queries(self): + query1 = MySQLQuery.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + + self.assertEqual( + "(SELECT `foo` FROM `abc`) INTERSECT (SELECT `bar` FROM `efg`)", + str(query1.intersect(query2)), + ) + + def test_intersect_as_subquery(self): + abc, efg = Tables("abc", "efg") + hij = Query.from_(abc).select(abc.t).intersect(Query.from_(efg).select(efg.t)) + q = Query.from_(hij).select(fn.Avg(hij.t)) + + self.assertEqual( + 'SELECT AVG("sq0"."t") FROM ((SELECT "t" FROM "abc") INTERSECT (SELECT "t" FROM "efg")) "sq0"', + str(q), + ) + + def test_intersect_with_no_quote_char(self): + abc, efg = Tables("abc", "efg") + hij = Query.from_(abc).select(abc.t).intersect(Query.from_(efg).select(efg.t)) + q = Query.from_(hij).select(fn.Avg(hij.t)) + + self.assertEqual( + "SELECT AVG(sq0.t) FROM ((SELECT t FROM abc) INTERSECT (SELECT t FROM efg)) sq0", + q.get_sql(quote_char=None), + ) + + +class MinusTests(unittest.TestCase): + table1, table2 = Tables("abc", "efg") + + def test_minus(self): + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + + self.assertEqual('(SELECT "foo" FROM "abc") MINUS (SELECT "bar" FROM "efg")', str(query1.minus(query2))) + + self.assertEqual( + '(SELECT "foo" FROM "abc") MINUS (SELECT "bar" FROM "efg")', + str(query1 - query2), + ) + + def test_minus_multiple(self): + table3, table4 = Tables("hij", "lmn") + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + query3 = Query.from_(table3).select(table3.baz) + query4 = Query.from_(table4).select(table4.faz) + + self.assertEqual( + '(SELECT "foo" FROM "abc") MINUS ' + '(SELECT "bar" FROM "efg") MINUS ' + '(SELECT "baz" FROM "hij") MINUS ' + '(SELECT "faz" FROM "lmn")', + str(query1 - query2 - query3 - query4), + ) + + self.assertEqual( + '(SELECT "foo" FROM "abc") MINUS ' + '(SELECT "bar" FROM "efg") MINUS ' + '(SELECT "baz" FROM "hij") MINUS ' + '(SELECT "faz" FROM "lmn")', + str(query1.minus(query2).minus(query3).minus(query4)), + ) + + def test_minus_with_order_by(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + minus_query = str(query1.minus(query2).orderby(query1.field("a"))) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "MINUS " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "a"', minus_query + ) + + def test_minus_query_with_order_by_use_minus_query_field(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + minus_query = query1.minus(query2) + minus_query = str(minus_query.orderby(minus_query.field("b"))) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "MINUS " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "b"', + minus_query, + ) + + def test_require_equal_number_of_fields(self): + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.fiz, self.table2.buz) + + with self.assertRaises(SetOperationException): + str(query1.minus(query2)) + + def test_mysql_query_wraps_minus_queries(self): + query1 = MySQLQuery.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + + self.assertEqual( + "(SELECT `foo` FROM `abc`) MINUS (SELECT `bar` FROM `efg`)", + str(query1 - query2), + ) + + def test_minus_as_subquery(self): + abc, efg = Tables("abc", "efg") + hij = Query.from_(abc).select(abc.t).minus(Query.from_(efg).select(efg.t)) + q = Query.from_(hij).select(fn.Avg(hij.t)) + + self.assertEqual( + 'SELECT AVG("sq0"."t") FROM ((SELECT "t" FROM "abc") MINUS (SELECT "t" FROM "efg")) "sq0"', + str(q), + ) + + def test_minus_with_no_quote_char(self): + abc, efg = Tables("abc", "efg") + hij = Query.from_(abc).select(abc.t).minus(Query.from_(efg).select(efg.t)) + q = Query.from_(hij).select(fn.Avg(hij.t)) + + self.assertEqual( + "SELECT AVG(sq0.t) FROM ((SELECT t FROM abc) MINUS (SELECT t FROM efg)) sq0", + q.get_sql(quote_char=None), + ) + + +class ExceptOfTests(unittest.TestCase): + table1, table2 = Tables("abc", "efg") + + def test_except(self): + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + + self.assertEqual('(SELECT "foo" FROM "abc") EXCEPT (SELECT "bar" FROM "efg")', str(query1.except_of(query2))) + + def test_except_multiple(self): + table3, table4 = Tables("hij", "lmn") + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + query3 = Query.from_(table3).select(table3.baz) + query4 = Query.from_(table4).select(table4.faz) + + self.assertEqual( + '(SELECT "foo" FROM "abc") EXCEPT ' + '(SELECT "bar" FROM "efg") EXCEPT ' + '(SELECT "baz" FROM "hij") EXCEPT ' + '(SELECT "faz" FROM "lmn")', + str(query1.except_of(query2).except_of(query3).except_of(query4)), + ) + + def test_except_with_order_by(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + except_query = str(query1.except_of(query2).orderby(query1.field("a"))) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "EXCEPT " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "a"', except_query + ) + + def test_except_query_with_order_by_use_minus_query_field(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + except_query = query1.except_of(query2) + except_query = str(except_query.orderby(except_query.field("b"))) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "EXCEPT " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "b"', + except_query, + ) + + def test_require_equal_number_of_fields_except_of(self): + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.fiz, self.table2.buz) + + with self.assertRaises(SetOperationException): + str(query1.except_of(query2)) + + def test_except_as_subquery(self): + abc, efg = Tables("abc", "efg") + hij = Query.from_(abc).select(abc.t).except_of(Query.from_(efg).select(efg.t)) + q = Query.from_(hij).select(fn.Avg(hij.t)) + + self.assertEqual( + 'SELECT AVG("sq0"."t") FROM ((SELECT "t" FROM "abc") EXCEPT (SELECT "t" FROM "efg")) "sq0"', + str(q), + ) + + def test_except_with_no_quote_char(self): + abc, efg = Tables("abc", "efg") + hij = Query.from_(abc).select(abc.t).except_of(Query.from_(efg).select(efg.t)) + q = Query.from_(hij).select(fn.Avg(hij.t)) + + self.assertEqual( + "SELECT AVG(sq0.t) FROM ((SELECT t FROM abc) EXCEPT (SELECT t FROM efg)) sq0", + q.get_sql(quote_char=None), + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/test_negation.py b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/test_negation.py new file mode 100644 index 0000000000000000000000000000000000000000..9f4db83b560dbc8546ce6d384b781dfccefd319d --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/test_negation.py @@ -0,0 +1,31 @@ +import unittest + +from pypika import ( + Tables, + functions as fn, +) +from pypika.terms import ValueWrapper + + +class NegationTests(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_negate_wrapped_float(self): + q = -ValueWrapper(1.0) + + self.assertEqual("-1.0", q.get_sql()) + + def test_negate_wrapped_int(self): + q = -ValueWrapper(1) + + self.assertEqual("-1", q.get_sql()) + + def test_negate_field(self): + q = -self.table_abc.foo + + self.assertEqual('-"abc"."foo"', q.get_sql(with_namespace=True, quote_char='"')) + + def test_negate_function(self): + q = -fn.Sum(self.table_abc.foo) + + self.assertEqual('-SUM("abc"."foo")', q.get_sql(with_namespace=True, quote_char='"')) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/test_parameter.py b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/test_parameter.py new file mode 100644 index 0000000000000000000000000000000000000000..c11e9afcd9624abb0a7313306eda34ebcf4c99ba --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/test_parameter.py @@ -0,0 +1,206 @@ +import unittest +from datetime import date + +from pypika import ( + FormatParameter, + NamedParameter, + NumericParameter, + Parameter, + PyformatParameter, + QmarkParameter, + Query, + Tables, +) +from pypika.terms import ListParameter, ParameterValueWrapper + + +class ParametrizedTests(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_param_insert(self): + q = Query.into(self.table_abc).columns("a", "b", "c").insert(Parameter("?"), Parameter("?"), Parameter("?")) + + self.assertEqual('INSERT INTO "abc" ("a","b","c") VALUES (?,?,?)', q.get_sql()) + + def test_param_select_join(self): + q = ( + Query.from_(self.table_abc) + .select("*") + .where(self.table_abc.category == Parameter("%s")) + .join(self.table_efg) + .on(self.table_abc.id == self.table_efg.abc_id) + .where(self.table_efg.date >= Parameter("%s")) + .limit(10) + ) + + self.assertEqual( + 'SELECT * FROM "abc" JOIN "efg" ON "abc"."id"="efg"."abc_id" WHERE "abc"."category"=%s AND "efg"."date">=%s LIMIT 10', + q.get_sql(), + ) + + def test_param_select_subquery(self): + q = ( + Query.from_(self.table_abc) + .select("*") + .where(self.table_abc.category == Parameter("&1")) + .where( + self.table_abc.id.isin( + Query.from_(self.table_efg) + .select(self.table_efg.abc_id) + .where(self.table_efg.date >= Parameter("&2")) + ) + ) + .limit(10) + ) + + self.assertEqual( + 'SELECT * FROM "abc" WHERE "category"=&1 AND "id" IN (SELECT "abc_id" FROM "efg" WHERE "date">=&2) LIMIT 10', + q.get_sql(), + ) + + def test_join(self): + subquery = ( + Query.from_(self.table_efg) + .select(self.table_efg.fiz, self.table_efg.buz) + .where(self.table_efg.buz == Parameter(":buz")) + ) + + q = ( + Query.from_(self.table_abc) + .join(subquery) + .on(self.table_abc.bar == subquery.buz) + .select(self.table_abc.foo, subquery.fiz) + .where(self.table_abc.bar == Parameter(":bar")) + ) + + self.assertEqual( + 'SELECT "abc"."foo","sq0"."fiz" FROM "abc" JOIN (SELECT "fiz","buz" FROM "efg" WHERE "buz"=:buz)' + ' "sq0" ON "abc"."bar"="sq0"."buz" WHERE "abc"."bar"=:bar', + q.get_sql(), + ) + + def test_qmark_parameter(self): + self.assertEqual('?', QmarkParameter().get_sql()) + + def test_numeric_parameter(self): + self.assertEqual(':14', NumericParameter('14').get_sql()) + self.assertEqual(':15', NumericParameter(15).get_sql()) + + def test_named_parameter(self): + self.assertEqual(':buz', NamedParameter('buz').get_sql()) + + def test_format_parameter(self): + self.assertEqual('%s', FormatParameter().get_sql()) + + def test_pyformat_parameter(self): + self.assertEqual('%(buz)s', PyformatParameter('buz').get_sql()) + + +class ParametrizedTestsWithValues(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_param_insert(self): + q = Query.into(self.table_abc).columns("a", "b", "c").insert(1, 2.2, 'foo') + + parameter = QmarkParameter() + sql = q.get_sql(parameter=parameter) + self.assertEqual('INSERT INTO "abc" ("a","b","c") VALUES (?,?,?)', sql) + self.assertEqual([1, 2.2, 'foo'], parameter.get_parameters()) + + def test_param_select_join(self): + q = ( + Query.from_(self.table_abc) + .select("*") + .where(self.table_abc.category == 'foobar') + .join(self.table_efg) + .on(self.table_abc.id == self.table_efg.abc_id) + .where(self.table_efg.date >= date(2024, 2, 22)) + .limit(10) + ) + + parameter = FormatParameter() + sql = q.get_sql(parameter=parameter) + self.assertEqual( + 'SELECT * FROM "abc" JOIN "efg" ON "abc"."id"="efg"."abc_id" WHERE "abc"."category"=%s AND "efg"."date">=%s LIMIT 10', + sql, + ) + self.assertEqual(['foobar', '2024-02-22'], parameter.get_parameters()) + + def test_param_select_subquery(self): + q = ( + Query.from_(self.table_abc) + .select("*") + .where(self.table_abc.category == 'foobar') + .where( + self.table_abc.id.isin( + Query.from_(self.table_efg) + .select(self.table_efg.abc_id) + .where(self.table_efg.date >= date(2024, 2, 22)) + ) + ) + .limit(10) + ) + + parameter = ListParameter(placeholder=lambda idx: f'&{idx+1}') + sql = q.get_sql(parameter=parameter) + self.assertEqual( + 'SELECT * FROM "abc" WHERE "category"=&1 AND "id" IN (SELECT "abc_id" FROM "efg" WHERE "date">=&2) LIMIT 10', + sql, + ) + self.assertEqual(['foobar', '2024-02-22'], parameter.get_parameters()) + + def test_join(self): + subquery = ( + Query.from_(self.table_efg) + .select(self.table_efg.fiz, self.table_efg.buz) + .where(self.table_efg.buz == 'buz') + ) + + q = ( + Query.from_(self.table_abc) + .join(subquery) + .on(self.table_abc.bar == subquery.buz) + .select(self.table_abc.foo, subquery.fiz) + .where(self.table_abc.bar == 'bar') + ) + + parameter = NamedParameter() + sql = q.get_sql(parameter=parameter) + self.assertEqual( + 'SELECT "abc"."foo","sq0"."fiz" FROM "abc" JOIN (SELECT "fiz","buz" FROM "efg" WHERE "buz"=:param1)' + ' "sq0" ON "abc"."bar"="sq0"."buz" WHERE "abc"."bar"=:param2', + sql, + ) + self.assertEqual({'param1': 'buz', 'param2': 'bar'}, parameter.get_parameters()) + + def test_join_with_parameter_value_wrapper(self): + subquery = ( + Query.from_(self.table_efg) + .select(self.table_efg.fiz, self.table_efg.buz) + .where(self.table_efg.buz == ParameterValueWrapper(Parameter(':buz'), 'buz')) + ) + + q = ( + Query.from_(self.table_abc) + .join(subquery) + .on(self.table_abc.bar == subquery.buz) + .select(self.table_abc.foo, subquery.fiz) + .where(self.table_abc.bar == ParameterValueWrapper(NamedParameter('bar'), 'bar')) + ) + + parameter = NamedParameter() + sql = q.get_sql(parameter=parameter) + self.assertEqual( + 'SELECT "abc"."foo","sq0"."fiz" FROM "abc" JOIN (SELECT "fiz","buz" FROM "efg" WHERE "buz"=:buz)' + ' "sq0" ON "abc"."bar"="sq0"."buz" WHERE "abc"."bar"=:bar', + sql, + ) + self.assertEqual({':buz': 'buz', 'bar': 'bar'}, parameter.get_parameters()) + + def test_pyformat_parameter(self): + q = Query.into(self.table_abc).columns("a", "b", "c").insert(1, 2.2, 'foo') + + parameter = PyformatParameter() + sql = q.get_sql(parameter=parameter) + self.assertEqual('INSERT INTO "abc" ("a","b","c") VALUES (%(param1)s,%(param2)s,%(param3)s)', sql) + self.assertEqual({"param1": 1, "param2": 2.2, "param3": "foo"}, parameter.get_parameters()) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/test_pseudocolumns.py b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/test_pseudocolumns.py new file mode 100644 index 0000000000000000000000000000000000000000..6a25c70269b2ccc98ac3870ac64a43c8a32ddbe9 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/test_pseudocolumns.py @@ -0,0 +1,51 @@ +import unittest + +from pypika import Query, Table +from pypika.pseudocolumns import ( + ColumnValue, + ObjectID, + ObjectValue, + RowID, + RowNum, + SysDate, +) +from pypika.terms import PseudoColumn + + +class PseudoColumnsTest(unittest.TestCase): + @classmethod + def setUpClass(cls): + super(PseudoColumnsTest, cls).setUpClass() + cls.table1 = Table("table1") + + def test_column_value(self): + self.assertEqual("COLUMN_VALUE", ColumnValue) + + def test_object_id(self): + self.assertEqual("OBJECT_ID", ObjectID) + + def test_object_value(self): + self.assertEqual("OBJECT_VALUE", ObjectValue) + + def test_row_id(self): + self.assertEqual("ROWID", RowID) + + def test_row_num(self): + self.assertEqual("ROWNUM", RowNum) + + def test_sys_date(self): + self.assertEqual("SYSDATE", SysDate) + + def test_can_be_used_in_a_select_statement(self): + query = Query.from_(self.table1).where(self.table1.is_active == 1).select(PseudoColumn("abcde")) + + self.assertEqual(str(query), 'SELECT abcde FROM "table1" WHERE "is_active"=1') + + def test_can_be_used_in_a_where_clause(self): + query = Query.from_(self.table1).where(PseudoColumn("abcde") > 1).select(self.table1.is_active) + + self.assertEqual(str(query), 'SELECT "is_active" FROM "table1" WHERE abcde>1') + + def test_can_be_used_in_orderby(self): + query = Query.from_(self.table1).select(self.table1.abcde.as_("some_name")).orderby(PseudoColumn("some_name")) + self.assertEqual(str(query), 'SELECT "abcde" "some_name" FROM "table1" ORDER BY some_name') diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/test_query.py b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/test_query.py new file mode 100644 index 0000000000000000000000000000000000000000..ae8dc01599a6a562b591ce15391bfe9b5c87e0f9 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/test_query.py @@ -0,0 +1,242 @@ +import unittest + +from pypika import Case, Query, Tables, Tuple, functions, Field +from pypika.dialects import ( + ClickHouseQuery, + ClickHouseQueryBuilder, + MSSQLQuery, + MSSQLQueryBuilder, + MySQLLoadQueryBuilder, + MySQLQuery, + MySQLQueryBuilder, + OracleQuery, + OracleQueryBuilder, + PostgreSQLQuery, + PostgreSQLQueryBuilder, + RedShiftQueryBuilder, + RedshiftQuery, + SQLLiteQuery, + SQLLiteQueryBuilder, + SnowflakeQuery, + SnowflakeQueryBuilder, + VerticaCopyQueryBuilder, + VerticaCreateQueryBuilder, + VerticaQuery, + VerticaQueryBuilder, +) +from pypika.queries import CreateQueryBuilder, DropQueryBuilder, QueryBuilder + + +class QueryTablesTests(unittest.TestCase): + table_a, table_b, table_c, table_d = Tables("a", "b", "c", "d") + + def test_replace_table(self): + query = Query.from_(self.table_a).select(self.table_a.time) + query = query.replace_table(self.table_a, self.table_b) + + self.assertEqual('SELECT "time" FROM "b"', str(query)) + + def test_replace_only_specified_table(self): + query = Query.from_(self.table_a).select(self.table_a.time) + query = query.replace_table(self.table_b, self.table_c) + + self.assertEqual('SELECT "time" FROM "a"', str(query)) + + def test_replace_insert_table(self): + query = Query.into(self.table_a).insert(1) + query = query.replace_table(self.table_a, self.table_b) + + self.assertEqual('INSERT INTO "b" VALUES (1)', str(query)) + + def test_replace_insert_table_current_table_not_match(self): + query = Query.into(self.table_a).insert(1) + query = query.replace_table(self.table_c, self.table_b) + + self.assertEqual('INSERT INTO "a" VALUES (1)', str(query)) + + def test_replace_update_table(self): + query = Query.update(self.table_a).set("foo", "bar") + query = query.replace_table(self.table_a, self.table_b) + + self.assertEqual('UPDATE "b" SET "foo"=\'bar\'', str(query)) + + def test_replace_update_table_current_table_not_match(self): + query = Query.update(self.table_a).set("foo", "bar") + query = query.replace_table(self.table_c, self.table_b) + + self.assertEqual('UPDATE "a" SET "foo"=\'bar\'', str(query)) + + def test_replace_delete_table(self): + query = Query.from_(self.table_a).delete() + query = query.replace_table(self.table_a, self.table_b) + + self.assertEqual('DELETE FROM "b"', str(query)) + + def test_replace_join_tables(self): + query = ( + Query.from_(self.table_a) + .join(self.table_b) + .on(self.table_a.customer_id == self.table_b.id) + .join(self.table_c) + .on(self.table_b.seller_id == self.table_c.id) + .select(self.table_a.star) + ) + query = query.replace_table(self.table_a, self.table_d) + + self.assertEqual( + 'SELECT "d".* ' + 'FROM "d" ' + 'JOIN "b" ON "d"."customer_id"="b"."id" ' + 'JOIN "c" ON "b"."seller_id"="c"."id"', + str(query), + ) + + def test_replace_filter_tables(self): + query = Query.from_(self.table_a).select(self.table_a.name).where(self.table_a.name == "Mustermann") + query = query.replace_table(self.table_a, self.table_b) + + self.assertEqual('SELECT "name" FROM "b" WHERE "name"=\'Mustermann\'', str(query)) + + def test_replace_having_table(self): + query = ( + Query.from_(self.table_a) + .select(functions.Sum(self.table_a.revenue)) + .groupby(self.table_a.customer) + .having(functions.Sum(self.table_a.revenue) >= 1000) + ) + query = query.replace_table(self.table_a, self.table_b) + + self.assertEqual( + 'SELECT SUM("revenue") ' 'FROM "b" ' 'GROUP BY "customer" ' 'HAVING SUM("revenue")>=1000', + str(query), + ) + + def test_replace_case_table(self): + query = Query.from_(self.table_a).select( + Case() + .when(self.table_a.fname == "Tom", "It was Tom") + .when(self.table_a.fname == "John", "It was John") + .else_("It was someone else.") + .as_("who_was_it") + ) + query = query.replace_table(self.table_a, self.table_b) + + self.assertEqual( + "SELECT CASE " + "WHEN \"fname\"='Tom' THEN 'It was Tom' " + "WHEN \"fname\"='John' THEN 'It was John' " + "ELSE 'It was someone else.' END \"who_was_it\" " + 'FROM "b"', + str(query), + ) + + def test_replace_orderby_table(self): + query = Query.from_(self.table_a).select(self.table_a.customer).orderby(self.table_a.customer) + query = query.replace_table(self.table_a, self.table_b) + + self.assertEqual('SELECT "customer" FROM "b" ORDER BY "customer"', str(query)) + + def test_replace_tuple_table(self): + query = ( + Query.from_(self.table_a) + .select(self.table_a.cost, self.table_a.revenue) + .where((self.table_a.cost, self.table_a.revenue) == Tuple(1, 2)) + ) + + query = query.replace_table(self.table_a, self.table_b) + + # Order is reversed due to lack of right equals method + self.assertEqual( + 'SELECT "cost","revenue" FROM "b" WHERE (1,2)=("cost","revenue")', + str(query), + ) + + def test_is_joined(self): + q = Query.from_(self.table_a).join(self.table_b).on(self.table_a.foo == self.table_b.boo) + + self.assertTrue(q.is_joined(self.table_b)) + self.assertFalse(q.is_joined(self.table_c)) + + +class QueryBuilderTests(unittest.TestCase): + def test_query_builders_have_reference_to_correct_query_class(self): + with self.subTest('QueryBuilder'): + self.assertEqual(Query, QueryBuilder.QUERY_CLS) + + with self.subTest('DropQueryBuilder'): + self.assertEqual(Query, DropQueryBuilder.QUERY_CLS) + + with self.subTest('CreateQueryBuilder'): + self.assertEqual(Query, CreateQueryBuilder.QUERY_CLS) + + with self.subTest('MySQLQueryBuilder'): + self.assertEqual(MySQLQuery, MySQLQueryBuilder.QUERY_CLS) + + with self.subTest('MySQLLoadQueryBuilder'): + self.assertEqual(MySQLQuery, MySQLLoadQueryBuilder.QUERY_CLS) + + with self.subTest('VerticaQueryBuilder'): + self.assertEqual(VerticaQuery, VerticaQueryBuilder.QUERY_CLS) + + with self.subTest('VerticaCreateQueryBuilder'): + self.assertEqual(VerticaQuery, VerticaCreateQueryBuilder.QUERY_CLS) + + with self.subTest('VerticaCopyQueryBuilder'): + self.assertEqual(VerticaQuery, VerticaCopyQueryBuilder.QUERY_CLS) + + with self.subTest('PostgreSQLQueryBuilder'): + self.assertEqual(PostgreSQLQuery, PostgreSQLQueryBuilder.QUERY_CLS) + + with self.subTest('MSSQLQueryBuilder'): + self.assertEqual(MSSQLQuery, MSSQLQueryBuilder.QUERY_CLS) + + with self.subTest('SnowflakeQueryBuilder'): + self.assertEqual(SnowflakeQuery, SnowflakeQueryBuilder.QUERY_CLS) + + with self.subTest('ClickHouseQueryBuilder'): + self.assertEqual(ClickHouseQuery, ClickHouseQueryBuilder.QUERY_CLS) + + with self.subTest('RedShiftQueryBuilder'): + self.assertEqual(RedshiftQuery, RedShiftQueryBuilder.QUERY_CLS) + + with self.subTest('SQLLiteQueryBuilder'): + self.assertEqual(SQLLiteQuery, SQLLiteQueryBuilder.QUERY_CLS) + + with self.subTest('OracleQueryBuilder'): + self.assertEqual(OracleQuery, OracleQueryBuilder.QUERY_CLS) + + def test_pipe(self) -> None: + base_query = Query.from_("test") + + def select(query: QueryBuilder) -> QueryBuilder: + return query.select("test1", "test2") + + def count_group(query: QueryBuilder, *groups) -> QueryBuilder: + return query.groupby(*groups).select(*groups, functions.Count("*")) + + for func, args, kwargs, expected_str in [ + (select, [], {}, 'SELECT "test1","test2" FROM "test"'), + ( + count_group, + ["test1", "test2"], + {}, + 'SELECT "test1","test2",COUNT(*) FROM "test" GROUP BY "test1","test2"', + ), + (count_group, ["test1"], {}, 'SELECT "test1",COUNT(*) FROM "test" GROUP BY "test1"'), + ]: + result_str = str(base_query.pipe(func, *args, **kwargs)) + self.assertEqual(result_str, str(func(base_query, *args, **kwargs))) + self.assertEqual(result_str, expected_str) + + def where_clause(query: QueryBuilder, num_days: int) -> QueryBuilder: + return query.where(Field("date") > functions.Now() - num_days) + + result_str = str(base_query.pipe(select).pipe(where_clause, num_days=1)) + self.assertEqual( + result_str, + str(select(where_clause(base_query, num_days=1))), + ) + self.assertEqual( + result_str, + 'SELECT "test1","test2" FROM "test" WHERE "date">NOW()-1', + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/test_selects.py b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/test_selects.py new file mode 100644 index 0000000000000000000000000000000000000000..1ce04937492e655db362b7e2a0a6856abf22a48f --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/test_selects.py @@ -0,0 +1,1331 @@ +import unittest +from datetime import date +from enum import Enum + +from pypika import ( + AliasedQuery, + Case, + ClickHouseQuery, + EmptyCriterion, + Field as F, + Index, + MSSQLQuery, + MySQLQuery, + NullValue, + OracleQuery, + Order, + PostgreSQLQuery, + Query, + QueryException, + RedshiftQuery, + SQLLiteQuery, + Table, + Tables, + VerticaQuery, + functions as fn, + SYSTEM_TIME, +) +from pypika.terms import ValueWrapper + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + + +class SelectTests(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_empty_query(self): + q = Query.from_("abc") + + self.assertEqual("", str(q)) + + def test_select_no_from(self): + q = Query.select(1) + + self.assertEqual("SELECT 1", str(q)) + + def test_select_no_with_alias_from(self): + q = Query.select(ValueWrapper(1, "test")) + + self.assertEqual('SELECT 1 "test"', str(q)) + + def test_select_no_from_with_field_raises_exception(self): + with self.assertRaises(QueryException): + Query.select("asdf") + + def test_select__star(self): + q = Query.from_("abc").select("*") + + self.assertEqual('SELECT * FROM "abc"', str(q)) + + def test_select__table_schema(self): + q = Query.from_(Table("abc", "schema1")).select("*") + + self.assertEqual('SELECT * FROM "schema1"."abc"', str(q)) + + def test_select__table_schema_with_multiple_levels_as_tuple(self): + q = Query.from_(Table("abc", ("schema1", "schema2"))).select("*") + + self.assertEqual('SELECT * FROM "schema1"."schema2"."abc"', str(q)) + + def test_select__table_schema_with_multiple_levels_as_list(self): + q = Query.from_(Table("abc", ["schema1", "schema2"])).select("*") + + self.assertEqual('SELECT * FROM "schema1"."schema2"."abc"', str(q)) + + def test_select__star__replacement(self): + q = Query.from_("abc").select("foo").select("*") + + self.assertEqual('SELECT * FROM "abc"', str(q)) + + def test_select__distinct__single(self): + q = Query.from_("abc").select("foo").distinct() + + self.assertEqual('SELECT DISTINCT "foo" FROM "abc"', str(q)) + + def test_select__distinct__multi(self): + q = Query.from_("abc").select("foo", "bar").distinct() + + self.assertEqual('SELECT DISTINCT "foo","bar" FROM "abc"', str(q)) + + def test_select__column__single__str(self): + q = Query.from_("abc").select("foo") + + self.assertEqual('SELECT "foo" FROM "abc"', str(q)) + + def test_select__column__single__alias__str(self): + q = Query.from_(self.table_abc).select(self.table_abc.foo.as_("bar")) + + self.assertEqual('SELECT "foo" "bar" FROM "abc"', str(q)) + + def test_select__column__single__table_alias__str(self): + q = Query.from_(self.table_abc.as_("fizzbuzz")).select(self.table_abc.foo.as_("bar")) + + self.assertEqual('SELECT "foo" "bar" FROM "abc" "fizzbuzz"', str(q)) + + def test_select__column__single__field(self): + t = Table("abc") + q = Query.from_(t).select(t.foo) + + self.assertEqual('SELECT "foo" FROM "abc"', str(q)) + + def test_select__columns__multi__str(self): + q1 = Query.from_("abc").select("foo", "bar") + q2 = Query.from_("abc").select("foo").select("bar") + + self.assertEqual('SELECT "foo","bar" FROM "abc"', str(q1)) + self.assertEqual('SELECT "foo","bar" FROM "abc"', str(q2)) + + def test_select__columns__multi__field(self): + q1 = Query.from_(self.table_abc).select(self.table_abc.foo, self.table_abc.bar) + q2 = Query.from_(self.table_abc).select(self.table_abc.foo).select(self.table_abc.bar) + + self.assertEqual('SELECT "foo","bar" FROM "abc"', str(q1)) + self.assertEqual('SELECT "foo","bar" FROM "abc"', str(q2)) + + def test_select__multiple_tables(self): + q = Query.from_(self.table_abc).select(self.table_abc.foo).from_(self.table_efg).select(self.table_efg.bar) + + self.assertEqual('SELECT "abc"."foo","efg"."bar" FROM "abc","efg"', str(q)) + + def test_select__subquery(self): + subquery = Query.from_(self.table_abc).select("*") + q = Query.from_(subquery).select(subquery.foo, subquery.bar) + + self.assertEqual('SELECT "sq0"."foo","sq0"."bar" ' 'FROM (SELECT * FROM "abc") "sq0"', str(q)) + + def test_select__multiple_subqueries(self): + subquery0 = Query.from_(self.table_abc).select("foo") + subquery1 = Query.from_(self.table_efg).select("bar") + q = Query.from_(subquery0).from_(subquery1).select(subquery0.foo, subquery1.bar) + + self.assertEqual( + 'SELECT "sq0"."foo","sq1"."bar" ' 'FROM (SELECT "foo" FROM "abc") "sq0",' '(SELECT "bar" FROM "efg") "sq1"', + str(q), + ) + + def test_select__nested_subquery(self): + subquery0 = Query.from_(self.table_abc).select("*") + subquery1 = Query.from_(subquery0).select(subquery0.foo, subquery0.bar) + subquery2 = Query.from_(subquery1).select(subquery1.foo) + + q = Query.from_(subquery2).select(subquery2.foo) + + self.assertEqual( + 'SELECT "sq2"."foo" ' + 'FROM (SELECT "sq1"."foo" ' + 'FROM (SELECT "sq0"."foo","sq0"."bar" ' + 'FROM (SELECT * FROM "abc") "sq0") "sq1") "sq2"', + str(q), + ) + + def test_select__no_table(self): + q = Query.select(1, 2, 3) + + self.assertEqual("SELECT 1,2,3", str(q)) + + def test_select_then_add_table(self): + q = Query.select(1).select(2, 3).from_("abc").select("foo") + + self.assertEqual('SELECT 1,2,3,"foo" FROM "abc"', str(q)) + + def test_select_with_limit(self): + q1 = Query.from_("abc").select("foo")[:10] + + self.assertEqual('SELECT "foo" FROM "abc" LIMIT 10', str(q1)) + + def test_select_with_limit_zero(self): + with self.subTest('using python slice'): + q1 = Query.from_("abc").select("foo")[:0] + self.assertEqual('SELECT "foo" FROM "abc" LIMIT 0', str(q1)) + + with self.subTest('using limit method'): + q2 = Query.from_("abc").select("foo").limit(0) + self.assertEqual('SELECT "foo" FROM "abc" LIMIT 0', str(q2)) + + def test_select_with_limit__func(self): + q1 = Query.from_("abc").select("foo").limit(10) + + self.assertEqual('SELECT "foo" FROM "abc" LIMIT 10', str(q1)) + + def test_select_with_offset(self): + q1 = Query.from_("abc").select("foo")[10:] + + self.assertEqual('SELECT "foo" FROM "abc" OFFSET 10', str(q1)) + + def test_select_with_offset__func(self): + q1 = Query.from_("abc").select("foo").offset(10) + + self.assertEqual('SELECT "foo" FROM "abc" OFFSET 10', str(q1)) + + def test_select_with_limit_and_offset(self): + q1 = Query.from_("abc").select("foo")[10:10] + + self.assertEqual('SELECT "foo" FROM "abc" LIMIT 10 OFFSET 10', str(q1)) + + def test_select_with_force_index(self): + q = Query.from_("abc").select("foo").force_index("egg") + + self.assertEqual('SELECT "foo" FROM "abc" FORCE INDEX ("egg")', str(q)) + + def test_select_with_force_index_with_index_object(self): + index = Index("egg") + q = Query.from_("abc").select("foo").force_index(index) + + self.assertEqual('SELECT "foo" FROM "abc" FORCE INDEX ("egg")', str(q)) + + def test_select_with_force_index_multiple_indexes(self): + q = Query.from_("abc").select("foo").force_index("egg", "bacon") + + self.assertEqual('SELECT "foo" FROM "abc" FORCE INDEX ("egg","bacon")', str(q)) + + def test_select_with_force_index_multiple_calls(self): + q = ( + Query.from_("abc") + .select("foo") + .force_index( + "egg", + ) + .force_index("spam") + ) + + self.assertEqual('SELECT "foo" FROM "abc" FORCE INDEX ("egg","spam")', str(q)) + + def test_select_with_use_index(self): + q = Query.from_("abc").select("foo").use_index("egg") + + self.assertEqual('SELECT "foo" FROM "abc" USE INDEX ("egg")', str(q)) + + def test_select_with_use_index_with_index_object(self): + index = Index("egg") + q = Query.from_("abc").select("foo").use_index(index) + + self.assertEqual('SELECT "foo" FROM "abc" USE INDEX ("egg")', str(q)) + + def test_select_with_use_index_multiple_indexes(self): + q = Query.from_("abc").select("foo").use_index("egg", "bacon") + + self.assertEqual('SELECT "foo" FROM "abc" USE INDEX ("egg","bacon")', str(q)) + + def test_select_with_use_index_multiple_calls(self): + q = ( + Query.from_("abc") + .select("foo") + .use_index( + "egg", + ) + .use_index("spam") + ) + + self.assertEqual('SELECT "foo" FROM "abc" USE INDEX ("egg","spam")', str(q)) + + def test_mysql_query_uses_backtick_quote_chars(self): + q = MySQLQuery.from_("abc").select("foo", "bar") + + self.assertEqual("SELECT `foo`,`bar` FROM `abc`", str(q)) + + def test_vertica_query_uses_double_quote_chars(self): + q = VerticaQuery.from_("abc").select("foo", "bar") + + self.assertEqual('SELECT "foo","bar" FROM "abc"', str(q)) + + def test_mssql_query_uses_double_quote_chars(self): + q = MSSQLQuery.from_("abc").select("foo", "bar") + + self.assertEqual('SELECT "foo","bar" FROM "abc"', str(q)) + + def test_oracle_query_uses_no_quote_chars(self): + q = OracleQuery.from_("abc").select("foo", "bar") + + self.assertEqual('SELECT foo,bar FROM abc', str(q)) + + def test_postgresql_query_uses_double_quote_chars(self): + q = PostgreSQLQuery.from_("abc").select("foo", "bar") + + self.assertEqual('SELECT "foo","bar" FROM "abc"', str(q)) + + def test_redshift_query_uses_double_quote_chars(self): + q = RedshiftQuery.from_("abc").select("foo", "bar") + + self.assertEqual('SELECT "foo","bar" FROM "abc"', str(q)) + + def test_table_select_alias(self): + q = self.table_abc.select(1) + + self.assertEqual('SELECT 1 FROM "abc"', str(q)) + self.assertEqual(q, Query.from_("abc").select(1)) + + def test_table_select_alias_with_offset_and_limit(self): + self.assertEqual(self.table_abc.select("foo")[10:10], Query.from_("abc").select("foo")[10:10]) + self.assertEqual( + self.table_abc.select(self.table_abc.foo)[10:10], + Query.from_("abc").select("foo")[10:10], + ) + + def test_temporal_select(self): + t = Table("abc") + + with self.subTest("with system time as of"): + q = Query.from_(t.for_(SYSTEM_TIME.as_of('2020-01-01'))).select("*") + + self.assertEqual('SELECT * FROM "abc" FOR SYSTEM_TIME AS OF \'2020-01-01\'', str(q)) + + with self.subTest("with system time between"): + q = Query.from_(t.for_(SYSTEM_TIME.between('2020-01-01', '2020-02-01'))).select("*") + + self.assertEqual('SELECT * FROM "abc" FOR SYSTEM_TIME BETWEEN \'2020-01-01\' AND \'2020-02-01\'', str(q)) + + with self.subTest("with system time from to"): + q = Query.from_(t.for_(SYSTEM_TIME.from_to('2020-01-01', '2020-02-01'))).select("*") + + self.assertEqual('SELECT * FROM "abc" FOR SYSTEM_TIME FROM \'2020-01-01\' TO \'2020-02-01\'', str(q)) + + with self.subTest("with ALL"): + q = Query.from_(t.for_(SYSTEM_TIME.all_())).select("*") + + self.assertEqual('SELECT * FROM "abc" FOR SYSTEM_TIME ALL', str(q)) + + with self.subTest("with period between"): + q = Query.from_(t.for_(t.valid_period.between('2020-01-01', '2020-02-01'))).select("*") + + self.assertEqual('SELECT * FROM "abc" FOR "valid_period" BETWEEN \'2020-01-01\' AND \'2020-02-01\'', str(q)) + + with self.subTest("with period from to"): + q = Query.from_(t.for_(t.valid_period.from_to('2020-01-01', '2020-02-01'))).select("*") + + self.assertEqual('SELECT * FROM "abc" FOR "valid_period" FROM \'2020-01-01\' TO \'2020-02-01\'', str(q)) + + with self.subTest("with ALL"): + q = Query.from_(t.for_(t.valid_period.all_())).select("*") + + self.assertEqual('SELECT * FROM "abc" FOR "valid_period" ALL', str(q)) + + +class MyEnum(Enum): + STR = "foo" + INT = 0 + BOOL = True + DATE = date(2020, 2, 2) + NONE = None + + +class WhereTests(unittest.TestCase): + t = Table("abc") + t2 = Table("cba") + + def test_where_enum(self): + q1 = Query.from_(self.t).select("*").where(self.t.foo == MyEnum.STR) + q2 = Query.from_(self.t).select("*").where(self.t.foo == MyEnum.INT) + q3 = Query.from_(self.t).select("*").where(self.t.foo == MyEnum.BOOL) + q4 = Query.from_(self.t).select("*").where(self.t.foo == MyEnum.DATE) + q5 = Query.from_(self.t).select("*").where(self.t.foo == MyEnum.NONE) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo"=\'foo\'', str(q1)) + self.assertEqual('SELECT * FROM "abc" WHERE "foo"=0', str(q2)) + self.assertEqual('SELECT * FROM "abc" WHERE "foo"=true', str(q3)) + self.assertEqual('SELECT * FROM "abc" WHERE "foo"=\'2020-02-02\'', str(q4)) + self.assertEqual('SELECT * FROM "abc" WHERE "foo"=null', str(q5)) + + def test_where_field_equals(self): + q1 = Query.from_(self.t).select("*").where(self.t.foo == self.t.bar) + q2 = Query.from_(self.t).select("*").where(self.t.foo.eq(self.t.bar)) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo"="bar"', str(q1)) + self.assertEqual('SELECT * FROM "abc" WHERE "foo"="bar"', str(q2)) + q = self.t.select("*").where(self.t.foo == self.t.bar) + self.assertEqual(q, q1) + + def test_where_field_equals_for_update(self): + q = Query.from_(self.t).select("*").where(self.t.foo == self.t.bar).for_update() + self.assertEqual('SELECT * FROM "abc" WHERE "foo"="bar" FOR UPDATE', str(q)) + + def test_where_field_equals_for_update_nowait(self): + for query_cls in [ + MySQLQuery, + PostgreSQLQuery, + ]: + quote_char = query_cls._builder().QUOTE_CHAR if isinstance(query_cls._builder().QUOTE_CHAR, str) else '"' + q = query_cls.from_(self.t).select("*").where(self.t.foo == self.t.bar).for_update(nowait=True) + self.assertEqual( + 'SELECT * ' + 'FROM {quote_char}abc{quote_char} ' + 'WHERE {quote_char}foo{quote_char}={quote_char}bar{quote_char} ' + 'FOR UPDATE NOWAIT'.format( + quote_char=quote_char, + ), + str(q), + ) + + def test_where_field_equals_for_update_skip_locked(self): + for query_cls in [ + MySQLQuery, + PostgreSQLQuery, + ]: + quote_char = query_cls._builder().QUOTE_CHAR if isinstance(query_cls._builder().QUOTE_CHAR, str) else '"' + q = query_cls.from_(self.t).select("*").where(self.t.foo == self.t.bar).for_update(skip_locked=True) + self.assertEqual( + 'SELECT * ' + 'FROM {quote_char}abc{quote_char} ' + 'WHERE {quote_char}foo{quote_char}={quote_char}bar{quote_char} ' + 'FOR UPDATE SKIP LOCKED'.format( + quote_char=quote_char, + ), + str(q), + ) + + def test_where_field_equals_for_update_of(self): + for query_cls in [ + MySQLQuery, + PostgreSQLQuery, + ]: + quote_char = query_cls._builder().QUOTE_CHAR if isinstance(query_cls._builder().QUOTE_CHAR, str) else '"' + q = query_cls.from_(self.t).select("*").where(self.t.foo == self.t.bar).for_update(of=("abc",)) + self.assertEqual( + 'SELECT * ' + 'FROM {quote_char}abc{quote_char} ' + 'WHERE {quote_char}foo{quote_char}={quote_char}bar{quote_char} ' + 'FOR UPDATE OF {quote_char}abc{quote_char}'.format( + quote_char=quote_char, + ), + str(q), + ) + + def test_where_field_equals_for_update_of_multiple_tables(self): + for query_cls in [ + MySQLQuery, + PostgreSQLQuery, + ]: + q = ( + query_cls.from_(self.t) + .join(self.t2) + .on(self.t.id == self.t2.abc_id) + .select("*") + .where(self.t.foo == self.t.bar) + .for_update(of=("abc", "cba")) + ) + quote_char = query_cls._builder().QUOTE_CHAR if isinstance(query_cls._builder().QUOTE_CHAR, str) else '"' + self.assertIn( + str(q), + [ + 'SELECT * ' + 'FROM {quote_char}abc{quote_char} ' + 'JOIN {quote_char}cba{quote_char} ' + 'ON {quote_char}abc{quote_char}.{quote_char}id{quote_char}=' + '{quote_char}cba{quote_char}.{quote_char}abc_id{quote_char} ' + 'WHERE {quote_char}abc{quote_char}.{quote_char}foo{quote_char}=' + '{quote_char}abc{quote_char}.{quote_char}bar{quote_char} ' + 'FOR UPDATE OF {quote_char}cba{quote_char}, {quote_char}abc{quote_char}'.format( + quote_char=quote_char, + ), + 'SELECT * ' + 'FROM {quote_char}abc{quote_char} ' + 'JOIN {quote_char}cba{quote_char} ' + 'ON {quote_char}abc{quote_char}.{quote_char}id{quote_char}=' + '{quote_char}cba{quote_char}.{quote_char}abc_id{quote_char} ' + 'WHERE {quote_char}abc{quote_char}.{quote_char}foo{quote_char}=' + '{quote_char}abc{quote_char}.{quote_char}bar{quote_char} ' + 'FOR UPDATE OF {quote_char}abc{quote_char}, {quote_char}cba{quote_char}'.format( + quote_char=quote_char, + ), + ], + ) + + def test_where_field_equals_for_update_of_nowait(self): + for query_cls in [ + MySQLQuery, + PostgreSQLQuery, + ]: + q = query_cls.from_(self.t).select("*").where(self.t.foo == self.t.bar).for_update(of=("abc",), nowait=True) + quote_char = query_cls._builder().QUOTE_CHAR if isinstance(query_cls._builder().QUOTE_CHAR, str) else '"' + self.assertEqual( + 'SELECT * ' + 'FROM {quote_char}abc{quote_char} ' + 'WHERE {quote_char}foo{quote_char}={quote_char}bar{quote_char} ' + 'FOR UPDATE OF {quote_char}abc{quote_char} NOWAIT'.format( + quote_char=quote_char, + ), + str(q), + ) + + def test_where_field_equals_for_update_of_skip_locked(self): + for query_cls in [ + MySQLQuery, + PostgreSQLQuery, + ]: + q = ( + query_cls.from_(self.t) + .select("*") + .where(self.t.foo == self.t.bar) + .for_update(of=("abc",), skip_locked=True) + ) + quote_char = query_cls._builder().QUOTE_CHAR if isinstance(query_cls._builder().QUOTE_CHAR, str) else '"' + self.assertEqual( + 'SELECT * ' + 'FROM {quote_char}abc{quote_char} ' + 'WHERE {quote_char}foo{quote_char}={quote_char}bar{quote_char} ' + 'FOR UPDATE OF {quote_char}abc{quote_char} SKIP LOCKED'.format( + quote_char=quote_char, + ), + str(q), + ) + + def test_where_field_equals_for_update_skip_locked_and_of(self): + for query_cls in [ + MySQLQuery, + PostgreSQLQuery, + ]: + q = ( + query_cls.from_(self.t) + .select("*") + .where(self.t.foo == self.t.bar) + .for_update(nowait=False, skip_locked=True, of=("abc",)) + ) + quote_char = query_cls._builder().QUOTE_CHAR if isinstance(query_cls._builder().QUOTE_CHAR, str) else '"' + self.assertEqual( + 'SELECT * ' + 'FROM {quote_char}abc{quote_char} ' + 'WHERE {quote_char}foo{quote_char}={quote_char}bar{quote_char} ' + 'FOR UPDATE OF {quote_char}abc{quote_char} SKIP LOCKED'.format( + quote_char=quote_char, + ), + str(q), + ) + + def test_where_field_equals_where(self): + q = Query.from_(self.t).select("*").where(self.t.foo == 1).where(self.t.bar == self.t.baz) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo"=1 AND "bar"="baz"', str(q)) + + def test_where_field_equals_where_not(self): + q = Query.from_(self.t).select("*").where((self.t.foo == 1).negate()).where(self.t.bar == self.t.baz) + + self.assertEqual('SELECT * FROM "abc" WHERE NOT "foo"=1 AND "bar"="baz"', str(q)) + + def test_where_field_equals_where_two_not(self): + q = Query.from_(self.t).select("*").where((self.t.foo == 1).negate()).where((self.t.bar == self.t.baz).negate()) + + self.assertEqual('SELECT * FROM "abc" WHERE NOT "foo"=1 AND NOT "bar"="baz"', str(q)) + + def test_where_single_quote(self): + q1 = Query.from_(self.t).select("*").where(self.t.foo == "bar'foo") + + self.assertEqual("SELECT * FROM \"abc\" WHERE \"foo\"='bar''foo'", str(q1)) + + def test_where_field_equals_and(self): + q = Query.from_(self.t).select("*").where((self.t.foo == 1) & (self.t.bar == self.t.baz)) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo"=1 AND "bar"="baz"', str(q)) + + def test_where_field_equals_or(self): + q = Query.from_(self.t).select("*").where((self.t.foo == 1) | (self.t.bar == self.t.baz)) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo"=1 OR "bar"="baz"', str(q)) + + def test_where_nested_conditions(self): + q = Query.from_(self.t).select("*").where((self.t.foo == 1) | (self.t.bar == self.t.baz)).where(self.t.baz == 0) + + self.assertEqual('SELECT * FROM "abc" WHERE ("foo"=1 OR "bar"="baz") AND "baz"=0', str(q)) + + def test_where_field_starts_with(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.like("ab%")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" LIKE \'ab%\'', str(q)) + + def test_where_field_contains(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.like("%fg%")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" LIKE \'%fg%\'', str(q)) + + def test_where_field_ends_with(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.like("%yz")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" LIKE \'%yz\'', str(q)) + + def test_where_field_is_n_chars_long(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.like("___")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" LIKE \'___\'', str(q)) + + def test_where_field_does_not_start_with(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.not_like("ab%")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" NOT LIKE \'ab%\'', str(q)) + + def test_where_field_does_not_contain(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.not_like("%fg%")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" NOT LIKE \'%fg%\'', str(q)) + + def test_where_field_does_not_end_with(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.not_like("%yz")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" NOT LIKE \'%yz\'', str(q)) + + def test_where_field_is_not_n_chars_long(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.not_like("___")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" NOT LIKE \'___\'', str(q)) + + def test_where_field_matches_regex(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.regex(r"^b")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" REGEX \'^b\'', str(q)) + + def test_where_field_matches_regexp(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.regexp(r"^b")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" REGEXP \'^b\'', str(q)) + + def test_where_field_matches_rlike(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.rlike(r"^b")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" RLIKE \'^b\'', str(q)) + + def test_ignore_empty_criterion_where(self): + q1 = Query.from_(self.t).select("*").where(EmptyCriterion()) + + self.assertEqual('SELECT * FROM "abc"', str(q1)) + + def test_ignore_empty_criterion_having(self): + q1 = Query.from_(self.t).select("*").having(EmptyCriterion()) + + self.assertEqual('SELECT * FROM "abc"', str(q1)) + + def test_select_with_force_index_and_where(self): + q = Query.from_("abc").select("foo").where(self.t.foo == self.t.bar).force_index("egg") + + self.assertEqual('SELECT "foo" FROM "abc" FORCE INDEX ("egg") WHERE "foo"="bar"', str(q)) + + def test_where_with_multiple_wheres_using_and_case(self): + case_stmt = Case().when(self.t.foo == 'bar', 1).else_(0) + query = Query.from_(self.t).select(case_stmt).where(case_stmt & self.t.blah.isin(['test'])) + + self.assertEqual( + 'SELECT CASE WHEN "foo"=\'bar\' THEN 1 ELSE 0 END FROM "abc" WHERE CASE WHEN "foo"=\'bar\' THEN 1 ELSE 0 ' + 'END AND "blah" IN (\'test\')', + str(query), + ) + + def test_where_with_multiple_wheres_using_or_case(self): + case_stmt = Case().when(self.t.foo == 'bar', 1).else_(0) + query = Query.from_(self.t).select(case_stmt).where(case_stmt | self.t.blah.isin(['test'])) + + self.assertEqual( + 'SELECT CASE WHEN "foo"=\'bar\' THEN 1 ELSE 0 END FROM "abc" WHERE CASE WHEN "foo"=\'bar\' THEN 1 ELSE 0 ' + 'END OR "blah" IN (\'test\')', + str(query), + ) + + +class PreWhereTests(WhereTests): + t = Table("abc") + + def test_prewhere_field_equals(self): + q1 = Query.from_(self.t).select("*").prewhere(self.t.foo == self.t.bar) + q2 = Query.from_(self.t).select("*").prewhere(self.t.foo.eq(self.t.bar)) + + self.assertEqual('SELECT * FROM "abc" PREWHERE "foo"="bar"', str(q1)) + self.assertEqual('SELECT * FROM "abc" PREWHERE "foo"="bar"', str(q2)) + + def test_where_and_prewhere(self): + q = Query.from_(self.t).select("*").prewhere(self.t.foo == self.t.bar).where(self.t.foo == self.t.bar) + + self.assertEqual('SELECT * FROM "abc" PREWHERE "foo"="bar" WHERE "foo"="bar"', str(q)) + + +class GroupByTests(unittest.TestCase): + t = Table("abc") + maxDiff = None + + def test_groupby__single(self): + q = Query.from_(self.t).groupby(self.t.foo).select(self.t.foo) + + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo"', str(q)) + + def test_groupby__multi(self): + q = Query.from_(self.t).groupby(self.t.foo, self.t.bar).select(self.t.foo, self.t.bar) + + self.assertEqual('SELECT "foo","bar" FROM "abc" GROUP BY "foo","bar"', str(q)) + + def test_groupby__count_star(self): + q = Query.from_(self.t).groupby(self.t.foo).select(self.t.foo, fn.Count("*")) + + self.assertEqual('SELECT "foo",COUNT(*) FROM "abc" GROUP BY "foo"', str(q)) + + def test_groupby__count_field(self): + q = Query.from_(self.t).groupby(self.t.foo).select(self.t.foo, fn.Count(self.t.bar)) + + self.assertEqual('SELECT "foo",COUNT("bar") FROM "abc" GROUP BY "foo"', str(q)) + + def test_groupby__count_distinct(self): + q = Query.from_(self.t).groupby(self.t.foo).select(self.t.foo, fn.Count("*").distinct()) + + self.assertEqual('SELECT "foo",COUNT(DISTINCT *) FROM "abc" GROUP BY "foo"', str(q)) + + def test_groupby__sum_distinct(self): + q = Query.from_(self.t).groupby(self.t.foo).select(self.t.foo, fn.Sum(self.t.bar).distinct()) + + self.assertEqual('SELECT "foo",SUM(DISTINCT "bar") FROM "abc" GROUP BY "foo"', str(q)) + + def test_groupby__sum_filter(self): + q = ( + Query.from_(self.t) + .groupby(self.t.foo) + .select(self.t.foo, fn.Sum(self.t.bar).filter(self.t.id.eq(1) & self.t.cid.gt(2))) + ) + + self.assertEqual('SELECT "foo",SUM("bar") FILTER(WHERE "id"=1 AND "cid">2) FROM "abc" GROUP BY "foo"', str(q)) + + def test_groupby__str(self): + q = Query.from_("abc").groupby("foo").select("foo", fn.Count("*").distinct()) + + self.assertEqual('SELECT "foo",COUNT(DISTINCT *) FROM "abc" GROUP BY "foo"', str(q)) + + def test_groupby__int(self): + q = Query.from_("abc").groupby(1).select("foo", fn.Count("*").distinct()) + + self.assertEqual('SELECT "foo",COUNT(DISTINCT *) FROM "abc" GROUP BY 1', str(q)) + + def test_groupby__alias(self): + bar = self.t.bar.as_("bar01") + q = Query.from_(self.t).select(fn.Sum(self.t.foo), bar).groupby(bar) + + self.assertEqual('SELECT SUM("foo"),"bar" "bar01" FROM "abc" GROUP BY "bar01"', str(q)) + + def test_groupby__no_alias(self): + bar = self.t.bar.as_("bar01") + q = Query.from_(self.t).select(fn.Sum(self.t.foo), bar).groupby(bar) + + self.assertEqual( + 'SELECT SUM("foo"),"bar" "bar01" FROM "abc" GROUP BY "bar"', + q.get_sql(groupby_alias=False), + ) + + def test_groupby__no_alias_mssql(self): + bar = self.t.bar.as_("bar01") + q = MSSQLQuery.from_(self.t).select(fn.Sum(self.t.foo), bar).groupby(bar) + + self.assertEqual('SELECT SUM("foo"),"bar" "bar01" FROM "abc" GROUP BY "bar"', str(q)) + + def test_groupby__no_alias_oracle(self): + bar = self.t.bar.as_("bar01") + q = OracleQuery.from_(self.t).select(fn.Sum(self.t.foo), bar).groupby(bar) + + self.assertEqual('SELECT SUM(foo),bar bar01 FROM abc GROUP BY bar', str(q)) + + def test_groupby__alias_platforms(self): + bar = self.t.bar.as_("bar01") + + for query_cls in [ + MySQLQuery, + VerticaQuery, + PostgreSQLQuery, + RedshiftQuery, + ClickHouseQuery, + SQLLiteQuery, + ]: + q = query_cls.from_(self.t).select(fn.Sum(self.t.foo), bar).groupby(bar) + + quote_char = query_cls._builder().QUOTE_CHAR if isinstance(query_cls._builder().QUOTE_CHAR, str) else '"' + + self.assertEqual( + "SELECT " + "SUM({quote_char}foo{quote_char})," + "{quote_char}bar{quote_char}{as_keyword}{quote_char}bar01{quote_char} " + "FROM {quote_char}abc{quote_char} " + "GROUP BY {quote_char}bar01{quote_char}".format( + as_keyword=' AS ' if query_cls is ClickHouseQuery else ' ', quote_char=quote_char + ), + str(q), + ) + + def test_groupby__alias_with_join(self): + table1 = Table("table1", alias="t1") + bar = table1.bar.as_("bar01") + q = Query.from_(self.t).join(table1).on(self.t.id == table1.t_ref).select(fn.Sum(self.t.foo), bar).groupby(bar) + + self.assertEqual( + 'SELECT SUM("abc"."foo"),"t1"."bar" "bar01" FROM "abc" ' + 'JOIN "table1" "t1" ON "abc"."id"="t1"."t_ref" ' + 'GROUP BY "bar01"', + str(q), + ) + + def test_groupby_with_case_uses_the_alias(self): + q = ( + Query.from_(self.t) + .select( + fn.Sum(self.t.foo).as_("bar"), + Case().when(self.t.fname == "Tom", "It was Tom").else_("It was someone else.").as_("who_was_it"), + ) + .groupby(Case().when(self.t.fname == "Tom", "It was Tom").else_("It was someone else.").as_("who_was_it")) + ) + + self.assertEqual( + 'SELECT SUM("foo") "bar",' + "CASE WHEN \"fname\"='Tom' THEN 'It was Tom' " + "ELSE 'It was someone else.' END \"who_was_it\" " + 'FROM "abc" ' + 'GROUP BY "who_was_it"', + str(q), + ) + + def test_mysql_query_uses_backtick_quote_chars(self): + q = MySQLQuery.from_(self.t).groupby(self.t.foo).select(self.t.foo) + + self.assertEqual("SELECT `foo` FROM `abc` GROUP BY `foo`", str(q)) + + def test_vertica_query_uses_double_quote_chars(self): + q = VerticaQuery.from_(self.t).groupby(self.t.foo).select(self.t.foo) + + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo"', str(q)) + + def test_mssql_query_uses_double_quote_chars(self): + q = MSSQLQuery.from_(self.t).groupby(self.t.foo).select(self.t.foo) + + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo"', str(q)) + + def test_oracle_query_uses_no_quote_chars(self): + q = OracleQuery.from_(self.t).groupby(self.t.foo).select(self.t.foo) + + self.assertEqual('SELECT foo FROM abc GROUP BY foo', str(q)) + + def test_postgres_query_uses_double_quote_chars(self): + q = PostgreSQLQuery.from_(self.t).groupby(self.t.foo).select(self.t.foo) + + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo"', str(q)) + + def test_redshift_query_uses_double_quote_chars(self): + q = RedshiftQuery.from_(self.t).groupby(self.t.foo).select(self.t.foo) + + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo"', str(q)) + + def test_group_by__single_with_totals(self): + q = Query.from_(self.t).groupby(self.t.foo).select(self.t.foo).with_totals() + + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo" WITH TOTALS', str(q)) + + def test_groupby__multi_with_totals(self): + q = Query.from_(self.t).groupby(self.t.foo, self.t.bar).select(self.t.foo, self.t.bar).with_totals() + + self.assertEqual('SELECT "foo","bar" FROM "abc" GROUP BY "foo","bar" WITH TOTALS', str(q)) + + +class HavingTests(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_having_greater_than(self): + q = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, fn.Sum(self.table_abc.bar)) + .groupby(self.table_abc.foo) + .having(fn.Sum(self.table_abc.bar) > 1) + ) + + self.assertEqual( + 'SELECT "foo",SUM("bar") FROM "abc" GROUP BY "foo" HAVING SUM("bar")>1', + str(q), + ) + + def test_having_and(self): + q = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, fn.Sum(self.table_abc.bar)) + .groupby(self.table_abc.foo) + .having((fn.Sum(self.table_abc.bar) > 1) & (fn.Sum(self.table_abc.bar) < 100)) + ) + + self.assertEqual( + 'SELECT "foo",SUM("bar") FROM "abc" GROUP BY "foo" HAVING SUM("bar")>1 AND SUM("bar")<100', + str(q), + ) + + def test_having_join_and_equality(self): + q = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.foo) + .select(self.table_abc.foo, fn.Sum(self.table_efg.bar), self.table_abc.buz) + .groupby(self.table_abc.foo) + .having(self.table_abc.buz == "fiz") + .having(fn.Sum(self.table_efg.bar) > 100) + ) + + self.assertEqual( + 'SELECT "abc"."foo",SUM("efg"."bar"),"abc"."buz" FROM "abc" ' + 'JOIN "efg" ON "abc"."foo"="efg"."foo" ' + 'GROUP BY "abc"."foo" ' + 'HAVING "abc"."buz"=\'fiz\' AND SUM("efg"."bar")>100', + str(q), + ) + + def test_mysql_query_uses_backtick_quote_chars(self): + q = ( + MySQLQuery.from_(self.table_abc) + .select(self.table_abc.foo) + .groupby(self.table_abc.foo) + .having(self.table_abc.buz == "fiz") + ) + self.assertEqual("SELECT `foo` FROM `abc` GROUP BY `foo` HAVING `buz`='fiz'", str(q)) + + def test_vertica_query_uses_double_quote_chars(self): + q = ( + VerticaQuery.from_(self.table_abc) + .select(self.table_abc.foo) + .groupby(self.table_abc.foo) + .having(self.table_abc.buz == "fiz") + ) + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo" HAVING "buz"=\'fiz\'', str(q)) + + def test_mssql_query_uses_double_quote_chars(self): + q = ( + MSSQLQuery.from_(self.table_abc) + .select(self.table_abc.foo) + .groupby(self.table_abc.foo) + .having(self.table_abc.buz == "fiz") + ) + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo" HAVING "buz"=\'fiz\'', str(q)) + + def test_oracle_query_uses_no_quote_chars(self): + q = ( + OracleQuery.from_(self.table_abc) + .select(self.table_abc.foo) + .groupby(self.table_abc.foo) + .having(self.table_abc.buz == "fiz") + ) + self.assertEqual('SELECT foo FROM abc GROUP BY foo HAVING buz=\'fiz\'', str(q)) + + def test_postgres_query_uses_double_quote_chars(self): + q = ( + PostgreSQLQuery.from_(self.table_abc) + .select(self.table_abc.foo) + .groupby(self.table_abc.foo) + .having(self.table_abc.buz == "fiz") + ) + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo" HAVING "buz"=\'fiz\'', str(q)) + + def test_redshift_query_uses_double_quote_chars(self): + q = ( + RedshiftQuery.from_(self.table_abc) + .select(self.table_abc.foo) + .groupby(self.table_abc.foo) + .having(self.table_abc.buz == "fiz") + ) + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo" HAVING "buz"=\'fiz\'', str(q)) + + +class OrderByTests(unittest.TestCase): + t = Table("abc") + + def test_orderby_single_field(self): + q = Query.from_(self.t).orderby(self.t.foo).select(self.t.foo) + + self.assertEqual('SELECT "foo" FROM "abc" ORDER BY "foo"', str(q)) + + def test_orderby_multi_fields(self): + q = Query.from_(self.t).orderby(self.t.foo, self.t.bar).select(self.t.foo, self.t.bar) + + self.assertEqual('SELECT "foo","bar" FROM "abc" ORDER BY "foo","bar"', str(q)) + + def test_orderby_single_str(self): + q = Query.from_("abc").orderby("foo").select("foo") + + self.assertEqual('SELECT "foo" FROM "abc" ORDER BY "foo"', str(q)) + + def test_orderby_asc(self): + q = Query.from_(self.t).orderby(self.t.foo, order=Order.asc).select(self.t.foo) + + self.assertEqual('SELECT "foo" FROM "abc" ORDER BY "foo" ASC', str(q)) + + def test_orderby_desc(self): + q = Query.from_(self.t).orderby(self.t.foo, order=Order.desc).select(self.t.foo) + + self.assertEqual('SELECT "foo" FROM "abc" ORDER BY "foo" DESC', str(q)) + + def test_orderby_no_alias(self): + bar = self.t.bar.as_("bar01") + q = Query.from_(self.t).select(fn.Sum(self.t.foo), bar).orderby(bar) + + self.assertEqual( + 'SELECT SUM("foo"),"bar" "bar01" FROM "abc" ORDER BY "bar"', + q.get_sql(orderby_alias=False), + ) + + def test_orderby_alias(self): + bar = self.t.bar.as_("bar01") + q = Query.from_(self.t).select(fn.Sum(self.t.foo), bar).orderby(bar) + + self.assertEqual('SELECT SUM("foo"),"bar" "bar01" FROM "abc" ORDER BY "bar01"', q.get_sql()) + + +class AliasTests(unittest.TestCase): + t = Table("abc") + + def test_table_field(self): + q = Query.from_(self.t).select(self.t.foo.as_("bar")) + + self.assertEqual('SELECT "foo" "bar" FROM "abc"', str(q)) + + def test_table_field__multi(self): + q = Query.from_(self.t).select(self.t.foo.as_("bar"), self.t.fiz.as_("buz")) + + self.assertEqual('SELECT "foo" "bar","fiz" "buz" FROM "abc"', str(q)) + + def test_arithmetic_function(self): + q = Query.from_(self.t).select((self.t.foo + self.t.bar).as_("biz")) + + self.assertEqual('SELECT "foo"+"bar" "biz" FROM "abc"', str(q)) + + def test_functions_using_as(self): + q = Query.from_(self.t).select(fn.Count("*").as_("foo")) + + self.assertEqual('SELECT COUNT(*) "foo" FROM "abc"', str(q)) + + def test_functions_using_constructor_param(self): + q = Query.from_(self.t).select(fn.Count("*", alias="foo")) + + self.assertEqual('SELECT COUNT(*) "foo" FROM "abc"', str(q)) + + def test_function_using_as_nested(self): + """ + We don't show aliases of fields that are arguments of a function. + """ + q = Query.from_(self.t).select(fn.Sqrt(fn.Count("*").as_("foo")).as_("bar")) + + self.assertEqual('SELECT SQRT(COUNT(*)) "bar" FROM "abc"', str(q)) + + def test_functions_using_constructor_param_nested(self): + """ + We don't show aliases of fields that are arguments of a function. + """ + q = Query.from_(self.t).select(fn.Sqrt(fn.Count("*", alias="foo"), alias="bar")) + + self.assertEqual('SELECT SQRT(COUNT(*)) "bar" FROM "abc"', str(q)) + + def test_ignored_in_where(self): + q = Query.from_(self.t).select(self.t.foo).where(self.t.foo.as_("bar") == 1) + + self.assertEqual('SELECT "foo" FROM "abc" WHERE "foo"=1', str(q)) + + def test_ignored_in_groupby(self): + q = Query.from_(self.t).select(self.t.foo).groupby(self.t.foo.as_("bar")) + + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo"', str(q)) + + def test_ignored_in_orderby(self): + q = Query.from_(self.t).select(self.t.foo).orderby(self.t.foo.as_("bar")) + + self.assertEqual('SELECT "foo" FROM "abc" ORDER BY "foo"', str(q)) + + def test_ignored_in_criterion(self): + c = self.t.foo.as_("bar") == 1 + + self.assertEqual('"foo"=1', str(c)) + + def test_ignored_in_criterion_comparison(self): + c = self.t.foo.as_("bar") == self.t.fiz.as_("buz") + + self.assertEqual('"foo"="fiz"', str(c)) + + def test_ignored_in_field_inside_case(self): + q = Query.from_(self.t).select(Case().when(self.t.foo == 1, "a").else_(self.t.bar.as_('"buz"'))) + + self.assertEqual('SELECT CASE WHEN "foo"=1 THEN \'a\' ELSE "bar" END FROM "abc"', str(q)) + + def test_case_using_as(self): + q = Query.from_(self.t).select(Case().when(self.t.foo == 1, "a").else_("b").as_("bar")) + + self.assertEqual( + 'SELECT CASE WHEN "foo"=1 THEN \'a\' ELSE \'b\' END "bar" FROM "abc"', + str(q), + ) + + def test_case_using_constructor_param(self): + q = Query.from_(self.t).select(Case(alias="bar").when(self.t.foo == 1, "a").else_("b")) + + self.assertEqual( + 'SELECT CASE WHEN "foo"=1 THEN \'a\' ELSE \'b\' END "bar" FROM "abc"', + str(q), + ) + + def test_select__multiple_tables(self): + table_abc, table_efg = Table("abc", alias="q0"), Table("efg", alias="q1") + + q = Query.from_(table_abc).select(table_abc.foo).from_(table_efg).select(table_efg.bar) + + self.assertEqual('SELECT "q0"."foo","q1"."bar" FROM "abc" "q0","efg" "q1"', str(q)) + + def test_use_aliases_in_groupby_and_orderby(self): + table_abc = Table("abc", alias="q0") + + my_foo = table_abc.foo.as_("my_foo") + q = Query.from_(table_abc).select(my_foo, table_abc.bar).groupby(my_foo).orderby(my_foo) + + self.assertEqual( + 'SELECT "q0"."foo" "my_foo","q0"."bar" ' 'FROM "abc" "q0" ' 'GROUP BY "my_foo" ' 'ORDER BY "my_foo"', + str(q), + ) + + def test_table_with_schema_and_alias(self): + table = Table("abc", schema="schema", alias="alias") + self.assertEqual('"schema"."abc" "alias"', str(table)) + + def test_null_value_with_alias(self): + q = Query.select(NullValue().as_("abcdef")) + + self.assertEqual('SELECT NULL "abcdef"', str(q)) + + +class SubqueryTests(unittest.TestCase): + maxDiff = None + + table_abc, table_efg, table_hij = Tables("abc", "efg", "hij") + + def test_where__in(self): + q = ( + Query.from_(self.table_abc) + .select("*") + .where( + self.table_abc.foo.isin( + Query.from_(self.table_efg).select(self.table_efg.foo).where(self.table_efg.bar == 0) + ) + ) + ) + + self.assertEqual( + 'SELECT * FROM "abc" WHERE "foo" IN (SELECT "foo" FROM "efg" WHERE "bar"=0)', + str(q), + ) + + def test_where__in_nested(self): + q = Query.from_(self.table_abc).select("*").where(self.table_abc.foo).isin(self.table_efg.select("*")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" IN (SELECT * FROM "efg")', str(q)) + + def test_join(self): + subquery = Query.from_("efg").select("fiz", "buz").where(F("buz") == 0) + + q = ( + Query.from_(self.table_abc) + .join(subquery) + .on(self.table_abc.bar == subquery.buz) + .select(self.table_abc.foo, subquery.fiz) + ) + + self.assertEqual( + 'SELECT "abc"."foo","sq0"."fiz" FROM "abc" ' + 'JOIN (SELECT "fiz","buz" FROM "efg" WHERE "buz"=0) "sq0" ' + 'ON "abc"."bar"="sq0"."buz"', + str(q), + ) + + def test_select_subquery(self): + subq = Query.from_(self.table_efg).select("fizzbuzz").where(self.table_efg.id == 1) + + q = Query.from_(self.table_abc).select("foo", "bar").select(subq) + + self.assertEqual( + 'SELECT "foo","bar",(SELECT "fizzbuzz" FROM "efg" WHERE "id"=1) ' 'FROM "abc"', + str(q), + ) + + def test_select_subquery_with_alias(self): + subq = Query.from_(self.table_efg).select("fizzbuzz").where(self.table_efg.id == 1) + + q = Query.from_(self.table_abc).select("foo", "bar").select(subq.as_("sq")) + + self.assertEqual( + 'SELECT "foo","bar",(SELECT "fizzbuzz" FROM "efg" WHERE "id"=1) "sq" ' 'FROM "abc"', + str(q), + ) + + def test_where__equality(self): + subquery = Query.from_("efg").select("fiz").where(F("buz") == 0) + query = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, self.table_abc.bar) + .where(self.table_abc.bar == subquery) + ) + + self.assertEqual( + 'SELECT "foo","bar" FROM "abc" ' 'WHERE "bar"=(SELECT "fiz" FROM "efg" WHERE "buz"=0)', + str(query), + ) + + def test_select_from_nested_query(self): + subquery = Query.from_(self.table_abc).select( + self.table_abc.foo, + self.table_abc.bar, + (self.table_abc.fizz + self.table_abc.buzz).as_("fizzbuzz"), + ) + + query = Query.from_(subquery).select(subquery.foo, subquery.bar, subquery.fizzbuzz) + + self.assertEqual( + 'SELECT "sq0"."foo","sq0"."bar","sq0"."fizzbuzz" ' + "FROM (" + 'SELECT "foo","bar","fizz"+"buzz" "fizzbuzz" ' + 'FROM "abc"' + ') "sq0"', + str(query), + ) + + def test_select_from_nested_query_with_join(self): + subquery1 = ( + Query.from_(self.table_abc) + .select( + self.table_abc.foo, + fn.Sum(self.table_abc.fizz + self.table_abc.buzz).as_("fizzbuzz"), + ) + .groupby(self.table_abc.foo) + ) + + subquery2 = Query.from_(self.table_efg).select( + self.table_efg.foo.as_("foo_two"), + self.table_efg.bar, + ) + + query = ( + Query.from_(subquery1) + .select(subquery1.foo, subquery1.fizzbuzz) + .join(subquery2) + .on(subquery1.foo == subquery2.foo_two) + .select(subquery2.foo_two, subquery2.bar) + ) + + self.assertEqual( + "SELECT " + '"sq0"."foo","sq0"."fizzbuzz",' + '"sq1"."foo_two","sq1"."bar" ' + "FROM (" + "SELECT " + '"foo",SUM("fizz"+"buzz") "fizzbuzz" ' + 'FROM "abc" ' + 'GROUP BY "foo"' + ') "sq0" JOIN (' + "SELECT " + '"foo" "foo_two","bar" ' + 'FROM "efg"' + ') "sq1" ON "sq0"."foo"="sq1"."foo_two"', + str(query), + ) + + def test_from_subquery_without_alias(self): + subquery = Query.from_(self.table_efg).select( + self.table_efg.base_id.as_("x"), self.table_efg.fizz, self.table_efg.buzz + ) + + test_query = Query.from_(subquery).select(subquery.x, subquery.fizz, subquery.buzz) + + self.assertEqual( + 'SELECT "sq0"."x","sq0"."fizz","sq0"."buzz" ' + "FROM (" + 'SELECT "base_id" "x","fizz","buzz" FROM "efg"' + ') "sq0"', + str(test_query), + ) + + def test_join_query_with_alias(self): + subquery = ( + Query.from_(self.table_efg) + .select( + self.table_efg.base_id.as_("x"), + self.table_efg.fizz, + self.table_efg.buzz, + ) + .as_("subq") + ) + + test_query = Query.from_(subquery).select(subquery.x, subquery.fizz, subquery.buzz) + + self.assertEqual( + 'SELECT "subq"."x","subq"."fizz","subq"."buzz" ' + "FROM (" + 'SELECT "base_id" "x","fizz","buzz" FROM "efg"' + ') "subq"', + str(test_query), + ) + + def test_with(self): + sub_query = Query.from_(self.table_efg).select("fizz") + test_query = Query.with_(sub_query, "an_alias").from_(AliasedQuery("an_alias")).select("*") + + self.assertEqual( + 'WITH an_alias AS (SELECT "fizz" FROM "efg") SELECT * FROM an_alias', + str(test_query), + ) + + def test_join_with_with(self): + sub_query = Query.from_(self.table_efg).select("fizz") + test_query = ( + Query.with_(sub_query, "an_alias") + .from_(self.table_abc) + .join(AliasedQuery("an_alias")) + .on(AliasedQuery("an_alias").fizz == self.table_abc.buzz) + .select("*") + ) + self.assertEqual( + 'WITH an_alias AS (SELECT "fizz" FROM "efg") ' + 'SELECT * FROM "abc" JOIN an_alias ON "an_alias"."fizz"="abc"."buzz"', + str(test_query), + ) + + def test_select_from_with_returning(self): + sub_query = PostgreSQLQuery.into(self.table_abc).insert(1).returning('*') + test_query = Query.with_(sub_query, "an_alias").from_(AliasedQuery("an_alias")).select("*") + self.assertEqual( + 'WITH an_alias AS (INSERT INTO "abc" VALUES (1) RETURNING *) SELECT * FROM an_alias', str(test_query) + ) + + +class QuoteTests(unittest.TestCase): + def test_extraneous_quotes(self): + t1 = Table("table1", alias="t1") + t2 = Table("table2", alias="t2") + + query = Query.from_(t1).join(t2).on(t1.Value.between(t2.start, t2.end)).select(t1.value) + + self.assertEqual( + "SELECT t1.value FROM table1 t1 " "JOIN table2 t2 ON t1.Value " "BETWEEN t2.start AND t2.end", + query.get_sql(quote_char=None), + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/test_tables.py b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/test_tables.py new file mode 100644 index 0000000000000000000000000000000000000000..f43e740915f642d29ce7497c36e3b68f01311016 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/test_tables.py @@ -0,0 +1,186 @@ +# from pypika.terms import ValueWrapper, SystemTimeValue +import unittest + +from pypika import Database, Dialects, Schema, SQLLiteQuery, Table, Tables, Query, SYSTEM_TIME + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + + +class TableStructureTests(unittest.TestCase): + def test_table_sql(self): + table = Table("test_table") + + self.assertEqual('"test_table"', str(table)) + + def test_table_with_alias(self): + table = Table("test_table").as_("my_table") + + self.assertEqual('"test_table" "my_table"', table.get_sql(with_alias=True, quote_char='"')) + + def test_schema_table_attr(self): + table = Schema("x_schema").test_table + + self.assertEqual('"x_schema"."test_table"', str(table)) + + def test_table_with_schema_arg(self): + table = Table("test_table", schema=Schema("x_schema")) + + self.assertEqual('"x_schema"."test_table"', str(table)) + + def test_database_schema_table_attr(self): + table = Database("x_db").x_schema.test_table + + self.assertEqual('"x_db"."x_schema"."test_table"', str(table)) + + def test_table_with_schema_and_schema_parent_arg(self): + table = Table("test_table", schema=Schema("x_schema", parent=Database("x_db"))) + + self.assertEqual('"x_db"."x_schema"."test_table"', str(table)) + + def test_table_for_system_time_sql(self): + with self.subTest("with between criterion"): + table = Table("test_table").for_(SYSTEM_TIME.between('2020-01-01', '2020-02-01')) + + self.assertEqual('"test_table" FOR SYSTEM_TIME BETWEEN \'2020-01-01\' AND \'2020-02-01\'', str(table)) + + with self.subTest("with as of criterion"): + table = Table("test_table").for_(SYSTEM_TIME.as_of('2020-01-01')) + + self.assertEqual('"test_table" FOR SYSTEM_TIME AS OF \'2020-01-01\'', str(table)) + + with self.subTest("with from to criterion"): + table = Table("test_table").for_(SYSTEM_TIME.from_to('2020-01-01', '2020-02-01')) + + self.assertEqual('"test_table" FOR SYSTEM_TIME FROM \'2020-01-01\' TO \'2020-02-01\'', str(table)) + + def test_table_for_period_sql(self): + with self.subTest("with between criterion"): + table = Table("test_table") + table = table.for_(table.valid_period.between('2020-01-01', '2020-02-01')) + + self.assertEqual('"test_table" FOR "valid_period" BETWEEN \'2020-01-01\' AND \'2020-02-01\'', str(table)) + + with self.subTest("with as of criterion"): + table = Table("test_table") + table = table.for_(table.valid_period.as_of('2020-01-01')) + + self.assertEqual('"test_table" FOR "valid_period" AS OF \'2020-01-01\'', str(table)) + + with self.subTest("with from to criterion"): + table = Table("test_table") + table = table.for_(table.valid_period.from_to('2020-01-01', '2020-02-01')) + + self.assertEqual('"test_table" FOR "valid_period" FROM \'2020-01-01\' TO \'2020-02-01\'', str(table)) + + +class TableEqualityTests(unittest.TestCase): + def test_tables_equal_by_name(self): + t1 = Table("t") + t2 = Table("t") + + self.assertEqual(t1, t2) + + def test_tables_equal_by_schema_and_name(self): + t1 = Table("t", schema="a") + t2 = Table("t", schema="a") + + self.assertEqual(t1, t2) + + def test_tables_equal_by_schema_and_name_using_schema(self): + a = Schema("a") + t1 = Table("t", schema=a) + t2 = Table("t", schema=a) + + self.assertEqual(t1, t2) + + def test_tables_equal_by_schema_and_name_using_schema_with_parent(self): + parent = Schema("parent") + a = Schema("a", parent=parent) + t1 = Table("t", schema=a) + t2 = Table("t", schema=a) + + self.assertEqual(t1, t2) + + def test_tables_not_equal_by_schema_and_name_using_schema_with_different_parents( + self, + ): + parent = Schema("parent") + a = Schema("a", parent=parent) + t1 = Table("t", schema=a) + t2 = Table("t", schema=Schema("a")) + + self.assertNotEqual(t1, t2) + + def test_tables_not_equal_with_different_schemas(self): + t1 = Table("t", schema="a") + t2 = Table("t", schema="b") + + self.assertNotEqual(t1, t2) + + def test_tables_not_equal_with_different_names(self): + t1 = Table("t", schema="a") + t2 = Table("q", schema="a") + + self.assertNotEqual(t1, t2) + + def test_many_tables_with_alias(self): + tables_data = [("table1", "t1"), ("table2", "t2"), ("table3", "t3")] + tables = Tables(*tables_data) + for el in tables: + self.assertIsNotNone(el.alias) + + def test_many_tables_without_alias(self): + tables_data = ["table1", "table2", "table3"] + tables = Tables(*tables_data) + for el in tables: + self.assertIsNone(el.alias) + + def test_many_tables_with_or_not_alias(self): + tables_data = [("table1", "t1"), ("table2"), "table3"] + tables = Tables(*tables_data) + for i in range(len(tables)): + if isinstance(tables_data[i], tuple): + self.assertIsNotNone(tables[i].alias) + else: + self.assertIsNone(tables[i].alias) + + +class TableDialectTests(unittest.TestCase): + def test_table_with_default_query_cls(self): + table = Table("abc") + q = table.select("1") + self.assertIs(q.dialect, None) + + def test_table_with_dialect_query_cls(self): + table = Table("abc", query_cls=SQLLiteQuery) + q = table.select("1") + self.assertIs(q.dialect, Dialects.SQLLITE) + + def test_table_factory_with_default_query_cls(self): + table = Query.Table("abc") + q = table.select("1") + self.assertIs(q.dialect, None) + + def test_table_factory_with_dialect_query_cls(self): + table = SQLLiteQuery.Table("abc") + q = table.select("1") + self.assertIs(q.dialect, Dialects.SQLLITE) + + def test_make_tables_factory_with_default_query_cls(self): + t1, t2 = Query.Tables("abc", "def") + q1 = t1.select("1") + q2 = t2.select("2") + self.assertIs(q1.dialect, None) + self.assertIs(q2.dialect, None) + + def test_make_tables_factory_with_dialect_query_cls(self): + t1, t2 = SQLLiteQuery.Tables("abc", "def") + q1 = t1.select("1") + q2 = t2.select("2") + self.assertIs(q1.dialect, Dialects.SQLLITE) + self.assertIs(q2.dialect, Dialects.SQLLITE) + + def test_table_with_bad_query_cls(self): + with self.assertRaises(TypeError): + Table("abc", query_cls=object) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/test_terms.py b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/test_terms.py new file mode 100644 index 0000000000000000000000000000000000000000..4c7590dfce129bac97a3f30de99b596cc746c893 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/test_terms.py @@ -0,0 +1,82 @@ +from unittest import TestCase + +from pypika import Query, Table, Field +from pypika.terms import AtTimezone + + +class FieldAliasTests(TestCase): + t = Table("test", alias="crit") + + def test_when_alias_specified(self): + c1 = Field("foo", alias="bar") + self.assertEqual('bar', str(c1.alias)) + + c1 = Field("foo").as_("bar") + self.assertEqual('bar', str(c1.alias)) + + +class FieldInitTests(TestCase): + def test_init_with_str_table(self): + test_table_name = "test_table" + field = Field(name="name", table=test_table_name) + self.assertEqual(field.table, Table(name=test_table_name)) + + +class FieldHashingTests(TestCase): + def test_tabled_eq_fields_equally_hashed(self): + client_name1 = Field(name="name", table=Table("clients")) + client_name2 = Field(name="name", table=Table("clients")) + self.assertTrue(hash(client_name1) == hash(client_name2)) + + def test_tabled_ne_fields_differently_hashed(self): + customer_name = Field(name="name", table=Table("customers")) + client_name = Field(name="name", table=Table("clients")) + self.assertTrue(hash(customer_name) != hash(client_name)) + + def test_non_tabled_aliased_eq_fields_equally_hashed(self): + self.assertTrue(hash(Field(name="A", alias="my_a")) == hash(Field(name="A", alias="my_a"))) + + def test_non_tabled_aliased_ne_fields_differently_hashed(self): + self.assertTrue(hash(Field(name="A", alias="my_a1")) != hash(Field(name="A", alias="my_a2"))) + + def test_non_tabled_eq_fields_equally_hashed(self): + self.assertTrue(hash(Field(name="A")) == hash(Field(name="A"))) + + def test_non_tabled_ne_fields_differently_hashed(self): + self.assertTrue(hash(Field(name="A")) != hash(Field(name="B"))) + + +class AtTimezoneTests(TestCase): + def test_when_interval_not_specified(self): + query = Query.from_("customers").select(AtTimezone("date", "US/Eastern")) + self.assertEqual('SELECT "date" AT TIME ZONE \'US/Eastern\' FROM "customers"', str(query)) + + def test_when_interval_specified(self): + query = Query.from_("customers").select(AtTimezone("date", "-06:00", interval=True)) + self.assertEqual( + 'SELECT "date" AT TIME ZONE INTERVAL \'-06:00\' FROM "customers"', + str(query), + ) + + def test_when_alias_specified(self): + query = Query.from_("customers").select(AtTimezone("date", "US/Eastern", alias="alias1")) + self.assertEqual( + 'SELECT "date" AT TIME ZONE \'US/Eastern\' "alias1" FROM "customers"', + str(query), + ) + + def test_passes_kwargs_to_field_get_sql(self): + customers = Table("customers") + accounts = Table("accounts") + query = ( + Query.from_(customers) + .join(accounts) + .on(customers.account_id == accounts.account_id) + .select(AtTimezone(customers.date, "US/Eastern", alias="alias1")) + ) + + self.assertEqual( + 'SELECT "customers"."date" AT TIME ZONE \'US/Eastern\' "alias1" ' + 'FROM "customers" JOIN "accounts" ON "customers"."account_id"="accounts"."account_id"', + query.get_sql(with_namespace=True), + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/test_tuples.py b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/test_tuples.py new file mode 100644 index 0000000000000000000000000000000000000000..c8ebc8e41b0115777f8b3c8cb01c04e62f13ee18 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/test_tuples.py @@ -0,0 +1,162 @@ +import unittest + +from pypika import ( + Array, + Bracket, + Query, + PostgreSQLQuery, + Table, + Tables, + Tuple, +) +from pypika.functions import Coalesce, NullIf, Sum +from pypika.terms import Field + + +class TupleTests(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_tuple_equality_tuple_on_both(self): + q = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, self.table_abc.bar) + .where(Tuple(self.table_abc.foo, self.table_abc.bar) == Tuple(1, 2)) + ) + + self.assertEqual('SELECT "foo","bar" FROM "abc" ' 'WHERE ("foo","bar")=(1,2)', str(q)) + + def test_tuple_equality_tuple_on_left(self): + q = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, self.table_abc.bar) + .where(Tuple(self.table_abc.foo, self.table_abc.bar) == (1, 2)) + ) + + self.assertEqual('SELECT "foo","bar" FROM "abc" ' 'WHERE ("foo","bar")=(1,2)', str(q)) + + def test_tuple_equality_tuple_on_right(self): + q = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, self.table_abc.bar) + .where((self.table_abc.foo, self.table_abc.bar) == Tuple(1, 2)) + ) + + # Order is reversed due to lack of right equals method + self.assertEqual('SELECT "foo","bar" FROM "abc" ' 'WHERE (1,2)=("foo","bar")', str(q)) + + def test_tuple_in_using_python_tuples(self): + q = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, self.table_abc.bar) + .where(Tuple(self.table_abc.foo, self.table_abc.bar).isin([(1, 1), (2, 2), (3, 3)])) + ) + + self.assertEqual( + 'SELECT "foo","bar" FROM "abc" ' 'WHERE ("foo","bar") IN ((1,1),(2,2),(3,3))', + str(q), + ) + + def test_tuple_in_using_pypika_tuples(self): + q = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, self.table_abc.bar) + .where(Tuple(self.table_abc.foo, self.table_abc.bar).isin([Tuple(1, 1), Tuple(2, 2), Tuple(3, 3)])) + ) + + self.assertEqual( + 'SELECT "foo","bar" FROM "abc" ' 'WHERE ("foo","bar") IN ((1,1),(2,2),(3,3))', + str(q), + ) + + def test_tuple_in_using_mixed_tuples(self): + q = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, self.table_abc.bar) + .where(Tuple(self.table_abc.foo, self.table_abc.bar).isin([(1, 1), Tuple(2, 2), (3, 3)])) + ) + + self.assertEqual( + 'SELECT "foo","bar" FROM "abc" ' 'WHERE ("foo","bar") IN ((1,1),(2,2),(3,3))', + str(q), + ) + + def test_tuples_in_join(self): + query = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .select("*") + .where(Tuple(self.table_abc.foo, self.table_efg.bar).isin([(1, 1), Tuple(2, 2), (3, 3)])) + ) + + self.assertEqual( + 'SELECT * FROM "abc" JOIN "efg" ON "abc"."foo"="efg"."bar" ' + 'WHERE ("abc"."foo","efg"."bar") IN ((1,1),(2,2),(3,3))', + str(query), + ) + + def test_render_alias_in_array_sql(self): + tb = Table("tb") + + q = Query.from_(tb).select(Tuple(tb.col).as_("different_name")) + self.assertEqual(str(q), 'SELECT ("col") "different_name" FROM "tb"') + + def test_tuple_is_aggregate(self): + with self.subTest('None if single argument returns None for is_aggregate'): + self.assertEqual(None, Tuple(0).is_aggregate) + self.assertEqual(None, Tuple(Coalesce('col')).is_aggregate) + + with self.subTest('None if multiple arguments all return None for is_aggregate'): + self.assertEqual(None, Tuple(0, 'a').is_aggregate) + self.assertEqual(None, Tuple(Coalesce('col'), NullIf('col2', 0)).is_aggregate) + + with self.subTest('True if single argument returns True for is_aggregate'): + self.assertEqual(True, Tuple(Sum('col')).is_aggregate) + + with self.subTest('True if multiple arguments return True for is_aggregate'): + self.assertEqual(True, Tuple(Sum('col'), Sum('col2')).is_aggregate) + + with self.subTest('True when mix of arguments returning None and True for is_aggregate'): + self.assertEqual(True, Tuple(Coalesce('col'), Coalesce('col2', 0), Sum('col3')).is_aggregate) + + with self.subTest('False when one of the arguments returns False for is_aggregate'): + self.assertEqual(False, Tuple(Field('col1'), Sum('col2')).is_aggregate) + + +class ArrayTests(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_array_general(self): + query = Query.from_(self.table_abc).select(Array(1, "a", ["b", 2, 3])) + + self.assertEqual("SELECT [1,'a',['b',2,3]] FROM \"abc\"", str(query)) + + def test_empty_psql_array(self): + query = PostgreSQLQuery.from_(self.table_abc).select(Array()) + + self.assertEqual("SELECT '{}' FROM \"abc\"", str(query)) + + def test_psql_array_general(self): + query = PostgreSQLQuery.from_(self.table_abc).select(Array(1, Array(2, 2, 2), 3)) + + self.assertEqual("SELECT ARRAY[1,ARRAY[2,2,2],3] FROM \"abc\"", str(query)) + + def test_render_alias_in_array_sql(self): + tb = Table("tb") + + q = Query.from_(tb).select(Array(tb.col).as_("different_name")) + self.assertEqual(str(q), 'SELECT ["col"] "different_name" FROM "tb"') + + +class BracketTests(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_arithmetic_with_brackets(self): + q = Query.from_(self.table_abc).select(Bracket(self.table_abc.foo / 2) / 2) + + self.assertEqual('SELECT ("foo"/2)/2 FROM "abc"', str(q)) + + def test_arithmetic_with_brackets_and_alias(self): + q = Query.from_(self.table_abc).select(Bracket(self.table_abc.foo / 2).as_("alias")) + + self.assertEqual('SELECT ("foo"/2) "alias" FROM "abc"', str(q)) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/test_updates.py b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/test_updates.py new file mode 100644 index 0000000000000000000000000000000000000000..fb9d714dbcb8213b4bda04bf7b8dd9b2419410ec --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/test_updates.py @@ -0,0 +1,162 @@ +import unittest + +from pypika import AliasedQuery, PostgreSQLQuery, Query, SQLLiteQuery, SYSTEM_TIME, Table + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + +from pypika.terms import Star + + +class UpdateTests(unittest.TestCase): + table_abc = Table("abc") + table_def = Table("def") + + def test_empty_query(self): + q = Query.update("abc") + + self.assertEqual("", str(q)) + + def test_omit_where(self): + q = Query.update(self.table_abc).set("foo", "bar") + + self.assertEqual('UPDATE "abc" SET "foo"=\'bar\'', str(q)) + + def test_single_quote_escape_in_set(self): + q = Query.update(self.table_abc).set("foo", "bar'foo") + + self.assertEqual("UPDATE \"abc\" SET \"foo\"='bar''foo'", str(q)) + + def test_update__table_schema(self): + table = Table("abc", "schema1") + q = Query.update(table).set(table.foo, 1).where(table.foo == 0) + + self.assertEqual('UPDATE "schema1"."abc" SET "foo"=1 WHERE "foo"=0', str(q)) + + def test_update_with_none(self): + q = Query.update("abc").set("foo", None) + self.assertEqual('UPDATE "abc" SET "foo"=null', str(q)) + + def test_update_with_join(self): + q = ( + Query.update(self.table_abc) + .join(self.table_def) + .on(self.table_def.abc_id == self.table_abc.id) + .set(self.table_abc.lname, self.table_def.lname) + ) + self.assertEqual( + 'UPDATE "abc" JOIN "def" ON "def"."abc_id"="abc"."id" SET "lname"="def"."lname"', + str(q), + ) + + def test_update_with_limit(self): + q = Query.update(self.table_abc).set(self.table_abc.lname, "test").limit(1) + self.assertEqual('UPDATE "abc" SET "lname"=\'test\' LIMIT 1', str(q)) + + def test_update_from(self): + from_table = Table('from_table') + + q = Query.update(self.table_abc).set(self.table_abc.lname, from_table.long_name).from_(from_table) + self.assertEqual('UPDATE "abc" SET "lname"="from_table"."long_name" FROM "from_table"', str(q)) + + def test_update_from_with_where(self): + from_table = Table('from_table') + + q = ( + Query.update(self.table_abc) + .set(self.table_abc.lname, from_table.long_name) + .from_(from_table) + .where(self.table_abc.fname.eq(from_table.full_name)) + ) + self.assertEqual( + 'UPDATE "abc" SET "lname"="from_table"."long_name" FROM "from_table" ' + 'WHERE "abc"."fname"="from_table"."full_name"', + str(q), + ) + + def test_update_with_statement(self): + table_efg = Table('efg') + + sub_query = Query.from_(table_efg).select("fizz") + an_alias = AliasedQuery("an_alias") + + q = ( + Query.with_(sub_query, "an_alias") + .update(self.table_abc) + .from_(an_alias) + .set(self.table_abc.lname, an_alias.long_name) + .where(self.table_abc.comp.eq(an_alias.alias_comp)) + ) + self.assertEqual( + 'WITH an_alias AS (SELECT "fizz" FROM "efg") ' + 'UPDATE "abc" SET "lname"="an_alias"."long_name" FROM an_alias ' + 'WHERE "abc"."comp"="an_alias"."alias_comp"', + str(q), + ) + + def test_for_portion(self): + with self.subTest("with system time"): + q = Query.update(self.table_abc.for_portion(SYSTEM_TIME.from_to('2020-01-01', '2020-02-01'))).set( + "foo", "bar" + ) + + self.assertEqual( + 'UPDATE "abc" FOR PORTION OF SYSTEM_TIME FROM \'2020-01-01\' TO \'2020-02-01\' SET "foo"=\'bar\'', + str(q), + ) + + with self.subTest("with column"): + q = Query.update( + self.table_abc.for_portion(self.table_abc.valid_period.from_to('2020-01-01', '2020-02-01')) + ).set("foo", "bar") + + self.assertEqual( + 'UPDATE "abc" FOR PORTION OF "valid_period" FROM \'2020-01-01\' TO \'2020-02-01\' SET "foo"=\'bar\'', + str(q), + ) + + +class PostgresUpdateTests(unittest.TestCase): + table_abc = Table("abc") + + def test_update_returning_str(self): + q = PostgreSQLQuery.update(self.table_abc).where(self.table_abc.foo == 0).set("foo", "bar").returning("id") + + self.assertEqual('UPDATE "abc" SET "foo"=\'bar\' WHERE "foo"=0 RETURNING "abc"."id"', str(q)) + + def test_update_returning(self): + q = ( + PostgreSQLQuery.update(self.table_abc) + .where(self.table_abc.foo == 0) + .set("foo", "bar") + .returning(self.table_abc.id) + ) + + self.assertEqual('UPDATE "abc" SET "foo"=\'bar\' WHERE "foo"=0 RETURNING "abc"."id"', str(q)) + + def test_update_returning_from_different_tables(self): + table_bcd = Table('bcd') + + q = ( + PostgreSQLQuery.update(self.table_abc) + .from_(table_bcd) + .set(self.table_abc.lname, table_bcd.long_name) + .returning(self.table_abc.id, table_bcd.fname) + ) + self.assertEqual( + 'UPDATE "abc" SET "lname"="bcd"."long_name" FROM "bcd" RETURNING "abc"."id","bcd"."fname"', str(q) + ) + + def test_update_returning_star(self): + q = PostgreSQLQuery.update(self.table_abc).where(self.table_abc.foo == 0).set("foo", "bar").returning(Star()) + + self.assertEqual('UPDATE "abc" SET "foo"=\'bar\' WHERE "foo"=0 RETURNING *', str(q)) + + +class SQLLiteUpdateTests(unittest.TestCase): + table_abc = Table("abc") + + def test_update_with_bool(self): + q = SQLLiteQuery.update(self.table_abc).set(self.table_abc.foo, True) + + self.assertEqual('UPDATE "abc" SET "foo"=1', str(q)) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/test_utils.py b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/test_utils.py new file mode 100644 index 0000000000000000000000000000000000000000..bb9a9b1c68fe8671989f7c49f9db90e389d06f59 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pypika/tests/test_utils.py @@ -0,0 +1,24 @@ +import unittest + +from pypika import utils + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + + +class ImmutabilityTests(unittest.TestCase): + def test_raise_attribute_error_for_deepcopy(self): + with self.assertRaises(AttributeError): + utils.raise_attribute_for_copy("Test", "__deepcopy__") + + def test_raise_attribute_error_for_getstate(self): + with self.assertRaises(AttributeError): + utils.raise_attribute_for_copy("Test", "__getstate__") + + def test_raise_attribute_error_for_setstate(self): + with self.assertRaises(AttributeError): + utils.raise_attribute_for_copy("Test", "__setstate__") + + def test_raise_attribute_error_for_getnewargs(self): + with self.assertRaises(AttributeError): + utils.raise_attribute_for_copy("Test", "__getnewargs__") diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pyproject.toml b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pyproject.toml new file mode 100644 index 0000000000000000000000000000000000000000..dcc56baede23e3571b336625e695c466ab833a56 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/pyproject.toml @@ -0,0 +1,22 @@ +[tool.black] +line-length = 120 +skip-string-normalization = true +target-version = ['py38', 'py39', 'py310', 'py311'] +force-exclude = ''' +( + /( + \.eggs # exclude a few common directories in the + | \.git # root of the project + | \.hg + | \.mypy_cache + | \.tox + | \.venv + | _build + | buck-out + | build + | dist + | docs + )/ + | setup.py +) +''' diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/setup.cfg b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/setup.cfg new file mode 100644 index 0000000000000000000000000000000000000000..46084aaf2ca9e95b2f9bb7680e432e637fc3ed90 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/setup.cfg @@ -0,0 +1,16 @@ +[bumpversion] +current_version = 0.48.9 +commit = True +tag = True + +[bumpversion:file:pypika/__init__.py] +search = __version__ = "{current_version}" +replace = __version__ = "{new_version}" + +[bdist_wheel] +universal = 1 + +[flake8] +exclude = docs, .git, __pycache__ +max-line-length = 120 +per-file-ignores = __init__.py:F401 diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/setup.py b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/setup.py new file mode 100644 index 0000000000000000000000000000000000000000..41cce7d742df3e33e8d76f267d77df486f69249a --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/setup.py @@ -0,0 +1,81 @@ +import ast + +from setuptools import setup + + +def readme(): + with open('README.rst', 'rb') as f: + return f.read().decode('UTF-8') + + +def version(): + path = 'pypika/__init__.py' + with open(path, 'r') as file: + t = compile(file.read(), path, 'exec', ast.PyCF_ONLY_AST) + for node in (n for n in t.body if isinstance(n, ast.Assign)): + if len(node.targets) == 1: + name = node.targets[0] + if isinstance(name, ast.Name) and name.id in ('__version__', '__version_info__', 'VERSION'): + v = node.value + if isinstance(v, ast.Str): + return v.s + + if isinstance(v, ast.Tuple): + r = [] + for e in v.elts: + if isinstance(e, ast.Str): + r.append(e.s) + elif isinstance(e, ast.Num): + r.append(str(e.n)) + return '.'.join(r) + + +setup( + # Application name: + name="PyPika", + + # Version number: + version=version(), + + # Application author details: + author="Timothy Heys", + author_email="theys@kayak.com", + + # License + license='Apache License Version 2.0', + + # Packages + packages=["pypika", "pypika.clickhouse"], + + # Include additional files into the package + package_data={"pypika": ["py.typed"]}, + include_package_data=True, + + install_requires=[], + + # Details + url="https://github.com/kayak/pypika", + + description="A SQL query builder API for Python", + long_description=readme(), + + classifiers=[ + 'License :: OSI Approved :: Apache Software License', + 'Development Status :: 5 - Production/Stable', + 'Intended Audience :: Developers', + 'Programming Language :: Python :: 3', + 'Programming Language :: PL/SQL', + 'Topic :: Software Development :: Libraries :: Python Modules', + 'Topic :: Scientific/Engineering :: Information Analysis', + 'Topic :: Scientific/Engineering :: Mathematics', + 'Operating System :: POSIX', + 'Operating System :: MacOS :: MacOS X', + 'Operating System :: Microsoft :: Windows', + ], + keywords=('pypika python query builder querybuilder sql mysql postgres psql oracle vertica aggregated ' + 'relational database rdbms business analytics bi data science analysis pandas ' + 'orm object mapper'), + + # Dependent packages (distributions) + test_suite="pypika.tests", +) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/tox.ini b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/tox.ini new file mode 100644 index 0000000000000000000000000000000000000000..2f0e6893243b1ca2ead6a12825e9014dc66364ce --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/tests/trusted/tox.ini @@ -0,0 +1,16 @@ +[tox] +envlist = py38,py39,py310,py311,pypy3 + +[testenv] +description = testing against {basepython} +deps = -r requirements-dev.txt +commands = + coverage run + coverage xml + +[gh-actions] +python = + 3.8: py38 + 3.9: py39 + 3.10: py310 + 3.11: py311 diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/validation/canaries/first-hunk-only.sh b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/validation/canaries/first-hunk-only.sh new file mode 100644 index 0000000000000000000000000000000000000000..994c84aab6c92da0f68d0f1595e534188e5f7ec9 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/validation/canaries/first-hunk-only.sh @@ -0,0 +1,16 @@ +#!/bin/bash +set -Eeuo pipefail +cd /testbed/repo +cat > /tmp/openenv-reference.diff <<'OPENENV_PARTIAL' +diff --git a/pypika/clickhouse/nullable_arg.py b/pypika/clickhouse/nullable_arg.py +index 14f7b0f07fc2a03b93391dd57a15b28a5b2a7bf7..a3f23fe53af3174a33b002f6965e2d1ca06d2790 100644 +--- a/pypika/clickhouse/nullable_arg.py ++++ b/pypika/clickhouse/nullable_arg.py +@@ -3,4 +3,4 @@ + + class IfNull(Function): + def __init__(self, term, alt, **kwargs): +- super().__init__("ifNull", alt, term, **kwargs) ++ super().__init__("ifNull", term, alt, **kwargs) +OPENENV_PARTIAL +/usr/bin/git -c core.hooksPath=/dev/null -c core.fsmonitor=false apply --whitespace=nowarn /tmp/openenv-reference.diff diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/validation/canaries/original-bug.sh b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/validation/canaries/original-bug.sh new file mode 100644 index 0000000000000000000000000000000000000000..927547df786c86ab3bb5eeb917a31e0fa1895f8b --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/validation/canaries/original-bug.sh @@ -0,0 +1,3 @@ +#!/bin/bash +set -Eeuo pipefail +: diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/validation/openenv.json b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/validation/openenv.json new file mode 100644 index 0000000000000000000000000000000000000000..a13b3c577df494f6c894584d2b608ab051ebc44f --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__smsizxe7/validation/openenv.json @@ -0,0 +1,27 @@ +{ + "canaries": "validation/canaries", + "profile": "harbor-semantic-v1", + "requires_credentials": false, + "resources": { + "cpu": 2, + "disk_mb": 16384, + "episode_timeout_s": 1800, + "memory_mb": 8192 + }, + "reward": { + "floor_margin": 0.1, + "oracle_tolerance": 0, + "range": [ + 0, + 1 + ] + }, + "reward_key": "reward", + "types": { + "tags": [ + "swe", + "python", + "mutation-repair" + ] + } +} diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/LICENSE.source b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/LICENSE.source new file mode 100644 index 0000000000000000000000000000000000000000..9c8f3ea0871e0bfe81da0fa6e7c1d7d156dc380e --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/LICENSE.source @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. \ No newline at end of file diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/adapter.json b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/adapter.json new file mode 100644 index 0000000000000000000000000000000000000000..15f84f49b090bcbe99e9e238072b975b8f026183 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/adapter.json @@ -0,0 +1,135 @@ +{ + "canary_selection": "Fixed first provided gold hunk only when at least2hunks exist; strict subset, never reward-selected. Single-hunk task original-bug canary is explicitly NOP-equivalent and adds no signal beyond floor_gap.", + "collector_sha256": "352e555112f2de8a1393f939903e4971c9ace0e944843762b707a725c5c72481", + "dependency_installation_pinned": false, + "dependency_setup_sha256": "ed8673d02878e91c7ae0b51b9178d6a15792b79c6992f800c14a941d95242392", + "gold_patch_sha256": "fd416c28266c45bd2df8b69dea41a0e26b93138ff9a7ff02204ea62f0e7289a1", + "hostile_code_isolation_established": false, + "known_wrong_semantic_implementations": 0, + "native_inventory_sha256": "3b57604704ed7303373f5853129d43aa315860efaebfaf0769bd58cb0a307228", + "new_files_deletions_and_executable_modes_supported": true, + "official_profile": { + "eval_sets": [], + "profile_class": "Pypika1c9646f0", + "profile_lines": [ + 736, + 739 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "upstream_repo": "kayak/pypika" + }, + "original_bug_canary_nop_equivalent": true, + "original_bug_runtime_wrongness_established": false, + "partial_repair_canary": true, + "partial_repair_sha256": "a630ca9d3b19d3a447e3e595a9d1cc54f0292823ee129d17ca712b0476ce3c45", + "partial_repair_wrongness_established": false, + "positive_approval_policy": "All original strict presence/identity/no-skip/no-error/exit checks retained", + "private_checker_sha256": "f0a641064b725415e23a0221bb53c90446d7efcb7f9ece5ede93a220d18dd9e7", + "private_checker_version": "matched-failure-precedence-v2", + "provided_original_bug_control": true, + "repo_url": "https://github.com/swesmith/kayak__pypika.1c9646f0.git", + "runtime_image": null, + "runtime_ready": false, + "runtime_recipe": { + "dependency_installation_pinned": false, + "official_install_cmds": [ + "python -m pip install -e ." + ], + "official_pytest_argv": [ + "pytest", + "--disable-warnings", + "--color=no", + "--tb=no", + "--verbose" + ], + "official_test_command": "source /opt/miniconda3/bin/activate; conda activate testbed; pytest --disable-warnings --color=no --tb=no --verbose", + "operator_test_runner_prerequisites": [ + "python -m pip install pytest==8.4.2" + ], + "operator_test_runner_reason": "The official profile invokes pytest, but the common tools runtime does not provide it; pinned separately from source-native project requirements.", + "panel_normalization": "Override project addopts only to execute the exact frozen native panels; add JUnit output, preserve official pytest options and all selectors.", + "python_version": "3.10", + "source_bound_test_dependency_cmds": [ + "python -m pip install parameterized==0.7.0" + ], + "test_dependency_source_sha256": { + "requirements-dev.txt": "10f4ba7b19a73950d28fd7403d7e1d1b1fe2ccc4f49516974f47199d2965f23d", + "setup.py": "f8bad274588a22e65764d8cf9fb2be5aa6fcfaf3bf861d71e5f751105898845a", + "tox.ini": "c2d7205d0ac93e9c9e80dc5d24f0a826a6781f587a33ea722ea621f9e2ccd0ea" + } + }, + "runtime_resource_review_required": false, + "schema": "python-git-patch-jobs-v1", + "source_base_commit": "d6c429eb6fad4a78ea7b28c24e19863ee2834f00", + "source_completion_sha256": "49863b83e0bf2f0eecc68d6c3cf78a5d6a303d58c8ba4dd4cb6dad8af227096c", + "source_index_sha256": "e856874b9410fce9f3bfea52c8c482e84b3e43942d87517f8b55f0034bd40f6f", + "source_pr_url": null, + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:kayak__pypika.1c9646f0.combine_module__yfbs6ldj", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "6a742f12bfa386994289ec8b75824663d8ee4b15", + "instruction_sha256": "ee48b33698ac88a8b8ef72014784a2e58e2be900aa3bd8ab274d40e03b6c0992", + "is_fork": true, + "learner_path": "tasks/1299b10ca38f6ce9cd431dfe/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "actual_upstream_url": "https://raw.githubusercontent.com/kayak/pypika/1c9646f0a019a167c32b649b6f5e6423c5ba2c9b/LICENSE.txt", + "reviewed": true, + "sha256": "c5accbbd8546e94c34aed24afe689a617627d18eed5a6c48277e48db57c23851", + "spdx": "Apache-2.0", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/kayak__pypika.1c9646f0/d6c429eb6fad4a78ea7b28c24e19863ee2834f00/LICENSE.txt" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "patch_sha256": "5b84b5d5723dae46b58193195732fccd44e4f7b88337c1b822cd9ed75570c17b", + "provenance_path": "tasks/1299b10ca38f6ce9cd431dfe/source-proof.json", + "repository_lineage": [ + "swesmith/kayak__pypika.1c9646f0", + "kayak/pypika" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "d6c429eb6fad4a78ea7b28c24e19863ee2834f00", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "4c3729566e8712e6639bc381f437a5900c1a1058", + "source_kind": "mutation", + "source_repo": "swesmith/kayak__pypika.1c9646f0", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "kayak__pypika.1c9646f0.combine_module__yfbs6ldj", + "task_sha256": "81541f034def031a66bd22b0bb523dec823d1d088105b88157f4fd6a702e9db0", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "kayak/pypika", + "usage": "quarantine_only" + }, + "source_repo": "swesmith/kayak__pypika.1c9646f0", + "symlink_submodule_changes_supported": false, + "task_id": "kayak__pypika.1c9646f0.combine_module__yfbs6ldj", + "transfer": "index-independent-worktree-to-Git-binary-patch", + "transfer_path": "/testbed/submission.patch", + "upstream_repo": "kayak/pypika" +} diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/dependency-setup.sh b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/dependency-setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e1a28db070ebf088cec3ef817cf2dc8715091ac2 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/dependency-setup.sh @@ -0,0 +1,9 @@ +#!/bin/bash +set -Eeuo pipefail +source /opt/miniconda3/bin/activate +conda activate testbed +cd /testbed/repo +python -c 'import sys; assert sys.version_info[:2] == (3, 10)' +python -m pip install pytest==8.4.2 +python -m pip install -e . +python -m pip install parameterized==0.7.0 diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/environment/Dockerfile b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..a59b58c2ea8217c78c1e39b4678f93c8c0023bcd --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/environment/Dockerfile @@ -0,0 +1,3 @@ +# Runtime is selected only by an independently qualified immutable amd64 receipt. +FROM ubuntu:22.04 +RUN false diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/instruction.md b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..3e8451285faaabcfc1a2fe65d24d9db1d77863f1 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/instruction.md @@ -0,0 +1,40 @@ +ClickHouse functions generating incorrect SQL output + +#### Description + +Several ClickHouse-specific functions are producing incorrect SQL output. The `If` function is generating `switch` instead of `if`, `MultiMatchAny` is producing `multiMatchAll` instead of `multiMatchAny`, and `ToFixedString` has multiple issues with parameter handling and function naming. + +#### Steps/Code to Reproduce + +```python +from pypika.clickhouse import If, MultiMatchAny, ToFixedString +from pypika import Field + +# If function issue +condition = Field('status') == 'active' +result = If(condition, 'yes', 'no') +print(result.get_sql()) +# Expected: if(status='active','yes','no') +# Actual: switch('no','yes',status='active') + +# MultiMatchAny function issue +field = Field('text') +patterns = ['pattern1', 'pattern2'] +match_result = MultiMatchAny(field, patterns) +print(match_result.get_sql()) +# Expected: multiMatchAny(text,['pattern1','pattern2']) +# Actual: multiMatchAll(text,['pattern1','pattern2']) + +# ToFixedString function issue +field = Field('name') +fixed_str = ToFixedString(field, 10) +print(fixed_str.get_sql()) +# Expected: toFixedString(name,10) +# Actual: toFixedStr(10,11) with swapped parameters +``` + +The functions are not generating the correct ClickHouse SQL syntax, which would cause queries to fail when executed against a ClickHouse database. + +## Environment + +The repository is at `/testbed/repo`. Its dependencies, including pytest, are installed in the `testbed` conda environment, which comes first on PATH. If `python -m pytest` reports that pytest is missing, use the full interpreter path: `/opt/miniconda3/envs/testbed/bin/python -m pytest `. Don't install packages: the tests need nothing else, and the sandbox may have no network access. diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/metadata.json b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/metadata.json new file mode 100644 index 0000000000000000000000000000000000000000..7a1e8b35b5ee2cf6eb2fb4d40e6e3f5c2db30d71 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/metadata.json @@ -0,0 +1,1277 @@ +{ + "all_runtime_and_training_flags": false, + "official_profile": { + "eval_sets": [], + "profile_class": "Pypika1c9646f0", + "profile_lines": [ + 736, + 739 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "upstream_repo": "kayak/pypika" + }, + "source_healthy_reference_proof": { + "FAIL_TO_PASS": [ + "pypika/tests/clickhouse/test_array.py::TestArray::test_get_sql_3__toFixedString_mogwai_10_toFixedString_mono_10_toFixedString_bonobo_10_arr", + "pypika/tests/clickhouse/test_array.py::TestHasAny::test_get_sql_2_hasAny_bands_toFixedString_port_royal_20_toFixedString_hammock_20_", + "pypika/tests/clickhouse/test_condition.py::TestIfCondition::test_get_sql_0", + "pypika/tests/clickhouse/test_condition.py::TestIfCondition::test_get_sql_1", + "pypika/tests/clickhouse/test_condition.py::TestMultiIfCondition::test_get_sql_0", + "pypika/tests/clickhouse/test_condition.py::TestMultiIfCondition::test_get_sql_1", + "pypika/tests/clickhouse/test_nullable_arg.py::TestSearchString::test_get_sql_1", + "pypika/tests/clickhouse/test_search_string.py::TestMultiSearch::test_multi_search_string_1", + "pypika/tests/clickhouse/test_type_conversion.py::TestToFixedString::test_get_sql_with_table" + ], + "PASS_TO_PASS": [ + "pypika/tests/clickhouse/test_array.py::TestArray::test_get_sql_0__ridley_scott_jimi_hendrix_", + "pypika/tests/clickhouse/test_array.py::TestArray::test_get_sql_1__1_2_3_4_", + "pypika/tests/clickhouse/test_array.py::TestArray::test_get_sql_2__toInt64_1_toInt64_2_toInt64_3_toInt64_4_", + "pypika/tests/clickhouse/test_array.py::TestHasAny::test_get_sql_0_hasAny_mental_abilities_physical_abilities_", + "pypika/tests/clickhouse/test_array.py::TestHasAny::test_get_sql_1_hasAny_1_2_3_4_3_", + "pypika/tests/clickhouse/test_array.py::TestLength::test_get_sql_0_length_tags_", + "pypika/tests/clickhouse/test_array.py::TestLength::test_get_sql_1_length_1_2_3_", + "pypika/tests/clickhouse/test_array.py::TestEmpty::test_get_sql_0_empty_tags_", + "pypika/tests/clickhouse/test_array.py::TestEmpty::test_get_sql_1_empty_1_2_3_", + "pypika/tests/clickhouse/test_array.py::TestNotEmpty::test_get_sql_0_notEmpty_tags_", + "pypika/tests/clickhouse/test_array.py::TestNotEmpty::test_get_sql_1_notEmpty_1_2_3_", + "pypika/tests/clickhouse/test_dates_and_times.py::TestFormatDateTime::test_get_sql_0", + "pypika/tests/clickhouse/test_dates_and_times.py::TestFormatDateTime::test_get_sql_1", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_00", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_01", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_02", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_03", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_04", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_05", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_06", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_07", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_08", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_09", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_10", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_11", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_12", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_13", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_14", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_15", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_16", + "pypika/tests/clickhouse/test_dates_and_times.py::TestToYYYYMM::test_get_sql", + "pypika/tests/clickhouse/test_nullable_arg.py::TestSearchString::test_get_sql_0", + "pypika/tests/clickhouse/test_search_string.py::TestSearchString::test_search_string_0", + "pypika/tests/clickhouse/test_search_string.py::TestSearchString::test_search_string_1", + "pypika/tests/clickhouse/test_search_string.py::TestSearchString::test_search_string_2", + "pypika/tests/clickhouse/test_search_string.py::TestMultiSearch::test_multi_search_string_0", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_00_toString_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_01_toInt8_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_02_toInt16_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_03_toInt32_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_04_toInt64_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_05_toUInt8_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_06_toUInt16_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_07_toUInt32_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_08_toUInt64_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_09_toFloat32_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_10_toFloat64_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_11_toFloat64_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_12_toDate_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_13_toDateTime_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_14_toFixedString_field_name_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_00_toString_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_01_toInt8_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_02_toInt16_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_03_toInt32_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_04_toInt64_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_05_toUInt8_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_06_toUInt16_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_07_toUInt32_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_08_toUInt64_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_09_toFloat32_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_10_toFloat64_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_11_toFloat64_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_12_toDate_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_13_toDateTime_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_14_toFixedString_100_100_", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseQueryTests::test_use_AS_keyword_for_alias", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseQueryTests::test_use_FINAL_keyword", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseQueryTests::test_use_SAMPLE_keyword", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseQueryTests::test_use_SAMPLE_with_offset_keyword", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDeleteTests::test_omit_where", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDeleteTests::test_omit_where__table_schema", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDeleteTests::test_where_field_equals", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseUpdateTests::test_update", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDropQuery::test_drop_database", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDropQuery::test_drop_dictionary", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDropQuery::test_drop_other", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDropQuery::test_drop_table", + "pypika/tests/dialects/test_clickhouse.py::DistinctOnTests::test_distinct_on", + "pypika/tests/dialects/test_clickhouse.py::LimitByTests::test_limit_by", + "pypika/tests/dialects/test_clickhouse.py::LimitByTests::test_limit_offset0_by", + "pypika/tests/dialects/test_clickhouse.py::LimitByTests::test_limit_offset_by", + "pypika/tests/dialects/test_clickhouse.py::LimitByTests::test_rename_table", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_distinct_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_groupby_alias_False_does_not_group_by_alias_when_subqueries_are_present", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_groupby_alias_False_does_not_group_by_alias_with_standard_query", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_limit", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_limit_with_offset", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_normal_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_offset", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_distinct_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_percent_invalid_range", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_percent_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_select_non_int", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_with_ties_select", + "pypika/tests/dialects/test_mysql.py::SelectTests::test_distinct_select", + "pypika/tests/dialects/test_mysql.py::SelectTests::test_modifier_select", + "pypika/tests/dialects/test_mysql.py::SelectTests::test_multiple_modifier_select", + "pypika/tests/dialects/test_mysql.py::SelectTests::test_normal_select", + "pypika/tests/dialects/test_mysql.py::UpdateTests::test_conflict_handlers_update", + "pypika/tests/dialects/test_mysql.py::UpdateTests::test_on_duplicate_key_ignore_update", + "pypika/tests/dialects/test_mysql.py::UpdateTests::test_on_duplicate_key_update_update", + "pypika/tests/dialects/test_mysql.py::UpdateTests::test_update", + "pypika/tests/dialects/test_mysql.py::LoadCSVTests::test_load_from_file", + "pypika/tests/dialects/test_mysql.py::TableTests::test_create_table", + "pypika/tests/dialects/test_mysql.py::TableTests::test_drop_table", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_fetch_next_method_deprecated", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_groupby_alias_False_does_not_group_by_alias_when_subqueries_are_present", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_groupby_alias_False_does_not_group_by_alias_with_standard_query", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_limit_offset_query", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_limit_query", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_offset_query", + "pypika/tests/dialects/test_postgresql.py::InsertTests::test_array_keyword", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_alias_set_correctly", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_json_value_from_array_num", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_json_value_from_array_str", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_json_value_from_dict", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_json_value_from_dict_recursive", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_json_value_by_index", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_json_value_by_key", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_path_json_value", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_path_text_value", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_text_value_by_index", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_text_value_by_key", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contained_by_using_list_arg", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contained_by_using_str_arg", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contained_by_with_complex_criterion", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contains_for_field", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contains_for_json", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_has_any_keys", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_has_key", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_has_keys", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_subnet_contains_inet", + "pypika/tests/dialects/test_postgresql.py::DistinctOnTests::test_distinct_on", + "pypika/tests/dialects/test_postgresql.py::ArrayTests::test_array_syntax", + "pypika/tests/dialects/test_postgresql.py::ArrayTests::test_render_alias_in_array_sql", + "pypika/tests/dialects/test_postgresql.py::ReturningClauseTests::test_no_queryexception_if_returning_used_on_valid_query_type", + "pypika/tests/dialects/test_postgresql.py::ReturningClauseTests::test_queryexception_if_returning_used_on_invalid_query", + "pypika/tests/dialects/test_postgresql.py::ReturningClauseTests::test_return_field_from_join_table", + "pypika/tests/dialects/test_postgresql.py::ReturningClauseTests::test_returning_from_missing_table_raises_queryexception", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_dont_use_double_quotes_on_create_queries", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_dont_use_double_quotes_on_drop_queries", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_dont_use_double_quotes_on_joining_queries", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_use_double_quotes_on_alias_but_not_on_terms", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_use_double_quotes_on_alias_but_not_on_terms_with_joins", + "pypika/tests/dialects/test_sqllite.py::SelectTests::test_bool_false_as_zero", + "pypika/tests/dialects/test_sqllite.py::SelectTests::test_bool_true_as_one", + "pypika/tests/dialects/test_sqllite.py::ReplaceTests::test_insert_or_replace", + "pypika/tests/dialects/test_sqllite.py::ReplaceTests::test_normal_replace", + "pypika/tests/dialects/test_sqllite.py::ReplaceTests::test_replace_subquery", + "pypika/tests/dialects/test_vertica.py::VerticaQueryTests::test_delete_query_with_hint", + "pypika/tests/dialects/test_vertica.py::VerticaQueryTests::test_insert_query_with_hint", + "pypika/tests/dialects/test_vertica.py::VerticaQueryTests::test_select_query_with_hint", + "pypika/tests/dialects/test_vertica.py::VerticaQueryTests::test_update_query_with_hint", + "pypika/tests/dialects/test_vertica.py::CopyCSVTests::test_copy_from_file", + "pypika/tests/dialects/test_vertica.py::CreateTemporaryTableTests::test_create_local_table_without_temporary_raises_error", + "pypika/tests/dialects/test_vertica.py::CreateTemporaryTableTests::test_create_local_temporary_table", + "pypika/tests/dialects/test_vertica.py::CreateTemporaryTableTests::test_create_table_preserve_rows_without_temporary_raises_error", + "pypika/tests/dialects/test_vertica.py::CreateTemporaryTableTests::test_create_temporary_table_preserve_rows", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__agg_case_criterion_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__agg_case_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__agg_func_arithmetic_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__agg_func_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__case_mixed_constant_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__case_mixed_else_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__case_with_field_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__case_with_single_aggregate_field_in_one_criterion_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__constant_arithmetic_is_aggregate_none", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__constant_is_aggregate_none", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__field_arithmetic_constant_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__field_arithmetic_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__field_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__func_arithmetic_constant_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__mixed_case_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__mixed_func_arithmetic_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__negative_agg_func_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__non_aggregate_function_with_aggregated_arg", + "pypika/tests/test_aggregate.py::IsAggregateTests::test_complicated", + "pypika/tests/test_analytic_queries.py::RankTests::test_avg", + "pypika/tests/test_analytic_queries.py::RankTests::test_count_range_between_unbounded_preceeding_current_row", + "pypika/tests/test_analytic_queries.py::RankTests::test_dense_rank", + "pypika/tests/test_analytic_queries.py::RankTests::test_empty_over", + "pypika/tests/test_analytic_queries.py::RankTests::test_filter", + "pypika/tests/test_analytic_queries.py::RankTests::test_filter_quote_table_in_filter", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value_ignore_nulls", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value_ignore_nulls_first", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value_multi_argument", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value_range_between_x_preceeding_unbounded_following", + "pypika/tests/test_analytic_queries.py::RankTests::test_lag_generates_correct_sql", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value_ignore_nulls", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value_multi_argument", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value_rows_between_current_row_unbounded_following", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value_rows_between_current_row_unbounded_following_ignore_nulls", + "pypika/tests/test_analytic_queries.py::RankTests::test_lead_generates_correct_sql", + "pypika/tests/test_analytic_queries.py::RankTests::test_max_range_x_preceeding", + "pypika/tests/test_analytic_queries.py::RankTests::test_max_rows_x_preceeding", + "pypika/tests/test_analytic_queries.py::RankTests::test_median", + "pypika/tests/test_analytic_queries.py::RankTests::test_min_range_current_row", + "pypika/tests/test_analytic_queries.py::RankTests::test_min_rows_current_row", + "pypika/tests/test_analytic_queries.py::RankTests::test_multiple_partitions", + "pypika/tests/test_analytic_queries.py::RankTests::test_ntile_no_partition_or_order_invalid_sql", + "pypika/tests/test_analytic_queries.py::RankTests::test_ntile_with_order", + "pypika/tests/test_analytic_queries.py::RankTests::test_ntile_with_partition", + "pypika/tests/test_analytic_queries.py::RankTests::test_ntile_with_partition_and_order", + "pypika/tests/test_analytic_queries.py::RankTests::test_orderby_asc", + "pypika/tests/test_analytic_queries.py::RankTests::test_orderby_desc", + "pypika/tests/test_analytic_queries.py::RankTests::test_range_called_twice_raises_attribute_error", + "pypika/tests/test_analytic_queries.py::RankTests::test_range_then_rows_raises_attribute_error", + "pypika/tests/test_analytic_queries.py::RankTests::test_rank", + "pypika/tests/test_analytic_queries.py::RankTests::test_rank_with_alias", + "pypika/tests/test_analytic_queries.py::RankTests::test_row_number", + "pypika/tests/test_analytic_queries.py::RankTests::test_rows_called_twice_raises_attribute_error", + "pypika/tests/test_analytic_queries.py::RankTests::test_rows_then_range_raises_attribute_error", + "pypika/tests/test_analytic_queries.py::RankTests::test_stddev", + "pypika/tests/test_analytic_queries.py::RankTests::test_stddev_pop", + "pypika/tests/test_analytic_queries.py::RankTests::test_stddev_samp", + "pypika/tests/test_analytic_queries.py::RankTests::test_sum_rows_unbounded_preceeding", + "pypika/tests/test_analytic_queries.py::RankTests::test_table_prefixes_used_in_analytic_functions", + "pypika/tests/test_analytic_queries.py::RankTests::test_var_pop", + "pypika/tests/test_analytic_queries.py::RankTests::test_var_samp", + "pypika/tests/test_analytic_queries.py::RankTests::test_variance", + "pypika/tests/test_analytic_queries.py::RankTests::test_variance_rows_between_unbounded_preceeding_unbounded_following", + "pypika/tests/test_analytic_queries.py::RankTests::test_varpop_range_unbounded_preceeding", + "pypika/tests/test_analytic_queries.py::RankTests::test_varpop_rows_between_unbounded_preceeding_x_following", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_as_select_not_query_raises_error", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_with_columns", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_with_select", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_with_select_and_columns_fails", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_without_columns_or_select_empty", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_if_not_exists", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_simple", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_unique", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_where", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_without_columns_raises_error", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_without_table_raises_error", + "pypika/tests/test_criterions.py::CriterionTests::test__bitwise_and_in_where_clause", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_bitwise_and", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_bitwise_and_with_alias", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_bool", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_decimal", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_str", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gt_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gt_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gt_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gt_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gte_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gte_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gte_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gte_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_is_null", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_is_null_with_alias", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lt_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lt_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lt_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lt_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lte_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lte_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lte_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lte_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_str", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_with_alias", + "pypika/tests/test_criterions.py::NotTests::test_chained_function", + "pypika/tests/test_criterions.py::NotTests::test_is_not_null", + "pypika/tests/test_criterions.py::NotTests::test_negate", + "pypika/tests/test_criterions.py::NotTests::test_not_null", + "pypika/tests/test_criterions.py::NotTests::test_not_null_with_alias", + "pypika/tests/test_criterions.py::NotTests::test_not_with_and_criterion", + "pypika/tests/test_criterions.py::NotTests::test_not_with_complex_criterion", + "pypika/tests/test_criterions.py::NotTests::test_not_with_or_criterion", + "pypika/tests/test_criterions.py::NotTests::test_notnullcriterion_replace_table", + "pypika/tests/test_criterions.py::NotTests::test_variable_access", + "pypika/tests/test_criterions.py::BetweenTests::test__between_date", + "pypika/tests/test_criterions.py::BetweenTests::test__between_datetime", + "pypika/tests/test_criterions.py::BetweenTests::test__between_number", + "pypika/tests/test_criterions.py::BetweenTests::test__between_with_alias", + "pypika/tests/test_criterions.py::BetweenTests::test__function_between", + "pypika/tests/test_criterions.py::BetweenTests::test_get_item_only_works_with_slice", + "pypika/tests/test_criterions.py::IsInTests::test__function_isin", + "pypika/tests/test_criterions.py::IsInTests::test__in_character", + "pypika/tests/test_criterions.py::IsInTests::test__in_date", + "pypika/tests/test_criterions.py::IsInTests::test__in_datetime", + "pypika/tests/test_criterions.py::IsInTests::test__in_number", + "pypika/tests/test_criterions.py::IsInTests::test__in_number_with_alias", + "pypika/tests/test_criterions.py::IsInTests::test__in_unicode", + "pypika/tests/test_criterions.py::ArithmeticExpressionTests::test__lshift", + "pypika/tests/test_criterions.py::ArithmeticExpressionTests::test__rshift", + "pypika/tests/test_criterions.py::NotInTests::test__function_notin", + "pypika/tests/test_criterions.py::NotInTests::test__notin_character", + "pypika/tests/test_criterions.py::NotInTests::test__notin_date", + "pypika/tests/test_criterions.py::NotInTests::test__notin_datetime", + "pypika/tests/test_criterions.py::NotInTests::test__notin_number", + "pypika/tests/test_criterions.py::NotInTests::test__notin_number_with_alias", + "pypika/tests/test_criterions.py::LikeTests::test_glob_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_contains", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_ends_with", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_n_chars_long", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_starts_with", + "pypika/tests/test_criterions.py::LikeTests::test_like_contains", + "pypika/tests/test_criterions.py::LikeTests::test_like_ends_with", + "pypika/tests/test_criterions.py::LikeTests::test_like_n_chars_long", + "pypika/tests/test_criterions.py::LikeTests::test_like_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_like_starts_with", + "pypika/tests/test_criterions.py::LikeTests::test_not_ilike_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_not_like_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_rlike_escape_chars", + "pypika/tests/test_criterions.py::ExistsCriterionTests::test_exists", + "pypika/tests/test_criterions.py::ExistsCriterionTests::test_not_exists", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__between_and_field", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__between_and_isin", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__nested__and", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__nested__mixed", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__nested__or", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_and", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_function_and", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_function_or", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_function_xor", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_or", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_xor", + "pypika/tests/test_criterions.py::FieldsAsCriterionTests::test__field_and_field", + "pypika/tests/test_criterions.py::FieldsAsCriterionTests::test__field_or_field", + "pypika/tests/test_criterions.py::FieldsAsCriterionTests::test__field_xor_field", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_arithmeticfunction_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_betweencriterion_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_complexcriterion_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_criterion_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_field_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_function_with_only_fields_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_function_with_values_and_fields_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_nullcriterion_replace_table", + "pypika/tests/test_criterions.py::AnyTests::test_multiple_args_returned_in_chain_of_ors", + "pypika/tests/test_criterions.py::AnyTests::test_single_arg_returns_self", + "pypika/tests/test_criterions.py::AnyTests::test_with_generator", + "pypika/tests/test_criterions.py::AnyTests::test_zero_args_returns_empty_criterion", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_different_operations_with_empty_criterion", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_empty_criterion_on_the_left", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_empty_criterion_on_the_right", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_fields_", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_invertion_of_the_empty_criterion", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_more_than_one_empty_criterions", + "pypika/tests/test_criterions.py::AllTests::test_multiple_args_returned_in_chain_of_ors", + "pypika/tests/test_criterions.py::AllTests::test_single_arg_returns_self", + "pypika/tests/test_criterions.py::AllTests::test_with_generator", + "pypika/tests/test_criterions.py::AllTests::test_zero_args_returns_empty_criterion", + "pypika/tests/test_custom_functions.py::TestUnitCustomFunction::test_should_fail_with_wrong_arguments", + "pypika/tests/test_custom_functions.py::TestUnitCustomFunction::test_should_return_function_with_arguments", + "pypika/tests/test_custom_functions.py::TestUnitCustomFunction::test_should_return_function_with_no_arguments", + "pypika/tests/test_custom_functions.py::TestFunctionalCustomFunction::test_should_fail_use_custom_function_on_select_with_wrong_arguments", + "pypika/tests/test_custom_functions.py::TestFunctionalCustomFunction::test_should_use_custom_function_on_select", + "pypika/tests/test_data_types.py::StringTests::test_inline_string_concatentation", + "pypika/tests/test_data_types.py::UuidTests::test_uuid_string_generation", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_day", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_default", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_microsecond", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_minute", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_month", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_quarter", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_second", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_week", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_year", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_day_hour", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_day_microsecond", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_day_minute", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_day_second", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_hour_microsecond", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_hour_minute", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_hour_second", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_minute_microsecond", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_minute_second", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_second_microsecond", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_value_complex_expressions", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_value_right", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_year_month", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_mysql_dialect_uses_single_quotes_around_expression_in_an_interval", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_oracle_dialect_uses_single_quotes_around_expression_in_an_interval", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_postgresql_dialect_uses_single_quotes_around_interval", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_redshift_dialect_uses_single_quotes_around_interval", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_vertica_dialect_uses_single_quotes_around_interval", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_day", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_month", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_week", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_year", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_year_month", + "pypika/tests/test_date_math.py::TruncateTrailingZerosTests::test_do_not_truncate_integer_values", + "pypika/tests/test_date_math.py::TruncateTrailingZerosTests::test_do_not_truncate_months_between_years_and_datys", + "pypika/tests/test_deletes.py::DeleteTests::test_for_portion", + "pypika/tests/test_deletes.py::DeleteTests::test_omit_where", + "pypika/tests/test_deletes.py::DeleteTests::test_omit_where__table_schema", + "pypika/tests/test_deletes.py::DeleteTests::test_where_field_equals", + "pypika/tests/test_deletes.py::PostgresDeleteTests::test_delete_returning", + "pypika/tests/test_deletes.py::PostgresDeleteTests::test_delete_returning_star", + "pypika/tests/test_deletes.py::PostgresDeleteTests::test_delete_returning_str", + "pypika/tests/test_deletes.py::PostgresDeleteTests::test_delete_using", + "pypika/tests/test_drop.py::DropTableTests::test_drop_database", + "pypika/tests/test_drop.py::DropTableTests::test_drop_index", + "pypika/tests/test_drop.py::DropTableTests::test_drop_table", + "pypika/tests/test_drop.py::DropTableTests::test_drop_user", + "pypika/tests/test_drop.py::DropTableTests::test_drop_view", + "pypika/tests/test_formats.py::QuoteTests::test_no_quote_char_in_complex_query", + "pypika/tests/test_formats.py::QuoteTests::test_replace_quote_char_in_complex_query", + "pypika/tests/test_functions.py::FunctionTests::test_dialect_propagation", + "pypika/tests/test_functions.py::FunctionTests::test_is_aggregate_None_for_non_aggregate_function_or_function_with_no_aggregate_functions", + "pypika/tests/test_functions.py::FunctionTests::test_is_aggregate_True_for_aggregate_function_or_function_with_aggregate_functions", + "pypika/tests/test_functions.py::SchemaTests::test_schema_included_in_function_sql", + "pypika/tests/test_functions.py::SchemaTests::test_schema_no_schema_in_sql_when_none_set", + "pypika/tests/test_functions.py::ArithmeticTests::test__addition__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__addition__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__addition__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__addition__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__arithmetic_equality", + "pypika/tests/test_functions.py::ArithmeticTests::test__arithmetic_with_function", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_add_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_div_no_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_div_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_exponent_no_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_exponent_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_floor_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_function_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_modulus_no_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_modulus_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_mul_no_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_mul_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_nested_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_sub_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__division__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__division__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__division__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__division__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__exponent__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__exponent__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__floor", + "pypika/tests/test_functions.py::ArithmeticTests::test__leftshift__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__leftshift__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__leftshift__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__modulus__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__multiplication__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__multiplication__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__multiplication__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__multiplication__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__rightshift__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__rightshift__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__rightshift__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__subtraction__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__subtraction__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__subtraction__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__subtraction__right", + "pypika/tests/test_functions.py::AggregationTests::test__approx_percentile", + "pypika/tests/test_functions.py::AggregationTests::test__avg", + "pypika/tests/test_functions.py::AggregationTests::test__count", + "pypika/tests/test_functions.py::AggregationTests::test__count__star", + "pypika/tests/test_functions.py::AggregationTests::test__first", + "pypika/tests/test_functions.py::AggregationTests::test__last", + "pypika/tests/test_functions.py::AggregationTests::test__max", + "pypika/tests/test_functions.py::AggregationTests::test__min", + "pypika/tests/test_functions.py::AggregationTests::test__std", + "pypika/tests/test_functions.py::AggregationTests::test__stddev", + "pypika/tests/test_functions.py::AggregationTests::test__subquery_in_params_functions", + "pypika/tests/test_functions.py::AggregationTests::test__sum", + "pypika/tests/test_functions.py::ConditionTests::test__case__else", + "pypika/tests/test_functions.py::ConditionTests::test__case__field", + "pypika/tests/test_functions.py::ConditionTests::test__case__multi", + "pypika/tests/test_functions.py::ConditionTests::test__case__no_cases", + "pypika/tests/test_functions.py::ConditionTests::test__case__raw", + "pypika/tests/test_functions.py::StringTests::test__ascii__field", + "pypika/tests/test_functions.py::StringTests::test__ascii__int", + "pypika/tests/test_functions.py::StringTests::test__ascii__str", + "pypika/tests/test_functions.py::StringTests::test__bin__field", + "pypika/tests/test_functions.py::StringTests::test__bin__int", + "pypika/tests/test_functions.py::StringTests::test__bin__str", + "pypika/tests/test_functions.py::StringTests::test__concat__field", + "pypika/tests/test_functions.py::StringTests::test__concat__str", + "pypika/tests/test_functions.py::StringTests::test__insert__field", + "pypika/tests/test_functions.py::StringTests::test__insert__str", + "pypika/tests/test_functions.py::StringTests::test__length__field", + "pypika/tests/test_functions.py::StringTests::test__length__str", + "pypika/tests/test_functions.py::StringTests::test__lower__field", + "pypika/tests/test_functions.py::StringTests::test__lower__str", + "pypika/tests/test_functions.py::StringTests::test__replace__field", + "pypika/tests/test_functions.py::StringTests::test__replace__str", + "pypika/tests/test_functions.py::StringTests::test__substring", + "pypika/tests/test_functions.py::SplitPartFunctionTests::test__split_part", + "pypika/tests/test_functions.py::RegexpLikeFunctionTests::test__regexp_like", + "pypika/tests/test_functions.py::CastTests::test__cast__as", + "pypika/tests/test_functions.py::CastTests::test__cast__binary", + "pypika/tests/test_functions.py::CastTests::test__cast__binary_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__boolean", + "pypika/tests/test_functions.py::CastTests::test__cast__char", + "pypika/tests/test_functions.py::CastTests::test__cast__char_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__date", + "pypika/tests/test_functions.py::CastTests::test__cast__float", + "pypika/tests/test_functions.py::CastTests::test__cast__integer", + "pypika/tests/test_functions.py::CastTests::test__cast__long_varbinary", + "pypika/tests/test_functions.py::CastTests::test__cast__long_varbinary_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__long_varchar", + "pypika/tests/test_functions.py::CastTests::test__cast__long_varchar_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__numeric", + "pypika/tests/test_functions.py::CastTests::test__cast__signed", + "pypika/tests/test_functions.py::CastTests::test__cast__timestamp", + "pypika/tests/test_functions.py::CastTests::test__cast__unsigned", + "pypika/tests/test_functions.py::CastTests::test__cast__varbinary", + "pypika/tests/test_functions.py::CastTests::test__cast__varbinary_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__varchar", + "pypika/tests/test_functions.py::CastTests::test__cast__varchar_with_arg", + "pypika/tests/test_functions.py::CastTests::test__tochar__", + "pypika/tests/test_functions.py::DateFunctionsTests::test_current_date", + "pypika/tests/test_functions.py::DateFunctionsTests::test_current_time", + "pypika/tests/test_functions.py::DateFunctionsTests::test_current_timestamp", + "pypika/tests/test_functions.py::DateFunctionsTests::test_current_timestamp_with_alias", + "pypika/tests/test_functions.py::DateFunctionsTests::test_date_add", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_day", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_hour", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_join", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_microsecond", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_minute", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_month", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_quarter", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_second", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_week", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_year", + "pypika/tests/test_functions.py::DateFunctionsTests::test_now", + "pypika/tests/test_functions.py::DateFunctionsTests::test_time_diff", + "pypika/tests/test_functions.py::DateFunctionsTests::test_timestampadd", + "pypika/tests/test_functions.py::DateFunctionsTests::test_to_date", + "pypika/tests/test_functions.py::DateFunctionsTests::test_utc_timestamp", + "pypika/tests/test_functions.py::NullFunctionsTests::test_coalesce", + "pypika/tests/test_functions.py::NullFunctionsTests::test_isnull", + "pypika/tests/test_functions.py::NullFunctionsTests::test_nullif", + "pypika/tests/test_functions.py::NullFunctionsTests::test_nvl", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_mysql_one_groupby", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_mysql_rollup_two_groupbys", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_no_rollup_after_rollup_mysql", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_no_rollup_before_groupby", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_from_groupbys", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_from_parameters", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_from_two_groupbys", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_func_one_groupby", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_func_partial", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_func_two_groupbys", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_multiple_rollups", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_rollups_with_multiple_rollups_and_parity", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_rollups_with_parity", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_force_index_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_groupby_returns_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_immutable_kwarg_on_query_builder_disables_immutability", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_insert_into_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_join_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_orderby_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_queries_after_join", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_replace_into_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_select_returns_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_update_set_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_use_index_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_with_return_new_query_instance", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_multi_rows", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_multi_rows_chained", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_multi_rows_chained_mixed", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_multi_rows_chained_multiple_rows", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_single_element", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_column_using_alias_with_chain", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_column_using_table_alias", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_empty_columns", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_empty_columns_type_list", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_empty_columns_type_tuple", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_ignore", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_multiple_rows_with_array_value", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_none_skipped", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_null", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_one_column", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_one_column_multi_element_array", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_one_column_single_element_array", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_selected_columns", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_selected_columns_type_list", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_selected_columns_type_tuple", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_single_row_with_array_value", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_with_statement", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_empty_on_conflict_do_update_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_field", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_field_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_mixed_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_multiple_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_multiple_fields_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_field", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_field_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_multiple_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_multiple_fields_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_multiple_mixed_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_no_handler", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_two_handlers_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_two_handlers_do_update", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_fieldless_conflict_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_fieldless_conflict_do_update_field", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_non_insert_on_conflict_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_non_insert_on_conflict_do_update", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_do_nothing_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_do_update_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_do_update_with_excluded_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_from_subquery", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_complex", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_conflict_fields_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_conflict_fields_do_update", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_empty_conflict_fields_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_empty_conflict_fields_do_update", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_where_and_on_conflict_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_all_columns_multi_rows_chained_returning_star", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_all_columns_multi_rows_chained_returning_star_and_id", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_all_columns_multi_rows_chained_returning_star_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_all_columns_single_element_arrays", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_aggregate", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_all_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_all_fields_and_arithmetics", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_arithmetics", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_from_other_table", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_functions", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_null", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_one_field", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_one_field_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_tuple", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_ignore", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multi_rows_chained_mixed_on_duplicate_update_multiple", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_multiple", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_different_value", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_expression", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_expression_using_original_field_value", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_expression_using_values", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_same_value", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_none_skipped", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_one_column", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_one_column_multi_element_array", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_one_column_single_element_array", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_one_column_using_values", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_selected_columns_on_duplicate_update_multiple", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_selected_columns_on_duplicate_update_one", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_columns_from_columns", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_columns_from_columns_with_join", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_columns_from_star", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_from_columns", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_ignore_star", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_star", + "pypika/tests/test_inserts.py::InsertSubqueryTests::test_insert_subquery_wrapped_in_brackets", + "pypika/tests/test_inserts.py::SelectIntoTests::test_select_columns_into", + "pypika/tests/test_inserts.py::SelectIntoTests::test_select_columns_into_with_join", + "pypika/tests/test_inserts.py::SelectIntoTests::test_select_star_into", + "pypika/tests/test_inserts.py::ReplaceTests::test_replace_simple", + "pypika/tests/test_inserts.py::ReplaceTests::test_replace_subquery", + "pypika/tests/test_internals.py::TablesTests::test__case_tables", + "pypika/tests/test_internals.py::TablesTests::test__criterion_replace_table_with_value", + "pypika/tests/test_internals.py::TablesTests::test__star_tables", + "pypika/tests/test_internals.py::TablesTests::test__table_star_tables", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_cross_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_cross_join_on_subquery", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_cross_join_on_table", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_default_join_type", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_full_outer_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_hash_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_inner_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_arithmetic_field", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_collate", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_complex_criteria", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_field_multi", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_field_multi_with_extra_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_field_single", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_field_without_fields_raises_exception", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_subquery_criteria", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_second_table_in_from_clause", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_using_multiple_fields", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_using_string_field_name", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_using_with_quote_char", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_using_without_fields_raises_exception", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_with_arithmetic_function_in_select", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_left_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_left_outer_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_outer_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_right_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_right_outer_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_temporal_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_use_different_table_objects_for_same_table", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_fail_when_joining_unknown_type", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_ignore_table_references", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_immutable__tables", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_from_join", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_query_with_column_alias", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_query_with_setoperation", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_query_with_table_alias", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_query_without_alias", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_same_table", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_same_table_with_prefixes", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_table_twice", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_prefixes_added_to_function_in_orderby", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_prefixes_added_to_groupby", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_prefixes_added_to_orderby", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_require_condition", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_require_condition_with_both_tables", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select__fields_after_table_star", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select__ordered_select_clauses", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select__star_for_table", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select__star_for_table__replacement", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select_field_from_missing_table", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select_fields_with_where", + "pypika/tests/test_joins.py::UnionTests::test_mysql_query_wraps_unioned_queries", + "pypika/tests/test_joins.py::UnionTests::test_require_equal_number_of_fields", + "pypika/tests/test_joins.py::UnionTests::test_union", + "pypika/tests/test_joins.py::UnionTests::test_union_all", + "pypika/tests/test_joins.py::UnionTests::test_union_all_multiple", + "pypika/tests/test_joins.py::UnionTests::test_union_as_subquery", + "pypika/tests/test_joins.py::UnionTests::test_union_multiple", + "pypika/tests/test_joins.py::UnionTests::test_union_with_no_quote_char", + "pypika/tests/test_joins.py::UnionTests::test_union_with_order_by", + "pypika/tests/test_joins.py::UnionTests::test_union_with_order_by_use_union_query_field", + "pypika/tests/test_joins.py::UnionTests::test_union_with_order_by_use_union_query_field_with_aliases", + "pypika/tests/test_joins.py::UnionTests::test_union_with_order_by_with_aliases", + "pypika/tests/test_joins.py::InsertQueryJoinTests::test_join_table_on_insert_query", + "pypika/tests/test_joins.py::UpdateQueryJoinTests::test_join_table_on_update_query", + "pypika/tests/test_joins.py::IntersectTests::test_intersect", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_as_subquery", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_multiple", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_with_limit", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_with_no_quote_char", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_with_offset", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_with_order_by", + "pypika/tests/test_joins.py::IntersectTests::test_mysql_query_wraps_intersected_queries", + "pypika/tests/test_joins.py::IntersectTests::test_require_equal_number_of_fields_intersect", + "pypika/tests/test_joins.py::MinusTests::test_minus", + "pypika/tests/test_joins.py::MinusTests::test_minus_as_subquery", + "pypika/tests/test_joins.py::MinusTests::test_minus_multiple", + "pypika/tests/test_joins.py::MinusTests::test_minus_query_with_order_by_use_minus_query_field", + "pypika/tests/test_joins.py::MinusTests::test_minus_with_no_quote_char", + "pypika/tests/test_joins.py::MinusTests::test_minus_with_order_by", + "pypika/tests/test_joins.py::MinusTests::test_mysql_query_wraps_minus_queries", + "pypika/tests/test_joins.py::MinusTests::test_require_equal_number_of_fields", + "pypika/tests/test_joins.py::ExceptOfTests::test_except", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_as_subquery", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_multiple", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_query_with_order_by_use_minus_query_field", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_with_no_quote_char", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_with_order_by", + "pypika/tests/test_joins.py::ExceptOfTests::test_require_equal_number_of_fields_except_of", + "pypika/tests/test_negation.py::NegationTests::test_negate_field", + "pypika/tests/test_negation.py::NegationTests::test_negate_function", + "pypika/tests/test_negation.py::NegationTests::test_negate_wrapped_float", + "pypika/tests/test_negation.py::NegationTests::test_negate_wrapped_int", + "pypika/tests/test_parameter.py::ParametrizedTests::test_format_parameter", + "pypika/tests/test_parameter.py::ParametrizedTests::test_join", + "pypika/tests/test_parameter.py::ParametrizedTests::test_named_parameter", + "pypika/tests/test_parameter.py::ParametrizedTests::test_numeric_parameter", + "pypika/tests/test_parameter.py::ParametrizedTests::test_param_insert", + "pypika/tests/test_parameter.py::ParametrizedTests::test_param_select_join", + "pypika/tests/test_parameter.py::ParametrizedTests::test_param_select_subquery", + "pypika/tests/test_parameter.py::ParametrizedTests::test_pyformat_parameter", + "pypika/tests/test_parameter.py::ParametrizedTests::test_qmark_parameter", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_join", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_join_with_parameter_value_wrapper", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_param_insert", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_param_select_join", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_param_select_subquery", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_pyformat_parameter", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_can_be_used_in_a_select_statement", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_can_be_used_in_a_where_clause", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_can_be_used_in_orderby", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_column_value", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_object_id", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_object_value", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_row_id", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_row_num", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_sys_date", + "pypika/tests/test_query.py::QueryTablesTests::test_is_joined", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_case_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_delete_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_filter_tables", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_having_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_insert_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_insert_table_current_table_not_match", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_join_tables", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_only_specified_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_orderby_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_tuple_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_update_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_update_table_current_table_not_match", + "pypika/tests/test_query.py::QueryBuilderTests::test_pipe", + "pypika/tests/test_query.py::QueryBuilderTests::test_query_builders_have_reference_to_correct_query_class", + "pypika/tests/test_selects.py::SelectTests::test_empty_query", + "pypika/tests/test_selects.py::SelectTests::test_mssql_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_mysql_query_uses_backtick_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_oracle_query_uses_no_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_postgresql_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_redshift_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_select__column__single__alias__str", + "pypika/tests/test_selects.py::SelectTests::test_select__column__single__field", + "pypika/tests/test_selects.py::SelectTests::test_select__column__single__str", + "pypika/tests/test_selects.py::SelectTests::test_select__column__single__table_alias__str", + "pypika/tests/test_selects.py::SelectTests::test_select__columns__multi__field", + "pypika/tests/test_selects.py::SelectTests::test_select__columns__multi__str", + "pypika/tests/test_selects.py::SelectTests::test_select__distinct__multi", + "pypika/tests/test_selects.py::SelectTests::test_select__distinct__single", + "pypika/tests/test_selects.py::SelectTests::test_select__multiple_subqueries", + "pypika/tests/test_selects.py::SelectTests::test_select__multiple_tables", + "pypika/tests/test_selects.py::SelectTests::test_select__nested_subquery", + "pypika/tests/test_selects.py::SelectTests::test_select__no_table", + "pypika/tests/test_selects.py::SelectTests::test_select__star", + "pypika/tests/test_selects.py::SelectTests::test_select__star__replacement", + "pypika/tests/test_selects.py::SelectTests::test_select__subquery", + "pypika/tests/test_selects.py::SelectTests::test_select__table_schema", + "pypika/tests/test_selects.py::SelectTests::test_select__table_schema_with_multiple_levels_as_list", + "pypika/tests/test_selects.py::SelectTests::test_select__table_schema_with_multiple_levels_as_tuple", + "pypika/tests/test_selects.py::SelectTests::test_select_no_from", + "pypika/tests/test_selects.py::SelectTests::test_select_no_from_with_field_raises_exception", + "pypika/tests/test_selects.py::SelectTests::test_select_no_with_alias_from", + "pypika/tests/test_selects.py::SelectTests::test_select_then_add_table", + "pypika/tests/test_selects.py::SelectTests::test_select_with_force_index", + "pypika/tests/test_selects.py::SelectTests::test_select_with_force_index_multiple_calls", + "pypika/tests/test_selects.py::SelectTests::test_select_with_force_index_multiple_indexes", + "pypika/tests/test_selects.py::SelectTests::test_select_with_force_index_with_index_object", + "pypika/tests/test_selects.py::SelectTests::test_select_with_limit", + "pypika/tests/test_selects.py::SelectTests::test_select_with_limit__func", + "pypika/tests/test_selects.py::SelectTests::test_select_with_limit_and_offset", + "pypika/tests/test_selects.py::SelectTests::test_select_with_limit_zero", + "pypika/tests/test_selects.py::SelectTests::test_select_with_offset", + "pypika/tests/test_selects.py::SelectTests::test_select_with_offset__func", + "pypika/tests/test_selects.py::SelectTests::test_select_with_use_index", + "pypika/tests/test_selects.py::SelectTests::test_select_with_use_index_multiple_calls", + "pypika/tests/test_selects.py::SelectTests::test_select_with_use_index_multiple_indexes", + "pypika/tests/test_selects.py::SelectTests::test_select_with_use_index_with_index_object", + "pypika/tests/test_selects.py::SelectTests::test_table_select_alias", + "pypika/tests/test_selects.py::SelectTests::test_table_select_alias_with_offset_and_limit", + "pypika/tests/test_selects.py::SelectTests::test_temporal_select", + "pypika/tests/test_selects.py::SelectTests::test_vertica_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::WhereTests::test_ignore_empty_criterion_having", + "pypika/tests/test_selects.py::WhereTests::test_ignore_empty_criterion_where", + "pypika/tests/test_selects.py::WhereTests::test_select_with_force_index_and_where", + "pypika/tests/test_selects.py::WhereTests::test_where_enum", + "pypika/tests/test_selects.py::WhereTests::test_where_field_contains", + "pypika/tests/test_selects.py::WhereTests::test_where_field_does_not_contain", + "pypika/tests/test_selects.py::WhereTests::test_where_field_does_not_end_with", + "pypika/tests/test_selects.py::WhereTests::test_where_field_does_not_start_with", + "pypika/tests/test_selects.py::WhereTests::test_where_field_ends_with", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_and", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_nowait", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_of", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_of_multiple_tables", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_of_nowait", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_of_skip_locked", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_skip_locked", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_skip_locked_and_of", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_or", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_where", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_where_not", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_where_two_not", + "pypika/tests/test_selects.py::WhereTests::test_where_field_is_n_chars_long", + "pypika/tests/test_selects.py::WhereTests::test_where_field_is_not_n_chars_long", + "pypika/tests/test_selects.py::WhereTests::test_where_field_matches_regex", + "pypika/tests/test_selects.py::WhereTests::test_where_field_matches_regexp", + "pypika/tests/test_selects.py::WhereTests::test_where_field_matches_rlike", + "pypika/tests/test_selects.py::WhereTests::test_where_field_starts_with", + "pypika/tests/test_selects.py::WhereTests::test_where_nested_conditions", + "pypika/tests/test_selects.py::WhereTests::test_where_single_quote", + "pypika/tests/test_selects.py::WhereTests::test_where_with_multiple_wheres_using_and_case", + "pypika/tests/test_selects.py::WhereTests::test_where_with_multiple_wheres_using_or_case", + "pypika/tests/test_selects.py::PreWhereTests::test_ignore_empty_criterion_having", + "pypika/tests/test_selects.py::PreWhereTests::test_ignore_empty_criterion_where", + "pypika/tests/test_selects.py::PreWhereTests::test_prewhere_field_equals", + "pypika/tests/test_selects.py::PreWhereTests::test_select_with_force_index_and_where", + "pypika/tests/test_selects.py::PreWhereTests::test_where_and_prewhere", + "pypika/tests/test_selects.py::PreWhereTests::test_where_enum", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_contains", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_does_not_contain", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_does_not_end_with", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_does_not_start_with", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_ends_with", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_and", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_nowait", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_of", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_of_multiple_tables", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_of_nowait", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_of_skip_locked", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_skip_locked", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_skip_locked_and_of", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_or", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_where", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_where_not", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_where_two_not", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_is_n_chars_long", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_is_not_n_chars_long", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_matches_regex", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_matches_regexp", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_matches_rlike", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_starts_with", + "pypika/tests/test_selects.py::PreWhereTests::test_where_nested_conditions", + "pypika/tests/test_selects.py::PreWhereTests::test_where_single_quote", + "pypika/tests/test_selects.py::PreWhereTests::test_where_with_multiple_wheres_using_and_case", + "pypika/tests/test_selects.py::PreWhereTests::test_where_with_multiple_wheres_using_or_case", + "pypika/tests/test_selects.py::GroupByTests::test_group_by__single_with_totals", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__alias", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__alias_platforms", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__alias_with_join", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__count_distinct", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__count_field", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__count_star", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__int", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__multi", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__multi_with_totals", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__no_alias", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__no_alias_mssql", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__no_alias_oracle", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__single", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__str", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__sum_distinct", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__sum_filter", + "pypika/tests/test_selects.py::GroupByTests::test_groupby_with_case_uses_the_alias", + "pypika/tests/test_selects.py::GroupByTests::test_mssql_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_mysql_query_uses_backtick_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_oracle_query_uses_no_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_postgres_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_redshift_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_vertica_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_having_and", + "pypika/tests/test_selects.py::HavingTests::test_having_greater_than", + "pypika/tests/test_selects.py::HavingTests::test_having_join_and_equality", + "pypika/tests/test_selects.py::HavingTests::test_mssql_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_mysql_query_uses_backtick_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_oracle_query_uses_no_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_postgres_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_redshift_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_vertica_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_alias", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_asc", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_desc", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_multi_fields", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_no_alias", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_single_field", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_single_str", + "pypika/tests/test_selects.py::AliasTests::test_arithmetic_function", + "pypika/tests/test_selects.py::AliasTests::test_case_using_as", + "pypika/tests/test_selects.py::AliasTests::test_case_using_constructor_param", + "pypika/tests/test_selects.py::AliasTests::test_function_using_as_nested", + "pypika/tests/test_selects.py::AliasTests::test_functions_using_as", + "pypika/tests/test_selects.py::AliasTests::test_functions_using_constructor_param", + "pypika/tests/test_selects.py::AliasTests::test_functions_using_constructor_param_nested", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_criterion", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_criterion_comparison", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_field_inside_case", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_groupby", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_orderby", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_where", + "pypika/tests/test_selects.py::AliasTests::test_null_value_with_alias", + "pypika/tests/test_selects.py::AliasTests::test_select__multiple_tables", + "pypika/tests/test_selects.py::AliasTests::test_table_field", + "pypika/tests/test_selects.py::AliasTests::test_table_field__multi", + "pypika/tests/test_selects.py::AliasTests::test_table_with_schema_and_alias", + "pypika/tests/test_selects.py::AliasTests::test_use_aliases_in_groupby_and_orderby", + "pypika/tests/test_selects.py::SubqueryTests::test_from_subquery_without_alias", + "pypika/tests/test_selects.py::SubqueryTests::test_join", + "pypika/tests/test_selects.py::SubqueryTests::test_join_query_with_alias", + "pypika/tests/test_selects.py::SubqueryTests::test_join_with_with", + "pypika/tests/test_selects.py::SubqueryTests::test_select_from_nested_query", + "pypika/tests/test_selects.py::SubqueryTests::test_select_from_nested_query_with_join", + "pypika/tests/test_selects.py::SubqueryTests::test_select_from_with_returning", + "pypika/tests/test_selects.py::SubqueryTests::test_select_subquery", + "pypika/tests/test_selects.py::SubqueryTests::test_select_subquery_with_alias", + "pypika/tests/test_selects.py::SubqueryTests::test_where__equality", + "pypika/tests/test_selects.py::SubqueryTests::test_where__in", + "pypika/tests/test_selects.py::SubqueryTests::test_where__in_nested", + "pypika/tests/test_selects.py::SubqueryTests::test_with", + "pypika/tests/test_selects.py::QuoteTests::test_extraneous_quotes", + "pypika/tests/test_tables.py::TableStructureTests::test_database_schema_table_attr", + "pypika/tests/test_tables.py::TableStructureTests::test_schema_table_attr", + "pypika/tests/test_tables.py::TableStructureTests::test_table_for_period_sql", + "pypika/tests/test_tables.py::TableStructureTests::test_table_for_system_time_sql", + "pypika/tests/test_tables.py::TableStructureTests::test_table_sql", + "pypika/tests/test_tables.py::TableStructureTests::test_table_with_alias", + "pypika/tests/test_tables.py::TableStructureTests::test_table_with_schema_and_schema_parent_arg", + "pypika/tests/test_tables.py::TableStructureTests::test_table_with_schema_arg", + "pypika/tests/test_tables.py::TableEqualityTests::test_many_tables_with_alias", + "pypika/tests/test_tables.py::TableEqualityTests::test_many_tables_with_or_not_alias", + "pypika/tests/test_tables.py::TableEqualityTests::test_many_tables_without_alias", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_equal_by_name", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_equal_by_schema_and_name", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_equal_by_schema_and_name_using_schema", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_equal_by_schema_and_name_using_schema_with_parent", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_not_equal_by_schema_and_name_using_schema_with_different_parents", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_not_equal_with_different_names", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_not_equal_with_different_schemas", + "pypika/tests/test_tables.py::TableDialectTests::test_make_tables_factory_with_default_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_make_tables_factory_with_dialect_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_factory_with_default_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_factory_with_dialect_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_with_bad_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_with_default_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_with_dialect_query_cls", + "pypika/tests/test_terms.py::FieldAliasTests::test_when_alias_specified", + "pypika/tests/test_terms.py::FieldInitTests::test_init_with_str_table", + "pypika/tests/test_terms.py::FieldHashingTests::test_non_tabled_aliased_eq_fields_equally_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_non_tabled_aliased_ne_fields_differently_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_non_tabled_eq_fields_equally_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_non_tabled_ne_fields_differently_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_tabled_eq_fields_equally_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_tabled_ne_fields_differently_hashed", + "pypika/tests/test_terms.py::AtTimezoneTests::test_passes_kwargs_to_field_get_sql", + "pypika/tests/test_terms.py::AtTimezoneTests::test_when_alias_specified", + "pypika/tests/test_terms.py::AtTimezoneTests::test_when_interval_not_specified", + "pypika/tests/test_terms.py::AtTimezoneTests::test_when_interval_specified", + "pypika/tests/test_tuples.py::TupleTests::test_render_alias_in_array_sql", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_equality_tuple_on_both", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_equality_tuple_on_left", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_equality_tuple_on_right", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_in_using_mixed_tuples", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_in_using_pypika_tuples", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_in_using_python_tuples", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_is_aggregate", + "pypika/tests/test_tuples.py::TupleTests::test_tuples_in_join", + "pypika/tests/test_tuples.py::ArrayTests::test_array_general", + "pypika/tests/test_tuples.py::ArrayTests::test_empty_psql_array", + "pypika/tests/test_tuples.py::ArrayTests::test_psql_array_general", + "pypika/tests/test_tuples.py::ArrayTests::test_render_alias_in_array_sql", + "pypika/tests/test_tuples.py::BracketTests::test_arithmetic_with_brackets", + "pypika/tests/test_tuples.py::BracketTests::test_arithmetic_with_brackets_and_alias", + "pypika/tests/test_updates.py::UpdateTests::test_empty_query", + "pypika/tests/test_updates.py::UpdateTests::test_for_portion", + "pypika/tests/test_updates.py::UpdateTests::test_omit_where", + "pypika/tests/test_updates.py::UpdateTests::test_single_quote_escape_in_set", + "pypika/tests/test_updates.py::UpdateTests::test_update__table_schema", + "pypika/tests/test_updates.py::UpdateTests::test_update_from", + "pypika/tests/test_updates.py::UpdateTests::test_update_from_with_where", + "pypika/tests/test_updates.py::UpdateTests::test_update_with_join", + "pypika/tests/test_updates.py::UpdateTests::test_update_with_limit", + "pypika/tests/test_updates.py::UpdateTests::test_update_with_none", + "pypika/tests/test_updates.py::UpdateTests::test_update_with_statement", + "pypika/tests/test_updates.py::PostgresUpdateTests::test_update_returning", + "pypika/tests/test_updates.py::PostgresUpdateTests::test_update_returning_from_different_tables", + "pypika/tests/test_updates.py::PostgresUpdateTests::test_update_returning_star", + "pypika/tests/test_updates.py::PostgresUpdateTests::test_update_returning_str", + "pypika/tests/test_updates.py::SQLLiteUpdateTests::test_update_with_bool", + "pypika/tests/test_utils.py::ImmutabilityTests::test_raise_attribute_error_for_deepcopy", + "pypika/tests/test_utils.py::ImmutabilityTests::test_raise_attribute_error_for_getnewargs", + "pypika/tests/test_utils.py::ImmutabilityTests::test_raise_attribute_error_for_getstate", + "pypika/tests/test_utils.py::ImmutabilityTests::test_raise_attribute_error_for_setstate" + ], + "all_git_blobs_modes_verified": true, + "cloud_launch_ready": false, + "commits": { + "bug": "4c3729566e8712e6639bc381f437a5900c1a1058", + "healthy": "6a742f12bfa386994289ec8b75824663d8ee4b15", + "learner": "d6c429eb6fad4a78ea7b28c24e19863ee2834f00" + }, + "existing_squirrel_snapshot_reused": false, + "full_transfer_allowlist": [ + "/testbed/.coveragerc", + "/testbed/.gitignore", + "/testbed/.pre-commit-config.yaml", + "/testbed/CODEOWNERS", + "/testbed/CONTRIBUTING.rst", + "/testbed/LICENSE.txt", + "/testbed/MANIFEST.in", + "/testbed/Makefile", + "/testbed/README.rst", + "/testbed/docs/1_installation.rst", + "/testbed/docs/2_tutorial.rst", + "/testbed/docs/3_advanced.rst", + "/testbed/docs/4_extending.rst", + "/testbed/docs/5_reference.rst", + "/testbed/docs/6_contributing.rst", + "/testbed/docs/Makefile", + "/testbed/docs/api/pypika.analytics.rst", + "/testbed/docs/api/pypika.dialects.rst", + "/testbed/docs/api/pypika.enums.rst", + "/testbed/docs/api/pypika.functions.rst", + "/testbed/docs/api/pypika.pseudocolumns.rst", + "/testbed/docs/api/pypika.queries.rst", + "/testbed/docs/api/pypika.rst", + "/testbed/docs/api/pypika.terms.rst", + "/testbed/docs/api/pypika.utils.rst", + "/testbed/docs/conf.py", + "/testbed/docs/index.rst", + "/testbed/pypika/__init__.py", + "/testbed/pypika/analytics.py", + "/testbed/pypika/clickhouse/__init__.py", + "/testbed/pypika/clickhouse/array.py", + "/testbed/pypika/clickhouse/condition.py", + "/testbed/pypika/clickhouse/dates_and_times.py", + "/testbed/pypika/clickhouse/nullable_arg.py", + "/testbed/pypika/clickhouse/search_string.py", + "/testbed/pypika/clickhouse/type_conversion.py", + "/testbed/pypika/dialects.py", + "/testbed/pypika/enums.py", + "/testbed/pypika/functions.py", + "/testbed/pypika/pseudocolumns.py", + "/testbed/pypika/py.typed", + "/testbed/pypika/queries.py", + "/testbed/pypika/terms.py", + "/testbed/pypika/tests/__init__.py", + "/testbed/pypika/tests/clickhouse/__init__.py", + "/testbed/pypika/tests/clickhouse/test_dates_and_times.py", + "/testbed/pypika/tests/dialects/__init__.py", + "/testbed/pypika/tests/dialects/test_clickhouse.py", + "/testbed/pypika/tests/dialects/test_mssql.py", + "/testbed/pypika/tests/dialects/test_mysql.py", + "/testbed/pypika/tests/dialects/test_oracle.py", + "/testbed/pypika/tests/dialects/test_postgresql.py", + "/testbed/pypika/tests/dialects/test_snowflake.py", + "/testbed/pypika/tests/dialects/test_sqllite.py", + "/testbed/pypika/tests/dialects/test_vertica.py", + "/testbed/pypika/tests/test_aggregate.py", + "/testbed/pypika/tests/test_analytic_queries.py", + "/testbed/pypika/tests/test_create.py", + "/testbed/pypika/tests/test_criterions.py", + "/testbed/pypika/tests/test_custom_functions.py", + "/testbed/pypika/tests/test_data_types.py", + "/testbed/pypika/tests/test_date_math.py", + "/testbed/pypika/tests/test_deletes.py", + "/testbed/pypika/tests/test_drop.py", + "/testbed/pypika/tests/test_formats.py", + "/testbed/pypika/tests/test_functions.py", + "/testbed/pypika/tests/test_groupby_modifiers.py", + "/testbed/pypika/tests/test_immutability.py", + "/testbed/pypika/tests/test_inserts.py", + "/testbed/pypika/tests/test_internals.py", + "/testbed/pypika/tests/test_joins.py", + "/testbed/pypika/tests/test_negation.py", + "/testbed/pypika/tests/test_parameter.py", + "/testbed/pypika/tests/test_pseudocolumns.py", + "/testbed/pypika/tests/test_query.py", + "/testbed/pypika/tests/test_selects.py", + "/testbed/pypika/tests/test_tables.py", + "/testbed/pypika/tests/test_terms.py", + "/testbed/pypika/tests/test_tuples.py", + "/testbed/pypika/tests/test_updates.py", + "/testbed/pypika/tests/test_utils.py", + "/testbed/pypika/utils.py", + "/testbed/pyproject.toml", + "/testbed/requirements-dev.txt", + "/testbed/setup.cfg", + "/testbed/setup.py", + "/testbed/tox.ini" + ], + "healthy_stage_meaning": "Direct parent of the mutation; no source or test execution has been performed", + "mutation_matches_dataset_and_git_blobs": true, + "official_profile": { + "eval_sets": [], + "profile_class": "Pypika1c9646f0", + "profile_lines": [ + 736, + 739 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "upstream_repo": "kayak/pypika" + }, + "original_source_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "private_test_paths": [ + "pypika/tests/clickhouse/test_array.py", + "pypika/tests/clickhouse/test_condition.py", + "pypika/tests/clickhouse/test_nullable_arg.py", + "pypika/tests/clickhouse/test_search_string.py", + "pypika/tests/clickhouse/test_type_conversion.py" + ], + "private_tests_unchanged": true, + "profile_mapping_basis": "Explicit upstream repo and full commit fields parsed from pinned official Python profile AST, not basename inference", + "qwen_calibrated": false, + "runtime_qualified": false, + "source_paths": [ + "pypika/clickhouse/condition.py", + "pypika/clickhouse/search_string.py", + "pypika/clickhouse/type_conversion.py" + ], + "source_repo": "swesmith/kayak__pypika.1c9646f0", + "source_stages_bytes": 1885261, + "task_id": "kayak__pypika.1c9646f0.combine_module__yfbs6ldj", + "transfer_limitation": "Existing regular files only; new arbitrary file additions need a qualified patch adapter", + "upstream_repo": "kayak/pypika" + }, + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:kayak__pypika.1c9646f0.combine_module__yfbs6ldj", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "6a742f12bfa386994289ec8b75824663d8ee4b15", + "instruction_sha256": "ee48b33698ac88a8b8ef72014784a2e58e2be900aa3bd8ab274d40e03b6c0992", + "is_fork": true, + "learner_path": "tasks/1299b10ca38f6ce9cd431dfe/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "actual_upstream_url": "https://raw.githubusercontent.com/kayak/pypika/1c9646f0a019a167c32b649b6f5e6423c5ba2c9b/LICENSE.txt", + "reviewed": true, + "sha256": "c5accbbd8546e94c34aed24afe689a617627d18eed5a6c48277e48db57c23851", + "spdx": "Apache-2.0", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/kayak__pypika.1c9646f0/d6c429eb6fad4a78ea7b28c24e19863ee2834f00/LICENSE.txt" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "patch_sha256": "5b84b5d5723dae46b58193195732fccd44e4f7b88337c1b822cd9ed75570c17b", + "provenance_path": "tasks/1299b10ca38f6ce9cd431dfe/source-proof.json", + "repository_lineage": [ + "swesmith/kayak__pypika.1c9646f0", + "kayak/pypika" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "d6c429eb6fad4a78ea7b28c24e19863ee2834f00", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "4c3729566e8712e6639bc381f437a5900c1a1058", + "source_kind": "mutation", + "source_repo": "swesmith/kayak__pypika.1c9646f0", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "kayak__pypika.1c9646f0.combine_module__yfbs6ldj", + "task_sha256": "81541f034def031a66bd22b0bb523dec823d1d088105b88157f4fd6a702e9db0", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "kayak/pypika", + "usage": "quarantine_only" + }, + "task_kind": "original-source-mutation" +} diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/provenance.json b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/provenance.json new file mode 100644 index 0000000000000000000000000000000000000000..a6e22710bc89bedf26b640625a63c32671037b69 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/provenance.json @@ -0,0 +1,88 @@ +{ + "generated_reference": false, + "healthy_reference_delta_sha256": "fd416c28266c45bd2df8b69dea41a0e26b93138ff9a7ff02204ea62f0e7289a1", + "native_pytest_ids_preserved": true, + "original_source_code_license": { + "actual_upstream_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "actual_upstream_url": "https://raw.githubusercontent.com/kayak/pypika/1c9646f0a019a167c32b649b6f5e6423c5ba2c9b/LICENSE.txt", + "reviewed": true, + "sha256": "c5accbbd8546e94c34aed24afe689a617627d18eed5a6c48277e48db57c23851", + "spdx": "Apache-2.0", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/kayak__pypika.1c9646f0/d6c429eb6fad4a78ea7b28c24e19863ee2834f00/LICENSE.txt" + }, + "provided_reference": true, + "qwen_calibrated": false, + "runtime_qualified": false, + "source_completion_sha256": "49863b83e0bf2f0eecc68d6c3cf78a5d6a303d58c8ba4dd4cb6dad8af227096c", + "source_index_sha256": "e856874b9410fce9f3bfea52c8c482e84b3e43942d87517f8b55f0034bd40f6f", + "source_proof_sha256": "e3745ac26822dd7cf0f5ba8707faf31b3b9f7cdcc522310082b5b03d016090db", + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:kayak__pypika.1c9646f0.combine_module__yfbs6ldj", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "6a742f12bfa386994289ec8b75824663d8ee4b15", + "instruction_sha256": "ee48b33698ac88a8b8ef72014784a2e58e2be900aa3bd8ab274d40e03b6c0992", + "is_fork": true, + "learner_path": "tasks/1299b10ca38f6ce9cd431dfe/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "actual_upstream_url": "https://raw.githubusercontent.com/kayak/pypika/1c9646f0a019a167c32b649b6f5e6423c5ba2c9b/LICENSE.txt", + "reviewed": true, + "sha256": "c5accbbd8546e94c34aed24afe689a617627d18eed5a6c48277e48db57c23851", + "spdx": "Apache-2.0", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/kayak__pypika.1c9646f0/d6c429eb6fad4a78ea7b28c24e19863ee2834f00/LICENSE.txt" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "patch_sha256": "5b84b5d5723dae46b58193195732fccd44e4f7b88337c1b822cd9ed75570c17b", + "provenance_path": "tasks/1299b10ca38f6ce9cd431dfe/source-proof.json", + "repository_lineage": [ + "swesmith/kayak__pypika.1c9646f0", + "kayak/pypika" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "d6c429eb6fad4a78ea7b28c24e19863ee2834f00", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "4c3729566e8712e6639bc381f437a5900c1a1058", + "source_kind": "mutation", + "source_repo": "swesmith/kayak__pypika.1c9646f0", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "kayak__pypika.1c9646f0.combine_module__yfbs6ldj", + "task_sha256": "81541f034def031a66bd22b0bb523dec823d1d088105b88157f4fd6a702e9db0", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "kayak/pypika", + "usage": "quarantine_only" + }, + "task_bundle_license": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + }, + "training_admissible": false, + "trusted_tests_sha256": "f2d0a1b335176a755d627907f32ef330383cf624ff3af2c5ea84ba2b6a2d7ebb" +} diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/provided-gold.diff b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/provided-gold.diff new file mode 100644 index 0000000000000000000000000000000000000000..091456967d8499a57ef67d9d12c112b076f9ef99 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/provided-gold.diff @@ -0,0 +1,46 @@ +diff --git a/pypika/clickhouse/condition.py b/pypika/clickhouse/condition.py +index c9545f3b46a7dca6861f9e93453a48eb15a5639e..ed08224e22fb27eb18876595a542dcd3ad14bffc 100644 +--- a/pypika/clickhouse/condition.py ++++ b/pypika/clickhouse/condition.py +@@ -3,7 +3,7 @@ + + class If(Function): + def __init__(self, *conditions, **kwargs): +- super().__init__("switch", *reversed(conditions), **kwargs) ++ super().__init__("if", *conditions, **kwargs) + + + class MultiIf(Function): +diff --git a/pypika/clickhouse/search_string.py b/pypika/clickhouse/search_string.py +index 3d307dae0e675ec48a3cf02ccb521e87ebb4328e..22a03027fcaf3ca0578e63980c00f4be1b2f67e7 100644 +--- a/pypika/clickhouse/search_string.py ++++ b/pypika/clickhouse/search_string.py +@@ -85,4 +85,4 @@ + class MultiMatchAny(_AbstractMultiSearchString): + @classmethod + def clickhouse_function(cls) -> str: +- return "multiMatchAll" ++ return "multiMatchAny" +diff --git a/pypika/clickhouse/type_conversion.py b/pypika/clickhouse/type_conversion.py +index 7c1ff1ae4b30e93d9b57ac2a100c81b48d37275d..80229b7e755dfb25bba5c4e65828a5d3cf42d988 100644 +--- a/pypika/clickhouse/type_conversion.py ++++ b/pypika/clickhouse/type_conversion.py +@@ -12,12 +12,12 @@ + + class ToFixedString(Function): + def __init__(self, field, length: int, alias: str = None, schema: str = None): +- self._length = length + 1 +- self._field = alias +- self.alias = field +- self.name = "toFixedStr" +- self.schema = None +- self.args = (schema,) ++ self._length = length ++ self._field = field ++ self.alias = alias ++ self.name = "toFixedString" ++ self.schema = schema ++ self.args = () + + def get_sql(self, with_alias=False, with_namespace=False, quote_char=None, dialect=None, **kwargs): + sql = "{name}({field},{length})".format( diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/solution/solve.sh b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..b01126af9602c006a3a305a32731509679c0b1a4 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/solution/solve.sh @@ -0,0 +1,52 @@ +#!/bin/bash +set -Eeuo pipefail +cd /testbed/repo +cat > /tmp/openenv-reference.diff <<'OPENENV_REFERENCE' +diff --git a/pypika/clickhouse/condition.py b/pypika/clickhouse/condition.py +index c9545f3b46a7dca6861f9e93453a48eb15a5639e..ed08224e22fb27eb18876595a542dcd3ad14bffc 100644 +--- a/pypika/clickhouse/condition.py ++++ b/pypika/clickhouse/condition.py +@@ -3,7 +3,7 @@ + + class If(Function): + def __init__(self, *conditions, **kwargs): +- super().__init__("switch", *reversed(conditions), **kwargs) ++ super().__init__("if", *conditions, **kwargs) + + + class MultiIf(Function): +diff --git a/pypika/clickhouse/search_string.py b/pypika/clickhouse/search_string.py +index 3d307dae0e675ec48a3cf02ccb521e87ebb4328e..22a03027fcaf3ca0578e63980c00f4be1b2f67e7 100644 +--- a/pypika/clickhouse/search_string.py ++++ b/pypika/clickhouse/search_string.py +@@ -85,4 +85,4 @@ + class MultiMatchAny(_AbstractMultiSearchString): + @classmethod + def clickhouse_function(cls) -> str: +- return "multiMatchAll" ++ return "multiMatchAny" +diff --git a/pypika/clickhouse/type_conversion.py b/pypika/clickhouse/type_conversion.py +index 7c1ff1ae4b30e93d9b57ac2a100c81b48d37275d..80229b7e755dfb25bba5c4e65828a5d3cf42d988 100644 +--- a/pypika/clickhouse/type_conversion.py ++++ b/pypika/clickhouse/type_conversion.py +@@ -12,12 +12,12 @@ + + class ToFixedString(Function): + def __init__(self, field, length: int, alias: str = None, schema: str = None): +- self._length = length + 1 +- self._field = alias +- self.alias = field +- self.name = "toFixedStr" +- self.schema = None +- self.args = (schema,) ++ self._length = length ++ self._field = field ++ self.alias = alias ++ self.name = "toFixedString" ++ self.schema = schema ++ self.args = () + + def get_sql(self, with_alias=False, with_namespace=False, quote_char=None, dialect=None, **kwargs): + sql = "{name}({field},{length})".format( +OPENENV_REFERENCE +/usr/bin/git -c core.hooksPath=/dev/null -c core.fsmonitor=false apply --whitespace=nowarn /tmp/openenv-reference.diff diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/task.toml b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..8b9488fd0c983fd6f25047b47177fde9b9e28496 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/task.toml @@ -0,0 +1,24 @@ +version = "1.0" + +[agent] +timeout_sec = 1800.0 + +[verifier] +timeout_sec = 900.0 + +[environment] +docker_image = "ghcr.io/younesbelkada/scale800@sha256:e9cab60b62a19976630f7839922fae53ccf33a076d46181b3b972deee55c2194" +build_timeout_sec = 600.0 +cpus = 2 +memory_mb = 8192 +storage_mb = 16384 + +[metadata] +author_name = "SWE-smith source adapter" +category = "bugfix" +tags = ["swe", "python", "mutation-repair"] + +[environment.env] +# The image's PATH with the testbed env first: the project and pytest are installed there, and the agent's +# non-interactive shells never run `conda activate` +PATH = "/opt/miniconda3/envs/testbed/bin:/opt/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/check_pytest.py b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/check_pytest.py new file mode 100644 index 0000000000000000000000000000000000000000..7abfdc5972f57ca7f0cecbbeeb373414670f780e --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/check_pytest.py @@ -0,0 +1,177 @@ +"""Preserve confirmed requested assertion failures; keep positive checks strict.""" + +import argparse +import hashlib +import json +import re +import xml.etree.ElementTree as ET +from pathlib import Path + +GROUPS = ("pass-to-pass", "fail-to-pass") + + +def split_nodeid(target): + prefix, bracket, parameter = target.partition("[") + parts = prefix.split("::") + if bracket: + parts[-1] += bracket + parameter + return parts + + +def matches(case, target): + parts = split_nodeid(target) + module = parts[0].removesuffix(".py").replace("/", ".") + classname, name = case.get("classname", ""), case.get("name", "") + if not (classname == module or classname.startswith(module + ".")): + return False + selector = parts[-1] if len(parts) > 1 else "" + classes = parts[1:-1] + if classes and classname != module + "." + ".".join(classes): + return False + return ( + not selector + or name == selector + or ("[" not in selector and name.startswith(selector + "[")) + ) + + +def capture_panels(root): + panels, digests = {}, {} + for group in GROUPS: + path = Path(root) / (group + ".xml") + if not path.exists(): + panels[group] = None + continue + with path.open("rb") as stream: + raw = stream.read(4 * 1024**2 + 1) + if not 0 < len(raw) <= 4 * 1024**2 or re.search( + rb" 20000: + raise ValueError("Too many pytest cases") + identities = [(case.get("classname"), case.get("name")) for case in cases] + if len(identities) != len(set(identities)): + raise ValueError("Duplicate pytest case evidence") + panels[group] = cases + digests[group] = hashlib.sha256(raw).hexdigest() + return panels, digests + + +def strict_assess(panels, expected, native_exit): + """The original positive-approval conditions, applied to captured cases.""" + all_cases, actual_failure = [], False + for group in GROUPS: + cases = panels[group] + if cases is None: + if actual_failure: + continue + raise ValueError("Missing preceding pytest panel") + if actual_failure: + raise ValueError( + "Pytest evidence continued after the native stop-on-failure" + ) + targets = expected[group] + if any(not any(matches(case, target) for target in targets) for case in cases): + raise ValueError("Unexpected pytest case") + all_cases.extend(cases) + failures = [case for case in cases if case.find("failure") is not None] + if any( + case.find("error") is not None or case.find("skipped") is not None + for case in cases + ): + raise ValueError("Pytest collection/error/skip is not a completed panel") + actual_failure = actual_failure or bool(failures) + if not failures and any( + not any(matches(case, target) for case in cases) for target in targets + ): + raise ValueError("Declared pytest target never ran") + if actual_failure: + if native_exit == 0: + raise ValueError("Native verifier exit disagrees with pytest failure") + return {"reward": 0, "valid_test_failure": True, "cases": len(all_cases)} + if native_exit != 0: + raise ValueError("Setup or native verifier failed without a real test failure") + if any(panels[group] is None for group in GROUPS): + raise ValueError("Missing completed pytest panel") + return {"reward": 1, "valid_test_failure": False, "cases": len(all_cases)} + + +def assess(root, expected, native_exit): + if type(native_exit) is not int: + raise ValueError("Native verifier exit must be an integer") + if not isinstance(expected, dict) or any( + not isinstance(expected.get(group), list) + or not expected[group] + or any(not isinstance(target, str) or not target for target in expected[group]) + for group in GROUPS + ): + raise ValueError("Complete exact native pytest targets required") + panels, digests = capture_panels(root) + counts = { + "cases": 0, + "matched_failures": 0, + "unexpected_cases": 0, + "unmatched_failures": 0, + "skipped_cases": 0, + "error_cases": 0, + "missing_panels": 0, + "missing_targets": 0, + } + for group in GROUPS: + cases = panels[group] + if cases is None: + counts["missing_panels"] += 1 + counts["missing_targets"] += len(expected[group]) + continue + counts["cases"] += len(cases) + for case in cases: + requested = any(matches(case, target) for target in expected[group]) + failure = case.find("failure") is not None + counts["matched_failures"] += int(requested and failure) + counts["unmatched_failures"] += int(not requested and failure) + counts["unexpected_cases"] += int(not requested) + counts["skipped_cases"] += int(case.find("skipped") is not None) + counts["error_cases"] += int(case.find("error") is not None) + counts["missing_targets"] += sum( + not any(matches(case, target) for case in cases) + for target in expected[group] + ) + if counts["matched_failures"]: + if native_exit == 0: + raise ValueError( + "Native verifier exit disagrees with requested pytest failure" + ) + return { + "reward": 0, + "valid_test_failure": True, + "cases": counts["cases"], + "diagnostic_counts": counts, + "panel_sha256": digests, + "decision": "confirmed_requested_failure_precedence", + } + result = strict_assess(panels, expected, native_exit) + result.update(diagnostic_counts=counts, panel_sha256=digests) + return result + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("--root", required=True) + parser.add_argument("--expected", required=True) + parser.add_argument("--native-exit", type=int, required=True) + args = parser.parse_args() + result = assess( + args.root, json.loads(Path(args.expected).read_bytes()), args.native_exit + ) + reward = Path(args.root) / "reward.txt" + if reward.read_text().strip() != str(result["reward"]): + raise ValueError("Native raw reward disagrees with pytest evidence") + (Path(args.root) / "pytest-evidence.json").write_text( + json.dumps(result, sort_keys=True) + "\n" + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/expected-panels.json b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/expected-panels.json new file mode 100644 index 0000000000000000000000000000000000000000..6d2148488767b35b7c270218f3d05cf5d90b65a5 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/expected-panels.json @@ -0,0 +1,1067 @@ +{ + "fail-to-pass": [ + "pypika/tests/clickhouse/test_array.py::TestArray::test_get_sql_3__toFixedString_mogwai_10_toFixedString_mono_10_toFixedString_bonobo_10_arr", + "pypika/tests/clickhouse/test_array.py::TestHasAny::test_get_sql_2_hasAny_bands_toFixedString_port_royal_20_toFixedString_hammock_20_", + "pypika/tests/clickhouse/test_condition.py::TestIfCondition::test_get_sql_0", + "pypika/tests/clickhouse/test_condition.py::TestIfCondition::test_get_sql_1", + "pypika/tests/clickhouse/test_condition.py::TestMultiIfCondition::test_get_sql_0", + "pypika/tests/clickhouse/test_condition.py::TestMultiIfCondition::test_get_sql_1", + "pypika/tests/clickhouse/test_nullable_arg.py::TestSearchString::test_get_sql_1", + "pypika/tests/clickhouse/test_search_string.py::TestMultiSearch::test_multi_search_string_1", + "pypika/tests/clickhouse/test_type_conversion.py::TestToFixedString::test_get_sql_with_table" + ], + "pass-to-pass": [ + "pypika/tests/clickhouse/test_array.py::TestArray::test_get_sql_0__ridley_scott_jimi_hendrix_", + "pypika/tests/clickhouse/test_array.py::TestArray::test_get_sql_1__1_2_3_4_", + "pypika/tests/clickhouse/test_array.py::TestArray::test_get_sql_2__toInt64_1_toInt64_2_toInt64_3_toInt64_4_", + "pypika/tests/clickhouse/test_array.py::TestHasAny::test_get_sql_0_hasAny_mental_abilities_physical_abilities_", + "pypika/tests/clickhouse/test_array.py::TestHasAny::test_get_sql_1_hasAny_1_2_3_4_3_", + "pypika/tests/clickhouse/test_array.py::TestLength::test_get_sql_0_length_tags_", + "pypika/tests/clickhouse/test_array.py::TestLength::test_get_sql_1_length_1_2_3_", + "pypika/tests/clickhouse/test_array.py::TestEmpty::test_get_sql_0_empty_tags_", + "pypika/tests/clickhouse/test_array.py::TestEmpty::test_get_sql_1_empty_1_2_3_", + "pypika/tests/clickhouse/test_array.py::TestNotEmpty::test_get_sql_0_notEmpty_tags_", + "pypika/tests/clickhouse/test_array.py::TestNotEmpty::test_get_sql_1_notEmpty_1_2_3_", + "pypika/tests/clickhouse/test_dates_and_times.py::TestFormatDateTime::test_get_sql_0", + "pypika/tests/clickhouse/test_dates_and_times.py::TestFormatDateTime::test_get_sql_1", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_00", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_01", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_02", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_03", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_04", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_05", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_06", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_07", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_08", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_09", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_10", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_11", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_12", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_13", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_14", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_15", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_16", + "pypika/tests/clickhouse/test_dates_and_times.py::TestToYYYYMM::test_get_sql", + "pypika/tests/clickhouse/test_nullable_arg.py::TestSearchString::test_get_sql_0", + "pypika/tests/clickhouse/test_search_string.py::TestSearchString::test_search_string_0", + "pypika/tests/clickhouse/test_search_string.py::TestSearchString::test_search_string_1", + "pypika/tests/clickhouse/test_search_string.py::TestSearchString::test_search_string_2", + "pypika/tests/clickhouse/test_search_string.py::TestMultiSearch::test_multi_search_string_0", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_00_toString_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_01_toInt8_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_02_toInt16_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_03_toInt32_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_04_toInt64_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_05_toUInt8_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_06_toUInt16_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_07_toUInt32_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_08_toUInt64_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_09_toFloat32_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_10_toFloat64_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_11_toFloat64_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_12_toDate_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_13_toDateTime_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_14_toFixedString_field_name_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_00_toString_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_01_toInt8_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_02_toInt16_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_03_toInt32_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_04_toInt64_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_05_toUInt8_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_06_toUInt16_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_07_toUInt32_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_08_toUInt64_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_09_toFloat32_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_10_toFloat64_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_11_toFloat64_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_12_toDate_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_13_toDateTime_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_14_toFixedString_100_100_", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseQueryTests::test_use_AS_keyword_for_alias", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseQueryTests::test_use_FINAL_keyword", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseQueryTests::test_use_SAMPLE_keyword", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseQueryTests::test_use_SAMPLE_with_offset_keyword", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDeleteTests::test_omit_where", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDeleteTests::test_omit_where__table_schema", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDeleteTests::test_where_field_equals", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseUpdateTests::test_update", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDropQuery::test_drop_database", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDropQuery::test_drop_dictionary", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDropQuery::test_drop_other", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDropQuery::test_drop_table", + "pypika/tests/dialects/test_clickhouse.py::DistinctOnTests::test_distinct_on", + "pypika/tests/dialects/test_clickhouse.py::LimitByTests::test_limit_by", + "pypika/tests/dialects/test_clickhouse.py::LimitByTests::test_limit_offset0_by", + "pypika/tests/dialects/test_clickhouse.py::LimitByTests::test_limit_offset_by", + "pypika/tests/dialects/test_clickhouse.py::LimitByTests::test_rename_table", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_distinct_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_groupby_alias_False_does_not_group_by_alias_when_subqueries_are_present", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_groupby_alias_False_does_not_group_by_alias_with_standard_query", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_limit", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_limit_with_offset", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_normal_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_offset", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_distinct_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_percent_invalid_range", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_percent_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_select_non_int", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_with_ties_select", + "pypika/tests/dialects/test_mysql.py::SelectTests::test_distinct_select", + "pypika/tests/dialects/test_mysql.py::SelectTests::test_modifier_select", + "pypika/tests/dialects/test_mysql.py::SelectTests::test_multiple_modifier_select", + "pypika/tests/dialects/test_mysql.py::SelectTests::test_normal_select", + "pypika/tests/dialects/test_mysql.py::UpdateTests::test_conflict_handlers_update", + "pypika/tests/dialects/test_mysql.py::UpdateTests::test_on_duplicate_key_ignore_update", + "pypika/tests/dialects/test_mysql.py::UpdateTests::test_on_duplicate_key_update_update", + "pypika/tests/dialects/test_mysql.py::UpdateTests::test_update", + "pypika/tests/dialects/test_mysql.py::LoadCSVTests::test_load_from_file", + "pypika/tests/dialects/test_mysql.py::TableTests::test_create_table", + "pypika/tests/dialects/test_mysql.py::TableTests::test_drop_table", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_fetch_next_method_deprecated", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_groupby_alias_False_does_not_group_by_alias_when_subqueries_are_present", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_groupby_alias_False_does_not_group_by_alias_with_standard_query", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_limit_offset_query", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_limit_query", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_offset_query", + "pypika/tests/dialects/test_postgresql.py::InsertTests::test_array_keyword", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_alias_set_correctly", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_json_value_from_array_num", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_json_value_from_array_str", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_json_value_from_dict", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_json_value_from_dict_recursive", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_json_value_by_index", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_json_value_by_key", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_path_json_value", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_path_text_value", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_text_value_by_index", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_text_value_by_key", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contained_by_using_list_arg", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contained_by_using_str_arg", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contained_by_with_complex_criterion", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contains_for_field", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contains_for_json", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_has_any_keys", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_has_key", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_has_keys", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_subnet_contains_inet", + "pypika/tests/dialects/test_postgresql.py::DistinctOnTests::test_distinct_on", + "pypika/tests/dialects/test_postgresql.py::ArrayTests::test_array_syntax", + "pypika/tests/dialects/test_postgresql.py::ArrayTests::test_render_alias_in_array_sql", + "pypika/tests/dialects/test_postgresql.py::ReturningClauseTests::test_no_queryexception_if_returning_used_on_valid_query_type", + "pypika/tests/dialects/test_postgresql.py::ReturningClauseTests::test_queryexception_if_returning_used_on_invalid_query", + "pypika/tests/dialects/test_postgresql.py::ReturningClauseTests::test_return_field_from_join_table", + "pypika/tests/dialects/test_postgresql.py::ReturningClauseTests::test_returning_from_missing_table_raises_queryexception", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_dont_use_double_quotes_on_create_queries", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_dont_use_double_quotes_on_drop_queries", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_dont_use_double_quotes_on_joining_queries", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_use_double_quotes_on_alias_but_not_on_terms", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_use_double_quotes_on_alias_but_not_on_terms_with_joins", + "pypika/tests/dialects/test_sqllite.py::SelectTests::test_bool_false_as_zero", + "pypika/tests/dialects/test_sqllite.py::SelectTests::test_bool_true_as_one", + "pypika/tests/dialects/test_sqllite.py::ReplaceTests::test_insert_or_replace", + "pypika/tests/dialects/test_sqllite.py::ReplaceTests::test_normal_replace", + "pypika/tests/dialects/test_sqllite.py::ReplaceTests::test_replace_subquery", + "pypika/tests/dialects/test_vertica.py::VerticaQueryTests::test_delete_query_with_hint", + "pypika/tests/dialects/test_vertica.py::VerticaQueryTests::test_insert_query_with_hint", + "pypika/tests/dialects/test_vertica.py::VerticaQueryTests::test_select_query_with_hint", + "pypika/tests/dialects/test_vertica.py::VerticaQueryTests::test_update_query_with_hint", + "pypika/tests/dialects/test_vertica.py::CopyCSVTests::test_copy_from_file", + "pypika/tests/dialects/test_vertica.py::CreateTemporaryTableTests::test_create_local_table_without_temporary_raises_error", + "pypika/tests/dialects/test_vertica.py::CreateTemporaryTableTests::test_create_local_temporary_table", + "pypika/tests/dialects/test_vertica.py::CreateTemporaryTableTests::test_create_table_preserve_rows_without_temporary_raises_error", + "pypika/tests/dialects/test_vertica.py::CreateTemporaryTableTests::test_create_temporary_table_preserve_rows", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__agg_case_criterion_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__agg_case_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__agg_func_arithmetic_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__agg_func_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__case_mixed_constant_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__case_mixed_else_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__case_with_field_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__case_with_single_aggregate_field_in_one_criterion_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__constant_arithmetic_is_aggregate_none", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__constant_is_aggregate_none", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__field_arithmetic_constant_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__field_arithmetic_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__field_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__func_arithmetic_constant_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__mixed_case_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__mixed_func_arithmetic_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__negative_agg_func_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__non_aggregate_function_with_aggregated_arg", + "pypika/tests/test_aggregate.py::IsAggregateTests::test_complicated", + "pypika/tests/test_analytic_queries.py::RankTests::test_avg", + "pypika/tests/test_analytic_queries.py::RankTests::test_count_range_between_unbounded_preceeding_current_row", + "pypika/tests/test_analytic_queries.py::RankTests::test_dense_rank", + "pypika/tests/test_analytic_queries.py::RankTests::test_empty_over", + "pypika/tests/test_analytic_queries.py::RankTests::test_filter", + "pypika/tests/test_analytic_queries.py::RankTests::test_filter_quote_table_in_filter", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value_ignore_nulls", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value_ignore_nulls_first", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value_multi_argument", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value_range_between_x_preceeding_unbounded_following", + "pypika/tests/test_analytic_queries.py::RankTests::test_lag_generates_correct_sql", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value_ignore_nulls", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value_multi_argument", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value_rows_between_current_row_unbounded_following", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value_rows_between_current_row_unbounded_following_ignore_nulls", + "pypika/tests/test_analytic_queries.py::RankTests::test_lead_generates_correct_sql", + "pypika/tests/test_analytic_queries.py::RankTests::test_max_range_x_preceeding", + "pypika/tests/test_analytic_queries.py::RankTests::test_max_rows_x_preceeding", + "pypika/tests/test_analytic_queries.py::RankTests::test_median", + "pypika/tests/test_analytic_queries.py::RankTests::test_min_range_current_row", + "pypika/tests/test_analytic_queries.py::RankTests::test_min_rows_current_row", + "pypika/tests/test_analytic_queries.py::RankTests::test_multiple_partitions", + "pypika/tests/test_analytic_queries.py::RankTests::test_ntile_no_partition_or_order_invalid_sql", + "pypika/tests/test_analytic_queries.py::RankTests::test_ntile_with_order", + "pypika/tests/test_analytic_queries.py::RankTests::test_ntile_with_partition", + "pypika/tests/test_analytic_queries.py::RankTests::test_ntile_with_partition_and_order", + "pypika/tests/test_analytic_queries.py::RankTests::test_orderby_asc", + "pypika/tests/test_analytic_queries.py::RankTests::test_orderby_desc", + "pypika/tests/test_analytic_queries.py::RankTests::test_range_called_twice_raises_attribute_error", + "pypika/tests/test_analytic_queries.py::RankTests::test_range_then_rows_raises_attribute_error", + "pypika/tests/test_analytic_queries.py::RankTests::test_rank", + "pypika/tests/test_analytic_queries.py::RankTests::test_rank_with_alias", + "pypika/tests/test_analytic_queries.py::RankTests::test_row_number", + "pypika/tests/test_analytic_queries.py::RankTests::test_rows_called_twice_raises_attribute_error", + "pypika/tests/test_analytic_queries.py::RankTests::test_rows_then_range_raises_attribute_error", + "pypika/tests/test_analytic_queries.py::RankTests::test_stddev", + "pypika/tests/test_analytic_queries.py::RankTests::test_stddev_pop", + "pypika/tests/test_analytic_queries.py::RankTests::test_stddev_samp", + "pypika/tests/test_analytic_queries.py::RankTests::test_sum_rows_unbounded_preceeding", + "pypika/tests/test_analytic_queries.py::RankTests::test_table_prefixes_used_in_analytic_functions", + "pypika/tests/test_analytic_queries.py::RankTests::test_var_pop", + "pypika/tests/test_analytic_queries.py::RankTests::test_var_samp", + "pypika/tests/test_analytic_queries.py::RankTests::test_variance", + "pypika/tests/test_analytic_queries.py::RankTests::test_variance_rows_between_unbounded_preceeding_unbounded_following", + "pypika/tests/test_analytic_queries.py::RankTests::test_varpop_range_unbounded_preceeding", + "pypika/tests/test_analytic_queries.py::RankTests::test_varpop_rows_between_unbounded_preceeding_x_following", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_as_select_not_query_raises_error", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_with_columns", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_with_select", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_with_select_and_columns_fails", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_without_columns_or_select_empty", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_if_not_exists", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_simple", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_unique", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_where", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_without_columns_raises_error", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_without_table_raises_error", + "pypika/tests/test_criterions.py::CriterionTests::test__bitwise_and_in_where_clause", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_bitwise_and", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_bitwise_and_with_alias", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_bool", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_decimal", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_str", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gt_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gt_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gt_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gt_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gte_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gte_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gte_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gte_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_is_null", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_is_null_with_alias", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lt_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lt_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lt_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lt_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lte_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lte_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lte_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lte_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_str", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_with_alias", + "pypika/tests/test_criterions.py::NotTests::test_chained_function", + "pypika/tests/test_criterions.py::NotTests::test_is_not_null", + "pypika/tests/test_criterions.py::NotTests::test_negate", + "pypika/tests/test_criterions.py::NotTests::test_not_null", + "pypika/tests/test_criterions.py::NotTests::test_not_null_with_alias", + "pypika/tests/test_criterions.py::NotTests::test_not_with_and_criterion", + "pypika/tests/test_criterions.py::NotTests::test_not_with_complex_criterion", + "pypika/tests/test_criterions.py::NotTests::test_not_with_or_criterion", + "pypika/tests/test_criterions.py::NotTests::test_notnullcriterion_replace_table", + "pypika/tests/test_criterions.py::NotTests::test_variable_access", + "pypika/tests/test_criterions.py::BetweenTests::test__between_date", + "pypika/tests/test_criterions.py::BetweenTests::test__between_datetime", + "pypika/tests/test_criterions.py::BetweenTests::test__between_number", + "pypika/tests/test_criterions.py::BetweenTests::test__between_with_alias", + "pypika/tests/test_criterions.py::BetweenTests::test__function_between", + "pypika/tests/test_criterions.py::BetweenTests::test_get_item_only_works_with_slice", + "pypika/tests/test_criterions.py::IsInTests::test__function_isin", + "pypika/tests/test_criterions.py::IsInTests::test__in_character", + "pypika/tests/test_criterions.py::IsInTests::test__in_date", + "pypika/tests/test_criterions.py::IsInTests::test__in_datetime", + "pypika/tests/test_criterions.py::IsInTests::test__in_number", + "pypika/tests/test_criterions.py::IsInTests::test__in_number_with_alias", + "pypika/tests/test_criterions.py::IsInTests::test__in_unicode", + "pypika/tests/test_criterions.py::ArithmeticExpressionTests::test__lshift", + "pypika/tests/test_criterions.py::ArithmeticExpressionTests::test__rshift", + "pypika/tests/test_criterions.py::NotInTests::test__function_notin", + "pypika/tests/test_criterions.py::NotInTests::test__notin_character", + "pypika/tests/test_criterions.py::NotInTests::test__notin_date", + "pypika/tests/test_criterions.py::NotInTests::test__notin_datetime", + "pypika/tests/test_criterions.py::NotInTests::test__notin_number", + "pypika/tests/test_criterions.py::NotInTests::test__notin_number_with_alias", + "pypika/tests/test_criterions.py::LikeTests::test_glob_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_contains", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_ends_with", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_n_chars_long", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_starts_with", + "pypika/tests/test_criterions.py::LikeTests::test_like_contains", + "pypika/tests/test_criterions.py::LikeTests::test_like_ends_with", + "pypika/tests/test_criterions.py::LikeTests::test_like_n_chars_long", + "pypika/tests/test_criterions.py::LikeTests::test_like_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_like_starts_with", + "pypika/tests/test_criterions.py::LikeTests::test_not_ilike_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_not_like_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_rlike_escape_chars", + "pypika/tests/test_criterions.py::ExistsCriterionTests::test_exists", + "pypika/tests/test_criterions.py::ExistsCriterionTests::test_not_exists", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__between_and_field", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__between_and_isin", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__nested__and", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__nested__mixed", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__nested__or", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_and", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_function_and", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_function_or", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_function_xor", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_or", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_xor", + "pypika/tests/test_criterions.py::FieldsAsCriterionTests::test__field_and_field", + "pypika/tests/test_criterions.py::FieldsAsCriterionTests::test__field_or_field", + "pypika/tests/test_criterions.py::FieldsAsCriterionTests::test__field_xor_field", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_arithmeticfunction_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_betweencriterion_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_complexcriterion_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_criterion_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_field_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_function_with_only_fields_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_function_with_values_and_fields_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_nullcriterion_replace_table", + "pypika/tests/test_criterions.py::AnyTests::test_multiple_args_returned_in_chain_of_ors", + "pypika/tests/test_criterions.py::AnyTests::test_single_arg_returns_self", + "pypika/tests/test_criterions.py::AnyTests::test_with_generator", + "pypika/tests/test_criterions.py::AnyTests::test_zero_args_returns_empty_criterion", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_different_operations_with_empty_criterion", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_empty_criterion_on_the_left", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_empty_criterion_on_the_right", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_fields_", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_invertion_of_the_empty_criterion", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_more_than_one_empty_criterions", + "pypika/tests/test_criterions.py::AllTests::test_multiple_args_returned_in_chain_of_ors", + "pypika/tests/test_criterions.py::AllTests::test_single_arg_returns_self", + "pypika/tests/test_criterions.py::AllTests::test_with_generator", + "pypika/tests/test_criterions.py::AllTests::test_zero_args_returns_empty_criterion", + "pypika/tests/test_custom_functions.py::TestUnitCustomFunction::test_should_fail_with_wrong_arguments", + "pypika/tests/test_custom_functions.py::TestUnitCustomFunction::test_should_return_function_with_arguments", + "pypika/tests/test_custom_functions.py::TestUnitCustomFunction::test_should_return_function_with_no_arguments", + "pypika/tests/test_custom_functions.py::TestFunctionalCustomFunction::test_should_fail_use_custom_function_on_select_with_wrong_arguments", + "pypika/tests/test_custom_functions.py::TestFunctionalCustomFunction::test_should_use_custom_function_on_select", + "pypika/tests/test_data_types.py::StringTests::test_inline_string_concatentation", + "pypika/tests/test_data_types.py::UuidTests::test_uuid_string_generation", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_day", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_default", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_microsecond", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_minute", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_month", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_quarter", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_second", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_week", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_year", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_day_hour", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_day_microsecond", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_day_minute", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_day_second", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_hour_microsecond", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_hour_minute", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_hour_second", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_minute_microsecond", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_minute_second", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_second_microsecond", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_value_complex_expressions", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_value_right", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_year_month", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_mysql_dialect_uses_single_quotes_around_expression_in_an_interval", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_oracle_dialect_uses_single_quotes_around_expression_in_an_interval", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_postgresql_dialect_uses_single_quotes_around_interval", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_redshift_dialect_uses_single_quotes_around_interval", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_vertica_dialect_uses_single_quotes_around_interval", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_day", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_month", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_week", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_year", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_year_month", + "pypika/tests/test_date_math.py::TruncateTrailingZerosTests::test_do_not_truncate_integer_values", + "pypika/tests/test_date_math.py::TruncateTrailingZerosTests::test_do_not_truncate_months_between_years_and_datys", + "pypika/tests/test_deletes.py::DeleteTests::test_for_portion", + "pypika/tests/test_deletes.py::DeleteTests::test_omit_where", + "pypika/tests/test_deletes.py::DeleteTests::test_omit_where__table_schema", + "pypika/tests/test_deletes.py::DeleteTests::test_where_field_equals", + "pypika/tests/test_deletes.py::PostgresDeleteTests::test_delete_returning", + "pypika/tests/test_deletes.py::PostgresDeleteTests::test_delete_returning_star", + "pypika/tests/test_deletes.py::PostgresDeleteTests::test_delete_returning_str", + "pypika/tests/test_deletes.py::PostgresDeleteTests::test_delete_using", + "pypika/tests/test_drop.py::DropTableTests::test_drop_database", + "pypika/tests/test_drop.py::DropTableTests::test_drop_index", + "pypika/tests/test_drop.py::DropTableTests::test_drop_table", + "pypika/tests/test_drop.py::DropTableTests::test_drop_user", + "pypika/tests/test_drop.py::DropTableTests::test_drop_view", + "pypika/tests/test_formats.py::QuoteTests::test_no_quote_char_in_complex_query", + "pypika/tests/test_formats.py::QuoteTests::test_replace_quote_char_in_complex_query", + "pypika/tests/test_functions.py::FunctionTests::test_dialect_propagation", + "pypika/tests/test_functions.py::FunctionTests::test_is_aggregate_None_for_non_aggregate_function_or_function_with_no_aggregate_functions", + "pypika/tests/test_functions.py::FunctionTests::test_is_aggregate_True_for_aggregate_function_or_function_with_aggregate_functions", + "pypika/tests/test_functions.py::SchemaTests::test_schema_included_in_function_sql", + "pypika/tests/test_functions.py::SchemaTests::test_schema_no_schema_in_sql_when_none_set", + "pypika/tests/test_functions.py::ArithmeticTests::test__addition__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__addition__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__addition__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__addition__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__arithmetic_equality", + "pypika/tests/test_functions.py::ArithmeticTests::test__arithmetic_with_function", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_add_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_div_no_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_div_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_exponent_no_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_exponent_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_floor_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_function_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_modulus_no_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_modulus_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_mul_no_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_mul_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_nested_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_sub_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__division__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__division__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__division__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__division__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__exponent__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__exponent__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__floor", + "pypika/tests/test_functions.py::ArithmeticTests::test__leftshift__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__leftshift__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__leftshift__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__modulus__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__multiplication__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__multiplication__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__multiplication__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__multiplication__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__rightshift__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__rightshift__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__rightshift__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__subtraction__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__subtraction__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__subtraction__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__subtraction__right", + "pypika/tests/test_functions.py::AggregationTests::test__approx_percentile", + "pypika/tests/test_functions.py::AggregationTests::test__avg", + "pypika/tests/test_functions.py::AggregationTests::test__count", + "pypika/tests/test_functions.py::AggregationTests::test__count__star", + "pypika/tests/test_functions.py::AggregationTests::test__first", + "pypika/tests/test_functions.py::AggregationTests::test__last", + "pypika/tests/test_functions.py::AggregationTests::test__max", + "pypika/tests/test_functions.py::AggregationTests::test__min", + "pypika/tests/test_functions.py::AggregationTests::test__std", + "pypika/tests/test_functions.py::AggregationTests::test__stddev", + "pypika/tests/test_functions.py::AggregationTests::test__subquery_in_params_functions", + "pypika/tests/test_functions.py::AggregationTests::test__sum", + "pypika/tests/test_functions.py::ConditionTests::test__case__else", + "pypika/tests/test_functions.py::ConditionTests::test__case__field", + "pypika/tests/test_functions.py::ConditionTests::test__case__multi", + "pypika/tests/test_functions.py::ConditionTests::test__case__no_cases", + "pypika/tests/test_functions.py::ConditionTests::test__case__raw", + "pypika/tests/test_functions.py::StringTests::test__ascii__field", + "pypika/tests/test_functions.py::StringTests::test__ascii__int", + "pypika/tests/test_functions.py::StringTests::test__ascii__str", + "pypika/tests/test_functions.py::StringTests::test__bin__field", + "pypika/tests/test_functions.py::StringTests::test__bin__int", + "pypika/tests/test_functions.py::StringTests::test__bin__str", + "pypika/tests/test_functions.py::StringTests::test__concat__field", + "pypika/tests/test_functions.py::StringTests::test__concat__str", + "pypika/tests/test_functions.py::StringTests::test__insert__field", + "pypika/tests/test_functions.py::StringTests::test__insert__str", + "pypika/tests/test_functions.py::StringTests::test__length__field", + "pypika/tests/test_functions.py::StringTests::test__length__str", + "pypika/tests/test_functions.py::StringTests::test__lower__field", + "pypika/tests/test_functions.py::StringTests::test__lower__str", + "pypika/tests/test_functions.py::StringTests::test__replace__field", + "pypika/tests/test_functions.py::StringTests::test__replace__str", + "pypika/tests/test_functions.py::StringTests::test__substring", + "pypika/tests/test_functions.py::SplitPartFunctionTests::test__split_part", + "pypika/tests/test_functions.py::RegexpLikeFunctionTests::test__regexp_like", + "pypika/tests/test_functions.py::CastTests::test__cast__as", + "pypika/tests/test_functions.py::CastTests::test__cast__binary", + "pypika/tests/test_functions.py::CastTests::test__cast__binary_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__boolean", + "pypika/tests/test_functions.py::CastTests::test__cast__char", + "pypika/tests/test_functions.py::CastTests::test__cast__char_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__date", + "pypika/tests/test_functions.py::CastTests::test__cast__float", + "pypika/tests/test_functions.py::CastTests::test__cast__integer", + "pypika/tests/test_functions.py::CastTests::test__cast__long_varbinary", + "pypika/tests/test_functions.py::CastTests::test__cast__long_varbinary_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__long_varchar", + "pypika/tests/test_functions.py::CastTests::test__cast__long_varchar_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__numeric", + "pypika/tests/test_functions.py::CastTests::test__cast__signed", + "pypika/tests/test_functions.py::CastTests::test__cast__timestamp", + "pypika/tests/test_functions.py::CastTests::test__cast__unsigned", + "pypika/tests/test_functions.py::CastTests::test__cast__varbinary", + "pypika/tests/test_functions.py::CastTests::test__cast__varbinary_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__varchar", + "pypika/tests/test_functions.py::CastTests::test__cast__varchar_with_arg", + "pypika/tests/test_functions.py::CastTests::test__tochar__", + "pypika/tests/test_functions.py::DateFunctionsTests::test_current_date", + "pypika/tests/test_functions.py::DateFunctionsTests::test_current_time", + "pypika/tests/test_functions.py::DateFunctionsTests::test_current_timestamp", + "pypika/tests/test_functions.py::DateFunctionsTests::test_current_timestamp_with_alias", + "pypika/tests/test_functions.py::DateFunctionsTests::test_date_add", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_day", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_hour", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_join", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_microsecond", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_minute", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_month", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_quarter", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_second", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_week", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_year", + "pypika/tests/test_functions.py::DateFunctionsTests::test_now", + "pypika/tests/test_functions.py::DateFunctionsTests::test_time_diff", + "pypika/tests/test_functions.py::DateFunctionsTests::test_timestampadd", + "pypika/tests/test_functions.py::DateFunctionsTests::test_to_date", + "pypika/tests/test_functions.py::DateFunctionsTests::test_utc_timestamp", + "pypika/tests/test_functions.py::NullFunctionsTests::test_coalesce", + "pypika/tests/test_functions.py::NullFunctionsTests::test_isnull", + "pypika/tests/test_functions.py::NullFunctionsTests::test_nullif", + "pypika/tests/test_functions.py::NullFunctionsTests::test_nvl", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_mysql_one_groupby", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_mysql_rollup_two_groupbys", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_no_rollup_after_rollup_mysql", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_no_rollup_before_groupby", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_from_groupbys", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_from_parameters", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_from_two_groupbys", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_func_one_groupby", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_func_partial", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_func_two_groupbys", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_multiple_rollups", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_rollups_with_multiple_rollups_and_parity", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_rollups_with_parity", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_force_index_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_groupby_returns_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_immutable_kwarg_on_query_builder_disables_immutability", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_insert_into_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_join_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_orderby_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_queries_after_join", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_replace_into_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_select_returns_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_update_set_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_use_index_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_with_return_new_query_instance", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_multi_rows", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_multi_rows_chained", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_multi_rows_chained_mixed", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_multi_rows_chained_multiple_rows", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_single_element", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_column_using_alias_with_chain", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_column_using_table_alias", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_empty_columns", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_empty_columns_type_list", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_empty_columns_type_tuple", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_ignore", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_multiple_rows_with_array_value", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_none_skipped", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_null", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_one_column", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_one_column_multi_element_array", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_one_column_single_element_array", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_selected_columns", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_selected_columns_type_list", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_selected_columns_type_tuple", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_single_row_with_array_value", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_with_statement", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_empty_on_conflict_do_update_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_field", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_field_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_mixed_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_multiple_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_multiple_fields_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_field", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_field_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_multiple_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_multiple_fields_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_multiple_mixed_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_no_handler", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_two_handlers_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_two_handlers_do_update", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_fieldless_conflict_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_fieldless_conflict_do_update_field", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_non_insert_on_conflict_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_non_insert_on_conflict_do_update", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_do_nothing_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_do_update_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_do_update_with_excluded_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_from_subquery", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_complex", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_conflict_fields_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_conflict_fields_do_update", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_empty_conflict_fields_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_empty_conflict_fields_do_update", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_where_and_on_conflict_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_all_columns_multi_rows_chained_returning_star", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_all_columns_multi_rows_chained_returning_star_and_id", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_all_columns_multi_rows_chained_returning_star_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_all_columns_single_element_arrays", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_aggregate", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_all_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_all_fields_and_arithmetics", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_arithmetics", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_from_other_table", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_functions", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_null", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_one_field", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_one_field_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_tuple", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_ignore", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multi_rows_chained_mixed_on_duplicate_update_multiple", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_multiple", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_different_value", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_expression", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_expression_using_original_field_value", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_expression_using_values", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_same_value", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_none_skipped", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_one_column", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_one_column_multi_element_array", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_one_column_single_element_array", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_one_column_using_values", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_selected_columns_on_duplicate_update_multiple", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_selected_columns_on_duplicate_update_one", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_columns_from_columns", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_columns_from_columns_with_join", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_columns_from_star", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_from_columns", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_ignore_star", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_star", + "pypika/tests/test_inserts.py::InsertSubqueryTests::test_insert_subquery_wrapped_in_brackets", + "pypika/tests/test_inserts.py::SelectIntoTests::test_select_columns_into", + "pypika/tests/test_inserts.py::SelectIntoTests::test_select_columns_into_with_join", + "pypika/tests/test_inserts.py::SelectIntoTests::test_select_star_into", + "pypika/tests/test_inserts.py::ReplaceTests::test_replace_simple", + "pypika/tests/test_inserts.py::ReplaceTests::test_replace_subquery", + "pypika/tests/test_internals.py::TablesTests::test__case_tables", + "pypika/tests/test_internals.py::TablesTests::test__criterion_replace_table_with_value", + "pypika/tests/test_internals.py::TablesTests::test__star_tables", + "pypika/tests/test_internals.py::TablesTests::test__table_star_tables", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_cross_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_cross_join_on_subquery", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_cross_join_on_table", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_default_join_type", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_full_outer_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_hash_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_inner_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_arithmetic_field", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_collate", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_complex_criteria", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_field_multi", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_field_multi_with_extra_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_field_single", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_field_without_fields_raises_exception", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_subquery_criteria", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_second_table_in_from_clause", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_using_multiple_fields", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_using_string_field_name", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_using_with_quote_char", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_using_without_fields_raises_exception", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_with_arithmetic_function_in_select", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_left_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_left_outer_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_outer_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_right_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_right_outer_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_temporal_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_use_different_table_objects_for_same_table", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_fail_when_joining_unknown_type", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_ignore_table_references", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_immutable__tables", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_from_join", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_query_with_column_alias", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_query_with_setoperation", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_query_with_table_alias", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_query_without_alias", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_same_table", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_same_table_with_prefixes", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_table_twice", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_prefixes_added_to_function_in_orderby", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_prefixes_added_to_groupby", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_prefixes_added_to_orderby", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_require_condition", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_require_condition_with_both_tables", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select__fields_after_table_star", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select__ordered_select_clauses", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select__star_for_table", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select__star_for_table__replacement", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select_field_from_missing_table", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select_fields_with_where", + "pypika/tests/test_joins.py::UnionTests::test_mysql_query_wraps_unioned_queries", + "pypika/tests/test_joins.py::UnionTests::test_require_equal_number_of_fields", + "pypika/tests/test_joins.py::UnionTests::test_union", + "pypika/tests/test_joins.py::UnionTests::test_union_all", + "pypika/tests/test_joins.py::UnionTests::test_union_all_multiple", + "pypika/tests/test_joins.py::UnionTests::test_union_as_subquery", + "pypika/tests/test_joins.py::UnionTests::test_union_multiple", + "pypika/tests/test_joins.py::UnionTests::test_union_with_no_quote_char", + "pypika/tests/test_joins.py::UnionTests::test_union_with_order_by", + "pypika/tests/test_joins.py::UnionTests::test_union_with_order_by_use_union_query_field", + "pypika/tests/test_joins.py::UnionTests::test_union_with_order_by_use_union_query_field_with_aliases", + "pypika/tests/test_joins.py::UnionTests::test_union_with_order_by_with_aliases", + "pypika/tests/test_joins.py::InsertQueryJoinTests::test_join_table_on_insert_query", + "pypika/tests/test_joins.py::UpdateQueryJoinTests::test_join_table_on_update_query", + "pypika/tests/test_joins.py::IntersectTests::test_intersect", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_as_subquery", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_multiple", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_with_limit", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_with_no_quote_char", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_with_offset", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_with_order_by", + "pypika/tests/test_joins.py::IntersectTests::test_mysql_query_wraps_intersected_queries", + "pypika/tests/test_joins.py::IntersectTests::test_require_equal_number_of_fields_intersect", + "pypika/tests/test_joins.py::MinusTests::test_minus", + "pypika/tests/test_joins.py::MinusTests::test_minus_as_subquery", + "pypika/tests/test_joins.py::MinusTests::test_minus_multiple", + "pypika/tests/test_joins.py::MinusTests::test_minus_query_with_order_by_use_minus_query_field", + "pypika/tests/test_joins.py::MinusTests::test_minus_with_no_quote_char", + "pypika/tests/test_joins.py::MinusTests::test_minus_with_order_by", + "pypika/tests/test_joins.py::MinusTests::test_mysql_query_wraps_minus_queries", + "pypika/tests/test_joins.py::MinusTests::test_require_equal_number_of_fields", + "pypika/tests/test_joins.py::ExceptOfTests::test_except", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_as_subquery", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_multiple", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_query_with_order_by_use_minus_query_field", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_with_no_quote_char", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_with_order_by", + "pypika/tests/test_joins.py::ExceptOfTests::test_require_equal_number_of_fields_except_of", + "pypika/tests/test_negation.py::NegationTests::test_negate_field", + "pypika/tests/test_negation.py::NegationTests::test_negate_function", + "pypika/tests/test_negation.py::NegationTests::test_negate_wrapped_float", + "pypika/tests/test_negation.py::NegationTests::test_negate_wrapped_int", + "pypika/tests/test_parameter.py::ParametrizedTests::test_format_parameter", + "pypika/tests/test_parameter.py::ParametrizedTests::test_join", + "pypika/tests/test_parameter.py::ParametrizedTests::test_named_parameter", + "pypika/tests/test_parameter.py::ParametrizedTests::test_numeric_parameter", + "pypika/tests/test_parameter.py::ParametrizedTests::test_param_insert", + "pypika/tests/test_parameter.py::ParametrizedTests::test_param_select_join", + "pypika/tests/test_parameter.py::ParametrizedTests::test_param_select_subquery", + "pypika/tests/test_parameter.py::ParametrizedTests::test_pyformat_parameter", + "pypika/tests/test_parameter.py::ParametrizedTests::test_qmark_parameter", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_join", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_join_with_parameter_value_wrapper", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_param_insert", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_param_select_join", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_param_select_subquery", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_pyformat_parameter", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_can_be_used_in_a_select_statement", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_can_be_used_in_a_where_clause", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_can_be_used_in_orderby", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_column_value", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_object_id", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_object_value", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_row_id", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_row_num", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_sys_date", + "pypika/tests/test_query.py::QueryTablesTests::test_is_joined", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_case_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_delete_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_filter_tables", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_having_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_insert_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_insert_table_current_table_not_match", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_join_tables", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_only_specified_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_orderby_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_tuple_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_update_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_update_table_current_table_not_match", + "pypika/tests/test_query.py::QueryBuilderTests::test_pipe", + "pypika/tests/test_query.py::QueryBuilderTests::test_query_builders_have_reference_to_correct_query_class", + "pypika/tests/test_selects.py::SelectTests::test_empty_query", + "pypika/tests/test_selects.py::SelectTests::test_mssql_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_mysql_query_uses_backtick_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_oracle_query_uses_no_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_postgresql_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_redshift_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_select__column__single__alias__str", + "pypika/tests/test_selects.py::SelectTests::test_select__column__single__field", + "pypika/tests/test_selects.py::SelectTests::test_select__column__single__str", + "pypika/tests/test_selects.py::SelectTests::test_select__column__single__table_alias__str", + "pypika/tests/test_selects.py::SelectTests::test_select__columns__multi__field", + "pypika/tests/test_selects.py::SelectTests::test_select__columns__multi__str", + "pypika/tests/test_selects.py::SelectTests::test_select__distinct__multi", + "pypika/tests/test_selects.py::SelectTests::test_select__distinct__single", + "pypika/tests/test_selects.py::SelectTests::test_select__multiple_subqueries", + "pypika/tests/test_selects.py::SelectTests::test_select__multiple_tables", + "pypika/tests/test_selects.py::SelectTests::test_select__nested_subquery", + "pypika/tests/test_selects.py::SelectTests::test_select__no_table", + "pypika/tests/test_selects.py::SelectTests::test_select__star", + "pypika/tests/test_selects.py::SelectTests::test_select__star__replacement", + "pypika/tests/test_selects.py::SelectTests::test_select__subquery", + "pypika/tests/test_selects.py::SelectTests::test_select__table_schema", + "pypika/tests/test_selects.py::SelectTests::test_select__table_schema_with_multiple_levels_as_list", + "pypika/tests/test_selects.py::SelectTests::test_select__table_schema_with_multiple_levels_as_tuple", + "pypika/tests/test_selects.py::SelectTests::test_select_no_from", + "pypika/tests/test_selects.py::SelectTests::test_select_no_from_with_field_raises_exception", + "pypika/tests/test_selects.py::SelectTests::test_select_no_with_alias_from", + "pypika/tests/test_selects.py::SelectTests::test_select_then_add_table", + "pypika/tests/test_selects.py::SelectTests::test_select_with_force_index", + "pypika/tests/test_selects.py::SelectTests::test_select_with_force_index_multiple_calls", + "pypika/tests/test_selects.py::SelectTests::test_select_with_force_index_multiple_indexes", + "pypika/tests/test_selects.py::SelectTests::test_select_with_force_index_with_index_object", + "pypika/tests/test_selects.py::SelectTests::test_select_with_limit", + "pypika/tests/test_selects.py::SelectTests::test_select_with_limit__func", + "pypika/tests/test_selects.py::SelectTests::test_select_with_limit_and_offset", + "pypika/tests/test_selects.py::SelectTests::test_select_with_limit_zero", + "pypika/tests/test_selects.py::SelectTests::test_select_with_offset", + "pypika/tests/test_selects.py::SelectTests::test_select_with_offset__func", + "pypika/tests/test_selects.py::SelectTests::test_select_with_use_index", + "pypika/tests/test_selects.py::SelectTests::test_select_with_use_index_multiple_calls", + "pypika/tests/test_selects.py::SelectTests::test_select_with_use_index_multiple_indexes", + "pypika/tests/test_selects.py::SelectTests::test_select_with_use_index_with_index_object", + "pypika/tests/test_selects.py::SelectTests::test_table_select_alias", + "pypika/tests/test_selects.py::SelectTests::test_table_select_alias_with_offset_and_limit", + "pypika/tests/test_selects.py::SelectTests::test_temporal_select", + "pypika/tests/test_selects.py::SelectTests::test_vertica_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::WhereTests::test_ignore_empty_criterion_having", + "pypika/tests/test_selects.py::WhereTests::test_ignore_empty_criterion_where", + "pypika/tests/test_selects.py::WhereTests::test_select_with_force_index_and_where", + "pypika/tests/test_selects.py::WhereTests::test_where_enum", + "pypika/tests/test_selects.py::WhereTests::test_where_field_contains", + "pypika/tests/test_selects.py::WhereTests::test_where_field_does_not_contain", + "pypika/tests/test_selects.py::WhereTests::test_where_field_does_not_end_with", + "pypika/tests/test_selects.py::WhereTests::test_where_field_does_not_start_with", + "pypika/tests/test_selects.py::WhereTests::test_where_field_ends_with", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_and", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_nowait", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_of", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_of_multiple_tables", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_of_nowait", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_of_skip_locked", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_skip_locked", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_skip_locked_and_of", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_or", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_where", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_where_not", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_where_two_not", + "pypika/tests/test_selects.py::WhereTests::test_where_field_is_n_chars_long", + "pypika/tests/test_selects.py::WhereTests::test_where_field_is_not_n_chars_long", + "pypika/tests/test_selects.py::WhereTests::test_where_field_matches_regex", + "pypika/tests/test_selects.py::WhereTests::test_where_field_matches_regexp", + "pypika/tests/test_selects.py::WhereTests::test_where_field_matches_rlike", + "pypika/tests/test_selects.py::WhereTests::test_where_field_starts_with", + "pypika/tests/test_selects.py::WhereTests::test_where_nested_conditions", + "pypika/tests/test_selects.py::WhereTests::test_where_single_quote", + "pypika/tests/test_selects.py::WhereTests::test_where_with_multiple_wheres_using_and_case", + "pypika/tests/test_selects.py::WhereTests::test_where_with_multiple_wheres_using_or_case", + "pypika/tests/test_selects.py::PreWhereTests::test_ignore_empty_criterion_having", + "pypika/tests/test_selects.py::PreWhereTests::test_ignore_empty_criterion_where", + "pypika/tests/test_selects.py::PreWhereTests::test_prewhere_field_equals", + "pypika/tests/test_selects.py::PreWhereTests::test_select_with_force_index_and_where", + "pypika/tests/test_selects.py::PreWhereTests::test_where_and_prewhere", + "pypika/tests/test_selects.py::PreWhereTests::test_where_enum", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_contains", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_does_not_contain", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_does_not_end_with", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_does_not_start_with", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_ends_with", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_and", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_nowait", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_of", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_of_multiple_tables", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_of_nowait", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_of_skip_locked", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_skip_locked", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_skip_locked_and_of", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_or", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_where", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_where_not", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_where_two_not", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_is_n_chars_long", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_is_not_n_chars_long", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_matches_regex", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_matches_regexp", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_matches_rlike", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_starts_with", + "pypika/tests/test_selects.py::PreWhereTests::test_where_nested_conditions", + "pypika/tests/test_selects.py::PreWhereTests::test_where_single_quote", + "pypika/tests/test_selects.py::PreWhereTests::test_where_with_multiple_wheres_using_and_case", + "pypika/tests/test_selects.py::PreWhereTests::test_where_with_multiple_wheres_using_or_case", + "pypika/tests/test_selects.py::GroupByTests::test_group_by__single_with_totals", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__alias", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__alias_platforms", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__alias_with_join", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__count_distinct", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__count_field", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__count_star", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__int", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__multi", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__multi_with_totals", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__no_alias", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__no_alias_mssql", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__no_alias_oracle", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__single", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__str", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__sum_distinct", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__sum_filter", + "pypika/tests/test_selects.py::GroupByTests::test_groupby_with_case_uses_the_alias", + "pypika/tests/test_selects.py::GroupByTests::test_mssql_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_mysql_query_uses_backtick_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_oracle_query_uses_no_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_postgres_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_redshift_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_vertica_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_having_and", + "pypika/tests/test_selects.py::HavingTests::test_having_greater_than", + "pypika/tests/test_selects.py::HavingTests::test_having_join_and_equality", + "pypika/tests/test_selects.py::HavingTests::test_mssql_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_mysql_query_uses_backtick_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_oracle_query_uses_no_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_postgres_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_redshift_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_vertica_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_alias", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_asc", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_desc", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_multi_fields", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_no_alias", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_single_field", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_single_str", + "pypika/tests/test_selects.py::AliasTests::test_arithmetic_function", + "pypika/tests/test_selects.py::AliasTests::test_case_using_as", + "pypika/tests/test_selects.py::AliasTests::test_case_using_constructor_param", + "pypika/tests/test_selects.py::AliasTests::test_function_using_as_nested", + "pypika/tests/test_selects.py::AliasTests::test_functions_using_as", + "pypika/tests/test_selects.py::AliasTests::test_functions_using_constructor_param", + "pypika/tests/test_selects.py::AliasTests::test_functions_using_constructor_param_nested", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_criterion", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_criterion_comparison", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_field_inside_case", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_groupby", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_orderby", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_where", + "pypika/tests/test_selects.py::AliasTests::test_null_value_with_alias", + "pypika/tests/test_selects.py::AliasTests::test_select__multiple_tables", + "pypika/tests/test_selects.py::AliasTests::test_table_field", + "pypika/tests/test_selects.py::AliasTests::test_table_field__multi", + "pypika/tests/test_selects.py::AliasTests::test_table_with_schema_and_alias", + "pypika/tests/test_selects.py::AliasTests::test_use_aliases_in_groupby_and_orderby", + "pypika/tests/test_selects.py::SubqueryTests::test_from_subquery_without_alias", + "pypika/tests/test_selects.py::SubqueryTests::test_join", + "pypika/tests/test_selects.py::SubqueryTests::test_join_query_with_alias", + "pypika/tests/test_selects.py::SubqueryTests::test_join_with_with", + "pypika/tests/test_selects.py::SubqueryTests::test_select_from_nested_query", + "pypika/tests/test_selects.py::SubqueryTests::test_select_from_nested_query_with_join", + "pypika/tests/test_selects.py::SubqueryTests::test_select_from_with_returning", + "pypika/tests/test_selects.py::SubqueryTests::test_select_subquery", + "pypika/tests/test_selects.py::SubqueryTests::test_select_subquery_with_alias", + "pypika/tests/test_selects.py::SubqueryTests::test_where__equality", + "pypika/tests/test_selects.py::SubqueryTests::test_where__in", + "pypika/tests/test_selects.py::SubqueryTests::test_where__in_nested", + "pypika/tests/test_selects.py::SubqueryTests::test_with", + "pypika/tests/test_selects.py::QuoteTests::test_extraneous_quotes", + "pypika/tests/test_tables.py::TableStructureTests::test_database_schema_table_attr", + "pypika/tests/test_tables.py::TableStructureTests::test_schema_table_attr", + "pypika/tests/test_tables.py::TableStructureTests::test_table_for_period_sql", + "pypika/tests/test_tables.py::TableStructureTests::test_table_for_system_time_sql", + "pypika/tests/test_tables.py::TableStructureTests::test_table_sql", + "pypika/tests/test_tables.py::TableStructureTests::test_table_with_alias", + "pypika/tests/test_tables.py::TableStructureTests::test_table_with_schema_and_schema_parent_arg", + "pypika/tests/test_tables.py::TableStructureTests::test_table_with_schema_arg", + "pypika/tests/test_tables.py::TableEqualityTests::test_many_tables_with_alias", + "pypika/tests/test_tables.py::TableEqualityTests::test_many_tables_with_or_not_alias", + "pypika/tests/test_tables.py::TableEqualityTests::test_many_tables_without_alias", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_equal_by_name", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_equal_by_schema_and_name", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_equal_by_schema_and_name_using_schema", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_equal_by_schema_and_name_using_schema_with_parent", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_not_equal_by_schema_and_name_using_schema_with_different_parents", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_not_equal_with_different_names", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_not_equal_with_different_schemas", + "pypika/tests/test_tables.py::TableDialectTests::test_make_tables_factory_with_default_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_make_tables_factory_with_dialect_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_factory_with_default_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_factory_with_dialect_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_with_bad_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_with_default_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_with_dialect_query_cls", + "pypika/tests/test_terms.py::FieldAliasTests::test_when_alias_specified", + "pypika/tests/test_terms.py::FieldInitTests::test_init_with_str_table", + "pypika/tests/test_terms.py::FieldHashingTests::test_non_tabled_aliased_eq_fields_equally_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_non_tabled_aliased_ne_fields_differently_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_non_tabled_eq_fields_equally_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_non_tabled_ne_fields_differently_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_tabled_eq_fields_equally_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_tabled_ne_fields_differently_hashed", + "pypika/tests/test_terms.py::AtTimezoneTests::test_passes_kwargs_to_field_get_sql", + "pypika/tests/test_terms.py::AtTimezoneTests::test_when_alias_specified", + "pypika/tests/test_terms.py::AtTimezoneTests::test_when_interval_not_specified", + "pypika/tests/test_terms.py::AtTimezoneTests::test_when_interval_specified", + "pypika/tests/test_tuples.py::TupleTests::test_render_alias_in_array_sql", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_equality_tuple_on_both", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_equality_tuple_on_left", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_equality_tuple_on_right", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_in_using_mixed_tuples", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_in_using_pypika_tuples", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_in_using_python_tuples", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_is_aggregate", + "pypika/tests/test_tuples.py::TupleTests::test_tuples_in_join", + "pypika/tests/test_tuples.py::ArrayTests::test_array_general", + "pypika/tests/test_tuples.py::ArrayTests::test_empty_psql_array", + "pypika/tests/test_tuples.py::ArrayTests::test_psql_array_general", + "pypika/tests/test_tuples.py::ArrayTests::test_render_alias_in_array_sql", + "pypika/tests/test_tuples.py::BracketTests::test_arithmetic_with_brackets", + "pypika/tests/test_tuples.py::BracketTests::test_arithmetic_with_brackets_and_alias", + "pypika/tests/test_updates.py::UpdateTests::test_empty_query", + "pypika/tests/test_updates.py::UpdateTests::test_for_portion", + "pypika/tests/test_updates.py::UpdateTests::test_omit_where", + "pypika/tests/test_updates.py::UpdateTests::test_single_quote_escape_in_set", + "pypika/tests/test_updates.py::UpdateTests::test_update__table_schema", + "pypika/tests/test_updates.py::UpdateTests::test_update_from", + "pypika/tests/test_updates.py::UpdateTests::test_update_from_with_where", + "pypika/tests/test_updates.py::UpdateTests::test_update_with_join", + "pypika/tests/test_updates.py::UpdateTests::test_update_with_limit", + "pypika/tests/test_updates.py::UpdateTests::test_update_with_none", + "pypika/tests/test_updates.py::UpdateTests::test_update_with_statement", + "pypika/tests/test_updates.py::PostgresUpdateTests::test_update_returning", + "pypika/tests/test_updates.py::PostgresUpdateTests::test_update_returning_from_different_tables", + "pypika/tests/test_updates.py::PostgresUpdateTests::test_update_returning_star", + "pypika/tests/test_updates.py::PostgresUpdateTests::test_update_returning_str", + "pypika/tests/test_updates.py::SQLLiteUpdateTests::test_update_with_bool", + "pypika/tests/test_utils.py::ImmutabilityTests::test_raise_attribute_error_for_deepcopy", + "pypika/tests/test_utils.py::ImmutabilityTests::test_raise_attribute_error_for_getnewargs", + "pypika/tests/test_utils.py::ImmutabilityTests::test_raise_attribute_error_for_getstate", + "pypika/tests/test_utils.py::ImmutabilityTests::test_raise_attribute_error_for_setstate" + ] +} diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/grade.py b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/grade.py new file mode 100644 index 0000000000000000000000000000000000000000..e3b37293830e51a5c5833c93c4705e1ed9364257 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/grade.py @@ -0,0 +1,128 @@ +"""Trusted private pytest panel runner. Installed only in a fresh grader Job.""" + +import hashlib +import importlib.util +import json +import os +import shutil +import stat +import subprocess +from pathlib import Path, PurePosixPath + + +def sha(raw): + return hashlib.sha256(raw).hexdigest() + + +def safe(value): + path = PurePosixPath(value) + if ( + path.is_absolute() + or path.as_posix() != value + or not path.parts + or any(part in {".", "..", ".git"} for part in path.parts) + ): + raise ValueError("Unsafe trusted test path") + return path + + +def restore(worktree, private, manifest): + worktree, private = Path(worktree), Path(private) + captured = {} + for name, expected in manifest["files"].items(): + path = private / safe(name) + info = path.lstat() + raw = path.read_bytes() if stat.S_ISREG(info.st_mode) else b"" + if ( + not stat.S_ISREG(info.st_mode) + or len(raw) != expected["bytes"] + or sha(raw) != expected["sha256"] + or stat.S_IMODE(info.st_mode) != expected["mode"] + ): + raise ValueError("Trusted private test bytes or modes drifted") + captured[name] = (raw, expected["mode"]) + # Capture and verify every private byte before changing the submitted tree. + for name in manifest["directory_roots"]: + destination = worktree / safe(name) + if destination.is_symlink(): + raise ValueError("Submitted test directory is a symlink") + for parent in destination.parents: + if parent == worktree: + break + if parent.is_symlink(): + raise ValueError("Submitted test parent is a symlink") + if destination.exists(): + if not destination.is_dir(): + raise ValueError("Submitted test directory is not a directory") + shutil.rmtree(destination) + for name, (raw, mode) in captured.items(): + destination = worktree / safe(name) + for parent in destination.parents: + if parent == worktree: + break + if parent.is_symlink(): + raise ValueError("Submitted test parent is a symlink") + if destination.is_symlink(): + raise ValueError("Submitted trusted file is a symlink") + destination.parent.mkdir(parents=True, exist_ok=True) + destination.write_bytes(raw) + destination.chmod(mode) + + +def run(worktree, private_root, output, invoke=None): + private_root, output, worktree = Path(private_root), Path(output), Path(worktree) + expected = json.loads((private_root / "expected-panels.json").read_bytes()) + config = json.loads((private_root / "panel-config.json").read_bytes()) + manifest = json.loads((private_root / "trusted-inventory.json").read_bytes()) + restore(worktree, private_root / "trusted", manifest) + output.mkdir(parents=True, exist_ok=True) + for name in ( + "reward.txt", + "pass-to-pass.xml", + "fail-to-pass.xml", + "pytest-evidence.json", + ): + (output / name).unlink(missing_ok=True) + environment = dict(os.environ) + for key in ("PYTEST_ADDOPTS", "PYTEST_DISABLE_PLUGIN_AUTOLOAD", "PYTHONPATH"): + environment.pop(key, None) + commands, native_exit = [], 0 + invoke = invoke or subprocess.run + for group in ("pass-to-pass", "fail-to-pass"): + if ( + not isinstance(expected[group], list) + or not expected[group] + or any( + not isinstance(target, str) or not target for target in expected[group] + ) + ): + raise ValueError("Frozen native pytest selectors are incomplete") + command = [ + *config["official_pytest_argv"], + "--override-ini=addopts=", + "--junitxml=" + str(output / (group + ".xml")), + *expected[group], + ] + result = invoke(command, cwd=worktree, env=environment, check=False) + native_exit = result.returncode + commands.append({"group": group, "argv": command, "exit_code": native_exit}) + if native_exit != 0: + break + (output / "pytest-commands.json").write_text( + json.dumps(commands, sort_keys=True) + "\n" + ) + spec = importlib.util.spec_from_file_location( + "trusted_pytest_result", private_root / "check_pytest.py" + ) + checker = importlib.util.module_from_spec(spec) + spec.loader.exec_module(checker) + result = checker.assess(output, expected, native_exit) + (output / "reward.txt").write_text(str(result["reward"]) + "\n") + (output / "pytest-evidence.json").write_text( + json.dumps(result, sort_keys=True) + "\n" + ) + return result + + +if __name__ == "__main__": + run("/testbed/repo", "/tests", "/logs/verifier") diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/panel-config.json b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/panel-config.json new file mode 100644 index 0000000000000000000000000000000000000000..6417b9c92e5da5b97ee641bd54f798302af42a31 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/panel-config.json @@ -0,0 +1,28 @@ +{ + "dependency_installation_pinned": false, + "official_install_cmds": [ + "python -m pip install -e ." + ], + "official_pytest_argv": [ + "pytest", + "--disable-warnings", + "--color=no", + "--tb=no", + "--verbose" + ], + "official_test_command": "source /opt/miniconda3/bin/activate; conda activate testbed; pytest --disable-warnings --color=no --tb=no --verbose", + "operator_test_runner_prerequisites": [ + "python -m pip install pytest==8.4.2" + ], + "operator_test_runner_reason": "The official profile invokes pytest, but the common tools runtime does not provide it; pinned separately from source-native project requirements.", + "panel_normalization": "Override project addopts only to execute the exact frozen native panels; add JUnit output, preserve official pytest options and all selectors.", + "python_version": "3.10", + "source_bound_test_dependency_cmds": [ + "python -m pip install parameterized==0.7.0" + ], + "test_dependency_source_sha256": { + "requirements-dev.txt": "10f4ba7b19a73950d28fd7403d7e1d1b1fe2ccc4f49516974f47199d2965f23d", + "setup.py": "f8bad274588a22e65764d8cf9fb2be5aa6fcfaf3bf861d71e5f751105898845a", + "tox.ini": "c2d7205d0ac93e9c9e80dc5d24f0a826a6781f587a33ea722ea621f9e2ccd0ea" + } +} diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/test.sh b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..81b6d0620f05dbd3b54b4e7ea5de04ce3f8a98e2 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/test.sh @@ -0,0 +1,6 @@ +#!/bin/bash +set -Eeuo pipefail +source /opt/miniconda3/bin/activate +conda activate testbed +cd /testbed/repo +exec python -I /tests/grade.py diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted-inventory.json b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted-inventory.json new file mode 100644 index 0000000000000000000000000000000000000000..6926ef1c22ed56457101c37cd70e0fe0d1656f0c --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted-inventory.json @@ -0,0 +1,242 @@ +{ + "directory_roots": [ + "pypika/tests" + ], + "files": { + "pypika/tests/__init__.py": { + "bytes": 58, + "mode": 420, + "sha256": "7d41f44b87688bdf162e6d5cbe7b517cfba468f96eaa421f02718c17eb486a18" + }, + "pypika/tests/clickhouse/__init__.py": { + "bytes": 0, + "mode": 420, + "sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "pypika/tests/clickhouse/test_array.py": { + "bytes": 2942, + "mode": 420, + "sha256": "0f0a5b4c3daf3ddce2944b6119795e80d50b74e4687ef2e34399e5d21d3d48ae" + }, + "pypika/tests/clickhouse/test_condition.py": { + "bytes": 2533, + "mode": 420, + "sha256": "c666976d082b1d12cd57e791d1a525183246335efad96a369b58871a6f1e4fa1" + }, + "pypika/tests/clickhouse/test_dates_and_times.py": { + "bytes": 2508, + "mode": 420, + "sha256": "cb8ea84363e35ad0a00b52a8ec20cb38f2348f4cba28d026a4c32c14fd1fc56f" + }, + "pypika/tests/clickhouse/test_nullable_arg.py": { + "bytes": 672, + "mode": 420, + "sha256": "883c5161ebeb09544ce124d20a096d248bd12a0404ad77c84637be75d6738529" + }, + "pypika/tests/clickhouse/test_search_string.py": { + "bytes": 1189, + "mode": 420, + "sha256": "d5f0ed6a51cf550bdd4b261fa2e98084184dd1cbb08f5dbb8b91278b4c8f3bfd" + }, + "pypika/tests/clickhouse/test_type_conversion.py": { + "bytes": 4445, + "mode": 420, + "sha256": "7e6045b64433a8947346cfb34ac30279349f7a2e2081a2815212c8cb7d0235ab" + }, + "pypika/tests/dialects/__init__.py": { + "bytes": 0, + "mode": 420, + "sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "pypika/tests/dialects/test_clickhouse.py": { + "bytes": 5747, + "mode": 420, + "sha256": "2272538d6eeb6dfb01f9803eed328b4cd4efc8d255b6a8ab3c4e25bee74d73fa" + }, + "pypika/tests/dialects/test_mssql.py": { + "bytes": 3152, + "mode": 420, + "sha256": "0cd9b2ee6498caa9fa75a51ead30803057fb23deb2ac706d396d88329e0e91d7" + }, + "pypika/tests/dialects/test_mysql.py": { + "bytes": 2984, + "mode": 420, + "sha256": "a5f4550dd14bf4820e5d85cf06b6c7c79286e41d2d3c794f639579d20fffab92" + }, + "pypika/tests/dialects/test_oracle.py": { + "bytes": 1906, + "mode": 420, + "sha256": "67f80eb40cc9b4dabcbad355e8be6d83c54a64cbee809182ef57fa9f48d2ebc6" + }, + "pypika/tests/dialects/test_postgresql.py": { + "bytes": 9532, + "mode": 420, + "sha256": "548ee7267ca87c9e1ae82ca89a4e5bd96c7392a55cc07996f2b105f911ffa6cf" + }, + "pypika/tests/dialects/test_snowflake.py": { + "bytes": 2159, + "mode": 420, + "sha256": "e567b9dab0a5366bd11a0ef162c3a3bb492280b78bc4b397a23070563dc84468" + }, + "pypika/tests/dialects/test_sqllite.py": { + "bytes": 1243, + "mode": 420, + "sha256": "118fed7e575415f276bda390a119080bd6a767aee3d9c953e11a8c219f0f017c" + }, + "pypika/tests/dialects/test_vertica.py": { + "bytes": 3578, + "mode": 420, + "sha256": "33a027e6735ca03b7afd11394905c4193e48a15dda3efbe47cdcd85fcabf840c" + }, + "pypika/tests/test_aggregate.py": { + "bytes": 3946, + "mode": 420, + "sha256": "5b0fb549de3bb50ad88ae1d75824f12f7ab4a5f1102b06a70c7b2ebae33bea6d" + }, + "pypika/tests/test_analytic_queries.py": { + "bytes": 20611, + "mode": 420, + "sha256": "8546b7a296c8e212c349c4baff95f93934b3120f74625b3945ade3b438e3a3ed" + }, + "pypika/tests/test_create.py": { + "bytes": 9088, + "mode": 420, + "sha256": "6c57302da52ca1044be0afdafe677d5de245e44873dff1386c9a1ccb2625cc82" + }, + "pypika/tests/test_criterions.py": { + "bytes": 32014, + "mode": 420, + "sha256": "78539ccca82f9a02fad0f5a39041ac343e3a142ce52368cd4f6ada489c52516a" + }, + "pypika/tests/test_custom_functions.py": { + "bytes": 1710, + "mode": 420, + "sha256": "bfa18bc328a3577965db7cc75eb94439f0cfd95a3775d9b1cc8af1062bb202cb" + }, + "pypika/tests/test_data_types.py": { + "bytes": 403, + "mode": 420, + "sha256": "c1be6ecc621a80dd91d35b1427bdfc8b1b33bd926515198e626d6fb5e1878c8b" + }, + "pypika/tests/test_date_math.py": { + "bytes": 5544, + "mode": 420, + "sha256": "85aa54efe54fe19639f2dc2a5750647e3337ac2681768bc3fe327841f1634d9e" + }, + "pypika/tests/test_deletes.py": { + "bytes": 3204, + "mode": 420, + "sha256": "ccde6df760d76d5d499ce828f6b0e2ad3eebcb2a5553c1890f481b9160b8d51a" + }, + "pypika/tests/test_drop.py": { + "bytes": 1556, + "mode": 420, + "sha256": "a13dffa59ef8657398d5498c18977bfd702635e336ea9966b1a86137afca7926" + }, + "pypika/tests/test_formats.py": { + "bytes": 1948, + "mode": 420, + "sha256": "240458a404bb119322778893b94a12be0f98f914acd701d2b4be73eb9be96f75" + }, + "pypika/tests/test_functions.py": { + "bytes": 32769, + "mode": 420, + "sha256": "3ceaac7791bd27e50f44e1b4a1451d1e09afe6a8011052caea838e5124582154" + }, + "pypika/tests/test_groupby_modifiers.py": { + "bytes": 5227, + "mode": 420, + "sha256": "9db4497660f08e3352a9a02c34889ad1cd6bab3aebaeaa485e84390ad71c84c5" + }, + "pypika/tests/test_immutability.py": { + "bytes": 3954, + "mode": 420, + "sha256": "af537ced19f7274951cc91697eae748ef6c9cd20a8d8e492d93dc85b06f8fb50" + }, + "pypika/tests/test_inserts.py": { + "bytes": 32549, + "mode": 420, + "sha256": "652e9f7f0f425e9acc0f70e2851ae29310b378262ea30369ea0113ef428f210f" + }, + "pypika/tests/test_internals.py": { + "bytes": 828, + "mode": 420, + "sha256": "4374c2632563346d00ca4de6af397a022ef3f5022e808c8711a3f207a3a21609" + }, + "pypika/tests/test_joins.py": { + "bytes": 43895, + "mode": 420, + "sha256": "53f224815c10393382443f020cb20e313420764495a8fd30f7ea2f34fd52935d" + }, + "pypika/tests/test_negation.py": { + "bytes": 763, + "mode": 420, + "sha256": "6be105e8f39b32fb23e6ac7c7158232ee78111455d4f35638c8af60781138c79" + }, + "pypika/tests/test_parameter.py": { + "bytes": 7382, + "mode": 420, + "sha256": "aaf2a3e79c8267bdc60e218445bc2a2254b97cf37b643a44d6f1a8141cbb5104" + }, + "pypika/tests/test_pseudocolumns.py": { + "bytes": 1609, + "mode": 420, + "sha256": "b7c69f7aca41323c0e14a6a9e58697399cd7860610f07291afc6e8af26079ca2" + }, + "pypika/tests/test_query.py": { + "bytes": 9025, + "mode": 420, + "sha256": "2da9d717673912a84e86e6c0d3955dbd8f2fa7b41b7ed9a6f78089dfa28f9444" + }, + "pypika/tests/test_selects.py": { + "bytes": 50757, + "mode": 420, + "sha256": "5ac1b7ad3248d64b1e3865a72c763873514ae5cd6e03356b913e531c0c336986" + }, + "pypika/tests/test_tables.py": { + "bytes": 6568, + "mode": 420, + "sha256": "384c8e843ba56374ee92cd7b7e2fd3f89247b899e23cd9e1f6663d751ad5d884" + }, + "pypika/tests/test_terms.py": { + "bytes": 3215, + "mode": 420, + "sha256": "8598513180ddcd28cc61582618d85bd570280978b07603044dae81b2eb099f77" + }, + "pypika/tests/test_tuples.py": { + "bytes": 6033, + "mode": 420, + "sha256": "863942196a93e8939be0d03c49cfeb42a35503ad42f9f3d6c730260112811087" + }, + "pypika/tests/test_updates.py": { + "bytes": 5689, + "mode": 420, + "sha256": "0f0f2521bb8d1f5d782f8fabaea5fd1d82090cde045ba87fad65770db6c75d2f" + }, + "pypika/tests/test_utils.py": { + "bytes": 834, + "mode": 420, + "sha256": "5db6e90df5daaa70b9f35f1243db69908da1f27887f63466fc27ce20c7e14892" + }, + "pyproject.toml": { + "bytes": 390, + "mode": 420, + "sha256": "037fedacd5be5d078f398265ff97e1677e25214ad8839d17073a439695ee7a91" + }, + "setup.cfg": { + "bytes": 317, + "mode": 420, + "sha256": "c84a31de586e8385e741127b004fc1f19ebae6463cdf0b3f243991db35cdeaea" + }, + "setup.py": { + "bytes": 2638, + "mode": 420, + "sha256": "f8bad274588a22e65764d8cf9fb2be5aa6fcfaf3bf861d71e5f751105898845a" + }, + "tox.ini": { + "bytes": 257, + "mode": 420, + "sha256": "c2d7205d0ac93e9c9e80dc5d24f0a826a6781f587a33ea722ea621f9e2ccd0ea" + } + } +} diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/__init__.py b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..86d8a68101915c27b95484243dd81d55f7dba356 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/__init__.py @@ -0,0 +1,2 @@ +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/clickhouse/__init__.py b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/clickhouse/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/clickhouse/test_array.py b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/clickhouse/test_array.py new file mode 100644 index 0000000000000000000000000000000000000000..469705a9ff3c8fe9cc7f02c44a9812521eeb67f4 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/clickhouse/test_array.py @@ -0,0 +1,104 @@ +import unittest + +from parameterized import parameterized + +from pypika import Field +from pypika.clickhouse.array import ( + Array, + Empty, + HasAny, + Length, + NotEmpty, +) +from pypika.clickhouse.type_conversion import ( + ToFixedString, + ToInt64, +) + + +class TestArray(unittest.TestCase): + @parameterized.expand( + [ + ( + "['ridley', 'scott', 'jimi', 'hendrix']", + Array(["ridley", "scott", "jimi", "hendrix"]), + ), + ( + "[1, 2, 3, 4]", + Array([1, 2, 3, 4]), + ), + ( + "[toInt64('1'),toInt64('2'),toInt64('3'),toInt64('4')]", + Array(["1", "2", "3", "4"], ToInt64), + ), + ( + "[toFixedString('mogwai',10),toFixedString('mono',10),toFixedString('bonobo',10)] arr", + Array(["mogwai", "mono", "bonobo"], ToFixedString, {"length": 10}).as_('arr'), + ), + ] + ) + def test_get_sql(self, expected: str, array: Array): + self.assertEqual(expected, array.get_sql()) + + +class TestHasAny(unittest.TestCase): + @parameterized.expand( + [ + ( + 'hasAny("mental_abilities","physical_abilities")', + HasAny(Field("mental_abilities"), Field("physical_abilities")), + ), + ("hasAny([1, 2, 3, 4],[3])", HasAny(Array([1, 2, 3, 4]), Array([3]))), + ( + "hasAny(\"bands\",[toFixedString('port-royal',20),toFixedString('hammock',20)])", + HasAny( + Field("bands"), + Array(["port-royal", "hammock"], ToFixedString, {"length": 20}), + ), + ), + ] + ) + def test_get_sql(self, expected: str, func: HasAny): + self.assertEqual(expected, func.get_sql()) + + +class TestLength(unittest.TestCase): + @parameterized.expand( + [ + ( + 'length("tags")', + Length(Field("tags")), + ), + ("length([1, 2, 3])", Length(Array([1, 2, 3]))), + ] + ) + def test_get_sql(self, expected: str, func: Length): + self.assertEqual(expected, func.get_sql()) + + +class TestEmpty(unittest.TestCase): + @parameterized.expand( + [ + ( + 'empty("tags")', + Empty(Field("tags")), + ), + ("empty([1, 2, 3])", Empty(Array([1, 2, 3]))), + ] + ) + def test_get_sql(self, expected: str, func: Empty): + self.assertEqual(expected, func.get_sql()) + + +class TestNotEmpty(unittest.TestCase): + @parameterized.expand( + [ + ( + 'notEmpty("tags")', + NotEmpty(Field("tags")), + ), + ("notEmpty([1, 2, 3])", NotEmpty(Array([1, 2, 3]))), + ] + ) + def test_get_sql(self, expected: str, func: NotEmpty): + self.assertEqual(expected, func.get_sql()) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/clickhouse/test_condition.py b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/clickhouse/test_condition.py new file mode 100644 index 0000000000000000000000000000000000000000..145baeb7753dd9cbefbd6f272bd672ae5730b0c0 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/clickhouse/test_condition.py @@ -0,0 +1,72 @@ +import unittest + +from parameterized import parameterized + +from pypika import Field +from pypika.clickhouse.condition import If, MultiIf +from pypika.clickhouse.type_conversion import ToFixedString + + +class TestIfCondition(unittest.TestCase): + @parameterized.expand( + [ + ( + If( + Field("filmmaker").isnull(), + ToFixedString("Tarantino", 20), + Field("filmmaker"), + ), + "if(filmmaker IS NULL,toFixedString('Tarantino',20),filmmaker)", + ), + ( + If( + Field("created") == Field("updated"), + ToFixedString("yes", 3), + ToFixedString("no", 3), + ), + "if(created=updated,toFixedString('yes',3),toFixedString('no',3))", + ), + ] + ) + def test_get_sql(self, func, expected): + self.assertEqual(func.get_sql(), expected) + + +class TestMultiIfCondition(unittest.TestCase): + @parameterized.expand( + [ + ( + MultiIf( + Field("filmmaker").isnull(), + ToFixedString("Tarantino", 20), + Field("filmmaker") == ToFixedString("undefined", 20), + ToFixedString("Tarantino", 20), + Field("filmmaker"), + ), + "multiIf(filmmaker IS NULL," + "toFixedString('Tarantino',20)," + "filmmaker=toFixedString('undefined',20)," + "toFixedString('Tarantino',20),filmmaker)", + ), + ( + MultiIf( + Field("color") == ToFixedString("black", 20), + ToFixedString("dark", 20), + Field("color") == ToFixedString("grey", 20), + ToFixedString("dark", 20), + Field("color") == ToFixedString("white", 20), + ToFixedString("light", 20), + ToFixedString("undefined", 20), + ), + "multiIf(color=toFixedString('black',20)," + "toFixedString('dark',20)," + "color=toFixedString('grey',20)," + "toFixedString('dark',20)," + "color=toFixedString('white',20)," + "toFixedString('light',20)," + "toFixedString('undefined',20))", + ), + ] + ) + def test_get_sql(self, func, expected): + self.assertEqual(func.get_sql(), expected) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/clickhouse/test_dates_and_times.py b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/clickhouse/test_dates_and_times.py new file mode 100644 index 0000000000000000000000000000000000000000..135dd7f112131776d76748e15eead1eb81752b59 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/clickhouse/test_dates_and_times.py @@ -0,0 +1,70 @@ +import unittest + +from parameterized import parameterized + +from pypika import Field +from pypika.clickhouse.dates_and_times import ( + AddDays, + AddHours, + AddMinutes, + AddMonths, + AddQuarters, + AddSeconds, + AddWeeks, + AddYears, + FormatDateTime, + SubtractDays, + SubtractHours, + SubtractMinutes, + SubtractMonths, + SubtractQuarters, + SubtractSeconds, + SubtractWeeks, + SubtractYears, + ToYYYYMM, +) + + +class TestFormatDateTime(unittest.TestCase): + @parameterized.expand( + [ + (FormatDateTime(Field("created"), "%V"), "formatDateTime(created,'%V')"), + ( + FormatDateTime(Field("created"), "%Y-%m-%d"), + "formatDateTime(created,'%Y-%m-%d')", + ), + ] + ) + def test_get_sql(self, func, expected): + self.assertEqual(func.get_sql(), expected) + + +class TestAddSubtractDt(unittest.TestCase): + @parameterized.expand( + [ + (AddYears(Field("created"), 1), "addYears(created,1)"), + (AddMonths(Field("created"), 2), "addMonths(created,2)"), + (AddWeeks(Field("created"), 3), "addWeeks(created,3)"), + (AddDays(Field("created"), 4), "addDays(created,4)"), + (AddHours(Field("created"), 5), "addHours(created,5)"), + (AddMinutes(Field("created"), 6), "addMinutes(created,6)"), + (AddSeconds(Field("created"), 7), "addSeconds(created,7)"), + (AddQuarters(Field("created"), 8), "addQuarters(created,8)"), + (SubtractYears(Field("created"), 9), "subtractYears(created,9)"), + (SubtractMonths(Field("created"), 10), "subtractMonths(created,10)"), + (SubtractWeeks(Field("created"), 11), "subtractWeeks(created,11)"), + (SubtractDays(Field("created"), 12), "subtractDays(created,12)"), + (SubtractHours(Field("created"), 13), "subtractHours(created,13)"), + (SubtractHours(Field("created"), 13), "subtractHours(created,13)"), + (SubtractMinutes(Field("created"), 14), "subtractMinutes(created,14)"), + (SubtractSeconds(Field("created"), 15), "subtractSeconds(created,15)"), + (SubtractQuarters(Field("created"), 16), "subtractQuarters(created,16)"), + ] + ) + def test_get_sql(self, func, expected): + self.assertEqual(func.get_sql(), expected) + + +class TestToYYYYMM(unittest.TestCase): + def test_get_sql(self): + self.assertEqual(ToYYYYMM(Field("created").get_sql()), "toYYYYMM(created)") diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/clickhouse/test_nullable_arg.py b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/clickhouse/test_nullable_arg.py new file mode 100644 index 0000000000000000000000000000000000000000..3c6c86207a4d0206b5c0ba80b77fac4cc257fa17 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/clickhouse/test_nullable_arg.py @@ -0,0 +1,24 @@ +import unittest + +from parameterized import parameterized + +from pypika import Field +from pypika.clickhouse.nullable_arg import IfNull +from pypika.clickhouse.type_conversion import ToFixedString + + +class TestSearchString(unittest.TestCase): + @parameterized.expand( + [ + ( + IfNull(Field("name"), Field("login")), + "ifNull(name,login)", + ), + ( + IfNull(Field("builder"), ToFixedString("pypika", 100)), + "ifNull(builder,toFixedString('pypika',100))", + ), + ] + ) + def test_get_sql(self, func, expected): + self.assertEqual(func.get_sql(), expected) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/clickhouse/test_search_string.py b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/clickhouse/test_search_string.py new file mode 100644 index 0000000000000000000000000000000000000000..9778eb32e47d4370c0bfe36dcd875903666d30b6 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/clickhouse/test_search_string.py @@ -0,0 +1,41 @@ +import unittest + +from parameterized import parameterized + +from pypika import Field +from pypika.clickhouse.search_string import ( + Match, + Like, + NotLike, + MultiSearchAny, + MultiMatchAny, +) + + +class TestSearchString(unittest.TestCase): + @parameterized.expand( + [ + (Match(Field("name"), "twheys"), "match(toString(\"name\"),'twheys')"), + (Like(Field("name"), "twheys"), "like(toString(\"name\"),'twheys')"), + (NotLike(Field("name"), "twheys"), "notLike(toString(\"name\"),'twheys')"), + ] + ) + def test_search_string(self, func, expected): + self.assertEqual(func, expected) + + +class TestMultiSearch(unittest.TestCase): + @parameterized.expand( + [ + ( + MultiSearchAny(Field("name"), ["sarah", "connor"]), + "multiSearchAny(toString(\"name\"),['sarah','connor'])", + ), + ( + MultiMatchAny(Field("name"), ["sarah", "connor"]), + "multiMatchAny(toString(\"name\"),['sarah','connor'])", + ), + ] + ) + def test_multi_search_string(self, func, expected): + self.assertEqual(func.get_sql(), expected) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/clickhouse/test_type_conversion.py b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/clickhouse/test_type_conversion.py new file mode 100644 index 0000000000000000000000000000000000000000..9692e17bee901e2629db9a5c77111e145358e8eb --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/clickhouse/test_type_conversion.py @@ -0,0 +1,176 @@ +import unittest + +from parameterized import parameterized + +from pypika import ClickHouseQuery, Field, Table +from pypika.clickhouse.type_conversion import ( + ToDate, + ToDateTime, + ToFixedString, + ToFloat32, + ToFloat64, + ToInt16, + ToInt32, + ToInt64, + ToInt8, + ToString, + ToUInt16, + ToUInt32, + ToUInt64, + ToUInt8, +) + + +class TestBasicTypeConverters(unittest.TestCase): + @parameterized.expand( + [ + ( + 'toString("field_name")', + ToString(Field("field_name")), + ), + ( + 'toInt8("field_name")', + ToInt8(Field("field_name")), + ), + ( + 'toInt16("field_name")', + ToInt16(Field("field_name")), + ), + ( + 'toInt32("field_name")', + ToInt32(Field("field_name")), + ), + ( + 'toInt64("field_name")', + ToInt64(Field("field_name")), + ), + ( + 'toUInt8("field_name")', + ToUInt8(Field("field_name")), + ), + ( + 'toUInt16("field_name")', + ToUInt16(Field("field_name")), + ), + ( + 'toUInt32("field_name")', + ToUInt32(Field("field_name")), + ), + ( + 'toUInt64("field_name")', + ToUInt64(Field("field_name")), + ), + ( + 'toFloat32("field_name")', + ToFloat32(Field("field_name")), + ), + ( + 'toFloat64("field_name")', + ToFloat64(Field("field_name")), + ), + ( + 'toFloat64("field_name")', + ToFloat64(Field("field_name")), + ), + ( + 'toDate("field_name")', + ToDate(Field("field_name")), + ), + ( + 'toDateTime("field_name")', + ToDateTime(Field("field_name")), + ), + ( + 'toFixedString("field_name",100)', + ToFixedString(Field("field_name"), 100), + ), + ] + ) + def test_basic_types_field(self, expected, func): + self.assertEqual(func, expected) + + @parameterized.expand( + [ + ( + "toString('100')", + ToString("100"), + ), + ( + "toInt8('100')", + ToInt8("100"), + ), + ( + "toInt16('100')", + ToInt16("100"), + ), + ( + "toInt32('100')", + ToInt32("100"), + ), + ( + "toInt64('100')", + ToInt64("100"), + ), + ( + "toUInt8('100')", + ToUInt8("100"), + ), + ( + "toUInt16('100')", + ToUInt16("100"), + ), + ( + "toUInt32('100')", + ToUInt32("100"), + ), + ( + "toUInt64('100')", + ToUInt64("100"), + ), + ( + "toFloat32('100')", + ToFloat32("100"), + ), + ( + "toFloat64('100')", + ToFloat64("100"), + ), + ( + "toFloat64('100')", + ToFloat64("100"), + ), + ( + "toDate('100')", + ToDate("100"), + ), + ( + "toDateTime('100')", + ToDateTime("100"), + ), + ( + "toFixedString('100',100)", + ToFixedString("100", 100), + ), + ] + ) + def test_basic_types_value(self, expected, func): + self.assertEqual(func, expected) + + +class TestToFixedString(unittest.TestCase): + def test_get_sql_with_table(self): + table = Table("example") + query = ( + ClickHouseQuery.from_(table) + .select( + table.name, + ) + .where( + table.name == ToFixedString("name", 50), + ) + ) + + self.assertEqual( + 'SELECT "name" FROM "example" WHERE "name"=toFixedString(\'name\',50)', + query.get_sql(), + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/dialects/__init__.py b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/dialects/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/dialects/test_clickhouse.py b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/dialects/test_clickhouse.py new file mode 100644 index 0000000000000000000000000000000000000000..f319c4627bd25d7004894181906a284b8b1c64cf --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/dialects/test_clickhouse.py @@ -0,0 +1,146 @@ +from unittest import TestCase + +from pypika import ( + ClickHouseQuery, + Database, + Table, +) + + +class ClickHouseQueryTests(TestCase): + def test_use_AS_keyword_for_alias(self): + t = Table('abc') + query = ClickHouseQuery.from_(t).select(t.foo.as_('f1'), t.bar.as_('f2')) + self.assertEqual(str(query), 'SELECT "foo" AS "f1","bar" AS "f2" FROM "abc"') + + def test_use_SAMPLE_keyword(self): + t = Table('abc') + query = ClickHouseQuery.from_(t).select(t.foo).sample(10) + self.assertEqual(str(query), 'SELECT "foo" FROM "abc" SAMPLE 10') + + def test_use_SAMPLE_with_offset_keyword(self): + t = Table('abc') + query = ClickHouseQuery.from_(t).select(t.foo).sample(10, 5) + self.assertEqual(str(query), 'SELECT "foo" FROM "abc" SAMPLE 10 OFFSET 5') + + def test_use_FINAL_keyword(self): + t = Table('abc') + query = ClickHouseQuery.from_(t).select(t.foo).final() + self.assertEqual(str(query), 'SELECT "foo" FROM "abc" FINAL') + + +class ClickHouseDeleteTests(TestCase): + table_abc = Table("abc") + + def test_omit_where(self): + q = ClickHouseQuery.from_("abc").delete() + + self.assertEqual('ALTER TABLE "abc" DELETE', str(q)) + + def test_omit_where__table_schema(self): + q = ClickHouseQuery.from_(Table("abc", "schema1")).delete() + + self.assertEqual('ALTER TABLE "schema1"."abc" DELETE', str(q)) + + def test_where_field_equals(self): + q1 = ClickHouseQuery.from_(self.table_abc).where(self.table_abc.foo == self.table_abc.bar).delete() + q2 = ClickHouseQuery.from_(self.table_abc).where(self.table_abc.foo.eq(self.table_abc.bar)).delete() + + self.assertEqual('ALTER TABLE "abc" DELETE WHERE "foo"="bar"', str(q1)) + self.assertEqual('ALTER TABLE "abc" DELETE WHERE "foo"="bar"', str(q2)) + + +class ClickHouseUpdateTests(TestCase): + table_abc = Table("abc") + + def test_update(self): + q = ClickHouseQuery.update(self.table_abc).where(self.table_abc.foo == 0).set("foo", "bar") + + self.assertEqual('ALTER TABLE "abc" UPDATE "foo"=\'bar\' WHERE "foo"=0', str(q)) + + +class ClickHouseDropQuery(TestCase): + table_abc = Table("abc") + database_xyz = Database("mydb") + cluster_name = "mycluster" + + def test_drop_database(self): + q1 = ClickHouseQuery.drop_database(self.database_xyz) + q2 = ClickHouseQuery.drop_database(self.database_xyz).on_cluster(self.cluster_name) + q3 = ClickHouseQuery.drop_database(self.database_xyz).if_exists().on_cluster(self.cluster_name) + + self.assertEqual('DROP DATABASE "mydb"', str(q1)) + self.assertEqual('DROP DATABASE "mydb" ON CLUSTER "mycluster"', str(q2)) + self.assertEqual('DROP DATABASE IF EXISTS "mydb" ON CLUSTER "mycluster"', str(q3)) + + def test_drop_table(self): + q1 = ClickHouseQuery.drop_table(self.table_abc) + q2 = ClickHouseQuery.drop_table(self.table_abc).on_cluster(self.cluster_name) + q3 = ClickHouseQuery.drop_table(self.table_abc).if_exists().on_cluster(self.cluster_name) + + self.assertEqual('DROP TABLE "abc"', str(q1)) + self.assertEqual('DROP TABLE "abc" ON CLUSTER "mycluster"', str(q2)) + self.assertEqual('DROP TABLE IF EXISTS "abc" ON CLUSTER "mycluster"', str(q3)) + + def test_drop_dictionary(self): + q1 = ClickHouseQuery.drop_dictionary("dict") + q2 = ClickHouseQuery.drop_dictionary("dict").on_cluster(self.cluster_name) + q3 = ClickHouseQuery.drop_dictionary("dict").if_exists().on_cluster(self.cluster_name) + + self.assertEqual('DROP DICTIONARY "dict"', str(q1)) + self.assertEqual('DROP DICTIONARY "dict"', str(q2)) # NO CLUSTER + self.assertEqual('DROP DICTIONARY IF EXISTS "dict"', str(q3)) # NO CLUSTER + + def test_drop_other(self): + q1 = ClickHouseQuery.drop_quota("myquota") + q2 = ClickHouseQuery.drop_user("myuser") + q3 = ClickHouseQuery.drop_view("myview") + + self.assertEqual('DROP QUOTA "myquota"', str(q1)) + self.assertEqual('DROP USER "myuser"', str(q2)) + self.assertEqual('DROP VIEW "myview"', str(q3)) + + +class DistinctOnTests(TestCase): + table_abc = Table("abc") + + def test_distinct_on(self): + q = ClickHouseQuery.from_(self.table_abc).distinct_on("lname", self.table_abc.fname).select("lname", "id") + + self.assertEqual('''SELECT DISTINCT ON("lname","fname") "lname","id" FROM "abc"''', str(q)) + + +class LimitByTests(TestCase): + table_abc = Table("abc") + + def test_limit_by(self): + q = ClickHouseQuery.from_(self.table_abc).limit_by(1, "a", self.table_abc.b).select("a", "b", "c") + + self.assertEqual('''SELECT "a","b","c" FROM "abc" LIMIT 1 BY ("a","b")''', str(q)) + + def test_limit_offset_by(self): + q = ClickHouseQuery.from_(self.table_abc).limit_offset_by(1, 2, "a", self.table_abc.b).select("a", "b", "c") + + self.assertEqual('''SELECT "a","b","c" FROM "abc" LIMIT 1 OFFSET 2 BY ("a","b")''', str(q)) + + def test_limit_offset0_by(self): + q = ClickHouseQuery.from_(self.table_abc).limit_offset_by(1, 0, "a", self.table_abc.b).select("a", "b", "c") + + self.assertEqual('''SELECT "a","b","c" FROM "abc" LIMIT 1 BY ("a","b")''', str(q)) + + def test_rename_table(self): + table_join = Table("join") + + q = ( + ClickHouseQuery.from_(self.table_abc) + .join(table_join) + .using("a") + .limit_by(1, self.table_abc.a, table_join.a) + .select(self.table_abc.b, table_join.b) + ) + q = q.replace_table(self.table_abc, Table("xyz")) + + self.assertEqual( + '''SELECT "xyz"."b","join"."b" FROM "xyz" JOIN "join" USING ("a") LIMIT 1 BY ("xyz"."a","join"."a")''', + str(q), + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/dialects/test_mssql.py b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/dialects/test_mssql.py new file mode 100644 index 0000000000000000000000000000000000000000..7cf53b228f413a8c7cd3e414fef5522a82f99b29 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/dialects/test_mssql.py @@ -0,0 +1,81 @@ +import unittest + +from pypika import Table +from pypika.analytics import Count +from pypika.dialects import MSSQLQuery +from pypika.utils import QueryException + + +class SelectTests(unittest.TestCase): + def test_normal_select(self): + q = MSSQLQuery.from_("abc").select("def") + + self.assertEqual('SELECT "def" FROM "abc"', str(q)) + + def test_distinct_select(self): + q = MSSQLQuery.from_("abc").select("def").distinct() + + self.assertEqual('SELECT DISTINCT "def" FROM "abc"', str(q)) + + def test_top_distinct_select(self): + q = MSSQLQuery.from_("abc").select("def").top(10).distinct() + + self.assertEqual('SELECT DISTINCT TOP (10) "def" FROM "abc"', str(q)) + + def test_top_select(self): + q = MSSQLQuery.from_("abc").select("def").top(10) + + self.assertEqual('SELECT TOP (10) "def" FROM "abc"', str(q)) + + def test_top_with_ties_select(self): + q = MSSQLQuery.from_("abc").select("def").top(10, with_ties=True) + + self.assertEqual('SELECT TOP (10) WITH TIES "def" FROM "abc"', str(q)) + + def test_top_percent_select(self): + q = MSSQLQuery.from_("abc").select("def").top(10, percent=True) + + self.assertEqual('SELECT TOP (10) PERCENT "def" FROM "abc"', str(q)) + + def test_top_percent_invalid_range(self): + for invalid_top in [-1, 101]: + with self.assertRaisesRegex( + QueryException, "TOP value must be between 0 and 100 when `percent` is specified" + ): + MSSQLQuery.from_("abc").select("def").top(invalid_top, percent=True) + + def test_top_select_non_int(self): + with self.assertRaisesRegex(QueryException, "TOP value must be an integer"): + MSSQLQuery.from_("abc").select("def").top("a") + + def test_limit(self): + q = MSSQLQuery.from_("abc").select("def").orderby("def").limit(10) + + self.assertEqual('SELECT "def" FROM "abc" ORDER BY "def" OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY', str(q)) + + def test_offset(self): + q = MSSQLQuery.from_("abc").select("def").orderby("def").offset(10) + + self.assertEqual('SELECT "def" FROM "abc" ORDER BY "def" OFFSET 10 ROWS', str(q)) + + def test_limit_with_offset(self): + q = MSSQLQuery.from_("abc").select("def").orderby("def").limit(10).offset(10) + + self.assertEqual('SELECT "def" FROM "abc" ORDER BY "def" OFFSET 10 ROWS FETCH NEXT 10 ROWS ONLY', str(q)) + + def test_groupby_alias_False_does_not_group_by_alias_with_standard_query(self): + t = Table('table1') + col = t.abc.as_('a') + q = MSSQLQuery.from_(t).select(col, Count('*')).groupby(col) + + self.assertEqual('SELECT "abc" "a",COUNT(\'*\') FROM "table1" GROUP BY "abc"', str(q)) + + def test_groupby_alias_False_does_not_group_by_alias_when_subqueries_are_present(self): + t = Table('table1') + subquery = MSSQLQuery.from_(t).select(t.abc) + col = subquery.abc.as_('a') + q = MSSQLQuery.from_(subquery).select(col, Count('*')).groupby(col) + + self.assertEqual( + 'SELECT "sq0"."abc" "a",COUNT(\'*\') FROM (SELECT "abc" FROM "table1") "sq0" GROUP BY "sq0"."abc"', str(q) + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/dialects/test_mysql.py b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/dialects/test_mysql.py new file mode 100644 index 0000000000000000000000000000000000000000..619d064adcdf8b5ff9ecd054fa4ab00eff1d69b3 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/dialects/test_mysql.py @@ -0,0 +1,91 @@ +import unittest + +from pypika import MySQLQuery, QueryException, Table, Column + + +class SelectTests(unittest.TestCase): + table_abc = Table("abc") + + def test_normal_select(self): + q = MySQLQuery.from_("abc").select("def") + + self.assertEqual("SELECT `def` FROM `abc`", str(q)) + + def test_distinct_select(self): + q = MySQLQuery.from_("abc").select("def").distinct() + + self.assertEqual("SELECT DISTINCT `def` FROM `abc`", str(q)) + + def test_modifier_select(self): + q = MySQLQuery.from_("abc").select("def").select("ghi").modifier("SQL_CALC_FOUND_ROWS") + + self.assertEqual("SELECT SQL_CALC_FOUND_ROWS `def`,`ghi` FROM `abc`", str(q)) + + def test_multiple_modifier_select(self): + q = MySQLQuery.from_("abc").select("def").modifier("HIGH_PRIORITY").modifier("SQL_CALC_FOUND_ROWS") + + self.assertEqual("SELECT HIGH_PRIORITY SQL_CALC_FOUND_ROWS `def` FROM `abc`", str(q)) + + +class UpdateTests(unittest.TestCase): + table_abc = Table("abc") + + def test_update(self): + q = MySQLQuery.into("abc").insert(1, [1, "a", True]) + + self.assertEqual("INSERT INTO `abc` VALUES (1,[1,'a',true])", str(q)) + + def test_on_duplicate_key_ignore_update(self): + q = MySQLQuery.into("abc").insert(1, [1, "a", True]).on_duplicate_key_ignore() + + self.assertEqual("INSERT INTO `abc` VALUES (1,[1,'a',true]) ON DUPLICATE KEY IGNORE", str(q)) + + def test_on_duplicate_key_update_update(self): + q = MySQLQuery.into("abc").insert(1, [1, "a", True]).on_duplicate_key_update(self.table_abc.a, 'b') + + self.assertEqual("INSERT INTO `abc` VALUES (1,[1,'a',true]) ON DUPLICATE KEY UPDATE `a`='b'", str(q)) + + def test_conflict_handlers_update(self): + with self.assertRaises(QueryException): + ( + MySQLQuery.into("abc") + .insert(1, [1, "a", True]) + .on_duplicate_key_ignore() + .on_duplicate_key_update(self.table_abc.a, 'b') + ) + + +class LoadCSVTests(unittest.TestCase): + table_abc = Table("abc") + + def test_load_from_file(self): + q1 = MySQLQuery.load("/path/to/file").into("abc") + + q2 = MySQLQuery.load("/path/to/file").into(self.table_abc) + + self.assertEqual( + "LOAD DATA LOCAL INFILE '/path/to/file' INTO TABLE `abc` FIELDS TERMINATED BY ','", + str(q1), + ) + self.assertEqual( + "LOAD DATA LOCAL INFILE '/path/to/file' INTO TABLE `abc` FIELDS TERMINATED BY ','", + str(q2), + ) + + +class TableTests(unittest.TestCase): + table_abc = Table("abc") + + def test_create_table(self): + q = MySQLQuery.create_table(self.table_abc).columns(Column("id", "INT")) + self.assertEqual( + 'CREATE TABLE `abc` (`id` INT)', + str(q), + ) + + def test_drop_table(self): + q = MySQLQuery.drop_table(self.table_abc) + self.assertEqual( + 'DROP TABLE `abc`', + str(q), + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/dialects/test_oracle.py b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/dialects/test_oracle.py new file mode 100644 index 0000000000000000000000000000000000000000..21b54f16fd5d3518b5c767d3605068637898a73f --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/dialects/test_oracle.py @@ -0,0 +1,51 @@ +import unittest + +from pypika import OracleQuery, Table +from pypika.analytics import Count + + +class SelectTests(unittest.TestCase): + def test_groupby_alias_False_does_not_group_by_alias_with_standard_query(self): + t = Table('table1') + col = t.abc.as_('a') + q = OracleQuery.from_(t).select(col, Count('*')).groupby(col) + + self.assertEqual('SELECT abc a,COUNT(\'*\') FROM table1 GROUP BY abc', str(q)) + + def test_groupby_alias_False_does_not_group_by_alias_when_subqueries_are_present(self): + t = Table('table1') + subquery = OracleQuery.from_(t).select(t.abc) + col = subquery.abc.as_('a') + q = OracleQuery.from_(subquery).select(col, Count('*')).groupby(col) + + self.assertEqual('SELECT sq0.abc a,COUNT(\'*\') FROM (SELECT abc FROM table1) sq0 GROUP BY sq0.abc', str(q)) + + def test_limit_query(self): + t = Table('table1') + limit = 5 + q = OracleQuery.from_(t).select(t.test).limit(limit) + + self.assertEqual(f'SELECT test FROM table1 FETCH NEXT {limit} ROWS ONLY', str(q)) + + def test_offset_query(self): + t = Table('table1') + offset = 5 + q = OracleQuery.from_(t).select(t.test).offset(offset) + + self.assertEqual(f'SELECT test FROM table1 OFFSET {offset} ROWS', str(q)) + + def test_limit_offset_query(self): + t = Table('table1') + limit = 5 + offset = 5 + q = OracleQuery.from_(t).select(t.test).limit(limit).offset(offset) + + self.assertEqual(f'SELECT test FROM table1 OFFSET {offset} ROWS FETCH NEXT {limit} ROWS ONLY', str(q)) + + def test_fetch_next_method_deprecated(self): + with self.assertWarns(DeprecationWarning): + t = Table('table1') + limit = 5 + q = OracleQuery.from_(t).select(t.test).fetch_next(limit) + + self.assertEqual(f'SELECT test FROM table1 FETCH NEXT {limit} ROWS ONLY', str(q)) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/dialects/test_postgresql.py b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/dialects/test_postgresql.py new file mode 100644 index 0000000000000000000000000000000000000000..437eed03e120485ed2a357a4c2d92426f1466e14 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/dialects/test_postgresql.py @@ -0,0 +1,262 @@ +import unittest +from collections import OrderedDict + +from pypika import ( + Array, + Field, + JSON, + QueryException, + Table, +) +from pypika.dialects import PostgreSQLQuery + + +class InsertTests(unittest.TestCase): + table_abc = Table("abc") + + def test_array_keyword(self): + q = PostgreSQLQuery.into(self.table_abc).insert(1, [1, "a", True]) + + self.assertEqual("INSERT INTO \"abc\" VALUES (1,ARRAY[1,'a',true])", str(q)) + + +class JSONObjectTests(unittest.TestCase): + def test_alias_set_correctly(self): + table = Table('jsonb_table') + q = PostgreSQLQuery.from_('abc').select(table.value.get_text_value('a').as_('name')) + + self.assertEqual('''SELECT "value"->>'a' "name" FROM "abc"''', str(q)) + + def test_json_value_from_dict(self): + q = PostgreSQLQuery.select(JSON({"a": "foo"})) + + self.assertEqual('SELECT \'{"a":"foo"}\'', str(q)) + + def test_json_value_from_array_num(self): + q = PostgreSQLQuery.select(JSON([1, 2, 3])) + + self.assertEqual("SELECT '[1,2,3]'", str(q)) + + def test_json_value_from_array_str(self): + q = PostgreSQLQuery.select(JSON(["a", "b", "c"])) + + self.assertEqual('SELECT \'["a","b","c"]\'', str(q)) + + def test_json_value_from_dict_recursive(self): + q = PostgreSQLQuery.select(JSON({"a": "z", "b": {"c": "foo"}, "d": 1})) + + # gotta split this one up to avoid the indeterminate order + sql = str(q) + start, end = 9, -2 + self.assertEqual("SELECT '{}'", sql[:start] + sql[end:]) + + members_set = set(sql[start:end].split(",")) + self.assertSetEqual({'"a":"z"', '"b":{"c":"foo"}', '"d":1'}, members_set) + + +class JSONOperatorsTests(unittest.TestCase): + # reference https://www.postgresql.org/docs/9.5/functions-json.html + table_abc = Table("abc") + + def test_get_json_value_by_key(self): + q = PostgreSQLQuery.from_(self.table_abc).select("*").where(self.table_abc.json.get_json_value("dates")) + + self.assertEqual('SELECT * FROM "abc" WHERE "json"->\'dates\'', str(q)) + + def test_get_json_value_by_index(self): + q = PostgreSQLQuery.from_(self.table_abc).select("*").where(self.table_abc.json.get_json_value(1)) + + self.assertEqual('SELECT * FROM "abc" WHERE "json"->1', str(q)) + + def test_get_text_value_by_key(self): + q = PostgreSQLQuery.from_(self.table_abc).select("*").where(self.table_abc.json.get_text_value("dates")) + + self.assertEqual('SELECT * FROM "abc" WHERE "json"->>\'dates\'', str(q)) + + def test_get_text_value_by_index(self): + q = PostgreSQLQuery.from_(self.table_abc).select("*").where(self.table_abc.json.get_text_value(1)) + + self.assertEqual('SELECT * FROM "abc" WHERE "json"->>1', str(q)) + + def test_get_path_json_value(self): + q = PostgreSQLQuery.from_(self.table_abc).select("*").where(self.table_abc.json.get_path_json_value("{a,b}")) + + self.assertEqual('SELECT * FROM "abc" WHERE "json"#>\'{a,b}\'', str(q)) + + def test_get_path_text_value(self): + q = PostgreSQLQuery.from_(self.table_abc).select("*").where(self.table_abc.json.get_path_text_value("{a,b}")) + + self.assertEqual('SELECT * FROM "abc" WHERE "json"#>>\'{a,b}\'', str(q)) + + +class JSONBOperatorsTests(unittest.TestCase): + # reference https://www.postgresql.org/docs/9.5/functions-json.html + table_abc = Table("abc") + + def test_json_contains_for_json(self): + q = PostgreSQLQuery.select(JSON({"a": 1, "b": 2}).contains({"a": 1})) + + # gotta split this one up to avoid the indeterminate order + sql = str(q) + start, end = 9, -13 + self.assertEqual("SELECT '{}'@>'{\"a\":1}'", sql[:start] + sql[end:]) + + members_set = set(sql[start:end].split(",")) + self.assertSetEqual({'"a":1', '"b":2'}, members_set) + + def test_json_contains_for_field(self): + q = ( + PostgreSQLQuery.from_(self.table_abc) + .select("*") + .where(self.table_abc.json.contains({"dates": "2018-07-10 - 2018-07-17"})) + ) + + self.assertEqual( + "SELECT * " 'FROM "abc" ' 'WHERE "json"@>\'{"dates":"2018-07-10 - 2018-07-17"}\'', + str(q), + ) + + def test_json_contained_by_using_str_arg(self): + q = ( + PostgreSQLQuery.from_(self.table_abc) + .select("*") + .where( + self.table_abc.json.contained_by( + OrderedDict( + [ + ("dates", "2018-07-10 - 2018-07-17"), + ("imported", "8"), + ] + ) + ) + ) + ) + self.assertEqual( + 'SELECT * FROM "abc" ' 'WHERE "json"<@\'{"dates":"2018-07-10 - 2018-07-17","imported":"8"}\'', + str(q), + ) + + def test_json_contained_by_using_list_arg(self): + q = ( + PostgreSQLQuery.from_(self.table_abc) + .select("*") + .where(self.table_abc.json.contained_by(["One", "Two", "Three"])) + ) + + self.assertEqual('SELECT * FROM "abc" WHERE "json"<@\'["One","Two","Three"]\'', str(q)) + + def test_json_contained_by_with_complex_criterion(self): + q = ( + PostgreSQLQuery.from_(self.table_abc) + .select("*") + .where(self.table_abc.json.contained_by(["One", "Two", "Three"]) & (self.table_abc.id == 26)) + ) + + self.assertEqual( + 'SELECT * FROM "abc" WHERE "json"<@\'["One","Two","Three"]\' AND "id"=26', + str(q), + ) + + def test_json_has_key(self): + q = PostgreSQLQuery.from_(self.table_abc).select("*").where(self.table_abc.json.has_key("dates")) + + self.assertEqual('SELECT * FROM "abc" WHERE "json"?\'dates\'', str(q)) + + def test_json_has_keys(self): + q = PostgreSQLQuery.from_(self.table_abc).select("*").where(self.table_abc.json.has_keys(["dates", "imported"])) + + self.assertEqual("SELECT * FROM \"abc\" WHERE \"json\"?&ARRAY['dates','imported']", str(q)) + + def test_json_has_any_keys(self): + q = ( + PostgreSQLQuery.from_(self.table_abc) + .select("*") + .where(self.table_abc.json.has_any_keys(["dates", "imported"])) + ) + + self.assertEqual("SELECT * FROM \"abc\" WHERE \"json\"?|ARRAY['dates','imported']", str(q)) + + def test_subnet_contains_inet(self): + q = ( + PostgreSQLQuery.from_(self.table_abc) + .select(self.table_abc.a.lshift(2)) + .where(self.table_abc.cidr >> "1.1.1.1") + ) + + self.assertEqual("SELECT \"a\"<<2 FROM \"abc\" WHERE \"cidr\">>'1.1.1.1'", str(q)) + + +class DistinctOnTests(unittest.TestCase): + table_abc = Table("abc") + + def test_distinct_on(self): + q = PostgreSQLQuery.from_(self.table_abc).distinct_on("lname", self.table_abc.fname).select("lname", "id") + + self.assertEqual('''SELECT DISTINCT ON("lname","fname") "lname","id" FROM "abc"''', str(q)) + + +class ArrayTests(unittest.TestCase): + def test_array_syntax(self): + tb = Table("tb") + q = PostgreSQLQuery.from_(tb).select(Array(1, "a", ["b", 2, 3])) + + self.assertEqual(str(q), "SELECT ARRAY[1,'a',ARRAY['b',2,3]] FROM \"tb\"") + + def test_render_alias_in_array_sql(self): + tb = Table("tb") + + q = PostgreSQLQuery.from_(tb).select(Array(tb.col).as_("different_name")) + self.assertEqual(str(q), 'SELECT ARRAY["col"] "different_name" FROM "tb"') + + +class ReturningClauseTests(unittest.TestCase): + @classmethod + def setUpClass(cls) -> None: + super().setUpClass() + cls.table_abc = Table('abc') + + def test_returning_from_missing_table_raises_queryexception(self): + field_from_diff_table = Field('xyz', table=Table('other')) + + with self.assertRaisesRegex(QueryException, "You can't return from other tables"): + ( + PostgreSQLQuery.from_(self.table_abc) + .where(self.table_abc.foo == self.table_abc.bar) + .delete() + .returning(field_from_diff_table) + ) + + def test_queryexception_if_returning_used_on_invalid_query(self): + with self.assertRaisesRegex(QueryException, "Returning can't be used in this query"): + PostgreSQLQuery.from_(self.table_abc).select('abc').returning('abc') + + def test_no_queryexception_if_returning_used_on_valid_query_type(self): + # No exceptions for insert, update and delete queries + with self.subTest('DELETE'): + PostgreSQLQuery.from_(self.table_abc).where(self.table_abc.foo == self.table_abc.bar).delete().returning( + "id" + ) + with self.subTest('UPDATE'): + PostgreSQLQuery.update(self.table_abc).where(self.table_abc.foo == 0).set("foo", "bar").returning("id") + with self.subTest('INSERT'): + PostgreSQLQuery.into(self.table_abc).insert('abc').returning('abc') + + def test_return_field_from_join_table(self): + new_table = Table('xyz') + q = ( + PostgreSQLQuery.update(self.table_abc) + .join(new_table) + .on(new_table.id == self.table_abc.xyz) + .where(self.table_abc.foo == 0) + .set("foo", "bar") + .returning(new_table.a) + ) + + self.assertEqual( + 'UPDATE "abc" ' + 'JOIN "xyz" ON "xyz"."id"="abc"."xyz" ' + 'SET "foo"=\'bar\' ' + 'WHERE "abc"."foo"=0 ' + 'RETURNING "xyz"."a"', + str(q), + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/dialects/test_snowflake.py b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/dialects/test_snowflake.py new file mode 100644 index 0000000000000000000000000000000000000000..5ac08b2d8b8b5496ed6f3510acf4be1ec7893405 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/dialects/test_snowflake.py @@ -0,0 +1,58 @@ +import unittest + +from pypika import ( + Tables, + functions as fn, + Column, +) +from pypika.dialects import SnowflakeQuery + + +class QuoteTests(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_use_double_quotes_on_alias_but_not_on_terms(self): + q = SnowflakeQuery.from_(self.table_abc).select(self.table_abc.a.as_("bar")) + + self.assertEqual('SELECT a "bar" FROM abc', q.get_sql(with_namespace=True)) + + def test_use_double_quotes_on_alias_but_not_on_terms_with_joins(self): + foo = self.table_abc.as_("foo") + bar = self.table_efg.as_("bar") + + q = SnowflakeQuery.from_(foo).join(bar).on(foo.fk == bar.id).select(foo.a, bar.b) + + self.assertEqual( + "SELECT foo.a,bar.b " 'FROM abc "foo" ' 'JOIN efg "bar" ' "ON foo.fk=bar.id", + q.get_sql(with_namespace=True), + ) + + def test_use_double_quotes_on_alias_but_not_on_terms(self): + idx = self.table_abc.index.as_("idx") + val = fn.Sum(self.table_abc.value).as_("val") + q = SnowflakeQuery.from_(self.table_abc).select(idx, val).groupby(idx).orderby(idx) + + self.assertEqual( + 'SELECT index "idx",SUM(value) "val" ' "FROM abc " 'GROUP BY "idx" ' 'ORDER BY "idx"', + q.get_sql(with_namespace=True), + ) + + def test_dont_use_double_quotes_on_joining_queries(self): + foo = self.table_abc + bar = self.table_efg + q1 = SnowflakeQuery.from_(foo).select(foo.b) + q2 = SnowflakeQuery.from_(bar).select(bar.b) + q = SnowflakeQuery.from_(q1).join(q2).on(q1.b == q2.b).select("*") + + self.assertEqual( + "SELECT * " 'FROM (SELECT b FROM abc) sq0 ' 'JOIN (SELECT b FROM efg) sq1 ' "ON sq0.b=sq1.b", + q.get_sql(), + ) + + def test_dont_use_double_quotes_on_create_queries(self): + q = SnowflakeQuery.create_table(self.table_abc).columns(Column("id", "INT")) + self.assertEqual("CREATE TABLE abc (id INT)", q.get_sql()) + + def test_dont_use_double_quotes_on_drop_queries(self): + q = SnowflakeQuery.drop_table(self.table_abc) + self.assertEqual("DROP TABLE abc", q.get_sql()) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/dialects/test_sqllite.py b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/dialects/test_sqllite.py new file mode 100644 index 0000000000000000000000000000000000000000..104a7235b6ea2d46fd365989f68c5d081eb20076 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/dialects/test_sqllite.py @@ -0,0 +1,35 @@ +import unittest + +from pypika import Table +from pypika.dialects import SQLLiteQuery + + +class SelectTests(unittest.TestCase): + table_abc = Table("abc") + + def test_bool_true_as_one(self): + q = SQLLiteQuery.from_("abc").select(True) + + self.assertEqual('SELECT 1 FROM "abc"', str(q)) + + def test_bool_false_as_zero(self): + q = SQLLiteQuery.from_("abc").select(False) + + self.assertEqual('SELECT 0 FROM "abc"', str(q)) + + +class ReplaceTests(unittest.TestCase): + def test_normal_replace(self): + query = SQLLiteQuery.into("abc").replace("v1", "v2", "v3") + expected_output = "REPLACE INTO \"abc\" VALUES ('v1','v2','v3')" + self.assertEqual(expected_output, str(query)) + + def test_replace_subquery(self): + query = SQLLiteQuery.into("abc").replace(SQLLiteQuery.from_("def").select("f1", "f2")) + expected_output = 'REPLACE INTO "abc" VALUES ((SELECT "f1","f2" FROM "def"))' + self.assertEqual(expected_output, str(query)) + + def test_insert_or_replace(self): + query = SQLLiteQuery.into("abc").insert_or_replace("v1", "v2", "v3") + expected_output = "INSERT OR REPLACE INTO \"abc\" VALUES ('v1','v2','v3')" + self.assertEqual(expected_output, str(query)) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/dialects/test_vertica.py b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/dialects/test_vertica.py new file mode 100644 index 0000000000000000000000000000000000000000..61985bfc244fcd663e7d8a904b4645901f3abdfc --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/dialects/test_vertica.py @@ -0,0 +1,93 @@ +import unittest + +from pypika import Columns, Table, Tables, VerticaQuery + + +class VerticaQueryTests(unittest.TestCase): + table_abc = Table("abc") + + def test_select_query_with_hint(self): + q = VerticaQuery.from_("abc").select("*").hint("test_hint") + + self.assertEqual('SELECT /*+label(test_hint)*/ * FROM "abc"', str(q)) + + def test_insert_query_with_hint(self): + query = VerticaQuery.into(self.table_abc).insert(1).hint("test_hint") + + self.assertEqual('INSERT /*+label(test_hint)*/ INTO "abc" VALUES (1)', str(query)) + + def test_update_query_with_hint(self): + q = VerticaQuery.update(self.table_abc).set("foo", "bar").hint("test_hint") + + self.assertEqual('UPDATE /*+label(test_hint)*/ "abc" SET "foo"=\'bar\'', str(q)) + + def test_delete_query_with_hint(self): + q = VerticaQuery.from_("abc").delete().hint("test_hint") + + self.assertEqual('DELETE /*+label(test_hint)*/ FROM "abc"', str(q)) + + +class CopyCSVTests(unittest.TestCase): + table_abc = Table("abc") + + def test_copy_from_file(self): + with self.subTest("with table as string"): + q = VerticaQuery.from_file("/path/to/file").copy_("abc") + + self.assertEqual( + "COPY \"abc\" FROM LOCAL '/path/to/file' PARSER fcsvparser(header=false)", + str(q), + ) + + with self.subTest("with table"): + q = VerticaQuery.from_file("/path/to/file").copy_(self.table_abc) + + self.assertEqual( + "COPY \"abc\" FROM LOCAL '/path/to/file' PARSER fcsvparser(header=false)", + str(q), + ) + + +class CreateTemporaryTableTests(unittest.TestCase): + new_table, existing_table = Tables("abc", "efg") + foo, bar = Columns(("a", "INT"), ("b", "VARCHAR(100)")) + select = VerticaQuery.from_(existing_table).select(existing_table.foo, existing_table.bar) + + def test_create_local_temporary_table(self): + with self.subTest("with columns"): + q = VerticaQuery.create_table(self.new_table).temporary().local().columns(self.foo, self.bar) + + self.assertEqual('CREATE LOCAL TEMPORARY TABLE "abc" ("a" INT,"b" VARCHAR(100))', str(q)) + + with self.subTest("with select"): + q = VerticaQuery.create_table(self.new_table).temporary().local().as_select(self.select) + + self.assertEqual( + 'CREATE LOCAL TEMPORARY TABLE "abc" AS (SELECT "foo","bar" FROM "efg")', + str(q), + ) + + def test_create_local_table_without_temporary_raises_error(self): + with self.assertRaises(AttributeError): + VerticaQuery.create_table(self.new_table).local() + + def test_create_temporary_table_preserve_rows(self): + with self.subTest("with columns"): + q = VerticaQuery.create_table(self.new_table).temporary().preserve_rows().columns(self.foo, self.bar) + + self.assertEqual( + 'CREATE TEMPORARY TABLE "abc" ("a" INT,"b" VARCHAR(100)) ON COMMIT PRESERVE ROWS', + str(q), + ) + + with self.subTest("with select"): + q = VerticaQuery.create_table(self.new_table).temporary().preserve_rows().as_select(self.select) + + self.assertEqual( + 'CREATE TEMPORARY TABLE "abc" ON COMMIT PRESERVE ROWS AS (SELECT "foo","bar" FROM "efg")', + str(q), + ) + + def test_create_table_preserve_rows_without_temporary_raises_error(self): + with self.assertRaises(AttributeError): + VerticaQuery.create_table(self.new_table).preserve_rows() diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/test_aggregate.py b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/test_aggregate.py new file mode 100644 index 0000000000000000000000000000000000000000..1c627d8e9c2d65410c67cf2c39974949b0720a0e --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/test_aggregate.py @@ -0,0 +1,122 @@ +import unittest + +from pypika import ( + Case, + Field, + Table, + functions as fn, +) +from pypika.terms import ( + Negative, + ValueWrapper, +) + + +class IsAggregateTests(unittest.TestCase): + def test__field_is_not_aggregate(self): + v = Field("foo") + self.assertFalse(v.is_aggregate) + + def test__constant_is_aggregate_none(self): + v = ValueWrapper(100) + self.assertIsNone(v.is_aggregate) + + def test__constant_arithmetic_is_aggregate_none(self): + v = ValueWrapper(100) + ValueWrapper(100) + self.assertIsNone(v.is_aggregate) + + def test__field_arithmetic_is_not_aggregate(self): + v = Field("foo") + Field("bar") + self.assertFalse(v.is_aggregate) + + def test__field_arithmetic_constant_is_not_aggregate(self): + v = Field("foo") + 1 + self.assertFalse(v.is_aggregate) + + def test__agg_func_is_aggregate(self): + v = fn.Sum(Field("foo")) + self.assertTrue(v.is_aggregate) + + def test__negative_agg_func_is_aggregate(self): + v = Negative(fn.Sum(Field("foo"))) + self.assertTrue(v.is_aggregate) + + def test__agg_func_arithmetic_is_aggregate(self): + v = fn.Sum(Field("foo")) / fn.Sum(Field("foo")) + self.assertTrue(v.is_aggregate) + + def test__mixed_func_arithmetic_is_not_aggregate(self): + v = Field("foo") / fn.Sum(Field("foo")) + self.assertFalse(v.is_aggregate) + + def test__func_arithmetic_constant_is_not_aggregate(self): + v = 1 / fn.Sum(Field("foo")) + self.assertTrue(v.is_aggregate) + + def test__agg_case_criterion_is_aggregate(self): + v = Case().when(fn.Sum(Field("foo")) > 666, 'More than 666').else_('Less than 666') + + self.assertTrue(v.is_aggregate) + + def test__agg_case_is_aggregate(self): + v = ( + Case() + .when(Field("foo") == 1, fn.Sum(Field("bar"))) + .when(Field("foo") == 2, fn.Sum(Field("fiz"))) + .else_(fn.Sum(Field("fiz"))) + ) + + self.assertTrue(v.is_aggregate) + + def test__mixed_case_is_not_aggregate(self): + v = Case().when(Field("foo") == 1, fn.Sum(Field("bar"))).when(Field("foo") == 2, Field("fiz")) + + self.assertFalse(v.is_aggregate) + + def test__case_mixed_else_is_not_aggregate(self): + v = ( + Case() + .when(Field("foo") == 1, fn.Sum(Field("bar"))) + .when(Field("foo") == 2, fn.Sum(Field("fiz"))) + .else_(Field("fiz")) + ) + + self.assertFalse(v.is_aggregate) + + def test__case_mixed_constant_is_not_aggregate(self): + v = Case().when(Field("foo") == 1, fn.Sum(Field("bar"))).when(Field("foo") == 2, fn.Sum(Field("fiz"))).else_(1) + + self.assertTrue(v.is_aggregate) + + def test__case_with_field_is_not_aggregate(self): + v = Case().when(Field("foo") == 1, 1).when(Field("foo") == 2, 2).else_(3) + + self.assertFalse(v.is_aggregate) + + def test__case_with_single_aggregate_field_in_one_criterion_is_aggregate(self): + v = Case().when(Field("foo") == 1, 1).when(fn.Sum(Field("foo")) == 2, 2).else_(3) + + self.assertTrue(v.is_aggregate) + + def test__non_aggregate_function_with_aggregated_arg(self): + t = Table("abc") + expr = fn.Sqrt(fn.Sum(t.a)) + + self.assertTrue(expr.is_aggregate) + + def test_complicated(self): + t = Table("abc") + is_placebo = t.campaign_extra_info == "placebo" + + pixel_mobile_search = Case().when(is_placebo, t.action_fb_pixel_search + t.action_fb_mobile_search) + unique_impressions = Case().when(is_placebo, t.unique_impressions) + + v = fn.Sum(pixel_mobile_search) / fn.Sum(unique_impressions) - 1.96 * fn.Sqrt( + 1 + / fn.Sum(unique_impressions) + * fn.Sum(pixel_mobile_search) + / fn.Sum(unique_impressions) + * (1 - fn.Sum(pixel_mobile_search) / fn.Sum(unique_impressions)) + ) + + self.assertTrue(v.is_aggregate) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/test_analytic_queries.py b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/test_analytic_queries.py new file mode 100644 index 0000000000000000000000000000000000000000..6a35ab854b30e3b0f91e633b3349706a22e0a2fd --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/test_analytic_queries.py @@ -0,0 +1,610 @@ +import unittest + +from pypika import Criterion, JoinType, Order, Query, Tables, analytics as an +from pypika.analytics import Lag, Lead + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + + +class RankTests(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_rank(self): + expr = an.Rank().over(self.table_abc.foo).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " "RANK() " 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_dense_rank(self): + expr = an.DenseRank().over(self.table_abc.foo).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " "DENSE_RANK() " 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_row_number(self): + expr = an.RowNumber().over(self.table_abc.foo).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " "ROW_NUMBER() " 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_rank_with_alias(self): + expr = an.Rank().over(self.table_abc.foo).orderby(self.table_abc.date).as_("rank") + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " "RANK() " 'OVER(PARTITION BY "foo" ORDER BY "date") "rank" ' 'FROM "abc"', + str(q), + ) + + def test_multiple_partitions(self): + expr = an.Rank().orderby(self.table_abc.date).over(self.table_abc.foo, self.table_abc.bar) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " "RANK() " 'OVER(PARTITION BY "foo","bar" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_ntile_no_partition_or_order_invalid_sql(self): + expr = an.NTile(5) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual("SELECT " "NTILE(5) " 'FROM "abc"', str(q)) + + def test_ntile_with_partition(self): + expr = an.NTile(5).over(self.table_abc.foo) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual("SELECT " "NTILE(5) " 'OVER(PARTITION BY "foo") ' 'FROM "abc"', str(q)) + + def test_ntile_with_order(self): + expr = an.NTile(5).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual("SELECT " "NTILE(5) " 'OVER(ORDER BY "date") ' 'FROM "abc"', str(q)) + + def test_ntile_with_partition_and_order(self): + expr = an.NTile(5).over(self.table_abc.foo).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " "NTILE(5) " 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_first_value(self): + expr = an.FirstValue(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'FIRST_VALUE("fizz") ' 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_first_value_ignore_nulls(self): + expr = an.FirstValue(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).ignore_nulls() + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'FIRST_VALUE("fizz" IGNORE NULLS) ' 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_first_value_ignore_nulls_first(self): + expr = an.FirstValue(self.table_abc.fizz).ignore_nulls().over(self.table_abc.foo).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'FIRST_VALUE("fizz" IGNORE NULLS) ' 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_first_value_multi_argument(self): + expr = ( + an.FirstValue(self.table_abc.fizz, self.table_abc.buzz) + .over(self.table_abc.foo) + .orderby(self.table_abc.date) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'FIRST_VALUE("fizz","buzz") ' 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_last_value(self): + expr = an.LastValue(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'LAST_VALUE("fizz") ' 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_filter(self): + expr = ( + an.LastValue(self.table_abc.fizz) + .filter(Criterion.all([self.table_abc.bar == True])) + .over(self.table_abc.foo) + .orderby(self.table_abc.date) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'LAST_VALUE("fizz") ' + 'FILTER(WHERE "bar"=true) ' + 'OVER(PARTITION BY "foo" ORDER BY "date") ' + 'FROM "abc"', + str(q), + ) + + def test_filter_quote_table_in_filter(self): + expr = ( + an.LastValue(self.table_efg.fizz) + .filter(self.table_efg.filed.eq('yes')) + .over(self.table_efg.foo) + .orderby(self.table_efg.date) + ) + + q = ( + Query.from_(self.table_abc) + .inner_join(self.table_efg) + .on(self.table_abc.id.eq(self.table_efg.id)) + .select(expr) + ) + + self.assertEqual( + 'SELECT ' + 'LAST_VALUE("efg"."fizz") ' + 'FILTER(WHERE "efg"."filed"=\'yes\') ' + 'OVER(PARTITION BY "efg"."foo" ORDER BY "efg"."date") ' + 'FROM "abc" ' + 'JOIN "efg" ON "abc"."id"="efg"."id"', + str(q), + ) + + def test_orderby_asc(self): + expr = an.LastValue(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date, order=Order.asc) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'LAST_VALUE("fizz") ' 'OVER(PARTITION BY "foo" ORDER BY "date" ASC) ' 'FROM "abc"', + str(q), + ) + + def test_orderby_desc(self): + expr = an.LastValue(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date, order=Order.desc) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'LAST_VALUE("fizz") ' 'OVER(PARTITION BY "foo" ORDER BY "date" DESC) ' 'FROM "abc"', + str(q), + ) + + def test_last_value_multi_argument(self): + expr = ( + an.LastValue(self.table_abc.fizz, self.table_abc.buzz).over(self.table_abc.foo).orderby(self.table_abc.date) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'LAST_VALUE("fizz","buzz") ' 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_last_value_ignore_nulls(self): + expr = an.LastValue(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).ignore_nulls() + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'LAST_VALUE("fizz" IGNORE NULLS) ' 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_median(self): + expr = an.Median(self.table_abc.fizz).over(self.table_abc.foo, self.table_abc.bar).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'MEDIAN("fizz") ' 'OVER(PARTITION BY "foo","bar" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_avg(self): + expr = an.Avg(self.table_abc.fizz).over(self.table_abc.foo, self.table_abc.bar).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'AVG("fizz") ' 'OVER(PARTITION BY "foo","bar" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_stddev(self): + expr = an.StdDev(self.table_abc.fizz).over(self.table_abc.foo, self.table_abc.bar).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'STDDEV("fizz") ' 'OVER(PARTITION BY "foo","bar" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_stddev_pop(self): + expr = ( + an.StdDevPop(self.table_abc.fizz).over(self.table_abc.foo, self.table_abc.bar).orderby(self.table_abc.date) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'STDDEV_POP("fizz") ' 'OVER(PARTITION BY "foo","bar" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_stddev_samp(self): + expr = ( + an.StdDevSamp(self.table_abc.fizz).over(self.table_abc.foo, self.table_abc.bar).orderby(self.table_abc.date) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'STDDEV_SAMP("fizz") ' 'OVER(PARTITION BY "foo","bar" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_variance(self): + expr = ( + an.Variance(self.table_abc.fizz).over(self.table_abc.foo, self.table_abc.bar).orderby(self.table_abc.date) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'VARIANCE("fizz") ' 'OVER(PARTITION BY "foo","bar" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_var_pop(self): + expr = an.VarPop(self.table_abc.fizz).over(self.table_abc.foo, self.table_abc.bar).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'VAR_POP("fizz") ' 'OVER(PARTITION BY "foo","bar" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_var_samp(self): + expr = an.VarSamp(self.table_abc.fizz).over(self.table_abc.foo, self.table_abc.bar).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'VAR_SAMP("fizz") ' 'OVER(PARTITION BY "foo","bar" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_table_prefixes_used_in_analytic_functions(self): + expr = an.Rank().over(self.table_abc.foo).orderby(self.table_efg.date) + + query = ( + Query.from_(self.table_abc) + .join(self.table_efg, how=JoinType.left) + .on(self.table_abc.foo == self.table_efg.bar) + .select("*", expr) + ) + + self.assertEqual( + 'SELECT *,RANK() OVER(PARTITION BY "abc"."foo" ORDER BY "efg"."date") ' + 'FROM "abc" LEFT JOIN "efg" ON "abc"."foo"="efg"."bar"', + str(query), + ) + + def test_sum_rows_unbounded_preceeding(self): + expr = an.Sum(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).rows(an.Preceding()) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'SUM("fizz") ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "ROWS UNBOUNDED PRECEDING" + ") " + 'FROM "abc"', + str(q), + ) + + def test_max_rows_x_preceeding(self): + expr = an.Max(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).rows(an.Preceding(5)) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'MAX("fizz") ' "OVER(" 'PARTITION BY "foo" ORDER BY "date" ' "ROWS 5 PRECEDING" ") " 'FROM "abc"', + str(q), + ) + + def test_min_rows_current_row(self): + expr = an.Min(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).rows(an.CURRENT_ROW) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'MIN("fizz") ' "OVER(" 'PARTITION BY "foo" ORDER BY "date" ' "ROWS CURRENT ROW" ") " 'FROM "abc"', + str(q), + ) + + def test_varpop_range_unbounded_preceeding(self): + expr = ( + an.VarPop(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).range(an.Preceding()) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'VAR_POP("fizz") ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "RANGE UNBOUNDED PRECEDING" + ") " + 'FROM "abc"', + str(q), + ) + + def test_max_range_x_preceeding(self): + expr = an.Max(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).range(an.Preceding(5)) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'MAX("fizz") ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "RANGE 5 PRECEDING" + ") " + 'FROM "abc"', + str(q), + ) + + def test_min_range_current_row(self): + expr = an.Min(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).range(an.CURRENT_ROW) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'MIN("fizz") ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "RANGE CURRENT ROW" + ") " + 'FROM "abc"', + str(q), + ) + + def test_variance_rows_between_unbounded_preceeding_unbounded_following(self): + expr = ( + an.Variance(self.table_abc.fizz) + .over(self.table_abc.foo) + .orderby(self.table_abc.date) + .rows(an.Preceding(), an.Following()) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'VARIANCE("fizz") ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING" + ") " + 'FROM "abc"', + str(q), + ) + + def test_first_value_range_between_x_preceeding_unbounded_following(self): + expr = ( + an.FirstValue(self.table_abc.fizz) + .over(self.table_abc.foo) + .orderby(self.table_abc.date) + .range(an.Preceding(3), an.Following()) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'FIRST_VALUE("fizz") ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "RANGE BETWEEN 3 PRECEDING AND UNBOUNDED FOLLOWING" + ") " + 'FROM "abc"', + str(q), + ) + + def test_varpop_rows_between_unbounded_preceeding_x_following(self): + expr = ( + an.VarPop(self.table_abc.fizz) + .over(self.table_abc.foo) + .orderby(self.table_abc.date) + .rows(an.Preceding(), an.Following(6)) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'VAR_POP("fizz") ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "ROWS BETWEEN UNBOUNDED PRECEDING AND 6 FOLLOWING" + ") " + 'FROM "abc"', + str(q), + ) + + def test_count_range_between_unbounded_preceeding_current_row(self): + expr = ( + an.Count(self.table_abc.fizz) + .over(self.table_abc.foo) + .orderby(self.table_abc.date) + .range(an.Preceding(), an.CURRENT_ROW) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'COUNT("fizz") ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW" + ") " + 'FROM "abc"', + str(q), + ) + + def test_last_value_rows_between_current_row_unbounded_following(self): + expr = ( + an.LastValue(self.table_abc.fizz) + .over(self.table_abc.foo) + .orderby(self.table_abc.date) + .rows(an.CURRENT_ROW, an.Following()) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'LAST_VALUE("fizz") ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING" + ") " + 'FROM "abc"', + str(q), + ) + + def test_last_value_rows_between_current_row_unbounded_following_ignore_nulls(self): + expr = ( + an.LastValue(self.table_abc.fizz) + .over(self.table_abc.foo) + .orderby(self.table_abc.date) + .ignore_nulls() + .rows(an.CURRENT_ROW, an.Following(8)) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'LAST_VALUE("fizz" IGNORE NULLS) ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "ROWS BETWEEN CURRENT ROW AND 8 FOLLOWING" + ") " + 'FROM "abc"', + str(q), + ) + + def test_empty_over(self): + query = Query.from_(self.table_abc).select(an.Sum(self.table_abc.fizz).over()) + + self.assertEqual("SELECT " 'SUM("fizz") OVER() ' 'FROM "abc"', str(query)) + + def test_rows_called_twice_raises_attribute_error(self): + with self.assertRaises(AttributeError): + an.Sum(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).rows(an.Preceding()).rows( + an.Preceding() + ) + + def test_range_called_twice_raises_attribute_error(self): + with self.assertRaises(AttributeError): + an.Sum(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).range( + an.Preceding() + ).range(an.Preceding()) + + def test_rows_then_range_raises_attribute_error(self): + with self.assertRaises(AttributeError): + an.Sum(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).rows( + an.Preceding() + ).range(an.Preceding()) + + def test_range_then_rows_raises_attribute_error(self): + with self.assertRaises(AttributeError): + an.Sum(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).range( + an.Preceding() + ).rows(an.Preceding()) + + def test_lag_generates_correct_sql(self): + with self.subTest('without partition by'): + q = Query.from_(self.table_abc).select( + Lag(self.table_abc.date, 1, '2000-01-01').orderby(self.table_abc.date) + ) + + self.assertEqual('SELECT LAG("date",1,\'2000-01-01\') OVER(ORDER BY "date") FROM "abc"', str(q)) + + with self.subTest('with partition by'): + q = Query.from_(self.table_abc).select( + Lag(self.table_abc.date, 1, '2000-01-01').over(self.table_abc.foo).orderby(self.table_abc.date) + ) + + self.assertEqual( + 'SELECT LAG("date",1,\'2000-01-01\') OVER(PARTITION BY "foo" ORDER BY "date") FROM "abc"', str(q) + ) + + def test_lead_generates_correct_sql(self): + with self.subTest('without partition by'): + q = Query.from_(self.table_abc).select( + Lead(self.table_abc.date, 1, '2000-01-01').orderby(self.table_abc.date) + ) + + self.assertEqual('SELECT LEAD("date",1,\'2000-01-01\') OVER(ORDER BY "date") FROM "abc"', str(q)) + + with self.subTest('with partition by'): + q = Query.from_(self.table_abc).select( + Lead(self.table_abc.date, 1, '2000-01-01').over(self.table_abc.foo).orderby(self.table_abc.date) + ) + + self.assertEqual( + 'SELECT LEAD("date",1,\'2000-01-01\') OVER(PARTITION BY "foo" ORDER BY "date") FROM "abc"', str(q) + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/test_create.py b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/test_create.py new file mode 100644 index 0000000000000000000000000000000000000000..325076544e3824b0d07f82f2378b88218b910dde --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/test_create.py @@ -0,0 +1,210 @@ +import unittest + +from pypika import Column, Columns, Query, Tables, Table +from pypika.terms import ValueWrapper, Index +from pypika.enums import ReferenceOption + + +class CreateTableTests(unittest.TestCase): + new_table, existing_table = Tables("abc", "efg") + foo, bar = Columns(("a", "INT"), ("b", "VARCHAR(100)")) + + def test_create_table_with_columns(self): + with self.subTest("with nullable"): + a = Column("a", "INT", True) + b = Column("b", "VARCHAR(100)", False) + q = Query.create_table(self.new_table).columns(a, b) + + self.assertEqual('CREATE TABLE "abc" ("a" INT NULL,"b" VARCHAR(100) NOT NULL)', str(q)) + + with self.subTest("with defaults"): + a = Column("a", "INT", default=ValueWrapper(42)) + b = Column("b", "VARCHAR(100)", default=ValueWrapper("foo")) + q = Query.create_table(self.new_table).columns(a, b) + + self.assertEqual('CREATE TABLE "abc" ("a" INT DEFAULT 42,"b" VARCHAR(100) DEFAULT \'foo\')', str(q)) + + with self.subTest("with unwrapped defaults"): + a = Column("a", "INT", default=42) + b = Column("b", "VARCHAR(100)", default="foo") + q = Query.create_table(self.new_table).columns(a, b) + + self.assertEqual('CREATE TABLE "abc" ("a" INT DEFAULT 42,"b" VARCHAR(100) DEFAULT \'foo\')', str(q)) + + with self.subTest("with period for"): + a = Column("id", "INT") + b = Column("valid_from", "DATETIME") + c = Column("valid_to", "DATETIME") + q = Query.create_table(self.new_table).columns(a, b, c).period_for('valid_period', b, c) + + self.assertEqual( + 'CREATE TABLE "abc" (' + '"id" INT,' + '"valid_from" DATETIME,' + '"valid_to" DATETIME,' + 'PERIOD FOR "valid_period" ("valid_from","valid_to"))', + str(q), + ) + + with self.subTest("without temporary keyword"): + q = Query.create_table(self.new_table).columns(self.foo, self.bar) + + self.assertEqual('CREATE TABLE "abc" ("a" INT,"b" VARCHAR(100))', str(q)) + + with self.subTest("with temporary keyword"): + q = Query.create_table(self.new_table).temporary().columns(self.foo, self.bar) + + self.assertEqual('CREATE TEMPORARY TABLE "abc" ("a" INT,"b" VARCHAR(100))', str(q)) + + with self.subTest("with primary key"): + q = Query.create_table(self.new_table).columns(self.foo, self.bar).primary_key(self.foo, self.bar) + + self.assertEqual('CREATE TABLE "abc" ("a" INT,"b" VARCHAR(100),PRIMARY KEY ("a","b"))', str(q)) + + with self.subTest("with simple foreign key"): + cref, dref = Columns(("c", "INT"), ("d", "VARCHAR(100)")) + q = ( + Query.create_table(self.new_table) + .columns(self.foo, self.bar) + .foreign_key([self.foo, self.bar], self.existing_table, [cref, dref]) + ) + + self.assertEqual( + 'CREATE TABLE "abc" (' + '"a" INT,' + '"b" VARCHAR(100),' + 'FOREIGN KEY ("a","b") REFERENCES "efg" ("c","d"))', + str(q), + ) + + with self.subTest("with foreign key reference options"): + cref, dref = Columns(("c", "INT"), ("d", "VARCHAR(100)")) + q = ( + Query.create_table(self.new_table) + .columns(self.foo, self.bar) + .foreign_key( + [self.foo, self.bar], + self.existing_table, + [cref, dref], + on_delete=ReferenceOption.cascade, + on_update=ReferenceOption.restrict, + ) + ) + + self.assertEqual( + 'CREATE TABLE "abc" (' + '"a" INT,' + '"b" VARCHAR(100),' + 'FOREIGN KEY ("a","b") REFERENCES "efg" ("c","d") ON DELETE CASCADE ON UPDATE RESTRICT)', + str(q), + ) + + with self.subTest("with unique keys"): + q = ( + Query.create_table(self.new_table) + .columns(self.foo, self.bar) + .unique(self.foo, self.bar) + .unique(self.foo) + ) + + self.assertEqual('CREATE TABLE "abc" ("a" INT,"b" VARCHAR(100),UNIQUE ("a","b"),UNIQUE ("a"))', str(q)) + + with self.subTest("with system versioning"): + q = Query.create_table(self.new_table).columns(self.foo, self.bar).with_system_versioning() + + self.assertEqual('CREATE TABLE "abc" ("a" INT,"b" VARCHAR(100)) WITH SYSTEM VERSIONING', str(q)) + + with self.subTest("with unlogged keyword"): + q = Query.create_table(self.new_table).unlogged().columns(self.foo, self.bar) + + self.assertEqual('CREATE UNLOGGED TABLE "abc" ("a" INT,"b" VARCHAR(100))', str(q)) + + with self.subTest("with if not exists keyword"): + q = Query.create_table(self.new_table).if_not_exists().columns(self.foo, self.bar) + + self.assertEqual('CREATE TABLE IF NOT EXISTS "abc" ("a" INT,"b" VARCHAR(100))', str(q)) + + def test_create_table_with_select(self): + select = Query.from_(self.existing_table).select(self.existing_table.foo, self.existing_table.bar) + + with self.subTest("without temporary keyword"): + q = Query.create_table(self.new_table).as_select(select) + + self.assertEqual('CREATE TABLE "abc" AS (SELECT "foo","bar" FROM "efg")', str(q)) + + with self.subTest("with temporary keyword"): + q = Query.create_table(self.new_table).temporary().as_select(select) + + self.assertEqual( + 'CREATE TEMPORARY TABLE "abc" AS (SELECT "foo","bar" FROM "efg")', + str(q), + ) + + def test_create_table_without_columns_or_select_empty(self): + q = Query.create_table(self.new_table) + + self.assertEqual("", str(q)) + + def test_create_table_with_select_and_columns_fails(self): + select = Query.from_(self.existing_table).select(self.existing_table.foo, self.existing_table.bar) + + with self.subTest("for columns before as_select"): + with self.assertRaises(AttributeError): + Query.create_table(self.new_table).columns(self.foo, self.bar).as_select(select) + + with self.subTest("for as_select before columns"): + with self.assertRaises(AttributeError): + Query.create_table(self.new_table).as_select(select).columns(self.foo, self.bar) + + with self.subTest("repeated foreign key"): + with self.assertRaises(AttributeError): + Query.create_table(self.new_table).foreign_key([self.foo], self.existing_table, [self.bar]).foreign_key( + [self.foo], self.existing_table, [self.bar] + ) + + def test_create_table_as_select_not_query_raises_error(self): + with self.assertRaises(TypeError): + Query.create_table(self.new_table).as_select("abc") + + +class CreateIndexTests(unittest.TestCase): + new_index = Index("abc") + new_table = Table("my_table") + columns = (new_table.a, new_table.b) + where = new_table.a > 1 + + def test_create_index_simple(self) -> None: + q = Query.create_index(self.new_index).on(self.new_table).columns(*self.columns) + self.assertEqual( + f'CREATE INDEX "{self.new_index.name}" ON "{self.new_table.get_table_name()}"({", ".join([c.name for c in self.columns])})', + q.get_sql(), + ) + + def test_create_index_where(self) -> None: + q = Query.create_index(self.new_index).on(self.new_table).columns(*self.columns).where(self.where) + self.assertEqual( + f'CREATE INDEX "{self.new_index.name}" ON "{self.new_table.get_table_name()}"({", ".join([c.name for c in self.columns])}) WHERE {self.where.get_sql()}', + q.get_sql(), + ) + + def test_create_index_unique(self) -> None: + q = Query.create_index(self.new_index).on(self.new_table).columns(*self.columns).unique() + self.assertEqual( + f'CREATE UNIQUE INDEX "{self.new_index.name}" ON "{self.new_table.get_table_name()}"({", ".join([c.name for c in self.columns])})', + q.get_sql(), + ) + + def test_create_index_if_not_exists(self) -> None: + q = Query.create_index(self.new_index).on(self.new_table).columns(*self.columns).if_not_exists() + self.assertEqual( + f'CREATE INDEX IF NOT EXISTS "{self.new_index.name}" ON "{self.new_table.get_table_name()}"({", ".join([c.name for c in self.columns])})', + q.get_sql(), + ) + + def test_create_index_without_columns_raises_error(self) -> None: + with self.assertRaises(AttributeError): + Query.create_index(self.new_index).on(self.new_table).get_sql() + + def test_create_index_without_table_raises_error(self) -> None: + with self.assertRaises(AttributeError): + Query.create_index(self.new_index).columns(*self.columns).get_sql() diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/test_criterions.py b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/test_criterions.py new file mode 100644 index 0000000000000000000000000000000000000000..fca2ceeeb18db88e34ebc38776f644fdcda67e93 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/test_criterions.py @@ -0,0 +1,873 @@ +import unittest +from datetime import ( + date, + datetime, +) + +from pypika import ( + Criterion, + EmptyCriterion, + Field, + Table, + functions as fn, +) +from pypika.queries import QueryBuilder +from pypika.terms import ExistsCriterion, Mod + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + + +class CriterionTests(unittest.TestCase): + t = Table("test", alias="crit") + + def test__criterion_with_alias(self): + c1 = (Field("foo") == Field("bar")).as_("criterion") + + self.assertEqual('"foo"="bar"', str(c1)) + self.assertEqual('"foo"="bar" "criterion"', c1.get_sql(with_alias=True, quote_char='"', alias_quote_char='"')) + + def test__criterion_eq_number(self): + c1 = Field("foo") == 1 + c2 = Field("foo", table=self.t).eq(0) + c3 = Field("foo", table=self.t) == -1 + + self.assertEqual('"foo"=1', str(c1)) + self.assertEqual('"crit"."foo"=0', str(c2)) + self.assertEqual('"crit"."foo"=-1', str(c3)) + + def test__criterion_eq_decimal(self): + c1 = Field("foo") == 1.0 + c2 = Field("foo", table=self.t).eq(0.5) + + self.assertEqual('"foo"=1.0', str(c1)) + self.assertEqual('"crit"."foo"=0.5', str(c2)) + + def test__criterion_eq_bool(self): + c1 = Field("foo") == True + c2 = Field("foo", table=self.t).eq(True) + c3 = Field("foo") == False + c4 = Field("foo", table=self.t).eq(False) + + self.assertEqual('"foo"=true', str(c1)) + self.assertEqual('"crit"."foo"=true', str(c2)) + self.assertEqual('"foo"=false', str(c3)) + self.assertEqual('"crit"."foo"=false', str(c4)) + + def test__criterion_eq_str(self): + c1 = Field("foo") == "abc" + c2 = Field("foo", table=self.t).eq("abc") + + self.assertEqual("\"foo\"='abc'", str(c1)) + self.assertEqual('"crit"."foo"=\'abc\'', str(c2)) + + def test__criterion_eq_date(self): + c1 = Field("foo") == date(2000, 1, 1) + c2 = Field("foo", table=self.t).eq(date(2000, 1, 1)) + + self.assertEqual("\"foo\"='2000-01-01'", str(c1)) + self.assertEqual('"crit"."foo"=\'2000-01-01\'', str(c2)) + + def test__criterion_eq_datetime(self): + c1 = Field("foo") == datetime(2000, 1, 1, 12, 30, 55) + c2 = Field("foo", table=self.t).eq(datetime(2000, 1, 1, 12, 30, 55)) + + self.assertEqual("\"foo\"='2000-01-01T12:30:55'", str(c1)) + self.assertEqual('"crit"."foo"=\'2000-01-01T12:30:55\'', str(c2)) + + def test__criterion_eq_right(self): + c1 = 1 == Field("foo") + c2 = -1 == Field("foo", table=self.t) + + self.assertEqual('"foo"=1', str(c1)) + self.assertEqual('"crit"."foo"=-1', str(c2)) + + def test__criterion_is_null(self): + c1 = Field("foo").isnull() + c2 = Field("foo", table=self.t).isnull() + + self.assertEqual('"foo" IS NULL', str(c1)) + self.assertEqual('"crit"."foo" IS NULL', str(c2)) + + def test__criterion_is_null_with_alias(self): + c1 = Field("foo").isnull().as_('alias') + c2 = Field("foo", table=self.t).isnull().as_('alias') + + self.assertEqual('"foo" IS NULL "alias"', str(c1)) + self.assertEqual('"crit"."foo" IS NULL "alias"', str(c2)) + + def test__criterion_ne_number(self): + c1 = Field("foo") != 1 + c2 = Field("foo", table=self.t).ne(0) + c3 = Field("foo") != -1 + + self.assertEqual('"foo"<>1', str(c1)) + self.assertEqual('"crit"."foo"<>0', str(c2)) + self.assertEqual('"foo"<>-1', str(c3)) + + def test__criterion_ne_str(self): + c1 = Field("foo") != "abc" + c2 = Field("foo", table=self.t).ne("abc") + + self.assertEqual("\"foo\"<>'abc'", str(c1)) + self.assertEqual('"crit"."foo"<>\'abc\'', str(c2)) + + def test__criterion_ne_date(self): + c1 = Field("foo") != date(2000, 1, 1) + c2 = Field("foo", table=self.t).ne(date(2000, 1, 1)) + + self.assertEqual("\"foo\"<>'2000-01-01'", str(c1)) + self.assertEqual('"crit"."foo"<>\'2000-01-01\'', str(c2)) + + def test__criterion_ne_datetime(self): + c1 = Field("foo") != datetime(2000, 1, 1, 12, 30, 55) + c2 = Field("foo", table=self.t).ne(datetime(2000, 1, 1, 12, 30, 55)) + + self.assertEqual("\"foo\"<>'2000-01-01T12:30:55'", str(c1)) + self.assertEqual('"crit"."foo"<>\'2000-01-01T12:30:55\'', str(c2)) + + def test__criterion_ne_right(self): + c1 = 1 != Field("foo") + c2 = -1 != Field("foo", table=self.t) + + self.assertEqual('"foo"<>1', str(c1)) + self.assertEqual('"crit"."foo"<>-1', str(c2)) + + def test__criterion_lt_number(self): + c1 = Field("foo") < 1 + c2 = Field("foo", table=self.t).lt(0) + c3 = Field("foo") < -1 + + self.assertEqual('"foo"<1', str(c1)) + self.assertEqual('"crit"."foo"<0', str(c2)) + self.assertEqual('"foo"<-1', str(c3)) + + def test__criterion_lt_date(self): + c1 = Field("foo") < date(2000, 1, 1) + c2 = Field("foo", table=self.t).lt(date(2000, 1, 1)) + + self.assertEqual("\"foo\"<'2000-01-01'", str(c1)) + self.assertEqual('"crit"."foo"<\'2000-01-01\'', str(c2)) + + def test__criterion_lt_datetime(self): + c1 = Field("foo") < datetime(2000, 1, 1, 12, 30, 55) + c2 = Field("foo", table=self.t).lt(datetime(2000, 1, 1, 12, 30, 55)) + + self.assertEqual("\"foo\"<'2000-01-01T12:30:55'", str(c1)) + self.assertEqual('"crit"."foo"<\'2000-01-01T12:30:55\'', str(c2)) + + def test__criterion_lt_right(self): + c1 = 1 > Field("foo") + c2 = -1 > Field("foo", table=self.t) + + self.assertEqual('"foo"<1', str(c1)) + self.assertEqual('"crit"."foo"<-1', str(c2)) + + def test__criterion_gt_number(self): + c1 = Field("foo") > 1 + c2 = Field("foo", table=self.t).gt(0) + c3 = Field("foo") > -1 + + self.assertEqual('"foo">1', str(c1)) + self.assertEqual('"crit"."foo">0', str(c2)) + self.assertEqual('"foo">-1', str(c3)) + + def test__criterion_gt_date(self): + c1 = Field("foo") > date(2000, 1, 1) + c2 = Field("foo", table=self.t).gt(date(2000, 1, 1)) + + self.assertEqual("\"foo\">'2000-01-01'", str(c1)) + self.assertEqual('"crit"."foo">\'2000-01-01\'', str(c2)) + + def test__criterion_gt_datetime(self): + c1 = Field("foo") > datetime(2000, 1, 1, 12, 30, 55) + c2 = Field("foo", table=self.t).gt(datetime(2000, 1, 1, 12, 30, 55)) + + self.assertEqual("\"foo\">'2000-01-01T12:30:55'", str(c1)) + self.assertEqual('"crit"."foo">\'2000-01-01T12:30:55\'', str(c2)) + + def test__criterion_gt_right(self): + c1 = 1 < Field("foo") + c2 = -1 < Field("foo", table=self.t) + + self.assertEqual('"foo">1', str(c1)) + self.assertEqual('"crit"."foo">-1', str(c2)) + + def test__criterion_lte_number(self): + c1 = Field("foo") <= 1 + c2 = Field("foo", table=self.t).lte(0) + c3 = Field("foo") <= -1 + + self.assertEqual('"foo"<=1', str(c1)) + self.assertEqual('"crit"."foo"<=0', str(c2)) + self.assertEqual('"foo"<=-1', str(c3)) + + def test__criterion_lte_date(self): + c1 = Field("foo") <= date(2000, 1, 1) + c2 = Field("foo", table=self.t).lte(date(2000, 1, 1)) + + self.assertEqual("\"foo\"<='2000-01-01'", str(c1)) + self.assertEqual('"crit"."foo"<=\'2000-01-01\'', str(c2)) + + def test__criterion_lte_datetime(self): + c1 = Field("foo") <= datetime(2000, 1, 1, 12, 30, 55) + c2 = Field("foo", table=self.t).lte(datetime(2000, 1, 1, 12, 30, 55)) + + self.assertEqual("\"foo\"<='2000-01-01T12:30:55'", str(c1)) + self.assertEqual('"crit"."foo"<=\'2000-01-01T12:30:55\'', str(c2)) + + def test__criterion_lte_right(self): + c1 = 1 >= Field("foo") + c2 = -1 >= Field("foo", table=self.t) + + self.assertEqual('"foo"<=1', str(c1)) + self.assertEqual('"crit"."foo"<=-1', str(c2)) + + def test__criterion_gte_number(self): + c1 = Field("foo") >= 1 + c2 = Field("foo", table=self.t).gte(0) + c3 = Field("foo") >= -1 + + self.assertEqual('"foo">=1', str(c1)) + self.assertEqual('"crit"."foo">=0', str(c2)) + self.assertEqual('"foo">=-1', str(c3)) + + def test__criterion_gte_date(self): + c1 = Field("foo") >= date(2000, 1, 1) + c2 = Field("foo", table=self.t).gte(date(2000, 1, 1)) + + self.assertEqual("\"foo\">='2000-01-01'", str(c1)) + self.assertEqual('"crit"."foo">=\'2000-01-01\'', str(c2)) + + def test__criterion_gte_datetime(self): + c1 = Field("foo") >= datetime(2000, 1, 1, 12, 30, 55) + c2 = Field("foo", table=self.t).gte(datetime(2000, 1, 1, 12, 30, 55)) + + self.assertEqual("\"foo\">='2000-01-01T12:30:55'", str(c1)) + self.assertEqual('"crit"."foo">=\'2000-01-01T12:30:55\'', str(c2)) + + def test__criterion_gte_right(self): + c1 = 1 <= Field("foo") + c2 = -1 <= Field("foo", table=self.t) + + self.assertEqual('"foo">=1', str(c1)) + self.assertEqual('"crit"."foo">=-1', str(c2)) + + def test__criterion_bitwise_and(self): + c1 = Field("foo").bitwiseand(2) + c2 = Field("foo", table=self.t).bitwiseand(10) == 2 + + self.assertEqual('("foo" & 2)', str(c1)) + self.assertEqual('("crit"."foo" & 10)=2', str(c2)) + + def test__criterion_bitwise_and_with_alias(self): + c1 = Field("foo").bitwiseand(2).as_('alias') + + self.assertEqual('("foo" & 2) "alias"', str(c1)) + + def test__bitwise_and_in_where_clause(self): + q = QueryBuilder().from_('items').select('abc').where(Field("foo").bitwiseand(1) == 1) + + self.assertEqual('SELECT "abc" FROM "items" WHERE ("foo" & 1)=1', str(q)) + + +class NotTests(unittest.TestCase): + table_abc, table_efg = Table("abc", alias="cx0"), Table("efg", alias="cx1") + + def test_negate(self): + c1 = Field("foo") >= 1 + c2 = c1.negate() + + self.assertEqual('"foo">=1', str(c1)) + self.assertEqual('NOT "foo">=1', str(c2)) + + def test_variable_access(self): + c1 = Field("foo").negate() + + self.assertEqual(c1.is_aggregate, False) + + def test_chained_function(self): + field1 = Field("foo").negate() + field2 = field1.eq("bar") + + self.assertEqual('NOT "foo"', str(field1)) + self.assertEqual("NOT \"foo\"='bar'", str(field2)) + self.assertIsNot(field1, field2) + + def test_not_null(self): + c1 = Field("foo").notnull() + c2 = Field("foo", table=self.table_abc).notnull() + + self.assertEqual('NOT "foo" IS NULL', str(c1)) + self.assertEqual('NOT "cx0"."foo" IS NULL', str(c2)) + + def test_is_not_null(self): + c1 = Field("foo").isnotnull() + c2 = Field("foo", table=self.table_abc).isnotnull() + + self.assertEqual('"foo" IS NOT NULL', str(c1)) + self.assertEqual('"cx0"."foo" IS NOT NULL', str(c2)) + + def test_not_null_with_alias(self): + c1 = Field("foo").notnull().as_("something") + c2 = Field("foo", table=self.table_abc).notnull().as_("something") + + self.assertEqual('NOT "foo" IS NULL "something"', str(c1)) + self.assertEqual('NOT "cx0"."foo" IS NULL "something"', str(c2)) + + def test_notnullcriterion_replace_table(self): + f = self.table_abc.foo.notnull().replace_table(self.table_abc, self.table_efg) + + self.assertEqual('NOT "cx1"."foo" IS NULL', str(f)) + + def test_not_with_or_criterion(self): + self.assertEqual('NOT ("foo" OR "bar")', str(~(Field("foo") | Field("bar")))) + + def test_not_with_and_criterion(self): + self.assertEqual('NOT ("foo" AND "bar")', str(~(Field("foo") & Field("bar")))) + + def test_not_with_complex_criterion(self): + self.assertEqual( + 'NOT ("foo" AND "bar" AND "fizz" AND "buzz")', + str(~(Field("foo") & Field("bar") & Field("fizz") & Field("buzz"))), + ) + + +class BetweenTests(unittest.TestCase): + t = Table("abc", alias="btw") + + def test__between_number(self): + c1 = Field("foo").between(0, 1) + c2 = Field("foo", table=self.t).between(0, 1) + c3 = Field("foo")[0:1] + + self.assertEqual('"foo" BETWEEN 0 AND 1', str(c1)) + self.assertEqual('"btw"."foo" BETWEEN 0 AND 1', str(c2)) + self.assertEqual('"foo" BETWEEN 0 AND 1', str(c3)) + + def test__between_with_alias(self): + c1 = Field("foo").between(0, 1).as_('alias') + c2 = Field("foo", table=self.t).between(0, 1).as_('alias') + c3 = Field("foo")[0:1].as_('alias') + + self.assertEqual('"foo" BETWEEN 0 AND 1 "alias"', str(c1)) + self.assertEqual('"btw"."foo" BETWEEN 0 AND 1 "alias"', str(c2)) + self.assertEqual('"foo" BETWEEN 0 AND 1 "alias"', str(c3)) + + def test__between_date(self): + c1 = Field("foo").between(date(2000, 1, 1), date(2000, 12, 31)) + c2 = Field("foo", table=self.t).between(date(2000, 1, 1), date(2000, 12, 31)) + c3 = Field("foo")[date(2000, 1, 1) : date(2000, 12, 31)] + + self.assertEqual("\"foo\" BETWEEN '2000-01-01' AND '2000-12-31'", str(c1)) + self.assertEqual("\"btw\".\"foo\" BETWEEN '2000-01-01' AND '2000-12-31'", str(c2)) + self.assertEqual("\"foo\" BETWEEN '2000-01-01' AND '2000-12-31'", str(c3)) + + def test__between_datetime(self): + c1 = Field("foo").between(datetime(2000, 1, 1, 0, 0, 0), datetime(2000, 12, 31, 23, 59, 59)) + c2 = Field("foo", table=self.t).between(datetime(2000, 1, 1, 0, 0, 0), datetime(2000, 12, 31, 23, 59, 59)) + c3 = Field("foo")[datetime(2000, 1, 1, 0, 0, 0) : datetime(2000, 12, 31, 23, 59, 59)] + + self.assertEqual("\"foo\" BETWEEN '2000-01-01T00:00:00' AND '2000-12-31T23:59:59'", str(c1)) + self.assertEqual( + "\"btw\".\"foo\" BETWEEN '2000-01-01T00:00:00' AND '2000-12-31T23:59:59'", + str(c2), + ) + self.assertEqual("\"foo\" BETWEEN '2000-01-01T00:00:00' AND '2000-12-31T23:59:59'", str(c3)) + + def test__function_between(self): + c1 = fn.Coalesce(Field("foo"), 0)[0:1] + c2 = fn.Coalesce(Field("foo", table=self.t), 0)[0:1] + + self.assertEqual('COALESCE("foo",0) BETWEEN 0 AND 1', str(c1)) + self.assertEqual('COALESCE("btw"."foo",0) BETWEEN 0 AND 1', str(c2)) + + def test_get_item_only_works_with_slice(self): + with self.assertRaises(TypeError): + Field("foo")[0] + + with self.assertRaises(TypeError): + Field("foo")[date(2000, 1, 1)] + + with self.assertRaises(TypeError): + Field("foo")[datetime(2000, 1, 1, 0, 0, 0)] + + +class IsInTests(unittest.TestCase): + t = Table("abc", alias="isin") + + def test__in_number(self): + c1 = Field("foo").isin([0, 1]) + c2 = Field("foo", table=self.t).isin([0, 1]) + + self.assertEqual('"foo" IN (0,1)', str(c1)) + self.assertEqual('"isin"."foo" IN (0,1)', str(c2)) + + def test__in_number_with_alias(self): + c1 = Field("foo").isin([0, 1]).as_('alias') + c2 = Field("foo", table=self.t).isin([0, 1]).as_('alias') + + self.assertEqual('"foo" IN (0,1) "alias"', str(c1)) + self.assertEqual('"isin"."foo" IN (0,1) "alias"', str(c2)) + + def test__in_character(self): + c1 = Field("foo").isin(["a", "b"]) + c2 = Field("foo", table=self.t).isin(["a", "b"]) + + self.assertEqual("\"foo\" IN ('a','b')", str(c1)) + self.assertEqual("\"isin\".\"foo\" IN ('a','b')", str(c2)) + + def test__in_date(self): + c1 = Field("foo").isin([date(2000, 1, 1), date(2000, 12, 31)]) + c2 = Field("foo", table=self.t).isin([date(2000, 1, 1), date(2000, 12, 31)]) + + self.assertEqual("\"foo\" IN ('2000-01-01','2000-12-31')", str(c1)) + self.assertEqual("\"isin\".\"foo\" IN ('2000-01-01','2000-12-31')", str(c2)) + + def test__in_datetime(self): + c1 = Field("foo").isin([datetime(2000, 1, 1, 0, 0, 0), datetime(2000, 12, 31, 23, 59, 59)]) + c2 = Field("foo", table=self.t).isin([datetime(2000, 1, 1, 0, 0, 0), datetime(2000, 12, 31, 23, 59, 59)]) + + self.assertEqual("\"foo\" IN ('2000-01-01T00:00:00','2000-12-31T23:59:59')", str(c1)) + self.assertEqual("\"isin\".\"foo\" IN ('2000-01-01T00:00:00','2000-12-31T23:59:59')", str(c2)) + + def test__function_isin(self): + c1 = fn.Coalesce(Field("foo"), 0).isin([0, 1]) + c2 = fn.Coalesce(Field("foo", table=self.t), 0).isin([0, 1]) + + self.assertEqual('COALESCE("foo",0) IN (0,1)', str(c1)) + self.assertEqual('COALESCE("isin"."foo",0) IN (0,1)', str(c2)) + + for t in (list, tuple, set, frozenset): + c_type = fn.Coalesce(Field("foo"), 0).isin(t([0, 1])) + self.assertEqual('COALESCE("foo",0) IN (0,1)', str(c_type)) + + self.assertRaises(AttributeError, lambda: str(fn.Coalesce(Field("foo"), 0).isin('SHOULD_FAIL'))) + + def test__in_unicode(self): + c1 = Field("foo").isin([u"a", u"b"]) + c2 = Field("foo", table=self.t).isin([u"a", u"b"]) + + self.assertEqual("\"foo\" IN ('a','b')", str(c1)) + self.assertEqual("\"isin\".\"foo\" IN ('a','b')", str(c2)) + + +class ArithmeticExpressionTests(unittest.TestCase): + def test__lshift(self): + c1 = Field("foo").lshift("1") + c2 = Field("foo").lshift("2") + + self.assertEqual("\"foo\"<<'1'", str(c1)) + self.assertEqual("\"foo\"<<'2'", str(c2)) + + def test__rshift(self): + c1 = Field("foo").rshift("1") + c2 = Field("foo").rshift("2") + + self.assertEqual("\"foo\">>'1'", str(c1)) + self.assertEqual("\"foo\">>'2'", str(c2)) + + +class NotInTests(unittest.TestCase): + t = Table("abc", alias="notin") + + def test__notin_number(self): + c1 = Field("foo").notin([0, 1]) + c2 = Field("foo", table=self.t).notin([0, 1]) + + self.assertEqual('"foo" NOT IN (0,1)', str(c1)) + self.assertEqual('"notin"."foo" NOT IN (0,1)', str(c2)) + + def test__notin_number_with_alias(self): + c1 = Field("foo").notin([0, 1]).as_('alias') + c2 = Field("foo", table=self.t).notin([0, 1]).as_('alias') + + self.assertEqual('"foo" NOT IN (0,1) "alias"', str(c1)) + self.assertEqual('"notin"."foo" NOT IN (0,1) "alias"', str(c2)) + + def test__notin_character(self): + c1 = Field("foo").notin(["a", "b"]) + c2 = Field("foo", table=self.t).notin(["a", "b"]) + + self.assertEqual("\"foo\" NOT IN ('a','b')", str(c1)) + self.assertEqual("\"notin\".\"foo\" NOT IN ('a','b')", str(c2)) + + def test__notin_date(self): + c1 = Field("foo").notin([date(2000, 1, 1), date(2000, 12, 31)]) + c2 = Field("foo", table=self.t).notin([date(2000, 1, 1), date(2000, 12, 31)]) + + self.assertEqual("\"foo\" NOT IN ('2000-01-01','2000-12-31')", str(c1)) + self.assertEqual("\"notin\".\"foo\" NOT IN ('2000-01-01','2000-12-31')", str(c2)) + + def test__notin_datetime(self): + c1 = Field("foo").notin([datetime(2000, 1, 1, 0, 0, 0), datetime(2000, 12, 31, 23, 59, 59)]) + c2 = Field("foo", table=self.t).notin([datetime(2000, 1, 1, 0, 0, 0), datetime(2000, 12, 31, 23, 59, 59)]) + + self.assertEqual("\"foo\" NOT IN ('2000-01-01T00:00:00','2000-12-31T23:59:59')", str(c1)) + self.assertEqual( + "\"notin\".\"foo\" NOT IN ('2000-01-01T00:00:00','2000-12-31T23:59:59')", + str(c2), + ) + + def test__function_notin(self): + c1 = fn.Coalesce(Field("foo"), 0).notin([0, 1]) + c2 = fn.Coalesce(Field("foo", table=self.t), 0).notin([0, 1]) + + self.assertEqual('COALESCE("foo",0) NOT IN (0,1)', str(c1)) + self.assertEqual('COALESCE("notin"."foo",0) NOT IN (0,1)', str(c2)) + + +class LikeTests(unittest.TestCase): + t = Table("abc", alias="like") + + def test_like_starts_with(self): + c1 = Field("foo").like("ab%") + c2 = Field("foo", table=self.t).like("ab%") + + self.assertEqual("\"foo\" LIKE 'ab%'", str(c1)) + self.assertEqual('"like"."foo" LIKE \'ab%\'', str(c2)) + + def test_like_contains(self): + c1 = Field("foo").like("%ab%") + c2 = Field("foo", table=self.t).like("%ab%") + + self.assertEqual("\"foo\" LIKE '%ab%'", str(c1)) + self.assertEqual('"like"."foo" LIKE \'%ab%\'', str(c2)) + + def test_like_ends_with(self): + c1 = Field("foo").like("%ab") + c2 = Field("foo", table=self.t).like("%ab") + + self.assertEqual("\"foo\" LIKE '%ab'", str(c1)) + self.assertEqual('"like"."foo" LIKE \'%ab\'', str(c2)) + + def test_like_n_chars_long(self): + c1 = Field("foo").like("___") + c2 = Field("foo", table=self.t).like("___") + + self.assertEqual("\"foo\" LIKE '___'", str(c1)) + self.assertEqual('"like"."foo" LIKE \'___\'', str(c2)) + + def test_like_single_chars_and_various_chars(self): + c1 = Field("foo").like("a_b%c") + c2 = Field("foo", table=self.t).like("a_b%c") + + self.assertEqual("\"foo\" LIKE 'a_b%c'", str(c1)) + self.assertEqual('"like"."foo" LIKE \'a_b%c\'', str(c2)) + + def test_not_like_single_chars_and_various_chars(self): + c1 = Field("foo").not_like("a_b%c") + c2 = Field("foo", table=self.t).not_like("a_b%c") + + self.assertEqual("\"foo\" NOT LIKE 'a_b%c'", str(c1)) + self.assertEqual('"like"."foo" NOT LIKE \'a_b%c\'', str(c2)) + + def test_ilike_starts_with(self): + c1 = Field("foo").ilike("ab%") + c2 = Field("foo", table=self.t).ilike("ab%") + + self.assertEqual("\"foo\" ILIKE 'ab%'", str(c1)) + self.assertEqual('"like"."foo" ILIKE \'ab%\'', str(c2)) + + def test_ilike_contains(self): + c1 = Field("foo").ilike("%ab%") + c2 = Field("foo", table=self.t).ilike("%ab%") + + self.assertEqual("\"foo\" ILIKE '%ab%'", str(c1)) + self.assertEqual('"like"."foo" ILIKE \'%ab%\'', str(c2)) + + def test_ilike_ends_with(self): + c1 = Field("foo").ilike("%ab") + c2 = Field("foo", table=self.t).ilike("%ab") + + self.assertEqual("\"foo\" ILIKE '%ab'", str(c1)) + self.assertEqual('"like"."foo" ILIKE \'%ab\'', str(c2)) + + def test_ilike_n_chars_long(self): + c1 = Field("foo").ilike("___") + c2 = Field("foo", table=self.t).ilike("___") + + self.assertEqual("\"foo\" ILIKE '___'", str(c1)) + self.assertEqual('"like"."foo" ILIKE \'___\'', str(c2)) + + def test_ilike_single_chars_and_various_chars(self): + c1 = Field("foo").ilike("a_b%c") + c2 = Field("foo", table=self.t).ilike("a_b%c") + + self.assertEqual("\"foo\" ILIKE 'a_b%c'", str(c1)) + self.assertEqual('"like"."foo" ILIKE \'a_b%c\'', str(c2)) + + def test_not_ilike_single_chars_and_various_chars(self): + c1 = Field("foo").not_ilike("a_b%c") + c2 = Field("foo", table=self.t).not_ilike("a_b%c") + + self.assertEqual("\"foo\" NOT ILIKE 'a_b%c'", str(c1)) + self.assertEqual('"like"."foo" NOT ILIKE \'a_b%c\'', str(c2)) + + def test_rlike_escape_chars(self): + c1 = Field("foo").rlike("\\\\d+$") + c2 = Field("foo", table=self.t).rlike("\\\\d+$") + + self.assertEqual("\"foo\" RLIKE '\\\\d+$'", str(c1)) + self.assertEqual('"like"."foo" RLIKE \'\\\\d+$\'', str(c2)) + + def test_glob_single_chars_and_various_chars(self): + c1 = Field("foo").glob("a_b*") + c2 = Field("foo", table=self.t).glob("a_b*") + + self.assertEqual("\"foo\" GLOB 'a_b*'", str(c1)) + self.assertEqual('"like"."foo" GLOB \'a_b*\'', str(c2)) + + +class ExistsCriterionTests(unittest.TestCase): + t2 = Table("abc", alias="t2") + q2 = QueryBuilder().from_(t2).select(t2.field2) + + def test_exists(self): + t1 = Table("def", alias="t1") + q1 = QueryBuilder().from_(t1).where(ExistsCriterion(self.q2)).select(t1.field1) + + self.assertEqual( + 'SELECT "t1"."field1" FROM "def" "t1" WHERE EXISTS (SELECT "t2"."field2" FROM "abc" "t2")', str(q1) + ) + + def test_not_exists(self): + t1 = Table("def", alias="t1") + q1 = QueryBuilder().from_(t1).where(ExistsCriterion(self.q2).negate()).select(t1.field1) + + self.assertEqual( + 'SELECT "t1"."field1" FROM "def" "t1" WHERE NOT EXISTS (SELECT "t2"."field2" FROM "abc" "t2")', str(q1) + ) + + +class ComplexCriterionTests(unittest.TestCase): + table_abc, table_efg = Table("abc", alias="cx0"), Table("efg", alias="cx1") + + def test_and(self): + c1 = (Field("foo") == 1) & (Field("bar") == 2) + c2 = (Field("foo", table=self.table_abc) == 1) & (Field("bar", table=self.table_efg) == 2) + + self.assertEqual('"foo"=1 AND "bar"=2', str(c1)) + self.assertEqual('"cx0"."foo"=1 AND "cx1"."bar"=2', str(c2)) + + def test_or(self): + c1 = (Field("foo") == 1) | (Field("bar") == 2) + c2 = (Field("foo", table=self.table_abc) == 1) | (Field("bar", table=self.table_efg) == 2) + + self.assertEqual('"foo"=1 OR "bar"=2', str(c1)) + self.assertEqual('"cx0"."foo"=1 OR "cx1"."bar"=2', str(c2)) + + def test_xor(self): + c1 = (Field("foo") == 1) ^ (Field("bar") == 2) + c2 = (Field("foo", table=self.table_abc) == 1) ^ (Field("bar", table=self.table_efg) == 2) + + self.assertEqual('"foo"=1 XOR "bar"=2', str(c1)) + self.assertEqual('"cx0"."foo"=1 XOR "cx1"."bar"=2', str(c2)) + + def test_function_and(self): + c1 = fn.IsNull(Field("foo")) & (Field("bar") == 2) + + self.assertEqual('ISNULL("foo") AND "bar"=2', str(c1)) + + def test_function_or(self): + c1 = fn.IsNull(Field("foo")) | (Field("bar") == 2) + + self.assertEqual('ISNULL("foo") OR "bar"=2', str(c1)) + + def test_function_xor(self): + c1 = fn.IsNull(Field("foo")) ^ (Field("bar") == 2) + + self.assertEqual('ISNULL("foo") XOR "bar"=2', str(c1)) + + def test__nested__and(self): + c = (Field("foo") == 1) & (Field("bar") == 2) & (Field("buz") == 3) + + self.assertEqual('"foo"=1 AND "bar"=2 AND "buz"=3', str(c)) + + def test__nested__or(self): + c = (Field("foo") == 1) | (Field("bar") == 2) | (Field("buz") == 3) + + self.assertEqual('"foo"=1 OR "bar"=2 OR "buz"=3', str(c)) + + def test__nested__mixed(self): + c = ((Field("foo") == 1) & (Field("bar") == 2)) | (Field("buz") == 3) + + self.assertEqual('("foo"=1 AND "bar"=2) OR "buz"=3', str(c)) + + def test__between_and_isin(self): + c = Field("foo").isin([1, 2, 3]) & Field("bar").between(0, 1) + + self.assertEqual('"foo" IN (1,2,3) AND "bar" BETWEEN 0 AND 1', str(c)) + + def test__between_and_field(self): + c1 = Field("foo").between(0, 1) + c2 = Field("bool_field") + + self.assertEqual('"foo" BETWEEN 0 AND 1 AND "bool_field"', str(c1 & c2)) + self.assertEqual('"bool_field" AND "foo" BETWEEN 0 AND 1', str(c2 & c1)) + + +class FieldsAsCriterionTests(unittest.TestCase): + def test__field_and_field(self): + c1 = Field("a") + c2 = Field("b") + + self.assertEqual('"a" AND "b"', str(c1 & c2)) + + def test__field_or_field(self): + c1 = Field("a") + c2 = Field("b") + + self.assertEqual('"a" OR "b"', str(c1 | c2)) + + def test__field_xor_field(self): + c1 = Field("a") + c2 = Field("b") + + self.assertEqual('"a" XOR "b"', str(c1 ^ c2)) + + +class CriterionOperationsTests(unittest.TestCase): + table_abc, table_efg = Table("abc", alias="cx0"), Table("efg", alias="cx1") + + def test_field_replace_table(self): + f = self.table_abc.foo.replace_table(self.table_abc, self.table_efg) + + self.assertEqual('"cx1"."foo"', str(f)) + + def test_arithmeticfunction_replace_table(self): + f = (self.table_abc.foo + self.table_abc.bar).replace_table(self.table_abc, self.table_efg) + + self.assertEqual('"cx1"."foo"+"cx1"."bar"', str(f)) + + def test_criterion_replace_table(self): + f = (self.table_abc.foo < self.table_abc.bar).replace_table(self.table_abc, self.table_efg) + + self.assertEqual('"cx1"."foo"<"cx1"."bar"', str(f)) + + def test_complexcriterion_replace_table(self): + f = (self.table_abc.foo < self.table_abc.bar) & (self.table_abc.fiz > self.table_abc.buz) + f = f.replace_table(self.table_abc, self.table_efg) + + self.assertEqual('"cx1"."foo"<"cx1"."bar" AND "cx1"."fiz">"cx1"."buz"', str(f)) + + def test_function_with_only_fields_replace_table(self): + f = fn.Sum(self.table_abc.foo).replace_table(self.table_abc, self.table_efg) + + self.assertEqual('SUM("cx1"."foo")', str(f)) + + def test_function_with_values_and_fields_replace_table(self): + f = Mod(self.table_abc.foo, 2).replace_table(self.table_abc, self.table_efg) + + self.assertEqual('MOD("cx1"."foo",2)', str(f)) + + def test_betweencriterion_replace_table(self): + f = self.table_abc.foo[0:1].replace_table(self.table_abc, self.table_efg) + + self.assertEqual('"cx1"."foo" BETWEEN 0 AND 1', str(f)) + + def test_nullcriterion_replace_table(self): + f = self.table_abc.foo.isnull().replace_table(self.table_abc, self.table_efg) + + self.assertEqual('"cx1"."foo" IS NULL', str(f)) + + +class AnyTests(unittest.TestCase): + def test_zero_args_returns_empty_criterion(self): + crit = Criterion.any() + self.assertIsInstance(crit, EmptyCriterion) + + def test_single_arg_returns_self(self): + f = Field("a") + crit = Criterion.any([f]) + self.assertEqual(str(f), str(crit)) + + def test_multiple_args_returned_in_chain_of_ors(self): + crit = Criterion.any([Field("a"), Field("b"), Field("c"), Field("d")]) + self.assertEqual(str(crit), '"a" OR "b" OR "c" OR "d"') + + def test_with_generator(self): + crit = Criterion.any(Field(letter) for letter in "abcd") + self.assertEqual(str(crit), '"a" OR "b" OR "c" OR "d"') + + +class EmptyCriterionTests(unittest.TestCase): + def test_fields_(self): + empty_criterion = EmptyCriterion() + + self.assertEqual(len(empty_criterion.fields_()), 0) + + def test_empty_criterion_on_the_left(self): + t = Table("test1") + q = EmptyCriterion() & t.f1 == "v1" + + self.assertEqual( + '"test1"."f1"=\'v1\'', + q.get_sql(with_namespace=True), + ) + + def test_empty_criterion_on_the_right(self): + t = Table("test1") + q = (t.f1 == "v1") & EmptyCriterion() + + self.assertEqual( + '"test1"."f1"=\'v1\'', + q.get_sql(with_namespace=True), + ) + + def test_invertion_of_the_empty_criterion(self): + t = Table("test1") + q = (t.f1 == "v1") & ~EmptyCriterion() + + self.assertEqual( + '"test1"."f1"=\'v1\'', + q.get_sql(with_namespace=True), + ) + + def test_different_operations_with_empty_criterion(self): + t = Table("test1") + q1 = (t.f1 == "v1") & EmptyCriterion() + q2 = (t.f1 == "v1") | EmptyCriterion() + q3 = (t.f1 == "v1") ^ EmptyCriterion() + + expected_sql = '"test1"."f1"=\'v1\'' + self.assertEqual( + expected_sql, + q1.get_sql(with_namespace=True), + ) + self.assertEqual( + expected_sql, + q2.get_sql(with_namespace=True), + ) + self.assertEqual( + expected_sql, + q3.get_sql(with_namespace=True), + ) + + def test_more_than_one_empty_criterions(self): + t = Table("test1") + q = EmptyCriterion() & ~(EmptyCriterion() | EmptyCriterion()) & (t.f1 == "v1") & ~EmptyCriterion() + + self.assertEqual( + '"test1"."f1"=\'v1\'', + q.get_sql(with_namespace=True), + ) + + +class AllTests(unittest.TestCase): + def test_zero_args_returns_empty_criterion(self): + crit = Criterion.all() + self.assertIsInstance(crit, EmptyCriterion) + + def test_single_arg_returns_self(self): + f = Field("a") + crit = Criterion.all([f]) + self.assertEqual(str(f), str(crit)) + + def test_multiple_args_returned_in_chain_of_ors(self): + crit = Criterion.all([Field("a"), Field("b"), Field("c"), Field("d")]) + self.assertEqual(str(crit), '"a" AND "b" AND "c" AND "d"') + + def test_with_generator(self): + crit = Criterion.all(Field(letter) for letter in "abcd") + self.assertEqual(str(crit), '"a" AND "b" AND "c" AND "d"') diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/test_custom_functions.py b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/test_custom_functions.py new file mode 100644 index 0000000000000000000000000000000000000000..60ffd3cd8e6191e3fc782dac003c41bfb7a78528 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/test_custom_functions.py @@ -0,0 +1,49 @@ +import unittest + +from pypika import CustomFunction, FunctionException, Query, Table + +__author__ = "Airton Zanon" +__email__ = "me@airton.dev" + + +class TestUnitCustomFunction(unittest.TestCase): + def test_should_fail_with_wrong_arguments(self): + DateDiff = CustomFunction("DATE_DIFF", ["interval", "start_date", "end_date"]) + + with self.assertRaises(FunctionException): + DateDiff("foo") + + def test_should_return_function_with_arguments(self): + DateDiff = CustomFunction("DATE_DIFF", ["interval", "start_date", "end_date"]) + + self.assertEqual( + "DATE_DIFF('day','start_date','end_date')", + str(DateDiff("day", "start_date", "end_date")), + ) + + def test_should_return_function_with_no_arguments(self): + CurrentDate = CustomFunction("CURRENT_DATE") + + self.assertEqual("CURRENT_DATE()", str(CurrentDate())) + + +class TestFunctionalCustomFunction(unittest.TestCase): + def test_should_use_custom_function_on_select(self): + service = Table("service") + + DateDiff = CustomFunction("DATE_DIFF", ["interval", "start_date", "end_date"]) + + q = Query.from_(service).select(DateDiff("day", service.created_date, service.updated_date)) + + self.assertEqual( + 'SELECT DATE_DIFF(\'day\',"created_date","updated_date") FROM "service"', + str(q), + ) + + def test_should_fail_use_custom_function_on_select_with_wrong_arguments(self): + service = Table("service") + + DateDiff = CustomFunction("DATE_DIFF", ["interval", "start_date", "end_date"]) + + with self.assertRaises(FunctionException): + Query.from_(service).select(DateDiff("day", service.created_date)) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/test_data_types.py b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/test_data_types.py new file mode 100644 index 0000000000000000000000000000000000000000..52fb4487fe7be3ae28a4e9eb08628fba89dc0f79 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/test_data_types.py @@ -0,0 +1,15 @@ +import unittest +import uuid + +from pypika.terms import ValueWrapper + + +class StringTests(unittest.TestCase): + def test_inline_string_concatentation(self): + self.assertEqual("'it''s'", ValueWrapper("it's").get_sql()) + + +class UuidTests(unittest.TestCase): + def test_uuid_string_generation(self): + id = uuid.uuid4() + self.assertEqual("'{}'".format(id), ValueWrapper(id).get_sql()) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/test_date_math.py b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/test_date_math.py new file mode 100644 index 0000000000000000000000000000000000000000..38db8ef2f8e812a97c6980a7ec6b9a3909d804fb --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/test_date_math.py @@ -0,0 +1,179 @@ +import unittest + +from pypika import ( + Field as F, + Interval, +) +from pypika.enums import Dialects + +dt = F("dt") + + +class AddIntervalTests(unittest.TestCase): + def test_add_microsecond(self): + c = dt + Interval(microseconds=1) + + self.assertEqual("\"dt\"+INTERVAL '1 MICROSECOND'", str(c)) + + def test_add_second(self): + c = dt + Interval(seconds=1) + + self.assertEqual("\"dt\"+INTERVAL '1 SECOND'", str(c)) + + def test_add_minute(self): + c = dt + Interval(minutes=1) + + self.assertEqual("\"dt\"+INTERVAL '1 MINUTE'", str(c)) + + def test_add_day(self): + c = dt + Interval(days=1) + + self.assertEqual("\"dt\"+INTERVAL '1 DAY'", str(c)) + + def test_add_week(self): + c = dt + Interval(weeks=1) + + self.assertEqual("\"dt\"+INTERVAL '1 WEEK'", str(c)) + + def test_add_month(self): + c = dt + Interval(months=1) + + self.assertEqual("\"dt\"+INTERVAL '1 MONTH'", str(c)) + + def test_add_quarter(self): + c = dt + Interval(quarters=1) + + self.assertEqual("\"dt\"+INTERVAL '1 QUARTER'", str(c)) + + def test_add_year(self): + c = dt + Interval(years=1) + + self.assertEqual("\"dt\"+INTERVAL '1 YEAR'", str(c)) + + def test_add_default(self): + c = dt + Interval(days=0) + + self.assertEqual("\"dt\"+INTERVAL '0 DAY'", str(c)) + + +class AddIntervalMultipleUnitsTests(unittest.TestCase): + def test_add_second_microsecond(self): + c = dt + Interval(seconds=1, microseconds=1) + + self.assertEqual("\"dt\"+INTERVAL '1.1 SECOND_MICROSECOND'", str(c)) + + def test_add_minute_microsecond(self): + c = dt + Interval(minutes=1, microseconds=1) + + self.assertEqual("\"dt\"+INTERVAL '1:0.1 MINUTE_MICROSECOND'", str(c)) + + def test_add_minute_second(self): + c = dt + Interval(minutes=1, seconds=1) + + self.assertEqual("\"dt\"+INTERVAL '1:1 MINUTE_SECOND'", str(c)) + + def test_add_hour_microsecond(self): + c = dt + Interval(hours=1, microseconds=1) + + self.assertEqual("\"dt\"+INTERVAL '1:0:0.1 HOUR_MICROSECOND'", str(c)) + + def test_add_hour_second(self): + c = dt + Interval(hours=1, seconds=1) + + self.assertEqual("\"dt\"+INTERVAL '1:0:1 HOUR_SECOND'", str(c)) + + def test_add_hour_minute(self): + c = dt + Interval(hours=1, minutes=1) + + self.assertEqual("\"dt\"+INTERVAL '1:1 HOUR_MINUTE'", str(c)) + + def test_add_day_microsecond(self): + c = dt + Interval(days=1, microseconds=1) + + self.assertEqual("\"dt\"+INTERVAL '1 0:0:0.1 DAY_MICROSECOND'", str(c)) + + def test_add_day_second(self): + c = dt + Interval(days=1, seconds=1) + + self.assertEqual("\"dt\"+INTERVAL '1 0:0:1 DAY_SECOND'", str(c)) + + def test_add_day_minute(self): + c = dt + Interval(days=1, minutes=1) + + self.assertEqual("\"dt\"+INTERVAL '1 0:1 DAY_MINUTE'", str(c)) + + def test_add_day_hour(self): + c = dt + Interval(days=1, hours=1) + + self.assertEqual("\"dt\"+INTERVAL '1 1 DAY_HOUR'", str(c)) + + def test_add_year_month(self): + c = dt + Interval(years=1, months=1) + + self.assertEqual("\"dt\"+INTERVAL '1-1 YEAR_MONTH'", str(c)) + + def test_add_value_right(self): + c = Interval(microseconds=1) - dt + + self.assertEqual("INTERVAL '1 MICROSECOND'-\"dt\"", str(c)) + + def test_add_value_complex_expressions(self): + c = dt + Interval(quarters=1) + Interval(weeks=1) + + self.assertEqual("\"dt\"+INTERVAL '1 QUARTER'+INTERVAL '1 WEEK'", str(c)) + + +class DialectIntervalTests(unittest.TestCase): + def test_mysql_dialect_uses_single_quotes_around_expression_in_an_interval(self): + c = Interval(days=1).get_sql(dialect=Dialects.MYSQL) + self.assertEqual("INTERVAL '1' DAY", c) + + def test_oracle_dialect_uses_single_quotes_around_expression_in_an_interval(self): + c = Interval(days=1).get_sql(dialect=Dialects.ORACLE) + self.assertEqual("INTERVAL '1' DAY", c) + + def test_vertica_dialect_uses_single_quotes_around_interval(self): + c = Interval(days=1).get_sql(dialect=Dialects.VERTICA) + self.assertEqual("INTERVAL '1 DAY'", c) + + def test_redshift_dialect_uses_single_quotes_around_interval(self): + c = Interval(days=1).get_sql(dialect=Dialects.REDSHIFT) + self.assertEqual("INTERVAL '1 DAY'", c) + + def test_postgresql_dialect_uses_single_quotes_around_interval(self): + c = Interval(days=1).get_sql(dialect=Dialects.POSTGRESQL) + self.assertEqual("INTERVAL '1 DAY'", c) + + +class TestNegativeIntervals(unittest.TestCase): + def test_day(self): + c = Interval(days=-1).get_sql() + self.assertEqual("INTERVAL '-1 DAY'", c) + + def test_week(self): + c = Interval(weeks=-1).get_sql() + self.assertEqual("INTERVAL '-1 WEEK'", c) + + def test_month(self): + c = Interval(months=-1).get_sql() + self.assertEqual("INTERVAL '-1 MONTH'", c) + + def test_year(self): + c = Interval(years=-1).get_sql() + self.assertEqual("INTERVAL '-1 YEAR'", c) + + def test_year_month(self): + c = Interval(years=-1, months=-4).get_sql() + self.assertEqual("INTERVAL '-1-4 YEAR_MONTH'", c) + + +class TruncateTrailingZerosTests(unittest.TestCase): + def test_do_not_truncate_integer_values(self): + i = Interval(seconds=10) + + self.assertEqual("INTERVAL '10 SECOND'", str(i)) + + def test_do_not_truncate_months_between_years_and_datys(self): + i = Interval(years=10, days=10) + + self.assertEqual("INTERVAL '10-0-10 YEAR_DAY'", str(i)) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/test_deletes.py b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/test_deletes.py new file mode 100644 index 0000000000000000000000000000000000000000..09df93f5331b845b0c3aed628bf1c4a3ec6b0f02 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/test_deletes.py @@ -0,0 +1,97 @@ +import unittest + +from pypika import PostgreSQLQuery, Query, SYSTEM_TIME, Table + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + +from pypika.terms import Star + + +class DeleteTests(unittest.TestCase): + @classmethod + def setUpClass(cls) -> None: + super().setUpClass() + cls.table_abc = Table("abc") + + def test_omit_where(self): + q = Query.from_("abc").delete() + + self.assertEqual('DELETE FROM "abc"', str(q)) + + def test_omit_where__table_schema(self): + q = Query.from_(Table("abc", "schema1")).delete() + + self.assertEqual('DELETE FROM "schema1"."abc"', str(q)) + + def test_where_field_equals(self): + q1 = Query.from_(self.table_abc).where(self.table_abc.foo == self.table_abc.bar).delete() + q2 = Query.from_(self.table_abc).where(self.table_abc.foo.eq(self.table_abc.bar)).delete() + + self.assertEqual('DELETE FROM "abc" WHERE "foo"="bar"', str(q1)) + self.assertEqual('DELETE FROM "abc" WHERE "foo"="bar"', str(q2)) + + def test_for_portion(self): + with self.subTest("with system time"): + q = Query.from_(self.table_abc.for_portion(SYSTEM_TIME.from_to('2020-01-01', '2020-02-01'))).delete() + + self.assertEqual( + 'DELETE FROM "abc" FOR PORTION OF SYSTEM_TIME FROM \'2020-01-01\' TO \'2020-02-01\'', str(q) + ) + + with self.subTest("with column"): + q = Query.from_( + self.table_abc.for_portion(self.table_abc.valid_period.from_to('2020-01-01', '2020-02-01')) + ).delete() + + self.assertEqual( + 'DELETE FROM "abc" FOR PORTION OF "valid_period" FROM \'2020-01-01\' TO \'2020-02-01\'', str(q) + ) + + +class PostgresDeleteTests(unittest.TestCase): + @classmethod + def setUpClass(cls) -> None: + super().setUpClass() + cls.table_abc = Table("abc") + + def test_delete_returning(self): + q1 = ( + PostgreSQLQuery.from_(self.table_abc) + .where(self.table_abc.foo == self.table_abc.bar) + .delete() + .returning(self.table_abc.id) + ) + + self.assertEqual('DELETE FROM "abc" WHERE "foo"="bar" RETURNING "id"', str(q1)) + + def test_delete_returning_str(self): + q1 = ( + PostgreSQLQuery.from_(self.table_abc) + .where(self.table_abc.foo == self.table_abc.bar) + .delete() + .returning("id") + ) + + self.assertEqual('DELETE FROM "abc" WHERE "foo"="bar" RETURNING "id"', str(q1)) + + def test_delete_returning_star(self): + q1 = ( + PostgreSQLQuery.from_(self.table_abc) + .where(self.table_abc.foo == self.table_abc.bar) + .delete() + .returning(Star()) + ) + + self.assertEqual('DELETE FROM "abc" WHERE "foo"="bar" RETURNING *', str(q1)) + + def test_delete_using(self): + table_trash = Table('trash') + q1 = ( + PostgreSQLQuery.from_(self.table_abc) + .using(table_trash) + .where(self.table_abc.id == table_trash.abc_id) + .delete() + ) + + self.assertEqual('DELETE FROM "abc" USING "trash" WHERE "abc"."id"="trash"."abc_id"', str(q1)) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/test_drop.py b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/test_drop.py new file mode 100644 index 0000000000000000000000000000000000000000..265ae7350d2054549731f9a8c4379fdac95dc580 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/test_drop.py @@ -0,0 +1,49 @@ +import unittest + +from pypika import ( + Columns, + Database, + Query, + Tables, +) + + +class DropTableTests(unittest.TestCase): + database_xyz = Database("mydb") + new_table, existing_table = Tables("abc", "efg") + foo, bar = Columns(("a", "INT"), ("b", "VARCHAR(100)")) + + def test_drop_database(self): + q1 = Query.drop_database(self.database_xyz) + q2 = Query.drop_database(self.database_xyz).if_exists() + + self.assertEqual('DROP DATABASE "mydb"', str(q1)) + self.assertEqual('DROP DATABASE IF EXISTS "mydb"', str(q2)) + + def test_drop_table(self): + q1 = Query.drop_table(self.new_table) + q2 = Query.drop_table(self.new_table).if_exists() + + self.assertEqual('DROP TABLE "abc"', str(q1)) + self.assertEqual('DROP TABLE IF EXISTS "abc"', str(q2)) + + def test_drop_user(self): + q1 = Query.drop_user("myuser") + q2 = Query.drop_user("myuser").if_exists() + + self.assertEqual('DROP USER "myuser"', str(q1)) + self.assertEqual('DROP USER IF EXISTS "myuser"', str(q2)) + + def test_drop_view(self): + q1 = Query.drop_view("myview") + q2 = Query.drop_view("myview").if_exists() + + self.assertEqual('DROP VIEW "myview"', str(q1)) + self.assertEqual('DROP VIEW IF EXISTS "myview"', str(q2)) + + def test_drop_index(self): + q1 = Query.drop_index("myindex") + q2 = Query.drop_index("myindex").if_exists() + + self.assertEqual('DROP INDEX "myindex"', str(q1)) + self.assertEqual('DROP INDEX IF EXISTS "myindex"', str(q2)) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/test_formats.py b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/test_formats.py new file mode 100644 index 0000000000000000000000000000000000000000..6a442757c6659a215661e03f1ca9c3771d394d96 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/test_formats.py @@ -0,0 +1,68 @@ +import unittest + +from pypika import Query, Tables, functions as fn + + +class QuoteTests(unittest.TestCase): + maxDiff = None + + table_abc, table_efg = Tables("abc", "efg") + + def setUp(self): + subquery1 = ( + Query.from_(self.table_abc) + .select( + self.table_abc.foo, + fn.Sum(self.table_abc.fizz + self.table_abc.buzz).as_("fizzbuzz"), + ) + .groupby(self.table_abc.foo) + ) + + subquery2 = Query.from_(self.table_efg).select( + self.table_efg.foo.as_("foo_two"), + self.table_efg.bar, + ) + + self.query = ( + Query.from_(subquery1) + .select(subquery1.foo, subquery1.fizzbuzz) + .join(subquery2) + .on(subquery1.foo == subquery2.foo_two) + .select(subquery2.foo_two, subquery2.bar) + ) + + def test_replace_quote_char_in_complex_query(self): + self.assertEqual( + "SELECT " + "`sq0`.`foo`,`sq0`.`fizzbuzz`," + "`sq1`.`foo_two`,`sq1`.`bar` " + "FROM (" + "SELECT " + "`foo`,SUM(`fizz`+`buzz`) `fizzbuzz` " + "FROM `abc` " + "GROUP BY `foo`" + ") `sq0` JOIN (" + "SELECT " + "`foo` `foo_two`,`bar` " + "FROM `efg`" + ") `sq1` ON `sq0`.`foo`=`sq1`.`foo_two`", + self.query.get_sql(quote_char="`"), + ) + + def test_no_quote_char_in_complex_query(self): + self.assertEqual( + "SELECT " + "sq0.foo,sq0.fizzbuzz," + "sq1.foo_two,sq1.bar " + "FROM (" + "SELECT " + "foo,SUM(fizz+buzz) fizzbuzz " + "FROM abc " + "GROUP BY foo" + ") sq0 JOIN (" + "SELECT " + "foo foo_two,bar " + "FROM efg" + ") sq1 ON sq0.foo=sq1.foo_two", + self.query.get_sql(quote_char=None), + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/test_functions.py b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/test_functions.py new file mode 100644 index 0000000000000000000000000000000000000000..f526966eefc554ec68d0e15fb69de7d69f1604c3 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/test_functions.py @@ -0,0 +1,847 @@ +import unittest + +from pypika import ( + Case, + CaseException, + DatePart, + Field as F, + Query, + Query as Q, + Schema, + Table as T, + VerticaQuery, + functions as fn, +) +from pypika.enums import Dialects, SqlTypes + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + + +class FunctionTests(unittest.TestCase): + def test_dialect_propagation(self): + func = fn.Function("func", ["a"], ["b"]) + self.assertEqual("func(ARRAY['a'],ARRAY['b'])", func.get_sql(dialect=Dialects.POSTGRESQL)) + + def test_is_aggregate_None_for_non_aggregate_function_or_function_with_no_aggregate_functions(self): + self.assertIsNone(fn.Coalesce('a', 0).is_aggregate) + self.assertIsNone(fn.Coalesce(fn.NullIf('a', 0), 0).is_aggregate) + + def test_is_aggregate_True_for_aggregate_function_or_function_with_aggregate_functions(self): + self.assertTrue(fn.Sum('a').is_aggregate) + self.assertTrue(fn.Coalesce(fn.Avg('a'), 0).is_aggregate) + self.assertTrue(fn.Coalesce(fn.NullIf(fn.Sum('a'), 0), 0).is_aggregate) + + +class SchemaTests(unittest.TestCase): + def test_schema_no_schema_in_sql_when_none_set(self): + func = fn.Function("my_proc", 1, 2, 3) + + self.assertEqual("my_proc(1,2,3)", func.get_sql(quote_char='"')) + + def test_schema_included_in_function_sql(self): + a = Schema("a") + func = fn.Function("my_proc", 1, 2, 3, schema=a) + + self.assertEqual('"a".my_proc(1,2,3)', func.get_sql(quote_char='"')) + + +class ArithmeticTests(unittest.TestCase): + t = T("abc") + + def test__addition__fields(self): + q1 = Q.from_("abc").select(F("a") + F("b")) + q2 = Q.from_(self.t).select(self.t.a + self.t.b) + + self.assertEqual('SELECT "a"+"b" FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"+"b" FROM "abc"', str(q2)) + + def test__addition__number(self): + q1 = Q.from_("abc").select(F("a") + 1) + q2 = Q.from_(self.t).select(self.t.a + 1) + + self.assertEqual('SELECT "a"+1 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"+1 FROM "abc"', str(q2)) + + def test__addition__decimal(self): + q1 = Q.from_("abc").select(F("a") + 1.0) + q2 = Q.from_(self.t).select(self.t.a + 1.0) + + self.assertEqual('SELECT "a"+1.0 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"+1.0 FROM "abc"', str(q2)) + + def test__addition__right(self): + q1 = Q.from_("abc").select(1 + F("a")) + q2 = Q.from_(self.t).select(1 + self.t.a) + + self.assertEqual('SELECT 1+"a" FROM "abc"', str(q1)) + self.assertEqual('SELECT 1+"a" FROM "abc"', str(q2)) + + def test__subtraction__fields(self): + q1 = Q.from_("abc").select(F("a") - F("b")) + q2 = Q.from_(self.t).select(self.t.a - self.t.b) + + self.assertEqual('SELECT "a"-"b" FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"-"b" FROM "abc"', str(q2)) + + def test__subtraction__number(self): + q1 = Q.from_("abc").select(F("a") - 1) + q2 = Q.from_(self.t).select(self.t.a - 1) + + self.assertEqual('SELECT "a"-1 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"-1 FROM "abc"', str(q2)) + + def test__subtraction__decimal(self): + q1 = Q.from_("abc").select(F("a") - 1.0) + q2 = Q.from_(self.t).select(self.t.a - 1.0) + + self.assertEqual('SELECT "a"-1.0 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"-1.0 FROM "abc"', str(q2)) + + def test__subtraction__right(self): + q1 = Q.from_("abc").select(1 - F("a")) + q2 = Q.from_(self.t).select(1 - self.t.a) + + self.assertEqual('SELECT 1-"a" FROM "abc"', str(q1)) + self.assertEqual('SELECT 1-"a" FROM "abc"', str(q2)) + + def test__multiplication__fields(self): + q1 = Q.from_("abc").select(F("a") * F("b")) + q2 = Q.from_(self.t).select(self.t.a * self.t.b) + + self.assertEqual('SELECT "a"*"b" FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"*"b" FROM "abc"', str(q2)) + + def test__multiplication__number(self): + q1 = Q.from_("abc").select(F("a") * 1) + q2 = Q.from_(self.t).select(self.t.a * 1) + + self.assertEqual('SELECT "a"*1 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"*1 FROM "abc"', str(q2)) + + def test__multiplication__decimal(self): + q1 = Q.from_("abc").select(F("a") * 1.0) + q2 = Q.from_(self.t).select(self.t.a * 1.0) + + self.assertEqual('SELECT "a"*1.0 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"*1.0 FROM "abc"', str(q2)) + + def test__multiplication__right(self): + q1 = Q.from_("abc").select(1 * F("a")) + q2 = Q.from_(self.t).select(1 * self.t.a) + + self.assertEqual('SELECT 1*"a" FROM "abc"', str(q1)) + self.assertEqual('SELECT 1*"a" FROM "abc"', str(q2)) + + def test__division__fields(self): + q1 = Q.from_("abc").select(F("a") / F("b")) + q2 = Q.from_(self.t).select(self.t.a / self.t.b) + + self.assertEqual('SELECT "a"/"b" FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"/"b" FROM "abc"', str(q2)) + + def test__division__number(self): + q1 = Q.from_("abc").select(F("a") / 1) + q2 = Q.from_(self.t).select(self.t.a / 1) + + self.assertEqual('SELECT "a"/1 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"/1 FROM "abc"', str(q2)) + + def test__division__decimal(self): + q1 = Q.from_("abc").select(F("a") / 1.0) + q2 = Q.from_(self.t).select(self.t.a / 1.0) + + self.assertEqual('SELECT "a"/1.0 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"/1.0 FROM "abc"', str(q2)) + + def test__division__right(self): + q1 = Q.from_("abc").select(1 / F("a")) + q2 = Q.from_(self.t).select(1 / self.t.a) + + self.assertEqual('SELECT 1/"a" FROM "abc"', str(q1)) + self.assertEqual('SELECT 1/"a" FROM "abc"', str(q2)) + + def test__leftshift__fields(self): + q1 = Q.from_("abc").select(F("a") << F("b")) + q2 = Q.from_(self.t).select(self.t.a << self.t.b) + + self.assertEqual('SELECT "a"<<"b" FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"<<"b" FROM "abc"', str(q2)) + + def test__leftshift__number(self): + q1 = Q.from_("abc").select(F('a') << 2) + q2 = Q.from_(self.t).select(self.t.a << 2) + + self.assertEqual('SELECT "a"<<2 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"<<2 FROM "abc"', str(q2)) + + def test__leftshift__right(self): + q1 = Q.from_("abc").select(1 << F("a")) + q2 = Q.from_(self.t).select(1 << self.t.a) + + self.assertEqual('SELECT 1<<"a" FROM "abc"', str(q1)) + self.assertEqual('SELECT 1<<"a" FROM "abc"', str(q2)) + + def test__rightshift__fields(self): + q1 = Q.from_("abc").select(F("a") >> F("b")) + q2 = Q.from_(self.t).select(self.t.a >> self.t.b) + + self.assertEqual('SELECT "a">>"b" FROM "abc"', str(q1)) + self.assertEqual('SELECT "a">>"b" FROM "abc"', str(q2)) + + def test__rightshift__number(self): + q1 = Q.from_("abc").select(F('a') >> 2) + q2 = Q.from_(self.t).select(self.t.a >> 2) + + self.assertEqual('SELECT "a">>2 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a">>2 FROM "abc"', str(q2)) + + def test__rightshift__right(self): + q1 = Q.from_("abc").select(1 >> F("a")) + q2 = Q.from_(self.t).select(1 >> self.t.a) + + self.assertEqual('SELECT 1>>"a" FROM "abc"', str(q1)) + self.assertEqual('SELECT 1>>"a" FROM "abc"', str(q2)) + + def test__complex_op(self): + q1 = Q.from_("abc").select(2 + 1 / F("a") - 5) + q2 = Q.from_(self.t).select(2 + 1 / self.t.a - 5) + + self.assertEqual('SELECT 2+1/"a"-5 FROM "abc"', str(q1)) + self.assertEqual('SELECT 2+1/"a"-5 FROM "abc"', str(q2)) + + def test__complex_op_add_parentheses(self): + q1 = Q.from_("abc").select((F("a") + 1) + (F("b") - 5)) + q2 = Q.from_(self.t).select((self.t.a + 1) + (self.t.b - 5)) + q3 = Q.from_("abc").select((F("a") / 1) + (F("b") / 5)) + q4 = Q.from_(self.t).select((self.t.a / 1) + (self.t.b / 5)) + + self.assertEqual('SELECT "a"+1+"b"-5 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"+1+"b"-5 FROM "abc"', str(q2)) + self.assertEqual('SELECT "a"/1+"b"/5 FROM "abc"', str(q3)) + self.assertEqual('SELECT "a"/1+"b"/5 FROM "abc"', str(q4)) + + def test__complex_op_sub_parentheses(self): + q1 = Q.from_("abc").select((F("a") + 1) - (F("b") - 5)) + q2 = Q.from_(self.t).select((self.t.a + 1) - (self.t.b - 5)) + q3 = Q.from_("abc").select((F("a") / 1) - (F("b") / 5)) + q4 = Q.from_(self.t).select((self.t.a / 1) - (self.t.b / 5)) + + self.assertEqual('SELECT "a"+1-("b"-5) FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"+1-("b"-5) FROM "abc"', str(q2)) + self.assertEqual('SELECT "a"/1-"b"/5 FROM "abc"', str(q3)) + self.assertEqual('SELECT "a"/1-"b"/5 FROM "abc"', str(q4)) + + def test__complex_op_mul_parentheses(self): + q1 = Q.from_("abc").select((F("a") + 1) * (F("b") - 5)) + q2 = Q.from_(self.t).select((self.t.a + 1) * (self.t.b - 5)) + q3 = Q.from_("abc").select((F("a") / 1) * (F("b") - 5)) + q4 = Q.from_(self.t).select((self.t.a / 1) * (self.t.b - 5)) + q5 = Q.from_("abc").select((F("a") + 1) * (F("b") / 5)) + q6 = Q.from_(self.t).select((self.t.a + 1) * (self.t.b / 5)) + + self.assertEqual('SELECT ("a"+1)*("b"-5) FROM "abc"', str(q1)) + self.assertEqual('SELECT ("a"+1)*("b"-5) FROM "abc"', str(q2)) + self.assertEqual('SELECT "a"/1*("b"-5) FROM "abc"', str(q3)) + self.assertEqual('SELECT "a"/1*("b"-5) FROM "abc"', str(q4)) + self.assertEqual('SELECT ("a"+1)*"b"/5 FROM "abc"', str(q5)) + self.assertEqual('SELECT ("a"+1)*"b"/5 FROM "abc"', str(q6)) + + def test__complex_op_mul_no_parentheses(self): + q = Q.from_("abc").select(F("a") + 1 * F("b") - 5) + + self.assertEqual('SELECT "a"+1*"b"-5 FROM "abc"', str(q)) + + def test__complex_op_div_parentheses(self): + q1 = Q.from_("abc").select((F("a") + 1) / (F("b") - 5)) + q2 = Q.from_(self.t).select((self.t.a + 1) / (self.t.b - 5)) + q3 = Q.from_("abc").select((F("a") / 1) / (F("b") - 5)) + q4 = Q.from_(self.t).select((self.t.a / 1) / (self.t.b - 5)) + q5 = Q.from_("abc").select((F("a") + 1) / (F("b") * 5)) + q6 = Q.from_(self.t).select((self.t.a + 1) / (self.t.b * 5)) + + self.assertEqual('SELECT ("a"+1)/("b"-5) FROM "abc"', str(q1)) + self.assertEqual('SELECT ("a"+1)/("b"-5) FROM "abc"', str(q2)) + self.assertEqual('SELECT "a"/1/("b"-5) FROM "abc"', str(q3)) + self.assertEqual('SELECT "a"/1/("b"-5) FROM "abc"', str(q4)) + self.assertEqual('SELECT ("a"+1)/("b"*5) FROM "abc"', str(q5)) + self.assertEqual('SELECT ("a"+1)/("b"*5) FROM "abc"', str(q6)) + + def test__complex_op_div_no_parentheses(self): + q = Q.from_("abc").select(F("a") + 1 / F("b") - 5) + + self.assertEqual('SELECT "a"+1/"b"-5 FROM "abc"', str(q)) + + def test__complex_op_exponent_parentheses(self): + q1 = Q.from_("abc").select(F("a") / (F("b") ** 2)) + q2 = Q.from_(self.t).select(self.t.a / (self.t.b**2)) + q3 = Q.from_("abc").select(F("a") ** (F("b") / 2)) + q4 = Q.from_(self.t).select(self.t.a ** (self.t.b / 2)) + q5 = Q.from_("abc").select((F("a") ** F("b")) ** 2) + q6 = Q.from_(self.t).select((self.t.a**self.t.b) ** 2) + + self.assertEqual('SELECT "a"/POW("b",2) FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"/POW("b",2) FROM "abc"', str(q2)) + self.assertEqual('SELECT POW("a","b"/2) FROM "abc"', str(q3)) + self.assertEqual('SELECT POW("a","b"/2) FROM "abc"', str(q4)) + self.assertEqual('SELECT POW(POW("a","b"),2) FROM "abc"', str(q5)) + self.assertEqual('SELECT POW(POW("a","b"),2) FROM "abc"', str(q6)) + + def test__complex_op_exponent_no_parentheses(self): + q1 = Q.from_("abc").select(F("a") ** F("b") ** 2) + q2 = Q.from_(self.t).select(self.t.a**self.t.b**2) + q3 = Q.from_("abc").select(F("a") / F("b") ** 2) + q4 = Q.from_(self.t).select(self.t.a / self.t.b**2) + + self.assertEqual('SELECT POW("a",POW("b",2)) FROM "abc"', str(q1)) + self.assertEqual('SELECT POW("a",POW("b",2)) FROM "abc"', str(q2)) + self.assertEqual('SELECT "a"/POW("b",2) FROM "abc"', str(q3)) + self.assertEqual('SELECT "a"/POW("b",2) FROM "abc"', str(q4)) + + def test__complex_op_function_parentheses(self): + q1 = Q.from_("abc").select(F("a") / (fn.Sum(F("b")) / 2)) + q2 = Q.from_("abc").select(self.t.a / (fn.Sum(self.t.b) / 2)) + q3 = Q.from_("abc").select(fn.Sum(F("a") / (F("b") / 2))) + q4 = Q.from_("abc").select(fn.Sum(self.t.a / (self.t.b / 2))) + + self.assertEqual('SELECT "a"/(SUM("b")/2) FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"/(SUM("b")/2) FROM "abc"', str(q2)) + self.assertEqual('SELECT SUM("a"/("b"/2)) FROM "abc"', str(q3)) + self.assertEqual('SELECT SUM("a"/("b"/2)) FROM "abc"', str(q4)) + + def test__complex_op_modulus_parentheses(self): + q1 = Q.from_("abc").select(F("a") / (F("b") % 2)) + q2 = Q.from_(self.t).select(self.t.a / (self.t.b % 2)) + q3 = Q.from_("abc").select(F("a") % (F("b") / 2)) + q4 = Q.from_(self.t).select(self.t.a % (self.t.b / 2)) + q5 = Q.from_("abc").select(F("a") % (F("b") % 2)) + q6 = Q.from_("abc").select(self.t.a % (self.t.b % 2)) + + self.assertEqual('SELECT "a"/MOD("b",2) FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"/MOD("b",2) FROM "abc"', str(q2)) + self.assertEqual('SELECT MOD("a","b"/2) FROM "abc"', str(q3)) + self.assertEqual('SELECT MOD("a","b"/2) FROM "abc"', str(q4)) + self.assertEqual('SELECT MOD("a",MOD("b",2)) FROM "abc"', str(q5)) + self.assertEqual('SELECT MOD("a",MOD("b",2)) FROM "abc"', str(q6)) + + def test__complex_op_modulus_no_parentheses(self): + q1 = Q.from_("abc").select(F("a") % F("b") % 2) + q2 = Q.from_(self.t).select(self.t.a % self.t.b % 2) + q3 = Q.from_("abc").select(F("a") / F("b") % 2) + q4 = Q.from_(self.t).select(self.t.a / self.t.b % 2) + + self.assertEqual('SELECT MOD(MOD("a","b"),2) FROM "abc"', str(q1)) + self.assertEqual('SELECT MOD(MOD("a","b"),2) FROM "abc"', str(q2)) + self.assertEqual('SELECT MOD("a"/"b",2) FROM "abc"', str(q3)) + self.assertEqual('SELECT MOD("a"/"b",2) FROM "abc"', str(q4)) + + def test__complex_op_floor_parentheses(self): + q1 = Q.from_("abc").select(F("a") / (fn.Floor(F("b")) / 2)) + q2 = Q.from_("abc").select(self.t.a / (fn.Floor(self.t.b) / 2)) + q3 = Q.from_("abc").select(fn.Floor(F("a") / (F("b") / 2))) + q4 = Q.from_("abc").select(fn.Floor(self.t.a / (self.t.b / 2))) + + self.assertEqual('SELECT "a"/(FLOOR("b")/2) FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"/(FLOOR("b")/2) FROM "abc"', str(q2)) + self.assertEqual('SELECT FLOOR("a"/("b"/2)) FROM "abc"', str(q3)) + self.assertEqual('SELECT FLOOR("a"/("b"/2)) FROM "abc"', str(q4)) + + def test__complex_op_nested_parentheses(self): + q1 = Q.from_("abc").select(F("a") / (F("b") / ((F("c") / 2)))) + q2 = Q.from_("abc").select(self.t.a / (self.t.b / ((self.t.c / 2)))) + + self.assertEqual('SELECT "a"/("b"/("c"/2)) FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"/("b"/("c"/2)) FROM "abc"', str(q2)) + + def test__arithmetic_equality(self): + q1 = Q.from_("abc").select(F("a") / 2 == 2) + q2 = Q.from_(self.t).select(self.t.a / 2 == 2) + + self.assertEqual('SELECT "a"/2=2 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"/2=2 FROM "abc"', str(q2)) + + def test__arithmetic_with_function(self): + q1 = Q.from_("abc").select(fn.Sum(F("foo")) + 1) + q2 = Q.from_(self.t).select(fn.Sum(self.t.foo) + 1) + + self.assertEqual('SELECT SUM("foo")+1 FROM "abc"', str(q1)) + self.assertEqual('SELECT SUM("foo")+1 FROM "abc"', str(q2)) + + def test__exponent__number(self): + q1 = Q.from_("abc").select(F("a") ** 2) + q2 = Q.from_(self.t).select(self.t.a**2) + + self.assertEqual('SELECT POW("a",2) FROM "abc"', str(q1)) + self.assertEqual('SELECT POW("a",2) FROM "abc"', str(q2)) + + def test__exponent__decimal(self): + q1 = Q.from_("abc").select(F("a") ** 0.5) + q2 = Q.from_(self.t).select(self.t.a**0.5) + + self.assertEqual('SELECT POW("a",0.5) FROM "abc"', str(q1)) + self.assertEqual('SELECT POW("a",0.5) FROM "abc"', str(q2)) + + def test__modulus__number(self): + q1 = Q.from_("abc").select(F("a") % 2) + q2 = Q.from_(self.t).select(self.t.a % 2) + + self.assertEqual('SELECT MOD("a",2) FROM "abc"', str(q1)) + self.assertEqual('SELECT MOD("a",2) FROM "abc"', str(q2)) + + def test__floor(self): + q1 = Q.from_("abc").select(fn.Floor(F("foo"))) + q2 = Q.from_(self.t).select(fn.Floor(self.t.foo)) + + self.assertEqual('SELECT FLOOR("foo") FROM "abc"', str(q1)) + self.assertEqual('SELECT FLOOR("foo") FROM "abc"', str(q2)) + + +class AggregationTests(unittest.TestCase): + def test__count(self): + q = Q.from_("abc").select(fn.Count(F("foo"))) + + self.assertEqual('SELECT COUNT("foo") FROM "abc"', str(q)) + + def test__count__star(self): + q = Q.from_("abc").select(fn.Count("*")) + + self.assertEqual('SELECT COUNT(*) FROM "abc"', str(q)) + + def test__sum(self): + q = Q.from_("abc").select(fn.Sum(F("foo"))) + + self.assertEqual('SELECT SUM("foo") FROM "abc"', str(q)) + + def test__avg(self): + q = Q.from_("abc").select(fn.Avg(F("foo"))) + + self.assertEqual('SELECT AVG("foo") FROM "abc"', str(q)) + + def test__first(self): + q = Q.from_("abc").select(fn.First(F("foo"))) + + self.assertEqual('SELECT FIRST("foo") FROM "abc"', str(q)) + + def test__last(self): + q = Q.from_("abc").select(fn.Last(F("foo"))) + + self.assertEqual('SELECT LAST("foo") FROM "abc"', str(q)) + + def test__min(self): + q = Q.from_("abc").select(fn.Min(F("foo"))) + + self.assertEqual('SELECT MIN("foo") FROM "abc"', str(q)) + + def test__max(self): + q = Q.from_("abc").select(fn.Max(F("foo"))) + + self.assertEqual('SELECT MAX("foo") FROM "abc"', str(q)) + + def test__std(self): + q = Q.from_("abc").select(fn.Std(F("foo"))) + + self.assertEqual('SELECT STD("foo") FROM "abc"', str(q)) + + def test__stddev(self): + q = Q.from_("abc").select(fn.StdDev(F("foo"))) + + self.assertEqual('SELECT STDDEV("foo") FROM "abc"', str(q)) + + def test__approx_percentile(self): + q = Q.from_("abc").select(fn.ApproximatePercentile(F("foo"), 0.5)) + + self.assertEqual( + 'SELECT APPROXIMATE_PERCENTILE("foo" USING PARAMETERS percentile=0.5) FROM "abc"', + str(q), + ) + + def test__subquery_in_params_functions(self): + subquery = Query.from_('table').select('id') + func = fn.Function('func', 'id', subquery) + self.assertEqual("func('id',(SELECT id FROM table))", func.get_sql()) + + +class ConditionTests(unittest.TestCase): + def test__case__raw(self): + q = Q.from_("abc").select(Case().when(F("foo") == 1, "a")) + + self.assertEqual('SELECT CASE WHEN "foo"=1 THEN \'a\' END FROM "abc"', str(q)) + + def test__case__else(self): + q = Q.from_("abc").select(Case().when(F("foo") == 1, "a").else_("b")) + + self.assertEqual("SELECT CASE WHEN \"foo\"=1 THEN 'a' ELSE 'b' END FROM \"abc\"", str(q)) + + def test__case__field(self): + q = Q.from_("abc").select(Case().when(F("foo") == 1, F("bar")).else_(F("buz"))) + + self.assertEqual('SELECT CASE WHEN "foo"=1 THEN "bar" ELSE "buz" END FROM "abc"', str(q)) + + def test__case__multi(self): + q = Q.from_("abc").select(Case().when(F("foo") > 0, F("fiz")).when(F("bar") <= 0, F("buz")).else_(1)) + + self.assertEqual( + 'SELECT CASE WHEN "foo">0 THEN "fiz" WHEN "bar"<=0 THEN "buz" ELSE 1 END FROM "abc"', + str(q), + ) + + def test__case__no_cases(self): + with self.assertRaises(CaseException): + q = Q.from_("abc").select(Case()) + + str(q) + + +class StringTests(unittest.TestCase): + t = T("abc") + + def test__ascii__str(self): + q = Q.select(fn.Ascii("2")) + + self.assertEqual("SELECT ASCII('2')", str(q)) + + def test__ascii__int(self): + q = Q.select(fn.Ascii(2)) + + self.assertEqual("SELECT ASCII(2)", str(q)) + + def test__ascii__field(self): + q = Q.from_(self.t).select(fn.Ascii(self.t.foo)) + + self.assertEqual('SELECT ASCII("foo") FROM "abc"', str(q)) + + def test__bin__str(self): + q = Q.select(fn.Bin("2")) + + self.assertEqual("SELECT BIN('2')", str(q)) + + def test__bin__int(self): + q = Q.select(fn.Bin(2)) + + self.assertEqual("SELECT BIN(2)", str(q)) + + def test__bin__field(self): + q = Q.from_(self.t).select(fn.Bin(self.t.foo)) + + self.assertEqual('SELECT BIN("foo") FROM "abc"', str(q)) + + def test__concat__str(self): + q = Q.select(fn.Concat("p", "y", "q", "b")) + + self.assertEqual("SELECT CONCAT('p','y','q','b')", str(q)) + + def test__concat__field(self): + q = Q.from_(self.t).select(fn.Concat(self.t.foo, self.t.bar)) + + self.assertEqual('SELECT CONCAT("foo","bar") FROM "abc"', str(q)) + + def test__insert__str(self): + q = Q.select(fn.Insert("Quadratic", 3, 4, "What")) + + self.assertEqual("SELECT INSERT('Quadratic',3,4,'What')", str(q)) + + def test__insert__field(self): + q = Q.from_(self.t).select(fn.Insert(self.t.foo, 3, 4, self.t.bar)) + + self.assertEqual('SELECT INSERT("foo",3,4,"bar") FROM "abc"', str(q)) + + def test__lower__str(self): + q = Q.select(fn.Lower("ABC")) + + self.assertEqual("SELECT LOWER('ABC')", str(q)) + + def test__lower__field(self): + q = Q.from_(self.t).select(fn.Lower(self.t.foo)) + + self.assertEqual('SELECT LOWER("foo") FROM "abc"', str(q)) + + def test__length__str(self): + q = Q.select(fn.Length("ABC")) + + self.assertEqual("SELECT LENGTH('ABC')", str(q)) + + def test__length__field(self): + q = Q.from_(self.t).select(fn.Length(self.t.foo)) + + self.assertEqual('SELECT LENGTH("foo") FROM "abc"', str(q)) + + def test__substring(self): + q = Q.from_(self.t).select(fn.Substring(self.t.foo, 2, 6)) + + self.assertEqual('SELECT SUBSTRING("foo",2,6) FROM "abc"', str(q)) + + def test__replace__str(self): + q = Q.select(fn.Replace("ABC_DEF", "_", " ")) + self.assertEqual("SELECT REPLACE('ABC_DEF','_',' ')", str(q)) + + def test__replace__field(self): + q = Q.from_(self.t).select(fn.Replace(self.t.foobar, self.t.foo, self.t.bar)) + self.assertEqual('SELECT REPLACE("foobar","foo","bar") FROM "abc"', str(q)) + + +class SplitPartFunctionTests(unittest.TestCase): + t = T("abc") + + def test__split_part(self): + q = VerticaQuery.from_(self.t).select(fn.SplitPart(self.t.foo, "|", 3)) + + self.assertEqual('SELECT SPLIT_PART("foo",\'|\',3) FROM "abc"', str(q)) + + +class RegexpLikeFunctionTests(unittest.TestCase): + t = T("abc") + + def test__regexp_like(self): + q = VerticaQuery.from_(self.t).select(fn.RegexpLike(self.t.foo, "^a", "x")) + + self.assertEqual("SELECT REGEXP_LIKE(\"foo\",'^a','x') FROM \"abc\"", str(q)) + + +class CastTests(unittest.TestCase): + t = T("abc") + + def test__cast__as(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.UNSIGNED)) + + self.assertEqual('SELECT CAST("foo" AS UNSIGNED) FROM "abc"', str(q)) + + def test__cast__signed(self): + q1 = Q.from_(self.t).select(fn.Signed(self.t.foo)) + q2 = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.SIGNED)) + + self.assertEqual('SELECT CAST("foo" AS SIGNED) FROM "abc"', str(q1)) + self.assertEqual('SELECT CAST("foo" AS SIGNED) FROM "abc"', str(q2)) + + def test__cast__unsigned(self): + q1 = Q.from_(self.t).select(fn.Unsigned(self.t.foo)) + q2 = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.UNSIGNED)) + + self.assertEqual('SELECT CAST("foo" AS UNSIGNED) FROM "abc"', str(q1)) + self.assertEqual('SELECT CAST("foo" AS UNSIGNED) FROM "abc"', str(q2)) + + def test__cast__date(self): + q1 = Q.from_(self.t).select(fn.Date(self.t.foo)) + q2 = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.DATE)) + + self.assertEqual('SELECT DATE("foo") FROM "abc"', str(q1)) + self.assertEqual('SELECT CAST("foo" AS DATE) FROM "abc"', str(q2)) + + def test__cast__timestamp(self): + q1 = Q.from_(self.t).select(fn.Timestamp(self.t.foo)) + q2 = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.TIMESTAMP)) + + self.assertEqual('SELECT TIMESTAMP("foo") FROM "abc"', str(q1)) + self.assertEqual('SELECT CAST("foo" AS TIMESTAMP) FROM "abc"', str(q2)) + + def test__cast__char(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.CHAR)) + + self.assertEqual('SELECT CAST("foo" AS CHAR) FROM "abc"', str(q)) + + def test__cast__char_with_arg(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.VARCHAR(24))) + + self.assertEqual('SELECT CAST("foo" AS VARCHAR(24)) FROM "abc"', str(q)) + + def test__cast__varchar(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.VARCHAR)) + + self.assertEqual('SELECT CAST("foo" AS VARCHAR) FROM "abc"', str(q)) + + def test__cast__varchar_with_arg(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.VARCHAR(24))) + + self.assertEqual('SELECT CAST("foo" AS VARCHAR(24)) FROM "abc"', str(q)) + + def test__cast__long_varchar(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.LONG_VARCHAR)) + + self.assertEqual('SELECT CAST("foo" AS LONG VARCHAR) FROM "abc"', str(q)) + + def test__cast__long_varchar_with_arg(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.LONG_VARCHAR(24))) + + self.assertEqual('SELECT CAST("foo" AS LONG VARCHAR(24)) FROM "abc"', str(q)) + + def test__cast__binary(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.BINARY)) + + self.assertEqual('SELECT CAST("foo" AS BINARY) FROM "abc"', str(q)) + + def test__cast__binary_with_arg(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.BINARY(24))) + + self.assertEqual('SELECT CAST("foo" AS BINARY(24)) FROM "abc"', str(q)) + + def test__cast__varbinary(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.VARBINARY)) + + self.assertEqual('SELECT CAST("foo" AS VARBINARY) FROM "abc"', str(q)) + + def test__cast__varbinary_with_arg(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.VARBINARY(24))) + + self.assertEqual('SELECT CAST("foo" AS VARBINARY(24)) FROM "abc"', str(q)) + + def test__cast__long_varbinary(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.LONG_VARBINARY)) + + self.assertEqual('SELECT CAST("foo" AS LONG VARBINARY) FROM "abc"', str(q)) + + def test__cast__long_varbinary_with_arg(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.LONG_VARBINARY(24))) + + self.assertEqual('SELECT CAST("foo" AS LONG VARBINARY(24)) FROM "abc"', str(q)) + + def test__cast__boolean(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.BOOLEAN)) + + self.assertEqual('SELECT CAST("foo" AS BOOLEAN) FROM "abc"', str(q)) + + def test__cast__integer(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.INTEGER)) + + self.assertEqual('SELECT CAST("foo" AS INTEGER) FROM "abc"', str(q)) + + def test__cast__float(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.FLOAT)) + + self.assertEqual('SELECT CAST("foo" AS FLOAT) FROM "abc"', str(q)) + + def test__cast__numeric(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.NUMERIC)) + + self.assertEqual('SELECT CAST("foo" AS NUMERIC) FROM "abc"', str(q)) + + def test__tochar__(self): + q = Q.from_(self.t).select(fn.ToChar(self.t.foo, "SomeFormat")) + + self.assertEqual('SELECT TO_CHAR("foo",\'SomeFormat\') FROM "abc"', str(q)) + + +class DateFunctionsTests(unittest.TestCase): + dt = F("dt") + t = T("abc") + t2 = T("efg") + + def _test_extract_datepart(self, date_part): + q = Q.from_(self.t).select(fn.Extract(date_part, self.t.foo)) + + value = getattr(date_part, 'value', date_part) + self.assertEqual('SELECT EXTRACT(%s FROM "foo") FROM "abc"' % value, str(q)) + + def test_extract_microsecond(self): + self._test_extract_datepart(DatePart.microsecond) + self._test_extract_datepart(DatePart.microsecond.value) + + def test_extract_second(self): + self._test_extract_datepart(DatePart.second) + self._test_extract_datepart(DatePart.second.value) + + def test_extract_minute(self): + self._test_extract_datepart(DatePart.minute) + self._test_extract_datepart(DatePart.minute.value) + + def test_extract_hour(self): + self._test_extract_datepart(DatePart.hour) + self._test_extract_datepart(DatePart.hour.value) + + def test_extract_day(self): + self._test_extract_datepart(DatePart.day) + self._test_extract_datepart(DatePart.day.value) + + def test_extract_week(self): + self._test_extract_datepart(DatePart.week) + self._test_extract_datepart(DatePart.week.value) + + def test_extract_month(self): + self._test_extract_datepart(DatePart.month) + self._test_extract_datepart(DatePart.month.value) + + def test_extract_quarter(self): + self._test_extract_datepart(DatePart.quarter) + self._test_extract_datepart(DatePart.quarter.value) + + def test_extract_year(self): + self._test_extract_datepart(DatePart.year) + self._test_extract_datepart(DatePart.year.value) + + def test_extract_join(self): + q = Q.from_(self.t).join(self.t2).on(self.t.id == self.t2.t_id).select(fn.Extract(DatePart.year, self.t.foo)) + + self.assertEqual( + 'SELECT EXTRACT(YEAR FROM "abc"."foo") FROM "abc" ' 'JOIN "efg" ON "abc"."id"="efg"."t_id"', str(q) + ) + + def test_timestampadd(self): + a = fn.TimestampAdd("year", 1, "2017-10-01") + self.assertEqual(str(a), "TIMESTAMPADD(year,1,'2017-10-01')") + + def test_time_diff(self): + a = fn.TimeDiff("18:00:00", "10:00:00") + self.assertEqual(str(a), "TIMEDIFF('18:00:00','10:00:00')") + + def test_date_add(self): + a = fn.DateAdd("year", 1, "2017-10-01") + self.assertEqual(str(a), "DATE_ADD(year,1,'2017-10-01')") + + def test_now(self): + query = Query.select(fn.Now()) + + self.assertEqual("SELECT NOW()", str(query)) + + def test_utc_timestamp(self): + query = Query.select(fn.UtcTimestamp()) + + self.assertEqual("SELECT UTC_TIMESTAMP()", str(query)) + + def test_current_date(self): + query = Query.select(fn.CurDate()) + + self.assertEqual("SELECT CURRENT_DATE()", str(query)) + + def test_current_time(self): + query = Query.select(fn.CurTime()) + + self.assertEqual("SELECT CURRENT_TIME()", str(query)) + + def test_current_timestamp(self): + query = Query.select(fn.CurTimestamp()) + + self.assertEqual("SELECT CURRENT_TIMESTAMP", str(query)) + + def test_current_timestamp_with_alias(self): + query = Query.select(fn.CurTimestamp("ts")) + + self.assertEqual('SELECT CURRENT_TIMESTAMP "ts"', str(query)) + + def test_to_date(self): + q1 = fn.ToDate("2019-06-21", "yyyy-mm-dd") + q2 = Query.from_(self.t).select(fn.ToDate("2019-06-21", "yyyy-mm-dd")) + q3 = Query.from_(self.t).select(fn.ToDate(F("foo"), "yyyy-mm-dd")) + + self.assertEqual(str(q1), "TO_DATE('2019-06-21','yyyy-mm-dd')") + self.assertEqual(str(q2), "SELECT TO_DATE('2019-06-21','yyyy-mm-dd') FROM \"abc\"") + self.assertEqual(str(q3), 'SELECT TO_DATE("foo",\'yyyy-mm-dd\') FROM "abc"') + + +class NullFunctionsTests(unittest.TestCase): + def test_isnull(self): + q = Q.from_("abc").select(fn.IsNull(F("foo"))) + + self.assertEqual('SELECT ISNULL("foo") FROM "abc"', str(q)) + + def test_coalesce(self): + q = Q.from_("abc").select(fn.Coalesce(F("foo"), 0)) + + self.assertEqual('SELECT COALESCE("foo",0) FROM "abc"', str(q)) + + def test_nullif(self): + q = Q.from_("abc").select(fn.NullIf(F("foo"), 0)) + + self.assertEqual('SELECT NULLIF("foo",0) FROM "abc"', str(q)) + + def test_nvl(self): + q = Q.from_("abc").select(fn.NVL(F("foo"), 0)) + + self.assertEqual('SELECT NVL("foo",0) FROM "abc"', str(q)) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/test_groupby_modifiers.py b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/test_groupby_modifiers.py new file mode 100644 index 0000000000000000000000000000000000000000..978834c2409f4b4800fedb9b1bb2538a31d0f31c --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/test_groupby_modifiers.py @@ -0,0 +1,168 @@ +import unittest + +from pypika import Query, Rollup, RollupException, Table, functions as fn + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + + +class RollupTests(unittest.TestCase): + table = Table("abc") + + def test_mysql_one_groupby(self): + q = ( + Query.from_(self.table) + .select(self.table.foo, fn.Sum(self.table.bar)) + .rollup(self.table.foo, vendor="mysql") + ) + + self.assertEqual('SELECT "foo",SUM("bar") FROM "abc" GROUP BY "foo" WITH ROLLUP', str(q)) + + def test_mysql_rollup_two_groupbys(self): + q = ( + Query.from_(self.table) + .select(self.table.foo, self.table.fiz, fn.Sum(self.table.bar)) + .rollup(self.table.foo, self.table.fiz, vendor="mysql") + ) + + self.assertEqual( + 'SELECT "foo","fiz",SUM("bar") FROM "abc" GROUP BY "foo","fiz" WITH ROLLUP', + str(q), + ) + + def test_no_rollup_before_groupby(self): + with self.assertRaises(RollupException): + Query.from_(self.table).select(self.table.foo, fn.Sum(self.table.bar)).rollup(vendor="mysql") + + def test_no_rollup_after_rollup_mysql(self): + with self.assertRaises(AttributeError): + Query.from_(self.table).select(self.table.foo, self.table.fiz, fn.Sum(self.table.bar)).rollup( + self.table.foo, vendor="mysql" + ).rollup(self.table.fiz, vendor="mysql") + + def test_verticaoracle_func_one_groupby(self): + q = Query.from_(self.table).select(self.table.foo, fn.Sum(self.table.bar)).groupby(Rollup(self.table.foo)) + + self.assertEqual('SELECT "foo",SUM("bar") FROM "abc" GROUP BY ROLLUP("foo")', str(q)) + + def test_verticaoracle_func_two_groupbys(self): + q = ( + Query.from_(self.table) + .select(self.table.foo, self.table.fiz, fn.Sum(self.table.bar)) + .groupby( + Rollup( + self.table.foo, + self.table.fiz, + ) + ) + ) + + self.assertEqual( + 'SELECT "foo","fiz",SUM("bar") FROM "abc" GROUP BY ROLLUP("foo","fiz")', + str(q), + ) + + def test_verticaoracle_func_partial(self): + q = ( + Query.from_(self.table) + .select(self.table.foo, self.table.fiz, self.table.buz, fn.Sum(self.table.bar)) + .groupby( + Rollup( + self.table.foo, + self.table.fiz, + ), + self.table.buz, + ) + ) + + self.assertEqual( + 'SELECT "foo","fiz","buz",SUM("bar") FROM "abc" GROUP BY ROLLUP("foo","fiz"),"buz"', + str(q), + ) + + def test_verticaoracle_from_groupbys(self): + q = Query.from_(self.table).select(self.table.foo, fn.Sum(self.table.bar)).rollup(self.table.foo) + + self.assertEqual('SELECT "foo",SUM("bar") FROM "abc" GROUP BY ROLLUP("foo")', str(q)) + + def test_verticaoracle_from_two_groupbys(self): + q = ( + Query.from_(self.table) + .select(self.table.foo, self.table.fiz, fn.Sum(self.table.bar)) + .rollup( + self.table.foo, + self.table.fiz, + ) + ) + + self.assertEqual( + 'SELECT "foo","fiz",SUM("bar") FROM "abc" GROUP BY ROLLUP("foo","fiz")', + str(q), + ) + + def test_verticaoracle_from_parameters(self): + q = ( + Query.from_(self.table) + .select(self.table.foo, self.table.fiz, fn.Sum(self.table.bar)) + .groupby( + self.table.foo, + ) + .rollup( + self.table.fiz, + ) + ) + + self.assertEqual( + 'SELECT "foo","fiz",SUM("bar") FROM "abc" GROUP BY "foo",ROLLUP("fiz")', + str(q), + ) + + def test_verticaoracle_multiple_rollups(self): + q = ( + Query.from_(self.table) + .select(self.table.foo, self.table.fiz, fn.Sum(self.table.bar)) + .rollup( + self.table.foo, + ) + .rollup( + self.table.fiz, + ) + ) + + self.assertEqual( + 'SELECT "foo","fiz",SUM("bar") FROM "abc" GROUP BY ROLLUP("foo","fiz")', + str(q), + ) + + def test_verticaoracle_rollups_with_parity(self): + q = ( + Query.from_(self.table) + .select( + self.table.buz, + ) + .rollup( + [self.table.foo, self.table.bar], + self.table.fiz, + ) + ) + + self.assertEqual('SELECT "buz" FROM "abc" GROUP BY ROLLUP(("foo","bar"),"fiz")', str(q)) + + def test_verticaoracle_rollups_with_multiple_rollups_and_parity(self): + q = ( + Query.from_(self.table) + .select( + self.table.buz, + ) + .rollup( + [self.table.foo, self.table.bar], + ) + .rollup( + [self.table.fiz, self.table.buz], + ) + ) + + self.assertEqual( + 'SELECT "buz" FROM "abc" GROUP BY ROLLUP(("foo","bar"),("fiz","buz"))', + str(q), + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/test_immutability.py b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/test_immutability.py new file mode 100644 index 0000000000000000000000000000000000000000..ee539bfa1e9c4509b929e7a86a03f098dd923515 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/test_immutability.py @@ -0,0 +1,99 @@ +import unittest + +from pypika import ( + AliasedQuery, + Query, + Tables, +) + + +class ImmutabilityTests(unittest.TestCase): + table_a, table_b, table_c = Tables("a", "b", "c") + + def test_select_returns_new_query_instance(self): + query_a = Query.from_(self.table_a).select(self.table_a.foo) + query_b = query_a.select(self.table_a.bar) + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_groupby_returns_new_query_instance(self): + query_a = Query.from_(self.table_a).select(self.table_a.foo).groupby(self.table_a.foo) + query_b = query_a.groupby(self.table_a.bar) + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_orderby_return_new_query_instance(self): + query_a = Query.from_(self.table_a).select(self.table_a.foo).orderby(self.table_a.foo) + query_b = query_a.orderby(self.table_a.bar) + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_join_return_new_query_instance(self): + base = Query.from_(self.table_a).select(self.table_a.foo) + query_a = base.join(self.table_b).on(self.table_a.foo == self.table_b.bar).select(self.table_b.bar) + query_b = query_a.join(self.table_c).on(self.table_a.foo == self.table_c.baz).select(self.table_c.baz) + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_use_index_return_new_query_instance(self): + query_a = Query.from_(self.table_a).select(self.table_a.foo).use_index('idx1') + query_b = query_a.use_index('idx2') + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_force_index_return_new_query_instance(self): + query_a = Query.from_(self.table_a).select(self.table_a.foo).force_index('idx1') + query_b = query_a.force_index('idx2') + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_with_return_new_query_instance(self): + alias_1 = Query.from_(self.table_a).select(self.table_a.foo) + alias_2 = Query.from_(self.table_b).select(self.table_b.bar) + query_a = Query.from_(AliasedQuery('a1')).select('foo').with_(alias_1, 'a1') + query_b = query_a.with_(alias_2, 'a2') + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_insert_into_return_new_query_instance(self): + query_a = Query.into(self.table_a).insert('foo1') + query_b = query_a.insert('foo2') + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_replace_into_return_new_query_instance(self): + query_a = Query.into(self.table_a).replace('foo') + query_b = query_a.replace('bar') + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_update_set_return_new_query_instance(self): + query_a = Query.update(self.table_a).set(self.table_a.foo, 'foo') + query_b = query_a.set(self.table_a.bar, 'bar') + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_queries_after_join(self): + query1 = Query.from_(self.table_a).select(self.table_a.foo) + query2 = query1.join(self.table_b).on(self.table_a.foo == self.table_b.bar).select(self.table_b.buz) + + self.assertEqual('SELECT "foo" FROM "a"', str(query1)) + self.assertEqual( + 'SELECT "a"."foo","b"."buz" FROM "a" JOIN "b" ON "a"."foo"="b"."bar"', + str(query2), + ) + + def test_immutable_kwarg_on_query_builder_disables_immutability(self): + query0 = Query.from_(self.table_a, immutable=False) + query1 = query0.select(self.table_a.foo) + self.assertIs(query0, query1) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/test_inserts.py b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/test_inserts.py new file mode 100644 index 0000000000000000000000000000000000000000..f86efd7a76dc498a69b61c6353951695f1933a61 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/test_inserts.py @@ -0,0 +1,885 @@ +import unittest + +from pypika import ( + AliasedQuery, + Case, + Field as F, + MySQLQuery, + PostgreSQLQuery, + Query, + Table, + Tables, + functions as fn, +) +from pypika.functions import ( + Avg, + Cast, +) +from pypika.terms import Values +from pypika.utils import QueryException + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + + +class InsertIntoTests(unittest.TestCase): + table_abc = Table("abc") + + def test_insert_one_column(self): + query = Query.into(self.table_abc).insert(1) + + self.assertEqual('INSERT INTO "abc" VALUES (1)', str(query)) + + def test_insert_one_column_single_element_array(self): + query = Query.into(self.table_abc).insert((1,)) + + self.assertEqual('INSERT INTO "abc" VALUES (1)', str(query)) + + def test_insert_one_column_multi_element_array(self): + query = Query.into(self.table_abc).insert((1,), (2,)) + + self.assertEqual('INSERT INTO "abc" VALUES (1),(2)', str(query)) + + def test_insert_single_row_with_array_value(self): + query = Query.into(self.table_abc).insert(1, ["a", "b", "c"]) + + self.assertEqual("INSERT INTO \"abc\" VALUES (1,['a','b','c'])", str(query)) + + def test_insert_multiple_rows_with_array_value(self): + query = Query.into(self.table_abc).insert( + (1, ["a", "b", "c"]), + (2, ["c", "d", "e"]), + ) + + self.assertEqual( + 'INSERT INTO "abc" ' "VALUES (1,['a','b','c']),(2,['c','d','e'])", + str(query), + ) + + def test_insert_all_columns(self): + query = Query.into(self.table_abc).insert(1, "a", True) + + self.assertEqual("INSERT INTO \"abc\" VALUES (1,'a',true)", str(query)) + + def test_insert_all_columns_single_element(self): + query = Query.into(self.table_abc).insert((1, "a", True)) + + self.assertEqual("INSERT INTO \"abc\" VALUES (1,'a',true)", str(query)) + + def test_insert_all_columns_multi_rows(self): + query = Query.into(self.table_abc).insert((1, "a", True), (2, "b", False)) + + self.assertEqual("INSERT INTO \"abc\" VALUES (1,'a',true),(2,'b',false)", str(query)) + + def test_insert_all_columns_multi_rows_chained(self): + query = Query.into(self.table_abc).insert(1, "a", True).insert(2, "b", False) + + self.assertEqual("INSERT INTO \"abc\" VALUES (1,'a',true),(2,'b',false)", str(query)) + + def test_insert_all_columns_multi_rows_chained_mixed(self): + query = Query.into(self.table_abc).insert((1, "a", True), (2, "b", False)).insert(3, "c", True) + + self.assertEqual( + 'INSERT INTO "abc" VALUES ' "(1,'a',true),(2,'b',false)," "(3,'c',true)", + str(query), + ) + + def test_insert_all_columns_multi_rows_chained_multiple_rows(self): + query = ( + Query.into(self.table_abc).insert((1, "a", True), (2, "b", False)).insert((3, "c", True), (4, "d", False)) + ) + + self.assertEqual( + 'INSERT INTO "abc" VALUES ' "(1,'a',true),(2,'b',false)," "(3,'c',true),(4,'d',false)", + str(query), + ) + + def test_insert_selected_columns(self): + query = ( + Query.into(self.table_abc) + .columns(self.table_abc.foo, self.table_abc.bar, self.table_abc.buz) + .insert(1, "a", True) + ) + + self.assertEqual('INSERT INTO "abc" ("foo","bar","buz") VALUES (1,\'a\',true)', str(query)) + + def test_insert_empty_columns(self): + query = Query.into(self.table_abc).columns().insert(1, "a", True) + + self.assertEqual('INSERT INTO "abc" VALUES (1,\'a\',true)', str(query)) + + def test_insert_selected_columns_type_list(self): + query = ( + Query.into(self.table_abc) + .columns([self.table_abc.foo, self.table_abc.bar, self.table_abc.buz]) + .insert(1, "a", True) + ) + + self.assertEqual('INSERT INTO "abc" ("foo","bar","buz") VALUES (1,\'a\',true)', str(query)) + + def test_insert_empty_columns_type_list(self): + query = Query.into(self.table_abc).columns([]).insert(1, "a", True) + + self.assertEqual('INSERT INTO "abc" VALUES (1,\'a\',true)', str(query)) + + def test_insert_selected_columns_type_tuple(self): + query = ( + Query.into(self.table_abc) + .columns((self.table_abc.foo, self.table_abc.bar, self.table_abc.buz)) + .insert(1, "a", True) + ) + + self.assertEqual('INSERT INTO "abc" ("foo","bar","buz") VALUES (1,\'a\',true)', str(query)) + + def test_insert_empty_columns_type_tuple(self): + query = Query.into(self.table_abc).columns(()).insert(1, "a", True) + + self.assertEqual('INSERT INTO "abc" VALUES (1,\'a\',true)', str(query)) + + def test_insert_none_skipped(self): + query = Query.into(self.table_abc).insert() + + self.assertEqual("", str(query)) + + def test_insert_ignore(self): + query = Query.into(self.table_abc).insert(1).ignore() + + self.assertEqual('INSERT IGNORE INTO "abc" VALUES (1)', str(query)) + + def test_insert_null(self): + query = Query.into(self.table_abc).insert(None) + + self.assertEqual('INSERT INTO "abc" VALUES (NULL)', str(query)) + + def test_insert_column_using_table_alias(self): + q = self.table_abc.insert(1) + self.assertEqual('INSERT INTO "abc" VALUES (1)', str(q)) + + def test_insert_column_using_alias_with_chain(self): + q = self.table_abc.insert(1, "a", True).insert(2, "b", False) + self.assertEqual("INSERT INTO \"abc\" VALUES (1,'a',true),(2,'b',false)", str(q)) + + def test_insert_with_statement(self): + sub_query = Query().select(self.table_abc.id).from_(self.table_abc) + aliased = AliasedQuery('sub_qs') + + q = Query().with_(sub_query, 'sub_qs').into(self.table_abc).select(aliased.id).from_(aliased) + self.assertEqual( + 'WITH sub_qs AS (SELECT "id" FROM "abc") INSERT INTO "abc" SELECT "sub_qs"."id" FROM sub_qs', str(q) + ) + + +class PostgresInsertIntoOnConflictTests(unittest.TestCase): + table_abc = Table("abc") + + def test_insert_on_conflict_do_nothing_field(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).on_conflict(self.table_abc.id).do_nothing() + + self.assertEqual('INSERT INTO "abc" VALUES (1) ON CONFLICT ("id") DO NOTHING', str(query)) + + def test_insert_on_conflict_do_nothing_multiple_fields(self): + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1) + .on_conflict(self.table_abc.id, self.table_abc.sub_id) + .do_nothing() + ) + + self.assertEqual('INSERT INTO "abc" VALUES (1) ON CONFLICT ("id", "sub_id") DO NOTHING', str(query)) + + def test_insert_on_conflict_do_nothing_field_str(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).on_conflict("id").do_nothing() + + self.assertEqual('INSERT INTO "abc" VALUES (1) ON CONFLICT ("id") DO NOTHING', str(query)) + + def test_insert_on_conflict_do_nothing_multiple_fields_str(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).on_conflict("id", "sub_id").do_nothing() + + self.assertEqual('INSERT INTO "abc" VALUES (1) ON CONFLICT ("id", "sub_id") DO NOTHING', str(query)) + + def test_insert_on_conflict_do_nothing_mixed_fields(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).on_conflict("id", self.table_abc.sub_id).do_nothing() + + self.assertEqual('INSERT INTO "abc" VALUES (1) ON CONFLICT ("id", "sub_id") DO NOTHING', str(query)) + + def test_insert_on_conflict_do_update_field(self): + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict(self.table_abc.id) + .do_update(self.table_abc.name, "m") + ) + + self.assertEqual( + "INSERT INTO \"abc\" VALUES (1,'m') ON CONFLICT (\"id\") DO UPDATE SET \"name\"='m'", + str(query), + ) + + def test_insert_on_conflict_do_update_multiple_fields(self): + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict(self.table_abc.id, self.table_abc.sub_id) + .do_update(self.table_abc.name, "m") + ) + + self.assertEqual( + "INSERT INTO \"abc\" VALUES (1,'m') ON CONFLICT (\"id\", \"sub_id\") DO UPDATE SET \"name\"='m'", + str(query), + ) + + def test_insert_on_conflict_do_update_field_str(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1, "m").on_conflict("id").do_update("name", "m") + + self.assertEqual( + "INSERT INTO \"abc\" VALUES (1,'m') ON CONFLICT (\"id\") DO UPDATE SET \"name\"='m'", + str(query), + ) + + def test_insert_on_conflict_do_update_multiple_fields_str(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1, "m").on_conflict("id", "sub_id").do_update("name", "m") + + self.assertEqual( + "INSERT INTO \"abc\" VALUES (1,'m') ON CONFLICT (\"id\", \"sub_id\") DO UPDATE SET \"name\"='m'", + str(query), + ) + + def test_insert_on_conflict_do_update_multiple_mixed_fields(self): + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict("id", self.table_abc.sub_id) + .do_update("name", "m") + ) + + self.assertEqual( + "INSERT INTO \"abc\" VALUES (1,'m') ON CONFLICT (\"id\", \"sub_id\") DO UPDATE SET \"name\"='m'", + str(query), + ) + + def test_insert_on_conflict_no_handler(self): + with self.assertRaises(QueryException): + query = str(PostgreSQLQuery.into(self.table_abc).insert(1).on_conflict(self.table_abc.id)) + + def test_insert_on_conflict_two_handlers_do_nothing(self): + with self.assertRaises(QueryException): + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1) + .on_conflict("id") + .do_nothing() + .do_update(self.table_abc.name, "m") + ) + + def test_insert_on_conflict_two_handlers_do_update(self): + with self.assertRaises(QueryException): + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1) + .on_conflict(self.table_abc.id) + .do_update(self.table_abc.name, "m") + .do_nothing() + ) + + def test_non_insert_on_conflict_do_nothing(self): + with self.assertRaises(QueryException): + query = PostgreSQLQuery.update(self.table_abc).set("foo", "bar").on_conflict("id").do_nothing() + + def test_non_insert_on_conflict_do_update(self): + with self.assertRaises(QueryException): + query = ( + PostgreSQLQuery.update(self.table_abc).set("foo", "bar").on_conflict("id").do_update(["name"], ["m"]) + ) + + def test_insert_on_fieldless_conflict_do_nothing(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).on_conflict(None).do_nothing() + + self.assertEqual('INSERT INTO "abc" VALUES (1) ON CONFLICT DO NOTHING', str(query)) + + def test_insert_on_fieldless_conflict_do_update_field(self): + with self.assertRaises(QueryException): + query = str( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict(None) + .do_update(self.table_abc.name, "m") + ) + + def test_on_conflict_from_subquery(self): + table_bcd = Table('bcd') + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(self.table_abc.fname, self.table_abc.lname) + .select(table_bcd.fname, table_bcd.lname) + .from_(table_bcd) + .on_conflict(self.table_abc.id, self.table_abc.sub_id) + .do_update(self.table_abc.fname, 1) + .do_update(self.table_abc.lname, table_bcd.lname) + .do_update( + self.table_abc.cname, + Case().when(self.table_abc.cname.eq('cname'), 'new_name').else_(self.table_abc.cname), + ) + ) + + self.assertEqual( + 'INSERT INTO "abc" VALUES ("fname","lname") ' + 'ON CONFLICT ("id", "sub_id") ' + 'DO UPDATE SET "fname"=1,"lname"="bcd"."lname",' + '"cname"=CASE WHEN "abc"."cname"=\'cname\' THEN \'new_name\' ELSE "abc"."cname" END', + str(query), + ) + + def test_on_conflict_where_empty_conflict_fields_do_nothing(self): + with self.assertRaises(QueryException): + ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict() + .where(self.table_abc.abc.eq(0)) + .where(self.table_abc.cde.eq(0)) + .do_nothing() + ) + + def test_on_conflict_where_conflict_fields_do_nothing(self): + qs = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict('id') + .where(self.table_abc.abc.eq(0)) + .where(self.table_abc.cde.eq(0)) + .do_nothing() + ) + self.assertEqual( + '''INSERT INTO "abc" VALUES (1,'m') ON CONFLICT ("id") WHERE "abc"=0 AND "cde"=0 DO NOTHING''', str(qs) + ) + + def test_on_conflict_where_empty_conflict_fields_do_update(self): + with self.assertRaises(QueryException): + ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict() + .where(self.table_abc.abc.eq(0)) + .where(self.table_abc.cde.eq(0)) + .do_update('field', 'val') + ) + + def test_on_conflict_where_conflict_fields_do_update(self): + qs = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict('id') + .where(self.table_abc.abc.eq(0)) + .where(self.table_abc.cde.eq(0)) + .do_update('field', 'val') + ) + self.assertEqual( + '''INSERT INTO "abc" VALUES (1,'m') ON CONFLICT ("id") WHERE "abc"=0 AND "cde"=0 ''' + '''DO UPDATE SET "field"='val\'''', + str(qs), + ) + + def test_where_and_on_conflict_where(self): + table_bcd = Table('bcd') + + qs = ( + PostgreSQLQuery.into(self.table_abc) + .select(table_bcd.abc) + .from_(table_bcd) + .where(table_bcd.abc.eq('1')) + .on_conflict('id') + .where(self.table_abc.abc.eq(0)) + .where(self.table_abc.cde.eq(0)) + .do_update('field', 'val') + ) + + self.assertEqual( + 'INSERT INTO "abc" SELECT "abc" FROM "bcd" WHERE "abc"=\'1\' ' + 'ON CONFLICT ("id") WHERE "abc"=0 AND "cde"=0 DO UPDATE SET "field"=\'val\'', + str(qs), + ) + + def test_on_conflict_do_nothing_where(self): + with self.assertRaises(QueryException): + ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict() + .do_nothing() + .where(self.table_abc.abc.eq(1)) + ) + + def test_empty_on_conflict_do_update_where(self): + with self.assertRaises(QueryException): + ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict() + .do_update('abc', 1) + .where(self.table_abc.abc.eq(1)) + ) + + def test_on_conflict_do_update_where(self): + qs = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict("id") + .do_update('abc', 1) + .where(self.table_abc.abc.eq(1)) + ) + self.assertEqual( + 'INSERT INTO "abc" VALUES (1,\'m\') ON CONFLICT ("id") DO UPDATE SET "abc"=1 WHERE "abc"."abc"=1', str(qs) + ) + + def test_on_conflict_do_update_with_excluded_where(self): + qs = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict("id") + .do_update('abc') + .where(self.table_abc.abc.eq(1)) + ) + self.assertEqual( + 'INSERT INTO "abc" VALUES (1,\'m\') ON CONFLICT ("id") DO UPDATE SET "abc"=EXCLUDED."abc" WHERE ' + '"abc"."abc"=1', + str(qs), + ) + + def test_on_conflict_where_complex(self): + table_bcd = Table('bcd') + + qs = ( + PostgreSQLQuery.into(self.table_abc) + .select(table_bcd.abc) + .from_(table_bcd) + .where(table_bcd.abc.eq('1')) + .on_conflict('id') + .where(self.table_abc.abc.eq(0)) + .where(self.table_abc.cde.eq(0)) + .do_update('field', 'val') + .where(self.table_abc.id.eq(2)) + .where(self.table_abc.sub_id.eq(3)) + ) + self.assertEqual( + 'INSERT INTO "abc" SELECT "abc" FROM "bcd" WHERE "abc"=\'1\' ' + 'ON CONFLICT ("id") WHERE "abc"=0 AND "cde"=0 ' + 'DO UPDATE SET "field"=\'val\' WHERE "abc"."id"=2 AND "abc"."sub_id"=3', + str(qs), + ) + + +class PostgresInsertIntoReturningTests(unittest.TestCase): + table_abc = Table("abc") + + def test_insert_returning_one_field(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).returning(self.table_abc.id) + + self.assertEqual('INSERT INTO "abc" VALUES (1) RETURNING "id"', str(query)) + + def test_insert_returning_one_field_str(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).returning("id") + + self.assertEqual('INSERT INTO "abc" VALUES (1) RETURNING "id"', str(query)) + + def test_insert_returning_all_fields(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).returning(self.table_abc.star) + + self.assertEqual('INSERT INTO "abc" VALUES (1) RETURNING *', str(query)) + + def test_insert_returning_all_fields_and_arithmetics(self): + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1) + .returning(self.table_abc.star, self.table_abc.f1 + self.table_abc.f2) + ) + + self.assertEqual('INSERT INTO "abc" VALUES (1) RETURNING *,"f1"+"f2"', str(query)) + + def test_insert_all_columns_multi_rows_chained_returning_star(self): + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "a", True) + .insert(2, "b", False) + .returning(self.table_abc.star) + ) + + self.assertEqual( + "INSERT INTO \"abc\" VALUES (1,'a',true),(2,'b',false) RETURNING *", + str(query), + ) + + def test_insert_all_columns_multi_rows_chained_returning_star_and_id(self): + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "a", True) + .insert(2, "b", False) + .returning( + self.table_abc.name, + self.table_abc.star, + self.table_abc.id, + ) + ) + + self.assertEqual( + "INSERT INTO \"abc\" VALUES (1,'a',true),(2,'b',false) RETURNING *", + str(query), + ) + + def test_insert_all_columns_multi_rows_chained_returning_star_str(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1, "a", True).insert(2, "b", False).returning("*") + + self.assertEqual( + "INSERT INTO \"abc\" VALUES (1,'a',true),(2,'b',false) RETURNING *", + str(query), + ) + + def test_insert_all_columns_single_element_arrays(self): + query = PostgreSQLQuery.into(self.table_abc).insert((1, "a", True)).returning(self.table_abc.star) + + self.assertEqual("INSERT INTO \"abc\" VALUES (1,'a',true) RETURNING *", str(query)) + + def test_insert_returning_null(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).returning(None) + + self.assertEqual('INSERT INTO "abc" VALUES (1) RETURNING NULL', str(query)) + + def test_insert_returning_tuple(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).returning((1, 2, 3)) + + self.assertEqual('INSERT INTO "abc" VALUES (1) RETURNING (1,2,3)', str(query)) + + def test_insert_returning_arithmetics(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).returning(self.table_abc.f1 + self.table_abc.f2) + + self.assertEqual('INSERT INTO "abc" VALUES (1) RETURNING "f1"+"f2"', str(query)) + + def test_insert_returning_functions(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).returning(Cast(self.table_abc.f1, "int")) + + self.assertEqual('INSERT INTO "abc" VALUES (1) RETURNING CAST("f1" AS INT)', str(query)) + + def test_insert_returning_aggregate(self): + with self.assertRaises(QueryException): + PostgreSQLQuery.into(self.table_abc).insert(1).returning(Avg(self.table_abc.views)) + + def test_insert_returning_from_other_table(self): + table_cba = Table("cba") + with self.assertRaises(QueryException): + PostgreSQLQuery.into(self.table_abc).insert(1).returning(table_cba.id) + + +class InsertIntoOnDuplicateTests(unittest.TestCase): + table_abc = Table("abc") + + def test_insert_one_column(self): + query = ( + MySQLQuery.into(self.table_abc).insert(1).on_duplicate_key_update(self.table_abc.foo, self.table_abc.foo) + ) + self.assertEqual( + "INSERT INTO `abc` VALUES (1) ON DUPLICATE KEY UPDATE `foo`=`foo`", + str(query), + ) + + def test_insert_one_column_using_values(self): + query = ( + MySQLQuery.into(self.table_abc) + .insert(1) + .on_duplicate_key_update(self.table_abc.foo, Values(self.table_abc.foo)) + ) + self.assertEqual( + "INSERT INTO `abc` VALUES (1) ON DUPLICATE KEY UPDATE `foo`=VALUES(`foo`)", + str(query), + ) + + def test_insert_one_column_single_element_array(self): + query = ( + MySQLQuery.into(self.table_abc).insert((1,)).on_duplicate_key_update(self.table_abc.foo, self.table_abc.foo) + ) + + self.assertEqual( + "INSERT INTO `abc` VALUES (1) ON DUPLICATE KEY UPDATE `foo`=`foo`", + str(query), + ) + + def test_insert_one_column_multi_element_array(self): + query = ( + MySQLQuery.into(self.table_abc) + .insert((1,), (2,)) + .on_duplicate_key_update(self.table_abc.foo, self.table_abc.foo) + ) + + self.assertEqual( + "INSERT INTO `abc` VALUES (1),(2) ON DUPLICATE KEY UPDATE `foo`=`foo`", + str(query), + ) + + def test_insert_multiple_columns_on_duplicate_update_one_with_same_value(self): + query = ( + MySQLQuery.into(self.table_abc) + .insert(1, "a") + .on_duplicate_key_update(self.table_abc.bar, Values(self.table_abc.bar)) + ) + + self.assertEqual( + "INSERT INTO `abc` VALUES (1,'a') ON DUPLICATE KEY UPDATE `bar`=VALUES(`bar`)", + str(query), + ) + + def test_insert_multiple_columns_on_duplicate_update_one_with_different_value(self): + query = MySQLQuery.into(self.table_abc).insert(1, "a").on_duplicate_key_update(self.table_abc.bar, "b") + + self.assertEqual( + "INSERT INTO `abc` VALUES (1,'a') ON DUPLICATE KEY UPDATE `bar`='b'", + str(query), + ) + + def test_insert_multiple_columns_on_duplicate_update_one_with_expression(self): + query = ( + MySQLQuery.into(self.table_abc).insert(1, 2).on_duplicate_key_update(self.table_abc.bar, 4 + F("bar")) + ) # todo sql expression? not python + + self.assertEqual( + "INSERT INTO `abc` VALUES (1,2) ON DUPLICATE KEY UPDATE `bar`=4+`bar`", + str(query), + ) + + def test_insert_multiple_columns_on_duplicate_update_one_with_expression_using_original_field_value( + self, + ): + query = ( + MySQLQuery.into(self.table_abc) + .insert(1, "a") + .on_duplicate_key_update(self.table_abc.bar, fn.Concat(self.table_abc.bar, "update")) + ) + + self.assertEqual( + "INSERT INTO `abc` VALUES (1,'a') ON DUPLICATE KEY UPDATE `bar`=CONCAT(`bar`,'update')", + str(query), + ) + + def test_insert_multiple_columns_on_duplicate_update_one_with_expression_using_values( + self, + ): + query = ( + MySQLQuery.into(self.table_abc) + .insert(1, "a") + .on_duplicate_key_update(self.table_abc.bar, fn.Concat(Values(self.table_abc.bar), "update")) + ) + + self.assertEqual( + "INSERT INTO `abc` VALUES (1,'a') ON DUPLICATE KEY UPDATE `bar`=CONCAT(VALUES(`bar`),'update')", + str(query), + ) + + def test_insert_multiple_columns_on_duplicate_update_multiple(self): + query = ( + MySQLQuery.into(self.table_abc) + .insert(1, "a", "b") + .on_duplicate_key_update(self.table_abc.bar, "b") + .on_duplicate_key_update(self.table_abc.baz, "c") + ) + + self.assertEqual( + "INSERT INTO `abc` VALUES (1,'a','b') ON DUPLICATE KEY UPDATE `bar`='b',`baz`='c'", + str(query), + ) + + def test_insert_multi_rows_chained_mixed_on_duplicate_update_multiple(self): + query = ( + MySQLQuery.into(self.table_abc) + .insert((1, "a", True), (2, "b", False)) + .insert(3, "c", True) + .on_duplicate_key_update(self.table_abc.foo, self.table_abc.foo) + .on_duplicate_key_update(self.table_abc.bar, Values(self.table_abc.bar)) + ) + + self.assertEqual( + "INSERT INTO `abc` VALUES (1,'a',true),(2,'b',false),(3,'c',true) " + "ON DUPLICATE KEY UPDATE `foo`=`foo`,`bar`=VALUES(`bar`)", + str(query), + ) + + def test_insert_selected_columns_on_duplicate_update_one(self): + query = ( + MySQLQuery.into(self.table_abc) + .columns(self.table_abc.foo, self.table_abc.bar, self.table_abc.baz) + .insert(1, "a", True) + .on_duplicate_key_update(self.table_abc.baz, False) + ) + + self.assertEqual( + "INSERT INTO `abc` (`foo`,`bar`,`baz`) VALUES (1,'a',true) ON DUPLICATE KEY UPDATE `baz`=false", + str(query), + ) + + def test_insert_selected_columns_on_duplicate_update_multiple(self): + query = ( + MySQLQuery.into(self.table_abc) + .columns(self.table_abc.foo, self.table_abc.bar, self.table_abc.baz) + .insert(1, "a", True) + .on_duplicate_key_update(self.table_abc.baz, False) + .on_duplicate_key_update(self.table_abc.bar, Values(self.table_abc.bar)) + ) + + self.assertEqual( + "INSERT INTO `abc` (`foo`,`bar`,`baz`) VALUES (1,'a',true) " + "ON DUPLICATE KEY UPDATE `baz`=false,`bar`=VALUES(`bar`)", + str(query), + ) + + def test_insert_none_skipped(self): + query = MySQLQuery.into(self.table_abc).insert().on_duplicate_key_update(self.table_abc.baz, False) + + self.assertEqual("", str(query)) + + def test_insert_ignore(self): + query = MySQLQuery.into(self.table_abc).insert(1).ignore().on_duplicate_key_update(self.table_abc.baz, False) + + self.assertEqual( + "INSERT IGNORE INTO `abc` VALUES (1) ON DUPLICATE KEY UPDATE `baz`=false", + str(query), + ) + + +class InsertSelectFromTests(unittest.TestCase): + table_abc, table_efg, table_hij = Tables("abc", "efg", "hij") + + def test_insert_star(self): + query = Query.into(self.table_abc).from_(self.table_efg).select("*") + + self.assertEqual('INSERT INTO "abc" SELECT * FROM "efg"', str(query)) + + def test_insert_ignore_star(self): + query = Query.into(self.table_abc).from_(self.table_efg).select("*").ignore() + + self.assertEqual('INSERT IGNORE INTO "abc" SELECT * FROM "efg"', str(query)) + + def test_insert_from_columns(self): + query = ( + Query.into(self.table_abc) + .from_(self.table_efg) + .select(self.table_efg.fiz, self.table_efg.buz, self.table_efg.baz) + ) + + self.assertEqual('INSERT INTO "abc" ' 'SELECT "fiz","buz","baz" FROM "efg"', str(query)) + + def test_insert_columns_from_star(self): + query = ( + Query.into(self.table_abc) + .columns( + self.table_abc.foo, + self.table_abc.bar, + self.table_abc.buz, + ) + .from_(self.table_efg) + .select("*") + ) + + self.assertEqual('INSERT INTO "abc" ("foo","bar","buz") ' 'SELECT * FROM "efg"', str(query)) + + def test_insert_columns_from_columns(self): + query = ( + Query.into(self.table_abc) + .columns(self.table_abc.foo, self.table_abc.bar, self.table_abc.buz) + .from_(self.table_efg) + .select(self.table_efg.fiz, self.table_efg.buz, self.table_efg.baz) + ) + + self.assertEqual( + 'INSERT INTO "abc" ("foo","bar","buz") ' 'SELECT "fiz","buz","baz" FROM "efg"', + str(query), + ) + + def test_insert_columns_from_columns_with_join(self): + query = ( + Query.into(self.table_abc) + .columns( + self.table_abc.c1, + self.table_abc.c2, + self.table_abc.c3, + self.table_abc.c4, + ) + .from_(self.table_efg) + .select(self.table_efg.foo, self.table_efg.bar) + .join(self.table_hij) + .on(self.table_efg.id == self.table_hij.abc_id) + .select(self.table_hij.fiz, self.table_hij.buz) + ) + + self.assertEqual( + 'INSERT INTO "abc" ("c1","c2","c3","c4") ' + 'SELECT "efg"."foo","efg"."bar","hij"."fiz","hij"."buz" FROM "efg" ' + 'JOIN "hij" ON "efg"."id"="hij"."abc_id"', + str(query), + ) + + +class InsertSubqueryTests(unittest.TestCase): + def test_insert_subquery_wrapped_in_brackets(self): + purchase_order_item, part = Tables("purchase_order_item", "part") + + q = ( + Query.into(purchase_order_item) + .columns(purchase_order_item.id_part, purchase_order_item.id_customer) + .insert( + Query.from_(part).select(part.part_id).where(part.part_number == "FOOBAR"), + 12345, + ) + ) + + self.assertEqual( + 'INSERT INTO "purchase_order_item" ' + '("id_part","id_customer") ' + "VALUES " + '((SELECT "part_id" FROM "part" WHERE "part_number"=\'FOOBAR\'),12345)', + str(q), + ) + + +class SelectIntoTests(unittest.TestCase): + table_abc, table_efg, table_hij = Tables("abc", "efg", "hij") + + def test_select_star_into(self): + query = Query.from_(self.table_abc).select("*").into(self.table_efg) + + self.assertEqual('SELECT * INTO "efg" FROM "abc"', str(query)) + + def test_select_columns_into(self): + query = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, self.table_abc.bar, self.table_abc.buz) + .into(self.table_efg) + ) + + self.assertEqual('SELECT "foo","bar","buz" INTO "efg" FROM "abc"', str(query)) + + def test_select_columns_into_with_join(self): + query = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, self.table_abc.bar) + .join(self.table_hij) + .on(self.table_abc.id == self.table_hij.abc_id) + .select(self.table_hij.fiz, self.table_hij.buz) + .into(self.table_efg) + ) + + self.assertEqual( + 'SELECT "abc"."foo","abc"."bar","hij"."fiz","hij"."buz" ' + 'INTO "efg" FROM "abc" ' + 'JOIN "hij" ON "abc"."id"="hij"."abc_id"', + str(query), + ) + + +class ReplaceTests(unittest.TestCase): + table_abc, table_def = Tables("abc", "efg") + + def test_replace_simple(self): + query = Query.into(self.table_abc).replace("v1", "v2", "v3") + expected_output = "REPLACE INTO \"abc\" VALUES ('v1','v2','v3')" + self.assertEqual(str(query), expected_output) + + def test_replace_subquery(self): + query = Query.into(self.table_abc).replace(Query.from_(self.table_def).select("f1", "f2")) + expected_output = 'REPLACE INTO "abc" VALUES ((SELECT "f1","f2" FROM "efg"))' + self.assertEqual(str(query), expected_output) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/test_internals.py b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/test_internals.py new file mode 100644 index 0000000000000000000000000000000000000000..921e381ba8613d4a83cc53bd60d111d9547e2c1f --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/test_internals.py @@ -0,0 +1,35 @@ +import unittest + +from pypika import ( + Case, + Field, + Table, +) +from pypika.terms import Star + + +class TablesTests(unittest.TestCase): + def test__criterion_replace_table_with_value(self): + table = Table("a") + + c = (Field("foo") > 1).replace_table(None, table) + self.assertEqual(c.left, table) + self.assertEqual(c.tables_, {table}) + + def test__case_tables(self): + table = Table("a") + + c = Case().when(table.a == 1, 2 * table.a) + self.assertIsInstance(c.tables_, set) + self.assertSetEqual(c.tables_, {table}) + + def test__star_tables(self): + star = Star() + + self.assertEqual(star.tables_, set()) + + def test__table_star_tables(self): + table = Table("a") + star = Star(table=table) + + self.assertEqual(star.tables_, {table}) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/test_joins.py b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/test_joins.py new file mode 100644 index 0000000000000000000000000000000000000000..03142d583921edbe966e0ae191d254e7b8bf46ba --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/test_joins.py @@ -0,0 +1,1168 @@ +import unittest + +from pypika import ( + Field, + Interval, + JoinException, + JoinType, + MySQLQuery, + Query, + SetOperationException, + Table, + Tables, + functions as fn, + SYSTEM_TIME, +) + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + + +class SelectQueryJoinTests(unittest.TestCase): + table0, table1, hij = Tables("abc", "efg", "hij") + + def test_default_join_type(self): + query = Query.from_(self.table0).join(self.table1).on(self.table0.foo == self.table1.bar).select("*") + + self.assertEqual('SELECT * FROM "abc" JOIN "efg" ON "abc"."foo"="efg"."bar"', str(query)) + + def test_inner_join(self): + expected = 'SELECT * FROM "abc" JOIN "efg" ON "abc"."foo"="efg"."bar"' + + with self.subTest("join with enum"): + query = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.inner) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + self.assertEqual(expected, str(query)) + + with self.subTest("join function"): + query = Query.from_(self.table0).inner_join(self.table1).on(self.table0.foo == self.table1.bar).select("*") + self.assertEqual(expected, str(query)) + + def test_left_join(self): + expected = 'SELECT * FROM "abc" LEFT JOIN "efg" ON "abc"."foo"="efg"."bar"' + + with self.subTest("join with enum"): + query = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.left) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + + self.assertEqual(expected, str(query)) + + with self.subTest("join function"): + query = Query.from_(self.table0).left_join(self.table1).on(self.table0.foo == self.table1.bar).select("*") + self.assertEqual(expected, str(query)) + + def test_right_join(self): + expected = 'SELECT * FROM "abc" RIGHT JOIN "efg" ON "abc"."foo"="efg"."bar"' + + with self.subTest("join with enum"): + query = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.right) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + + self.assertEqual(expected, str(query)) + + with self.subTest("join function"): + query = Query.from_(self.table0).right_join(self.table1).on(self.table0.foo == self.table1.bar).select("*") + self.assertEqual(expected, str(query)) + + def test_hash_join(self): + expected = 'SELECT * FROM "abc" HASH JOIN "efg" ON "abc"."foo"="efg"."bar"' + + with self.subTest("join with enum"): + query = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.hash) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + + self.assertEqual(expected, str(query)) + + with self.subTest("join function"): + query = Query.from_(self.table0).hash_join(self.table1).on(self.table0.foo == self.table1.bar).select("*") + self.assertEqual(expected, str(query)) + + def test_outer_join(self): + expected = 'SELECT * FROM "abc" FULL OUTER JOIN "efg" ON "abc"."foo"="efg"."bar"' + + with self.subTest("join with enum"): + query = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.outer) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + + self.assertEqual(expected, str(query)) + + with self.subTest("join function"): + query = Query.from_(self.table0).outer_join(self.table1).on(self.table0.foo == self.table1.bar).select("*") + self.assertEqual(expected, str(query)) + + def test_cross_join(self): + expected = 'SELECT * FROM "abc" CROSS JOIN "efg" ON "abc"."foo"="efg"."bar"' + + with self.subTest("join with enum"): + query = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.cross) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + + self.assertEqual(expected, str(query)) + + with self.subTest("join function"): + query = Query.from_(self.table0).cross_join(self.table1).on(self.table0.foo == self.table1.bar).select("*") + self.assertEqual(expected, str(query)) + + def test_left_outer_join(self): + expected = 'SELECT * FROM "abc" LEFT OUTER JOIN "efg" ON "abc"."foo"="efg"."bar"' + with self.subTest("join with enum"): + query = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.left_outer) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + + self.assertEqual(expected, str(query)) + + with self.subTest("join function"): + query = ( + Query.from_(self.table0).left_outer_join(self.table1).on(self.table0.foo == self.table1.bar).select("*") + ) + + self.assertEqual(expected, str(query)) + + def test_right_outer_join(self): + expected = 'SELECT * FROM "abc" RIGHT OUTER JOIN "efg" ON "abc"."foo"="efg"."bar"' + with self.subTest("join with enum"): + query = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.right_outer) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + + self.assertEqual(expected, str(query)) + + with self.subTest("join function"): + query = ( + Query.from_(self.table0) + .right_outer_join(self.table1) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + + self.assertEqual(expected, str(query)) + + def test_full_outer_join(self): + expected = 'SELECT * FROM "abc" FULL OUTER JOIN "efg" ON "abc"."foo"="efg"."bar"' + + with self.subTest("join with enum"): + query = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.full_outer) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + + self.assertEqual(expected, str(query)) + + with self.subTest("join function"): + query = ( + Query.from_(self.table0).full_outer_join(self.table1).on(self.table0.foo == self.table1.bar).select("*") + ) + + self.assertEqual(expected, str(query)) + + def test_join_on_field_single(self): + query = Query.from_(self.table0).join(self.table1).on_field("foo").select("*") + self.assertEqual('SELECT * FROM "abc" JOIN "efg" ON "abc"."foo"="efg"."foo"', str(query)) + + def test_join_on_field_multi(self): + query = Query.from_(self.table0).join(self.table1).on_field("foo", "bar").select("*") + self.assertEqual( + 'SELECT * FROM "abc" JOIN "efg" ON "abc"."foo"="efg"."foo" ' 'AND "abc"."bar"="efg"."bar"', + str(query), + ) + + def test_join_on_field_multi_with_extra_join(self): + query = ( + Query.from_(self.table0) + .join(self.hij) + .on_field("buzz") + .join(self.table1) + .on_field("foo", "bar") + .select("*") + ) + + self.assertEqual( + 'SELECT * FROM "abc" JOIN "hij" ON "abc"."buzz"="hij"."buzz" ' + 'JOIN "efg" ON "abc"."foo"="efg"."foo" AND "abc"."bar"="efg"."bar"', + str(query), + ) + + def test_join_using_string_field_name(self): + query = Query.from_(self.table0).join(self.table1).using("id").select("*") + + self.assertEqual('SELECT * FROM "abc" JOIN "efg" USING ("id")', str(query)) + + def test_join_using_multiple_fields(self): + query = Query.from_(self.table0).join(self.table1).using("foo", "bar").select("*") + + self.assertEqual('SELECT * FROM "abc" JOIN "efg" USING ("foo","bar")', str(query)) + + def test_join_using_with_quote_char(self): + query = Query.from_(self.table0).join(self.table1).using("foo", "bar").select("*") + + self.assertEqual("SELECT * FROM abc JOIN efg USING (foo,bar)", query.get_sql(quote_char="")) + + def test_join_using_without_fields_raises_exception(self): + with self.assertRaises(JoinException): + Query.from_(self.table0).join(self.table1).using() + + def test_join_on_field_without_fields_raises_exception(self): + with self.assertRaises(JoinException): + Query.from_(self.table0).join(self.table1).on_field() + + def test_join_arithmetic_field(self): + q = ( + Query.from_(self.table0) + .join(self.table1) + .on(self.table0.dt == (self.table1.dt - Interval(weeks=1))) + .select("*") + ) + + self.assertEqual( + 'SELECT * FROM "abc" ' 'JOIN "efg" ON "abc"."dt"="efg"."dt"-INTERVAL \'1 WEEK\'', + str(q), + ) + + def test_join_with_arithmetic_function_in_select(self): + q = ( + Query.from_( + self.table0, + ) + .join(self.table1) + .on(self.table0.dt == (self.table1.dt - Interval(weeks=1))) + .select(self.table0.fiz - self.table0.buz, self.table1.star) + ) + + self.assertEqual( + 'SELECT "abc"."fiz"-"abc"."buz","efg".* FROM "abc" ' + 'JOIN "efg" ON "abc"."dt"="efg"."dt"-INTERVAL \'1 WEEK\'', + str(q), + ) + + def test_join_on_complex_criteria(self): + q = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.right) + .on((self.table0.foo == self.table1.fiz) & (self.table0.bar == self.table1.buz)) + .select("*") + ) + + self.assertEqual( + 'SELECT * FROM "abc" ' 'RIGHT JOIN "efg" ON "abc"."foo"="efg"."fiz" AND "abc"."bar"="efg"."buz"', + str(q), + ) + + def test_join_on_subquery_criteria(self): + table_a, table_b, table_c = Tables("a", "b", "c") + subquery = Query.from_(table_c).select("id").limit(1) + query = ( + Query.from_(table_a).select("*").join(table_b).on((table_a.b_id == table_b.id) & (table_b.c_id == subquery)) + ) + + self.assertEqual( + "SELECT * " 'FROM "a" ' 'JOIN "b" ON "a"."b_id"="b"."id" AND "b"."c_id"=' '(SELECT "id" FROM "c" LIMIT 1)', + str(query), + ) + + def test_use_different_table_objects_for_same_table(self): + table = Table("t") + q = Query.from_(table).select("*").where(Field("id", table=table) == 1) + + self.assertEqual('SELECT * FROM "t" WHERE "id"=1', str(q)) + + def test_join_second_table_in_from_clause(self): + table_a, table_b, table_c = Tables("a", "b", "c") + q = Query.from_(table_a).from_(table_b).select("*").join(table_c).on(table_b.c_id == table_c.id) + + self.assertEqual("SELECT * " 'FROM "a","b" ' 'JOIN "c" ON "b"."c_id"="c"."id"', str(q)) + + def test_cross_join_on_table(self): + table_a, table_b = Tables("a", "b") + q = Query.from_(table_a).join(table_b).cross().select("*") + + self.assertEqual('SELECT * FROM "a" CROSS JOIN "b"', str(q)) + + def test_cross_join_on_subquery(self): + table_a, table_b = Tables("a", "b") + q_a = Query.from_(table_a).select("*") + q_b = Query.from_(table_b).select("*").join(q_a).cross().select("*") + + self.assertEqual('SELECT * FROM "b" CROSS JOIN (SELECT * FROM "a") "sq0"', str(q_b)) + + def test_join_on_collate(self): + table_a, table_b = Tables("a", "b") + + q1 = ( + Query.from_(table_a) + .select(table_b.ouch) + .join(table_b) + .on(table_a.foo == table_b.boo, collate="utf8_general_ci") + ) + q2 = Query.from_(table_a).select(table_b.ouch).join(table_b).on(table_a.foo == table_b.boo) + + self.assertEqual( + 'SELECT "b"."ouch" FROM "a" JOIN "b" ON "a"."foo"="b"."boo" COLLATE utf8_general_ci', + str(q1), + ) + self.assertEqual('SELECT "b"."ouch" FROM "a" JOIN "b" ON "a"."foo"="b"."boo"', str(q2)) + + def test_temporal_join(self): + t0 = self.table0.for_(SYSTEM_TIME.as_of('2020-01-01')) + t1 = self.table1.for_(SYSTEM_TIME.as_of('2020-01-01')) + query = Query.from_(t0).join(t1).on(t0.foo == t1.bar).select("*") + + self.assertEqual( + 'SELECT * FROM "abc" FOR SYSTEM_TIME AS OF \'2020-01-01\' ' + 'JOIN "efg" FOR SYSTEM_TIME AS OF \'2020-01-01\' ' + 'ON "abc"."foo"="efg"."bar"', + str(query), + ) + + +class JoinBehaviorTests(unittest.TestCase): + table_abc, table_efg, table_hij, table_klm = Tables("abc", "efg", "hij", "klm") + + def test_select__ordered_select_clauses(self): + q = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .select( + self.table_abc.baz, + self.table_efg.buz, + self.table_abc.fiz, + self.table_efg.bam, + ) + ) + + self.assertEqual( + 'SELECT "abc"."baz","efg"."buz","abc"."fiz","efg"."bam" FROM "abc" ' + 'JOIN "efg" ON "abc"."foo"="efg"."bar"', + str(q), + ) + + def test_select__star_for_table(self): + q = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .join(self.table_hij) + .on(self.table_abc.buz == self.table_hij.bam) + .select(self.table_abc.star) + .select(self.table_efg.star) + .select(self.table_hij.star) + ) + + self.assertEqual( + 'SELECT "abc".*,"efg".*,"hij".* FROM "abc" ' + 'JOIN "efg" ON "abc"."foo"="efg"."bar" ' + 'JOIN "hij" ON "abc"."buz"="hij"."bam"', + str(q), + ) + + def test_select__star_for_table__replacement(self): + q = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .join(self.table_hij) + .on(self.table_abc.buz == self.table_hij.bam) + .select(self.table_abc.foo, self.table_efg.bar, self.table_hij.bam) + .select(self.table_abc.star, self.table_efg.star, self.table_hij.star) + ) + + self.assertEqual( + 'SELECT "abc".*,"efg".*,"hij".* FROM "abc" ' + 'JOIN "efg" ON "abc"."foo"="efg"."bar" ' + 'JOIN "hij" ON "abc"."buz"="hij"."bam"', + str(q), + ) + + def test_select_fields_with_where(self): + q = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .join(self.table_hij) + .on(self.table_abc.buz == self.table_hij.bam) + .select(self.table_abc.foo, self.table_efg.bar, self.table_hij.bam) + .where(self.table_abc.foo > 1) + .where(self.table_efg.bar != 2) + ) + + self.assertEqual( + 'SELECT "abc"."foo","efg"."bar","hij"."bam" FROM "abc" ' + 'JOIN "efg" ON "abc"."foo"="efg"."bar" ' + 'JOIN "hij" ON "abc"."buz"="hij"."bam" ' + 'WHERE "abc"."foo">1 AND "efg"."bar"<>2', + str(q), + ) + + def test_require_condition(self): + with self.assertRaises(JoinException): + Query.from_(self.table_abc).join(self.table_efg).on(None) + + def test_require_condition_with_both_tables(self): + with self.assertRaises(JoinException): + Query.from_(self.table_abc).join(self.table_efg).on(self.table_abc.foo == self.table_hij.bar) + + with self.assertRaises(JoinException): + Query.from_(self.table_abc).join(self.table_efg).on(self.table_hij.foo == self.table_efg.bar) + + with self.assertRaises(JoinException): + Query.from_(self.table_abc).join(self.table_efg).on(self.table_hij.foo == self.table_klm.bar) + + def test_join_same_table(self): + table1 = Table("abc") + table2 = Table("abc") + q = Query.from_(table1).join(table2).on(table1.foo == table2.bar).select(table1.foo, table2.buz) + + self.assertEqual( + 'SELECT "abc"."foo","abc2"."buz" FROM "abc" ' 'JOIN "abc" "abc2" ON "abc"."foo"="abc2"."bar"', + str(q), + ) + + def test_join_same_table_with_prefixes(self): + table1 = Table("abc").as_("x") + table2 = Table("abc").as_("y") + q = Query.from_(table1).join(table2).on(table1.foo == table2.bar).select(table1.foo, table2.buz) + + self.assertEqual( + 'SELECT "x"."foo","y"."buz" FROM "abc" "x" ' 'JOIN "abc" "y" ON "x"."foo"="y"."bar"', + str(q), + ) + + def test_join_table_twice(self): + table1, table2 = Table("efg").as_("efg1"), Table("efg").as_("efg2") + q = ( + Query.from_(self.table_abc) + .join(table1) + .on(self.table_abc.foo == table1.bar) + .join(table2) + .on(self.table_abc.foo == table2.bam) + .select(self.table_abc.foo, table1.fiz, table2.buz) + ) + + self.assertEqual( + 'SELECT "abc"."foo","efg1"."fiz","efg2"."buz" FROM "abc" ' + 'JOIN "efg" "efg1" ON "abc"."foo"="efg1"."bar" ' + 'JOIN "efg" "efg2" ON "abc"."foo"="efg2"."bam"', + str(q), + ) + + def test_select__fields_after_table_star(self): + q = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .select(self.table_abc.star, self.table_efg.bar) + .select(self.table_abc.foo) + ) + + self.assertEqual( + 'SELECT "abc".*,"efg"."bar" FROM "abc" JOIN "efg" ON "abc"."foo"="efg"."bar"', + str(q), + ) + + def test_fail_when_joining_unknown_type(self): + with self.assertRaises(ValueError): + Query.from_(self.table_abc).join("this is a string") + + def test_immutable__tables(self): + query1 = Query.from_(self.table_abc).select(self.table_abc.foo) + query2 = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .select(self.table_abc.foo, self.table_efg.buz) + ) + + self.assertEqual( + 'SELECT "abc"."foo","efg"."buz" FROM "abc" ' 'JOIN "efg" ON "abc"."foo"="efg"."bar"', + str(query2), + ) + self.assertEqual('SELECT "foo" FROM "abc"', str(query1)) + + def test_select_field_from_missing_table(self): + """ + Previously we validated the select field was a member of a table + in the query (e.g. FROM clause or a JOIN). However this made + correlated subqueries awkward to write (subqueries which refer + to their parent table. So the validation was removed. + + None of the following raise an error. Previously raised JoinException + """ + Query.from_(self.table_abc).select(self.table_efg.foo) + + Query.from_(self.table_abc).where(self.table_efg.foo == 0) + + Query.from_(self.table_abc).where(fn.Sum(self.table_efg.foo) == 0) + + Query.from_(self.table_abc).select(fn.Sum(self.table_abc.bar * 2) + fn.Sum(self.table_efg.foo * 2)) + + Query.from_(self.table_abc).groupby(self.table_efg.foo) + + Query.from_(self.table_abc).groupby(self.table_abc.foo).having(self.table_efg.bar) + + subquery = ( + Query.from_(self.table_efg).select(self.table_efg.id).where(self.table_efg.abc_id == self.table_abc.id) + ) + query = Query.from_(self.table_abc).select(subquery.as_("efg_id").limit(1)) + self.assertEqual( + 'SELECT (SELECT "efg"."id" FROM "efg" WHERE "efg"."abc_id"="abc"."id" LIMIT 1) "efg_id" FROM "abc"', + str(query), + ) + + def test_ignore_table_references(self): + query = Query.from_(Table("abc")).select(Table("abc").foo) + + self.assertEqual('SELECT "foo" FROM "abc"', str(query)) + + def test_prefixes_added_to_groupby(self): + test_query = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .select(self.table_abc.foo, fn.Sum(self.table_efg.buz)) + .groupby(self.table_abc.foo) + ) + + self.assertEqual( + 'SELECT "abc"."foo",SUM("efg"."buz") FROM "abc" ' + 'JOIN "efg" ON "abc"."foo"="efg"."bar" ' + 'GROUP BY "abc"."foo"', + str(test_query), + ) + + def test_prefixes_added_to_orderby(self): + test_query = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .select(self.table_abc.foo, self.table_efg.buz) + .orderby(self.table_abc.foo) + ) + + self.assertEqual( + 'SELECT "abc"."foo","efg"."buz" FROM "abc" ' + 'JOIN "efg" ON "abc"."foo"="efg"."bar" ' + 'ORDER BY "abc"."foo"', + str(test_query), + ) + + def test_prefixes_added_to_function_in_orderby(self): + test_query = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .select(self.table_abc.foo, self.table_efg.buz) + .orderby(fn.Date(self.table_abc.foo)) + ) + + self.assertEqual( + 'SELECT "abc"."foo","efg"."buz" FROM "abc" ' + 'JOIN "efg" ON "abc"."foo"="efg"."bar" ' + 'ORDER BY DATE("abc"."foo")', + str(test_query), + ) + + def test_join_from_join(self): + test_query = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.efg_id == self.table_efg.id) + .join(self.table_hij) + .on(self.table_efg.hij_id == self.table_hij.id) + .select(self.table_abc.foo, self.table_efg.bar, self.table_hij.fizz) + ) + + self.assertEqual( + 'SELECT "abc"."foo","efg"."bar","hij"."fizz" FROM "abc" ' + 'JOIN "efg" ON "abc"."efg_id"="efg"."id" ' + 'JOIN "hij" ON "efg"."hij_id"="hij"."id"', + str(test_query), + ) + + def test_join_query_without_alias(self): + subquery = Query.from_(self.table_efg).select( + self.table_efg.base_id.as_("x"), self.table_efg.fizz, self.table_efg.buzz + ) + + test_query = ( + Query.from_(self.table_abc) + .join(subquery) + .on(subquery.x == self.table_abc.id) + .select(self.table_abc.foo, subquery.fizz, subquery.buzz) + ) + + self.assertEqual( + 'SELECT "abc"."foo","sq0"."fizz","sq0"."buzz" ' + 'FROM "abc" JOIN (' + 'SELECT "base_id" "x","fizz","buzz" FROM "efg"' + ') "sq0" ' + 'ON "sq0"."x"="abc"."id"', + str(test_query), + ) + + def test_join_query_with_column_alias(self): + subquery = ( + Query.from_(self.table_efg) + .select( + self.table_efg.base_id.as_("x"), + self.table_efg.fizz, + self.table_efg.buzz, + ) + .as_("subq") + ) + + test_query = ( + Query.from_(self.table_abc) + .join(subquery) + .on(subquery.x == self.table_abc.id) + .select(self.table_abc.foo, subquery.fizz, subquery.buzz) + ) + + self.assertEqual( + 'SELECT "abc"."foo","subq"."fizz","subq"."buzz" ' + 'FROM "abc" JOIN (' + 'SELECT "base_id" "x","fizz","buzz" FROM "efg"' + ') "subq" ' + 'ON "subq"."x"="abc"."id"', + str(test_query), + ) + + def test_join_query_with_table_alias(self): + xxx = self.table_efg.as_("xxx") + subquery = Query.from_(xxx).select(xxx.base_id, xxx.fizz, xxx.buzz).as_("subq") + + test_query = ( + Query.from_(self.table_abc) + .join(subquery) + .on(subquery.x == self.table_abc.id) + .select(self.table_abc.foo, subquery.fizz, subquery.buzz) + ) + + self.assertEqual( + 'SELECT "abc"."foo","subq"."fizz","subq"."buzz" ' + 'FROM "abc" JOIN (' + 'SELECT "xxx"."base_id","xxx"."fizz","xxx"."buzz" FROM "efg" "xxx"' + ') "subq" ' + 'ON "subq"."x"="abc"."id"', + str(test_query), + ) + + def test_join_query_with_setoperation(self): + subquery = Query.from_(self.table_abc).select("*").union(Query.from_(self.table_abc).select("*")).as_("subq") + + test_query = ( + Query.from_(self.table_abc).join(subquery).on(subquery.x == self.table_abc.id).select(self.table_abc.foo) + ) + + self.assertEqual( + 'SELECT "abc"."foo" FROM "abc" ' + 'JOIN ' + '((SELECT * FROM "abc") ' + 'UNION ' + '(SELECT * FROM "abc")) "subq" ' + 'ON "subq"."x"="abc"."id"', + str(test_query), + ) + + +class UnionTests(unittest.TestCase): + table1, table2 = Tables("abc", "efg") + + def test_union(self): + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + + self.assertEqual( + '(SELECT "foo" FROM "abc") UNION (SELECT "bar" FROM "efg")', + str(query1 + query2), + ) + self.assertEqual( + '(SELECT "foo" FROM "abc") UNION (SELECT "bar" FROM "efg")', + str(query1.union(query2)), + ) + + def test_union_multiple(self): + table3, table4 = Tables("hij", "lmn") + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + query3 = Query.from_(table3).select(table3.baz) + query4 = Query.from_(table4).select(table4.faz) + + self.assertEqual( + '(SELECT "foo" FROM "abc") UNION ' + '(SELECT "bar" FROM "efg") UNION ' + '(SELECT "baz" FROM "hij") UNION ' + '(SELECT "faz" FROM "lmn")', + str(query1 + query2 + query3 + query4), + ) + self.assertEqual( + '(SELECT "foo" FROM "abc") UNION ' + '(SELECT "bar" FROM "efg") UNION ' + '(SELECT "baz" FROM "hij") UNION ' + '(SELECT "faz" FROM "lmn")', + str(query1.union(query2).union(query3).union(query4)), + ) + + def test_union_all(self): + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + + self.assertEqual( + '(SELECT "foo" FROM "abc") UNION ALL (SELECT "bar" FROM "efg")', + str(query1 * query2), + ) + self.assertEqual( + '(SELECT "foo" FROM "abc") UNION ALL (SELECT "bar" FROM "efg")', + str(query1.union_all(query2)), + ) + + def test_union_all_multiple(self): + table3, table4 = Tables("hij", "lmn") + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + query3 = Query.from_(table3).select(table3.baz) + query4 = Query.from_(table4).select(table4.faz) + + self.assertEqual( + '(SELECT "foo" FROM "abc") UNION ALL ' + '(SELECT "bar" FROM "efg") UNION ALL ' + '(SELECT "baz" FROM "hij") UNION ALL ' + '(SELECT "faz" FROM "lmn")', + str(query1 * query2 * query3 * query4), + ) + self.assertEqual( + '(SELECT "foo" FROM "abc") UNION ALL ' + '(SELECT "bar" FROM "efg") UNION ALL ' + '(SELECT "baz" FROM "hij") UNION ALL ' + '(SELECT "faz" FROM "lmn")', + str(query1.union_all(query2).union_all(query3).union_all(query4)), + ) + + def test_union_with_order_by(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + union_query = str((query1 + query2).orderby(query1.field("a"))) + union_all_query = str((query1 * query2).orderby(query1.field("a"))) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "UNION " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "a"', + union_query, + ) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "UNION ALL " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "a"', + union_all_query, + ) + + def test_union_with_order_by_use_union_query_field(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + union_query = query1 + query2 + union_query = str(union_query.orderby(union_query.field("a"))) + union_all_query = query1 * query2 + union_all_query = str(union_all_query.orderby(union_all_query.field("a"))) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "UNION " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "a"', + union_query, + ) + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "UNION ALL " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "a"', + union_all_query, + ) + + def test_union_with_order_by_with_aliases(self): + query1 = Query.from_(self.table1.as_("a")).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2.as_("b")).select(self.table2.bar.as_("a")) + + union_all_query = str((query1 * query2).orderby(query1.field("a"))) + union_query = str((query1 + query2).orderby(query1.field("a"))) + self.assertEqual( + '(SELECT "foo" "a" FROM "abc" "a")' " UNION ALL " '(SELECT "bar" "a" FROM "efg" "b")' ' ORDER BY "a"', + union_all_query, + ) + self.assertEqual( + '(SELECT "foo" "a" FROM "abc" "a")' " UNION " '(SELECT "bar" "a" FROM "efg" "b")' ' ORDER BY "a"', + union_query, + ) + + def test_union_with_order_by_use_union_query_field_with_aliases(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + union_query = (query1 + query2).as_("x") + union_query = union_query.orderby(union_query.field("a")) + union_all_query = (query1 * query2).as_("x") + union_all_query = union_all_query.orderby(union_all_query.field("a")) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "UNION " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "x"."a"', + str(union_query), + ) + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "UNION ALL " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "x"."a"', + str(union_all_query), + ) + + def test_require_equal_number_of_fields(self): + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.fiz, self.table2.buz) + + with self.assertRaises(SetOperationException): + str(query1 + query2) + + def test_mysql_query_wraps_unioned_queries(self): + query1 = MySQLQuery.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + + self.assertEqual( + "(SELECT `foo` FROM `abc`) UNION (SELECT `bar` FROM `efg`)", + str(query1 + query2), + ) + + def test_union_as_subquery(self): + abc, efg = Tables("abc", "efg") + hij = Query.from_(abc).select(abc.t).union(Query.from_(efg).select(efg.t)) + q = Query.from_(hij).select(fn.Avg(hij.t)) + + self.assertEqual( + 'SELECT AVG("sq0"."t") FROM ((SELECT "t" FROM "abc") UNION (SELECT "t" FROM "efg")) "sq0"', + str(q), + ) + + def test_union_with_no_quote_char(self): + abc, efg = Tables("abc", "efg") + hij = Query.from_(abc).select(abc.t).union(Query.from_(efg).select(efg.t)) + q = Query.from_(hij).select(fn.Avg(hij.t)) + + self.assertEqual( + "SELECT AVG(sq0.t) FROM ((SELECT t FROM abc) UNION (SELECT t FROM efg)) sq0", + q.get_sql(quote_char=None), + ) + + +class InsertQueryJoinTests(unittest.TestCase): + def test_join_table_on_insert_query(self): + a, b, c = Tables("a", "b", "c") + q = Query.into(c).from_(a).join(b).on(a.fkey_id == b.id).where(b.foo == 1).select("a.*", "b.*") + + self.assertEqual( + 'INSERT INTO "c" ' + 'SELECT "a"."a.*","a"."b.*" ' + 'FROM "a" JOIN "b" ' + 'ON "a"."fkey_id"="b"."id" ' + 'WHERE "b"."foo"=1', + str(q), + ) + + +class UpdateQueryJoinTests(unittest.TestCase): + def test_join_table_on_update_query(self): + a, b = Tables("a", "b") + q = Query.update(a).join(b).on(a.fkey_id == b.id).where(b.foo == 1).set("adwords_batch_job_id", 1) + + self.assertEqual( + 'UPDATE "a" ' 'JOIN "b" ' 'ON "a"."fkey_id"="b"."id" ' 'SET "adwords_batch_job_id"=1 ' 'WHERE "b"."foo"=1', + str(q), + ) + + +class IntersectTests(unittest.TestCase): + table1, table2 = Tables("abc", "efg") + + def test_intersect(self): + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + + self.assertEqual( + '(SELECT "foo" FROM "abc") INTERSECT (SELECT "bar" FROM "efg")', + str(query1.intersect(query2)), + ) + + def test_intersect_multiple(self): + table3, table4 = Tables("hij", "lmn") + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + query3 = Query.from_(table3).select(table3.baz) + query4 = Query.from_(table4).select(table4.faz) + + self.assertEqual( + '(SELECT "foo" FROM "abc") INTERSECT ' + '(SELECT "bar" FROM "efg") INTERSECT ' + '(SELECT "baz" FROM "hij") INTERSECT ' + '(SELECT "faz" FROM "lmn")', + str(query1.intersect(query2).intersect(query3).intersect(query4)), + ) + + def test_intersect_with_order_by(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + intersect_query = str((query1.intersect(query2)).orderby(query1.field("a"))) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "INTERSECT " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "a"', + intersect_query, + ) + + def test_intersect_with_limit(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + intersect_query = str((query1.intersect(query2)).limit(10)) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "INTERSECT " '(SELECT "bar" "a" FROM "efg") ' 'LIMIT 10', + intersect_query, + ) + + def test_intersect_with_offset(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + intersect_query = str((query1.intersect(query2)).offset(10)) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "INTERSECT " '(SELECT "bar" "a" FROM "efg") ' 'OFFSET 10', + intersect_query, + ) + + def test_require_equal_number_of_fields_intersect(self): + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.fiz, self.table2.buz) + + with self.assertRaises(SetOperationException): + str(query1.intersect(query2)) + + def test_mysql_query_wraps_intersected_queries(self): + query1 = MySQLQuery.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + + self.assertEqual( + "(SELECT `foo` FROM `abc`) INTERSECT (SELECT `bar` FROM `efg`)", + str(query1.intersect(query2)), + ) + + def test_intersect_as_subquery(self): + abc, efg = Tables("abc", "efg") + hij = Query.from_(abc).select(abc.t).intersect(Query.from_(efg).select(efg.t)) + q = Query.from_(hij).select(fn.Avg(hij.t)) + + self.assertEqual( + 'SELECT AVG("sq0"."t") FROM ((SELECT "t" FROM "abc") INTERSECT (SELECT "t" FROM "efg")) "sq0"', + str(q), + ) + + def test_intersect_with_no_quote_char(self): + abc, efg = Tables("abc", "efg") + hij = Query.from_(abc).select(abc.t).intersect(Query.from_(efg).select(efg.t)) + q = Query.from_(hij).select(fn.Avg(hij.t)) + + self.assertEqual( + "SELECT AVG(sq0.t) FROM ((SELECT t FROM abc) INTERSECT (SELECT t FROM efg)) sq0", + q.get_sql(quote_char=None), + ) + + +class MinusTests(unittest.TestCase): + table1, table2 = Tables("abc", "efg") + + def test_minus(self): + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + + self.assertEqual('(SELECT "foo" FROM "abc") MINUS (SELECT "bar" FROM "efg")', str(query1.minus(query2))) + + self.assertEqual( + '(SELECT "foo" FROM "abc") MINUS (SELECT "bar" FROM "efg")', + str(query1 - query2), + ) + + def test_minus_multiple(self): + table3, table4 = Tables("hij", "lmn") + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + query3 = Query.from_(table3).select(table3.baz) + query4 = Query.from_(table4).select(table4.faz) + + self.assertEqual( + '(SELECT "foo" FROM "abc") MINUS ' + '(SELECT "bar" FROM "efg") MINUS ' + '(SELECT "baz" FROM "hij") MINUS ' + '(SELECT "faz" FROM "lmn")', + str(query1 - query2 - query3 - query4), + ) + + self.assertEqual( + '(SELECT "foo" FROM "abc") MINUS ' + '(SELECT "bar" FROM "efg") MINUS ' + '(SELECT "baz" FROM "hij") MINUS ' + '(SELECT "faz" FROM "lmn")', + str(query1.minus(query2).minus(query3).minus(query4)), + ) + + def test_minus_with_order_by(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + minus_query = str(query1.minus(query2).orderby(query1.field("a"))) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "MINUS " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "a"', minus_query + ) + + def test_minus_query_with_order_by_use_minus_query_field(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + minus_query = query1.minus(query2) + minus_query = str(minus_query.orderby(minus_query.field("b"))) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "MINUS " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "b"', + minus_query, + ) + + def test_require_equal_number_of_fields(self): + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.fiz, self.table2.buz) + + with self.assertRaises(SetOperationException): + str(query1.minus(query2)) + + def test_mysql_query_wraps_minus_queries(self): + query1 = MySQLQuery.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + + self.assertEqual( + "(SELECT `foo` FROM `abc`) MINUS (SELECT `bar` FROM `efg`)", + str(query1 - query2), + ) + + def test_minus_as_subquery(self): + abc, efg = Tables("abc", "efg") + hij = Query.from_(abc).select(abc.t).minus(Query.from_(efg).select(efg.t)) + q = Query.from_(hij).select(fn.Avg(hij.t)) + + self.assertEqual( + 'SELECT AVG("sq0"."t") FROM ((SELECT "t" FROM "abc") MINUS (SELECT "t" FROM "efg")) "sq0"', + str(q), + ) + + def test_minus_with_no_quote_char(self): + abc, efg = Tables("abc", "efg") + hij = Query.from_(abc).select(abc.t).minus(Query.from_(efg).select(efg.t)) + q = Query.from_(hij).select(fn.Avg(hij.t)) + + self.assertEqual( + "SELECT AVG(sq0.t) FROM ((SELECT t FROM abc) MINUS (SELECT t FROM efg)) sq0", + q.get_sql(quote_char=None), + ) + + +class ExceptOfTests(unittest.TestCase): + table1, table2 = Tables("abc", "efg") + + def test_except(self): + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + + self.assertEqual('(SELECT "foo" FROM "abc") EXCEPT (SELECT "bar" FROM "efg")', str(query1.except_of(query2))) + + def test_except_multiple(self): + table3, table4 = Tables("hij", "lmn") + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + query3 = Query.from_(table3).select(table3.baz) + query4 = Query.from_(table4).select(table4.faz) + + self.assertEqual( + '(SELECT "foo" FROM "abc") EXCEPT ' + '(SELECT "bar" FROM "efg") EXCEPT ' + '(SELECT "baz" FROM "hij") EXCEPT ' + '(SELECT "faz" FROM "lmn")', + str(query1.except_of(query2).except_of(query3).except_of(query4)), + ) + + def test_except_with_order_by(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + except_query = str(query1.except_of(query2).orderby(query1.field("a"))) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "EXCEPT " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "a"', except_query + ) + + def test_except_query_with_order_by_use_minus_query_field(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + except_query = query1.except_of(query2) + except_query = str(except_query.orderby(except_query.field("b"))) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "EXCEPT " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "b"', + except_query, + ) + + def test_require_equal_number_of_fields_except_of(self): + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.fiz, self.table2.buz) + + with self.assertRaises(SetOperationException): + str(query1.except_of(query2)) + + def test_except_as_subquery(self): + abc, efg = Tables("abc", "efg") + hij = Query.from_(abc).select(abc.t).except_of(Query.from_(efg).select(efg.t)) + q = Query.from_(hij).select(fn.Avg(hij.t)) + + self.assertEqual( + 'SELECT AVG("sq0"."t") FROM ((SELECT "t" FROM "abc") EXCEPT (SELECT "t" FROM "efg")) "sq0"', + str(q), + ) + + def test_except_with_no_quote_char(self): + abc, efg = Tables("abc", "efg") + hij = Query.from_(abc).select(abc.t).except_of(Query.from_(efg).select(efg.t)) + q = Query.from_(hij).select(fn.Avg(hij.t)) + + self.assertEqual( + "SELECT AVG(sq0.t) FROM ((SELECT t FROM abc) EXCEPT (SELECT t FROM efg)) sq0", + q.get_sql(quote_char=None), + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/test_negation.py b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/test_negation.py new file mode 100644 index 0000000000000000000000000000000000000000..9f4db83b560dbc8546ce6d384b781dfccefd319d --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/test_negation.py @@ -0,0 +1,31 @@ +import unittest + +from pypika import ( + Tables, + functions as fn, +) +from pypika.terms import ValueWrapper + + +class NegationTests(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_negate_wrapped_float(self): + q = -ValueWrapper(1.0) + + self.assertEqual("-1.0", q.get_sql()) + + def test_negate_wrapped_int(self): + q = -ValueWrapper(1) + + self.assertEqual("-1", q.get_sql()) + + def test_negate_field(self): + q = -self.table_abc.foo + + self.assertEqual('-"abc"."foo"', q.get_sql(with_namespace=True, quote_char='"')) + + def test_negate_function(self): + q = -fn.Sum(self.table_abc.foo) + + self.assertEqual('-SUM("abc"."foo")', q.get_sql(with_namespace=True, quote_char='"')) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/test_parameter.py b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/test_parameter.py new file mode 100644 index 0000000000000000000000000000000000000000..c11e9afcd9624abb0a7313306eda34ebcf4c99ba --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/test_parameter.py @@ -0,0 +1,206 @@ +import unittest +from datetime import date + +from pypika import ( + FormatParameter, + NamedParameter, + NumericParameter, + Parameter, + PyformatParameter, + QmarkParameter, + Query, + Tables, +) +from pypika.terms import ListParameter, ParameterValueWrapper + + +class ParametrizedTests(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_param_insert(self): + q = Query.into(self.table_abc).columns("a", "b", "c").insert(Parameter("?"), Parameter("?"), Parameter("?")) + + self.assertEqual('INSERT INTO "abc" ("a","b","c") VALUES (?,?,?)', q.get_sql()) + + def test_param_select_join(self): + q = ( + Query.from_(self.table_abc) + .select("*") + .where(self.table_abc.category == Parameter("%s")) + .join(self.table_efg) + .on(self.table_abc.id == self.table_efg.abc_id) + .where(self.table_efg.date >= Parameter("%s")) + .limit(10) + ) + + self.assertEqual( + 'SELECT * FROM "abc" JOIN "efg" ON "abc"."id"="efg"."abc_id" WHERE "abc"."category"=%s AND "efg"."date">=%s LIMIT 10', + q.get_sql(), + ) + + def test_param_select_subquery(self): + q = ( + Query.from_(self.table_abc) + .select("*") + .where(self.table_abc.category == Parameter("&1")) + .where( + self.table_abc.id.isin( + Query.from_(self.table_efg) + .select(self.table_efg.abc_id) + .where(self.table_efg.date >= Parameter("&2")) + ) + ) + .limit(10) + ) + + self.assertEqual( + 'SELECT * FROM "abc" WHERE "category"=&1 AND "id" IN (SELECT "abc_id" FROM "efg" WHERE "date">=&2) LIMIT 10', + q.get_sql(), + ) + + def test_join(self): + subquery = ( + Query.from_(self.table_efg) + .select(self.table_efg.fiz, self.table_efg.buz) + .where(self.table_efg.buz == Parameter(":buz")) + ) + + q = ( + Query.from_(self.table_abc) + .join(subquery) + .on(self.table_abc.bar == subquery.buz) + .select(self.table_abc.foo, subquery.fiz) + .where(self.table_abc.bar == Parameter(":bar")) + ) + + self.assertEqual( + 'SELECT "abc"."foo","sq0"."fiz" FROM "abc" JOIN (SELECT "fiz","buz" FROM "efg" WHERE "buz"=:buz)' + ' "sq0" ON "abc"."bar"="sq0"."buz" WHERE "abc"."bar"=:bar', + q.get_sql(), + ) + + def test_qmark_parameter(self): + self.assertEqual('?', QmarkParameter().get_sql()) + + def test_numeric_parameter(self): + self.assertEqual(':14', NumericParameter('14').get_sql()) + self.assertEqual(':15', NumericParameter(15).get_sql()) + + def test_named_parameter(self): + self.assertEqual(':buz', NamedParameter('buz').get_sql()) + + def test_format_parameter(self): + self.assertEqual('%s', FormatParameter().get_sql()) + + def test_pyformat_parameter(self): + self.assertEqual('%(buz)s', PyformatParameter('buz').get_sql()) + + +class ParametrizedTestsWithValues(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_param_insert(self): + q = Query.into(self.table_abc).columns("a", "b", "c").insert(1, 2.2, 'foo') + + parameter = QmarkParameter() + sql = q.get_sql(parameter=parameter) + self.assertEqual('INSERT INTO "abc" ("a","b","c") VALUES (?,?,?)', sql) + self.assertEqual([1, 2.2, 'foo'], parameter.get_parameters()) + + def test_param_select_join(self): + q = ( + Query.from_(self.table_abc) + .select("*") + .where(self.table_abc.category == 'foobar') + .join(self.table_efg) + .on(self.table_abc.id == self.table_efg.abc_id) + .where(self.table_efg.date >= date(2024, 2, 22)) + .limit(10) + ) + + parameter = FormatParameter() + sql = q.get_sql(parameter=parameter) + self.assertEqual( + 'SELECT * FROM "abc" JOIN "efg" ON "abc"."id"="efg"."abc_id" WHERE "abc"."category"=%s AND "efg"."date">=%s LIMIT 10', + sql, + ) + self.assertEqual(['foobar', '2024-02-22'], parameter.get_parameters()) + + def test_param_select_subquery(self): + q = ( + Query.from_(self.table_abc) + .select("*") + .where(self.table_abc.category == 'foobar') + .where( + self.table_abc.id.isin( + Query.from_(self.table_efg) + .select(self.table_efg.abc_id) + .where(self.table_efg.date >= date(2024, 2, 22)) + ) + ) + .limit(10) + ) + + parameter = ListParameter(placeholder=lambda idx: f'&{idx+1}') + sql = q.get_sql(parameter=parameter) + self.assertEqual( + 'SELECT * FROM "abc" WHERE "category"=&1 AND "id" IN (SELECT "abc_id" FROM "efg" WHERE "date">=&2) LIMIT 10', + sql, + ) + self.assertEqual(['foobar', '2024-02-22'], parameter.get_parameters()) + + def test_join(self): + subquery = ( + Query.from_(self.table_efg) + .select(self.table_efg.fiz, self.table_efg.buz) + .where(self.table_efg.buz == 'buz') + ) + + q = ( + Query.from_(self.table_abc) + .join(subquery) + .on(self.table_abc.bar == subquery.buz) + .select(self.table_abc.foo, subquery.fiz) + .where(self.table_abc.bar == 'bar') + ) + + parameter = NamedParameter() + sql = q.get_sql(parameter=parameter) + self.assertEqual( + 'SELECT "abc"."foo","sq0"."fiz" FROM "abc" JOIN (SELECT "fiz","buz" FROM "efg" WHERE "buz"=:param1)' + ' "sq0" ON "abc"."bar"="sq0"."buz" WHERE "abc"."bar"=:param2', + sql, + ) + self.assertEqual({'param1': 'buz', 'param2': 'bar'}, parameter.get_parameters()) + + def test_join_with_parameter_value_wrapper(self): + subquery = ( + Query.from_(self.table_efg) + .select(self.table_efg.fiz, self.table_efg.buz) + .where(self.table_efg.buz == ParameterValueWrapper(Parameter(':buz'), 'buz')) + ) + + q = ( + Query.from_(self.table_abc) + .join(subquery) + .on(self.table_abc.bar == subquery.buz) + .select(self.table_abc.foo, subquery.fiz) + .where(self.table_abc.bar == ParameterValueWrapper(NamedParameter('bar'), 'bar')) + ) + + parameter = NamedParameter() + sql = q.get_sql(parameter=parameter) + self.assertEqual( + 'SELECT "abc"."foo","sq0"."fiz" FROM "abc" JOIN (SELECT "fiz","buz" FROM "efg" WHERE "buz"=:buz)' + ' "sq0" ON "abc"."bar"="sq0"."buz" WHERE "abc"."bar"=:bar', + sql, + ) + self.assertEqual({':buz': 'buz', 'bar': 'bar'}, parameter.get_parameters()) + + def test_pyformat_parameter(self): + q = Query.into(self.table_abc).columns("a", "b", "c").insert(1, 2.2, 'foo') + + parameter = PyformatParameter() + sql = q.get_sql(parameter=parameter) + self.assertEqual('INSERT INTO "abc" ("a","b","c") VALUES (%(param1)s,%(param2)s,%(param3)s)', sql) + self.assertEqual({"param1": 1, "param2": 2.2, "param3": "foo"}, parameter.get_parameters()) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/test_pseudocolumns.py b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/test_pseudocolumns.py new file mode 100644 index 0000000000000000000000000000000000000000..6a25c70269b2ccc98ac3870ac64a43c8a32ddbe9 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/test_pseudocolumns.py @@ -0,0 +1,51 @@ +import unittest + +from pypika import Query, Table +from pypika.pseudocolumns import ( + ColumnValue, + ObjectID, + ObjectValue, + RowID, + RowNum, + SysDate, +) +from pypika.terms import PseudoColumn + + +class PseudoColumnsTest(unittest.TestCase): + @classmethod + def setUpClass(cls): + super(PseudoColumnsTest, cls).setUpClass() + cls.table1 = Table("table1") + + def test_column_value(self): + self.assertEqual("COLUMN_VALUE", ColumnValue) + + def test_object_id(self): + self.assertEqual("OBJECT_ID", ObjectID) + + def test_object_value(self): + self.assertEqual("OBJECT_VALUE", ObjectValue) + + def test_row_id(self): + self.assertEqual("ROWID", RowID) + + def test_row_num(self): + self.assertEqual("ROWNUM", RowNum) + + def test_sys_date(self): + self.assertEqual("SYSDATE", SysDate) + + def test_can_be_used_in_a_select_statement(self): + query = Query.from_(self.table1).where(self.table1.is_active == 1).select(PseudoColumn("abcde")) + + self.assertEqual(str(query), 'SELECT abcde FROM "table1" WHERE "is_active"=1') + + def test_can_be_used_in_a_where_clause(self): + query = Query.from_(self.table1).where(PseudoColumn("abcde") > 1).select(self.table1.is_active) + + self.assertEqual(str(query), 'SELECT "is_active" FROM "table1" WHERE abcde>1') + + def test_can_be_used_in_orderby(self): + query = Query.from_(self.table1).select(self.table1.abcde.as_("some_name")).orderby(PseudoColumn("some_name")) + self.assertEqual(str(query), 'SELECT "abcde" "some_name" FROM "table1" ORDER BY some_name') diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/test_query.py b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/test_query.py new file mode 100644 index 0000000000000000000000000000000000000000..ae8dc01599a6a562b591ce15391bfe9b5c87e0f9 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/test_query.py @@ -0,0 +1,242 @@ +import unittest + +from pypika import Case, Query, Tables, Tuple, functions, Field +from pypika.dialects import ( + ClickHouseQuery, + ClickHouseQueryBuilder, + MSSQLQuery, + MSSQLQueryBuilder, + MySQLLoadQueryBuilder, + MySQLQuery, + MySQLQueryBuilder, + OracleQuery, + OracleQueryBuilder, + PostgreSQLQuery, + PostgreSQLQueryBuilder, + RedShiftQueryBuilder, + RedshiftQuery, + SQLLiteQuery, + SQLLiteQueryBuilder, + SnowflakeQuery, + SnowflakeQueryBuilder, + VerticaCopyQueryBuilder, + VerticaCreateQueryBuilder, + VerticaQuery, + VerticaQueryBuilder, +) +from pypika.queries import CreateQueryBuilder, DropQueryBuilder, QueryBuilder + + +class QueryTablesTests(unittest.TestCase): + table_a, table_b, table_c, table_d = Tables("a", "b", "c", "d") + + def test_replace_table(self): + query = Query.from_(self.table_a).select(self.table_a.time) + query = query.replace_table(self.table_a, self.table_b) + + self.assertEqual('SELECT "time" FROM "b"', str(query)) + + def test_replace_only_specified_table(self): + query = Query.from_(self.table_a).select(self.table_a.time) + query = query.replace_table(self.table_b, self.table_c) + + self.assertEqual('SELECT "time" FROM "a"', str(query)) + + def test_replace_insert_table(self): + query = Query.into(self.table_a).insert(1) + query = query.replace_table(self.table_a, self.table_b) + + self.assertEqual('INSERT INTO "b" VALUES (1)', str(query)) + + def test_replace_insert_table_current_table_not_match(self): + query = Query.into(self.table_a).insert(1) + query = query.replace_table(self.table_c, self.table_b) + + self.assertEqual('INSERT INTO "a" VALUES (1)', str(query)) + + def test_replace_update_table(self): + query = Query.update(self.table_a).set("foo", "bar") + query = query.replace_table(self.table_a, self.table_b) + + self.assertEqual('UPDATE "b" SET "foo"=\'bar\'', str(query)) + + def test_replace_update_table_current_table_not_match(self): + query = Query.update(self.table_a).set("foo", "bar") + query = query.replace_table(self.table_c, self.table_b) + + self.assertEqual('UPDATE "a" SET "foo"=\'bar\'', str(query)) + + def test_replace_delete_table(self): + query = Query.from_(self.table_a).delete() + query = query.replace_table(self.table_a, self.table_b) + + self.assertEqual('DELETE FROM "b"', str(query)) + + def test_replace_join_tables(self): + query = ( + Query.from_(self.table_a) + .join(self.table_b) + .on(self.table_a.customer_id == self.table_b.id) + .join(self.table_c) + .on(self.table_b.seller_id == self.table_c.id) + .select(self.table_a.star) + ) + query = query.replace_table(self.table_a, self.table_d) + + self.assertEqual( + 'SELECT "d".* ' + 'FROM "d" ' + 'JOIN "b" ON "d"."customer_id"="b"."id" ' + 'JOIN "c" ON "b"."seller_id"="c"."id"', + str(query), + ) + + def test_replace_filter_tables(self): + query = Query.from_(self.table_a).select(self.table_a.name).where(self.table_a.name == "Mustermann") + query = query.replace_table(self.table_a, self.table_b) + + self.assertEqual('SELECT "name" FROM "b" WHERE "name"=\'Mustermann\'', str(query)) + + def test_replace_having_table(self): + query = ( + Query.from_(self.table_a) + .select(functions.Sum(self.table_a.revenue)) + .groupby(self.table_a.customer) + .having(functions.Sum(self.table_a.revenue) >= 1000) + ) + query = query.replace_table(self.table_a, self.table_b) + + self.assertEqual( + 'SELECT SUM("revenue") ' 'FROM "b" ' 'GROUP BY "customer" ' 'HAVING SUM("revenue")>=1000', + str(query), + ) + + def test_replace_case_table(self): + query = Query.from_(self.table_a).select( + Case() + .when(self.table_a.fname == "Tom", "It was Tom") + .when(self.table_a.fname == "John", "It was John") + .else_("It was someone else.") + .as_("who_was_it") + ) + query = query.replace_table(self.table_a, self.table_b) + + self.assertEqual( + "SELECT CASE " + "WHEN \"fname\"='Tom' THEN 'It was Tom' " + "WHEN \"fname\"='John' THEN 'It was John' " + "ELSE 'It was someone else.' END \"who_was_it\" " + 'FROM "b"', + str(query), + ) + + def test_replace_orderby_table(self): + query = Query.from_(self.table_a).select(self.table_a.customer).orderby(self.table_a.customer) + query = query.replace_table(self.table_a, self.table_b) + + self.assertEqual('SELECT "customer" FROM "b" ORDER BY "customer"', str(query)) + + def test_replace_tuple_table(self): + query = ( + Query.from_(self.table_a) + .select(self.table_a.cost, self.table_a.revenue) + .where((self.table_a.cost, self.table_a.revenue) == Tuple(1, 2)) + ) + + query = query.replace_table(self.table_a, self.table_b) + + # Order is reversed due to lack of right equals method + self.assertEqual( + 'SELECT "cost","revenue" FROM "b" WHERE (1,2)=("cost","revenue")', + str(query), + ) + + def test_is_joined(self): + q = Query.from_(self.table_a).join(self.table_b).on(self.table_a.foo == self.table_b.boo) + + self.assertTrue(q.is_joined(self.table_b)) + self.assertFalse(q.is_joined(self.table_c)) + + +class QueryBuilderTests(unittest.TestCase): + def test_query_builders_have_reference_to_correct_query_class(self): + with self.subTest('QueryBuilder'): + self.assertEqual(Query, QueryBuilder.QUERY_CLS) + + with self.subTest('DropQueryBuilder'): + self.assertEqual(Query, DropQueryBuilder.QUERY_CLS) + + with self.subTest('CreateQueryBuilder'): + self.assertEqual(Query, CreateQueryBuilder.QUERY_CLS) + + with self.subTest('MySQLQueryBuilder'): + self.assertEqual(MySQLQuery, MySQLQueryBuilder.QUERY_CLS) + + with self.subTest('MySQLLoadQueryBuilder'): + self.assertEqual(MySQLQuery, MySQLLoadQueryBuilder.QUERY_CLS) + + with self.subTest('VerticaQueryBuilder'): + self.assertEqual(VerticaQuery, VerticaQueryBuilder.QUERY_CLS) + + with self.subTest('VerticaCreateQueryBuilder'): + self.assertEqual(VerticaQuery, VerticaCreateQueryBuilder.QUERY_CLS) + + with self.subTest('VerticaCopyQueryBuilder'): + self.assertEqual(VerticaQuery, VerticaCopyQueryBuilder.QUERY_CLS) + + with self.subTest('PostgreSQLQueryBuilder'): + self.assertEqual(PostgreSQLQuery, PostgreSQLQueryBuilder.QUERY_CLS) + + with self.subTest('MSSQLQueryBuilder'): + self.assertEqual(MSSQLQuery, MSSQLQueryBuilder.QUERY_CLS) + + with self.subTest('SnowflakeQueryBuilder'): + self.assertEqual(SnowflakeQuery, SnowflakeQueryBuilder.QUERY_CLS) + + with self.subTest('ClickHouseQueryBuilder'): + self.assertEqual(ClickHouseQuery, ClickHouseQueryBuilder.QUERY_CLS) + + with self.subTest('RedShiftQueryBuilder'): + self.assertEqual(RedshiftQuery, RedShiftQueryBuilder.QUERY_CLS) + + with self.subTest('SQLLiteQueryBuilder'): + self.assertEqual(SQLLiteQuery, SQLLiteQueryBuilder.QUERY_CLS) + + with self.subTest('OracleQueryBuilder'): + self.assertEqual(OracleQuery, OracleQueryBuilder.QUERY_CLS) + + def test_pipe(self) -> None: + base_query = Query.from_("test") + + def select(query: QueryBuilder) -> QueryBuilder: + return query.select("test1", "test2") + + def count_group(query: QueryBuilder, *groups) -> QueryBuilder: + return query.groupby(*groups).select(*groups, functions.Count("*")) + + for func, args, kwargs, expected_str in [ + (select, [], {}, 'SELECT "test1","test2" FROM "test"'), + ( + count_group, + ["test1", "test2"], + {}, + 'SELECT "test1","test2",COUNT(*) FROM "test" GROUP BY "test1","test2"', + ), + (count_group, ["test1"], {}, 'SELECT "test1",COUNT(*) FROM "test" GROUP BY "test1"'), + ]: + result_str = str(base_query.pipe(func, *args, **kwargs)) + self.assertEqual(result_str, str(func(base_query, *args, **kwargs))) + self.assertEqual(result_str, expected_str) + + def where_clause(query: QueryBuilder, num_days: int) -> QueryBuilder: + return query.where(Field("date") > functions.Now() - num_days) + + result_str = str(base_query.pipe(select).pipe(where_clause, num_days=1)) + self.assertEqual( + result_str, + str(select(where_clause(base_query, num_days=1))), + ) + self.assertEqual( + result_str, + 'SELECT "test1","test2" FROM "test" WHERE "date">NOW()-1', + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/test_selects.py b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/test_selects.py new file mode 100644 index 0000000000000000000000000000000000000000..1ce04937492e655db362b7e2a0a6856abf22a48f --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/test_selects.py @@ -0,0 +1,1331 @@ +import unittest +from datetime import date +from enum import Enum + +from pypika import ( + AliasedQuery, + Case, + ClickHouseQuery, + EmptyCriterion, + Field as F, + Index, + MSSQLQuery, + MySQLQuery, + NullValue, + OracleQuery, + Order, + PostgreSQLQuery, + Query, + QueryException, + RedshiftQuery, + SQLLiteQuery, + Table, + Tables, + VerticaQuery, + functions as fn, + SYSTEM_TIME, +) +from pypika.terms import ValueWrapper + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + + +class SelectTests(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_empty_query(self): + q = Query.from_("abc") + + self.assertEqual("", str(q)) + + def test_select_no_from(self): + q = Query.select(1) + + self.assertEqual("SELECT 1", str(q)) + + def test_select_no_with_alias_from(self): + q = Query.select(ValueWrapper(1, "test")) + + self.assertEqual('SELECT 1 "test"', str(q)) + + def test_select_no_from_with_field_raises_exception(self): + with self.assertRaises(QueryException): + Query.select("asdf") + + def test_select__star(self): + q = Query.from_("abc").select("*") + + self.assertEqual('SELECT * FROM "abc"', str(q)) + + def test_select__table_schema(self): + q = Query.from_(Table("abc", "schema1")).select("*") + + self.assertEqual('SELECT * FROM "schema1"."abc"', str(q)) + + def test_select__table_schema_with_multiple_levels_as_tuple(self): + q = Query.from_(Table("abc", ("schema1", "schema2"))).select("*") + + self.assertEqual('SELECT * FROM "schema1"."schema2"."abc"', str(q)) + + def test_select__table_schema_with_multiple_levels_as_list(self): + q = Query.from_(Table("abc", ["schema1", "schema2"])).select("*") + + self.assertEqual('SELECT * FROM "schema1"."schema2"."abc"', str(q)) + + def test_select__star__replacement(self): + q = Query.from_("abc").select("foo").select("*") + + self.assertEqual('SELECT * FROM "abc"', str(q)) + + def test_select__distinct__single(self): + q = Query.from_("abc").select("foo").distinct() + + self.assertEqual('SELECT DISTINCT "foo" FROM "abc"', str(q)) + + def test_select__distinct__multi(self): + q = Query.from_("abc").select("foo", "bar").distinct() + + self.assertEqual('SELECT DISTINCT "foo","bar" FROM "abc"', str(q)) + + def test_select__column__single__str(self): + q = Query.from_("abc").select("foo") + + self.assertEqual('SELECT "foo" FROM "abc"', str(q)) + + def test_select__column__single__alias__str(self): + q = Query.from_(self.table_abc).select(self.table_abc.foo.as_("bar")) + + self.assertEqual('SELECT "foo" "bar" FROM "abc"', str(q)) + + def test_select__column__single__table_alias__str(self): + q = Query.from_(self.table_abc.as_("fizzbuzz")).select(self.table_abc.foo.as_("bar")) + + self.assertEqual('SELECT "foo" "bar" FROM "abc" "fizzbuzz"', str(q)) + + def test_select__column__single__field(self): + t = Table("abc") + q = Query.from_(t).select(t.foo) + + self.assertEqual('SELECT "foo" FROM "abc"', str(q)) + + def test_select__columns__multi__str(self): + q1 = Query.from_("abc").select("foo", "bar") + q2 = Query.from_("abc").select("foo").select("bar") + + self.assertEqual('SELECT "foo","bar" FROM "abc"', str(q1)) + self.assertEqual('SELECT "foo","bar" FROM "abc"', str(q2)) + + def test_select__columns__multi__field(self): + q1 = Query.from_(self.table_abc).select(self.table_abc.foo, self.table_abc.bar) + q2 = Query.from_(self.table_abc).select(self.table_abc.foo).select(self.table_abc.bar) + + self.assertEqual('SELECT "foo","bar" FROM "abc"', str(q1)) + self.assertEqual('SELECT "foo","bar" FROM "abc"', str(q2)) + + def test_select__multiple_tables(self): + q = Query.from_(self.table_abc).select(self.table_abc.foo).from_(self.table_efg).select(self.table_efg.bar) + + self.assertEqual('SELECT "abc"."foo","efg"."bar" FROM "abc","efg"', str(q)) + + def test_select__subquery(self): + subquery = Query.from_(self.table_abc).select("*") + q = Query.from_(subquery).select(subquery.foo, subquery.bar) + + self.assertEqual('SELECT "sq0"."foo","sq0"."bar" ' 'FROM (SELECT * FROM "abc") "sq0"', str(q)) + + def test_select__multiple_subqueries(self): + subquery0 = Query.from_(self.table_abc).select("foo") + subquery1 = Query.from_(self.table_efg).select("bar") + q = Query.from_(subquery0).from_(subquery1).select(subquery0.foo, subquery1.bar) + + self.assertEqual( + 'SELECT "sq0"."foo","sq1"."bar" ' 'FROM (SELECT "foo" FROM "abc") "sq0",' '(SELECT "bar" FROM "efg") "sq1"', + str(q), + ) + + def test_select__nested_subquery(self): + subquery0 = Query.from_(self.table_abc).select("*") + subquery1 = Query.from_(subquery0).select(subquery0.foo, subquery0.bar) + subquery2 = Query.from_(subquery1).select(subquery1.foo) + + q = Query.from_(subquery2).select(subquery2.foo) + + self.assertEqual( + 'SELECT "sq2"."foo" ' + 'FROM (SELECT "sq1"."foo" ' + 'FROM (SELECT "sq0"."foo","sq0"."bar" ' + 'FROM (SELECT * FROM "abc") "sq0") "sq1") "sq2"', + str(q), + ) + + def test_select__no_table(self): + q = Query.select(1, 2, 3) + + self.assertEqual("SELECT 1,2,3", str(q)) + + def test_select_then_add_table(self): + q = Query.select(1).select(2, 3).from_("abc").select("foo") + + self.assertEqual('SELECT 1,2,3,"foo" FROM "abc"', str(q)) + + def test_select_with_limit(self): + q1 = Query.from_("abc").select("foo")[:10] + + self.assertEqual('SELECT "foo" FROM "abc" LIMIT 10', str(q1)) + + def test_select_with_limit_zero(self): + with self.subTest('using python slice'): + q1 = Query.from_("abc").select("foo")[:0] + self.assertEqual('SELECT "foo" FROM "abc" LIMIT 0', str(q1)) + + with self.subTest('using limit method'): + q2 = Query.from_("abc").select("foo").limit(0) + self.assertEqual('SELECT "foo" FROM "abc" LIMIT 0', str(q2)) + + def test_select_with_limit__func(self): + q1 = Query.from_("abc").select("foo").limit(10) + + self.assertEqual('SELECT "foo" FROM "abc" LIMIT 10', str(q1)) + + def test_select_with_offset(self): + q1 = Query.from_("abc").select("foo")[10:] + + self.assertEqual('SELECT "foo" FROM "abc" OFFSET 10', str(q1)) + + def test_select_with_offset__func(self): + q1 = Query.from_("abc").select("foo").offset(10) + + self.assertEqual('SELECT "foo" FROM "abc" OFFSET 10', str(q1)) + + def test_select_with_limit_and_offset(self): + q1 = Query.from_("abc").select("foo")[10:10] + + self.assertEqual('SELECT "foo" FROM "abc" LIMIT 10 OFFSET 10', str(q1)) + + def test_select_with_force_index(self): + q = Query.from_("abc").select("foo").force_index("egg") + + self.assertEqual('SELECT "foo" FROM "abc" FORCE INDEX ("egg")', str(q)) + + def test_select_with_force_index_with_index_object(self): + index = Index("egg") + q = Query.from_("abc").select("foo").force_index(index) + + self.assertEqual('SELECT "foo" FROM "abc" FORCE INDEX ("egg")', str(q)) + + def test_select_with_force_index_multiple_indexes(self): + q = Query.from_("abc").select("foo").force_index("egg", "bacon") + + self.assertEqual('SELECT "foo" FROM "abc" FORCE INDEX ("egg","bacon")', str(q)) + + def test_select_with_force_index_multiple_calls(self): + q = ( + Query.from_("abc") + .select("foo") + .force_index( + "egg", + ) + .force_index("spam") + ) + + self.assertEqual('SELECT "foo" FROM "abc" FORCE INDEX ("egg","spam")', str(q)) + + def test_select_with_use_index(self): + q = Query.from_("abc").select("foo").use_index("egg") + + self.assertEqual('SELECT "foo" FROM "abc" USE INDEX ("egg")', str(q)) + + def test_select_with_use_index_with_index_object(self): + index = Index("egg") + q = Query.from_("abc").select("foo").use_index(index) + + self.assertEqual('SELECT "foo" FROM "abc" USE INDEX ("egg")', str(q)) + + def test_select_with_use_index_multiple_indexes(self): + q = Query.from_("abc").select("foo").use_index("egg", "bacon") + + self.assertEqual('SELECT "foo" FROM "abc" USE INDEX ("egg","bacon")', str(q)) + + def test_select_with_use_index_multiple_calls(self): + q = ( + Query.from_("abc") + .select("foo") + .use_index( + "egg", + ) + .use_index("spam") + ) + + self.assertEqual('SELECT "foo" FROM "abc" USE INDEX ("egg","spam")', str(q)) + + def test_mysql_query_uses_backtick_quote_chars(self): + q = MySQLQuery.from_("abc").select("foo", "bar") + + self.assertEqual("SELECT `foo`,`bar` FROM `abc`", str(q)) + + def test_vertica_query_uses_double_quote_chars(self): + q = VerticaQuery.from_("abc").select("foo", "bar") + + self.assertEqual('SELECT "foo","bar" FROM "abc"', str(q)) + + def test_mssql_query_uses_double_quote_chars(self): + q = MSSQLQuery.from_("abc").select("foo", "bar") + + self.assertEqual('SELECT "foo","bar" FROM "abc"', str(q)) + + def test_oracle_query_uses_no_quote_chars(self): + q = OracleQuery.from_("abc").select("foo", "bar") + + self.assertEqual('SELECT foo,bar FROM abc', str(q)) + + def test_postgresql_query_uses_double_quote_chars(self): + q = PostgreSQLQuery.from_("abc").select("foo", "bar") + + self.assertEqual('SELECT "foo","bar" FROM "abc"', str(q)) + + def test_redshift_query_uses_double_quote_chars(self): + q = RedshiftQuery.from_("abc").select("foo", "bar") + + self.assertEqual('SELECT "foo","bar" FROM "abc"', str(q)) + + def test_table_select_alias(self): + q = self.table_abc.select(1) + + self.assertEqual('SELECT 1 FROM "abc"', str(q)) + self.assertEqual(q, Query.from_("abc").select(1)) + + def test_table_select_alias_with_offset_and_limit(self): + self.assertEqual(self.table_abc.select("foo")[10:10], Query.from_("abc").select("foo")[10:10]) + self.assertEqual( + self.table_abc.select(self.table_abc.foo)[10:10], + Query.from_("abc").select("foo")[10:10], + ) + + def test_temporal_select(self): + t = Table("abc") + + with self.subTest("with system time as of"): + q = Query.from_(t.for_(SYSTEM_TIME.as_of('2020-01-01'))).select("*") + + self.assertEqual('SELECT * FROM "abc" FOR SYSTEM_TIME AS OF \'2020-01-01\'', str(q)) + + with self.subTest("with system time between"): + q = Query.from_(t.for_(SYSTEM_TIME.between('2020-01-01', '2020-02-01'))).select("*") + + self.assertEqual('SELECT * FROM "abc" FOR SYSTEM_TIME BETWEEN \'2020-01-01\' AND \'2020-02-01\'', str(q)) + + with self.subTest("with system time from to"): + q = Query.from_(t.for_(SYSTEM_TIME.from_to('2020-01-01', '2020-02-01'))).select("*") + + self.assertEqual('SELECT * FROM "abc" FOR SYSTEM_TIME FROM \'2020-01-01\' TO \'2020-02-01\'', str(q)) + + with self.subTest("with ALL"): + q = Query.from_(t.for_(SYSTEM_TIME.all_())).select("*") + + self.assertEqual('SELECT * FROM "abc" FOR SYSTEM_TIME ALL', str(q)) + + with self.subTest("with period between"): + q = Query.from_(t.for_(t.valid_period.between('2020-01-01', '2020-02-01'))).select("*") + + self.assertEqual('SELECT * FROM "abc" FOR "valid_period" BETWEEN \'2020-01-01\' AND \'2020-02-01\'', str(q)) + + with self.subTest("with period from to"): + q = Query.from_(t.for_(t.valid_period.from_to('2020-01-01', '2020-02-01'))).select("*") + + self.assertEqual('SELECT * FROM "abc" FOR "valid_period" FROM \'2020-01-01\' TO \'2020-02-01\'', str(q)) + + with self.subTest("with ALL"): + q = Query.from_(t.for_(t.valid_period.all_())).select("*") + + self.assertEqual('SELECT * FROM "abc" FOR "valid_period" ALL', str(q)) + + +class MyEnum(Enum): + STR = "foo" + INT = 0 + BOOL = True + DATE = date(2020, 2, 2) + NONE = None + + +class WhereTests(unittest.TestCase): + t = Table("abc") + t2 = Table("cba") + + def test_where_enum(self): + q1 = Query.from_(self.t).select("*").where(self.t.foo == MyEnum.STR) + q2 = Query.from_(self.t).select("*").where(self.t.foo == MyEnum.INT) + q3 = Query.from_(self.t).select("*").where(self.t.foo == MyEnum.BOOL) + q4 = Query.from_(self.t).select("*").where(self.t.foo == MyEnum.DATE) + q5 = Query.from_(self.t).select("*").where(self.t.foo == MyEnum.NONE) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo"=\'foo\'', str(q1)) + self.assertEqual('SELECT * FROM "abc" WHERE "foo"=0', str(q2)) + self.assertEqual('SELECT * FROM "abc" WHERE "foo"=true', str(q3)) + self.assertEqual('SELECT * FROM "abc" WHERE "foo"=\'2020-02-02\'', str(q4)) + self.assertEqual('SELECT * FROM "abc" WHERE "foo"=null', str(q5)) + + def test_where_field_equals(self): + q1 = Query.from_(self.t).select("*").where(self.t.foo == self.t.bar) + q2 = Query.from_(self.t).select("*").where(self.t.foo.eq(self.t.bar)) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo"="bar"', str(q1)) + self.assertEqual('SELECT * FROM "abc" WHERE "foo"="bar"', str(q2)) + q = self.t.select("*").where(self.t.foo == self.t.bar) + self.assertEqual(q, q1) + + def test_where_field_equals_for_update(self): + q = Query.from_(self.t).select("*").where(self.t.foo == self.t.bar).for_update() + self.assertEqual('SELECT * FROM "abc" WHERE "foo"="bar" FOR UPDATE', str(q)) + + def test_where_field_equals_for_update_nowait(self): + for query_cls in [ + MySQLQuery, + PostgreSQLQuery, + ]: + quote_char = query_cls._builder().QUOTE_CHAR if isinstance(query_cls._builder().QUOTE_CHAR, str) else '"' + q = query_cls.from_(self.t).select("*").where(self.t.foo == self.t.bar).for_update(nowait=True) + self.assertEqual( + 'SELECT * ' + 'FROM {quote_char}abc{quote_char} ' + 'WHERE {quote_char}foo{quote_char}={quote_char}bar{quote_char} ' + 'FOR UPDATE NOWAIT'.format( + quote_char=quote_char, + ), + str(q), + ) + + def test_where_field_equals_for_update_skip_locked(self): + for query_cls in [ + MySQLQuery, + PostgreSQLQuery, + ]: + quote_char = query_cls._builder().QUOTE_CHAR if isinstance(query_cls._builder().QUOTE_CHAR, str) else '"' + q = query_cls.from_(self.t).select("*").where(self.t.foo == self.t.bar).for_update(skip_locked=True) + self.assertEqual( + 'SELECT * ' + 'FROM {quote_char}abc{quote_char} ' + 'WHERE {quote_char}foo{quote_char}={quote_char}bar{quote_char} ' + 'FOR UPDATE SKIP LOCKED'.format( + quote_char=quote_char, + ), + str(q), + ) + + def test_where_field_equals_for_update_of(self): + for query_cls in [ + MySQLQuery, + PostgreSQLQuery, + ]: + quote_char = query_cls._builder().QUOTE_CHAR if isinstance(query_cls._builder().QUOTE_CHAR, str) else '"' + q = query_cls.from_(self.t).select("*").where(self.t.foo == self.t.bar).for_update(of=("abc",)) + self.assertEqual( + 'SELECT * ' + 'FROM {quote_char}abc{quote_char} ' + 'WHERE {quote_char}foo{quote_char}={quote_char}bar{quote_char} ' + 'FOR UPDATE OF {quote_char}abc{quote_char}'.format( + quote_char=quote_char, + ), + str(q), + ) + + def test_where_field_equals_for_update_of_multiple_tables(self): + for query_cls in [ + MySQLQuery, + PostgreSQLQuery, + ]: + q = ( + query_cls.from_(self.t) + .join(self.t2) + .on(self.t.id == self.t2.abc_id) + .select("*") + .where(self.t.foo == self.t.bar) + .for_update(of=("abc", "cba")) + ) + quote_char = query_cls._builder().QUOTE_CHAR if isinstance(query_cls._builder().QUOTE_CHAR, str) else '"' + self.assertIn( + str(q), + [ + 'SELECT * ' + 'FROM {quote_char}abc{quote_char} ' + 'JOIN {quote_char}cba{quote_char} ' + 'ON {quote_char}abc{quote_char}.{quote_char}id{quote_char}=' + '{quote_char}cba{quote_char}.{quote_char}abc_id{quote_char} ' + 'WHERE {quote_char}abc{quote_char}.{quote_char}foo{quote_char}=' + '{quote_char}abc{quote_char}.{quote_char}bar{quote_char} ' + 'FOR UPDATE OF {quote_char}cba{quote_char}, {quote_char}abc{quote_char}'.format( + quote_char=quote_char, + ), + 'SELECT * ' + 'FROM {quote_char}abc{quote_char} ' + 'JOIN {quote_char}cba{quote_char} ' + 'ON {quote_char}abc{quote_char}.{quote_char}id{quote_char}=' + '{quote_char}cba{quote_char}.{quote_char}abc_id{quote_char} ' + 'WHERE {quote_char}abc{quote_char}.{quote_char}foo{quote_char}=' + '{quote_char}abc{quote_char}.{quote_char}bar{quote_char} ' + 'FOR UPDATE OF {quote_char}abc{quote_char}, {quote_char}cba{quote_char}'.format( + quote_char=quote_char, + ), + ], + ) + + def test_where_field_equals_for_update_of_nowait(self): + for query_cls in [ + MySQLQuery, + PostgreSQLQuery, + ]: + q = query_cls.from_(self.t).select("*").where(self.t.foo == self.t.bar).for_update(of=("abc",), nowait=True) + quote_char = query_cls._builder().QUOTE_CHAR if isinstance(query_cls._builder().QUOTE_CHAR, str) else '"' + self.assertEqual( + 'SELECT * ' + 'FROM {quote_char}abc{quote_char} ' + 'WHERE {quote_char}foo{quote_char}={quote_char}bar{quote_char} ' + 'FOR UPDATE OF {quote_char}abc{quote_char} NOWAIT'.format( + quote_char=quote_char, + ), + str(q), + ) + + def test_where_field_equals_for_update_of_skip_locked(self): + for query_cls in [ + MySQLQuery, + PostgreSQLQuery, + ]: + q = ( + query_cls.from_(self.t) + .select("*") + .where(self.t.foo == self.t.bar) + .for_update(of=("abc",), skip_locked=True) + ) + quote_char = query_cls._builder().QUOTE_CHAR if isinstance(query_cls._builder().QUOTE_CHAR, str) else '"' + self.assertEqual( + 'SELECT * ' + 'FROM {quote_char}abc{quote_char} ' + 'WHERE {quote_char}foo{quote_char}={quote_char}bar{quote_char} ' + 'FOR UPDATE OF {quote_char}abc{quote_char} SKIP LOCKED'.format( + quote_char=quote_char, + ), + str(q), + ) + + def test_where_field_equals_for_update_skip_locked_and_of(self): + for query_cls in [ + MySQLQuery, + PostgreSQLQuery, + ]: + q = ( + query_cls.from_(self.t) + .select("*") + .where(self.t.foo == self.t.bar) + .for_update(nowait=False, skip_locked=True, of=("abc",)) + ) + quote_char = query_cls._builder().QUOTE_CHAR if isinstance(query_cls._builder().QUOTE_CHAR, str) else '"' + self.assertEqual( + 'SELECT * ' + 'FROM {quote_char}abc{quote_char} ' + 'WHERE {quote_char}foo{quote_char}={quote_char}bar{quote_char} ' + 'FOR UPDATE OF {quote_char}abc{quote_char} SKIP LOCKED'.format( + quote_char=quote_char, + ), + str(q), + ) + + def test_where_field_equals_where(self): + q = Query.from_(self.t).select("*").where(self.t.foo == 1).where(self.t.bar == self.t.baz) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo"=1 AND "bar"="baz"', str(q)) + + def test_where_field_equals_where_not(self): + q = Query.from_(self.t).select("*").where((self.t.foo == 1).negate()).where(self.t.bar == self.t.baz) + + self.assertEqual('SELECT * FROM "abc" WHERE NOT "foo"=1 AND "bar"="baz"', str(q)) + + def test_where_field_equals_where_two_not(self): + q = Query.from_(self.t).select("*").where((self.t.foo == 1).negate()).where((self.t.bar == self.t.baz).negate()) + + self.assertEqual('SELECT * FROM "abc" WHERE NOT "foo"=1 AND NOT "bar"="baz"', str(q)) + + def test_where_single_quote(self): + q1 = Query.from_(self.t).select("*").where(self.t.foo == "bar'foo") + + self.assertEqual("SELECT * FROM \"abc\" WHERE \"foo\"='bar''foo'", str(q1)) + + def test_where_field_equals_and(self): + q = Query.from_(self.t).select("*").where((self.t.foo == 1) & (self.t.bar == self.t.baz)) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo"=1 AND "bar"="baz"', str(q)) + + def test_where_field_equals_or(self): + q = Query.from_(self.t).select("*").where((self.t.foo == 1) | (self.t.bar == self.t.baz)) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo"=1 OR "bar"="baz"', str(q)) + + def test_where_nested_conditions(self): + q = Query.from_(self.t).select("*").where((self.t.foo == 1) | (self.t.bar == self.t.baz)).where(self.t.baz == 0) + + self.assertEqual('SELECT * FROM "abc" WHERE ("foo"=1 OR "bar"="baz") AND "baz"=0', str(q)) + + def test_where_field_starts_with(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.like("ab%")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" LIKE \'ab%\'', str(q)) + + def test_where_field_contains(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.like("%fg%")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" LIKE \'%fg%\'', str(q)) + + def test_where_field_ends_with(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.like("%yz")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" LIKE \'%yz\'', str(q)) + + def test_where_field_is_n_chars_long(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.like("___")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" LIKE \'___\'', str(q)) + + def test_where_field_does_not_start_with(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.not_like("ab%")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" NOT LIKE \'ab%\'', str(q)) + + def test_where_field_does_not_contain(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.not_like("%fg%")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" NOT LIKE \'%fg%\'', str(q)) + + def test_where_field_does_not_end_with(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.not_like("%yz")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" NOT LIKE \'%yz\'', str(q)) + + def test_where_field_is_not_n_chars_long(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.not_like("___")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" NOT LIKE \'___\'', str(q)) + + def test_where_field_matches_regex(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.regex(r"^b")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" REGEX \'^b\'', str(q)) + + def test_where_field_matches_regexp(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.regexp(r"^b")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" REGEXP \'^b\'', str(q)) + + def test_where_field_matches_rlike(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.rlike(r"^b")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" RLIKE \'^b\'', str(q)) + + def test_ignore_empty_criterion_where(self): + q1 = Query.from_(self.t).select("*").where(EmptyCriterion()) + + self.assertEqual('SELECT * FROM "abc"', str(q1)) + + def test_ignore_empty_criterion_having(self): + q1 = Query.from_(self.t).select("*").having(EmptyCriterion()) + + self.assertEqual('SELECT * FROM "abc"', str(q1)) + + def test_select_with_force_index_and_where(self): + q = Query.from_("abc").select("foo").where(self.t.foo == self.t.bar).force_index("egg") + + self.assertEqual('SELECT "foo" FROM "abc" FORCE INDEX ("egg") WHERE "foo"="bar"', str(q)) + + def test_where_with_multiple_wheres_using_and_case(self): + case_stmt = Case().when(self.t.foo == 'bar', 1).else_(0) + query = Query.from_(self.t).select(case_stmt).where(case_stmt & self.t.blah.isin(['test'])) + + self.assertEqual( + 'SELECT CASE WHEN "foo"=\'bar\' THEN 1 ELSE 0 END FROM "abc" WHERE CASE WHEN "foo"=\'bar\' THEN 1 ELSE 0 ' + 'END AND "blah" IN (\'test\')', + str(query), + ) + + def test_where_with_multiple_wheres_using_or_case(self): + case_stmt = Case().when(self.t.foo == 'bar', 1).else_(0) + query = Query.from_(self.t).select(case_stmt).where(case_stmt | self.t.blah.isin(['test'])) + + self.assertEqual( + 'SELECT CASE WHEN "foo"=\'bar\' THEN 1 ELSE 0 END FROM "abc" WHERE CASE WHEN "foo"=\'bar\' THEN 1 ELSE 0 ' + 'END OR "blah" IN (\'test\')', + str(query), + ) + + +class PreWhereTests(WhereTests): + t = Table("abc") + + def test_prewhere_field_equals(self): + q1 = Query.from_(self.t).select("*").prewhere(self.t.foo == self.t.bar) + q2 = Query.from_(self.t).select("*").prewhere(self.t.foo.eq(self.t.bar)) + + self.assertEqual('SELECT * FROM "abc" PREWHERE "foo"="bar"', str(q1)) + self.assertEqual('SELECT * FROM "abc" PREWHERE "foo"="bar"', str(q2)) + + def test_where_and_prewhere(self): + q = Query.from_(self.t).select("*").prewhere(self.t.foo == self.t.bar).where(self.t.foo == self.t.bar) + + self.assertEqual('SELECT * FROM "abc" PREWHERE "foo"="bar" WHERE "foo"="bar"', str(q)) + + +class GroupByTests(unittest.TestCase): + t = Table("abc") + maxDiff = None + + def test_groupby__single(self): + q = Query.from_(self.t).groupby(self.t.foo).select(self.t.foo) + + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo"', str(q)) + + def test_groupby__multi(self): + q = Query.from_(self.t).groupby(self.t.foo, self.t.bar).select(self.t.foo, self.t.bar) + + self.assertEqual('SELECT "foo","bar" FROM "abc" GROUP BY "foo","bar"', str(q)) + + def test_groupby__count_star(self): + q = Query.from_(self.t).groupby(self.t.foo).select(self.t.foo, fn.Count("*")) + + self.assertEqual('SELECT "foo",COUNT(*) FROM "abc" GROUP BY "foo"', str(q)) + + def test_groupby__count_field(self): + q = Query.from_(self.t).groupby(self.t.foo).select(self.t.foo, fn.Count(self.t.bar)) + + self.assertEqual('SELECT "foo",COUNT("bar") FROM "abc" GROUP BY "foo"', str(q)) + + def test_groupby__count_distinct(self): + q = Query.from_(self.t).groupby(self.t.foo).select(self.t.foo, fn.Count("*").distinct()) + + self.assertEqual('SELECT "foo",COUNT(DISTINCT *) FROM "abc" GROUP BY "foo"', str(q)) + + def test_groupby__sum_distinct(self): + q = Query.from_(self.t).groupby(self.t.foo).select(self.t.foo, fn.Sum(self.t.bar).distinct()) + + self.assertEqual('SELECT "foo",SUM(DISTINCT "bar") FROM "abc" GROUP BY "foo"', str(q)) + + def test_groupby__sum_filter(self): + q = ( + Query.from_(self.t) + .groupby(self.t.foo) + .select(self.t.foo, fn.Sum(self.t.bar).filter(self.t.id.eq(1) & self.t.cid.gt(2))) + ) + + self.assertEqual('SELECT "foo",SUM("bar") FILTER(WHERE "id"=1 AND "cid">2) FROM "abc" GROUP BY "foo"', str(q)) + + def test_groupby__str(self): + q = Query.from_("abc").groupby("foo").select("foo", fn.Count("*").distinct()) + + self.assertEqual('SELECT "foo",COUNT(DISTINCT *) FROM "abc" GROUP BY "foo"', str(q)) + + def test_groupby__int(self): + q = Query.from_("abc").groupby(1).select("foo", fn.Count("*").distinct()) + + self.assertEqual('SELECT "foo",COUNT(DISTINCT *) FROM "abc" GROUP BY 1', str(q)) + + def test_groupby__alias(self): + bar = self.t.bar.as_("bar01") + q = Query.from_(self.t).select(fn.Sum(self.t.foo), bar).groupby(bar) + + self.assertEqual('SELECT SUM("foo"),"bar" "bar01" FROM "abc" GROUP BY "bar01"', str(q)) + + def test_groupby__no_alias(self): + bar = self.t.bar.as_("bar01") + q = Query.from_(self.t).select(fn.Sum(self.t.foo), bar).groupby(bar) + + self.assertEqual( + 'SELECT SUM("foo"),"bar" "bar01" FROM "abc" GROUP BY "bar"', + q.get_sql(groupby_alias=False), + ) + + def test_groupby__no_alias_mssql(self): + bar = self.t.bar.as_("bar01") + q = MSSQLQuery.from_(self.t).select(fn.Sum(self.t.foo), bar).groupby(bar) + + self.assertEqual('SELECT SUM("foo"),"bar" "bar01" FROM "abc" GROUP BY "bar"', str(q)) + + def test_groupby__no_alias_oracle(self): + bar = self.t.bar.as_("bar01") + q = OracleQuery.from_(self.t).select(fn.Sum(self.t.foo), bar).groupby(bar) + + self.assertEqual('SELECT SUM(foo),bar bar01 FROM abc GROUP BY bar', str(q)) + + def test_groupby__alias_platforms(self): + bar = self.t.bar.as_("bar01") + + for query_cls in [ + MySQLQuery, + VerticaQuery, + PostgreSQLQuery, + RedshiftQuery, + ClickHouseQuery, + SQLLiteQuery, + ]: + q = query_cls.from_(self.t).select(fn.Sum(self.t.foo), bar).groupby(bar) + + quote_char = query_cls._builder().QUOTE_CHAR if isinstance(query_cls._builder().QUOTE_CHAR, str) else '"' + + self.assertEqual( + "SELECT " + "SUM({quote_char}foo{quote_char})," + "{quote_char}bar{quote_char}{as_keyword}{quote_char}bar01{quote_char} " + "FROM {quote_char}abc{quote_char} " + "GROUP BY {quote_char}bar01{quote_char}".format( + as_keyword=' AS ' if query_cls is ClickHouseQuery else ' ', quote_char=quote_char + ), + str(q), + ) + + def test_groupby__alias_with_join(self): + table1 = Table("table1", alias="t1") + bar = table1.bar.as_("bar01") + q = Query.from_(self.t).join(table1).on(self.t.id == table1.t_ref).select(fn.Sum(self.t.foo), bar).groupby(bar) + + self.assertEqual( + 'SELECT SUM("abc"."foo"),"t1"."bar" "bar01" FROM "abc" ' + 'JOIN "table1" "t1" ON "abc"."id"="t1"."t_ref" ' + 'GROUP BY "bar01"', + str(q), + ) + + def test_groupby_with_case_uses_the_alias(self): + q = ( + Query.from_(self.t) + .select( + fn.Sum(self.t.foo).as_("bar"), + Case().when(self.t.fname == "Tom", "It was Tom").else_("It was someone else.").as_("who_was_it"), + ) + .groupby(Case().when(self.t.fname == "Tom", "It was Tom").else_("It was someone else.").as_("who_was_it")) + ) + + self.assertEqual( + 'SELECT SUM("foo") "bar",' + "CASE WHEN \"fname\"='Tom' THEN 'It was Tom' " + "ELSE 'It was someone else.' END \"who_was_it\" " + 'FROM "abc" ' + 'GROUP BY "who_was_it"', + str(q), + ) + + def test_mysql_query_uses_backtick_quote_chars(self): + q = MySQLQuery.from_(self.t).groupby(self.t.foo).select(self.t.foo) + + self.assertEqual("SELECT `foo` FROM `abc` GROUP BY `foo`", str(q)) + + def test_vertica_query_uses_double_quote_chars(self): + q = VerticaQuery.from_(self.t).groupby(self.t.foo).select(self.t.foo) + + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo"', str(q)) + + def test_mssql_query_uses_double_quote_chars(self): + q = MSSQLQuery.from_(self.t).groupby(self.t.foo).select(self.t.foo) + + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo"', str(q)) + + def test_oracle_query_uses_no_quote_chars(self): + q = OracleQuery.from_(self.t).groupby(self.t.foo).select(self.t.foo) + + self.assertEqual('SELECT foo FROM abc GROUP BY foo', str(q)) + + def test_postgres_query_uses_double_quote_chars(self): + q = PostgreSQLQuery.from_(self.t).groupby(self.t.foo).select(self.t.foo) + + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo"', str(q)) + + def test_redshift_query_uses_double_quote_chars(self): + q = RedshiftQuery.from_(self.t).groupby(self.t.foo).select(self.t.foo) + + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo"', str(q)) + + def test_group_by__single_with_totals(self): + q = Query.from_(self.t).groupby(self.t.foo).select(self.t.foo).with_totals() + + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo" WITH TOTALS', str(q)) + + def test_groupby__multi_with_totals(self): + q = Query.from_(self.t).groupby(self.t.foo, self.t.bar).select(self.t.foo, self.t.bar).with_totals() + + self.assertEqual('SELECT "foo","bar" FROM "abc" GROUP BY "foo","bar" WITH TOTALS', str(q)) + + +class HavingTests(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_having_greater_than(self): + q = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, fn.Sum(self.table_abc.bar)) + .groupby(self.table_abc.foo) + .having(fn.Sum(self.table_abc.bar) > 1) + ) + + self.assertEqual( + 'SELECT "foo",SUM("bar") FROM "abc" GROUP BY "foo" HAVING SUM("bar")>1', + str(q), + ) + + def test_having_and(self): + q = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, fn.Sum(self.table_abc.bar)) + .groupby(self.table_abc.foo) + .having((fn.Sum(self.table_abc.bar) > 1) & (fn.Sum(self.table_abc.bar) < 100)) + ) + + self.assertEqual( + 'SELECT "foo",SUM("bar") FROM "abc" GROUP BY "foo" HAVING SUM("bar")>1 AND SUM("bar")<100', + str(q), + ) + + def test_having_join_and_equality(self): + q = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.foo) + .select(self.table_abc.foo, fn.Sum(self.table_efg.bar), self.table_abc.buz) + .groupby(self.table_abc.foo) + .having(self.table_abc.buz == "fiz") + .having(fn.Sum(self.table_efg.bar) > 100) + ) + + self.assertEqual( + 'SELECT "abc"."foo",SUM("efg"."bar"),"abc"."buz" FROM "abc" ' + 'JOIN "efg" ON "abc"."foo"="efg"."foo" ' + 'GROUP BY "abc"."foo" ' + 'HAVING "abc"."buz"=\'fiz\' AND SUM("efg"."bar")>100', + str(q), + ) + + def test_mysql_query_uses_backtick_quote_chars(self): + q = ( + MySQLQuery.from_(self.table_abc) + .select(self.table_abc.foo) + .groupby(self.table_abc.foo) + .having(self.table_abc.buz == "fiz") + ) + self.assertEqual("SELECT `foo` FROM `abc` GROUP BY `foo` HAVING `buz`='fiz'", str(q)) + + def test_vertica_query_uses_double_quote_chars(self): + q = ( + VerticaQuery.from_(self.table_abc) + .select(self.table_abc.foo) + .groupby(self.table_abc.foo) + .having(self.table_abc.buz == "fiz") + ) + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo" HAVING "buz"=\'fiz\'', str(q)) + + def test_mssql_query_uses_double_quote_chars(self): + q = ( + MSSQLQuery.from_(self.table_abc) + .select(self.table_abc.foo) + .groupby(self.table_abc.foo) + .having(self.table_abc.buz == "fiz") + ) + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo" HAVING "buz"=\'fiz\'', str(q)) + + def test_oracle_query_uses_no_quote_chars(self): + q = ( + OracleQuery.from_(self.table_abc) + .select(self.table_abc.foo) + .groupby(self.table_abc.foo) + .having(self.table_abc.buz == "fiz") + ) + self.assertEqual('SELECT foo FROM abc GROUP BY foo HAVING buz=\'fiz\'', str(q)) + + def test_postgres_query_uses_double_quote_chars(self): + q = ( + PostgreSQLQuery.from_(self.table_abc) + .select(self.table_abc.foo) + .groupby(self.table_abc.foo) + .having(self.table_abc.buz == "fiz") + ) + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo" HAVING "buz"=\'fiz\'', str(q)) + + def test_redshift_query_uses_double_quote_chars(self): + q = ( + RedshiftQuery.from_(self.table_abc) + .select(self.table_abc.foo) + .groupby(self.table_abc.foo) + .having(self.table_abc.buz == "fiz") + ) + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo" HAVING "buz"=\'fiz\'', str(q)) + + +class OrderByTests(unittest.TestCase): + t = Table("abc") + + def test_orderby_single_field(self): + q = Query.from_(self.t).orderby(self.t.foo).select(self.t.foo) + + self.assertEqual('SELECT "foo" FROM "abc" ORDER BY "foo"', str(q)) + + def test_orderby_multi_fields(self): + q = Query.from_(self.t).orderby(self.t.foo, self.t.bar).select(self.t.foo, self.t.bar) + + self.assertEqual('SELECT "foo","bar" FROM "abc" ORDER BY "foo","bar"', str(q)) + + def test_orderby_single_str(self): + q = Query.from_("abc").orderby("foo").select("foo") + + self.assertEqual('SELECT "foo" FROM "abc" ORDER BY "foo"', str(q)) + + def test_orderby_asc(self): + q = Query.from_(self.t).orderby(self.t.foo, order=Order.asc).select(self.t.foo) + + self.assertEqual('SELECT "foo" FROM "abc" ORDER BY "foo" ASC', str(q)) + + def test_orderby_desc(self): + q = Query.from_(self.t).orderby(self.t.foo, order=Order.desc).select(self.t.foo) + + self.assertEqual('SELECT "foo" FROM "abc" ORDER BY "foo" DESC', str(q)) + + def test_orderby_no_alias(self): + bar = self.t.bar.as_("bar01") + q = Query.from_(self.t).select(fn.Sum(self.t.foo), bar).orderby(bar) + + self.assertEqual( + 'SELECT SUM("foo"),"bar" "bar01" FROM "abc" ORDER BY "bar"', + q.get_sql(orderby_alias=False), + ) + + def test_orderby_alias(self): + bar = self.t.bar.as_("bar01") + q = Query.from_(self.t).select(fn.Sum(self.t.foo), bar).orderby(bar) + + self.assertEqual('SELECT SUM("foo"),"bar" "bar01" FROM "abc" ORDER BY "bar01"', q.get_sql()) + + +class AliasTests(unittest.TestCase): + t = Table("abc") + + def test_table_field(self): + q = Query.from_(self.t).select(self.t.foo.as_("bar")) + + self.assertEqual('SELECT "foo" "bar" FROM "abc"', str(q)) + + def test_table_field__multi(self): + q = Query.from_(self.t).select(self.t.foo.as_("bar"), self.t.fiz.as_("buz")) + + self.assertEqual('SELECT "foo" "bar","fiz" "buz" FROM "abc"', str(q)) + + def test_arithmetic_function(self): + q = Query.from_(self.t).select((self.t.foo + self.t.bar).as_("biz")) + + self.assertEqual('SELECT "foo"+"bar" "biz" FROM "abc"', str(q)) + + def test_functions_using_as(self): + q = Query.from_(self.t).select(fn.Count("*").as_("foo")) + + self.assertEqual('SELECT COUNT(*) "foo" FROM "abc"', str(q)) + + def test_functions_using_constructor_param(self): + q = Query.from_(self.t).select(fn.Count("*", alias="foo")) + + self.assertEqual('SELECT COUNT(*) "foo" FROM "abc"', str(q)) + + def test_function_using_as_nested(self): + """ + We don't show aliases of fields that are arguments of a function. + """ + q = Query.from_(self.t).select(fn.Sqrt(fn.Count("*").as_("foo")).as_("bar")) + + self.assertEqual('SELECT SQRT(COUNT(*)) "bar" FROM "abc"', str(q)) + + def test_functions_using_constructor_param_nested(self): + """ + We don't show aliases of fields that are arguments of a function. + """ + q = Query.from_(self.t).select(fn.Sqrt(fn.Count("*", alias="foo"), alias="bar")) + + self.assertEqual('SELECT SQRT(COUNT(*)) "bar" FROM "abc"', str(q)) + + def test_ignored_in_where(self): + q = Query.from_(self.t).select(self.t.foo).where(self.t.foo.as_("bar") == 1) + + self.assertEqual('SELECT "foo" FROM "abc" WHERE "foo"=1', str(q)) + + def test_ignored_in_groupby(self): + q = Query.from_(self.t).select(self.t.foo).groupby(self.t.foo.as_("bar")) + + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo"', str(q)) + + def test_ignored_in_orderby(self): + q = Query.from_(self.t).select(self.t.foo).orderby(self.t.foo.as_("bar")) + + self.assertEqual('SELECT "foo" FROM "abc" ORDER BY "foo"', str(q)) + + def test_ignored_in_criterion(self): + c = self.t.foo.as_("bar") == 1 + + self.assertEqual('"foo"=1', str(c)) + + def test_ignored_in_criterion_comparison(self): + c = self.t.foo.as_("bar") == self.t.fiz.as_("buz") + + self.assertEqual('"foo"="fiz"', str(c)) + + def test_ignored_in_field_inside_case(self): + q = Query.from_(self.t).select(Case().when(self.t.foo == 1, "a").else_(self.t.bar.as_('"buz"'))) + + self.assertEqual('SELECT CASE WHEN "foo"=1 THEN \'a\' ELSE "bar" END FROM "abc"', str(q)) + + def test_case_using_as(self): + q = Query.from_(self.t).select(Case().when(self.t.foo == 1, "a").else_("b").as_("bar")) + + self.assertEqual( + 'SELECT CASE WHEN "foo"=1 THEN \'a\' ELSE \'b\' END "bar" FROM "abc"', + str(q), + ) + + def test_case_using_constructor_param(self): + q = Query.from_(self.t).select(Case(alias="bar").when(self.t.foo == 1, "a").else_("b")) + + self.assertEqual( + 'SELECT CASE WHEN "foo"=1 THEN \'a\' ELSE \'b\' END "bar" FROM "abc"', + str(q), + ) + + def test_select__multiple_tables(self): + table_abc, table_efg = Table("abc", alias="q0"), Table("efg", alias="q1") + + q = Query.from_(table_abc).select(table_abc.foo).from_(table_efg).select(table_efg.bar) + + self.assertEqual('SELECT "q0"."foo","q1"."bar" FROM "abc" "q0","efg" "q1"', str(q)) + + def test_use_aliases_in_groupby_and_orderby(self): + table_abc = Table("abc", alias="q0") + + my_foo = table_abc.foo.as_("my_foo") + q = Query.from_(table_abc).select(my_foo, table_abc.bar).groupby(my_foo).orderby(my_foo) + + self.assertEqual( + 'SELECT "q0"."foo" "my_foo","q0"."bar" ' 'FROM "abc" "q0" ' 'GROUP BY "my_foo" ' 'ORDER BY "my_foo"', + str(q), + ) + + def test_table_with_schema_and_alias(self): + table = Table("abc", schema="schema", alias="alias") + self.assertEqual('"schema"."abc" "alias"', str(table)) + + def test_null_value_with_alias(self): + q = Query.select(NullValue().as_("abcdef")) + + self.assertEqual('SELECT NULL "abcdef"', str(q)) + + +class SubqueryTests(unittest.TestCase): + maxDiff = None + + table_abc, table_efg, table_hij = Tables("abc", "efg", "hij") + + def test_where__in(self): + q = ( + Query.from_(self.table_abc) + .select("*") + .where( + self.table_abc.foo.isin( + Query.from_(self.table_efg).select(self.table_efg.foo).where(self.table_efg.bar == 0) + ) + ) + ) + + self.assertEqual( + 'SELECT * FROM "abc" WHERE "foo" IN (SELECT "foo" FROM "efg" WHERE "bar"=0)', + str(q), + ) + + def test_where__in_nested(self): + q = Query.from_(self.table_abc).select("*").where(self.table_abc.foo).isin(self.table_efg.select("*")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" IN (SELECT * FROM "efg")', str(q)) + + def test_join(self): + subquery = Query.from_("efg").select("fiz", "buz").where(F("buz") == 0) + + q = ( + Query.from_(self.table_abc) + .join(subquery) + .on(self.table_abc.bar == subquery.buz) + .select(self.table_abc.foo, subquery.fiz) + ) + + self.assertEqual( + 'SELECT "abc"."foo","sq0"."fiz" FROM "abc" ' + 'JOIN (SELECT "fiz","buz" FROM "efg" WHERE "buz"=0) "sq0" ' + 'ON "abc"."bar"="sq0"."buz"', + str(q), + ) + + def test_select_subquery(self): + subq = Query.from_(self.table_efg).select("fizzbuzz").where(self.table_efg.id == 1) + + q = Query.from_(self.table_abc).select("foo", "bar").select(subq) + + self.assertEqual( + 'SELECT "foo","bar",(SELECT "fizzbuzz" FROM "efg" WHERE "id"=1) ' 'FROM "abc"', + str(q), + ) + + def test_select_subquery_with_alias(self): + subq = Query.from_(self.table_efg).select("fizzbuzz").where(self.table_efg.id == 1) + + q = Query.from_(self.table_abc).select("foo", "bar").select(subq.as_("sq")) + + self.assertEqual( + 'SELECT "foo","bar",(SELECT "fizzbuzz" FROM "efg" WHERE "id"=1) "sq" ' 'FROM "abc"', + str(q), + ) + + def test_where__equality(self): + subquery = Query.from_("efg").select("fiz").where(F("buz") == 0) + query = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, self.table_abc.bar) + .where(self.table_abc.bar == subquery) + ) + + self.assertEqual( + 'SELECT "foo","bar" FROM "abc" ' 'WHERE "bar"=(SELECT "fiz" FROM "efg" WHERE "buz"=0)', + str(query), + ) + + def test_select_from_nested_query(self): + subquery = Query.from_(self.table_abc).select( + self.table_abc.foo, + self.table_abc.bar, + (self.table_abc.fizz + self.table_abc.buzz).as_("fizzbuzz"), + ) + + query = Query.from_(subquery).select(subquery.foo, subquery.bar, subquery.fizzbuzz) + + self.assertEqual( + 'SELECT "sq0"."foo","sq0"."bar","sq0"."fizzbuzz" ' + "FROM (" + 'SELECT "foo","bar","fizz"+"buzz" "fizzbuzz" ' + 'FROM "abc"' + ') "sq0"', + str(query), + ) + + def test_select_from_nested_query_with_join(self): + subquery1 = ( + Query.from_(self.table_abc) + .select( + self.table_abc.foo, + fn.Sum(self.table_abc.fizz + self.table_abc.buzz).as_("fizzbuzz"), + ) + .groupby(self.table_abc.foo) + ) + + subquery2 = Query.from_(self.table_efg).select( + self.table_efg.foo.as_("foo_two"), + self.table_efg.bar, + ) + + query = ( + Query.from_(subquery1) + .select(subquery1.foo, subquery1.fizzbuzz) + .join(subquery2) + .on(subquery1.foo == subquery2.foo_two) + .select(subquery2.foo_two, subquery2.bar) + ) + + self.assertEqual( + "SELECT " + '"sq0"."foo","sq0"."fizzbuzz",' + '"sq1"."foo_two","sq1"."bar" ' + "FROM (" + "SELECT " + '"foo",SUM("fizz"+"buzz") "fizzbuzz" ' + 'FROM "abc" ' + 'GROUP BY "foo"' + ') "sq0" JOIN (' + "SELECT " + '"foo" "foo_two","bar" ' + 'FROM "efg"' + ') "sq1" ON "sq0"."foo"="sq1"."foo_two"', + str(query), + ) + + def test_from_subquery_without_alias(self): + subquery = Query.from_(self.table_efg).select( + self.table_efg.base_id.as_("x"), self.table_efg.fizz, self.table_efg.buzz + ) + + test_query = Query.from_(subquery).select(subquery.x, subquery.fizz, subquery.buzz) + + self.assertEqual( + 'SELECT "sq0"."x","sq0"."fizz","sq0"."buzz" ' + "FROM (" + 'SELECT "base_id" "x","fizz","buzz" FROM "efg"' + ') "sq0"', + str(test_query), + ) + + def test_join_query_with_alias(self): + subquery = ( + Query.from_(self.table_efg) + .select( + self.table_efg.base_id.as_("x"), + self.table_efg.fizz, + self.table_efg.buzz, + ) + .as_("subq") + ) + + test_query = Query.from_(subquery).select(subquery.x, subquery.fizz, subquery.buzz) + + self.assertEqual( + 'SELECT "subq"."x","subq"."fizz","subq"."buzz" ' + "FROM (" + 'SELECT "base_id" "x","fizz","buzz" FROM "efg"' + ') "subq"', + str(test_query), + ) + + def test_with(self): + sub_query = Query.from_(self.table_efg).select("fizz") + test_query = Query.with_(sub_query, "an_alias").from_(AliasedQuery("an_alias")).select("*") + + self.assertEqual( + 'WITH an_alias AS (SELECT "fizz" FROM "efg") SELECT * FROM an_alias', + str(test_query), + ) + + def test_join_with_with(self): + sub_query = Query.from_(self.table_efg).select("fizz") + test_query = ( + Query.with_(sub_query, "an_alias") + .from_(self.table_abc) + .join(AliasedQuery("an_alias")) + .on(AliasedQuery("an_alias").fizz == self.table_abc.buzz) + .select("*") + ) + self.assertEqual( + 'WITH an_alias AS (SELECT "fizz" FROM "efg") ' + 'SELECT * FROM "abc" JOIN an_alias ON "an_alias"."fizz"="abc"."buzz"', + str(test_query), + ) + + def test_select_from_with_returning(self): + sub_query = PostgreSQLQuery.into(self.table_abc).insert(1).returning('*') + test_query = Query.with_(sub_query, "an_alias").from_(AliasedQuery("an_alias")).select("*") + self.assertEqual( + 'WITH an_alias AS (INSERT INTO "abc" VALUES (1) RETURNING *) SELECT * FROM an_alias', str(test_query) + ) + + +class QuoteTests(unittest.TestCase): + def test_extraneous_quotes(self): + t1 = Table("table1", alias="t1") + t2 = Table("table2", alias="t2") + + query = Query.from_(t1).join(t2).on(t1.Value.between(t2.start, t2.end)).select(t1.value) + + self.assertEqual( + "SELECT t1.value FROM table1 t1 " "JOIN table2 t2 ON t1.Value " "BETWEEN t2.start AND t2.end", + query.get_sql(quote_char=None), + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/test_tables.py b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/test_tables.py new file mode 100644 index 0000000000000000000000000000000000000000..f43e740915f642d29ce7497c36e3b68f01311016 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/test_tables.py @@ -0,0 +1,186 @@ +# from pypika.terms import ValueWrapper, SystemTimeValue +import unittest + +from pypika import Database, Dialects, Schema, SQLLiteQuery, Table, Tables, Query, SYSTEM_TIME + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + + +class TableStructureTests(unittest.TestCase): + def test_table_sql(self): + table = Table("test_table") + + self.assertEqual('"test_table"', str(table)) + + def test_table_with_alias(self): + table = Table("test_table").as_("my_table") + + self.assertEqual('"test_table" "my_table"', table.get_sql(with_alias=True, quote_char='"')) + + def test_schema_table_attr(self): + table = Schema("x_schema").test_table + + self.assertEqual('"x_schema"."test_table"', str(table)) + + def test_table_with_schema_arg(self): + table = Table("test_table", schema=Schema("x_schema")) + + self.assertEqual('"x_schema"."test_table"', str(table)) + + def test_database_schema_table_attr(self): + table = Database("x_db").x_schema.test_table + + self.assertEqual('"x_db"."x_schema"."test_table"', str(table)) + + def test_table_with_schema_and_schema_parent_arg(self): + table = Table("test_table", schema=Schema("x_schema", parent=Database("x_db"))) + + self.assertEqual('"x_db"."x_schema"."test_table"', str(table)) + + def test_table_for_system_time_sql(self): + with self.subTest("with between criterion"): + table = Table("test_table").for_(SYSTEM_TIME.between('2020-01-01', '2020-02-01')) + + self.assertEqual('"test_table" FOR SYSTEM_TIME BETWEEN \'2020-01-01\' AND \'2020-02-01\'', str(table)) + + with self.subTest("with as of criterion"): + table = Table("test_table").for_(SYSTEM_TIME.as_of('2020-01-01')) + + self.assertEqual('"test_table" FOR SYSTEM_TIME AS OF \'2020-01-01\'', str(table)) + + with self.subTest("with from to criterion"): + table = Table("test_table").for_(SYSTEM_TIME.from_to('2020-01-01', '2020-02-01')) + + self.assertEqual('"test_table" FOR SYSTEM_TIME FROM \'2020-01-01\' TO \'2020-02-01\'', str(table)) + + def test_table_for_period_sql(self): + with self.subTest("with between criterion"): + table = Table("test_table") + table = table.for_(table.valid_period.between('2020-01-01', '2020-02-01')) + + self.assertEqual('"test_table" FOR "valid_period" BETWEEN \'2020-01-01\' AND \'2020-02-01\'', str(table)) + + with self.subTest("with as of criterion"): + table = Table("test_table") + table = table.for_(table.valid_period.as_of('2020-01-01')) + + self.assertEqual('"test_table" FOR "valid_period" AS OF \'2020-01-01\'', str(table)) + + with self.subTest("with from to criterion"): + table = Table("test_table") + table = table.for_(table.valid_period.from_to('2020-01-01', '2020-02-01')) + + self.assertEqual('"test_table" FOR "valid_period" FROM \'2020-01-01\' TO \'2020-02-01\'', str(table)) + + +class TableEqualityTests(unittest.TestCase): + def test_tables_equal_by_name(self): + t1 = Table("t") + t2 = Table("t") + + self.assertEqual(t1, t2) + + def test_tables_equal_by_schema_and_name(self): + t1 = Table("t", schema="a") + t2 = Table("t", schema="a") + + self.assertEqual(t1, t2) + + def test_tables_equal_by_schema_and_name_using_schema(self): + a = Schema("a") + t1 = Table("t", schema=a) + t2 = Table("t", schema=a) + + self.assertEqual(t1, t2) + + def test_tables_equal_by_schema_and_name_using_schema_with_parent(self): + parent = Schema("parent") + a = Schema("a", parent=parent) + t1 = Table("t", schema=a) + t2 = Table("t", schema=a) + + self.assertEqual(t1, t2) + + def test_tables_not_equal_by_schema_and_name_using_schema_with_different_parents( + self, + ): + parent = Schema("parent") + a = Schema("a", parent=parent) + t1 = Table("t", schema=a) + t2 = Table("t", schema=Schema("a")) + + self.assertNotEqual(t1, t2) + + def test_tables_not_equal_with_different_schemas(self): + t1 = Table("t", schema="a") + t2 = Table("t", schema="b") + + self.assertNotEqual(t1, t2) + + def test_tables_not_equal_with_different_names(self): + t1 = Table("t", schema="a") + t2 = Table("q", schema="a") + + self.assertNotEqual(t1, t2) + + def test_many_tables_with_alias(self): + tables_data = [("table1", "t1"), ("table2", "t2"), ("table3", "t3")] + tables = Tables(*tables_data) + for el in tables: + self.assertIsNotNone(el.alias) + + def test_many_tables_without_alias(self): + tables_data = ["table1", "table2", "table3"] + tables = Tables(*tables_data) + for el in tables: + self.assertIsNone(el.alias) + + def test_many_tables_with_or_not_alias(self): + tables_data = [("table1", "t1"), ("table2"), "table3"] + tables = Tables(*tables_data) + for i in range(len(tables)): + if isinstance(tables_data[i], tuple): + self.assertIsNotNone(tables[i].alias) + else: + self.assertIsNone(tables[i].alias) + + +class TableDialectTests(unittest.TestCase): + def test_table_with_default_query_cls(self): + table = Table("abc") + q = table.select("1") + self.assertIs(q.dialect, None) + + def test_table_with_dialect_query_cls(self): + table = Table("abc", query_cls=SQLLiteQuery) + q = table.select("1") + self.assertIs(q.dialect, Dialects.SQLLITE) + + def test_table_factory_with_default_query_cls(self): + table = Query.Table("abc") + q = table.select("1") + self.assertIs(q.dialect, None) + + def test_table_factory_with_dialect_query_cls(self): + table = SQLLiteQuery.Table("abc") + q = table.select("1") + self.assertIs(q.dialect, Dialects.SQLLITE) + + def test_make_tables_factory_with_default_query_cls(self): + t1, t2 = Query.Tables("abc", "def") + q1 = t1.select("1") + q2 = t2.select("2") + self.assertIs(q1.dialect, None) + self.assertIs(q2.dialect, None) + + def test_make_tables_factory_with_dialect_query_cls(self): + t1, t2 = SQLLiteQuery.Tables("abc", "def") + q1 = t1.select("1") + q2 = t2.select("2") + self.assertIs(q1.dialect, Dialects.SQLLITE) + self.assertIs(q2.dialect, Dialects.SQLLITE) + + def test_table_with_bad_query_cls(self): + with self.assertRaises(TypeError): + Table("abc", query_cls=object) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/test_terms.py b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/test_terms.py new file mode 100644 index 0000000000000000000000000000000000000000..4c7590dfce129bac97a3f30de99b596cc746c893 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/test_terms.py @@ -0,0 +1,82 @@ +from unittest import TestCase + +from pypika import Query, Table, Field +from pypika.terms import AtTimezone + + +class FieldAliasTests(TestCase): + t = Table("test", alias="crit") + + def test_when_alias_specified(self): + c1 = Field("foo", alias="bar") + self.assertEqual('bar', str(c1.alias)) + + c1 = Field("foo").as_("bar") + self.assertEqual('bar', str(c1.alias)) + + +class FieldInitTests(TestCase): + def test_init_with_str_table(self): + test_table_name = "test_table" + field = Field(name="name", table=test_table_name) + self.assertEqual(field.table, Table(name=test_table_name)) + + +class FieldHashingTests(TestCase): + def test_tabled_eq_fields_equally_hashed(self): + client_name1 = Field(name="name", table=Table("clients")) + client_name2 = Field(name="name", table=Table("clients")) + self.assertTrue(hash(client_name1) == hash(client_name2)) + + def test_tabled_ne_fields_differently_hashed(self): + customer_name = Field(name="name", table=Table("customers")) + client_name = Field(name="name", table=Table("clients")) + self.assertTrue(hash(customer_name) != hash(client_name)) + + def test_non_tabled_aliased_eq_fields_equally_hashed(self): + self.assertTrue(hash(Field(name="A", alias="my_a")) == hash(Field(name="A", alias="my_a"))) + + def test_non_tabled_aliased_ne_fields_differently_hashed(self): + self.assertTrue(hash(Field(name="A", alias="my_a1")) != hash(Field(name="A", alias="my_a2"))) + + def test_non_tabled_eq_fields_equally_hashed(self): + self.assertTrue(hash(Field(name="A")) == hash(Field(name="A"))) + + def test_non_tabled_ne_fields_differently_hashed(self): + self.assertTrue(hash(Field(name="A")) != hash(Field(name="B"))) + + +class AtTimezoneTests(TestCase): + def test_when_interval_not_specified(self): + query = Query.from_("customers").select(AtTimezone("date", "US/Eastern")) + self.assertEqual('SELECT "date" AT TIME ZONE \'US/Eastern\' FROM "customers"', str(query)) + + def test_when_interval_specified(self): + query = Query.from_("customers").select(AtTimezone("date", "-06:00", interval=True)) + self.assertEqual( + 'SELECT "date" AT TIME ZONE INTERVAL \'-06:00\' FROM "customers"', + str(query), + ) + + def test_when_alias_specified(self): + query = Query.from_("customers").select(AtTimezone("date", "US/Eastern", alias="alias1")) + self.assertEqual( + 'SELECT "date" AT TIME ZONE \'US/Eastern\' "alias1" FROM "customers"', + str(query), + ) + + def test_passes_kwargs_to_field_get_sql(self): + customers = Table("customers") + accounts = Table("accounts") + query = ( + Query.from_(customers) + .join(accounts) + .on(customers.account_id == accounts.account_id) + .select(AtTimezone(customers.date, "US/Eastern", alias="alias1")) + ) + + self.assertEqual( + 'SELECT "customers"."date" AT TIME ZONE \'US/Eastern\' "alias1" ' + 'FROM "customers" JOIN "accounts" ON "customers"."account_id"="accounts"."account_id"', + query.get_sql(with_namespace=True), + ) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/test_tuples.py b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/test_tuples.py new file mode 100644 index 0000000000000000000000000000000000000000..c8ebc8e41b0115777f8b3c8cb01c04e62f13ee18 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/test_tuples.py @@ -0,0 +1,162 @@ +import unittest + +from pypika import ( + Array, + Bracket, + Query, + PostgreSQLQuery, + Table, + Tables, + Tuple, +) +from pypika.functions import Coalesce, NullIf, Sum +from pypika.terms import Field + + +class TupleTests(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_tuple_equality_tuple_on_both(self): + q = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, self.table_abc.bar) + .where(Tuple(self.table_abc.foo, self.table_abc.bar) == Tuple(1, 2)) + ) + + self.assertEqual('SELECT "foo","bar" FROM "abc" ' 'WHERE ("foo","bar")=(1,2)', str(q)) + + def test_tuple_equality_tuple_on_left(self): + q = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, self.table_abc.bar) + .where(Tuple(self.table_abc.foo, self.table_abc.bar) == (1, 2)) + ) + + self.assertEqual('SELECT "foo","bar" FROM "abc" ' 'WHERE ("foo","bar")=(1,2)', str(q)) + + def test_tuple_equality_tuple_on_right(self): + q = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, self.table_abc.bar) + .where((self.table_abc.foo, self.table_abc.bar) == Tuple(1, 2)) + ) + + # Order is reversed due to lack of right equals method + self.assertEqual('SELECT "foo","bar" FROM "abc" ' 'WHERE (1,2)=("foo","bar")', str(q)) + + def test_tuple_in_using_python_tuples(self): + q = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, self.table_abc.bar) + .where(Tuple(self.table_abc.foo, self.table_abc.bar).isin([(1, 1), (2, 2), (3, 3)])) + ) + + self.assertEqual( + 'SELECT "foo","bar" FROM "abc" ' 'WHERE ("foo","bar") IN ((1,1),(2,2),(3,3))', + str(q), + ) + + def test_tuple_in_using_pypika_tuples(self): + q = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, self.table_abc.bar) + .where(Tuple(self.table_abc.foo, self.table_abc.bar).isin([Tuple(1, 1), Tuple(2, 2), Tuple(3, 3)])) + ) + + self.assertEqual( + 'SELECT "foo","bar" FROM "abc" ' 'WHERE ("foo","bar") IN ((1,1),(2,2),(3,3))', + str(q), + ) + + def test_tuple_in_using_mixed_tuples(self): + q = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, self.table_abc.bar) + .where(Tuple(self.table_abc.foo, self.table_abc.bar).isin([(1, 1), Tuple(2, 2), (3, 3)])) + ) + + self.assertEqual( + 'SELECT "foo","bar" FROM "abc" ' 'WHERE ("foo","bar") IN ((1,1),(2,2),(3,3))', + str(q), + ) + + def test_tuples_in_join(self): + query = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .select("*") + .where(Tuple(self.table_abc.foo, self.table_efg.bar).isin([(1, 1), Tuple(2, 2), (3, 3)])) + ) + + self.assertEqual( + 'SELECT * FROM "abc" JOIN "efg" ON "abc"."foo"="efg"."bar" ' + 'WHERE ("abc"."foo","efg"."bar") IN ((1,1),(2,2),(3,3))', + str(query), + ) + + def test_render_alias_in_array_sql(self): + tb = Table("tb") + + q = Query.from_(tb).select(Tuple(tb.col).as_("different_name")) + self.assertEqual(str(q), 'SELECT ("col") "different_name" FROM "tb"') + + def test_tuple_is_aggregate(self): + with self.subTest('None if single argument returns None for is_aggregate'): + self.assertEqual(None, Tuple(0).is_aggregate) + self.assertEqual(None, Tuple(Coalesce('col')).is_aggregate) + + with self.subTest('None if multiple arguments all return None for is_aggregate'): + self.assertEqual(None, Tuple(0, 'a').is_aggregate) + self.assertEqual(None, Tuple(Coalesce('col'), NullIf('col2', 0)).is_aggregate) + + with self.subTest('True if single argument returns True for is_aggregate'): + self.assertEqual(True, Tuple(Sum('col')).is_aggregate) + + with self.subTest('True if multiple arguments return True for is_aggregate'): + self.assertEqual(True, Tuple(Sum('col'), Sum('col2')).is_aggregate) + + with self.subTest('True when mix of arguments returning None and True for is_aggregate'): + self.assertEqual(True, Tuple(Coalesce('col'), Coalesce('col2', 0), Sum('col3')).is_aggregate) + + with self.subTest('False when one of the arguments returns False for is_aggregate'): + self.assertEqual(False, Tuple(Field('col1'), Sum('col2')).is_aggregate) + + +class ArrayTests(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_array_general(self): + query = Query.from_(self.table_abc).select(Array(1, "a", ["b", 2, 3])) + + self.assertEqual("SELECT [1,'a',['b',2,3]] FROM \"abc\"", str(query)) + + def test_empty_psql_array(self): + query = PostgreSQLQuery.from_(self.table_abc).select(Array()) + + self.assertEqual("SELECT '{}' FROM \"abc\"", str(query)) + + def test_psql_array_general(self): + query = PostgreSQLQuery.from_(self.table_abc).select(Array(1, Array(2, 2, 2), 3)) + + self.assertEqual("SELECT ARRAY[1,ARRAY[2,2,2],3] FROM \"abc\"", str(query)) + + def test_render_alias_in_array_sql(self): + tb = Table("tb") + + q = Query.from_(tb).select(Array(tb.col).as_("different_name")) + self.assertEqual(str(q), 'SELECT ["col"] "different_name" FROM "tb"') + + +class BracketTests(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_arithmetic_with_brackets(self): + q = Query.from_(self.table_abc).select(Bracket(self.table_abc.foo / 2) / 2) + + self.assertEqual('SELECT ("foo"/2)/2 FROM "abc"', str(q)) + + def test_arithmetic_with_brackets_and_alias(self): + q = Query.from_(self.table_abc).select(Bracket(self.table_abc.foo / 2).as_("alias")) + + self.assertEqual('SELECT ("foo"/2) "alias" FROM "abc"', str(q)) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/test_updates.py b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/test_updates.py new file mode 100644 index 0000000000000000000000000000000000000000..fb9d714dbcb8213b4bda04bf7b8dd9b2419410ec --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/test_updates.py @@ -0,0 +1,162 @@ +import unittest + +from pypika import AliasedQuery, PostgreSQLQuery, Query, SQLLiteQuery, SYSTEM_TIME, Table + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + +from pypika.terms import Star + + +class UpdateTests(unittest.TestCase): + table_abc = Table("abc") + table_def = Table("def") + + def test_empty_query(self): + q = Query.update("abc") + + self.assertEqual("", str(q)) + + def test_omit_where(self): + q = Query.update(self.table_abc).set("foo", "bar") + + self.assertEqual('UPDATE "abc" SET "foo"=\'bar\'', str(q)) + + def test_single_quote_escape_in_set(self): + q = Query.update(self.table_abc).set("foo", "bar'foo") + + self.assertEqual("UPDATE \"abc\" SET \"foo\"='bar''foo'", str(q)) + + def test_update__table_schema(self): + table = Table("abc", "schema1") + q = Query.update(table).set(table.foo, 1).where(table.foo == 0) + + self.assertEqual('UPDATE "schema1"."abc" SET "foo"=1 WHERE "foo"=0', str(q)) + + def test_update_with_none(self): + q = Query.update("abc").set("foo", None) + self.assertEqual('UPDATE "abc" SET "foo"=null', str(q)) + + def test_update_with_join(self): + q = ( + Query.update(self.table_abc) + .join(self.table_def) + .on(self.table_def.abc_id == self.table_abc.id) + .set(self.table_abc.lname, self.table_def.lname) + ) + self.assertEqual( + 'UPDATE "abc" JOIN "def" ON "def"."abc_id"="abc"."id" SET "lname"="def"."lname"', + str(q), + ) + + def test_update_with_limit(self): + q = Query.update(self.table_abc).set(self.table_abc.lname, "test").limit(1) + self.assertEqual('UPDATE "abc" SET "lname"=\'test\' LIMIT 1', str(q)) + + def test_update_from(self): + from_table = Table('from_table') + + q = Query.update(self.table_abc).set(self.table_abc.lname, from_table.long_name).from_(from_table) + self.assertEqual('UPDATE "abc" SET "lname"="from_table"."long_name" FROM "from_table"', str(q)) + + def test_update_from_with_where(self): + from_table = Table('from_table') + + q = ( + Query.update(self.table_abc) + .set(self.table_abc.lname, from_table.long_name) + .from_(from_table) + .where(self.table_abc.fname.eq(from_table.full_name)) + ) + self.assertEqual( + 'UPDATE "abc" SET "lname"="from_table"."long_name" FROM "from_table" ' + 'WHERE "abc"."fname"="from_table"."full_name"', + str(q), + ) + + def test_update_with_statement(self): + table_efg = Table('efg') + + sub_query = Query.from_(table_efg).select("fizz") + an_alias = AliasedQuery("an_alias") + + q = ( + Query.with_(sub_query, "an_alias") + .update(self.table_abc) + .from_(an_alias) + .set(self.table_abc.lname, an_alias.long_name) + .where(self.table_abc.comp.eq(an_alias.alias_comp)) + ) + self.assertEqual( + 'WITH an_alias AS (SELECT "fizz" FROM "efg") ' + 'UPDATE "abc" SET "lname"="an_alias"."long_name" FROM an_alias ' + 'WHERE "abc"."comp"="an_alias"."alias_comp"', + str(q), + ) + + def test_for_portion(self): + with self.subTest("with system time"): + q = Query.update(self.table_abc.for_portion(SYSTEM_TIME.from_to('2020-01-01', '2020-02-01'))).set( + "foo", "bar" + ) + + self.assertEqual( + 'UPDATE "abc" FOR PORTION OF SYSTEM_TIME FROM \'2020-01-01\' TO \'2020-02-01\' SET "foo"=\'bar\'', + str(q), + ) + + with self.subTest("with column"): + q = Query.update( + self.table_abc.for_portion(self.table_abc.valid_period.from_to('2020-01-01', '2020-02-01')) + ).set("foo", "bar") + + self.assertEqual( + 'UPDATE "abc" FOR PORTION OF "valid_period" FROM \'2020-01-01\' TO \'2020-02-01\' SET "foo"=\'bar\'', + str(q), + ) + + +class PostgresUpdateTests(unittest.TestCase): + table_abc = Table("abc") + + def test_update_returning_str(self): + q = PostgreSQLQuery.update(self.table_abc).where(self.table_abc.foo == 0).set("foo", "bar").returning("id") + + self.assertEqual('UPDATE "abc" SET "foo"=\'bar\' WHERE "foo"=0 RETURNING "abc"."id"', str(q)) + + def test_update_returning(self): + q = ( + PostgreSQLQuery.update(self.table_abc) + .where(self.table_abc.foo == 0) + .set("foo", "bar") + .returning(self.table_abc.id) + ) + + self.assertEqual('UPDATE "abc" SET "foo"=\'bar\' WHERE "foo"=0 RETURNING "abc"."id"', str(q)) + + def test_update_returning_from_different_tables(self): + table_bcd = Table('bcd') + + q = ( + PostgreSQLQuery.update(self.table_abc) + .from_(table_bcd) + .set(self.table_abc.lname, table_bcd.long_name) + .returning(self.table_abc.id, table_bcd.fname) + ) + self.assertEqual( + 'UPDATE "abc" SET "lname"="bcd"."long_name" FROM "bcd" RETURNING "abc"."id","bcd"."fname"', str(q) + ) + + def test_update_returning_star(self): + q = PostgreSQLQuery.update(self.table_abc).where(self.table_abc.foo == 0).set("foo", "bar").returning(Star()) + + self.assertEqual('UPDATE "abc" SET "foo"=\'bar\' WHERE "foo"=0 RETURNING *', str(q)) + + +class SQLLiteUpdateTests(unittest.TestCase): + table_abc = Table("abc") + + def test_update_with_bool(self): + q = SQLLiteQuery.update(self.table_abc).set(self.table_abc.foo, True) + + self.assertEqual('UPDATE "abc" SET "foo"=1', str(q)) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/test_utils.py b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/test_utils.py new file mode 100644 index 0000000000000000000000000000000000000000..bb9a9b1c68fe8671989f7c49f9db90e389d06f59 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pypika/tests/test_utils.py @@ -0,0 +1,24 @@ +import unittest + +from pypika import utils + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + + +class ImmutabilityTests(unittest.TestCase): + def test_raise_attribute_error_for_deepcopy(self): + with self.assertRaises(AttributeError): + utils.raise_attribute_for_copy("Test", "__deepcopy__") + + def test_raise_attribute_error_for_getstate(self): + with self.assertRaises(AttributeError): + utils.raise_attribute_for_copy("Test", "__getstate__") + + def test_raise_attribute_error_for_setstate(self): + with self.assertRaises(AttributeError): + utils.raise_attribute_for_copy("Test", "__setstate__") + + def test_raise_attribute_error_for_getnewargs(self): + with self.assertRaises(AttributeError): + utils.raise_attribute_for_copy("Test", "__getnewargs__") diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pyproject.toml b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pyproject.toml new file mode 100644 index 0000000000000000000000000000000000000000..dcc56baede23e3571b336625e695c466ab833a56 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/pyproject.toml @@ -0,0 +1,22 @@ +[tool.black] +line-length = 120 +skip-string-normalization = true +target-version = ['py38', 'py39', 'py310', 'py311'] +force-exclude = ''' +( + /( + \.eggs # exclude a few common directories in the + | \.git # root of the project + | \.hg + | \.mypy_cache + | \.tox + | \.venv + | _build + | buck-out + | build + | dist + | docs + )/ + | setup.py +) +''' diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/setup.cfg b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/setup.cfg new file mode 100644 index 0000000000000000000000000000000000000000..46084aaf2ca9e95b2f9bb7680e432e637fc3ed90 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/setup.cfg @@ -0,0 +1,16 @@ +[bumpversion] +current_version = 0.48.9 +commit = True +tag = True + +[bumpversion:file:pypika/__init__.py] +search = __version__ = "{current_version}" +replace = __version__ = "{new_version}" + +[bdist_wheel] +universal = 1 + +[flake8] +exclude = docs, .git, __pycache__ +max-line-length = 120 +per-file-ignores = __init__.py:F401 diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/setup.py b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/setup.py new file mode 100644 index 0000000000000000000000000000000000000000..41cce7d742df3e33e8d76f267d77df486f69249a --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/setup.py @@ -0,0 +1,81 @@ +import ast + +from setuptools import setup + + +def readme(): + with open('README.rst', 'rb') as f: + return f.read().decode('UTF-8') + + +def version(): + path = 'pypika/__init__.py' + with open(path, 'r') as file: + t = compile(file.read(), path, 'exec', ast.PyCF_ONLY_AST) + for node in (n for n in t.body if isinstance(n, ast.Assign)): + if len(node.targets) == 1: + name = node.targets[0] + if isinstance(name, ast.Name) and name.id in ('__version__', '__version_info__', 'VERSION'): + v = node.value + if isinstance(v, ast.Str): + return v.s + + if isinstance(v, ast.Tuple): + r = [] + for e in v.elts: + if isinstance(e, ast.Str): + r.append(e.s) + elif isinstance(e, ast.Num): + r.append(str(e.n)) + return '.'.join(r) + + +setup( + # Application name: + name="PyPika", + + # Version number: + version=version(), + + # Application author details: + author="Timothy Heys", + author_email="theys@kayak.com", + + # License + license='Apache License Version 2.0', + + # Packages + packages=["pypika", "pypika.clickhouse"], + + # Include additional files into the package + package_data={"pypika": ["py.typed"]}, + include_package_data=True, + + install_requires=[], + + # Details + url="https://github.com/kayak/pypika", + + description="A SQL query builder API for Python", + long_description=readme(), + + classifiers=[ + 'License :: OSI Approved :: Apache Software License', + 'Development Status :: 5 - Production/Stable', + 'Intended Audience :: Developers', + 'Programming Language :: Python :: 3', + 'Programming Language :: PL/SQL', + 'Topic :: Software Development :: Libraries :: Python Modules', + 'Topic :: Scientific/Engineering :: Information Analysis', + 'Topic :: Scientific/Engineering :: Mathematics', + 'Operating System :: POSIX', + 'Operating System :: MacOS :: MacOS X', + 'Operating System :: Microsoft :: Windows', + ], + keywords=('pypika python query builder querybuilder sql mysql postgres psql oracle vertica aggregated ' + 'relational database rdbms business analytics bi data science analysis pandas ' + 'orm object mapper'), + + # Dependent packages (distributions) + test_suite="pypika.tests", +) diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/tox.ini b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/tox.ini new file mode 100644 index 0000000000000000000000000000000000000000..2f0e6893243b1ca2ead6a12825e9014dc66364ce --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/tests/trusted/tox.ini @@ -0,0 +1,16 @@ +[tox] +envlist = py38,py39,py310,py311,pypy3 + +[testenv] +description = testing against {basepython} +deps = -r requirements-dev.txt +commands = + coverage run + coverage xml + +[gh-actions] +python = + 3.8: py38 + 3.9: py39 + 3.10: py310 + 3.11: py311 diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/validation/canaries/first-hunk-only.sh b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/validation/canaries/first-hunk-only.sh new file mode 100644 index 0000000000000000000000000000000000000000..976eaaf9c1cd5b983849f24b1a863a585e0e5c1a --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/validation/canaries/first-hunk-only.sh @@ -0,0 +1,19 @@ +#!/bin/bash +set -Eeuo pipefail +cd /testbed/repo +cat > /tmp/openenv-reference.diff <<'OPENENV_PARTIAL' +diff --git a/pypika/clickhouse/condition.py b/pypika/clickhouse/condition.py +index c9545f3b46a7dca6861f9e93453a48eb15a5639e..ed08224e22fb27eb18876595a542dcd3ad14bffc 100644 +--- a/pypika/clickhouse/condition.py ++++ b/pypika/clickhouse/condition.py +@@ -3,7 +3,7 @@ + + class If(Function): + def __init__(self, *conditions, **kwargs): +- super().__init__("switch", *reversed(conditions), **kwargs) ++ super().__init__("if", *conditions, **kwargs) + + + class MultiIf(Function): +OPENENV_PARTIAL +/usr/bin/git -c core.hooksPath=/dev/null -c core.fsmonitor=false apply --whitespace=nowarn /tmp/openenv-reference.diff diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/validation/canaries/original-bug.sh b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/validation/canaries/original-bug.sh new file mode 100644 index 0000000000000000000000000000000000000000..927547df786c86ab3bb5eeb917a31e0fa1895f8b --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/validation/canaries/original-bug.sh @@ -0,0 +1,3 @@ +#!/bin/bash +set -Eeuo pipefail +: diff --git a/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/validation/openenv.json b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/validation/openenv.json new file mode 100644 index 0000000000000000000000000000000000000000..a13b3c577df494f6c894584d2b608ab051ebc44f --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.combine_module__yfbs6ldj/validation/openenv.json @@ -0,0 +1,27 @@ +{ + "canaries": "validation/canaries", + "profile": "harbor-semantic-v1", + "requires_credentials": false, + "resources": { + "cpu": 2, + "disk_mb": 16384, + "episode_timeout_s": 1800, + "memory_mb": 8192 + }, + "reward": { + "floor_margin": 0.1, + "oracle_tolerance": 0, + "range": [ + 0, + 1 + ] + }, + "reward_key": "reward", + "types": { + "tags": [ + "swe", + "python", + "mutation-repair" + ] + } +} diff --git a/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/LICENSE.source b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/LICENSE.source new file mode 100644 index 0000000000000000000000000000000000000000..9c8f3ea0871e0bfe81da0fa6e7c1d7d156dc380e --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/LICENSE.source @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. \ No newline at end of file diff --git a/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/adapter.json b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/adapter.json new file mode 100644 index 0000000000000000000000000000000000000000..126d7f4c139752281d5b50eaeba6b62daa2f70a4 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/adapter.json @@ -0,0 +1,135 @@ +{ + "canary_selection": "Fixed first provided gold hunk only when at least2hunks exist; strict subset, never reward-selected. Single-hunk task original-bug canary is explicitly NOP-equivalent and adds no signal beyond floor_gap.", + "collector_sha256": "352e555112f2de8a1393f939903e4971c9ace0e944843762b707a725c5c72481", + "dependency_installation_pinned": false, + "dependency_setup_sha256": "ed8673d02878e91c7ae0b51b9178d6a15792b79c6992f800c14a941d95242392", + "gold_patch_sha256": "dca0fb6f423013f0d5290d14e3a043ec7290e8cefeafc4ba15924ad1fa6c4cb3", + "hostile_code_isolation_established": false, + "known_wrong_semantic_implementations": 0, + "native_inventory_sha256": "9409c254a3d9dd3af89ef163bccf8a5f59a17e9c5cadea6cc0b5e808be410ced", + "new_files_deletions_and_executable_modes_supported": true, + "official_profile": { + "eval_sets": [], + "profile_class": "Pypika1c9646f0", + "profile_lines": [ + 736, + 739 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "upstream_repo": "kayak/pypika" + }, + "original_bug_canary_nop_equivalent": true, + "original_bug_runtime_wrongness_established": false, + "partial_repair_canary": false, + "partial_repair_sha256": null, + "partial_repair_wrongness_established": false, + "positive_approval_policy": "All original strict presence/identity/no-skip/no-error/exit checks retained", + "private_checker_sha256": "f0a641064b725415e23a0221bb53c90446d7efcb7f9ece5ede93a220d18dd9e7", + "private_checker_version": "matched-failure-precedence-v2", + "provided_original_bug_control": true, + "repo_url": "https://github.com/swesmith/kayak__pypika.1c9646f0.git", + "runtime_image": null, + "runtime_ready": false, + "runtime_recipe": { + "dependency_installation_pinned": false, + "official_install_cmds": [ + "python -m pip install -e ." + ], + "official_pytest_argv": [ + "pytest", + "--disable-warnings", + "--color=no", + "--tb=no", + "--verbose" + ], + "official_test_command": "source /opt/miniconda3/bin/activate; conda activate testbed; pytest --disable-warnings --color=no --tb=no --verbose", + "operator_test_runner_prerequisites": [ + "python -m pip install pytest==8.4.2" + ], + "operator_test_runner_reason": "The official profile invokes pytest, but the common tools runtime does not provide it; pinned separately from source-native project requirements.", + "panel_normalization": "Override project addopts only to execute the exact frozen native panels; add JUnit output, preserve official pytest options and all selectors.", + "python_version": "3.10", + "source_bound_test_dependency_cmds": [ + "python -m pip install parameterized==0.7.0" + ], + "test_dependency_source_sha256": { + "requirements-dev.txt": "10f4ba7b19a73950d28fd7403d7e1d1b1fe2ccc4f49516974f47199d2965f23d", + "setup.py": "f8bad274588a22e65764d8cf9fb2be5aa6fcfaf3bf861d71e5f751105898845a", + "tox.ini": "c2d7205d0ac93e9c9e80dc5d24f0a826a6781f587a33ea722ea621f9e2ccd0ea" + } + }, + "runtime_resource_review_required": false, + "schema": "python-git-patch-jobs-v1", + "source_base_commit": "283132c4a6a6725c2a6abe522d6cf224b4e65444", + "source_completion_sha256": "bb979fc97b5e6324a10fb87fb3139ea48169462817b4b97eda5aa487090fb83d", + "source_index_sha256": "e856874b9410fce9f3bfea52c8c482e84b3e43942d87517f8b55f0034bd40f6f", + "source_pr_url": null, + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:kayak__pypika.1c9646f0.func_basic__00jnvt3b", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "6a742f12bfa386994289ec8b75824663d8ee4b15", + "instruction_sha256": "1929b798f90257eb0f895e3d55966c88625eb21ee5c58f9e78aed383a5421bbb", + "is_fork": true, + "learner_path": "tasks/14d0edf46691002bf37e013b/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "actual_upstream_url": "https://raw.githubusercontent.com/kayak/pypika/1c9646f0a019a167c32b649b6f5e6423c5ba2c9b/LICENSE.txt", + "reviewed": true, + "sha256": "c5accbbd8546e94c34aed24afe689a617627d18eed5a6c48277e48db57c23851", + "spdx": "Apache-2.0", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/kayak__pypika.1c9646f0/283132c4a6a6725c2a6abe522d6cf224b4e65444/LICENSE.txt" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "patch_sha256": "476b7d4e0c89673732154abd96dc7714a5a7ddd8ef21f0e356b68229582f3e41", + "provenance_path": "tasks/14d0edf46691002bf37e013b/source-proof.json", + "repository_lineage": [ + "swesmith/kayak__pypika.1c9646f0", + "kayak/pypika" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "283132c4a6a6725c2a6abe522d6cf224b4e65444", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "26e76fefeac36a78ec4787e4a8d85276120b1285", + "source_kind": "mutation", + "source_repo": "swesmith/kayak__pypika.1c9646f0", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "kayak__pypika.1c9646f0.func_basic__00jnvt3b", + "task_sha256": "bc004eb41a3c1352eb7cfd832c96a9f9510a1beaf9962e84f4cf51155be01a54", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "kayak/pypika", + "usage": "quarantine_only" + }, + "source_repo": "swesmith/kayak__pypika.1c9646f0", + "symlink_submodule_changes_supported": false, + "task_id": "kayak__pypika.1c9646f0.func_basic__00jnvt3b", + "transfer": "index-independent-worktree-to-Git-binary-patch", + "transfer_path": "/testbed/submission.patch", + "upstream_repo": "kayak/pypika" +} diff --git a/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/dependency-setup.sh b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/dependency-setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..e1a28db070ebf088cec3ef817cf2dc8715091ac2 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/dependency-setup.sh @@ -0,0 +1,9 @@ +#!/bin/bash +set -Eeuo pipefail +source /opt/miniconda3/bin/activate +conda activate testbed +cd /testbed/repo +python -c 'import sys; assert sys.version_info[:2] == (3, 10)' +python -m pip install pytest==8.4.2 +python -m pip install -e . +python -m pip install parameterized==0.7.0 diff --git a/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/environment/Dockerfile b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..a59b58c2ea8217c78c1e39b4678f93c8c0023bcd --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/environment/Dockerfile @@ -0,0 +1,3 @@ +# Runtime is selected only by an independently qualified immutable amd64 receipt. +FROM ubuntu:22.04 +RUN false diff --git a/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/instruction.md b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..76b6aad1405cf4b0c1058e2279d61b2c0db5ce63 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/instruction.md @@ -0,0 +1,39 @@ +PseudoColumn returns None instead of column name in SQL output + +#### Description + +When using PseudoColumn in queries, the generated SQL contains `None` instead of the expected column name. + +#### Steps/Code to Reproduce + +```python +from pypika import Query +from pypika.terms import PseudoColumn + +# Create a simple table for testing +table1 = Query.Table('table1') + +# Try to use PseudoColumn in a select statement +query = Query.from_(table1).where(table1.is_active == 1).select(PseudoColumn('abcde')) +print(str(query)) +# Expected: SELECT abcde FROM "table1" WHERE "is_active"=1 +# Actual: SELECT None FROM "table1" WHERE "is_active"=1 + +# Try to use PseudoColumn in orderby +query = Query.from_(table1).select(table1.abcde.as_('some_name')).orderby(PseudoColumn('some_name')) +print(str(query)) +# Expected: SELECT "abcde" "some_name" FROM "table1" ORDER BY some_name +# Actual: SELECT "abcde" "some_name" FROM "table1" ORDER BY None + +# Try to use PseudoColumn in where clause +query = Query.from_(table1).where(PseudoColumn('abcde') > 1).select(table1.is_active) +print(str(query)) +# Expected: SELECT "is_active" FROM "table1" WHERE abcde>1 +# Actual: SELECT "is_active" FROM "table1" WHERE None>1 +``` + +The PseudoColumn class seems to be returning `None` instead of the column name that was passed during initialization. + +## Environment + +The repository is at `/testbed/repo`. Its dependencies, including pytest, are installed in the `testbed` conda environment, which comes first on PATH. If `python -m pytest` reports that pytest is missing, use the full interpreter path: `/opt/miniconda3/envs/testbed/bin/python -m pytest `. Don't install packages: the tests need nothing else, and the sandbox may have no network access. diff --git a/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/metadata.json b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/metadata.json new file mode 100644 index 0000000000000000000000000000000000000000..00ef4bb3e02d6ebca4b7d383354a4a8da3b25906 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/metadata.json @@ -0,0 +1,1275 @@ +{ + "all_runtime_and_training_flags": false, + "official_profile": { + "eval_sets": [], + "profile_class": "Pypika1c9646f0", + "profile_lines": [ + 736, + 739 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "upstream_repo": "kayak/pypika" + }, + "source_healthy_reference_proof": { + "FAIL_TO_PASS": [ + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_can_be_used_in_a_select_statement", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_can_be_used_in_a_where_clause", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_can_be_used_in_orderby" + ], + "PASS_TO_PASS": [ + "pypika/tests/clickhouse/test_array.py::TestArray::test_get_sql_0__ridley_scott_jimi_hendrix_", + "pypika/tests/clickhouse/test_array.py::TestArray::test_get_sql_1__1_2_3_4_", + "pypika/tests/clickhouse/test_array.py::TestArray::test_get_sql_2__toInt64_1_toInt64_2_toInt64_3_toInt64_4_", + "pypika/tests/clickhouse/test_array.py::TestArray::test_get_sql_3__toFixedString_mogwai_10_toFixedString_mono_10_toFixedString_bonobo_10_arr", + "pypika/tests/clickhouse/test_array.py::TestHasAny::test_get_sql_0_hasAny_mental_abilities_physical_abilities_", + "pypika/tests/clickhouse/test_array.py::TestHasAny::test_get_sql_1_hasAny_1_2_3_4_3_", + "pypika/tests/clickhouse/test_array.py::TestHasAny::test_get_sql_2_hasAny_bands_toFixedString_port_royal_20_toFixedString_hammock_20_", + "pypika/tests/clickhouse/test_array.py::TestLength::test_get_sql_0_length_tags_", + "pypika/tests/clickhouse/test_array.py::TestLength::test_get_sql_1_length_1_2_3_", + "pypika/tests/clickhouse/test_array.py::TestEmpty::test_get_sql_0_empty_tags_", + "pypika/tests/clickhouse/test_array.py::TestEmpty::test_get_sql_1_empty_1_2_3_", + "pypika/tests/clickhouse/test_array.py::TestNotEmpty::test_get_sql_0_notEmpty_tags_", + "pypika/tests/clickhouse/test_array.py::TestNotEmpty::test_get_sql_1_notEmpty_1_2_3_", + "pypika/tests/clickhouse/test_condition.py::TestIfCondition::test_get_sql_0", + "pypika/tests/clickhouse/test_condition.py::TestIfCondition::test_get_sql_1", + "pypika/tests/clickhouse/test_condition.py::TestMultiIfCondition::test_get_sql_0", + "pypika/tests/clickhouse/test_condition.py::TestMultiIfCondition::test_get_sql_1", + "pypika/tests/clickhouse/test_dates_and_times.py::TestFormatDateTime::test_get_sql_0", + "pypika/tests/clickhouse/test_dates_and_times.py::TestFormatDateTime::test_get_sql_1", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_00", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_01", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_02", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_03", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_04", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_05", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_06", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_07", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_08", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_09", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_10", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_11", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_12", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_13", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_14", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_15", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_16", + "pypika/tests/clickhouse/test_dates_and_times.py::TestToYYYYMM::test_get_sql", + "pypika/tests/clickhouse/test_nullable_arg.py::TestSearchString::test_get_sql_0", + "pypika/tests/clickhouse/test_nullable_arg.py::TestSearchString::test_get_sql_1", + "pypika/tests/clickhouse/test_search_string.py::TestSearchString::test_search_string_0", + "pypika/tests/clickhouse/test_search_string.py::TestSearchString::test_search_string_1", + "pypika/tests/clickhouse/test_search_string.py::TestSearchString::test_search_string_2", + "pypika/tests/clickhouse/test_search_string.py::TestMultiSearch::test_multi_search_string_0", + "pypika/tests/clickhouse/test_search_string.py::TestMultiSearch::test_multi_search_string_1", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_00_toString_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_01_toInt8_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_02_toInt16_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_03_toInt32_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_04_toInt64_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_05_toUInt8_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_06_toUInt16_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_07_toUInt32_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_08_toUInt64_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_09_toFloat32_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_10_toFloat64_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_11_toFloat64_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_12_toDate_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_13_toDateTime_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_14_toFixedString_field_name_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_00_toString_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_01_toInt8_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_02_toInt16_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_03_toInt32_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_04_toInt64_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_05_toUInt8_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_06_toUInt16_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_07_toUInt32_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_08_toUInt64_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_09_toFloat32_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_10_toFloat64_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_11_toFloat64_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_12_toDate_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_13_toDateTime_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_14_toFixedString_100_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestToFixedString::test_get_sql_with_table", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseQueryTests::test_use_AS_keyword_for_alias", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseQueryTests::test_use_FINAL_keyword", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseQueryTests::test_use_SAMPLE_keyword", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseQueryTests::test_use_SAMPLE_with_offset_keyword", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDeleteTests::test_omit_where", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDeleteTests::test_omit_where__table_schema", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDeleteTests::test_where_field_equals", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseUpdateTests::test_update", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDropQuery::test_drop_database", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDropQuery::test_drop_dictionary", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDropQuery::test_drop_other", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDropQuery::test_drop_table", + "pypika/tests/dialects/test_clickhouse.py::DistinctOnTests::test_distinct_on", + "pypika/tests/dialects/test_clickhouse.py::LimitByTests::test_limit_by", + "pypika/tests/dialects/test_clickhouse.py::LimitByTests::test_limit_offset0_by", + "pypika/tests/dialects/test_clickhouse.py::LimitByTests::test_limit_offset_by", + "pypika/tests/dialects/test_clickhouse.py::LimitByTests::test_rename_table", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_distinct_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_groupby_alias_False_does_not_group_by_alias_when_subqueries_are_present", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_groupby_alias_False_does_not_group_by_alias_with_standard_query", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_limit", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_limit_with_offset", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_normal_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_offset", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_distinct_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_percent_invalid_range", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_percent_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_select_non_int", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_with_ties_select", + "pypika/tests/dialects/test_mysql.py::SelectTests::test_distinct_select", + "pypika/tests/dialects/test_mysql.py::SelectTests::test_modifier_select", + "pypika/tests/dialects/test_mysql.py::SelectTests::test_multiple_modifier_select", + "pypika/tests/dialects/test_mysql.py::SelectTests::test_normal_select", + "pypika/tests/dialects/test_mysql.py::UpdateTests::test_conflict_handlers_update", + "pypika/tests/dialects/test_mysql.py::UpdateTests::test_on_duplicate_key_ignore_update", + "pypika/tests/dialects/test_mysql.py::UpdateTests::test_on_duplicate_key_update_update", + "pypika/tests/dialects/test_mysql.py::UpdateTests::test_update", + "pypika/tests/dialects/test_mysql.py::LoadCSVTests::test_load_from_file", + "pypika/tests/dialects/test_mysql.py::TableTests::test_create_table", + "pypika/tests/dialects/test_mysql.py::TableTests::test_drop_table", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_fetch_next_method_deprecated", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_groupby_alias_False_does_not_group_by_alias_when_subqueries_are_present", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_groupby_alias_False_does_not_group_by_alias_with_standard_query", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_limit_offset_query", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_limit_query", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_offset_query", + "pypika/tests/dialects/test_postgresql.py::InsertTests::test_array_keyword", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_alias_set_correctly", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_json_value_from_array_num", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_json_value_from_array_str", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_json_value_from_dict", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_json_value_from_dict_recursive", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_json_value_by_index", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_json_value_by_key", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_path_json_value", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_path_text_value", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_text_value_by_index", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_text_value_by_key", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contained_by_using_list_arg", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contained_by_using_str_arg", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contained_by_with_complex_criterion", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contains_for_field", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contains_for_json", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_has_any_keys", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_has_key", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_has_keys", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_subnet_contains_inet", + "pypika/tests/dialects/test_postgresql.py::DistinctOnTests::test_distinct_on", + "pypika/tests/dialects/test_postgresql.py::ArrayTests::test_array_syntax", + "pypika/tests/dialects/test_postgresql.py::ArrayTests::test_render_alias_in_array_sql", + "pypika/tests/dialects/test_postgresql.py::ReturningClauseTests::test_no_queryexception_if_returning_used_on_valid_query_type", + "pypika/tests/dialects/test_postgresql.py::ReturningClauseTests::test_queryexception_if_returning_used_on_invalid_query", + "pypika/tests/dialects/test_postgresql.py::ReturningClauseTests::test_return_field_from_join_table", + "pypika/tests/dialects/test_postgresql.py::ReturningClauseTests::test_returning_from_missing_table_raises_queryexception", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_dont_use_double_quotes_on_create_queries", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_dont_use_double_quotes_on_drop_queries", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_dont_use_double_quotes_on_joining_queries", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_use_double_quotes_on_alias_but_not_on_terms", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_use_double_quotes_on_alias_but_not_on_terms_with_joins", + "pypika/tests/dialects/test_sqllite.py::SelectTests::test_bool_false_as_zero", + "pypika/tests/dialects/test_sqllite.py::SelectTests::test_bool_true_as_one", + "pypika/tests/dialects/test_sqllite.py::ReplaceTests::test_insert_or_replace", + "pypika/tests/dialects/test_sqllite.py::ReplaceTests::test_normal_replace", + "pypika/tests/dialects/test_sqllite.py::ReplaceTests::test_replace_subquery", + "pypika/tests/dialects/test_vertica.py::VerticaQueryTests::test_delete_query_with_hint", + "pypika/tests/dialects/test_vertica.py::VerticaQueryTests::test_insert_query_with_hint", + "pypika/tests/dialects/test_vertica.py::VerticaQueryTests::test_select_query_with_hint", + "pypika/tests/dialects/test_vertica.py::VerticaQueryTests::test_update_query_with_hint", + "pypika/tests/dialects/test_vertica.py::CopyCSVTests::test_copy_from_file", + "pypika/tests/dialects/test_vertica.py::CreateTemporaryTableTests::test_create_local_table_without_temporary_raises_error", + "pypika/tests/dialects/test_vertica.py::CreateTemporaryTableTests::test_create_local_temporary_table", + "pypika/tests/dialects/test_vertica.py::CreateTemporaryTableTests::test_create_table_preserve_rows_without_temporary_raises_error", + "pypika/tests/dialects/test_vertica.py::CreateTemporaryTableTests::test_create_temporary_table_preserve_rows", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__agg_case_criterion_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__agg_case_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__agg_func_arithmetic_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__agg_func_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__case_mixed_constant_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__case_mixed_else_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__case_with_field_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__case_with_single_aggregate_field_in_one_criterion_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__constant_arithmetic_is_aggregate_none", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__constant_is_aggregate_none", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__field_arithmetic_constant_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__field_arithmetic_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__field_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__func_arithmetic_constant_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__mixed_case_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__mixed_func_arithmetic_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__negative_agg_func_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__non_aggregate_function_with_aggregated_arg", + "pypika/tests/test_aggregate.py::IsAggregateTests::test_complicated", + "pypika/tests/test_analytic_queries.py::RankTests::test_avg", + "pypika/tests/test_analytic_queries.py::RankTests::test_count_range_between_unbounded_preceeding_current_row", + "pypika/tests/test_analytic_queries.py::RankTests::test_dense_rank", + "pypika/tests/test_analytic_queries.py::RankTests::test_empty_over", + "pypika/tests/test_analytic_queries.py::RankTests::test_filter", + "pypika/tests/test_analytic_queries.py::RankTests::test_filter_quote_table_in_filter", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value_ignore_nulls", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value_ignore_nulls_first", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value_multi_argument", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value_range_between_x_preceeding_unbounded_following", + "pypika/tests/test_analytic_queries.py::RankTests::test_lag_generates_correct_sql", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value_ignore_nulls", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value_multi_argument", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value_rows_between_current_row_unbounded_following", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value_rows_between_current_row_unbounded_following_ignore_nulls", + "pypika/tests/test_analytic_queries.py::RankTests::test_lead_generates_correct_sql", + "pypika/tests/test_analytic_queries.py::RankTests::test_max_range_x_preceeding", + "pypika/tests/test_analytic_queries.py::RankTests::test_max_rows_x_preceeding", + "pypika/tests/test_analytic_queries.py::RankTests::test_median", + "pypika/tests/test_analytic_queries.py::RankTests::test_min_range_current_row", + "pypika/tests/test_analytic_queries.py::RankTests::test_min_rows_current_row", + "pypika/tests/test_analytic_queries.py::RankTests::test_multiple_partitions", + "pypika/tests/test_analytic_queries.py::RankTests::test_ntile_no_partition_or_order_invalid_sql", + "pypika/tests/test_analytic_queries.py::RankTests::test_ntile_with_order", + "pypika/tests/test_analytic_queries.py::RankTests::test_ntile_with_partition", + "pypika/tests/test_analytic_queries.py::RankTests::test_ntile_with_partition_and_order", + "pypika/tests/test_analytic_queries.py::RankTests::test_orderby_asc", + "pypika/tests/test_analytic_queries.py::RankTests::test_orderby_desc", + "pypika/tests/test_analytic_queries.py::RankTests::test_range_called_twice_raises_attribute_error", + "pypika/tests/test_analytic_queries.py::RankTests::test_range_then_rows_raises_attribute_error", + "pypika/tests/test_analytic_queries.py::RankTests::test_rank", + "pypika/tests/test_analytic_queries.py::RankTests::test_rank_with_alias", + "pypika/tests/test_analytic_queries.py::RankTests::test_row_number", + "pypika/tests/test_analytic_queries.py::RankTests::test_rows_called_twice_raises_attribute_error", + "pypika/tests/test_analytic_queries.py::RankTests::test_rows_then_range_raises_attribute_error", + "pypika/tests/test_analytic_queries.py::RankTests::test_stddev", + "pypika/tests/test_analytic_queries.py::RankTests::test_stddev_pop", + "pypika/tests/test_analytic_queries.py::RankTests::test_stddev_samp", + "pypika/tests/test_analytic_queries.py::RankTests::test_sum_rows_unbounded_preceeding", + "pypika/tests/test_analytic_queries.py::RankTests::test_table_prefixes_used_in_analytic_functions", + "pypika/tests/test_analytic_queries.py::RankTests::test_var_pop", + "pypika/tests/test_analytic_queries.py::RankTests::test_var_samp", + "pypika/tests/test_analytic_queries.py::RankTests::test_variance", + "pypika/tests/test_analytic_queries.py::RankTests::test_variance_rows_between_unbounded_preceeding_unbounded_following", + "pypika/tests/test_analytic_queries.py::RankTests::test_varpop_range_unbounded_preceeding", + "pypika/tests/test_analytic_queries.py::RankTests::test_varpop_rows_between_unbounded_preceeding_x_following", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_as_select_not_query_raises_error", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_with_columns", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_with_select", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_with_select_and_columns_fails", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_without_columns_or_select_empty", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_if_not_exists", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_simple", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_unique", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_where", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_without_columns_raises_error", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_without_table_raises_error", + "pypika/tests/test_criterions.py::CriterionTests::test__bitwise_and_in_where_clause", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_bitwise_and", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_bitwise_and_with_alias", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_bool", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_decimal", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_str", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gt_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gt_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gt_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gt_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gte_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gte_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gte_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gte_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_is_null", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_is_null_with_alias", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lt_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lt_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lt_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lt_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lte_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lte_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lte_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lte_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_str", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_with_alias", + "pypika/tests/test_criterions.py::NotTests::test_chained_function", + "pypika/tests/test_criterions.py::NotTests::test_is_not_null", + "pypika/tests/test_criterions.py::NotTests::test_negate", + "pypika/tests/test_criterions.py::NotTests::test_not_null", + "pypika/tests/test_criterions.py::NotTests::test_not_null_with_alias", + "pypika/tests/test_criterions.py::NotTests::test_not_with_and_criterion", + "pypika/tests/test_criterions.py::NotTests::test_not_with_complex_criterion", + "pypika/tests/test_criterions.py::NotTests::test_not_with_or_criterion", + "pypika/tests/test_criterions.py::NotTests::test_notnullcriterion_replace_table", + "pypika/tests/test_criterions.py::NotTests::test_variable_access", + "pypika/tests/test_criterions.py::BetweenTests::test__between_date", + "pypika/tests/test_criterions.py::BetweenTests::test__between_datetime", + "pypika/tests/test_criterions.py::BetweenTests::test__between_number", + "pypika/tests/test_criterions.py::BetweenTests::test__between_with_alias", + "pypika/tests/test_criterions.py::BetweenTests::test__function_between", + "pypika/tests/test_criterions.py::BetweenTests::test_get_item_only_works_with_slice", + "pypika/tests/test_criterions.py::IsInTests::test__function_isin", + "pypika/tests/test_criterions.py::IsInTests::test__in_character", + "pypika/tests/test_criterions.py::IsInTests::test__in_date", + "pypika/tests/test_criterions.py::IsInTests::test__in_datetime", + "pypika/tests/test_criterions.py::IsInTests::test__in_number", + "pypika/tests/test_criterions.py::IsInTests::test__in_number_with_alias", + "pypika/tests/test_criterions.py::IsInTests::test__in_unicode", + "pypika/tests/test_criterions.py::ArithmeticExpressionTests::test__lshift", + "pypika/tests/test_criterions.py::ArithmeticExpressionTests::test__rshift", + "pypika/tests/test_criterions.py::NotInTests::test__function_notin", + "pypika/tests/test_criterions.py::NotInTests::test__notin_character", + "pypika/tests/test_criterions.py::NotInTests::test__notin_date", + "pypika/tests/test_criterions.py::NotInTests::test__notin_datetime", + "pypika/tests/test_criterions.py::NotInTests::test__notin_number", + "pypika/tests/test_criterions.py::NotInTests::test__notin_number_with_alias", + "pypika/tests/test_criterions.py::LikeTests::test_glob_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_contains", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_ends_with", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_n_chars_long", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_starts_with", + "pypika/tests/test_criterions.py::LikeTests::test_like_contains", + "pypika/tests/test_criterions.py::LikeTests::test_like_ends_with", + "pypika/tests/test_criterions.py::LikeTests::test_like_n_chars_long", + "pypika/tests/test_criterions.py::LikeTests::test_like_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_like_starts_with", + "pypika/tests/test_criterions.py::LikeTests::test_not_ilike_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_not_like_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_rlike_escape_chars", + "pypika/tests/test_criterions.py::ExistsCriterionTests::test_exists", + "pypika/tests/test_criterions.py::ExistsCriterionTests::test_not_exists", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__between_and_field", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__between_and_isin", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__nested__and", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__nested__mixed", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__nested__or", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_and", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_function_and", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_function_or", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_function_xor", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_or", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_xor", + "pypika/tests/test_criterions.py::FieldsAsCriterionTests::test__field_and_field", + "pypika/tests/test_criterions.py::FieldsAsCriterionTests::test__field_or_field", + "pypika/tests/test_criterions.py::FieldsAsCriterionTests::test__field_xor_field", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_arithmeticfunction_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_betweencriterion_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_complexcriterion_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_criterion_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_field_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_function_with_only_fields_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_function_with_values_and_fields_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_nullcriterion_replace_table", + "pypika/tests/test_criterions.py::AnyTests::test_multiple_args_returned_in_chain_of_ors", + "pypika/tests/test_criterions.py::AnyTests::test_single_arg_returns_self", + "pypika/tests/test_criterions.py::AnyTests::test_with_generator", + "pypika/tests/test_criterions.py::AnyTests::test_zero_args_returns_empty_criterion", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_different_operations_with_empty_criterion", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_empty_criterion_on_the_left", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_empty_criterion_on_the_right", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_fields_", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_invertion_of_the_empty_criterion", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_more_than_one_empty_criterions", + "pypika/tests/test_criterions.py::AllTests::test_multiple_args_returned_in_chain_of_ors", + "pypika/tests/test_criterions.py::AllTests::test_single_arg_returns_self", + "pypika/tests/test_criterions.py::AllTests::test_with_generator", + "pypika/tests/test_criterions.py::AllTests::test_zero_args_returns_empty_criterion", + "pypika/tests/test_custom_functions.py::TestUnitCustomFunction::test_should_fail_with_wrong_arguments", + "pypika/tests/test_custom_functions.py::TestUnitCustomFunction::test_should_return_function_with_arguments", + "pypika/tests/test_custom_functions.py::TestUnitCustomFunction::test_should_return_function_with_no_arguments", + "pypika/tests/test_custom_functions.py::TestFunctionalCustomFunction::test_should_fail_use_custom_function_on_select_with_wrong_arguments", + "pypika/tests/test_custom_functions.py::TestFunctionalCustomFunction::test_should_use_custom_function_on_select", + "pypika/tests/test_data_types.py::StringTests::test_inline_string_concatentation", + "pypika/tests/test_data_types.py::UuidTests::test_uuid_string_generation", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_day", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_default", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_microsecond", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_minute", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_month", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_quarter", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_second", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_week", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_year", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_day_hour", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_day_microsecond", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_day_minute", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_day_second", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_hour_microsecond", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_hour_minute", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_hour_second", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_minute_microsecond", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_minute_second", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_second_microsecond", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_value_complex_expressions", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_value_right", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_year_month", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_mysql_dialect_uses_single_quotes_around_expression_in_an_interval", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_oracle_dialect_uses_single_quotes_around_expression_in_an_interval", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_postgresql_dialect_uses_single_quotes_around_interval", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_redshift_dialect_uses_single_quotes_around_interval", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_vertica_dialect_uses_single_quotes_around_interval", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_day", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_month", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_week", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_year", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_year_month", + "pypika/tests/test_date_math.py::TruncateTrailingZerosTests::test_do_not_truncate_integer_values", + "pypika/tests/test_date_math.py::TruncateTrailingZerosTests::test_do_not_truncate_months_between_years_and_datys", + "pypika/tests/test_deletes.py::DeleteTests::test_for_portion", + "pypika/tests/test_deletes.py::DeleteTests::test_omit_where", + "pypika/tests/test_deletes.py::DeleteTests::test_omit_where__table_schema", + "pypika/tests/test_deletes.py::DeleteTests::test_where_field_equals", + "pypika/tests/test_deletes.py::PostgresDeleteTests::test_delete_returning", + "pypika/tests/test_deletes.py::PostgresDeleteTests::test_delete_returning_star", + "pypika/tests/test_deletes.py::PostgresDeleteTests::test_delete_returning_str", + "pypika/tests/test_deletes.py::PostgresDeleteTests::test_delete_using", + "pypika/tests/test_drop.py::DropTableTests::test_drop_database", + "pypika/tests/test_drop.py::DropTableTests::test_drop_index", + "pypika/tests/test_drop.py::DropTableTests::test_drop_table", + "pypika/tests/test_drop.py::DropTableTests::test_drop_user", + "pypika/tests/test_drop.py::DropTableTests::test_drop_view", + "pypika/tests/test_formats.py::QuoteTests::test_no_quote_char_in_complex_query", + "pypika/tests/test_formats.py::QuoteTests::test_replace_quote_char_in_complex_query", + "pypika/tests/test_functions.py::FunctionTests::test_dialect_propagation", + "pypika/tests/test_functions.py::FunctionTests::test_is_aggregate_None_for_non_aggregate_function_or_function_with_no_aggregate_functions", + "pypika/tests/test_functions.py::FunctionTests::test_is_aggregate_True_for_aggregate_function_or_function_with_aggregate_functions", + "pypika/tests/test_functions.py::SchemaTests::test_schema_included_in_function_sql", + "pypika/tests/test_functions.py::SchemaTests::test_schema_no_schema_in_sql_when_none_set", + "pypika/tests/test_functions.py::ArithmeticTests::test__addition__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__addition__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__addition__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__addition__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__arithmetic_equality", + "pypika/tests/test_functions.py::ArithmeticTests::test__arithmetic_with_function", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_add_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_div_no_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_div_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_exponent_no_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_exponent_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_floor_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_function_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_modulus_no_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_modulus_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_mul_no_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_mul_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_nested_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_sub_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__division__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__division__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__division__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__division__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__exponent__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__exponent__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__floor", + "pypika/tests/test_functions.py::ArithmeticTests::test__leftshift__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__leftshift__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__leftshift__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__modulus__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__multiplication__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__multiplication__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__multiplication__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__multiplication__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__rightshift__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__rightshift__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__rightshift__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__subtraction__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__subtraction__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__subtraction__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__subtraction__right", + "pypika/tests/test_functions.py::AggregationTests::test__approx_percentile", + "pypika/tests/test_functions.py::AggregationTests::test__avg", + "pypika/tests/test_functions.py::AggregationTests::test__count", + "pypika/tests/test_functions.py::AggregationTests::test__count__star", + "pypika/tests/test_functions.py::AggregationTests::test__first", + "pypika/tests/test_functions.py::AggregationTests::test__last", + "pypika/tests/test_functions.py::AggregationTests::test__max", + "pypika/tests/test_functions.py::AggregationTests::test__min", + "pypika/tests/test_functions.py::AggregationTests::test__std", + "pypika/tests/test_functions.py::AggregationTests::test__stddev", + "pypika/tests/test_functions.py::AggregationTests::test__subquery_in_params_functions", + "pypika/tests/test_functions.py::AggregationTests::test__sum", + "pypika/tests/test_functions.py::ConditionTests::test__case__else", + "pypika/tests/test_functions.py::ConditionTests::test__case__field", + "pypika/tests/test_functions.py::ConditionTests::test__case__multi", + "pypika/tests/test_functions.py::ConditionTests::test__case__no_cases", + "pypika/tests/test_functions.py::ConditionTests::test__case__raw", + "pypika/tests/test_functions.py::StringTests::test__ascii__field", + "pypika/tests/test_functions.py::StringTests::test__ascii__int", + "pypika/tests/test_functions.py::StringTests::test__ascii__str", + "pypika/tests/test_functions.py::StringTests::test__bin__field", + "pypika/tests/test_functions.py::StringTests::test__bin__int", + "pypika/tests/test_functions.py::StringTests::test__bin__str", + "pypika/tests/test_functions.py::StringTests::test__concat__field", + "pypika/tests/test_functions.py::StringTests::test__concat__str", + "pypika/tests/test_functions.py::StringTests::test__insert__field", + "pypika/tests/test_functions.py::StringTests::test__insert__str", + "pypika/tests/test_functions.py::StringTests::test__length__field", + "pypika/tests/test_functions.py::StringTests::test__length__str", + "pypika/tests/test_functions.py::StringTests::test__lower__field", + "pypika/tests/test_functions.py::StringTests::test__lower__str", + "pypika/tests/test_functions.py::StringTests::test__replace__field", + "pypika/tests/test_functions.py::StringTests::test__replace__str", + "pypika/tests/test_functions.py::StringTests::test__substring", + "pypika/tests/test_functions.py::SplitPartFunctionTests::test__split_part", + "pypika/tests/test_functions.py::RegexpLikeFunctionTests::test__regexp_like", + "pypika/tests/test_functions.py::CastTests::test__cast__as", + "pypika/tests/test_functions.py::CastTests::test__cast__binary", + "pypika/tests/test_functions.py::CastTests::test__cast__binary_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__boolean", + "pypika/tests/test_functions.py::CastTests::test__cast__char", + "pypika/tests/test_functions.py::CastTests::test__cast__char_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__date", + "pypika/tests/test_functions.py::CastTests::test__cast__float", + "pypika/tests/test_functions.py::CastTests::test__cast__integer", + "pypika/tests/test_functions.py::CastTests::test__cast__long_varbinary", + "pypika/tests/test_functions.py::CastTests::test__cast__long_varbinary_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__long_varchar", + "pypika/tests/test_functions.py::CastTests::test__cast__long_varchar_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__numeric", + "pypika/tests/test_functions.py::CastTests::test__cast__signed", + "pypika/tests/test_functions.py::CastTests::test__cast__timestamp", + "pypika/tests/test_functions.py::CastTests::test__cast__unsigned", + "pypika/tests/test_functions.py::CastTests::test__cast__varbinary", + "pypika/tests/test_functions.py::CastTests::test__cast__varbinary_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__varchar", + "pypika/tests/test_functions.py::CastTests::test__cast__varchar_with_arg", + "pypika/tests/test_functions.py::CastTests::test__tochar__", + "pypika/tests/test_functions.py::DateFunctionsTests::test_current_date", + "pypika/tests/test_functions.py::DateFunctionsTests::test_current_time", + "pypika/tests/test_functions.py::DateFunctionsTests::test_current_timestamp", + "pypika/tests/test_functions.py::DateFunctionsTests::test_current_timestamp_with_alias", + "pypika/tests/test_functions.py::DateFunctionsTests::test_date_add", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_day", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_hour", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_join", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_microsecond", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_minute", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_month", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_quarter", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_second", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_week", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_year", + "pypika/tests/test_functions.py::DateFunctionsTests::test_now", + "pypika/tests/test_functions.py::DateFunctionsTests::test_time_diff", + "pypika/tests/test_functions.py::DateFunctionsTests::test_timestampadd", + "pypika/tests/test_functions.py::DateFunctionsTests::test_to_date", + "pypika/tests/test_functions.py::DateFunctionsTests::test_utc_timestamp", + "pypika/tests/test_functions.py::NullFunctionsTests::test_coalesce", + "pypika/tests/test_functions.py::NullFunctionsTests::test_isnull", + "pypika/tests/test_functions.py::NullFunctionsTests::test_nullif", + "pypika/tests/test_functions.py::NullFunctionsTests::test_nvl", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_mysql_one_groupby", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_mysql_rollup_two_groupbys", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_no_rollup_after_rollup_mysql", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_no_rollup_before_groupby", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_from_groupbys", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_from_parameters", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_from_two_groupbys", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_func_one_groupby", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_func_partial", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_func_two_groupbys", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_multiple_rollups", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_rollups_with_multiple_rollups_and_parity", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_rollups_with_parity", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_force_index_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_groupby_returns_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_immutable_kwarg_on_query_builder_disables_immutability", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_insert_into_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_join_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_orderby_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_queries_after_join", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_replace_into_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_select_returns_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_update_set_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_use_index_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_with_return_new_query_instance", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_multi_rows", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_multi_rows_chained", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_multi_rows_chained_mixed", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_multi_rows_chained_multiple_rows", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_single_element", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_column_using_alias_with_chain", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_column_using_table_alias", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_empty_columns", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_empty_columns_type_list", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_empty_columns_type_tuple", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_ignore", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_multiple_rows_with_array_value", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_none_skipped", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_null", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_one_column", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_one_column_multi_element_array", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_one_column_single_element_array", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_selected_columns", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_selected_columns_type_list", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_selected_columns_type_tuple", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_single_row_with_array_value", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_with_statement", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_empty_on_conflict_do_update_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_field", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_field_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_mixed_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_multiple_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_multiple_fields_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_field", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_field_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_multiple_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_multiple_fields_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_multiple_mixed_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_no_handler", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_two_handlers_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_two_handlers_do_update", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_fieldless_conflict_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_fieldless_conflict_do_update_field", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_non_insert_on_conflict_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_non_insert_on_conflict_do_update", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_do_nothing_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_do_update_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_do_update_with_excluded_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_from_subquery", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_complex", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_conflict_fields_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_conflict_fields_do_update", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_empty_conflict_fields_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_empty_conflict_fields_do_update", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_where_and_on_conflict_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_all_columns_multi_rows_chained_returning_star", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_all_columns_multi_rows_chained_returning_star_and_id", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_all_columns_multi_rows_chained_returning_star_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_all_columns_single_element_arrays", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_aggregate", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_all_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_all_fields_and_arithmetics", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_arithmetics", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_from_other_table", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_functions", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_null", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_one_field", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_one_field_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_tuple", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_ignore", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multi_rows_chained_mixed_on_duplicate_update_multiple", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_multiple", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_different_value", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_expression", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_expression_using_original_field_value", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_expression_using_values", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_same_value", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_none_skipped", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_one_column", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_one_column_multi_element_array", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_one_column_single_element_array", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_one_column_using_values", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_selected_columns_on_duplicate_update_multiple", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_selected_columns_on_duplicate_update_one", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_columns_from_columns", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_columns_from_columns_with_join", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_columns_from_star", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_from_columns", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_ignore_star", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_star", + "pypika/tests/test_inserts.py::InsertSubqueryTests::test_insert_subquery_wrapped_in_brackets", + "pypika/tests/test_inserts.py::SelectIntoTests::test_select_columns_into", + "pypika/tests/test_inserts.py::SelectIntoTests::test_select_columns_into_with_join", + "pypika/tests/test_inserts.py::SelectIntoTests::test_select_star_into", + "pypika/tests/test_inserts.py::ReplaceTests::test_replace_simple", + "pypika/tests/test_inserts.py::ReplaceTests::test_replace_subquery", + "pypika/tests/test_internals.py::TablesTests::test__case_tables", + "pypika/tests/test_internals.py::TablesTests::test__criterion_replace_table_with_value", + "pypika/tests/test_internals.py::TablesTests::test__star_tables", + "pypika/tests/test_internals.py::TablesTests::test__table_star_tables", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_cross_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_cross_join_on_subquery", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_cross_join_on_table", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_default_join_type", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_full_outer_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_hash_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_inner_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_arithmetic_field", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_collate", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_complex_criteria", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_field_multi", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_field_multi_with_extra_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_field_single", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_field_without_fields_raises_exception", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_subquery_criteria", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_second_table_in_from_clause", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_using_multiple_fields", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_using_string_field_name", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_using_with_quote_char", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_using_without_fields_raises_exception", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_with_arithmetic_function_in_select", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_left_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_left_outer_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_outer_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_right_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_right_outer_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_temporal_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_use_different_table_objects_for_same_table", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_fail_when_joining_unknown_type", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_ignore_table_references", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_immutable__tables", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_from_join", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_query_with_column_alias", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_query_with_setoperation", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_query_with_table_alias", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_query_without_alias", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_same_table", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_same_table_with_prefixes", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_table_twice", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_prefixes_added_to_function_in_orderby", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_prefixes_added_to_groupby", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_prefixes_added_to_orderby", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_require_condition", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_require_condition_with_both_tables", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select__fields_after_table_star", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select__ordered_select_clauses", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select__star_for_table", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select__star_for_table__replacement", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select_field_from_missing_table", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select_fields_with_where", + "pypika/tests/test_joins.py::UnionTests::test_mysql_query_wraps_unioned_queries", + "pypika/tests/test_joins.py::UnionTests::test_require_equal_number_of_fields", + "pypika/tests/test_joins.py::UnionTests::test_union", + "pypika/tests/test_joins.py::UnionTests::test_union_all", + "pypika/tests/test_joins.py::UnionTests::test_union_all_multiple", + "pypika/tests/test_joins.py::UnionTests::test_union_as_subquery", + "pypika/tests/test_joins.py::UnionTests::test_union_multiple", + "pypika/tests/test_joins.py::UnionTests::test_union_with_no_quote_char", + "pypika/tests/test_joins.py::UnionTests::test_union_with_order_by", + "pypika/tests/test_joins.py::UnionTests::test_union_with_order_by_use_union_query_field", + "pypika/tests/test_joins.py::UnionTests::test_union_with_order_by_use_union_query_field_with_aliases", + "pypika/tests/test_joins.py::UnionTests::test_union_with_order_by_with_aliases", + "pypika/tests/test_joins.py::InsertQueryJoinTests::test_join_table_on_insert_query", + "pypika/tests/test_joins.py::UpdateQueryJoinTests::test_join_table_on_update_query", + "pypika/tests/test_joins.py::IntersectTests::test_intersect", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_as_subquery", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_multiple", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_with_limit", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_with_no_quote_char", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_with_offset", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_with_order_by", + "pypika/tests/test_joins.py::IntersectTests::test_mysql_query_wraps_intersected_queries", + "pypika/tests/test_joins.py::IntersectTests::test_require_equal_number_of_fields_intersect", + "pypika/tests/test_joins.py::MinusTests::test_minus", + "pypika/tests/test_joins.py::MinusTests::test_minus_as_subquery", + "pypika/tests/test_joins.py::MinusTests::test_minus_multiple", + "pypika/tests/test_joins.py::MinusTests::test_minus_query_with_order_by_use_minus_query_field", + "pypika/tests/test_joins.py::MinusTests::test_minus_with_no_quote_char", + "pypika/tests/test_joins.py::MinusTests::test_minus_with_order_by", + "pypika/tests/test_joins.py::MinusTests::test_mysql_query_wraps_minus_queries", + "pypika/tests/test_joins.py::MinusTests::test_require_equal_number_of_fields", + "pypika/tests/test_joins.py::ExceptOfTests::test_except", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_as_subquery", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_multiple", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_query_with_order_by_use_minus_query_field", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_with_no_quote_char", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_with_order_by", + "pypika/tests/test_joins.py::ExceptOfTests::test_require_equal_number_of_fields_except_of", + "pypika/tests/test_negation.py::NegationTests::test_negate_field", + "pypika/tests/test_negation.py::NegationTests::test_negate_function", + "pypika/tests/test_negation.py::NegationTests::test_negate_wrapped_float", + "pypika/tests/test_negation.py::NegationTests::test_negate_wrapped_int", + "pypika/tests/test_parameter.py::ParametrizedTests::test_format_parameter", + "pypika/tests/test_parameter.py::ParametrizedTests::test_join", + "pypika/tests/test_parameter.py::ParametrizedTests::test_named_parameter", + "pypika/tests/test_parameter.py::ParametrizedTests::test_numeric_parameter", + "pypika/tests/test_parameter.py::ParametrizedTests::test_param_insert", + "pypika/tests/test_parameter.py::ParametrizedTests::test_param_select_join", + "pypika/tests/test_parameter.py::ParametrizedTests::test_param_select_subquery", + "pypika/tests/test_parameter.py::ParametrizedTests::test_pyformat_parameter", + "pypika/tests/test_parameter.py::ParametrizedTests::test_qmark_parameter", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_join", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_join_with_parameter_value_wrapper", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_param_insert", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_param_select_join", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_param_select_subquery", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_pyformat_parameter", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_column_value", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_object_id", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_object_value", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_row_id", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_row_num", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_sys_date", + "pypika/tests/test_query.py::QueryTablesTests::test_is_joined", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_case_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_delete_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_filter_tables", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_having_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_insert_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_insert_table_current_table_not_match", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_join_tables", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_only_specified_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_orderby_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_tuple_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_update_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_update_table_current_table_not_match", + "pypika/tests/test_query.py::QueryBuilderTests::test_pipe", + "pypika/tests/test_query.py::QueryBuilderTests::test_query_builders_have_reference_to_correct_query_class", + "pypika/tests/test_selects.py::SelectTests::test_empty_query", + "pypika/tests/test_selects.py::SelectTests::test_mssql_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_mysql_query_uses_backtick_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_oracle_query_uses_no_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_postgresql_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_redshift_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_select__column__single__alias__str", + "pypika/tests/test_selects.py::SelectTests::test_select__column__single__field", + "pypika/tests/test_selects.py::SelectTests::test_select__column__single__str", + "pypika/tests/test_selects.py::SelectTests::test_select__column__single__table_alias__str", + "pypika/tests/test_selects.py::SelectTests::test_select__columns__multi__field", + "pypika/tests/test_selects.py::SelectTests::test_select__columns__multi__str", + "pypika/tests/test_selects.py::SelectTests::test_select__distinct__multi", + "pypika/tests/test_selects.py::SelectTests::test_select__distinct__single", + "pypika/tests/test_selects.py::SelectTests::test_select__multiple_subqueries", + "pypika/tests/test_selects.py::SelectTests::test_select__multiple_tables", + "pypika/tests/test_selects.py::SelectTests::test_select__nested_subquery", + "pypika/tests/test_selects.py::SelectTests::test_select__no_table", + "pypika/tests/test_selects.py::SelectTests::test_select__star", + "pypika/tests/test_selects.py::SelectTests::test_select__star__replacement", + "pypika/tests/test_selects.py::SelectTests::test_select__subquery", + "pypika/tests/test_selects.py::SelectTests::test_select__table_schema", + "pypika/tests/test_selects.py::SelectTests::test_select__table_schema_with_multiple_levels_as_list", + "pypika/tests/test_selects.py::SelectTests::test_select__table_schema_with_multiple_levels_as_tuple", + "pypika/tests/test_selects.py::SelectTests::test_select_no_from", + "pypika/tests/test_selects.py::SelectTests::test_select_no_from_with_field_raises_exception", + "pypika/tests/test_selects.py::SelectTests::test_select_no_with_alias_from", + "pypika/tests/test_selects.py::SelectTests::test_select_then_add_table", + "pypika/tests/test_selects.py::SelectTests::test_select_with_force_index", + "pypika/tests/test_selects.py::SelectTests::test_select_with_force_index_multiple_calls", + "pypika/tests/test_selects.py::SelectTests::test_select_with_force_index_multiple_indexes", + "pypika/tests/test_selects.py::SelectTests::test_select_with_force_index_with_index_object", + "pypika/tests/test_selects.py::SelectTests::test_select_with_limit", + "pypika/tests/test_selects.py::SelectTests::test_select_with_limit__func", + "pypika/tests/test_selects.py::SelectTests::test_select_with_limit_and_offset", + "pypika/tests/test_selects.py::SelectTests::test_select_with_limit_zero", + "pypika/tests/test_selects.py::SelectTests::test_select_with_offset", + "pypika/tests/test_selects.py::SelectTests::test_select_with_offset__func", + "pypika/tests/test_selects.py::SelectTests::test_select_with_use_index", + "pypika/tests/test_selects.py::SelectTests::test_select_with_use_index_multiple_calls", + "pypika/tests/test_selects.py::SelectTests::test_select_with_use_index_multiple_indexes", + "pypika/tests/test_selects.py::SelectTests::test_select_with_use_index_with_index_object", + "pypika/tests/test_selects.py::SelectTests::test_table_select_alias", + "pypika/tests/test_selects.py::SelectTests::test_table_select_alias_with_offset_and_limit", + "pypika/tests/test_selects.py::SelectTests::test_temporal_select", + "pypika/tests/test_selects.py::SelectTests::test_vertica_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::WhereTests::test_ignore_empty_criterion_having", + "pypika/tests/test_selects.py::WhereTests::test_ignore_empty_criterion_where", + "pypika/tests/test_selects.py::WhereTests::test_select_with_force_index_and_where", + "pypika/tests/test_selects.py::WhereTests::test_where_enum", + "pypika/tests/test_selects.py::WhereTests::test_where_field_contains", + "pypika/tests/test_selects.py::WhereTests::test_where_field_does_not_contain", + "pypika/tests/test_selects.py::WhereTests::test_where_field_does_not_end_with", + "pypika/tests/test_selects.py::WhereTests::test_where_field_does_not_start_with", + "pypika/tests/test_selects.py::WhereTests::test_where_field_ends_with", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_and", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_nowait", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_of", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_of_multiple_tables", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_of_nowait", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_of_skip_locked", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_skip_locked", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_skip_locked_and_of", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_or", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_where", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_where_not", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_where_two_not", + "pypika/tests/test_selects.py::WhereTests::test_where_field_is_n_chars_long", + "pypika/tests/test_selects.py::WhereTests::test_where_field_is_not_n_chars_long", + "pypika/tests/test_selects.py::WhereTests::test_where_field_matches_regex", + "pypika/tests/test_selects.py::WhereTests::test_where_field_matches_regexp", + "pypika/tests/test_selects.py::WhereTests::test_where_field_matches_rlike", + "pypika/tests/test_selects.py::WhereTests::test_where_field_starts_with", + "pypika/tests/test_selects.py::WhereTests::test_where_nested_conditions", + "pypika/tests/test_selects.py::WhereTests::test_where_single_quote", + "pypika/tests/test_selects.py::WhereTests::test_where_with_multiple_wheres_using_and_case", + "pypika/tests/test_selects.py::WhereTests::test_where_with_multiple_wheres_using_or_case", + "pypika/tests/test_selects.py::PreWhereTests::test_ignore_empty_criterion_having", + "pypika/tests/test_selects.py::PreWhereTests::test_ignore_empty_criterion_where", + "pypika/tests/test_selects.py::PreWhereTests::test_prewhere_field_equals", + "pypika/tests/test_selects.py::PreWhereTests::test_select_with_force_index_and_where", + "pypika/tests/test_selects.py::PreWhereTests::test_where_and_prewhere", + "pypika/tests/test_selects.py::PreWhereTests::test_where_enum", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_contains", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_does_not_contain", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_does_not_end_with", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_does_not_start_with", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_ends_with", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_and", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_nowait", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_of", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_of_multiple_tables", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_of_nowait", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_of_skip_locked", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_skip_locked", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_skip_locked_and_of", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_or", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_where", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_where_not", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_where_two_not", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_is_n_chars_long", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_is_not_n_chars_long", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_matches_regex", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_matches_regexp", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_matches_rlike", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_starts_with", + "pypika/tests/test_selects.py::PreWhereTests::test_where_nested_conditions", + "pypika/tests/test_selects.py::PreWhereTests::test_where_single_quote", + "pypika/tests/test_selects.py::PreWhereTests::test_where_with_multiple_wheres_using_and_case", + "pypika/tests/test_selects.py::PreWhereTests::test_where_with_multiple_wheres_using_or_case", + "pypika/tests/test_selects.py::GroupByTests::test_group_by__single_with_totals", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__alias", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__alias_platforms", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__alias_with_join", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__count_distinct", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__count_field", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__count_star", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__int", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__multi", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__multi_with_totals", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__no_alias", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__no_alias_mssql", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__no_alias_oracle", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__single", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__str", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__sum_distinct", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__sum_filter", + "pypika/tests/test_selects.py::GroupByTests::test_groupby_with_case_uses_the_alias", + "pypika/tests/test_selects.py::GroupByTests::test_mssql_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_mysql_query_uses_backtick_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_oracle_query_uses_no_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_postgres_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_redshift_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_vertica_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_having_and", + "pypika/tests/test_selects.py::HavingTests::test_having_greater_than", + "pypika/tests/test_selects.py::HavingTests::test_having_join_and_equality", + "pypika/tests/test_selects.py::HavingTests::test_mssql_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_mysql_query_uses_backtick_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_oracle_query_uses_no_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_postgres_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_redshift_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_vertica_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_alias", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_asc", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_desc", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_multi_fields", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_no_alias", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_single_field", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_single_str", + "pypika/tests/test_selects.py::AliasTests::test_arithmetic_function", + "pypika/tests/test_selects.py::AliasTests::test_case_using_as", + "pypika/tests/test_selects.py::AliasTests::test_case_using_constructor_param", + "pypika/tests/test_selects.py::AliasTests::test_function_using_as_nested", + "pypika/tests/test_selects.py::AliasTests::test_functions_using_as", + "pypika/tests/test_selects.py::AliasTests::test_functions_using_constructor_param", + "pypika/tests/test_selects.py::AliasTests::test_functions_using_constructor_param_nested", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_criterion", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_criterion_comparison", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_field_inside_case", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_groupby", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_orderby", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_where", + "pypika/tests/test_selects.py::AliasTests::test_null_value_with_alias", + "pypika/tests/test_selects.py::AliasTests::test_select__multiple_tables", + "pypika/tests/test_selects.py::AliasTests::test_table_field", + "pypika/tests/test_selects.py::AliasTests::test_table_field__multi", + "pypika/tests/test_selects.py::AliasTests::test_table_with_schema_and_alias", + "pypika/tests/test_selects.py::AliasTests::test_use_aliases_in_groupby_and_orderby", + "pypika/tests/test_selects.py::SubqueryTests::test_from_subquery_without_alias", + "pypika/tests/test_selects.py::SubqueryTests::test_join", + "pypika/tests/test_selects.py::SubqueryTests::test_join_query_with_alias", + "pypika/tests/test_selects.py::SubqueryTests::test_join_with_with", + "pypika/tests/test_selects.py::SubqueryTests::test_select_from_nested_query", + "pypika/tests/test_selects.py::SubqueryTests::test_select_from_nested_query_with_join", + "pypika/tests/test_selects.py::SubqueryTests::test_select_from_with_returning", + "pypika/tests/test_selects.py::SubqueryTests::test_select_subquery", + "pypika/tests/test_selects.py::SubqueryTests::test_select_subquery_with_alias", + "pypika/tests/test_selects.py::SubqueryTests::test_where__equality", + "pypika/tests/test_selects.py::SubqueryTests::test_where__in", + "pypika/tests/test_selects.py::SubqueryTests::test_where__in_nested", + "pypika/tests/test_selects.py::SubqueryTests::test_with", + "pypika/tests/test_selects.py::QuoteTests::test_extraneous_quotes", + "pypika/tests/test_tables.py::TableStructureTests::test_database_schema_table_attr", + "pypika/tests/test_tables.py::TableStructureTests::test_schema_table_attr", + "pypika/tests/test_tables.py::TableStructureTests::test_table_for_period_sql", + "pypika/tests/test_tables.py::TableStructureTests::test_table_for_system_time_sql", + "pypika/tests/test_tables.py::TableStructureTests::test_table_sql", + "pypika/tests/test_tables.py::TableStructureTests::test_table_with_alias", + "pypika/tests/test_tables.py::TableStructureTests::test_table_with_schema_and_schema_parent_arg", + "pypika/tests/test_tables.py::TableStructureTests::test_table_with_schema_arg", + "pypika/tests/test_tables.py::TableEqualityTests::test_many_tables_with_alias", + "pypika/tests/test_tables.py::TableEqualityTests::test_many_tables_with_or_not_alias", + "pypika/tests/test_tables.py::TableEqualityTests::test_many_tables_without_alias", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_equal_by_name", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_equal_by_schema_and_name", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_equal_by_schema_and_name_using_schema", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_equal_by_schema_and_name_using_schema_with_parent", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_not_equal_by_schema_and_name_using_schema_with_different_parents", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_not_equal_with_different_names", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_not_equal_with_different_schemas", + "pypika/tests/test_tables.py::TableDialectTests::test_make_tables_factory_with_default_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_make_tables_factory_with_dialect_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_factory_with_default_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_factory_with_dialect_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_with_bad_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_with_default_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_with_dialect_query_cls", + "pypika/tests/test_terms.py::FieldAliasTests::test_when_alias_specified", + "pypika/tests/test_terms.py::FieldInitTests::test_init_with_str_table", + "pypika/tests/test_terms.py::FieldHashingTests::test_non_tabled_aliased_eq_fields_equally_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_non_tabled_aliased_ne_fields_differently_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_non_tabled_eq_fields_equally_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_non_tabled_ne_fields_differently_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_tabled_eq_fields_equally_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_tabled_ne_fields_differently_hashed", + "pypika/tests/test_terms.py::AtTimezoneTests::test_passes_kwargs_to_field_get_sql", + "pypika/tests/test_terms.py::AtTimezoneTests::test_when_alias_specified", + "pypika/tests/test_terms.py::AtTimezoneTests::test_when_interval_not_specified", + "pypika/tests/test_terms.py::AtTimezoneTests::test_when_interval_specified", + "pypika/tests/test_tuples.py::TupleTests::test_render_alias_in_array_sql", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_equality_tuple_on_both", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_equality_tuple_on_left", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_equality_tuple_on_right", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_in_using_mixed_tuples", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_in_using_pypika_tuples", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_in_using_python_tuples", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_is_aggregate", + "pypika/tests/test_tuples.py::TupleTests::test_tuples_in_join", + "pypika/tests/test_tuples.py::ArrayTests::test_array_general", + "pypika/tests/test_tuples.py::ArrayTests::test_empty_psql_array", + "pypika/tests/test_tuples.py::ArrayTests::test_psql_array_general", + "pypika/tests/test_tuples.py::ArrayTests::test_render_alias_in_array_sql", + "pypika/tests/test_tuples.py::BracketTests::test_arithmetic_with_brackets", + "pypika/tests/test_tuples.py::BracketTests::test_arithmetic_with_brackets_and_alias", + "pypika/tests/test_updates.py::UpdateTests::test_empty_query", + "pypika/tests/test_updates.py::UpdateTests::test_for_portion", + "pypika/tests/test_updates.py::UpdateTests::test_omit_where", + "pypika/tests/test_updates.py::UpdateTests::test_single_quote_escape_in_set", + "pypika/tests/test_updates.py::UpdateTests::test_update__table_schema", + "pypika/tests/test_updates.py::UpdateTests::test_update_from", + "pypika/tests/test_updates.py::UpdateTests::test_update_from_with_where", + "pypika/tests/test_updates.py::UpdateTests::test_update_with_join", + "pypika/tests/test_updates.py::UpdateTests::test_update_with_limit", + "pypika/tests/test_updates.py::UpdateTests::test_update_with_none", + "pypika/tests/test_updates.py::UpdateTests::test_update_with_statement", + "pypika/tests/test_updates.py::PostgresUpdateTests::test_update_returning", + "pypika/tests/test_updates.py::PostgresUpdateTests::test_update_returning_from_different_tables", + "pypika/tests/test_updates.py::PostgresUpdateTests::test_update_returning_star", + "pypika/tests/test_updates.py::PostgresUpdateTests::test_update_returning_str", + "pypika/tests/test_updates.py::SQLLiteUpdateTests::test_update_with_bool", + "pypika/tests/test_utils.py::ImmutabilityTests::test_raise_attribute_error_for_deepcopy", + "pypika/tests/test_utils.py::ImmutabilityTests::test_raise_attribute_error_for_getnewargs", + "pypika/tests/test_utils.py::ImmutabilityTests::test_raise_attribute_error_for_getstate", + "pypika/tests/test_utils.py::ImmutabilityTests::test_raise_attribute_error_for_setstate" + ], + "all_git_blobs_modes_verified": true, + "cloud_launch_ready": false, + "commits": { + "bug": "26e76fefeac36a78ec4787e4a8d85276120b1285", + "healthy": "6a742f12bfa386994289ec8b75824663d8ee4b15", + "learner": "283132c4a6a6725c2a6abe522d6cf224b4e65444" + }, + "existing_squirrel_snapshot_reused": false, + "full_transfer_allowlist": [ + "/testbed/.coveragerc", + "/testbed/.gitignore", + "/testbed/.pre-commit-config.yaml", + "/testbed/CODEOWNERS", + "/testbed/CONTRIBUTING.rst", + "/testbed/LICENSE.txt", + "/testbed/MANIFEST.in", + "/testbed/Makefile", + "/testbed/README.rst", + "/testbed/docs/1_installation.rst", + "/testbed/docs/2_tutorial.rst", + "/testbed/docs/3_advanced.rst", + "/testbed/docs/4_extending.rst", + "/testbed/docs/5_reference.rst", + "/testbed/docs/6_contributing.rst", + "/testbed/docs/Makefile", + "/testbed/docs/api/pypika.analytics.rst", + "/testbed/docs/api/pypika.dialects.rst", + "/testbed/docs/api/pypika.enums.rst", + "/testbed/docs/api/pypika.functions.rst", + "/testbed/docs/api/pypika.pseudocolumns.rst", + "/testbed/docs/api/pypika.queries.rst", + "/testbed/docs/api/pypika.rst", + "/testbed/docs/api/pypika.terms.rst", + "/testbed/docs/api/pypika.utils.rst", + "/testbed/docs/conf.py", + "/testbed/docs/index.rst", + "/testbed/pypika/__init__.py", + "/testbed/pypika/analytics.py", + "/testbed/pypika/clickhouse/__init__.py", + "/testbed/pypika/clickhouse/array.py", + "/testbed/pypika/clickhouse/condition.py", + "/testbed/pypika/clickhouse/dates_and_times.py", + "/testbed/pypika/clickhouse/nullable_arg.py", + "/testbed/pypika/clickhouse/search_string.py", + "/testbed/pypika/clickhouse/type_conversion.py", + "/testbed/pypika/dialects.py", + "/testbed/pypika/enums.py", + "/testbed/pypika/functions.py", + "/testbed/pypika/pseudocolumns.py", + "/testbed/pypika/py.typed", + "/testbed/pypika/queries.py", + "/testbed/pypika/terms.py", + "/testbed/pypika/tests/__init__.py", + "/testbed/pypika/tests/clickhouse/__init__.py", + "/testbed/pypika/tests/clickhouse/test_array.py", + "/testbed/pypika/tests/clickhouse/test_condition.py", + "/testbed/pypika/tests/clickhouse/test_dates_and_times.py", + "/testbed/pypika/tests/clickhouse/test_nullable_arg.py", + "/testbed/pypika/tests/clickhouse/test_search_string.py", + "/testbed/pypika/tests/clickhouse/test_type_conversion.py", + "/testbed/pypika/tests/dialects/__init__.py", + "/testbed/pypika/tests/dialects/test_clickhouse.py", + "/testbed/pypika/tests/dialects/test_mssql.py", + "/testbed/pypika/tests/dialects/test_mysql.py", + "/testbed/pypika/tests/dialects/test_oracle.py", + "/testbed/pypika/tests/dialects/test_postgresql.py", + "/testbed/pypika/tests/dialects/test_snowflake.py", + "/testbed/pypika/tests/dialects/test_sqllite.py", + "/testbed/pypika/tests/dialects/test_vertica.py", + "/testbed/pypika/tests/test_aggregate.py", + "/testbed/pypika/tests/test_analytic_queries.py", + "/testbed/pypika/tests/test_create.py", + "/testbed/pypika/tests/test_criterions.py", + "/testbed/pypika/tests/test_custom_functions.py", + "/testbed/pypika/tests/test_data_types.py", + "/testbed/pypika/tests/test_date_math.py", + "/testbed/pypika/tests/test_deletes.py", + "/testbed/pypika/tests/test_drop.py", + "/testbed/pypika/tests/test_formats.py", + "/testbed/pypika/tests/test_functions.py", + "/testbed/pypika/tests/test_groupby_modifiers.py", + "/testbed/pypika/tests/test_immutability.py", + "/testbed/pypika/tests/test_inserts.py", + "/testbed/pypika/tests/test_internals.py", + "/testbed/pypika/tests/test_joins.py", + "/testbed/pypika/tests/test_negation.py", + "/testbed/pypika/tests/test_parameter.py", + "/testbed/pypika/tests/test_query.py", + "/testbed/pypika/tests/test_selects.py", + "/testbed/pypika/tests/test_tables.py", + "/testbed/pypika/tests/test_terms.py", + "/testbed/pypika/tests/test_tuples.py", + "/testbed/pypika/tests/test_updates.py", + "/testbed/pypika/tests/test_utils.py", + "/testbed/pypika/utils.py", + "/testbed/pyproject.toml", + "/testbed/requirements-dev.txt", + "/testbed/setup.cfg", + "/testbed/setup.py", + "/testbed/tox.ini" + ], + "healthy_stage_meaning": "Direct parent of the mutation; no source or test execution has been performed", + "mutation_matches_dataset_and_git_blobs": true, + "official_profile": { + "eval_sets": [], + "profile_class": "Pypika1c9646f0", + "profile_lines": [ + 736, + 739 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "upstream_repo": "kayak/pypika" + }, + "original_source_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "private_test_paths": [ + "pypika/tests/test_pseudocolumns.py" + ], + "private_tests_unchanged": true, + "profile_mapping_basis": "Explicit upstream repo and full commit fields parsed from pinned official Python profile AST, not basename inference", + "qwen_calibrated": false, + "runtime_qualified": false, + "source_paths": [ + "pypika/terms.py" + ], + "source_repo": "swesmith/kayak__pypika.1c9646f0", + "source_stages_bytes": 1895393, + "task_id": "kayak__pypika.1c9646f0.func_basic__00jnvt3b", + "transfer_limitation": "Existing regular files only; new arbitrary file additions need a qualified patch adapter", + "upstream_repo": "kayak/pypika" + }, + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:kayak__pypika.1c9646f0.func_basic__00jnvt3b", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "6a742f12bfa386994289ec8b75824663d8ee4b15", + "instruction_sha256": "1929b798f90257eb0f895e3d55966c88625eb21ee5c58f9e78aed383a5421bbb", + "is_fork": true, + "learner_path": "tasks/14d0edf46691002bf37e013b/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "actual_upstream_url": "https://raw.githubusercontent.com/kayak/pypika/1c9646f0a019a167c32b649b6f5e6423c5ba2c9b/LICENSE.txt", + "reviewed": true, + "sha256": "c5accbbd8546e94c34aed24afe689a617627d18eed5a6c48277e48db57c23851", + "spdx": "Apache-2.0", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/kayak__pypika.1c9646f0/283132c4a6a6725c2a6abe522d6cf224b4e65444/LICENSE.txt" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "patch_sha256": "476b7d4e0c89673732154abd96dc7714a5a7ddd8ef21f0e356b68229582f3e41", + "provenance_path": "tasks/14d0edf46691002bf37e013b/source-proof.json", + "repository_lineage": [ + "swesmith/kayak__pypika.1c9646f0", + "kayak/pypika" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "283132c4a6a6725c2a6abe522d6cf224b4e65444", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "26e76fefeac36a78ec4787e4a8d85276120b1285", + "source_kind": "mutation", + "source_repo": "swesmith/kayak__pypika.1c9646f0", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "kayak__pypika.1c9646f0.func_basic__00jnvt3b", + "task_sha256": "bc004eb41a3c1352eb7cfd832c96a9f9510a1beaf9962e84f4cf51155be01a54", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "kayak/pypika", + "usage": "quarantine_only" + }, + "task_kind": "original-source-mutation" +} diff --git a/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/provenance.json b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/provenance.json new file mode 100644 index 0000000000000000000000000000000000000000..d367f154c61361621f5a5cb97f4c15d5eb3abdbc --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/provenance.json @@ -0,0 +1,88 @@ +{ + "generated_reference": false, + "healthy_reference_delta_sha256": "dca0fb6f423013f0d5290d14e3a043ec7290e8cefeafc4ba15924ad1fa6c4cb3", + "native_pytest_ids_preserved": true, + "original_source_code_license": { + "actual_upstream_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "actual_upstream_url": "https://raw.githubusercontent.com/kayak/pypika/1c9646f0a019a167c32b649b6f5e6423c5ba2c9b/LICENSE.txt", + "reviewed": true, + "sha256": "c5accbbd8546e94c34aed24afe689a617627d18eed5a6c48277e48db57c23851", + "spdx": "Apache-2.0", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/kayak__pypika.1c9646f0/283132c4a6a6725c2a6abe522d6cf224b4e65444/LICENSE.txt" + }, + "provided_reference": true, + "qwen_calibrated": false, + "runtime_qualified": false, + "source_completion_sha256": "bb979fc97b5e6324a10fb87fb3139ea48169462817b4b97eda5aa487090fb83d", + "source_index_sha256": "e856874b9410fce9f3bfea52c8c482e84b3e43942d87517f8b55f0034bd40f6f", + "source_proof_sha256": "2324d1b1523ff5de3bb98e98306604431869229ad3245812c57c3b0dc0075623", + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:kayak__pypika.1c9646f0.func_basic__00jnvt3b", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "6a742f12bfa386994289ec8b75824663d8ee4b15", + "instruction_sha256": "1929b798f90257eb0f895e3d55966c88625eb21ee5c58f9e78aed383a5421bbb", + "is_fork": true, + "learner_path": "tasks/14d0edf46691002bf37e013b/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "actual_upstream_url": "https://raw.githubusercontent.com/kayak/pypika/1c9646f0a019a167c32b649b6f5e6423c5ba2c9b/LICENSE.txt", + "reviewed": true, + "sha256": "c5accbbd8546e94c34aed24afe689a617627d18eed5a6c48277e48db57c23851", + "spdx": "Apache-2.0", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/kayak__pypika.1c9646f0/283132c4a6a6725c2a6abe522d6cf224b4e65444/LICENSE.txt" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "1c9646f0a019a167c32b649b6f5e6423c5ba2c9b", + "patch_sha256": "476b7d4e0c89673732154abd96dc7714a5a7ddd8ef21f0e356b68229582f3e41", + "provenance_path": "tasks/14d0edf46691002bf37e013b/source-proof.json", + "repository_lineage": [ + "swesmith/kayak__pypika.1c9646f0", + "kayak/pypika" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "283132c4a6a6725c2a6abe522d6cf224b4e65444", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "26e76fefeac36a78ec4787e4a8d85276120b1285", + "source_kind": "mutation", + "source_repo": "swesmith/kayak__pypika.1c9646f0", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "kayak__pypika.1c9646f0.func_basic__00jnvt3b", + "task_sha256": "bc004eb41a3c1352eb7cfd832c96a9f9510a1beaf9962e84f4cf51155be01a54", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "kayak/pypika", + "usage": "quarantine_only" + }, + "task_bundle_license": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + }, + "training_admissible": false, + "trusted_tests_sha256": "f2d0a1b335176a755d627907f32ef330383cf624ff3af2c5ea84ba2b6a2d7ebb" +} diff --git a/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/provided-gold.diff b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/provided-gold.diff new file mode 100644 index 0000000000000000000000000000000000000000..6a77f790132fe64a497de9634cc199b6e4b2a7a4 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/provided-gold.diff @@ -0,0 +1,15 @@ +diff --git a/pypika/terms.py b/pypika/terms.py +index cf30c687619e821097a694caa28fed9e6d614581..a277e1a5ce6c58229fabc38cfd6d8f8d15af7cb1 100644 +--- a/pypika/terms.py ++++ b/pypika/terms.py +@@ -1740,8 +1740,8 @@ + """ + + def __init__(self, name: str) -> None: +- super().__init__(alias=name) +- self.name = None ++ super().__init__(alias=None) ++ self.name = name + + def get_sql(self, **kwargs: Any) -> str: + return self.name diff --git a/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/solution/solve.sh b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..ee70a21f4dc70b3b493c50eb58a57464b436fb4d --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/solution/solve.sh @@ -0,0 +1,21 @@ +#!/bin/bash +set -Eeuo pipefail +cd /testbed/repo +cat > /tmp/openenv-reference.diff <<'OPENENV_REFERENCE' +diff --git a/pypika/terms.py b/pypika/terms.py +index cf30c687619e821097a694caa28fed9e6d614581..a277e1a5ce6c58229fabc38cfd6d8f8d15af7cb1 100644 +--- a/pypika/terms.py ++++ b/pypika/terms.py +@@ -1740,8 +1740,8 @@ + """ + + def __init__(self, name: str) -> None: +- super().__init__(alias=name) +- self.name = None ++ super().__init__(alias=None) ++ self.name = name + + def get_sql(self, **kwargs: Any) -> str: + return self.name +OPENENV_REFERENCE +/usr/bin/git -c core.hooksPath=/dev/null -c core.fsmonitor=false apply --whitespace=nowarn /tmp/openenv-reference.diff diff --git a/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/task.toml b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..22200ba06d4364f107efd6630c7829e15e808e82 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/task.toml @@ -0,0 +1,24 @@ +version = "1.0" + +[agent] +timeout_sec = 1800.0 + +[verifier] +timeout_sec = 900.0 + +[environment] +docker_image = "ghcr.io/younesbelkada/scale800@sha256:e65abb94c730f86f71bf1fdc6ff52143087cea2c368298bfbf16dddd0b7e2abe" +build_timeout_sec = 600.0 +cpus = 2 +memory_mb = 8192 +storage_mb = 16384 + +[metadata] +author_name = "SWE-smith source adapter" +category = "bugfix" +tags = ["swe", "python", "mutation-repair"] + +[environment.env] +# The image's PATH with the testbed env first: the project and pytest are installed there, and the agent's +# non-interactive shells never run `conda activate` +PATH = "/opt/miniconda3/envs/testbed/bin:/opt/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" diff --git a/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/check_pytest.py b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/check_pytest.py new file mode 100644 index 0000000000000000000000000000000000000000..7abfdc5972f57ca7f0cecbbeeb373414670f780e --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/check_pytest.py @@ -0,0 +1,177 @@ +"""Preserve confirmed requested assertion failures; keep positive checks strict.""" + +import argparse +import hashlib +import json +import re +import xml.etree.ElementTree as ET +from pathlib import Path + +GROUPS = ("pass-to-pass", "fail-to-pass") + + +def split_nodeid(target): + prefix, bracket, parameter = target.partition("[") + parts = prefix.split("::") + if bracket: + parts[-1] += bracket + parameter + return parts + + +def matches(case, target): + parts = split_nodeid(target) + module = parts[0].removesuffix(".py").replace("/", ".") + classname, name = case.get("classname", ""), case.get("name", "") + if not (classname == module or classname.startswith(module + ".")): + return False + selector = parts[-1] if len(parts) > 1 else "" + classes = parts[1:-1] + if classes and classname != module + "." + ".".join(classes): + return False + return ( + not selector + or name == selector + or ("[" not in selector and name.startswith(selector + "[")) + ) + + +def capture_panels(root): + panels, digests = {}, {} + for group in GROUPS: + path = Path(root) / (group + ".xml") + if not path.exists(): + panels[group] = None + continue + with path.open("rb") as stream: + raw = stream.read(4 * 1024**2 + 1) + if not 0 < len(raw) <= 4 * 1024**2 or re.search( + rb" 20000: + raise ValueError("Too many pytest cases") + identities = [(case.get("classname"), case.get("name")) for case in cases] + if len(identities) != len(set(identities)): + raise ValueError("Duplicate pytest case evidence") + panels[group] = cases + digests[group] = hashlib.sha256(raw).hexdigest() + return panels, digests + + +def strict_assess(panels, expected, native_exit): + """The original positive-approval conditions, applied to captured cases.""" + all_cases, actual_failure = [], False + for group in GROUPS: + cases = panels[group] + if cases is None: + if actual_failure: + continue + raise ValueError("Missing preceding pytest panel") + if actual_failure: + raise ValueError( + "Pytest evidence continued after the native stop-on-failure" + ) + targets = expected[group] + if any(not any(matches(case, target) for target in targets) for case in cases): + raise ValueError("Unexpected pytest case") + all_cases.extend(cases) + failures = [case for case in cases if case.find("failure") is not None] + if any( + case.find("error") is not None or case.find("skipped") is not None + for case in cases + ): + raise ValueError("Pytest collection/error/skip is not a completed panel") + actual_failure = actual_failure or bool(failures) + if not failures and any( + not any(matches(case, target) for case in cases) for target in targets + ): + raise ValueError("Declared pytest target never ran") + if actual_failure: + if native_exit == 0: + raise ValueError("Native verifier exit disagrees with pytest failure") + return {"reward": 0, "valid_test_failure": True, "cases": len(all_cases)} + if native_exit != 0: + raise ValueError("Setup or native verifier failed without a real test failure") + if any(panels[group] is None for group in GROUPS): + raise ValueError("Missing completed pytest panel") + return {"reward": 1, "valid_test_failure": False, "cases": len(all_cases)} + + +def assess(root, expected, native_exit): + if type(native_exit) is not int: + raise ValueError("Native verifier exit must be an integer") + if not isinstance(expected, dict) or any( + not isinstance(expected.get(group), list) + or not expected[group] + or any(not isinstance(target, str) or not target for target in expected[group]) + for group in GROUPS + ): + raise ValueError("Complete exact native pytest targets required") + panels, digests = capture_panels(root) + counts = { + "cases": 0, + "matched_failures": 0, + "unexpected_cases": 0, + "unmatched_failures": 0, + "skipped_cases": 0, + "error_cases": 0, + "missing_panels": 0, + "missing_targets": 0, + } + for group in GROUPS: + cases = panels[group] + if cases is None: + counts["missing_panels"] += 1 + counts["missing_targets"] += len(expected[group]) + continue + counts["cases"] += len(cases) + for case in cases: + requested = any(matches(case, target) for target in expected[group]) + failure = case.find("failure") is not None + counts["matched_failures"] += int(requested and failure) + counts["unmatched_failures"] += int(not requested and failure) + counts["unexpected_cases"] += int(not requested) + counts["skipped_cases"] += int(case.find("skipped") is not None) + counts["error_cases"] += int(case.find("error") is not None) + counts["missing_targets"] += sum( + not any(matches(case, target) for case in cases) + for target in expected[group] + ) + if counts["matched_failures"]: + if native_exit == 0: + raise ValueError( + "Native verifier exit disagrees with requested pytest failure" + ) + return { + "reward": 0, + "valid_test_failure": True, + "cases": counts["cases"], + "diagnostic_counts": counts, + "panel_sha256": digests, + "decision": "confirmed_requested_failure_precedence", + } + result = strict_assess(panels, expected, native_exit) + result.update(diagnostic_counts=counts, panel_sha256=digests) + return result + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("--root", required=True) + parser.add_argument("--expected", required=True) + parser.add_argument("--native-exit", type=int, required=True) + args = parser.parse_args() + result = assess( + args.root, json.loads(Path(args.expected).read_bytes()), args.native_exit + ) + reward = Path(args.root) / "reward.txt" + if reward.read_text().strip() != str(result["reward"]): + raise ValueError("Native raw reward disagrees with pytest evidence") + (Path(args.root) / "pytest-evidence.json").write_text( + json.dumps(result, sort_keys=True) + "\n" + ) diff --git a/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/expected-panels.json b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/expected-panels.json new file mode 100644 index 0000000000000000000000000000000000000000..c8132dc027552e87b5ac4a41573165dd50b49713 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/expected-panels.json @@ -0,0 +1,1067 @@ +{ + "fail-to-pass": [ + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_can_be_used_in_a_select_statement", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_can_be_used_in_a_where_clause", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_can_be_used_in_orderby" + ], + "pass-to-pass": [ + "pypika/tests/clickhouse/test_array.py::TestArray::test_get_sql_0__ridley_scott_jimi_hendrix_", + "pypika/tests/clickhouse/test_array.py::TestArray::test_get_sql_1__1_2_3_4_", + "pypika/tests/clickhouse/test_array.py::TestArray::test_get_sql_2__toInt64_1_toInt64_2_toInt64_3_toInt64_4_", + "pypika/tests/clickhouse/test_array.py::TestArray::test_get_sql_3__toFixedString_mogwai_10_toFixedString_mono_10_toFixedString_bonobo_10_arr", + "pypika/tests/clickhouse/test_array.py::TestHasAny::test_get_sql_0_hasAny_mental_abilities_physical_abilities_", + "pypika/tests/clickhouse/test_array.py::TestHasAny::test_get_sql_1_hasAny_1_2_3_4_3_", + "pypika/tests/clickhouse/test_array.py::TestHasAny::test_get_sql_2_hasAny_bands_toFixedString_port_royal_20_toFixedString_hammock_20_", + "pypika/tests/clickhouse/test_array.py::TestLength::test_get_sql_0_length_tags_", + "pypika/tests/clickhouse/test_array.py::TestLength::test_get_sql_1_length_1_2_3_", + "pypika/tests/clickhouse/test_array.py::TestEmpty::test_get_sql_0_empty_tags_", + "pypika/tests/clickhouse/test_array.py::TestEmpty::test_get_sql_1_empty_1_2_3_", + "pypika/tests/clickhouse/test_array.py::TestNotEmpty::test_get_sql_0_notEmpty_tags_", + "pypika/tests/clickhouse/test_array.py::TestNotEmpty::test_get_sql_1_notEmpty_1_2_3_", + "pypika/tests/clickhouse/test_condition.py::TestIfCondition::test_get_sql_0", + "pypika/tests/clickhouse/test_condition.py::TestIfCondition::test_get_sql_1", + "pypika/tests/clickhouse/test_condition.py::TestMultiIfCondition::test_get_sql_0", + "pypika/tests/clickhouse/test_condition.py::TestMultiIfCondition::test_get_sql_1", + "pypika/tests/clickhouse/test_dates_and_times.py::TestFormatDateTime::test_get_sql_0", + "pypika/tests/clickhouse/test_dates_and_times.py::TestFormatDateTime::test_get_sql_1", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_00", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_01", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_02", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_03", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_04", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_05", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_06", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_07", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_08", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_09", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_10", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_11", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_12", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_13", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_14", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_15", + "pypika/tests/clickhouse/test_dates_and_times.py::TestAddSubtractDt::test_get_sql_16", + "pypika/tests/clickhouse/test_dates_and_times.py::TestToYYYYMM::test_get_sql", + "pypika/tests/clickhouse/test_nullable_arg.py::TestSearchString::test_get_sql_0", + "pypika/tests/clickhouse/test_nullable_arg.py::TestSearchString::test_get_sql_1", + "pypika/tests/clickhouse/test_search_string.py::TestSearchString::test_search_string_0", + "pypika/tests/clickhouse/test_search_string.py::TestSearchString::test_search_string_1", + "pypika/tests/clickhouse/test_search_string.py::TestSearchString::test_search_string_2", + "pypika/tests/clickhouse/test_search_string.py::TestMultiSearch::test_multi_search_string_0", + "pypika/tests/clickhouse/test_search_string.py::TestMultiSearch::test_multi_search_string_1", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_00_toString_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_01_toInt8_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_02_toInt16_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_03_toInt32_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_04_toInt64_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_05_toUInt8_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_06_toUInt16_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_07_toUInt32_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_08_toUInt64_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_09_toFloat32_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_10_toFloat64_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_11_toFloat64_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_12_toDate_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_13_toDateTime_field_name_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_field_14_toFixedString_field_name_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_00_toString_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_01_toInt8_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_02_toInt16_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_03_toInt32_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_04_toInt64_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_05_toUInt8_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_06_toUInt16_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_07_toUInt32_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_08_toUInt64_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_09_toFloat32_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_10_toFloat64_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_11_toFloat64_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_12_toDate_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_13_toDateTime_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestBasicTypeConverters::test_basic_types_value_14_toFixedString_100_100_", + "pypika/tests/clickhouse/test_type_conversion.py::TestToFixedString::test_get_sql_with_table", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseQueryTests::test_use_AS_keyword_for_alias", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseQueryTests::test_use_FINAL_keyword", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseQueryTests::test_use_SAMPLE_keyword", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseQueryTests::test_use_SAMPLE_with_offset_keyword", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDeleteTests::test_omit_where", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDeleteTests::test_omit_where__table_schema", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDeleteTests::test_where_field_equals", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseUpdateTests::test_update", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDropQuery::test_drop_database", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDropQuery::test_drop_dictionary", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDropQuery::test_drop_other", + "pypika/tests/dialects/test_clickhouse.py::ClickHouseDropQuery::test_drop_table", + "pypika/tests/dialects/test_clickhouse.py::DistinctOnTests::test_distinct_on", + "pypika/tests/dialects/test_clickhouse.py::LimitByTests::test_limit_by", + "pypika/tests/dialects/test_clickhouse.py::LimitByTests::test_limit_offset0_by", + "pypika/tests/dialects/test_clickhouse.py::LimitByTests::test_limit_offset_by", + "pypika/tests/dialects/test_clickhouse.py::LimitByTests::test_rename_table", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_distinct_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_groupby_alias_False_does_not_group_by_alias_when_subqueries_are_present", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_groupby_alias_False_does_not_group_by_alias_with_standard_query", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_limit", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_limit_with_offset", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_normal_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_offset", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_distinct_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_percent_invalid_range", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_percent_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_select", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_select_non_int", + "pypika/tests/dialects/test_mssql.py::SelectTests::test_top_with_ties_select", + "pypika/tests/dialects/test_mysql.py::SelectTests::test_distinct_select", + "pypika/tests/dialects/test_mysql.py::SelectTests::test_modifier_select", + "pypika/tests/dialects/test_mysql.py::SelectTests::test_multiple_modifier_select", + "pypika/tests/dialects/test_mysql.py::SelectTests::test_normal_select", + "pypika/tests/dialects/test_mysql.py::UpdateTests::test_conflict_handlers_update", + "pypika/tests/dialects/test_mysql.py::UpdateTests::test_on_duplicate_key_ignore_update", + "pypika/tests/dialects/test_mysql.py::UpdateTests::test_on_duplicate_key_update_update", + "pypika/tests/dialects/test_mysql.py::UpdateTests::test_update", + "pypika/tests/dialects/test_mysql.py::LoadCSVTests::test_load_from_file", + "pypika/tests/dialects/test_mysql.py::TableTests::test_create_table", + "pypika/tests/dialects/test_mysql.py::TableTests::test_drop_table", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_fetch_next_method_deprecated", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_groupby_alias_False_does_not_group_by_alias_when_subqueries_are_present", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_groupby_alias_False_does_not_group_by_alias_with_standard_query", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_limit_offset_query", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_limit_query", + "pypika/tests/dialects/test_oracle.py::SelectTests::test_offset_query", + "pypika/tests/dialects/test_postgresql.py::InsertTests::test_array_keyword", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_alias_set_correctly", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_json_value_from_array_num", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_json_value_from_array_str", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_json_value_from_dict", + "pypika/tests/dialects/test_postgresql.py::JSONObjectTests::test_json_value_from_dict_recursive", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_json_value_by_index", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_json_value_by_key", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_path_json_value", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_path_text_value", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_text_value_by_index", + "pypika/tests/dialects/test_postgresql.py::JSONOperatorsTests::test_get_text_value_by_key", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contained_by_using_list_arg", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contained_by_using_str_arg", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contained_by_with_complex_criterion", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contains_for_field", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_contains_for_json", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_has_any_keys", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_has_key", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_json_has_keys", + "pypika/tests/dialects/test_postgresql.py::JSONBOperatorsTests::test_subnet_contains_inet", + "pypika/tests/dialects/test_postgresql.py::DistinctOnTests::test_distinct_on", + "pypika/tests/dialects/test_postgresql.py::ArrayTests::test_array_syntax", + "pypika/tests/dialects/test_postgresql.py::ArrayTests::test_render_alias_in_array_sql", + "pypika/tests/dialects/test_postgresql.py::ReturningClauseTests::test_no_queryexception_if_returning_used_on_valid_query_type", + "pypika/tests/dialects/test_postgresql.py::ReturningClauseTests::test_queryexception_if_returning_used_on_invalid_query", + "pypika/tests/dialects/test_postgresql.py::ReturningClauseTests::test_return_field_from_join_table", + "pypika/tests/dialects/test_postgresql.py::ReturningClauseTests::test_returning_from_missing_table_raises_queryexception", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_dont_use_double_quotes_on_create_queries", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_dont_use_double_quotes_on_drop_queries", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_dont_use_double_quotes_on_joining_queries", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_use_double_quotes_on_alias_but_not_on_terms", + "pypika/tests/dialects/test_snowflake.py::QuoteTests::test_use_double_quotes_on_alias_but_not_on_terms_with_joins", + "pypika/tests/dialects/test_sqllite.py::SelectTests::test_bool_false_as_zero", + "pypika/tests/dialects/test_sqllite.py::SelectTests::test_bool_true_as_one", + "pypika/tests/dialects/test_sqllite.py::ReplaceTests::test_insert_or_replace", + "pypika/tests/dialects/test_sqllite.py::ReplaceTests::test_normal_replace", + "pypika/tests/dialects/test_sqllite.py::ReplaceTests::test_replace_subquery", + "pypika/tests/dialects/test_vertica.py::VerticaQueryTests::test_delete_query_with_hint", + "pypika/tests/dialects/test_vertica.py::VerticaQueryTests::test_insert_query_with_hint", + "pypika/tests/dialects/test_vertica.py::VerticaQueryTests::test_select_query_with_hint", + "pypika/tests/dialects/test_vertica.py::VerticaQueryTests::test_update_query_with_hint", + "pypika/tests/dialects/test_vertica.py::CopyCSVTests::test_copy_from_file", + "pypika/tests/dialects/test_vertica.py::CreateTemporaryTableTests::test_create_local_table_without_temporary_raises_error", + "pypika/tests/dialects/test_vertica.py::CreateTemporaryTableTests::test_create_local_temporary_table", + "pypika/tests/dialects/test_vertica.py::CreateTemporaryTableTests::test_create_table_preserve_rows_without_temporary_raises_error", + "pypika/tests/dialects/test_vertica.py::CreateTemporaryTableTests::test_create_temporary_table_preserve_rows", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__agg_case_criterion_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__agg_case_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__agg_func_arithmetic_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__agg_func_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__case_mixed_constant_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__case_mixed_else_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__case_with_field_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__case_with_single_aggregate_field_in_one_criterion_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__constant_arithmetic_is_aggregate_none", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__constant_is_aggregate_none", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__field_arithmetic_constant_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__field_arithmetic_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__field_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__func_arithmetic_constant_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__mixed_case_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__mixed_func_arithmetic_is_not_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__negative_agg_func_is_aggregate", + "pypika/tests/test_aggregate.py::IsAggregateTests::test__non_aggregate_function_with_aggregated_arg", + "pypika/tests/test_aggregate.py::IsAggregateTests::test_complicated", + "pypika/tests/test_analytic_queries.py::RankTests::test_avg", + "pypika/tests/test_analytic_queries.py::RankTests::test_count_range_between_unbounded_preceeding_current_row", + "pypika/tests/test_analytic_queries.py::RankTests::test_dense_rank", + "pypika/tests/test_analytic_queries.py::RankTests::test_empty_over", + "pypika/tests/test_analytic_queries.py::RankTests::test_filter", + "pypika/tests/test_analytic_queries.py::RankTests::test_filter_quote_table_in_filter", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value_ignore_nulls", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value_ignore_nulls_first", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value_multi_argument", + "pypika/tests/test_analytic_queries.py::RankTests::test_first_value_range_between_x_preceeding_unbounded_following", + "pypika/tests/test_analytic_queries.py::RankTests::test_lag_generates_correct_sql", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value_ignore_nulls", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value_multi_argument", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value_rows_between_current_row_unbounded_following", + "pypika/tests/test_analytic_queries.py::RankTests::test_last_value_rows_between_current_row_unbounded_following_ignore_nulls", + "pypika/tests/test_analytic_queries.py::RankTests::test_lead_generates_correct_sql", + "pypika/tests/test_analytic_queries.py::RankTests::test_max_range_x_preceeding", + "pypika/tests/test_analytic_queries.py::RankTests::test_max_rows_x_preceeding", + "pypika/tests/test_analytic_queries.py::RankTests::test_median", + "pypika/tests/test_analytic_queries.py::RankTests::test_min_range_current_row", + "pypika/tests/test_analytic_queries.py::RankTests::test_min_rows_current_row", + "pypika/tests/test_analytic_queries.py::RankTests::test_multiple_partitions", + "pypika/tests/test_analytic_queries.py::RankTests::test_ntile_no_partition_or_order_invalid_sql", + "pypika/tests/test_analytic_queries.py::RankTests::test_ntile_with_order", + "pypika/tests/test_analytic_queries.py::RankTests::test_ntile_with_partition", + "pypika/tests/test_analytic_queries.py::RankTests::test_ntile_with_partition_and_order", + "pypika/tests/test_analytic_queries.py::RankTests::test_orderby_asc", + "pypika/tests/test_analytic_queries.py::RankTests::test_orderby_desc", + "pypika/tests/test_analytic_queries.py::RankTests::test_range_called_twice_raises_attribute_error", + "pypika/tests/test_analytic_queries.py::RankTests::test_range_then_rows_raises_attribute_error", + "pypika/tests/test_analytic_queries.py::RankTests::test_rank", + "pypika/tests/test_analytic_queries.py::RankTests::test_rank_with_alias", + "pypika/tests/test_analytic_queries.py::RankTests::test_row_number", + "pypika/tests/test_analytic_queries.py::RankTests::test_rows_called_twice_raises_attribute_error", + "pypika/tests/test_analytic_queries.py::RankTests::test_rows_then_range_raises_attribute_error", + "pypika/tests/test_analytic_queries.py::RankTests::test_stddev", + "pypika/tests/test_analytic_queries.py::RankTests::test_stddev_pop", + "pypika/tests/test_analytic_queries.py::RankTests::test_stddev_samp", + "pypika/tests/test_analytic_queries.py::RankTests::test_sum_rows_unbounded_preceeding", + "pypika/tests/test_analytic_queries.py::RankTests::test_table_prefixes_used_in_analytic_functions", + "pypika/tests/test_analytic_queries.py::RankTests::test_var_pop", + "pypika/tests/test_analytic_queries.py::RankTests::test_var_samp", + "pypika/tests/test_analytic_queries.py::RankTests::test_variance", + "pypika/tests/test_analytic_queries.py::RankTests::test_variance_rows_between_unbounded_preceeding_unbounded_following", + "pypika/tests/test_analytic_queries.py::RankTests::test_varpop_range_unbounded_preceeding", + "pypika/tests/test_analytic_queries.py::RankTests::test_varpop_rows_between_unbounded_preceeding_x_following", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_as_select_not_query_raises_error", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_with_columns", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_with_select", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_with_select_and_columns_fails", + "pypika/tests/test_create.py::CreateTableTests::test_create_table_without_columns_or_select_empty", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_if_not_exists", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_simple", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_unique", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_where", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_without_columns_raises_error", + "pypika/tests/test_create.py::CreateIndexTests::test_create_index_without_table_raises_error", + "pypika/tests/test_criterions.py::CriterionTests::test__bitwise_and_in_where_clause", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_bitwise_and", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_bitwise_and_with_alias", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_bool", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_decimal", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_eq_str", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gt_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gt_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gt_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gt_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gte_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gte_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gte_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_gte_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_is_null", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_is_null_with_alias", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lt_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lt_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lt_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lt_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lte_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lte_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lte_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_lte_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_date", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_datetime", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_number", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_right", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_ne_str", + "pypika/tests/test_criterions.py::CriterionTests::test__criterion_with_alias", + "pypika/tests/test_criterions.py::NotTests::test_chained_function", + "pypika/tests/test_criterions.py::NotTests::test_is_not_null", + "pypika/tests/test_criterions.py::NotTests::test_negate", + "pypika/tests/test_criterions.py::NotTests::test_not_null", + "pypika/tests/test_criterions.py::NotTests::test_not_null_with_alias", + "pypika/tests/test_criterions.py::NotTests::test_not_with_and_criterion", + "pypika/tests/test_criterions.py::NotTests::test_not_with_complex_criterion", + "pypika/tests/test_criterions.py::NotTests::test_not_with_or_criterion", + "pypika/tests/test_criterions.py::NotTests::test_notnullcriterion_replace_table", + "pypika/tests/test_criterions.py::NotTests::test_variable_access", + "pypika/tests/test_criterions.py::BetweenTests::test__between_date", + "pypika/tests/test_criterions.py::BetweenTests::test__between_datetime", + "pypika/tests/test_criterions.py::BetweenTests::test__between_number", + "pypika/tests/test_criterions.py::BetweenTests::test__between_with_alias", + "pypika/tests/test_criterions.py::BetweenTests::test__function_between", + "pypika/tests/test_criterions.py::BetweenTests::test_get_item_only_works_with_slice", + "pypika/tests/test_criterions.py::IsInTests::test__function_isin", + "pypika/tests/test_criterions.py::IsInTests::test__in_character", + "pypika/tests/test_criterions.py::IsInTests::test__in_date", + "pypika/tests/test_criterions.py::IsInTests::test__in_datetime", + "pypika/tests/test_criterions.py::IsInTests::test__in_number", + "pypika/tests/test_criterions.py::IsInTests::test__in_number_with_alias", + "pypika/tests/test_criterions.py::IsInTests::test__in_unicode", + "pypika/tests/test_criterions.py::ArithmeticExpressionTests::test__lshift", + "pypika/tests/test_criterions.py::ArithmeticExpressionTests::test__rshift", + "pypika/tests/test_criterions.py::NotInTests::test__function_notin", + "pypika/tests/test_criterions.py::NotInTests::test__notin_character", + "pypika/tests/test_criterions.py::NotInTests::test__notin_date", + "pypika/tests/test_criterions.py::NotInTests::test__notin_datetime", + "pypika/tests/test_criterions.py::NotInTests::test__notin_number", + "pypika/tests/test_criterions.py::NotInTests::test__notin_number_with_alias", + "pypika/tests/test_criterions.py::LikeTests::test_glob_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_contains", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_ends_with", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_n_chars_long", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_ilike_starts_with", + "pypika/tests/test_criterions.py::LikeTests::test_like_contains", + "pypika/tests/test_criterions.py::LikeTests::test_like_ends_with", + "pypika/tests/test_criterions.py::LikeTests::test_like_n_chars_long", + "pypika/tests/test_criterions.py::LikeTests::test_like_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_like_starts_with", + "pypika/tests/test_criterions.py::LikeTests::test_not_ilike_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_not_like_single_chars_and_various_chars", + "pypika/tests/test_criterions.py::LikeTests::test_rlike_escape_chars", + "pypika/tests/test_criterions.py::ExistsCriterionTests::test_exists", + "pypika/tests/test_criterions.py::ExistsCriterionTests::test_not_exists", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__between_and_field", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__between_and_isin", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__nested__and", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__nested__mixed", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test__nested__or", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_and", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_function_and", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_function_or", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_function_xor", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_or", + "pypika/tests/test_criterions.py::ComplexCriterionTests::test_xor", + "pypika/tests/test_criterions.py::FieldsAsCriterionTests::test__field_and_field", + "pypika/tests/test_criterions.py::FieldsAsCriterionTests::test__field_or_field", + "pypika/tests/test_criterions.py::FieldsAsCriterionTests::test__field_xor_field", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_arithmeticfunction_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_betweencriterion_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_complexcriterion_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_criterion_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_field_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_function_with_only_fields_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_function_with_values_and_fields_replace_table", + "pypika/tests/test_criterions.py::CriterionOperationsTests::test_nullcriterion_replace_table", + "pypika/tests/test_criterions.py::AnyTests::test_multiple_args_returned_in_chain_of_ors", + "pypika/tests/test_criterions.py::AnyTests::test_single_arg_returns_self", + "pypika/tests/test_criterions.py::AnyTests::test_with_generator", + "pypika/tests/test_criterions.py::AnyTests::test_zero_args_returns_empty_criterion", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_different_operations_with_empty_criterion", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_empty_criterion_on_the_left", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_empty_criterion_on_the_right", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_fields_", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_invertion_of_the_empty_criterion", + "pypika/tests/test_criterions.py::EmptyCriterionTests::test_more_than_one_empty_criterions", + "pypika/tests/test_criterions.py::AllTests::test_multiple_args_returned_in_chain_of_ors", + "pypika/tests/test_criterions.py::AllTests::test_single_arg_returns_self", + "pypika/tests/test_criterions.py::AllTests::test_with_generator", + "pypika/tests/test_criterions.py::AllTests::test_zero_args_returns_empty_criterion", + "pypika/tests/test_custom_functions.py::TestUnitCustomFunction::test_should_fail_with_wrong_arguments", + "pypika/tests/test_custom_functions.py::TestUnitCustomFunction::test_should_return_function_with_arguments", + "pypika/tests/test_custom_functions.py::TestUnitCustomFunction::test_should_return_function_with_no_arguments", + "pypika/tests/test_custom_functions.py::TestFunctionalCustomFunction::test_should_fail_use_custom_function_on_select_with_wrong_arguments", + "pypika/tests/test_custom_functions.py::TestFunctionalCustomFunction::test_should_use_custom_function_on_select", + "pypika/tests/test_data_types.py::StringTests::test_inline_string_concatentation", + "pypika/tests/test_data_types.py::UuidTests::test_uuid_string_generation", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_day", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_default", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_microsecond", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_minute", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_month", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_quarter", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_second", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_week", + "pypika/tests/test_date_math.py::AddIntervalTests::test_add_year", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_day_hour", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_day_microsecond", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_day_minute", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_day_second", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_hour_microsecond", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_hour_minute", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_hour_second", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_minute_microsecond", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_minute_second", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_second_microsecond", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_value_complex_expressions", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_value_right", + "pypika/tests/test_date_math.py::AddIntervalMultipleUnitsTests::test_add_year_month", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_mysql_dialect_uses_single_quotes_around_expression_in_an_interval", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_oracle_dialect_uses_single_quotes_around_expression_in_an_interval", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_postgresql_dialect_uses_single_quotes_around_interval", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_redshift_dialect_uses_single_quotes_around_interval", + "pypika/tests/test_date_math.py::DialectIntervalTests::test_vertica_dialect_uses_single_quotes_around_interval", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_day", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_month", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_week", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_year", + "pypika/tests/test_date_math.py::TestNegativeIntervals::test_year_month", + "pypika/tests/test_date_math.py::TruncateTrailingZerosTests::test_do_not_truncate_integer_values", + "pypika/tests/test_date_math.py::TruncateTrailingZerosTests::test_do_not_truncate_months_between_years_and_datys", + "pypika/tests/test_deletes.py::DeleteTests::test_for_portion", + "pypika/tests/test_deletes.py::DeleteTests::test_omit_where", + "pypika/tests/test_deletes.py::DeleteTests::test_omit_where__table_schema", + "pypika/tests/test_deletes.py::DeleteTests::test_where_field_equals", + "pypika/tests/test_deletes.py::PostgresDeleteTests::test_delete_returning", + "pypika/tests/test_deletes.py::PostgresDeleteTests::test_delete_returning_star", + "pypika/tests/test_deletes.py::PostgresDeleteTests::test_delete_returning_str", + "pypika/tests/test_deletes.py::PostgresDeleteTests::test_delete_using", + "pypika/tests/test_drop.py::DropTableTests::test_drop_database", + "pypika/tests/test_drop.py::DropTableTests::test_drop_index", + "pypika/tests/test_drop.py::DropTableTests::test_drop_table", + "pypika/tests/test_drop.py::DropTableTests::test_drop_user", + "pypika/tests/test_drop.py::DropTableTests::test_drop_view", + "pypika/tests/test_formats.py::QuoteTests::test_no_quote_char_in_complex_query", + "pypika/tests/test_formats.py::QuoteTests::test_replace_quote_char_in_complex_query", + "pypika/tests/test_functions.py::FunctionTests::test_dialect_propagation", + "pypika/tests/test_functions.py::FunctionTests::test_is_aggregate_None_for_non_aggregate_function_or_function_with_no_aggregate_functions", + "pypika/tests/test_functions.py::FunctionTests::test_is_aggregate_True_for_aggregate_function_or_function_with_aggregate_functions", + "pypika/tests/test_functions.py::SchemaTests::test_schema_included_in_function_sql", + "pypika/tests/test_functions.py::SchemaTests::test_schema_no_schema_in_sql_when_none_set", + "pypika/tests/test_functions.py::ArithmeticTests::test__addition__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__addition__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__addition__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__addition__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__arithmetic_equality", + "pypika/tests/test_functions.py::ArithmeticTests::test__arithmetic_with_function", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_add_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_div_no_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_div_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_exponent_no_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_exponent_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_floor_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_function_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_modulus_no_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_modulus_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_mul_no_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_mul_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_nested_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__complex_op_sub_parentheses", + "pypika/tests/test_functions.py::ArithmeticTests::test__division__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__division__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__division__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__division__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__exponent__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__exponent__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__floor", + "pypika/tests/test_functions.py::ArithmeticTests::test__leftshift__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__leftshift__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__leftshift__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__modulus__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__multiplication__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__multiplication__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__multiplication__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__multiplication__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__rightshift__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__rightshift__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__rightshift__right", + "pypika/tests/test_functions.py::ArithmeticTests::test__subtraction__decimal", + "pypika/tests/test_functions.py::ArithmeticTests::test__subtraction__fields", + "pypika/tests/test_functions.py::ArithmeticTests::test__subtraction__number", + "pypika/tests/test_functions.py::ArithmeticTests::test__subtraction__right", + "pypika/tests/test_functions.py::AggregationTests::test__approx_percentile", + "pypika/tests/test_functions.py::AggregationTests::test__avg", + "pypika/tests/test_functions.py::AggregationTests::test__count", + "pypika/tests/test_functions.py::AggregationTests::test__count__star", + "pypika/tests/test_functions.py::AggregationTests::test__first", + "pypika/tests/test_functions.py::AggregationTests::test__last", + "pypika/tests/test_functions.py::AggregationTests::test__max", + "pypika/tests/test_functions.py::AggregationTests::test__min", + "pypika/tests/test_functions.py::AggregationTests::test__std", + "pypika/tests/test_functions.py::AggregationTests::test__stddev", + "pypika/tests/test_functions.py::AggregationTests::test__subquery_in_params_functions", + "pypika/tests/test_functions.py::AggregationTests::test__sum", + "pypika/tests/test_functions.py::ConditionTests::test__case__else", + "pypika/tests/test_functions.py::ConditionTests::test__case__field", + "pypika/tests/test_functions.py::ConditionTests::test__case__multi", + "pypika/tests/test_functions.py::ConditionTests::test__case__no_cases", + "pypika/tests/test_functions.py::ConditionTests::test__case__raw", + "pypika/tests/test_functions.py::StringTests::test__ascii__field", + "pypika/tests/test_functions.py::StringTests::test__ascii__int", + "pypika/tests/test_functions.py::StringTests::test__ascii__str", + "pypika/tests/test_functions.py::StringTests::test__bin__field", + "pypika/tests/test_functions.py::StringTests::test__bin__int", + "pypika/tests/test_functions.py::StringTests::test__bin__str", + "pypika/tests/test_functions.py::StringTests::test__concat__field", + "pypika/tests/test_functions.py::StringTests::test__concat__str", + "pypika/tests/test_functions.py::StringTests::test__insert__field", + "pypika/tests/test_functions.py::StringTests::test__insert__str", + "pypika/tests/test_functions.py::StringTests::test__length__field", + "pypika/tests/test_functions.py::StringTests::test__length__str", + "pypika/tests/test_functions.py::StringTests::test__lower__field", + "pypika/tests/test_functions.py::StringTests::test__lower__str", + "pypika/tests/test_functions.py::StringTests::test__replace__field", + "pypika/tests/test_functions.py::StringTests::test__replace__str", + "pypika/tests/test_functions.py::StringTests::test__substring", + "pypika/tests/test_functions.py::SplitPartFunctionTests::test__split_part", + "pypika/tests/test_functions.py::RegexpLikeFunctionTests::test__regexp_like", + "pypika/tests/test_functions.py::CastTests::test__cast__as", + "pypika/tests/test_functions.py::CastTests::test__cast__binary", + "pypika/tests/test_functions.py::CastTests::test__cast__binary_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__boolean", + "pypika/tests/test_functions.py::CastTests::test__cast__char", + "pypika/tests/test_functions.py::CastTests::test__cast__char_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__date", + "pypika/tests/test_functions.py::CastTests::test__cast__float", + "pypika/tests/test_functions.py::CastTests::test__cast__integer", + "pypika/tests/test_functions.py::CastTests::test__cast__long_varbinary", + "pypika/tests/test_functions.py::CastTests::test__cast__long_varbinary_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__long_varchar", + "pypika/tests/test_functions.py::CastTests::test__cast__long_varchar_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__numeric", + "pypika/tests/test_functions.py::CastTests::test__cast__signed", + "pypika/tests/test_functions.py::CastTests::test__cast__timestamp", + "pypika/tests/test_functions.py::CastTests::test__cast__unsigned", + "pypika/tests/test_functions.py::CastTests::test__cast__varbinary", + "pypika/tests/test_functions.py::CastTests::test__cast__varbinary_with_arg", + "pypika/tests/test_functions.py::CastTests::test__cast__varchar", + "pypika/tests/test_functions.py::CastTests::test__cast__varchar_with_arg", + "pypika/tests/test_functions.py::CastTests::test__tochar__", + "pypika/tests/test_functions.py::DateFunctionsTests::test_current_date", + "pypika/tests/test_functions.py::DateFunctionsTests::test_current_time", + "pypika/tests/test_functions.py::DateFunctionsTests::test_current_timestamp", + "pypika/tests/test_functions.py::DateFunctionsTests::test_current_timestamp_with_alias", + "pypika/tests/test_functions.py::DateFunctionsTests::test_date_add", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_day", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_hour", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_join", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_microsecond", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_minute", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_month", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_quarter", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_second", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_week", + "pypika/tests/test_functions.py::DateFunctionsTests::test_extract_year", + "pypika/tests/test_functions.py::DateFunctionsTests::test_now", + "pypika/tests/test_functions.py::DateFunctionsTests::test_time_diff", + "pypika/tests/test_functions.py::DateFunctionsTests::test_timestampadd", + "pypika/tests/test_functions.py::DateFunctionsTests::test_to_date", + "pypika/tests/test_functions.py::DateFunctionsTests::test_utc_timestamp", + "pypika/tests/test_functions.py::NullFunctionsTests::test_coalesce", + "pypika/tests/test_functions.py::NullFunctionsTests::test_isnull", + "pypika/tests/test_functions.py::NullFunctionsTests::test_nullif", + "pypika/tests/test_functions.py::NullFunctionsTests::test_nvl", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_mysql_one_groupby", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_mysql_rollup_two_groupbys", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_no_rollup_after_rollup_mysql", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_no_rollup_before_groupby", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_from_groupbys", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_from_parameters", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_from_two_groupbys", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_func_one_groupby", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_func_partial", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_func_two_groupbys", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_multiple_rollups", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_rollups_with_multiple_rollups_and_parity", + "pypika/tests/test_groupby_modifiers.py::RollupTests::test_verticaoracle_rollups_with_parity", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_force_index_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_groupby_returns_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_immutable_kwarg_on_query_builder_disables_immutability", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_insert_into_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_join_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_orderby_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_queries_after_join", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_replace_into_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_select_returns_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_update_set_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_use_index_return_new_query_instance", + "pypika/tests/test_immutability.py::ImmutabilityTests::test_with_return_new_query_instance", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_multi_rows", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_multi_rows_chained", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_multi_rows_chained_mixed", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_multi_rows_chained_multiple_rows", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_all_columns_single_element", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_column_using_alias_with_chain", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_column_using_table_alias", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_empty_columns", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_empty_columns_type_list", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_empty_columns_type_tuple", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_ignore", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_multiple_rows_with_array_value", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_none_skipped", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_null", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_one_column", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_one_column_multi_element_array", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_one_column_single_element_array", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_selected_columns", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_selected_columns_type_list", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_selected_columns_type_tuple", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_single_row_with_array_value", + "pypika/tests/test_inserts.py::InsertIntoTests::test_insert_with_statement", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_empty_on_conflict_do_update_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_field", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_field_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_mixed_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_multiple_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_nothing_multiple_fields_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_field", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_field_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_multiple_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_multiple_fields_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_do_update_multiple_mixed_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_no_handler", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_two_handlers_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_conflict_two_handlers_do_update", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_fieldless_conflict_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_insert_on_fieldless_conflict_do_update_field", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_non_insert_on_conflict_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_non_insert_on_conflict_do_update", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_do_nothing_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_do_update_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_do_update_with_excluded_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_from_subquery", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_complex", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_conflict_fields_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_conflict_fields_do_update", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_empty_conflict_fields_do_nothing", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_on_conflict_where_empty_conflict_fields_do_update", + "pypika/tests/test_inserts.py::PostgresInsertIntoOnConflictTests::test_where_and_on_conflict_where", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_all_columns_multi_rows_chained_returning_star", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_all_columns_multi_rows_chained_returning_star_and_id", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_all_columns_multi_rows_chained_returning_star_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_all_columns_single_element_arrays", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_aggregate", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_all_fields", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_all_fields_and_arithmetics", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_arithmetics", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_from_other_table", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_functions", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_null", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_one_field", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_one_field_str", + "pypika/tests/test_inserts.py::PostgresInsertIntoReturningTests::test_insert_returning_tuple", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_ignore", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multi_rows_chained_mixed_on_duplicate_update_multiple", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_multiple", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_different_value", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_expression", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_expression_using_original_field_value", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_expression_using_values", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_multiple_columns_on_duplicate_update_one_with_same_value", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_none_skipped", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_one_column", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_one_column_multi_element_array", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_one_column_single_element_array", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_one_column_using_values", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_selected_columns_on_duplicate_update_multiple", + "pypika/tests/test_inserts.py::InsertIntoOnDuplicateTests::test_insert_selected_columns_on_duplicate_update_one", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_columns_from_columns", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_columns_from_columns_with_join", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_columns_from_star", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_from_columns", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_ignore_star", + "pypika/tests/test_inserts.py::InsertSelectFromTests::test_insert_star", + "pypika/tests/test_inserts.py::InsertSubqueryTests::test_insert_subquery_wrapped_in_brackets", + "pypika/tests/test_inserts.py::SelectIntoTests::test_select_columns_into", + "pypika/tests/test_inserts.py::SelectIntoTests::test_select_columns_into_with_join", + "pypika/tests/test_inserts.py::SelectIntoTests::test_select_star_into", + "pypika/tests/test_inserts.py::ReplaceTests::test_replace_simple", + "pypika/tests/test_inserts.py::ReplaceTests::test_replace_subquery", + "pypika/tests/test_internals.py::TablesTests::test__case_tables", + "pypika/tests/test_internals.py::TablesTests::test__criterion_replace_table_with_value", + "pypika/tests/test_internals.py::TablesTests::test__star_tables", + "pypika/tests/test_internals.py::TablesTests::test__table_star_tables", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_cross_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_cross_join_on_subquery", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_cross_join_on_table", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_default_join_type", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_full_outer_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_hash_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_inner_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_arithmetic_field", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_collate", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_complex_criteria", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_field_multi", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_field_multi_with_extra_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_field_single", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_field_without_fields_raises_exception", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_on_subquery_criteria", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_second_table_in_from_clause", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_using_multiple_fields", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_using_string_field_name", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_using_with_quote_char", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_using_without_fields_raises_exception", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_join_with_arithmetic_function_in_select", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_left_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_left_outer_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_outer_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_right_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_right_outer_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_temporal_join", + "pypika/tests/test_joins.py::SelectQueryJoinTests::test_use_different_table_objects_for_same_table", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_fail_when_joining_unknown_type", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_ignore_table_references", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_immutable__tables", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_from_join", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_query_with_column_alias", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_query_with_setoperation", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_query_with_table_alias", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_query_without_alias", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_same_table", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_same_table_with_prefixes", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_join_table_twice", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_prefixes_added_to_function_in_orderby", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_prefixes_added_to_groupby", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_prefixes_added_to_orderby", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_require_condition", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_require_condition_with_both_tables", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select__fields_after_table_star", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select__ordered_select_clauses", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select__star_for_table", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select__star_for_table__replacement", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select_field_from_missing_table", + "pypika/tests/test_joins.py::JoinBehaviorTests::test_select_fields_with_where", + "pypika/tests/test_joins.py::UnionTests::test_mysql_query_wraps_unioned_queries", + "pypika/tests/test_joins.py::UnionTests::test_require_equal_number_of_fields", + "pypika/tests/test_joins.py::UnionTests::test_union", + "pypika/tests/test_joins.py::UnionTests::test_union_all", + "pypika/tests/test_joins.py::UnionTests::test_union_all_multiple", + "pypika/tests/test_joins.py::UnionTests::test_union_as_subquery", + "pypika/tests/test_joins.py::UnionTests::test_union_multiple", + "pypika/tests/test_joins.py::UnionTests::test_union_with_no_quote_char", + "pypika/tests/test_joins.py::UnionTests::test_union_with_order_by", + "pypika/tests/test_joins.py::UnionTests::test_union_with_order_by_use_union_query_field", + "pypika/tests/test_joins.py::UnionTests::test_union_with_order_by_use_union_query_field_with_aliases", + "pypika/tests/test_joins.py::UnionTests::test_union_with_order_by_with_aliases", + "pypika/tests/test_joins.py::InsertQueryJoinTests::test_join_table_on_insert_query", + "pypika/tests/test_joins.py::UpdateQueryJoinTests::test_join_table_on_update_query", + "pypika/tests/test_joins.py::IntersectTests::test_intersect", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_as_subquery", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_multiple", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_with_limit", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_with_no_quote_char", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_with_offset", + "pypika/tests/test_joins.py::IntersectTests::test_intersect_with_order_by", + "pypika/tests/test_joins.py::IntersectTests::test_mysql_query_wraps_intersected_queries", + "pypika/tests/test_joins.py::IntersectTests::test_require_equal_number_of_fields_intersect", + "pypika/tests/test_joins.py::MinusTests::test_minus", + "pypika/tests/test_joins.py::MinusTests::test_minus_as_subquery", + "pypika/tests/test_joins.py::MinusTests::test_minus_multiple", + "pypika/tests/test_joins.py::MinusTests::test_minus_query_with_order_by_use_minus_query_field", + "pypika/tests/test_joins.py::MinusTests::test_minus_with_no_quote_char", + "pypika/tests/test_joins.py::MinusTests::test_minus_with_order_by", + "pypika/tests/test_joins.py::MinusTests::test_mysql_query_wraps_minus_queries", + "pypika/tests/test_joins.py::MinusTests::test_require_equal_number_of_fields", + "pypika/tests/test_joins.py::ExceptOfTests::test_except", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_as_subquery", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_multiple", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_query_with_order_by_use_minus_query_field", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_with_no_quote_char", + "pypika/tests/test_joins.py::ExceptOfTests::test_except_with_order_by", + "pypika/tests/test_joins.py::ExceptOfTests::test_require_equal_number_of_fields_except_of", + "pypika/tests/test_negation.py::NegationTests::test_negate_field", + "pypika/tests/test_negation.py::NegationTests::test_negate_function", + "pypika/tests/test_negation.py::NegationTests::test_negate_wrapped_float", + "pypika/tests/test_negation.py::NegationTests::test_negate_wrapped_int", + "pypika/tests/test_parameter.py::ParametrizedTests::test_format_parameter", + "pypika/tests/test_parameter.py::ParametrizedTests::test_join", + "pypika/tests/test_parameter.py::ParametrizedTests::test_named_parameter", + "pypika/tests/test_parameter.py::ParametrizedTests::test_numeric_parameter", + "pypika/tests/test_parameter.py::ParametrizedTests::test_param_insert", + "pypika/tests/test_parameter.py::ParametrizedTests::test_param_select_join", + "pypika/tests/test_parameter.py::ParametrizedTests::test_param_select_subquery", + "pypika/tests/test_parameter.py::ParametrizedTests::test_pyformat_parameter", + "pypika/tests/test_parameter.py::ParametrizedTests::test_qmark_parameter", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_join", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_join_with_parameter_value_wrapper", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_param_insert", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_param_select_join", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_param_select_subquery", + "pypika/tests/test_parameter.py::ParametrizedTestsWithValues::test_pyformat_parameter", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_column_value", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_object_id", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_object_value", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_row_id", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_row_num", + "pypika/tests/test_pseudocolumns.py::PseudoColumnsTest::test_sys_date", + "pypika/tests/test_query.py::QueryTablesTests::test_is_joined", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_case_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_delete_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_filter_tables", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_having_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_insert_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_insert_table_current_table_not_match", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_join_tables", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_only_specified_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_orderby_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_tuple_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_update_table", + "pypika/tests/test_query.py::QueryTablesTests::test_replace_update_table_current_table_not_match", + "pypika/tests/test_query.py::QueryBuilderTests::test_pipe", + "pypika/tests/test_query.py::QueryBuilderTests::test_query_builders_have_reference_to_correct_query_class", + "pypika/tests/test_selects.py::SelectTests::test_empty_query", + "pypika/tests/test_selects.py::SelectTests::test_mssql_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_mysql_query_uses_backtick_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_oracle_query_uses_no_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_postgresql_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_redshift_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::SelectTests::test_select__column__single__alias__str", + "pypika/tests/test_selects.py::SelectTests::test_select__column__single__field", + "pypika/tests/test_selects.py::SelectTests::test_select__column__single__str", + "pypika/tests/test_selects.py::SelectTests::test_select__column__single__table_alias__str", + "pypika/tests/test_selects.py::SelectTests::test_select__columns__multi__field", + "pypika/tests/test_selects.py::SelectTests::test_select__columns__multi__str", + "pypika/tests/test_selects.py::SelectTests::test_select__distinct__multi", + "pypika/tests/test_selects.py::SelectTests::test_select__distinct__single", + "pypika/tests/test_selects.py::SelectTests::test_select__multiple_subqueries", + "pypika/tests/test_selects.py::SelectTests::test_select__multiple_tables", + "pypika/tests/test_selects.py::SelectTests::test_select__nested_subquery", + "pypika/tests/test_selects.py::SelectTests::test_select__no_table", + "pypika/tests/test_selects.py::SelectTests::test_select__star", + "pypika/tests/test_selects.py::SelectTests::test_select__star__replacement", + "pypika/tests/test_selects.py::SelectTests::test_select__subquery", + "pypika/tests/test_selects.py::SelectTests::test_select__table_schema", + "pypika/tests/test_selects.py::SelectTests::test_select__table_schema_with_multiple_levels_as_list", + "pypika/tests/test_selects.py::SelectTests::test_select__table_schema_with_multiple_levels_as_tuple", + "pypika/tests/test_selects.py::SelectTests::test_select_no_from", + "pypika/tests/test_selects.py::SelectTests::test_select_no_from_with_field_raises_exception", + "pypika/tests/test_selects.py::SelectTests::test_select_no_with_alias_from", + "pypika/tests/test_selects.py::SelectTests::test_select_then_add_table", + "pypika/tests/test_selects.py::SelectTests::test_select_with_force_index", + "pypika/tests/test_selects.py::SelectTests::test_select_with_force_index_multiple_calls", + "pypika/tests/test_selects.py::SelectTests::test_select_with_force_index_multiple_indexes", + "pypika/tests/test_selects.py::SelectTests::test_select_with_force_index_with_index_object", + "pypika/tests/test_selects.py::SelectTests::test_select_with_limit", + "pypika/tests/test_selects.py::SelectTests::test_select_with_limit__func", + "pypika/tests/test_selects.py::SelectTests::test_select_with_limit_and_offset", + "pypika/tests/test_selects.py::SelectTests::test_select_with_limit_zero", + "pypika/tests/test_selects.py::SelectTests::test_select_with_offset", + "pypika/tests/test_selects.py::SelectTests::test_select_with_offset__func", + "pypika/tests/test_selects.py::SelectTests::test_select_with_use_index", + "pypika/tests/test_selects.py::SelectTests::test_select_with_use_index_multiple_calls", + "pypika/tests/test_selects.py::SelectTests::test_select_with_use_index_multiple_indexes", + "pypika/tests/test_selects.py::SelectTests::test_select_with_use_index_with_index_object", + "pypika/tests/test_selects.py::SelectTests::test_table_select_alias", + "pypika/tests/test_selects.py::SelectTests::test_table_select_alias_with_offset_and_limit", + "pypika/tests/test_selects.py::SelectTests::test_temporal_select", + "pypika/tests/test_selects.py::SelectTests::test_vertica_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::WhereTests::test_ignore_empty_criterion_having", + "pypika/tests/test_selects.py::WhereTests::test_ignore_empty_criterion_where", + "pypika/tests/test_selects.py::WhereTests::test_select_with_force_index_and_where", + "pypika/tests/test_selects.py::WhereTests::test_where_enum", + "pypika/tests/test_selects.py::WhereTests::test_where_field_contains", + "pypika/tests/test_selects.py::WhereTests::test_where_field_does_not_contain", + "pypika/tests/test_selects.py::WhereTests::test_where_field_does_not_end_with", + "pypika/tests/test_selects.py::WhereTests::test_where_field_does_not_start_with", + "pypika/tests/test_selects.py::WhereTests::test_where_field_ends_with", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_and", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_nowait", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_of", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_of_multiple_tables", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_of_nowait", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_of_skip_locked", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_skip_locked", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_for_update_skip_locked_and_of", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_or", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_where", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_where_not", + "pypika/tests/test_selects.py::WhereTests::test_where_field_equals_where_two_not", + "pypika/tests/test_selects.py::WhereTests::test_where_field_is_n_chars_long", + "pypika/tests/test_selects.py::WhereTests::test_where_field_is_not_n_chars_long", + "pypika/tests/test_selects.py::WhereTests::test_where_field_matches_regex", + "pypika/tests/test_selects.py::WhereTests::test_where_field_matches_regexp", + "pypika/tests/test_selects.py::WhereTests::test_where_field_matches_rlike", + "pypika/tests/test_selects.py::WhereTests::test_where_field_starts_with", + "pypika/tests/test_selects.py::WhereTests::test_where_nested_conditions", + "pypika/tests/test_selects.py::WhereTests::test_where_single_quote", + "pypika/tests/test_selects.py::WhereTests::test_where_with_multiple_wheres_using_and_case", + "pypika/tests/test_selects.py::WhereTests::test_where_with_multiple_wheres_using_or_case", + "pypika/tests/test_selects.py::PreWhereTests::test_ignore_empty_criterion_having", + "pypika/tests/test_selects.py::PreWhereTests::test_ignore_empty_criterion_where", + "pypika/tests/test_selects.py::PreWhereTests::test_prewhere_field_equals", + "pypika/tests/test_selects.py::PreWhereTests::test_select_with_force_index_and_where", + "pypika/tests/test_selects.py::PreWhereTests::test_where_and_prewhere", + "pypika/tests/test_selects.py::PreWhereTests::test_where_enum", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_contains", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_does_not_contain", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_does_not_end_with", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_does_not_start_with", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_ends_with", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_and", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_nowait", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_of", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_of_multiple_tables", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_of_nowait", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_of_skip_locked", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_skip_locked", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_for_update_skip_locked_and_of", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_or", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_where", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_where_not", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_equals_where_two_not", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_is_n_chars_long", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_is_not_n_chars_long", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_matches_regex", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_matches_regexp", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_matches_rlike", + "pypika/tests/test_selects.py::PreWhereTests::test_where_field_starts_with", + "pypika/tests/test_selects.py::PreWhereTests::test_where_nested_conditions", + "pypika/tests/test_selects.py::PreWhereTests::test_where_single_quote", + "pypika/tests/test_selects.py::PreWhereTests::test_where_with_multiple_wheres_using_and_case", + "pypika/tests/test_selects.py::PreWhereTests::test_where_with_multiple_wheres_using_or_case", + "pypika/tests/test_selects.py::GroupByTests::test_group_by__single_with_totals", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__alias", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__alias_platforms", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__alias_with_join", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__count_distinct", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__count_field", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__count_star", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__int", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__multi", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__multi_with_totals", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__no_alias", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__no_alias_mssql", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__no_alias_oracle", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__single", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__str", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__sum_distinct", + "pypika/tests/test_selects.py::GroupByTests::test_groupby__sum_filter", + "pypika/tests/test_selects.py::GroupByTests::test_groupby_with_case_uses_the_alias", + "pypika/tests/test_selects.py::GroupByTests::test_mssql_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_mysql_query_uses_backtick_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_oracle_query_uses_no_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_postgres_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_redshift_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::GroupByTests::test_vertica_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_having_and", + "pypika/tests/test_selects.py::HavingTests::test_having_greater_than", + "pypika/tests/test_selects.py::HavingTests::test_having_join_and_equality", + "pypika/tests/test_selects.py::HavingTests::test_mssql_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_mysql_query_uses_backtick_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_oracle_query_uses_no_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_postgres_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_redshift_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::HavingTests::test_vertica_query_uses_double_quote_chars", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_alias", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_asc", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_desc", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_multi_fields", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_no_alias", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_single_field", + "pypika/tests/test_selects.py::OrderByTests::test_orderby_single_str", + "pypika/tests/test_selects.py::AliasTests::test_arithmetic_function", + "pypika/tests/test_selects.py::AliasTests::test_case_using_as", + "pypika/tests/test_selects.py::AliasTests::test_case_using_constructor_param", + "pypika/tests/test_selects.py::AliasTests::test_function_using_as_nested", + "pypika/tests/test_selects.py::AliasTests::test_functions_using_as", + "pypika/tests/test_selects.py::AliasTests::test_functions_using_constructor_param", + "pypika/tests/test_selects.py::AliasTests::test_functions_using_constructor_param_nested", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_criterion", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_criterion_comparison", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_field_inside_case", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_groupby", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_orderby", + "pypika/tests/test_selects.py::AliasTests::test_ignored_in_where", + "pypika/tests/test_selects.py::AliasTests::test_null_value_with_alias", + "pypika/tests/test_selects.py::AliasTests::test_select__multiple_tables", + "pypika/tests/test_selects.py::AliasTests::test_table_field", + "pypika/tests/test_selects.py::AliasTests::test_table_field__multi", + "pypika/tests/test_selects.py::AliasTests::test_table_with_schema_and_alias", + "pypika/tests/test_selects.py::AliasTests::test_use_aliases_in_groupby_and_orderby", + "pypika/tests/test_selects.py::SubqueryTests::test_from_subquery_without_alias", + "pypika/tests/test_selects.py::SubqueryTests::test_join", + "pypika/tests/test_selects.py::SubqueryTests::test_join_query_with_alias", + "pypika/tests/test_selects.py::SubqueryTests::test_join_with_with", + "pypika/tests/test_selects.py::SubqueryTests::test_select_from_nested_query", + "pypika/tests/test_selects.py::SubqueryTests::test_select_from_nested_query_with_join", + "pypika/tests/test_selects.py::SubqueryTests::test_select_from_with_returning", + "pypika/tests/test_selects.py::SubqueryTests::test_select_subquery", + "pypika/tests/test_selects.py::SubqueryTests::test_select_subquery_with_alias", + "pypika/tests/test_selects.py::SubqueryTests::test_where__equality", + "pypika/tests/test_selects.py::SubqueryTests::test_where__in", + "pypika/tests/test_selects.py::SubqueryTests::test_where__in_nested", + "pypika/tests/test_selects.py::SubqueryTests::test_with", + "pypika/tests/test_selects.py::QuoteTests::test_extraneous_quotes", + "pypika/tests/test_tables.py::TableStructureTests::test_database_schema_table_attr", + "pypika/tests/test_tables.py::TableStructureTests::test_schema_table_attr", + "pypika/tests/test_tables.py::TableStructureTests::test_table_for_period_sql", + "pypika/tests/test_tables.py::TableStructureTests::test_table_for_system_time_sql", + "pypika/tests/test_tables.py::TableStructureTests::test_table_sql", + "pypika/tests/test_tables.py::TableStructureTests::test_table_with_alias", + "pypika/tests/test_tables.py::TableStructureTests::test_table_with_schema_and_schema_parent_arg", + "pypika/tests/test_tables.py::TableStructureTests::test_table_with_schema_arg", + "pypika/tests/test_tables.py::TableEqualityTests::test_many_tables_with_alias", + "pypika/tests/test_tables.py::TableEqualityTests::test_many_tables_with_or_not_alias", + "pypika/tests/test_tables.py::TableEqualityTests::test_many_tables_without_alias", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_equal_by_name", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_equal_by_schema_and_name", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_equal_by_schema_and_name_using_schema", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_equal_by_schema_and_name_using_schema_with_parent", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_not_equal_by_schema_and_name_using_schema_with_different_parents", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_not_equal_with_different_names", + "pypika/tests/test_tables.py::TableEqualityTests::test_tables_not_equal_with_different_schemas", + "pypika/tests/test_tables.py::TableDialectTests::test_make_tables_factory_with_default_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_make_tables_factory_with_dialect_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_factory_with_default_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_factory_with_dialect_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_with_bad_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_with_default_query_cls", + "pypika/tests/test_tables.py::TableDialectTests::test_table_with_dialect_query_cls", + "pypika/tests/test_terms.py::FieldAliasTests::test_when_alias_specified", + "pypika/tests/test_terms.py::FieldInitTests::test_init_with_str_table", + "pypika/tests/test_terms.py::FieldHashingTests::test_non_tabled_aliased_eq_fields_equally_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_non_tabled_aliased_ne_fields_differently_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_non_tabled_eq_fields_equally_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_non_tabled_ne_fields_differently_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_tabled_eq_fields_equally_hashed", + "pypika/tests/test_terms.py::FieldHashingTests::test_tabled_ne_fields_differently_hashed", + "pypika/tests/test_terms.py::AtTimezoneTests::test_passes_kwargs_to_field_get_sql", + "pypika/tests/test_terms.py::AtTimezoneTests::test_when_alias_specified", + "pypika/tests/test_terms.py::AtTimezoneTests::test_when_interval_not_specified", + "pypika/tests/test_terms.py::AtTimezoneTests::test_when_interval_specified", + "pypika/tests/test_tuples.py::TupleTests::test_render_alias_in_array_sql", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_equality_tuple_on_both", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_equality_tuple_on_left", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_equality_tuple_on_right", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_in_using_mixed_tuples", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_in_using_pypika_tuples", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_in_using_python_tuples", + "pypika/tests/test_tuples.py::TupleTests::test_tuple_is_aggregate", + "pypika/tests/test_tuples.py::TupleTests::test_tuples_in_join", + "pypika/tests/test_tuples.py::ArrayTests::test_array_general", + "pypika/tests/test_tuples.py::ArrayTests::test_empty_psql_array", + "pypika/tests/test_tuples.py::ArrayTests::test_psql_array_general", + "pypika/tests/test_tuples.py::ArrayTests::test_render_alias_in_array_sql", + "pypika/tests/test_tuples.py::BracketTests::test_arithmetic_with_brackets", + "pypika/tests/test_tuples.py::BracketTests::test_arithmetic_with_brackets_and_alias", + "pypika/tests/test_updates.py::UpdateTests::test_empty_query", + "pypika/tests/test_updates.py::UpdateTests::test_for_portion", + "pypika/tests/test_updates.py::UpdateTests::test_omit_where", + "pypika/tests/test_updates.py::UpdateTests::test_single_quote_escape_in_set", + "pypika/tests/test_updates.py::UpdateTests::test_update__table_schema", + "pypika/tests/test_updates.py::UpdateTests::test_update_from", + "pypika/tests/test_updates.py::UpdateTests::test_update_from_with_where", + "pypika/tests/test_updates.py::UpdateTests::test_update_with_join", + "pypika/tests/test_updates.py::UpdateTests::test_update_with_limit", + "pypika/tests/test_updates.py::UpdateTests::test_update_with_none", + "pypika/tests/test_updates.py::UpdateTests::test_update_with_statement", + "pypika/tests/test_updates.py::PostgresUpdateTests::test_update_returning", + "pypika/tests/test_updates.py::PostgresUpdateTests::test_update_returning_from_different_tables", + "pypika/tests/test_updates.py::PostgresUpdateTests::test_update_returning_star", + "pypika/tests/test_updates.py::PostgresUpdateTests::test_update_returning_str", + "pypika/tests/test_updates.py::SQLLiteUpdateTests::test_update_with_bool", + "pypika/tests/test_utils.py::ImmutabilityTests::test_raise_attribute_error_for_deepcopy", + "pypika/tests/test_utils.py::ImmutabilityTests::test_raise_attribute_error_for_getnewargs", + "pypika/tests/test_utils.py::ImmutabilityTests::test_raise_attribute_error_for_getstate", + "pypika/tests/test_utils.py::ImmutabilityTests::test_raise_attribute_error_for_setstate" + ] +} diff --git a/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/grade.py b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/grade.py new file mode 100644 index 0000000000000000000000000000000000000000..e3b37293830e51a5c5833c93c4705e1ed9364257 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/grade.py @@ -0,0 +1,128 @@ +"""Trusted private pytest panel runner. Installed only in a fresh grader Job.""" + +import hashlib +import importlib.util +import json +import os +import shutil +import stat +import subprocess +from pathlib import Path, PurePosixPath + + +def sha(raw): + return hashlib.sha256(raw).hexdigest() + + +def safe(value): + path = PurePosixPath(value) + if ( + path.is_absolute() + or path.as_posix() != value + or not path.parts + or any(part in {".", "..", ".git"} for part in path.parts) + ): + raise ValueError("Unsafe trusted test path") + return path + + +def restore(worktree, private, manifest): + worktree, private = Path(worktree), Path(private) + captured = {} + for name, expected in manifest["files"].items(): + path = private / safe(name) + info = path.lstat() + raw = path.read_bytes() if stat.S_ISREG(info.st_mode) else b"" + if ( + not stat.S_ISREG(info.st_mode) + or len(raw) != expected["bytes"] + or sha(raw) != expected["sha256"] + or stat.S_IMODE(info.st_mode) != expected["mode"] + ): + raise ValueError("Trusted private test bytes or modes drifted") + captured[name] = (raw, expected["mode"]) + # Capture and verify every private byte before changing the submitted tree. + for name in manifest["directory_roots"]: + destination = worktree / safe(name) + if destination.is_symlink(): + raise ValueError("Submitted test directory is a symlink") + for parent in destination.parents: + if parent == worktree: + break + if parent.is_symlink(): + raise ValueError("Submitted test parent is a symlink") + if destination.exists(): + if not destination.is_dir(): + raise ValueError("Submitted test directory is not a directory") + shutil.rmtree(destination) + for name, (raw, mode) in captured.items(): + destination = worktree / safe(name) + for parent in destination.parents: + if parent == worktree: + break + if parent.is_symlink(): + raise ValueError("Submitted test parent is a symlink") + if destination.is_symlink(): + raise ValueError("Submitted trusted file is a symlink") + destination.parent.mkdir(parents=True, exist_ok=True) + destination.write_bytes(raw) + destination.chmod(mode) + + +def run(worktree, private_root, output, invoke=None): + private_root, output, worktree = Path(private_root), Path(output), Path(worktree) + expected = json.loads((private_root / "expected-panels.json").read_bytes()) + config = json.loads((private_root / "panel-config.json").read_bytes()) + manifest = json.loads((private_root / "trusted-inventory.json").read_bytes()) + restore(worktree, private_root / "trusted", manifest) + output.mkdir(parents=True, exist_ok=True) + for name in ( + "reward.txt", + "pass-to-pass.xml", + "fail-to-pass.xml", + "pytest-evidence.json", + ): + (output / name).unlink(missing_ok=True) + environment = dict(os.environ) + for key in ("PYTEST_ADDOPTS", "PYTEST_DISABLE_PLUGIN_AUTOLOAD", "PYTHONPATH"): + environment.pop(key, None) + commands, native_exit = [], 0 + invoke = invoke or subprocess.run + for group in ("pass-to-pass", "fail-to-pass"): + if ( + not isinstance(expected[group], list) + or not expected[group] + or any( + not isinstance(target, str) or not target for target in expected[group] + ) + ): + raise ValueError("Frozen native pytest selectors are incomplete") + command = [ + *config["official_pytest_argv"], + "--override-ini=addopts=", + "--junitxml=" + str(output / (group + ".xml")), + *expected[group], + ] + result = invoke(command, cwd=worktree, env=environment, check=False) + native_exit = result.returncode + commands.append({"group": group, "argv": command, "exit_code": native_exit}) + if native_exit != 0: + break + (output / "pytest-commands.json").write_text( + json.dumps(commands, sort_keys=True) + "\n" + ) + spec = importlib.util.spec_from_file_location( + "trusted_pytest_result", private_root / "check_pytest.py" + ) + checker = importlib.util.module_from_spec(spec) + spec.loader.exec_module(checker) + result = checker.assess(output, expected, native_exit) + (output / "reward.txt").write_text(str(result["reward"]) + "\n") + (output / "pytest-evidence.json").write_text( + json.dumps(result, sort_keys=True) + "\n" + ) + return result + + +if __name__ == "__main__": + run("/testbed/repo", "/tests", "/logs/verifier") diff --git a/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/panel-config.json b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/panel-config.json new file mode 100644 index 0000000000000000000000000000000000000000..6417b9c92e5da5b97ee641bd54f798302af42a31 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/panel-config.json @@ -0,0 +1,28 @@ +{ + "dependency_installation_pinned": false, + "official_install_cmds": [ + "python -m pip install -e ." + ], + "official_pytest_argv": [ + "pytest", + "--disable-warnings", + "--color=no", + "--tb=no", + "--verbose" + ], + "official_test_command": "source /opt/miniconda3/bin/activate; conda activate testbed; pytest --disable-warnings --color=no --tb=no --verbose", + "operator_test_runner_prerequisites": [ + "python -m pip install pytest==8.4.2" + ], + "operator_test_runner_reason": "The official profile invokes pytest, but the common tools runtime does not provide it; pinned separately from source-native project requirements.", + "panel_normalization": "Override project addopts only to execute the exact frozen native panels; add JUnit output, preserve official pytest options and all selectors.", + "python_version": "3.10", + "source_bound_test_dependency_cmds": [ + "python -m pip install parameterized==0.7.0" + ], + "test_dependency_source_sha256": { + "requirements-dev.txt": "10f4ba7b19a73950d28fd7403d7e1d1b1fe2ccc4f49516974f47199d2965f23d", + "setup.py": "f8bad274588a22e65764d8cf9fb2be5aa6fcfaf3bf861d71e5f751105898845a", + "tox.ini": "c2d7205d0ac93e9c9e80dc5d24f0a826a6781f587a33ea722ea621f9e2ccd0ea" + } +} diff --git a/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/test.sh b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..81b6d0620f05dbd3b54b4e7ea5de04ce3f8a98e2 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/test.sh @@ -0,0 +1,6 @@ +#!/bin/bash +set -Eeuo pipefail +source /opt/miniconda3/bin/activate +conda activate testbed +cd /testbed/repo +exec python -I /tests/grade.py diff --git a/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted-inventory.json b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted-inventory.json new file mode 100644 index 0000000000000000000000000000000000000000..6926ef1c22ed56457101c37cd70e0fe0d1656f0c --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted-inventory.json @@ -0,0 +1,242 @@ +{ + "directory_roots": [ + "pypika/tests" + ], + "files": { + "pypika/tests/__init__.py": { + "bytes": 58, + "mode": 420, + "sha256": "7d41f44b87688bdf162e6d5cbe7b517cfba468f96eaa421f02718c17eb486a18" + }, + "pypika/tests/clickhouse/__init__.py": { + "bytes": 0, + "mode": 420, + "sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "pypika/tests/clickhouse/test_array.py": { + "bytes": 2942, + "mode": 420, + "sha256": "0f0a5b4c3daf3ddce2944b6119795e80d50b74e4687ef2e34399e5d21d3d48ae" + }, + "pypika/tests/clickhouse/test_condition.py": { + "bytes": 2533, + "mode": 420, + "sha256": "c666976d082b1d12cd57e791d1a525183246335efad96a369b58871a6f1e4fa1" + }, + "pypika/tests/clickhouse/test_dates_and_times.py": { + "bytes": 2508, + "mode": 420, + "sha256": "cb8ea84363e35ad0a00b52a8ec20cb38f2348f4cba28d026a4c32c14fd1fc56f" + }, + "pypika/tests/clickhouse/test_nullable_arg.py": { + "bytes": 672, + "mode": 420, + "sha256": "883c5161ebeb09544ce124d20a096d248bd12a0404ad77c84637be75d6738529" + }, + "pypika/tests/clickhouse/test_search_string.py": { + "bytes": 1189, + "mode": 420, + "sha256": "d5f0ed6a51cf550bdd4b261fa2e98084184dd1cbb08f5dbb8b91278b4c8f3bfd" + }, + "pypika/tests/clickhouse/test_type_conversion.py": { + "bytes": 4445, + "mode": 420, + "sha256": "7e6045b64433a8947346cfb34ac30279349f7a2e2081a2815212c8cb7d0235ab" + }, + "pypika/tests/dialects/__init__.py": { + "bytes": 0, + "mode": 420, + "sha256": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "pypika/tests/dialects/test_clickhouse.py": { + "bytes": 5747, + "mode": 420, + "sha256": "2272538d6eeb6dfb01f9803eed328b4cd4efc8d255b6a8ab3c4e25bee74d73fa" + }, + "pypika/tests/dialects/test_mssql.py": { + "bytes": 3152, + "mode": 420, + "sha256": "0cd9b2ee6498caa9fa75a51ead30803057fb23deb2ac706d396d88329e0e91d7" + }, + "pypika/tests/dialects/test_mysql.py": { + "bytes": 2984, + "mode": 420, + "sha256": "a5f4550dd14bf4820e5d85cf06b6c7c79286e41d2d3c794f639579d20fffab92" + }, + "pypika/tests/dialects/test_oracle.py": { + "bytes": 1906, + "mode": 420, + "sha256": "67f80eb40cc9b4dabcbad355e8be6d83c54a64cbee809182ef57fa9f48d2ebc6" + }, + "pypika/tests/dialects/test_postgresql.py": { + "bytes": 9532, + "mode": 420, + "sha256": "548ee7267ca87c9e1ae82ca89a4e5bd96c7392a55cc07996f2b105f911ffa6cf" + }, + "pypika/tests/dialects/test_snowflake.py": { + "bytes": 2159, + "mode": 420, + "sha256": "e567b9dab0a5366bd11a0ef162c3a3bb492280b78bc4b397a23070563dc84468" + }, + "pypika/tests/dialects/test_sqllite.py": { + "bytes": 1243, + "mode": 420, + "sha256": "118fed7e575415f276bda390a119080bd6a767aee3d9c953e11a8c219f0f017c" + }, + "pypika/tests/dialects/test_vertica.py": { + "bytes": 3578, + "mode": 420, + "sha256": "33a027e6735ca03b7afd11394905c4193e48a15dda3efbe47cdcd85fcabf840c" + }, + "pypika/tests/test_aggregate.py": { + "bytes": 3946, + "mode": 420, + "sha256": "5b0fb549de3bb50ad88ae1d75824f12f7ab4a5f1102b06a70c7b2ebae33bea6d" + }, + "pypika/tests/test_analytic_queries.py": { + "bytes": 20611, + "mode": 420, + "sha256": "8546b7a296c8e212c349c4baff95f93934b3120f74625b3945ade3b438e3a3ed" + }, + "pypika/tests/test_create.py": { + "bytes": 9088, + "mode": 420, + "sha256": "6c57302da52ca1044be0afdafe677d5de245e44873dff1386c9a1ccb2625cc82" + }, + "pypika/tests/test_criterions.py": { + "bytes": 32014, + "mode": 420, + "sha256": "78539ccca82f9a02fad0f5a39041ac343e3a142ce52368cd4f6ada489c52516a" + }, + "pypika/tests/test_custom_functions.py": { + "bytes": 1710, + "mode": 420, + "sha256": "bfa18bc328a3577965db7cc75eb94439f0cfd95a3775d9b1cc8af1062bb202cb" + }, + "pypika/tests/test_data_types.py": { + "bytes": 403, + "mode": 420, + "sha256": "c1be6ecc621a80dd91d35b1427bdfc8b1b33bd926515198e626d6fb5e1878c8b" + }, + "pypika/tests/test_date_math.py": { + "bytes": 5544, + "mode": 420, + "sha256": "85aa54efe54fe19639f2dc2a5750647e3337ac2681768bc3fe327841f1634d9e" + }, + "pypika/tests/test_deletes.py": { + "bytes": 3204, + "mode": 420, + "sha256": "ccde6df760d76d5d499ce828f6b0e2ad3eebcb2a5553c1890f481b9160b8d51a" + }, + "pypika/tests/test_drop.py": { + "bytes": 1556, + "mode": 420, + "sha256": "a13dffa59ef8657398d5498c18977bfd702635e336ea9966b1a86137afca7926" + }, + "pypika/tests/test_formats.py": { + "bytes": 1948, + "mode": 420, + "sha256": "240458a404bb119322778893b94a12be0f98f914acd701d2b4be73eb9be96f75" + }, + "pypika/tests/test_functions.py": { + "bytes": 32769, + "mode": 420, + "sha256": "3ceaac7791bd27e50f44e1b4a1451d1e09afe6a8011052caea838e5124582154" + }, + "pypika/tests/test_groupby_modifiers.py": { + "bytes": 5227, + "mode": 420, + "sha256": "9db4497660f08e3352a9a02c34889ad1cd6bab3aebaeaa485e84390ad71c84c5" + }, + "pypika/tests/test_immutability.py": { + "bytes": 3954, + "mode": 420, + "sha256": "af537ced19f7274951cc91697eae748ef6c9cd20a8d8e492d93dc85b06f8fb50" + }, + "pypika/tests/test_inserts.py": { + "bytes": 32549, + "mode": 420, + "sha256": "652e9f7f0f425e9acc0f70e2851ae29310b378262ea30369ea0113ef428f210f" + }, + "pypika/tests/test_internals.py": { + "bytes": 828, + "mode": 420, + "sha256": "4374c2632563346d00ca4de6af397a022ef3f5022e808c8711a3f207a3a21609" + }, + "pypika/tests/test_joins.py": { + "bytes": 43895, + "mode": 420, + "sha256": "53f224815c10393382443f020cb20e313420764495a8fd30f7ea2f34fd52935d" + }, + "pypika/tests/test_negation.py": { + "bytes": 763, + "mode": 420, + "sha256": "6be105e8f39b32fb23e6ac7c7158232ee78111455d4f35638c8af60781138c79" + }, + "pypika/tests/test_parameter.py": { + "bytes": 7382, + "mode": 420, + "sha256": "aaf2a3e79c8267bdc60e218445bc2a2254b97cf37b643a44d6f1a8141cbb5104" + }, + "pypika/tests/test_pseudocolumns.py": { + "bytes": 1609, + "mode": 420, + "sha256": "b7c69f7aca41323c0e14a6a9e58697399cd7860610f07291afc6e8af26079ca2" + }, + "pypika/tests/test_query.py": { + "bytes": 9025, + "mode": 420, + "sha256": "2da9d717673912a84e86e6c0d3955dbd8f2fa7b41b7ed9a6f78089dfa28f9444" + }, + "pypika/tests/test_selects.py": { + "bytes": 50757, + "mode": 420, + "sha256": "5ac1b7ad3248d64b1e3865a72c763873514ae5cd6e03356b913e531c0c336986" + }, + "pypika/tests/test_tables.py": { + "bytes": 6568, + "mode": 420, + "sha256": "384c8e843ba56374ee92cd7b7e2fd3f89247b899e23cd9e1f6663d751ad5d884" + }, + "pypika/tests/test_terms.py": { + "bytes": 3215, + "mode": 420, + "sha256": "8598513180ddcd28cc61582618d85bd570280978b07603044dae81b2eb099f77" + }, + "pypika/tests/test_tuples.py": { + "bytes": 6033, + "mode": 420, + "sha256": "863942196a93e8939be0d03c49cfeb42a35503ad42f9f3d6c730260112811087" + }, + "pypika/tests/test_updates.py": { + "bytes": 5689, + "mode": 420, + "sha256": "0f0f2521bb8d1f5d782f8fabaea5fd1d82090cde045ba87fad65770db6c75d2f" + }, + "pypika/tests/test_utils.py": { + "bytes": 834, + "mode": 420, + "sha256": "5db6e90df5daaa70b9f35f1243db69908da1f27887f63466fc27ce20c7e14892" + }, + "pyproject.toml": { + "bytes": 390, + "mode": 420, + "sha256": "037fedacd5be5d078f398265ff97e1677e25214ad8839d17073a439695ee7a91" + }, + "setup.cfg": { + "bytes": 317, + "mode": 420, + "sha256": "c84a31de586e8385e741127b004fc1f19ebae6463cdf0b3f243991db35cdeaea" + }, + "setup.py": { + "bytes": 2638, + "mode": 420, + "sha256": "f8bad274588a22e65764d8cf9fb2be5aa6fcfaf3bf861d71e5f751105898845a" + }, + "tox.ini": { + "bytes": 257, + "mode": 420, + "sha256": "c2d7205d0ac93e9c9e80dc5d24f0a826a6781f587a33ea722ea621f9e2ccd0ea" + } + } +} diff --git a/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/__init__.py b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..86d8a68101915c27b95484243dd81d55f7dba356 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/__init__.py @@ -0,0 +1,2 @@ +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" diff --git a/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/clickhouse/__init__.py b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/clickhouse/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/clickhouse/test_array.py b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/clickhouse/test_array.py new file mode 100644 index 0000000000000000000000000000000000000000..469705a9ff3c8fe9cc7f02c44a9812521eeb67f4 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/clickhouse/test_array.py @@ -0,0 +1,104 @@ +import unittest + +from parameterized import parameterized + +from pypika import Field +from pypika.clickhouse.array import ( + Array, + Empty, + HasAny, + Length, + NotEmpty, +) +from pypika.clickhouse.type_conversion import ( + ToFixedString, + ToInt64, +) + + +class TestArray(unittest.TestCase): + @parameterized.expand( + [ + ( + "['ridley', 'scott', 'jimi', 'hendrix']", + Array(["ridley", "scott", "jimi", "hendrix"]), + ), + ( + "[1, 2, 3, 4]", + Array([1, 2, 3, 4]), + ), + ( + "[toInt64('1'),toInt64('2'),toInt64('3'),toInt64('4')]", + Array(["1", "2", "3", "4"], ToInt64), + ), + ( + "[toFixedString('mogwai',10),toFixedString('mono',10),toFixedString('bonobo',10)] arr", + Array(["mogwai", "mono", "bonobo"], ToFixedString, {"length": 10}).as_('arr'), + ), + ] + ) + def test_get_sql(self, expected: str, array: Array): + self.assertEqual(expected, array.get_sql()) + + +class TestHasAny(unittest.TestCase): + @parameterized.expand( + [ + ( + 'hasAny("mental_abilities","physical_abilities")', + HasAny(Field("mental_abilities"), Field("physical_abilities")), + ), + ("hasAny([1, 2, 3, 4],[3])", HasAny(Array([1, 2, 3, 4]), Array([3]))), + ( + "hasAny(\"bands\",[toFixedString('port-royal',20),toFixedString('hammock',20)])", + HasAny( + Field("bands"), + Array(["port-royal", "hammock"], ToFixedString, {"length": 20}), + ), + ), + ] + ) + def test_get_sql(self, expected: str, func: HasAny): + self.assertEqual(expected, func.get_sql()) + + +class TestLength(unittest.TestCase): + @parameterized.expand( + [ + ( + 'length("tags")', + Length(Field("tags")), + ), + ("length([1, 2, 3])", Length(Array([1, 2, 3]))), + ] + ) + def test_get_sql(self, expected: str, func: Length): + self.assertEqual(expected, func.get_sql()) + + +class TestEmpty(unittest.TestCase): + @parameterized.expand( + [ + ( + 'empty("tags")', + Empty(Field("tags")), + ), + ("empty([1, 2, 3])", Empty(Array([1, 2, 3]))), + ] + ) + def test_get_sql(self, expected: str, func: Empty): + self.assertEqual(expected, func.get_sql()) + + +class TestNotEmpty(unittest.TestCase): + @parameterized.expand( + [ + ( + 'notEmpty("tags")', + NotEmpty(Field("tags")), + ), + ("notEmpty([1, 2, 3])", NotEmpty(Array([1, 2, 3]))), + ] + ) + def test_get_sql(self, expected: str, func: NotEmpty): + self.assertEqual(expected, func.get_sql()) diff --git a/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/clickhouse/test_condition.py b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/clickhouse/test_condition.py new file mode 100644 index 0000000000000000000000000000000000000000..145baeb7753dd9cbefbd6f272bd672ae5730b0c0 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/clickhouse/test_condition.py @@ -0,0 +1,72 @@ +import unittest + +from parameterized import parameterized + +from pypika import Field +from pypika.clickhouse.condition import If, MultiIf +from pypika.clickhouse.type_conversion import ToFixedString + + +class TestIfCondition(unittest.TestCase): + @parameterized.expand( + [ + ( + If( + Field("filmmaker").isnull(), + ToFixedString("Tarantino", 20), + Field("filmmaker"), + ), + "if(filmmaker IS NULL,toFixedString('Tarantino',20),filmmaker)", + ), + ( + If( + Field("created") == Field("updated"), + ToFixedString("yes", 3), + ToFixedString("no", 3), + ), + "if(created=updated,toFixedString('yes',3),toFixedString('no',3))", + ), + ] + ) + def test_get_sql(self, func, expected): + self.assertEqual(func.get_sql(), expected) + + +class TestMultiIfCondition(unittest.TestCase): + @parameterized.expand( + [ + ( + MultiIf( + Field("filmmaker").isnull(), + ToFixedString("Tarantino", 20), + Field("filmmaker") == ToFixedString("undefined", 20), + ToFixedString("Tarantino", 20), + Field("filmmaker"), + ), + "multiIf(filmmaker IS NULL," + "toFixedString('Tarantino',20)," + "filmmaker=toFixedString('undefined',20)," + "toFixedString('Tarantino',20),filmmaker)", + ), + ( + MultiIf( + Field("color") == ToFixedString("black", 20), + ToFixedString("dark", 20), + Field("color") == ToFixedString("grey", 20), + ToFixedString("dark", 20), + Field("color") == ToFixedString("white", 20), + ToFixedString("light", 20), + ToFixedString("undefined", 20), + ), + "multiIf(color=toFixedString('black',20)," + "toFixedString('dark',20)," + "color=toFixedString('grey',20)," + "toFixedString('dark',20)," + "color=toFixedString('white',20)," + "toFixedString('light',20)," + "toFixedString('undefined',20))", + ), + ] + ) + def test_get_sql(self, func, expected): + self.assertEqual(func.get_sql(), expected) diff --git a/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/clickhouse/test_dates_and_times.py b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/clickhouse/test_dates_and_times.py new file mode 100644 index 0000000000000000000000000000000000000000..135dd7f112131776d76748e15eead1eb81752b59 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/clickhouse/test_dates_and_times.py @@ -0,0 +1,70 @@ +import unittest + +from parameterized import parameterized + +from pypika import Field +from pypika.clickhouse.dates_and_times import ( + AddDays, + AddHours, + AddMinutes, + AddMonths, + AddQuarters, + AddSeconds, + AddWeeks, + AddYears, + FormatDateTime, + SubtractDays, + SubtractHours, + SubtractMinutes, + SubtractMonths, + SubtractQuarters, + SubtractSeconds, + SubtractWeeks, + SubtractYears, + ToYYYYMM, +) + + +class TestFormatDateTime(unittest.TestCase): + @parameterized.expand( + [ + (FormatDateTime(Field("created"), "%V"), "formatDateTime(created,'%V')"), + ( + FormatDateTime(Field("created"), "%Y-%m-%d"), + "formatDateTime(created,'%Y-%m-%d')", + ), + ] + ) + def test_get_sql(self, func, expected): + self.assertEqual(func.get_sql(), expected) + + +class TestAddSubtractDt(unittest.TestCase): + @parameterized.expand( + [ + (AddYears(Field("created"), 1), "addYears(created,1)"), + (AddMonths(Field("created"), 2), "addMonths(created,2)"), + (AddWeeks(Field("created"), 3), "addWeeks(created,3)"), + (AddDays(Field("created"), 4), "addDays(created,4)"), + (AddHours(Field("created"), 5), "addHours(created,5)"), + (AddMinutes(Field("created"), 6), "addMinutes(created,6)"), + (AddSeconds(Field("created"), 7), "addSeconds(created,7)"), + (AddQuarters(Field("created"), 8), "addQuarters(created,8)"), + (SubtractYears(Field("created"), 9), "subtractYears(created,9)"), + (SubtractMonths(Field("created"), 10), "subtractMonths(created,10)"), + (SubtractWeeks(Field("created"), 11), "subtractWeeks(created,11)"), + (SubtractDays(Field("created"), 12), "subtractDays(created,12)"), + (SubtractHours(Field("created"), 13), "subtractHours(created,13)"), + (SubtractHours(Field("created"), 13), "subtractHours(created,13)"), + (SubtractMinutes(Field("created"), 14), "subtractMinutes(created,14)"), + (SubtractSeconds(Field("created"), 15), "subtractSeconds(created,15)"), + (SubtractQuarters(Field("created"), 16), "subtractQuarters(created,16)"), + ] + ) + def test_get_sql(self, func, expected): + self.assertEqual(func.get_sql(), expected) + + +class TestToYYYYMM(unittest.TestCase): + def test_get_sql(self): + self.assertEqual(ToYYYYMM(Field("created").get_sql()), "toYYYYMM(created)") diff --git a/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/clickhouse/test_nullable_arg.py b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/clickhouse/test_nullable_arg.py new file mode 100644 index 0000000000000000000000000000000000000000..3c6c86207a4d0206b5c0ba80b77fac4cc257fa17 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/clickhouse/test_nullable_arg.py @@ -0,0 +1,24 @@ +import unittest + +from parameterized import parameterized + +from pypika import Field +from pypika.clickhouse.nullable_arg import IfNull +from pypika.clickhouse.type_conversion import ToFixedString + + +class TestSearchString(unittest.TestCase): + @parameterized.expand( + [ + ( + IfNull(Field("name"), Field("login")), + "ifNull(name,login)", + ), + ( + IfNull(Field("builder"), ToFixedString("pypika", 100)), + "ifNull(builder,toFixedString('pypika',100))", + ), + ] + ) + def test_get_sql(self, func, expected): + self.assertEqual(func.get_sql(), expected) diff --git a/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/clickhouse/test_search_string.py b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/clickhouse/test_search_string.py new file mode 100644 index 0000000000000000000000000000000000000000..9778eb32e47d4370c0bfe36dcd875903666d30b6 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/clickhouse/test_search_string.py @@ -0,0 +1,41 @@ +import unittest + +from parameterized import parameterized + +from pypika import Field +from pypika.clickhouse.search_string import ( + Match, + Like, + NotLike, + MultiSearchAny, + MultiMatchAny, +) + + +class TestSearchString(unittest.TestCase): + @parameterized.expand( + [ + (Match(Field("name"), "twheys"), "match(toString(\"name\"),'twheys')"), + (Like(Field("name"), "twheys"), "like(toString(\"name\"),'twheys')"), + (NotLike(Field("name"), "twheys"), "notLike(toString(\"name\"),'twheys')"), + ] + ) + def test_search_string(self, func, expected): + self.assertEqual(func, expected) + + +class TestMultiSearch(unittest.TestCase): + @parameterized.expand( + [ + ( + MultiSearchAny(Field("name"), ["sarah", "connor"]), + "multiSearchAny(toString(\"name\"),['sarah','connor'])", + ), + ( + MultiMatchAny(Field("name"), ["sarah", "connor"]), + "multiMatchAny(toString(\"name\"),['sarah','connor'])", + ), + ] + ) + def test_multi_search_string(self, func, expected): + self.assertEqual(func.get_sql(), expected) diff --git a/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/clickhouse/test_type_conversion.py b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/clickhouse/test_type_conversion.py new file mode 100644 index 0000000000000000000000000000000000000000..9692e17bee901e2629db9a5c77111e145358e8eb --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/clickhouse/test_type_conversion.py @@ -0,0 +1,176 @@ +import unittest + +from parameterized import parameterized + +from pypika import ClickHouseQuery, Field, Table +from pypika.clickhouse.type_conversion import ( + ToDate, + ToDateTime, + ToFixedString, + ToFloat32, + ToFloat64, + ToInt16, + ToInt32, + ToInt64, + ToInt8, + ToString, + ToUInt16, + ToUInt32, + ToUInt64, + ToUInt8, +) + + +class TestBasicTypeConverters(unittest.TestCase): + @parameterized.expand( + [ + ( + 'toString("field_name")', + ToString(Field("field_name")), + ), + ( + 'toInt8("field_name")', + ToInt8(Field("field_name")), + ), + ( + 'toInt16("field_name")', + ToInt16(Field("field_name")), + ), + ( + 'toInt32("field_name")', + ToInt32(Field("field_name")), + ), + ( + 'toInt64("field_name")', + ToInt64(Field("field_name")), + ), + ( + 'toUInt8("field_name")', + ToUInt8(Field("field_name")), + ), + ( + 'toUInt16("field_name")', + ToUInt16(Field("field_name")), + ), + ( + 'toUInt32("field_name")', + ToUInt32(Field("field_name")), + ), + ( + 'toUInt64("field_name")', + ToUInt64(Field("field_name")), + ), + ( + 'toFloat32("field_name")', + ToFloat32(Field("field_name")), + ), + ( + 'toFloat64("field_name")', + ToFloat64(Field("field_name")), + ), + ( + 'toFloat64("field_name")', + ToFloat64(Field("field_name")), + ), + ( + 'toDate("field_name")', + ToDate(Field("field_name")), + ), + ( + 'toDateTime("field_name")', + ToDateTime(Field("field_name")), + ), + ( + 'toFixedString("field_name",100)', + ToFixedString(Field("field_name"), 100), + ), + ] + ) + def test_basic_types_field(self, expected, func): + self.assertEqual(func, expected) + + @parameterized.expand( + [ + ( + "toString('100')", + ToString("100"), + ), + ( + "toInt8('100')", + ToInt8("100"), + ), + ( + "toInt16('100')", + ToInt16("100"), + ), + ( + "toInt32('100')", + ToInt32("100"), + ), + ( + "toInt64('100')", + ToInt64("100"), + ), + ( + "toUInt8('100')", + ToUInt8("100"), + ), + ( + "toUInt16('100')", + ToUInt16("100"), + ), + ( + "toUInt32('100')", + ToUInt32("100"), + ), + ( + "toUInt64('100')", + ToUInt64("100"), + ), + ( + "toFloat32('100')", + ToFloat32("100"), + ), + ( + "toFloat64('100')", + ToFloat64("100"), + ), + ( + "toFloat64('100')", + ToFloat64("100"), + ), + ( + "toDate('100')", + ToDate("100"), + ), + ( + "toDateTime('100')", + ToDateTime("100"), + ), + ( + "toFixedString('100',100)", + ToFixedString("100", 100), + ), + ] + ) + def test_basic_types_value(self, expected, func): + self.assertEqual(func, expected) + + +class TestToFixedString(unittest.TestCase): + def test_get_sql_with_table(self): + table = Table("example") + query = ( + ClickHouseQuery.from_(table) + .select( + table.name, + ) + .where( + table.name == ToFixedString("name", 50), + ) + ) + + self.assertEqual( + 'SELECT "name" FROM "example" WHERE "name"=toFixedString(\'name\',50)', + query.get_sql(), + ) diff --git a/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/dialects/__init__.py b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/dialects/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/dialects/test_clickhouse.py b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/dialects/test_clickhouse.py new file mode 100644 index 0000000000000000000000000000000000000000..f319c4627bd25d7004894181906a284b8b1c64cf --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/dialects/test_clickhouse.py @@ -0,0 +1,146 @@ +from unittest import TestCase + +from pypika import ( + ClickHouseQuery, + Database, + Table, +) + + +class ClickHouseQueryTests(TestCase): + def test_use_AS_keyword_for_alias(self): + t = Table('abc') + query = ClickHouseQuery.from_(t).select(t.foo.as_('f1'), t.bar.as_('f2')) + self.assertEqual(str(query), 'SELECT "foo" AS "f1","bar" AS "f2" FROM "abc"') + + def test_use_SAMPLE_keyword(self): + t = Table('abc') + query = ClickHouseQuery.from_(t).select(t.foo).sample(10) + self.assertEqual(str(query), 'SELECT "foo" FROM "abc" SAMPLE 10') + + def test_use_SAMPLE_with_offset_keyword(self): + t = Table('abc') + query = ClickHouseQuery.from_(t).select(t.foo).sample(10, 5) + self.assertEqual(str(query), 'SELECT "foo" FROM "abc" SAMPLE 10 OFFSET 5') + + def test_use_FINAL_keyword(self): + t = Table('abc') + query = ClickHouseQuery.from_(t).select(t.foo).final() + self.assertEqual(str(query), 'SELECT "foo" FROM "abc" FINAL') + + +class ClickHouseDeleteTests(TestCase): + table_abc = Table("abc") + + def test_omit_where(self): + q = ClickHouseQuery.from_("abc").delete() + + self.assertEqual('ALTER TABLE "abc" DELETE', str(q)) + + def test_omit_where__table_schema(self): + q = ClickHouseQuery.from_(Table("abc", "schema1")).delete() + + self.assertEqual('ALTER TABLE "schema1"."abc" DELETE', str(q)) + + def test_where_field_equals(self): + q1 = ClickHouseQuery.from_(self.table_abc).where(self.table_abc.foo == self.table_abc.bar).delete() + q2 = ClickHouseQuery.from_(self.table_abc).where(self.table_abc.foo.eq(self.table_abc.bar)).delete() + + self.assertEqual('ALTER TABLE "abc" DELETE WHERE "foo"="bar"', str(q1)) + self.assertEqual('ALTER TABLE "abc" DELETE WHERE "foo"="bar"', str(q2)) + + +class ClickHouseUpdateTests(TestCase): + table_abc = Table("abc") + + def test_update(self): + q = ClickHouseQuery.update(self.table_abc).where(self.table_abc.foo == 0).set("foo", "bar") + + self.assertEqual('ALTER TABLE "abc" UPDATE "foo"=\'bar\' WHERE "foo"=0', str(q)) + + +class ClickHouseDropQuery(TestCase): + table_abc = Table("abc") + database_xyz = Database("mydb") + cluster_name = "mycluster" + + def test_drop_database(self): + q1 = ClickHouseQuery.drop_database(self.database_xyz) + q2 = ClickHouseQuery.drop_database(self.database_xyz).on_cluster(self.cluster_name) + q3 = ClickHouseQuery.drop_database(self.database_xyz).if_exists().on_cluster(self.cluster_name) + + self.assertEqual('DROP DATABASE "mydb"', str(q1)) + self.assertEqual('DROP DATABASE "mydb" ON CLUSTER "mycluster"', str(q2)) + self.assertEqual('DROP DATABASE IF EXISTS "mydb" ON CLUSTER "mycluster"', str(q3)) + + def test_drop_table(self): + q1 = ClickHouseQuery.drop_table(self.table_abc) + q2 = ClickHouseQuery.drop_table(self.table_abc).on_cluster(self.cluster_name) + q3 = ClickHouseQuery.drop_table(self.table_abc).if_exists().on_cluster(self.cluster_name) + + self.assertEqual('DROP TABLE "abc"', str(q1)) + self.assertEqual('DROP TABLE "abc" ON CLUSTER "mycluster"', str(q2)) + self.assertEqual('DROP TABLE IF EXISTS "abc" ON CLUSTER "mycluster"', str(q3)) + + def test_drop_dictionary(self): + q1 = ClickHouseQuery.drop_dictionary("dict") + q2 = ClickHouseQuery.drop_dictionary("dict").on_cluster(self.cluster_name) + q3 = ClickHouseQuery.drop_dictionary("dict").if_exists().on_cluster(self.cluster_name) + + self.assertEqual('DROP DICTIONARY "dict"', str(q1)) + self.assertEqual('DROP DICTIONARY "dict"', str(q2)) # NO CLUSTER + self.assertEqual('DROP DICTIONARY IF EXISTS "dict"', str(q3)) # NO CLUSTER + + def test_drop_other(self): + q1 = ClickHouseQuery.drop_quota("myquota") + q2 = ClickHouseQuery.drop_user("myuser") + q3 = ClickHouseQuery.drop_view("myview") + + self.assertEqual('DROP QUOTA "myquota"', str(q1)) + self.assertEqual('DROP USER "myuser"', str(q2)) + self.assertEqual('DROP VIEW "myview"', str(q3)) + + +class DistinctOnTests(TestCase): + table_abc = Table("abc") + + def test_distinct_on(self): + q = ClickHouseQuery.from_(self.table_abc).distinct_on("lname", self.table_abc.fname).select("lname", "id") + + self.assertEqual('''SELECT DISTINCT ON("lname","fname") "lname","id" FROM "abc"''', str(q)) + + +class LimitByTests(TestCase): + table_abc = Table("abc") + + def test_limit_by(self): + q = ClickHouseQuery.from_(self.table_abc).limit_by(1, "a", self.table_abc.b).select("a", "b", "c") + + self.assertEqual('''SELECT "a","b","c" FROM "abc" LIMIT 1 BY ("a","b")''', str(q)) + + def test_limit_offset_by(self): + q = ClickHouseQuery.from_(self.table_abc).limit_offset_by(1, 2, "a", self.table_abc.b).select("a", "b", "c") + + self.assertEqual('''SELECT "a","b","c" FROM "abc" LIMIT 1 OFFSET 2 BY ("a","b")''', str(q)) + + def test_limit_offset0_by(self): + q = ClickHouseQuery.from_(self.table_abc).limit_offset_by(1, 0, "a", self.table_abc.b).select("a", "b", "c") + + self.assertEqual('''SELECT "a","b","c" FROM "abc" LIMIT 1 BY ("a","b")''', str(q)) + + def test_rename_table(self): + table_join = Table("join") + + q = ( + ClickHouseQuery.from_(self.table_abc) + .join(table_join) + .using("a") + .limit_by(1, self.table_abc.a, table_join.a) + .select(self.table_abc.b, table_join.b) + ) + q = q.replace_table(self.table_abc, Table("xyz")) + + self.assertEqual( + '''SELECT "xyz"."b","join"."b" FROM "xyz" JOIN "join" USING ("a") LIMIT 1 BY ("xyz"."a","join"."a")''', + str(q), + ) diff --git a/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/dialects/test_mssql.py b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/dialects/test_mssql.py new file mode 100644 index 0000000000000000000000000000000000000000..7cf53b228f413a8c7cd3e414fef5522a82f99b29 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/dialects/test_mssql.py @@ -0,0 +1,81 @@ +import unittest + +from pypika import Table +from pypika.analytics import Count +from pypika.dialects import MSSQLQuery +from pypika.utils import QueryException + + +class SelectTests(unittest.TestCase): + def test_normal_select(self): + q = MSSQLQuery.from_("abc").select("def") + + self.assertEqual('SELECT "def" FROM "abc"', str(q)) + + def test_distinct_select(self): + q = MSSQLQuery.from_("abc").select("def").distinct() + + self.assertEqual('SELECT DISTINCT "def" FROM "abc"', str(q)) + + def test_top_distinct_select(self): + q = MSSQLQuery.from_("abc").select("def").top(10).distinct() + + self.assertEqual('SELECT DISTINCT TOP (10) "def" FROM "abc"', str(q)) + + def test_top_select(self): + q = MSSQLQuery.from_("abc").select("def").top(10) + + self.assertEqual('SELECT TOP (10) "def" FROM "abc"', str(q)) + + def test_top_with_ties_select(self): + q = MSSQLQuery.from_("abc").select("def").top(10, with_ties=True) + + self.assertEqual('SELECT TOP (10) WITH TIES "def" FROM "abc"', str(q)) + + def test_top_percent_select(self): + q = MSSQLQuery.from_("abc").select("def").top(10, percent=True) + + self.assertEqual('SELECT TOP (10) PERCENT "def" FROM "abc"', str(q)) + + def test_top_percent_invalid_range(self): + for invalid_top in [-1, 101]: + with self.assertRaisesRegex( + QueryException, "TOP value must be between 0 and 100 when `percent` is specified" + ): + MSSQLQuery.from_("abc").select("def").top(invalid_top, percent=True) + + def test_top_select_non_int(self): + with self.assertRaisesRegex(QueryException, "TOP value must be an integer"): + MSSQLQuery.from_("abc").select("def").top("a") + + def test_limit(self): + q = MSSQLQuery.from_("abc").select("def").orderby("def").limit(10) + + self.assertEqual('SELECT "def" FROM "abc" ORDER BY "def" OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY', str(q)) + + def test_offset(self): + q = MSSQLQuery.from_("abc").select("def").orderby("def").offset(10) + + self.assertEqual('SELECT "def" FROM "abc" ORDER BY "def" OFFSET 10 ROWS', str(q)) + + def test_limit_with_offset(self): + q = MSSQLQuery.from_("abc").select("def").orderby("def").limit(10).offset(10) + + self.assertEqual('SELECT "def" FROM "abc" ORDER BY "def" OFFSET 10 ROWS FETCH NEXT 10 ROWS ONLY', str(q)) + + def test_groupby_alias_False_does_not_group_by_alias_with_standard_query(self): + t = Table('table1') + col = t.abc.as_('a') + q = MSSQLQuery.from_(t).select(col, Count('*')).groupby(col) + + self.assertEqual('SELECT "abc" "a",COUNT(\'*\') FROM "table1" GROUP BY "abc"', str(q)) + + def test_groupby_alias_False_does_not_group_by_alias_when_subqueries_are_present(self): + t = Table('table1') + subquery = MSSQLQuery.from_(t).select(t.abc) + col = subquery.abc.as_('a') + q = MSSQLQuery.from_(subquery).select(col, Count('*')).groupby(col) + + self.assertEqual( + 'SELECT "sq0"."abc" "a",COUNT(\'*\') FROM (SELECT "abc" FROM "table1") "sq0" GROUP BY "sq0"."abc"', str(q) + ) diff --git a/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/dialects/test_mysql.py b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/dialects/test_mysql.py new file mode 100644 index 0000000000000000000000000000000000000000..619d064adcdf8b5ff9ecd054fa4ab00eff1d69b3 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/dialects/test_mysql.py @@ -0,0 +1,91 @@ +import unittest + +from pypika import MySQLQuery, QueryException, Table, Column + + +class SelectTests(unittest.TestCase): + table_abc = Table("abc") + + def test_normal_select(self): + q = MySQLQuery.from_("abc").select("def") + + self.assertEqual("SELECT `def` FROM `abc`", str(q)) + + def test_distinct_select(self): + q = MySQLQuery.from_("abc").select("def").distinct() + + self.assertEqual("SELECT DISTINCT `def` FROM `abc`", str(q)) + + def test_modifier_select(self): + q = MySQLQuery.from_("abc").select("def").select("ghi").modifier("SQL_CALC_FOUND_ROWS") + + self.assertEqual("SELECT SQL_CALC_FOUND_ROWS `def`,`ghi` FROM `abc`", str(q)) + + def test_multiple_modifier_select(self): + q = MySQLQuery.from_("abc").select("def").modifier("HIGH_PRIORITY").modifier("SQL_CALC_FOUND_ROWS") + + self.assertEqual("SELECT HIGH_PRIORITY SQL_CALC_FOUND_ROWS `def` FROM `abc`", str(q)) + + +class UpdateTests(unittest.TestCase): + table_abc = Table("abc") + + def test_update(self): + q = MySQLQuery.into("abc").insert(1, [1, "a", True]) + + self.assertEqual("INSERT INTO `abc` VALUES (1,[1,'a',true])", str(q)) + + def test_on_duplicate_key_ignore_update(self): + q = MySQLQuery.into("abc").insert(1, [1, "a", True]).on_duplicate_key_ignore() + + self.assertEqual("INSERT INTO `abc` VALUES (1,[1,'a',true]) ON DUPLICATE KEY IGNORE", str(q)) + + def test_on_duplicate_key_update_update(self): + q = MySQLQuery.into("abc").insert(1, [1, "a", True]).on_duplicate_key_update(self.table_abc.a, 'b') + + self.assertEqual("INSERT INTO `abc` VALUES (1,[1,'a',true]) ON DUPLICATE KEY UPDATE `a`='b'", str(q)) + + def test_conflict_handlers_update(self): + with self.assertRaises(QueryException): + ( + MySQLQuery.into("abc") + .insert(1, [1, "a", True]) + .on_duplicate_key_ignore() + .on_duplicate_key_update(self.table_abc.a, 'b') + ) + + +class LoadCSVTests(unittest.TestCase): + table_abc = Table("abc") + + def test_load_from_file(self): + q1 = MySQLQuery.load("/path/to/file").into("abc") + + q2 = MySQLQuery.load("/path/to/file").into(self.table_abc) + + self.assertEqual( + "LOAD DATA LOCAL INFILE '/path/to/file' INTO TABLE `abc` FIELDS TERMINATED BY ','", + str(q1), + ) + self.assertEqual( + "LOAD DATA LOCAL INFILE '/path/to/file' INTO TABLE `abc` FIELDS TERMINATED BY ','", + str(q2), + ) + + +class TableTests(unittest.TestCase): + table_abc = Table("abc") + + def test_create_table(self): + q = MySQLQuery.create_table(self.table_abc).columns(Column("id", "INT")) + self.assertEqual( + 'CREATE TABLE `abc` (`id` INT)', + str(q), + ) + + def test_drop_table(self): + q = MySQLQuery.drop_table(self.table_abc) + self.assertEqual( + 'DROP TABLE `abc`', + str(q), + ) diff --git a/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/dialects/test_oracle.py b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/dialects/test_oracle.py new file mode 100644 index 0000000000000000000000000000000000000000..21b54f16fd5d3518b5c767d3605068637898a73f --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/dialects/test_oracle.py @@ -0,0 +1,51 @@ +import unittest + +from pypika import OracleQuery, Table +from pypika.analytics import Count + + +class SelectTests(unittest.TestCase): + def test_groupby_alias_False_does_not_group_by_alias_with_standard_query(self): + t = Table('table1') + col = t.abc.as_('a') + q = OracleQuery.from_(t).select(col, Count('*')).groupby(col) + + self.assertEqual('SELECT abc a,COUNT(\'*\') FROM table1 GROUP BY abc', str(q)) + + def test_groupby_alias_False_does_not_group_by_alias_when_subqueries_are_present(self): + t = Table('table1') + subquery = OracleQuery.from_(t).select(t.abc) + col = subquery.abc.as_('a') + q = OracleQuery.from_(subquery).select(col, Count('*')).groupby(col) + + self.assertEqual('SELECT sq0.abc a,COUNT(\'*\') FROM (SELECT abc FROM table1) sq0 GROUP BY sq0.abc', str(q)) + + def test_limit_query(self): + t = Table('table1') + limit = 5 + q = OracleQuery.from_(t).select(t.test).limit(limit) + + self.assertEqual(f'SELECT test FROM table1 FETCH NEXT {limit} ROWS ONLY', str(q)) + + def test_offset_query(self): + t = Table('table1') + offset = 5 + q = OracleQuery.from_(t).select(t.test).offset(offset) + + self.assertEqual(f'SELECT test FROM table1 OFFSET {offset} ROWS', str(q)) + + def test_limit_offset_query(self): + t = Table('table1') + limit = 5 + offset = 5 + q = OracleQuery.from_(t).select(t.test).limit(limit).offset(offset) + + self.assertEqual(f'SELECT test FROM table1 OFFSET {offset} ROWS FETCH NEXT {limit} ROWS ONLY', str(q)) + + def test_fetch_next_method_deprecated(self): + with self.assertWarns(DeprecationWarning): + t = Table('table1') + limit = 5 + q = OracleQuery.from_(t).select(t.test).fetch_next(limit) + + self.assertEqual(f'SELECT test FROM table1 FETCH NEXT {limit} ROWS ONLY', str(q)) diff --git a/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/dialects/test_postgresql.py b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/dialects/test_postgresql.py new file mode 100644 index 0000000000000000000000000000000000000000..437eed03e120485ed2a357a4c2d92426f1466e14 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/dialects/test_postgresql.py @@ -0,0 +1,262 @@ +import unittest +from collections import OrderedDict + +from pypika import ( + Array, + Field, + JSON, + QueryException, + Table, +) +from pypika.dialects import PostgreSQLQuery + + +class InsertTests(unittest.TestCase): + table_abc = Table("abc") + + def test_array_keyword(self): + q = PostgreSQLQuery.into(self.table_abc).insert(1, [1, "a", True]) + + self.assertEqual("INSERT INTO \"abc\" VALUES (1,ARRAY[1,'a',true])", str(q)) + + +class JSONObjectTests(unittest.TestCase): + def test_alias_set_correctly(self): + table = Table('jsonb_table') + q = PostgreSQLQuery.from_('abc').select(table.value.get_text_value('a').as_('name')) + + self.assertEqual('''SELECT "value"->>'a' "name" FROM "abc"''', str(q)) + + def test_json_value_from_dict(self): + q = PostgreSQLQuery.select(JSON({"a": "foo"})) + + self.assertEqual('SELECT \'{"a":"foo"}\'', str(q)) + + def test_json_value_from_array_num(self): + q = PostgreSQLQuery.select(JSON([1, 2, 3])) + + self.assertEqual("SELECT '[1,2,3]'", str(q)) + + def test_json_value_from_array_str(self): + q = PostgreSQLQuery.select(JSON(["a", "b", "c"])) + + self.assertEqual('SELECT \'["a","b","c"]\'', str(q)) + + def test_json_value_from_dict_recursive(self): + q = PostgreSQLQuery.select(JSON({"a": "z", "b": {"c": "foo"}, "d": 1})) + + # gotta split this one up to avoid the indeterminate order + sql = str(q) + start, end = 9, -2 + self.assertEqual("SELECT '{}'", sql[:start] + sql[end:]) + + members_set = set(sql[start:end].split(",")) + self.assertSetEqual({'"a":"z"', '"b":{"c":"foo"}', '"d":1'}, members_set) + + +class JSONOperatorsTests(unittest.TestCase): + # reference https://www.postgresql.org/docs/9.5/functions-json.html + table_abc = Table("abc") + + def test_get_json_value_by_key(self): + q = PostgreSQLQuery.from_(self.table_abc).select("*").where(self.table_abc.json.get_json_value("dates")) + + self.assertEqual('SELECT * FROM "abc" WHERE "json"->\'dates\'', str(q)) + + def test_get_json_value_by_index(self): + q = PostgreSQLQuery.from_(self.table_abc).select("*").where(self.table_abc.json.get_json_value(1)) + + self.assertEqual('SELECT * FROM "abc" WHERE "json"->1', str(q)) + + def test_get_text_value_by_key(self): + q = PostgreSQLQuery.from_(self.table_abc).select("*").where(self.table_abc.json.get_text_value("dates")) + + self.assertEqual('SELECT * FROM "abc" WHERE "json"->>\'dates\'', str(q)) + + def test_get_text_value_by_index(self): + q = PostgreSQLQuery.from_(self.table_abc).select("*").where(self.table_abc.json.get_text_value(1)) + + self.assertEqual('SELECT * FROM "abc" WHERE "json"->>1', str(q)) + + def test_get_path_json_value(self): + q = PostgreSQLQuery.from_(self.table_abc).select("*").where(self.table_abc.json.get_path_json_value("{a,b}")) + + self.assertEqual('SELECT * FROM "abc" WHERE "json"#>\'{a,b}\'', str(q)) + + def test_get_path_text_value(self): + q = PostgreSQLQuery.from_(self.table_abc).select("*").where(self.table_abc.json.get_path_text_value("{a,b}")) + + self.assertEqual('SELECT * FROM "abc" WHERE "json"#>>\'{a,b}\'', str(q)) + + +class JSONBOperatorsTests(unittest.TestCase): + # reference https://www.postgresql.org/docs/9.5/functions-json.html + table_abc = Table("abc") + + def test_json_contains_for_json(self): + q = PostgreSQLQuery.select(JSON({"a": 1, "b": 2}).contains({"a": 1})) + + # gotta split this one up to avoid the indeterminate order + sql = str(q) + start, end = 9, -13 + self.assertEqual("SELECT '{}'@>'{\"a\":1}'", sql[:start] + sql[end:]) + + members_set = set(sql[start:end].split(",")) + self.assertSetEqual({'"a":1', '"b":2'}, members_set) + + def test_json_contains_for_field(self): + q = ( + PostgreSQLQuery.from_(self.table_abc) + .select("*") + .where(self.table_abc.json.contains({"dates": "2018-07-10 - 2018-07-17"})) + ) + + self.assertEqual( + "SELECT * " 'FROM "abc" ' 'WHERE "json"@>\'{"dates":"2018-07-10 - 2018-07-17"}\'', + str(q), + ) + + def test_json_contained_by_using_str_arg(self): + q = ( + PostgreSQLQuery.from_(self.table_abc) + .select("*") + .where( + self.table_abc.json.contained_by( + OrderedDict( + [ + ("dates", "2018-07-10 - 2018-07-17"), + ("imported", "8"), + ] + ) + ) + ) + ) + self.assertEqual( + 'SELECT * FROM "abc" ' 'WHERE "json"<@\'{"dates":"2018-07-10 - 2018-07-17","imported":"8"}\'', + str(q), + ) + + def test_json_contained_by_using_list_arg(self): + q = ( + PostgreSQLQuery.from_(self.table_abc) + .select("*") + .where(self.table_abc.json.contained_by(["One", "Two", "Three"])) + ) + + self.assertEqual('SELECT * FROM "abc" WHERE "json"<@\'["One","Two","Three"]\'', str(q)) + + def test_json_contained_by_with_complex_criterion(self): + q = ( + PostgreSQLQuery.from_(self.table_abc) + .select("*") + .where(self.table_abc.json.contained_by(["One", "Two", "Three"]) & (self.table_abc.id == 26)) + ) + + self.assertEqual( + 'SELECT * FROM "abc" WHERE "json"<@\'["One","Two","Three"]\' AND "id"=26', + str(q), + ) + + def test_json_has_key(self): + q = PostgreSQLQuery.from_(self.table_abc).select("*").where(self.table_abc.json.has_key("dates")) + + self.assertEqual('SELECT * FROM "abc" WHERE "json"?\'dates\'', str(q)) + + def test_json_has_keys(self): + q = PostgreSQLQuery.from_(self.table_abc).select("*").where(self.table_abc.json.has_keys(["dates", "imported"])) + + self.assertEqual("SELECT * FROM \"abc\" WHERE \"json\"?&ARRAY['dates','imported']", str(q)) + + def test_json_has_any_keys(self): + q = ( + PostgreSQLQuery.from_(self.table_abc) + .select("*") + .where(self.table_abc.json.has_any_keys(["dates", "imported"])) + ) + + self.assertEqual("SELECT * FROM \"abc\" WHERE \"json\"?|ARRAY['dates','imported']", str(q)) + + def test_subnet_contains_inet(self): + q = ( + PostgreSQLQuery.from_(self.table_abc) + .select(self.table_abc.a.lshift(2)) + .where(self.table_abc.cidr >> "1.1.1.1") + ) + + self.assertEqual("SELECT \"a\"<<2 FROM \"abc\" WHERE \"cidr\">>'1.1.1.1'", str(q)) + + +class DistinctOnTests(unittest.TestCase): + table_abc = Table("abc") + + def test_distinct_on(self): + q = PostgreSQLQuery.from_(self.table_abc).distinct_on("lname", self.table_abc.fname).select("lname", "id") + + self.assertEqual('''SELECT DISTINCT ON("lname","fname") "lname","id" FROM "abc"''', str(q)) + + +class ArrayTests(unittest.TestCase): + def test_array_syntax(self): + tb = Table("tb") + q = PostgreSQLQuery.from_(tb).select(Array(1, "a", ["b", 2, 3])) + + self.assertEqual(str(q), "SELECT ARRAY[1,'a',ARRAY['b',2,3]] FROM \"tb\"") + + def test_render_alias_in_array_sql(self): + tb = Table("tb") + + q = PostgreSQLQuery.from_(tb).select(Array(tb.col).as_("different_name")) + self.assertEqual(str(q), 'SELECT ARRAY["col"] "different_name" FROM "tb"') + + +class ReturningClauseTests(unittest.TestCase): + @classmethod + def setUpClass(cls) -> None: + super().setUpClass() + cls.table_abc = Table('abc') + + def test_returning_from_missing_table_raises_queryexception(self): + field_from_diff_table = Field('xyz', table=Table('other')) + + with self.assertRaisesRegex(QueryException, "You can't return from other tables"): + ( + PostgreSQLQuery.from_(self.table_abc) + .where(self.table_abc.foo == self.table_abc.bar) + .delete() + .returning(field_from_diff_table) + ) + + def test_queryexception_if_returning_used_on_invalid_query(self): + with self.assertRaisesRegex(QueryException, "Returning can't be used in this query"): + PostgreSQLQuery.from_(self.table_abc).select('abc').returning('abc') + + def test_no_queryexception_if_returning_used_on_valid_query_type(self): + # No exceptions for insert, update and delete queries + with self.subTest('DELETE'): + PostgreSQLQuery.from_(self.table_abc).where(self.table_abc.foo == self.table_abc.bar).delete().returning( + "id" + ) + with self.subTest('UPDATE'): + PostgreSQLQuery.update(self.table_abc).where(self.table_abc.foo == 0).set("foo", "bar").returning("id") + with self.subTest('INSERT'): + PostgreSQLQuery.into(self.table_abc).insert('abc').returning('abc') + + def test_return_field_from_join_table(self): + new_table = Table('xyz') + q = ( + PostgreSQLQuery.update(self.table_abc) + .join(new_table) + .on(new_table.id == self.table_abc.xyz) + .where(self.table_abc.foo == 0) + .set("foo", "bar") + .returning(new_table.a) + ) + + self.assertEqual( + 'UPDATE "abc" ' + 'JOIN "xyz" ON "xyz"."id"="abc"."xyz" ' + 'SET "foo"=\'bar\' ' + 'WHERE "abc"."foo"=0 ' + 'RETURNING "xyz"."a"', + str(q), + ) diff --git a/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/dialects/test_snowflake.py b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/dialects/test_snowflake.py new file mode 100644 index 0000000000000000000000000000000000000000..5ac08b2d8b8b5496ed6f3510acf4be1ec7893405 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/dialects/test_snowflake.py @@ -0,0 +1,58 @@ +import unittest + +from pypika import ( + Tables, + functions as fn, + Column, +) +from pypika.dialects import SnowflakeQuery + + +class QuoteTests(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_use_double_quotes_on_alias_but_not_on_terms(self): + q = SnowflakeQuery.from_(self.table_abc).select(self.table_abc.a.as_("bar")) + + self.assertEqual('SELECT a "bar" FROM abc', q.get_sql(with_namespace=True)) + + def test_use_double_quotes_on_alias_but_not_on_terms_with_joins(self): + foo = self.table_abc.as_("foo") + bar = self.table_efg.as_("bar") + + q = SnowflakeQuery.from_(foo).join(bar).on(foo.fk == bar.id).select(foo.a, bar.b) + + self.assertEqual( + "SELECT foo.a,bar.b " 'FROM abc "foo" ' 'JOIN efg "bar" ' "ON foo.fk=bar.id", + q.get_sql(with_namespace=True), + ) + + def test_use_double_quotes_on_alias_but_not_on_terms(self): + idx = self.table_abc.index.as_("idx") + val = fn.Sum(self.table_abc.value).as_("val") + q = SnowflakeQuery.from_(self.table_abc).select(idx, val).groupby(idx).orderby(idx) + + self.assertEqual( + 'SELECT index "idx",SUM(value) "val" ' "FROM abc " 'GROUP BY "idx" ' 'ORDER BY "idx"', + q.get_sql(with_namespace=True), + ) + + def test_dont_use_double_quotes_on_joining_queries(self): + foo = self.table_abc + bar = self.table_efg + q1 = SnowflakeQuery.from_(foo).select(foo.b) + q2 = SnowflakeQuery.from_(bar).select(bar.b) + q = SnowflakeQuery.from_(q1).join(q2).on(q1.b == q2.b).select("*") + + self.assertEqual( + "SELECT * " 'FROM (SELECT b FROM abc) sq0 ' 'JOIN (SELECT b FROM efg) sq1 ' "ON sq0.b=sq1.b", + q.get_sql(), + ) + + def test_dont_use_double_quotes_on_create_queries(self): + q = SnowflakeQuery.create_table(self.table_abc).columns(Column("id", "INT")) + self.assertEqual("CREATE TABLE abc (id INT)", q.get_sql()) + + def test_dont_use_double_quotes_on_drop_queries(self): + q = SnowflakeQuery.drop_table(self.table_abc) + self.assertEqual("DROP TABLE abc", q.get_sql()) diff --git a/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/dialects/test_sqllite.py b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/dialects/test_sqllite.py new file mode 100644 index 0000000000000000000000000000000000000000..104a7235b6ea2d46fd365989f68c5d081eb20076 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/dialects/test_sqllite.py @@ -0,0 +1,35 @@ +import unittest + +from pypika import Table +from pypika.dialects import SQLLiteQuery + + +class SelectTests(unittest.TestCase): + table_abc = Table("abc") + + def test_bool_true_as_one(self): + q = SQLLiteQuery.from_("abc").select(True) + + self.assertEqual('SELECT 1 FROM "abc"', str(q)) + + def test_bool_false_as_zero(self): + q = SQLLiteQuery.from_("abc").select(False) + + self.assertEqual('SELECT 0 FROM "abc"', str(q)) + + +class ReplaceTests(unittest.TestCase): + def test_normal_replace(self): + query = SQLLiteQuery.into("abc").replace("v1", "v2", "v3") + expected_output = "REPLACE INTO \"abc\" VALUES ('v1','v2','v3')" + self.assertEqual(expected_output, str(query)) + + def test_replace_subquery(self): + query = SQLLiteQuery.into("abc").replace(SQLLiteQuery.from_("def").select("f1", "f2")) + expected_output = 'REPLACE INTO "abc" VALUES ((SELECT "f1","f2" FROM "def"))' + self.assertEqual(expected_output, str(query)) + + def test_insert_or_replace(self): + query = SQLLiteQuery.into("abc").insert_or_replace("v1", "v2", "v3") + expected_output = "INSERT OR REPLACE INTO \"abc\" VALUES ('v1','v2','v3')" + self.assertEqual(expected_output, str(query)) diff --git a/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/dialects/test_vertica.py b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/dialects/test_vertica.py new file mode 100644 index 0000000000000000000000000000000000000000..61985bfc244fcd663e7d8a904b4645901f3abdfc --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/dialects/test_vertica.py @@ -0,0 +1,93 @@ +import unittest + +from pypika import Columns, Table, Tables, VerticaQuery + + +class VerticaQueryTests(unittest.TestCase): + table_abc = Table("abc") + + def test_select_query_with_hint(self): + q = VerticaQuery.from_("abc").select("*").hint("test_hint") + + self.assertEqual('SELECT /*+label(test_hint)*/ * FROM "abc"', str(q)) + + def test_insert_query_with_hint(self): + query = VerticaQuery.into(self.table_abc).insert(1).hint("test_hint") + + self.assertEqual('INSERT /*+label(test_hint)*/ INTO "abc" VALUES (1)', str(query)) + + def test_update_query_with_hint(self): + q = VerticaQuery.update(self.table_abc).set("foo", "bar").hint("test_hint") + + self.assertEqual('UPDATE /*+label(test_hint)*/ "abc" SET "foo"=\'bar\'', str(q)) + + def test_delete_query_with_hint(self): + q = VerticaQuery.from_("abc").delete().hint("test_hint") + + self.assertEqual('DELETE /*+label(test_hint)*/ FROM "abc"', str(q)) + + +class CopyCSVTests(unittest.TestCase): + table_abc = Table("abc") + + def test_copy_from_file(self): + with self.subTest("with table as string"): + q = VerticaQuery.from_file("/path/to/file").copy_("abc") + + self.assertEqual( + "COPY \"abc\" FROM LOCAL '/path/to/file' PARSER fcsvparser(header=false)", + str(q), + ) + + with self.subTest("with table"): + q = VerticaQuery.from_file("/path/to/file").copy_(self.table_abc) + + self.assertEqual( + "COPY \"abc\" FROM LOCAL '/path/to/file' PARSER fcsvparser(header=false)", + str(q), + ) + + +class CreateTemporaryTableTests(unittest.TestCase): + new_table, existing_table = Tables("abc", "efg") + foo, bar = Columns(("a", "INT"), ("b", "VARCHAR(100)")) + select = VerticaQuery.from_(existing_table).select(existing_table.foo, existing_table.bar) + + def test_create_local_temporary_table(self): + with self.subTest("with columns"): + q = VerticaQuery.create_table(self.new_table).temporary().local().columns(self.foo, self.bar) + + self.assertEqual('CREATE LOCAL TEMPORARY TABLE "abc" ("a" INT,"b" VARCHAR(100))', str(q)) + + with self.subTest("with select"): + q = VerticaQuery.create_table(self.new_table).temporary().local().as_select(self.select) + + self.assertEqual( + 'CREATE LOCAL TEMPORARY TABLE "abc" AS (SELECT "foo","bar" FROM "efg")', + str(q), + ) + + def test_create_local_table_without_temporary_raises_error(self): + with self.assertRaises(AttributeError): + VerticaQuery.create_table(self.new_table).local() + + def test_create_temporary_table_preserve_rows(self): + with self.subTest("with columns"): + q = VerticaQuery.create_table(self.new_table).temporary().preserve_rows().columns(self.foo, self.bar) + + self.assertEqual( + 'CREATE TEMPORARY TABLE "abc" ("a" INT,"b" VARCHAR(100)) ON COMMIT PRESERVE ROWS', + str(q), + ) + + with self.subTest("with select"): + q = VerticaQuery.create_table(self.new_table).temporary().preserve_rows().as_select(self.select) + + self.assertEqual( + 'CREATE TEMPORARY TABLE "abc" ON COMMIT PRESERVE ROWS AS (SELECT "foo","bar" FROM "efg")', + str(q), + ) + + def test_create_table_preserve_rows_without_temporary_raises_error(self): + with self.assertRaises(AttributeError): + VerticaQuery.create_table(self.new_table).preserve_rows() diff --git a/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/test_aggregate.py b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/test_aggregate.py new file mode 100644 index 0000000000000000000000000000000000000000..1c627d8e9c2d65410c67cf2c39974949b0720a0e --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/test_aggregate.py @@ -0,0 +1,122 @@ +import unittest + +from pypika import ( + Case, + Field, + Table, + functions as fn, +) +from pypika.terms import ( + Negative, + ValueWrapper, +) + + +class IsAggregateTests(unittest.TestCase): + def test__field_is_not_aggregate(self): + v = Field("foo") + self.assertFalse(v.is_aggregate) + + def test__constant_is_aggregate_none(self): + v = ValueWrapper(100) + self.assertIsNone(v.is_aggregate) + + def test__constant_arithmetic_is_aggregate_none(self): + v = ValueWrapper(100) + ValueWrapper(100) + self.assertIsNone(v.is_aggregate) + + def test__field_arithmetic_is_not_aggregate(self): + v = Field("foo") + Field("bar") + self.assertFalse(v.is_aggregate) + + def test__field_arithmetic_constant_is_not_aggregate(self): + v = Field("foo") + 1 + self.assertFalse(v.is_aggregate) + + def test__agg_func_is_aggregate(self): + v = fn.Sum(Field("foo")) + self.assertTrue(v.is_aggregate) + + def test__negative_agg_func_is_aggregate(self): + v = Negative(fn.Sum(Field("foo"))) + self.assertTrue(v.is_aggregate) + + def test__agg_func_arithmetic_is_aggregate(self): + v = fn.Sum(Field("foo")) / fn.Sum(Field("foo")) + self.assertTrue(v.is_aggregate) + + def test__mixed_func_arithmetic_is_not_aggregate(self): + v = Field("foo") / fn.Sum(Field("foo")) + self.assertFalse(v.is_aggregate) + + def test__func_arithmetic_constant_is_not_aggregate(self): + v = 1 / fn.Sum(Field("foo")) + self.assertTrue(v.is_aggregate) + + def test__agg_case_criterion_is_aggregate(self): + v = Case().when(fn.Sum(Field("foo")) > 666, 'More than 666').else_('Less than 666') + + self.assertTrue(v.is_aggregate) + + def test__agg_case_is_aggregate(self): + v = ( + Case() + .when(Field("foo") == 1, fn.Sum(Field("bar"))) + .when(Field("foo") == 2, fn.Sum(Field("fiz"))) + .else_(fn.Sum(Field("fiz"))) + ) + + self.assertTrue(v.is_aggregate) + + def test__mixed_case_is_not_aggregate(self): + v = Case().when(Field("foo") == 1, fn.Sum(Field("bar"))).when(Field("foo") == 2, Field("fiz")) + + self.assertFalse(v.is_aggregate) + + def test__case_mixed_else_is_not_aggregate(self): + v = ( + Case() + .when(Field("foo") == 1, fn.Sum(Field("bar"))) + .when(Field("foo") == 2, fn.Sum(Field("fiz"))) + .else_(Field("fiz")) + ) + + self.assertFalse(v.is_aggregate) + + def test__case_mixed_constant_is_not_aggregate(self): + v = Case().when(Field("foo") == 1, fn.Sum(Field("bar"))).when(Field("foo") == 2, fn.Sum(Field("fiz"))).else_(1) + + self.assertTrue(v.is_aggregate) + + def test__case_with_field_is_not_aggregate(self): + v = Case().when(Field("foo") == 1, 1).when(Field("foo") == 2, 2).else_(3) + + self.assertFalse(v.is_aggregate) + + def test__case_with_single_aggregate_field_in_one_criterion_is_aggregate(self): + v = Case().when(Field("foo") == 1, 1).when(fn.Sum(Field("foo")) == 2, 2).else_(3) + + self.assertTrue(v.is_aggregate) + + def test__non_aggregate_function_with_aggregated_arg(self): + t = Table("abc") + expr = fn.Sqrt(fn.Sum(t.a)) + + self.assertTrue(expr.is_aggregate) + + def test_complicated(self): + t = Table("abc") + is_placebo = t.campaign_extra_info == "placebo" + + pixel_mobile_search = Case().when(is_placebo, t.action_fb_pixel_search + t.action_fb_mobile_search) + unique_impressions = Case().when(is_placebo, t.unique_impressions) + + v = fn.Sum(pixel_mobile_search) / fn.Sum(unique_impressions) - 1.96 * fn.Sqrt( + 1 + / fn.Sum(unique_impressions) + * fn.Sum(pixel_mobile_search) + / fn.Sum(unique_impressions) + * (1 - fn.Sum(pixel_mobile_search) / fn.Sum(unique_impressions)) + ) + + self.assertTrue(v.is_aggregate) diff --git a/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/test_analytic_queries.py b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/test_analytic_queries.py new file mode 100644 index 0000000000000000000000000000000000000000..6a35ab854b30e3b0f91e633b3349706a22e0a2fd --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/test_analytic_queries.py @@ -0,0 +1,610 @@ +import unittest + +from pypika import Criterion, JoinType, Order, Query, Tables, analytics as an +from pypika.analytics import Lag, Lead + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + + +class RankTests(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_rank(self): + expr = an.Rank().over(self.table_abc.foo).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " "RANK() " 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_dense_rank(self): + expr = an.DenseRank().over(self.table_abc.foo).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " "DENSE_RANK() " 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_row_number(self): + expr = an.RowNumber().over(self.table_abc.foo).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " "ROW_NUMBER() " 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_rank_with_alias(self): + expr = an.Rank().over(self.table_abc.foo).orderby(self.table_abc.date).as_("rank") + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " "RANK() " 'OVER(PARTITION BY "foo" ORDER BY "date") "rank" ' 'FROM "abc"', + str(q), + ) + + def test_multiple_partitions(self): + expr = an.Rank().orderby(self.table_abc.date).over(self.table_abc.foo, self.table_abc.bar) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " "RANK() " 'OVER(PARTITION BY "foo","bar" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_ntile_no_partition_or_order_invalid_sql(self): + expr = an.NTile(5) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual("SELECT " "NTILE(5) " 'FROM "abc"', str(q)) + + def test_ntile_with_partition(self): + expr = an.NTile(5).over(self.table_abc.foo) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual("SELECT " "NTILE(5) " 'OVER(PARTITION BY "foo") ' 'FROM "abc"', str(q)) + + def test_ntile_with_order(self): + expr = an.NTile(5).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual("SELECT " "NTILE(5) " 'OVER(ORDER BY "date") ' 'FROM "abc"', str(q)) + + def test_ntile_with_partition_and_order(self): + expr = an.NTile(5).over(self.table_abc.foo).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " "NTILE(5) " 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_first_value(self): + expr = an.FirstValue(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'FIRST_VALUE("fizz") ' 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_first_value_ignore_nulls(self): + expr = an.FirstValue(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).ignore_nulls() + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'FIRST_VALUE("fizz" IGNORE NULLS) ' 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_first_value_ignore_nulls_first(self): + expr = an.FirstValue(self.table_abc.fizz).ignore_nulls().over(self.table_abc.foo).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'FIRST_VALUE("fizz" IGNORE NULLS) ' 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_first_value_multi_argument(self): + expr = ( + an.FirstValue(self.table_abc.fizz, self.table_abc.buzz) + .over(self.table_abc.foo) + .orderby(self.table_abc.date) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'FIRST_VALUE("fizz","buzz") ' 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_last_value(self): + expr = an.LastValue(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'LAST_VALUE("fizz") ' 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_filter(self): + expr = ( + an.LastValue(self.table_abc.fizz) + .filter(Criterion.all([self.table_abc.bar == True])) + .over(self.table_abc.foo) + .orderby(self.table_abc.date) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'LAST_VALUE("fizz") ' + 'FILTER(WHERE "bar"=true) ' + 'OVER(PARTITION BY "foo" ORDER BY "date") ' + 'FROM "abc"', + str(q), + ) + + def test_filter_quote_table_in_filter(self): + expr = ( + an.LastValue(self.table_efg.fizz) + .filter(self.table_efg.filed.eq('yes')) + .over(self.table_efg.foo) + .orderby(self.table_efg.date) + ) + + q = ( + Query.from_(self.table_abc) + .inner_join(self.table_efg) + .on(self.table_abc.id.eq(self.table_efg.id)) + .select(expr) + ) + + self.assertEqual( + 'SELECT ' + 'LAST_VALUE("efg"."fizz") ' + 'FILTER(WHERE "efg"."filed"=\'yes\') ' + 'OVER(PARTITION BY "efg"."foo" ORDER BY "efg"."date") ' + 'FROM "abc" ' + 'JOIN "efg" ON "abc"."id"="efg"."id"', + str(q), + ) + + def test_orderby_asc(self): + expr = an.LastValue(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date, order=Order.asc) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'LAST_VALUE("fizz") ' 'OVER(PARTITION BY "foo" ORDER BY "date" ASC) ' 'FROM "abc"', + str(q), + ) + + def test_orderby_desc(self): + expr = an.LastValue(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date, order=Order.desc) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'LAST_VALUE("fizz") ' 'OVER(PARTITION BY "foo" ORDER BY "date" DESC) ' 'FROM "abc"', + str(q), + ) + + def test_last_value_multi_argument(self): + expr = ( + an.LastValue(self.table_abc.fizz, self.table_abc.buzz).over(self.table_abc.foo).orderby(self.table_abc.date) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'LAST_VALUE("fizz","buzz") ' 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_last_value_ignore_nulls(self): + expr = an.LastValue(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).ignore_nulls() + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'LAST_VALUE("fizz" IGNORE NULLS) ' 'OVER(PARTITION BY "foo" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_median(self): + expr = an.Median(self.table_abc.fizz).over(self.table_abc.foo, self.table_abc.bar).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'MEDIAN("fizz") ' 'OVER(PARTITION BY "foo","bar" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_avg(self): + expr = an.Avg(self.table_abc.fizz).over(self.table_abc.foo, self.table_abc.bar).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'AVG("fizz") ' 'OVER(PARTITION BY "foo","bar" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_stddev(self): + expr = an.StdDev(self.table_abc.fizz).over(self.table_abc.foo, self.table_abc.bar).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'STDDEV("fizz") ' 'OVER(PARTITION BY "foo","bar" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_stddev_pop(self): + expr = ( + an.StdDevPop(self.table_abc.fizz).over(self.table_abc.foo, self.table_abc.bar).orderby(self.table_abc.date) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'STDDEV_POP("fizz") ' 'OVER(PARTITION BY "foo","bar" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_stddev_samp(self): + expr = ( + an.StdDevSamp(self.table_abc.fizz).over(self.table_abc.foo, self.table_abc.bar).orderby(self.table_abc.date) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'STDDEV_SAMP("fizz") ' 'OVER(PARTITION BY "foo","bar" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_variance(self): + expr = ( + an.Variance(self.table_abc.fizz).over(self.table_abc.foo, self.table_abc.bar).orderby(self.table_abc.date) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'VARIANCE("fizz") ' 'OVER(PARTITION BY "foo","bar" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_var_pop(self): + expr = an.VarPop(self.table_abc.fizz).over(self.table_abc.foo, self.table_abc.bar).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'VAR_POP("fizz") ' 'OVER(PARTITION BY "foo","bar" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_var_samp(self): + expr = an.VarSamp(self.table_abc.fizz).over(self.table_abc.foo, self.table_abc.bar).orderby(self.table_abc.date) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'VAR_SAMP("fizz") ' 'OVER(PARTITION BY "foo","bar" ORDER BY "date") ' 'FROM "abc"', + str(q), + ) + + def test_table_prefixes_used_in_analytic_functions(self): + expr = an.Rank().over(self.table_abc.foo).orderby(self.table_efg.date) + + query = ( + Query.from_(self.table_abc) + .join(self.table_efg, how=JoinType.left) + .on(self.table_abc.foo == self.table_efg.bar) + .select("*", expr) + ) + + self.assertEqual( + 'SELECT *,RANK() OVER(PARTITION BY "abc"."foo" ORDER BY "efg"."date") ' + 'FROM "abc" LEFT JOIN "efg" ON "abc"."foo"="efg"."bar"', + str(query), + ) + + def test_sum_rows_unbounded_preceeding(self): + expr = an.Sum(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).rows(an.Preceding()) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'SUM("fizz") ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "ROWS UNBOUNDED PRECEDING" + ") " + 'FROM "abc"', + str(q), + ) + + def test_max_rows_x_preceeding(self): + expr = an.Max(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).rows(an.Preceding(5)) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'MAX("fizz") ' "OVER(" 'PARTITION BY "foo" ORDER BY "date" ' "ROWS 5 PRECEDING" ") " 'FROM "abc"', + str(q), + ) + + def test_min_rows_current_row(self): + expr = an.Min(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).rows(an.CURRENT_ROW) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " 'MIN("fizz") ' "OVER(" 'PARTITION BY "foo" ORDER BY "date" ' "ROWS CURRENT ROW" ") " 'FROM "abc"', + str(q), + ) + + def test_varpop_range_unbounded_preceeding(self): + expr = ( + an.VarPop(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).range(an.Preceding()) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'VAR_POP("fizz") ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "RANGE UNBOUNDED PRECEDING" + ") " + 'FROM "abc"', + str(q), + ) + + def test_max_range_x_preceeding(self): + expr = an.Max(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).range(an.Preceding(5)) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'MAX("fizz") ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "RANGE 5 PRECEDING" + ") " + 'FROM "abc"', + str(q), + ) + + def test_min_range_current_row(self): + expr = an.Min(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).range(an.CURRENT_ROW) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'MIN("fizz") ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "RANGE CURRENT ROW" + ") " + 'FROM "abc"', + str(q), + ) + + def test_variance_rows_between_unbounded_preceeding_unbounded_following(self): + expr = ( + an.Variance(self.table_abc.fizz) + .over(self.table_abc.foo) + .orderby(self.table_abc.date) + .rows(an.Preceding(), an.Following()) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'VARIANCE("fizz") ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING" + ") " + 'FROM "abc"', + str(q), + ) + + def test_first_value_range_between_x_preceeding_unbounded_following(self): + expr = ( + an.FirstValue(self.table_abc.fizz) + .over(self.table_abc.foo) + .orderby(self.table_abc.date) + .range(an.Preceding(3), an.Following()) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'FIRST_VALUE("fizz") ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "RANGE BETWEEN 3 PRECEDING AND UNBOUNDED FOLLOWING" + ") " + 'FROM "abc"', + str(q), + ) + + def test_varpop_rows_between_unbounded_preceeding_x_following(self): + expr = ( + an.VarPop(self.table_abc.fizz) + .over(self.table_abc.foo) + .orderby(self.table_abc.date) + .rows(an.Preceding(), an.Following(6)) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'VAR_POP("fizz") ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "ROWS BETWEEN UNBOUNDED PRECEDING AND 6 FOLLOWING" + ") " + 'FROM "abc"', + str(q), + ) + + def test_count_range_between_unbounded_preceeding_current_row(self): + expr = ( + an.Count(self.table_abc.fizz) + .over(self.table_abc.foo) + .orderby(self.table_abc.date) + .range(an.Preceding(), an.CURRENT_ROW) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'COUNT("fizz") ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW" + ") " + 'FROM "abc"', + str(q), + ) + + def test_last_value_rows_between_current_row_unbounded_following(self): + expr = ( + an.LastValue(self.table_abc.fizz) + .over(self.table_abc.foo) + .orderby(self.table_abc.date) + .rows(an.CURRENT_ROW, an.Following()) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'LAST_VALUE("fizz") ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING" + ") " + 'FROM "abc"', + str(q), + ) + + def test_last_value_rows_between_current_row_unbounded_following_ignore_nulls(self): + expr = ( + an.LastValue(self.table_abc.fizz) + .over(self.table_abc.foo) + .orderby(self.table_abc.date) + .ignore_nulls() + .rows(an.CURRENT_ROW, an.Following(8)) + ) + + q = Query.from_(self.table_abc).select(expr) + + self.assertEqual( + "SELECT " + 'LAST_VALUE("fizz" IGNORE NULLS) ' + "OVER(" + 'PARTITION BY "foo" ORDER BY "date" ' + "ROWS BETWEEN CURRENT ROW AND 8 FOLLOWING" + ") " + 'FROM "abc"', + str(q), + ) + + def test_empty_over(self): + query = Query.from_(self.table_abc).select(an.Sum(self.table_abc.fizz).over()) + + self.assertEqual("SELECT " 'SUM("fizz") OVER() ' 'FROM "abc"', str(query)) + + def test_rows_called_twice_raises_attribute_error(self): + with self.assertRaises(AttributeError): + an.Sum(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).rows(an.Preceding()).rows( + an.Preceding() + ) + + def test_range_called_twice_raises_attribute_error(self): + with self.assertRaises(AttributeError): + an.Sum(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).range( + an.Preceding() + ).range(an.Preceding()) + + def test_rows_then_range_raises_attribute_error(self): + with self.assertRaises(AttributeError): + an.Sum(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).rows( + an.Preceding() + ).range(an.Preceding()) + + def test_range_then_rows_raises_attribute_error(self): + with self.assertRaises(AttributeError): + an.Sum(self.table_abc.fizz).over(self.table_abc.foo).orderby(self.table_abc.date).range( + an.Preceding() + ).rows(an.Preceding()) + + def test_lag_generates_correct_sql(self): + with self.subTest('without partition by'): + q = Query.from_(self.table_abc).select( + Lag(self.table_abc.date, 1, '2000-01-01').orderby(self.table_abc.date) + ) + + self.assertEqual('SELECT LAG("date",1,\'2000-01-01\') OVER(ORDER BY "date") FROM "abc"', str(q)) + + with self.subTest('with partition by'): + q = Query.from_(self.table_abc).select( + Lag(self.table_abc.date, 1, '2000-01-01').over(self.table_abc.foo).orderby(self.table_abc.date) + ) + + self.assertEqual( + 'SELECT LAG("date",1,\'2000-01-01\') OVER(PARTITION BY "foo" ORDER BY "date") FROM "abc"', str(q) + ) + + def test_lead_generates_correct_sql(self): + with self.subTest('without partition by'): + q = Query.from_(self.table_abc).select( + Lead(self.table_abc.date, 1, '2000-01-01').orderby(self.table_abc.date) + ) + + self.assertEqual('SELECT LEAD("date",1,\'2000-01-01\') OVER(ORDER BY "date") FROM "abc"', str(q)) + + with self.subTest('with partition by'): + q = Query.from_(self.table_abc).select( + Lead(self.table_abc.date, 1, '2000-01-01').over(self.table_abc.foo).orderby(self.table_abc.date) + ) + + self.assertEqual( + 'SELECT LEAD("date",1,\'2000-01-01\') OVER(PARTITION BY "foo" ORDER BY "date") FROM "abc"', str(q) + ) diff --git a/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/test_create.py b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/test_create.py new file mode 100644 index 0000000000000000000000000000000000000000..325076544e3824b0d07f82f2378b88218b910dde --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/test_create.py @@ -0,0 +1,210 @@ +import unittest + +from pypika import Column, Columns, Query, Tables, Table +from pypika.terms import ValueWrapper, Index +from pypika.enums import ReferenceOption + + +class CreateTableTests(unittest.TestCase): + new_table, existing_table = Tables("abc", "efg") + foo, bar = Columns(("a", "INT"), ("b", "VARCHAR(100)")) + + def test_create_table_with_columns(self): + with self.subTest("with nullable"): + a = Column("a", "INT", True) + b = Column("b", "VARCHAR(100)", False) + q = Query.create_table(self.new_table).columns(a, b) + + self.assertEqual('CREATE TABLE "abc" ("a" INT NULL,"b" VARCHAR(100) NOT NULL)', str(q)) + + with self.subTest("with defaults"): + a = Column("a", "INT", default=ValueWrapper(42)) + b = Column("b", "VARCHAR(100)", default=ValueWrapper("foo")) + q = Query.create_table(self.new_table).columns(a, b) + + self.assertEqual('CREATE TABLE "abc" ("a" INT DEFAULT 42,"b" VARCHAR(100) DEFAULT \'foo\')', str(q)) + + with self.subTest("with unwrapped defaults"): + a = Column("a", "INT", default=42) + b = Column("b", "VARCHAR(100)", default="foo") + q = Query.create_table(self.new_table).columns(a, b) + + self.assertEqual('CREATE TABLE "abc" ("a" INT DEFAULT 42,"b" VARCHAR(100) DEFAULT \'foo\')', str(q)) + + with self.subTest("with period for"): + a = Column("id", "INT") + b = Column("valid_from", "DATETIME") + c = Column("valid_to", "DATETIME") + q = Query.create_table(self.new_table).columns(a, b, c).period_for('valid_period', b, c) + + self.assertEqual( + 'CREATE TABLE "abc" (' + '"id" INT,' + '"valid_from" DATETIME,' + '"valid_to" DATETIME,' + 'PERIOD FOR "valid_period" ("valid_from","valid_to"))', + str(q), + ) + + with self.subTest("without temporary keyword"): + q = Query.create_table(self.new_table).columns(self.foo, self.bar) + + self.assertEqual('CREATE TABLE "abc" ("a" INT,"b" VARCHAR(100))', str(q)) + + with self.subTest("with temporary keyword"): + q = Query.create_table(self.new_table).temporary().columns(self.foo, self.bar) + + self.assertEqual('CREATE TEMPORARY TABLE "abc" ("a" INT,"b" VARCHAR(100))', str(q)) + + with self.subTest("with primary key"): + q = Query.create_table(self.new_table).columns(self.foo, self.bar).primary_key(self.foo, self.bar) + + self.assertEqual('CREATE TABLE "abc" ("a" INT,"b" VARCHAR(100),PRIMARY KEY ("a","b"))', str(q)) + + with self.subTest("with simple foreign key"): + cref, dref = Columns(("c", "INT"), ("d", "VARCHAR(100)")) + q = ( + Query.create_table(self.new_table) + .columns(self.foo, self.bar) + .foreign_key([self.foo, self.bar], self.existing_table, [cref, dref]) + ) + + self.assertEqual( + 'CREATE TABLE "abc" (' + '"a" INT,' + '"b" VARCHAR(100),' + 'FOREIGN KEY ("a","b") REFERENCES "efg" ("c","d"))', + str(q), + ) + + with self.subTest("with foreign key reference options"): + cref, dref = Columns(("c", "INT"), ("d", "VARCHAR(100)")) + q = ( + Query.create_table(self.new_table) + .columns(self.foo, self.bar) + .foreign_key( + [self.foo, self.bar], + self.existing_table, + [cref, dref], + on_delete=ReferenceOption.cascade, + on_update=ReferenceOption.restrict, + ) + ) + + self.assertEqual( + 'CREATE TABLE "abc" (' + '"a" INT,' + '"b" VARCHAR(100),' + 'FOREIGN KEY ("a","b") REFERENCES "efg" ("c","d") ON DELETE CASCADE ON UPDATE RESTRICT)', + str(q), + ) + + with self.subTest("with unique keys"): + q = ( + Query.create_table(self.new_table) + .columns(self.foo, self.bar) + .unique(self.foo, self.bar) + .unique(self.foo) + ) + + self.assertEqual('CREATE TABLE "abc" ("a" INT,"b" VARCHAR(100),UNIQUE ("a","b"),UNIQUE ("a"))', str(q)) + + with self.subTest("with system versioning"): + q = Query.create_table(self.new_table).columns(self.foo, self.bar).with_system_versioning() + + self.assertEqual('CREATE TABLE "abc" ("a" INT,"b" VARCHAR(100)) WITH SYSTEM VERSIONING', str(q)) + + with self.subTest("with unlogged keyword"): + q = Query.create_table(self.new_table).unlogged().columns(self.foo, self.bar) + + self.assertEqual('CREATE UNLOGGED TABLE "abc" ("a" INT,"b" VARCHAR(100))', str(q)) + + with self.subTest("with if not exists keyword"): + q = Query.create_table(self.new_table).if_not_exists().columns(self.foo, self.bar) + + self.assertEqual('CREATE TABLE IF NOT EXISTS "abc" ("a" INT,"b" VARCHAR(100))', str(q)) + + def test_create_table_with_select(self): + select = Query.from_(self.existing_table).select(self.existing_table.foo, self.existing_table.bar) + + with self.subTest("without temporary keyword"): + q = Query.create_table(self.new_table).as_select(select) + + self.assertEqual('CREATE TABLE "abc" AS (SELECT "foo","bar" FROM "efg")', str(q)) + + with self.subTest("with temporary keyword"): + q = Query.create_table(self.new_table).temporary().as_select(select) + + self.assertEqual( + 'CREATE TEMPORARY TABLE "abc" AS (SELECT "foo","bar" FROM "efg")', + str(q), + ) + + def test_create_table_without_columns_or_select_empty(self): + q = Query.create_table(self.new_table) + + self.assertEqual("", str(q)) + + def test_create_table_with_select_and_columns_fails(self): + select = Query.from_(self.existing_table).select(self.existing_table.foo, self.existing_table.bar) + + with self.subTest("for columns before as_select"): + with self.assertRaises(AttributeError): + Query.create_table(self.new_table).columns(self.foo, self.bar).as_select(select) + + with self.subTest("for as_select before columns"): + with self.assertRaises(AttributeError): + Query.create_table(self.new_table).as_select(select).columns(self.foo, self.bar) + + with self.subTest("repeated foreign key"): + with self.assertRaises(AttributeError): + Query.create_table(self.new_table).foreign_key([self.foo], self.existing_table, [self.bar]).foreign_key( + [self.foo], self.existing_table, [self.bar] + ) + + def test_create_table_as_select_not_query_raises_error(self): + with self.assertRaises(TypeError): + Query.create_table(self.new_table).as_select("abc") + + +class CreateIndexTests(unittest.TestCase): + new_index = Index("abc") + new_table = Table("my_table") + columns = (new_table.a, new_table.b) + where = new_table.a > 1 + + def test_create_index_simple(self) -> None: + q = Query.create_index(self.new_index).on(self.new_table).columns(*self.columns) + self.assertEqual( + f'CREATE INDEX "{self.new_index.name}" ON "{self.new_table.get_table_name()}"({", ".join([c.name for c in self.columns])})', + q.get_sql(), + ) + + def test_create_index_where(self) -> None: + q = Query.create_index(self.new_index).on(self.new_table).columns(*self.columns).where(self.where) + self.assertEqual( + f'CREATE INDEX "{self.new_index.name}" ON "{self.new_table.get_table_name()}"({", ".join([c.name for c in self.columns])}) WHERE {self.where.get_sql()}', + q.get_sql(), + ) + + def test_create_index_unique(self) -> None: + q = Query.create_index(self.new_index).on(self.new_table).columns(*self.columns).unique() + self.assertEqual( + f'CREATE UNIQUE INDEX "{self.new_index.name}" ON "{self.new_table.get_table_name()}"({", ".join([c.name for c in self.columns])})', + q.get_sql(), + ) + + def test_create_index_if_not_exists(self) -> None: + q = Query.create_index(self.new_index).on(self.new_table).columns(*self.columns).if_not_exists() + self.assertEqual( + f'CREATE INDEX IF NOT EXISTS "{self.new_index.name}" ON "{self.new_table.get_table_name()}"({", ".join([c.name for c in self.columns])})', + q.get_sql(), + ) + + def test_create_index_without_columns_raises_error(self) -> None: + with self.assertRaises(AttributeError): + Query.create_index(self.new_index).on(self.new_table).get_sql() + + def test_create_index_without_table_raises_error(self) -> None: + with self.assertRaises(AttributeError): + Query.create_index(self.new_index).columns(*self.columns).get_sql() diff --git a/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/test_criterions.py b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/test_criterions.py new file mode 100644 index 0000000000000000000000000000000000000000..fca2ceeeb18db88e34ebc38776f644fdcda67e93 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/test_criterions.py @@ -0,0 +1,873 @@ +import unittest +from datetime import ( + date, + datetime, +) + +from pypika import ( + Criterion, + EmptyCriterion, + Field, + Table, + functions as fn, +) +from pypika.queries import QueryBuilder +from pypika.terms import ExistsCriterion, Mod + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + + +class CriterionTests(unittest.TestCase): + t = Table("test", alias="crit") + + def test__criterion_with_alias(self): + c1 = (Field("foo") == Field("bar")).as_("criterion") + + self.assertEqual('"foo"="bar"', str(c1)) + self.assertEqual('"foo"="bar" "criterion"', c1.get_sql(with_alias=True, quote_char='"', alias_quote_char='"')) + + def test__criterion_eq_number(self): + c1 = Field("foo") == 1 + c2 = Field("foo", table=self.t).eq(0) + c3 = Field("foo", table=self.t) == -1 + + self.assertEqual('"foo"=1', str(c1)) + self.assertEqual('"crit"."foo"=0', str(c2)) + self.assertEqual('"crit"."foo"=-1', str(c3)) + + def test__criterion_eq_decimal(self): + c1 = Field("foo") == 1.0 + c2 = Field("foo", table=self.t).eq(0.5) + + self.assertEqual('"foo"=1.0', str(c1)) + self.assertEqual('"crit"."foo"=0.5', str(c2)) + + def test__criterion_eq_bool(self): + c1 = Field("foo") == True + c2 = Field("foo", table=self.t).eq(True) + c3 = Field("foo") == False + c4 = Field("foo", table=self.t).eq(False) + + self.assertEqual('"foo"=true', str(c1)) + self.assertEqual('"crit"."foo"=true', str(c2)) + self.assertEqual('"foo"=false', str(c3)) + self.assertEqual('"crit"."foo"=false', str(c4)) + + def test__criterion_eq_str(self): + c1 = Field("foo") == "abc" + c2 = Field("foo", table=self.t).eq("abc") + + self.assertEqual("\"foo\"='abc'", str(c1)) + self.assertEqual('"crit"."foo"=\'abc\'', str(c2)) + + def test__criterion_eq_date(self): + c1 = Field("foo") == date(2000, 1, 1) + c2 = Field("foo", table=self.t).eq(date(2000, 1, 1)) + + self.assertEqual("\"foo\"='2000-01-01'", str(c1)) + self.assertEqual('"crit"."foo"=\'2000-01-01\'', str(c2)) + + def test__criterion_eq_datetime(self): + c1 = Field("foo") == datetime(2000, 1, 1, 12, 30, 55) + c2 = Field("foo", table=self.t).eq(datetime(2000, 1, 1, 12, 30, 55)) + + self.assertEqual("\"foo\"='2000-01-01T12:30:55'", str(c1)) + self.assertEqual('"crit"."foo"=\'2000-01-01T12:30:55\'', str(c2)) + + def test__criterion_eq_right(self): + c1 = 1 == Field("foo") + c2 = -1 == Field("foo", table=self.t) + + self.assertEqual('"foo"=1', str(c1)) + self.assertEqual('"crit"."foo"=-1', str(c2)) + + def test__criterion_is_null(self): + c1 = Field("foo").isnull() + c2 = Field("foo", table=self.t).isnull() + + self.assertEqual('"foo" IS NULL', str(c1)) + self.assertEqual('"crit"."foo" IS NULL', str(c2)) + + def test__criterion_is_null_with_alias(self): + c1 = Field("foo").isnull().as_('alias') + c2 = Field("foo", table=self.t).isnull().as_('alias') + + self.assertEqual('"foo" IS NULL "alias"', str(c1)) + self.assertEqual('"crit"."foo" IS NULL "alias"', str(c2)) + + def test__criterion_ne_number(self): + c1 = Field("foo") != 1 + c2 = Field("foo", table=self.t).ne(0) + c3 = Field("foo") != -1 + + self.assertEqual('"foo"<>1', str(c1)) + self.assertEqual('"crit"."foo"<>0', str(c2)) + self.assertEqual('"foo"<>-1', str(c3)) + + def test__criterion_ne_str(self): + c1 = Field("foo") != "abc" + c2 = Field("foo", table=self.t).ne("abc") + + self.assertEqual("\"foo\"<>'abc'", str(c1)) + self.assertEqual('"crit"."foo"<>\'abc\'', str(c2)) + + def test__criterion_ne_date(self): + c1 = Field("foo") != date(2000, 1, 1) + c2 = Field("foo", table=self.t).ne(date(2000, 1, 1)) + + self.assertEqual("\"foo\"<>'2000-01-01'", str(c1)) + self.assertEqual('"crit"."foo"<>\'2000-01-01\'', str(c2)) + + def test__criterion_ne_datetime(self): + c1 = Field("foo") != datetime(2000, 1, 1, 12, 30, 55) + c2 = Field("foo", table=self.t).ne(datetime(2000, 1, 1, 12, 30, 55)) + + self.assertEqual("\"foo\"<>'2000-01-01T12:30:55'", str(c1)) + self.assertEqual('"crit"."foo"<>\'2000-01-01T12:30:55\'', str(c2)) + + def test__criterion_ne_right(self): + c1 = 1 != Field("foo") + c2 = -1 != Field("foo", table=self.t) + + self.assertEqual('"foo"<>1', str(c1)) + self.assertEqual('"crit"."foo"<>-1', str(c2)) + + def test__criterion_lt_number(self): + c1 = Field("foo") < 1 + c2 = Field("foo", table=self.t).lt(0) + c3 = Field("foo") < -1 + + self.assertEqual('"foo"<1', str(c1)) + self.assertEqual('"crit"."foo"<0', str(c2)) + self.assertEqual('"foo"<-1', str(c3)) + + def test__criterion_lt_date(self): + c1 = Field("foo") < date(2000, 1, 1) + c2 = Field("foo", table=self.t).lt(date(2000, 1, 1)) + + self.assertEqual("\"foo\"<'2000-01-01'", str(c1)) + self.assertEqual('"crit"."foo"<\'2000-01-01\'', str(c2)) + + def test__criterion_lt_datetime(self): + c1 = Field("foo") < datetime(2000, 1, 1, 12, 30, 55) + c2 = Field("foo", table=self.t).lt(datetime(2000, 1, 1, 12, 30, 55)) + + self.assertEqual("\"foo\"<'2000-01-01T12:30:55'", str(c1)) + self.assertEqual('"crit"."foo"<\'2000-01-01T12:30:55\'', str(c2)) + + def test__criterion_lt_right(self): + c1 = 1 > Field("foo") + c2 = -1 > Field("foo", table=self.t) + + self.assertEqual('"foo"<1', str(c1)) + self.assertEqual('"crit"."foo"<-1', str(c2)) + + def test__criterion_gt_number(self): + c1 = Field("foo") > 1 + c2 = Field("foo", table=self.t).gt(0) + c3 = Field("foo") > -1 + + self.assertEqual('"foo">1', str(c1)) + self.assertEqual('"crit"."foo">0', str(c2)) + self.assertEqual('"foo">-1', str(c3)) + + def test__criterion_gt_date(self): + c1 = Field("foo") > date(2000, 1, 1) + c2 = Field("foo", table=self.t).gt(date(2000, 1, 1)) + + self.assertEqual("\"foo\">'2000-01-01'", str(c1)) + self.assertEqual('"crit"."foo">\'2000-01-01\'', str(c2)) + + def test__criterion_gt_datetime(self): + c1 = Field("foo") > datetime(2000, 1, 1, 12, 30, 55) + c2 = Field("foo", table=self.t).gt(datetime(2000, 1, 1, 12, 30, 55)) + + self.assertEqual("\"foo\">'2000-01-01T12:30:55'", str(c1)) + self.assertEqual('"crit"."foo">\'2000-01-01T12:30:55\'', str(c2)) + + def test__criterion_gt_right(self): + c1 = 1 < Field("foo") + c2 = -1 < Field("foo", table=self.t) + + self.assertEqual('"foo">1', str(c1)) + self.assertEqual('"crit"."foo">-1', str(c2)) + + def test__criterion_lte_number(self): + c1 = Field("foo") <= 1 + c2 = Field("foo", table=self.t).lte(0) + c3 = Field("foo") <= -1 + + self.assertEqual('"foo"<=1', str(c1)) + self.assertEqual('"crit"."foo"<=0', str(c2)) + self.assertEqual('"foo"<=-1', str(c3)) + + def test__criterion_lte_date(self): + c1 = Field("foo") <= date(2000, 1, 1) + c2 = Field("foo", table=self.t).lte(date(2000, 1, 1)) + + self.assertEqual("\"foo\"<='2000-01-01'", str(c1)) + self.assertEqual('"crit"."foo"<=\'2000-01-01\'', str(c2)) + + def test__criterion_lte_datetime(self): + c1 = Field("foo") <= datetime(2000, 1, 1, 12, 30, 55) + c2 = Field("foo", table=self.t).lte(datetime(2000, 1, 1, 12, 30, 55)) + + self.assertEqual("\"foo\"<='2000-01-01T12:30:55'", str(c1)) + self.assertEqual('"crit"."foo"<=\'2000-01-01T12:30:55\'', str(c2)) + + def test__criterion_lte_right(self): + c1 = 1 >= Field("foo") + c2 = -1 >= Field("foo", table=self.t) + + self.assertEqual('"foo"<=1', str(c1)) + self.assertEqual('"crit"."foo"<=-1', str(c2)) + + def test__criterion_gte_number(self): + c1 = Field("foo") >= 1 + c2 = Field("foo", table=self.t).gte(0) + c3 = Field("foo") >= -1 + + self.assertEqual('"foo">=1', str(c1)) + self.assertEqual('"crit"."foo">=0', str(c2)) + self.assertEqual('"foo">=-1', str(c3)) + + def test__criterion_gte_date(self): + c1 = Field("foo") >= date(2000, 1, 1) + c2 = Field("foo", table=self.t).gte(date(2000, 1, 1)) + + self.assertEqual("\"foo\">='2000-01-01'", str(c1)) + self.assertEqual('"crit"."foo">=\'2000-01-01\'', str(c2)) + + def test__criterion_gte_datetime(self): + c1 = Field("foo") >= datetime(2000, 1, 1, 12, 30, 55) + c2 = Field("foo", table=self.t).gte(datetime(2000, 1, 1, 12, 30, 55)) + + self.assertEqual("\"foo\">='2000-01-01T12:30:55'", str(c1)) + self.assertEqual('"crit"."foo">=\'2000-01-01T12:30:55\'', str(c2)) + + def test__criterion_gte_right(self): + c1 = 1 <= Field("foo") + c2 = -1 <= Field("foo", table=self.t) + + self.assertEqual('"foo">=1', str(c1)) + self.assertEqual('"crit"."foo">=-1', str(c2)) + + def test__criterion_bitwise_and(self): + c1 = Field("foo").bitwiseand(2) + c2 = Field("foo", table=self.t).bitwiseand(10) == 2 + + self.assertEqual('("foo" & 2)', str(c1)) + self.assertEqual('("crit"."foo" & 10)=2', str(c2)) + + def test__criterion_bitwise_and_with_alias(self): + c1 = Field("foo").bitwiseand(2).as_('alias') + + self.assertEqual('("foo" & 2) "alias"', str(c1)) + + def test__bitwise_and_in_where_clause(self): + q = QueryBuilder().from_('items').select('abc').where(Field("foo").bitwiseand(1) == 1) + + self.assertEqual('SELECT "abc" FROM "items" WHERE ("foo" & 1)=1', str(q)) + + +class NotTests(unittest.TestCase): + table_abc, table_efg = Table("abc", alias="cx0"), Table("efg", alias="cx1") + + def test_negate(self): + c1 = Field("foo") >= 1 + c2 = c1.negate() + + self.assertEqual('"foo">=1', str(c1)) + self.assertEqual('NOT "foo">=1', str(c2)) + + def test_variable_access(self): + c1 = Field("foo").negate() + + self.assertEqual(c1.is_aggregate, False) + + def test_chained_function(self): + field1 = Field("foo").negate() + field2 = field1.eq("bar") + + self.assertEqual('NOT "foo"', str(field1)) + self.assertEqual("NOT \"foo\"='bar'", str(field2)) + self.assertIsNot(field1, field2) + + def test_not_null(self): + c1 = Field("foo").notnull() + c2 = Field("foo", table=self.table_abc).notnull() + + self.assertEqual('NOT "foo" IS NULL', str(c1)) + self.assertEqual('NOT "cx0"."foo" IS NULL', str(c2)) + + def test_is_not_null(self): + c1 = Field("foo").isnotnull() + c2 = Field("foo", table=self.table_abc).isnotnull() + + self.assertEqual('"foo" IS NOT NULL', str(c1)) + self.assertEqual('"cx0"."foo" IS NOT NULL', str(c2)) + + def test_not_null_with_alias(self): + c1 = Field("foo").notnull().as_("something") + c2 = Field("foo", table=self.table_abc).notnull().as_("something") + + self.assertEqual('NOT "foo" IS NULL "something"', str(c1)) + self.assertEqual('NOT "cx0"."foo" IS NULL "something"', str(c2)) + + def test_notnullcriterion_replace_table(self): + f = self.table_abc.foo.notnull().replace_table(self.table_abc, self.table_efg) + + self.assertEqual('NOT "cx1"."foo" IS NULL', str(f)) + + def test_not_with_or_criterion(self): + self.assertEqual('NOT ("foo" OR "bar")', str(~(Field("foo") | Field("bar")))) + + def test_not_with_and_criterion(self): + self.assertEqual('NOT ("foo" AND "bar")', str(~(Field("foo") & Field("bar")))) + + def test_not_with_complex_criterion(self): + self.assertEqual( + 'NOT ("foo" AND "bar" AND "fizz" AND "buzz")', + str(~(Field("foo") & Field("bar") & Field("fizz") & Field("buzz"))), + ) + + +class BetweenTests(unittest.TestCase): + t = Table("abc", alias="btw") + + def test__between_number(self): + c1 = Field("foo").between(0, 1) + c2 = Field("foo", table=self.t).between(0, 1) + c3 = Field("foo")[0:1] + + self.assertEqual('"foo" BETWEEN 0 AND 1', str(c1)) + self.assertEqual('"btw"."foo" BETWEEN 0 AND 1', str(c2)) + self.assertEqual('"foo" BETWEEN 0 AND 1', str(c3)) + + def test__between_with_alias(self): + c1 = Field("foo").between(0, 1).as_('alias') + c2 = Field("foo", table=self.t).between(0, 1).as_('alias') + c3 = Field("foo")[0:1].as_('alias') + + self.assertEqual('"foo" BETWEEN 0 AND 1 "alias"', str(c1)) + self.assertEqual('"btw"."foo" BETWEEN 0 AND 1 "alias"', str(c2)) + self.assertEqual('"foo" BETWEEN 0 AND 1 "alias"', str(c3)) + + def test__between_date(self): + c1 = Field("foo").between(date(2000, 1, 1), date(2000, 12, 31)) + c2 = Field("foo", table=self.t).between(date(2000, 1, 1), date(2000, 12, 31)) + c3 = Field("foo")[date(2000, 1, 1) : date(2000, 12, 31)] + + self.assertEqual("\"foo\" BETWEEN '2000-01-01' AND '2000-12-31'", str(c1)) + self.assertEqual("\"btw\".\"foo\" BETWEEN '2000-01-01' AND '2000-12-31'", str(c2)) + self.assertEqual("\"foo\" BETWEEN '2000-01-01' AND '2000-12-31'", str(c3)) + + def test__between_datetime(self): + c1 = Field("foo").between(datetime(2000, 1, 1, 0, 0, 0), datetime(2000, 12, 31, 23, 59, 59)) + c2 = Field("foo", table=self.t).between(datetime(2000, 1, 1, 0, 0, 0), datetime(2000, 12, 31, 23, 59, 59)) + c3 = Field("foo")[datetime(2000, 1, 1, 0, 0, 0) : datetime(2000, 12, 31, 23, 59, 59)] + + self.assertEqual("\"foo\" BETWEEN '2000-01-01T00:00:00' AND '2000-12-31T23:59:59'", str(c1)) + self.assertEqual( + "\"btw\".\"foo\" BETWEEN '2000-01-01T00:00:00' AND '2000-12-31T23:59:59'", + str(c2), + ) + self.assertEqual("\"foo\" BETWEEN '2000-01-01T00:00:00' AND '2000-12-31T23:59:59'", str(c3)) + + def test__function_between(self): + c1 = fn.Coalesce(Field("foo"), 0)[0:1] + c2 = fn.Coalesce(Field("foo", table=self.t), 0)[0:1] + + self.assertEqual('COALESCE("foo",0) BETWEEN 0 AND 1', str(c1)) + self.assertEqual('COALESCE("btw"."foo",0) BETWEEN 0 AND 1', str(c2)) + + def test_get_item_only_works_with_slice(self): + with self.assertRaises(TypeError): + Field("foo")[0] + + with self.assertRaises(TypeError): + Field("foo")[date(2000, 1, 1)] + + with self.assertRaises(TypeError): + Field("foo")[datetime(2000, 1, 1, 0, 0, 0)] + + +class IsInTests(unittest.TestCase): + t = Table("abc", alias="isin") + + def test__in_number(self): + c1 = Field("foo").isin([0, 1]) + c2 = Field("foo", table=self.t).isin([0, 1]) + + self.assertEqual('"foo" IN (0,1)', str(c1)) + self.assertEqual('"isin"."foo" IN (0,1)', str(c2)) + + def test__in_number_with_alias(self): + c1 = Field("foo").isin([0, 1]).as_('alias') + c2 = Field("foo", table=self.t).isin([0, 1]).as_('alias') + + self.assertEqual('"foo" IN (0,1) "alias"', str(c1)) + self.assertEqual('"isin"."foo" IN (0,1) "alias"', str(c2)) + + def test__in_character(self): + c1 = Field("foo").isin(["a", "b"]) + c2 = Field("foo", table=self.t).isin(["a", "b"]) + + self.assertEqual("\"foo\" IN ('a','b')", str(c1)) + self.assertEqual("\"isin\".\"foo\" IN ('a','b')", str(c2)) + + def test__in_date(self): + c1 = Field("foo").isin([date(2000, 1, 1), date(2000, 12, 31)]) + c2 = Field("foo", table=self.t).isin([date(2000, 1, 1), date(2000, 12, 31)]) + + self.assertEqual("\"foo\" IN ('2000-01-01','2000-12-31')", str(c1)) + self.assertEqual("\"isin\".\"foo\" IN ('2000-01-01','2000-12-31')", str(c2)) + + def test__in_datetime(self): + c1 = Field("foo").isin([datetime(2000, 1, 1, 0, 0, 0), datetime(2000, 12, 31, 23, 59, 59)]) + c2 = Field("foo", table=self.t).isin([datetime(2000, 1, 1, 0, 0, 0), datetime(2000, 12, 31, 23, 59, 59)]) + + self.assertEqual("\"foo\" IN ('2000-01-01T00:00:00','2000-12-31T23:59:59')", str(c1)) + self.assertEqual("\"isin\".\"foo\" IN ('2000-01-01T00:00:00','2000-12-31T23:59:59')", str(c2)) + + def test__function_isin(self): + c1 = fn.Coalesce(Field("foo"), 0).isin([0, 1]) + c2 = fn.Coalesce(Field("foo", table=self.t), 0).isin([0, 1]) + + self.assertEqual('COALESCE("foo",0) IN (0,1)', str(c1)) + self.assertEqual('COALESCE("isin"."foo",0) IN (0,1)', str(c2)) + + for t in (list, tuple, set, frozenset): + c_type = fn.Coalesce(Field("foo"), 0).isin(t([0, 1])) + self.assertEqual('COALESCE("foo",0) IN (0,1)', str(c_type)) + + self.assertRaises(AttributeError, lambda: str(fn.Coalesce(Field("foo"), 0).isin('SHOULD_FAIL'))) + + def test__in_unicode(self): + c1 = Field("foo").isin([u"a", u"b"]) + c2 = Field("foo", table=self.t).isin([u"a", u"b"]) + + self.assertEqual("\"foo\" IN ('a','b')", str(c1)) + self.assertEqual("\"isin\".\"foo\" IN ('a','b')", str(c2)) + + +class ArithmeticExpressionTests(unittest.TestCase): + def test__lshift(self): + c1 = Field("foo").lshift("1") + c2 = Field("foo").lshift("2") + + self.assertEqual("\"foo\"<<'1'", str(c1)) + self.assertEqual("\"foo\"<<'2'", str(c2)) + + def test__rshift(self): + c1 = Field("foo").rshift("1") + c2 = Field("foo").rshift("2") + + self.assertEqual("\"foo\">>'1'", str(c1)) + self.assertEqual("\"foo\">>'2'", str(c2)) + + +class NotInTests(unittest.TestCase): + t = Table("abc", alias="notin") + + def test__notin_number(self): + c1 = Field("foo").notin([0, 1]) + c2 = Field("foo", table=self.t).notin([0, 1]) + + self.assertEqual('"foo" NOT IN (0,1)', str(c1)) + self.assertEqual('"notin"."foo" NOT IN (0,1)', str(c2)) + + def test__notin_number_with_alias(self): + c1 = Field("foo").notin([0, 1]).as_('alias') + c2 = Field("foo", table=self.t).notin([0, 1]).as_('alias') + + self.assertEqual('"foo" NOT IN (0,1) "alias"', str(c1)) + self.assertEqual('"notin"."foo" NOT IN (0,1) "alias"', str(c2)) + + def test__notin_character(self): + c1 = Field("foo").notin(["a", "b"]) + c2 = Field("foo", table=self.t).notin(["a", "b"]) + + self.assertEqual("\"foo\" NOT IN ('a','b')", str(c1)) + self.assertEqual("\"notin\".\"foo\" NOT IN ('a','b')", str(c2)) + + def test__notin_date(self): + c1 = Field("foo").notin([date(2000, 1, 1), date(2000, 12, 31)]) + c2 = Field("foo", table=self.t).notin([date(2000, 1, 1), date(2000, 12, 31)]) + + self.assertEqual("\"foo\" NOT IN ('2000-01-01','2000-12-31')", str(c1)) + self.assertEqual("\"notin\".\"foo\" NOT IN ('2000-01-01','2000-12-31')", str(c2)) + + def test__notin_datetime(self): + c1 = Field("foo").notin([datetime(2000, 1, 1, 0, 0, 0), datetime(2000, 12, 31, 23, 59, 59)]) + c2 = Field("foo", table=self.t).notin([datetime(2000, 1, 1, 0, 0, 0), datetime(2000, 12, 31, 23, 59, 59)]) + + self.assertEqual("\"foo\" NOT IN ('2000-01-01T00:00:00','2000-12-31T23:59:59')", str(c1)) + self.assertEqual( + "\"notin\".\"foo\" NOT IN ('2000-01-01T00:00:00','2000-12-31T23:59:59')", + str(c2), + ) + + def test__function_notin(self): + c1 = fn.Coalesce(Field("foo"), 0).notin([0, 1]) + c2 = fn.Coalesce(Field("foo", table=self.t), 0).notin([0, 1]) + + self.assertEqual('COALESCE("foo",0) NOT IN (0,1)', str(c1)) + self.assertEqual('COALESCE("notin"."foo",0) NOT IN (0,1)', str(c2)) + + +class LikeTests(unittest.TestCase): + t = Table("abc", alias="like") + + def test_like_starts_with(self): + c1 = Field("foo").like("ab%") + c2 = Field("foo", table=self.t).like("ab%") + + self.assertEqual("\"foo\" LIKE 'ab%'", str(c1)) + self.assertEqual('"like"."foo" LIKE \'ab%\'', str(c2)) + + def test_like_contains(self): + c1 = Field("foo").like("%ab%") + c2 = Field("foo", table=self.t).like("%ab%") + + self.assertEqual("\"foo\" LIKE '%ab%'", str(c1)) + self.assertEqual('"like"."foo" LIKE \'%ab%\'', str(c2)) + + def test_like_ends_with(self): + c1 = Field("foo").like("%ab") + c2 = Field("foo", table=self.t).like("%ab") + + self.assertEqual("\"foo\" LIKE '%ab'", str(c1)) + self.assertEqual('"like"."foo" LIKE \'%ab\'', str(c2)) + + def test_like_n_chars_long(self): + c1 = Field("foo").like("___") + c2 = Field("foo", table=self.t).like("___") + + self.assertEqual("\"foo\" LIKE '___'", str(c1)) + self.assertEqual('"like"."foo" LIKE \'___\'', str(c2)) + + def test_like_single_chars_and_various_chars(self): + c1 = Field("foo").like("a_b%c") + c2 = Field("foo", table=self.t).like("a_b%c") + + self.assertEqual("\"foo\" LIKE 'a_b%c'", str(c1)) + self.assertEqual('"like"."foo" LIKE \'a_b%c\'', str(c2)) + + def test_not_like_single_chars_and_various_chars(self): + c1 = Field("foo").not_like("a_b%c") + c2 = Field("foo", table=self.t).not_like("a_b%c") + + self.assertEqual("\"foo\" NOT LIKE 'a_b%c'", str(c1)) + self.assertEqual('"like"."foo" NOT LIKE \'a_b%c\'', str(c2)) + + def test_ilike_starts_with(self): + c1 = Field("foo").ilike("ab%") + c2 = Field("foo", table=self.t).ilike("ab%") + + self.assertEqual("\"foo\" ILIKE 'ab%'", str(c1)) + self.assertEqual('"like"."foo" ILIKE \'ab%\'', str(c2)) + + def test_ilike_contains(self): + c1 = Field("foo").ilike("%ab%") + c2 = Field("foo", table=self.t).ilike("%ab%") + + self.assertEqual("\"foo\" ILIKE '%ab%'", str(c1)) + self.assertEqual('"like"."foo" ILIKE \'%ab%\'', str(c2)) + + def test_ilike_ends_with(self): + c1 = Field("foo").ilike("%ab") + c2 = Field("foo", table=self.t).ilike("%ab") + + self.assertEqual("\"foo\" ILIKE '%ab'", str(c1)) + self.assertEqual('"like"."foo" ILIKE \'%ab\'', str(c2)) + + def test_ilike_n_chars_long(self): + c1 = Field("foo").ilike("___") + c2 = Field("foo", table=self.t).ilike("___") + + self.assertEqual("\"foo\" ILIKE '___'", str(c1)) + self.assertEqual('"like"."foo" ILIKE \'___\'', str(c2)) + + def test_ilike_single_chars_and_various_chars(self): + c1 = Field("foo").ilike("a_b%c") + c2 = Field("foo", table=self.t).ilike("a_b%c") + + self.assertEqual("\"foo\" ILIKE 'a_b%c'", str(c1)) + self.assertEqual('"like"."foo" ILIKE \'a_b%c\'', str(c2)) + + def test_not_ilike_single_chars_and_various_chars(self): + c1 = Field("foo").not_ilike("a_b%c") + c2 = Field("foo", table=self.t).not_ilike("a_b%c") + + self.assertEqual("\"foo\" NOT ILIKE 'a_b%c'", str(c1)) + self.assertEqual('"like"."foo" NOT ILIKE \'a_b%c\'', str(c2)) + + def test_rlike_escape_chars(self): + c1 = Field("foo").rlike("\\\\d+$") + c2 = Field("foo", table=self.t).rlike("\\\\d+$") + + self.assertEqual("\"foo\" RLIKE '\\\\d+$'", str(c1)) + self.assertEqual('"like"."foo" RLIKE \'\\\\d+$\'', str(c2)) + + def test_glob_single_chars_and_various_chars(self): + c1 = Field("foo").glob("a_b*") + c2 = Field("foo", table=self.t).glob("a_b*") + + self.assertEqual("\"foo\" GLOB 'a_b*'", str(c1)) + self.assertEqual('"like"."foo" GLOB \'a_b*\'', str(c2)) + + +class ExistsCriterionTests(unittest.TestCase): + t2 = Table("abc", alias="t2") + q2 = QueryBuilder().from_(t2).select(t2.field2) + + def test_exists(self): + t1 = Table("def", alias="t1") + q1 = QueryBuilder().from_(t1).where(ExistsCriterion(self.q2)).select(t1.field1) + + self.assertEqual( + 'SELECT "t1"."field1" FROM "def" "t1" WHERE EXISTS (SELECT "t2"."field2" FROM "abc" "t2")', str(q1) + ) + + def test_not_exists(self): + t1 = Table("def", alias="t1") + q1 = QueryBuilder().from_(t1).where(ExistsCriterion(self.q2).negate()).select(t1.field1) + + self.assertEqual( + 'SELECT "t1"."field1" FROM "def" "t1" WHERE NOT EXISTS (SELECT "t2"."field2" FROM "abc" "t2")', str(q1) + ) + + +class ComplexCriterionTests(unittest.TestCase): + table_abc, table_efg = Table("abc", alias="cx0"), Table("efg", alias="cx1") + + def test_and(self): + c1 = (Field("foo") == 1) & (Field("bar") == 2) + c2 = (Field("foo", table=self.table_abc) == 1) & (Field("bar", table=self.table_efg) == 2) + + self.assertEqual('"foo"=1 AND "bar"=2', str(c1)) + self.assertEqual('"cx0"."foo"=1 AND "cx1"."bar"=2', str(c2)) + + def test_or(self): + c1 = (Field("foo") == 1) | (Field("bar") == 2) + c2 = (Field("foo", table=self.table_abc) == 1) | (Field("bar", table=self.table_efg) == 2) + + self.assertEqual('"foo"=1 OR "bar"=2', str(c1)) + self.assertEqual('"cx0"."foo"=1 OR "cx1"."bar"=2', str(c2)) + + def test_xor(self): + c1 = (Field("foo") == 1) ^ (Field("bar") == 2) + c2 = (Field("foo", table=self.table_abc) == 1) ^ (Field("bar", table=self.table_efg) == 2) + + self.assertEqual('"foo"=1 XOR "bar"=2', str(c1)) + self.assertEqual('"cx0"."foo"=1 XOR "cx1"."bar"=2', str(c2)) + + def test_function_and(self): + c1 = fn.IsNull(Field("foo")) & (Field("bar") == 2) + + self.assertEqual('ISNULL("foo") AND "bar"=2', str(c1)) + + def test_function_or(self): + c1 = fn.IsNull(Field("foo")) | (Field("bar") == 2) + + self.assertEqual('ISNULL("foo") OR "bar"=2', str(c1)) + + def test_function_xor(self): + c1 = fn.IsNull(Field("foo")) ^ (Field("bar") == 2) + + self.assertEqual('ISNULL("foo") XOR "bar"=2', str(c1)) + + def test__nested__and(self): + c = (Field("foo") == 1) & (Field("bar") == 2) & (Field("buz") == 3) + + self.assertEqual('"foo"=1 AND "bar"=2 AND "buz"=3', str(c)) + + def test__nested__or(self): + c = (Field("foo") == 1) | (Field("bar") == 2) | (Field("buz") == 3) + + self.assertEqual('"foo"=1 OR "bar"=2 OR "buz"=3', str(c)) + + def test__nested__mixed(self): + c = ((Field("foo") == 1) & (Field("bar") == 2)) | (Field("buz") == 3) + + self.assertEqual('("foo"=1 AND "bar"=2) OR "buz"=3', str(c)) + + def test__between_and_isin(self): + c = Field("foo").isin([1, 2, 3]) & Field("bar").between(0, 1) + + self.assertEqual('"foo" IN (1,2,3) AND "bar" BETWEEN 0 AND 1', str(c)) + + def test__between_and_field(self): + c1 = Field("foo").between(0, 1) + c2 = Field("bool_field") + + self.assertEqual('"foo" BETWEEN 0 AND 1 AND "bool_field"', str(c1 & c2)) + self.assertEqual('"bool_field" AND "foo" BETWEEN 0 AND 1', str(c2 & c1)) + + +class FieldsAsCriterionTests(unittest.TestCase): + def test__field_and_field(self): + c1 = Field("a") + c2 = Field("b") + + self.assertEqual('"a" AND "b"', str(c1 & c2)) + + def test__field_or_field(self): + c1 = Field("a") + c2 = Field("b") + + self.assertEqual('"a" OR "b"', str(c1 | c2)) + + def test__field_xor_field(self): + c1 = Field("a") + c2 = Field("b") + + self.assertEqual('"a" XOR "b"', str(c1 ^ c2)) + + +class CriterionOperationsTests(unittest.TestCase): + table_abc, table_efg = Table("abc", alias="cx0"), Table("efg", alias="cx1") + + def test_field_replace_table(self): + f = self.table_abc.foo.replace_table(self.table_abc, self.table_efg) + + self.assertEqual('"cx1"."foo"', str(f)) + + def test_arithmeticfunction_replace_table(self): + f = (self.table_abc.foo + self.table_abc.bar).replace_table(self.table_abc, self.table_efg) + + self.assertEqual('"cx1"."foo"+"cx1"."bar"', str(f)) + + def test_criterion_replace_table(self): + f = (self.table_abc.foo < self.table_abc.bar).replace_table(self.table_abc, self.table_efg) + + self.assertEqual('"cx1"."foo"<"cx1"."bar"', str(f)) + + def test_complexcriterion_replace_table(self): + f = (self.table_abc.foo < self.table_abc.bar) & (self.table_abc.fiz > self.table_abc.buz) + f = f.replace_table(self.table_abc, self.table_efg) + + self.assertEqual('"cx1"."foo"<"cx1"."bar" AND "cx1"."fiz">"cx1"."buz"', str(f)) + + def test_function_with_only_fields_replace_table(self): + f = fn.Sum(self.table_abc.foo).replace_table(self.table_abc, self.table_efg) + + self.assertEqual('SUM("cx1"."foo")', str(f)) + + def test_function_with_values_and_fields_replace_table(self): + f = Mod(self.table_abc.foo, 2).replace_table(self.table_abc, self.table_efg) + + self.assertEqual('MOD("cx1"."foo",2)', str(f)) + + def test_betweencriterion_replace_table(self): + f = self.table_abc.foo[0:1].replace_table(self.table_abc, self.table_efg) + + self.assertEqual('"cx1"."foo" BETWEEN 0 AND 1', str(f)) + + def test_nullcriterion_replace_table(self): + f = self.table_abc.foo.isnull().replace_table(self.table_abc, self.table_efg) + + self.assertEqual('"cx1"."foo" IS NULL', str(f)) + + +class AnyTests(unittest.TestCase): + def test_zero_args_returns_empty_criterion(self): + crit = Criterion.any() + self.assertIsInstance(crit, EmptyCriterion) + + def test_single_arg_returns_self(self): + f = Field("a") + crit = Criterion.any([f]) + self.assertEqual(str(f), str(crit)) + + def test_multiple_args_returned_in_chain_of_ors(self): + crit = Criterion.any([Field("a"), Field("b"), Field("c"), Field("d")]) + self.assertEqual(str(crit), '"a" OR "b" OR "c" OR "d"') + + def test_with_generator(self): + crit = Criterion.any(Field(letter) for letter in "abcd") + self.assertEqual(str(crit), '"a" OR "b" OR "c" OR "d"') + + +class EmptyCriterionTests(unittest.TestCase): + def test_fields_(self): + empty_criterion = EmptyCriterion() + + self.assertEqual(len(empty_criterion.fields_()), 0) + + def test_empty_criterion_on_the_left(self): + t = Table("test1") + q = EmptyCriterion() & t.f1 == "v1" + + self.assertEqual( + '"test1"."f1"=\'v1\'', + q.get_sql(with_namespace=True), + ) + + def test_empty_criterion_on_the_right(self): + t = Table("test1") + q = (t.f1 == "v1") & EmptyCriterion() + + self.assertEqual( + '"test1"."f1"=\'v1\'', + q.get_sql(with_namespace=True), + ) + + def test_invertion_of_the_empty_criterion(self): + t = Table("test1") + q = (t.f1 == "v1") & ~EmptyCriterion() + + self.assertEqual( + '"test1"."f1"=\'v1\'', + q.get_sql(with_namespace=True), + ) + + def test_different_operations_with_empty_criterion(self): + t = Table("test1") + q1 = (t.f1 == "v1") & EmptyCriterion() + q2 = (t.f1 == "v1") | EmptyCriterion() + q3 = (t.f1 == "v1") ^ EmptyCriterion() + + expected_sql = '"test1"."f1"=\'v1\'' + self.assertEqual( + expected_sql, + q1.get_sql(with_namespace=True), + ) + self.assertEqual( + expected_sql, + q2.get_sql(with_namespace=True), + ) + self.assertEqual( + expected_sql, + q3.get_sql(with_namespace=True), + ) + + def test_more_than_one_empty_criterions(self): + t = Table("test1") + q = EmptyCriterion() & ~(EmptyCriterion() | EmptyCriterion()) & (t.f1 == "v1") & ~EmptyCriterion() + + self.assertEqual( + '"test1"."f1"=\'v1\'', + q.get_sql(with_namespace=True), + ) + + +class AllTests(unittest.TestCase): + def test_zero_args_returns_empty_criterion(self): + crit = Criterion.all() + self.assertIsInstance(crit, EmptyCriterion) + + def test_single_arg_returns_self(self): + f = Field("a") + crit = Criterion.all([f]) + self.assertEqual(str(f), str(crit)) + + def test_multiple_args_returned_in_chain_of_ors(self): + crit = Criterion.all([Field("a"), Field("b"), Field("c"), Field("d")]) + self.assertEqual(str(crit), '"a" AND "b" AND "c" AND "d"') + + def test_with_generator(self): + crit = Criterion.all(Field(letter) for letter in "abcd") + self.assertEqual(str(crit), '"a" AND "b" AND "c" AND "d"') diff --git a/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/test_custom_functions.py b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/test_custom_functions.py new file mode 100644 index 0000000000000000000000000000000000000000..60ffd3cd8e6191e3fc782dac003c41bfb7a78528 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/test_custom_functions.py @@ -0,0 +1,49 @@ +import unittest + +from pypika import CustomFunction, FunctionException, Query, Table + +__author__ = "Airton Zanon" +__email__ = "me@airton.dev" + + +class TestUnitCustomFunction(unittest.TestCase): + def test_should_fail_with_wrong_arguments(self): + DateDiff = CustomFunction("DATE_DIFF", ["interval", "start_date", "end_date"]) + + with self.assertRaises(FunctionException): + DateDiff("foo") + + def test_should_return_function_with_arguments(self): + DateDiff = CustomFunction("DATE_DIFF", ["interval", "start_date", "end_date"]) + + self.assertEqual( + "DATE_DIFF('day','start_date','end_date')", + str(DateDiff("day", "start_date", "end_date")), + ) + + def test_should_return_function_with_no_arguments(self): + CurrentDate = CustomFunction("CURRENT_DATE") + + self.assertEqual("CURRENT_DATE()", str(CurrentDate())) + + +class TestFunctionalCustomFunction(unittest.TestCase): + def test_should_use_custom_function_on_select(self): + service = Table("service") + + DateDiff = CustomFunction("DATE_DIFF", ["interval", "start_date", "end_date"]) + + q = Query.from_(service).select(DateDiff("day", service.created_date, service.updated_date)) + + self.assertEqual( + 'SELECT DATE_DIFF(\'day\',"created_date","updated_date") FROM "service"', + str(q), + ) + + def test_should_fail_use_custom_function_on_select_with_wrong_arguments(self): + service = Table("service") + + DateDiff = CustomFunction("DATE_DIFF", ["interval", "start_date", "end_date"]) + + with self.assertRaises(FunctionException): + Query.from_(service).select(DateDiff("day", service.created_date)) diff --git a/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/test_data_types.py b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/test_data_types.py new file mode 100644 index 0000000000000000000000000000000000000000..52fb4487fe7be3ae28a4e9eb08628fba89dc0f79 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/test_data_types.py @@ -0,0 +1,15 @@ +import unittest +import uuid + +from pypika.terms import ValueWrapper + + +class StringTests(unittest.TestCase): + def test_inline_string_concatentation(self): + self.assertEqual("'it''s'", ValueWrapper("it's").get_sql()) + + +class UuidTests(unittest.TestCase): + def test_uuid_string_generation(self): + id = uuid.uuid4() + self.assertEqual("'{}'".format(id), ValueWrapper(id).get_sql()) diff --git a/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/test_date_math.py b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/test_date_math.py new file mode 100644 index 0000000000000000000000000000000000000000..38db8ef2f8e812a97c6980a7ec6b9a3909d804fb --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/test_date_math.py @@ -0,0 +1,179 @@ +import unittest + +from pypika import ( + Field as F, + Interval, +) +from pypika.enums import Dialects + +dt = F("dt") + + +class AddIntervalTests(unittest.TestCase): + def test_add_microsecond(self): + c = dt + Interval(microseconds=1) + + self.assertEqual("\"dt\"+INTERVAL '1 MICROSECOND'", str(c)) + + def test_add_second(self): + c = dt + Interval(seconds=1) + + self.assertEqual("\"dt\"+INTERVAL '1 SECOND'", str(c)) + + def test_add_minute(self): + c = dt + Interval(minutes=1) + + self.assertEqual("\"dt\"+INTERVAL '1 MINUTE'", str(c)) + + def test_add_day(self): + c = dt + Interval(days=1) + + self.assertEqual("\"dt\"+INTERVAL '1 DAY'", str(c)) + + def test_add_week(self): + c = dt + Interval(weeks=1) + + self.assertEqual("\"dt\"+INTERVAL '1 WEEK'", str(c)) + + def test_add_month(self): + c = dt + Interval(months=1) + + self.assertEqual("\"dt\"+INTERVAL '1 MONTH'", str(c)) + + def test_add_quarter(self): + c = dt + Interval(quarters=1) + + self.assertEqual("\"dt\"+INTERVAL '1 QUARTER'", str(c)) + + def test_add_year(self): + c = dt + Interval(years=1) + + self.assertEqual("\"dt\"+INTERVAL '1 YEAR'", str(c)) + + def test_add_default(self): + c = dt + Interval(days=0) + + self.assertEqual("\"dt\"+INTERVAL '0 DAY'", str(c)) + + +class AddIntervalMultipleUnitsTests(unittest.TestCase): + def test_add_second_microsecond(self): + c = dt + Interval(seconds=1, microseconds=1) + + self.assertEqual("\"dt\"+INTERVAL '1.1 SECOND_MICROSECOND'", str(c)) + + def test_add_minute_microsecond(self): + c = dt + Interval(minutes=1, microseconds=1) + + self.assertEqual("\"dt\"+INTERVAL '1:0.1 MINUTE_MICROSECOND'", str(c)) + + def test_add_minute_second(self): + c = dt + Interval(minutes=1, seconds=1) + + self.assertEqual("\"dt\"+INTERVAL '1:1 MINUTE_SECOND'", str(c)) + + def test_add_hour_microsecond(self): + c = dt + Interval(hours=1, microseconds=1) + + self.assertEqual("\"dt\"+INTERVAL '1:0:0.1 HOUR_MICROSECOND'", str(c)) + + def test_add_hour_second(self): + c = dt + Interval(hours=1, seconds=1) + + self.assertEqual("\"dt\"+INTERVAL '1:0:1 HOUR_SECOND'", str(c)) + + def test_add_hour_minute(self): + c = dt + Interval(hours=1, minutes=1) + + self.assertEqual("\"dt\"+INTERVAL '1:1 HOUR_MINUTE'", str(c)) + + def test_add_day_microsecond(self): + c = dt + Interval(days=1, microseconds=1) + + self.assertEqual("\"dt\"+INTERVAL '1 0:0:0.1 DAY_MICROSECOND'", str(c)) + + def test_add_day_second(self): + c = dt + Interval(days=1, seconds=1) + + self.assertEqual("\"dt\"+INTERVAL '1 0:0:1 DAY_SECOND'", str(c)) + + def test_add_day_minute(self): + c = dt + Interval(days=1, minutes=1) + + self.assertEqual("\"dt\"+INTERVAL '1 0:1 DAY_MINUTE'", str(c)) + + def test_add_day_hour(self): + c = dt + Interval(days=1, hours=1) + + self.assertEqual("\"dt\"+INTERVAL '1 1 DAY_HOUR'", str(c)) + + def test_add_year_month(self): + c = dt + Interval(years=1, months=1) + + self.assertEqual("\"dt\"+INTERVAL '1-1 YEAR_MONTH'", str(c)) + + def test_add_value_right(self): + c = Interval(microseconds=1) - dt + + self.assertEqual("INTERVAL '1 MICROSECOND'-\"dt\"", str(c)) + + def test_add_value_complex_expressions(self): + c = dt + Interval(quarters=1) + Interval(weeks=1) + + self.assertEqual("\"dt\"+INTERVAL '1 QUARTER'+INTERVAL '1 WEEK'", str(c)) + + +class DialectIntervalTests(unittest.TestCase): + def test_mysql_dialect_uses_single_quotes_around_expression_in_an_interval(self): + c = Interval(days=1).get_sql(dialect=Dialects.MYSQL) + self.assertEqual("INTERVAL '1' DAY", c) + + def test_oracle_dialect_uses_single_quotes_around_expression_in_an_interval(self): + c = Interval(days=1).get_sql(dialect=Dialects.ORACLE) + self.assertEqual("INTERVAL '1' DAY", c) + + def test_vertica_dialect_uses_single_quotes_around_interval(self): + c = Interval(days=1).get_sql(dialect=Dialects.VERTICA) + self.assertEqual("INTERVAL '1 DAY'", c) + + def test_redshift_dialect_uses_single_quotes_around_interval(self): + c = Interval(days=1).get_sql(dialect=Dialects.REDSHIFT) + self.assertEqual("INTERVAL '1 DAY'", c) + + def test_postgresql_dialect_uses_single_quotes_around_interval(self): + c = Interval(days=1).get_sql(dialect=Dialects.POSTGRESQL) + self.assertEqual("INTERVAL '1 DAY'", c) + + +class TestNegativeIntervals(unittest.TestCase): + def test_day(self): + c = Interval(days=-1).get_sql() + self.assertEqual("INTERVAL '-1 DAY'", c) + + def test_week(self): + c = Interval(weeks=-1).get_sql() + self.assertEqual("INTERVAL '-1 WEEK'", c) + + def test_month(self): + c = Interval(months=-1).get_sql() + self.assertEqual("INTERVAL '-1 MONTH'", c) + + def test_year(self): + c = Interval(years=-1).get_sql() + self.assertEqual("INTERVAL '-1 YEAR'", c) + + def test_year_month(self): + c = Interval(years=-1, months=-4).get_sql() + self.assertEqual("INTERVAL '-1-4 YEAR_MONTH'", c) + + +class TruncateTrailingZerosTests(unittest.TestCase): + def test_do_not_truncate_integer_values(self): + i = Interval(seconds=10) + + self.assertEqual("INTERVAL '10 SECOND'", str(i)) + + def test_do_not_truncate_months_between_years_and_datys(self): + i = Interval(years=10, days=10) + + self.assertEqual("INTERVAL '10-0-10 YEAR_DAY'", str(i)) diff --git a/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/test_deletes.py b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/test_deletes.py new file mode 100644 index 0000000000000000000000000000000000000000..09df93f5331b845b0c3aed628bf1c4a3ec6b0f02 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/test_deletes.py @@ -0,0 +1,97 @@ +import unittest + +from pypika import PostgreSQLQuery, Query, SYSTEM_TIME, Table + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + +from pypika.terms import Star + + +class DeleteTests(unittest.TestCase): + @classmethod + def setUpClass(cls) -> None: + super().setUpClass() + cls.table_abc = Table("abc") + + def test_omit_where(self): + q = Query.from_("abc").delete() + + self.assertEqual('DELETE FROM "abc"', str(q)) + + def test_omit_where__table_schema(self): + q = Query.from_(Table("abc", "schema1")).delete() + + self.assertEqual('DELETE FROM "schema1"."abc"', str(q)) + + def test_where_field_equals(self): + q1 = Query.from_(self.table_abc).where(self.table_abc.foo == self.table_abc.bar).delete() + q2 = Query.from_(self.table_abc).where(self.table_abc.foo.eq(self.table_abc.bar)).delete() + + self.assertEqual('DELETE FROM "abc" WHERE "foo"="bar"', str(q1)) + self.assertEqual('DELETE FROM "abc" WHERE "foo"="bar"', str(q2)) + + def test_for_portion(self): + with self.subTest("with system time"): + q = Query.from_(self.table_abc.for_portion(SYSTEM_TIME.from_to('2020-01-01', '2020-02-01'))).delete() + + self.assertEqual( + 'DELETE FROM "abc" FOR PORTION OF SYSTEM_TIME FROM \'2020-01-01\' TO \'2020-02-01\'', str(q) + ) + + with self.subTest("with column"): + q = Query.from_( + self.table_abc.for_portion(self.table_abc.valid_period.from_to('2020-01-01', '2020-02-01')) + ).delete() + + self.assertEqual( + 'DELETE FROM "abc" FOR PORTION OF "valid_period" FROM \'2020-01-01\' TO \'2020-02-01\'', str(q) + ) + + +class PostgresDeleteTests(unittest.TestCase): + @classmethod + def setUpClass(cls) -> None: + super().setUpClass() + cls.table_abc = Table("abc") + + def test_delete_returning(self): + q1 = ( + PostgreSQLQuery.from_(self.table_abc) + .where(self.table_abc.foo == self.table_abc.bar) + .delete() + .returning(self.table_abc.id) + ) + + self.assertEqual('DELETE FROM "abc" WHERE "foo"="bar" RETURNING "id"', str(q1)) + + def test_delete_returning_str(self): + q1 = ( + PostgreSQLQuery.from_(self.table_abc) + .where(self.table_abc.foo == self.table_abc.bar) + .delete() + .returning("id") + ) + + self.assertEqual('DELETE FROM "abc" WHERE "foo"="bar" RETURNING "id"', str(q1)) + + def test_delete_returning_star(self): + q1 = ( + PostgreSQLQuery.from_(self.table_abc) + .where(self.table_abc.foo == self.table_abc.bar) + .delete() + .returning(Star()) + ) + + self.assertEqual('DELETE FROM "abc" WHERE "foo"="bar" RETURNING *', str(q1)) + + def test_delete_using(self): + table_trash = Table('trash') + q1 = ( + PostgreSQLQuery.from_(self.table_abc) + .using(table_trash) + .where(self.table_abc.id == table_trash.abc_id) + .delete() + ) + + self.assertEqual('DELETE FROM "abc" USING "trash" WHERE "abc"."id"="trash"."abc_id"', str(q1)) diff --git a/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/test_drop.py b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/test_drop.py new file mode 100644 index 0000000000000000000000000000000000000000..265ae7350d2054549731f9a8c4379fdac95dc580 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/test_drop.py @@ -0,0 +1,49 @@ +import unittest + +from pypika import ( + Columns, + Database, + Query, + Tables, +) + + +class DropTableTests(unittest.TestCase): + database_xyz = Database("mydb") + new_table, existing_table = Tables("abc", "efg") + foo, bar = Columns(("a", "INT"), ("b", "VARCHAR(100)")) + + def test_drop_database(self): + q1 = Query.drop_database(self.database_xyz) + q2 = Query.drop_database(self.database_xyz).if_exists() + + self.assertEqual('DROP DATABASE "mydb"', str(q1)) + self.assertEqual('DROP DATABASE IF EXISTS "mydb"', str(q2)) + + def test_drop_table(self): + q1 = Query.drop_table(self.new_table) + q2 = Query.drop_table(self.new_table).if_exists() + + self.assertEqual('DROP TABLE "abc"', str(q1)) + self.assertEqual('DROP TABLE IF EXISTS "abc"', str(q2)) + + def test_drop_user(self): + q1 = Query.drop_user("myuser") + q2 = Query.drop_user("myuser").if_exists() + + self.assertEqual('DROP USER "myuser"', str(q1)) + self.assertEqual('DROP USER IF EXISTS "myuser"', str(q2)) + + def test_drop_view(self): + q1 = Query.drop_view("myview") + q2 = Query.drop_view("myview").if_exists() + + self.assertEqual('DROP VIEW "myview"', str(q1)) + self.assertEqual('DROP VIEW IF EXISTS "myview"', str(q2)) + + def test_drop_index(self): + q1 = Query.drop_index("myindex") + q2 = Query.drop_index("myindex").if_exists() + + self.assertEqual('DROP INDEX "myindex"', str(q1)) + self.assertEqual('DROP INDEX IF EXISTS "myindex"', str(q2)) diff --git a/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/test_formats.py b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/test_formats.py new file mode 100644 index 0000000000000000000000000000000000000000..6a442757c6659a215661e03f1ca9c3771d394d96 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/test_formats.py @@ -0,0 +1,68 @@ +import unittest + +from pypika import Query, Tables, functions as fn + + +class QuoteTests(unittest.TestCase): + maxDiff = None + + table_abc, table_efg = Tables("abc", "efg") + + def setUp(self): + subquery1 = ( + Query.from_(self.table_abc) + .select( + self.table_abc.foo, + fn.Sum(self.table_abc.fizz + self.table_abc.buzz).as_("fizzbuzz"), + ) + .groupby(self.table_abc.foo) + ) + + subquery2 = Query.from_(self.table_efg).select( + self.table_efg.foo.as_("foo_two"), + self.table_efg.bar, + ) + + self.query = ( + Query.from_(subquery1) + .select(subquery1.foo, subquery1.fizzbuzz) + .join(subquery2) + .on(subquery1.foo == subquery2.foo_two) + .select(subquery2.foo_two, subquery2.bar) + ) + + def test_replace_quote_char_in_complex_query(self): + self.assertEqual( + "SELECT " + "`sq0`.`foo`,`sq0`.`fizzbuzz`," + "`sq1`.`foo_two`,`sq1`.`bar` " + "FROM (" + "SELECT " + "`foo`,SUM(`fizz`+`buzz`) `fizzbuzz` " + "FROM `abc` " + "GROUP BY `foo`" + ") `sq0` JOIN (" + "SELECT " + "`foo` `foo_two`,`bar` " + "FROM `efg`" + ") `sq1` ON `sq0`.`foo`=`sq1`.`foo_two`", + self.query.get_sql(quote_char="`"), + ) + + def test_no_quote_char_in_complex_query(self): + self.assertEqual( + "SELECT " + "sq0.foo,sq0.fizzbuzz," + "sq1.foo_two,sq1.bar " + "FROM (" + "SELECT " + "foo,SUM(fizz+buzz) fizzbuzz " + "FROM abc " + "GROUP BY foo" + ") sq0 JOIN (" + "SELECT " + "foo foo_two,bar " + "FROM efg" + ") sq1 ON sq0.foo=sq1.foo_two", + self.query.get_sql(quote_char=None), + ) diff --git a/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/test_functions.py b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/test_functions.py new file mode 100644 index 0000000000000000000000000000000000000000..f526966eefc554ec68d0e15fb69de7d69f1604c3 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/test_functions.py @@ -0,0 +1,847 @@ +import unittest + +from pypika import ( + Case, + CaseException, + DatePart, + Field as F, + Query, + Query as Q, + Schema, + Table as T, + VerticaQuery, + functions as fn, +) +from pypika.enums import Dialects, SqlTypes + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + + +class FunctionTests(unittest.TestCase): + def test_dialect_propagation(self): + func = fn.Function("func", ["a"], ["b"]) + self.assertEqual("func(ARRAY['a'],ARRAY['b'])", func.get_sql(dialect=Dialects.POSTGRESQL)) + + def test_is_aggregate_None_for_non_aggregate_function_or_function_with_no_aggregate_functions(self): + self.assertIsNone(fn.Coalesce('a', 0).is_aggregate) + self.assertIsNone(fn.Coalesce(fn.NullIf('a', 0), 0).is_aggregate) + + def test_is_aggregate_True_for_aggregate_function_or_function_with_aggregate_functions(self): + self.assertTrue(fn.Sum('a').is_aggregate) + self.assertTrue(fn.Coalesce(fn.Avg('a'), 0).is_aggregate) + self.assertTrue(fn.Coalesce(fn.NullIf(fn.Sum('a'), 0), 0).is_aggregate) + + +class SchemaTests(unittest.TestCase): + def test_schema_no_schema_in_sql_when_none_set(self): + func = fn.Function("my_proc", 1, 2, 3) + + self.assertEqual("my_proc(1,2,3)", func.get_sql(quote_char='"')) + + def test_schema_included_in_function_sql(self): + a = Schema("a") + func = fn.Function("my_proc", 1, 2, 3, schema=a) + + self.assertEqual('"a".my_proc(1,2,3)', func.get_sql(quote_char='"')) + + +class ArithmeticTests(unittest.TestCase): + t = T("abc") + + def test__addition__fields(self): + q1 = Q.from_("abc").select(F("a") + F("b")) + q2 = Q.from_(self.t).select(self.t.a + self.t.b) + + self.assertEqual('SELECT "a"+"b" FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"+"b" FROM "abc"', str(q2)) + + def test__addition__number(self): + q1 = Q.from_("abc").select(F("a") + 1) + q2 = Q.from_(self.t).select(self.t.a + 1) + + self.assertEqual('SELECT "a"+1 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"+1 FROM "abc"', str(q2)) + + def test__addition__decimal(self): + q1 = Q.from_("abc").select(F("a") + 1.0) + q2 = Q.from_(self.t).select(self.t.a + 1.0) + + self.assertEqual('SELECT "a"+1.0 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"+1.0 FROM "abc"', str(q2)) + + def test__addition__right(self): + q1 = Q.from_("abc").select(1 + F("a")) + q2 = Q.from_(self.t).select(1 + self.t.a) + + self.assertEqual('SELECT 1+"a" FROM "abc"', str(q1)) + self.assertEqual('SELECT 1+"a" FROM "abc"', str(q2)) + + def test__subtraction__fields(self): + q1 = Q.from_("abc").select(F("a") - F("b")) + q2 = Q.from_(self.t).select(self.t.a - self.t.b) + + self.assertEqual('SELECT "a"-"b" FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"-"b" FROM "abc"', str(q2)) + + def test__subtraction__number(self): + q1 = Q.from_("abc").select(F("a") - 1) + q2 = Q.from_(self.t).select(self.t.a - 1) + + self.assertEqual('SELECT "a"-1 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"-1 FROM "abc"', str(q2)) + + def test__subtraction__decimal(self): + q1 = Q.from_("abc").select(F("a") - 1.0) + q2 = Q.from_(self.t).select(self.t.a - 1.0) + + self.assertEqual('SELECT "a"-1.0 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"-1.0 FROM "abc"', str(q2)) + + def test__subtraction__right(self): + q1 = Q.from_("abc").select(1 - F("a")) + q2 = Q.from_(self.t).select(1 - self.t.a) + + self.assertEqual('SELECT 1-"a" FROM "abc"', str(q1)) + self.assertEqual('SELECT 1-"a" FROM "abc"', str(q2)) + + def test__multiplication__fields(self): + q1 = Q.from_("abc").select(F("a") * F("b")) + q2 = Q.from_(self.t).select(self.t.a * self.t.b) + + self.assertEqual('SELECT "a"*"b" FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"*"b" FROM "abc"', str(q2)) + + def test__multiplication__number(self): + q1 = Q.from_("abc").select(F("a") * 1) + q2 = Q.from_(self.t).select(self.t.a * 1) + + self.assertEqual('SELECT "a"*1 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"*1 FROM "abc"', str(q2)) + + def test__multiplication__decimal(self): + q1 = Q.from_("abc").select(F("a") * 1.0) + q2 = Q.from_(self.t).select(self.t.a * 1.0) + + self.assertEqual('SELECT "a"*1.0 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"*1.0 FROM "abc"', str(q2)) + + def test__multiplication__right(self): + q1 = Q.from_("abc").select(1 * F("a")) + q2 = Q.from_(self.t).select(1 * self.t.a) + + self.assertEqual('SELECT 1*"a" FROM "abc"', str(q1)) + self.assertEqual('SELECT 1*"a" FROM "abc"', str(q2)) + + def test__division__fields(self): + q1 = Q.from_("abc").select(F("a") / F("b")) + q2 = Q.from_(self.t).select(self.t.a / self.t.b) + + self.assertEqual('SELECT "a"/"b" FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"/"b" FROM "abc"', str(q2)) + + def test__division__number(self): + q1 = Q.from_("abc").select(F("a") / 1) + q2 = Q.from_(self.t).select(self.t.a / 1) + + self.assertEqual('SELECT "a"/1 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"/1 FROM "abc"', str(q2)) + + def test__division__decimal(self): + q1 = Q.from_("abc").select(F("a") / 1.0) + q2 = Q.from_(self.t).select(self.t.a / 1.0) + + self.assertEqual('SELECT "a"/1.0 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"/1.0 FROM "abc"', str(q2)) + + def test__division__right(self): + q1 = Q.from_("abc").select(1 / F("a")) + q2 = Q.from_(self.t).select(1 / self.t.a) + + self.assertEqual('SELECT 1/"a" FROM "abc"', str(q1)) + self.assertEqual('SELECT 1/"a" FROM "abc"', str(q2)) + + def test__leftshift__fields(self): + q1 = Q.from_("abc").select(F("a") << F("b")) + q2 = Q.from_(self.t).select(self.t.a << self.t.b) + + self.assertEqual('SELECT "a"<<"b" FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"<<"b" FROM "abc"', str(q2)) + + def test__leftshift__number(self): + q1 = Q.from_("abc").select(F('a') << 2) + q2 = Q.from_(self.t).select(self.t.a << 2) + + self.assertEqual('SELECT "a"<<2 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"<<2 FROM "abc"', str(q2)) + + def test__leftshift__right(self): + q1 = Q.from_("abc").select(1 << F("a")) + q2 = Q.from_(self.t).select(1 << self.t.a) + + self.assertEqual('SELECT 1<<"a" FROM "abc"', str(q1)) + self.assertEqual('SELECT 1<<"a" FROM "abc"', str(q2)) + + def test__rightshift__fields(self): + q1 = Q.from_("abc").select(F("a") >> F("b")) + q2 = Q.from_(self.t).select(self.t.a >> self.t.b) + + self.assertEqual('SELECT "a">>"b" FROM "abc"', str(q1)) + self.assertEqual('SELECT "a">>"b" FROM "abc"', str(q2)) + + def test__rightshift__number(self): + q1 = Q.from_("abc").select(F('a') >> 2) + q2 = Q.from_(self.t).select(self.t.a >> 2) + + self.assertEqual('SELECT "a">>2 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a">>2 FROM "abc"', str(q2)) + + def test__rightshift__right(self): + q1 = Q.from_("abc").select(1 >> F("a")) + q2 = Q.from_(self.t).select(1 >> self.t.a) + + self.assertEqual('SELECT 1>>"a" FROM "abc"', str(q1)) + self.assertEqual('SELECT 1>>"a" FROM "abc"', str(q2)) + + def test__complex_op(self): + q1 = Q.from_("abc").select(2 + 1 / F("a") - 5) + q2 = Q.from_(self.t).select(2 + 1 / self.t.a - 5) + + self.assertEqual('SELECT 2+1/"a"-5 FROM "abc"', str(q1)) + self.assertEqual('SELECT 2+1/"a"-5 FROM "abc"', str(q2)) + + def test__complex_op_add_parentheses(self): + q1 = Q.from_("abc").select((F("a") + 1) + (F("b") - 5)) + q2 = Q.from_(self.t).select((self.t.a + 1) + (self.t.b - 5)) + q3 = Q.from_("abc").select((F("a") / 1) + (F("b") / 5)) + q4 = Q.from_(self.t).select((self.t.a / 1) + (self.t.b / 5)) + + self.assertEqual('SELECT "a"+1+"b"-5 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"+1+"b"-5 FROM "abc"', str(q2)) + self.assertEqual('SELECT "a"/1+"b"/5 FROM "abc"', str(q3)) + self.assertEqual('SELECT "a"/1+"b"/5 FROM "abc"', str(q4)) + + def test__complex_op_sub_parentheses(self): + q1 = Q.from_("abc").select((F("a") + 1) - (F("b") - 5)) + q2 = Q.from_(self.t).select((self.t.a + 1) - (self.t.b - 5)) + q3 = Q.from_("abc").select((F("a") / 1) - (F("b") / 5)) + q4 = Q.from_(self.t).select((self.t.a / 1) - (self.t.b / 5)) + + self.assertEqual('SELECT "a"+1-("b"-5) FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"+1-("b"-5) FROM "abc"', str(q2)) + self.assertEqual('SELECT "a"/1-"b"/5 FROM "abc"', str(q3)) + self.assertEqual('SELECT "a"/1-"b"/5 FROM "abc"', str(q4)) + + def test__complex_op_mul_parentheses(self): + q1 = Q.from_("abc").select((F("a") + 1) * (F("b") - 5)) + q2 = Q.from_(self.t).select((self.t.a + 1) * (self.t.b - 5)) + q3 = Q.from_("abc").select((F("a") / 1) * (F("b") - 5)) + q4 = Q.from_(self.t).select((self.t.a / 1) * (self.t.b - 5)) + q5 = Q.from_("abc").select((F("a") + 1) * (F("b") / 5)) + q6 = Q.from_(self.t).select((self.t.a + 1) * (self.t.b / 5)) + + self.assertEqual('SELECT ("a"+1)*("b"-5) FROM "abc"', str(q1)) + self.assertEqual('SELECT ("a"+1)*("b"-5) FROM "abc"', str(q2)) + self.assertEqual('SELECT "a"/1*("b"-5) FROM "abc"', str(q3)) + self.assertEqual('SELECT "a"/1*("b"-5) FROM "abc"', str(q4)) + self.assertEqual('SELECT ("a"+1)*"b"/5 FROM "abc"', str(q5)) + self.assertEqual('SELECT ("a"+1)*"b"/5 FROM "abc"', str(q6)) + + def test__complex_op_mul_no_parentheses(self): + q = Q.from_("abc").select(F("a") + 1 * F("b") - 5) + + self.assertEqual('SELECT "a"+1*"b"-5 FROM "abc"', str(q)) + + def test__complex_op_div_parentheses(self): + q1 = Q.from_("abc").select((F("a") + 1) / (F("b") - 5)) + q2 = Q.from_(self.t).select((self.t.a + 1) / (self.t.b - 5)) + q3 = Q.from_("abc").select((F("a") / 1) / (F("b") - 5)) + q4 = Q.from_(self.t).select((self.t.a / 1) / (self.t.b - 5)) + q5 = Q.from_("abc").select((F("a") + 1) / (F("b") * 5)) + q6 = Q.from_(self.t).select((self.t.a + 1) / (self.t.b * 5)) + + self.assertEqual('SELECT ("a"+1)/("b"-5) FROM "abc"', str(q1)) + self.assertEqual('SELECT ("a"+1)/("b"-5) FROM "abc"', str(q2)) + self.assertEqual('SELECT "a"/1/("b"-5) FROM "abc"', str(q3)) + self.assertEqual('SELECT "a"/1/("b"-5) FROM "abc"', str(q4)) + self.assertEqual('SELECT ("a"+1)/("b"*5) FROM "abc"', str(q5)) + self.assertEqual('SELECT ("a"+1)/("b"*5) FROM "abc"', str(q6)) + + def test__complex_op_div_no_parentheses(self): + q = Q.from_("abc").select(F("a") + 1 / F("b") - 5) + + self.assertEqual('SELECT "a"+1/"b"-5 FROM "abc"', str(q)) + + def test__complex_op_exponent_parentheses(self): + q1 = Q.from_("abc").select(F("a") / (F("b") ** 2)) + q2 = Q.from_(self.t).select(self.t.a / (self.t.b**2)) + q3 = Q.from_("abc").select(F("a") ** (F("b") / 2)) + q4 = Q.from_(self.t).select(self.t.a ** (self.t.b / 2)) + q5 = Q.from_("abc").select((F("a") ** F("b")) ** 2) + q6 = Q.from_(self.t).select((self.t.a**self.t.b) ** 2) + + self.assertEqual('SELECT "a"/POW("b",2) FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"/POW("b",2) FROM "abc"', str(q2)) + self.assertEqual('SELECT POW("a","b"/2) FROM "abc"', str(q3)) + self.assertEqual('SELECT POW("a","b"/2) FROM "abc"', str(q4)) + self.assertEqual('SELECT POW(POW("a","b"),2) FROM "abc"', str(q5)) + self.assertEqual('SELECT POW(POW("a","b"),2) FROM "abc"', str(q6)) + + def test__complex_op_exponent_no_parentheses(self): + q1 = Q.from_("abc").select(F("a") ** F("b") ** 2) + q2 = Q.from_(self.t).select(self.t.a**self.t.b**2) + q3 = Q.from_("abc").select(F("a") / F("b") ** 2) + q4 = Q.from_(self.t).select(self.t.a / self.t.b**2) + + self.assertEqual('SELECT POW("a",POW("b",2)) FROM "abc"', str(q1)) + self.assertEqual('SELECT POW("a",POW("b",2)) FROM "abc"', str(q2)) + self.assertEqual('SELECT "a"/POW("b",2) FROM "abc"', str(q3)) + self.assertEqual('SELECT "a"/POW("b",2) FROM "abc"', str(q4)) + + def test__complex_op_function_parentheses(self): + q1 = Q.from_("abc").select(F("a") / (fn.Sum(F("b")) / 2)) + q2 = Q.from_("abc").select(self.t.a / (fn.Sum(self.t.b) / 2)) + q3 = Q.from_("abc").select(fn.Sum(F("a") / (F("b") / 2))) + q4 = Q.from_("abc").select(fn.Sum(self.t.a / (self.t.b / 2))) + + self.assertEqual('SELECT "a"/(SUM("b")/2) FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"/(SUM("b")/2) FROM "abc"', str(q2)) + self.assertEqual('SELECT SUM("a"/("b"/2)) FROM "abc"', str(q3)) + self.assertEqual('SELECT SUM("a"/("b"/2)) FROM "abc"', str(q4)) + + def test__complex_op_modulus_parentheses(self): + q1 = Q.from_("abc").select(F("a") / (F("b") % 2)) + q2 = Q.from_(self.t).select(self.t.a / (self.t.b % 2)) + q3 = Q.from_("abc").select(F("a") % (F("b") / 2)) + q4 = Q.from_(self.t).select(self.t.a % (self.t.b / 2)) + q5 = Q.from_("abc").select(F("a") % (F("b") % 2)) + q6 = Q.from_("abc").select(self.t.a % (self.t.b % 2)) + + self.assertEqual('SELECT "a"/MOD("b",2) FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"/MOD("b",2) FROM "abc"', str(q2)) + self.assertEqual('SELECT MOD("a","b"/2) FROM "abc"', str(q3)) + self.assertEqual('SELECT MOD("a","b"/2) FROM "abc"', str(q4)) + self.assertEqual('SELECT MOD("a",MOD("b",2)) FROM "abc"', str(q5)) + self.assertEqual('SELECT MOD("a",MOD("b",2)) FROM "abc"', str(q6)) + + def test__complex_op_modulus_no_parentheses(self): + q1 = Q.from_("abc").select(F("a") % F("b") % 2) + q2 = Q.from_(self.t).select(self.t.a % self.t.b % 2) + q3 = Q.from_("abc").select(F("a") / F("b") % 2) + q4 = Q.from_(self.t).select(self.t.a / self.t.b % 2) + + self.assertEqual('SELECT MOD(MOD("a","b"),2) FROM "abc"', str(q1)) + self.assertEqual('SELECT MOD(MOD("a","b"),2) FROM "abc"', str(q2)) + self.assertEqual('SELECT MOD("a"/"b",2) FROM "abc"', str(q3)) + self.assertEqual('SELECT MOD("a"/"b",2) FROM "abc"', str(q4)) + + def test__complex_op_floor_parentheses(self): + q1 = Q.from_("abc").select(F("a") / (fn.Floor(F("b")) / 2)) + q2 = Q.from_("abc").select(self.t.a / (fn.Floor(self.t.b) / 2)) + q3 = Q.from_("abc").select(fn.Floor(F("a") / (F("b") / 2))) + q4 = Q.from_("abc").select(fn.Floor(self.t.a / (self.t.b / 2))) + + self.assertEqual('SELECT "a"/(FLOOR("b")/2) FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"/(FLOOR("b")/2) FROM "abc"', str(q2)) + self.assertEqual('SELECT FLOOR("a"/("b"/2)) FROM "abc"', str(q3)) + self.assertEqual('SELECT FLOOR("a"/("b"/2)) FROM "abc"', str(q4)) + + def test__complex_op_nested_parentheses(self): + q1 = Q.from_("abc").select(F("a") / (F("b") / ((F("c") / 2)))) + q2 = Q.from_("abc").select(self.t.a / (self.t.b / ((self.t.c / 2)))) + + self.assertEqual('SELECT "a"/("b"/("c"/2)) FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"/("b"/("c"/2)) FROM "abc"', str(q2)) + + def test__arithmetic_equality(self): + q1 = Q.from_("abc").select(F("a") / 2 == 2) + q2 = Q.from_(self.t).select(self.t.a / 2 == 2) + + self.assertEqual('SELECT "a"/2=2 FROM "abc"', str(q1)) + self.assertEqual('SELECT "a"/2=2 FROM "abc"', str(q2)) + + def test__arithmetic_with_function(self): + q1 = Q.from_("abc").select(fn.Sum(F("foo")) + 1) + q2 = Q.from_(self.t).select(fn.Sum(self.t.foo) + 1) + + self.assertEqual('SELECT SUM("foo")+1 FROM "abc"', str(q1)) + self.assertEqual('SELECT SUM("foo")+1 FROM "abc"', str(q2)) + + def test__exponent__number(self): + q1 = Q.from_("abc").select(F("a") ** 2) + q2 = Q.from_(self.t).select(self.t.a**2) + + self.assertEqual('SELECT POW("a",2) FROM "abc"', str(q1)) + self.assertEqual('SELECT POW("a",2) FROM "abc"', str(q2)) + + def test__exponent__decimal(self): + q1 = Q.from_("abc").select(F("a") ** 0.5) + q2 = Q.from_(self.t).select(self.t.a**0.5) + + self.assertEqual('SELECT POW("a",0.5) FROM "abc"', str(q1)) + self.assertEqual('SELECT POW("a",0.5) FROM "abc"', str(q2)) + + def test__modulus__number(self): + q1 = Q.from_("abc").select(F("a") % 2) + q2 = Q.from_(self.t).select(self.t.a % 2) + + self.assertEqual('SELECT MOD("a",2) FROM "abc"', str(q1)) + self.assertEqual('SELECT MOD("a",2) FROM "abc"', str(q2)) + + def test__floor(self): + q1 = Q.from_("abc").select(fn.Floor(F("foo"))) + q2 = Q.from_(self.t).select(fn.Floor(self.t.foo)) + + self.assertEqual('SELECT FLOOR("foo") FROM "abc"', str(q1)) + self.assertEqual('SELECT FLOOR("foo") FROM "abc"', str(q2)) + + +class AggregationTests(unittest.TestCase): + def test__count(self): + q = Q.from_("abc").select(fn.Count(F("foo"))) + + self.assertEqual('SELECT COUNT("foo") FROM "abc"', str(q)) + + def test__count__star(self): + q = Q.from_("abc").select(fn.Count("*")) + + self.assertEqual('SELECT COUNT(*) FROM "abc"', str(q)) + + def test__sum(self): + q = Q.from_("abc").select(fn.Sum(F("foo"))) + + self.assertEqual('SELECT SUM("foo") FROM "abc"', str(q)) + + def test__avg(self): + q = Q.from_("abc").select(fn.Avg(F("foo"))) + + self.assertEqual('SELECT AVG("foo") FROM "abc"', str(q)) + + def test__first(self): + q = Q.from_("abc").select(fn.First(F("foo"))) + + self.assertEqual('SELECT FIRST("foo") FROM "abc"', str(q)) + + def test__last(self): + q = Q.from_("abc").select(fn.Last(F("foo"))) + + self.assertEqual('SELECT LAST("foo") FROM "abc"', str(q)) + + def test__min(self): + q = Q.from_("abc").select(fn.Min(F("foo"))) + + self.assertEqual('SELECT MIN("foo") FROM "abc"', str(q)) + + def test__max(self): + q = Q.from_("abc").select(fn.Max(F("foo"))) + + self.assertEqual('SELECT MAX("foo") FROM "abc"', str(q)) + + def test__std(self): + q = Q.from_("abc").select(fn.Std(F("foo"))) + + self.assertEqual('SELECT STD("foo") FROM "abc"', str(q)) + + def test__stddev(self): + q = Q.from_("abc").select(fn.StdDev(F("foo"))) + + self.assertEqual('SELECT STDDEV("foo") FROM "abc"', str(q)) + + def test__approx_percentile(self): + q = Q.from_("abc").select(fn.ApproximatePercentile(F("foo"), 0.5)) + + self.assertEqual( + 'SELECT APPROXIMATE_PERCENTILE("foo" USING PARAMETERS percentile=0.5) FROM "abc"', + str(q), + ) + + def test__subquery_in_params_functions(self): + subquery = Query.from_('table').select('id') + func = fn.Function('func', 'id', subquery) + self.assertEqual("func('id',(SELECT id FROM table))", func.get_sql()) + + +class ConditionTests(unittest.TestCase): + def test__case__raw(self): + q = Q.from_("abc").select(Case().when(F("foo") == 1, "a")) + + self.assertEqual('SELECT CASE WHEN "foo"=1 THEN \'a\' END FROM "abc"', str(q)) + + def test__case__else(self): + q = Q.from_("abc").select(Case().when(F("foo") == 1, "a").else_("b")) + + self.assertEqual("SELECT CASE WHEN \"foo\"=1 THEN 'a' ELSE 'b' END FROM \"abc\"", str(q)) + + def test__case__field(self): + q = Q.from_("abc").select(Case().when(F("foo") == 1, F("bar")).else_(F("buz"))) + + self.assertEqual('SELECT CASE WHEN "foo"=1 THEN "bar" ELSE "buz" END FROM "abc"', str(q)) + + def test__case__multi(self): + q = Q.from_("abc").select(Case().when(F("foo") > 0, F("fiz")).when(F("bar") <= 0, F("buz")).else_(1)) + + self.assertEqual( + 'SELECT CASE WHEN "foo">0 THEN "fiz" WHEN "bar"<=0 THEN "buz" ELSE 1 END FROM "abc"', + str(q), + ) + + def test__case__no_cases(self): + with self.assertRaises(CaseException): + q = Q.from_("abc").select(Case()) + + str(q) + + +class StringTests(unittest.TestCase): + t = T("abc") + + def test__ascii__str(self): + q = Q.select(fn.Ascii("2")) + + self.assertEqual("SELECT ASCII('2')", str(q)) + + def test__ascii__int(self): + q = Q.select(fn.Ascii(2)) + + self.assertEqual("SELECT ASCII(2)", str(q)) + + def test__ascii__field(self): + q = Q.from_(self.t).select(fn.Ascii(self.t.foo)) + + self.assertEqual('SELECT ASCII("foo") FROM "abc"', str(q)) + + def test__bin__str(self): + q = Q.select(fn.Bin("2")) + + self.assertEqual("SELECT BIN('2')", str(q)) + + def test__bin__int(self): + q = Q.select(fn.Bin(2)) + + self.assertEqual("SELECT BIN(2)", str(q)) + + def test__bin__field(self): + q = Q.from_(self.t).select(fn.Bin(self.t.foo)) + + self.assertEqual('SELECT BIN("foo") FROM "abc"', str(q)) + + def test__concat__str(self): + q = Q.select(fn.Concat("p", "y", "q", "b")) + + self.assertEqual("SELECT CONCAT('p','y','q','b')", str(q)) + + def test__concat__field(self): + q = Q.from_(self.t).select(fn.Concat(self.t.foo, self.t.bar)) + + self.assertEqual('SELECT CONCAT("foo","bar") FROM "abc"', str(q)) + + def test__insert__str(self): + q = Q.select(fn.Insert("Quadratic", 3, 4, "What")) + + self.assertEqual("SELECT INSERT('Quadratic',3,4,'What')", str(q)) + + def test__insert__field(self): + q = Q.from_(self.t).select(fn.Insert(self.t.foo, 3, 4, self.t.bar)) + + self.assertEqual('SELECT INSERT("foo",3,4,"bar") FROM "abc"', str(q)) + + def test__lower__str(self): + q = Q.select(fn.Lower("ABC")) + + self.assertEqual("SELECT LOWER('ABC')", str(q)) + + def test__lower__field(self): + q = Q.from_(self.t).select(fn.Lower(self.t.foo)) + + self.assertEqual('SELECT LOWER("foo") FROM "abc"', str(q)) + + def test__length__str(self): + q = Q.select(fn.Length("ABC")) + + self.assertEqual("SELECT LENGTH('ABC')", str(q)) + + def test__length__field(self): + q = Q.from_(self.t).select(fn.Length(self.t.foo)) + + self.assertEqual('SELECT LENGTH("foo") FROM "abc"', str(q)) + + def test__substring(self): + q = Q.from_(self.t).select(fn.Substring(self.t.foo, 2, 6)) + + self.assertEqual('SELECT SUBSTRING("foo",2,6) FROM "abc"', str(q)) + + def test__replace__str(self): + q = Q.select(fn.Replace("ABC_DEF", "_", " ")) + self.assertEqual("SELECT REPLACE('ABC_DEF','_',' ')", str(q)) + + def test__replace__field(self): + q = Q.from_(self.t).select(fn.Replace(self.t.foobar, self.t.foo, self.t.bar)) + self.assertEqual('SELECT REPLACE("foobar","foo","bar") FROM "abc"', str(q)) + + +class SplitPartFunctionTests(unittest.TestCase): + t = T("abc") + + def test__split_part(self): + q = VerticaQuery.from_(self.t).select(fn.SplitPart(self.t.foo, "|", 3)) + + self.assertEqual('SELECT SPLIT_PART("foo",\'|\',3) FROM "abc"', str(q)) + + +class RegexpLikeFunctionTests(unittest.TestCase): + t = T("abc") + + def test__regexp_like(self): + q = VerticaQuery.from_(self.t).select(fn.RegexpLike(self.t.foo, "^a", "x")) + + self.assertEqual("SELECT REGEXP_LIKE(\"foo\",'^a','x') FROM \"abc\"", str(q)) + + +class CastTests(unittest.TestCase): + t = T("abc") + + def test__cast__as(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.UNSIGNED)) + + self.assertEqual('SELECT CAST("foo" AS UNSIGNED) FROM "abc"', str(q)) + + def test__cast__signed(self): + q1 = Q.from_(self.t).select(fn.Signed(self.t.foo)) + q2 = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.SIGNED)) + + self.assertEqual('SELECT CAST("foo" AS SIGNED) FROM "abc"', str(q1)) + self.assertEqual('SELECT CAST("foo" AS SIGNED) FROM "abc"', str(q2)) + + def test__cast__unsigned(self): + q1 = Q.from_(self.t).select(fn.Unsigned(self.t.foo)) + q2 = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.UNSIGNED)) + + self.assertEqual('SELECT CAST("foo" AS UNSIGNED) FROM "abc"', str(q1)) + self.assertEqual('SELECT CAST("foo" AS UNSIGNED) FROM "abc"', str(q2)) + + def test__cast__date(self): + q1 = Q.from_(self.t).select(fn.Date(self.t.foo)) + q2 = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.DATE)) + + self.assertEqual('SELECT DATE("foo") FROM "abc"', str(q1)) + self.assertEqual('SELECT CAST("foo" AS DATE) FROM "abc"', str(q2)) + + def test__cast__timestamp(self): + q1 = Q.from_(self.t).select(fn.Timestamp(self.t.foo)) + q2 = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.TIMESTAMP)) + + self.assertEqual('SELECT TIMESTAMP("foo") FROM "abc"', str(q1)) + self.assertEqual('SELECT CAST("foo" AS TIMESTAMP) FROM "abc"', str(q2)) + + def test__cast__char(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.CHAR)) + + self.assertEqual('SELECT CAST("foo" AS CHAR) FROM "abc"', str(q)) + + def test__cast__char_with_arg(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.VARCHAR(24))) + + self.assertEqual('SELECT CAST("foo" AS VARCHAR(24)) FROM "abc"', str(q)) + + def test__cast__varchar(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.VARCHAR)) + + self.assertEqual('SELECT CAST("foo" AS VARCHAR) FROM "abc"', str(q)) + + def test__cast__varchar_with_arg(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.VARCHAR(24))) + + self.assertEqual('SELECT CAST("foo" AS VARCHAR(24)) FROM "abc"', str(q)) + + def test__cast__long_varchar(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.LONG_VARCHAR)) + + self.assertEqual('SELECT CAST("foo" AS LONG VARCHAR) FROM "abc"', str(q)) + + def test__cast__long_varchar_with_arg(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.LONG_VARCHAR(24))) + + self.assertEqual('SELECT CAST("foo" AS LONG VARCHAR(24)) FROM "abc"', str(q)) + + def test__cast__binary(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.BINARY)) + + self.assertEqual('SELECT CAST("foo" AS BINARY) FROM "abc"', str(q)) + + def test__cast__binary_with_arg(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.BINARY(24))) + + self.assertEqual('SELECT CAST("foo" AS BINARY(24)) FROM "abc"', str(q)) + + def test__cast__varbinary(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.VARBINARY)) + + self.assertEqual('SELECT CAST("foo" AS VARBINARY) FROM "abc"', str(q)) + + def test__cast__varbinary_with_arg(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.VARBINARY(24))) + + self.assertEqual('SELECT CAST("foo" AS VARBINARY(24)) FROM "abc"', str(q)) + + def test__cast__long_varbinary(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.LONG_VARBINARY)) + + self.assertEqual('SELECT CAST("foo" AS LONG VARBINARY) FROM "abc"', str(q)) + + def test__cast__long_varbinary_with_arg(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.LONG_VARBINARY(24))) + + self.assertEqual('SELECT CAST("foo" AS LONG VARBINARY(24)) FROM "abc"', str(q)) + + def test__cast__boolean(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.BOOLEAN)) + + self.assertEqual('SELECT CAST("foo" AS BOOLEAN) FROM "abc"', str(q)) + + def test__cast__integer(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.INTEGER)) + + self.assertEqual('SELECT CAST("foo" AS INTEGER) FROM "abc"', str(q)) + + def test__cast__float(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.FLOAT)) + + self.assertEqual('SELECT CAST("foo" AS FLOAT) FROM "abc"', str(q)) + + def test__cast__numeric(self): + q = Q.from_(self.t).select(fn.Cast(self.t.foo, SqlTypes.NUMERIC)) + + self.assertEqual('SELECT CAST("foo" AS NUMERIC) FROM "abc"', str(q)) + + def test__tochar__(self): + q = Q.from_(self.t).select(fn.ToChar(self.t.foo, "SomeFormat")) + + self.assertEqual('SELECT TO_CHAR("foo",\'SomeFormat\') FROM "abc"', str(q)) + + +class DateFunctionsTests(unittest.TestCase): + dt = F("dt") + t = T("abc") + t2 = T("efg") + + def _test_extract_datepart(self, date_part): + q = Q.from_(self.t).select(fn.Extract(date_part, self.t.foo)) + + value = getattr(date_part, 'value', date_part) + self.assertEqual('SELECT EXTRACT(%s FROM "foo") FROM "abc"' % value, str(q)) + + def test_extract_microsecond(self): + self._test_extract_datepart(DatePart.microsecond) + self._test_extract_datepart(DatePart.microsecond.value) + + def test_extract_second(self): + self._test_extract_datepart(DatePart.second) + self._test_extract_datepart(DatePart.second.value) + + def test_extract_minute(self): + self._test_extract_datepart(DatePart.minute) + self._test_extract_datepart(DatePart.minute.value) + + def test_extract_hour(self): + self._test_extract_datepart(DatePart.hour) + self._test_extract_datepart(DatePart.hour.value) + + def test_extract_day(self): + self._test_extract_datepart(DatePart.day) + self._test_extract_datepart(DatePart.day.value) + + def test_extract_week(self): + self._test_extract_datepart(DatePart.week) + self._test_extract_datepart(DatePart.week.value) + + def test_extract_month(self): + self._test_extract_datepart(DatePart.month) + self._test_extract_datepart(DatePart.month.value) + + def test_extract_quarter(self): + self._test_extract_datepart(DatePart.quarter) + self._test_extract_datepart(DatePart.quarter.value) + + def test_extract_year(self): + self._test_extract_datepart(DatePart.year) + self._test_extract_datepart(DatePart.year.value) + + def test_extract_join(self): + q = Q.from_(self.t).join(self.t2).on(self.t.id == self.t2.t_id).select(fn.Extract(DatePart.year, self.t.foo)) + + self.assertEqual( + 'SELECT EXTRACT(YEAR FROM "abc"."foo") FROM "abc" ' 'JOIN "efg" ON "abc"."id"="efg"."t_id"', str(q) + ) + + def test_timestampadd(self): + a = fn.TimestampAdd("year", 1, "2017-10-01") + self.assertEqual(str(a), "TIMESTAMPADD(year,1,'2017-10-01')") + + def test_time_diff(self): + a = fn.TimeDiff("18:00:00", "10:00:00") + self.assertEqual(str(a), "TIMEDIFF('18:00:00','10:00:00')") + + def test_date_add(self): + a = fn.DateAdd("year", 1, "2017-10-01") + self.assertEqual(str(a), "DATE_ADD(year,1,'2017-10-01')") + + def test_now(self): + query = Query.select(fn.Now()) + + self.assertEqual("SELECT NOW()", str(query)) + + def test_utc_timestamp(self): + query = Query.select(fn.UtcTimestamp()) + + self.assertEqual("SELECT UTC_TIMESTAMP()", str(query)) + + def test_current_date(self): + query = Query.select(fn.CurDate()) + + self.assertEqual("SELECT CURRENT_DATE()", str(query)) + + def test_current_time(self): + query = Query.select(fn.CurTime()) + + self.assertEqual("SELECT CURRENT_TIME()", str(query)) + + def test_current_timestamp(self): + query = Query.select(fn.CurTimestamp()) + + self.assertEqual("SELECT CURRENT_TIMESTAMP", str(query)) + + def test_current_timestamp_with_alias(self): + query = Query.select(fn.CurTimestamp("ts")) + + self.assertEqual('SELECT CURRENT_TIMESTAMP "ts"', str(query)) + + def test_to_date(self): + q1 = fn.ToDate("2019-06-21", "yyyy-mm-dd") + q2 = Query.from_(self.t).select(fn.ToDate("2019-06-21", "yyyy-mm-dd")) + q3 = Query.from_(self.t).select(fn.ToDate(F("foo"), "yyyy-mm-dd")) + + self.assertEqual(str(q1), "TO_DATE('2019-06-21','yyyy-mm-dd')") + self.assertEqual(str(q2), "SELECT TO_DATE('2019-06-21','yyyy-mm-dd') FROM \"abc\"") + self.assertEqual(str(q3), 'SELECT TO_DATE("foo",\'yyyy-mm-dd\') FROM "abc"') + + +class NullFunctionsTests(unittest.TestCase): + def test_isnull(self): + q = Q.from_("abc").select(fn.IsNull(F("foo"))) + + self.assertEqual('SELECT ISNULL("foo") FROM "abc"', str(q)) + + def test_coalesce(self): + q = Q.from_("abc").select(fn.Coalesce(F("foo"), 0)) + + self.assertEqual('SELECT COALESCE("foo",0) FROM "abc"', str(q)) + + def test_nullif(self): + q = Q.from_("abc").select(fn.NullIf(F("foo"), 0)) + + self.assertEqual('SELECT NULLIF("foo",0) FROM "abc"', str(q)) + + def test_nvl(self): + q = Q.from_("abc").select(fn.NVL(F("foo"), 0)) + + self.assertEqual('SELECT NVL("foo",0) FROM "abc"', str(q)) diff --git a/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/test_groupby_modifiers.py b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/test_groupby_modifiers.py new file mode 100644 index 0000000000000000000000000000000000000000..978834c2409f4b4800fedb9b1bb2538a31d0f31c --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/test_groupby_modifiers.py @@ -0,0 +1,168 @@ +import unittest + +from pypika import Query, Rollup, RollupException, Table, functions as fn + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + + +class RollupTests(unittest.TestCase): + table = Table("abc") + + def test_mysql_one_groupby(self): + q = ( + Query.from_(self.table) + .select(self.table.foo, fn.Sum(self.table.bar)) + .rollup(self.table.foo, vendor="mysql") + ) + + self.assertEqual('SELECT "foo",SUM("bar") FROM "abc" GROUP BY "foo" WITH ROLLUP', str(q)) + + def test_mysql_rollup_two_groupbys(self): + q = ( + Query.from_(self.table) + .select(self.table.foo, self.table.fiz, fn.Sum(self.table.bar)) + .rollup(self.table.foo, self.table.fiz, vendor="mysql") + ) + + self.assertEqual( + 'SELECT "foo","fiz",SUM("bar") FROM "abc" GROUP BY "foo","fiz" WITH ROLLUP', + str(q), + ) + + def test_no_rollup_before_groupby(self): + with self.assertRaises(RollupException): + Query.from_(self.table).select(self.table.foo, fn.Sum(self.table.bar)).rollup(vendor="mysql") + + def test_no_rollup_after_rollup_mysql(self): + with self.assertRaises(AttributeError): + Query.from_(self.table).select(self.table.foo, self.table.fiz, fn.Sum(self.table.bar)).rollup( + self.table.foo, vendor="mysql" + ).rollup(self.table.fiz, vendor="mysql") + + def test_verticaoracle_func_one_groupby(self): + q = Query.from_(self.table).select(self.table.foo, fn.Sum(self.table.bar)).groupby(Rollup(self.table.foo)) + + self.assertEqual('SELECT "foo",SUM("bar") FROM "abc" GROUP BY ROLLUP("foo")', str(q)) + + def test_verticaoracle_func_two_groupbys(self): + q = ( + Query.from_(self.table) + .select(self.table.foo, self.table.fiz, fn.Sum(self.table.bar)) + .groupby( + Rollup( + self.table.foo, + self.table.fiz, + ) + ) + ) + + self.assertEqual( + 'SELECT "foo","fiz",SUM("bar") FROM "abc" GROUP BY ROLLUP("foo","fiz")', + str(q), + ) + + def test_verticaoracle_func_partial(self): + q = ( + Query.from_(self.table) + .select(self.table.foo, self.table.fiz, self.table.buz, fn.Sum(self.table.bar)) + .groupby( + Rollup( + self.table.foo, + self.table.fiz, + ), + self.table.buz, + ) + ) + + self.assertEqual( + 'SELECT "foo","fiz","buz",SUM("bar") FROM "abc" GROUP BY ROLLUP("foo","fiz"),"buz"', + str(q), + ) + + def test_verticaoracle_from_groupbys(self): + q = Query.from_(self.table).select(self.table.foo, fn.Sum(self.table.bar)).rollup(self.table.foo) + + self.assertEqual('SELECT "foo",SUM("bar") FROM "abc" GROUP BY ROLLUP("foo")', str(q)) + + def test_verticaoracle_from_two_groupbys(self): + q = ( + Query.from_(self.table) + .select(self.table.foo, self.table.fiz, fn.Sum(self.table.bar)) + .rollup( + self.table.foo, + self.table.fiz, + ) + ) + + self.assertEqual( + 'SELECT "foo","fiz",SUM("bar") FROM "abc" GROUP BY ROLLUP("foo","fiz")', + str(q), + ) + + def test_verticaoracle_from_parameters(self): + q = ( + Query.from_(self.table) + .select(self.table.foo, self.table.fiz, fn.Sum(self.table.bar)) + .groupby( + self.table.foo, + ) + .rollup( + self.table.fiz, + ) + ) + + self.assertEqual( + 'SELECT "foo","fiz",SUM("bar") FROM "abc" GROUP BY "foo",ROLLUP("fiz")', + str(q), + ) + + def test_verticaoracle_multiple_rollups(self): + q = ( + Query.from_(self.table) + .select(self.table.foo, self.table.fiz, fn.Sum(self.table.bar)) + .rollup( + self.table.foo, + ) + .rollup( + self.table.fiz, + ) + ) + + self.assertEqual( + 'SELECT "foo","fiz",SUM("bar") FROM "abc" GROUP BY ROLLUP("foo","fiz")', + str(q), + ) + + def test_verticaoracle_rollups_with_parity(self): + q = ( + Query.from_(self.table) + .select( + self.table.buz, + ) + .rollup( + [self.table.foo, self.table.bar], + self.table.fiz, + ) + ) + + self.assertEqual('SELECT "buz" FROM "abc" GROUP BY ROLLUP(("foo","bar"),"fiz")', str(q)) + + def test_verticaoracle_rollups_with_multiple_rollups_and_parity(self): + q = ( + Query.from_(self.table) + .select( + self.table.buz, + ) + .rollup( + [self.table.foo, self.table.bar], + ) + .rollup( + [self.table.fiz, self.table.buz], + ) + ) + + self.assertEqual( + 'SELECT "buz" FROM "abc" GROUP BY ROLLUP(("foo","bar"),("fiz","buz"))', + str(q), + ) diff --git a/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/test_immutability.py b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/test_immutability.py new file mode 100644 index 0000000000000000000000000000000000000000..ee539bfa1e9c4509b929e7a86a03f098dd923515 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/test_immutability.py @@ -0,0 +1,99 @@ +import unittest + +from pypika import ( + AliasedQuery, + Query, + Tables, +) + + +class ImmutabilityTests(unittest.TestCase): + table_a, table_b, table_c = Tables("a", "b", "c") + + def test_select_returns_new_query_instance(self): + query_a = Query.from_(self.table_a).select(self.table_a.foo) + query_b = query_a.select(self.table_a.bar) + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_groupby_returns_new_query_instance(self): + query_a = Query.from_(self.table_a).select(self.table_a.foo).groupby(self.table_a.foo) + query_b = query_a.groupby(self.table_a.bar) + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_orderby_return_new_query_instance(self): + query_a = Query.from_(self.table_a).select(self.table_a.foo).orderby(self.table_a.foo) + query_b = query_a.orderby(self.table_a.bar) + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_join_return_new_query_instance(self): + base = Query.from_(self.table_a).select(self.table_a.foo) + query_a = base.join(self.table_b).on(self.table_a.foo == self.table_b.bar).select(self.table_b.bar) + query_b = query_a.join(self.table_c).on(self.table_a.foo == self.table_c.baz).select(self.table_c.baz) + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_use_index_return_new_query_instance(self): + query_a = Query.from_(self.table_a).select(self.table_a.foo).use_index('idx1') + query_b = query_a.use_index('idx2') + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_force_index_return_new_query_instance(self): + query_a = Query.from_(self.table_a).select(self.table_a.foo).force_index('idx1') + query_b = query_a.force_index('idx2') + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_with_return_new_query_instance(self): + alias_1 = Query.from_(self.table_a).select(self.table_a.foo) + alias_2 = Query.from_(self.table_b).select(self.table_b.bar) + query_a = Query.from_(AliasedQuery('a1')).select('foo').with_(alias_1, 'a1') + query_b = query_a.with_(alias_2, 'a2') + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_insert_into_return_new_query_instance(self): + query_a = Query.into(self.table_a).insert('foo1') + query_b = query_a.insert('foo2') + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_replace_into_return_new_query_instance(self): + query_a = Query.into(self.table_a).replace('foo') + query_b = query_a.replace('bar') + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_update_set_return_new_query_instance(self): + query_a = Query.update(self.table_a).set(self.table_a.foo, 'foo') + query_b = query_a.set(self.table_a.bar, 'bar') + + self.assertIsNot(query_a, query_b) + self.assertNotEqual(str(query_a), str(query_b)) + + def test_queries_after_join(self): + query1 = Query.from_(self.table_a).select(self.table_a.foo) + query2 = query1.join(self.table_b).on(self.table_a.foo == self.table_b.bar).select(self.table_b.buz) + + self.assertEqual('SELECT "foo" FROM "a"', str(query1)) + self.assertEqual( + 'SELECT "a"."foo","b"."buz" FROM "a" JOIN "b" ON "a"."foo"="b"."bar"', + str(query2), + ) + + def test_immutable_kwarg_on_query_builder_disables_immutability(self): + query0 = Query.from_(self.table_a, immutable=False) + query1 = query0.select(self.table_a.foo) + self.assertIs(query0, query1) diff --git a/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/test_inserts.py b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/test_inserts.py new file mode 100644 index 0000000000000000000000000000000000000000..f86efd7a76dc498a69b61c6353951695f1933a61 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/test_inserts.py @@ -0,0 +1,885 @@ +import unittest + +from pypika import ( + AliasedQuery, + Case, + Field as F, + MySQLQuery, + PostgreSQLQuery, + Query, + Table, + Tables, + functions as fn, +) +from pypika.functions import ( + Avg, + Cast, +) +from pypika.terms import Values +from pypika.utils import QueryException + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + + +class InsertIntoTests(unittest.TestCase): + table_abc = Table("abc") + + def test_insert_one_column(self): + query = Query.into(self.table_abc).insert(1) + + self.assertEqual('INSERT INTO "abc" VALUES (1)', str(query)) + + def test_insert_one_column_single_element_array(self): + query = Query.into(self.table_abc).insert((1,)) + + self.assertEqual('INSERT INTO "abc" VALUES (1)', str(query)) + + def test_insert_one_column_multi_element_array(self): + query = Query.into(self.table_abc).insert((1,), (2,)) + + self.assertEqual('INSERT INTO "abc" VALUES (1),(2)', str(query)) + + def test_insert_single_row_with_array_value(self): + query = Query.into(self.table_abc).insert(1, ["a", "b", "c"]) + + self.assertEqual("INSERT INTO \"abc\" VALUES (1,['a','b','c'])", str(query)) + + def test_insert_multiple_rows_with_array_value(self): + query = Query.into(self.table_abc).insert( + (1, ["a", "b", "c"]), + (2, ["c", "d", "e"]), + ) + + self.assertEqual( + 'INSERT INTO "abc" ' "VALUES (1,['a','b','c']),(2,['c','d','e'])", + str(query), + ) + + def test_insert_all_columns(self): + query = Query.into(self.table_abc).insert(1, "a", True) + + self.assertEqual("INSERT INTO \"abc\" VALUES (1,'a',true)", str(query)) + + def test_insert_all_columns_single_element(self): + query = Query.into(self.table_abc).insert((1, "a", True)) + + self.assertEqual("INSERT INTO \"abc\" VALUES (1,'a',true)", str(query)) + + def test_insert_all_columns_multi_rows(self): + query = Query.into(self.table_abc).insert((1, "a", True), (2, "b", False)) + + self.assertEqual("INSERT INTO \"abc\" VALUES (1,'a',true),(2,'b',false)", str(query)) + + def test_insert_all_columns_multi_rows_chained(self): + query = Query.into(self.table_abc).insert(1, "a", True).insert(2, "b", False) + + self.assertEqual("INSERT INTO \"abc\" VALUES (1,'a',true),(2,'b',false)", str(query)) + + def test_insert_all_columns_multi_rows_chained_mixed(self): + query = Query.into(self.table_abc).insert((1, "a", True), (2, "b", False)).insert(3, "c", True) + + self.assertEqual( + 'INSERT INTO "abc" VALUES ' "(1,'a',true),(2,'b',false)," "(3,'c',true)", + str(query), + ) + + def test_insert_all_columns_multi_rows_chained_multiple_rows(self): + query = ( + Query.into(self.table_abc).insert((1, "a", True), (2, "b", False)).insert((3, "c", True), (4, "d", False)) + ) + + self.assertEqual( + 'INSERT INTO "abc" VALUES ' "(1,'a',true),(2,'b',false)," "(3,'c',true),(4,'d',false)", + str(query), + ) + + def test_insert_selected_columns(self): + query = ( + Query.into(self.table_abc) + .columns(self.table_abc.foo, self.table_abc.bar, self.table_abc.buz) + .insert(1, "a", True) + ) + + self.assertEqual('INSERT INTO "abc" ("foo","bar","buz") VALUES (1,\'a\',true)', str(query)) + + def test_insert_empty_columns(self): + query = Query.into(self.table_abc).columns().insert(1, "a", True) + + self.assertEqual('INSERT INTO "abc" VALUES (1,\'a\',true)', str(query)) + + def test_insert_selected_columns_type_list(self): + query = ( + Query.into(self.table_abc) + .columns([self.table_abc.foo, self.table_abc.bar, self.table_abc.buz]) + .insert(1, "a", True) + ) + + self.assertEqual('INSERT INTO "abc" ("foo","bar","buz") VALUES (1,\'a\',true)', str(query)) + + def test_insert_empty_columns_type_list(self): + query = Query.into(self.table_abc).columns([]).insert(1, "a", True) + + self.assertEqual('INSERT INTO "abc" VALUES (1,\'a\',true)', str(query)) + + def test_insert_selected_columns_type_tuple(self): + query = ( + Query.into(self.table_abc) + .columns((self.table_abc.foo, self.table_abc.bar, self.table_abc.buz)) + .insert(1, "a", True) + ) + + self.assertEqual('INSERT INTO "abc" ("foo","bar","buz") VALUES (1,\'a\',true)', str(query)) + + def test_insert_empty_columns_type_tuple(self): + query = Query.into(self.table_abc).columns(()).insert(1, "a", True) + + self.assertEqual('INSERT INTO "abc" VALUES (1,\'a\',true)', str(query)) + + def test_insert_none_skipped(self): + query = Query.into(self.table_abc).insert() + + self.assertEqual("", str(query)) + + def test_insert_ignore(self): + query = Query.into(self.table_abc).insert(1).ignore() + + self.assertEqual('INSERT IGNORE INTO "abc" VALUES (1)', str(query)) + + def test_insert_null(self): + query = Query.into(self.table_abc).insert(None) + + self.assertEqual('INSERT INTO "abc" VALUES (NULL)', str(query)) + + def test_insert_column_using_table_alias(self): + q = self.table_abc.insert(1) + self.assertEqual('INSERT INTO "abc" VALUES (1)', str(q)) + + def test_insert_column_using_alias_with_chain(self): + q = self.table_abc.insert(1, "a", True).insert(2, "b", False) + self.assertEqual("INSERT INTO \"abc\" VALUES (1,'a',true),(2,'b',false)", str(q)) + + def test_insert_with_statement(self): + sub_query = Query().select(self.table_abc.id).from_(self.table_abc) + aliased = AliasedQuery('sub_qs') + + q = Query().with_(sub_query, 'sub_qs').into(self.table_abc).select(aliased.id).from_(aliased) + self.assertEqual( + 'WITH sub_qs AS (SELECT "id" FROM "abc") INSERT INTO "abc" SELECT "sub_qs"."id" FROM sub_qs', str(q) + ) + + +class PostgresInsertIntoOnConflictTests(unittest.TestCase): + table_abc = Table("abc") + + def test_insert_on_conflict_do_nothing_field(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).on_conflict(self.table_abc.id).do_nothing() + + self.assertEqual('INSERT INTO "abc" VALUES (1) ON CONFLICT ("id") DO NOTHING', str(query)) + + def test_insert_on_conflict_do_nothing_multiple_fields(self): + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1) + .on_conflict(self.table_abc.id, self.table_abc.sub_id) + .do_nothing() + ) + + self.assertEqual('INSERT INTO "abc" VALUES (1) ON CONFLICT ("id", "sub_id") DO NOTHING', str(query)) + + def test_insert_on_conflict_do_nothing_field_str(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).on_conflict("id").do_nothing() + + self.assertEqual('INSERT INTO "abc" VALUES (1) ON CONFLICT ("id") DO NOTHING', str(query)) + + def test_insert_on_conflict_do_nothing_multiple_fields_str(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).on_conflict("id", "sub_id").do_nothing() + + self.assertEqual('INSERT INTO "abc" VALUES (1) ON CONFLICT ("id", "sub_id") DO NOTHING', str(query)) + + def test_insert_on_conflict_do_nothing_mixed_fields(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).on_conflict("id", self.table_abc.sub_id).do_nothing() + + self.assertEqual('INSERT INTO "abc" VALUES (1) ON CONFLICT ("id", "sub_id") DO NOTHING', str(query)) + + def test_insert_on_conflict_do_update_field(self): + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict(self.table_abc.id) + .do_update(self.table_abc.name, "m") + ) + + self.assertEqual( + "INSERT INTO \"abc\" VALUES (1,'m') ON CONFLICT (\"id\") DO UPDATE SET \"name\"='m'", + str(query), + ) + + def test_insert_on_conflict_do_update_multiple_fields(self): + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict(self.table_abc.id, self.table_abc.sub_id) + .do_update(self.table_abc.name, "m") + ) + + self.assertEqual( + "INSERT INTO \"abc\" VALUES (1,'m') ON CONFLICT (\"id\", \"sub_id\") DO UPDATE SET \"name\"='m'", + str(query), + ) + + def test_insert_on_conflict_do_update_field_str(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1, "m").on_conflict("id").do_update("name", "m") + + self.assertEqual( + "INSERT INTO \"abc\" VALUES (1,'m') ON CONFLICT (\"id\") DO UPDATE SET \"name\"='m'", + str(query), + ) + + def test_insert_on_conflict_do_update_multiple_fields_str(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1, "m").on_conflict("id", "sub_id").do_update("name", "m") + + self.assertEqual( + "INSERT INTO \"abc\" VALUES (1,'m') ON CONFLICT (\"id\", \"sub_id\") DO UPDATE SET \"name\"='m'", + str(query), + ) + + def test_insert_on_conflict_do_update_multiple_mixed_fields(self): + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict("id", self.table_abc.sub_id) + .do_update("name", "m") + ) + + self.assertEqual( + "INSERT INTO \"abc\" VALUES (1,'m') ON CONFLICT (\"id\", \"sub_id\") DO UPDATE SET \"name\"='m'", + str(query), + ) + + def test_insert_on_conflict_no_handler(self): + with self.assertRaises(QueryException): + query = str(PostgreSQLQuery.into(self.table_abc).insert(1).on_conflict(self.table_abc.id)) + + def test_insert_on_conflict_two_handlers_do_nothing(self): + with self.assertRaises(QueryException): + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1) + .on_conflict("id") + .do_nothing() + .do_update(self.table_abc.name, "m") + ) + + def test_insert_on_conflict_two_handlers_do_update(self): + with self.assertRaises(QueryException): + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1) + .on_conflict(self.table_abc.id) + .do_update(self.table_abc.name, "m") + .do_nothing() + ) + + def test_non_insert_on_conflict_do_nothing(self): + with self.assertRaises(QueryException): + query = PostgreSQLQuery.update(self.table_abc).set("foo", "bar").on_conflict("id").do_nothing() + + def test_non_insert_on_conflict_do_update(self): + with self.assertRaises(QueryException): + query = ( + PostgreSQLQuery.update(self.table_abc).set("foo", "bar").on_conflict("id").do_update(["name"], ["m"]) + ) + + def test_insert_on_fieldless_conflict_do_nothing(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).on_conflict(None).do_nothing() + + self.assertEqual('INSERT INTO "abc" VALUES (1) ON CONFLICT DO NOTHING', str(query)) + + def test_insert_on_fieldless_conflict_do_update_field(self): + with self.assertRaises(QueryException): + query = str( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict(None) + .do_update(self.table_abc.name, "m") + ) + + def test_on_conflict_from_subquery(self): + table_bcd = Table('bcd') + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(self.table_abc.fname, self.table_abc.lname) + .select(table_bcd.fname, table_bcd.lname) + .from_(table_bcd) + .on_conflict(self.table_abc.id, self.table_abc.sub_id) + .do_update(self.table_abc.fname, 1) + .do_update(self.table_abc.lname, table_bcd.lname) + .do_update( + self.table_abc.cname, + Case().when(self.table_abc.cname.eq('cname'), 'new_name').else_(self.table_abc.cname), + ) + ) + + self.assertEqual( + 'INSERT INTO "abc" VALUES ("fname","lname") ' + 'ON CONFLICT ("id", "sub_id") ' + 'DO UPDATE SET "fname"=1,"lname"="bcd"."lname",' + '"cname"=CASE WHEN "abc"."cname"=\'cname\' THEN \'new_name\' ELSE "abc"."cname" END', + str(query), + ) + + def test_on_conflict_where_empty_conflict_fields_do_nothing(self): + with self.assertRaises(QueryException): + ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict() + .where(self.table_abc.abc.eq(0)) + .where(self.table_abc.cde.eq(0)) + .do_nothing() + ) + + def test_on_conflict_where_conflict_fields_do_nothing(self): + qs = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict('id') + .where(self.table_abc.abc.eq(0)) + .where(self.table_abc.cde.eq(0)) + .do_nothing() + ) + self.assertEqual( + '''INSERT INTO "abc" VALUES (1,'m') ON CONFLICT ("id") WHERE "abc"=0 AND "cde"=0 DO NOTHING''', str(qs) + ) + + def test_on_conflict_where_empty_conflict_fields_do_update(self): + with self.assertRaises(QueryException): + ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict() + .where(self.table_abc.abc.eq(0)) + .where(self.table_abc.cde.eq(0)) + .do_update('field', 'val') + ) + + def test_on_conflict_where_conflict_fields_do_update(self): + qs = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict('id') + .where(self.table_abc.abc.eq(0)) + .where(self.table_abc.cde.eq(0)) + .do_update('field', 'val') + ) + self.assertEqual( + '''INSERT INTO "abc" VALUES (1,'m') ON CONFLICT ("id") WHERE "abc"=0 AND "cde"=0 ''' + '''DO UPDATE SET "field"='val\'''', + str(qs), + ) + + def test_where_and_on_conflict_where(self): + table_bcd = Table('bcd') + + qs = ( + PostgreSQLQuery.into(self.table_abc) + .select(table_bcd.abc) + .from_(table_bcd) + .where(table_bcd.abc.eq('1')) + .on_conflict('id') + .where(self.table_abc.abc.eq(0)) + .where(self.table_abc.cde.eq(0)) + .do_update('field', 'val') + ) + + self.assertEqual( + 'INSERT INTO "abc" SELECT "abc" FROM "bcd" WHERE "abc"=\'1\' ' + 'ON CONFLICT ("id") WHERE "abc"=0 AND "cde"=0 DO UPDATE SET "field"=\'val\'', + str(qs), + ) + + def test_on_conflict_do_nothing_where(self): + with self.assertRaises(QueryException): + ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict() + .do_nothing() + .where(self.table_abc.abc.eq(1)) + ) + + def test_empty_on_conflict_do_update_where(self): + with self.assertRaises(QueryException): + ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict() + .do_update('abc', 1) + .where(self.table_abc.abc.eq(1)) + ) + + def test_on_conflict_do_update_where(self): + qs = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict("id") + .do_update('abc', 1) + .where(self.table_abc.abc.eq(1)) + ) + self.assertEqual( + 'INSERT INTO "abc" VALUES (1,\'m\') ON CONFLICT ("id") DO UPDATE SET "abc"=1 WHERE "abc"."abc"=1', str(qs) + ) + + def test_on_conflict_do_update_with_excluded_where(self): + qs = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "m") + .on_conflict("id") + .do_update('abc') + .where(self.table_abc.abc.eq(1)) + ) + self.assertEqual( + 'INSERT INTO "abc" VALUES (1,\'m\') ON CONFLICT ("id") DO UPDATE SET "abc"=EXCLUDED."abc" WHERE ' + '"abc"."abc"=1', + str(qs), + ) + + def test_on_conflict_where_complex(self): + table_bcd = Table('bcd') + + qs = ( + PostgreSQLQuery.into(self.table_abc) + .select(table_bcd.abc) + .from_(table_bcd) + .where(table_bcd.abc.eq('1')) + .on_conflict('id') + .where(self.table_abc.abc.eq(0)) + .where(self.table_abc.cde.eq(0)) + .do_update('field', 'val') + .where(self.table_abc.id.eq(2)) + .where(self.table_abc.sub_id.eq(3)) + ) + self.assertEqual( + 'INSERT INTO "abc" SELECT "abc" FROM "bcd" WHERE "abc"=\'1\' ' + 'ON CONFLICT ("id") WHERE "abc"=0 AND "cde"=0 ' + 'DO UPDATE SET "field"=\'val\' WHERE "abc"."id"=2 AND "abc"."sub_id"=3', + str(qs), + ) + + +class PostgresInsertIntoReturningTests(unittest.TestCase): + table_abc = Table("abc") + + def test_insert_returning_one_field(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).returning(self.table_abc.id) + + self.assertEqual('INSERT INTO "abc" VALUES (1) RETURNING "id"', str(query)) + + def test_insert_returning_one_field_str(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).returning("id") + + self.assertEqual('INSERT INTO "abc" VALUES (1) RETURNING "id"', str(query)) + + def test_insert_returning_all_fields(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).returning(self.table_abc.star) + + self.assertEqual('INSERT INTO "abc" VALUES (1) RETURNING *', str(query)) + + def test_insert_returning_all_fields_and_arithmetics(self): + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1) + .returning(self.table_abc.star, self.table_abc.f1 + self.table_abc.f2) + ) + + self.assertEqual('INSERT INTO "abc" VALUES (1) RETURNING *,"f1"+"f2"', str(query)) + + def test_insert_all_columns_multi_rows_chained_returning_star(self): + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "a", True) + .insert(2, "b", False) + .returning(self.table_abc.star) + ) + + self.assertEqual( + "INSERT INTO \"abc\" VALUES (1,'a',true),(2,'b',false) RETURNING *", + str(query), + ) + + def test_insert_all_columns_multi_rows_chained_returning_star_and_id(self): + query = ( + PostgreSQLQuery.into(self.table_abc) + .insert(1, "a", True) + .insert(2, "b", False) + .returning( + self.table_abc.name, + self.table_abc.star, + self.table_abc.id, + ) + ) + + self.assertEqual( + "INSERT INTO \"abc\" VALUES (1,'a',true),(2,'b',false) RETURNING *", + str(query), + ) + + def test_insert_all_columns_multi_rows_chained_returning_star_str(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1, "a", True).insert(2, "b", False).returning("*") + + self.assertEqual( + "INSERT INTO \"abc\" VALUES (1,'a',true),(2,'b',false) RETURNING *", + str(query), + ) + + def test_insert_all_columns_single_element_arrays(self): + query = PostgreSQLQuery.into(self.table_abc).insert((1, "a", True)).returning(self.table_abc.star) + + self.assertEqual("INSERT INTO \"abc\" VALUES (1,'a',true) RETURNING *", str(query)) + + def test_insert_returning_null(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).returning(None) + + self.assertEqual('INSERT INTO "abc" VALUES (1) RETURNING NULL', str(query)) + + def test_insert_returning_tuple(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).returning((1, 2, 3)) + + self.assertEqual('INSERT INTO "abc" VALUES (1) RETURNING (1,2,3)', str(query)) + + def test_insert_returning_arithmetics(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).returning(self.table_abc.f1 + self.table_abc.f2) + + self.assertEqual('INSERT INTO "abc" VALUES (1) RETURNING "f1"+"f2"', str(query)) + + def test_insert_returning_functions(self): + query = PostgreSQLQuery.into(self.table_abc).insert(1).returning(Cast(self.table_abc.f1, "int")) + + self.assertEqual('INSERT INTO "abc" VALUES (1) RETURNING CAST("f1" AS INT)', str(query)) + + def test_insert_returning_aggregate(self): + with self.assertRaises(QueryException): + PostgreSQLQuery.into(self.table_abc).insert(1).returning(Avg(self.table_abc.views)) + + def test_insert_returning_from_other_table(self): + table_cba = Table("cba") + with self.assertRaises(QueryException): + PostgreSQLQuery.into(self.table_abc).insert(1).returning(table_cba.id) + + +class InsertIntoOnDuplicateTests(unittest.TestCase): + table_abc = Table("abc") + + def test_insert_one_column(self): + query = ( + MySQLQuery.into(self.table_abc).insert(1).on_duplicate_key_update(self.table_abc.foo, self.table_abc.foo) + ) + self.assertEqual( + "INSERT INTO `abc` VALUES (1) ON DUPLICATE KEY UPDATE `foo`=`foo`", + str(query), + ) + + def test_insert_one_column_using_values(self): + query = ( + MySQLQuery.into(self.table_abc) + .insert(1) + .on_duplicate_key_update(self.table_abc.foo, Values(self.table_abc.foo)) + ) + self.assertEqual( + "INSERT INTO `abc` VALUES (1) ON DUPLICATE KEY UPDATE `foo`=VALUES(`foo`)", + str(query), + ) + + def test_insert_one_column_single_element_array(self): + query = ( + MySQLQuery.into(self.table_abc).insert((1,)).on_duplicate_key_update(self.table_abc.foo, self.table_abc.foo) + ) + + self.assertEqual( + "INSERT INTO `abc` VALUES (1) ON DUPLICATE KEY UPDATE `foo`=`foo`", + str(query), + ) + + def test_insert_one_column_multi_element_array(self): + query = ( + MySQLQuery.into(self.table_abc) + .insert((1,), (2,)) + .on_duplicate_key_update(self.table_abc.foo, self.table_abc.foo) + ) + + self.assertEqual( + "INSERT INTO `abc` VALUES (1),(2) ON DUPLICATE KEY UPDATE `foo`=`foo`", + str(query), + ) + + def test_insert_multiple_columns_on_duplicate_update_one_with_same_value(self): + query = ( + MySQLQuery.into(self.table_abc) + .insert(1, "a") + .on_duplicate_key_update(self.table_abc.bar, Values(self.table_abc.bar)) + ) + + self.assertEqual( + "INSERT INTO `abc` VALUES (1,'a') ON DUPLICATE KEY UPDATE `bar`=VALUES(`bar`)", + str(query), + ) + + def test_insert_multiple_columns_on_duplicate_update_one_with_different_value(self): + query = MySQLQuery.into(self.table_abc).insert(1, "a").on_duplicate_key_update(self.table_abc.bar, "b") + + self.assertEqual( + "INSERT INTO `abc` VALUES (1,'a') ON DUPLICATE KEY UPDATE `bar`='b'", + str(query), + ) + + def test_insert_multiple_columns_on_duplicate_update_one_with_expression(self): + query = ( + MySQLQuery.into(self.table_abc).insert(1, 2).on_duplicate_key_update(self.table_abc.bar, 4 + F("bar")) + ) # todo sql expression? not python + + self.assertEqual( + "INSERT INTO `abc` VALUES (1,2) ON DUPLICATE KEY UPDATE `bar`=4+`bar`", + str(query), + ) + + def test_insert_multiple_columns_on_duplicate_update_one_with_expression_using_original_field_value( + self, + ): + query = ( + MySQLQuery.into(self.table_abc) + .insert(1, "a") + .on_duplicate_key_update(self.table_abc.bar, fn.Concat(self.table_abc.bar, "update")) + ) + + self.assertEqual( + "INSERT INTO `abc` VALUES (1,'a') ON DUPLICATE KEY UPDATE `bar`=CONCAT(`bar`,'update')", + str(query), + ) + + def test_insert_multiple_columns_on_duplicate_update_one_with_expression_using_values( + self, + ): + query = ( + MySQLQuery.into(self.table_abc) + .insert(1, "a") + .on_duplicate_key_update(self.table_abc.bar, fn.Concat(Values(self.table_abc.bar), "update")) + ) + + self.assertEqual( + "INSERT INTO `abc` VALUES (1,'a') ON DUPLICATE KEY UPDATE `bar`=CONCAT(VALUES(`bar`),'update')", + str(query), + ) + + def test_insert_multiple_columns_on_duplicate_update_multiple(self): + query = ( + MySQLQuery.into(self.table_abc) + .insert(1, "a", "b") + .on_duplicate_key_update(self.table_abc.bar, "b") + .on_duplicate_key_update(self.table_abc.baz, "c") + ) + + self.assertEqual( + "INSERT INTO `abc` VALUES (1,'a','b') ON DUPLICATE KEY UPDATE `bar`='b',`baz`='c'", + str(query), + ) + + def test_insert_multi_rows_chained_mixed_on_duplicate_update_multiple(self): + query = ( + MySQLQuery.into(self.table_abc) + .insert((1, "a", True), (2, "b", False)) + .insert(3, "c", True) + .on_duplicate_key_update(self.table_abc.foo, self.table_abc.foo) + .on_duplicate_key_update(self.table_abc.bar, Values(self.table_abc.bar)) + ) + + self.assertEqual( + "INSERT INTO `abc` VALUES (1,'a',true),(2,'b',false),(3,'c',true) " + "ON DUPLICATE KEY UPDATE `foo`=`foo`,`bar`=VALUES(`bar`)", + str(query), + ) + + def test_insert_selected_columns_on_duplicate_update_one(self): + query = ( + MySQLQuery.into(self.table_abc) + .columns(self.table_abc.foo, self.table_abc.bar, self.table_abc.baz) + .insert(1, "a", True) + .on_duplicate_key_update(self.table_abc.baz, False) + ) + + self.assertEqual( + "INSERT INTO `abc` (`foo`,`bar`,`baz`) VALUES (1,'a',true) ON DUPLICATE KEY UPDATE `baz`=false", + str(query), + ) + + def test_insert_selected_columns_on_duplicate_update_multiple(self): + query = ( + MySQLQuery.into(self.table_abc) + .columns(self.table_abc.foo, self.table_abc.bar, self.table_abc.baz) + .insert(1, "a", True) + .on_duplicate_key_update(self.table_abc.baz, False) + .on_duplicate_key_update(self.table_abc.bar, Values(self.table_abc.bar)) + ) + + self.assertEqual( + "INSERT INTO `abc` (`foo`,`bar`,`baz`) VALUES (1,'a',true) " + "ON DUPLICATE KEY UPDATE `baz`=false,`bar`=VALUES(`bar`)", + str(query), + ) + + def test_insert_none_skipped(self): + query = MySQLQuery.into(self.table_abc).insert().on_duplicate_key_update(self.table_abc.baz, False) + + self.assertEqual("", str(query)) + + def test_insert_ignore(self): + query = MySQLQuery.into(self.table_abc).insert(1).ignore().on_duplicate_key_update(self.table_abc.baz, False) + + self.assertEqual( + "INSERT IGNORE INTO `abc` VALUES (1) ON DUPLICATE KEY UPDATE `baz`=false", + str(query), + ) + + +class InsertSelectFromTests(unittest.TestCase): + table_abc, table_efg, table_hij = Tables("abc", "efg", "hij") + + def test_insert_star(self): + query = Query.into(self.table_abc).from_(self.table_efg).select("*") + + self.assertEqual('INSERT INTO "abc" SELECT * FROM "efg"', str(query)) + + def test_insert_ignore_star(self): + query = Query.into(self.table_abc).from_(self.table_efg).select("*").ignore() + + self.assertEqual('INSERT IGNORE INTO "abc" SELECT * FROM "efg"', str(query)) + + def test_insert_from_columns(self): + query = ( + Query.into(self.table_abc) + .from_(self.table_efg) + .select(self.table_efg.fiz, self.table_efg.buz, self.table_efg.baz) + ) + + self.assertEqual('INSERT INTO "abc" ' 'SELECT "fiz","buz","baz" FROM "efg"', str(query)) + + def test_insert_columns_from_star(self): + query = ( + Query.into(self.table_abc) + .columns( + self.table_abc.foo, + self.table_abc.bar, + self.table_abc.buz, + ) + .from_(self.table_efg) + .select("*") + ) + + self.assertEqual('INSERT INTO "abc" ("foo","bar","buz") ' 'SELECT * FROM "efg"', str(query)) + + def test_insert_columns_from_columns(self): + query = ( + Query.into(self.table_abc) + .columns(self.table_abc.foo, self.table_abc.bar, self.table_abc.buz) + .from_(self.table_efg) + .select(self.table_efg.fiz, self.table_efg.buz, self.table_efg.baz) + ) + + self.assertEqual( + 'INSERT INTO "abc" ("foo","bar","buz") ' 'SELECT "fiz","buz","baz" FROM "efg"', + str(query), + ) + + def test_insert_columns_from_columns_with_join(self): + query = ( + Query.into(self.table_abc) + .columns( + self.table_abc.c1, + self.table_abc.c2, + self.table_abc.c3, + self.table_abc.c4, + ) + .from_(self.table_efg) + .select(self.table_efg.foo, self.table_efg.bar) + .join(self.table_hij) + .on(self.table_efg.id == self.table_hij.abc_id) + .select(self.table_hij.fiz, self.table_hij.buz) + ) + + self.assertEqual( + 'INSERT INTO "abc" ("c1","c2","c3","c4") ' + 'SELECT "efg"."foo","efg"."bar","hij"."fiz","hij"."buz" FROM "efg" ' + 'JOIN "hij" ON "efg"."id"="hij"."abc_id"', + str(query), + ) + + +class InsertSubqueryTests(unittest.TestCase): + def test_insert_subquery_wrapped_in_brackets(self): + purchase_order_item, part = Tables("purchase_order_item", "part") + + q = ( + Query.into(purchase_order_item) + .columns(purchase_order_item.id_part, purchase_order_item.id_customer) + .insert( + Query.from_(part).select(part.part_id).where(part.part_number == "FOOBAR"), + 12345, + ) + ) + + self.assertEqual( + 'INSERT INTO "purchase_order_item" ' + '("id_part","id_customer") ' + "VALUES " + '((SELECT "part_id" FROM "part" WHERE "part_number"=\'FOOBAR\'),12345)', + str(q), + ) + + +class SelectIntoTests(unittest.TestCase): + table_abc, table_efg, table_hij = Tables("abc", "efg", "hij") + + def test_select_star_into(self): + query = Query.from_(self.table_abc).select("*").into(self.table_efg) + + self.assertEqual('SELECT * INTO "efg" FROM "abc"', str(query)) + + def test_select_columns_into(self): + query = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, self.table_abc.bar, self.table_abc.buz) + .into(self.table_efg) + ) + + self.assertEqual('SELECT "foo","bar","buz" INTO "efg" FROM "abc"', str(query)) + + def test_select_columns_into_with_join(self): + query = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, self.table_abc.bar) + .join(self.table_hij) + .on(self.table_abc.id == self.table_hij.abc_id) + .select(self.table_hij.fiz, self.table_hij.buz) + .into(self.table_efg) + ) + + self.assertEqual( + 'SELECT "abc"."foo","abc"."bar","hij"."fiz","hij"."buz" ' + 'INTO "efg" FROM "abc" ' + 'JOIN "hij" ON "abc"."id"="hij"."abc_id"', + str(query), + ) + + +class ReplaceTests(unittest.TestCase): + table_abc, table_def = Tables("abc", "efg") + + def test_replace_simple(self): + query = Query.into(self.table_abc).replace("v1", "v2", "v3") + expected_output = "REPLACE INTO \"abc\" VALUES ('v1','v2','v3')" + self.assertEqual(str(query), expected_output) + + def test_replace_subquery(self): + query = Query.into(self.table_abc).replace(Query.from_(self.table_def).select("f1", "f2")) + expected_output = 'REPLACE INTO "abc" VALUES ((SELECT "f1","f2" FROM "efg"))' + self.assertEqual(str(query), expected_output) diff --git a/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/test_internals.py b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/test_internals.py new file mode 100644 index 0000000000000000000000000000000000000000..921e381ba8613d4a83cc53bd60d111d9547e2c1f --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/test_internals.py @@ -0,0 +1,35 @@ +import unittest + +from pypika import ( + Case, + Field, + Table, +) +from pypika.terms import Star + + +class TablesTests(unittest.TestCase): + def test__criterion_replace_table_with_value(self): + table = Table("a") + + c = (Field("foo") > 1).replace_table(None, table) + self.assertEqual(c.left, table) + self.assertEqual(c.tables_, {table}) + + def test__case_tables(self): + table = Table("a") + + c = Case().when(table.a == 1, 2 * table.a) + self.assertIsInstance(c.tables_, set) + self.assertSetEqual(c.tables_, {table}) + + def test__star_tables(self): + star = Star() + + self.assertEqual(star.tables_, set()) + + def test__table_star_tables(self): + table = Table("a") + star = Star(table=table) + + self.assertEqual(star.tables_, {table}) diff --git a/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/test_joins.py b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/test_joins.py new file mode 100644 index 0000000000000000000000000000000000000000..03142d583921edbe966e0ae191d254e7b8bf46ba --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/test_joins.py @@ -0,0 +1,1168 @@ +import unittest + +from pypika import ( + Field, + Interval, + JoinException, + JoinType, + MySQLQuery, + Query, + SetOperationException, + Table, + Tables, + functions as fn, + SYSTEM_TIME, +) + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + + +class SelectQueryJoinTests(unittest.TestCase): + table0, table1, hij = Tables("abc", "efg", "hij") + + def test_default_join_type(self): + query = Query.from_(self.table0).join(self.table1).on(self.table0.foo == self.table1.bar).select("*") + + self.assertEqual('SELECT * FROM "abc" JOIN "efg" ON "abc"."foo"="efg"."bar"', str(query)) + + def test_inner_join(self): + expected = 'SELECT * FROM "abc" JOIN "efg" ON "abc"."foo"="efg"."bar"' + + with self.subTest("join with enum"): + query = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.inner) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + self.assertEqual(expected, str(query)) + + with self.subTest("join function"): + query = Query.from_(self.table0).inner_join(self.table1).on(self.table0.foo == self.table1.bar).select("*") + self.assertEqual(expected, str(query)) + + def test_left_join(self): + expected = 'SELECT * FROM "abc" LEFT JOIN "efg" ON "abc"."foo"="efg"."bar"' + + with self.subTest("join with enum"): + query = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.left) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + + self.assertEqual(expected, str(query)) + + with self.subTest("join function"): + query = Query.from_(self.table0).left_join(self.table1).on(self.table0.foo == self.table1.bar).select("*") + self.assertEqual(expected, str(query)) + + def test_right_join(self): + expected = 'SELECT * FROM "abc" RIGHT JOIN "efg" ON "abc"."foo"="efg"."bar"' + + with self.subTest("join with enum"): + query = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.right) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + + self.assertEqual(expected, str(query)) + + with self.subTest("join function"): + query = Query.from_(self.table0).right_join(self.table1).on(self.table0.foo == self.table1.bar).select("*") + self.assertEqual(expected, str(query)) + + def test_hash_join(self): + expected = 'SELECT * FROM "abc" HASH JOIN "efg" ON "abc"."foo"="efg"."bar"' + + with self.subTest("join with enum"): + query = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.hash) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + + self.assertEqual(expected, str(query)) + + with self.subTest("join function"): + query = Query.from_(self.table0).hash_join(self.table1).on(self.table0.foo == self.table1.bar).select("*") + self.assertEqual(expected, str(query)) + + def test_outer_join(self): + expected = 'SELECT * FROM "abc" FULL OUTER JOIN "efg" ON "abc"."foo"="efg"."bar"' + + with self.subTest("join with enum"): + query = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.outer) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + + self.assertEqual(expected, str(query)) + + with self.subTest("join function"): + query = Query.from_(self.table0).outer_join(self.table1).on(self.table0.foo == self.table1.bar).select("*") + self.assertEqual(expected, str(query)) + + def test_cross_join(self): + expected = 'SELECT * FROM "abc" CROSS JOIN "efg" ON "abc"."foo"="efg"."bar"' + + with self.subTest("join with enum"): + query = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.cross) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + + self.assertEqual(expected, str(query)) + + with self.subTest("join function"): + query = Query.from_(self.table0).cross_join(self.table1).on(self.table0.foo == self.table1.bar).select("*") + self.assertEqual(expected, str(query)) + + def test_left_outer_join(self): + expected = 'SELECT * FROM "abc" LEFT OUTER JOIN "efg" ON "abc"."foo"="efg"."bar"' + with self.subTest("join with enum"): + query = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.left_outer) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + + self.assertEqual(expected, str(query)) + + with self.subTest("join function"): + query = ( + Query.from_(self.table0).left_outer_join(self.table1).on(self.table0.foo == self.table1.bar).select("*") + ) + + self.assertEqual(expected, str(query)) + + def test_right_outer_join(self): + expected = 'SELECT * FROM "abc" RIGHT OUTER JOIN "efg" ON "abc"."foo"="efg"."bar"' + with self.subTest("join with enum"): + query = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.right_outer) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + + self.assertEqual(expected, str(query)) + + with self.subTest("join function"): + query = ( + Query.from_(self.table0) + .right_outer_join(self.table1) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + + self.assertEqual(expected, str(query)) + + def test_full_outer_join(self): + expected = 'SELECT * FROM "abc" FULL OUTER JOIN "efg" ON "abc"."foo"="efg"."bar"' + + with self.subTest("join with enum"): + query = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.full_outer) + .on(self.table0.foo == self.table1.bar) + .select("*") + ) + + self.assertEqual(expected, str(query)) + + with self.subTest("join function"): + query = ( + Query.from_(self.table0).full_outer_join(self.table1).on(self.table0.foo == self.table1.bar).select("*") + ) + + self.assertEqual(expected, str(query)) + + def test_join_on_field_single(self): + query = Query.from_(self.table0).join(self.table1).on_field("foo").select("*") + self.assertEqual('SELECT * FROM "abc" JOIN "efg" ON "abc"."foo"="efg"."foo"', str(query)) + + def test_join_on_field_multi(self): + query = Query.from_(self.table0).join(self.table1).on_field("foo", "bar").select("*") + self.assertEqual( + 'SELECT * FROM "abc" JOIN "efg" ON "abc"."foo"="efg"."foo" ' 'AND "abc"."bar"="efg"."bar"', + str(query), + ) + + def test_join_on_field_multi_with_extra_join(self): + query = ( + Query.from_(self.table0) + .join(self.hij) + .on_field("buzz") + .join(self.table1) + .on_field("foo", "bar") + .select("*") + ) + + self.assertEqual( + 'SELECT * FROM "abc" JOIN "hij" ON "abc"."buzz"="hij"."buzz" ' + 'JOIN "efg" ON "abc"."foo"="efg"."foo" AND "abc"."bar"="efg"."bar"', + str(query), + ) + + def test_join_using_string_field_name(self): + query = Query.from_(self.table0).join(self.table1).using("id").select("*") + + self.assertEqual('SELECT * FROM "abc" JOIN "efg" USING ("id")', str(query)) + + def test_join_using_multiple_fields(self): + query = Query.from_(self.table0).join(self.table1).using("foo", "bar").select("*") + + self.assertEqual('SELECT * FROM "abc" JOIN "efg" USING ("foo","bar")', str(query)) + + def test_join_using_with_quote_char(self): + query = Query.from_(self.table0).join(self.table1).using("foo", "bar").select("*") + + self.assertEqual("SELECT * FROM abc JOIN efg USING (foo,bar)", query.get_sql(quote_char="")) + + def test_join_using_without_fields_raises_exception(self): + with self.assertRaises(JoinException): + Query.from_(self.table0).join(self.table1).using() + + def test_join_on_field_without_fields_raises_exception(self): + with self.assertRaises(JoinException): + Query.from_(self.table0).join(self.table1).on_field() + + def test_join_arithmetic_field(self): + q = ( + Query.from_(self.table0) + .join(self.table1) + .on(self.table0.dt == (self.table1.dt - Interval(weeks=1))) + .select("*") + ) + + self.assertEqual( + 'SELECT * FROM "abc" ' 'JOIN "efg" ON "abc"."dt"="efg"."dt"-INTERVAL \'1 WEEK\'', + str(q), + ) + + def test_join_with_arithmetic_function_in_select(self): + q = ( + Query.from_( + self.table0, + ) + .join(self.table1) + .on(self.table0.dt == (self.table1.dt - Interval(weeks=1))) + .select(self.table0.fiz - self.table0.buz, self.table1.star) + ) + + self.assertEqual( + 'SELECT "abc"."fiz"-"abc"."buz","efg".* FROM "abc" ' + 'JOIN "efg" ON "abc"."dt"="efg"."dt"-INTERVAL \'1 WEEK\'', + str(q), + ) + + def test_join_on_complex_criteria(self): + q = ( + Query.from_(self.table0) + .join(self.table1, how=JoinType.right) + .on((self.table0.foo == self.table1.fiz) & (self.table0.bar == self.table1.buz)) + .select("*") + ) + + self.assertEqual( + 'SELECT * FROM "abc" ' 'RIGHT JOIN "efg" ON "abc"."foo"="efg"."fiz" AND "abc"."bar"="efg"."buz"', + str(q), + ) + + def test_join_on_subquery_criteria(self): + table_a, table_b, table_c = Tables("a", "b", "c") + subquery = Query.from_(table_c).select("id").limit(1) + query = ( + Query.from_(table_a).select("*").join(table_b).on((table_a.b_id == table_b.id) & (table_b.c_id == subquery)) + ) + + self.assertEqual( + "SELECT * " 'FROM "a" ' 'JOIN "b" ON "a"."b_id"="b"."id" AND "b"."c_id"=' '(SELECT "id" FROM "c" LIMIT 1)', + str(query), + ) + + def test_use_different_table_objects_for_same_table(self): + table = Table("t") + q = Query.from_(table).select("*").where(Field("id", table=table) == 1) + + self.assertEqual('SELECT * FROM "t" WHERE "id"=1', str(q)) + + def test_join_second_table_in_from_clause(self): + table_a, table_b, table_c = Tables("a", "b", "c") + q = Query.from_(table_a).from_(table_b).select("*").join(table_c).on(table_b.c_id == table_c.id) + + self.assertEqual("SELECT * " 'FROM "a","b" ' 'JOIN "c" ON "b"."c_id"="c"."id"', str(q)) + + def test_cross_join_on_table(self): + table_a, table_b = Tables("a", "b") + q = Query.from_(table_a).join(table_b).cross().select("*") + + self.assertEqual('SELECT * FROM "a" CROSS JOIN "b"', str(q)) + + def test_cross_join_on_subquery(self): + table_a, table_b = Tables("a", "b") + q_a = Query.from_(table_a).select("*") + q_b = Query.from_(table_b).select("*").join(q_a).cross().select("*") + + self.assertEqual('SELECT * FROM "b" CROSS JOIN (SELECT * FROM "a") "sq0"', str(q_b)) + + def test_join_on_collate(self): + table_a, table_b = Tables("a", "b") + + q1 = ( + Query.from_(table_a) + .select(table_b.ouch) + .join(table_b) + .on(table_a.foo == table_b.boo, collate="utf8_general_ci") + ) + q2 = Query.from_(table_a).select(table_b.ouch).join(table_b).on(table_a.foo == table_b.boo) + + self.assertEqual( + 'SELECT "b"."ouch" FROM "a" JOIN "b" ON "a"."foo"="b"."boo" COLLATE utf8_general_ci', + str(q1), + ) + self.assertEqual('SELECT "b"."ouch" FROM "a" JOIN "b" ON "a"."foo"="b"."boo"', str(q2)) + + def test_temporal_join(self): + t0 = self.table0.for_(SYSTEM_TIME.as_of('2020-01-01')) + t1 = self.table1.for_(SYSTEM_TIME.as_of('2020-01-01')) + query = Query.from_(t0).join(t1).on(t0.foo == t1.bar).select("*") + + self.assertEqual( + 'SELECT * FROM "abc" FOR SYSTEM_TIME AS OF \'2020-01-01\' ' + 'JOIN "efg" FOR SYSTEM_TIME AS OF \'2020-01-01\' ' + 'ON "abc"."foo"="efg"."bar"', + str(query), + ) + + +class JoinBehaviorTests(unittest.TestCase): + table_abc, table_efg, table_hij, table_klm = Tables("abc", "efg", "hij", "klm") + + def test_select__ordered_select_clauses(self): + q = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .select( + self.table_abc.baz, + self.table_efg.buz, + self.table_abc.fiz, + self.table_efg.bam, + ) + ) + + self.assertEqual( + 'SELECT "abc"."baz","efg"."buz","abc"."fiz","efg"."bam" FROM "abc" ' + 'JOIN "efg" ON "abc"."foo"="efg"."bar"', + str(q), + ) + + def test_select__star_for_table(self): + q = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .join(self.table_hij) + .on(self.table_abc.buz == self.table_hij.bam) + .select(self.table_abc.star) + .select(self.table_efg.star) + .select(self.table_hij.star) + ) + + self.assertEqual( + 'SELECT "abc".*,"efg".*,"hij".* FROM "abc" ' + 'JOIN "efg" ON "abc"."foo"="efg"."bar" ' + 'JOIN "hij" ON "abc"."buz"="hij"."bam"', + str(q), + ) + + def test_select__star_for_table__replacement(self): + q = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .join(self.table_hij) + .on(self.table_abc.buz == self.table_hij.bam) + .select(self.table_abc.foo, self.table_efg.bar, self.table_hij.bam) + .select(self.table_abc.star, self.table_efg.star, self.table_hij.star) + ) + + self.assertEqual( + 'SELECT "abc".*,"efg".*,"hij".* FROM "abc" ' + 'JOIN "efg" ON "abc"."foo"="efg"."bar" ' + 'JOIN "hij" ON "abc"."buz"="hij"."bam"', + str(q), + ) + + def test_select_fields_with_where(self): + q = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .join(self.table_hij) + .on(self.table_abc.buz == self.table_hij.bam) + .select(self.table_abc.foo, self.table_efg.bar, self.table_hij.bam) + .where(self.table_abc.foo > 1) + .where(self.table_efg.bar != 2) + ) + + self.assertEqual( + 'SELECT "abc"."foo","efg"."bar","hij"."bam" FROM "abc" ' + 'JOIN "efg" ON "abc"."foo"="efg"."bar" ' + 'JOIN "hij" ON "abc"."buz"="hij"."bam" ' + 'WHERE "abc"."foo">1 AND "efg"."bar"<>2', + str(q), + ) + + def test_require_condition(self): + with self.assertRaises(JoinException): + Query.from_(self.table_abc).join(self.table_efg).on(None) + + def test_require_condition_with_both_tables(self): + with self.assertRaises(JoinException): + Query.from_(self.table_abc).join(self.table_efg).on(self.table_abc.foo == self.table_hij.bar) + + with self.assertRaises(JoinException): + Query.from_(self.table_abc).join(self.table_efg).on(self.table_hij.foo == self.table_efg.bar) + + with self.assertRaises(JoinException): + Query.from_(self.table_abc).join(self.table_efg).on(self.table_hij.foo == self.table_klm.bar) + + def test_join_same_table(self): + table1 = Table("abc") + table2 = Table("abc") + q = Query.from_(table1).join(table2).on(table1.foo == table2.bar).select(table1.foo, table2.buz) + + self.assertEqual( + 'SELECT "abc"."foo","abc2"."buz" FROM "abc" ' 'JOIN "abc" "abc2" ON "abc"."foo"="abc2"."bar"', + str(q), + ) + + def test_join_same_table_with_prefixes(self): + table1 = Table("abc").as_("x") + table2 = Table("abc").as_("y") + q = Query.from_(table1).join(table2).on(table1.foo == table2.bar).select(table1.foo, table2.buz) + + self.assertEqual( + 'SELECT "x"."foo","y"."buz" FROM "abc" "x" ' 'JOIN "abc" "y" ON "x"."foo"="y"."bar"', + str(q), + ) + + def test_join_table_twice(self): + table1, table2 = Table("efg").as_("efg1"), Table("efg").as_("efg2") + q = ( + Query.from_(self.table_abc) + .join(table1) + .on(self.table_abc.foo == table1.bar) + .join(table2) + .on(self.table_abc.foo == table2.bam) + .select(self.table_abc.foo, table1.fiz, table2.buz) + ) + + self.assertEqual( + 'SELECT "abc"."foo","efg1"."fiz","efg2"."buz" FROM "abc" ' + 'JOIN "efg" "efg1" ON "abc"."foo"="efg1"."bar" ' + 'JOIN "efg" "efg2" ON "abc"."foo"="efg2"."bam"', + str(q), + ) + + def test_select__fields_after_table_star(self): + q = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .select(self.table_abc.star, self.table_efg.bar) + .select(self.table_abc.foo) + ) + + self.assertEqual( + 'SELECT "abc".*,"efg"."bar" FROM "abc" JOIN "efg" ON "abc"."foo"="efg"."bar"', + str(q), + ) + + def test_fail_when_joining_unknown_type(self): + with self.assertRaises(ValueError): + Query.from_(self.table_abc).join("this is a string") + + def test_immutable__tables(self): + query1 = Query.from_(self.table_abc).select(self.table_abc.foo) + query2 = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .select(self.table_abc.foo, self.table_efg.buz) + ) + + self.assertEqual( + 'SELECT "abc"."foo","efg"."buz" FROM "abc" ' 'JOIN "efg" ON "abc"."foo"="efg"."bar"', + str(query2), + ) + self.assertEqual('SELECT "foo" FROM "abc"', str(query1)) + + def test_select_field_from_missing_table(self): + """ + Previously we validated the select field was a member of a table + in the query (e.g. FROM clause or a JOIN). However this made + correlated subqueries awkward to write (subqueries which refer + to their parent table. So the validation was removed. + + None of the following raise an error. Previously raised JoinException + """ + Query.from_(self.table_abc).select(self.table_efg.foo) + + Query.from_(self.table_abc).where(self.table_efg.foo == 0) + + Query.from_(self.table_abc).where(fn.Sum(self.table_efg.foo) == 0) + + Query.from_(self.table_abc).select(fn.Sum(self.table_abc.bar * 2) + fn.Sum(self.table_efg.foo * 2)) + + Query.from_(self.table_abc).groupby(self.table_efg.foo) + + Query.from_(self.table_abc).groupby(self.table_abc.foo).having(self.table_efg.bar) + + subquery = ( + Query.from_(self.table_efg).select(self.table_efg.id).where(self.table_efg.abc_id == self.table_abc.id) + ) + query = Query.from_(self.table_abc).select(subquery.as_("efg_id").limit(1)) + self.assertEqual( + 'SELECT (SELECT "efg"."id" FROM "efg" WHERE "efg"."abc_id"="abc"."id" LIMIT 1) "efg_id" FROM "abc"', + str(query), + ) + + def test_ignore_table_references(self): + query = Query.from_(Table("abc")).select(Table("abc").foo) + + self.assertEqual('SELECT "foo" FROM "abc"', str(query)) + + def test_prefixes_added_to_groupby(self): + test_query = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .select(self.table_abc.foo, fn.Sum(self.table_efg.buz)) + .groupby(self.table_abc.foo) + ) + + self.assertEqual( + 'SELECT "abc"."foo",SUM("efg"."buz") FROM "abc" ' + 'JOIN "efg" ON "abc"."foo"="efg"."bar" ' + 'GROUP BY "abc"."foo"', + str(test_query), + ) + + def test_prefixes_added_to_orderby(self): + test_query = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .select(self.table_abc.foo, self.table_efg.buz) + .orderby(self.table_abc.foo) + ) + + self.assertEqual( + 'SELECT "abc"."foo","efg"."buz" FROM "abc" ' + 'JOIN "efg" ON "abc"."foo"="efg"."bar" ' + 'ORDER BY "abc"."foo"', + str(test_query), + ) + + def test_prefixes_added_to_function_in_orderby(self): + test_query = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .select(self.table_abc.foo, self.table_efg.buz) + .orderby(fn.Date(self.table_abc.foo)) + ) + + self.assertEqual( + 'SELECT "abc"."foo","efg"."buz" FROM "abc" ' + 'JOIN "efg" ON "abc"."foo"="efg"."bar" ' + 'ORDER BY DATE("abc"."foo")', + str(test_query), + ) + + def test_join_from_join(self): + test_query = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.efg_id == self.table_efg.id) + .join(self.table_hij) + .on(self.table_efg.hij_id == self.table_hij.id) + .select(self.table_abc.foo, self.table_efg.bar, self.table_hij.fizz) + ) + + self.assertEqual( + 'SELECT "abc"."foo","efg"."bar","hij"."fizz" FROM "abc" ' + 'JOIN "efg" ON "abc"."efg_id"="efg"."id" ' + 'JOIN "hij" ON "efg"."hij_id"="hij"."id"', + str(test_query), + ) + + def test_join_query_without_alias(self): + subquery = Query.from_(self.table_efg).select( + self.table_efg.base_id.as_("x"), self.table_efg.fizz, self.table_efg.buzz + ) + + test_query = ( + Query.from_(self.table_abc) + .join(subquery) + .on(subquery.x == self.table_abc.id) + .select(self.table_abc.foo, subquery.fizz, subquery.buzz) + ) + + self.assertEqual( + 'SELECT "abc"."foo","sq0"."fizz","sq0"."buzz" ' + 'FROM "abc" JOIN (' + 'SELECT "base_id" "x","fizz","buzz" FROM "efg"' + ') "sq0" ' + 'ON "sq0"."x"="abc"."id"', + str(test_query), + ) + + def test_join_query_with_column_alias(self): + subquery = ( + Query.from_(self.table_efg) + .select( + self.table_efg.base_id.as_("x"), + self.table_efg.fizz, + self.table_efg.buzz, + ) + .as_("subq") + ) + + test_query = ( + Query.from_(self.table_abc) + .join(subquery) + .on(subquery.x == self.table_abc.id) + .select(self.table_abc.foo, subquery.fizz, subquery.buzz) + ) + + self.assertEqual( + 'SELECT "abc"."foo","subq"."fizz","subq"."buzz" ' + 'FROM "abc" JOIN (' + 'SELECT "base_id" "x","fizz","buzz" FROM "efg"' + ') "subq" ' + 'ON "subq"."x"="abc"."id"', + str(test_query), + ) + + def test_join_query_with_table_alias(self): + xxx = self.table_efg.as_("xxx") + subquery = Query.from_(xxx).select(xxx.base_id, xxx.fizz, xxx.buzz).as_("subq") + + test_query = ( + Query.from_(self.table_abc) + .join(subquery) + .on(subquery.x == self.table_abc.id) + .select(self.table_abc.foo, subquery.fizz, subquery.buzz) + ) + + self.assertEqual( + 'SELECT "abc"."foo","subq"."fizz","subq"."buzz" ' + 'FROM "abc" JOIN (' + 'SELECT "xxx"."base_id","xxx"."fizz","xxx"."buzz" FROM "efg" "xxx"' + ') "subq" ' + 'ON "subq"."x"="abc"."id"', + str(test_query), + ) + + def test_join_query_with_setoperation(self): + subquery = Query.from_(self.table_abc).select("*").union(Query.from_(self.table_abc).select("*")).as_("subq") + + test_query = ( + Query.from_(self.table_abc).join(subquery).on(subquery.x == self.table_abc.id).select(self.table_abc.foo) + ) + + self.assertEqual( + 'SELECT "abc"."foo" FROM "abc" ' + 'JOIN ' + '((SELECT * FROM "abc") ' + 'UNION ' + '(SELECT * FROM "abc")) "subq" ' + 'ON "subq"."x"="abc"."id"', + str(test_query), + ) + + +class UnionTests(unittest.TestCase): + table1, table2 = Tables("abc", "efg") + + def test_union(self): + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + + self.assertEqual( + '(SELECT "foo" FROM "abc") UNION (SELECT "bar" FROM "efg")', + str(query1 + query2), + ) + self.assertEqual( + '(SELECT "foo" FROM "abc") UNION (SELECT "bar" FROM "efg")', + str(query1.union(query2)), + ) + + def test_union_multiple(self): + table3, table4 = Tables("hij", "lmn") + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + query3 = Query.from_(table3).select(table3.baz) + query4 = Query.from_(table4).select(table4.faz) + + self.assertEqual( + '(SELECT "foo" FROM "abc") UNION ' + '(SELECT "bar" FROM "efg") UNION ' + '(SELECT "baz" FROM "hij") UNION ' + '(SELECT "faz" FROM "lmn")', + str(query1 + query2 + query3 + query4), + ) + self.assertEqual( + '(SELECT "foo" FROM "abc") UNION ' + '(SELECT "bar" FROM "efg") UNION ' + '(SELECT "baz" FROM "hij") UNION ' + '(SELECT "faz" FROM "lmn")', + str(query1.union(query2).union(query3).union(query4)), + ) + + def test_union_all(self): + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + + self.assertEqual( + '(SELECT "foo" FROM "abc") UNION ALL (SELECT "bar" FROM "efg")', + str(query1 * query2), + ) + self.assertEqual( + '(SELECT "foo" FROM "abc") UNION ALL (SELECT "bar" FROM "efg")', + str(query1.union_all(query2)), + ) + + def test_union_all_multiple(self): + table3, table4 = Tables("hij", "lmn") + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + query3 = Query.from_(table3).select(table3.baz) + query4 = Query.from_(table4).select(table4.faz) + + self.assertEqual( + '(SELECT "foo" FROM "abc") UNION ALL ' + '(SELECT "bar" FROM "efg") UNION ALL ' + '(SELECT "baz" FROM "hij") UNION ALL ' + '(SELECT "faz" FROM "lmn")', + str(query1 * query2 * query3 * query4), + ) + self.assertEqual( + '(SELECT "foo" FROM "abc") UNION ALL ' + '(SELECT "bar" FROM "efg") UNION ALL ' + '(SELECT "baz" FROM "hij") UNION ALL ' + '(SELECT "faz" FROM "lmn")', + str(query1.union_all(query2).union_all(query3).union_all(query4)), + ) + + def test_union_with_order_by(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + union_query = str((query1 + query2).orderby(query1.field("a"))) + union_all_query = str((query1 * query2).orderby(query1.field("a"))) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "UNION " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "a"', + union_query, + ) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "UNION ALL " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "a"', + union_all_query, + ) + + def test_union_with_order_by_use_union_query_field(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + union_query = query1 + query2 + union_query = str(union_query.orderby(union_query.field("a"))) + union_all_query = query1 * query2 + union_all_query = str(union_all_query.orderby(union_all_query.field("a"))) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "UNION " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "a"', + union_query, + ) + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "UNION ALL " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "a"', + union_all_query, + ) + + def test_union_with_order_by_with_aliases(self): + query1 = Query.from_(self.table1.as_("a")).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2.as_("b")).select(self.table2.bar.as_("a")) + + union_all_query = str((query1 * query2).orderby(query1.field("a"))) + union_query = str((query1 + query2).orderby(query1.field("a"))) + self.assertEqual( + '(SELECT "foo" "a" FROM "abc" "a")' " UNION ALL " '(SELECT "bar" "a" FROM "efg" "b")' ' ORDER BY "a"', + union_all_query, + ) + self.assertEqual( + '(SELECT "foo" "a" FROM "abc" "a")' " UNION " '(SELECT "bar" "a" FROM "efg" "b")' ' ORDER BY "a"', + union_query, + ) + + def test_union_with_order_by_use_union_query_field_with_aliases(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + union_query = (query1 + query2).as_("x") + union_query = union_query.orderby(union_query.field("a")) + union_all_query = (query1 * query2).as_("x") + union_all_query = union_all_query.orderby(union_all_query.field("a")) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "UNION " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "x"."a"', + str(union_query), + ) + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "UNION ALL " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "x"."a"', + str(union_all_query), + ) + + def test_require_equal_number_of_fields(self): + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.fiz, self.table2.buz) + + with self.assertRaises(SetOperationException): + str(query1 + query2) + + def test_mysql_query_wraps_unioned_queries(self): + query1 = MySQLQuery.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + + self.assertEqual( + "(SELECT `foo` FROM `abc`) UNION (SELECT `bar` FROM `efg`)", + str(query1 + query2), + ) + + def test_union_as_subquery(self): + abc, efg = Tables("abc", "efg") + hij = Query.from_(abc).select(abc.t).union(Query.from_(efg).select(efg.t)) + q = Query.from_(hij).select(fn.Avg(hij.t)) + + self.assertEqual( + 'SELECT AVG("sq0"."t") FROM ((SELECT "t" FROM "abc") UNION (SELECT "t" FROM "efg")) "sq0"', + str(q), + ) + + def test_union_with_no_quote_char(self): + abc, efg = Tables("abc", "efg") + hij = Query.from_(abc).select(abc.t).union(Query.from_(efg).select(efg.t)) + q = Query.from_(hij).select(fn.Avg(hij.t)) + + self.assertEqual( + "SELECT AVG(sq0.t) FROM ((SELECT t FROM abc) UNION (SELECT t FROM efg)) sq0", + q.get_sql(quote_char=None), + ) + + +class InsertQueryJoinTests(unittest.TestCase): + def test_join_table_on_insert_query(self): + a, b, c = Tables("a", "b", "c") + q = Query.into(c).from_(a).join(b).on(a.fkey_id == b.id).where(b.foo == 1).select("a.*", "b.*") + + self.assertEqual( + 'INSERT INTO "c" ' + 'SELECT "a"."a.*","a"."b.*" ' + 'FROM "a" JOIN "b" ' + 'ON "a"."fkey_id"="b"."id" ' + 'WHERE "b"."foo"=1', + str(q), + ) + + +class UpdateQueryJoinTests(unittest.TestCase): + def test_join_table_on_update_query(self): + a, b = Tables("a", "b") + q = Query.update(a).join(b).on(a.fkey_id == b.id).where(b.foo == 1).set("adwords_batch_job_id", 1) + + self.assertEqual( + 'UPDATE "a" ' 'JOIN "b" ' 'ON "a"."fkey_id"="b"."id" ' 'SET "adwords_batch_job_id"=1 ' 'WHERE "b"."foo"=1', + str(q), + ) + + +class IntersectTests(unittest.TestCase): + table1, table2 = Tables("abc", "efg") + + def test_intersect(self): + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + + self.assertEqual( + '(SELECT "foo" FROM "abc") INTERSECT (SELECT "bar" FROM "efg")', + str(query1.intersect(query2)), + ) + + def test_intersect_multiple(self): + table3, table4 = Tables("hij", "lmn") + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + query3 = Query.from_(table3).select(table3.baz) + query4 = Query.from_(table4).select(table4.faz) + + self.assertEqual( + '(SELECT "foo" FROM "abc") INTERSECT ' + '(SELECT "bar" FROM "efg") INTERSECT ' + '(SELECT "baz" FROM "hij") INTERSECT ' + '(SELECT "faz" FROM "lmn")', + str(query1.intersect(query2).intersect(query3).intersect(query4)), + ) + + def test_intersect_with_order_by(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + intersect_query = str((query1.intersect(query2)).orderby(query1.field("a"))) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "INTERSECT " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "a"', + intersect_query, + ) + + def test_intersect_with_limit(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + intersect_query = str((query1.intersect(query2)).limit(10)) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "INTERSECT " '(SELECT "bar" "a" FROM "efg") ' 'LIMIT 10', + intersect_query, + ) + + def test_intersect_with_offset(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + intersect_query = str((query1.intersect(query2)).offset(10)) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "INTERSECT " '(SELECT "bar" "a" FROM "efg") ' 'OFFSET 10', + intersect_query, + ) + + def test_require_equal_number_of_fields_intersect(self): + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.fiz, self.table2.buz) + + with self.assertRaises(SetOperationException): + str(query1.intersect(query2)) + + def test_mysql_query_wraps_intersected_queries(self): + query1 = MySQLQuery.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + + self.assertEqual( + "(SELECT `foo` FROM `abc`) INTERSECT (SELECT `bar` FROM `efg`)", + str(query1.intersect(query2)), + ) + + def test_intersect_as_subquery(self): + abc, efg = Tables("abc", "efg") + hij = Query.from_(abc).select(abc.t).intersect(Query.from_(efg).select(efg.t)) + q = Query.from_(hij).select(fn.Avg(hij.t)) + + self.assertEqual( + 'SELECT AVG("sq0"."t") FROM ((SELECT "t" FROM "abc") INTERSECT (SELECT "t" FROM "efg")) "sq0"', + str(q), + ) + + def test_intersect_with_no_quote_char(self): + abc, efg = Tables("abc", "efg") + hij = Query.from_(abc).select(abc.t).intersect(Query.from_(efg).select(efg.t)) + q = Query.from_(hij).select(fn.Avg(hij.t)) + + self.assertEqual( + "SELECT AVG(sq0.t) FROM ((SELECT t FROM abc) INTERSECT (SELECT t FROM efg)) sq0", + q.get_sql(quote_char=None), + ) + + +class MinusTests(unittest.TestCase): + table1, table2 = Tables("abc", "efg") + + def test_minus(self): + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + + self.assertEqual('(SELECT "foo" FROM "abc") MINUS (SELECT "bar" FROM "efg")', str(query1.minus(query2))) + + self.assertEqual( + '(SELECT "foo" FROM "abc") MINUS (SELECT "bar" FROM "efg")', + str(query1 - query2), + ) + + def test_minus_multiple(self): + table3, table4 = Tables("hij", "lmn") + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + query3 = Query.from_(table3).select(table3.baz) + query4 = Query.from_(table4).select(table4.faz) + + self.assertEqual( + '(SELECT "foo" FROM "abc") MINUS ' + '(SELECT "bar" FROM "efg") MINUS ' + '(SELECT "baz" FROM "hij") MINUS ' + '(SELECT "faz" FROM "lmn")', + str(query1 - query2 - query3 - query4), + ) + + self.assertEqual( + '(SELECT "foo" FROM "abc") MINUS ' + '(SELECT "bar" FROM "efg") MINUS ' + '(SELECT "baz" FROM "hij") MINUS ' + '(SELECT "faz" FROM "lmn")', + str(query1.minus(query2).minus(query3).minus(query4)), + ) + + def test_minus_with_order_by(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + minus_query = str(query1.minus(query2).orderby(query1.field("a"))) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "MINUS " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "a"', minus_query + ) + + def test_minus_query_with_order_by_use_minus_query_field(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + minus_query = query1.minus(query2) + minus_query = str(minus_query.orderby(minus_query.field("b"))) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "MINUS " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "b"', + minus_query, + ) + + def test_require_equal_number_of_fields(self): + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.fiz, self.table2.buz) + + with self.assertRaises(SetOperationException): + str(query1.minus(query2)) + + def test_mysql_query_wraps_minus_queries(self): + query1 = MySQLQuery.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + + self.assertEqual( + "(SELECT `foo` FROM `abc`) MINUS (SELECT `bar` FROM `efg`)", + str(query1 - query2), + ) + + def test_minus_as_subquery(self): + abc, efg = Tables("abc", "efg") + hij = Query.from_(abc).select(abc.t).minus(Query.from_(efg).select(efg.t)) + q = Query.from_(hij).select(fn.Avg(hij.t)) + + self.assertEqual( + 'SELECT AVG("sq0"."t") FROM ((SELECT "t" FROM "abc") MINUS (SELECT "t" FROM "efg")) "sq0"', + str(q), + ) + + def test_minus_with_no_quote_char(self): + abc, efg = Tables("abc", "efg") + hij = Query.from_(abc).select(abc.t).minus(Query.from_(efg).select(efg.t)) + q = Query.from_(hij).select(fn.Avg(hij.t)) + + self.assertEqual( + "SELECT AVG(sq0.t) FROM ((SELECT t FROM abc) MINUS (SELECT t FROM efg)) sq0", + q.get_sql(quote_char=None), + ) + + +class ExceptOfTests(unittest.TestCase): + table1, table2 = Tables("abc", "efg") + + def test_except(self): + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + + self.assertEqual('(SELECT "foo" FROM "abc") EXCEPT (SELECT "bar" FROM "efg")', str(query1.except_of(query2))) + + def test_except_multiple(self): + table3, table4 = Tables("hij", "lmn") + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.bar) + query3 = Query.from_(table3).select(table3.baz) + query4 = Query.from_(table4).select(table4.faz) + + self.assertEqual( + '(SELECT "foo" FROM "abc") EXCEPT ' + '(SELECT "bar" FROM "efg") EXCEPT ' + '(SELECT "baz" FROM "hij") EXCEPT ' + '(SELECT "faz" FROM "lmn")', + str(query1.except_of(query2).except_of(query3).except_of(query4)), + ) + + def test_except_with_order_by(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + except_query = str(query1.except_of(query2).orderby(query1.field("a"))) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "EXCEPT " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "a"', except_query + ) + + def test_except_query_with_order_by_use_minus_query_field(self): + query1 = Query.from_(self.table1).select(self.table1.foo.as_("a")) + query2 = Query.from_(self.table2).select(self.table2.bar.as_("a")) + + except_query = query1.except_of(query2) + except_query = str(except_query.orderby(except_query.field("b"))) + + self.assertEqual( + '(SELECT "foo" "a" FROM "abc") ' "EXCEPT " '(SELECT "bar" "a" FROM "efg") ' 'ORDER BY "b"', + except_query, + ) + + def test_require_equal_number_of_fields_except_of(self): + query1 = Query.from_(self.table1).select(self.table1.foo) + query2 = Query.from_(self.table2).select(self.table2.fiz, self.table2.buz) + + with self.assertRaises(SetOperationException): + str(query1.except_of(query2)) + + def test_except_as_subquery(self): + abc, efg = Tables("abc", "efg") + hij = Query.from_(abc).select(abc.t).except_of(Query.from_(efg).select(efg.t)) + q = Query.from_(hij).select(fn.Avg(hij.t)) + + self.assertEqual( + 'SELECT AVG("sq0"."t") FROM ((SELECT "t" FROM "abc") EXCEPT (SELECT "t" FROM "efg")) "sq0"', + str(q), + ) + + def test_except_with_no_quote_char(self): + abc, efg = Tables("abc", "efg") + hij = Query.from_(abc).select(abc.t).except_of(Query.from_(efg).select(efg.t)) + q = Query.from_(hij).select(fn.Avg(hij.t)) + + self.assertEqual( + "SELECT AVG(sq0.t) FROM ((SELECT t FROM abc) EXCEPT (SELECT t FROM efg)) sq0", + q.get_sql(quote_char=None), + ) diff --git a/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/test_negation.py b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/test_negation.py new file mode 100644 index 0000000000000000000000000000000000000000..9f4db83b560dbc8546ce6d384b781dfccefd319d --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/test_negation.py @@ -0,0 +1,31 @@ +import unittest + +from pypika import ( + Tables, + functions as fn, +) +from pypika.terms import ValueWrapper + + +class NegationTests(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_negate_wrapped_float(self): + q = -ValueWrapper(1.0) + + self.assertEqual("-1.0", q.get_sql()) + + def test_negate_wrapped_int(self): + q = -ValueWrapper(1) + + self.assertEqual("-1", q.get_sql()) + + def test_negate_field(self): + q = -self.table_abc.foo + + self.assertEqual('-"abc"."foo"', q.get_sql(with_namespace=True, quote_char='"')) + + def test_negate_function(self): + q = -fn.Sum(self.table_abc.foo) + + self.assertEqual('-SUM("abc"."foo")', q.get_sql(with_namespace=True, quote_char='"')) diff --git a/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/test_parameter.py b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/test_parameter.py new file mode 100644 index 0000000000000000000000000000000000000000..c11e9afcd9624abb0a7313306eda34ebcf4c99ba --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/test_parameter.py @@ -0,0 +1,206 @@ +import unittest +from datetime import date + +from pypika import ( + FormatParameter, + NamedParameter, + NumericParameter, + Parameter, + PyformatParameter, + QmarkParameter, + Query, + Tables, +) +from pypika.terms import ListParameter, ParameterValueWrapper + + +class ParametrizedTests(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_param_insert(self): + q = Query.into(self.table_abc).columns("a", "b", "c").insert(Parameter("?"), Parameter("?"), Parameter("?")) + + self.assertEqual('INSERT INTO "abc" ("a","b","c") VALUES (?,?,?)', q.get_sql()) + + def test_param_select_join(self): + q = ( + Query.from_(self.table_abc) + .select("*") + .where(self.table_abc.category == Parameter("%s")) + .join(self.table_efg) + .on(self.table_abc.id == self.table_efg.abc_id) + .where(self.table_efg.date >= Parameter("%s")) + .limit(10) + ) + + self.assertEqual( + 'SELECT * FROM "abc" JOIN "efg" ON "abc"."id"="efg"."abc_id" WHERE "abc"."category"=%s AND "efg"."date">=%s LIMIT 10', + q.get_sql(), + ) + + def test_param_select_subquery(self): + q = ( + Query.from_(self.table_abc) + .select("*") + .where(self.table_abc.category == Parameter("&1")) + .where( + self.table_abc.id.isin( + Query.from_(self.table_efg) + .select(self.table_efg.abc_id) + .where(self.table_efg.date >= Parameter("&2")) + ) + ) + .limit(10) + ) + + self.assertEqual( + 'SELECT * FROM "abc" WHERE "category"=&1 AND "id" IN (SELECT "abc_id" FROM "efg" WHERE "date">=&2) LIMIT 10', + q.get_sql(), + ) + + def test_join(self): + subquery = ( + Query.from_(self.table_efg) + .select(self.table_efg.fiz, self.table_efg.buz) + .where(self.table_efg.buz == Parameter(":buz")) + ) + + q = ( + Query.from_(self.table_abc) + .join(subquery) + .on(self.table_abc.bar == subquery.buz) + .select(self.table_abc.foo, subquery.fiz) + .where(self.table_abc.bar == Parameter(":bar")) + ) + + self.assertEqual( + 'SELECT "abc"."foo","sq0"."fiz" FROM "abc" JOIN (SELECT "fiz","buz" FROM "efg" WHERE "buz"=:buz)' + ' "sq0" ON "abc"."bar"="sq0"."buz" WHERE "abc"."bar"=:bar', + q.get_sql(), + ) + + def test_qmark_parameter(self): + self.assertEqual('?', QmarkParameter().get_sql()) + + def test_numeric_parameter(self): + self.assertEqual(':14', NumericParameter('14').get_sql()) + self.assertEqual(':15', NumericParameter(15).get_sql()) + + def test_named_parameter(self): + self.assertEqual(':buz', NamedParameter('buz').get_sql()) + + def test_format_parameter(self): + self.assertEqual('%s', FormatParameter().get_sql()) + + def test_pyformat_parameter(self): + self.assertEqual('%(buz)s', PyformatParameter('buz').get_sql()) + + +class ParametrizedTestsWithValues(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_param_insert(self): + q = Query.into(self.table_abc).columns("a", "b", "c").insert(1, 2.2, 'foo') + + parameter = QmarkParameter() + sql = q.get_sql(parameter=parameter) + self.assertEqual('INSERT INTO "abc" ("a","b","c") VALUES (?,?,?)', sql) + self.assertEqual([1, 2.2, 'foo'], parameter.get_parameters()) + + def test_param_select_join(self): + q = ( + Query.from_(self.table_abc) + .select("*") + .where(self.table_abc.category == 'foobar') + .join(self.table_efg) + .on(self.table_abc.id == self.table_efg.abc_id) + .where(self.table_efg.date >= date(2024, 2, 22)) + .limit(10) + ) + + parameter = FormatParameter() + sql = q.get_sql(parameter=parameter) + self.assertEqual( + 'SELECT * FROM "abc" JOIN "efg" ON "abc"."id"="efg"."abc_id" WHERE "abc"."category"=%s AND "efg"."date">=%s LIMIT 10', + sql, + ) + self.assertEqual(['foobar', '2024-02-22'], parameter.get_parameters()) + + def test_param_select_subquery(self): + q = ( + Query.from_(self.table_abc) + .select("*") + .where(self.table_abc.category == 'foobar') + .where( + self.table_abc.id.isin( + Query.from_(self.table_efg) + .select(self.table_efg.abc_id) + .where(self.table_efg.date >= date(2024, 2, 22)) + ) + ) + .limit(10) + ) + + parameter = ListParameter(placeholder=lambda idx: f'&{idx+1}') + sql = q.get_sql(parameter=parameter) + self.assertEqual( + 'SELECT * FROM "abc" WHERE "category"=&1 AND "id" IN (SELECT "abc_id" FROM "efg" WHERE "date">=&2) LIMIT 10', + sql, + ) + self.assertEqual(['foobar', '2024-02-22'], parameter.get_parameters()) + + def test_join(self): + subquery = ( + Query.from_(self.table_efg) + .select(self.table_efg.fiz, self.table_efg.buz) + .where(self.table_efg.buz == 'buz') + ) + + q = ( + Query.from_(self.table_abc) + .join(subquery) + .on(self.table_abc.bar == subquery.buz) + .select(self.table_abc.foo, subquery.fiz) + .where(self.table_abc.bar == 'bar') + ) + + parameter = NamedParameter() + sql = q.get_sql(parameter=parameter) + self.assertEqual( + 'SELECT "abc"."foo","sq0"."fiz" FROM "abc" JOIN (SELECT "fiz","buz" FROM "efg" WHERE "buz"=:param1)' + ' "sq0" ON "abc"."bar"="sq0"."buz" WHERE "abc"."bar"=:param2', + sql, + ) + self.assertEqual({'param1': 'buz', 'param2': 'bar'}, parameter.get_parameters()) + + def test_join_with_parameter_value_wrapper(self): + subquery = ( + Query.from_(self.table_efg) + .select(self.table_efg.fiz, self.table_efg.buz) + .where(self.table_efg.buz == ParameterValueWrapper(Parameter(':buz'), 'buz')) + ) + + q = ( + Query.from_(self.table_abc) + .join(subquery) + .on(self.table_abc.bar == subquery.buz) + .select(self.table_abc.foo, subquery.fiz) + .where(self.table_abc.bar == ParameterValueWrapper(NamedParameter('bar'), 'bar')) + ) + + parameter = NamedParameter() + sql = q.get_sql(parameter=parameter) + self.assertEqual( + 'SELECT "abc"."foo","sq0"."fiz" FROM "abc" JOIN (SELECT "fiz","buz" FROM "efg" WHERE "buz"=:buz)' + ' "sq0" ON "abc"."bar"="sq0"."buz" WHERE "abc"."bar"=:bar', + sql, + ) + self.assertEqual({':buz': 'buz', 'bar': 'bar'}, parameter.get_parameters()) + + def test_pyformat_parameter(self): + q = Query.into(self.table_abc).columns("a", "b", "c").insert(1, 2.2, 'foo') + + parameter = PyformatParameter() + sql = q.get_sql(parameter=parameter) + self.assertEqual('INSERT INTO "abc" ("a","b","c") VALUES (%(param1)s,%(param2)s,%(param3)s)', sql) + self.assertEqual({"param1": 1, "param2": 2.2, "param3": "foo"}, parameter.get_parameters()) diff --git a/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/test_pseudocolumns.py b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/test_pseudocolumns.py new file mode 100644 index 0000000000000000000000000000000000000000..6a25c70269b2ccc98ac3870ac64a43c8a32ddbe9 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/test_pseudocolumns.py @@ -0,0 +1,51 @@ +import unittest + +from pypika import Query, Table +from pypika.pseudocolumns import ( + ColumnValue, + ObjectID, + ObjectValue, + RowID, + RowNum, + SysDate, +) +from pypika.terms import PseudoColumn + + +class PseudoColumnsTest(unittest.TestCase): + @classmethod + def setUpClass(cls): + super(PseudoColumnsTest, cls).setUpClass() + cls.table1 = Table("table1") + + def test_column_value(self): + self.assertEqual("COLUMN_VALUE", ColumnValue) + + def test_object_id(self): + self.assertEqual("OBJECT_ID", ObjectID) + + def test_object_value(self): + self.assertEqual("OBJECT_VALUE", ObjectValue) + + def test_row_id(self): + self.assertEqual("ROWID", RowID) + + def test_row_num(self): + self.assertEqual("ROWNUM", RowNum) + + def test_sys_date(self): + self.assertEqual("SYSDATE", SysDate) + + def test_can_be_used_in_a_select_statement(self): + query = Query.from_(self.table1).where(self.table1.is_active == 1).select(PseudoColumn("abcde")) + + self.assertEqual(str(query), 'SELECT abcde FROM "table1" WHERE "is_active"=1') + + def test_can_be_used_in_a_where_clause(self): + query = Query.from_(self.table1).where(PseudoColumn("abcde") > 1).select(self.table1.is_active) + + self.assertEqual(str(query), 'SELECT "is_active" FROM "table1" WHERE abcde>1') + + def test_can_be_used_in_orderby(self): + query = Query.from_(self.table1).select(self.table1.abcde.as_("some_name")).orderby(PseudoColumn("some_name")) + self.assertEqual(str(query), 'SELECT "abcde" "some_name" FROM "table1" ORDER BY some_name') diff --git a/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/test_query.py b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/test_query.py new file mode 100644 index 0000000000000000000000000000000000000000..ae8dc01599a6a562b591ce15391bfe9b5c87e0f9 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/test_query.py @@ -0,0 +1,242 @@ +import unittest + +from pypika import Case, Query, Tables, Tuple, functions, Field +from pypika.dialects import ( + ClickHouseQuery, + ClickHouseQueryBuilder, + MSSQLQuery, + MSSQLQueryBuilder, + MySQLLoadQueryBuilder, + MySQLQuery, + MySQLQueryBuilder, + OracleQuery, + OracleQueryBuilder, + PostgreSQLQuery, + PostgreSQLQueryBuilder, + RedShiftQueryBuilder, + RedshiftQuery, + SQLLiteQuery, + SQLLiteQueryBuilder, + SnowflakeQuery, + SnowflakeQueryBuilder, + VerticaCopyQueryBuilder, + VerticaCreateQueryBuilder, + VerticaQuery, + VerticaQueryBuilder, +) +from pypika.queries import CreateQueryBuilder, DropQueryBuilder, QueryBuilder + + +class QueryTablesTests(unittest.TestCase): + table_a, table_b, table_c, table_d = Tables("a", "b", "c", "d") + + def test_replace_table(self): + query = Query.from_(self.table_a).select(self.table_a.time) + query = query.replace_table(self.table_a, self.table_b) + + self.assertEqual('SELECT "time" FROM "b"', str(query)) + + def test_replace_only_specified_table(self): + query = Query.from_(self.table_a).select(self.table_a.time) + query = query.replace_table(self.table_b, self.table_c) + + self.assertEqual('SELECT "time" FROM "a"', str(query)) + + def test_replace_insert_table(self): + query = Query.into(self.table_a).insert(1) + query = query.replace_table(self.table_a, self.table_b) + + self.assertEqual('INSERT INTO "b" VALUES (1)', str(query)) + + def test_replace_insert_table_current_table_not_match(self): + query = Query.into(self.table_a).insert(1) + query = query.replace_table(self.table_c, self.table_b) + + self.assertEqual('INSERT INTO "a" VALUES (1)', str(query)) + + def test_replace_update_table(self): + query = Query.update(self.table_a).set("foo", "bar") + query = query.replace_table(self.table_a, self.table_b) + + self.assertEqual('UPDATE "b" SET "foo"=\'bar\'', str(query)) + + def test_replace_update_table_current_table_not_match(self): + query = Query.update(self.table_a).set("foo", "bar") + query = query.replace_table(self.table_c, self.table_b) + + self.assertEqual('UPDATE "a" SET "foo"=\'bar\'', str(query)) + + def test_replace_delete_table(self): + query = Query.from_(self.table_a).delete() + query = query.replace_table(self.table_a, self.table_b) + + self.assertEqual('DELETE FROM "b"', str(query)) + + def test_replace_join_tables(self): + query = ( + Query.from_(self.table_a) + .join(self.table_b) + .on(self.table_a.customer_id == self.table_b.id) + .join(self.table_c) + .on(self.table_b.seller_id == self.table_c.id) + .select(self.table_a.star) + ) + query = query.replace_table(self.table_a, self.table_d) + + self.assertEqual( + 'SELECT "d".* ' + 'FROM "d" ' + 'JOIN "b" ON "d"."customer_id"="b"."id" ' + 'JOIN "c" ON "b"."seller_id"="c"."id"', + str(query), + ) + + def test_replace_filter_tables(self): + query = Query.from_(self.table_a).select(self.table_a.name).where(self.table_a.name == "Mustermann") + query = query.replace_table(self.table_a, self.table_b) + + self.assertEqual('SELECT "name" FROM "b" WHERE "name"=\'Mustermann\'', str(query)) + + def test_replace_having_table(self): + query = ( + Query.from_(self.table_a) + .select(functions.Sum(self.table_a.revenue)) + .groupby(self.table_a.customer) + .having(functions.Sum(self.table_a.revenue) >= 1000) + ) + query = query.replace_table(self.table_a, self.table_b) + + self.assertEqual( + 'SELECT SUM("revenue") ' 'FROM "b" ' 'GROUP BY "customer" ' 'HAVING SUM("revenue")>=1000', + str(query), + ) + + def test_replace_case_table(self): + query = Query.from_(self.table_a).select( + Case() + .when(self.table_a.fname == "Tom", "It was Tom") + .when(self.table_a.fname == "John", "It was John") + .else_("It was someone else.") + .as_("who_was_it") + ) + query = query.replace_table(self.table_a, self.table_b) + + self.assertEqual( + "SELECT CASE " + "WHEN \"fname\"='Tom' THEN 'It was Tom' " + "WHEN \"fname\"='John' THEN 'It was John' " + "ELSE 'It was someone else.' END \"who_was_it\" " + 'FROM "b"', + str(query), + ) + + def test_replace_orderby_table(self): + query = Query.from_(self.table_a).select(self.table_a.customer).orderby(self.table_a.customer) + query = query.replace_table(self.table_a, self.table_b) + + self.assertEqual('SELECT "customer" FROM "b" ORDER BY "customer"', str(query)) + + def test_replace_tuple_table(self): + query = ( + Query.from_(self.table_a) + .select(self.table_a.cost, self.table_a.revenue) + .where((self.table_a.cost, self.table_a.revenue) == Tuple(1, 2)) + ) + + query = query.replace_table(self.table_a, self.table_b) + + # Order is reversed due to lack of right equals method + self.assertEqual( + 'SELECT "cost","revenue" FROM "b" WHERE (1,2)=("cost","revenue")', + str(query), + ) + + def test_is_joined(self): + q = Query.from_(self.table_a).join(self.table_b).on(self.table_a.foo == self.table_b.boo) + + self.assertTrue(q.is_joined(self.table_b)) + self.assertFalse(q.is_joined(self.table_c)) + + +class QueryBuilderTests(unittest.TestCase): + def test_query_builders_have_reference_to_correct_query_class(self): + with self.subTest('QueryBuilder'): + self.assertEqual(Query, QueryBuilder.QUERY_CLS) + + with self.subTest('DropQueryBuilder'): + self.assertEqual(Query, DropQueryBuilder.QUERY_CLS) + + with self.subTest('CreateQueryBuilder'): + self.assertEqual(Query, CreateQueryBuilder.QUERY_CLS) + + with self.subTest('MySQLQueryBuilder'): + self.assertEqual(MySQLQuery, MySQLQueryBuilder.QUERY_CLS) + + with self.subTest('MySQLLoadQueryBuilder'): + self.assertEqual(MySQLQuery, MySQLLoadQueryBuilder.QUERY_CLS) + + with self.subTest('VerticaQueryBuilder'): + self.assertEqual(VerticaQuery, VerticaQueryBuilder.QUERY_CLS) + + with self.subTest('VerticaCreateQueryBuilder'): + self.assertEqual(VerticaQuery, VerticaCreateQueryBuilder.QUERY_CLS) + + with self.subTest('VerticaCopyQueryBuilder'): + self.assertEqual(VerticaQuery, VerticaCopyQueryBuilder.QUERY_CLS) + + with self.subTest('PostgreSQLQueryBuilder'): + self.assertEqual(PostgreSQLQuery, PostgreSQLQueryBuilder.QUERY_CLS) + + with self.subTest('MSSQLQueryBuilder'): + self.assertEqual(MSSQLQuery, MSSQLQueryBuilder.QUERY_CLS) + + with self.subTest('SnowflakeQueryBuilder'): + self.assertEqual(SnowflakeQuery, SnowflakeQueryBuilder.QUERY_CLS) + + with self.subTest('ClickHouseQueryBuilder'): + self.assertEqual(ClickHouseQuery, ClickHouseQueryBuilder.QUERY_CLS) + + with self.subTest('RedShiftQueryBuilder'): + self.assertEqual(RedshiftQuery, RedShiftQueryBuilder.QUERY_CLS) + + with self.subTest('SQLLiteQueryBuilder'): + self.assertEqual(SQLLiteQuery, SQLLiteQueryBuilder.QUERY_CLS) + + with self.subTest('OracleQueryBuilder'): + self.assertEqual(OracleQuery, OracleQueryBuilder.QUERY_CLS) + + def test_pipe(self) -> None: + base_query = Query.from_("test") + + def select(query: QueryBuilder) -> QueryBuilder: + return query.select("test1", "test2") + + def count_group(query: QueryBuilder, *groups) -> QueryBuilder: + return query.groupby(*groups).select(*groups, functions.Count("*")) + + for func, args, kwargs, expected_str in [ + (select, [], {}, 'SELECT "test1","test2" FROM "test"'), + ( + count_group, + ["test1", "test2"], + {}, + 'SELECT "test1","test2",COUNT(*) FROM "test" GROUP BY "test1","test2"', + ), + (count_group, ["test1"], {}, 'SELECT "test1",COUNT(*) FROM "test" GROUP BY "test1"'), + ]: + result_str = str(base_query.pipe(func, *args, **kwargs)) + self.assertEqual(result_str, str(func(base_query, *args, **kwargs))) + self.assertEqual(result_str, expected_str) + + def where_clause(query: QueryBuilder, num_days: int) -> QueryBuilder: + return query.where(Field("date") > functions.Now() - num_days) + + result_str = str(base_query.pipe(select).pipe(where_clause, num_days=1)) + self.assertEqual( + result_str, + str(select(where_clause(base_query, num_days=1))), + ) + self.assertEqual( + result_str, + 'SELECT "test1","test2" FROM "test" WHERE "date">NOW()-1', + ) diff --git a/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/test_selects.py b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/test_selects.py new file mode 100644 index 0000000000000000000000000000000000000000..1ce04937492e655db362b7e2a0a6856abf22a48f --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/test_selects.py @@ -0,0 +1,1331 @@ +import unittest +from datetime import date +from enum import Enum + +from pypika import ( + AliasedQuery, + Case, + ClickHouseQuery, + EmptyCriterion, + Field as F, + Index, + MSSQLQuery, + MySQLQuery, + NullValue, + OracleQuery, + Order, + PostgreSQLQuery, + Query, + QueryException, + RedshiftQuery, + SQLLiteQuery, + Table, + Tables, + VerticaQuery, + functions as fn, + SYSTEM_TIME, +) +from pypika.terms import ValueWrapper + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + + +class SelectTests(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_empty_query(self): + q = Query.from_("abc") + + self.assertEqual("", str(q)) + + def test_select_no_from(self): + q = Query.select(1) + + self.assertEqual("SELECT 1", str(q)) + + def test_select_no_with_alias_from(self): + q = Query.select(ValueWrapper(1, "test")) + + self.assertEqual('SELECT 1 "test"', str(q)) + + def test_select_no_from_with_field_raises_exception(self): + with self.assertRaises(QueryException): + Query.select("asdf") + + def test_select__star(self): + q = Query.from_("abc").select("*") + + self.assertEqual('SELECT * FROM "abc"', str(q)) + + def test_select__table_schema(self): + q = Query.from_(Table("abc", "schema1")).select("*") + + self.assertEqual('SELECT * FROM "schema1"."abc"', str(q)) + + def test_select__table_schema_with_multiple_levels_as_tuple(self): + q = Query.from_(Table("abc", ("schema1", "schema2"))).select("*") + + self.assertEqual('SELECT * FROM "schema1"."schema2"."abc"', str(q)) + + def test_select__table_schema_with_multiple_levels_as_list(self): + q = Query.from_(Table("abc", ["schema1", "schema2"])).select("*") + + self.assertEqual('SELECT * FROM "schema1"."schema2"."abc"', str(q)) + + def test_select__star__replacement(self): + q = Query.from_("abc").select("foo").select("*") + + self.assertEqual('SELECT * FROM "abc"', str(q)) + + def test_select__distinct__single(self): + q = Query.from_("abc").select("foo").distinct() + + self.assertEqual('SELECT DISTINCT "foo" FROM "abc"', str(q)) + + def test_select__distinct__multi(self): + q = Query.from_("abc").select("foo", "bar").distinct() + + self.assertEqual('SELECT DISTINCT "foo","bar" FROM "abc"', str(q)) + + def test_select__column__single__str(self): + q = Query.from_("abc").select("foo") + + self.assertEqual('SELECT "foo" FROM "abc"', str(q)) + + def test_select__column__single__alias__str(self): + q = Query.from_(self.table_abc).select(self.table_abc.foo.as_("bar")) + + self.assertEqual('SELECT "foo" "bar" FROM "abc"', str(q)) + + def test_select__column__single__table_alias__str(self): + q = Query.from_(self.table_abc.as_("fizzbuzz")).select(self.table_abc.foo.as_("bar")) + + self.assertEqual('SELECT "foo" "bar" FROM "abc" "fizzbuzz"', str(q)) + + def test_select__column__single__field(self): + t = Table("abc") + q = Query.from_(t).select(t.foo) + + self.assertEqual('SELECT "foo" FROM "abc"', str(q)) + + def test_select__columns__multi__str(self): + q1 = Query.from_("abc").select("foo", "bar") + q2 = Query.from_("abc").select("foo").select("bar") + + self.assertEqual('SELECT "foo","bar" FROM "abc"', str(q1)) + self.assertEqual('SELECT "foo","bar" FROM "abc"', str(q2)) + + def test_select__columns__multi__field(self): + q1 = Query.from_(self.table_abc).select(self.table_abc.foo, self.table_abc.bar) + q2 = Query.from_(self.table_abc).select(self.table_abc.foo).select(self.table_abc.bar) + + self.assertEqual('SELECT "foo","bar" FROM "abc"', str(q1)) + self.assertEqual('SELECT "foo","bar" FROM "abc"', str(q2)) + + def test_select__multiple_tables(self): + q = Query.from_(self.table_abc).select(self.table_abc.foo).from_(self.table_efg).select(self.table_efg.bar) + + self.assertEqual('SELECT "abc"."foo","efg"."bar" FROM "abc","efg"', str(q)) + + def test_select__subquery(self): + subquery = Query.from_(self.table_abc).select("*") + q = Query.from_(subquery).select(subquery.foo, subquery.bar) + + self.assertEqual('SELECT "sq0"."foo","sq0"."bar" ' 'FROM (SELECT * FROM "abc") "sq0"', str(q)) + + def test_select__multiple_subqueries(self): + subquery0 = Query.from_(self.table_abc).select("foo") + subquery1 = Query.from_(self.table_efg).select("bar") + q = Query.from_(subquery0).from_(subquery1).select(subquery0.foo, subquery1.bar) + + self.assertEqual( + 'SELECT "sq0"."foo","sq1"."bar" ' 'FROM (SELECT "foo" FROM "abc") "sq0",' '(SELECT "bar" FROM "efg") "sq1"', + str(q), + ) + + def test_select__nested_subquery(self): + subquery0 = Query.from_(self.table_abc).select("*") + subquery1 = Query.from_(subquery0).select(subquery0.foo, subquery0.bar) + subquery2 = Query.from_(subquery1).select(subquery1.foo) + + q = Query.from_(subquery2).select(subquery2.foo) + + self.assertEqual( + 'SELECT "sq2"."foo" ' + 'FROM (SELECT "sq1"."foo" ' + 'FROM (SELECT "sq0"."foo","sq0"."bar" ' + 'FROM (SELECT * FROM "abc") "sq0") "sq1") "sq2"', + str(q), + ) + + def test_select__no_table(self): + q = Query.select(1, 2, 3) + + self.assertEqual("SELECT 1,2,3", str(q)) + + def test_select_then_add_table(self): + q = Query.select(1).select(2, 3).from_("abc").select("foo") + + self.assertEqual('SELECT 1,2,3,"foo" FROM "abc"', str(q)) + + def test_select_with_limit(self): + q1 = Query.from_("abc").select("foo")[:10] + + self.assertEqual('SELECT "foo" FROM "abc" LIMIT 10', str(q1)) + + def test_select_with_limit_zero(self): + with self.subTest('using python slice'): + q1 = Query.from_("abc").select("foo")[:0] + self.assertEqual('SELECT "foo" FROM "abc" LIMIT 0', str(q1)) + + with self.subTest('using limit method'): + q2 = Query.from_("abc").select("foo").limit(0) + self.assertEqual('SELECT "foo" FROM "abc" LIMIT 0', str(q2)) + + def test_select_with_limit__func(self): + q1 = Query.from_("abc").select("foo").limit(10) + + self.assertEqual('SELECT "foo" FROM "abc" LIMIT 10', str(q1)) + + def test_select_with_offset(self): + q1 = Query.from_("abc").select("foo")[10:] + + self.assertEqual('SELECT "foo" FROM "abc" OFFSET 10', str(q1)) + + def test_select_with_offset__func(self): + q1 = Query.from_("abc").select("foo").offset(10) + + self.assertEqual('SELECT "foo" FROM "abc" OFFSET 10', str(q1)) + + def test_select_with_limit_and_offset(self): + q1 = Query.from_("abc").select("foo")[10:10] + + self.assertEqual('SELECT "foo" FROM "abc" LIMIT 10 OFFSET 10', str(q1)) + + def test_select_with_force_index(self): + q = Query.from_("abc").select("foo").force_index("egg") + + self.assertEqual('SELECT "foo" FROM "abc" FORCE INDEX ("egg")', str(q)) + + def test_select_with_force_index_with_index_object(self): + index = Index("egg") + q = Query.from_("abc").select("foo").force_index(index) + + self.assertEqual('SELECT "foo" FROM "abc" FORCE INDEX ("egg")', str(q)) + + def test_select_with_force_index_multiple_indexes(self): + q = Query.from_("abc").select("foo").force_index("egg", "bacon") + + self.assertEqual('SELECT "foo" FROM "abc" FORCE INDEX ("egg","bacon")', str(q)) + + def test_select_with_force_index_multiple_calls(self): + q = ( + Query.from_("abc") + .select("foo") + .force_index( + "egg", + ) + .force_index("spam") + ) + + self.assertEqual('SELECT "foo" FROM "abc" FORCE INDEX ("egg","spam")', str(q)) + + def test_select_with_use_index(self): + q = Query.from_("abc").select("foo").use_index("egg") + + self.assertEqual('SELECT "foo" FROM "abc" USE INDEX ("egg")', str(q)) + + def test_select_with_use_index_with_index_object(self): + index = Index("egg") + q = Query.from_("abc").select("foo").use_index(index) + + self.assertEqual('SELECT "foo" FROM "abc" USE INDEX ("egg")', str(q)) + + def test_select_with_use_index_multiple_indexes(self): + q = Query.from_("abc").select("foo").use_index("egg", "bacon") + + self.assertEqual('SELECT "foo" FROM "abc" USE INDEX ("egg","bacon")', str(q)) + + def test_select_with_use_index_multiple_calls(self): + q = ( + Query.from_("abc") + .select("foo") + .use_index( + "egg", + ) + .use_index("spam") + ) + + self.assertEqual('SELECT "foo" FROM "abc" USE INDEX ("egg","spam")', str(q)) + + def test_mysql_query_uses_backtick_quote_chars(self): + q = MySQLQuery.from_("abc").select("foo", "bar") + + self.assertEqual("SELECT `foo`,`bar` FROM `abc`", str(q)) + + def test_vertica_query_uses_double_quote_chars(self): + q = VerticaQuery.from_("abc").select("foo", "bar") + + self.assertEqual('SELECT "foo","bar" FROM "abc"', str(q)) + + def test_mssql_query_uses_double_quote_chars(self): + q = MSSQLQuery.from_("abc").select("foo", "bar") + + self.assertEqual('SELECT "foo","bar" FROM "abc"', str(q)) + + def test_oracle_query_uses_no_quote_chars(self): + q = OracleQuery.from_("abc").select("foo", "bar") + + self.assertEqual('SELECT foo,bar FROM abc', str(q)) + + def test_postgresql_query_uses_double_quote_chars(self): + q = PostgreSQLQuery.from_("abc").select("foo", "bar") + + self.assertEqual('SELECT "foo","bar" FROM "abc"', str(q)) + + def test_redshift_query_uses_double_quote_chars(self): + q = RedshiftQuery.from_("abc").select("foo", "bar") + + self.assertEqual('SELECT "foo","bar" FROM "abc"', str(q)) + + def test_table_select_alias(self): + q = self.table_abc.select(1) + + self.assertEqual('SELECT 1 FROM "abc"', str(q)) + self.assertEqual(q, Query.from_("abc").select(1)) + + def test_table_select_alias_with_offset_and_limit(self): + self.assertEqual(self.table_abc.select("foo")[10:10], Query.from_("abc").select("foo")[10:10]) + self.assertEqual( + self.table_abc.select(self.table_abc.foo)[10:10], + Query.from_("abc").select("foo")[10:10], + ) + + def test_temporal_select(self): + t = Table("abc") + + with self.subTest("with system time as of"): + q = Query.from_(t.for_(SYSTEM_TIME.as_of('2020-01-01'))).select("*") + + self.assertEqual('SELECT * FROM "abc" FOR SYSTEM_TIME AS OF \'2020-01-01\'', str(q)) + + with self.subTest("with system time between"): + q = Query.from_(t.for_(SYSTEM_TIME.between('2020-01-01', '2020-02-01'))).select("*") + + self.assertEqual('SELECT * FROM "abc" FOR SYSTEM_TIME BETWEEN \'2020-01-01\' AND \'2020-02-01\'', str(q)) + + with self.subTest("with system time from to"): + q = Query.from_(t.for_(SYSTEM_TIME.from_to('2020-01-01', '2020-02-01'))).select("*") + + self.assertEqual('SELECT * FROM "abc" FOR SYSTEM_TIME FROM \'2020-01-01\' TO \'2020-02-01\'', str(q)) + + with self.subTest("with ALL"): + q = Query.from_(t.for_(SYSTEM_TIME.all_())).select("*") + + self.assertEqual('SELECT * FROM "abc" FOR SYSTEM_TIME ALL', str(q)) + + with self.subTest("with period between"): + q = Query.from_(t.for_(t.valid_period.between('2020-01-01', '2020-02-01'))).select("*") + + self.assertEqual('SELECT * FROM "abc" FOR "valid_period" BETWEEN \'2020-01-01\' AND \'2020-02-01\'', str(q)) + + with self.subTest("with period from to"): + q = Query.from_(t.for_(t.valid_period.from_to('2020-01-01', '2020-02-01'))).select("*") + + self.assertEqual('SELECT * FROM "abc" FOR "valid_period" FROM \'2020-01-01\' TO \'2020-02-01\'', str(q)) + + with self.subTest("with ALL"): + q = Query.from_(t.for_(t.valid_period.all_())).select("*") + + self.assertEqual('SELECT * FROM "abc" FOR "valid_period" ALL', str(q)) + + +class MyEnum(Enum): + STR = "foo" + INT = 0 + BOOL = True + DATE = date(2020, 2, 2) + NONE = None + + +class WhereTests(unittest.TestCase): + t = Table("abc") + t2 = Table("cba") + + def test_where_enum(self): + q1 = Query.from_(self.t).select("*").where(self.t.foo == MyEnum.STR) + q2 = Query.from_(self.t).select("*").where(self.t.foo == MyEnum.INT) + q3 = Query.from_(self.t).select("*").where(self.t.foo == MyEnum.BOOL) + q4 = Query.from_(self.t).select("*").where(self.t.foo == MyEnum.DATE) + q5 = Query.from_(self.t).select("*").where(self.t.foo == MyEnum.NONE) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo"=\'foo\'', str(q1)) + self.assertEqual('SELECT * FROM "abc" WHERE "foo"=0', str(q2)) + self.assertEqual('SELECT * FROM "abc" WHERE "foo"=true', str(q3)) + self.assertEqual('SELECT * FROM "abc" WHERE "foo"=\'2020-02-02\'', str(q4)) + self.assertEqual('SELECT * FROM "abc" WHERE "foo"=null', str(q5)) + + def test_where_field_equals(self): + q1 = Query.from_(self.t).select("*").where(self.t.foo == self.t.bar) + q2 = Query.from_(self.t).select("*").where(self.t.foo.eq(self.t.bar)) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo"="bar"', str(q1)) + self.assertEqual('SELECT * FROM "abc" WHERE "foo"="bar"', str(q2)) + q = self.t.select("*").where(self.t.foo == self.t.bar) + self.assertEqual(q, q1) + + def test_where_field_equals_for_update(self): + q = Query.from_(self.t).select("*").where(self.t.foo == self.t.bar).for_update() + self.assertEqual('SELECT * FROM "abc" WHERE "foo"="bar" FOR UPDATE', str(q)) + + def test_where_field_equals_for_update_nowait(self): + for query_cls in [ + MySQLQuery, + PostgreSQLQuery, + ]: + quote_char = query_cls._builder().QUOTE_CHAR if isinstance(query_cls._builder().QUOTE_CHAR, str) else '"' + q = query_cls.from_(self.t).select("*").where(self.t.foo == self.t.bar).for_update(nowait=True) + self.assertEqual( + 'SELECT * ' + 'FROM {quote_char}abc{quote_char} ' + 'WHERE {quote_char}foo{quote_char}={quote_char}bar{quote_char} ' + 'FOR UPDATE NOWAIT'.format( + quote_char=quote_char, + ), + str(q), + ) + + def test_where_field_equals_for_update_skip_locked(self): + for query_cls in [ + MySQLQuery, + PostgreSQLQuery, + ]: + quote_char = query_cls._builder().QUOTE_CHAR if isinstance(query_cls._builder().QUOTE_CHAR, str) else '"' + q = query_cls.from_(self.t).select("*").where(self.t.foo == self.t.bar).for_update(skip_locked=True) + self.assertEqual( + 'SELECT * ' + 'FROM {quote_char}abc{quote_char} ' + 'WHERE {quote_char}foo{quote_char}={quote_char}bar{quote_char} ' + 'FOR UPDATE SKIP LOCKED'.format( + quote_char=quote_char, + ), + str(q), + ) + + def test_where_field_equals_for_update_of(self): + for query_cls in [ + MySQLQuery, + PostgreSQLQuery, + ]: + quote_char = query_cls._builder().QUOTE_CHAR if isinstance(query_cls._builder().QUOTE_CHAR, str) else '"' + q = query_cls.from_(self.t).select("*").where(self.t.foo == self.t.bar).for_update(of=("abc",)) + self.assertEqual( + 'SELECT * ' + 'FROM {quote_char}abc{quote_char} ' + 'WHERE {quote_char}foo{quote_char}={quote_char}bar{quote_char} ' + 'FOR UPDATE OF {quote_char}abc{quote_char}'.format( + quote_char=quote_char, + ), + str(q), + ) + + def test_where_field_equals_for_update_of_multiple_tables(self): + for query_cls in [ + MySQLQuery, + PostgreSQLQuery, + ]: + q = ( + query_cls.from_(self.t) + .join(self.t2) + .on(self.t.id == self.t2.abc_id) + .select("*") + .where(self.t.foo == self.t.bar) + .for_update(of=("abc", "cba")) + ) + quote_char = query_cls._builder().QUOTE_CHAR if isinstance(query_cls._builder().QUOTE_CHAR, str) else '"' + self.assertIn( + str(q), + [ + 'SELECT * ' + 'FROM {quote_char}abc{quote_char} ' + 'JOIN {quote_char}cba{quote_char} ' + 'ON {quote_char}abc{quote_char}.{quote_char}id{quote_char}=' + '{quote_char}cba{quote_char}.{quote_char}abc_id{quote_char} ' + 'WHERE {quote_char}abc{quote_char}.{quote_char}foo{quote_char}=' + '{quote_char}abc{quote_char}.{quote_char}bar{quote_char} ' + 'FOR UPDATE OF {quote_char}cba{quote_char}, {quote_char}abc{quote_char}'.format( + quote_char=quote_char, + ), + 'SELECT * ' + 'FROM {quote_char}abc{quote_char} ' + 'JOIN {quote_char}cba{quote_char} ' + 'ON {quote_char}abc{quote_char}.{quote_char}id{quote_char}=' + '{quote_char}cba{quote_char}.{quote_char}abc_id{quote_char} ' + 'WHERE {quote_char}abc{quote_char}.{quote_char}foo{quote_char}=' + '{quote_char}abc{quote_char}.{quote_char}bar{quote_char} ' + 'FOR UPDATE OF {quote_char}abc{quote_char}, {quote_char}cba{quote_char}'.format( + quote_char=quote_char, + ), + ], + ) + + def test_where_field_equals_for_update_of_nowait(self): + for query_cls in [ + MySQLQuery, + PostgreSQLQuery, + ]: + q = query_cls.from_(self.t).select("*").where(self.t.foo == self.t.bar).for_update(of=("abc",), nowait=True) + quote_char = query_cls._builder().QUOTE_CHAR if isinstance(query_cls._builder().QUOTE_CHAR, str) else '"' + self.assertEqual( + 'SELECT * ' + 'FROM {quote_char}abc{quote_char} ' + 'WHERE {quote_char}foo{quote_char}={quote_char}bar{quote_char} ' + 'FOR UPDATE OF {quote_char}abc{quote_char} NOWAIT'.format( + quote_char=quote_char, + ), + str(q), + ) + + def test_where_field_equals_for_update_of_skip_locked(self): + for query_cls in [ + MySQLQuery, + PostgreSQLQuery, + ]: + q = ( + query_cls.from_(self.t) + .select("*") + .where(self.t.foo == self.t.bar) + .for_update(of=("abc",), skip_locked=True) + ) + quote_char = query_cls._builder().QUOTE_CHAR if isinstance(query_cls._builder().QUOTE_CHAR, str) else '"' + self.assertEqual( + 'SELECT * ' + 'FROM {quote_char}abc{quote_char} ' + 'WHERE {quote_char}foo{quote_char}={quote_char}bar{quote_char} ' + 'FOR UPDATE OF {quote_char}abc{quote_char} SKIP LOCKED'.format( + quote_char=quote_char, + ), + str(q), + ) + + def test_where_field_equals_for_update_skip_locked_and_of(self): + for query_cls in [ + MySQLQuery, + PostgreSQLQuery, + ]: + q = ( + query_cls.from_(self.t) + .select("*") + .where(self.t.foo == self.t.bar) + .for_update(nowait=False, skip_locked=True, of=("abc",)) + ) + quote_char = query_cls._builder().QUOTE_CHAR if isinstance(query_cls._builder().QUOTE_CHAR, str) else '"' + self.assertEqual( + 'SELECT * ' + 'FROM {quote_char}abc{quote_char} ' + 'WHERE {quote_char}foo{quote_char}={quote_char}bar{quote_char} ' + 'FOR UPDATE OF {quote_char}abc{quote_char} SKIP LOCKED'.format( + quote_char=quote_char, + ), + str(q), + ) + + def test_where_field_equals_where(self): + q = Query.from_(self.t).select("*").where(self.t.foo == 1).where(self.t.bar == self.t.baz) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo"=1 AND "bar"="baz"', str(q)) + + def test_where_field_equals_where_not(self): + q = Query.from_(self.t).select("*").where((self.t.foo == 1).negate()).where(self.t.bar == self.t.baz) + + self.assertEqual('SELECT * FROM "abc" WHERE NOT "foo"=1 AND "bar"="baz"', str(q)) + + def test_where_field_equals_where_two_not(self): + q = Query.from_(self.t).select("*").where((self.t.foo == 1).negate()).where((self.t.bar == self.t.baz).negate()) + + self.assertEqual('SELECT * FROM "abc" WHERE NOT "foo"=1 AND NOT "bar"="baz"', str(q)) + + def test_where_single_quote(self): + q1 = Query.from_(self.t).select("*").where(self.t.foo == "bar'foo") + + self.assertEqual("SELECT * FROM \"abc\" WHERE \"foo\"='bar''foo'", str(q1)) + + def test_where_field_equals_and(self): + q = Query.from_(self.t).select("*").where((self.t.foo == 1) & (self.t.bar == self.t.baz)) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo"=1 AND "bar"="baz"', str(q)) + + def test_where_field_equals_or(self): + q = Query.from_(self.t).select("*").where((self.t.foo == 1) | (self.t.bar == self.t.baz)) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo"=1 OR "bar"="baz"', str(q)) + + def test_where_nested_conditions(self): + q = Query.from_(self.t).select("*").where((self.t.foo == 1) | (self.t.bar == self.t.baz)).where(self.t.baz == 0) + + self.assertEqual('SELECT * FROM "abc" WHERE ("foo"=1 OR "bar"="baz") AND "baz"=0', str(q)) + + def test_where_field_starts_with(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.like("ab%")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" LIKE \'ab%\'', str(q)) + + def test_where_field_contains(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.like("%fg%")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" LIKE \'%fg%\'', str(q)) + + def test_where_field_ends_with(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.like("%yz")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" LIKE \'%yz\'', str(q)) + + def test_where_field_is_n_chars_long(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.like("___")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" LIKE \'___\'', str(q)) + + def test_where_field_does_not_start_with(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.not_like("ab%")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" NOT LIKE \'ab%\'', str(q)) + + def test_where_field_does_not_contain(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.not_like("%fg%")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" NOT LIKE \'%fg%\'', str(q)) + + def test_where_field_does_not_end_with(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.not_like("%yz")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" NOT LIKE \'%yz\'', str(q)) + + def test_where_field_is_not_n_chars_long(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.not_like("___")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" NOT LIKE \'___\'', str(q)) + + def test_where_field_matches_regex(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.regex(r"^b")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" REGEX \'^b\'', str(q)) + + def test_where_field_matches_regexp(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.regexp(r"^b")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" REGEXP \'^b\'', str(q)) + + def test_where_field_matches_rlike(self): + q = Query.from_(self.t).select(self.t.star).where(self.t.foo.rlike(r"^b")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" RLIKE \'^b\'', str(q)) + + def test_ignore_empty_criterion_where(self): + q1 = Query.from_(self.t).select("*").where(EmptyCriterion()) + + self.assertEqual('SELECT * FROM "abc"', str(q1)) + + def test_ignore_empty_criterion_having(self): + q1 = Query.from_(self.t).select("*").having(EmptyCriterion()) + + self.assertEqual('SELECT * FROM "abc"', str(q1)) + + def test_select_with_force_index_and_where(self): + q = Query.from_("abc").select("foo").where(self.t.foo == self.t.bar).force_index("egg") + + self.assertEqual('SELECT "foo" FROM "abc" FORCE INDEX ("egg") WHERE "foo"="bar"', str(q)) + + def test_where_with_multiple_wheres_using_and_case(self): + case_stmt = Case().when(self.t.foo == 'bar', 1).else_(0) + query = Query.from_(self.t).select(case_stmt).where(case_stmt & self.t.blah.isin(['test'])) + + self.assertEqual( + 'SELECT CASE WHEN "foo"=\'bar\' THEN 1 ELSE 0 END FROM "abc" WHERE CASE WHEN "foo"=\'bar\' THEN 1 ELSE 0 ' + 'END AND "blah" IN (\'test\')', + str(query), + ) + + def test_where_with_multiple_wheres_using_or_case(self): + case_stmt = Case().when(self.t.foo == 'bar', 1).else_(0) + query = Query.from_(self.t).select(case_stmt).where(case_stmt | self.t.blah.isin(['test'])) + + self.assertEqual( + 'SELECT CASE WHEN "foo"=\'bar\' THEN 1 ELSE 0 END FROM "abc" WHERE CASE WHEN "foo"=\'bar\' THEN 1 ELSE 0 ' + 'END OR "blah" IN (\'test\')', + str(query), + ) + + +class PreWhereTests(WhereTests): + t = Table("abc") + + def test_prewhere_field_equals(self): + q1 = Query.from_(self.t).select("*").prewhere(self.t.foo == self.t.bar) + q2 = Query.from_(self.t).select("*").prewhere(self.t.foo.eq(self.t.bar)) + + self.assertEqual('SELECT * FROM "abc" PREWHERE "foo"="bar"', str(q1)) + self.assertEqual('SELECT * FROM "abc" PREWHERE "foo"="bar"', str(q2)) + + def test_where_and_prewhere(self): + q = Query.from_(self.t).select("*").prewhere(self.t.foo == self.t.bar).where(self.t.foo == self.t.bar) + + self.assertEqual('SELECT * FROM "abc" PREWHERE "foo"="bar" WHERE "foo"="bar"', str(q)) + + +class GroupByTests(unittest.TestCase): + t = Table("abc") + maxDiff = None + + def test_groupby__single(self): + q = Query.from_(self.t).groupby(self.t.foo).select(self.t.foo) + + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo"', str(q)) + + def test_groupby__multi(self): + q = Query.from_(self.t).groupby(self.t.foo, self.t.bar).select(self.t.foo, self.t.bar) + + self.assertEqual('SELECT "foo","bar" FROM "abc" GROUP BY "foo","bar"', str(q)) + + def test_groupby__count_star(self): + q = Query.from_(self.t).groupby(self.t.foo).select(self.t.foo, fn.Count("*")) + + self.assertEqual('SELECT "foo",COUNT(*) FROM "abc" GROUP BY "foo"', str(q)) + + def test_groupby__count_field(self): + q = Query.from_(self.t).groupby(self.t.foo).select(self.t.foo, fn.Count(self.t.bar)) + + self.assertEqual('SELECT "foo",COUNT("bar") FROM "abc" GROUP BY "foo"', str(q)) + + def test_groupby__count_distinct(self): + q = Query.from_(self.t).groupby(self.t.foo).select(self.t.foo, fn.Count("*").distinct()) + + self.assertEqual('SELECT "foo",COUNT(DISTINCT *) FROM "abc" GROUP BY "foo"', str(q)) + + def test_groupby__sum_distinct(self): + q = Query.from_(self.t).groupby(self.t.foo).select(self.t.foo, fn.Sum(self.t.bar).distinct()) + + self.assertEqual('SELECT "foo",SUM(DISTINCT "bar") FROM "abc" GROUP BY "foo"', str(q)) + + def test_groupby__sum_filter(self): + q = ( + Query.from_(self.t) + .groupby(self.t.foo) + .select(self.t.foo, fn.Sum(self.t.bar).filter(self.t.id.eq(1) & self.t.cid.gt(2))) + ) + + self.assertEqual('SELECT "foo",SUM("bar") FILTER(WHERE "id"=1 AND "cid">2) FROM "abc" GROUP BY "foo"', str(q)) + + def test_groupby__str(self): + q = Query.from_("abc").groupby("foo").select("foo", fn.Count("*").distinct()) + + self.assertEqual('SELECT "foo",COUNT(DISTINCT *) FROM "abc" GROUP BY "foo"', str(q)) + + def test_groupby__int(self): + q = Query.from_("abc").groupby(1).select("foo", fn.Count("*").distinct()) + + self.assertEqual('SELECT "foo",COUNT(DISTINCT *) FROM "abc" GROUP BY 1', str(q)) + + def test_groupby__alias(self): + bar = self.t.bar.as_("bar01") + q = Query.from_(self.t).select(fn.Sum(self.t.foo), bar).groupby(bar) + + self.assertEqual('SELECT SUM("foo"),"bar" "bar01" FROM "abc" GROUP BY "bar01"', str(q)) + + def test_groupby__no_alias(self): + bar = self.t.bar.as_("bar01") + q = Query.from_(self.t).select(fn.Sum(self.t.foo), bar).groupby(bar) + + self.assertEqual( + 'SELECT SUM("foo"),"bar" "bar01" FROM "abc" GROUP BY "bar"', + q.get_sql(groupby_alias=False), + ) + + def test_groupby__no_alias_mssql(self): + bar = self.t.bar.as_("bar01") + q = MSSQLQuery.from_(self.t).select(fn.Sum(self.t.foo), bar).groupby(bar) + + self.assertEqual('SELECT SUM("foo"),"bar" "bar01" FROM "abc" GROUP BY "bar"', str(q)) + + def test_groupby__no_alias_oracle(self): + bar = self.t.bar.as_("bar01") + q = OracleQuery.from_(self.t).select(fn.Sum(self.t.foo), bar).groupby(bar) + + self.assertEqual('SELECT SUM(foo),bar bar01 FROM abc GROUP BY bar', str(q)) + + def test_groupby__alias_platforms(self): + bar = self.t.bar.as_("bar01") + + for query_cls in [ + MySQLQuery, + VerticaQuery, + PostgreSQLQuery, + RedshiftQuery, + ClickHouseQuery, + SQLLiteQuery, + ]: + q = query_cls.from_(self.t).select(fn.Sum(self.t.foo), bar).groupby(bar) + + quote_char = query_cls._builder().QUOTE_CHAR if isinstance(query_cls._builder().QUOTE_CHAR, str) else '"' + + self.assertEqual( + "SELECT " + "SUM({quote_char}foo{quote_char})," + "{quote_char}bar{quote_char}{as_keyword}{quote_char}bar01{quote_char} " + "FROM {quote_char}abc{quote_char} " + "GROUP BY {quote_char}bar01{quote_char}".format( + as_keyword=' AS ' if query_cls is ClickHouseQuery else ' ', quote_char=quote_char + ), + str(q), + ) + + def test_groupby__alias_with_join(self): + table1 = Table("table1", alias="t1") + bar = table1.bar.as_("bar01") + q = Query.from_(self.t).join(table1).on(self.t.id == table1.t_ref).select(fn.Sum(self.t.foo), bar).groupby(bar) + + self.assertEqual( + 'SELECT SUM("abc"."foo"),"t1"."bar" "bar01" FROM "abc" ' + 'JOIN "table1" "t1" ON "abc"."id"="t1"."t_ref" ' + 'GROUP BY "bar01"', + str(q), + ) + + def test_groupby_with_case_uses_the_alias(self): + q = ( + Query.from_(self.t) + .select( + fn.Sum(self.t.foo).as_("bar"), + Case().when(self.t.fname == "Tom", "It was Tom").else_("It was someone else.").as_("who_was_it"), + ) + .groupby(Case().when(self.t.fname == "Tom", "It was Tom").else_("It was someone else.").as_("who_was_it")) + ) + + self.assertEqual( + 'SELECT SUM("foo") "bar",' + "CASE WHEN \"fname\"='Tom' THEN 'It was Tom' " + "ELSE 'It was someone else.' END \"who_was_it\" " + 'FROM "abc" ' + 'GROUP BY "who_was_it"', + str(q), + ) + + def test_mysql_query_uses_backtick_quote_chars(self): + q = MySQLQuery.from_(self.t).groupby(self.t.foo).select(self.t.foo) + + self.assertEqual("SELECT `foo` FROM `abc` GROUP BY `foo`", str(q)) + + def test_vertica_query_uses_double_quote_chars(self): + q = VerticaQuery.from_(self.t).groupby(self.t.foo).select(self.t.foo) + + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo"', str(q)) + + def test_mssql_query_uses_double_quote_chars(self): + q = MSSQLQuery.from_(self.t).groupby(self.t.foo).select(self.t.foo) + + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo"', str(q)) + + def test_oracle_query_uses_no_quote_chars(self): + q = OracleQuery.from_(self.t).groupby(self.t.foo).select(self.t.foo) + + self.assertEqual('SELECT foo FROM abc GROUP BY foo', str(q)) + + def test_postgres_query_uses_double_quote_chars(self): + q = PostgreSQLQuery.from_(self.t).groupby(self.t.foo).select(self.t.foo) + + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo"', str(q)) + + def test_redshift_query_uses_double_quote_chars(self): + q = RedshiftQuery.from_(self.t).groupby(self.t.foo).select(self.t.foo) + + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo"', str(q)) + + def test_group_by__single_with_totals(self): + q = Query.from_(self.t).groupby(self.t.foo).select(self.t.foo).with_totals() + + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo" WITH TOTALS', str(q)) + + def test_groupby__multi_with_totals(self): + q = Query.from_(self.t).groupby(self.t.foo, self.t.bar).select(self.t.foo, self.t.bar).with_totals() + + self.assertEqual('SELECT "foo","bar" FROM "abc" GROUP BY "foo","bar" WITH TOTALS', str(q)) + + +class HavingTests(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_having_greater_than(self): + q = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, fn.Sum(self.table_abc.bar)) + .groupby(self.table_abc.foo) + .having(fn.Sum(self.table_abc.bar) > 1) + ) + + self.assertEqual( + 'SELECT "foo",SUM("bar") FROM "abc" GROUP BY "foo" HAVING SUM("bar")>1', + str(q), + ) + + def test_having_and(self): + q = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, fn.Sum(self.table_abc.bar)) + .groupby(self.table_abc.foo) + .having((fn.Sum(self.table_abc.bar) > 1) & (fn.Sum(self.table_abc.bar) < 100)) + ) + + self.assertEqual( + 'SELECT "foo",SUM("bar") FROM "abc" GROUP BY "foo" HAVING SUM("bar")>1 AND SUM("bar")<100', + str(q), + ) + + def test_having_join_and_equality(self): + q = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.foo) + .select(self.table_abc.foo, fn.Sum(self.table_efg.bar), self.table_abc.buz) + .groupby(self.table_abc.foo) + .having(self.table_abc.buz == "fiz") + .having(fn.Sum(self.table_efg.bar) > 100) + ) + + self.assertEqual( + 'SELECT "abc"."foo",SUM("efg"."bar"),"abc"."buz" FROM "abc" ' + 'JOIN "efg" ON "abc"."foo"="efg"."foo" ' + 'GROUP BY "abc"."foo" ' + 'HAVING "abc"."buz"=\'fiz\' AND SUM("efg"."bar")>100', + str(q), + ) + + def test_mysql_query_uses_backtick_quote_chars(self): + q = ( + MySQLQuery.from_(self.table_abc) + .select(self.table_abc.foo) + .groupby(self.table_abc.foo) + .having(self.table_abc.buz == "fiz") + ) + self.assertEqual("SELECT `foo` FROM `abc` GROUP BY `foo` HAVING `buz`='fiz'", str(q)) + + def test_vertica_query_uses_double_quote_chars(self): + q = ( + VerticaQuery.from_(self.table_abc) + .select(self.table_abc.foo) + .groupby(self.table_abc.foo) + .having(self.table_abc.buz == "fiz") + ) + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo" HAVING "buz"=\'fiz\'', str(q)) + + def test_mssql_query_uses_double_quote_chars(self): + q = ( + MSSQLQuery.from_(self.table_abc) + .select(self.table_abc.foo) + .groupby(self.table_abc.foo) + .having(self.table_abc.buz == "fiz") + ) + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo" HAVING "buz"=\'fiz\'', str(q)) + + def test_oracle_query_uses_no_quote_chars(self): + q = ( + OracleQuery.from_(self.table_abc) + .select(self.table_abc.foo) + .groupby(self.table_abc.foo) + .having(self.table_abc.buz == "fiz") + ) + self.assertEqual('SELECT foo FROM abc GROUP BY foo HAVING buz=\'fiz\'', str(q)) + + def test_postgres_query_uses_double_quote_chars(self): + q = ( + PostgreSQLQuery.from_(self.table_abc) + .select(self.table_abc.foo) + .groupby(self.table_abc.foo) + .having(self.table_abc.buz == "fiz") + ) + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo" HAVING "buz"=\'fiz\'', str(q)) + + def test_redshift_query_uses_double_quote_chars(self): + q = ( + RedshiftQuery.from_(self.table_abc) + .select(self.table_abc.foo) + .groupby(self.table_abc.foo) + .having(self.table_abc.buz == "fiz") + ) + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo" HAVING "buz"=\'fiz\'', str(q)) + + +class OrderByTests(unittest.TestCase): + t = Table("abc") + + def test_orderby_single_field(self): + q = Query.from_(self.t).orderby(self.t.foo).select(self.t.foo) + + self.assertEqual('SELECT "foo" FROM "abc" ORDER BY "foo"', str(q)) + + def test_orderby_multi_fields(self): + q = Query.from_(self.t).orderby(self.t.foo, self.t.bar).select(self.t.foo, self.t.bar) + + self.assertEqual('SELECT "foo","bar" FROM "abc" ORDER BY "foo","bar"', str(q)) + + def test_orderby_single_str(self): + q = Query.from_("abc").orderby("foo").select("foo") + + self.assertEqual('SELECT "foo" FROM "abc" ORDER BY "foo"', str(q)) + + def test_orderby_asc(self): + q = Query.from_(self.t).orderby(self.t.foo, order=Order.asc).select(self.t.foo) + + self.assertEqual('SELECT "foo" FROM "abc" ORDER BY "foo" ASC', str(q)) + + def test_orderby_desc(self): + q = Query.from_(self.t).orderby(self.t.foo, order=Order.desc).select(self.t.foo) + + self.assertEqual('SELECT "foo" FROM "abc" ORDER BY "foo" DESC', str(q)) + + def test_orderby_no_alias(self): + bar = self.t.bar.as_("bar01") + q = Query.from_(self.t).select(fn.Sum(self.t.foo), bar).orderby(bar) + + self.assertEqual( + 'SELECT SUM("foo"),"bar" "bar01" FROM "abc" ORDER BY "bar"', + q.get_sql(orderby_alias=False), + ) + + def test_orderby_alias(self): + bar = self.t.bar.as_("bar01") + q = Query.from_(self.t).select(fn.Sum(self.t.foo), bar).orderby(bar) + + self.assertEqual('SELECT SUM("foo"),"bar" "bar01" FROM "abc" ORDER BY "bar01"', q.get_sql()) + + +class AliasTests(unittest.TestCase): + t = Table("abc") + + def test_table_field(self): + q = Query.from_(self.t).select(self.t.foo.as_("bar")) + + self.assertEqual('SELECT "foo" "bar" FROM "abc"', str(q)) + + def test_table_field__multi(self): + q = Query.from_(self.t).select(self.t.foo.as_("bar"), self.t.fiz.as_("buz")) + + self.assertEqual('SELECT "foo" "bar","fiz" "buz" FROM "abc"', str(q)) + + def test_arithmetic_function(self): + q = Query.from_(self.t).select((self.t.foo + self.t.bar).as_("biz")) + + self.assertEqual('SELECT "foo"+"bar" "biz" FROM "abc"', str(q)) + + def test_functions_using_as(self): + q = Query.from_(self.t).select(fn.Count("*").as_("foo")) + + self.assertEqual('SELECT COUNT(*) "foo" FROM "abc"', str(q)) + + def test_functions_using_constructor_param(self): + q = Query.from_(self.t).select(fn.Count("*", alias="foo")) + + self.assertEqual('SELECT COUNT(*) "foo" FROM "abc"', str(q)) + + def test_function_using_as_nested(self): + """ + We don't show aliases of fields that are arguments of a function. + """ + q = Query.from_(self.t).select(fn.Sqrt(fn.Count("*").as_("foo")).as_("bar")) + + self.assertEqual('SELECT SQRT(COUNT(*)) "bar" FROM "abc"', str(q)) + + def test_functions_using_constructor_param_nested(self): + """ + We don't show aliases of fields that are arguments of a function. + """ + q = Query.from_(self.t).select(fn.Sqrt(fn.Count("*", alias="foo"), alias="bar")) + + self.assertEqual('SELECT SQRT(COUNT(*)) "bar" FROM "abc"', str(q)) + + def test_ignored_in_where(self): + q = Query.from_(self.t).select(self.t.foo).where(self.t.foo.as_("bar") == 1) + + self.assertEqual('SELECT "foo" FROM "abc" WHERE "foo"=1', str(q)) + + def test_ignored_in_groupby(self): + q = Query.from_(self.t).select(self.t.foo).groupby(self.t.foo.as_("bar")) + + self.assertEqual('SELECT "foo" FROM "abc" GROUP BY "foo"', str(q)) + + def test_ignored_in_orderby(self): + q = Query.from_(self.t).select(self.t.foo).orderby(self.t.foo.as_("bar")) + + self.assertEqual('SELECT "foo" FROM "abc" ORDER BY "foo"', str(q)) + + def test_ignored_in_criterion(self): + c = self.t.foo.as_("bar") == 1 + + self.assertEqual('"foo"=1', str(c)) + + def test_ignored_in_criterion_comparison(self): + c = self.t.foo.as_("bar") == self.t.fiz.as_("buz") + + self.assertEqual('"foo"="fiz"', str(c)) + + def test_ignored_in_field_inside_case(self): + q = Query.from_(self.t).select(Case().when(self.t.foo == 1, "a").else_(self.t.bar.as_('"buz"'))) + + self.assertEqual('SELECT CASE WHEN "foo"=1 THEN \'a\' ELSE "bar" END FROM "abc"', str(q)) + + def test_case_using_as(self): + q = Query.from_(self.t).select(Case().when(self.t.foo == 1, "a").else_("b").as_("bar")) + + self.assertEqual( + 'SELECT CASE WHEN "foo"=1 THEN \'a\' ELSE \'b\' END "bar" FROM "abc"', + str(q), + ) + + def test_case_using_constructor_param(self): + q = Query.from_(self.t).select(Case(alias="bar").when(self.t.foo == 1, "a").else_("b")) + + self.assertEqual( + 'SELECT CASE WHEN "foo"=1 THEN \'a\' ELSE \'b\' END "bar" FROM "abc"', + str(q), + ) + + def test_select__multiple_tables(self): + table_abc, table_efg = Table("abc", alias="q0"), Table("efg", alias="q1") + + q = Query.from_(table_abc).select(table_abc.foo).from_(table_efg).select(table_efg.bar) + + self.assertEqual('SELECT "q0"."foo","q1"."bar" FROM "abc" "q0","efg" "q1"', str(q)) + + def test_use_aliases_in_groupby_and_orderby(self): + table_abc = Table("abc", alias="q0") + + my_foo = table_abc.foo.as_("my_foo") + q = Query.from_(table_abc).select(my_foo, table_abc.bar).groupby(my_foo).orderby(my_foo) + + self.assertEqual( + 'SELECT "q0"."foo" "my_foo","q0"."bar" ' 'FROM "abc" "q0" ' 'GROUP BY "my_foo" ' 'ORDER BY "my_foo"', + str(q), + ) + + def test_table_with_schema_and_alias(self): + table = Table("abc", schema="schema", alias="alias") + self.assertEqual('"schema"."abc" "alias"', str(table)) + + def test_null_value_with_alias(self): + q = Query.select(NullValue().as_("abcdef")) + + self.assertEqual('SELECT NULL "abcdef"', str(q)) + + +class SubqueryTests(unittest.TestCase): + maxDiff = None + + table_abc, table_efg, table_hij = Tables("abc", "efg", "hij") + + def test_where__in(self): + q = ( + Query.from_(self.table_abc) + .select("*") + .where( + self.table_abc.foo.isin( + Query.from_(self.table_efg).select(self.table_efg.foo).where(self.table_efg.bar == 0) + ) + ) + ) + + self.assertEqual( + 'SELECT * FROM "abc" WHERE "foo" IN (SELECT "foo" FROM "efg" WHERE "bar"=0)', + str(q), + ) + + def test_where__in_nested(self): + q = Query.from_(self.table_abc).select("*").where(self.table_abc.foo).isin(self.table_efg.select("*")) + + self.assertEqual('SELECT * FROM "abc" WHERE "foo" IN (SELECT * FROM "efg")', str(q)) + + def test_join(self): + subquery = Query.from_("efg").select("fiz", "buz").where(F("buz") == 0) + + q = ( + Query.from_(self.table_abc) + .join(subquery) + .on(self.table_abc.bar == subquery.buz) + .select(self.table_abc.foo, subquery.fiz) + ) + + self.assertEqual( + 'SELECT "abc"."foo","sq0"."fiz" FROM "abc" ' + 'JOIN (SELECT "fiz","buz" FROM "efg" WHERE "buz"=0) "sq0" ' + 'ON "abc"."bar"="sq0"."buz"', + str(q), + ) + + def test_select_subquery(self): + subq = Query.from_(self.table_efg).select("fizzbuzz").where(self.table_efg.id == 1) + + q = Query.from_(self.table_abc).select("foo", "bar").select(subq) + + self.assertEqual( + 'SELECT "foo","bar",(SELECT "fizzbuzz" FROM "efg" WHERE "id"=1) ' 'FROM "abc"', + str(q), + ) + + def test_select_subquery_with_alias(self): + subq = Query.from_(self.table_efg).select("fizzbuzz").where(self.table_efg.id == 1) + + q = Query.from_(self.table_abc).select("foo", "bar").select(subq.as_("sq")) + + self.assertEqual( + 'SELECT "foo","bar",(SELECT "fizzbuzz" FROM "efg" WHERE "id"=1) "sq" ' 'FROM "abc"', + str(q), + ) + + def test_where__equality(self): + subquery = Query.from_("efg").select("fiz").where(F("buz") == 0) + query = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, self.table_abc.bar) + .where(self.table_abc.bar == subquery) + ) + + self.assertEqual( + 'SELECT "foo","bar" FROM "abc" ' 'WHERE "bar"=(SELECT "fiz" FROM "efg" WHERE "buz"=0)', + str(query), + ) + + def test_select_from_nested_query(self): + subquery = Query.from_(self.table_abc).select( + self.table_abc.foo, + self.table_abc.bar, + (self.table_abc.fizz + self.table_abc.buzz).as_("fizzbuzz"), + ) + + query = Query.from_(subquery).select(subquery.foo, subquery.bar, subquery.fizzbuzz) + + self.assertEqual( + 'SELECT "sq0"."foo","sq0"."bar","sq0"."fizzbuzz" ' + "FROM (" + 'SELECT "foo","bar","fizz"+"buzz" "fizzbuzz" ' + 'FROM "abc"' + ') "sq0"', + str(query), + ) + + def test_select_from_nested_query_with_join(self): + subquery1 = ( + Query.from_(self.table_abc) + .select( + self.table_abc.foo, + fn.Sum(self.table_abc.fizz + self.table_abc.buzz).as_("fizzbuzz"), + ) + .groupby(self.table_abc.foo) + ) + + subquery2 = Query.from_(self.table_efg).select( + self.table_efg.foo.as_("foo_two"), + self.table_efg.bar, + ) + + query = ( + Query.from_(subquery1) + .select(subquery1.foo, subquery1.fizzbuzz) + .join(subquery2) + .on(subquery1.foo == subquery2.foo_two) + .select(subquery2.foo_two, subquery2.bar) + ) + + self.assertEqual( + "SELECT " + '"sq0"."foo","sq0"."fizzbuzz",' + '"sq1"."foo_two","sq1"."bar" ' + "FROM (" + "SELECT " + '"foo",SUM("fizz"+"buzz") "fizzbuzz" ' + 'FROM "abc" ' + 'GROUP BY "foo"' + ') "sq0" JOIN (' + "SELECT " + '"foo" "foo_two","bar" ' + 'FROM "efg"' + ') "sq1" ON "sq0"."foo"="sq1"."foo_two"', + str(query), + ) + + def test_from_subquery_without_alias(self): + subquery = Query.from_(self.table_efg).select( + self.table_efg.base_id.as_("x"), self.table_efg.fizz, self.table_efg.buzz + ) + + test_query = Query.from_(subquery).select(subquery.x, subquery.fizz, subquery.buzz) + + self.assertEqual( + 'SELECT "sq0"."x","sq0"."fizz","sq0"."buzz" ' + "FROM (" + 'SELECT "base_id" "x","fizz","buzz" FROM "efg"' + ') "sq0"', + str(test_query), + ) + + def test_join_query_with_alias(self): + subquery = ( + Query.from_(self.table_efg) + .select( + self.table_efg.base_id.as_("x"), + self.table_efg.fizz, + self.table_efg.buzz, + ) + .as_("subq") + ) + + test_query = Query.from_(subquery).select(subquery.x, subquery.fizz, subquery.buzz) + + self.assertEqual( + 'SELECT "subq"."x","subq"."fizz","subq"."buzz" ' + "FROM (" + 'SELECT "base_id" "x","fizz","buzz" FROM "efg"' + ') "subq"', + str(test_query), + ) + + def test_with(self): + sub_query = Query.from_(self.table_efg).select("fizz") + test_query = Query.with_(sub_query, "an_alias").from_(AliasedQuery("an_alias")).select("*") + + self.assertEqual( + 'WITH an_alias AS (SELECT "fizz" FROM "efg") SELECT * FROM an_alias', + str(test_query), + ) + + def test_join_with_with(self): + sub_query = Query.from_(self.table_efg).select("fizz") + test_query = ( + Query.with_(sub_query, "an_alias") + .from_(self.table_abc) + .join(AliasedQuery("an_alias")) + .on(AliasedQuery("an_alias").fizz == self.table_abc.buzz) + .select("*") + ) + self.assertEqual( + 'WITH an_alias AS (SELECT "fizz" FROM "efg") ' + 'SELECT * FROM "abc" JOIN an_alias ON "an_alias"."fizz"="abc"."buzz"', + str(test_query), + ) + + def test_select_from_with_returning(self): + sub_query = PostgreSQLQuery.into(self.table_abc).insert(1).returning('*') + test_query = Query.with_(sub_query, "an_alias").from_(AliasedQuery("an_alias")).select("*") + self.assertEqual( + 'WITH an_alias AS (INSERT INTO "abc" VALUES (1) RETURNING *) SELECT * FROM an_alias', str(test_query) + ) + + +class QuoteTests(unittest.TestCase): + def test_extraneous_quotes(self): + t1 = Table("table1", alias="t1") + t2 = Table("table2", alias="t2") + + query = Query.from_(t1).join(t2).on(t1.Value.between(t2.start, t2.end)).select(t1.value) + + self.assertEqual( + "SELECT t1.value FROM table1 t1 " "JOIN table2 t2 ON t1.Value " "BETWEEN t2.start AND t2.end", + query.get_sql(quote_char=None), + ) diff --git a/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/test_tables.py b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/test_tables.py new file mode 100644 index 0000000000000000000000000000000000000000..f43e740915f642d29ce7497c36e3b68f01311016 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/test_tables.py @@ -0,0 +1,186 @@ +# from pypika.terms import ValueWrapper, SystemTimeValue +import unittest + +from pypika import Database, Dialects, Schema, SQLLiteQuery, Table, Tables, Query, SYSTEM_TIME + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + + +class TableStructureTests(unittest.TestCase): + def test_table_sql(self): + table = Table("test_table") + + self.assertEqual('"test_table"', str(table)) + + def test_table_with_alias(self): + table = Table("test_table").as_("my_table") + + self.assertEqual('"test_table" "my_table"', table.get_sql(with_alias=True, quote_char='"')) + + def test_schema_table_attr(self): + table = Schema("x_schema").test_table + + self.assertEqual('"x_schema"."test_table"', str(table)) + + def test_table_with_schema_arg(self): + table = Table("test_table", schema=Schema("x_schema")) + + self.assertEqual('"x_schema"."test_table"', str(table)) + + def test_database_schema_table_attr(self): + table = Database("x_db").x_schema.test_table + + self.assertEqual('"x_db"."x_schema"."test_table"', str(table)) + + def test_table_with_schema_and_schema_parent_arg(self): + table = Table("test_table", schema=Schema("x_schema", parent=Database("x_db"))) + + self.assertEqual('"x_db"."x_schema"."test_table"', str(table)) + + def test_table_for_system_time_sql(self): + with self.subTest("with between criterion"): + table = Table("test_table").for_(SYSTEM_TIME.between('2020-01-01', '2020-02-01')) + + self.assertEqual('"test_table" FOR SYSTEM_TIME BETWEEN \'2020-01-01\' AND \'2020-02-01\'', str(table)) + + with self.subTest("with as of criterion"): + table = Table("test_table").for_(SYSTEM_TIME.as_of('2020-01-01')) + + self.assertEqual('"test_table" FOR SYSTEM_TIME AS OF \'2020-01-01\'', str(table)) + + with self.subTest("with from to criterion"): + table = Table("test_table").for_(SYSTEM_TIME.from_to('2020-01-01', '2020-02-01')) + + self.assertEqual('"test_table" FOR SYSTEM_TIME FROM \'2020-01-01\' TO \'2020-02-01\'', str(table)) + + def test_table_for_period_sql(self): + with self.subTest("with between criterion"): + table = Table("test_table") + table = table.for_(table.valid_period.between('2020-01-01', '2020-02-01')) + + self.assertEqual('"test_table" FOR "valid_period" BETWEEN \'2020-01-01\' AND \'2020-02-01\'', str(table)) + + with self.subTest("with as of criterion"): + table = Table("test_table") + table = table.for_(table.valid_period.as_of('2020-01-01')) + + self.assertEqual('"test_table" FOR "valid_period" AS OF \'2020-01-01\'', str(table)) + + with self.subTest("with from to criterion"): + table = Table("test_table") + table = table.for_(table.valid_period.from_to('2020-01-01', '2020-02-01')) + + self.assertEqual('"test_table" FOR "valid_period" FROM \'2020-01-01\' TO \'2020-02-01\'', str(table)) + + +class TableEqualityTests(unittest.TestCase): + def test_tables_equal_by_name(self): + t1 = Table("t") + t2 = Table("t") + + self.assertEqual(t1, t2) + + def test_tables_equal_by_schema_and_name(self): + t1 = Table("t", schema="a") + t2 = Table("t", schema="a") + + self.assertEqual(t1, t2) + + def test_tables_equal_by_schema_and_name_using_schema(self): + a = Schema("a") + t1 = Table("t", schema=a) + t2 = Table("t", schema=a) + + self.assertEqual(t1, t2) + + def test_tables_equal_by_schema_and_name_using_schema_with_parent(self): + parent = Schema("parent") + a = Schema("a", parent=parent) + t1 = Table("t", schema=a) + t2 = Table("t", schema=a) + + self.assertEqual(t1, t2) + + def test_tables_not_equal_by_schema_and_name_using_schema_with_different_parents( + self, + ): + parent = Schema("parent") + a = Schema("a", parent=parent) + t1 = Table("t", schema=a) + t2 = Table("t", schema=Schema("a")) + + self.assertNotEqual(t1, t2) + + def test_tables_not_equal_with_different_schemas(self): + t1 = Table("t", schema="a") + t2 = Table("t", schema="b") + + self.assertNotEqual(t1, t2) + + def test_tables_not_equal_with_different_names(self): + t1 = Table("t", schema="a") + t2 = Table("q", schema="a") + + self.assertNotEqual(t1, t2) + + def test_many_tables_with_alias(self): + tables_data = [("table1", "t1"), ("table2", "t2"), ("table3", "t3")] + tables = Tables(*tables_data) + for el in tables: + self.assertIsNotNone(el.alias) + + def test_many_tables_without_alias(self): + tables_data = ["table1", "table2", "table3"] + tables = Tables(*tables_data) + for el in tables: + self.assertIsNone(el.alias) + + def test_many_tables_with_or_not_alias(self): + tables_data = [("table1", "t1"), ("table2"), "table3"] + tables = Tables(*tables_data) + for i in range(len(tables)): + if isinstance(tables_data[i], tuple): + self.assertIsNotNone(tables[i].alias) + else: + self.assertIsNone(tables[i].alias) + + +class TableDialectTests(unittest.TestCase): + def test_table_with_default_query_cls(self): + table = Table("abc") + q = table.select("1") + self.assertIs(q.dialect, None) + + def test_table_with_dialect_query_cls(self): + table = Table("abc", query_cls=SQLLiteQuery) + q = table.select("1") + self.assertIs(q.dialect, Dialects.SQLLITE) + + def test_table_factory_with_default_query_cls(self): + table = Query.Table("abc") + q = table.select("1") + self.assertIs(q.dialect, None) + + def test_table_factory_with_dialect_query_cls(self): + table = SQLLiteQuery.Table("abc") + q = table.select("1") + self.assertIs(q.dialect, Dialects.SQLLITE) + + def test_make_tables_factory_with_default_query_cls(self): + t1, t2 = Query.Tables("abc", "def") + q1 = t1.select("1") + q2 = t2.select("2") + self.assertIs(q1.dialect, None) + self.assertIs(q2.dialect, None) + + def test_make_tables_factory_with_dialect_query_cls(self): + t1, t2 = SQLLiteQuery.Tables("abc", "def") + q1 = t1.select("1") + q2 = t2.select("2") + self.assertIs(q1.dialect, Dialects.SQLLITE) + self.assertIs(q2.dialect, Dialects.SQLLITE) + + def test_table_with_bad_query_cls(self): + with self.assertRaises(TypeError): + Table("abc", query_cls=object) diff --git a/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/test_terms.py b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/test_terms.py new file mode 100644 index 0000000000000000000000000000000000000000..4c7590dfce129bac97a3f30de99b596cc746c893 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/test_terms.py @@ -0,0 +1,82 @@ +from unittest import TestCase + +from pypika import Query, Table, Field +from pypika.terms import AtTimezone + + +class FieldAliasTests(TestCase): + t = Table("test", alias="crit") + + def test_when_alias_specified(self): + c1 = Field("foo", alias="bar") + self.assertEqual('bar', str(c1.alias)) + + c1 = Field("foo").as_("bar") + self.assertEqual('bar', str(c1.alias)) + + +class FieldInitTests(TestCase): + def test_init_with_str_table(self): + test_table_name = "test_table" + field = Field(name="name", table=test_table_name) + self.assertEqual(field.table, Table(name=test_table_name)) + + +class FieldHashingTests(TestCase): + def test_tabled_eq_fields_equally_hashed(self): + client_name1 = Field(name="name", table=Table("clients")) + client_name2 = Field(name="name", table=Table("clients")) + self.assertTrue(hash(client_name1) == hash(client_name2)) + + def test_tabled_ne_fields_differently_hashed(self): + customer_name = Field(name="name", table=Table("customers")) + client_name = Field(name="name", table=Table("clients")) + self.assertTrue(hash(customer_name) != hash(client_name)) + + def test_non_tabled_aliased_eq_fields_equally_hashed(self): + self.assertTrue(hash(Field(name="A", alias="my_a")) == hash(Field(name="A", alias="my_a"))) + + def test_non_tabled_aliased_ne_fields_differently_hashed(self): + self.assertTrue(hash(Field(name="A", alias="my_a1")) != hash(Field(name="A", alias="my_a2"))) + + def test_non_tabled_eq_fields_equally_hashed(self): + self.assertTrue(hash(Field(name="A")) == hash(Field(name="A"))) + + def test_non_tabled_ne_fields_differently_hashed(self): + self.assertTrue(hash(Field(name="A")) != hash(Field(name="B"))) + + +class AtTimezoneTests(TestCase): + def test_when_interval_not_specified(self): + query = Query.from_("customers").select(AtTimezone("date", "US/Eastern")) + self.assertEqual('SELECT "date" AT TIME ZONE \'US/Eastern\' FROM "customers"', str(query)) + + def test_when_interval_specified(self): + query = Query.from_("customers").select(AtTimezone("date", "-06:00", interval=True)) + self.assertEqual( + 'SELECT "date" AT TIME ZONE INTERVAL \'-06:00\' FROM "customers"', + str(query), + ) + + def test_when_alias_specified(self): + query = Query.from_("customers").select(AtTimezone("date", "US/Eastern", alias="alias1")) + self.assertEqual( + 'SELECT "date" AT TIME ZONE \'US/Eastern\' "alias1" FROM "customers"', + str(query), + ) + + def test_passes_kwargs_to_field_get_sql(self): + customers = Table("customers") + accounts = Table("accounts") + query = ( + Query.from_(customers) + .join(accounts) + .on(customers.account_id == accounts.account_id) + .select(AtTimezone(customers.date, "US/Eastern", alias="alias1")) + ) + + self.assertEqual( + 'SELECT "customers"."date" AT TIME ZONE \'US/Eastern\' "alias1" ' + 'FROM "customers" JOIN "accounts" ON "customers"."account_id"="accounts"."account_id"', + query.get_sql(with_namespace=True), + ) diff --git a/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/test_tuples.py b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/test_tuples.py new file mode 100644 index 0000000000000000000000000000000000000000..c8ebc8e41b0115777f8b3c8cb01c04e62f13ee18 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/test_tuples.py @@ -0,0 +1,162 @@ +import unittest + +from pypika import ( + Array, + Bracket, + Query, + PostgreSQLQuery, + Table, + Tables, + Tuple, +) +from pypika.functions import Coalesce, NullIf, Sum +from pypika.terms import Field + + +class TupleTests(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_tuple_equality_tuple_on_both(self): + q = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, self.table_abc.bar) + .where(Tuple(self.table_abc.foo, self.table_abc.bar) == Tuple(1, 2)) + ) + + self.assertEqual('SELECT "foo","bar" FROM "abc" ' 'WHERE ("foo","bar")=(1,2)', str(q)) + + def test_tuple_equality_tuple_on_left(self): + q = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, self.table_abc.bar) + .where(Tuple(self.table_abc.foo, self.table_abc.bar) == (1, 2)) + ) + + self.assertEqual('SELECT "foo","bar" FROM "abc" ' 'WHERE ("foo","bar")=(1,2)', str(q)) + + def test_tuple_equality_tuple_on_right(self): + q = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, self.table_abc.bar) + .where((self.table_abc.foo, self.table_abc.bar) == Tuple(1, 2)) + ) + + # Order is reversed due to lack of right equals method + self.assertEqual('SELECT "foo","bar" FROM "abc" ' 'WHERE (1,2)=("foo","bar")', str(q)) + + def test_tuple_in_using_python_tuples(self): + q = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, self.table_abc.bar) + .where(Tuple(self.table_abc.foo, self.table_abc.bar).isin([(1, 1), (2, 2), (3, 3)])) + ) + + self.assertEqual( + 'SELECT "foo","bar" FROM "abc" ' 'WHERE ("foo","bar") IN ((1,1),(2,2),(3,3))', + str(q), + ) + + def test_tuple_in_using_pypika_tuples(self): + q = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, self.table_abc.bar) + .where(Tuple(self.table_abc.foo, self.table_abc.bar).isin([Tuple(1, 1), Tuple(2, 2), Tuple(3, 3)])) + ) + + self.assertEqual( + 'SELECT "foo","bar" FROM "abc" ' 'WHERE ("foo","bar") IN ((1,1),(2,2),(3,3))', + str(q), + ) + + def test_tuple_in_using_mixed_tuples(self): + q = ( + Query.from_(self.table_abc) + .select(self.table_abc.foo, self.table_abc.bar) + .where(Tuple(self.table_abc.foo, self.table_abc.bar).isin([(1, 1), Tuple(2, 2), (3, 3)])) + ) + + self.assertEqual( + 'SELECT "foo","bar" FROM "abc" ' 'WHERE ("foo","bar") IN ((1,1),(2,2),(3,3))', + str(q), + ) + + def test_tuples_in_join(self): + query = ( + Query.from_(self.table_abc) + .join(self.table_efg) + .on(self.table_abc.foo == self.table_efg.bar) + .select("*") + .where(Tuple(self.table_abc.foo, self.table_efg.bar).isin([(1, 1), Tuple(2, 2), (3, 3)])) + ) + + self.assertEqual( + 'SELECT * FROM "abc" JOIN "efg" ON "abc"."foo"="efg"."bar" ' + 'WHERE ("abc"."foo","efg"."bar") IN ((1,1),(2,2),(3,3))', + str(query), + ) + + def test_render_alias_in_array_sql(self): + tb = Table("tb") + + q = Query.from_(tb).select(Tuple(tb.col).as_("different_name")) + self.assertEqual(str(q), 'SELECT ("col") "different_name" FROM "tb"') + + def test_tuple_is_aggregate(self): + with self.subTest('None if single argument returns None for is_aggregate'): + self.assertEqual(None, Tuple(0).is_aggregate) + self.assertEqual(None, Tuple(Coalesce('col')).is_aggregate) + + with self.subTest('None if multiple arguments all return None for is_aggregate'): + self.assertEqual(None, Tuple(0, 'a').is_aggregate) + self.assertEqual(None, Tuple(Coalesce('col'), NullIf('col2', 0)).is_aggregate) + + with self.subTest('True if single argument returns True for is_aggregate'): + self.assertEqual(True, Tuple(Sum('col')).is_aggregate) + + with self.subTest('True if multiple arguments return True for is_aggregate'): + self.assertEqual(True, Tuple(Sum('col'), Sum('col2')).is_aggregate) + + with self.subTest('True when mix of arguments returning None and True for is_aggregate'): + self.assertEqual(True, Tuple(Coalesce('col'), Coalesce('col2', 0), Sum('col3')).is_aggregate) + + with self.subTest('False when one of the arguments returns False for is_aggregate'): + self.assertEqual(False, Tuple(Field('col1'), Sum('col2')).is_aggregate) + + +class ArrayTests(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_array_general(self): + query = Query.from_(self.table_abc).select(Array(1, "a", ["b", 2, 3])) + + self.assertEqual("SELECT [1,'a',['b',2,3]] FROM \"abc\"", str(query)) + + def test_empty_psql_array(self): + query = PostgreSQLQuery.from_(self.table_abc).select(Array()) + + self.assertEqual("SELECT '{}' FROM \"abc\"", str(query)) + + def test_psql_array_general(self): + query = PostgreSQLQuery.from_(self.table_abc).select(Array(1, Array(2, 2, 2), 3)) + + self.assertEqual("SELECT ARRAY[1,ARRAY[2,2,2],3] FROM \"abc\"", str(query)) + + def test_render_alias_in_array_sql(self): + tb = Table("tb") + + q = Query.from_(tb).select(Array(tb.col).as_("different_name")) + self.assertEqual(str(q), 'SELECT ["col"] "different_name" FROM "tb"') + + +class BracketTests(unittest.TestCase): + table_abc, table_efg = Tables("abc", "efg") + + def test_arithmetic_with_brackets(self): + q = Query.from_(self.table_abc).select(Bracket(self.table_abc.foo / 2) / 2) + + self.assertEqual('SELECT ("foo"/2)/2 FROM "abc"', str(q)) + + def test_arithmetic_with_brackets_and_alias(self): + q = Query.from_(self.table_abc).select(Bracket(self.table_abc.foo / 2).as_("alias")) + + self.assertEqual('SELECT ("foo"/2) "alias" FROM "abc"', str(q)) diff --git a/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/test_updates.py b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/test_updates.py new file mode 100644 index 0000000000000000000000000000000000000000..fb9d714dbcb8213b4bda04bf7b8dd9b2419410ec --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/test_updates.py @@ -0,0 +1,162 @@ +import unittest + +from pypika import AliasedQuery, PostgreSQLQuery, Query, SQLLiteQuery, SYSTEM_TIME, Table + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + +from pypika.terms import Star + + +class UpdateTests(unittest.TestCase): + table_abc = Table("abc") + table_def = Table("def") + + def test_empty_query(self): + q = Query.update("abc") + + self.assertEqual("", str(q)) + + def test_omit_where(self): + q = Query.update(self.table_abc).set("foo", "bar") + + self.assertEqual('UPDATE "abc" SET "foo"=\'bar\'', str(q)) + + def test_single_quote_escape_in_set(self): + q = Query.update(self.table_abc).set("foo", "bar'foo") + + self.assertEqual("UPDATE \"abc\" SET \"foo\"='bar''foo'", str(q)) + + def test_update__table_schema(self): + table = Table("abc", "schema1") + q = Query.update(table).set(table.foo, 1).where(table.foo == 0) + + self.assertEqual('UPDATE "schema1"."abc" SET "foo"=1 WHERE "foo"=0', str(q)) + + def test_update_with_none(self): + q = Query.update("abc").set("foo", None) + self.assertEqual('UPDATE "abc" SET "foo"=null', str(q)) + + def test_update_with_join(self): + q = ( + Query.update(self.table_abc) + .join(self.table_def) + .on(self.table_def.abc_id == self.table_abc.id) + .set(self.table_abc.lname, self.table_def.lname) + ) + self.assertEqual( + 'UPDATE "abc" JOIN "def" ON "def"."abc_id"="abc"."id" SET "lname"="def"."lname"', + str(q), + ) + + def test_update_with_limit(self): + q = Query.update(self.table_abc).set(self.table_abc.lname, "test").limit(1) + self.assertEqual('UPDATE "abc" SET "lname"=\'test\' LIMIT 1', str(q)) + + def test_update_from(self): + from_table = Table('from_table') + + q = Query.update(self.table_abc).set(self.table_abc.lname, from_table.long_name).from_(from_table) + self.assertEqual('UPDATE "abc" SET "lname"="from_table"."long_name" FROM "from_table"', str(q)) + + def test_update_from_with_where(self): + from_table = Table('from_table') + + q = ( + Query.update(self.table_abc) + .set(self.table_abc.lname, from_table.long_name) + .from_(from_table) + .where(self.table_abc.fname.eq(from_table.full_name)) + ) + self.assertEqual( + 'UPDATE "abc" SET "lname"="from_table"."long_name" FROM "from_table" ' + 'WHERE "abc"."fname"="from_table"."full_name"', + str(q), + ) + + def test_update_with_statement(self): + table_efg = Table('efg') + + sub_query = Query.from_(table_efg).select("fizz") + an_alias = AliasedQuery("an_alias") + + q = ( + Query.with_(sub_query, "an_alias") + .update(self.table_abc) + .from_(an_alias) + .set(self.table_abc.lname, an_alias.long_name) + .where(self.table_abc.comp.eq(an_alias.alias_comp)) + ) + self.assertEqual( + 'WITH an_alias AS (SELECT "fizz" FROM "efg") ' + 'UPDATE "abc" SET "lname"="an_alias"."long_name" FROM an_alias ' + 'WHERE "abc"."comp"="an_alias"."alias_comp"', + str(q), + ) + + def test_for_portion(self): + with self.subTest("with system time"): + q = Query.update(self.table_abc.for_portion(SYSTEM_TIME.from_to('2020-01-01', '2020-02-01'))).set( + "foo", "bar" + ) + + self.assertEqual( + 'UPDATE "abc" FOR PORTION OF SYSTEM_TIME FROM \'2020-01-01\' TO \'2020-02-01\' SET "foo"=\'bar\'', + str(q), + ) + + with self.subTest("with column"): + q = Query.update( + self.table_abc.for_portion(self.table_abc.valid_period.from_to('2020-01-01', '2020-02-01')) + ).set("foo", "bar") + + self.assertEqual( + 'UPDATE "abc" FOR PORTION OF "valid_period" FROM \'2020-01-01\' TO \'2020-02-01\' SET "foo"=\'bar\'', + str(q), + ) + + +class PostgresUpdateTests(unittest.TestCase): + table_abc = Table("abc") + + def test_update_returning_str(self): + q = PostgreSQLQuery.update(self.table_abc).where(self.table_abc.foo == 0).set("foo", "bar").returning("id") + + self.assertEqual('UPDATE "abc" SET "foo"=\'bar\' WHERE "foo"=0 RETURNING "abc"."id"', str(q)) + + def test_update_returning(self): + q = ( + PostgreSQLQuery.update(self.table_abc) + .where(self.table_abc.foo == 0) + .set("foo", "bar") + .returning(self.table_abc.id) + ) + + self.assertEqual('UPDATE "abc" SET "foo"=\'bar\' WHERE "foo"=0 RETURNING "abc"."id"', str(q)) + + def test_update_returning_from_different_tables(self): + table_bcd = Table('bcd') + + q = ( + PostgreSQLQuery.update(self.table_abc) + .from_(table_bcd) + .set(self.table_abc.lname, table_bcd.long_name) + .returning(self.table_abc.id, table_bcd.fname) + ) + self.assertEqual( + 'UPDATE "abc" SET "lname"="bcd"."long_name" FROM "bcd" RETURNING "abc"."id","bcd"."fname"', str(q) + ) + + def test_update_returning_star(self): + q = PostgreSQLQuery.update(self.table_abc).where(self.table_abc.foo == 0).set("foo", "bar").returning(Star()) + + self.assertEqual('UPDATE "abc" SET "foo"=\'bar\' WHERE "foo"=0 RETURNING *', str(q)) + + +class SQLLiteUpdateTests(unittest.TestCase): + table_abc = Table("abc") + + def test_update_with_bool(self): + q = SQLLiteQuery.update(self.table_abc).set(self.table_abc.foo, True) + + self.assertEqual('UPDATE "abc" SET "foo"=1', str(q)) diff --git a/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/test_utils.py b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/test_utils.py new file mode 100644 index 0000000000000000000000000000000000000000..bb9a9b1c68fe8671989f7c49f9db90e389d06f59 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pypika/tests/test_utils.py @@ -0,0 +1,24 @@ +import unittest + +from pypika import utils + +__author__ = "Timothy Heys" +__email__ = "theys@kayak.com" + + +class ImmutabilityTests(unittest.TestCase): + def test_raise_attribute_error_for_deepcopy(self): + with self.assertRaises(AttributeError): + utils.raise_attribute_for_copy("Test", "__deepcopy__") + + def test_raise_attribute_error_for_getstate(self): + with self.assertRaises(AttributeError): + utils.raise_attribute_for_copy("Test", "__getstate__") + + def test_raise_attribute_error_for_setstate(self): + with self.assertRaises(AttributeError): + utils.raise_attribute_for_copy("Test", "__setstate__") + + def test_raise_attribute_error_for_getnewargs(self): + with self.assertRaises(AttributeError): + utils.raise_attribute_for_copy("Test", "__getnewargs__") diff --git a/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pyproject.toml b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pyproject.toml new file mode 100644 index 0000000000000000000000000000000000000000..dcc56baede23e3571b336625e695c466ab833a56 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/pyproject.toml @@ -0,0 +1,22 @@ +[tool.black] +line-length = 120 +skip-string-normalization = true +target-version = ['py38', 'py39', 'py310', 'py311'] +force-exclude = ''' +( + /( + \.eggs # exclude a few common directories in the + | \.git # root of the project + | \.hg + | \.mypy_cache + | \.tox + | \.venv + | _build + | buck-out + | build + | dist + | docs + )/ + | setup.py +) +''' diff --git a/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/setup.cfg b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/setup.cfg new file mode 100644 index 0000000000000000000000000000000000000000..46084aaf2ca9e95b2f9bb7680e432e637fc3ed90 --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/setup.cfg @@ -0,0 +1,16 @@ +[bumpversion] +current_version = 0.48.9 +commit = True +tag = True + +[bumpversion:file:pypika/__init__.py] +search = __version__ = "{current_version}" +replace = __version__ = "{new_version}" + +[bdist_wheel] +universal = 1 + +[flake8] +exclude = docs, .git, __pycache__ +max-line-length = 120 +per-file-ignores = __init__.py:F401 diff --git a/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/setup.py b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/setup.py new file mode 100644 index 0000000000000000000000000000000000000000..41cce7d742df3e33e8d76f267d77df486f69249a --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/setup.py @@ -0,0 +1,81 @@ +import ast + +from setuptools import setup + + +def readme(): + with open('README.rst', 'rb') as f: + return f.read().decode('UTF-8') + + +def version(): + path = 'pypika/__init__.py' + with open(path, 'r') as file: + t = compile(file.read(), path, 'exec', ast.PyCF_ONLY_AST) + for node in (n for n in t.body if isinstance(n, ast.Assign)): + if len(node.targets) == 1: + name = node.targets[0] + if isinstance(name, ast.Name) and name.id in ('__version__', '__version_info__', 'VERSION'): + v = node.value + if isinstance(v, ast.Str): + return v.s + + if isinstance(v, ast.Tuple): + r = [] + for e in v.elts: + if isinstance(e, ast.Str): + r.append(e.s) + elif isinstance(e, ast.Num): + r.append(str(e.n)) + return '.'.join(r) + + +setup( + # Application name: + name="PyPika", + + # Version number: + version=version(), + + # Application author details: + author="Timothy Heys", + author_email="theys@kayak.com", + + # License + license='Apache License Version 2.0', + + # Packages + packages=["pypika", "pypika.clickhouse"], + + # Include additional files into the package + package_data={"pypika": ["py.typed"]}, + include_package_data=True, + + install_requires=[], + + # Details + url="https://github.com/kayak/pypika", + + description="A SQL query builder API for Python", + long_description=readme(), + + classifiers=[ + 'License :: OSI Approved :: Apache Software License', + 'Development Status :: 5 - Production/Stable', + 'Intended Audience :: Developers', + 'Programming Language :: Python :: 3', + 'Programming Language :: PL/SQL', + 'Topic :: Software Development :: Libraries :: Python Modules', + 'Topic :: Scientific/Engineering :: Information Analysis', + 'Topic :: Scientific/Engineering :: Mathematics', + 'Operating System :: POSIX', + 'Operating System :: MacOS :: MacOS X', + 'Operating System :: Microsoft :: Windows', + ], + keywords=('pypika python query builder querybuilder sql mysql postgres psql oracle vertica aggregated ' + 'relational database rdbms business analytics bi data science analysis pandas ' + 'orm object mapper'), + + # Dependent packages (distributions) + test_suite="pypika.tests", +) diff --git a/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/tox.ini b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/tox.ini new file mode 100644 index 0000000000000000000000000000000000000000..2f0e6893243b1ca2ead6a12825e9014dc66364ce --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/tests/trusted/tox.ini @@ -0,0 +1,16 @@ +[tox] +envlist = py38,py39,py310,py311,pypy3 + +[testenv] +description = testing against {basepython} +deps = -r requirements-dev.txt +commands = + coverage run + coverage xml + +[gh-actions] +python = + 3.8: py38 + 3.9: py39 + 3.10: py310 + 3.11: py311 diff --git a/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/validation/canaries/original-bug.sh b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/validation/canaries/original-bug.sh new file mode 100644 index 0000000000000000000000000000000000000000..927547df786c86ab3bb5eeb917a31e0fa1895f8b --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/validation/canaries/original-bug.sh @@ -0,0 +1,3 @@ +#!/bin/bash +set -Eeuo pipefail +: diff --git a/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/validation/openenv.json b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/validation/openenv.json new file mode 100644 index 0000000000000000000000000000000000000000..a13b3c577df494f6c894584d2b608ab051ebc44f --- /dev/null +++ b/tasks/kayak__pypika.1c9646f0.func_basic__00jnvt3b/validation/openenv.json @@ -0,0 +1,27 @@ +{ + "canaries": "validation/canaries", + "profile": "harbor-semantic-v1", + "requires_credentials": false, + "resources": { + "cpu": 2, + "disk_mb": 16384, + "episode_timeout_s": 1800, + "memory_mb": 8192 + }, + "reward": { + "floor_margin": 0.1, + "oracle_tolerance": 0, + "range": [ + 0, + 1 + ] + }, + "reward_key": "reward", + "types": { + "tags": [ + "swe", + "python", + "mutation-repair" + ] + } +} diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/LICENSE.source b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/LICENSE.source new file mode 100644 index 0000000000000000000000000000000000000000..b141cdb9f3cb8010b9c3dfb392ff1a00db58a413 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/LICENSE.source @@ -0,0 +1,14 @@ +Copyright (c) 2014, Hsiaoming Yang + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + +* Neither the name of the creator nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/adapter.json b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/adapter.json new file mode 100644 index 0000000000000000000000000000000000000000..f5773fb935b12d7ae825f0278a01897753dd4415 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/adapter.json @@ -0,0 +1,131 @@ +{ + "canary_selection": "Fixed first provided gold hunk only when at least2hunks exist; strict subset, never reward-selected. Single-hunk task original-bug canary is explicitly NOP-equivalent and adds no signal beyond floor_gap.", + "collector_sha256": "352e555112f2de8a1393f939903e4971c9ace0e944843762b707a725c5c72481", + "dependency_installation_pinned": false, + "dependency_setup_sha256": "883d23539d00e744dc83da083548b6dd699be04238df34d5bd5b500a5dc53f28", + "gold_patch_sha256": "22b60e8883f2918169a3cd556762d4ec88511f2755703e07d40f3493927c1194", + "hostile_code_isolation_established": false, + "known_wrong_semantic_implementations": 0, + "native_inventory_sha256": "5c6846fbb912febbe19f0ecbbd87717d262c8e6c7ed9a7f0ec7aab2323c1f88f", + "new_files_deletions_and_executable_modes_supported": true, + "official_profile": { + "eval_sets": [], + "profile_class": "MistuneBf54ef67", + "profile_lines": [ + 570, + 573 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "bf54ef67390e02a5cdee7495d4386d7770c1902b", + "upstream_repo": "lepture/mistune" + }, + "original_bug_canary_nop_equivalent": true, + "original_bug_runtime_wrongness_established": false, + "partial_repair_canary": true, + "partial_repair_sha256": "bfd0483c8914f6d801200d7811fafd6b34eb295420c7d59b2f1927747f481b25", + "partial_repair_wrongness_established": false, + "positive_approval_policy": "All original strict presence/identity/no-skip/no-error/exit checks retained", + "private_checker_sha256": "f0a641064b725415e23a0221bb53c90446d7efcb7f9ece5ede93a220d18dd9e7", + "private_checker_version": "matched-failure-precedence-v2", + "provided_original_bug_control": true, + "repo_url": "https://github.com/swesmith/lepture__mistune.bf54ef67.git", + "runtime_image": null, + "runtime_ready": false, + "runtime_recipe": { + "dependency_installation_pinned": false, + "official_install_cmds": [ + "python -m pip install -e ." + ], + "official_pytest_argv": [ + "pytest", + "--disable-warnings", + "--color=no", + "--tb=no", + "--verbose" + ], + "official_test_command": "source /opt/miniconda3/bin/activate; conda activate testbed; pytest --disable-warnings --color=no --tb=no --verbose", + "operator_test_runner_prerequisites": [ + "python -m pip install pytest==8.4.2" + ], + "operator_test_runner_reason": "The official profile invokes pytest, but the common tools runtime does not provide it; pinned separately from source-native project requirements.", + "panel_normalization": "Override project addopts only to execute the exact frozen native panels; add JUnit output, preserve official pytest options and all selectors.", + "python_version": "3.10", + "source_bound_test_dependency_cmds": [], + "test_dependency_source_sha256": { + "pyproject.toml": "b2922e3ef89e2918935d38fb3a777bdbc741619942276a75fd21a8dd9faf6b42" + } + }, + "runtime_resource_review_required": false, + "schema": "python-git-patch-jobs-v1", + "source_base_commit": "4d6d7dec37acc043e6beb19ab0a4d114fb76b1c2", + "source_completion_sha256": "331de350de24ec13b79543d31a26b66305abc60701a8296fb245092aa868606e", + "source_index_sha256": "e3ea2fb9bd6c335cdb937a3a8cd4fe62a1ee4e9a65ba1e0deeeb395c0103fde1", + "source_pr_url": null, + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:lepture__mistune.bf54ef67.combine_file__01ys6r85", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "62750c95db25a8fb93dda09242f64e07508d9231", + "instruction_sha256": "594c53bc148e4b4ea23cb1cf09bfc5c5c0d499e2ff41a0c7dd23a0f213a819da", + "is_fork": true, + "learner_path": "tasks/a658c0a0037cef2b90f345da/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "bf54ef67390e02a5cdee7495d4386d7770c1902b", + "actual_upstream_url": "https://raw.githubusercontent.com/lepture/mistune/bf54ef67390e02a5cdee7495d4386d7770c1902b/LICENSE", + "reviewed": true, + "sha256": "539013fd8e19f744f8bf0e27a532bbff54cd689ecef7a800f56ae5dc824be870", + "spdx": "BSD-3-Clause", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/lepture__mistune.bf54ef67/4d6d7dec37acc043e6beb19ab0a4d114fb76b1c2/LICENSE" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "bf54ef67390e02a5cdee7495d4386d7770c1902b", + "patch_sha256": "138645f5b5f0f36dd7db653b27103a2e69131c814ed4ccd2a2b4d1fb450083b0", + "provenance_path": "tasks/a658c0a0037cef2b90f345da/source-proof.json", + "repository_lineage": [ + "swesmith/lepture__mistune.bf54ef67", + "lepture/mistune" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "4d6d7dec37acc043e6beb19ab0a4d114fb76b1c2", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "44bbd1b0606511e7d54205d2cd4917eba8d67515", + "source_kind": "mutation", + "source_repo": "swesmith/lepture__mistune.bf54ef67", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "lepture__mistune.bf54ef67.combine_file__01ys6r85", + "task_sha256": "376e90643984f215a7c3c7f28a11ae36f61ea5e906b723ac34e4247f4de01f88", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "lepture/mistune", + "usage": "quarantine_only" + }, + "source_repo": "swesmith/lepture__mistune.bf54ef67", + "symlink_submodule_changes_supported": false, + "task_id": "lepture__mistune.bf54ef67.combine_file__01ys6r85", + "transfer": "index-independent-worktree-to-Git-binary-patch", + "transfer_path": "/testbed/submission.patch", + "upstream_repo": "lepture/mistune" +} diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/dependency-setup.sh b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/dependency-setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..551d5bb0d87bd3b22dd7098dddea7e0794a2ab40 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/dependency-setup.sh @@ -0,0 +1,8 @@ +#!/bin/bash +set -Eeuo pipefail +source /opt/miniconda3/bin/activate +conda activate testbed +cd /testbed/repo +python -c 'import sys; assert sys.version_info[:2] == (3, 10)' +python -m pip install pytest==8.4.2 +python -m pip install -e . diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/environment/Dockerfile b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..a59b58c2ea8217c78c1e39b4678f93c8c0023bcd --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/environment/Dockerfile @@ -0,0 +1,3 @@ +# Runtime is selected only by an independently qualified immutable amd64 receipt. +FROM ubuntu:22.04 +RUN false diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/instruction.md b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..00cb7fdbd6a3e75f495a36852a4cdf1907be1148 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/instruction.md @@ -0,0 +1,35 @@ +Definition list plugin broken after recent changes + +#### Description + +The definition list plugin is completely broken and fails to parse definition lists correctly. When trying to render markdown with definition lists, the parser throws errors and produces incorrect output. + +#### Steps/Code to Reproduce + +```python +import mistune +from mistune.plugins.def_list import def_list + +# Create markdown with definition list +markdown_text = """ +Apple +: Pomaceous fruit of plants of the genus Malus in + the family Rosaceae. + +Orange +: The fruit of an evergreen tree of the genus Citrus. +""" + +# Try to parse with def_list plugin +md = mistune.create_markdown(plugins=[def_list]) +result = md(markdown_text) +print(result) +``` + +This should produce proper HTML definition list output with `
`, `
`, and `
` tags, but instead it fails to parse correctly. + +The issue seems to affect all definition list parsing functionality - simple single-line definitions, multi-line definitions, and complex nested structures all fail to work properly. + +## Environment + +The repository is at `/testbed/repo`. Its dependencies, including pytest, are installed in the `testbed` conda environment, which comes first on PATH. If `python -m pytest` reports that pytest is missing, use the full interpreter path: `/opt/miniconda3/envs/testbed/bin/python -m pytest `. Don't install packages: the tests need nothing else, and the sandbox may have no network access. diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/metadata.json b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/metadata.json new file mode 100644 index 0000000000000000000000000000000000000000..1a8a852365fe7c7cc381901d6716eb8d91f88b09 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/metadata.json @@ -0,0 +1,1190 @@ +{ + "all_runtime_and_training_flags": false, + "official_profile": { + "eval_sets": [], + "profile_class": "MistuneBf54ef67", + "profile_lines": [ + 570, + 573 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "bf54ef67390e02a5cdee7495d4386d7770c1902b", + "upstream_repo": "lepture/mistune" + }, + "source_healthy_reference_proof": { + "FAIL_TO_PASS": [ + "tests/test_plugins.py::TestPlugin1_def_list::test_definition_lists_001", + "tests/test_plugins.py::TestPlugin1_def_list::test_definition_lists_002", + "tests/test_plugins.py::TestPlugin1_def_list::test_definition_lists_003", + "tests/test_plugins.py::TestPlugin1_def_list::test_definition_lists_004", + "tests/test_plugins.py::TestPlugin1_def_list::test_definition_lists_005", + "tests/test_plugins.py::TestPlugin1_def_list::test_definition_lists_006", + "tests/test_plugins.py::TestPlugin1_def_list::test_definition_with_multiple_lines_001", + "tests/test_plugins.py::TestPlugin1_def_list::test_definition_with_multiple_lines_002", + "tests/test_plugins.py::TestPlugin1_def_list::test_definition_with_multiple_lines_003", + "tests/test_plugins.py::TestPlugin1_def_list::test_definition_with_multiple_lines_004", + "tests/test_plugins.py::TestPlugin1_def_list::test_definition_with_multiple_lines_005", + "tests/test_plugins.py::TestPlugin2_def_list::test_definition_lists_001", + "tests/test_plugins.py::TestPlugin2_def_list::test_definition_lists_002", + "tests/test_plugins.py::TestPlugin2_def_list::test_definition_lists_003", + "tests/test_plugins.py::TestPlugin2_def_list::test_definition_lists_004", + "tests/test_plugins.py::TestPlugin2_def_list::test_definition_lists_005", + "tests/test_plugins.py::TestPlugin2_def_list::test_definition_lists_006", + "tests/test_plugins.py::TestPlugin2_def_list::test_definition_with_multiple_lines_001", + "tests/test_plugins.py::TestPlugin2_def_list::test_definition_with_multiple_lines_002", + "tests/test_plugins.py::TestPlugin2_def_list::test_definition_with_multiple_lines_003", + "tests/test_plugins.py::TestPlugin2_def_list::test_definition_with_multiple_lines_004", + "tests/test_plugins.py::TestPlugin2_def_list::test_definition_with_multiple_lines_005" + ], + "PASS_TO_PASS": [ + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_062", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_063", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_064", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_065", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_066", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_067", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_068", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_069", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_070", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_071", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_072", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_073", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_074", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_075", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_076", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_077", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_078", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_079", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_593", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_594", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_595", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_596", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_597", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_598", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_599", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_600", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_601", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_602", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_603", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_604", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_605", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_606", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_607", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_608", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_609", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_610", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_611", + "tests/test_commonmark.py::TestCommonMark::test_backslash_escapes_012", + "tests/test_commonmark.py::TestCommonMark::test_backslash_escapes_013", + "tests/test_commonmark.py::TestCommonMark::test_backslash_escapes_014", + "tests/test_commonmark.py::TestCommonMark::test_backslash_escapes_015", + "tests/test_commonmark.py::TestCommonMark::test_backslash_escapes_016", + "tests/test_commonmark.py::TestCommonMark::test_backslash_escapes_017", + "tests/test_commonmark.py::TestCommonMark::test_backslash_escapes_018", + "tests/test_commonmark.py::TestCommonMark::test_backslash_escapes_019", + "tests/test_commonmark.py::TestCommonMark::test_backslash_escapes_020", + "tests/test_commonmark.py::TestCommonMark::test_backslash_escapes_021", + "tests/test_commonmark.py::TestCommonMark::test_backslash_escapes_022", + "tests/test_commonmark.py::TestCommonMark::test_backslash_escapes_023", + "tests/test_commonmark.py::TestCommonMark::test_backslash_escapes_024", + "tests/test_commonmark.py::TestCommonMark::test_blank_lines_227", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_228", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_229", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_230", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_231", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_232", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_233", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_234", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_235", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_236", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_237", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_238", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_239", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_240", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_241", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_242", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_243", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_244", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_245", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_246", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_247", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_248", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_249", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_250", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_251", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_252", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_328", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_329", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_330", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_331", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_332", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_333", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_334", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_335", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_336", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_337", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_338", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_339", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_340", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_341", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_342", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_343", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_344", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_345", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_346", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_347", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_348", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_349", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_350", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_351", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_353", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_354", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_355", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_356", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_357", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_358", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_359", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_360", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_361", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_362", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_363", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_364", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_365", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_366", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_369", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_370", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_371", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_373", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_374", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_375", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_376", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_377", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_378", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_380", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_381", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_382", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_383", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_384", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_385", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_386", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_387", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_389", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_390", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_392", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_393", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_394", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_395", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_396", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_397", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_398", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_399", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_400", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_401", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_402", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_403", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_404", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_405", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_409", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_410", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_411", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_415", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_419", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_420", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_421", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_422", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_423", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_427", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_428", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_432", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_433", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_434", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_435", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_436", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_437", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_438", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_439", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_440", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_447", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_448", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_449", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_450", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_451", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_452", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_459", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_461", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_466", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_468", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_469", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_472", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_473", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_474", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_475", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_476", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_479", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_480", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_025", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_026", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_027", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_028", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_029", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_030", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_031", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_032", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_033", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_034", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_035", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_036", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_037", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_038", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_039", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_040", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_041", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_119", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_120", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_121", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_122", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_123", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_124", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_125", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_126", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_127", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_128", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_129", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_130", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_131", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_132", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_133", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_134", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_135", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_136", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_137", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_138", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_139", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_140", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_141", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_142", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_143", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_144", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_145", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_146", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_147", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_633", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_634", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_635", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_636", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_637", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_638", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_639", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_640", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_641", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_642", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_643", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_644", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_645", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_646", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_647", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_148", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_149", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_150", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_151", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_152", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_153", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_154", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_155", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_156", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_157", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_158", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_159", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_160", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_161", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_162", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_163", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_164", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_165", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_166", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_167", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_168", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_169", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_170", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_171", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_172", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_173", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_174", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_175", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_176", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_177", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_178", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_179", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_180", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_181", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_182", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_183", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_184", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_185", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_186", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_187", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_188", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_189", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_190", + "tests/test_commonmark.py::TestCommonMark::test_images_571", + "tests/test_commonmark.py::TestCommonMark::test_images_572", + "tests/test_commonmark.py::TestCommonMark::test_images_574", + "tests/test_commonmark.py::TestCommonMark::test_images_575", + "tests/test_commonmark.py::TestCommonMark::test_images_576", + "tests/test_commonmark.py::TestCommonMark::test_images_577", + "tests/test_commonmark.py::TestCommonMark::test_images_578", + "tests/test_commonmark.py::TestCommonMark::test_images_579", + "tests/test_commonmark.py::TestCommonMark::test_images_580", + "tests/test_commonmark.py::TestCommonMark::test_images_581", + "tests/test_commonmark.py::TestCommonMark::test_images_582", + "tests/test_commonmark.py::TestCommonMark::test_images_583", + "tests/test_commonmark.py::TestCommonMark::test_images_584", + "tests/test_commonmark.py::TestCommonMark::test_images_585", + "tests/test_commonmark.py::TestCommonMark::test_images_586", + "tests/test_commonmark.py::TestCommonMark::test_images_587", + "tests/test_commonmark.py::TestCommonMark::test_images_588", + "tests/test_commonmark.py::TestCommonMark::test_images_589", + "tests/test_commonmark.py::TestCommonMark::test_images_590", + "tests/test_commonmark.py::TestCommonMark::test_images_591", + "tests/test_commonmark.py::TestCommonMark::test_images_592", + "tests/test_commonmark.py::TestCommonMark::test_indented_code_blocks_107", + "tests/test_commonmark.py::TestCommonMark::test_indented_code_blocks_108", + "tests/test_commonmark.py::TestCommonMark::test_indented_code_blocks_109", + "tests/test_commonmark.py::TestCommonMark::test_indented_code_blocks_110", + "tests/test_commonmark.py::TestCommonMark::test_indented_code_blocks_111", + "tests/test_commonmark.py::TestCommonMark::test_indented_code_blocks_112", + "tests/test_commonmark.py::TestCommonMark::test_indented_code_blocks_113", + "tests/test_commonmark.py::TestCommonMark::test_indented_code_blocks_114", + "tests/test_commonmark.py::TestCommonMark::test_indented_code_blocks_115", + "tests/test_commonmark.py::TestCommonMark::test_indented_code_blocks_116", + "tests/test_commonmark.py::TestCommonMark::test_indented_code_blocks_117", + "tests/test_commonmark.py::TestCommonMark::test_indented_code_blocks_118", + "tests/test_commonmark.py::TestCommonMark::test_inlines_327", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_192", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_193", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_194", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_195", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_196", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_197", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_198", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_199", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_200", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_201", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_202", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_203", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_204", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_205", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_206", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_207", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_208", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_209", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_210", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_211", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_212", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_213", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_214", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_215", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_216", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_217", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_218", + "tests/test_commonmark.py::TestCommonMark::test_links_481", + "tests/test_commonmark.py::TestCommonMark::test_links_482", + "tests/test_commonmark.py::TestCommonMark::test_links_483", + "tests/test_commonmark.py::TestCommonMark::test_links_484", + "tests/test_commonmark.py::TestCommonMark::test_links_485", + "tests/test_commonmark.py::TestCommonMark::test_links_486", + "tests/test_commonmark.py::TestCommonMark::test_links_487", + "tests/test_commonmark.py::TestCommonMark::test_links_488", + "tests/test_commonmark.py::TestCommonMark::test_links_489", + "tests/test_commonmark.py::TestCommonMark::test_links_490", + "tests/test_commonmark.py::TestCommonMark::test_links_491", + "tests/test_commonmark.py::TestCommonMark::test_links_492", + "tests/test_commonmark.py::TestCommonMark::test_links_493", + "tests/test_commonmark.py::TestCommonMark::test_links_494", + "tests/test_commonmark.py::TestCommonMark::test_links_497", + "tests/test_commonmark.py::TestCommonMark::test_links_498", + "tests/test_commonmark.py::TestCommonMark::test_links_499", + "tests/test_commonmark.py::TestCommonMark::test_links_500", + "tests/test_commonmark.py::TestCommonMark::test_links_501", + "tests/test_commonmark.py::TestCommonMark::test_links_502", + "tests/test_commonmark.py::TestCommonMark::test_links_503", + "tests/test_commonmark.py::TestCommonMark::test_links_505", + "tests/test_commonmark.py::TestCommonMark::test_links_506", + "tests/test_commonmark.py::TestCommonMark::test_links_507", + "tests/test_commonmark.py::TestCommonMark::test_links_508", + "tests/test_commonmark.py::TestCommonMark::test_links_509", + "tests/test_commonmark.py::TestCommonMark::test_links_510", + "tests/test_commonmark.py::TestCommonMark::test_links_511", + "tests/test_commonmark.py::TestCommonMark::test_links_512", + "tests/test_commonmark.py::TestCommonMark::test_links_513", + "tests/test_commonmark.py::TestCommonMark::test_links_514", + "tests/test_commonmark.py::TestCommonMark::test_links_515", + "tests/test_commonmark.py::TestCommonMark::test_links_516", + "tests/test_commonmark.py::TestCommonMark::test_links_520", + "tests/test_commonmark.py::TestCommonMark::test_links_521", + "tests/test_commonmark.py::TestCommonMark::test_links_522", + "tests/test_commonmark.py::TestCommonMark::test_links_523", + "tests/test_commonmark.py::TestCommonMark::test_links_524", + "tests/test_commonmark.py::TestCommonMark::test_links_525", + "tests/test_commonmark.py::TestCommonMark::test_links_526", + "tests/test_commonmark.py::TestCommonMark::test_links_527", + "tests/test_commonmark.py::TestCommonMark::test_links_528", + "tests/test_commonmark.py::TestCommonMark::test_links_529", + "tests/test_commonmark.py::TestCommonMark::test_links_530", + "tests/test_commonmark.py::TestCommonMark::test_links_533", + "tests/test_commonmark.py::TestCommonMark::test_links_534", + "tests/test_commonmark.py::TestCommonMark::test_links_535", + "tests/test_commonmark.py::TestCommonMark::test_links_536", + "tests/test_commonmark.py::TestCommonMark::test_links_537", + "tests/test_commonmark.py::TestCommonMark::test_links_538", + "tests/test_commonmark.py::TestCommonMark::test_links_539", + "tests/test_commonmark.py::TestCommonMark::test_links_540", + "tests/test_commonmark.py::TestCommonMark::test_links_541", + "tests/test_commonmark.py::TestCommonMark::test_links_542", + "tests/test_commonmark.py::TestCommonMark::test_links_543", + "tests/test_commonmark.py::TestCommonMark::test_links_544", + "tests/test_commonmark.py::TestCommonMark::test_links_545", + "tests/test_commonmark.py::TestCommonMark::test_links_546", + "tests/test_commonmark.py::TestCommonMark::test_links_547", + "tests/test_commonmark.py::TestCommonMark::test_links_548", + "tests/test_commonmark.py::TestCommonMark::test_links_549", + "tests/test_commonmark.py::TestCommonMark::test_links_550", + "tests/test_commonmark.py::TestCommonMark::test_links_551", + "tests/test_commonmark.py::TestCommonMark::test_links_552", + "tests/test_commonmark.py::TestCommonMark::test_links_553", + "tests/test_commonmark.py::TestCommonMark::test_links_554", + "tests/test_commonmark.py::TestCommonMark::test_links_555", + "tests/test_commonmark.py::TestCommonMark::test_links_556", + "tests/test_commonmark.py::TestCommonMark::test_links_557", + "tests/test_commonmark.py::TestCommonMark::test_links_558", + "tests/test_commonmark.py::TestCommonMark::test_links_559", + "tests/test_commonmark.py::TestCommonMark::test_links_560", + "tests/test_commonmark.py::TestCommonMark::test_links_561", + "tests/test_commonmark.py::TestCommonMark::test_links_562", + "tests/test_commonmark.py::TestCommonMark::test_links_563", + "tests/test_commonmark.py::TestCommonMark::test_links_564", + "tests/test_commonmark.py::TestCommonMark::test_links_565", + "tests/test_commonmark.py::TestCommonMark::test_links_566", + "tests/test_commonmark.py::TestCommonMark::test_links_567", + "tests/test_commonmark.py::TestCommonMark::test_links_568", + "tests/test_commonmark.py::TestCommonMark::test_links_569", + "tests/test_commonmark.py::TestCommonMark::test_links_570", + "tests/test_commonmark.py::TestCommonMark::test_list_items_253", + "tests/test_commonmark.py::TestCommonMark::test_list_items_254", + "tests/test_commonmark.py::TestCommonMark::test_list_items_255", + "tests/test_commonmark.py::TestCommonMark::test_list_items_256", + "tests/test_commonmark.py::TestCommonMark::test_list_items_257", + "tests/test_commonmark.py::TestCommonMark::test_list_items_258", + "tests/test_commonmark.py::TestCommonMark::test_list_items_259", + "tests/test_commonmark.py::TestCommonMark::test_list_items_260", + "tests/test_commonmark.py::TestCommonMark::test_list_items_261", + "tests/test_commonmark.py::TestCommonMark::test_list_items_262", + "tests/test_commonmark.py::TestCommonMark::test_list_items_263", + "tests/test_commonmark.py::TestCommonMark::test_list_items_264", + "tests/test_commonmark.py::TestCommonMark::test_list_items_265", + "tests/test_commonmark.py::TestCommonMark::test_list_items_266", + "tests/test_commonmark.py::TestCommonMark::test_list_items_267", + "tests/test_commonmark.py::TestCommonMark::test_list_items_268", + "tests/test_commonmark.py::TestCommonMark::test_list_items_269", + "tests/test_commonmark.py::TestCommonMark::test_list_items_270", + "tests/test_commonmark.py::TestCommonMark::test_list_items_271", + "tests/test_commonmark.py::TestCommonMark::test_list_items_272", + "tests/test_commonmark.py::TestCommonMark::test_list_items_273", + "tests/test_commonmark.py::TestCommonMark::test_list_items_274", + "tests/test_commonmark.py::TestCommonMark::test_list_items_275", + "tests/test_commonmark.py::TestCommonMark::test_list_items_276", + "tests/test_commonmark.py::TestCommonMark::test_list_items_277", + "tests/test_commonmark.py::TestCommonMark::test_list_items_278", + "tests/test_commonmark.py::TestCommonMark::test_list_items_279", + "tests/test_commonmark.py::TestCommonMark::test_list_items_280", + "tests/test_commonmark.py::TestCommonMark::test_list_items_281", + "tests/test_commonmark.py::TestCommonMark::test_list_items_282", + "tests/test_commonmark.py::TestCommonMark::test_list_items_283", + "tests/test_commonmark.py::TestCommonMark::test_list_items_284", + "tests/test_commonmark.py::TestCommonMark::test_list_items_285", + "tests/test_commonmark.py::TestCommonMark::test_list_items_286", + "tests/test_commonmark.py::TestCommonMark::test_list_items_287", + "tests/test_commonmark.py::TestCommonMark::test_list_items_288", + "tests/test_commonmark.py::TestCommonMark::test_list_items_289", + "tests/test_commonmark.py::TestCommonMark::test_list_items_290", + "tests/test_commonmark.py::TestCommonMark::test_list_items_291", + "tests/test_commonmark.py::TestCommonMark::test_list_items_292", + "tests/test_commonmark.py::TestCommonMark::test_list_items_293", + "tests/test_commonmark.py::TestCommonMark::test_list_items_294", + "tests/test_commonmark.py::TestCommonMark::test_list_items_295", + "tests/test_commonmark.py::TestCommonMark::test_list_items_296", + "tests/test_commonmark.py::TestCommonMark::test_list_items_297", + "tests/test_commonmark.py::TestCommonMark::test_list_items_298", + "tests/test_commonmark.py::TestCommonMark::test_list_items_299", + "tests/test_commonmark.py::TestCommonMark::test_list_items_300", + "tests/test_commonmark.py::TestCommonMark::test_lists_301", + "tests/test_commonmark.py::TestCommonMark::test_lists_302", + "tests/test_commonmark.py::TestCommonMark::test_lists_303", + "tests/test_commonmark.py::TestCommonMark::test_lists_304", + "tests/test_commonmark.py::TestCommonMark::test_lists_305", + "tests/test_commonmark.py::TestCommonMark::test_lists_306", + "tests/test_commonmark.py::TestCommonMark::test_lists_307", + "tests/test_commonmark.py::TestCommonMark::test_lists_308", + "tests/test_commonmark.py::TestCommonMark::test_lists_309", + "tests/test_commonmark.py::TestCommonMark::test_lists_310", + "tests/test_commonmark.py::TestCommonMark::test_lists_311", + "tests/test_commonmark.py::TestCommonMark::test_lists_312", + "tests/test_commonmark.py::TestCommonMark::test_lists_313", + "tests/test_commonmark.py::TestCommonMark::test_lists_314", + "tests/test_commonmark.py::TestCommonMark::test_lists_315", + "tests/test_commonmark.py::TestCommonMark::test_lists_316", + "tests/test_commonmark.py::TestCommonMark::test_lists_317", + "tests/test_commonmark.py::TestCommonMark::test_lists_318", + "tests/test_commonmark.py::TestCommonMark::test_lists_319", + "tests/test_commonmark.py::TestCommonMark::test_lists_320", + "tests/test_commonmark.py::TestCommonMark::test_lists_321", + "tests/test_commonmark.py::TestCommonMark::test_lists_322", + "tests/test_commonmark.py::TestCommonMark::test_lists_323", + "tests/test_commonmark.py::TestCommonMark::test_lists_324", + "tests/test_commonmark.py::TestCommonMark::test_lists_325", + "tests/test_commonmark.py::TestCommonMark::test_lists_326", + "tests/test_commonmark.py::TestCommonMark::test_paragraphs_219", + "tests/test_commonmark.py::TestCommonMark::test_paragraphs_220", + "tests/test_commonmark.py::TestCommonMark::test_paragraphs_221", + "tests/test_commonmark.py::TestCommonMark::test_paragraphs_222", + "tests/test_commonmark.py::TestCommonMark::test_paragraphs_223", + "tests/test_commonmark.py::TestCommonMark::test_paragraphs_224", + "tests/test_commonmark.py::TestCommonMark::test_paragraphs_225", + "tests/test_commonmark.py::TestCommonMark::test_paragraphs_226", + "tests/test_commonmark.py::TestCommonMark::test_precedence_042", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_612", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_613", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_614", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_615", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_616", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_617", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_618", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_619", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_620", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_621", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_622", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_623", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_624", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_625", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_626", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_627", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_628", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_629", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_630", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_631", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_632", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_080", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_081", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_082", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_083", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_084", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_085", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_086", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_087", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_088", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_089", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_090", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_091", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_092", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_094", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_095", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_096", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_097", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_098", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_099", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_100", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_101", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_102", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_103", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_104", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_105", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_106", + "tests/test_commonmark.py::TestCommonMark::test_soft_line_breaks_648", + "tests/test_commonmark.py::TestCommonMark::test_soft_line_breaks_649", + "tests/test_commonmark.py::TestCommonMark::test_tabs_001", + "tests/test_commonmark.py::TestCommonMark::test_tabs_002", + "tests/test_commonmark.py::TestCommonMark::test_tabs_003", + "tests/test_commonmark.py::TestCommonMark::test_tabs_004", + "tests/test_commonmark.py::TestCommonMark::test_tabs_005", + "tests/test_commonmark.py::TestCommonMark::test_tabs_006", + "tests/test_commonmark.py::TestCommonMark::test_tabs_007", + "tests/test_commonmark.py::TestCommonMark::test_tabs_008", + "tests/test_commonmark.py::TestCommonMark::test_tabs_009", + "tests/test_commonmark.py::TestCommonMark::test_tabs_010", + "tests/test_commonmark.py::TestCommonMark::test_tabs_011", + "tests/test_commonmark.py::TestCommonMark::test_textual_content_650", + "tests/test_commonmark.py::TestCommonMark::test_textual_content_651", + "tests/test_commonmark.py::TestCommonMark::test_textual_content_652", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_043", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_044", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_045", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_046", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_047", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_048", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_049", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_050", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_051", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_052", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_053", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_054", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_055", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_056", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_057", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_058", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_059", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_060", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_061", + "tests/test_directives.py::TestDirective_rst_admonition::test_admonition_001", + "tests/test_directives.py::TestDirective_rst_admonition::test_admonition_002", + "tests/test_directives.py::TestDirective_rst_admonition::test_admonition_003", + "tests/test_directives.py::TestDirective_rst_admonition::test_admonition_004", + "tests/test_directives.py::TestDirective_rst_toc::test_collapse_toc_001", + "tests/test_directives.py::TestDirective_rst_toc::test_complex_001", + "tests/test_directives.py::TestDirective_rst_toc::test_html_in_heading_001", + "tests/test_directives.py::TestDirective_rst_toc::test_insane_001", + "tests/test_directives.py::TestDirective_rst_toc::test_insane_002", + "tests/test_directives.py::TestDirective_rst_toc::test_invalid_option_001", + "tests/test_directives.py::TestDirective_rst_toc::test_invalid_option_002", + "tests/test_directives.py::TestDirective_rst_toc::test_invalid_option_003", + "tests/test_directives.py::TestDirective_rst_toc::test_link_in_heading_001", + "tests/test_directives.py::TestDirective_rst_toc::test_no_toc_001", + "tests/test_directives.py::TestDirective_rst_toc::test_no_toc_002", + "tests/test_directives.py::TestDirective_rst_toc::test_simple_toc_001", + "tests/test_directives.py::TestDirective_fenced_admonition::test_admonition_001", + "tests/test_directives.py::TestDirective_fenced_admonition::test_admonition_002", + "tests/test_directives.py::TestDirective_fenced_admonition::test_admonition_003", + "tests/test_directives.py::TestDirective_fenced_admonition::test_admonition_004", + "tests/test_directives.py::TestDirective_fenced_admonition::test_admonition_005", + "tests/test_directives.py::TestDirective_fenced_admonition::test_admonition_006", + "tests/test_directives.py::TestDirective_fenced_admonition::test_admonition_007", + "tests/test_directives.py::TestDirective_fenced_admonition::test_admonition_008", + "tests/test_directives.py::TestDirective_fenced_toc::test_collapse_toc_001", + "tests/test_directives.py::TestDirective_fenced_toc::test_complex_001", + "tests/test_directives.py::TestDirective_fenced_toc::test_html_in_heading_001", + "tests/test_directives.py::TestDirective_fenced_toc::test_insane_001", + "tests/test_directives.py::TestDirective_fenced_toc::test_insane_002", + "tests/test_directives.py::TestDirective_fenced_toc::test_invalid_option_001", + "tests/test_directives.py::TestDirective_fenced_toc::test_invalid_option_002", + "tests/test_directives.py::TestDirective_fenced_toc::test_invalid_option_003", + "tests/test_directives.py::TestDirective_fenced_toc::test_link_in_heading_001", + "tests/test_directives.py::TestDirective_fenced_toc::test_no_toc_001", + "tests/test_directives.py::TestDirective_fenced_toc::test_no_toc_002", + "tests/test_directives.py::TestDirective_fenced_toc::test_simple_toc_001", + "tests/test_directives.py::TestDirective_fenced_image::test_align_options_001", + "tests/test_directives.py::TestDirective_fenced_image::test_align_options_002", + "tests/test_directives.py::TestDirective_fenced_image::test_all_options_001", + "tests/test_directives.py::TestDirective_fenced_image::test_alt_option_001", + "tests/test_directives.py::TestDirective_fenced_image::test_ampersand_in_source_001", + "tests/test_directives.py::TestDirective_fenced_image::test_ampersand_in_target_001", + "tests/test_directives.py::TestDirective_fenced_image::test_no_options_001", + "tests/test_directives.py::TestDirective_fenced_image::test_target_option_001", + "tests/test_directives.py::TestDirective_fenced_image::test_width_and_height_001", + "tests/test_directives.py::TestDirective_fenced_image::test_width_and_height_002", + "tests/test_directives.py::TestDirective_fenced_figure::test_align_options_001", + "tests/test_directives.py::TestDirective_fenced_figure::test_align_options_002", + "tests/test_directives.py::TestDirective_fenced_figure::test_all_options_001", + "tests/test_directives.py::TestDirective_fenced_figure::test_alt_option_001", + "tests/test_directives.py::TestDirective_fenced_figure::test_caption_001", + "tests/test_directives.py::TestDirective_fenced_figure::test_legend_001", + "tests/test_directives.py::TestDirective_fenced_figure::test_legend_002", + "tests/test_directives.py::TestDirective_fenced_figure::test_no_options_001", + "tests/test_directives.py::TestDirective_fenced_figure::test_target_option_001", + "tests/test_directives.py::TestDirective_fenced_figure::test_width_and_height_001", + "tests/test_directives.py::TestDirective_fenced_figure::test_width_and_height_002", + "tests/test_directives.py::TestDirective_fenced_figure::test_width_and_height_003", + "tests/test_directives.py::TestCustomizeToc::test_colon_fenced_toc", + "tests/test_directives.py::TestCustomizeToc::test_fenced_toc", + "tests/test_directives.py::TestCustomizeToc::test_rst_toc", + "tests/test_directives.py::TestDirectiveInclude::test_html_include", + "tests/test_directives.py::TestDirectiveInclude::test_include_missing_source", + "tests/test_hooks.py::TestTocHook::test_complex_toc_001", + "tests/test_hooks.py::TestTocHook::test_customize_heading_id_func", + "tests/test_hooks.py::TestTocHook::test_html_in_heading_001", + "tests/test_hooks.py::TestTocHook::test_insane_toc_001", + "tests/test_hooks.py::TestTocHook::test_insane_toc_002", + "tests/test_hooks.py::TestTocHook::test_link_in_heading_001", + "tests/test_hooks.py::TestTocHook::test_simple_toc_001", + "tests/test_misc.py::TestMiscCases::test_allow_data_protocols", + "tests/test_misc.py::TestMiscCases::test_allow_harmful_protocols", + "tests/test_misc.py::TestMiscCases::test_ast_output", + "tests/test_misc.py::TestMiscCases::test_ast_url", + "tests/test_misc.py::TestMiscCases::test_before_parse_hooks", + "tests/test_misc.py::TestMiscCases::test_emsp", + "tests/test_misc.py::TestMiscCases::test_escape_html", + "tests/test_misc.py::TestMiscCases::test_hard_wrap", + "tests/test_misc.py::TestMiscCases::test_harmful_links", + "tests/test_misc.py::TestMiscCases::test_html_tag_text_following_list", + "tests/test_misc.py::TestMiscCases::test_markdown_func", + "tests/test_misc.py::TestMiscCases::test_none", + "tests/test_misc.py::TestMiscCases::test_ref_link", + "tests/test_misc.py::TestMiscCases::test_use_plugin", + "tests/test_plugins.py::TestPlugin1_url::test_url_plugin_001", + "tests/test_plugins.py::TestPlugin1_url::test_url_plugin_002", + "tests/test_plugins.py::TestPlugin1_url::test_url_plugin_003", + "tests/test_plugins.py::TestPlugin2_url::test_url_plugin_001", + "tests/test_plugins.py::TestPlugin2_url::test_url_plugin_002", + "tests/test_plugins.py::TestPlugin2_url::test_url_plugin_003", + "tests/test_plugins.py::TestPlugin1_strikethrough::test_strikethrough_001", + "tests/test_plugins.py::TestPlugin1_strikethrough::test_strikethrough_002", + "tests/test_plugins.py::TestPlugin1_strikethrough::test_strikethrough_003", + "tests/test_plugins.py::TestPlugin1_strikethrough::test_strikethrough_004", + "tests/test_plugins.py::TestPlugin1_strikethrough::test_strikethrough_005", + "tests/test_plugins.py::TestPlugin1_strikethrough::test_strikethrough_006", + "tests/test_plugins.py::TestPlugin1_strikethrough::test_strikethrough_007", + "tests/test_plugins.py::TestPlugin2_strikethrough::test_strikethrough_001", + "tests/test_plugins.py::TestPlugin2_strikethrough::test_strikethrough_002", + "tests/test_plugins.py::TestPlugin2_strikethrough::test_strikethrough_003", + "tests/test_plugins.py::TestPlugin2_strikethrough::test_strikethrough_004", + "tests/test_plugins.py::TestPlugin2_strikethrough::test_strikethrough_005", + "tests/test_plugins.py::TestPlugin2_strikethrough::test_strikethrough_006", + "tests/test_plugins.py::TestPlugin2_strikethrough::test_strikethrough_007", + "tests/test_plugins.py::TestPlugin1_mark::test_escape_mark_001", + "tests/test_plugins.py::TestPlugin1_mark::test_escape_mark_002", + "tests/test_plugins.py::TestPlugin1_mark::test_mark_001", + "tests/test_plugins.py::TestPlugin1_mark::test_mark_link_001", + "tests/test_plugins.py::TestPlugin1_mark::test_mark_link_002", + "tests/test_plugins.py::TestPlugin1_mark::test_normal_mark_001", + "tests/test_plugins.py::TestPlugin1_mark::test_normal_mark_002", + "tests/test_plugins.py::TestPlugin1_mark::test_normal_mark_003", + "tests/test_plugins.py::TestPlugin1_mark::test_normal_mark_004", + "tests/test_plugins.py::TestPlugin2_mark::test_escape_mark_001", + "tests/test_plugins.py::TestPlugin2_mark::test_escape_mark_002", + "tests/test_plugins.py::TestPlugin2_mark::test_mark_001", + "tests/test_plugins.py::TestPlugin2_mark::test_mark_link_001", + "tests/test_plugins.py::TestPlugin2_mark::test_mark_link_002", + "tests/test_plugins.py::TestPlugin2_mark::test_normal_mark_001", + "tests/test_plugins.py::TestPlugin2_mark::test_normal_mark_002", + "tests/test_plugins.py::TestPlugin2_mark::test_normal_mark_003", + "tests/test_plugins.py::TestPlugin2_mark::test_normal_mark_004", + "tests/test_plugins.py::TestPlugin1_insert::test_escape_insert_001", + "tests/test_plugins.py::TestPlugin1_insert::test_escape_insert_002", + "tests/test_plugins.py::TestPlugin1_insert::test_insert_001", + "tests/test_plugins.py::TestPlugin1_insert::test_insert_link_001", + "tests/test_plugins.py::TestPlugin1_insert::test_insert_link_002", + "tests/test_plugins.py::TestPlugin1_insert::test_normal_insert_001", + "tests/test_plugins.py::TestPlugin1_insert::test_normal_insert_002", + "tests/test_plugins.py::TestPlugin1_insert::test_normal_insert_003", + "tests/test_plugins.py::TestPlugin1_insert::test_normal_insert_004", + "tests/test_plugins.py::TestPlugin2_insert::test_escape_insert_001", + "tests/test_plugins.py::TestPlugin2_insert::test_escape_insert_002", + "tests/test_plugins.py::TestPlugin2_insert::test_insert_001", + "tests/test_plugins.py::TestPlugin2_insert::test_insert_link_001", + "tests/test_plugins.py::TestPlugin2_insert::test_insert_link_002", + "tests/test_plugins.py::TestPlugin2_insert::test_normal_insert_001", + "tests/test_plugins.py::TestPlugin2_insert::test_normal_insert_002", + "tests/test_plugins.py::TestPlugin2_insert::test_normal_insert_003", + "tests/test_plugins.py::TestPlugin2_insert::test_normal_insert_004", + "tests/test_plugins.py::TestPlugin1_superscript::test_superscript_001", + "tests/test_plugins.py::TestPlugin1_superscript::test_superscript_002", + "tests/test_plugins.py::TestPlugin1_superscript::test_superscript_003", + "tests/test_plugins.py::TestPlugin1_superscript::test_superscript_004", + "tests/test_plugins.py::TestPlugin2_superscript::test_superscript_001", + "tests/test_plugins.py::TestPlugin2_superscript::test_superscript_002", + "tests/test_plugins.py::TestPlugin2_superscript::test_superscript_003", + "tests/test_plugins.py::TestPlugin2_superscript::test_superscript_004", + "tests/test_plugins.py::TestPlugin1_subscript::test_subscript_001", + "tests/test_plugins.py::TestPlugin1_subscript::test_subscript_002", + "tests/test_plugins.py::TestPlugin1_subscript::test_subscript_003", + "tests/test_plugins.py::TestPlugin1_subscript::test_subscript_004", + "tests/test_plugins.py::TestPlugin2_subscript::test_subscript_001", + "tests/test_plugins.py::TestPlugin2_subscript::test_subscript_002", + "tests/test_plugins.py::TestPlugin2_subscript::test_subscript_003", + "tests/test_plugins.py::TestPlugin2_subscript::test_subscript_004", + "tests/test_plugins.py::TestPlugin1_task_lists::test_task_lists_001", + "tests/test_plugins.py::TestPlugin1_task_lists::test_task_lists_002", + "tests/test_plugins.py::TestPlugin1_task_lists::test_task_lists_003", + "tests/test_plugins.py::TestPlugin1_task_lists::test_task_lists_004", + "tests/test_plugins.py::TestPlugin1_task_lists::test_task_lists_005", + "tests/test_plugins.py::TestPlugin1_task_lists::test_task_lists_006", + "tests/test_plugins.py::TestPlugin1_task_lists::test_task_lists_007", + "tests/test_plugins.py::TestPlugin1_task_lists::test_task_lists_008", + "tests/test_plugins.py::TestPlugin2_task_lists::test_task_lists_001", + "tests/test_plugins.py::TestPlugin2_task_lists::test_task_lists_002", + "tests/test_plugins.py::TestPlugin2_task_lists::test_task_lists_003", + "tests/test_plugins.py::TestPlugin2_task_lists::test_task_lists_004", + "tests/test_plugins.py::TestPlugin2_task_lists::test_task_lists_005", + "tests/test_plugins.py::TestPlugin2_task_lists::test_task_lists_006", + "tests/test_plugins.py::TestPlugin2_task_lists::test_task_lists_007", + "tests/test_plugins.py::TestPlugin2_task_lists::test_task_lists_008", + "tests/test_plugins.py::TestPlugin1_table::test_align_table_001", + "tests/test_plugins.py::TestPlugin1_table::test_align_table_002", + "tests/test_plugins.py::TestPlugin1_table::test_misc_table_001", + "tests/test_plugins.py::TestPlugin1_table::test_misc_table_002", + "tests/test_plugins.py::TestPlugin1_table::test_misc_table_003", + "tests/test_plugins.py::TestPlugin1_table::test_mismatch_length_001", + "tests/test_plugins.py::TestPlugin1_table::test_mismatch_length_002", + "tests/test_plugins.py::TestPlugin1_table::test_mismatch_length_003", + "tests/test_plugins.py::TestPlugin1_table::test_mismatch_length_004", + "tests/test_plugins.py::TestPlugin1_table::test_nptable_001", + "tests/test_plugins.py::TestPlugin1_table::test_table_001", + "tests/test_plugins.py::TestPlugin1_table::test_table_002", + "tests/test_plugins.py::TestPlugin2_table::test_align_table_001", + "tests/test_plugins.py::TestPlugin2_table::test_align_table_002", + "tests/test_plugins.py::TestPlugin2_table::test_misc_table_001", + "tests/test_plugins.py::TestPlugin2_table::test_misc_table_002", + "tests/test_plugins.py::TestPlugin2_table::test_misc_table_003", + "tests/test_plugins.py::TestPlugin2_table::test_mismatch_length_001", + "tests/test_plugins.py::TestPlugin2_table::test_mismatch_length_002", + "tests/test_plugins.py::TestPlugin2_table::test_mismatch_length_003", + "tests/test_plugins.py::TestPlugin2_table::test_mismatch_length_004", + "tests/test_plugins.py::TestPlugin2_table::test_nptable_001", + "tests/test_plugins.py::TestPlugin2_table::test_table_001", + "tests/test_plugins.py::TestPlugin2_table::test_table_002", + "tests/test_plugins.py::TestPlugin1_footnotes::test_footnotes_001", + "tests/test_plugins.py::TestPlugin1_footnotes::test_footnotes_002", + "tests/test_plugins.py::TestPlugin1_footnotes::test_footnotes_003", + "tests/test_plugins.py::TestPlugin2_footnotes::test_footnotes_001", + "tests/test_plugins.py::TestPlugin2_footnotes::test_footnotes_002", + "tests/test_plugins.py::TestPlugin2_footnotes::test_footnotes_003", + "tests/test_plugins.py::TestPlugin1_abbr::test_abbreviation_001", + "tests/test_plugins.py::TestPlugin1_abbr::test_abbreviation_002", + "tests/test_plugins.py::TestPlugin1_abbr::test_abbreviation_003", + "tests/test_plugins.py::TestPlugin1_abbr::test_abbreviation_004", + "tests/test_plugins.py::TestPlugin1_abbr::test_abbreviation_005", + "tests/test_plugins.py::TestPlugin1_abbr::test_abbreviation_006", + "tests/test_plugins.py::TestPlugin1_abbr::test_abbreviation_007", + "tests/test_plugins.py::TestPlugin1_abbr::test_abbreviation_008", + "tests/test_plugins.py::TestPlugin1_abbr::test_abbreviation_009", + "tests/test_plugins.py::TestPlugin1_abbr::test_abbreviation_010", + "tests/test_plugins.py::TestPlugin2_abbr::test_abbreviation_001", + "tests/test_plugins.py::TestPlugin2_abbr::test_abbreviation_002", + "tests/test_plugins.py::TestPlugin2_abbr::test_abbreviation_003", + "tests/test_plugins.py::TestPlugin2_abbr::test_abbreviation_004", + "tests/test_plugins.py::TestPlugin2_abbr::test_abbreviation_005", + "tests/test_plugins.py::TestPlugin2_abbr::test_abbreviation_006", + "tests/test_plugins.py::TestPlugin2_abbr::test_abbreviation_007", + "tests/test_plugins.py::TestPlugin2_abbr::test_abbreviation_008", + "tests/test_plugins.py::TestPlugin2_abbr::test_abbreviation_009", + "tests/test_plugins.py::TestPlugin2_abbr::test_abbreviation_010", + "tests/test_plugins.py::TestPlugin1_math::test_block_math_001", + "tests/test_plugins.py::TestPlugin1_math::test_block_math_002", + "tests/test_plugins.py::TestPlugin1_math::test_block_math_003", + "tests/test_plugins.py::TestPlugin1_math::test_block_math_004", + "tests/test_plugins.py::TestPlugin1_math::test_inline_math_001", + "tests/test_plugins.py::TestPlugin2_math::test_block_math_001", + "tests/test_plugins.py::TestPlugin2_math::test_block_math_002", + "tests/test_plugins.py::TestPlugin2_math::test_block_math_003", + "tests/test_plugins.py::TestPlugin2_math::test_block_math_004", + "tests/test_plugins.py::TestPlugin2_math::test_inline_math_001", + "tests/test_plugins.py::TestPlugin1_ruby::test_ruby_splits_001", + "tests/test_plugins.py::TestPlugin1_ruby::test_ruby_splits_002", + "tests/test_plugins.py::TestPlugin1_ruby::test_ruby_with_link_001", + "tests/test_plugins.py::TestPlugin1_ruby::test_ruby_with_link_002", + "tests/test_plugins.py::TestPlugin1_ruby::test_ruby_with_link_003", + "tests/test_plugins.py::TestPlugin1_ruby::test_ruby_without_link_001", + "tests/test_plugins.py::TestPlugin1_ruby::test_ruby_without_link_002", + "tests/test_plugins.py::TestPlugin1_ruby::test_ruby_without_link_003", + "tests/test_plugins.py::TestPlugin1_ruby::test_ruby_without_link_004", + "tests/test_plugins.py::TestPlugin2_ruby::test_ruby_splits_001", + "tests/test_plugins.py::TestPlugin2_ruby::test_ruby_splits_002", + "tests/test_plugins.py::TestPlugin2_ruby::test_ruby_with_link_001", + "tests/test_plugins.py::TestPlugin2_ruby::test_ruby_with_link_002", + "tests/test_plugins.py::TestPlugin2_ruby::test_ruby_with_link_003", + "tests/test_plugins.py::TestPlugin2_ruby::test_ruby_without_link_001", + "tests/test_plugins.py::TestPlugin2_ruby::test_ruby_without_link_002", + "tests/test_plugins.py::TestPlugin2_ruby::test_ruby_without_link_003", + "tests/test_plugins.py::TestPlugin2_ruby::test_ruby_without_link_004", + "tests/test_plugins.py::TestPlugin1_spoiler::test_block_spoiler_001", + "tests/test_plugins.py::TestPlugin1_spoiler::test_block_spoiler_002", + "tests/test_plugins.py::TestPlugin1_spoiler::test_block_spoiler_003", + "tests/test_plugins.py::TestPlugin1_spoiler::test_block_spoiler_004", + "tests/test_plugins.py::TestPlugin1_spoiler::test_block_spoiler_005", + "tests/test_plugins.py::TestPlugin1_spoiler::test_inline_spoiler_001", + "tests/test_plugins.py::TestPlugin1_spoiler::test_inline_spoiler_002", + "tests/test_plugins.py::TestPlugin1_spoiler::test_inline_spoiler_003", + "tests/test_plugins.py::TestPlugin2_spoiler::test_block_spoiler_001", + "tests/test_plugins.py::TestPlugin2_spoiler::test_block_spoiler_002", + "tests/test_plugins.py::TestPlugin2_spoiler::test_block_spoiler_003", + "tests/test_plugins.py::TestPlugin2_spoiler::test_block_spoiler_004", + "tests/test_plugins.py::TestPlugin2_spoiler::test_block_spoiler_005", + "tests/test_plugins.py::TestPlugin2_spoiler::test_inline_spoiler_001", + "tests/test_plugins.py::TestPlugin2_spoiler::test_inline_spoiler_002", + "tests/test_plugins.py::TestPlugin2_spoiler::test_inline_spoiler_003", + "tests/test_plugins.py::TestExtraPlugins::test_math_in_list", + "tests/test_plugins.py::TestExtraPlugins::test_math_in_quote", + "tests/test_plugins.py::TestExtraPlugins::test_table_in_list", + "tests/test_plugins.py::TestExtraPlugins::test_table_in_quote", + "tests/test_renderers.py::TestRendererRst::test_code_001", + "tests/test_renderers.py::TestRendererRst::test_code_002", + "tests/test_renderers.py::TestRendererRst::test_heading_001", + "tests/test_renderers.py::TestRendererRst::test_html_001", + "tests/test_renderers.py::TestRendererRst::test_images_001", + "tests/test_renderers.py::TestRendererRst::test_images_002", + "tests/test_renderers.py::TestRendererRst::test_images_003", + "tests/test_renderers.py::TestRendererRst::test_inline_001", + "tests/test_renderers.py::TestRendererRst::test_inline_002", + "tests/test_renderers.py::TestRendererRst::test_line_break_001", + "tests/test_renderers.py::TestRendererRst::test_links_001", + "tests/test_renderers.py::TestRendererRst::test_list_001", + "tests/test_renderers.py::TestRendererRst::test_list_002", + "tests/test_renderers.py::TestRendererRst::test_list_003", + "tests/test_renderers.py::TestRendererRst::test_list_004", + "tests/test_renderers.py::TestRendererRst::test_list_005", + "tests/test_renderers.py::TestRendererRst::test_quote_001", + "tests/test_renderers.py::TestRendererRst::test_quote_002", + "tests/test_renderers.py::TestRendererRst::test_quote_003", + "tests/test_renderers.py::TestRendererRst::test_thematic_break_001", + "tests/test_renderers.py::TestRendererMarkdown::test_code_001", + "tests/test_renderers.py::TestRendererMarkdown::test_code_002", + "tests/test_renderers.py::TestRendererMarkdown::test_code_003", + "tests/test_renderers.py::TestRendererMarkdown::test_code_004", + "tests/test_renderers.py::TestRendererMarkdown::test_code_005", + "tests/test_renderers.py::TestRendererMarkdown::test_heading_001", + "tests/test_renderers.py::TestRendererMarkdown::test_html_001", + "tests/test_renderers.py::TestRendererMarkdown::test_images_001", + "tests/test_renderers.py::TestRendererMarkdown::test_inline_001", + "tests/test_renderers.py::TestRendererMarkdown::test_linebreak_001", + "tests/test_renderers.py::TestRendererMarkdown::test_links_001", + "tests/test_renderers.py::TestRendererMarkdown::test_links_002", + "tests/test_renderers.py::TestRendererMarkdown::test_links_003", + "tests/test_renderers.py::TestRendererMarkdown::test_list_001", + "tests/test_renderers.py::TestRendererMarkdown::test_list_002", + "tests/test_renderers.py::TestRendererMarkdown::test_list_003", + "tests/test_renderers.py::TestRendererMarkdown::test_list_004", + "tests/test_renderers.py::TestRendererMarkdown::test_list_005", + "tests/test_renderers.py::TestRendererMarkdown::test_list_006", + "tests/test_renderers.py::TestRendererMarkdown::test_quote_001", + "tests/test_renderers.py::TestRendererMarkdown::test_quote_002", + "tests/test_renderers.py::TestRendererMarkdown::test_thematic_break_001", + "tests/test_syntax.py::TestSyntax::test_emphasis_001", + "tests/test_syntax.py::TestSyntax::test_image_001", + "tests/test_syntax.py::TestSyntax::test_link_001", + "tests/test_syntax.py::TestSyntax::test_link_002", + "tests/test_syntax.py::TestSyntax::test_link_003", + "tests/test_syntax.py::TestSyntax::test_links_001", + "tests/test_syntax.py::TestSyntax::test_links_002", + "tests/test_syntax.py::TestSyntax::test_max_depth_001", + "tests/test_syntax.py::TestSyntax::test_max_depth_002", + "tests/test_syntax.py::TestSyntax::test_non_aggressive_emphasis_001", + "tests/test_syntax.py::TestSyntax::test_non_aggressive_emphasis_002", + "tests/test_syntax.py::TestSyntax::test_non_aggressive_emphasis_003", + "tests/test_syntax.py::TestSyntax::test_setext_headings_001", + "tests/test_syntax.py::TestSyntax::test_setext_headings_002" + ], + "all_git_blobs_modes_verified": true, + "cloud_launch_ready": false, + "commits": { + "bug": "44bbd1b0606511e7d54205d2cd4917eba8d67515", + "healthy": "62750c95db25a8fb93dda09242f64e07508d9231", + "learner": "4d6d7dec37acc043e6beb19ab0a4d114fb76b1c2" + }, + "existing_squirrel_snapshot_reused": false, + "full_transfer_allowlist": [ + "/testbed/.editorconfig", + "/testbed/.github/FUNDING.yml", + "/testbed/.gitignore", + "/testbed/.readthedocs.yaml", + "/testbed/BACKERS.md", + "/testbed/LICENSE", + "/testbed/MANIFEST.in", + "/testbed/Makefile", + "/testbed/README.md", + "/testbed/README.rst", + "/testbed/benchmark/bench.py", + "/testbed/benchmark/cases/atx.txt", + "/testbed/benchmark/cases/auto_links.txt", + "/testbed/benchmark/cases/blockcode.txt", + "/testbed/benchmark/cases/blockhtml.txt", + "/testbed/benchmark/cases/blockquote.txt", + "/testbed/benchmark/cases/emphasis.txt", + "/testbed/benchmark/cases/fenced.txt", + "/testbed/benchmark/cases/insane_ol.txt", + "/testbed/benchmark/cases/insane_ul.txt", + "/testbed/benchmark/cases/normal_ol.txt", + "/testbed/benchmark/cases/normal_ul.txt", + "/testbed/benchmark/cases/paragraph.txt", + "/testbed/benchmark/cases/ref_links.txt", + "/testbed/benchmark/cases/setext.txt", + "/testbed/benchmark/cases/std_links.txt", + "/testbed/docs/Makefile", + "/testbed/docs/_static/dark-icon.svg", + "/testbed/docs/_static/light-icon.svg", + "/testbed/docs/_static/logo-black.svg", + "/testbed/docs/_static/logo-white.svg", + "/testbed/docs/_templates/partials/globaltoc-above.html", + "/testbed/docs/advanced.rst", + "/testbed/docs/api.rst", + "/testbed/docs/changes.rst", + "/testbed/docs/cli.rst", + "/testbed/docs/community.rst", + "/testbed/docs/conf.py", + "/testbed/docs/directives.rst", + "/testbed/docs/guide.rst", + "/testbed/docs/index.rst", + "/testbed/docs/plugins.rst", + "/testbed/docs/renderers.rst", + "/testbed/docs/requirements.txt", + "/testbed/docs/upgrade.rst", + "/testbed/pyproject.toml", + "/testbed/serve-doc.py", + "/testbed/setup.py", + "/testbed/src/mistune/__init__.py", + "/testbed/src/mistune/__main__.py", + "/testbed/src/mistune/block_parser.py", + "/testbed/src/mistune/core.py", + "/testbed/src/mistune/directives/__init__.py", + "/testbed/src/mistune/directives/_base.py", + "/testbed/src/mistune/directives/_fenced.py", + "/testbed/src/mistune/directives/_rst.py", + "/testbed/src/mistune/directives/admonition.py", + "/testbed/src/mistune/directives/image.py", + "/testbed/src/mistune/directives/include.py", + "/testbed/src/mistune/directives/toc.py", + "/testbed/src/mistune/helpers.py", + "/testbed/src/mistune/inline_parser.py", + "/testbed/src/mistune/list_parser.py", + "/testbed/src/mistune/markdown.py", + "/testbed/src/mistune/plugins/__init__.py", + "/testbed/src/mistune/plugins/abbr.py", + "/testbed/src/mistune/plugins/def_list.py", + "/testbed/src/mistune/plugins/footnotes.py", + "/testbed/src/mistune/plugins/formatting.py", + "/testbed/src/mistune/plugins/math.py", + "/testbed/src/mistune/plugins/ruby.py", + "/testbed/src/mistune/plugins/speedup.py", + "/testbed/src/mistune/plugins/spoiler.py", + "/testbed/src/mistune/plugins/table.py", + "/testbed/src/mistune/plugins/task_lists.py", + "/testbed/src/mistune/plugins/url.py", + "/testbed/src/mistune/py.typed", + "/testbed/src/mistune/renderers/__init__.py", + "/testbed/src/mistune/renderers/_list.py", + "/testbed/src/mistune/renderers/html.py", + "/testbed/src/mistune/renderers/markdown.py", + "/testbed/src/mistune/renderers/rst.py", + "/testbed/src/mistune/toc.py", + "/testbed/src/mistune/util.py", + "/testbed/tests/__init__.py", + "/testbed/tests/fixtures/__init__.py", + "/testbed/tests/fixtures/abbr.txt", + "/testbed/tests/fixtures/commonmark.json", + "/testbed/tests/fixtures/def_list.txt", + "/testbed/tests/fixtures/diff-commonmark.txt", + "/testbed/tests/fixtures/fenced_admonition.txt", + "/testbed/tests/fixtures/fenced_figure.txt", + "/testbed/tests/fixtures/fenced_image.txt", + "/testbed/tests/fixtures/fenced_toc.txt", + "/testbed/tests/fixtures/fix-commonmark.txt", + "/testbed/tests/fixtures/footnotes.txt", + "/testbed/tests/fixtures/hook_toc.txt", + "/testbed/tests/fixtures/include/hello.md", + "/testbed/tests/fixtures/include/hello.txt", + "/testbed/tests/fixtures/include/text.html", + "/testbed/tests/fixtures/include/text.md", + "/testbed/tests/fixtures/insert.txt", + "/testbed/tests/fixtures/mark.txt", + "/testbed/tests/fixtures/math.txt", + "/testbed/tests/fixtures/renderer_markdown.txt", + "/testbed/tests/fixtures/renderer_rst.txt", + "/testbed/tests/fixtures/rst_admonition.txt", + "/testbed/tests/fixtures/rst_toc.txt", + "/testbed/tests/fixtures/ruby.txt", + "/testbed/tests/fixtures/spoiler.txt", + "/testbed/tests/fixtures/strikethrough.txt", + "/testbed/tests/fixtures/subscript.txt", + "/testbed/tests/fixtures/superscript.txt", + "/testbed/tests/fixtures/table.txt", + "/testbed/tests/fixtures/task_lists.txt", + "/testbed/tests/fixtures/url.txt", + "/testbed/tests/test_commonmark.py", + "/testbed/tests/test_directives.py", + "/testbed/tests/test_hooks.py", + "/testbed/tests/test_misc.py", + "/testbed/tests/test_renderers.py", + "/testbed/tests/test_syntax.py" + ], + "healthy_stage_meaning": "Direct parent of the mutation; no source or test execution has been performed", + "mutation_matches_dataset_and_git_blobs": true, + "official_profile": { + "eval_sets": [], + "profile_class": "MistuneBf54ef67", + "profile_lines": [ + 570, + 573 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "bf54ef67390e02a5cdee7495d4386d7770c1902b", + "upstream_repo": "lepture/mistune" + }, + "original_source_commit": "bf54ef67390e02a5cdee7495d4386d7770c1902b", + "private_test_paths": [ + "tests/test_plugins.py" + ], + "private_tests_unchanged": true, + "profile_mapping_basis": "Explicit upstream repo and full commit fields parsed from pinned official Python profile AST, not basename inference", + "qwen_calibrated": false, + "runtime_qualified": false, + "source_paths": [ + "src/mistune/plugins/def_list.py" + ], + "source_repo": "swesmith/lepture__mistune.bf54ef67", + "source_stages_bytes": 1359845, + "task_id": "lepture__mistune.bf54ef67.combine_file__01ys6r85", + "transfer_limitation": "Existing regular files only; new arbitrary file additions need a qualified patch adapter", + "upstream_repo": "lepture/mistune" + }, + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:lepture__mistune.bf54ef67.combine_file__01ys6r85", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "62750c95db25a8fb93dda09242f64e07508d9231", + "instruction_sha256": "594c53bc148e4b4ea23cb1cf09bfc5c5c0d499e2ff41a0c7dd23a0f213a819da", + "is_fork": true, + "learner_path": "tasks/a658c0a0037cef2b90f345da/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "bf54ef67390e02a5cdee7495d4386d7770c1902b", + "actual_upstream_url": "https://raw.githubusercontent.com/lepture/mistune/bf54ef67390e02a5cdee7495d4386d7770c1902b/LICENSE", + "reviewed": true, + "sha256": "539013fd8e19f744f8bf0e27a532bbff54cd689ecef7a800f56ae5dc824be870", + "spdx": "BSD-3-Clause", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/lepture__mistune.bf54ef67/4d6d7dec37acc043e6beb19ab0a4d114fb76b1c2/LICENSE" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "bf54ef67390e02a5cdee7495d4386d7770c1902b", + "patch_sha256": "138645f5b5f0f36dd7db653b27103a2e69131c814ed4ccd2a2b4d1fb450083b0", + "provenance_path": "tasks/a658c0a0037cef2b90f345da/source-proof.json", + "repository_lineage": [ + "swesmith/lepture__mistune.bf54ef67", + "lepture/mistune" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "4d6d7dec37acc043e6beb19ab0a4d114fb76b1c2", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "44bbd1b0606511e7d54205d2cd4917eba8d67515", + "source_kind": "mutation", + "source_repo": "swesmith/lepture__mistune.bf54ef67", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "lepture__mistune.bf54ef67.combine_file__01ys6r85", + "task_sha256": "376e90643984f215a7c3c7f28a11ae36f61ea5e906b723ac34e4247f4de01f88", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "lepture/mistune", + "usage": "quarantine_only" + }, + "task_kind": "original-source-mutation" +} diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/provenance.json b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/provenance.json new file mode 100644 index 0000000000000000000000000000000000000000..9fc874039a724fd2ab2c495cc26181e12aca5ad2 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/provenance.json @@ -0,0 +1,88 @@ +{ + "generated_reference": false, + "healthy_reference_delta_sha256": "22b60e8883f2918169a3cd556762d4ec88511f2755703e07d40f3493927c1194", + "native_pytest_ids_preserved": true, + "original_source_code_license": { + "actual_upstream_commit": "bf54ef67390e02a5cdee7495d4386d7770c1902b", + "actual_upstream_url": "https://raw.githubusercontent.com/lepture/mistune/bf54ef67390e02a5cdee7495d4386d7770c1902b/LICENSE", + "reviewed": true, + "sha256": "539013fd8e19f744f8bf0e27a532bbff54cd689ecef7a800f56ae5dc824be870", + "spdx": "BSD-3-Clause", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/lepture__mistune.bf54ef67/4d6d7dec37acc043e6beb19ab0a4d114fb76b1c2/LICENSE" + }, + "provided_reference": true, + "qwen_calibrated": false, + "runtime_qualified": false, + "source_completion_sha256": "331de350de24ec13b79543d31a26b66305abc60701a8296fb245092aa868606e", + "source_index_sha256": "e3ea2fb9bd6c335cdb937a3a8cd4fe62a1ee4e9a65ba1e0deeeb395c0103fde1", + "source_proof_sha256": "f01c1651b9acf13e5f60e53cfdd8712b969c676ea024e96c1112045d81f41f6b", + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:lepture__mistune.bf54ef67.combine_file__01ys6r85", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "62750c95db25a8fb93dda09242f64e07508d9231", + "instruction_sha256": "594c53bc148e4b4ea23cb1cf09bfc5c5c0d499e2ff41a0c7dd23a0f213a819da", + "is_fork": true, + "learner_path": "tasks/a658c0a0037cef2b90f345da/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "bf54ef67390e02a5cdee7495d4386d7770c1902b", + "actual_upstream_url": "https://raw.githubusercontent.com/lepture/mistune/bf54ef67390e02a5cdee7495d4386d7770c1902b/LICENSE", + "reviewed": true, + "sha256": "539013fd8e19f744f8bf0e27a532bbff54cd689ecef7a800f56ae5dc824be870", + "spdx": "BSD-3-Clause", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/lepture__mistune.bf54ef67/4d6d7dec37acc043e6beb19ab0a4d114fb76b1c2/LICENSE" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "bf54ef67390e02a5cdee7495d4386d7770c1902b", + "patch_sha256": "138645f5b5f0f36dd7db653b27103a2e69131c814ed4ccd2a2b4d1fb450083b0", + "provenance_path": "tasks/a658c0a0037cef2b90f345da/source-proof.json", + "repository_lineage": [ + "swesmith/lepture__mistune.bf54ef67", + "lepture/mistune" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "4d6d7dec37acc043e6beb19ab0a4d114fb76b1c2", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "44bbd1b0606511e7d54205d2cd4917eba8d67515", + "source_kind": "mutation", + "source_repo": "swesmith/lepture__mistune.bf54ef67", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "lepture__mistune.bf54ef67.combine_file__01ys6r85", + "task_sha256": "376e90643984f215a7c3c7f28a11ae36f61ea5e906b723ac34e4247f4de01f88", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "lepture/mistune", + "usage": "quarantine_only" + }, + "task_bundle_license": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + }, + "training_admissible": false, + "trusted_tests_sha256": "cb345067f46bf3d3e7a60b2963e26cee25fe8aae6cd4a620d05e02f799d96fca" +} diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/provided-gold.diff b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/provided-gold.diff new file mode 100644 index 0000000000000000000000000000000000000000..ff40174f8412dfead56ba7dbdd244dce665fc542 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/provided-gold.diff @@ -0,0 +1,85 @@ +diff --git a/src/mistune/plugins/def_list.py b/src/mistune/plugins/def_list.py +index 9d50d6a416b900237aa543b45f78f61bc0d913a4..4d792f41fe12cac68cff8bb432305ae7e1d9827b 100644 +--- a/src/mistune/plugins/def_list.py ++++ b/src/mistune/plugins/def_list.py +@@ -28,31 +28,37 @@ + + + def parse_def_list(block: "BlockParser", m: Match[str], state: "BlockState") -> int: +- pos = m.start() +- children = list(_parse_def_item(state, m)) ++ pos = m.end() ++ children = list(_parse_def_item(block, m)) + +- m2 = DEF_RE.match(state.src, pos + 1) ++ m2 = DEF_RE.match(state.src, pos) + while m2: +- children.append(_parse_def_item(block, m2)) +- pos = m2.start() +- m2 = DEF_RE.search(state.src, pos) ++ children.extend(list(_parse_def_item(block, m2))) ++ pos = m2.end() ++ m2 = DEF_RE.match(state.src, pos) + + state.append_token({ +- 'type': 'definition_list', +- 'child_nodes': children, ++ 'type': 'def_list', ++ 'children': children, + }) +- return pos + 1 ++ return pos + + + def _parse_def_item(block: "BlockParser", m: Match[str]) -> Iterable[Dict[str, Any]]: +- start = m2.start() + head = m.group("def_list_head") +- children = _process_text(block, text, prev_blank_line) + for line in head.splitlines(): + yield { + 'type': 'def_list_head', + 'text': line, + } ++ ++ src = m.group(0) ++ end = len(head) ++ ++ m2 = DD_START_RE.search(src, end) ++ assert m2 is not None ++ start = m2.start() ++ prev_blank_line = src[end:start] == '\n' + while m2: + m2 = DD_START_RE.search(src, start + 1) + if not m2: +@@ -67,19 +73,14 @@ + 'children': children, + } + start = end +- end = len(head) +- prev_blank_line = src[end:start] == '\n' ++ ++ text = src[start:].replace(':', ' ', 1) ++ children = _process_text(block, text, prev_blank_line) + yield { + 'type': 'def_list_item', + 'children': children, + } + +- src = m.group(0) +- assert m2 is not None +- +- text = src[start:].replace(':', ' ', 1) +- +- m2 = DD_START_RE.search(src, end) + + def _process_text(block: "BlockParser", text: str, loose: bool) -> List[Any]: + text = TRIM_RE.sub("", text) +@@ -98,7 +99,7 @@ + + + def render_def_list_head(renderer: "BaseRenderer", text: str) -> str: +- return "
" + text + "\n" ++ return "
" + text + "
\n" + + + def render_def_list_item(renderer: "BaseRenderer", text: str) -> str: diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/solution/solve.sh b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..b1ef1ac83fbc092bd82c9457359af783eaffbf1b --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/solution/solve.sh @@ -0,0 +1,91 @@ +#!/bin/bash +set -Eeuo pipefail +cd /testbed/repo +cat > /tmp/openenv-reference.diff <<'OPENENV_REFERENCE' +diff --git a/src/mistune/plugins/def_list.py b/src/mistune/plugins/def_list.py +index 9d50d6a416b900237aa543b45f78f61bc0d913a4..4d792f41fe12cac68cff8bb432305ae7e1d9827b 100644 +--- a/src/mistune/plugins/def_list.py ++++ b/src/mistune/plugins/def_list.py +@@ -28,31 +28,37 @@ + + + def parse_def_list(block: "BlockParser", m: Match[str], state: "BlockState") -> int: +- pos = m.start() +- children = list(_parse_def_item(state, m)) ++ pos = m.end() ++ children = list(_parse_def_item(block, m)) + +- m2 = DEF_RE.match(state.src, pos + 1) ++ m2 = DEF_RE.match(state.src, pos) + while m2: +- children.append(_parse_def_item(block, m2)) +- pos = m2.start() +- m2 = DEF_RE.search(state.src, pos) ++ children.extend(list(_parse_def_item(block, m2))) ++ pos = m2.end() ++ m2 = DEF_RE.match(state.src, pos) + + state.append_token({ +- 'type': 'definition_list', +- 'child_nodes': children, ++ 'type': 'def_list', ++ 'children': children, + }) +- return pos + 1 ++ return pos + + + def _parse_def_item(block: "BlockParser", m: Match[str]) -> Iterable[Dict[str, Any]]: +- start = m2.start() + head = m.group("def_list_head") +- children = _process_text(block, text, prev_blank_line) + for line in head.splitlines(): + yield { + 'type': 'def_list_head', + 'text': line, + } ++ ++ src = m.group(0) ++ end = len(head) ++ ++ m2 = DD_START_RE.search(src, end) ++ assert m2 is not None ++ start = m2.start() ++ prev_blank_line = src[end:start] == '\n' + while m2: + m2 = DD_START_RE.search(src, start + 1) + if not m2: +@@ -67,19 +73,14 @@ + 'children': children, + } + start = end +- end = len(head) +- prev_blank_line = src[end:start] == '\n' ++ ++ text = src[start:].replace(':', ' ', 1) ++ children = _process_text(block, text, prev_blank_line) + yield { + 'type': 'def_list_item', + 'children': children, + } + +- src = m.group(0) +- assert m2 is not None +- +- text = src[start:].replace(':', ' ', 1) +- +- m2 = DD_START_RE.search(src, end) + + def _process_text(block: "BlockParser", text: str, loose: bool) -> List[Any]: + text = TRIM_RE.sub("", text) +@@ -98,7 +99,7 @@ + + + def render_def_list_head(renderer: "BaseRenderer", text: str) -> str: +- return "
" + text + "\n" ++ return "
" + text + "
\n" + + + def render_def_list_item(renderer: "BaseRenderer", text: str) -> str: +OPENENV_REFERENCE +/usr/bin/git -c core.hooksPath=/dev/null -c core.fsmonitor=false apply --whitespace=nowarn /tmp/openenv-reference.diff diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/task.toml b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..d2ad3a881a23c036237d97ef3daf435ae7f98c89 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/task.toml @@ -0,0 +1,24 @@ +version = "1.0" + +[agent] +timeout_sec = 1800.0 + +[verifier] +timeout_sec = 900.0 + +[environment] +docker_image = "ghcr.io/younesbelkada/scale800@sha256:f83e878ab7d2e5944cf235380f88afc46b419e5102418319f700d382b3e6df82" +build_timeout_sec = 600.0 +cpus = 2 +memory_mb = 8192 +storage_mb = 16384 + +[metadata] +author_name = "SWE-smith source adapter" +category = "bugfix" +tags = ["swe", "python", "mutation-repair"] + +[environment.env] +# The image's PATH with the testbed env first: the project and pytest are installed there, and the agent's +# non-interactive shells never run `conda activate` +PATH = "/opt/miniconda3/envs/testbed/bin:/opt/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/check_pytest.py b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/check_pytest.py new file mode 100644 index 0000000000000000000000000000000000000000..7abfdc5972f57ca7f0cecbbeeb373414670f780e --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/check_pytest.py @@ -0,0 +1,177 @@ +"""Preserve confirmed requested assertion failures; keep positive checks strict.""" + +import argparse +import hashlib +import json +import re +import xml.etree.ElementTree as ET +from pathlib import Path + +GROUPS = ("pass-to-pass", "fail-to-pass") + + +def split_nodeid(target): + prefix, bracket, parameter = target.partition("[") + parts = prefix.split("::") + if bracket: + parts[-1] += bracket + parameter + return parts + + +def matches(case, target): + parts = split_nodeid(target) + module = parts[0].removesuffix(".py").replace("/", ".") + classname, name = case.get("classname", ""), case.get("name", "") + if not (classname == module or classname.startswith(module + ".")): + return False + selector = parts[-1] if len(parts) > 1 else "" + classes = parts[1:-1] + if classes and classname != module + "." + ".".join(classes): + return False + return ( + not selector + or name == selector + or ("[" not in selector and name.startswith(selector + "[")) + ) + + +def capture_panels(root): + panels, digests = {}, {} + for group in GROUPS: + path = Path(root) / (group + ".xml") + if not path.exists(): + panels[group] = None + continue + with path.open("rb") as stream: + raw = stream.read(4 * 1024**2 + 1) + if not 0 < len(raw) <= 4 * 1024**2 or re.search( + rb" 20000: + raise ValueError("Too many pytest cases") + identities = [(case.get("classname"), case.get("name")) for case in cases] + if len(identities) != len(set(identities)): + raise ValueError("Duplicate pytest case evidence") + panels[group] = cases + digests[group] = hashlib.sha256(raw).hexdigest() + return panels, digests + + +def strict_assess(panels, expected, native_exit): + """The original positive-approval conditions, applied to captured cases.""" + all_cases, actual_failure = [], False + for group in GROUPS: + cases = panels[group] + if cases is None: + if actual_failure: + continue + raise ValueError("Missing preceding pytest panel") + if actual_failure: + raise ValueError( + "Pytest evidence continued after the native stop-on-failure" + ) + targets = expected[group] + if any(not any(matches(case, target) for target in targets) for case in cases): + raise ValueError("Unexpected pytest case") + all_cases.extend(cases) + failures = [case for case in cases if case.find("failure") is not None] + if any( + case.find("error") is not None or case.find("skipped") is not None + for case in cases + ): + raise ValueError("Pytest collection/error/skip is not a completed panel") + actual_failure = actual_failure or bool(failures) + if not failures and any( + not any(matches(case, target) for case in cases) for target in targets + ): + raise ValueError("Declared pytest target never ran") + if actual_failure: + if native_exit == 0: + raise ValueError("Native verifier exit disagrees with pytest failure") + return {"reward": 0, "valid_test_failure": True, "cases": len(all_cases)} + if native_exit != 0: + raise ValueError("Setup or native verifier failed without a real test failure") + if any(panels[group] is None for group in GROUPS): + raise ValueError("Missing completed pytest panel") + return {"reward": 1, "valid_test_failure": False, "cases": len(all_cases)} + + +def assess(root, expected, native_exit): + if type(native_exit) is not int: + raise ValueError("Native verifier exit must be an integer") + if not isinstance(expected, dict) or any( + not isinstance(expected.get(group), list) + or not expected[group] + or any(not isinstance(target, str) or not target for target in expected[group]) + for group in GROUPS + ): + raise ValueError("Complete exact native pytest targets required") + panels, digests = capture_panels(root) + counts = { + "cases": 0, + "matched_failures": 0, + "unexpected_cases": 0, + "unmatched_failures": 0, + "skipped_cases": 0, + "error_cases": 0, + "missing_panels": 0, + "missing_targets": 0, + } + for group in GROUPS: + cases = panels[group] + if cases is None: + counts["missing_panels"] += 1 + counts["missing_targets"] += len(expected[group]) + continue + counts["cases"] += len(cases) + for case in cases: + requested = any(matches(case, target) for target in expected[group]) + failure = case.find("failure") is not None + counts["matched_failures"] += int(requested and failure) + counts["unmatched_failures"] += int(not requested and failure) + counts["unexpected_cases"] += int(not requested) + counts["skipped_cases"] += int(case.find("skipped") is not None) + counts["error_cases"] += int(case.find("error") is not None) + counts["missing_targets"] += sum( + not any(matches(case, target) for case in cases) + for target in expected[group] + ) + if counts["matched_failures"]: + if native_exit == 0: + raise ValueError( + "Native verifier exit disagrees with requested pytest failure" + ) + return { + "reward": 0, + "valid_test_failure": True, + "cases": counts["cases"], + "diagnostic_counts": counts, + "panel_sha256": digests, + "decision": "confirmed_requested_failure_precedence", + } + result = strict_assess(panels, expected, native_exit) + result.update(diagnostic_counts=counts, panel_sha256=digests) + return result + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("--root", required=True) + parser.add_argument("--expected", required=True) + parser.add_argument("--native-exit", type=int, required=True) + args = parser.parse_args() + result = assess( + args.root, json.loads(Path(args.expected).read_bytes()), args.native_exit + ) + reward = Path(args.root) / "reward.txt" + if reward.read_text().strip() != str(result["reward"]): + raise ValueError("Native raw reward disagrees with pytest evidence") + (Path(args.root) / "pytest-evidence.json").write_text( + json.dumps(result, sort_keys=True) + "\n" + ) diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/expected-panels.json b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/expected-panels.json new file mode 100644 index 0000000000000000000000000000000000000000..a222eb5bab8d74fc0671b7b1daa0a832cef2f081 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/expected-panels.json @@ -0,0 +1,951 @@ +{ + "fail-to-pass": [ + "tests/test_plugins.py::TestPlugin1_def_list::test_definition_lists_001", + "tests/test_plugins.py::TestPlugin1_def_list::test_definition_lists_002", + "tests/test_plugins.py::TestPlugin1_def_list::test_definition_lists_003", + "tests/test_plugins.py::TestPlugin1_def_list::test_definition_lists_004", + "tests/test_plugins.py::TestPlugin1_def_list::test_definition_lists_005", + "tests/test_plugins.py::TestPlugin1_def_list::test_definition_lists_006", + "tests/test_plugins.py::TestPlugin1_def_list::test_definition_with_multiple_lines_001", + "tests/test_plugins.py::TestPlugin1_def_list::test_definition_with_multiple_lines_002", + "tests/test_plugins.py::TestPlugin1_def_list::test_definition_with_multiple_lines_003", + "tests/test_plugins.py::TestPlugin1_def_list::test_definition_with_multiple_lines_004", + "tests/test_plugins.py::TestPlugin1_def_list::test_definition_with_multiple_lines_005", + "tests/test_plugins.py::TestPlugin2_def_list::test_definition_lists_001", + "tests/test_plugins.py::TestPlugin2_def_list::test_definition_lists_002", + "tests/test_plugins.py::TestPlugin2_def_list::test_definition_lists_003", + "tests/test_plugins.py::TestPlugin2_def_list::test_definition_lists_004", + "tests/test_plugins.py::TestPlugin2_def_list::test_definition_lists_005", + "tests/test_plugins.py::TestPlugin2_def_list::test_definition_lists_006", + "tests/test_plugins.py::TestPlugin2_def_list::test_definition_with_multiple_lines_001", + "tests/test_plugins.py::TestPlugin2_def_list::test_definition_with_multiple_lines_002", + "tests/test_plugins.py::TestPlugin2_def_list::test_definition_with_multiple_lines_003", + "tests/test_plugins.py::TestPlugin2_def_list::test_definition_with_multiple_lines_004", + "tests/test_plugins.py::TestPlugin2_def_list::test_definition_with_multiple_lines_005" + ], + "pass-to-pass": [ + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_062", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_063", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_064", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_065", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_066", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_067", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_068", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_069", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_070", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_071", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_072", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_073", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_074", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_075", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_076", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_077", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_078", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_079", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_593", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_594", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_595", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_596", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_597", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_598", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_599", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_600", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_601", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_602", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_603", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_604", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_605", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_606", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_607", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_608", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_609", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_610", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_611", + "tests/test_commonmark.py::TestCommonMark::test_backslash_escapes_012", + "tests/test_commonmark.py::TestCommonMark::test_backslash_escapes_013", + "tests/test_commonmark.py::TestCommonMark::test_backslash_escapes_014", + "tests/test_commonmark.py::TestCommonMark::test_backslash_escapes_015", + "tests/test_commonmark.py::TestCommonMark::test_backslash_escapes_016", + "tests/test_commonmark.py::TestCommonMark::test_backslash_escapes_017", + "tests/test_commonmark.py::TestCommonMark::test_backslash_escapes_018", + "tests/test_commonmark.py::TestCommonMark::test_backslash_escapes_019", + "tests/test_commonmark.py::TestCommonMark::test_backslash_escapes_020", + "tests/test_commonmark.py::TestCommonMark::test_backslash_escapes_021", + "tests/test_commonmark.py::TestCommonMark::test_backslash_escapes_022", + "tests/test_commonmark.py::TestCommonMark::test_backslash_escapes_023", + "tests/test_commonmark.py::TestCommonMark::test_backslash_escapes_024", + "tests/test_commonmark.py::TestCommonMark::test_blank_lines_227", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_228", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_229", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_230", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_231", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_232", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_233", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_234", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_235", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_236", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_237", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_238", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_239", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_240", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_241", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_242", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_243", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_244", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_245", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_246", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_247", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_248", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_249", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_250", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_251", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_252", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_328", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_329", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_330", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_331", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_332", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_333", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_334", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_335", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_336", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_337", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_338", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_339", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_340", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_341", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_342", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_343", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_344", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_345", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_346", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_347", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_348", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_349", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_350", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_351", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_353", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_354", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_355", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_356", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_357", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_358", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_359", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_360", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_361", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_362", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_363", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_364", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_365", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_366", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_369", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_370", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_371", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_373", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_374", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_375", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_376", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_377", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_378", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_380", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_381", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_382", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_383", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_384", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_385", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_386", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_387", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_389", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_390", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_392", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_393", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_394", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_395", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_396", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_397", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_398", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_399", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_400", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_401", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_402", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_403", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_404", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_405", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_409", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_410", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_411", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_415", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_419", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_420", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_421", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_422", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_423", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_427", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_428", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_432", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_433", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_434", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_435", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_436", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_437", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_438", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_439", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_440", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_447", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_448", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_449", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_450", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_451", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_452", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_459", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_461", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_466", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_468", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_469", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_472", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_473", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_474", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_475", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_476", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_479", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_480", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_025", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_026", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_027", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_028", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_029", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_030", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_031", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_032", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_033", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_034", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_035", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_036", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_037", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_038", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_039", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_040", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_041", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_119", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_120", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_121", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_122", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_123", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_124", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_125", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_126", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_127", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_128", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_129", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_130", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_131", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_132", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_133", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_134", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_135", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_136", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_137", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_138", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_139", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_140", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_141", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_142", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_143", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_144", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_145", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_146", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_147", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_633", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_634", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_635", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_636", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_637", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_638", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_639", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_640", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_641", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_642", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_643", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_644", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_645", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_646", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_647", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_148", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_149", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_150", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_151", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_152", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_153", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_154", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_155", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_156", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_157", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_158", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_159", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_160", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_161", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_162", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_163", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_164", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_165", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_166", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_167", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_168", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_169", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_170", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_171", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_172", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_173", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_174", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_175", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_176", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_177", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_178", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_179", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_180", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_181", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_182", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_183", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_184", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_185", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_186", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_187", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_188", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_189", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_190", + "tests/test_commonmark.py::TestCommonMark::test_images_571", + "tests/test_commonmark.py::TestCommonMark::test_images_572", + "tests/test_commonmark.py::TestCommonMark::test_images_574", + "tests/test_commonmark.py::TestCommonMark::test_images_575", + "tests/test_commonmark.py::TestCommonMark::test_images_576", + "tests/test_commonmark.py::TestCommonMark::test_images_577", + "tests/test_commonmark.py::TestCommonMark::test_images_578", + "tests/test_commonmark.py::TestCommonMark::test_images_579", + "tests/test_commonmark.py::TestCommonMark::test_images_580", + "tests/test_commonmark.py::TestCommonMark::test_images_581", + "tests/test_commonmark.py::TestCommonMark::test_images_582", + "tests/test_commonmark.py::TestCommonMark::test_images_583", + "tests/test_commonmark.py::TestCommonMark::test_images_584", + "tests/test_commonmark.py::TestCommonMark::test_images_585", + "tests/test_commonmark.py::TestCommonMark::test_images_586", + "tests/test_commonmark.py::TestCommonMark::test_images_587", + "tests/test_commonmark.py::TestCommonMark::test_images_588", + "tests/test_commonmark.py::TestCommonMark::test_images_589", + "tests/test_commonmark.py::TestCommonMark::test_images_590", + "tests/test_commonmark.py::TestCommonMark::test_images_591", + "tests/test_commonmark.py::TestCommonMark::test_images_592", + "tests/test_commonmark.py::TestCommonMark::test_indented_code_blocks_107", + "tests/test_commonmark.py::TestCommonMark::test_indented_code_blocks_108", + "tests/test_commonmark.py::TestCommonMark::test_indented_code_blocks_109", + "tests/test_commonmark.py::TestCommonMark::test_indented_code_blocks_110", + "tests/test_commonmark.py::TestCommonMark::test_indented_code_blocks_111", + "tests/test_commonmark.py::TestCommonMark::test_indented_code_blocks_112", + "tests/test_commonmark.py::TestCommonMark::test_indented_code_blocks_113", + "tests/test_commonmark.py::TestCommonMark::test_indented_code_blocks_114", + "tests/test_commonmark.py::TestCommonMark::test_indented_code_blocks_115", + "tests/test_commonmark.py::TestCommonMark::test_indented_code_blocks_116", + "tests/test_commonmark.py::TestCommonMark::test_indented_code_blocks_117", + "tests/test_commonmark.py::TestCommonMark::test_indented_code_blocks_118", + "tests/test_commonmark.py::TestCommonMark::test_inlines_327", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_192", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_193", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_194", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_195", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_196", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_197", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_198", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_199", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_200", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_201", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_202", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_203", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_204", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_205", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_206", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_207", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_208", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_209", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_210", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_211", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_212", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_213", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_214", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_215", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_216", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_217", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_218", + "tests/test_commonmark.py::TestCommonMark::test_links_481", + "tests/test_commonmark.py::TestCommonMark::test_links_482", + "tests/test_commonmark.py::TestCommonMark::test_links_483", + "tests/test_commonmark.py::TestCommonMark::test_links_484", + "tests/test_commonmark.py::TestCommonMark::test_links_485", + "tests/test_commonmark.py::TestCommonMark::test_links_486", + "tests/test_commonmark.py::TestCommonMark::test_links_487", + "tests/test_commonmark.py::TestCommonMark::test_links_488", + "tests/test_commonmark.py::TestCommonMark::test_links_489", + "tests/test_commonmark.py::TestCommonMark::test_links_490", + "tests/test_commonmark.py::TestCommonMark::test_links_491", + "tests/test_commonmark.py::TestCommonMark::test_links_492", + "tests/test_commonmark.py::TestCommonMark::test_links_493", + "tests/test_commonmark.py::TestCommonMark::test_links_494", + "tests/test_commonmark.py::TestCommonMark::test_links_497", + "tests/test_commonmark.py::TestCommonMark::test_links_498", + "tests/test_commonmark.py::TestCommonMark::test_links_499", + "tests/test_commonmark.py::TestCommonMark::test_links_500", + "tests/test_commonmark.py::TestCommonMark::test_links_501", + "tests/test_commonmark.py::TestCommonMark::test_links_502", + "tests/test_commonmark.py::TestCommonMark::test_links_503", + "tests/test_commonmark.py::TestCommonMark::test_links_505", + "tests/test_commonmark.py::TestCommonMark::test_links_506", + "tests/test_commonmark.py::TestCommonMark::test_links_507", + "tests/test_commonmark.py::TestCommonMark::test_links_508", + "tests/test_commonmark.py::TestCommonMark::test_links_509", + "tests/test_commonmark.py::TestCommonMark::test_links_510", + "tests/test_commonmark.py::TestCommonMark::test_links_511", + "tests/test_commonmark.py::TestCommonMark::test_links_512", + "tests/test_commonmark.py::TestCommonMark::test_links_513", + "tests/test_commonmark.py::TestCommonMark::test_links_514", + "tests/test_commonmark.py::TestCommonMark::test_links_515", + "tests/test_commonmark.py::TestCommonMark::test_links_516", + "tests/test_commonmark.py::TestCommonMark::test_links_520", + "tests/test_commonmark.py::TestCommonMark::test_links_521", + "tests/test_commonmark.py::TestCommonMark::test_links_522", + "tests/test_commonmark.py::TestCommonMark::test_links_523", + "tests/test_commonmark.py::TestCommonMark::test_links_524", + "tests/test_commonmark.py::TestCommonMark::test_links_525", + "tests/test_commonmark.py::TestCommonMark::test_links_526", + "tests/test_commonmark.py::TestCommonMark::test_links_527", + "tests/test_commonmark.py::TestCommonMark::test_links_528", + "tests/test_commonmark.py::TestCommonMark::test_links_529", + "tests/test_commonmark.py::TestCommonMark::test_links_530", + "tests/test_commonmark.py::TestCommonMark::test_links_533", + "tests/test_commonmark.py::TestCommonMark::test_links_534", + "tests/test_commonmark.py::TestCommonMark::test_links_535", + "tests/test_commonmark.py::TestCommonMark::test_links_536", + "tests/test_commonmark.py::TestCommonMark::test_links_537", + "tests/test_commonmark.py::TestCommonMark::test_links_538", + "tests/test_commonmark.py::TestCommonMark::test_links_539", + "tests/test_commonmark.py::TestCommonMark::test_links_540", + "tests/test_commonmark.py::TestCommonMark::test_links_541", + "tests/test_commonmark.py::TestCommonMark::test_links_542", + "tests/test_commonmark.py::TestCommonMark::test_links_543", + "tests/test_commonmark.py::TestCommonMark::test_links_544", + "tests/test_commonmark.py::TestCommonMark::test_links_545", + "tests/test_commonmark.py::TestCommonMark::test_links_546", + "tests/test_commonmark.py::TestCommonMark::test_links_547", + "tests/test_commonmark.py::TestCommonMark::test_links_548", + "tests/test_commonmark.py::TestCommonMark::test_links_549", + "tests/test_commonmark.py::TestCommonMark::test_links_550", + "tests/test_commonmark.py::TestCommonMark::test_links_551", + "tests/test_commonmark.py::TestCommonMark::test_links_552", + "tests/test_commonmark.py::TestCommonMark::test_links_553", + "tests/test_commonmark.py::TestCommonMark::test_links_554", + "tests/test_commonmark.py::TestCommonMark::test_links_555", + "tests/test_commonmark.py::TestCommonMark::test_links_556", + "tests/test_commonmark.py::TestCommonMark::test_links_557", + "tests/test_commonmark.py::TestCommonMark::test_links_558", + "tests/test_commonmark.py::TestCommonMark::test_links_559", + "tests/test_commonmark.py::TestCommonMark::test_links_560", + "tests/test_commonmark.py::TestCommonMark::test_links_561", + "tests/test_commonmark.py::TestCommonMark::test_links_562", + "tests/test_commonmark.py::TestCommonMark::test_links_563", + "tests/test_commonmark.py::TestCommonMark::test_links_564", + "tests/test_commonmark.py::TestCommonMark::test_links_565", + "tests/test_commonmark.py::TestCommonMark::test_links_566", + "tests/test_commonmark.py::TestCommonMark::test_links_567", + "tests/test_commonmark.py::TestCommonMark::test_links_568", + "tests/test_commonmark.py::TestCommonMark::test_links_569", + "tests/test_commonmark.py::TestCommonMark::test_links_570", + "tests/test_commonmark.py::TestCommonMark::test_list_items_253", + "tests/test_commonmark.py::TestCommonMark::test_list_items_254", + "tests/test_commonmark.py::TestCommonMark::test_list_items_255", + "tests/test_commonmark.py::TestCommonMark::test_list_items_256", + "tests/test_commonmark.py::TestCommonMark::test_list_items_257", + "tests/test_commonmark.py::TestCommonMark::test_list_items_258", + "tests/test_commonmark.py::TestCommonMark::test_list_items_259", + "tests/test_commonmark.py::TestCommonMark::test_list_items_260", + "tests/test_commonmark.py::TestCommonMark::test_list_items_261", + "tests/test_commonmark.py::TestCommonMark::test_list_items_262", + "tests/test_commonmark.py::TestCommonMark::test_list_items_263", + "tests/test_commonmark.py::TestCommonMark::test_list_items_264", + "tests/test_commonmark.py::TestCommonMark::test_list_items_265", + "tests/test_commonmark.py::TestCommonMark::test_list_items_266", + "tests/test_commonmark.py::TestCommonMark::test_list_items_267", + "tests/test_commonmark.py::TestCommonMark::test_list_items_268", + "tests/test_commonmark.py::TestCommonMark::test_list_items_269", + "tests/test_commonmark.py::TestCommonMark::test_list_items_270", + "tests/test_commonmark.py::TestCommonMark::test_list_items_271", + "tests/test_commonmark.py::TestCommonMark::test_list_items_272", + "tests/test_commonmark.py::TestCommonMark::test_list_items_273", + "tests/test_commonmark.py::TestCommonMark::test_list_items_274", + "tests/test_commonmark.py::TestCommonMark::test_list_items_275", + "tests/test_commonmark.py::TestCommonMark::test_list_items_276", + "tests/test_commonmark.py::TestCommonMark::test_list_items_277", + "tests/test_commonmark.py::TestCommonMark::test_list_items_278", + "tests/test_commonmark.py::TestCommonMark::test_list_items_279", + "tests/test_commonmark.py::TestCommonMark::test_list_items_280", + "tests/test_commonmark.py::TestCommonMark::test_list_items_281", + "tests/test_commonmark.py::TestCommonMark::test_list_items_282", + "tests/test_commonmark.py::TestCommonMark::test_list_items_283", + "tests/test_commonmark.py::TestCommonMark::test_list_items_284", + "tests/test_commonmark.py::TestCommonMark::test_list_items_285", + "tests/test_commonmark.py::TestCommonMark::test_list_items_286", + "tests/test_commonmark.py::TestCommonMark::test_list_items_287", + "tests/test_commonmark.py::TestCommonMark::test_list_items_288", + "tests/test_commonmark.py::TestCommonMark::test_list_items_289", + "tests/test_commonmark.py::TestCommonMark::test_list_items_290", + "tests/test_commonmark.py::TestCommonMark::test_list_items_291", + "tests/test_commonmark.py::TestCommonMark::test_list_items_292", + "tests/test_commonmark.py::TestCommonMark::test_list_items_293", + "tests/test_commonmark.py::TestCommonMark::test_list_items_294", + "tests/test_commonmark.py::TestCommonMark::test_list_items_295", + "tests/test_commonmark.py::TestCommonMark::test_list_items_296", + "tests/test_commonmark.py::TestCommonMark::test_list_items_297", + "tests/test_commonmark.py::TestCommonMark::test_list_items_298", + "tests/test_commonmark.py::TestCommonMark::test_list_items_299", + "tests/test_commonmark.py::TestCommonMark::test_list_items_300", + "tests/test_commonmark.py::TestCommonMark::test_lists_301", + "tests/test_commonmark.py::TestCommonMark::test_lists_302", + "tests/test_commonmark.py::TestCommonMark::test_lists_303", + "tests/test_commonmark.py::TestCommonMark::test_lists_304", + "tests/test_commonmark.py::TestCommonMark::test_lists_305", + "tests/test_commonmark.py::TestCommonMark::test_lists_306", + "tests/test_commonmark.py::TestCommonMark::test_lists_307", + "tests/test_commonmark.py::TestCommonMark::test_lists_308", + "tests/test_commonmark.py::TestCommonMark::test_lists_309", + "tests/test_commonmark.py::TestCommonMark::test_lists_310", + "tests/test_commonmark.py::TestCommonMark::test_lists_311", + "tests/test_commonmark.py::TestCommonMark::test_lists_312", + "tests/test_commonmark.py::TestCommonMark::test_lists_313", + "tests/test_commonmark.py::TestCommonMark::test_lists_314", + "tests/test_commonmark.py::TestCommonMark::test_lists_315", + "tests/test_commonmark.py::TestCommonMark::test_lists_316", + "tests/test_commonmark.py::TestCommonMark::test_lists_317", + "tests/test_commonmark.py::TestCommonMark::test_lists_318", + "tests/test_commonmark.py::TestCommonMark::test_lists_319", + "tests/test_commonmark.py::TestCommonMark::test_lists_320", + "tests/test_commonmark.py::TestCommonMark::test_lists_321", + "tests/test_commonmark.py::TestCommonMark::test_lists_322", + "tests/test_commonmark.py::TestCommonMark::test_lists_323", + "tests/test_commonmark.py::TestCommonMark::test_lists_324", + "tests/test_commonmark.py::TestCommonMark::test_lists_325", + "tests/test_commonmark.py::TestCommonMark::test_lists_326", + "tests/test_commonmark.py::TestCommonMark::test_paragraphs_219", + "tests/test_commonmark.py::TestCommonMark::test_paragraphs_220", + "tests/test_commonmark.py::TestCommonMark::test_paragraphs_221", + "tests/test_commonmark.py::TestCommonMark::test_paragraphs_222", + "tests/test_commonmark.py::TestCommonMark::test_paragraphs_223", + "tests/test_commonmark.py::TestCommonMark::test_paragraphs_224", + "tests/test_commonmark.py::TestCommonMark::test_paragraphs_225", + "tests/test_commonmark.py::TestCommonMark::test_paragraphs_226", + "tests/test_commonmark.py::TestCommonMark::test_precedence_042", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_612", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_613", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_614", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_615", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_616", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_617", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_618", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_619", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_620", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_621", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_622", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_623", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_624", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_625", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_626", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_627", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_628", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_629", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_630", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_631", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_632", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_080", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_081", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_082", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_083", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_084", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_085", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_086", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_087", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_088", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_089", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_090", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_091", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_092", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_094", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_095", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_096", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_097", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_098", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_099", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_100", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_101", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_102", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_103", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_104", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_105", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_106", + "tests/test_commonmark.py::TestCommonMark::test_soft_line_breaks_648", + "tests/test_commonmark.py::TestCommonMark::test_soft_line_breaks_649", + "tests/test_commonmark.py::TestCommonMark::test_tabs_001", + "tests/test_commonmark.py::TestCommonMark::test_tabs_002", + "tests/test_commonmark.py::TestCommonMark::test_tabs_003", + "tests/test_commonmark.py::TestCommonMark::test_tabs_004", + "tests/test_commonmark.py::TestCommonMark::test_tabs_005", + "tests/test_commonmark.py::TestCommonMark::test_tabs_006", + "tests/test_commonmark.py::TestCommonMark::test_tabs_007", + "tests/test_commonmark.py::TestCommonMark::test_tabs_008", + "tests/test_commonmark.py::TestCommonMark::test_tabs_009", + "tests/test_commonmark.py::TestCommonMark::test_tabs_010", + "tests/test_commonmark.py::TestCommonMark::test_tabs_011", + "tests/test_commonmark.py::TestCommonMark::test_textual_content_650", + "tests/test_commonmark.py::TestCommonMark::test_textual_content_651", + "tests/test_commonmark.py::TestCommonMark::test_textual_content_652", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_043", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_044", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_045", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_046", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_047", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_048", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_049", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_050", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_051", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_052", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_053", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_054", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_055", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_056", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_057", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_058", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_059", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_060", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_061", + "tests/test_directives.py::TestDirective_rst_admonition::test_admonition_001", + "tests/test_directives.py::TestDirective_rst_admonition::test_admonition_002", + "tests/test_directives.py::TestDirective_rst_admonition::test_admonition_003", + "tests/test_directives.py::TestDirective_rst_admonition::test_admonition_004", + "tests/test_directives.py::TestDirective_rst_toc::test_collapse_toc_001", + "tests/test_directives.py::TestDirective_rst_toc::test_complex_001", + "tests/test_directives.py::TestDirective_rst_toc::test_html_in_heading_001", + "tests/test_directives.py::TestDirective_rst_toc::test_insane_001", + "tests/test_directives.py::TestDirective_rst_toc::test_insane_002", + "tests/test_directives.py::TestDirective_rst_toc::test_invalid_option_001", + "tests/test_directives.py::TestDirective_rst_toc::test_invalid_option_002", + "tests/test_directives.py::TestDirective_rst_toc::test_invalid_option_003", + "tests/test_directives.py::TestDirective_rst_toc::test_link_in_heading_001", + "tests/test_directives.py::TestDirective_rst_toc::test_no_toc_001", + "tests/test_directives.py::TestDirective_rst_toc::test_no_toc_002", + "tests/test_directives.py::TestDirective_rst_toc::test_simple_toc_001", + "tests/test_directives.py::TestDirective_fenced_admonition::test_admonition_001", + "tests/test_directives.py::TestDirective_fenced_admonition::test_admonition_002", + "tests/test_directives.py::TestDirective_fenced_admonition::test_admonition_003", + "tests/test_directives.py::TestDirective_fenced_admonition::test_admonition_004", + "tests/test_directives.py::TestDirective_fenced_admonition::test_admonition_005", + "tests/test_directives.py::TestDirective_fenced_admonition::test_admonition_006", + "tests/test_directives.py::TestDirective_fenced_admonition::test_admonition_007", + "tests/test_directives.py::TestDirective_fenced_admonition::test_admonition_008", + "tests/test_directives.py::TestDirective_fenced_toc::test_collapse_toc_001", + "tests/test_directives.py::TestDirective_fenced_toc::test_complex_001", + "tests/test_directives.py::TestDirective_fenced_toc::test_html_in_heading_001", + "tests/test_directives.py::TestDirective_fenced_toc::test_insane_001", + "tests/test_directives.py::TestDirective_fenced_toc::test_insane_002", + "tests/test_directives.py::TestDirective_fenced_toc::test_invalid_option_001", + "tests/test_directives.py::TestDirective_fenced_toc::test_invalid_option_002", + "tests/test_directives.py::TestDirective_fenced_toc::test_invalid_option_003", + "tests/test_directives.py::TestDirective_fenced_toc::test_link_in_heading_001", + "tests/test_directives.py::TestDirective_fenced_toc::test_no_toc_001", + "tests/test_directives.py::TestDirective_fenced_toc::test_no_toc_002", + "tests/test_directives.py::TestDirective_fenced_toc::test_simple_toc_001", + "tests/test_directives.py::TestDirective_fenced_image::test_align_options_001", + "tests/test_directives.py::TestDirective_fenced_image::test_align_options_002", + "tests/test_directives.py::TestDirective_fenced_image::test_all_options_001", + "tests/test_directives.py::TestDirective_fenced_image::test_alt_option_001", + "tests/test_directives.py::TestDirective_fenced_image::test_ampersand_in_source_001", + "tests/test_directives.py::TestDirective_fenced_image::test_ampersand_in_target_001", + "tests/test_directives.py::TestDirective_fenced_image::test_no_options_001", + "tests/test_directives.py::TestDirective_fenced_image::test_target_option_001", + "tests/test_directives.py::TestDirective_fenced_image::test_width_and_height_001", + "tests/test_directives.py::TestDirective_fenced_image::test_width_and_height_002", + "tests/test_directives.py::TestDirective_fenced_figure::test_align_options_001", + "tests/test_directives.py::TestDirective_fenced_figure::test_align_options_002", + "tests/test_directives.py::TestDirective_fenced_figure::test_all_options_001", + "tests/test_directives.py::TestDirective_fenced_figure::test_alt_option_001", + "tests/test_directives.py::TestDirective_fenced_figure::test_caption_001", + "tests/test_directives.py::TestDirective_fenced_figure::test_legend_001", + "tests/test_directives.py::TestDirective_fenced_figure::test_legend_002", + "tests/test_directives.py::TestDirective_fenced_figure::test_no_options_001", + "tests/test_directives.py::TestDirective_fenced_figure::test_target_option_001", + "tests/test_directives.py::TestDirective_fenced_figure::test_width_and_height_001", + "tests/test_directives.py::TestDirective_fenced_figure::test_width_and_height_002", + "tests/test_directives.py::TestDirective_fenced_figure::test_width_and_height_003", + "tests/test_directives.py::TestCustomizeToc::test_colon_fenced_toc", + "tests/test_directives.py::TestCustomizeToc::test_fenced_toc", + "tests/test_directives.py::TestCustomizeToc::test_rst_toc", + "tests/test_directives.py::TestDirectiveInclude::test_html_include", + "tests/test_directives.py::TestDirectiveInclude::test_include_missing_source", + "tests/test_hooks.py::TestTocHook::test_complex_toc_001", + "tests/test_hooks.py::TestTocHook::test_customize_heading_id_func", + "tests/test_hooks.py::TestTocHook::test_html_in_heading_001", + "tests/test_hooks.py::TestTocHook::test_insane_toc_001", + "tests/test_hooks.py::TestTocHook::test_insane_toc_002", + "tests/test_hooks.py::TestTocHook::test_link_in_heading_001", + "tests/test_hooks.py::TestTocHook::test_simple_toc_001", + "tests/test_misc.py::TestMiscCases::test_allow_data_protocols", + "tests/test_misc.py::TestMiscCases::test_allow_harmful_protocols", + "tests/test_misc.py::TestMiscCases::test_ast_output", + "tests/test_misc.py::TestMiscCases::test_ast_url", + "tests/test_misc.py::TestMiscCases::test_before_parse_hooks", + "tests/test_misc.py::TestMiscCases::test_emsp", + "tests/test_misc.py::TestMiscCases::test_escape_html", + "tests/test_misc.py::TestMiscCases::test_hard_wrap", + "tests/test_misc.py::TestMiscCases::test_harmful_links", + "tests/test_misc.py::TestMiscCases::test_html_tag_text_following_list", + "tests/test_misc.py::TestMiscCases::test_markdown_func", + "tests/test_misc.py::TestMiscCases::test_none", + "tests/test_misc.py::TestMiscCases::test_ref_link", + "tests/test_misc.py::TestMiscCases::test_use_plugin", + "tests/test_plugins.py::TestPlugin1_url::test_url_plugin_001", + "tests/test_plugins.py::TestPlugin1_url::test_url_plugin_002", + "tests/test_plugins.py::TestPlugin1_url::test_url_plugin_003", + "tests/test_plugins.py::TestPlugin2_url::test_url_plugin_001", + "tests/test_plugins.py::TestPlugin2_url::test_url_plugin_002", + "tests/test_plugins.py::TestPlugin2_url::test_url_plugin_003", + "tests/test_plugins.py::TestPlugin1_strikethrough::test_strikethrough_001", + "tests/test_plugins.py::TestPlugin1_strikethrough::test_strikethrough_002", + "tests/test_plugins.py::TestPlugin1_strikethrough::test_strikethrough_003", + "tests/test_plugins.py::TestPlugin1_strikethrough::test_strikethrough_004", + "tests/test_plugins.py::TestPlugin1_strikethrough::test_strikethrough_005", + "tests/test_plugins.py::TestPlugin1_strikethrough::test_strikethrough_006", + "tests/test_plugins.py::TestPlugin1_strikethrough::test_strikethrough_007", + "tests/test_plugins.py::TestPlugin2_strikethrough::test_strikethrough_001", + "tests/test_plugins.py::TestPlugin2_strikethrough::test_strikethrough_002", + "tests/test_plugins.py::TestPlugin2_strikethrough::test_strikethrough_003", + "tests/test_plugins.py::TestPlugin2_strikethrough::test_strikethrough_004", + "tests/test_plugins.py::TestPlugin2_strikethrough::test_strikethrough_005", + "tests/test_plugins.py::TestPlugin2_strikethrough::test_strikethrough_006", + "tests/test_plugins.py::TestPlugin2_strikethrough::test_strikethrough_007", + "tests/test_plugins.py::TestPlugin1_mark::test_escape_mark_001", + "tests/test_plugins.py::TestPlugin1_mark::test_escape_mark_002", + "tests/test_plugins.py::TestPlugin1_mark::test_mark_001", + "tests/test_plugins.py::TestPlugin1_mark::test_mark_link_001", + "tests/test_plugins.py::TestPlugin1_mark::test_mark_link_002", + "tests/test_plugins.py::TestPlugin1_mark::test_normal_mark_001", + "tests/test_plugins.py::TestPlugin1_mark::test_normal_mark_002", + "tests/test_plugins.py::TestPlugin1_mark::test_normal_mark_003", + "tests/test_plugins.py::TestPlugin1_mark::test_normal_mark_004", + "tests/test_plugins.py::TestPlugin2_mark::test_escape_mark_001", + "tests/test_plugins.py::TestPlugin2_mark::test_escape_mark_002", + "tests/test_plugins.py::TestPlugin2_mark::test_mark_001", + "tests/test_plugins.py::TestPlugin2_mark::test_mark_link_001", + "tests/test_plugins.py::TestPlugin2_mark::test_mark_link_002", + "tests/test_plugins.py::TestPlugin2_mark::test_normal_mark_001", + "tests/test_plugins.py::TestPlugin2_mark::test_normal_mark_002", + "tests/test_plugins.py::TestPlugin2_mark::test_normal_mark_003", + "tests/test_plugins.py::TestPlugin2_mark::test_normal_mark_004", + "tests/test_plugins.py::TestPlugin1_insert::test_escape_insert_001", + "tests/test_plugins.py::TestPlugin1_insert::test_escape_insert_002", + "tests/test_plugins.py::TestPlugin1_insert::test_insert_001", + "tests/test_plugins.py::TestPlugin1_insert::test_insert_link_001", + "tests/test_plugins.py::TestPlugin1_insert::test_insert_link_002", + "tests/test_plugins.py::TestPlugin1_insert::test_normal_insert_001", + "tests/test_plugins.py::TestPlugin1_insert::test_normal_insert_002", + "tests/test_plugins.py::TestPlugin1_insert::test_normal_insert_003", + "tests/test_plugins.py::TestPlugin1_insert::test_normal_insert_004", + "tests/test_plugins.py::TestPlugin2_insert::test_escape_insert_001", + "tests/test_plugins.py::TestPlugin2_insert::test_escape_insert_002", + "tests/test_plugins.py::TestPlugin2_insert::test_insert_001", + "tests/test_plugins.py::TestPlugin2_insert::test_insert_link_001", + "tests/test_plugins.py::TestPlugin2_insert::test_insert_link_002", + "tests/test_plugins.py::TestPlugin2_insert::test_normal_insert_001", + "tests/test_plugins.py::TestPlugin2_insert::test_normal_insert_002", + "tests/test_plugins.py::TestPlugin2_insert::test_normal_insert_003", + "tests/test_plugins.py::TestPlugin2_insert::test_normal_insert_004", + "tests/test_plugins.py::TestPlugin1_superscript::test_superscript_001", + "tests/test_plugins.py::TestPlugin1_superscript::test_superscript_002", + "tests/test_plugins.py::TestPlugin1_superscript::test_superscript_003", + "tests/test_plugins.py::TestPlugin1_superscript::test_superscript_004", + "tests/test_plugins.py::TestPlugin2_superscript::test_superscript_001", + "tests/test_plugins.py::TestPlugin2_superscript::test_superscript_002", + "tests/test_plugins.py::TestPlugin2_superscript::test_superscript_003", + "tests/test_plugins.py::TestPlugin2_superscript::test_superscript_004", + "tests/test_plugins.py::TestPlugin1_subscript::test_subscript_001", + "tests/test_plugins.py::TestPlugin1_subscript::test_subscript_002", + "tests/test_plugins.py::TestPlugin1_subscript::test_subscript_003", + "tests/test_plugins.py::TestPlugin1_subscript::test_subscript_004", + "tests/test_plugins.py::TestPlugin2_subscript::test_subscript_001", + "tests/test_plugins.py::TestPlugin2_subscript::test_subscript_002", + "tests/test_plugins.py::TestPlugin2_subscript::test_subscript_003", + "tests/test_plugins.py::TestPlugin2_subscript::test_subscript_004", + "tests/test_plugins.py::TestPlugin1_task_lists::test_task_lists_001", + "tests/test_plugins.py::TestPlugin1_task_lists::test_task_lists_002", + "tests/test_plugins.py::TestPlugin1_task_lists::test_task_lists_003", + "tests/test_plugins.py::TestPlugin1_task_lists::test_task_lists_004", + "tests/test_plugins.py::TestPlugin1_task_lists::test_task_lists_005", + "tests/test_plugins.py::TestPlugin1_task_lists::test_task_lists_006", + "tests/test_plugins.py::TestPlugin1_task_lists::test_task_lists_007", + "tests/test_plugins.py::TestPlugin1_task_lists::test_task_lists_008", + "tests/test_plugins.py::TestPlugin2_task_lists::test_task_lists_001", + "tests/test_plugins.py::TestPlugin2_task_lists::test_task_lists_002", + "tests/test_plugins.py::TestPlugin2_task_lists::test_task_lists_003", + "tests/test_plugins.py::TestPlugin2_task_lists::test_task_lists_004", + "tests/test_plugins.py::TestPlugin2_task_lists::test_task_lists_005", + "tests/test_plugins.py::TestPlugin2_task_lists::test_task_lists_006", + "tests/test_plugins.py::TestPlugin2_task_lists::test_task_lists_007", + "tests/test_plugins.py::TestPlugin2_task_lists::test_task_lists_008", + "tests/test_plugins.py::TestPlugin1_table::test_align_table_001", + "tests/test_plugins.py::TestPlugin1_table::test_align_table_002", + "tests/test_plugins.py::TestPlugin1_table::test_misc_table_001", + "tests/test_plugins.py::TestPlugin1_table::test_misc_table_002", + "tests/test_plugins.py::TestPlugin1_table::test_misc_table_003", + "tests/test_plugins.py::TestPlugin1_table::test_mismatch_length_001", + "tests/test_plugins.py::TestPlugin1_table::test_mismatch_length_002", + "tests/test_plugins.py::TestPlugin1_table::test_mismatch_length_003", + "tests/test_plugins.py::TestPlugin1_table::test_mismatch_length_004", + "tests/test_plugins.py::TestPlugin1_table::test_nptable_001", + "tests/test_plugins.py::TestPlugin1_table::test_table_001", + "tests/test_plugins.py::TestPlugin1_table::test_table_002", + "tests/test_plugins.py::TestPlugin2_table::test_align_table_001", + "tests/test_plugins.py::TestPlugin2_table::test_align_table_002", + "tests/test_plugins.py::TestPlugin2_table::test_misc_table_001", + "tests/test_plugins.py::TestPlugin2_table::test_misc_table_002", + "tests/test_plugins.py::TestPlugin2_table::test_misc_table_003", + "tests/test_plugins.py::TestPlugin2_table::test_mismatch_length_001", + "tests/test_plugins.py::TestPlugin2_table::test_mismatch_length_002", + "tests/test_plugins.py::TestPlugin2_table::test_mismatch_length_003", + "tests/test_plugins.py::TestPlugin2_table::test_mismatch_length_004", + "tests/test_plugins.py::TestPlugin2_table::test_nptable_001", + "tests/test_plugins.py::TestPlugin2_table::test_table_001", + "tests/test_plugins.py::TestPlugin2_table::test_table_002", + "tests/test_plugins.py::TestPlugin1_footnotes::test_footnotes_001", + "tests/test_plugins.py::TestPlugin1_footnotes::test_footnotes_002", + "tests/test_plugins.py::TestPlugin1_footnotes::test_footnotes_003", + "tests/test_plugins.py::TestPlugin2_footnotes::test_footnotes_001", + "tests/test_plugins.py::TestPlugin2_footnotes::test_footnotes_002", + "tests/test_plugins.py::TestPlugin2_footnotes::test_footnotes_003", + "tests/test_plugins.py::TestPlugin1_abbr::test_abbreviation_001", + "tests/test_plugins.py::TestPlugin1_abbr::test_abbreviation_002", + "tests/test_plugins.py::TestPlugin1_abbr::test_abbreviation_003", + "tests/test_plugins.py::TestPlugin1_abbr::test_abbreviation_004", + "tests/test_plugins.py::TestPlugin1_abbr::test_abbreviation_005", + "tests/test_plugins.py::TestPlugin1_abbr::test_abbreviation_006", + "tests/test_plugins.py::TestPlugin1_abbr::test_abbreviation_007", + "tests/test_plugins.py::TestPlugin1_abbr::test_abbreviation_008", + "tests/test_plugins.py::TestPlugin1_abbr::test_abbreviation_009", + "tests/test_plugins.py::TestPlugin1_abbr::test_abbreviation_010", + "tests/test_plugins.py::TestPlugin2_abbr::test_abbreviation_001", + "tests/test_plugins.py::TestPlugin2_abbr::test_abbreviation_002", + "tests/test_plugins.py::TestPlugin2_abbr::test_abbreviation_003", + "tests/test_plugins.py::TestPlugin2_abbr::test_abbreviation_004", + "tests/test_plugins.py::TestPlugin2_abbr::test_abbreviation_005", + "tests/test_plugins.py::TestPlugin2_abbr::test_abbreviation_006", + "tests/test_plugins.py::TestPlugin2_abbr::test_abbreviation_007", + "tests/test_plugins.py::TestPlugin2_abbr::test_abbreviation_008", + "tests/test_plugins.py::TestPlugin2_abbr::test_abbreviation_009", + "tests/test_plugins.py::TestPlugin2_abbr::test_abbreviation_010", + "tests/test_plugins.py::TestPlugin1_math::test_block_math_001", + "tests/test_plugins.py::TestPlugin1_math::test_block_math_002", + "tests/test_plugins.py::TestPlugin1_math::test_block_math_003", + "tests/test_plugins.py::TestPlugin1_math::test_block_math_004", + "tests/test_plugins.py::TestPlugin1_math::test_inline_math_001", + "tests/test_plugins.py::TestPlugin2_math::test_block_math_001", + "tests/test_plugins.py::TestPlugin2_math::test_block_math_002", + "tests/test_plugins.py::TestPlugin2_math::test_block_math_003", + "tests/test_plugins.py::TestPlugin2_math::test_block_math_004", + "tests/test_plugins.py::TestPlugin2_math::test_inline_math_001", + "tests/test_plugins.py::TestPlugin1_ruby::test_ruby_splits_001", + "tests/test_plugins.py::TestPlugin1_ruby::test_ruby_splits_002", + "tests/test_plugins.py::TestPlugin1_ruby::test_ruby_with_link_001", + "tests/test_plugins.py::TestPlugin1_ruby::test_ruby_with_link_002", + "tests/test_plugins.py::TestPlugin1_ruby::test_ruby_with_link_003", + "tests/test_plugins.py::TestPlugin1_ruby::test_ruby_without_link_001", + "tests/test_plugins.py::TestPlugin1_ruby::test_ruby_without_link_002", + "tests/test_plugins.py::TestPlugin1_ruby::test_ruby_without_link_003", + "tests/test_plugins.py::TestPlugin1_ruby::test_ruby_without_link_004", + "tests/test_plugins.py::TestPlugin2_ruby::test_ruby_splits_001", + "tests/test_plugins.py::TestPlugin2_ruby::test_ruby_splits_002", + "tests/test_plugins.py::TestPlugin2_ruby::test_ruby_with_link_001", + "tests/test_plugins.py::TestPlugin2_ruby::test_ruby_with_link_002", + "tests/test_plugins.py::TestPlugin2_ruby::test_ruby_with_link_003", + "tests/test_plugins.py::TestPlugin2_ruby::test_ruby_without_link_001", + "tests/test_plugins.py::TestPlugin2_ruby::test_ruby_without_link_002", + "tests/test_plugins.py::TestPlugin2_ruby::test_ruby_without_link_003", + "tests/test_plugins.py::TestPlugin2_ruby::test_ruby_without_link_004", + "tests/test_plugins.py::TestPlugin1_spoiler::test_block_spoiler_001", + "tests/test_plugins.py::TestPlugin1_spoiler::test_block_spoiler_002", + "tests/test_plugins.py::TestPlugin1_spoiler::test_block_spoiler_003", + "tests/test_plugins.py::TestPlugin1_spoiler::test_block_spoiler_004", + "tests/test_plugins.py::TestPlugin1_spoiler::test_block_spoiler_005", + "tests/test_plugins.py::TestPlugin1_spoiler::test_inline_spoiler_001", + "tests/test_plugins.py::TestPlugin1_spoiler::test_inline_spoiler_002", + "tests/test_plugins.py::TestPlugin1_spoiler::test_inline_spoiler_003", + "tests/test_plugins.py::TestPlugin2_spoiler::test_block_spoiler_001", + "tests/test_plugins.py::TestPlugin2_spoiler::test_block_spoiler_002", + "tests/test_plugins.py::TestPlugin2_spoiler::test_block_spoiler_003", + "tests/test_plugins.py::TestPlugin2_spoiler::test_block_spoiler_004", + "tests/test_plugins.py::TestPlugin2_spoiler::test_block_spoiler_005", + "tests/test_plugins.py::TestPlugin2_spoiler::test_inline_spoiler_001", + "tests/test_plugins.py::TestPlugin2_spoiler::test_inline_spoiler_002", + "tests/test_plugins.py::TestPlugin2_spoiler::test_inline_spoiler_003", + "tests/test_plugins.py::TestExtraPlugins::test_math_in_list", + "tests/test_plugins.py::TestExtraPlugins::test_math_in_quote", + "tests/test_plugins.py::TestExtraPlugins::test_table_in_list", + "tests/test_plugins.py::TestExtraPlugins::test_table_in_quote", + "tests/test_renderers.py::TestRendererRst::test_code_001", + "tests/test_renderers.py::TestRendererRst::test_code_002", + "tests/test_renderers.py::TestRendererRst::test_heading_001", + "tests/test_renderers.py::TestRendererRst::test_html_001", + "tests/test_renderers.py::TestRendererRst::test_images_001", + "tests/test_renderers.py::TestRendererRst::test_images_002", + "tests/test_renderers.py::TestRendererRst::test_images_003", + "tests/test_renderers.py::TestRendererRst::test_inline_001", + "tests/test_renderers.py::TestRendererRst::test_inline_002", + "tests/test_renderers.py::TestRendererRst::test_line_break_001", + "tests/test_renderers.py::TestRendererRst::test_links_001", + "tests/test_renderers.py::TestRendererRst::test_list_001", + "tests/test_renderers.py::TestRendererRst::test_list_002", + "tests/test_renderers.py::TestRendererRst::test_list_003", + "tests/test_renderers.py::TestRendererRst::test_list_004", + "tests/test_renderers.py::TestRendererRst::test_list_005", + "tests/test_renderers.py::TestRendererRst::test_quote_001", + "tests/test_renderers.py::TestRendererRst::test_quote_002", + "tests/test_renderers.py::TestRendererRst::test_quote_003", + "tests/test_renderers.py::TestRendererRst::test_thematic_break_001", + "tests/test_renderers.py::TestRendererMarkdown::test_code_001", + "tests/test_renderers.py::TestRendererMarkdown::test_code_002", + "tests/test_renderers.py::TestRendererMarkdown::test_code_003", + "tests/test_renderers.py::TestRendererMarkdown::test_code_004", + "tests/test_renderers.py::TestRendererMarkdown::test_code_005", + "tests/test_renderers.py::TestRendererMarkdown::test_heading_001", + "tests/test_renderers.py::TestRendererMarkdown::test_html_001", + "tests/test_renderers.py::TestRendererMarkdown::test_images_001", + "tests/test_renderers.py::TestRendererMarkdown::test_inline_001", + "tests/test_renderers.py::TestRendererMarkdown::test_linebreak_001", + "tests/test_renderers.py::TestRendererMarkdown::test_links_001", + "tests/test_renderers.py::TestRendererMarkdown::test_links_002", + "tests/test_renderers.py::TestRendererMarkdown::test_links_003", + "tests/test_renderers.py::TestRendererMarkdown::test_list_001", + "tests/test_renderers.py::TestRendererMarkdown::test_list_002", + "tests/test_renderers.py::TestRendererMarkdown::test_list_003", + "tests/test_renderers.py::TestRendererMarkdown::test_list_004", + "tests/test_renderers.py::TestRendererMarkdown::test_list_005", + "tests/test_renderers.py::TestRendererMarkdown::test_list_006", + "tests/test_renderers.py::TestRendererMarkdown::test_quote_001", + "tests/test_renderers.py::TestRendererMarkdown::test_quote_002", + "tests/test_renderers.py::TestRendererMarkdown::test_thematic_break_001", + "tests/test_syntax.py::TestSyntax::test_emphasis_001", + "tests/test_syntax.py::TestSyntax::test_image_001", + "tests/test_syntax.py::TestSyntax::test_link_001", + "tests/test_syntax.py::TestSyntax::test_link_002", + "tests/test_syntax.py::TestSyntax::test_link_003", + "tests/test_syntax.py::TestSyntax::test_links_001", + "tests/test_syntax.py::TestSyntax::test_links_002", + "tests/test_syntax.py::TestSyntax::test_max_depth_001", + "tests/test_syntax.py::TestSyntax::test_max_depth_002", + "tests/test_syntax.py::TestSyntax::test_non_aggressive_emphasis_001", + "tests/test_syntax.py::TestSyntax::test_non_aggressive_emphasis_002", + "tests/test_syntax.py::TestSyntax::test_non_aggressive_emphasis_003", + "tests/test_syntax.py::TestSyntax::test_setext_headings_001", + "tests/test_syntax.py::TestSyntax::test_setext_headings_002" + ] +} diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/grade.py b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/grade.py new file mode 100644 index 0000000000000000000000000000000000000000..e3b37293830e51a5c5833c93c4705e1ed9364257 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/grade.py @@ -0,0 +1,128 @@ +"""Trusted private pytest panel runner. Installed only in a fresh grader Job.""" + +import hashlib +import importlib.util +import json +import os +import shutil +import stat +import subprocess +from pathlib import Path, PurePosixPath + + +def sha(raw): + return hashlib.sha256(raw).hexdigest() + + +def safe(value): + path = PurePosixPath(value) + if ( + path.is_absolute() + or path.as_posix() != value + or not path.parts + or any(part in {".", "..", ".git"} for part in path.parts) + ): + raise ValueError("Unsafe trusted test path") + return path + + +def restore(worktree, private, manifest): + worktree, private = Path(worktree), Path(private) + captured = {} + for name, expected in manifest["files"].items(): + path = private / safe(name) + info = path.lstat() + raw = path.read_bytes() if stat.S_ISREG(info.st_mode) else b"" + if ( + not stat.S_ISREG(info.st_mode) + or len(raw) != expected["bytes"] + or sha(raw) != expected["sha256"] + or stat.S_IMODE(info.st_mode) != expected["mode"] + ): + raise ValueError("Trusted private test bytes or modes drifted") + captured[name] = (raw, expected["mode"]) + # Capture and verify every private byte before changing the submitted tree. + for name in manifest["directory_roots"]: + destination = worktree / safe(name) + if destination.is_symlink(): + raise ValueError("Submitted test directory is a symlink") + for parent in destination.parents: + if parent == worktree: + break + if parent.is_symlink(): + raise ValueError("Submitted test parent is a symlink") + if destination.exists(): + if not destination.is_dir(): + raise ValueError("Submitted test directory is not a directory") + shutil.rmtree(destination) + for name, (raw, mode) in captured.items(): + destination = worktree / safe(name) + for parent in destination.parents: + if parent == worktree: + break + if parent.is_symlink(): + raise ValueError("Submitted test parent is a symlink") + if destination.is_symlink(): + raise ValueError("Submitted trusted file is a symlink") + destination.parent.mkdir(parents=True, exist_ok=True) + destination.write_bytes(raw) + destination.chmod(mode) + + +def run(worktree, private_root, output, invoke=None): + private_root, output, worktree = Path(private_root), Path(output), Path(worktree) + expected = json.loads((private_root / "expected-panels.json").read_bytes()) + config = json.loads((private_root / "panel-config.json").read_bytes()) + manifest = json.loads((private_root / "trusted-inventory.json").read_bytes()) + restore(worktree, private_root / "trusted", manifest) + output.mkdir(parents=True, exist_ok=True) + for name in ( + "reward.txt", + "pass-to-pass.xml", + "fail-to-pass.xml", + "pytest-evidence.json", + ): + (output / name).unlink(missing_ok=True) + environment = dict(os.environ) + for key in ("PYTEST_ADDOPTS", "PYTEST_DISABLE_PLUGIN_AUTOLOAD", "PYTHONPATH"): + environment.pop(key, None) + commands, native_exit = [], 0 + invoke = invoke or subprocess.run + for group in ("pass-to-pass", "fail-to-pass"): + if ( + not isinstance(expected[group], list) + or not expected[group] + or any( + not isinstance(target, str) or not target for target in expected[group] + ) + ): + raise ValueError("Frozen native pytest selectors are incomplete") + command = [ + *config["official_pytest_argv"], + "--override-ini=addopts=", + "--junitxml=" + str(output / (group + ".xml")), + *expected[group], + ] + result = invoke(command, cwd=worktree, env=environment, check=False) + native_exit = result.returncode + commands.append({"group": group, "argv": command, "exit_code": native_exit}) + if native_exit != 0: + break + (output / "pytest-commands.json").write_text( + json.dumps(commands, sort_keys=True) + "\n" + ) + spec = importlib.util.spec_from_file_location( + "trusted_pytest_result", private_root / "check_pytest.py" + ) + checker = importlib.util.module_from_spec(spec) + spec.loader.exec_module(checker) + result = checker.assess(output, expected, native_exit) + (output / "reward.txt").write_text(str(result["reward"]) + "\n") + (output / "pytest-evidence.json").write_text( + json.dumps(result, sort_keys=True) + "\n" + ) + return result + + +if __name__ == "__main__": + run("/testbed/repo", "/tests", "/logs/verifier") diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/panel-config.json b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/panel-config.json new file mode 100644 index 0000000000000000000000000000000000000000..fcf9afd120808ef57ca8e15a2ff5adfbb1b9b425 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/panel-config.json @@ -0,0 +1,24 @@ +{ + "dependency_installation_pinned": false, + "official_install_cmds": [ + "python -m pip install -e ." + ], + "official_pytest_argv": [ + "pytest", + "--disable-warnings", + "--color=no", + "--tb=no", + "--verbose" + ], + "official_test_command": "source /opt/miniconda3/bin/activate; conda activate testbed; pytest --disable-warnings --color=no --tb=no --verbose", + "operator_test_runner_prerequisites": [ + "python -m pip install pytest==8.4.2" + ], + "operator_test_runner_reason": "The official profile invokes pytest, but the common tools runtime does not provide it; pinned separately from source-native project requirements.", + "panel_normalization": "Override project addopts only to execute the exact frozen native panels; add JUnit output, preserve official pytest options and all selectors.", + "python_version": "3.10", + "source_bound_test_dependency_cmds": [], + "test_dependency_source_sha256": { + "pyproject.toml": "b2922e3ef89e2918935d38fb3a777bdbc741619942276a75fd21a8dd9faf6b42" + } +} diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/test.sh b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..81b6d0620f05dbd3b54b4e7ea5de04ce3f8a98e2 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/test.sh @@ -0,0 +1,6 @@ +#!/bin/bash +set -Eeuo pipefail +source /opt/miniconda3/bin/activate +conda activate testbed +cd /testbed/repo +exec python -I /tests/grade.py diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted-inventory.json b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted-inventory.json new file mode 100644 index 0000000000000000000000000000000000000000..aa70e1f5d5d129ced763ef7db40f73f94595e1e2 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted-inventory.json @@ -0,0 +1,212 @@ +{ + "directory_roots": [ + "tests" + ], + "files": { + "pyproject.toml": { + "bytes": 1781, + "mode": 420, + "sha256": "b2922e3ef89e2918935d38fb3a777bdbc741619942276a75fd21a8dd9faf6b42" + }, + "setup.py": { + "bytes": 52, + "mode": 420, + "sha256": "504f5c8cbb3b966b1f3f838da0a0cdc77b312f0c5935951357d17328e5324e21" + }, + "tests/__init__.py": { + "bytes": 1149, + "mode": 420, + "sha256": "229cc35ee9a5f5a9fb37e036683e2276f940b80df2dc6203102c0f36f960e467" + }, + "tests/fixtures/__init__.py": { + "bytes": 1502, + "mode": 420, + "sha256": "960fa58f01c3a473a956cc2d5430314d10f070bff18b35c9707c52c1c42a57e2" + }, + "tests/fixtures/abbr.txt": { + "bytes": 2703, + "mode": 420, + "sha256": "18c7e06359486daeaafa88c7404f4ca8248cd47bf38a7ed475ddd35353e68bea" + }, + "tests/fixtures/commonmark.json": { + "bytes": 140423, + "mode": 420, + "sha256": "ae6129f3ce3caf4f99cf4f9a5ad3558a309652b5b887171013e2bf0797289b98" + }, + "tests/fixtures/def_list.txt": { + "bytes": 2834, + "mode": 420, + "sha256": "909b7156a5ba1f005ea3d8a203946e7ab3576149ec5af73ecad657bb046f386d" + }, + "tests/fixtures/diff-commonmark.txt": { + "bytes": 1176, + "mode": 420, + "sha256": "920df6e3c9c8e3d4627842d5a7aeb172bdd23229acfbbb9a9b728a9f6ce2c1f0" + }, + "tests/fixtures/fenced_admonition.txt": { + "bytes": 2344, + "mode": 420, + "sha256": "0f231afd472bc2c742170798e619d1baa5dd34e9e4a6cb18906dabd1aa37a1d0" + }, + "tests/fixtures/fenced_figure.txt": { + "bytes": 3481, + "mode": 420, + "sha256": "83c3d636e8d4f0dd5a767045cf38877fd3c6c03a20c351f06c50e30ae7f30cda" + }, + "tests/fixtures/fenced_image.txt": { + "bytes": 2343, + "mode": 420, + "sha256": "fa7ede5a90b718aaeb46af7f5a4d98a0e17cec0411355f460a166356020e6780" + }, + "tests/fixtures/fenced_toc.txt": { + "bytes": 3656, + "mode": 420, + "sha256": "019a12ca2e293699d88241460bdea48ee6a65981b36b6bae4c0bbf78f020a296" + }, + "tests/fixtures/fix-commonmark.txt": { + "bytes": 1905, + "mode": 420, + "sha256": "1f2777b457f4da70e02983bbcb2104fa3b442dbb8a5bcac1621499b0b796292f" + }, + "tests/fixtures/footnotes.txt": { + "bytes": 847, + "mode": 420, + "sha256": "55227ab43a3986fd07ecbf0742903a977f04cd9ed403086d7c76f23b1967aab1" + }, + "tests/fixtures/hook_toc.txt": { + "bytes": 1896, + "mode": 420, + "sha256": "bdb1a5c90f08cb29c4eed3c892e9c694f92855507b6cd5809eac3b8eb4fc7dc5" + }, + "tests/fixtures/include/hello.md": { + "bytes": 8, + "mode": 420, + "sha256": "389aaf8f17da55ef35fedf530bc70cd1287042f6410ec94c2b44c1b22c36e60a" + }, + "tests/fixtures/include/hello.txt": { + "bytes": 6, + "mode": 420, + "sha256": "5891b5b522d5df086d0ff0b110fbd9d21bb4fc7163af34d08286a2e846f6be03" + }, + "tests/fixtures/include/text.html": { + "bytes": 24, + "mode": 420, + "sha256": "bac2f8a2e3937f8923da8e560248d2a52867b502fbda531ba73f1d066b35d2ba" + }, + "tests/fixtures/include/text.md": { + "bytes": 163, + "mode": 420, + "sha256": "3ffb497b2829ca6333bc6eb4e7d2959aa7baeaa44180225a4820e0051ae7ef75" + }, + "tests/fixtures/insert.txt": { + "bytes": 1165, + "mode": 420, + "sha256": "de7b89a58c2cbd2d4948c10b8c599fd7500b3ae6734d271a35ff2cf2854b1572" + }, + "tests/fixtures/mark.txt": { + "bytes": 1138, + "mode": 420, + "sha256": "6b5c232cf89f61097ae6d032865a99bdcd9f65e3ef99517d9423b2da0aa983d0" + }, + "tests/fixtures/math.txt": { + "bytes": 1174, + "mode": 420, + "sha256": "eadc29b04cc85928e50003b2908b002a778447ef028c4b773ca1753b907fd898" + }, + "tests/fixtures/renderer_markdown.txt": { + "bytes": 3569, + "mode": 420, + "sha256": "2ba5fc55634d7dbaabd91aedea9e04b34882e67abc3020034bd809a408cac2a7" + }, + "tests/fixtures/renderer_rst.txt": { + "bytes": 2915, + "mode": 420, + "sha256": "47007bc353f230e9b73d8604548539bb16374a4b837bf7ba8d2f478444fff84e" + }, + "tests/fixtures/rst_admonition.txt": { + "bytes": 848, + "mode": 420, + "sha256": "821676f07a4e595c51c84da87edc592e22e8bbed6241e070040d87a4de7c5d7e" + }, + "tests/fixtures/rst_toc.txt": { + "bytes": 3643, + "mode": 420, + "sha256": "f9ae334cef85d776c37d7ad029e1e38d9e1b035423ab624dab8499aff28f7e98" + }, + "tests/fixtures/ruby.txt": { + "bytes": 1773, + "mode": 420, + "sha256": "1302542447ac0befc2618d9c2da1657581fcc1d90c332896e6dc086b698e30ed" + }, + "tests/fixtures/spoiler.txt": { + "bytes": 1154, + "mode": 420, + "sha256": "21446f2e88b70cc3c50e606c36fbcdf567993581ccf8397ace5948973c251985" + }, + "tests/fixtures/strikethrough.txt": { + "bytes": 886, + "mode": 420, + "sha256": "fee85a2207da74bdcf437c2c58804b009b657b4dfd505989fdbee46f78feac07" + }, + "tests/fixtures/subscript.txt": { + "bytes": 521, + "mode": 420, + "sha256": "61fd94b4718edbbfaa782533f659f4f193585fb09e61761a662cd313906932b8" + }, + "tests/fixtures/superscript.txt": { + "bytes": 523, + "mode": 420, + "sha256": "658ac752d95d74e6e97e7daceba6f48ef279dc6f1389a878610bc608e82f34b3" + }, + "tests/fixtures/table.txt": { + "bytes": 4134, + "mode": 420, + "sha256": "f92d66b63d00f95f7a9938cb6e0e42ea4968d6e9f1f62e902b63bc1be69f51b6" + }, + "tests/fixtures/task_lists.txt": { + "bytes": 3104, + "mode": 420, + "sha256": "d17a07a9cb077dd25c3b4c4dd7301bc9f508ab75ec83c2293b0ebaca954be76c" + }, + "tests/fixtures/url.txt": { + "bytes": 530, + "mode": 420, + "sha256": "441ea5e1e27f6edcd52b51f8c20ca1eee8b76d4adcc3b2fcdd419448c528ef21" + }, + "tests/test_commonmark.py": { + "bytes": 2199, + "mode": 420, + "sha256": "77396377672a8419ecab283aebf55a5e206b1aa413626975dc8b2a006c796973" + }, + "tests/test_directives.py": { + "bytes": 2954, + "mode": 420, + "sha256": "3d46db4f9e52d3067954ab7fcaba80ef855008a516a86ee3baf07b2a9c730817" + }, + "tests/test_hooks.py": { + "bytes": 729, + "mode": 420, + "sha256": "9d6f177c6dd52223ac44e31508ed66bbc2b6fc7a4725ed7121fb39842b0a6a61" + }, + "tests/test_misc.py": { + "bytes": 4830, + "mode": 420, + "sha256": "a1bba411b7b74f1b9d43bf88459db1d9fa2c13e7db32dfee707c93cd8ccb5575" + }, + "tests/test_plugins.py": { + "bytes": 2280, + "mode": 420, + "sha256": "56a6731c5e5667870122edfb3d49925a34dc394ae00ce3282dc3e89cbe2fd6b8" + }, + "tests/test_renderers.py": { + "bytes": 500, + "mode": 420, + "sha256": "efc0fa48c74f8ee1b84c961e4ca034eb5f0246b69b4663428c93cc77d471e7b8" + }, + "tests/test_syntax.py": { + "bytes": 342, + "mode": 420, + "sha256": "88f99c6afc5f39f088c0cd1cdf4fab8a69b60b208a1b28924eeb8fbd0d7bef2e" + } + } +} diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/pyproject.toml b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/pyproject.toml new file mode 100644 index 0000000000000000000000000000000000000000..2d95f9b3bd4ee9817157eab051c5277fb0a3846f --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/pyproject.toml @@ -0,0 +1,69 @@ +[project] +name = "mistune" +description = "A sane and fast Markdown parser with useful plugins and renderers" +authors = [{name = "Hsiaoming Yang", email="me@lepture.com"}] +dependencies = [ + "typing-extensions; python_version<'3.11'", +] +license = {text = "BSD-3-Clause"} +dynamic = ["version"] +requires-python = ">=3.8" +readme = "README.rst" +classifiers = [ + "Development Status :: 4 - Beta", + "Environment :: Console", + "Environment :: Web Environment", + "Intended Audience :: Developers", + "License :: OSI Approved :: BSD License", + "Operating System :: OS Independent", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: Implementation :: CPython", + "Programming Language :: Python :: Implementation :: PyPy", + "Topic :: Text Processing :: Markup", +] + +[project.urls] +Documentation = "https://mistune.lepture.com/" +Source = "https://github.com/lepture/mistune" +Donate = "https://github.com/sponsors/lepture" + +[build-system] +requires = ["setuptools"] +build-backend = "setuptools.build_meta" + +[tool.setuptools.dynamic] +version = {attr = "mistune.__version__"} + +[tool.setuptools.packages.find] +where = ["src"] + +[tool.setuptools.package-data] +mistune = ["py.typed"] + +[tool.ruff] +line-length = 120 + +[tool.pytest.ini_options] +pythonpath = ["src", "."] +testpaths = ["tests"] +filterwarnings = ["error"] + +[tool.coverage.run] +branch = true +source = ["mistune"] + +[tool.coverage.paths] +source = ["src"] + +[tool.coverage.report] +exclude_lines = [ + "pragma: no cover", + "def __repr__", + "raise NotImplementedError", + "@(abc\\.)?abstractmethod", +] diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/setup.py b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/setup.py new file mode 100644 index 0000000000000000000000000000000000000000..af8a0fc50e9db1a27585118393965a8c87e19129 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/setup.py @@ -0,0 +1,3 @@ +from setuptools import setup + +setup(name="mistune") diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/__init__.py b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..b715104d1f96221038f7c9060d66b4bc6a5bdda2 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/__init__.py @@ -0,0 +1,40 @@ +import re +from abc import abstractmethod +from unittest import TestCase + +from tests import fixtures + + +class BaseTestCase(TestCase): + @classmethod + def load_fixtures(cls, case_file: str) -> None: + def attach_case(n: str, text: str, html: str) -> None: + def method(self: 'BaseTestCase') -> None: + self.assert_case(n, text, html) + + name = 'test_{}'.format(n) + method.__name__ = name + method.__doc__ = 'Run fixture {} - {}'.format(case_file, n) + setattr(cls, name, method) + + for n, text, html in fixtures.load_examples(case_file): + if cls.ignore_case(n): + continue + attach_case(n, text, html) + + @classmethod + def ignore_case(cls, name: str) -> bool: + return False + + @abstractmethod + def parse(self, text: str) -> str: ... + + def assert_case(self, name: str, text: str, html: str) -> None: + result = self.parse(text) + self.assertEqual(result, html) + + +def normalize_html(html: str) -> str: + html = re.sub(r'>\n+', '>', html) + html = re.sub(r'\n+<', '<', html) + return html.strip() diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/fixtures/__init__.py b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/fixtures/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..9a1abe299918fbbac039621a46f85061a7f0c31e --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/fixtures/__init__.py @@ -0,0 +1,56 @@ +import os +import re +import json +from typing import Any, Iterable, Tuple + +ROOT = os.path.join(os.path.dirname(__file__)) + +EXAMPLE_PATTERN = re.compile( + r'^`{32} example\n([\s\S]*?)' + r'^\.\n([\s\S]*?)' + r'^`{32}$|^#{1,6} *(.*)$', + flags=re.M +) + + +def load_ast(filename: str) -> Any: + with open(os.path.join(ROOT, 'ast', filename)) as f: + return json.load(f) + + +def load_json(filename: str) -> Any: + with open(os.path.join(ROOT, filename)) as f: + return json.load(f) + + +def load_examples(filename: str) -> Iterable[Tuple[str, str, str]]: + if filename.endswith('.json'): + data = load_json(filename) + for item in data: + section = item['section'].lower().replace(' ', '_') + n = '%s_%03d' % (section, item['example']) + yield n, item['markdown'], item['html'] + else: + with open(os.path.join(ROOT, filename), 'rb') as f: + content = f.read() + s = content.decode('utf-8') + yield from parse_examples(s) + + + +def parse_examples(text: str) -> Iterable[Tuple[str, str, str]]: + data = EXAMPLE_PATTERN.findall(text) + + section = None + count = 0 + for md, html, title in data: + if title: + count = 0 + section = title.lower().replace(' ', '_') + + if md and html: + count += 1 + n = '%s_%03d' % (section, count) + md = md.replace(u'\u2192', '\t') + html = html.replace(u'\u2192', '\t') + yield n, md, html diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/fixtures/abbr.txt b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/fixtures/abbr.txt new file mode 100644 index 0000000000000000000000000000000000000000..a87b4f1521511a9071a901311c07372340bb958c --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/fixtures/abbr.txt @@ -0,0 +1,79 @@ +# Abbreviation + +## abbreviation + +```````````````````````````````` example +HTML +. +

HTML

+```````````````````````````````` + +```````````````````````````````` example +HTML +*[HTML]: Hyper Text Markup Language +. +

HTML

+```````````````````````````````` + +```````````````````````````````` example +The HTML specification is maintained by the W3C. +*[HTML]: Hyper Text Markup Language +*[W3C]: World Wide Web Consortium +. +

The HTML specification is maintained by the W3C.

+```````````````````````````````` + +```````````````````````````````` example +The HTML specification is maintained by the W3C. +*[HTML]: + Hyper Text Markup Language +*[W3C]: + World Wide Web Consortium +. +

The HTML specification is maintained by the W3C.

+```````````````````````````````` + +```````````````````````````````` example +The HTML specification is maintained by the W3C. +*[HTML]: Hyper Text Markup Language +*[W3C]: World Wide Web Consortium +There is more text below this one. +. +

The HTML specification is maintained by the W3C.

+

There is more text below this one.

+```````````````````````````````` + +```````````````````````````````` example +The latest spec of HTML is HTML5. +*[HTML]: Hyper Text Markup Language +. +

The latest spec of HTML is HTML5.

+```````````````````````````````` + +```````````````````````````````` example +HTML should always be spelt with capital letters and not spelt html. +*[HTML]: Hyper Text Markup Language +. +

HTML should always be spelt with capital letters and not spelt html.

+```````````````````````````````` + +```````````````````````````````` example +HTML is an abbreviation but nobody knows what it stands for. +*[HTML]: +. +

HTML is an abbreviation but nobody knows what it stands for.

+```````````````````````````````` + +```````````````````````````````` example +Foo.* looks like a regular expression. +*[Foo.*]: Just foo +. +

Foo.* looks like a regular expression.

+```````````````````````````````` + +```````````````````````````````` example +Untrusted HTML should be escaped. +*[HTML]:

This is some HTML

+. +

Untrusted HTML should be escaped.

+```````````````````````````````` diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/fixtures/commonmark.json b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/fixtures/commonmark.json new file mode 100644 index 0000000000000000000000000000000000000000..d742f941312421f89a3491b7e1d5edd0e44d2207 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/fixtures/commonmark.json @@ -0,0 +1,5218 @@ +[ + { + "markdown": "\tfoo\tbaz\t\tbim\n", + "html": "
foo\tbaz\t\tbim\n
\n", + "example": 1, + "start_line": 356, + "end_line": 361, + "section": "Tabs" + }, + { + "markdown": " \tfoo\tbaz\t\tbim\n", + "html": "
foo\tbaz\t\tbim\n
\n", + "example": 2, + "start_line": 363, + "end_line": 368, + "section": "Tabs" + }, + { + "markdown": " a\ta\n ὐ\ta\n", + "html": "
a\ta\nὐ\ta\n
\n", + "example": 3, + "start_line": 370, + "end_line": 377, + "section": "Tabs" + }, + { + "markdown": " - foo\n\n\tbar\n", + "html": "
    \n
  • \n

    foo

    \n

    bar

    \n
  • \n
\n", + "example": 4, + "start_line": 383, + "end_line": 394, + "section": "Tabs" + }, + { + "markdown": "- foo\n\n\t\tbar\n", + "html": "
    \n
  • \n

    foo

    \n
      bar\n
    \n
  • \n
\n", + "example": 5, + "start_line": 396, + "end_line": 408, + "section": "Tabs" + }, + { + "markdown": ">\t\tfoo\n", + "html": "
\n
  foo\n
\n
\n", + "example": 6, + "start_line": 419, + "end_line": 426, + "section": "Tabs" + }, + { + "markdown": "-\t\tfoo\n", + "html": "
    \n
  • \n
      foo\n
    \n
  • \n
\n", + "example": 7, + "start_line": 428, + "end_line": 437, + "section": "Tabs" + }, + { + "markdown": " foo\n\tbar\n", + "html": "
foo\nbar\n
\n", + "example": 8, + "start_line": 440, + "end_line": 447, + "section": "Tabs" + }, + { + "markdown": " - foo\n - bar\n\t - baz\n", + "html": "
    \n
  • foo\n
      \n
    • bar\n
        \n
      • baz
      • \n
      \n
    • \n
    \n
  • \n
\n", + "example": 9, + "start_line": 449, + "end_line": 465, + "section": "Tabs" + }, + { + "markdown": "#\tFoo\n", + "html": "

Foo

\n", + "example": 10, + "start_line": 467, + "end_line": 471, + "section": "Tabs" + }, + { + "markdown": "*\t*\t*\t\n", + "html": "
\n", + "example": 11, + "start_line": 473, + "end_line": 477, + "section": "Tabs" + }, + { + "markdown": "\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\-\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\_\\`\\{\\|\\}\\~\n", + "html": "

!"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~

\n", + "example": 12, + "start_line": 490, + "end_line": 494, + "section": "Backslash escapes" + }, + { + "markdown": "\\\t\\A\\a\\ \\3\\φ\\«\n", + "html": "

\\\t\\A\\a\\ \\3\\φ\\«

\n", + "example": 13, + "start_line": 500, + "end_line": 504, + "section": "Backslash escapes" + }, + { + "markdown": "\\*not emphasized*\n\\
not a tag\n\\[not a link](/foo)\n\\`not code`\n1\\. not a list\n\\* not a list\n\\# not a heading\n\\[foo]: /url \"not a reference\"\n\\ö not a character entity\n", + "html": "

*not emphasized*\n<br/> not a tag\n[not a link](/foo)\n`not code`\n1. not a list\n* not a list\n# not a heading\n[foo]: /url "not a reference"\n&ouml; not a character entity

\n", + "example": 14, + "start_line": 510, + "end_line": 530, + "section": "Backslash escapes" + }, + { + "markdown": "\\\\*emphasis*\n", + "html": "

\\emphasis

\n", + "example": 15, + "start_line": 535, + "end_line": 539, + "section": "Backslash escapes" + }, + { + "markdown": "foo\\\nbar\n", + "html": "

foo
\nbar

\n", + "example": 16, + "start_line": 544, + "end_line": 550, + "section": "Backslash escapes" + }, + { + "markdown": "`` \\[\\` ``\n", + "html": "

\\[\\`

\n", + "example": 17, + "start_line": 556, + "end_line": 560, + "section": "Backslash escapes" + }, + { + "markdown": " \\[\\]\n", + "html": "
\\[\\]\n
\n", + "example": 18, + "start_line": 563, + "end_line": 568, + "section": "Backslash escapes" + }, + { + "markdown": "~~~\n\\[\\]\n~~~\n", + "html": "
\\[\\]\n
\n", + "example": 19, + "start_line": 571, + "end_line": 578, + "section": "Backslash escapes" + }, + { + "markdown": "\n", + "html": "

http://example.com?find=\\*

\n", + "example": 20, + "start_line": 581, + "end_line": 585, + "section": "Backslash escapes" + }, + { + "markdown": "\n", + "html": "\n", + "example": 21, + "start_line": 588, + "end_line": 592, + "section": "Backslash escapes" + }, + { + "markdown": "[foo](/bar\\* \"ti\\*tle\")\n", + "html": "

foo

\n", + "example": 22, + "start_line": 598, + "end_line": 602, + "section": "Backslash escapes" + }, + { + "markdown": "[foo]\n\n[foo]: /bar\\* \"ti\\*tle\"\n", + "html": "

foo

\n", + "example": 23, + "start_line": 605, + "end_line": 611, + "section": "Backslash escapes" + }, + { + "markdown": "``` foo\\+bar\nfoo\n```\n", + "html": "
foo\n
\n", + "example": 24, + "start_line": 614, + "end_line": 621, + "section": "Backslash escapes" + }, + { + "markdown": "  & © Æ Ď\n¾ ℋ ⅆ\n∲ ≧̸\n", + "html": "

  & © Æ Ď\n¾ ℋ ⅆ\n∲ ≧̸

\n", + "example": 25, + "start_line": 650, + "end_line": 658, + "section": "Entity and numeric character references" + }, + { + "markdown": "# Ӓ Ϡ �\n", + "html": "

# Ӓ Ϡ �

\n", + "example": 26, + "start_line": 669, + "end_line": 673, + "section": "Entity and numeric character references" + }, + { + "markdown": "" ആ ಫ\n", + "html": "

" ആ ಫ

\n", + "example": 27, + "start_line": 682, + "end_line": 686, + "section": "Entity and numeric character references" + }, + { + "markdown": "  &x; &#; &#x;\n�\n&#abcdef0;\n&ThisIsNotDefined; &hi?;\n", + "html": "

&nbsp &x; &#; &#x;\n&#87654321;\n&#abcdef0;\n&ThisIsNotDefined; &hi?;

\n", + "example": 28, + "start_line": 691, + "end_line": 701, + "section": "Entity and numeric character references" + }, + { + "markdown": "©\n", + "html": "

&copy

\n", + "example": 29, + "start_line": 708, + "end_line": 712, + "section": "Entity and numeric character references" + }, + { + "markdown": "&MadeUpEntity;\n", + "html": "

&MadeUpEntity;

\n", + "example": 30, + "start_line": 718, + "end_line": 722, + "section": "Entity and numeric character references" + }, + { + "markdown": "\n", + "html": "\n", + "example": 31, + "start_line": 729, + "end_line": 733, + "section": "Entity and numeric character references" + }, + { + "markdown": "[foo](/föö \"föö\")\n", + "html": "

foo

\n", + "example": 32, + "start_line": 736, + "end_line": 740, + "section": "Entity and numeric character references" + }, + { + "markdown": "[foo]\n\n[foo]: /föö \"föö\"\n", + "html": "

foo

\n", + "example": 33, + "start_line": 743, + "end_line": 749, + "section": "Entity and numeric character references" + }, + { + "markdown": "``` föö\nfoo\n```\n", + "html": "
foo\n
\n", + "example": 34, + "start_line": 752, + "end_line": 759, + "section": "Entity and numeric character references" + }, + { + "markdown": "`föö`\n", + "html": "

f&ouml;&ouml;

\n", + "example": 35, + "start_line": 765, + "end_line": 769, + "section": "Entity and numeric character references" + }, + { + "markdown": " föfö\n", + "html": "
f&ouml;f&ouml;\n
\n", + "example": 36, + "start_line": 772, + "end_line": 777, + "section": "Entity and numeric character references" + }, + { + "markdown": "*foo*\n*foo*\n", + "html": "

*foo*\nfoo

\n", + "example": 37, + "start_line": 784, + "end_line": 790, + "section": "Entity and numeric character references" + }, + { + "markdown": "* foo\n\n* foo\n", + "html": "

* foo

\n
    \n
  • foo
  • \n
\n", + "example": 38, + "start_line": 792, + "end_line": 801, + "section": "Entity and numeric character references" + }, + { + "markdown": "foo bar\n", + "html": "

foo\n\nbar

\n", + "example": 39, + "start_line": 803, + "end_line": 809, + "section": "Entity and numeric character references" + }, + { + "markdown": " foo\n", + "html": "

\tfoo

\n", + "example": 40, + "start_line": 811, + "end_line": 815, + "section": "Entity and numeric character references" + }, + { + "markdown": "[a](url "tit")\n", + "html": "

[a](url "tit")

\n", + "example": 41, + "start_line": 818, + "end_line": 822, + "section": "Entity and numeric character references" + }, + { + "markdown": "- `one\n- two`\n", + "html": "
    \n
  • `one
  • \n
  • two`
  • \n
\n", + "example": 42, + "start_line": 841, + "end_line": 849, + "section": "Precedence" + }, + { + "markdown": "***\n---\n___\n", + "html": "
\n
\n
\n", + "example": 43, + "start_line": 880, + "end_line": 888, + "section": "Thematic breaks" + }, + { + "markdown": "+++\n", + "html": "

+++

\n", + "example": 44, + "start_line": 893, + "end_line": 897, + "section": "Thematic breaks" + }, + { + "markdown": "===\n", + "html": "

===

\n", + "example": 45, + "start_line": 900, + "end_line": 904, + "section": "Thematic breaks" + }, + { + "markdown": "--\n**\n__\n", + "html": "

--\n**\n__

\n", + "example": 46, + "start_line": 909, + "end_line": 917, + "section": "Thematic breaks" + }, + { + "markdown": " ***\n ***\n ***\n", + "html": "
\n
\n
\n", + "example": 47, + "start_line": 922, + "end_line": 930, + "section": "Thematic breaks" + }, + { + "markdown": " ***\n", + "html": "
***\n
\n", + "example": 48, + "start_line": 935, + "end_line": 940, + "section": "Thematic breaks" + }, + { + "markdown": "Foo\n ***\n", + "html": "

Foo\n***

\n", + "example": 49, + "start_line": 943, + "end_line": 949, + "section": "Thematic breaks" + }, + { + "markdown": "_____________________________________\n", + "html": "
\n", + "example": 50, + "start_line": 954, + "end_line": 958, + "section": "Thematic breaks" + }, + { + "markdown": " - - -\n", + "html": "
\n", + "example": 51, + "start_line": 963, + "end_line": 967, + "section": "Thematic breaks" + }, + { + "markdown": " ** * ** * ** * **\n", + "html": "
\n", + "example": 52, + "start_line": 970, + "end_line": 974, + "section": "Thematic breaks" + }, + { + "markdown": "- - - -\n", + "html": "
\n", + "example": 53, + "start_line": 977, + "end_line": 981, + "section": "Thematic breaks" + }, + { + "markdown": "- - - - \n", + "html": "
\n", + "example": 54, + "start_line": 986, + "end_line": 990, + "section": "Thematic breaks" + }, + { + "markdown": "_ _ _ _ a\n\na------\n\n---a---\n", + "html": "

_ _ _ _ a

\n

a------

\n

---a---

\n", + "example": 55, + "start_line": 995, + "end_line": 1005, + "section": "Thematic breaks" + }, + { + "markdown": " *-*\n", + "html": "

-

\n", + "example": 56, + "start_line": 1011, + "end_line": 1015, + "section": "Thematic breaks" + }, + { + "markdown": "- foo\n***\n- bar\n", + "html": "
    \n
  • foo
  • \n
\n
\n
    \n
  • bar
  • \n
\n", + "example": 57, + "start_line": 1020, + "end_line": 1032, + "section": "Thematic breaks" + }, + { + "markdown": "Foo\n***\nbar\n", + "html": "

Foo

\n
\n

bar

\n", + "example": 58, + "start_line": 1037, + "end_line": 1045, + "section": "Thematic breaks" + }, + { + "markdown": "Foo\n---\nbar\n", + "html": "

Foo

\n

bar

\n", + "example": 59, + "start_line": 1054, + "end_line": 1061, + "section": "Thematic breaks" + }, + { + "markdown": "* Foo\n* * *\n* Bar\n", + "html": "
    \n
  • Foo
  • \n
\n
\n
    \n
  • Bar
  • \n
\n", + "example": 60, + "start_line": 1067, + "end_line": 1079, + "section": "Thematic breaks" + }, + { + "markdown": "- Foo\n- * * *\n", + "html": "
    \n
  • Foo
  • \n
  • \n
    \n
  • \n
\n", + "example": 61, + "start_line": 1084, + "end_line": 1094, + "section": "Thematic breaks" + }, + { + "markdown": "# foo\n## foo\n### foo\n#### foo\n##### foo\n###### foo\n", + "html": "

foo

\n

foo

\n

foo

\n

foo

\n
foo
\n
foo
\n", + "example": 62, + "start_line": 1113, + "end_line": 1127, + "section": "ATX headings" + }, + { + "markdown": "####### foo\n", + "html": "

####### foo

\n", + "example": 63, + "start_line": 1132, + "end_line": 1136, + "section": "ATX headings" + }, + { + "markdown": "#5 bolt\n\n#hashtag\n", + "html": "

#5 bolt

\n

#hashtag

\n", + "example": 64, + "start_line": 1147, + "end_line": 1154, + "section": "ATX headings" + }, + { + "markdown": "\\## foo\n", + "html": "

## foo

\n", + "example": 65, + "start_line": 1159, + "end_line": 1163, + "section": "ATX headings" + }, + { + "markdown": "# foo *bar* \\*baz\\*\n", + "html": "

foo bar *baz*

\n", + "example": 66, + "start_line": 1168, + "end_line": 1172, + "section": "ATX headings" + }, + { + "markdown": "# foo \n", + "html": "

foo

\n", + "example": 67, + "start_line": 1177, + "end_line": 1181, + "section": "ATX headings" + }, + { + "markdown": " ### foo\n ## foo\n # foo\n", + "html": "

foo

\n

foo

\n

foo

\n", + "example": 68, + "start_line": 1186, + "end_line": 1194, + "section": "ATX headings" + }, + { + "markdown": " # foo\n", + "html": "
# foo\n
\n", + "example": 69, + "start_line": 1199, + "end_line": 1204, + "section": "ATX headings" + }, + { + "markdown": "foo\n # bar\n", + "html": "

foo\n# bar

\n", + "example": 70, + "start_line": 1207, + "end_line": 1213, + "section": "ATX headings" + }, + { + "markdown": "## foo ##\n ### bar ###\n", + "html": "

foo

\n

bar

\n", + "example": 71, + "start_line": 1218, + "end_line": 1224, + "section": "ATX headings" + }, + { + "markdown": "# foo ##################################\n##### foo ##\n", + "html": "

foo

\n
foo
\n", + "example": 72, + "start_line": 1229, + "end_line": 1235, + "section": "ATX headings" + }, + { + "markdown": "### foo ### \n", + "html": "

foo

\n", + "example": 73, + "start_line": 1240, + "end_line": 1244, + "section": "ATX headings" + }, + { + "markdown": "### foo ### b\n", + "html": "

foo ### b

\n", + "example": 74, + "start_line": 1251, + "end_line": 1255, + "section": "ATX headings" + }, + { + "markdown": "# foo#\n", + "html": "

foo#

\n", + "example": 75, + "start_line": 1260, + "end_line": 1264, + "section": "ATX headings" + }, + { + "markdown": "### foo \\###\n## foo #\\##\n# foo \\#\n", + "html": "

foo ###

\n

foo ###

\n

foo #

\n", + "example": 76, + "start_line": 1270, + "end_line": 1278, + "section": "ATX headings" + }, + { + "markdown": "****\n## foo\n****\n", + "html": "
\n

foo

\n
\n", + "example": 77, + "start_line": 1284, + "end_line": 1292, + "section": "ATX headings" + }, + { + "markdown": "Foo bar\n# baz\nBar foo\n", + "html": "

Foo bar

\n

baz

\n

Bar foo

\n", + "example": 78, + "start_line": 1295, + "end_line": 1303, + "section": "ATX headings" + }, + { + "markdown": "## \n#\n### ###\n", + "html": "

\n

\n

\n", + "example": 79, + "start_line": 1308, + "end_line": 1316, + "section": "ATX headings" + }, + { + "markdown": "Foo *bar*\n=========\n\nFoo *bar*\n---------\n", + "html": "

Foo bar

\n

Foo bar

\n", + "example": 80, + "start_line": 1351, + "end_line": 1360, + "section": "Setext headings" + }, + { + "markdown": "Foo *bar\nbaz*\n====\n", + "html": "

Foo bar\nbaz

\n", + "example": 81, + "start_line": 1365, + "end_line": 1372, + "section": "Setext headings" + }, + { + "markdown": " Foo *bar\nbaz*\t\n====\n", + "html": "

Foo bar\nbaz

\n", + "example": 82, + "start_line": 1379, + "end_line": 1386, + "section": "Setext headings" + }, + { + "markdown": "Foo\n-------------------------\n\nFoo\n=\n", + "html": "

Foo

\n

Foo

\n", + "example": 83, + "start_line": 1391, + "end_line": 1400, + "section": "Setext headings" + }, + { + "markdown": " Foo\n---\n\n Foo\n-----\n\n Foo\n ===\n", + "html": "

Foo

\n

Foo

\n

Foo

\n", + "example": 84, + "start_line": 1406, + "end_line": 1419, + "section": "Setext headings" + }, + { + "markdown": " Foo\n ---\n\n Foo\n---\n", + "html": "
Foo\n---\n\nFoo\n
\n
\n", + "example": 85, + "start_line": 1424, + "end_line": 1437, + "section": "Setext headings" + }, + { + "markdown": "Foo\n ---- \n", + "html": "

Foo

\n", + "example": 86, + "start_line": 1443, + "end_line": 1448, + "section": "Setext headings" + }, + { + "markdown": "Foo\n ---\n", + "html": "

Foo\n---

\n", + "example": 87, + "start_line": 1453, + "end_line": 1459, + "section": "Setext headings" + }, + { + "markdown": "Foo\n= =\n\nFoo\n--- -\n", + "html": "

Foo\n= =

\n

Foo

\n
\n", + "example": 88, + "start_line": 1464, + "end_line": 1475, + "section": "Setext headings" + }, + { + "markdown": "Foo \n-----\n", + "html": "

Foo

\n", + "example": 89, + "start_line": 1480, + "end_line": 1485, + "section": "Setext headings" + }, + { + "markdown": "Foo\\\n----\n", + "html": "

Foo\\

\n", + "example": 90, + "start_line": 1490, + "end_line": 1495, + "section": "Setext headings" + }, + { + "markdown": "`Foo\n----\n`\n\n\n", + "html": "

`Foo

\n

`

\n

<a title="a lot

\n

of dashes"/>

\n", + "example": 91, + "start_line": 1501, + "end_line": 1514, + "section": "Setext headings" + }, + { + "markdown": "> Foo\n---\n", + "html": "
\n

Foo

\n
\n
\n", + "example": 92, + "start_line": 1520, + "end_line": 1528, + "section": "Setext headings" + }, + { + "markdown": "> foo\nbar\n===\n", + "html": "
\n

foo\nbar\n===

\n
\n", + "example": 93, + "start_line": 1531, + "end_line": 1541, + "section": "Setext headings" + }, + { + "markdown": "- Foo\n---\n", + "html": "
    \n
  • Foo
  • \n
\n
\n", + "example": 94, + "start_line": 1544, + "end_line": 1552, + "section": "Setext headings" + }, + { + "markdown": "Foo\nBar\n---\n", + "html": "

Foo\nBar

\n", + "example": 95, + "start_line": 1559, + "end_line": 1566, + "section": "Setext headings" + }, + { + "markdown": "---\nFoo\n---\nBar\n---\nBaz\n", + "html": "
\n

Foo

\n

Bar

\n

Baz

\n", + "example": 96, + "start_line": 1572, + "end_line": 1584, + "section": "Setext headings" + }, + { + "markdown": "\n====\n", + "html": "

====

\n", + "example": 97, + "start_line": 1589, + "end_line": 1594, + "section": "Setext headings" + }, + { + "markdown": "---\n---\n", + "html": "
\n
\n", + "example": 98, + "start_line": 1601, + "end_line": 1607, + "section": "Setext headings" + }, + { + "markdown": "- foo\n-----\n", + "html": "
    \n
  • foo
  • \n
\n
\n", + "example": 99, + "start_line": 1610, + "end_line": 1618, + "section": "Setext headings" + }, + { + "markdown": " foo\n---\n", + "html": "
foo\n
\n
\n", + "example": 100, + "start_line": 1621, + "end_line": 1628, + "section": "Setext headings" + }, + { + "markdown": "> foo\n-----\n", + "html": "
\n

foo

\n
\n
\n", + "example": 101, + "start_line": 1631, + "end_line": 1639, + "section": "Setext headings" + }, + { + "markdown": "\\> foo\n------\n", + "html": "

> foo

\n", + "example": 102, + "start_line": 1645, + "end_line": 1650, + "section": "Setext headings" + }, + { + "markdown": "Foo\n\nbar\n---\nbaz\n", + "html": "

Foo

\n

bar

\n

baz

\n", + "example": 103, + "start_line": 1676, + "end_line": 1686, + "section": "Setext headings" + }, + { + "markdown": "Foo\nbar\n\n---\n\nbaz\n", + "html": "

Foo\nbar

\n
\n

baz

\n", + "example": 104, + "start_line": 1692, + "end_line": 1704, + "section": "Setext headings" + }, + { + "markdown": "Foo\nbar\n* * *\nbaz\n", + "html": "

Foo\nbar

\n
\n

baz

\n", + "example": 105, + "start_line": 1710, + "end_line": 1720, + "section": "Setext headings" + }, + { + "markdown": "Foo\nbar\n\\---\nbaz\n", + "html": "

Foo\nbar\n---\nbaz

\n", + "example": 106, + "start_line": 1725, + "end_line": 1735, + "section": "Setext headings" + }, + { + "markdown": " a simple\n indented code block\n", + "html": "
a simple\n  indented code block\n
\n", + "example": 107, + "start_line": 1753, + "end_line": 1760, + "section": "Indented code blocks" + }, + { + "markdown": " - foo\n\n bar\n", + "html": "
    \n
  • \n

    foo

    \n

    bar

    \n
  • \n
\n", + "example": 108, + "start_line": 1767, + "end_line": 1778, + "section": "Indented code blocks" + }, + { + "markdown": "1. foo\n\n - bar\n", + "html": "
    \n
  1. \n

    foo

    \n
      \n
    • bar
    • \n
    \n
  2. \n
\n", + "example": 109, + "start_line": 1781, + "end_line": 1794, + "section": "Indented code blocks" + }, + { + "markdown": "
\n *hi*\n\n - one\n", + "html": "
<a/>\n*hi*\n\n- one\n
\n", + "example": 110, + "start_line": 1801, + "end_line": 1812, + "section": "Indented code blocks" + }, + { + "markdown": " chunk1\n\n chunk2\n \n \n \n chunk3\n", + "html": "
chunk1\n\nchunk2\n\n\n\nchunk3\n
\n", + "example": 111, + "start_line": 1817, + "end_line": 1834, + "section": "Indented code blocks" + }, + { + "markdown": " chunk1\n \n chunk2\n", + "html": "
chunk1\n  \n  chunk2\n
\n", + "example": 112, + "start_line": 1840, + "end_line": 1849, + "section": "Indented code blocks" + }, + { + "markdown": "Foo\n bar\n\n", + "html": "

Foo\nbar

\n", + "example": 113, + "start_line": 1855, + "end_line": 1862, + "section": "Indented code blocks" + }, + { + "markdown": " foo\nbar\n", + "html": "
foo\n
\n

bar

\n", + "example": 114, + "start_line": 1869, + "end_line": 1876, + "section": "Indented code blocks" + }, + { + "markdown": "# Heading\n foo\nHeading\n------\n foo\n----\n", + "html": "

Heading

\n
foo\n
\n

Heading

\n
foo\n
\n
\n", + "example": 115, + "start_line": 1882, + "end_line": 1897, + "section": "Indented code blocks" + }, + { + "markdown": " foo\n bar\n", + "html": "
    foo\nbar\n
\n", + "example": 116, + "start_line": 1902, + "end_line": 1909, + "section": "Indented code blocks" + }, + { + "markdown": "\n \n foo\n \n\n", + "html": "
foo\n
\n", + "example": 117, + "start_line": 1915, + "end_line": 1924, + "section": "Indented code blocks" + }, + { + "markdown": " foo \n", + "html": "
foo  \n
\n", + "example": 118, + "start_line": 1929, + "end_line": 1934, + "section": "Indented code blocks" + }, + { + "markdown": "```\n<\n >\n```\n", + "html": "
<\n >\n
\n", + "example": 119, + "start_line": 1984, + "end_line": 1993, + "section": "Fenced code blocks" + }, + { + "markdown": "~~~\n<\n >\n~~~\n", + "html": "
<\n >\n
\n", + "example": 120, + "start_line": 1998, + "end_line": 2007, + "section": "Fenced code blocks" + }, + { + "markdown": "``\nfoo\n``\n", + "html": "

foo

\n", + "example": 121, + "start_line": 2011, + "end_line": 2017, + "section": "Fenced code blocks" + }, + { + "markdown": "```\naaa\n~~~\n```\n", + "html": "
aaa\n~~~\n
\n", + "example": 122, + "start_line": 2022, + "end_line": 2031, + "section": "Fenced code blocks" + }, + { + "markdown": "~~~\naaa\n```\n~~~\n", + "html": "
aaa\n```\n
\n", + "example": 123, + "start_line": 2034, + "end_line": 2043, + "section": "Fenced code blocks" + }, + { + "markdown": "````\naaa\n```\n``````\n", + "html": "
aaa\n```\n
\n", + "example": 124, + "start_line": 2048, + "end_line": 2057, + "section": "Fenced code blocks" + }, + { + "markdown": "~~~~\naaa\n~~~\n~~~~\n", + "html": "
aaa\n~~~\n
\n", + "example": 125, + "start_line": 2060, + "end_line": 2069, + "section": "Fenced code blocks" + }, + { + "markdown": "```\n", + "html": "
\n", + "example": 126, + "start_line": 2075, + "end_line": 2079, + "section": "Fenced code blocks" + }, + { + "markdown": "`````\n\n```\naaa\n", + "html": "
\n```\naaa\n
\n", + "example": 127, + "start_line": 2082, + "end_line": 2092, + "section": "Fenced code blocks" + }, + { + "markdown": "> ```\n> aaa\n\nbbb\n", + "html": "
\n
aaa\n
\n
\n

bbb

\n", + "example": 128, + "start_line": 2095, + "end_line": 2106, + "section": "Fenced code blocks" + }, + { + "markdown": "```\n\n \n```\n", + "html": "
\n  \n
\n", + "example": 129, + "start_line": 2111, + "end_line": 2120, + "section": "Fenced code blocks" + }, + { + "markdown": "```\n```\n", + "html": "
\n", + "example": 130, + "start_line": 2125, + "end_line": 2130, + "section": "Fenced code blocks" + }, + { + "markdown": " ```\n aaa\naaa\n```\n", + "html": "
aaa\naaa\n
\n", + "example": 131, + "start_line": 2137, + "end_line": 2146, + "section": "Fenced code blocks" + }, + { + "markdown": " ```\naaa\n aaa\naaa\n ```\n", + "html": "
aaa\naaa\naaa\n
\n", + "example": 132, + "start_line": 2149, + "end_line": 2160, + "section": "Fenced code blocks" + }, + { + "markdown": " ```\n aaa\n aaa\n aaa\n ```\n", + "html": "
aaa\n aaa\naaa\n
\n", + "example": 133, + "start_line": 2163, + "end_line": 2174, + "section": "Fenced code blocks" + }, + { + "markdown": " ```\n aaa\n ```\n", + "html": "
```\naaa\n```\n
\n", + "example": 134, + "start_line": 2179, + "end_line": 2188, + "section": "Fenced code blocks" + }, + { + "markdown": "```\naaa\n ```\n", + "html": "
aaa\n
\n", + "example": 135, + "start_line": 2194, + "end_line": 2201, + "section": "Fenced code blocks" + }, + { + "markdown": " ```\naaa\n ```\n", + "html": "
aaa\n
\n", + "example": 136, + "start_line": 2204, + "end_line": 2211, + "section": "Fenced code blocks" + }, + { + "markdown": "```\naaa\n ```\n", + "html": "
aaa\n    ```\n
\n", + "example": 137, + "start_line": 2216, + "end_line": 2224, + "section": "Fenced code blocks" + }, + { + "markdown": "``` ```\naaa\n", + "html": "

\naaa

\n", + "example": 138, + "start_line": 2230, + "end_line": 2236, + "section": "Fenced code blocks" + }, + { + "markdown": "~~~~~~\naaa\n~~~ ~~\n", + "html": "
aaa\n~~~ ~~\n
\n", + "example": 139, + "start_line": 2239, + "end_line": 2247, + "section": "Fenced code blocks" + }, + { + "markdown": "foo\n```\nbar\n```\nbaz\n", + "html": "

foo

\n
bar\n
\n

baz

\n", + "example": 140, + "start_line": 2253, + "end_line": 2264, + "section": "Fenced code blocks" + }, + { + "markdown": "foo\n---\n~~~\nbar\n~~~\n# baz\n", + "html": "

foo

\n
bar\n
\n

baz

\n", + "example": 141, + "start_line": 2270, + "end_line": 2282, + "section": "Fenced code blocks" + }, + { + "markdown": "```ruby\ndef foo(x)\n return 3\nend\n```\n", + "html": "
def foo(x)\n  return 3\nend\n
\n", + "example": 142, + "start_line": 2292, + "end_line": 2303, + "section": "Fenced code blocks" + }, + { + "markdown": "~~~~ ruby startline=3 $%@#$\ndef foo(x)\n return 3\nend\n~~~~~~~\n", + "html": "
def foo(x)\n  return 3\nend\n
\n", + "example": 143, + "start_line": 2306, + "end_line": 2317, + "section": "Fenced code blocks" + }, + { + "markdown": "````;\n````\n", + "html": "
\n", + "example": 144, + "start_line": 2320, + "end_line": 2325, + "section": "Fenced code blocks" + }, + { + "markdown": "``` aa ```\nfoo\n", + "html": "

aa\nfoo

\n", + "example": 145, + "start_line": 2330, + "end_line": 2336, + "section": "Fenced code blocks" + }, + { + "markdown": "~~~ aa ``` ~~~\nfoo\n~~~\n", + "html": "
foo\n
\n", + "example": 146, + "start_line": 2341, + "end_line": 2348, + "section": "Fenced code blocks" + }, + { + "markdown": "```\n``` aaa\n```\n", + "html": "
``` aaa\n
\n", + "example": 147, + "start_line": 2353, + "end_line": 2360, + "section": "Fenced code blocks" + }, + { + "markdown": "
\n
\n**Hello**,\n\n_world_.\n
\n
\n", + "html": "
\n
\n**Hello**,\n

world.\n

\n
\n", + "example": 148, + "start_line": 2432, + "end_line": 2447, + "section": "HTML blocks" + }, + { + "markdown": "\n \n \n \n
\n hi\n
\n\nokay.\n", + "html": "\n \n \n \n
\n hi\n
\n

okay.

\n", + "example": 149, + "start_line": 2461, + "end_line": 2480, + "section": "HTML blocks" + }, + { + "markdown": "
\n*foo*\n", + "example": 151, + "start_line": 2496, + "end_line": 2502, + "section": "HTML blocks" + }, + { + "markdown": "
\n\n*Markdown*\n\n
\n", + "html": "
\n

Markdown

\n
\n", + "example": 152, + "start_line": 2507, + "end_line": 2517, + "section": "HTML blocks" + }, + { + "markdown": "
\n
\n", + "html": "
\n
\n", + "example": 153, + "start_line": 2523, + "end_line": 2531, + "section": "HTML blocks" + }, + { + "markdown": "
\n
\n", + "html": "
\n
\n", + "example": 154, + "start_line": 2534, + "end_line": 2542, + "section": "HTML blocks" + }, + { + "markdown": "
\n*foo*\n\n*bar*\n", + "html": "
\n*foo*\n

bar

\n", + "example": 155, + "start_line": 2546, + "end_line": 2555, + "section": "HTML blocks" + }, + { + "markdown": "
\n", + "html": "\n", + "example": 159, + "start_line": 2595, + "end_line": 2599, + "section": "HTML blocks" + }, + { + "markdown": "
\nfoo\n
\n", + "html": "
\nfoo\n
\n", + "example": 160, + "start_line": 2602, + "end_line": 2610, + "section": "HTML blocks" + }, + { + "markdown": "
\n``` c\nint x = 33;\n```\n", + "html": "
\n``` c\nint x = 33;\n```\n", + "example": 161, + "start_line": 2619, + "end_line": 2629, + "section": "HTML blocks" + }, + { + "markdown": "\n*bar*\n\n", + "html": "\n*bar*\n\n", + "example": 162, + "start_line": 2636, + "end_line": 2644, + "section": "HTML blocks" + }, + { + "markdown": "\n*bar*\n\n", + "html": "\n*bar*\n\n", + "example": 163, + "start_line": 2649, + "end_line": 2657, + "section": "HTML blocks" + }, + { + "markdown": "\n*bar*\n\n", + "html": "\n*bar*\n\n", + "example": 164, + "start_line": 2660, + "end_line": 2668, + "section": "HTML blocks" + }, + { + "markdown": "\n*bar*\n", + "html": "\n*bar*\n", + "example": 165, + "start_line": 2671, + "end_line": 2677, + "section": "HTML blocks" + }, + { + "markdown": "\n*foo*\n\n", + "html": "\n*foo*\n\n", + "example": 166, + "start_line": 2686, + "end_line": 2694, + "section": "HTML blocks" + }, + { + "markdown": "\n\n*foo*\n\n\n", + "html": "\n

foo

\n
\n", + "example": 167, + "start_line": 2701, + "end_line": 2711, + "section": "HTML blocks" + }, + { + "markdown": "*foo*\n", + "html": "

foo

\n", + "example": 168, + "start_line": 2719, + "end_line": 2723, + "section": "HTML blocks" + }, + { + "markdown": "
\nimport Text.HTML.TagSoup\n\nmain :: IO ()\nmain = print $ parseTags tags\n
\nokay\n", + "html": "
\nimport Text.HTML.TagSoup\n\nmain :: IO ()\nmain = print $ parseTags tags\n
\n

okay

\n", + "example": 169, + "start_line": 2735, + "end_line": 2751, + "section": "HTML blocks" + }, + { + "markdown": "\nokay\n", + "html": "\n

okay

\n", + "example": 170, + "start_line": 2756, + "end_line": 2770, + "section": "HTML blocks" + }, + { + "markdown": "\n", + "html": "\n", + "example": 171, + "start_line": 2775, + "end_line": 2791, + "section": "HTML blocks" + }, + { + "markdown": "\nh1 {color:red;}\n\np {color:blue;}\n\nokay\n", + "html": "\nh1 {color:red;}\n\np {color:blue;}\n\n

okay

\n", + "example": 172, + "start_line": 2795, + "end_line": 2811, + "section": "HTML blocks" + }, + { + "markdown": "\n\nfoo\n", + "html": "\n\nfoo\n", + "example": 173, + "start_line": 2818, + "end_line": 2828, + "section": "HTML blocks" + }, + { + "markdown": ">
\n> foo\n\nbar\n", + "html": "
\n
\nfoo\n
\n

bar

\n", + "example": 174, + "start_line": 2831, + "end_line": 2842, + "section": "HTML blocks" + }, + { + "markdown": "-
\n- foo\n", + "html": "
    \n
  • \n
    \n
  • \n
  • foo
  • \n
\n", + "example": 175, + "start_line": 2845, + "end_line": 2855, + "section": "HTML blocks" + }, + { + "markdown": "\n*foo*\n", + "html": "\n

foo

\n", + "example": 176, + "start_line": 2860, + "end_line": 2866, + "section": "HTML blocks" + }, + { + "markdown": "*bar*\n*baz*\n", + "html": "*bar*\n

baz

\n", + "example": 177, + "start_line": 2869, + "end_line": 2875, + "section": "HTML blocks" + }, + { + "markdown": "1. *bar*\n", + "html": "1. *bar*\n", + "example": 178, + "start_line": 2881, + "end_line": 2889, + "section": "HTML blocks" + }, + { + "markdown": "\nokay\n", + "html": "\n

okay

\n", + "example": 179, + "start_line": 2894, + "end_line": 2906, + "section": "HTML blocks" + }, + { + "markdown": "';\n\n?>\nokay\n", + "html": "';\n\n?>\n

okay

\n", + "example": 180, + "start_line": 2912, + "end_line": 2926, + "section": "HTML blocks" + }, + { + "markdown": "\n", + "html": "\n", + "example": 181, + "start_line": 2931, + "end_line": 2935, + "section": "HTML blocks" + }, + { + "markdown": "\nokay\n", + "html": "\n

okay

\n", + "example": 182, + "start_line": 2940, + "end_line": 2968, + "section": "HTML blocks" + }, + { + "markdown": " \n\n \n", + "html": " \n
<!-- foo -->\n
\n", + "example": 183, + "start_line": 2974, + "end_line": 2982, + "section": "HTML blocks" + }, + { + "markdown": "
\n\n
\n", + "html": "
\n
<div>\n
\n", + "example": 184, + "start_line": 2985, + "end_line": 2993, + "section": "HTML blocks" + }, + { + "markdown": "Foo\n
\nbar\n
\n", + "html": "

Foo

\n
\nbar\n
\n", + "example": 185, + "start_line": 2999, + "end_line": 3009, + "section": "HTML blocks" + }, + { + "markdown": "
\nbar\n
\n*foo*\n", + "html": "
\nbar\n
\n*foo*\n", + "example": 186, + "start_line": 3016, + "end_line": 3026, + "section": "HTML blocks" + }, + { + "markdown": "Foo\n\nbaz\n", + "html": "

Foo\n\nbaz

\n", + "example": 187, + "start_line": 3031, + "end_line": 3039, + "section": "HTML blocks" + }, + { + "markdown": "
\n\n*Emphasized* text.\n\n
\n", + "html": "
\n

Emphasized text.

\n
\n", + "example": 188, + "start_line": 3072, + "end_line": 3082, + "section": "HTML blocks" + }, + { + "markdown": "
\n*Emphasized* text.\n
\n", + "html": "
\n*Emphasized* text.\n
\n", + "example": 189, + "start_line": 3085, + "end_line": 3093, + "section": "HTML blocks" + }, + { + "markdown": "\n\n\n\n\n\n\n\n
\nHi\n
\n", + "html": "\n\n\n\n
\nHi\n
\n", + "example": 190, + "start_line": 3107, + "end_line": 3127, + "section": "HTML blocks" + }, + { + "markdown": "\n\n \n\n \n\n \n\n
\n Hi\n
\n", + "html": "\n \n
<td>\n  Hi\n</td>\n
\n \n
\n", + "example": 191, + "start_line": 3134, + "end_line": 3155, + "section": "HTML blocks" + }, + { + "markdown": "[foo]: /url \"title\"\n\n[foo]\n", + "html": "

foo

\n", + "example": 192, + "start_line": 3183, + "end_line": 3189, + "section": "Link reference definitions" + }, + { + "markdown": " [foo]: \n /url \n 'the title' \n\n[foo]\n", + "html": "

foo

\n", + "example": 193, + "start_line": 3192, + "end_line": 3200, + "section": "Link reference definitions" + }, + { + "markdown": "[Foo*bar\\]]:my_(url) 'title (with parens)'\n\n[Foo*bar\\]]\n", + "html": "

Foo*bar]

\n", + "example": 194, + "start_line": 3203, + "end_line": 3209, + "section": "Link reference definitions" + }, + { + "markdown": "[Foo bar]:\n\n'title'\n\n[Foo bar]\n", + "html": "

Foo bar

\n", + "example": 195, + "start_line": 3212, + "end_line": 3220, + "section": "Link reference definitions" + }, + { + "markdown": "[foo]: /url '\ntitle\nline1\nline2\n'\n\n[foo]\n", + "html": "

foo

\n", + "example": 196, + "start_line": 3225, + "end_line": 3239, + "section": "Link reference definitions" + }, + { + "markdown": "[foo]: /url 'title\n\nwith blank line'\n\n[foo]\n", + "html": "

[foo]: /url 'title

\n

with blank line'

\n

[foo]

\n", + "example": 197, + "start_line": 3244, + "end_line": 3254, + "section": "Link reference definitions" + }, + { + "markdown": "[foo]:\n/url\n\n[foo]\n", + "html": "

foo

\n", + "example": 198, + "start_line": 3259, + "end_line": 3266, + "section": "Link reference definitions" + }, + { + "markdown": "[foo]:\n\n[foo]\n", + "html": "

[foo]:

\n

[foo]

\n", + "example": 199, + "start_line": 3271, + "end_line": 3278, + "section": "Link reference definitions" + }, + { + "markdown": "[foo]: <>\n\n[foo]\n", + "html": "

foo

\n", + "example": 200, + "start_line": 3283, + "end_line": 3289, + "section": "Link reference definitions" + }, + { + "markdown": "[foo]: (baz)\n\n[foo]\n", + "html": "

[foo]: (baz)

\n

[foo]

\n", + "example": 201, + "start_line": 3294, + "end_line": 3301, + "section": "Link reference definitions" + }, + { + "markdown": "[foo]: /url\\bar\\*baz \"foo\\\"bar\\baz\"\n\n[foo]\n", + "html": "

foo

\n", + "example": 202, + "start_line": 3307, + "end_line": 3313, + "section": "Link reference definitions" + }, + { + "markdown": "[foo]\n\n[foo]: url\n", + "html": "

foo

\n", + "example": 203, + "start_line": 3318, + "end_line": 3324, + "section": "Link reference definitions" + }, + { + "markdown": "[foo]\n\n[foo]: first\n[foo]: second\n", + "html": "

foo

\n", + "example": 204, + "start_line": 3330, + "end_line": 3337, + "section": "Link reference definitions" + }, + { + "markdown": "[FOO]: /url\n\n[Foo]\n", + "html": "

Foo

\n", + "example": 205, + "start_line": 3343, + "end_line": 3349, + "section": "Link reference definitions" + }, + { + "markdown": "[ΑΓΩ]: /φου\n\n[αγω]\n", + "html": "

αγω

\n", + "example": 206, + "start_line": 3352, + "end_line": 3358, + "section": "Link reference definitions" + }, + { + "markdown": "[foo]: /url\n", + "html": "", + "example": 207, + "start_line": 3367, + "end_line": 3370, + "section": "Link reference definitions" + }, + { + "markdown": "[\nfoo\n]: /url\nbar\n", + "html": "

bar

\n", + "example": 208, + "start_line": 3375, + "end_line": 3382, + "section": "Link reference definitions" + }, + { + "markdown": "[foo]: /url \"title\" ok\n", + "html": "

[foo]: /url "title" ok

\n", + "example": 209, + "start_line": 3388, + "end_line": 3392, + "section": "Link reference definitions" + }, + { + "markdown": "[foo]: /url\n\"title\" ok\n", + "html": "

"title" ok

\n", + "example": 210, + "start_line": 3397, + "end_line": 3402, + "section": "Link reference definitions" + }, + { + "markdown": " [foo]: /url \"title\"\n\n[foo]\n", + "html": "
[foo]: /url "title"\n
\n

[foo]

\n", + "example": 211, + "start_line": 3408, + "end_line": 3416, + "section": "Link reference definitions" + }, + { + "markdown": "```\n[foo]: /url\n```\n\n[foo]\n", + "html": "
[foo]: /url\n
\n

[foo]

\n", + "example": 212, + "start_line": 3422, + "end_line": 3432, + "section": "Link reference definitions" + }, + { + "markdown": "Foo\n[bar]: /baz\n\n[bar]\n", + "html": "

Foo\n[bar]: /baz

\n

[bar]

\n", + "example": 213, + "start_line": 3437, + "end_line": 3446, + "section": "Link reference definitions" + }, + { + "markdown": "# [Foo]\n[foo]: /url\n> bar\n", + "html": "

Foo

\n
\n

bar

\n
\n", + "example": 214, + "start_line": 3452, + "end_line": 3461, + "section": "Link reference definitions" + }, + { + "markdown": "[foo]: /url\nbar\n===\n[foo]\n", + "html": "

bar

\n

foo

\n", + "example": 215, + "start_line": 3463, + "end_line": 3471, + "section": "Link reference definitions" + }, + { + "markdown": "[foo]: /url\n===\n[foo]\n", + "html": "

===\nfoo

\n", + "example": 216, + "start_line": 3473, + "end_line": 3480, + "section": "Link reference definitions" + }, + { + "markdown": "[foo]: /foo-url \"foo\"\n[bar]: /bar-url\n \"bar\"\n[baz]: /baz-url\n\n[foo],\n[bar],\n[baz]\n", + "html": "

foo,\nbar,\nbaz

\n", + "example": 217, + "start_line": 3486, + "end_line": 3499, + "section": "Link reference definitions" + }, + { + "markdown": "[foo]\n\n> [foo]: /url\n", + "html": "

foo

\n
\n
\n", + "example": 218, + "start_line": 3507, + "end_line": 3515, + "section": "Link reference definitions" + }, + { + "markdown": "aaa\n\nbbb\n", + "html": "

aaa

\n

bbb

\n", + "example": 219, + "start_line": 3529, + "end_line": 3536, + "section": "Paragraphs" + }, + { + "markdown": "aaa\nbbb\n\nccc\nddd\n", + "html": "

aaa\nbbb

\n

ccc\nddd

\n", + "example": 220, + "start_line": 3541, + "end_line": 3552, + "section": "Paragraphs" + }, + { + "markdown": "aaa\n\n\nbbb\n", + "html": "

aaa

\n

bbb

\n", + "example": 221, + "start_line": 3557, + "end_line": 3565, + "section": "Paragraphs" + }, + { + "markdown": " aaa\n bbb\n", + "html": "

aaa\nbbb

\n", + "example": 222, + "start_line": 3570, + "end_line": 3576, + "section": "Paragraphs" + }, + { + "markdown": "aaa\n bbb\n ccc\n", + "html": "

aaa\nbbb\nccc

\n", + "example": 223, + "start_line": 3582, + "end_line": 3590, + "section": "Paragraphs" + }, + { + "markdown": " aaa\nbbb\n", + "html": "

aaa\nbbb

\n", + "example": 224, + "start_line": 3596, + "end_line": 3602, + "section": "Paragraphs" + }, + { + "markdown": " aaa\nbbb\n", + "html": "
aaa\n
\n

bbb

\n", + "example": 225, + "start_line": 3605, + "end_line": 3612, + "section": "Paragraphs" + }, + { + "markdown": "aaa \nbbb \n", + "html": "

aaa
\nbbb

\n", + "example": 226, + "start_line": 3619, + "end_line": 3625, + "section": "Paragraphs" + }, + { + "markdown": " \n\naaa\n \n\n# aaa\n\n \n", + "html": "

aaa

\n

aaa

\n", + "example": 227, + "start_line": 3636, + "end_line": 3648, + "section": "Blank lines" + }, + { + "markdown": "> # Foo\n> bar\n> baz\n", + "html": "
\n

Foo

\n

bar\nbaz

\n
\n", + "example": 228, + "start_line": 3704, + "end_line": 3714, + "section": "Block quotes" + }, + { + "markdown": "># Foo\n>bar\n> baz\n", + "html": "
\n

Foo

\n

bar\nbaz

\n
\n", + "example": 229, + "start_line": 3719, + "end_line": 3729, + "section": "Block quotes" + }, + { + "markdown": " > # Foo\n > bar\n > baz\n", + "html": "
\n

Foo

\n

bar\nbaz

\n
\n", + "example": 230, + "start_line": 3734, + "end_line": 3744, + "section": "Block quotes" + }, + { + "markdown": " > # Foo\n > bar\n > baz\n", + "html": "
> # Foo\n> bar\n> baz\n
\n", + "example": 231, + "start_line": 3749, + "end_line": 3758, + "section": "Block quotes" + }, + { + "markdown": "> # Foo\n> bar\nbaz\n", + "html": "
\n

Foo

\n

bar\nbaz

\n
\n", + "example": 232, + "start_line": 3764, + "end_line": 3774, + "section": "Block quotes" + }, + { + "markdown": "> bar\nbaz\n> foo\n", + "html": "
\n

bar\nbaz\nfoo

\n
\n", + "example": 233, + "start_line": 3780, + "end_line": 3790, + "section": "Block quotes" + }, + { + "markdown": "> foo\n---\n", + "html": "
\n

foo

\n
\n
\n", + "example": 234, + "start_line": 3804, + "end_line": 3812, + "section": "Block quotes" + }, + { + "markdown": "> - foo\n- bar\n", + "html": "
\n
    \n
  • foo
  • \n
\n
\n
    \n
  • bar
  • \n
\n", + "example": 235, + "start_line": 3824, + "end_line": 3836, + "section": "Block quotes" + }, + { + "markdown": "> foo\n bar\n", + "html": "
\n
foo\n
\n
\n
bar\n
\n", + "example": 236, + "start_line": 3842, + "end_line": 3852, + "section": "Block quotes" + }, + { + "markdown": "> ```\nfoo\n```\n", + "html": "
\n
\n
\n

foo

\n
\n", + "example": 237, + "start_line": 3855, + "end_line": 3865, + "section": "Block quotes" + }, + { + "markdown": "> foo\n - bar\n", + "html": "
\n

foo\n- bar

\n
\n", + "example": 238, + "start_line": 3871, + "end_line": 3879, + "section": "Block quotes" + }, + { + "markdown": ">\n", + "html": "
\n
\n", + "example": 239, + "start_line": 3895, + "end_line": 3900, + "section": "Block quotes" + }, + { + "markdown": ">\n> \n> \n", + "html": "
\n
\n", + "example": 240, + "start_line": 3903, + "end_line": 3910, + "section": "Block quotes" + }, + { + "markdown": ">\n> foo\n> \n", + "html": "
\n

foo

\n
\n", + "example": 241, + "start_line": 3915, + "end_line": 3923, + "section": "Block quotes" + }, + { + "markdown": "> foo\n\n> bar\n", + "html": "
\n

foo

\n
\n
\n

bar

\n
\n", + "example": 242, + "start_line": 3928, + "end_line": 3939, + "section": "Block quotes" + }, + { + "markdown": "> foo\n> bar\n", + "html": "
\n

foo\nbar

\n
\n", + "example": 243, + "start_line": 3950, + "end_line": 3958, + "section": "Block quotes" + }, + { + "markdown": "> foo\n>\n> bar\n", + "html": "
\n

foo

\n

bar

\n
\n", + "example": 244, + "start_line": 3963, + "end_line": 3972, + "section": "Block quotes" + }, + { + "markdown": "foo\n> bar\n", + "html": "

foo

\n
\n

bar

\n
\n", + "example": 245, + "start_line": 3977, + "end_line": 3985, + "section": "Block quotes" + }, + { + "markdown": "> aaa\n***\n> bbb\n", + "html": "
\n

aaa

\n
\n
\n
\n

bbb

\n
\n", + "example": 246, + "start_line": 3991, + "end_line": 4003, + "section": "Block quotes" + }, + { + "markdown": "> bar\nbaz\n", + "html": "
\n

bar\nbaz

\n
\n", + "example": 247, + "start_line": 4009, + "end_line": 4017, + "section": "Block quotes" + }, + { + "markdown": "> bar\n\nbaz\n", + "html": "
\n

bar

\n
\n

baz

\n", + "example": 248, + "start_line": 4020, + "end_line": 4029, + "section": "Block quotes" + }, + { + "markdown": "> bar\n>\nbaz\n", + "html": "
\n

bar

\n
\n

baz

\n", + "example": 249, + "start_line": 4032, + "end_line": 4041, + "section": "Block quotes" + }, + { + "markdown": "> > > foo\nbar\n", + "html": "
\n
\n
\n

foo\nbar

\n
\n
\n
\n", + "example": 250, + "start_line": 4048, + "end_line": 4060, + "section": "Block quotes" + }, + { + "markdown": ">>> foo\n> bar\n>>baz\n", + "html": "
\n
\n
\n

foo\nbar\nbaz

\n
\n
\n
\n", + "example": 251, + "start_line": 4063, + "end_line": 4077, + "section": "Block quotes" + }, + { + "markdown": "> code\n\n> not code\n", + "html": "
\n
code\n
\n
\n
\n

not code

\n
\n", + "example": 252, + "start_line": 4085, + "end_line": 4097, + "section": "Block quotes" + }, + { + "markdown": "A paragraph\nwith two lines.\n\n indented code\n\n> A block quote.\n", + "html": "

A paragraph\nwith two lines.

\n
indented code\n
\n
\n

A block quote.

\n
\n", + "example": 253, + "start_line": 4139, + "end_line": 4154, + "section": "List items" + }, + { + "markdown": "1. A paragraph\n with two lines.\n\n indented code\n\n > A block quote.\n", + "html": "
    \n
  1. \n

    A paragraph\nwith two lines.

    \n
    indented code\n
    \n
    \n

    A block quote.

    \n
    \n
  2. \n
\n", + "example": 254, + "start_line": 4161, + "end_line": 4180, + "section": "List items" + }, + { + "markdown": "- one\n\n two\n", + "html": "
    \n
  • one
  • \n
\n

two

\n", + "example": 255, + "start_line": 4194, + "end_line": 4203, + "section": "List items" + }, + { + "markdown": "- one\n\n two\n", + "html": "
    \n
  • \n

    one

    \n

    two

    \n
  • \n
\n", + "example": 256, + "start_line": 4206, + "end_line": 4217, + "section": "List items" + }, + { + "markdown": " - one\n\n two\n", + "html": "
    \n
  • one
  • \n
\n
 two\n
\n", + "example": 257, + "start_line": 4220, + "end_line": 4230, + "section": "List items" + }, + { + "markdown": " - one\n\n two\n", + "html": "
    \n
  • \n

    one

    \n

    two

    \n
  • \n
\n", + "example": 258, + "start_line": 4233, + "end_line": 4244, + "section": "List items" + }, + { + "markdown": " > > 1. one\n>>\n>> two\n", + "html": "
\n
\n
    \n
  1. \n

    one

    \n

    two

    \n
  2. \n
\n
\n
\n", + "example": 259, + "start_line": 4255, + "end_line": 4270, + "section": "List items" + }, + { + "markdown": ">>- one\n>>\n > > two\n", + "html": "
\n
\n
    \n
  • one
  • \n
\n

two

\n
\n
\n", + "example": 260, + "start_line": 4282, + "end_line": 4295, + "section": "List items" + }, + { + "markdown": "-one\n\n2.two\n", + "html": "

-one

\n

2.two

\n", + "example": 261, + "start_line": 4301, + "end_line": 4308, + "section": "List items" + }, + { + "markdown": "- foo\n\n\n bar\n", + "html": "
    \n
  • \n

    foo

    \n

    bar

    \n
  • \n
\n", + "example": 262, + "start_line": 4314, + "end_line": 4326, + "section": "List items" + }, + { + "markdown": "1. foo\n\n ```\n bar\n ```\n\n baz\n\n > bam\n", + "html": "
    \n
  1. \n

    foo

    \n
    bar\n
    \n

    baz

    \n
    \n

    bam

    \n
    \n
  2. \n
\n", + "example": 263, + "start_line": 4331, + "end_line": 4353, + "section": "List items" + }, + { + "markdown": "- Foo\n\n bar\n\n\n baz\n", + "html": "
    \n
  • \n

    Foo

    \n
    bar\n\n\nbaz\n
    \n
  • \n
\n", + "example": 264, + "start_line": 4359, + "end_line": 4377, + "section": "List items" + }, + { + "markdown": "123456789. ok\n", + "html": "
    \n
  1. ok
  2. \n
\n", + "example": 265, + "start_line": 4381, + "end_line": 4387, + "section": "List items" + }, + { + "markdown": "1234567890. not ok\n", + "html": "

1234567890. not ok

\n", + "example": 266, + "start_line": 4390, + "end_line": 4394, + "section": "List items" + }, + { + "markdown": "0. ok\n", + "html": "
    \n
  1. ok
  2. \n
\n", + "example": 267, + "start_line": 4399, + "end_line": 4405, + "section": "List items" + }, + { + "markdown": "003. ok\n", + "html": "
    \n
  1. ok
  2. \n
\n", + "example": 268, + "start_line": 4408, + "end_line": 4414, + "section": "List items" + }, + { + "markdown": "-1. not ok\n", + "html": "

-1. not ok

\n", + "example": 269, + "start_line": 4419, + "end_line": 4423, + "section": "List items" + }, + { + "markdown": "- foo\n\n bar\n", + "html": "
    \n
  • \n

    foo

    \n
    bar\n
    \n
  • \n
\n", + "example": 270, + "start_line": 4442, + "end_line": 4454, + "section": "List items" + }, + { + "markdown": " 10. foo\n\n bar\n", + "html": "
    \n
  1. \n

    foo

    \n
    bar\n
    \n
  2. \n
\n", + "example": 271, + "start_line": 4459, + "end_line": 4471, + "section": "List items" + }, + { + "markdown": " indented code\n\nparagraph\n\n more code\n", + "html": "
indented code\n
\n

paragraph

\n
more code\n
\n", + "example": 272, + "start_line": 4478, + "end_line": 4490, + "section": "List items" + }, + { + "markdown": "1. indented code\n\n paragraph\n\n more code\n", + "html": "
    \n
  1. \n
    indented code\n
    \n

    paragraph

    \n
    more code\n
    \n
  2. \n
\n", + "example": 273, + "start_line": 4493, + "end_line": 4509, + "section": "List items" + }, + { + "markdown": "1. indented code\n\n paragraph\n\n more code\n", + "html": "
    \n
  1. \n
     indented code\n
    \n

    paragraph

    \n
    more code\n
    \n
  2. \n
\n", + "example": 274, + "start_line": 4515, + "end_line": 4531, + "section": "List items" + }, + { + "markdown": " foo\n\nbar\n", + "html": "

foo

\n

bar

\n", + "example": 275, + "start_line": 4542, + "end_line": 4549, + "section": "List items" + }, + { + "markdown": "- foo\n\n bar\n", + "html": "
    \n
  • foo
  • \n
\n

bar

\n", + "example": 276, + "start_line": 4552, + "end_line": 4561, + "section": "List items" + }, + { + "markdown": "- foo\n\n bar\n", + "html": "
    \n
  • \n

    foo

    \n

    bar

    \n
  • \n
\n", + "example": 277, + "start_line": 4569, + "end_line": 4580, + "section": "List items" + }, + { + "markdown": "-\n foo\n-\n ```\n bar\n ```\n-\n baz\n", + "html": "
    \n
  • foo
  • \n
  • \n
    bar\n
    \n
  • \n
  • \n
    baz\n
    \n
  • \n
\n", + "example": 278, + "start_line": 4596, + "end_line": 4617, + "section": "List items" + }, + { + "markdown": "- \n foo\n", + "html": "
    \n
  • foo
  • \n
\n", + "example": 279, + "start_line": 4622, + "end_line": 4629, + "section": "List items" + }, + { + "markdown": "-\n\n foo\n", + "html": "
    \n
  • \n
\n

foo

\n", + "example": 280, + "start_line": 4636, + "end_line": 4645, + "section": "List items" + }, + { + "markdown": "- foo\n-\n- bar\n", + "html": "
    \n
  • foo
  • \n
  • \n
  • bar
  • \n
\n", + "example": 281, + "start_line": 4650, + "end_line": 4660, + "section": "List items" + }, + { + "markdown": "- foo\n- \n- bar\n", + "html": "
    \n
  • foo
  • \n
  • \n
  • bar
  • \n
\n", + "example": 282, + "start_line": 4665, + "end_line": 4675, + "section": "List items" + }, + { + "markdown": "1. foo\n2.\n3. bar\n", + "html": "
    \n
  1. foo
  2. \n
  3. \n
  4. bar
  5. \n
\n", + "example": 283, + "start_line": 4680, + "end_line": 4690, + "section": "List items" + }, + { + "markdown": "*\n", + "html": "
    \n
  • \n
\n", + "example": 284, + "start_line": 4695, + "end_line": 4701, + "section": "List items" + }, + { + "markdown": "foo\n*\n\nfoo\n1.\n", + "html": "

foo\n*

\n

foo\n1.

\n", + "example": 285, + "start_line": 4705, + "end_line": 4716, + "section": "List items" + }, + { + "markdown": " 1. A paragraph\n with two lines.\n\n indented code\n\n > A block quote.\n", + "html": "
    \n
  1. \n

    A paragraph\nwith two lines.

    \n
    indented code\n
    \n
    \n

    A block quote.

    \n
    \n
  2. \n
\n", + "example": 286, + "start_line": 4727, + "end_line": 4746, + "section": "List items" + }, + { + "markdown": " 1. A paragraph\n with two lines.\n\n indented code\n\n > A block quote.\n", + "html": "
    \n
  1. \n

    A paragraph\nwith two lines.

    \n
    indented code\n
    \n
    \n

    A block quote.

    \n
    \n
  2. \n
\n", + "example": 287, + "start_line": 4751, + "end_line": 4770, + "section": "List items" + }, + { + "markdown": " 1. A paragraph\n with two lines.\n\n indented code\n\n > A block quote.\n", + "html": "
    \n
  1. \n

    A paragraph\nwith two lines.

    \n
    indented code\n
    \n
    \n

    A block quote.

    \n
    \n
  2. \n
\n", + "example": 288, + "start_line": 4775, + "end_line": 4794, + "section": "List items" + }, + { + "markdown": " 1. A paragraph\n with two lines.\n\n indented code\n\n > A block quote.\n", + "html": "
1.  A paragraph\n    with two lines.\n\n        indented code\n\n    > A block quote.\n
\n", + "example": 289, + "start_line": 4799, + "end_line": 4814, + "section": "List items" + }, + { + "markdown": " 1. A paragraph\nwith two lines.\n\n indented code\n\n > A block quote.\n", + "html": "
    \n
  1. \n

    A paragraph\nwith two lines.

    \n
    indented code\n
    \n
    \n

    A block quote.

    \n
    \n
  2. \n
\n", + "example": 290, + "start_line": 4829, + "end_line": 4848, + "section": "List items" + }, + { + "markdown": " 1. A paragraph\n with two lines.\n", + "html": "
    \n
  1. A paragraph\nwith two lines.
  2. \n
\n", + "example": 291, + "start_line": 4853, + "end_line": 4861, + "section": "List items" + }, + { + "markdown": "> 1. > Blockquote\ncontinued here.\n", + "html": "
\n
    \n
  1. \n
    \n

    Blockquote\ncontinued here.

    \n
    \n
  2. \n
\n
\n", + "example": 292, + "start_line": 4866, + "end_line": 4880, + "section": "List items" + }, + { + "markdown": "> 1. > Blockquote\n> continued here.\n", + "html": "
\n
    \n
  1. \n
    \n

    Blockquote\ncontinued here.

    \n
    \n
  2. \n
\n
\n", + "example": 293, + "start_line": 4883, + "end_line": 4897, + "section": "List items" + }, + { + "markdown": "- foo\n - bar\n - baz\n - boo\n", + "html": "
    \n
  • foo\n
      \n
    • bar\n
        \n
      • baz\n
          \n
        • boo
        • \n
        \n
      • \n
      \n
    • \n
    \n
  • \n
\n", + "example": 294, + "start_line": 4911, + "end_line": 4932, + "section": "List items" + }, + { + "markdown": "- foo\n - bar\n - baz\n - boo\n", + "html": "
    \n
  • foo
  • \n
  • bar
  • \n
  • baz
  • \n
  • boo
  • \n
\n", + "example": 295, + "start_line": 4937, + "end_line": 4949, + "section": "List items" + }, + { + "markdown": "10) foo\n - bar\n", + "html": "
    \n
  1. foo\n
      \n
    • bar
    • \n
    \n
  2. \n
\n", + "example": 296, + "start_line": 4954, + "end_line": 4965, + "section": "List items" + }, + { + "markdown": "10) foo\n - bar\n", + "html": "
    \n
  1. foo
  2. \n
\n
    \n
  • bar
  • \n
\n", + "example": 297, + "start_line": 4970, + "end_line": 4980, + "section": "List items" + }, + { + "markdown": "- - foo\n", + "html": "
    \n
  • \n
      \n
    • foo
    • \n
    \n
  • \n
\n", + "example": 298, + "start_line": 4985, + "end_line": 4995, + "section": "List items" + }, + { + "markdown": "1. - 2. foo\n", + "html": "
    \n
  1. \n
      \n
    • \n
        \n
      1. foo
      2. \n
      \n
    • \n
    \n
  2. \n
\n", + "example": 299, + "start_line": 4998, + "end_line": 5012, + "section": "List items" + }, + { + "markdown": "- # Foo\n- Bar\n ---\n baz\n", + "html": "
    \n
  • \n

    Foo

    \n
  • \n
  • \n

    Bar

    \nbaz
  • \n
\n", + "example": 300, + "start_line": 5017, + "end_line": 5031, + "section": "List items" + }, + { + "markdown": "- foo\n- bar\n+ baz\n", + "html": "
    \n
  • foo
  • \n
  • bar
  • \n
\n
    \n
  • baz
  • \n
\n", + "example": 301, + "start_line": 5253, + "end_line": 5265, + "section": "Lists" + }, + { + "markdown": "1. foo\n2. bar\n3) baz\n", + "html": "
    \n
  1. foo
  2. \n
  3. bar
  4. \n
\n
    \n
  1. baz
  2. \n
\n", + "example": 302, + "start_line": 5268, + "end_line": 5280, + "section": "Lists" + }, + { + "markdown": "Foo\n- bar\n- baz\n", + "html": "

Foo

\n
    \n
  • bar
  • \n
  • baz
  • \n
\n", + "example": 303, + "start_line": 5287, + "end_line": 5297, + "section": "Lists" + }, + { + "markdown": "The number of windows in my house is\n14. The number of doors is 6.\n", + "html": "

The number of windows in my house is\n14. The number of doors is 6.

\n", + "example": 304, + "start_line": 5364, + "end_line": 5370, + "section": "Lists" + }, + { + "markdown": "The number of windows in my house is\n1. The number of doors is 6.\n", + "html": "

The number of windows in my house is

\n
    \n
  1. The number of doors is 6.
  2. \n
\n", + "example": 305, + "start_line": 5374, + "end_line": 5382, + "section": "Lists" + }, + { + "markdown": "- foo\n\n- bar\n\n\n- baz\n", + "html": "
    \n
  • \n

    foo

    \n
  • \n
  • \n

    bar

    \n
  • \n
  • \n

    baz

    \n
  • \n
\n", + "example": 306, + "start_line": 5388, + "end_line": 5407, + "section": "Lists" + }, + { + "markdown": "- foo\n - bar\n - baz\n\n\n bim\n", + "html": "
    \n
  • foo\n
      \n
    • bar\n
        \n
      • \n

        baz

        \n

        bim

        \n
      • \n
      \n
    • \n
    \n
  • \n
\n", + "example": 307, + "start_line": 5409, + "end_line": 5431, + "section": "Lists" + }, + { + "markdown": "- foo\n- bar\n\n\n\n- baz\n- bim\n", + "html": "
    \n
  • foo
  • \n
  • bar
  • \n
\n\n
    \n
  • baz
  • \n
  • bim
  • \n
\n", + "example": 308, + "start_line": 5439, + "end_line": 5457, + "section": "Lists" + }, + { + "markdown": "- foo\n\n notcode\n\n- foo\n\n\n\n code\n", + "html": "
    \n
  • \n

    foo

    \n

    notcode

    \n
  • \n
  • \n

    foo

    \n
  • \n
\n\n
code\n
\n", + "example": 309, + "start_line": 5460, + "end_line": 5483, + "section": "Lists" + }, + { + "markdown": "- a\n - b\n - c\n - d\n - e\n - f\n- g\n", + "html": "
    \n
  • a
  • \n
  • b
  • \n
  • c
  • \n
  • d
  • \n
  • e
  • \n
  • f
  • \n
  • g
  • \n
\n", + "example": 310, + "start_line": 5491, + "end_line": 5509, + "section": "Lists" + }, + { + "markdown": "1. a\n\n 2. b\n\n 3. c\n", + "html": "
    \n
  1. \n

    a

    \n
  2. \n
  3. \n

    b

    \n
  4. \n
  5. \n

    c

    \n
  6. \n
\n", + "example": 311, + "start_line": 5512, + "end_line": 5530, + "section": "Lists" + }, + { + "markdown": "- a\n - b\n - c\n - d\n - e\n", + "html": "
    \n
  • a
  • \n
  • b
  • \n
  • c
  • \n
  • d\n- e
  • \n
\n", + "example": 312, + "start_line": 5536, + "end_line": 5550, + "section": "Lists" + }, + { + "markdown": "1. a\n\n 2. b\n\n 3. c\n", + "html": "
    \n
  1. \n

    a

    \n
  2. \n
  3. \n

    b

    \n
  4. \n
\n
3. c\n
\n", + "example": 313, + "start_line": 5556, + "end_line": 5573, + "section": "Lists" + }, + { + "markdown": "- a\n- b\n\n- c\n", + "html": "
    \n
  • \n

    a

    \n
  • \n
  • \n

    b

    \n
  • \n
  • \n

    c

    \n
  • \n
\n", + "example": 314, + "start_line": 5579, + "end_line": 5596, + "section": "Lists" + }, + { + "markdown": "* a\n*\n\n* c\n", + "html": "
    \n
  • \n

    a

    \n
  • \n
  • \n
  • \n

    c

    \n
  • \n
\n", + "example": 315, + "start_line": 5601, + "end_line": 5616, + "section": "Lists" + }, + { + "markdown": "- a\n- b\n\n c\n- d\n", + "html": "
    \n
  • \n

    a

    \n
  • \n
  • \n

    b

    \n

    c

    \n
  • \n
  • \n

    d

    \n
  • \n
\n", + "example": 316, + "start_line": 5623, + "end_line": 5642, + "section": "Lists" + }, + { + "markdown": "- a\n- b\n\n [ref]: /url\n- d\n", + "html": "
    \n
  • \n

    a

    \n
  • \n
  • \n

    b

    \n
  • \n
  • \n

    d

    \n
  • \n
\n", + "example": 317, + "start_line": 5645, + "end_line": 5663, + "section": "Lists" + }, + { + "markdown": "- a\n- ```\n b\n\n\n ```\n- c\n", + "html": "
    \n
  • a
  • \n
  • \n
    b\n\n\n
    \n
  • \n
  • c
  • \n
\n", + "example": 318, + "start_line": 5668, + "end_line": 5687, + "section": "Lists" + }, + { + "markdown": "- a\n - b\n\n c\n- d\n", + "html": "
    \n
  • a\n
      \n
    • \n

      b

      \n

      c

      \n
    • \n
    \n
  • \n
  • d
  • \n
\n", + "example": 319, + "start_line": 5694, + "end_line": 5712, + "section": "Lists" + }, + { + "markdown": "* a\n > b\n >\n* c\n", + "html": "
    \n
  • a\n
    \n

    b

    \n
    \n
  • \n
  • c
  • \n
\n", + "example": 320, + "start_line": 5718, + "end_line": 5732, + "section": "Lists" + }, + { + "markdown": "- a\n > b\n ```\n c\n ```\n- d\n", + "html": "
    \n
  • a\n
    \n

    b

    \n
    \n
    c\n
    \n
  • \n
  • d
  • \n
\n", + "example": 321, + "start_line": 5738, + "end_line": 5756, + "section": "Lists" + }, + { + "markdown": "- a\n", + "html": "
    \n
  • a
  • \n
\n", + "example": 322, + "start_line": 5761, + "end_line": 5767, + "section": "Lists" + }, + { + "markdown": "- a\n - b\n", + "html": "
    \n
  • a\n
      \n
    • b
    • \n
    \n
  • \n
\n", + "example": 323, + "start_line": 5770, + "end_line": 5781, + "section": "Lists" + }, + { + "markdown": "1. ```\n foo\n ```\n\n bar\n", + "html": "
    \n
  1. \n
    foo\n
    \n

    bar

    \n
  2. \n
\n", + "example": 324, + "start_line": 5787, + "end_line": 5801, + "section": "Lists" + }, + { + "markdown": "* foo\n * bar\n\n baz\n", + "html": "
    \n
  • \n

    foo

    \n
      \n
    • bar
    • \n
    \n

    baz

    \n
  • \n
\n", + "example": 325, + "start_line": 5806, + "end_line": 5821, + "section": "Lists" + }, + { + "markdown": "- a\n - b\n - c\n\n- d\n - e\n - f\n", + "html": "
    \n
  • \n

    a

    \n
      \n
    • b
    • \n
    • c
    • \n
    \n
  • \n
  • \n

    d

    \n
      \n
    • e
    • \n
    • f
    • \n
    \n
  • \n
\n", + "example": 326, + "start_line": 5824, + "end_line": 5849, + "section": "Lists" + }, + { + "markdown": "`hi`lo`\n", + "html": "

hilo`

\n", + "example": 327, + "start_line": 5858, + "end_line": 5862, + "section": "Inlines" + }, + { + "markdown": "`foo`\n", + "html": "

foo

\n", + "example": 328, + "start_line": 5890, + "end_line": 5894, + "section": "Code spans" + }, + { + "markdown": "`` foo ` bar ``\n", + "html": "

foo ` bar

\n", + "example": 329, + "start_line": 5901, + "end_line": 5905, + "section": "Code spans" + }, + { + "markdown": "` `` `\n", + "html": "

``

\n", + "example": 330, + "start_line": 5911, + "end_line": 5915, + "section": "Code spans" + }, + { + "markdown": "` `` `\n", + "html": "

``

\n", + "example": 331, + "start_line": 5919, + "end_line": 5923, + "section": "Code spans" + }, + { + "markdown": "` a`\n", + "html": "

a

\n", + "example": 332, + "start_line": 5928, + "end_line": 5932, + "section": "Code spans" + }, + { + "markdown": "` b `\n", + "html": "

 b 

\n", + "example": 333, + "start_line": 5937, + "end_line": 5941, + "section": "Code spans" + }, + { + "markdown": "` `\n` `\n", + "html": "

 \n

\n", + "example": 334, + "start_line": 5945, + "end_line": 5951, + "section": "Code spans" + }, + { + "markdown": "``\nfoo\nbar \nbaz\n``\n", + "html": "

foo bar baz

\n", + "example": 335, + "start_line": 5956, + "end_line": 5964, + "section": "Code spans" + }, + { + "markdown": "``\nfoo \n``\n", + "html": "

foo

\n", + "example": 336, + "start_line": 5966, + "end_line": 5972, + "section": "Code spans" + }, + { + "markdown": "`foo bar \nbaz`\n", + "html": "

foo bar baz

\n", + "example": 337, + "start_line": 5977, + "end_line": 5982, + "section": "Code spans" + }, + { + "markdown": "`foo\\`bar`\n", + "html": "

foo\\bar`

\n", + "example": 338, + "start_line": 5994, + "end_line": 5998, + "section": "Code spans" + }, + { + "markdown": "``foo`bar``\n", + "html": "

foo`bar

\n", + "example": 339, + "start_line": 6005, + "end_line": 6009, + "section": "Code spans" + }, + { + "markdown": "` foo `` bar `\n", + "html": "

foo `` bar

\n", + "example": 340, + "start_line": 6011, + "end_line": 6015, + "section": "Code spans" + }, + { + "markdown": "*foo`*`\n", + "html": "

*foo*

\n", + "example": 341, + "start_line": 6023, + "end_line": 6027, + "section": "Code spans" + }, + { + "markdown": "[not a `link](/foo`)\n", + "html": "

[not a link](/foo)

\n", + "example": 342, + "start_line": 6032, + "end_line": 6036, + "section": "Code spans" + }, + { + "markdown": "``\n", + "html": "

<a href="">`

\n", + "example": 343, + "start_line": 6042, + "end_line": 6046, + "section": "Code spans" + }, + { + "markdown": "
`\n", + "html": "

`

\n", + "example": 344, + "start_line": 6051, + "end_line": 6055, + "section": "Code spans" + }, + { + "markdown": "``\n", + "html": "

<http://foo.bar.baz>`

\n", + "example": 345, + "start_line": 6060, + "end_line": 6064, + "section": "Code spans" + }, + { + "markdown": "`\n", + "html": "

http://foo.bar.`baz`

\n", + "example": 346, + "start_line": 6069, + "end_line": 6073, + "section": "Code spans" + }, + { + "markdown": "```foo``\n", + "html": "

```foo``

\n", + "example": 347, + "start_line": 6079, + "end_line": 6083, + "section": "Code spans" + }, + { + "markdown": "`foo\n", + "html": "

`foo

\n", + "example": 348, + "start_line": 6086, + "end_line": 6090, + "section": "Code spans" + }, + { + "markdown": "`foo``bar``\n", + "html": "

`foobar

\n", + "example": 349, + "start_line": 6095, + "end_line": 6099, + "section": "Code spans" + }, + { + "markdown": "*foo bar*\n", + "html": "

foo bar

\n", + "example": 350, + "start_line": 6312, + "end_line": 6316, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "a * foo bar*\n", + "html": "

a * foo bar*

\n", + "example": 351, + "start_line": 6322, + "end_line": 6326, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "a*\"foo\"*\n", + "html": "

a*"foo"*

\n", + "example": 352, + "start_line": 6333, + "end_line": 6337, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "* a *\n", + "html": "

* a *

\n", + "example": 353, + "start_line": 6342, + "end_line": 6346, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "foo*bar*\n", + "html": "

foobar

\n", + "example": 354, + "start_line": 6351, + "end_line": 6355, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "5*6*78\n", + "html": "

5678

\n", + "example": 355, + "start_line": 6358, + "end_line": 6362, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "_foo bar_\n", + "html": "

foo bar

\n", + "example": 356, + "start_line": 6367, + "end_line": 6371, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "_ foo bar_\n", + "html": "

_ foo bar_

\n", + "example": 357, + "start_line": 6377, + "end_line": 6381, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "a_\"foo\"_\n", + "html": "

a_"foo"_

\n", + "example": 358, + "start_line": 6387, + "end_line": 6391, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "foo_bar_\n", + "html": "

foo_bar_

\n", + "example": 359, + "start_line": 6396, + "end_line": 6400, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "5_6_78\n", + "html": "

5_6_78

\n", + "example": 360, + "start_line": 6403, + "end_line": 6407, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "пристаням_стремятся_\n", + "html": "

пристаням_стремятся_

\n", + "example": 361, + "start_line": 6410, + "end_line": 6414, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "aa_\"bb\"_cc\n", + "html": "

aa_"bb"_cc

\n", + "example": 362, + "start_line": 6420, + "end_line": 6424, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "foo-_(bar)_\n", + "html": "

foo-(bar)

\n", + "example": 363, + "start_line": 6431, + "end_line": 6435, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "_foo*\n", + "html": "

_foo*

\n", + "example": 364, + "start_line": 6443, + "end_line": 6447, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*foo bar *\n", + "html": "

*foo bar *

\n", + "example": 365, + "start_line": 6453, + "end_line": 6457, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*foo bar\n*\n", + "html": "

*foo bar\n*

\n", + "example": 366, + "start_line": 6462, + "end_line": 6468, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*(*foo)\n", + "html": "

*(*foo)

\n", + "example": 367, + "start_line": 6475, + "end_line": 6479, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*(*foo*)*\n", + "html": "

(foo)

\n", + "example": 368, + "start_line": 6485, + "end_line": 6489, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*foo*bar\n", + "html": "

foobar

\n", + "example": 369, + "start_line": 6494, + "end_line": 6498, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "_foo bar _\n", + "html": "

_foo bar _

\n", + "example": 370, + "start_line": 6507, + "end_line": 6511, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "_(_foo)\n", + "html": "

_(_foo)

\n", + "example": 371, + "start_line": 6517, + "end_line": 6521, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "_(_foo_)_\n", + "html": "

(foo)

\n", + "example": 372, + "start_line": 6526, + "end_line": 6530, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "_foo_bar\n", + "html": "

_foo_bar

\n", + "example": 373, + "start_line": 6535, + "end_line": 6539, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "_пристаням_стремятся\n", + "html": "

_пристаням_стремятся

\n", + "example": 374, + "start_line": 6542, + "end_line": 6546, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "_foo_bar_baz_\n", + "html": "

foo_bar_baz

\n", + "example": 375, + "start_line": 6549, + "end_line": 6553, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "_(bar)_.\n", + "html": "

(bar).

\n", + "example": 376, + "start_line": 6560, + "end_line": 6564, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "**foo bar**\n", + "html": "

foo bar

\n", + "example": 377, + "start_line": 6569, + "end_line": 6573, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "** foo bar**\n", + "html": "

** foo bar**

\n", + "example": 378, + "start_line": 6579, + "end_line": 6583, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "a**\"foo\"**\n", + "html": "

a**"foo"**

\n", + "example": 379, + "start_line": 6590, + "end_line": 6594, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "foo**bar**\n", + "html": "

foobar

\n", + "example": 380, + "start_line": 6599, + "end_line": 6603, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "__foo bar__\n", + "html": "

foo bar

\n", + "example": 381, + "start_line": 6608, + "end_line": 6612, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "__ foo bar__\n", + "html": "

__ foo bar__

\n", + "example": 382, + "start_line": 6618, + "end_line": 6622, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "__\nfoo bar__\n", + "html": "

__\nfoo bar__

\n", + "example": 383, + "start_line": 6626, + "end_line": 6632, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "a__\"foo\"__\n", + "html": "

a__"foo"__

\n", + "example": 384, + "start_line": 6638, + "end_line": 6642, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "foo__bar__\n", + "html": "

foo__bar__

\n", + "example": 385, + "start_line": 6647, + "end_line": 6651, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "5__6__78\n", + "html": "

5__6__78

\n", + "example": 386, + "start_line": 6654, + "end_line": 6658, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "пристаням__стремятся__\n", + "html": "

пристаням__стремятся__

\n", + "example": 387, + "start_line": 6661, + "end_line": 6665, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "__foo, __bar__, baz__\n", + "html": "

foo, bar, baz

\n", + "example": 388, + "start_line": 6668, + "end_line": 6672, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "foo-__(bar)__\n", + "html": "

foo-(bar)

\n", + "example": 389, + "start_line": 6679, + "end_line": 6683, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "**foo bar **\n", + "html": "

**foo bar **

\n", + "example": 390, + "start_line": 6692, + "end_line": 6696, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "**(**foo)\n", + "html": "

**(**foo)

\n", + "example": 391, + "start_line": 6705, + "end_line": 6709, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*(**foo**)*\n", + "html": "

(foo)

\n", + "example": 392, + "start_line": 6715, + "end_line": 6719, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "**Gomphocarpus (*Gomphocarpus physocarpus*, syn.\n*Asclepias physocarpa*)**\n", + "html": "

Gomphocarpus (Gomphocarpus physocarpus, syn.\nAsclepias physocarpa)

\n", + "example": 393, + "start_line": 6722, + "end_line": 6728, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "**foo \"*bar*\" foo**\n", + "html": "

foo "bar" foo

\n", + "example": 394, + "start_line": 6731, + "end_line": 6735, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "**foo**bar\n", + "html": "

foobar

\n", + "example": 395, + "start_line": 6740, + "end_line": 6744, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "__foo bar __\n", + "html": "

__foo bar __

\n", + "example": 396, + "start_line": 6752, + "end_line": 6756, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "__(__foo)\n", + "html": "

__(__foo)

\n", + "example": 397, + "start_line": 6762, + "end_line": 6766, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "_(__foo__)_\n", + "html": "

(foo)

\n", + "example": 398, + "start_line": 6772, + "end_line": 6776, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "__foo__bar\n", + "html": "

__foo__bar

\n", + "example": 399, + "start_line": 6781, + "end_line": 6785, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "__пристаням__стремятся\n", + "html": "

__пристаням__стремятся

\n", + "example": 400, + "start_line": 6788, + "end_line": 6792, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "__foo__bar__baz__\n", + "html": "

foo__bar__baz

\n", + "example": 401, + "start_line": 6795, + "end_line": 6799, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "__(bar)__.\n", + "html": "

(bar).

\n", + "example": 402, + "start_line": 6806, + "end_line": 6810, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*foo [bar](/url)*\n", + "html": "

foo bar

\n", + "example": 403, + "start_line": 6818, + "end_line": 6822, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*foo\nbar*\n", + "html": "

foo\nbar

\n", + "example": 404, + "start_line": 6825, + "end_line": 6831, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "_foo __bar__ baz_\n", + "html": "

foo bar baz

\n", + "example": 405, + "start_line": 6837, + "end_line": 6841, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "_foo _bar_ baz_\n", + "html": "

foo bar baz

\n", + "example": 406, + "start_line": 6844, + "end_line": 6848, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "__foo_ bar_\n", + "html": "

foo bar

\n", + "example": 407, + "start_line": 6851, + "end_line": 6855, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*foo *bar**\n", + "html": "

foo bar

\n", + "example": 408, + "start_line": 6858, + "end_line": 6862, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*foo **bar** baz*\n", + "html": "

foo bar baz

\n", + "example": 409, + "start_line": 6865, + "end_line": 6869, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*foo**bar**baz*\n", + "html": "

foobarbaz

\n", + "example": 410, + "start_line": 6871, + "end_line": 6875, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*foo**bar*\n", + "html": "

foo**bar

\n", + "example": 411, + "start_line": 6895, + "end_line": 6899, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "***foo** bar*\n", + "html": "

foo bar

\n", + "example": 412, + "start_line": 6908, + "end_line": 6912, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*foo **bar***\n", + "html": "

foo bar

\n", + "example": 413, + "start_line": 6915, + "end_line": 6919, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*foo**bar***\n", + "html": "

foobar

\n", + "example": 414, + "start_line": 6922, + "end_line": 6926, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "foo***bar***baz\n", + "html": "

foobarbaz

\n", + "example": 415, + "start_line": 6933, + "end_line": 6937, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "foo******bar*********baz\n", + "html": "

foobar***baz

\n", + "example": 416, + "start_line": 6939, + "end_line": 6943, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*foo **bar *baz* bim** bop*\n", + "html": "

foo bar baz bim bop

\n", + "example": 417, + "start_line": 6948, + "end_line": 6952, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*foo [*bar*](/url)*\n", + "html": "

foo bar

\n", + "example": 418, + "start_line": 6955, + "end_line": 6959, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "** is not an empty emphasis\n", + "html": "

** is not an empty emphasis

\n", + "example": 419, + "start_line": 6964, + "end_line": 6968, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "**** is not an empty strong emphasis\n", + "html": "

**** is not an empty strong emphasis

\n", + "example": 420, + "start_line": 6971, + "end_line": 6975, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "**foo [bar](/url)**\n", + "html": "

foo bar

\n", + "example": 421, + "start_line": 6984, + "end_line": 6988, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "**foo\nbar**\n", + "html": "

foo\nbar

\n", + "example": 422, + "start_line": 6991, + "end_line": 6997, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "__foo _bar_ baz__\n", + "html": "

foo bar baz

\n", + "example": 423, + "start_line": 7003, + "end_line": 7007, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "__foo __bar__ baz__\n", + "html": "

foo bar baz

\n", + "example": 424, + "start_line": 7010, + "end_line": 7014, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "____foo__ bar__\n", + "html": "

foo bar

\n", + "example": 425, + "start_line": 7017, + "end_line": 7021, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "**foo **bar****\n", + "html": "

foo bar

\n", + "example": 426, + "start_line": 7024, + "end_line": 7028, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "**foo *bar* baz**\n", + "html": "

foo bar baz

\n", + "example": 427, + "start_line": 7031, + "end_line": 7035, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "**foo*bar*baz**\n", + "html": "

foobarbaz

\n", + "example": 428, + "start_line": 7038, + "end_line": 7042, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "***foo* bar**\n", + "html": "

foo bar

\n", + "example": 429, + "start_line": 7045, + "end_line": 7049, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "**foo *bar***\n", + "html": "

foo bar

\n", + "example": 430, + "start_line": 7052, + "end_line": 7056, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "**foo *bar **baz**\nbim* bop**\n", + "html": "

foo bar baz\nbim bop

\n", + "example": 431, + "start_line": 7061, + "end_line": 7067, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "**foo [*bar*](/url)**\n", + "html": "

foo bar

\n", + "example": 432, + "start_line": 7070, + "end_line": 7074, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "__ is not an empty emphasis\n", + "html": "

__ is not an empty emphasis

\n", + "example": 433, + "start_line": 7079, + "end_line": 7083, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "____ is not an empty strong emphasis\n", + "html": "

____ is not an empty strong emphasis

\n", + "example": 434, + "start_line": 7086, + "end_line": 7090, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "foo ***\n", + "html": "

foo ***

\n", + "example": 435, + "start_line": 7096, + "end_line": 7100, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "foo *\\**\n", + "html": "

foo *

\n", + "example": 436, + "start_line": 7103, + "end_line": 7107, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "foo *_*\n", + "html": "

foo _

\n", + "example": 437, + "start_line": 7110, + "end_line": 7114, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "foo *****\n", + "html": "

foo *****

\n", + "example": 438, + "start_line": 7117, + "end_line": 7121, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "foo **\\***\n", + "html": "

foo *

\n", + "example": 439, + "start_line": 7124, + "end_line": 7128, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "foo **_**\n", + "html": "

foo _

\n", + "example": 440, + "start_line": 7131, + "end_line": 7135, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "**foo*\n", + "html": "

*foo

\n", + "example": 441, + "start_line": 7142, + "end_line": 7146, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*foo**\n", + "html": "

foo*

\n", + "example": 442, + "start_line": 7149, + "end_line": 7153, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "***foo**\n", + "html": "

*foo

\n", + "example": 443, + "start_line": 7156, + "end_line": 7160, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "****foo*\n", + "html": "

***foo

\n", + "example": 444, + "start_line": 7163, + "end_line": 7167, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "**foo***\n", + "html": "

foo*

\n", + "example": 445, + "start_line": 7170, + "end_line": 7174, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*foo****\n", + "html": "

foo***

\n", + "example": 446, + "start_line": 7177, + "end_line": 7181, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "foo ___\n", + "html": "

foo ___

\n", + "example": 447, + "start_line": 7187, + "end_line": 7191, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "foo _\\__\n", + "html": "

foo _

\n", + "example": 448, + "start_line": 7194, + "end_line": 7198, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "foo _*_\n", + "html": "

foo *

\n", + "example": 449, + "start_line": 7201, + "end_line": 7205, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "foo _____\n", + "html": "

foo _____

\n", + "example": 450, + "start_line": 7208, + "end_line": 7212, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "foo __\\___\n", + "html": "

foo _

\n", + "example": 451, + "start_line": 7215, + "end_line": 7219, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "foo __*__\n", + "html": "

foo *

\n", + "example": 452, + "start_line": 7222, + "end_line": 7226, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "__foo_\n", + "html": "

_foo

\n", + "example": 453, + "start_line": 7229, + "end_line": 7233, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "_foo__\n", + "html": "

foo_

\n", + "example": 454, + "start_line": 7240, + "end_line": 7244, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "___foo__\n", + "html": "

_foo

\n", + "example": 455, + "start_line": 7247, + "end_line": 7251, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "____foo_\n", + "html": "

___foo

\n", + "example": 456, + "start_line": 7254, + "end_line": 7258, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "__foo___\n", + "html": "

foo_

\n", + "example": 457, + "start_line": 7261, + "end_line": 7265, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "_foo____\n", + "html": "

foo___

\n", + "example": 458, + "start_line": 7268, + "end_line": 7272, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "**foo**\n", + "html": "

foo

\n", + "example": 459, + "start_line": 7278, + "end_line": 7282, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*_foo_*\n", + "html": "

foo

\n", + "example": 460, + "start_line": 7285, + "end_line": 7289, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "__foo__\n", + "html": "

foo

\n", + "example": 461, + "start_line": 7292, + "end_line": 7296, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "_*foo*_\n", + "html": "

foo

\n", + "example": 462, + "start_line": 7299, + "end_line": 7303, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "****foo****\n", + "html": "

foo

\n", + "example": 463, + "start_line": 7309, + "end_line": 7313, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "____foo____\n", + "html": "

foo

\n", + "example": 464, + "start_line": 7316, + "end_line": 7320, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "******foo******\n", + "html": "

foo

\n", + "example": 465, + "start_line": 7327, + "end_line": 7331, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "***foo***\n", + "html": "

foo

\n", + "example": 466, + "start_line": 7336, + "end_line": 7340, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "_____foo_____\n", + "html": "

foo

\n", + "example": 467, + "start_line": 7343, + "end_line": 7347, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*foo _bar* baz_\n", + "html": "

foo _bar baz_

\n", + "example": 468, + "start_line": 7352, + "end_line": 7356, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*foo __bar *baz bim__ bam*\n", + "html": "

foo bar *baz bim bam

\n", + "example": 469, + "start_line": 7359, + "end_line": 7363, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "**foo **bar baz**\n", + "html": "

**foo bar baz

\n", + "example": 470, + "start_line": 7368, + "end_line": 7372, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*foo *bar baz*\n", + "html": "

*foo bar baz

\n", + "example": 471, + "start_line": 7375, + "end_line": 7379, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*[bar*](/url)\n", + "html": "

*bar*

\n", + "example": 472, + "start_line": 7384, + "end_line": 7388, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "_foo [bar_](/url)\n", + "html": "

_foo bar_

\n", + "example": 473, + "start_line": 7391, + "end_line": 7395, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*\n", + "html": "

*

\n", + "example": 474, + "start_line": 7398, + "end_line": 7402, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "**\n", + "html": "

**

\n", + "example": 475, + "start_line": 7405, + "end_line": 7409, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "__\n", + "html": "

__

\n", + "example": 476, + "start_line": 7412, + "end_line": 7416, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*a `*`*\n", + "html": "

a *

\n", + "example": 477, + "start_line": 7419, + "end_line": 7423, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "_a `_`_\n", + "html": "

a _

\n", + "example": 478, + "start_line": 7426, + "end_line": 7430, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "**a\n", + "html": "

**ahttp://foo.bar/?q=**

\n", + "example": 479, + "start_line": 7433, + "end_line": 7437, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "__a\n", + "html": "

__ahttp://foo.bar/?q=__

\n", + "example": 480, + "start_line": 7440, + "end_line": 7444, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "[link](/uri \"title\")\n", + "html": "

link

\n", + "example": 481, + "start_line": 7528, + "end_line": 7532, + "section": "Links" + }, + { + "markdown": "[link](/uri)\n", + "html": "

link

\n", + "example": 482, + "start_line": 7538, + "end_line": 7542, + "section": "Links" + }, + { + "markdown": "[](./target.md)\n", + "html": "

\n", + "example": 483, + "start_line": 7544, + "end_line": 7548, + "section": "Links" + }, + { + "markdown": "[link]()\n", + "html": "

link

\n", + "example": 484, + "start_line": 7551, + "end_line": 7555, + "section": "Links" + }, + { + "markdown": "[link](<>)\n", + "html": "

link

\n", + "example": 485, + "start_line": 7558, + "end_line": 7562, + "section": "Links" + }, + { + "markdown": "[]()\n", + "html": "

\n", + "example": 486, + "start_line": 7565, + "end_line": 7569, + "section": "Links" + }, + { + "markdown": "[link](/my uri)\n", + "html": "

[link](/my uri)

\n", + "example": 487, + "start_line": 7574, + "end_line": 7578, + "section": "Links" + }, + { + "markdown": "[link](
)\n", + "html": "

link

\n", + "example": 488, + "start_line": 7580, + "end_line": 7584, + "section": "Links" + }, + { + "markdown": "[link](foo\nbar)\n", + "html": "

[link](foo\nbar)

\n", + "example": 489, + "start_line": 7589, + "end_line": 7595, + "section": "Links" + }, + { + "markdown": "[link]()\n", + "html": "

[link]()

\n", + "example": 490, + "start_line": 7597, + "end_line": 7603, + "section": "Links" + }, + { + "markdown": "[a]()\n", + "html": "

a

\n", + "example": 491, + "start_line": 7608, + "end_line": 7612, + "section": "Links" + }, + { + "markdown": "[link]()\n", + "html": "

[link](<foo>)

\n", + "example": 492, + "start_line": 7616, + "end_line": 7620, + "section": "Links" + }, + { + "markdown": "[a](\n[a](c)\n", + "html": "

[a](<b)c\n[a](<b)c>\n[a](c)

\n", + "example": 493, + "start_line": 7625, + "end_line": 7633, + "section": "Links" + }, + { + "markdown": "[link](\\(foo\\))\n", + "html": "

link

\n", + "example": 494, + "start_line": 7637, + "end_line": 7641, + "section": "Links" + }, + { + "markdown": "[link](foo(and(bar)))\n", + "html": "

link

\n", + "example": 495, + "start_line": 7646, + "end_line": 7650, + "section": "Links" + }, + { + "markdown": "[link](foo(and(bar))\n", + "html": "

[link](foo(and(bar))

\n", + "example": 496, + "start_line": 7655, + "end_line": 7659, + "section": "Links" + }, + { + "markdown": "[link](foo\\(and\\(bar\\))\n", + "html": "

link

\n", + "example": 497, + "start_line": 7662, + "end_line": 7666, + "section": "Links" + }, + { + "markdown": "[link]()\n", + "html": "

link

\n", + "example": 498, + "start_line": 7669, + "end_line": 7673, + "section": "Links" + }, + { + "markdown": "[link](foo\\)\\:)\n", + "html": "

link

\n", + "example": 499, + "start_line": 7679, + "end_line": 7683, + "section": "Links" + }, + { + "markdown": "[link](#fragment)\n\n[link](http://example.com#fragment)\n\n[link](http://example.com?foo=3#frag)\n", + "html": "

link

\n

link

\n

link

\n", + "example": 500, + "start_line": 7688, + "end_line": 7698, + "section": "Links" + }, + { + "markdown": "[link](foo\\bar)\n", + "html": "

link

\n", + "example": 501, + "start_line": 7704, + "end_line": 7708, + "section": "Links" + }, + { + "markdown": "[link](foo%20bä)\n", + "html": "

link

\n", + "example": 502, + "start_line": 7720, + "end_line": 7724, + "section": "Links" + }, + { + "markdown": "[link](\"title\")\n", + "html": "

link

\n", + "example": 503, + "start_line": 7731, + "end_line": 7735, + "section": "Links" + }, + { + "markdown": "[link](/url \"title\")\n[link](/url 'title')\n[link](/url (title))\n", + "html": "

link\nlink\nlink

\n", + "example": 504, + "start_line": 7740, + "end_line": 7748, + "section": "Links" + }, + { + "markdown": "[link](/url \"title \\\""\")\n", + "html": "

link

\n", + "example": 505, + "start_line": 7754, + "end_line": 7758, + "section": "Links" + }, + { + "markdown": "[link](/url \"title\")\n", + "html": "

link

\n", + "example": 506, + "start_line": 7765, + "end_line": 7769, + "section": "Links" + }, + { + "markdown": "[link](/url \"title \"and\" title\")\n", + "html": "

[link](/url "title "and" title")

\n", + "example": 507, + "start_line": 7774, + "end_line": 7778, + "section": "Links" + }, + { + "markdown": "[link](/url 'title \"and\" title')\n", + "html": "

link

\n", + "example": 508, + "start_line": 7783, + "end_line": 7787, + "section": "Links" + }, + { + "markdown": "[link]( /uri\n \"title\" )\n", + "html": "

link

\n", + "example": 509, + "start_line": 7808, + "end_line": 7813, + "section": "Links" + }, + { + "markdown": "[link] (/uri)\n", + "html": "

[link] (/uri)

\n", + "example": 510, + "start_line": 7819, + "end_line": 7823, + "section": "Links" + }, + { + "markdown": "[link [foo [bar]]](/uri)\n", + "html": "

link [foo [bar]]

\n", + "example": 511, + "start_line": 7829, + "end_line": 7833, + "section": "Links" + }, + { + "markdown": "[link] bar](/uri)\n", + "html": "

[link] bar](/uri)

\n", + "example": 512, + "start_line": 7836, + "end_line": 7840, + "section": "Links" + }, + { + "markdown": "[link [bar](/uri)\n", + "html": "

[link bar

\n", + "example": 513, + "start_line": 7843, + "end_line": 7847, + "section": "Links" + }, + { + "markdown": "[link \\[bar](/uri)\n", + "html": "

link [bar

\n", + "example": 514, + "start_line": 7850, + "end_line": 7854, + "section": "Links" + }, + { + "markdown": "[link *foo **bar** `#`*](/uri)\n", + "html": "

link foo bar #

\n", + "example": 515, + "start_line": 7859, + "end_line": 7863, + "section": "Links" + }, + { + "markdown": "[![moon](moon.jpg)](/uri)\n", + "html": "

\"moon\"

\n", + "example": 516, + "start_line": 7866, + "end_line": 7870, + "section": "Links" + }, + { + "markdown": "[foo [bar](/uri)](/uri)\n", + "html": "

[foo bar](/uri)

\n", + "example": 517, + "start_line": 7875, + "end_line": 7879, + "section": "Links" + }, + { + "markdown": "[foo *[bar [baz](/uri)](/uri)*](/uri)\n", + "html": "

[foo [bar baz](/uri)](/uri)

\n", + "example": 518, + "start_line": 7882, + "end_line": 7886, + "section": "Links" + }, + { + "markdown": "![[[foo](uri1)](uri2)](uri3)\n", + "html": "

\"[foo](uri2)\"

\n", + "example": 519, + "start_line": 7889, + "end_line": 7893, + "section": "Links" + }, + { + "markdown": "*[foo*](/uri)\n", + "html": "

*foo*

\n", + "example": 520, + "start_line": 7899, + "end_line": 7903, + "section": "Links" + }, + { + "markdown": "[foo *bar](baz*)\n", + "html": "

foo *bar

\n", + "example": 521, + "start_line": 7906, + "end_line": 7910, + "section": "Links" + }, + { + "markdown": "*foo [bar* baz]\n", + "html": "

foo [bar baz]

\n", + "example": 522, + "start_line": 7916, + "end_line": 7920, + "section": "Links" + }, + { + "markdown": "[foo \n", + "html": "

[foo

\n", + "example": 523, + "start_line": 7926, + "end_line": 7930, + "section": "Links" + }, + { + "markdown": "[foo`](/uri)`\n", + "html": "

[foo](/uri)

\n", + "example": 524, + "start_line": 7933, + "end_line": 7937, + "section": "Links" + }, + { + "markdown": "[foo\n", + "html": "

[foohttp://example.com/?search=](uri)

\n", + "example": 525, + "start_line": 7940, + "end_line": 7944, + "section": "Links" + }, + { + "markdown": "[foo][bar]\n\n[bar]: /url \"title\"\n", + "html": "

foo

\n", + "example": 526, + "start_line": 7978, + "end_line": 7984, + "section": "Links" + }, + { + "markdown": "[link [foo [bar]]][ref]\n\n[ref]: /uri\n", + "html": "

link [foo [bar]]

\n", + "example": 527, + "start_line": 7993, + "end_line": 7999, + "section": "Links" + }, + { + "markdown": "[link \\[bar][ref]\n\n[ref]: /uri\n", + "html": "

link [bar

\n", + "example": 528, + "start_line": 8002, + "end_line": 8008, + "section": "Links" + }, + { + "markdown": "[link *foo **bar** `#`*][ref]\n\n[ref]: /uri\n", + "html": "

link foo bar #

\n", + "example": 529, + "start_line": 8013, + "end_line": 8019, + "section": "Links" + }, + { + "markdown": "[![moon](moon.jpg)][ref]\n\n[ref]: /uri\n", + "html": "

\"moon\"

\n", + "example": 530, + "start_line": 8022, + "end_line": 8028, + "section": "Links" + }, + { + "markdown": "[foo [bar](/uri)][ref]\n\n[ref]: /uri\n", + "html": "

[foo bar]ref

\n", + "example": 531, + "start_line": 8033, + "end_line": 8039, + "section": "Links" + }, + { + "markdown": "[foo *bar [baz][ref]*][ref]\n\n[ref]: /uri\n", + "html": "

[foo bar baz]ref

\n", + "example": 532, + "start_line": 8042, + "end_line": 8048, + "section": "Links" + }, + { + "markdown": "*[foo*][ref]\n\n[ref]: /uri\n", + "html": "

*foo*

\n", + "example": 533, + "start_line": 8057, + "end_line": 8063, + "section": "Links" + }, + { + "markdown": "[foo *bar][ref]*\n\n[ref]: /uri\n", + "html": "

foo *bar*

\n", + "example": 534, + "start_line": 8066, + "end_line": 8072, + "section": "Links" + }, + { + "markdown": "[foo \n\n[ref]: /uri\n", + "html": "

[foo

\n", + "example": 535, + "start_line": 8078, + "end_line": 8084, + "section": "Links" + }, + { + "markdown": "[foo`][ref]`\n\n[ref]: /uri\n", + "html": "

[foo][ref]

\n", + "example": 536, + "start_line": 8087, + "end_line": 8093, + "section": "Links" + }, + { + "markdown": "[foo\n\n[ref]: /uri\n", + "html": "

[foohttp://example.com/?search=][ref]

\n", + "example": 537, + "start_line": 8096, + "end_line": 8102, + "section": "Links" + }, + { + "markdown": "[foo][BaR]\n\n[bar]: /url \"title\"\n", + "html": "

foo

\n", + "example": 538, + "start_line": 8107, + "end_line": 8113, + "section": "Links" + }, + { + "markdown": "[ẞ]\n\n[SS]: /url\n", + "html": "

ẞ

\n", + "example": 539, + "start_line": 8118, + "end_line": 8124, + "section": "Links" + }, + { + "markdown": "[Foo\n bar]: /url\n\n[Baz][Foo bar]\n", + "html": "

Baz

\n", + "example": 540, + "start_line": 8130, + "end_line": 8137, + "section": "Links" + }, + { + "markdown": "[foo] [bar]\n\n[bar]: /url \"title\"\n", + "html": "

[foo] bar

\n", + "example": 541, + "start_line": 8143, + "end_line": 8149, + "section": "Links" + }, + { + "markdown": "[foo]\n[bar]\n\n[bar]: /url \"title\"\n", + "html": "

[foo]\nbar

\n", + "example": 542, + "start_line": 8152, + "end_line": 8160, + "section": "Links" + }, + { + "markdown": "[foo]: /url1\n\n[foo]: /url2\n\n[bar][foo]\n", + "html": "

bar

\n", + "example": 543, + "start_line": 8193, + "end_line": 8201, + "section": "Links" + }, + { + "markdown": "[bar][foo\\!]\n\n[foo!]: /url\n", + "html": "

[bar][foo!]

\n", + "example": 544, + "start_line": 8208, + "end_line": 8214, + "section": "Links" + }, + { + "markdown": "[foo][ref[]\n\n[ref[]: /uri\n", + "html": "

[foo][ref[]

\n

[ref[]: /uri

\n", + "example": 545, + "start_line": 8220, + "end_line": 8227, + "section": "Links" + }, + { + "markdown": "[foo][ref[bar]]\n\n[ref[bar]]: /uri\n", + "html": "

[foo][ref[bar]]

\n

[ref[bar]]: /uri

\n", + "example": 546, + "start_line": 8230, + "end_line": 8237, + "section": "Links" + }, + { + "markdown": "[[[foo]]]\n\n[[[foo]]]: /url\n", + "html": "

[[[foo]]]

\n

[[[foo]]]: /url

\n", + "example": 547, + "start_line": 8240, + "end_line": 8247, + "section": "Links" + }, + { + "markdown": "[foo][ref\\[]\n\n[ref\\[]: /uri\n", + "html": "

foo

\n", + "example": 548, + "start_line": 8250, + "end_line": 8256, + "section": "Links" + }, + { + "markdown": "[bar\\\\]: /uri\n\n[bar\\\\]\n", + "html": "

bar\\

\n", + "example": 549, + "start_line": 8261, + "end_line": 8267, + "section": "Links" + }, + { + "markdown": "[]\n\n[]: /uri\n", + "html": "

[]

\n

[]: /uri

\n", + "example": 550, + "start_line": 8273, + "end_line": 8280, + "section": "Links" + }, + { + "markdown": "[\n ]\n\n[\n ]: /uri\n", + "html": "

[\n]

\n

[\n]: /uri

\n", + "example": 551, + "start_line": 8283, + "end_line": 8294, + "section": "Links" + }, + { + "markdown": "[foo][]\n\n[foo]: /url \"title\"\n", + "html": "

foo

\n", + "example": 552, + "start_line": 8306, + "end_line": 8312, + "section": "Links" + }, + { + "markdown": "[*foo* bar][]\n\n[*foo* bar]: /url \"title\"\n", + "html": "

foo bar

\n", + "example": 553, + "start_line": 8315, + "end_line": 8321, + "section": "Links" + }, + { + "markdown": "[Foo][]\n\n[foo]: /url \"title\"\n", + "html": "

Foo

\n", + "example": 554, + "start_line": 8326, + "end_line": 8332, + "section": "Links" + }, + { + "markdown": "[foo] \n[]\n\n[foo]: /url \"title\"\n", + "html": "

foo\n[]

\n", + "example": 555, + "start_line": 8339, + "end_line": 8347, + "section": "Links" + }, + { + "markdown": "[foo]\n\n[foo]: /url \"title\"\n", + "html": "

foo

\n", + "example": 556, + "start_line": 8359, + "end_line": 8365, + "section": "Links" + }, + { + "markdown": "[*foo* bar]\n\n[*foo* bar]: /url \"title\"\n", + "html": "

foo bar

\n", + "example": 557, + "start_line": 8368, + "end_line": 8374, + "section": "Links" + }, + { + "markdown": "[[*foo* bar]]\n\n[*foo* bar]: /url \"title\"\n", + "html": "

[foo bar]

\n", + "example": 558, + "start_line": 8377, + "end_line": 8383, + "section": "Links" + }, + { + "markdown": "[[bar [foo]\n\n[foo]: /url\n", + "html": "

[[bar foo

\n", + "example": 559, + "start_line": 8386, + "end_line": 8392, + "section": "Links" + }, + { + "markdown": "[Foo]\n\n[foo]: /url \"title\"\n", + "html": "

Foo

\n", + "example": 560, + "start_line": 8397, + "end_line": 8403, + "section": "Links" + }, + { + "markdown": "[foo] bar\n\n[foo]: /url\n", + "html": "

foo bar

\n", + "example": 561, + "start_line": 8408, + "end_line": 8414, + "section": "Links" + }, + { + "markdown": "\\[foo]\n\n[foo]: /url \"title\"\n", + "html": "

[foo]

\n", + "example": 562, + "start_line": 8420, + "end_line": 8426, + "section": "Links" + }, + { + "markdown": "[foo*]: /url\n\n*[foo*]\n", + "html": "

*foo*

\n", + "example": 563, + "start_line": 8432, + "end_line": 8438, + "section": "Links" + }, + { + "markdown": "[foo][bar]\n\n[foo]: /url1\n[bar]: /url2\n", + "html": "

foo

\n", + "example": 564, + "start_line": 8444, + "end_line": 8451, + "section": "Links" + }, + { + "markdown": "[foo][]\n\n[foo]: /url1\n", + "html": "

foo

\n", + "example": 565, + "start_line": 8453, + "end_line": 8459, + "section": "Links" + }, + { + "markdown": "[foo]()\n\n[foo]: /url1\n", + "html": "

foo

\n", + "example": 566, + "start_line": 8463, + "end_line": 8469, + "section": "Links" + }, + { + "markdown": "[foo](not a link)\n\n[foo]: /url1\n", + "html": "

foo(not a link)

\n", + "example": 567, + "start_line": 8471, + "end_line": 8477, + "section": "Links" + }, + { + "markdown": "[foo][bar][baz]\n\n[baz]: /url\n", + "html": "

[foo]bar

\n", + "example": 568, + "start_line": 8482, + "end_line": 8488, + "section": "Links" + }, + { + "markdown": "[foo][bar][baz]\n\n[baz]: /url1\n[bar]: /url2\n", + "html": "

foobaz

\n", + "example": 569, + "start_line": 8494, + "end_line": 8501, + "section": "Links" + }, + { + "markdown": "[foo][bar][baz]\n\n[baz]: /url1\n[foo]: /url2\n", + "html": "

[foo]bar

\n", + "example": 570, + "start_line": 8507, + "end_line": 8514, + "section": "Links" + }, + { + "markdown": "![foo](/url \"title\")\n", + "html": "

\"foo\"

\n", + "example": 571, + "start_line": 8530, + "end_line": 8534, + "section": "Images" + }, + { + "markdown": "![foo *bar*]\n\n[foo *bar*]: train.jpg \"train & tracks\"\n", + "html": "

\"foo

\n", + "example": 572, + "start_line": 8537, + "end_line": 8543, + "section": "Images" + }, + { + "markdown": "![foo ![bar](/url)](/url2)\n", + "html": "

\"foo

\n", + "example": 573, + "start_line": 8546, + "end_line": 8550, + "section": "Images" + }, + { + "markdown": "![foo [bar](/url)](/url2)\n", + "html": "

\"foo

\n", + "example": 574, + "start_line": 8553, + "end_line": 8557, + "section": "Images" + }, + { + "markdown": "![foo *bar*][]\n\n[foo *bar*]: train.jpg \"train & tracks\"\n", + "html": "

\"foo

\n", + "example": 575, + "start_line": 8567, + "end_line": 8573, + "section": "Images" + }, + { + "markdown": "![foo *bar*][foobar]\n\n[FOOBAR]: train.jpg \"train & tracks\"\n", + "html": "

\"foo

\n", + "example": 576, + "start_line": 8576, + "end_line": 8582, + "section": "Images" + }, + { + "markdown": "![foo](train.jpg)\n", + "html": "

\"foo\"

\n", + "example": 577, + "start_line": 8585, + "end_line": 8589, + "section": "Images" + }, + { + "markdown": "My ![foo bar](/path/to/train.jpg \"title\" )\n", + "html": "

My \"foo

\n", + "example": 578, + "start_line": 8592, + "end_line": 8596, + "section": "Images" + }, + { + "markdown": "![foo]()\n", + "html": "

\"foo\"

\n", + "example": 579, + "start_line": 8599, + "end_line": 8603, + "section": "Images" + }, + { + "markdown": "![](/url)\n", + "html": "

\"\"

\n", + "example": 580, + "start_line": 8606, + "end_line": 8610, + "section": "Images" + }, + { + "markdown": "![foo][bar]\n\n[bar]: /url\n", + "html": "

\"foo\"

\n", + "example": 581, + "start_line": 8615, + "end_line": 8621, + "section": "Images" + }, + { + "markdown": "![foo][bar]\n\n[BAR]: /url\n", + "html": "

\"foo\"

\n", + "example": 582, + "start_line": 8624, + "end_line": 8630, + "section": "Images" + }, + { + "markdown": "![foo][]\n\n[foo]: /url \"title\"\n", + "html": "

\"foo\"

\n", + "example": 583, + "start_line": 8635, + "end_line": 8641, + "section": "Images" + }, + { + "markdown": "![*foo* bar][]\n\n[*foo* bar]: /url \"title\"\n", + "html": "

\"foo

\n", + "example": 584, + "start_line": 8644, + "end_line": 8650, + "section": "Images" + }, + { + "markdown": "![Foo][]\n\n[foo]: /url \"title\"\n", + "html": "

\"Foo\"

\n", + "example": 585, + "start_line": 8655, + "end_line": 8661, + "section": "Images" + }, + { + "markdown": "![foo] \n[]\n\n[foo]: /url \"title\"\n", + "html": "

\"foo\"\n[]

\n", + "example": 586, + "start_line": 8667, + "end_line": 8675, + "section": "Images" + }, + { + "markdown": "![foo]\n\n[foo]: /url \"title\"\n", + "html": "

\"foo\"

\n", + "example": 587, + "start_line": 8680, + "end_line": 8686, + "section": "Images" + }, + { + "markdown": "![*foo* bar]\n\n[*foo* bar]: /url \"title\"\n", + "html": "

\"foo

\n", + "example": 588, + "start_line": 8689, + "end_line": 8695, + "section": "Images" + }, + { + "markdown": "![[foo]]\n\n[[foo]]: /url \"title\"\n", + "html": "

![[foo]]

\n

[[foo]]: /url "title"

\n", + "example": 589, + "start_line": 8700, + "end_line": 8707, + "section": "Images" + }, + { + "markdown": "![Foo]\n\n[foo]: /url \"title\"\n", + "html": "

\"Foo\"

\n", + "example": 590, + "start_line": 8712, + "end_line": 8718, + "section": "Images" + }, + { + "markdown": "!\\[foo]\n\n[foo]: /url \"title\"\n", + "html": "

![foo]

\n", + "example": 591, + "start_line": 8724, + "end_line": 8730, + "section": "Images" + }, + { + "markdown": "\\![foo]\n\n[foo]: /url \"title\"\n", + "html": "

!foo

\n", + "example": 592, + "start_line": 8736, + "end_line": 8742, + "section": "Images" + }, + { + "markdown": "\n", + "html": "

http://foo.bar.baz

\n", + "example": 593, + "start_line": 8769, + "end_line": 8773, + "section": "Autolinks" + }, + { + "markdown": "\n", + "html": "

http://foo.bar.baz/test?q=hello&id=22&boolean

\n", + "example": 594, + "start_line": 8776, + "end_line": 8780, + "section": "Autolinks" + }, + { + "markdown": "\n", + "html": "

irc://foo.bar:2233/baz

\n", + "example": 595, + "start_line": 8783, + "end_line": 8787, + "section": "Autolinks" + }, + { + "markdown": "\n", + "html": "

MAILTO:FOO@BAR.BAZ

\n", + "example": 596, + "start_line": 8792, + "end_line": 8796, + "section": "Autolinks" + }, + { + "markdown": "\n", + "html": "

a+b+c:d

\n", + "example": 597, + "start_line": 8804, + "end_line": 8808, + "section": "Autolinks" + }, + { + "markdown": "\n", + "html": "

made-up-scheme://foo,bar

\n", + "example": 598, + "start_line": 8811, + "end_line": 8815, + "section": "Autolinks" + }, + { + "markdown": "\n", + "html": "

http://../

\n", + "example": 599, + "start_line": 8818, + "end_line": 8822, + "section": "Autolinks" + }, + { + "markdown": "\n", + "html": "

localhost:5001/foo

\n", + "example": 600, + "start_line": 8825, + "end_line": 8829, + "section": "Autolinks" + }, + { + "markdown": "\n", + "html": "

<http://foo.bar/baz bim>

\n", + "example": 601, + "start_line": 8834, + "end_line": 8838, + "section": "Autolinks" + }, + { + "markdown": "\n", + "html": "

http://example.com/\\[\\

\n", + "example": 602, + "start_line": 8843, + "end_line": 8847, + "section": "Autolinks" + }, + { + "markdown": "\n", + "html": "

foo@bar.example.com

\n", + "example": 603, + "start_line": 8865, + "end_line": 8869, + "section": "Autolinks" + }, + { + "markdown": "\n", + "html": "

foo+special@Bar.baz-bar0.com

\n", + "example": 604, + "start_line": 8872, + "end_line": 8876, + "section": "Autolinks" + }, + { + "markdown": "\n", + "html": "

<foo+@bar.example.com>

\n", + "example": 605, + "start_line": 8881, + "end_line": 8885, + "section": "Autolinks" + }, + { + "markdown": "<>\n", + "html": "

<>

\n", + "example": 606, + "start_line": 8890, + "end_line": 8894, + "section": "Autolinks" + }, + { + "markdown": "< http://foo.bar >\n", + "html": "

< http://foo.bar >

\n", + "example": 607, + "start_line": 8897, + "end_line": 8901, + "section": "Autolinks" + }, + { + "markdown": "\n", + "html": "

<m:abc>

\n", + "example": 608, + "start_line": 8904, + "end_line": 8908, + "section": "Autolinks" + }, + { + "markdown": "\n", + "html": "

<foo.bar.baz>

\n", + "example": 609, + "start_line": 8911, + "end_line": 8915, + "section": "Autolinks" + }, + { + "markdown": "http://example.com\n", + "html": "

http://example.com

\n", + "example": 610, + "start_line": 8918, + "end_line": 8922, + "section": "Autolinks" + }, + { + "markdown": "foo@bar.example.com\n", + "html": "

foo@bar.example.com

\n", + "example": 611, + "start_line": 8925, + "end_line": 8929, + "section": "Autolinks" + }, + { + "markdown": "\n", + "html": "

\n", + "example": 612, + "start_line": 9006, + "end_line": 9010, + "section": "Raw HTML" + }, + { + "markdown": "\n", + "html": "

\n", + "example": 613, + "start_line": 9015, + "end_line": 9019, + "section": "Raw HTML" + }, + { + "markdown": "\n", + "html": "

\n", + "example": 614, + "start_line": 9024, + "end_line": 9030, + "section": "Raw HTML" + }, + { + "markdown": "\n", + "html": "

\n", + "example": 615, + "start_line": 9035, + "end_line": 9041, + "section": "Raw HTML" + }, + { + "markdown": "Foo \n", + "html": "

Foo

\n", + "example": 616, + "start_line": 9046, + "end_line": 9050, + "section": "Raw HTML" + }, + { + "markdown": "<33> <__>\n", + "html": "

<33> <__>

\n", + "example": 617, + "start_line": 9055, + "end_line": 9059, + "section": "Raw HTML" + }, + { + "markdown": "
\n", + "html": "

<a h*#ref="hi">

\n", + "example": 618, + "start_line": 9064, + "end_line": 9068, + "section": "Raw HTML" + }, + { + "markdown": "
\n", + "html": "

<a href="hi'> <a href=hi'>

\n", + "example": 619, + "start_line": 9073, + "end_line": 9077, + "section": "Raw HTML" + }, + { + "markdown": "< a><\nfoo>\n\n", + "html": "

< a><\nfoo><bar/ >\n<foo bar=baz\nbim!bop />

\n", + "example": 620, + "start_line": 9082, + "end_line": 9092, + "section": "Raw HTML" + }, + { + "markdown": "
\n", + "html": "

<a href='bar'title=title>

\n", + "example": 621, + "start_line": 9097, + "end_line": 9101, + "section": "Raw HTML" + }, + { + "markdown": "
\n", + "html": "

\n", + "example": 622, + "start_line": 9106, + "end_line": 9110, + "section": "Raw HTML" + }, + { + "markdown": "\n", + "html": "

</a href="foo">

\n", + "example": 623, + "start_line": 9115, + "end_line": 9119, + "section": "Raw HTML" + }, + { + "markdown": "foo \n", + "html": "

foo

\n", + "example": 624, + "start_line": 9124, + "end_line": 9130, + "section": "Raw HTML" + }, + { + "markdown": "foo \n", + "html": "

foo <!-- not a comment -- two hyphens -->

\n", + "example": 625, + "start_line": 9133, + "end_line": 9137, + "section": "Raw HTML" + }, + { + "markdown": "foo foo -->\n\nfoo \n", + "html": "

foo <!--> foo -->

\n

foo <!-- foo--->

\n", + "example": 626, + "start_line": 9142, + "end_line": 9149, + "section": "Raw HTML" + }, + { + "markdown": "foo \n", + "html": "

foo

\n", + "example": 627, + "start_line": 9154, + "end_line": 9158, + "section": "Raw HTML" + }, + { + "markdown": "foo \n", + "html": "

foo

\n", + "example": 628, + "start_line": 9163, + "end_line": 9167, + "section": "Raw HTML" + }, + { + "markdown": "foo &<]]>\n", + "html": "

foo &<]]>

\n", + "example": 629, + "start_line": 9172, + "end_line": 9176, + "section": "Raw HTML" + }, + { + "markdown": "foo \n", + "html": "

foo

\n", + "example": 630, + "start_line": 9182, + "end_line": 9186, + "section": "Raw HTML" + }, + { + "markdown": "foo \n", + "html": "

foo

\n", + "example": 631, + "start_line": 9191, + "end_line": 9195, + "section": "Raw HTML" + }, + { + "markdown": "\n", + "html": "

<a href=""">

\n", + "example": 632, + "start_line": 9198, + "end_line": 9202, + "section": "Raw HTML" + }, + { + "markdown": "foo \nbaz\n", + "html": "

foo
\nbaz

\n", + "example": 633, + "start_line": 9212, + "end_line": 9218, + "section": "Hard line breaks" + }, + { + "markdown": "foo\\\nbaz\n", + "html": "

foo
\nbaz

\n", + "example": 634, + "start_line": 9224, + "end_line": 9230, + "section": "Hard line breaks" + }, + { + "markdown": "foo \nbaz\n", + "html": "

foo
\nbaz

\n", + "example": 635, + "start_line": 9235, + "end_line": 9241, + "section": "Hard line breaks" + }, + { + "markdown": "foo \n bar\n", + "html": "

foo
\nbar

\n", + "example": 636, + "start_line": 9246, + "end_line": 9252, + "section": "Hard line breaks" + }, + { + "markdown": "foo\\\n bar\n", + "html": "

foo
\nbar

\n", + "example": 637, + "start_line": 9255, + "end_line": 9261, + "section": "Hard line breaks" + }, + { + "markdown": "*foo \nbar*\n", + "html": "

foo
\nbar

\n", + "example": 638, + "start_line": 9267, + "end_line": 9273, + "section": "Hard line breaks" + }, + { + "markdown": "*foo\\\nbar*\n", + "html": "

foo
\nbar

\n", + "example": 639, + "start_line": 9276, + "end_line": 9282, + "section": "Hard line breaks" + }, + { + "markdown": "`code \nspan`\n", + "html": "

code span

\n", + "example": 640, + "start_line": 9287, + "end_line": 9292, + "section": "Hard line breaks" + }, + { + "markdown": "`code\\\nspan`\n", + "html": "

code\\ span

\n", + "example": 641, + "start_line": 9295, + "end_line": 9300, + "section": "Hard line breaks" + }, + { + "markdown": "
\n", + "html": "

\n", + "example": 642, + "start_line": 9305, + "end_line": 9311, + "section": "Hard line breaks" + }, + { + "markdown": "\n", + "html": "

\n", + "example": 643, + "start_line": 9314, + "end_line": 9320, + "section": "Hard line breaks" + }, + { + "markdown": "foo\\\n", + "html": "

foo\\

\n", + "example": 644, + "start_line": 9327, + "end_line": 9331, + "section": "Hard line breaks" + }, + { + "markdown": "foo \n", + "html": "

foo

\n", + "example": 645, + "start_line": 9334, + "end_line": 9338, + "section": "Hard line breaks" + }, + { + "markdown": "### foo\\\n", + "html": "

foo\\

\n", + "example": 646, + "start_line": 9341, + "end_line": 9345, + "section": "Hard line breaks" + }, + { + "markdown": "### foo \n", + "html": "

foo

\n", + "example": 647, + "start_line": 9348, + "end_line": 9352, + "section": "Hard line breaks" + }, + { + "markdown": "foo\nbaz\n", + "html": "

foo\nbaz

\n", + "example": 648, + "start_line": 9363, + "end_line": 9369, + "section": "Soft line breaks" + }, + { + "markdown": "foo \n baz\n", + "html": "

foo\nbaz

\n", + "example": 649, + "start_line": 9375, + "end_line": 9381, + "section": "Soft line breaks" + }, + { + "markdown": "hello $.;'there\n", + "html": "

hello $.;'there

\n", + "example": 650, + "start_line": 9395, + "end_line": 9399, + "section": "Textual content" + }, + { + "markdown": "Foo χρῆν\n", + "html": "

Foo χρῆν

\n", + "example": 651, + "start_line": 9402, + "end_line": 9406, + "section": "Textual content" + }, + { + "markdown": "Multiple spaces\n", + "html": "

Multiple spaces

\n", + "example": 652, + "start_line": 9411, + "end_line": 9415, + "section": "Textual content" + } +] \ No newline at end of file diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/fixtures/def_list.txt b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/fixtures/def_list.txt new file mode 100644 index 0000000000000000000000000000000000000000..6c5a210232576e53330d55888c2d041ffeccc145 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/fixtures/def_list.txt @@ -0,0 +1,172 @@ +# Definition Lists + +```````````````````````````````` example +Term +: definition +. +
+
Term
+
definition
+
+```````````````````````````````` + +```````````````````````````````` example +Term +: definition1 +: definition2 +. +
+
Term
+
definition1
+
definition2
+
+```````````````````````````````` + +```````````````````````````````` example +Term +: definition1 +: definition2 + +paragraph +. +
+
Term
+
definition1
+
definition2
+
+

paragraph

+```````````````````````````````` + +```````````````````````````````` example +First Term +: This is the definition of the first term. + +Second Term +: This is one definition of the second term. +: This is another definition of the second term. +. +
+
First Term
+
This is the definition of the first term.
+
Second Term
+
This is one definition of the second term.
+
This is another definition of the second term.
+
+```````````````````````````````` + +```````````````````````````````` example +First Term +: This is the definition of the first term. + +Second Term +: This is one definition of the second term. +: This is another definition of the second term. + +paragraph +. +
+
First Term
+
This is the definition of the first term.
+
Second Term
+
This is one definition of the second term.
+
This is another definition of the second term.
+
+

paragraph

+```````````````````````````````` + +```````````````````````````````` example +First Term +: This is the definition of the first term. +Not Second Term +: This is one definition of the second term. +: This is another definition of the second term. + +paragraph +. +
+
First Term
+
This is the definition of the first term. +Not Second Term
+
This is one definition of the second term.
+
This is another definition of the second term.
+
+

paragraph

+```````````````````````````````` + +## Definition with Multiple Lines + +```````````````````````````````` example +Term + +: definition +. +
+
Term
+

definition

+
+
+```````````````````````````````` + + +```````````````````````````````` example +Term +: foo + + bar +. +
+
Term
+

foo

+

bar

+
+
+```````````````````````````````` + +Leading 4 white spaces + +```````````````````````````````` example +Term +: foo + + bar +. +
+
Term
+

foo

+

bar

+
+
+```````````````````````````````` + + +```````````````````````````````` example +Term +: foo + + bar +. +
+
Term
+

foo

+
bar
+
+
+```````````````````````````````` + +```````````````````````````````` example +Term +: foo + + - bar + - baz +. +
+
Term
+

foo

+
    +
  • bar
  • +
  • baz
  • +
+
+
+```````````````````````````````` diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/fixtures/diff-commonmark.txt b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/fixtures/diff-commonmark.txt new file mode 100644 index 0000000000000000000000000000000000000000..9573e2a383b273af5db4a2386d9f9fe35120d9b4 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/fixtures/diff-commonmark.txt @@ -0,0 +1,76 @@ +# Differences + +Results different than commonmark. + + +## Setext headings + + +Example: 93 + + +```````````````````````````````` example +> foo +bar +=== +. +
+

foo +bar

+
+```````````````````````````````` + +If the dash is less than 3, it is not a `
`, in this case, it +can be rendered into `

`. + +```````````````````````````````` example +- # Foo +- Bar + -- + baz +. +
    +
  • +

    Foo

    +
  • +
  • +

    Bar

    +baz
  • +
+```````````````````````````````` + +## Image + +Example 573 + +```````````````````````````````` example +![foo ![bar](/url)](/url2) +. +

foo ![bar](/url)

+```````````````````````````````` + +## Link + +Example 517 + +```````````````````````````````` example +[foo [bar](/uri)](/uri) +. +

foo [bar](/uri)

+```````````````````````````````` + +Example 518 + +```````````````````````````````` example +[foo *[bar [baz](/uri)](/uri)*](/uri) +. +

foo [bar [baz](/uri)](/uri)

+```````````````````````````````` + +Example 519 + +```````````````````````````````` example +![[[foo](uri1)](uri2)](uri3) +. +

[foo](uri1)

+```````````````````````````````` diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/fixtures/fenced_admonition.txt b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/fixtures/fenced_admonition.txt new file mode 100644 index 0000000000000000000000000000000000000000..0f962c5e4d44d9fa81effe866998e1fc6f88565d --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/fixtures/fenced_admonition.txt @@ -0,0 +1,129 @@ +# Admonition + +```````````````````````````````` example +```{unknown} Hi + +this is **strong** world +``` +. +
{unknown} Hi
+
+this is **strong** world
+
+```````````````````````````````` + +```````````````````````````````` example +``` +this is code +``` +. +
this is code
+
+```````````````````````````````` + + +```````````````````````````````` example +~~~{note} Warning + +message +~~~ +. +
+

Warning

+

message

+
+```````````````````````````````` + +```````````````````````````````` example +~~~{note} A **strong** title + +_message_ +~~~ +. +
+

A strong title

+

message

+
+```````````````````````````````` + +Test with code block. + +```````````````````````````````` example +```{note} + + print() +``` +. +
+

Note

+
print()
+
+```````````````````````````````` + +Test with no message. + +```````````````````````````````` example +~~~{note} Warning +~~~ +. +
+

Warning

+
+```````````````````````````````` + +Test with no ending fence + +```````````````````````````````` example +~~~{note} Warning +. +
+

Warning

+
+```````````````````````````````` + +Test with nested admonition + +```````````````````````````````` example +~~~~~~~{note} +~~~~~~{warning} +~~~~~{tip} +~~~~{caution} +~~~{hint} +``````{danger} +`````{attention} +````{important} +```{error} +``` +```` +````` +`````` +~~~ +~~~~ +~~~~~ +~~~~~~ +~~~~~~~ +. +
+

Note

+
+

Warning

+
+

Tip

+
+

Caution

+
+

Hint

+
+

Danger

+
````{important}
+```{error}
+```
+````
+
+
+
+
+
+
+
+```````````````````````````````` diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/fixtures/fenced_figure.txt b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/fixtures/fenced_figure.txt new file mode 100644 index 0000000000000000000000000000000000000000..0fcd23c1f1280e6e9b17a43fbb8942d21b702254 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/fixtures/fenced_figure.txt @@ -0,0 +1,166 @@ +# Figure + +## No options + +```````````````````````````````` example +~~~{figure} picture.png +~~~ +. +
+
+
+```````````````````````````````` + +## Align options + +```````````````````````````````` example +~~~{figure} picture.png +:align: left +~~~ +. +
+
+
+```````````````````````````````` + + +```````````````````````````````` example +~~~{figure} picture.png +:align: invalid +~~~ +. +
+
+
+```````````````````````````````` + +## width and height + +```````````````````````````````` example +~~~{figure} picture.png +:width: 100 +:height: 50 +~~~ +. +
+
+
+```````````````````````````````` + +```````````````````````````````` example +~~~{figure} picture.png +:width: 100px +:height: 50px +~~~ +. +
+
+
+```````````````````````````````` + +```````````````````````````````` example +~~~{figure} picture.png +:figwidth: 400px +~~~ +. +
+
+
+```````````````````````````````` + +## alt option + +```````````````````````````````` example +~~~{figure} picture.png +:alt: description text +~~~ +. +
+
description text
+
+```````````````````````````````` + +## target option + +```````````````````````````````` example +~~~{figure} picture.png +:target: https://lepture.com +~~~ +. +
+ +
+```````````````````````````````` + +## caption + +```````````````````````````````` example +~~~{figure} picture.png +a caption with **emphasis** text +~~~ +. +
+
+
a caption with emphasis text
+
+```````````````````````````````` + +## legend + +```````````````````````````````` example +~~~{figure} picture.png +a caption with **emphasis** text + +> quote +~~~ +. +
+
+
a caption with emphasis text
+
+
+

quote

+
+
+
+```````````````````````````````` + + +```````````````````````````````` example +~~~{figure} picture.png +> quote +~~~ +. +
+
+
+```````````````````````````````` + +## all options + + +```````````````````````````````` example +~~~{figure} picture.png +:figwidth: 400px +:figclass: all-options +:target: https://lepture.com +:alt: description +:align: left +:width: 100 +:height: 50 + +a caption with **emphasis** text + +> quote +~~~ +. +
+description +
a caption with emphasis text
+
+
+

quote

+
+
+
+```````````````````````````````` diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/fixtures/fenced_image.txt b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/fixtures/fenced_image.txt new file mode 100644 index 0000000000000000000000000000000000000000..afec622ce413acb5fcbb287e020c4588e892de8c --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/fixtures/fenced_image.txt @@ -0,0 +1,102 @@ +# Image + +## No options + +```````````````````````````````` example +~~~{image} picture.png +~~~ +. +
+```````````````````````````````` + +## Align options + +```````````````````````````````` example +~~~{image} picture.png +:align: left +~~~ +. +
+```````````````````````````````` + + +```````````````````````````````` example +~~~{image} picture.png +:align: invalid +~~~ +. +
+```````````````````````````````` + +## width and height + +```````````````````````````````` example +~~~{image} picture.png +:width: 100 +:height: 50 +~~~ +. +
+```````````````````````````````` + +```````````````````````````````` example +~~~{image} picture.png +:width: 100px +:height: 50px +~~~ +. +
+```````````````````````````````` + +## alt option + +```````````````````````````````` example +~~~{image} picture.png +:alt: description text +~~~ +. +
description text
+```````````````````````````````` + +## target option + +```````````````````````````````` example +~~~{image} picture.png +:target: https://lepture.com +~~~ +. + +```````````````````````````````` + +## all options + +```````````````````````````````` example +~~~{image} picture.png +:target: https://lepture.com +:alt: description +:align: left +:width: 100 +:height: 50 +~~~ +. +description +```````````````````````````````` + +## ampersand in source + +```````````````````````````````` example +~~~{image} https://example.com/picture.png?foo=qux&test=me +~~~ +. +
+```````````````````````````````` + +## ampersand in target + +```````````````````````````````` example +~~~{image} picture.png +:target: https://example.com/rickroll?a=1&b=2 +~~~ +. + +```````````````````````````````` diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/fixtures/fenced_toc.txt b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/fixtures/fenced_toc.txt new file mode 100644 index 0000000000000000000000000000000000000000..1744000ce6ca473d1d75fb2d9388d46d3463a64c --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/fixtures/fenced_toc.txt @@ -0,0 +1,237 @@ +# Table of Contents + +## No TOC + +```````````````````````````````` example +none +. +

none

+```````````````````````````````` + +```````````````````````````````` example +# H1 +## H2 +. +

H1

+

H2

+```````````````````````````````` + + +## Simple TOC + +```````````````````````````````` example +~~~{toc} +~~~ + +# H1 +## H2 +. +
+Table of Contents + +
+

H1

+

H2

+```````````````````````````````` + +## Invalid Option + +```````````````````````````````` example +# H1 +## H2 + +~~~{toc} +:max-level: s +~~~ +. +

H1

+

H2

+
"max-level" option MUST be integer
+```````````````````````````````` + +```````````````````````````````` example +# H1 +## H2 + +~~~{toc} +:max-level: 9 +~~~ +. +

H1

+

H2

+
"max-level" option MUST be <= 3
+```````````````````````````````` + +```````````````````````````````` example +# H1 +## H2 + +~~~{toc} +:min-level: 2 +:max-level: 1 +~~~ +. +

H1

+

H2

+
"min-level" option MUST be less than "max-level" option
+```````````````````````````````` + +## Complex + +```````````````````````````````` example +# H1 +## H2 +### H3 +#### H4 +# H1 B +# H1 `C` + +```{toc} Contents +``` +. +

H1

+

H2

+

H3

+

H4

+

H1 B

+

H1 C

+
+Contents + +
+```````````````````````````````` + +## Insane + +```````````````````````````````` example +# H1 +### H3 +## H2 +#### H4 +### H3 B +# H1 B + +```{toc} +``` +. +

H1

+

H3

+

H2

+

H4

+

H3 B

+

H1 B

+
+Table of Contents + +
+```````````````````````````````` + +```````````````````````````````` example +### H3 +## H2 +# H1 + +```{toc} +``` +. +

H3

+

H2

+

H1

+
+Table of Contents + +
+```````````````````````````````` + +## Link in Heading + + +```````````````````````````````` example +# [foo](/bar) + +```{toc} +``` +. +

foo

+
+Table of Contents + +
+```````````````````````````````` + +## HTML in Heading + +```````````````````````````````` example +# H1 +```{toc} +``` +. +

H1

+
+Table of Contents + +
+```````````````````````````````` + +## Collapse TOC + +```````````````````````````````` example + +```{toc} +:collapse: +``` + +# H1 +## H2 +. +
+Table of Contents + +
+

H1

+

H2

+```````````````````````````````` diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/fixtures/fix-commonmark.txt b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/fixtures/fix-commonmark.txt new file mode 100644 index 0000000000000000000000000000000000000000..c7870065cc61e07f114050eaaecf60d3db5cbdf9 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/fixtures/fix-commonmark.txt @@ -0,0 +1,123 @@ +Fix problems that commonmark has. + + +## Links + +Links can't contain links. + +```````````````````````````````` example +[](/foo) +. +

<https://example.com>

+```````````````````````````````` + +```````````````````````````````` example +[](/foo) +. +

<name@example.com>

+```````````````````````````````` + +## Emphasis + +`` doesn't contain ``, `` doesn't contain ``. + +```````````````````````````````` example +*_em_* __**strong**__ ______m______ +. +

_em_ **strong** ______m______

+```````````````````````````````` + +### Non aggressive emphasis + +```````````````````````````````` example +*a **b c* d** +. +

a **b c d**

+```````````````````````````````` + +While CommonMark would render it into: + +``` +

a b c d

+``` + +```````````````````````````````` example +*a **b c* d** +. +

a **b c d**

+```````````````````````````````` + +While CommonMark would render it into: + +``` +

a b c d

+``` + +What if the string is: + +```````````````````````````````` example +*a **b c* d +. +

a **b c d

+```````````````````````````````` + +CommonMark would still be a mess: + +``` +

*a *b c d

+``` + + +## Max depth + + +```````````````````````````````` example +> > > > > > > > b +. +
+
+
+
+
+
+

> > b

+
+
+
+
+
+
+```````````````````````````````` + + +```````````````````````````````` example +- a + - b + - c + - d + - e + - f + - g + - h +. +
    +
  • a
      +
    • b
        +
      • c
          +
        • d
            +
          • e
              +
            • f +- g +- h
            • +
            +
          • +
          +
        • +
        +
      • +
      +
    • +
    +
  • +
+```````````````````````````````` diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/fixtures/footnotes.txt b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/fixtures/footnotes.txt new file mode 100644 index 0000000000000000000000000000000000000000..485cfd87c0a18859af15ec52b8baacad5c44fe6c --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/fixtures/footnotes.txt @@ -0,0 +1,45 @@ +# Footnotes + +```````````````````````````````` example +none [^1] +. +

none [^1]

+```````````````````````````````` + +```````````````````````````````` example +oneline [^1] + +[^1]: foo +. +

oneline 1

+
+
    +
  1. foo↩

  2. +
+
+```````````````````````````````` + +```````````````````````````````` example +multiple lines [^1] + +[^1]: foo + + one + + two + + three + + four +. +

multiple lines 1

+
four
+
+
    +
  1. foo

    +

    one

    +

    two

    +

    three↩

  2. +
+
+```````````````````````````````` diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/fixtures/hook_toc.txt b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/fixtures/hook_toc.txt new file mode 100644 index 0000000000000000000000000000000000000000..62a1a1ec79dacaf8854a67e3b48f5a1c1e9d2f4b --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/fixtures/hook_toc.txt @@ -0,0 +1,122 @@ +# Table of Contents + +## Simple TOC + +```````````````````````````````` example +# H1 + +content + +## H2 +. +

H1

+

content

+

H2

+ +```````````````````````````````` + +## Complex TOC + +```````````````````````````````` example +# H1 +## H2 +### H3 +#### H4 +# H1 B +# H1 `C` +. +

H1

+

H2

+

H3

+

H4

+

H1 B

+

H1 C

+ +```````````````````````````````` + +## Insane TOC + +```````````````````````````````` example +# H1 +### H3 +## H2 +#### H4 +### H3 B +# H1 B +. +

H1

+

H3

+

H2

+

H4

+

H3 B

+

H1 B

+ +```````````````````````````````` + +```````````````````````````````` example +### H3 +## H2 +# H1 +. +

H3

+

H2

+

H1

+ +```````````````````````````````` + +## Link in Heading + + +```````````````````````````````` example +# [foo](/bar) +. +

foo

+ +```````````````````````````````` + +## HTML in Heading + +```````````````````````````````` example +# H1 +. +

H1

+ +```````````````````````````````` diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/fixtures/include/hello.md b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/fixtures/include/hello.md new file mode 100644 index 0000000000000000000000000000000000000000..5e3d2769d88dd761efbd358b5dd0cb095d652294 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/fixtures/include/hello.md @@ -0,0 +1 @@ +> hello diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/fixtures/include/hello.txt b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/fixtures/include/hello.txt new file mode 100644 index 0000000000000000000000000000000000000000..ce013625030ba8dba906f756967f9e9ca394464a --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/fixtures/include/hello.txt @@ -0,0 +1 @@ +hello diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/fixtures/include/text.html b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/fixtures/include/text.html new file mode 100644 index 0000000000000000000000000000000000000000..da12a4c59bef8e4cc80b93ee6c98ebf6e9a10372 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/fixtures/include/text.html @@ -0,0 +1 @@ +
include html
diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/fixtures/include/text.md b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/fixtures/include/text.md new file mode 100644 index 0000000000000000000000000000000000000000..e9faa6cc816e06f743ffb9a1ae753a209607840e --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/fixtures/include/text.md @@ -0,0 +1,12 @@ +# Include + +.. include:: ./text.md + +.. include:: ./not-exist.md + +.. include:: ./text.html + :encoding: utf-8 + +.. include:: ./hello.md + +.. include:: ../rst_toc.txt diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/fixtures/insert.txt b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/fixtures/insert.txt new file mode 100644 index 0000000000000000000000000000000000000000..74d02058f0a66e5598e91d8a84429d17b7c4b62a --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/fixtures/insert.txt @@ -0,0 +1,62 @@ +# Insert + +```````````````````````````````` example +^^insert me +. +

^^insert me

+```````````````````````````````` + + +## normal insert + +```````````````````````````````` example +^^insert me^^ +. +

insert me

+```````````````````````````````` + +```````````````````````````````` example +foo ^^insert me^^ +. +

foo insert me

+```````````````````````````````` + +```````````````````````````````` example +^^insert me^^foo +. +

insert mefoo

+```````````````````````````````` + +```````````````````````````````` example +^^insert me^^^ +. +

^^insert me^^^

+```````````````````````````````` + +## escape insert + +```````````````````````````````` example +^^insert me\^^^ +. +

insert me^

+```````````````````````````````` + +```````````````````````````````` example +^^insert \^\^ me^^ +. +

insert ^^ me

+```````````````````````````````` + +## insert link + +```````````````````````````````` example +^^insert [me^^](/) +. +

insert [me](/)

+```````````````````````````````` + +```````````````````````````````` example +^^[hello](/)^^ +. +

hello

+```````````````````````````````` diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/fixtures/mark.txt b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/fixtures/mark.txt new file mode 100644 index 0000000000000000000000000000000000000000..9c8d2fbc1bf286f937a2ed288f5d497bcfca2136 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/fixtures/mark.txt @@ -0,0 +1,61 @@ +# Mark + +```````````````````````````````` example +==mark me +. +

==mark me

+```````````````````````````````` + +## normal mark + +```````````````````````````````` example +==mark me== +. +

mark me

+```````````````````````````````` + +```````````````````````````````` example +foo ==mark me== +. +

foo mark me

+```````````````````````````````` + +```````````````````````````````` example +==mark me==foo +. +

mark mefoo

+```````````````````````````````` + +```````````````````````````````` example +==mark me=== +. +

==mark me===

+```````````````````````````````` + +## escape mark + +```````````````````````````````` example +==mark me\=== +. +

mark me=

+```````````````````````````````` + +```````````````````````````````` example +==mark \=\= me== +. +

mark == me

+```````````````````````````````` + +## mark link + +```````````````````````````````` example +==mark [me==](/) +. +

mark [me](/)

+```````````````````````````````` + +```````````````````````````````` example +==[hello](/)== +. +

hello

+```````````````````````````````` diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/fixtures/math.txt b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/fixtures/math.txt new file mode 100644 index 0000000000000000000000000000000000000000..e7afaf9d1d2757c25e797b47ef4803bdeee503ef --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/fixtures/math.txt @@ -0,0 +1,57 @@ +# Math + +## Block Math + +```````````````````````````````` example +$$ +. +

$$

+```````````````````````````````` + + +```````````````````````````````` example +$$ +\operatorname{ker} f=\{g\in G:f(g)=e_{H}\}{\mbox{.}} +$$ +. +
$$ +\operatorname{ker} f=\{g\in G:f(g)=e_{H}\}{\mbox{.}} +$$
+```````````````````````````````` + +```````````````````````````````` example +$$ +foo +$$ +bar +. +
$$ +foo +$$
+

bar

+```````````````````````````````` + +```````````````````````````````` example +$$ +foo +bar +$$ +. +
$$ +foo +bar +$$
+```````````````````````````````` + + +## Inline Math + +```````````````````````````````` example +The homomorphism $f$ is injective if and only if its kernel is only the +singleton set $e_G$, because otherwise $\exists a,b\in G$ +with $a\neq b$ such that $f(a)=f(b)$. +. +

The homomorphism \(f\) is injective if and only if its kernel is only the +singleton set \(e_G\), because otherwise \(\exists a,b\in G\) +with \(a\neq b\) such that \(f(a)=f(b)\).

+```````````````````````````````` diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/fixtures/renderer_markdown.txt b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/fixtures/renderer_markdown.txt new file mode 100644 index 0000000000000000000000000000000000000000..fd618f9f281f83c0e5f2f51bcb19080e4188011a --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/fixtures/renderer_markdown.txt @@ -0,0 +1,299 @@ +# MarkdownRenderer + + +## inline + +```````````````````````````````` example +this is _em_, **strong**, and `code` +. +this is *em*, **strong**, and `code` +```````````````````````````````` + +## links + +```````````````````````````````` example +[link], [link][], [text][link], [link](/foo), [link](/foo "title") + +[link]: /url +. +[link][link], [link][link], [text][link], [link](/foo), [link](/foo "title") + +[link]: /url +```````````````````````````````` + +```````````````````````````````` example +[link], [link](https://foo(bar "title") + +[link]: /url "title" +. +[link][link], [link]( "title") + +[link]: /url "title" +```````````````````````````````` + +```````````````````````````````` example +[https://lepture.com](https://lepture.com) + + + + [demo@example.com](mailto:demo@example.com) +. + + + + + +```````````````````````````````` + +## images + +```````````````````````````````` example +[link]: /url + +![link], ![link][], ![alt][link] +. +![link][link], ![link][link], ![alt][link] + +[link]: /url +```````````````````````````````` + +## linebreak + +```````````````````````````````` example +foo\ +bar +. +foo +bar +```````````````````````````````` + +## html + +```````````````````````````````` example +inline html text + +and block html + +
hi
+. +inline html text + +and block html + +
hi
+```````````````````````````````` + +## heading + +```````````````````````````````` example +# h1 +## h2 +### h3 +#### h4 +##### h5 +###### h6 + +h1 +== +. +# h1 + +## h2 + +### h3 + +#### h4 + +##### h5 + +###### h6 + +# h1 +```````````````````````````````` + +## thematic break + +```````````````````````````````` example +hi +*** +. +hi + +*** +```````````````````````````````` + +## code + +```````````````````````````````` example +start + + def foo(): + pass + +end +. +start + +``` +def foo(): + pass +``` + +end +```````````````````````````````` + +```````````````````````````````` example +start +```py +def foo(): + pass +``` +end +. +start + +```py +def foo(): + pass +``` + +end +```````````````````````````````` + +```````````````````````````````` example +indent code + + markdown + ``` + fenced +. +indent code + +~~~ +markdown +``` +fenced +~~~ +```````````````````````````````` + +```````````````````````````````` example +indent code + + markdown + ~~~ + fenced +. +indent code + +``` +markdown +~~~ +fenced +``` +```````````````````````````````` + +```````````````````````````````` example +indent code + + markdown + ``` + fenced + ~~~ +. +indent code + +```` +markdown +``` +fenced +~~~ +```` +```````````````````````````````` + + +## quote + +```````````````````````````````` example +> quote +. +> quote +```````````````````````````````` + +```````````````````````````````` example +hello +> quote +. +hello + +> quote +```````````````````````````````` + +> quote + +> quote +> +> continuation +. +> quote + +> quote +> +> continuation + +## list + +```````````````````````````````` example +- list ++ list +. +- list + ++ list +```````````````````````````````` + +```````````````````````````````` example +- item 1 + item 2 +. +- item 1 + item 2 +```````````````````````````````` + +```````````````````````````````` example +- item 1 + + item 2 +- item 3 +. +- item 1 + + item 2 + +- item 3 +```````````````````````````````` + +```````````````````````````````` example +- item 1 + 1. item 2 +. +- item 1 + 1. item 2 +```````````````````````````````` + +```````````````````````````````` example +- item 1 + + 2. item 2 +. +- item 1 + + 2. item 2 +```````````````````````````````` + +```````````````````````````````` example +- list +- +. +- list +- +```````````````````````````````` diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/fixtures/renderer_rst.txt b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/fixtures/renderer_rst.txt new file mode 100644 index 0000000000000000000000000000000000000000..1b2499ddb74fc532191d296612fd19687224ec5b --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/fixtures/renderer_rst.txt @@ -0,0 +1,250 @@ +# RSTRenderer + +## inline + +```````````````````````````````` example +this is _em_, **strong**, and `code` +. +this is *em*, **strong**, and ``code`` +```````````````````````````````` + +```````````````````````````````` example +| escape | +. +\| escape \| +```````````````````````````````` + +## links + +```````````````````````````````` example +this is [link][] and [link](/foo) + +[link]: /url +. +this is `link
`__ and `link `__ +```````````````````````````````` + +## images + +```````````````````````````````` example +this is inline ![alt _text_](/foo) +. +this is inline |img-0| + +.. |img-0| image:: /foo + :alt: alt *text* +```````````````````````````````` + +```````````````````````````````` example +this is figure + +![alt _text_](/foo) +. +this is figure + +.. figure:: /foo + + alt *text* +```````````````````````````````` + +```````````````````````````````` example +this is figure + +![alt _text_](/foo "title") +. +this is figure + +.. figure:: /foo + :alt: title + + alt *text* +```````````````````````````````` + + +## html + +```````````````````````````````` example +ignore inline html text + +but show block html + +
hi
+. +ignore inline html text + +but show block html + +.. raw:: html + +
hi
+```````````````````````````````` + +## line break + +```````````````````````````````` example +hello +world +. +| hello +| world +```````````````````````````````` + +## heading + +```````````````````````````````` example +# h1 +## h2 +### h3 +#### h4 +##### h5 +###### h6 +. +h1 +== + +h2 +-- + +h3 +~~ + +h4 +^^ + +h5 +"" + +h6 +'' +```````````````````````````````` + +## thematic break + +```````````````````````````````` example +hi +*** +. +hi + +-------------- +```````````````````````````````` + +## code + +```````````````````````````````` example +start + + def foo(): + pass + +end +. +start + +:: + + def foo(): + pass + +end +```````````````````````````````` + +```````````````````````````````` example +start + +```py +def foo(): + pass +``` + +end +. +start + +.. code:: py + + def foo(): + pass + +end +```````````````````````````````` + + +## quote + +```````````````````````````````` example +> quote +. + quote +```````````````````````````````` + +```````````````````````````````` example +hello + +> quote +. +hello + + quote +```````````````````````````````` + +```````````````````````````````` example +> hello + +> quote +. + hello + +.. + + quote +```````````````````````````````` + +## list + +```````````````````````````````` example +- list ++ list +. +- list + ++ list +```````````````````````````````` + +```````````````````````````````` example +- item 1 + item 2 +. +- item 1 item 2 +```````````````````````````````` + +```````````````````````````````` example +- item 1 + + item 2 +- item 3 +. +- item 1 + + item 2 + +- item 3 +```````````````````````````````` + +```````````````````````````````` example +- item 1 + 1. item 2 +. +- item 1 + 1. item 2 +```````````````````````````````` + +```````````````````````````````` example +- item 1 + + 1. item 2 +. +- item 1 + + 1. item 2 +```````````````````````````````` diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/fixtures/rst_admonition.txt b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/fixtures/rst_admonition.txt new file mode 100644 index 0000000000000000000000000000000000000000..b29bda3046fdb97802fefc9a7d16a9439d9efeb6 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/fixtures/rst_admonition.txt @@ -0,0 +1,46 @@ +# Admonition + +```````````````````````````````` example +.. hello:: Warning + + message +. +
..  hello:: Warning
+
+    message
+
+```````````````````````````````` + +```````````````````````````````` example +.. note:: Warning + + message +. +
+

Warning

+

message

+
+```````````````````````````````` + +Test with code block. + +```````````````````````````````` example +.. note:: + + print() +. +
+

Note

+
print()
+
+```````````````````````````````` + +Test with no message. + +```````````````````````````````` example +.. note:: Warning +. +
+

Warning

+
+```````````````````````````````` diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/fixtures/rst_toc.txt b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/fixtures/rst_toc.txt new file mode 100644 index 0000000000000000000000000000000000000000..d65e7516398316de9532f5f52cd0ccfe182b86f1 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/fixtures/rst_toc.txt @@ -0,0 +1,223 @@ +# Table of Contents + +## No TOC + +```````````````````````````````` example +none +. +

none

+```````````````````````````````` + +```````````````````````````````` example +# H1 +## H2 +. +

H1

+

H2

+```````````````````````````````` + + +## Simple TOC + +```````````````````````````````` example +.. toc:: + +# H1 +## H2 +. +
+Table of Contents + +
+

H1

+

H2

+```````````````````````````````` + +## Invalid Option + +```````````````````````````````` example +# H1 +## H2 + +.. toc:: + :max-level: s +. +

H1

+

H2

+
"max-level" option MUST be integer
+```````````````````````````````` + +```````````````````````````````` example +# H1 +## H2 +.. toc:: + :max-level: 9 +. +

H1

+

H2

+
"max-level" option MUST be <= 3
+```````````````````````````````` + +```````````````````````````````` example +# H1 +## H2 +.. toc:: + :min-level: 2 + :max-level: 1 +. +

H1

+

H2

+
"min-level" option MUST be less than "max-level" option
+```````````````````````````````` + + +## Complex + +```````````````````````````````` example +# H1 +## H2 +### H3 +#### H4 +# H1 B +# H1 `C` + +.. toc:: Contents + :max-level: 3 +. +

H1

+

H2

+

H3

+

H4

+

H1 B

+

H1 C

+
+Contents + +
+```````````````````````````````` + +## Insane + +```````````````````````````````` example +# H1 +### H3 +## H2 +#### H4 +### H3 B +# H1 B +.. toc:: +. +

H1

+

H3

+

H2

+

H4

+

H3 B

+

H1 B

+
+Table of Contents + +
+```````````````````````````````` + +```````````````````````````````` example +### H3 +## H2 +# H1 +.. toc:: +. +

H3

+

H2

+

H1

+
+Table of Contents + +
+```````````````````````````````` + +## Link in Heading + + +```````````````````````````````` example +# [foo](/bar) +.. toc:: +. +

foo

+
+Table of Contents + +
+```````````````````````````````` + +## HTML in Heading + +```````````````````````````````` example +# H1 +.. toc:: +. +

H1

+
+Table of Contents + +
+```````````````````````````````` + +## Collapse TOC + +```````````````````````````````` example +.. toc:: + :collapse: + +# H1 +## H2 +. +
+Table of Contents + +
+

H1

+

H2

+```````````````````````````````` diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/fixtures/ruby.txt b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/fixtures/ruby.txt new file mode 100644 index 0000000000000000000000000000000000000000..d89ebe28e1161ec3915768d72303feaa168f3c63 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/fixtures/ruby.txt @@ -0,0 +1,64 @@ +# Ruby + + +## ruby without link + +```````````````````````````````` example +[漢字(ㄏㄢˋㄗˋ)] +. +

漢字ㄏㄢˋㄗˋ

+```````````````````````````````` + +```````````````````````````````` example +[漢(ㄏㄢˋ)字(ㄗˋ)] +. +

漢ㄏㄢˋ字ㄗˋ

+```````````````````````````````` + +```````````````````````````````` example +[漢字(ㄏㄢˋㄗˋ)][] +. +

漢字ㄏㄢˋㄗˋ[]

+```````````````````````````````` + +```````````````````````````````` example +[漢字(ㄏㄢˋㄗˋ)][link] +. +

漢字ㄏㄢˋㄗˋ[link]

+```````````````````````````````` + +## ruby with link + +```````````````````````````````` example +[link]: /url + +[漢字(ㄏㄢˋㄗˋ)][link] +. +

漢字ㄏㄢˋㄗˋ

+```````````````````````````````` + +```````````````````````````````` example +[漢字(ㄏㄢˋㄗˋ)]() +. +

漢字ㄏㄢˋㄗˋ

+```````````````````````````````` + +```````````````````````````````` example +[漢字(ㄏㄢˋㄗˋ)](/url) +. +

漢字ㄏㄢˋㄗˋ

+```````````````````````````````` + +## ruby splits + +```````````````````````````````` example +[漢(かん)][字(じ)] +. +

漢かん字じ

+```````````````````````````````` + +```````````````````````````````` example +[[漢(かん)][字(じ)]](https://jisho.org/search/漢字) +. +

漢かん字じ

+```````````````````````````````` diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/fixtures/spoiler.txt b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/fixtures/spoiler.txt new file mode 100644 index 0000000000000000000000000000000000000000..b1394193004aa9a896ac9212dcab200818613506 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/fixtures/spoiler.txt @@ -0,0 +1,74 @@ +# Spoiler + +## Block spoiler + +```````````````````````````````` example +>! hi +. +
+

hi

+
+```````````````````````````````` + + +```````````````````````````````` example +>! not +> spoiler +. +
+

! not +spoiler

+
+```````````````````````````````` + +```````````````````````````````` example +>! multiple +>! lines +. +
+

multiple +lines

+
+```````````````````````````````` + +```````````````````````````````` example +>! foo +>! +>! bar +. +
+

foo

+

bar

+
+```````````````````````````````` + +```````````````````````````````` example +>! foo +> +>! bar +. +
+

! foo

+

! bar

+
+```````````````````````````````` + +## Inline spoiler + +```````````````````````````````` example +hi >! hide !< +. +

hi hide

+```````````````````````````````` + +```````````````````````````````` example +hi >!hide !< +. +

hi hide

+```````````````````````````````` + +```````````````````````````````` example +hi >!hide!< +. +

hi hide

+```````````````````````````````` diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/fixtures/strikethrough.txt b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/fixtures/strikethrough.txt new file mode 100644 index 0000000000000000000000000000000000000000..007a7777aefe1f68e20026c6d87675a12623f1b8 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/fixtures/strikethrough.txt @@ -0,0 +1,46 @@ +# Strikethrough + + +## strikethrough + +```````````````````````````````` example +~~delete me +. +

~~delete me

+```````````````````````````````` + +```````````````````````````````` example +~~delete me~~ +. +

delete me

+```````````````````````````````` + +```````````````````````````````` example +~~delete me~~~ +. +

~~delete me~~~

+```````````````````````````````` + +```````````````````````````````` example +~~delete me\~~~ +. +

delete me~

+```````````````````````````````` + +```````````````````````````````` example +~~delete \~\~ me~~ +. +

delete ~~ me

+```````````````````````````````` + +```````````````````````````````` example +~~delete [me~~](/) +. +

delete [me](/)

+```````````````````````````````` + +```````````````````````````````` example +~~[hello](/)~~ +. +

hello

+```````````````````````````````` diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/fixtures/subscript.txt b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/fixtures/subscript.txt new file mode 100644 index 0000000000000000000000000000000000000000..9e4ef8bad50771b18039cd681d91d51c203128aa --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/fixtures/subscript.txt @@ -0,0 +1,26 @@ +# Subscript + + +```````````````````````````````` example +CH~3~CH~2~OH +. +

CH3CH2OH

+```````````````````````````````` + +```````````````````````````````` example +text~a\ subscript~ +. +

texta subscript

+```````````````````````````````` + +```````````````````````````````` example +text~a subscript~ +. +

text~a subscript~

+```````````````````````````````` + +```````````````````````````````` example +text~a\~subscript~ +. +

texta~subscript

+```````````````````````````````` diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/fixtures/superscript.txt b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/fixtures/superscript.txt new file mode 100644 index 0000000000000000000000000000000000000000..8f114ca8c9566ddfd1d2800341f2065ded0ad560 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/fixtures/superscript.txt @@ -0,0 +1,26 @@ +# Superscript + + +```````````````````````````````` example +CH^3^CH^2^OH +. +

CH3CH2OH

+```````````````````````````````` + +```````````````````````````````` example +text^a\ supscript^ +. +

texta supscript

+```````````````````````````````` + +```````````````````````````````` example +text^a supscript^ +. +

text^a supscript^

+```````````````````````````````` + +```````````````````````````````` example +text^a\^supscript^ +. +

texta^supscript

+```````````````````````````````` diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/fixtures/table.txt b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/fixtures/table.txt new file mode 100644 index 0000000000000000000000000000000000000000..ff4e13ae743b2733f0174cca08c10da2a9b6f1f1 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/fixtures/table.txt @@ -0,0 +1,258 @@ +# Table in Markdown + +https://michelf.ca/projects/php-markdown/extra/#table + + +## nptable + + +```````````````````````````````` example +First Header | Second Header +------------- | ------------- +Content Cell | Content Cell +Content Cell | Content Cell +. + + + + + + + + + + + + + + + + + +
First HeaderSecond Header
Content CellContent Cell
Content CellContent Cell
+```````````````````````````````` + + +## table + +```````````````````````````````` example +| First Header | Second Header | +| ------------- | ------------- | +| Content Cell | | +| Content Cell | Content Cell | +. + + + + + + + + + + + + + + + + + +
First HeaderSecond Header
Content Cell
Content CellContent Cell
+```````````````````````````````` + + +```````````````````````````````` example +| Command | Description | +| --- | --- | +| git status | List all new or modified files | +| git diff | Show file differences that haven't been staged | +. + + + + + + + + + + + + + + + + + +
CommandDescription
git statusList all new or modified files
git diffShow file differences that haven't been staged
+```````````````````````````````` + +## align table + +```````````````````````````````` example + Left | Center | Right +:---- | :--------: | ------: + a | b | c +. + + + + + + + + + + + + + + + +
LeftCenterRight
abc
+```````````````````````````````` + +```````````````````````````````` example +| Left | Center | Right | +| :--- | :----: | ----: | +| a | b | c | +. + + + + + + + + + + + + + + + +
LeftCenterRight
abc
+```````````````````````````````` + +## Misc Table + +```````````````````````````````` example +| A | | +| - | | +| a | b | +. + + + + + + + + + + + + + +
A
ab
+```````````````````````````````` + +```````````````````````````````` example +A | +- | +a | b +. + + + + + + + + + + + + + +
A
ab
+```````````````````````````````` + + +```````````````````````````````` example +| Foo | Bar | +|-----|-----| +| boo | baz | +| faz | | +. + + + + + + + + + + + + + + + + + +
FooBar
boobaz
faz
+```````````````````````````````` + +## Mismatch length + +```````````````````````````````` example +| First Header | +| ------------- | ------------- | +| Content Cell | | +| Content Cell | Content Cell | +. +

| First Header | +| ------------- | ------------- | +| Content Cell | | +| Content Cell | Content Cell |

+```````````````````````````````` + +```````````````````````````````` example +| First Header | Second Header | +| ------------- | ------------- | +| Content Cell | +| Content Cell | Content Cell | +. +

| First Header | Second Header | +| ------------- | ------------- | +| Content Cell | +| Content Cell | Content Cell |

+```````````````````````````````` + +```````````````````````````````` example +A | +- | - | +a | b | c +. +

A |

+
    +
  • | - | +a | b | c
  • +
+```````````````````````````````` + +```````````````````````````````` example +A | B | C +- | - | - +a | b +. +

A | B | C

+
    +
  • | - | - +a | b
  • +
+```````````````````````````````` diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/fixtures/task_lists.txt b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/fixtures/task_lists.txt new file mode 100644 index 0000000000000000000000000000000000000000..c1760acbdd4dd55d815789bc11afad6f2f3a8c3d --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/fixtures/task_lists.txt @@ -0,0 +1,108 @@ +# Task Lists + +```````````````````````````````` example +- [ ] foo +- [x] bar +- [X] baz +. +
    +
  • foo
  • +
  • bar
  • +
  • baz
  • +
+```````````````````````````````` + +```````````````````````````````` example +- foo +- [ ] bar +. +
    +
  • foo
  • +
  • bar
  • +
+```````````````````````````````` + +```````````````````````````````` example +- foo + +- [ ] bar +- [x] baz + + text +. +
    +
  • foo

    +
  • +
  • bar

    +
  • +
  • baz

    +

    text

    +
  • +
+```````````````````````````````` + +```````````````````````````````` example +1. [ ] foo +2. [x] bar +3. [X] baz +. +
    +
  1. foo
  2. +
  3. bar
  4. +
  5. baz
  6. +
+```````````````````````````````` + +```````````````````````````````` example +- [ ] Task list item + over two lines +. +
    +
  • Task list item +over two lines
  • +
+```````````````````````````````` + +```````````````````````````````` example +- [ ] foo + - [x] bar + - [ ] baz +. +
    +
  • foo
      +
    • bar
    • +
    • baz
    • +
    +
  • +
+```````````````````````````````` + +```````````````````````````````` example +1. [ ] foo + 1. [ ] bar + 2. [ ] baz +. +
    +
  1. foo
      +
    1. bar
    2. +
    3. baz
    4. +
    +
  2. +
+```````````````````````````````` + +```````````````````````````````` example +> - [ ] foo +> - [x] bar +> - [ ] baz +. +
+
    +
  • foo
      +
    • bar
    • +
    • baz
    • +
    +
  • +
+
+```````````````````````````````` \ No newline at end of file diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/fixtures/url.txt b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/fixtures/url.txt new file mode 100644 index 0000000000000000000000000000000000000000..669bdd5f34d93942e407aa41569072a6ff6a2f91 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/fixtures/url.txt @@ -0,0 +1,22 @@ +# url plugin + + +```````````````````````````````` example +visit https://lepture.com/ +. +

visit https://lepture.com/

+```````````````````````````````` + + +```````````````````````````````` example +visit [https://lepture.com/](/foo) +. +

visit https://lepture.com/

+```````````````````````````````` + + +```````````````````````````````` example +visit https://lepture.com/ +. +

visit https://lepture.com/

+```````````````````````````````` diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/test_commonmark.py b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/test_commonmark.py new file mode 100644 index 0000000000000000000000000000000000000000..5ece254838b130d5765744897028436efb73b0e6 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/test_commonmark.py @@ -0,0 +1,76 @@ +import mistune +from tests import BaseTestCase, normalize_html + + +DIFF_CASES = { + 'setext_headings_093', + 'html_blocks_191', # mistune keeps \n + + 'images_573', # image can not be in image + + 'links_495', + 'links_517', # aggressive link group + 'links_518', + 'links_519', + 'links_531', + 'links_532', +} + +IGNORE_CASES = { + # we don't support link title in (title) + 'links_496', + 'links_504', + + # we don't support flanking delimiter run + 'emphasis_and_strong_emphasis_352', + 'emphasis_and_strong_emphasis_367', + 'emphasis_and_strong_emphasis_368', + 'emphasis_and_strong_emphasis_372', + 'emphasis_and_strong_emphasis_379', + 'emphasis_and_strong_emphasis_388', + 'emphasis_and_strong_emphasis_391', + + 'emphasis_and_strong_emphasis_406', + 'emphasis_and_strong_emphasis_407', + 'emphasis_and_strong_emphasis_408', + + 'emphasis_and_strong_emphasis_412', + 'emphasis_and_strong_emphasis_413', + 'emphasis_and_strong_emphasis_414', + 'emphasis_and_strong_emphasis_416', + 'emphasis_and_strong_emphasis_417', + 'emphasis_and_strong_emphasis_418', + + 'emphasis_and_strong_emphasis_424', + 'emphasis_and_strong_emphasis_425', + 'emphasis_and_strong_emphasis_426', + 'emphasis_and_strong_emphasis_429', + 'emphasis_and_strong_emphasis_430', + 'emphasis_and_strong_emphasis_431', + 'emphasis_and_strong_emphasis_460', + 'emphasis_and_strong_emphasis_467', + 'emphasis_and_strong_emphasis_470', + 'emphasis_and_strong_emphasis_471', + 'emphasis_and_strong_emphasis_477', + 'emphasis_and_strong_emphasis_478', +} + +for i in range(441, 447): + IGNORE_CASES.add('emphasis_and_strong_emphasis_' + str(i)) +for i in range(453, 459): + IGNORE_CASES.add('emphasis_and_strong_emphasis_' + str(i)) +for i in range(462, 466): + IGNORE_CASES.add('emphasis_and_strong_emphasis_' + str(i)) + + +class TestCommonMark(BaseTestCase): + @classmethod + def ignore_case(cls, n): + return n in IGNORE_CASES or n in DIFF_CASES + + def assert_case(self, n, text, html): + result = mistune.html(text) + self.assertEqual(normalize_html(result), normalize_html(html)) + + +TestCommonMark.load_fixtures('commonmark.json') diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/test_directives.py b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/test_directives.py new file mode 100644 index 0000000000000000000000000000000000000000..388963a4b196c3252368bc842d1bd250d66f3d98 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/test_directives.py @@ -0,0 +1,93 @@ +import os +from mistune import create_markdown +from mistune.directives import ( + RSTDirective, + FencedDirective, + Admonition, + TableOfContents, + Include, + Image, + Figure, +) +from tests import BaseTestCase +from tests.fixtures import ROOT + + +def load_directive_test(filename, directive, cls): + class TestDirective(BaseTestCase): + @staticmethod + def parse(text): + md = create_markdown( + escape=False, + plugins=[cls([directive])], + ) + html = md(text) + return html + + TestDirective.load_fixtures(filename + '.txt') + globals()["TestDirective_" + filename] = TestDirective + + +load_directive_test('rst_admonition', Admonition(), RSTDirective) +load_directive_test('rst_toc', TableOfContents(), RSTDirective) +load_directive_test('fenced_admonition', Admonition(), FencedDirective) +load_directive_test('fenced_toc', TableOfContents(), FencedDirective) +load_directive_test('fenced_image', Image(), FencedDirective) +load_directive_test('fenced_figure', Figure(), FencedDirective) + + +class CustomizeTableOfContents(TableOfContents): + def generate_heading_id(self, token, i): + return 't-' + str(i + 1) + + +class TestCustomizeToc(BaseTestCase): + def test_rst_toc(self): + md = create_markdown( + escape=False, + plugins=[ + RSTDirective([CustomizeTableOfContents()]), + ], + ) + html = md('# h1\n\n.. toc::\n') + self.assertIn('

h1

', html) + self.assertIn('h1', html) + + def test_fenced_toc(self): + md = create_markdown( + escape=False, + plugins=[ + FencedDirective([CustomizeTableOfContents()]), + ], + ) + html = md('# h1\n\n```{toc}\n```\n') + self.assertIn('

h1

', html) + self.assertIn('h1', html) + + def test_colon_fenced_toc(self): + md = create_markdown( + escape=False, + plugins=[ + FencedDirective([CustomizeTableOfContents()], ':'), + ], + ) + html = md('# h1\n\n:::{toc}\n:::\n') + self.assertIn('

h1

', html) + self.assertIn('h1', html) + + +class TestDirectiveInclude(BaseTestCase): + md = create_markdown(escape=False, plugins=[RSTDirective([Include()])]) # type: ignore[list-item] + + def test_html_include(self): + html = self.md.read(os.path.join(ROOT, 'include/text.md'))[0] + self.assertIn('Could not include self', html) + self.assertIn('Could not find file', html) + self.assertIn('
include html
', html) + self.assertIn('
', html) + self.assertIn('# Table of Contents', html) + + def test_include_missing_source(self): + s = '.. include:: foo.txt' + html = self.md(s) + self.assertIn('Missing source file', html) diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/test_hooks.py b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/test_hooks.py new file mode 100644 index 0000000000000000000000000000000000000000..8c0a02e9b600a6034ea367fd014ec7949fb0f5d3 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/test_hooks.py @@ -0,0 +1,26 @@ +import os +from mistune import create_markdown +from mistune.toc import add_toc_hook, render_toc_ul +from tests import BaseTestCase + + +class TestTocHook(BaseTestCase): + @staticmethod + def parse(text): + md = create_markdown(escape=False) + add_toc_hook(md) + html, state = md.parse(text) + result = html + render_toc_ul(state.env['toc_items']) + return result + + def test_customize_heading_id_func(self): + def heading_id(token, i): + return 't-' + str(i + 1) + + md = create_markdown(escape=False) + add_toc_hook(md, heading_id=heading_id) + html = md('# h1') + self.assertEqual(html, '

h1

\n') + + +TestTocHook.load_fixtures('hook_toc.txt') diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/test_misc.py b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/test_misc.py new file mode 100644 index 0000000000000000000000000000000000000000..99bc68d6eca362d235a2dff0ad449ceb8dd5eebc --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/test_misc.py @@ -0,0 +1,137 @@ +import mistune +from unittest import TestCase + + +class TestMiscCases(TestCase): + def test_none(self): + self.assertEqual(mistune.html(None), '') + + def test_before_parse_hooks(self): + def _add_name(md, state): + state.env['name'] = 'test' + + md = mistune.create_markdown() + md.before_parse_hooks.append(_add_name) + state = md.block.state_cls() + md.parse('', state) + self.assertEqual(state.env['name'], 'test') + + def test_hard_wrap(self): + md = mistune.create_markdown(escape=False, hard_wrap=True) + result = md('foo\nbar') + expected = '

foo
\nbar

' + self.assertEqual(result.strip(), expected) + + md = mistune.create_markdown( + escape=False, hard_wrap=True, plugins=['speedup']) + result = md('foo\nbar') + self.assertEqual(result.strip(), expected) + + def test_escape_html(self): + md = mistune.create_markdown(escape=True) + result = md('
1
') + expected = '

<div>1</div>

' + self.assertEqual(result.strip(), expected) + + result = md('1') + expected = '

<em>1</em>

' + self.assertEqual(result.strip(), expected) + + def test_harmful_links(self): + result = mistune.html('[h](javAscript:alert)') + expected = '

h

' + self.assertEqual(result.strip(), expected) + + def test_ref_link(self): + result = mistune.html('[link][h]\n\n[h]: /foo') + expected = '

link

' + self.assertEqual(result.strip(), expected) + + def test_allow_harmful_protocols(self): + renderer = mistune.HTMLRenderer(allow_harmful_protocols=True) + md = mistune.Markdown(renderer) + result = md('[h](javascript:alert)') + expected = '

h

' + self.assertEqual(result.strip(), expected) + + def test_allow_data_protocols(self): + renderer = mistune.HTMLRenderer(allow_harmful_protocols=['data:']) + md = mistune.Markdown(renderer) + result = md('[h](data:alert)') + expected = '

h

' + self.assertEqual(result.strip(), expected) + + def test_use_plugin(self): + from mistune.plugins.url import url + md = mistune.Markdown(mistune.HTMLRenderer()) + md.use(url) + + def test_markdown_func(self): + result = mistune.markdown('**b**') + expected = '

b

\n' + self.assertEqual(result, expected) + + # trigger to use cached parser + result = mistune.markdown('**b**') + self.assertEqual(result, expected) + + def test_ast_output(self): + md = mistune.create_markdown(escape=False, renderer=None) + text = '# h1\n\nfoo **bar**\n\n`&<>"`' + result = md(text) + expected = [ + { + 'type': 'heading', + 'children': [{'type': 'text', 'raw': 'h1'}], + 'attrs': {'level': 1}, + 'style': 'atx', + }, + {'type': 'blank_line'}, + { + 'type': 'paragraph', + 'children': [ + {'type': 'text', 'raw': 'foo '}, + {'type': 'strong', 'children': [{'type': 'text', 'raw': 'bar'}]} + ] + }, + {'type': 'blank_line'}, + { + 'type': 'paragraph', + 'children': [ + {'type': 'codespan', 'raw': '&<>"'}, + ] + }, + ] + self.assertEqual(result, expected) + + def test_ast_url(self): + md = mistune.create_markdown(escape=False, renderer=None) + label = 'hi &<>"' + url = 'https://example.com/foo?a=1&b=2' + text = '[{}]({})'.format(label, url) + result = md(text) + expected = [ + { + 'type': 'paragraph', + 'children': [ + { + 'type': 'link', + 'children': [{'type': 'text', 'raw': label}], + 'attrs': {'url': url}, + }, + ], + }, + ] + self.assertEqual(result, expected) + + def test_emsp(self): + md = mistune.create_markdown(escape=False, hard_wrap=True) + result = md('\u2003\u2003foo\nbar\n\n\u2003\u2003foobar') + expected = '

\u2003\u2003foo
\nbar

\n

\u2003\u2003foobar

' + self.assertEqual(result.strip(), expected) + + def test_html_tag_text_following_list(self): + md = mistune.create_markdown(escape=False, hard_wrap=True) + result = md('foo\n- bar\n\ntable') + expected = '

foo

\n
    \n
  • bar
  • \n
\n

table

' + self.assertEqual(result.strip(), expected) diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/test_plugins.py b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/test_plugins.py new file mode 100644 index 0000000000000000000000000000000000000000..408c5fac6733b3307ee4db14e0996137e1843ebf --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/test_plugins.py @@ -0,0 +1,66 @@ +from mistune import create_markdown +from mistune.plugins.table import table_in_list, table_in_quote +from mistune.plugins.math import math_in_list, math_in_quote +from tests import BaseTestCase + + +def load_plugin(plugin_name): + md1 = create_markdown(escape=False, plugins=[plugin_name]) + md2 = create_markdown(escape=False, plugins=[plugin_name, 'speedup']) + + class TestPlugin1(BaseTestCase): + parse = md1 + + class TestPlugin2(BaseTestCase): + parse = md2 + + TestPlugin1.load_fixtures(plugin_name + ".txt") + TestPlugin2.load_fixtures(plugin_name + ".txt") + globals()["TestPlugin1_" + plugin_name] = TestPlugin1 + globals()["TestPlugin2_" + plugin_name] = TestPlugin2 + + +load_plugin("url") +load_plugin("strikethrough") +load_plugin("mark") +load_plugin("insert") +load_plugin("superscript") +load_plugin("subscript") +load_plugin("task_lists") +load_plugin("table") +load_plugin("def_list") +load_plugin("footnotes") +load_plugin("abbr") +load_plugin("math") +load_plugin("ruby") +load_plugin("spoiler") + + +class TestExtraPlugins(BaseTestCase): + def test_table_in_list(self): + text = '''- Cell | Cell\n ---- | ----\n 1 | 2\n''' + md1 = create_markdown(escape=False) + md2 = create_markdown(escape=False, plugins=['table', table_in_list]) + self.assertNotIn('', md1(text)) + self.assertIn('
', md2(text)) + + def test_table_in_quote(self): + text = '''> Cell | Cell\n> ---- | ----\n> 1 | 2\n''' + md1 = create_markdown(escape=False) + md2 = create_markdown(escape=False, plugins=['table', table_in_quote]) + self.assertNotIn('
', md1(text)) + self.assertIn('
', md2(text)) + + def test_math_in_list(self): + text = '''- $$\n foo\n $$\n''' + md1 = create_markdown(escape=False) + md2 = create_markdown(escape=False, plugins=['math', math_in_list]) + self.assertNotIn('class="math"', md1(text)) + self.assertIn('class="math"', md2(text)) + + def test_math_in_quote(self): + text = '''> $$\n> foo\n> $$\n''' + md1 = create_markdown(escape=False) + md2 = create_markdown(escape=False, plugins=['math', math_in_quote]) + self.assertNotIn('class="math"', md1(text)) + self.assertIn('class="math"', md2(text)) diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/test_renderers.py b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/test_renderers.py new file mode 100644 index 0000000000000000000000000000000000000000..dca515873cd24cf642fab5ff6dbb34d884c9a7ae --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/test_renderers.py @@ -0,0 +1,17 @@ +from mistune import create_markdown +from mistune.renderers.rst import RSTRenderer +from mistune.renderers.markdown import MarkdownRenderer +from tests import BaseTestCase + + +def load_renderer(renderer): + class TestRenderer(BaseTestCase): + parse = create_markdown(renderer=renderer) + + name = renderer.NAME + TestRenderer.load_fixtures('renderer_' + name + '.txt') + globals()["TestRenderer" + name.title()] = TestRenderer + + +load_renderer(RSTRenderer()) +load_renderer(MarkdownRenderer()) diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/test_syntax.py b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/test_syntax.py new file mode 100644 index 0000000000000000000000000000000000000000..06341d595c3cc5ef64f36c729f97901f312317d7 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/tests/trusted/tests/test_syntax.py @@ -0,0 +1,12 @@ +import mistune +from tests import BaseTestCase, normalize_html + + +class TestSyntax(BaseTestCase): + def assert_case(self, n, text, html): + result = mistune.html(text) + self.assertEqual(normalize_html(result), normalize_html(html)) + + +TestSyntax.load_fixtures('fix-commonmark.txt') +TestSyntax.load_fixtures('diff-commonmark.txt') diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/validation/canaries/first-hunk-only.sh b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/validation/canaries/first-hunk-only.sh new file mode 100644 index 0000000000000000000000000000000000000000..1451014292a47590b8af566d1462a669c2b04acc --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/validation/canaries/first-hunk-only.sh @@ -0,0 +1,59 @@ +#!/bin/bash +set -Eeuo pipefail +cd /testbed/repo +cat > /tmp/openenv-reference.diff <<'OPENENV_PARTIAL' +diff --git a/src/mistune/plugins/def_list.py b/src/mistune/plugins/def_list.py +index 9d50d6a416b900237aa543b45f78f61bc0d913a4..4d792f41fe12cac68cff8bb432305ae7e1d9827b 100644 +--- a/src/mistune/plugins/def_list.py ++++ b/src/mistune/plugins/def_list.py +@@ -28,31 +28,37 @@ + + + def parse_def_list(block: "BlockParser", m: Match[str], state: "BlockState") -> int: +- pos = m.start() +- children = list(_parse_def_item(state, m)) ++ pos = m.end() ++ children = list(_parse_def_item(block, m)) + +- m2 = DEF_RE.match(state.src, pos + 1) ++ m2 = DEF_RE.match(state.src, pos) + while m2: +- children.append(_parse_def_item(block, m2)) +- pos = m2.start() +- m2 = DEF_RE.search(state.src, pos) ++ children.extend(list(_parse_def_item(block, m2))) ++ pos = m2.end() ++ m2 = DEF_RE.match(state.src, pos) + + state.append_token({ +- 'type': 'definition_list', +- 'child_nodes': children, ++ 'type': 'def_list', ++ 'children': children, + }) +- return pos + 1 ++ return pos + + + def _parse_def_item(block: "BlockParser", m: Match[str]) -> Iterable[Dict[str, Any]]: +- start = m2.start() + head = m.group("def_list_head") +- children = _process_text(block, text, prev_blank_line) + for line in head.splitlines(): + yield { + 'type': 'def_list_head', + 'text': line, + } ++ ++ src = m.group(0) ++ end = len(head) ++ ++ m2 = DD_START_RE.search(src, end) ++ assert m2 is not None ++ start = m2.start() ++ prev_blank_line = src[end:start] == '\n' + while m2: + m2 = DD_START_RE.search(src, start + 1) + if not m2: +OPENENV_PARTIAL +/usr/bin/git -c core.hooksPath=/dev/null -c core.fsmonitor=false apply --whitespace=nowarn /tmp/openenv-reference.diff diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/validation/canaries/original-bug.sh b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/validation/canaries/original-bug.sh new file mode 100644 index 0000000000000000000000000000000000000000..927547df786c86ab3bb5eeb917a31e0fa1895f8b --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/validation/canaries/original-bug.sh @@ -0,0 +1,3 @@ +#!/bin/bash +set -Eeuo pipefail +: diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/validation/openenv.json b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/validation/openenv.json new file mode 100644 index 0000000000000000000000000000000000000000..a13b3c577df494f6c894584d2b608ab051ebc44f --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__01ys6r85/validation/openenv.json @@ -0,0 +1,27 @@ +{ + "canaries": "validation/canaries", + "profile": "harbor-semantic-v1", + "requires_credentials": false, + "resources": { + "cpu": 2, + "disk_mb": 16384, + "episode_timeout_s": 1800, + "memory_mb": 8192 + }, + "reward": { + "floor_margin": 0.1, + "oracle_tolerance": 0, + "range": [ + 0, + 1 + ] + }, + "reward_key": "reward", + "types": { + "tags": [ + "swe", + "python", + "mutation-repair" + ] + } +} diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/LICENSE.source b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/LICENSE.source new file mode 100644 index 0000000000000000000000000000000000000000..b141cdb9f3cb8010b9c3dfb392ff1a00db58a413 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/LICENSE.source @@ -0,0 +1,14 @@ +Copyright (c) 2014, Hsiaoming Yang + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + +* Neither the name of the creator nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/adapter.json b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/adapter.json new file mode 100644 index 0000000000000000000000000000000000000000..5f1269b24bd696988f73ae8157377219a0ff917e --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/adapter.json @@ -0,0 +1,131 @@ +{ + "canary_selection": "Fixed first provided gold hunk only when at least2hunks exist; strict subset, never reward-selected. Single-hunk task original-bug canary is explicitly NOP-equivalent and adds no signal beyond floor_gap.", + "collector_sha256": "352e555112f2de8a1393f939903e4971c9ace0e944843762b707a725c5c72481", + "dependency_installation_pinned": false, + "dependency_setup_sha256": "883d23539d00e744dc83da083548b6dd699be04238df34d5bd5b500a5dc53f28", + "gold_patch_sha256": "2ced3cead2857351deecc8b648a0c91dd94815a2ec6c59093aee133e6e4d013d", + "hostile_code_isolation_established": false, + "known_wrong_semantic_implementations": 0, + "native_inventory_sha256": "f0334454f6e30f50fb2658f3403dbdfc595329cf8760221a7d033f0719ecbd7a", + "new_files_deletions_and_executable_modes_supported": true, + "official_profile": { + "eval_sets": [], + "profile_class": "MistuneBf54ef67", + "profile_lines": [ + 570, + 573 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "bf54ef67390e02a5cdee7495d4386d7770c1902b", + "upstream_repo": "lepture/mistune" + }, + "original_bug_canary_nop_equivalent": true, + "original_bug_runtime_wrongness_established": false, + "partial_repair_canary": true, + "partial_repair_sha256": "a2eae6f6c91f045af43664f07444c7f5f344fd25252c0e46d904f0059b62374a", + "partial_repair_wrongness_established": false, + "positive_approval_policy": "All original strict presence/identity/no-skip/no-error/exit checks retained", + "private_checker_sha256": "f0a641064b725415e23a0221bb53c90446d7efcb7f9ece5ede93a220d18dd9e7", + "private_checker_version": "matched-failure-precedence-v2", + "provided_original_bug_control": true, + "repo_url": "https://github.com/swesmith/lepture__mistune.bf54ef67.git", + "runtime_image": null, + "runtime_ready": false, + "runtime_recipe": { + "dependency_installation_pinned": false, + "official_install_cmds": [ + "python -m pip install -e ." + ], + "official_pytest_argv": [ + "pytest", + "--disable-warnings", + "--color=no", + "--tb=no", + "--verbose" + ], + "official_test_command": "source /opt/miniconda3/bin/activate; conda activate testbed; pytest --disable-warnings --color=no --tb=no --verbose", + "operator_test_runner_prerequisites": [ + "python -m pip install pytest==8.4.2" + ], + "operator_test_runner_reason": "The official profile invokes pytest, but the common tools runtime does not provide it; pinned separately from source-native project requirements.", + "panel_normalization": "Override project addopts only to execute the exact frozen native panels; add JUnit output, preserve official pytest options and all selectors.", + "python_version": "3.10", + "source_bound_test_dependency_cmds": [], + "test_dependency_source_sha256": { + "pyproject.toml": "b2922e3ef89e2918935d38fb3a777bdbc741619942276a75fd21a8dd9faf6b42" + } + }, + "runtime_resource_review_required": false, + "schema": "python-git-patch-jobs-v1", + "source_base_commit": "b518b74b82af6ee0b45f46747be1868faab2eefc", + "source_completion_sha256": "09d8ec6381d1f71ae819d0da5512bf9d3aef843516c81a5d18e494977844086e", + "source_index_sha256": "e856874b9410fce9f3bfea52c8c482e84b3e43942d87517f8b55f0034bd40f6f", + "source_pr_url": null, + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:lepture__mistune.bf54ef67.combine_file__09mnfd6d", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "62750c95db25a8fb93dda09242f64e07508d9231", + "instruction_sha256": "6616c3d34e23061b20b76f1ceb23c5d0c352eac17b00136bdd4aa5ef31df5f65", + "is_fork": true, + "learner_path": "tasks/49f581aadac1a5e1674af0ea/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "bf54ef67390e02a5cdee7495d4386d7770c1902b", + "actual_upstream_url": "https://raw.githubusercontent.com/lepture/mistune/bf54ef67390e02a5cdee7495d4386d7770c1902b/LICENSE", + "reviewed": true, + "sha256": "539013fd8e19f744f8bf0e27a532bbff54cd689ecef7a800f56ae5dc824be870", + "spdx": "BSD-3-Clause", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/lepture__mistune.bf54ef67/b518b74b82af6ee0b45f46747be1868faab2eefc/LICENSE" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "bf54ef67390e02a5cdee7495d4386d7770c1902b", + "patch_sha256": "62abb66efa04dbcc8bad4cc5aebb0db4533b312c057c330e6ce1e189b02110d9", + "provenance_path": "tasks/49f581aadac1a5e1674af0ea/source-proof.json", + "repository_lineage": [ + "swesmith/lepture__mistune.bf54ef67", + "lepture/mistune" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "b518b74b82af6ee0b45f46747be1868faab2eefc", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "cacf6ca5378e5c94b593438f18c03c27dce261dd", + "source_kind": "mutation", + "source_repo": "swesmith/lepture__mistune.bf54ef67", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "lepture__mistune.bf54ef67.combine_file__09mnfd6d", + "task_sha256": "804eb4fddea6abef0026d4b34aed7d4a41eee4565574056ebb804b63f6148cbb", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "lepture/mistune", + "usage": "quarantine_only" + }, + "source_repo": "swesmith/lepture__mistune.bf54ef67", + "symlink_submodule_changes_supported": false, + "task_id": "lepture__mistune.bf54ef67.combine_file__09mnfd6d", + "transfer": "index-independent-worktree-to-Git-binary-patch", + "transfer_path": "/testbed/submission.patch", + "upstream_repo": "lepture/mistune" +} diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/dependency-setup.sh b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/dependency-setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..551d5bb0d87bd3b22dd7098dddea7e0794a2ab40 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/dependency-setup.sh @@ -0,0 +1,8 @@ +#!/bin/bash +set -Eeuo pipefail +source /opt/miniconda3/bin/activate +conda activate testbed +cd /testbed/repo +python -c 'import sys; assert sys.version_info[:2] == (3, 10)' +python -m pip install pytest==8.4.2 +python -m pip install -e . diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/environment/Dockerfile b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..a59b58c2ea8217c78c1e39b4678f93c8c0023bcd --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/environment/Dockerfile @@ -0,0 +1,3 @@ +# Runtime is selected only by an independently qualified immutable amd64 receipt. +FROM ubuntu:22.04 +RUN false diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/instruction.md b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..0d2928ddfd2e324fb3d62bbd4f421409872500ec --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/instruction.md @@ -0,0 +1,34 @@ +MarkdownRenderer breaks with TypeError after recent changes + +#### Description + +The MarkdownRenderer is throwing TypeErrors when trying to render markdown content. This appears to be related to argument order issues in the renderer methods. + +#### Steps/Code to Reproduce + +```python +import mistune + +# Create a markdown renderer +renderer = mistune.create_markdown() + +# Try to render some basic markdown +text = "# Hello World\n\nThis is a test." +result = renderer(text) +``` + +This will raise a TypeError when the renderer tries to process the tokens. + +The issue affects all markdown rendering functionality - headings, code blocks, lists, links, images, etc. all fail with similar TypeError exceptions. + +#### Expected Behavior + +The markdown renderer should successfully parse and render markdown content without throwing TypeErrors. + +#### Actual Behavior + +TypeError is raised during the rendering process, preventing any markdown content from being processed by the MarkdownRenderer. + +## Environment + +The repository is at `/testbed/repo`. Its dependencies, including pytest, are installed in the `testbed` conda environment, which comes first on PATH. If `python -m pytest` reports that pytest is missing, use the full interpreter path: `/opt/miniconda3/envs/testbed/bin/python -m pytest `. Don't install packages: the tests need nothing else, and the sandbox may have no network access. diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/metadata.json b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/metadata.json new file mode 100644 index 0000000000000000000000000000000000000000..fd6e7e7582d4f6b70d3a2671c9ef06a54a466706 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/metadata.json @@ -0,0 +1,1190 @@ +{ + "all_runtime_and_training_flags": false, + "official_profile": { + "eval_sets": [], + "profile_class": "MistuneBf54ef67", + "profile_lines": [ + 570, + 573 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "bf54ef67390e02a5cdee7495d4386d7770c1902b", + "upstream_repo": "lepture/mistune" + }, + "source_healthy_reference_proof": { + "FAIL_TO_PASS": [ + "tests/test_renderers.py::TestRendererMarkdown::test_code_001", + "tests/test_renderers.py::TestRendererMarkdown::test_code_002", + "tests/test_renderers.py::TestRendererMarkdown::test_code_003", + "tests/test_renderers.py::TestRendererMarkdown::test_code_004", + "tests/test_renderers.py::TestRendererMarkdown::test_code_005", + "tests/test_renderers.py::TestRendererMarkdown::test_heading_001", + "tests/test_renderers.py::TestRendererMarkdown::test_html_001", + "tests/test_renderers.py::TestRendererMarkdown::test_images_001", + "tests/test_renderers.py::TestRendererMarkdown::test_inline_001", + "tests/test_renderers.py::TestRendererMarkdown::test_linebreak_001", + "tests/test_renderers.py::TestRendererMarkdown::test_links_001", + "tests/test_renderers.py::TestRendererMarkdown::test_links_002", + "tests/test_renderers.py::TestRendererMarkdown::test_links_003", + "tests/test_renderers.py::TestRendererMarkdown::test_list_001", + "tests/test_renderers.py::TestRendererMarkdown::test_list_002", + "tests/test_renderers.py::TestRendererMarkdown::test_list_003", + "tests/test_renderers.py::TestRendererMarkdown::test_list_004", + "tests/test_renderers.py::TestRendererMarkdown::test_list_005", + "tests/test_renderers.py::TestRendererMarkdown::test_list_006", + "tests/test_renderers.py::TestRendererMarkdown::test_quote_001", + "tests/test_renderers.py::TestRendererMarkdown::test_quote_002", + "tests/test_renderers.py::TestRendererMarkdown::test_thematic_break_001" + ], + "PASS_TO_PASS": [ + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_062", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_063", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_064", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_065", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_066", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_067", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_068", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_069", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_070", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_071", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_072", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_073", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_074", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_075", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_076", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_077", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_078", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_079", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_593", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_594", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_595", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_596", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_597", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_598", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_599", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_600", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_601", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_602", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_603", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_604", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_605", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_606", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_607", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_608", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_609", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_610", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_611", + "tests/test_commonmark.py::TestCommonMark::test_backslash_escapes_012", + "tests/test_commonmark.py::TestCommonMark::test_backslash_escapes_013", + "tests/test_commonmark.py::TestCommonMark::test_backslash_escapes_014", + "tests/test_commonmark.py::TestCommonMark::test_backslash_escapes_015", + "tests/test_commonmark.py::TestCommonMark::test_backslash_escapes_016", + "tests/test_commonmark.py::TestCommonMark::test_backslash_escapes_017", + "tests/test_commonmark.py::TestCommonMark::test_backslash_escapes_018", + "tests/test_commonmark.py::TestCommonMark::test_backslash_escapes_019", + "tests/test_commonmark.py::TestCommonMark::test_backslash_escapes_020", + "tests/test_commonmark.py::TestCommonMark::test_backslash_escapes_021", + "tests/test_commonmark.py::TestCommonMark::test_backslash_escapes_022", + "tests/test_commonmark.py::TestCommonMark::test_backslash_escapes_023", + "tests/test_commonmark.py::TestCommonMark::test_backslash_escapes_024", + "tests/test_commonmark.py::TestCommonMark::test_blank_lines_227", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_228", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_229", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_230", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_231", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_232", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_233", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_234", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_235", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_236", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_237", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_238", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_239", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_240", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_241", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_242", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_243", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_244", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_245", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_246", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_247", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_248", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_249", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_250", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_251", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_252", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_328", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_329", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_330", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_331", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_332", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_333", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_334", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_335", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_336", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_337", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_338", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_339", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_340", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_341", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_342", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_343", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_344", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_345", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_346", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_347", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_348", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_349", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_350", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_351", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_353", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_354", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_355", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_356", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_357", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_358", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_359", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_360", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_361", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_362", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_363", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_364", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_365", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_366", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_369", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_370", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_371", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_373", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_374", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_375", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_376", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_377", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_378", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_380", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_381", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_382", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_383", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_384", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_385", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_386", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_387", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_389", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_390", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_392", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_393", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_394", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_395", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_396", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_397", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_398", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_399", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_400", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_401", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_402", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_403", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_404", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_405", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_409", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_410", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_411", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_415", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_419", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_420", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_421", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_422", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_423", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_427", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_428", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_432", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_433", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_434", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_435", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_436", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_437", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_438", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_439", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_440", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_447", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_448", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_449", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_450", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_451", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_452", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_459", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_461", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_466", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_468", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_469", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_472", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_473", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_474", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_475", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_476", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_479", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_480", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_025", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_026", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_027", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_028", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_029", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_030", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_031", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_032", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_033", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_034", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_035", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_036", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_037", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_038", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_039", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_040", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_041", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_119", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_120", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_121", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_122", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_123", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_124", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_125", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_126", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_127", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_128", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_129", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_130", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_131", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_132", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_133", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_134", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_135", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_136", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_137", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_138", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_139", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_140", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_141", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_142", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_143", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_144", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_145", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_146", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_147", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_633", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_634", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_635", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_636", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_637", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_638", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_639", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_640", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_641", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_642", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_643", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_644", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_645", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_646", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_647", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_148", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_149", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_150", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_151", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_152", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_153", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_154", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_155", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_156", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_157", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_158", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_159", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_160", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_161", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_162", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_163", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_164", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_165", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_166", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_167", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_168", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_169", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_170", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_171", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_172", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_173", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_174", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_175", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_176", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_177", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_178", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_179", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_180", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_181", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_182", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_183", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_184", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_185", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_186", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_187", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_188", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_189", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_190", + "tests/test_commonmark.py::TestCommonMark::test_images_571", + "tests/test_commonmark.py::TestCommonMark::test_images_572", + "tests/test_commonmark.py::TestCommonMark::test_images_574", + "tests/test_commonmark.py::TestCommonMark::test_images_575", + "tests/test_commonmark.py::TestCommonMark::test_images_576", + "tests/test_commonmark.py::TestCommonMark::test_images_577", + "tests/test_commonmark.py::TestCommonMark::test_images_578", + "tests/test_commonmark.py::TestCommonMark::test_images_579", + "tests/test_commonmark.py::TestCommonMark::test_images_580", + "tests/test_commonmark.py::TestCommonMark::test_images_581", + "tests/test_commonmark.py::TestCommonMark::test_images_582", + "tests/test_commonmark.py::TestCommonMark::test_images_583", + "tests/test_commonmark.py::TestCommonMark::test_images_584", + "tests/test_commonmark.py::TestCommonMark::test_images_585", + "tests/test_commonmark.py::TestCommonMark::test_images_586", + "tests/test_commonmark.py::TestCommonMark::test_images_587", + "tests/test_commonmark.py::TestCommonMark::test_images_588", + "tests/test_commonmark.py::TestCommonMark::test_images_589", + "tests/test_commonmark.py::TestCommonMark::test_images_590", + "tests/test_commonmark.py::TestCommonMark::test_images_591", + "tests/test_commonmark.py::TestCommonMark::test_images_592", + "tests/test_commonmark.py::TestCommonMark::test_indented_code_blocks_107", + "tests/test_commonmark.py::TestCommonMark::test_indented_code_blocks_108", + "tests/test_commonmark.py::TestCommonMark::test_indented_code_blocks_109", + "tests/test_commonmark.py::TestCommonMark::test_indented_code_blocks_110", + "tests/test_commonmark.py::TestCommonMark::test_indented_code_blocks_111", + "tests/test_commonmark.py::TestCommonMark::test_indented_code_blocks_112", + "tests/test_commonmark.py::TestCommonMark::test_indented_code_blocks_113", + "tests/test_commonmark.py::TestCommonMark::test_indented_code_blocks_114", + "tests/test_commonmark.py::TestCommonMark::test_indented_code_blocks_115", + "tests/test_commonmark.py::TestCommonMark::test_indented_code_blocks_116", + "tests/test_commonmark.py::TestCommonMark::test_indented_code_blocks_117", + "tests/test_commonmark.py::TestCommonMark::test_indented_code_blocks_118", + "tests/test_commonmark.py::TestCommonMark::test_inlines_327", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_192", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_193", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_194", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_195", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_196", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_197", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_198", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_199", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_200", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_201", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_202", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_203", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_204", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_205", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_206", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_207", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_208", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_209", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_210", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_211", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_212", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_213", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_214", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_215", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_216", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_217", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_218", + "tests/test_commonmark.py::TestCommonMark::test_links_481", + "tests/test_commonmark.py::TestCommonMark::test_links_482", + "tests/test_commonmark.py::TestCommonMark::test_links_483", + "tests/test_commonmark.py::TestCommonMark::test_links_484", + "tests/test_commonmark.py::TestCommonMark::test_links_485", + "tests/test_commonmark.py::TestCommonMark::test_links_486", + "tests/test_commonmark.py::TestCommonMark::test_links_487", + "tests/test_commonmark.py::TestCommonMark::test_links_488", + "tests/test_commonmark.py::TestCommonMark::test_links_489", + "tests/test_commonmark.py::TestCommonMark::test_links_490", + "tests/test_commonmark.py::TestCommonMark::test_links_491", + "tests/test_commonmark.py::TestCommonMark::test_links_492", + "tests/test_commonmark.py::TestCommonMark::test_links_493", + "tests/test_commonmark.py::TestCommonMark::test_links_494", + "tests/test_commonmark.py::TestCommonMark::test_links_497", + "tests/test_commonmark.py::TestCommonMark::test_links_498", + "tests/test_commonmark.py::TestCommonMark::test_links_499", + "tests/test_commonmark.py::TestCommonMark::test_links_500", + "tests/test_commonmark.py::TestCommonMark::test_links_501", + "tests/test_commonmark.py::TestCommonMark::test_links_502", + "tests/test_commonmark.py::TestCommonMark::test_links_503", + "tests/test_commonmark.py::TestCommonMark::test_links_505", + "tests/test_commonmark.py::TestCommonMark::test_links_506", + "tests/test_commonmark.py::TestCommonMark::test_links_507", + "tests/test_commonmark.py::TestCommonMark::test_links_508", + "tests/test_commonmark.py::TestCommonMark::test_links_509", + "tests/test_commonmark.py::TestCommonMark::test_links_510", + "tests/test_commonmark.py::TestCommonMark::test_links_511", + "tests/test_commonmark.py::TestCommonMark::test_links_512", + "tests/test_commonmark.py::TestCommonMark::test_links_513", + "tests/test_commonmark.py::TestCommonMark::test_links_514", + "tests/test_commonmark.py::TestCommonMark::test_links_515", + "tests/test_commonmark.py::TestCommonMark::test_links_516", + "tests/test_commonmark.py::TestCommonMark::test_links_520", + "tests/test_commonmark.py::TestCommonMark::test_links_521", + "tests/test_commonmark.py::TestCommonMark::test_links_522", + "tests/test_commonmark.py::TestCommonMark::test_links_523", + "tests/test_commonmark.py::TestCommonMark::test_links_524", + "tests/test_commonmark.py::TestCommonMark::test_links_525", + "tests/test_commonmark.py::TestCommonMark::test_links_526", + "tests/test_commonmark.py::TestCommonMark::test_links_527", + "tests/test_commonmark.py::TestCommonMark::test_links_528", + "tests/test_commonmark.py::TestCommonMark::test_links_529", + "tests/test_commonmark.py::TestCommonMark::test_links_530", + "tests/test_commonmark.py::TestCommonMark::test_links_533", + "tests/test_commonmark.py::TestCommonMark::test_links_534", + "tests/test_commonmark.py::TestCommonMark::test_links_535", + "tests/test_commonmark.py::TestCommonMark::test_links_536", + "tests/test_commonmark.py::TestCommonMark::test_links_537", + "tests/test_commonmark.py::TestCommonMark::test_links_538", + "tests/test_commonmark.py::TestCommonMark::test_links_539", + "tests/test_commonmark.py::TestCommonMark::test_links_540", + "tests/test_commonmark.py::TestCommonMark::test_links_541", + "tests/test_commonmark.py::TestCommonMark::test_links_542", + "tests/test_commonmark.py::TestCommonMark::test_links_543", + "tests/test_commonmark.py::TestCommonMark::test_links_544", + "tests/test_commonmark.py::TestCommonMark::test_links_545", + "tests/test_commonmark.py::TestCommonMark::test_links_546", + "tests/test_commonmark.py::TestCommonMark::test_links_547", + "tests/test_commonmark.py::TestCommonMark::test_links_548", + "tests/test_commonmark.py::TestCommonMark::test_links_549", + "tests/test_commonmark.py::TestCommonMark::test_links_550", + "tests/test_commonmark.py::TestCommonMark::test_links_551", + "tests/test_commonmark.py::TestCommonMark::test_links_552", + "tests/test_commonmark.py::TestCommonMark::test_links_553", + "tests/test_commonmark.py::TestCommonMark::test_links_554", + "tests/test_commonmark.py::TestCommonMark::test_links_555", + "tests/test_commonmark.py::TestCommonMark::test_links_556", + "tests/test_commonmark.py::TestCommonMark::test_links_557", + "tests/test_commonmark.py::TestCommonMark::test_links_558", + "tests/test_commonmark.py::TestCommonMark::test_links_559", + "tests/test_commonmark.py::TestCommonMark::test_links_560", + "tests/test_commonmark.py::TestCommonMark::test_links_561", + "tests/test_commonmark.py::TestCommonMark::test_links_562", + "tests/test_commonmark.py::TestCommonMark::test_links_563", + "tests/test_commonmark.py::TestCommonMark::test_links_564", + "tests/test_commonmark.py::TestCommonMark::test_links_565", + "tests/test_commonmark.py::TestCommonMark::test_links_566", + "tests/test_commonmark.py::TestCommonMark::test_links_567", + "tests/test_commonmark.py::TestCommonMark::test_links_568", + "tests/test_commonmark.py::TestCommonMark::test_links_569", + "tests/test_commonmark.py::TestCommonMark::test_links_570", + "tests/test_commonmark.py::TestCommonMark::test_list_items_253", + "tests/test_commonmark.py::TestCommonMark::test_list_items_254", + "tests/test_commonmark.py::TestCommonMark::test_list_items_255", + "tests/test_commonmark.py::TestCommonMark::test_list_items_256", + "tests/test_commonmark.py::TestCommonMark::test_list_items_257", + "tests/test_commonmark.py::TestCommonMark::test_list_items_258", + "tests/test_commonmark.py::TestCommonMark::test_list_items_259", + "tests/test_commonmark.py::TestCommonMark::test_list_items_260", + "tests/test_commonmark.py::TestCommonMark::test_list_items_261", + "tests/test_commonmark.py::TestCommonMark::test_list_items_262", + "tests/test_commonmark.py::TestCommonMark::test_list_items_263", + "tests/test_commonmark.py::TestCommonMark::test_list_items_264", + "tests/test_commonmark.py::TestCommonMark::test_list_items_265", + "tests/test_commonmark.py::TestCommonMark::test_list_items_266", + "tests/test_commonmark.py::TestCommonMark::test_list_items_267", + "tests/test_commonmark.py::TestCommonMark::test_list_items_268", + "tests/test_commonmark.py::TestCommonMark::test_list_items_269", + "tests/test_commonmark.py::TestCommonMark::test_list_items_270", + "tests/test_commonmark.py::TestCommonMark::test_list_items_271", + "tests/test_commonmark.py::TestCommonMark::test_list_items_272", + "tests/test_commonmark.py::TestCommonMark::test_list_items_273", + "tests/test_commonmark.py::TestCommonMark::test_list_items_274", + "tests/test_commonmark.py::TestCommonMark::test_list_items_275", + "tests/test_commonmark.py::TestCommonMark::test_list_items_276", + "tests/test_commonmark.py::TestCommonMark::test_list_items_277", + "tests/test_commonmark.py::TestCommonMark::test_list_items_278", + "tests/test_commonmark.py::TestCommonMark::test_list_items_279", + "tests/test_commonmark.py::TestCommonMark::test_list_items_280", + "tests/test_commonmark.py::TestCommonMark::test_list_items_281", + "tests/test_commonmark.py::TestCommonMark::test_list_items_282", + "tests/test_commonmark.py::TestCommonMark::test_list_items_283", + "tests/test_commonmark.py::TestCommonMark::test_list_items_284", + "tests/test_commonmark.py::TestCommonMark::test_list_items_285", + "tests/test_commonmark.py::TestCommonMark::test_list_items_286", + "tests/test_commonmark.py::TestCommonMark::test_list_items_287", + "tests/test_commonmark.py::TestCommonMark::test_list_items_288", + "tests/test_commonmark.py::TestCommonMark::test_list_items_289", + "tests/test_commonmark.py::TestCommonMark::test_list_items_290", + "tests/test_commonmark.py::TestCommonMark::test_list_items_291", + "tests/test_commonmark.py::TestCommonMark::test_list_items_292", + "tests/test_commonmark.py::TestCommonMark::test_list_items_293", + "tests/test_commonmark.py::TestCommonMark::test_list_items_294", + "tests/test_commonmark.py::TestCommonMark::test_list_items_295", + "tests/test_commonmark.py::TestCommonMark::test_list_items_296", + "tests/test_commonmark.py::TestCommonMark::test_list_items_297", + "tests/test_commonmark.py::TestCommonMark::test_list_items_298", + "tests/test_commonmark.py::TestCommonMark::test_list_items_299", + "tests/test_commonmark.py::TestCommonMark::test_list_items_300", + "tests/test_commonmark.py::TestCommonMark::test_lists_301", + "tests/test_commonmark.py::TestCommonMark::test_lists_302", + "tests/test_commonmark.py::TestCommonMark::test_lists_303", + "tests/test_commonmark.py::TestCommonMark::test_lists_304", + "tests/test_commonmark.py::TestCommonMark::test_lists_305", + "tests/test_commonmark.py::TestCommonMark::test_lists_306", + "tests/test_commonmark.py::TestCommonMark::test_lists_307", + "tests/test_commonmark.py::TestCommonMark::test_lists_308", + "tests/test_commonmark.py::TestCommonMark::test_lists_309", + "tests/test_commonmark.py::TestCommonMark::test_lists_310", + "tests/test_commonmark.py::TestCommonMark::test_lists_311", + "tests/test_commonmark.py::TestCommonMark::test_lists_312", + "tests/test_commonmark.py::TestCommonMark::test_lists_313", + "tests/test_commonmark.py::TestCommonMark::test_lists_314", + "tests/test_commonmark.py::TestCommonMark::test_lists_315", + "tests/test_commonmark.py::TestCommonMark::test_lists_316", + "tests/test_commonmark.py::TestCommonMark::test_lists_317", + "tests/test_commonmark.py::TestCommonMark::test_lists_318", + "tests/test_commonmark.py::TestCommonMark::test_lists_319", + "tests/test_commonmark.py::TestCommonMark::test_lists_320", + "tests/test_commonmark.py::TestCommonMark::test_lists_321", + "tests/test_commonmark.py::TestCommonMark::test_lists_322", + "tests/test_commonmark.py::TestCommonMark::test_lists_323", + "tests/test_commonmark.py::TestCommonMark::test_lists_324", + "tests/test_commonmark.py::TestCommonMark::test_lists_325", + "tests/test_commonmark.py::TestCommonMark::test_lists_326", + "tests/test_commonmark.py::TestCommonMark::test_paragraphs_219", + "tests/test_commonmark.py::TestCommonMark::test_paragraphs_220", + "tests/test_commonmark.py::TestCommonMark::test_paragraphs_221", + "tests/test_commonmark.py::TestCommonMark::test_paragraphs_222", + "tests/test_commonmark.py::TestCommonMark::test_paragraphs_223", + "tests/test_commonmark.py::TestCommonMark::test_paragraphs_224", + "tests/test_commonmark.py::TestCommonMark::test_paragraphs_225", + "tests/test_commonmark.py::TestCommonMark::test_paragraphs_226", + "tests/test_commonmark.py::TestCommonMark::test_precedence_042", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_612", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_613", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_614", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_615", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_616", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_617", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_618", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_619", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_620", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_621", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_622", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_623", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_624", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_625", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_626", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_627", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_628", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_629", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_630", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_631", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_632", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_080", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_081", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_082", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_083", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_084", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_085", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_086", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_087", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_088", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_089", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_090", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_091", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_092", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_094", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_095", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_096", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_097", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_098", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_099", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_100", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_101", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_102", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_103", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_104", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_105", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_106", + "tests/test_commonmark.py::TestCommonMark::test_soft_line_breaks_648", + "tests/test_commonmark.py::TestCommonMark::test_soft_line_breaks_649", + "tests/test_commonmark.py::TestCommonMark::test_tabs_001", + "tests/test_commonmark.py::TestCommonMark::test_tabs_002", + "tests/test_commonmark.py::TestCommonMark::test_tabs_003", + "tests/test_commonmark.py::TestCommonMark::test_tabs_004", + "tests/test_commonmark.py::TestCommonMark::test_tabs_005", + "tests/test_commonmark.py::TestCommonMark::test_tabs_006", + "tests/test_commonmark.py::TestCommonMark::test_tabs_007", + "tests/test_commonmark.py::TestCommonMark::test_tabs_008", + "tests/test_commonmark.py::TestCommonMark::test_tabs_009", + "tests/test_commonmark.py::TestCommonMark::test_tabs_010", + "tests/test_commonmark.py::TestCommonMark::test_tabs_011", + "tests/test_commonmark.py::TestCommonMark::test_textual_content_650", + "tests/test_commonmark.py::TestCommonMark::test_textual_content_651", + "tests/test_commonmark.py::TestCommonMark::test_textual_content_652", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_043", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_044", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_045", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_046", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_047", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_048", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_049", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_050", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_051", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_052", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_053", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_054", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_055", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_056", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_057", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_058", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_059", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_060", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_061", + "tests/test_directives.py::TestDirective_rst_admonition::test_admonition_001", + "tests/test_directives.py::TestDirective_rst_admonition::test_admonition_002", + "tests/test_directives.py::TestDirective_rst_admonition::test_admonition_003", + "tests/test_directives.py::TestDirective_rst_admonition::test_admonition_004", + "tests/test_directives.py::TestDirective_rst_toc::test_collapse_toc_001", + "tests/test_directives.py::TestDirective_rst_toc::test_complex_001", + "tests/test_directives.py::TestDirective_rst_toc::test_html_in_heading_001", + "tests/test_directives.py::TestDirective_rst_toc::test_insane_001", + "tests/test_directives.py::TestDirective_rst_toc::test_insane_002", + "tests/test_directives.py::TestDirective_rst_toc::test_invalid_option_001", + "tests/test_directives.py::TestDirective_rst_toc::test_invalid_option_002", + "tests/test_directives.py::TestDirective_rst_toc::test_invalid_option_003", + "tests/test_directives.py::TestDirective_rst_toc::test_link_in_heading_001", + "tests/test_directives.py::TestDirective_rst_toc::test_no_toc_001", + "tests/test_directives.py::TestDirective_rst_toc::test_no_toc_002", + "tests/test_directives.py::TestDirective_rst_toc::test_simple_toc_001", + "tests/test_directives.py::TestDirective_fenced_admonition::test_admonition_001", + "tests/test_directives.py::TestDirective_fenced_admonition::test_admonition_002", + "tests/test_directives.py::TestDirective_fenced_admonition::test_admonition_003", + "tests/test_directives.py::TestDirective_fenced_admonition::test_admonition_004", + "tests/test_directives.py::TestDirective_fenced_admonition::test_admonition_005", + "tests/test_directives.py::TestDirective_fenced_admonition::test_admonition_006", + "tests/test_directives.py::TestDirective_fenced_admonition::test_admonition_007", + "tests/test_directives.py::TestDirective_fenced_admonition::test_admonition_008", + "tests/test_directives.py::TestDirective_fenced_toc::test_collapse_toc_001", + "tests/test_directives.py::TestDirective_fenced_toc::test_complex_001", + "tests/test_directives.py::TestDirective_fenced_toc::test_html_in_heading_001", + "tests/test_directives.py::TestDirective_fenced_toc::test_insane_001", + "tests/test_directives.py::TestDirective_fenced_toc::test_insane_002", + "tests/test_directives.py::TestDirective_fenced_toc::test_invalid_option_001", + "tests/test_directives.py::TestDirective_fenced_toc::test_invalid_option_002", + "tests/test_directives.py::TestDirective_fenced_toc::test_invalid_option_003", + "tests/test_directives.py::TestDirective_fenced_toc::test_link_in_heading_001", + "tests/test_directives.py::TestDirective_fenced_toc::test_no_toc_001", + "tests/test_directives.py::TestDirective_fenced_toc::test_no_toc_002", + "tests/test_directives.py::TestDirective_fenced_toc::test_simple_toc_001", + "tests/test_directives.py::TestDirective_fenced_image::test_align_options_001", + "tests/test_directives.py::TestDirective_fenced_image::test_align_options_002", + "tests/test_directives.py::TestDirective_fenced_image::test_all_options_001", + "tests/test_directives.py::TestDirective_fenced_image::test_alt_option_001", + "tests/test_directives.py::TestDirective_fenced_image::test_ampersand_in_source_001", + "tests/test_directives.py::TestDirective_fenced_image::test_ampersand_in_target_001", + "tests/test_directives.py::TestDirective_fenced_image::test_no_options_001", + "tests/test_directives.py::TestDirective_fenced_image::test_target_option_001", + "tests/test_directives.py::TestDirective_fenced_image::test_width_and_height_001", + "tests/test_directives.py::TestDirective_fenced_image::test_width_and_height_002", + "tests/test_directives.py::TestDirective_fenced_figure::test_align_options_001", + "tests/test_directives.py::TestDirective_fenced_figure::test_align_options_002", + "tests/test_directives.py::TestDirective_fenced_figure::test_all_options_001", + "tests/test_directives.py::TestDirective_fenced_figure::test_alt_option_001", + "tests/test_directives.py::TestDirective_fenced_figure::test_caption_001", + "tests/test_directives.py::TestDirective_fenced_figure::test_legend_001", + "tests/test_directives.py::TestDirective_fenced_figure::test_legend_002", + "tests/test_directives.py::TestDirective_fenced_figure::test_no_options_001", + "tests/test_directives.py::TestDirective_fenced_figure::test_target_option_001", + "tests/test_directives.py::TestDirective_fenced_figure::test_width_and_height_001", + "tests/test_directives.py::TestDirective_fenced_figure::test_width_and_height_002", + "tests/test_directives.py::TestDirective_fenced_figure::test_width_and_height_003", + "tests/test_directives.py::TestCustomizeToc::test_colon_fenced_toc", + "tests/test_directives.py::TestCustomizeToc::test_fenced_toc", + "tests/test_directives.py::TestCustomizeToc::test_rst_toc", + "tests/test_directives.py::TestDirectiveInclude::test_html_include", + "tests/test_directives.py::TestDirectiveInclude::test_include_missing_source", + "tests/test_hooks.py::TestTocHook::test_complex_toc_001", + "tests/test_hooks.py::TestTocHook::test_customize_heading_id_func", + "tests/test_hooks.py::TestTocHook::test_html_in_heading_001", + "tests/test_hooks.py::TestTocHook::test_insane_toc_001", + "tests/test_hooks.py::TestTocHook::test_insane_toc_002", + "tests/test_hooks.py::TestTocHook::test_link_in_heading_001", + "tests/test_hooks.py::TestTocHook::test_simple_toc_001", + "tests/test_misc.py::TestMiscCases::test_allow_data_protocols", + "tests/test_misc.py::TestMiscCases::test_allow_harmful_protocols", + "tests/test_misc.py::TestMiscCases::test_ast_output", + "tests/test_misc.py::TestMiscCases::test_ast_url", + "tests/test_misc.py::TestMiscCases::test_before_parse_hooks", + "tests/test_misc.py::TestMiscCases::test_emsp", + "tests/test_misc.py::TestMiscCases::test_escape_html", + "tests/test_misc.py::TestMiscCases::test_hard_wrap", + "tests/test_misc.py::TestMiscCases::test_harmful_links", + "tests/test_misc.py::TestMiscCases::test_html_tag_text_following_list", + "tests/test_misc.py::TestMiscCases::test_markdown_func", + "tests/test_misc.py::TestMiscCases::test_none", + "tests/test_misc.py::TestMiscCases::test_ref_link", + "tests/test_misc.py::TestMiscCases::test_use_plugin", + "tests/test_plugins.py::TestPlugin1_url::test_url_plugin_001", + "tests/test_plugins.py::TestPlugin1_url::test_url_plugin_002", + "tests/test_plugins.py::TestPlugin1_url::test_url_plugin_003", + "tests/test_plugins.py::TestPlugin2_url::test_url_plugin_001", + "tests/test_plugins.py::TestPlugin2_url::test_url_plugin_002", + "tests/test_plugins.py::TestPlugin2_url::test_url_plugin_003", + "tests/test_plugins.py::TestPlugin1_strikethrough::test_strikethrough_001", + "tests/test_plugins.py::TestPlugin1_strikethrough::test_strikethrough_002", + "tests/test_plugins.py::TestPlugin1_strikethrough::test_strikethrough_003", + "tests/test_plugins.py::TestPlugin1_strikethrough::test_strikethrough_004", + "tests/test_plugins.py::TestPlugin1_strikethrough::test_strikethrough_005", + "tests/test_plugins.py::TestPlugin1_strikethrough::test_strikethrough_006", + "tests/test_plugins.py::TestPlugin1_strikethrough::test_strikethrough_007", + "tests/test_plugins.py::TestPlugin2_strikethrough::test_strikethrough_001", + "tests/test_plugins.py::TestPlugin2_strikethrough::test_strikethrough_002", + "tests/test_plugins.py::TestPlugin2_strikethrough::test_strikethrough_003", + "tests/test_plugins.py::TestPlugin2_strikethrough::test_strikethrough_004", + "tests/test_plugins.py::TestPlugin2_strikethrough::test_strikethrough_005", + "tests/test_plugins.py::TestPlugin2_strikethrough::test_strikethrough_006", + "tests/test_plugins.py::TestPlugin2_strikethrough::test_strikethrough_007", + "tests/test_plugins.py::TestPlugin1_mark::test_escape_mark_001", + "tests/test_plugins.py::TestPlugin1_mark::test_escape_mark_002", + "tests/test_plugins.py::TestPlugin1_mark::test_mark_001", + "tests/test_plugins.py::TestPlugin1_mark::test_mark_link_001", + "tests/test_plugins.py::TestPlugin1_mark::test_mark_link_002", + "tests/test_plugins.py::TestPlugin1_mark::test_normal_mark_001", + "tests/test_plugins.py::TestPlugin1_mark::test_normal_mark_002", + "tests/test_plugins.py::TestPlugin1_mark::test_normal_mark_003", + "tests/test_plugins.py::TestPlugin1_mark::test_normal_mark_004", + "tests/test_plugins.py::TestPlugin2_mark::test_escape_mark_001", + "tests/test_plugins.py::TestPlugin2_mark::test_escape_mark_002", + "tests/test_plugins.py::TestPlugin2_mark::test_mark_001", + "tests/test_plugins.py::TestPlugin2_mark::test_mark_link_001", + "tests/test_plugins.py::TestPlugin2_mark::test_mark_link_002", + "tests/test_plugins.py::TestPlugin2_mark::test_normal_mark_001", + "tests/test_plugins.py::TestPlugin2_mark::test_normal_mark_002", + "tests/test_plugins.py::TestPlugin2_mark::test_normal_mark_003", + "tests/test_plugins.py::TestPlugin2_mark::test_normal_mark_004", + "tests/test_plugins.py::TestPlugin1_insert::test_escape_insert_001", + "tests/test_plugins.py::TestPlugin1_insert::test_escape_insert_002", + "tests/test_plugins.py::TestPlugin1_insert::test_insert_001", + "tests/test_plugins.py::TestPlugin1_insert::test_insert_link_001", + "tests/test_plugins.py::TestPlugin1_insert::test_insert_link_002", + "tests/test_plugins.py::TestPlugin1_insert::test_normal_insert_001", + "tests/test_plugins.py::TestPlugin1_insert::test_normal_insert_002", + "tests/test_plugins.py::TestPlugin1_insert::test_normal_insert_003", + "tests/test_plugins.py::TestPlugin1_insert::test_normal_insert_004", + "tests/test_plugins.py::TestPlugin2_insert::test_escape_insert_001", + "tests/test_plugins.py::TestPlugin2_insert::test_escape_insert_002", + "tests/test_plugins.py::TestPlugin2_insert::test_insert_001", + "tests/test_plugins.py::TestPlugin2_insert::test_insert_link_001", + "tests/test_plugins.py::TestPlugin2_insert::test_insert_link_002", + "tests/test_plugins.py::TestPlugin2_insert::test_normal_insert_001", + "tests/test_plugins.py::TestPlugin2_insert::test_normal_insert_002", + "tests/test_plugins.py::TestPlugin2_insert::test_normal_insert_003", + "tests/test_plugins.py::TestPlugin2_insert::test_normal_insert_004", + "tests/test_plugins.py::TestPlugin1_superscript::test_superscript_001", + "tests/test_plugins.py::TestPlugin1_superscript::test_superscript_002", + "tests/test_plugins.py::TestPlugin1_superscript::test_superscript_003", + "tests/test_plugins.py::TestPlugin1_superscript::test_superscript_004", + "tests/test_plugins.py::TestPlugin2_superscript::test_superscript_001", + "tests/test_plugins.py::TestPlugin2_superscript::test_superscript_002", + "tests/test_plugins.py::TestPlugin2_superscript::test_superscript_003", + "tests/test_plugins.py::TestPlugin2_superscript::test_superscript_004", + "tests/test_plugins.py::TestPlugin1_subscript::test_subscript_001", + "tests/test_plugins.py::TestPlugin1_subscript::test_subscript_002", + "tests/test_plugins.py::TestPlugin1_subscript::test_subscript_003", + "tests/test_plugins.py::TestPlugin1_subscript::test_subscript_004", + "tests/test_plugins.py::TestPlugin2_subscript::test_subscript_001", + "tests/test_plugins.py::TestPlugin2_subscript::test_subscript_002", + "tests/test_plugins.py::TestPlugin2_subscript::test_subscript_003", + "tests/test_plugins.py::TestPlugin2_subscript::test_subscript_004", + "tests/test_plugins.py::TestPlugin1_task_lists::test_task_lists_001", + "tests/test_plugins.py::TestPlugin1_task_lists::test_task_lists_002", + "tests/test_plugins.py::TestPlugin1_task_lists::test_task_lists_003", + "tests/test_plugins.py::TestPlugin1_task_lists::test_task_lists_004", + "tests/test_plugins.py::TestPlugin1_task_lists::test_task_lists_005", + "tests/test_plugins.py::TestPlugin1_task_lists::test_task_lists_006", + "tests/test_plugins.py::TestPlugin1_task_lists::test_task_lists_007", + "tests/test_plugins.py::TestPlugin1_task_lists::test_task_lists_008", + "tests/test_plugins.py::TestPlugin2_task_lists::test_task_lists_001", + "tests/test_plugins.py::TestPlugin2_task_lists::test_task_lists_002", + "tests/test_plugins.py::TestPlugin2_task_lists::test_task_lists_003", + "tests/test_plugins.py::TestPlugin2_task_lists::test_task_lists_004", + "tests/test_plugins.py::TestPlugin2_task_lists::test_task_lists_005", + "tests/test_plugins.py::TestPlugin2_task_lists::test_task_lists_006", + "tests/test_plugins.py::TestPlugin2_task_lists::test_task_lists_007", + "tests/test_plugins.py::TestPlugin2_task_lists::test_task_lists_008", + "tests/test_plugins.py::TestPlugin1_table::test_align_table_001", + "tests/test_plugins.py::TestPlugin1_table::test_align_table_002", + "tests/test_plugins.py::TestPlugin1_table::test_misc_table_001", + "tests/test_plugins.py::TestPlugin1_table::test_misc_table_002", + "tests/test_plugins.py::TestPlugin1_table::test_misc_table_003", + "tests/test_plugins.py::TestPlugin1_table::test_mismatch_length_001", + "tests/test_plugins.py::TestPlugin1_table::test_mismatch_length_002", + "tests/test_plugins.py::TestPlugin1_table::test_mismatch_length_003", + "tests/test_plugins.py::TestPlugin1_table::test_mismatch_length_004", + "tests/test_plugins.py::TestPlugin1_table::test_nptable_001", + "tests/test_plugins.py::TestPlugin1_table::test_table_001", + "tests/test_plugins.py::TestPlugin1_table::test_table_002", + "tests/test_plugins.py::TestPlugin2_table::test_align_table_001", + "tests/test_plugins.py::TestPlugin2_table::test_align_table_002", + "tests/test_plugins.py::TestPlugin2_table::test_misc_table_001", + "tests/test_plugins.py::TestPlugin2_table::test_misc_table_002", + "tests/test_plugins.py::TestPlugin2_table::test_misc_table_003", + "tests/test_plugins.py::TestPlugin2_table::test_mismatch_length_001", + "tests/test_plugins.py::TestPlugin2_table::test_mismatch_length_002", + "tests/test_plugins.py::TestPlugin2_table::test_mismatch_length_003", + "tests/test_plugins.py::TestPlugin2_table::test_mismatch_length_004", + "tests/test_plugins.py::TestPlugin2_table::test_nptable_001", + "tests/test_plugins.py::TestPlugin2_table::test_table_001", + "tests/test_plugins.py::TestPlugin2_table::test_table_002", + "tests/test_plugins.py::TestPlugin1_def_list::test_definition_lists_001", + "tests/test_plugins.py::TestPlugin1_def_list::test_definition_lists_002", + "tests/test_plugins.py::TestPlugin1_def_list::test_definition_lists_003", + "tests/test_plugins.py::TestPlugin1_def_list::test_definition_lists_004", + "tests/test_plugins.py::TestPlugin1_def_list::test_definition_lists_005", + "tests/test_plugins.py::TestPlugin1_def_list::test_definition_lists_006", + "tests/test_plugins.py::TestPlugin1_def_list::test_definition_with_multiple_lines_001", + "tests/test_plugins.py::TestPlugin1_def_list::test_definition_with_multiple_lines_002", + "tests/test_plugins.py::TestPlugin1_def_list::test_definition_with_multiple_lines_003", + "tests/test_plugins.py::TestPlugin1_def_list::test_definition_with_multiple_lines_004", + "tests/test_plugins.py::TestPlugin1_def_list::test_definition_with_multiple_lines_005", + "tests/test_plugins.py::TestPlugin2_def_list::test_definition_lists_001", + "tests/test_plugins.py::TestPlugin2_def_list::test_definition_lists_002", + "tests/test_plugins.py::TestPlugin2_def_list::test_definition_lists_003", + "tests/test_plugins.py::TestPlugin2_def_list::test_definition_lists_004", + "tests/test_plugins.py::TestPlugin2_def_list::test_definition_lists_005", + "tests/test_plugins.py::TestPlugin2_def_list::test_definition_lists_006", + "tests/test_plugins.py::TestPlugin2_def_list::test_definition_with_multiple_lines_001", + "tests/test_plugins.py::TestPlugin2_def_list::test_definition_with_multiple_lines_002", + "tests/test_plugins.py::TestPlugin2_def_list::test_definition_with_multiple_lines_003", + "tests/test_plugins.py::TestPlugin2_def_list::test_definition_with_multiple_lines_004", + "tests/test_plugins.py::TestPlugin2_def_list::test_definition_with_multiple_lines_005", + "tests/test_plugins.py::TestPlugin1_footnotes::test_footnotes_001", + "tests/test_plugins.py::TestPlugin1_footnotes::test_footnotes_002", + "tests/test_plugins.py::TestPlugin1_footnotes::test_footnotes_003", + "tests/test_plugins.py::TestPlugin2_footnotes::test_footnotes_001", + "tests/test_plugins.py::TestPlugin2_footnotes::test_footnotes_002", + "tests/test_plugins.py::TestPlugin2_footnotes::test_footnotes_003", + "tests/test_plugins.py::TestPlugin1_abbr::test_abbreviation_001", + "tests/test_plugins.py::TestPlugin1_abbr::test_abbreviation_002", + "tests/test_plugins.py::TestPlugin1_abbr::test_abbreviation_003", + "tests/test_plugins.py::TestPlugin1_abbr::test_abbreviation_004", + "tests/test_plugins.py::TestPlugin1_abbr::test_abbreviation_005", + "tests/test_plugins.py::TestPlugin1_abbr::test_abbreviation_006", + "tests/test_plugins.py::TestPlugin1_abbr::test_abbreviation_007", + "tests/test_plugins.py::TestPlugin1_abbr::test_abbreviation_008", + "tests/test_plugins.py::TestPlugin1_abbr::test_abbreviation_009", + "tests/test_plugins.py::TestPlugin1_abbr::test_abbreviation_010", + "tests/test_plugins.py::TestPlugin2_abbr::test_abbreviation_001", + "tests/test_plugins.py::TestPlugin2_abbr::test_abbreviation_002", + "tests/test_plugins.py::TestPlugin2_abbr::test_abbreviation_003", + "tests/test_plugins.py::TestPlugin2_abbr::test_abbreviation_004", + "tests/test_plugins.py::TestPlugin2_abbr::test_abbreviation_005", + "tests/test_plugins.py::TestPlugin2_abbr::test_abbreviation_006", + "tests/test_plugins.py::TestPlugin2_abbr::test_abbreviation_007", + "tests/test_plugins.py::TestPlugin2_abbr::test_abbreviation_008", + "tests/test_plugins.py::TestPlugin2_abbr::test_abbreviation_009", + "tests/test_plugins.py::TestPlugin2_abbr::test_abbreviation_010", + "tests/test_plugins.py::TestPlugin1_math::test_block_math_001", + "tests/test_plugins.py::TestPlugin1_math::test_block_math_002", + "tests/test_plugins.py::TestPlugin1_math::test_block_math_003", + "tests/test_plugins.py::TestPlugin1_math::test_block_math_004", + "tests/test_plugins.py::TestPlugin1_math::test_inline_math_001", + "tests/test_plugins.py::TestPlugin2_math::test_block_math_001", + "tests/test_plugins.py::TestPlugin2_math::test_block_math_002", + "tests/test_plugins.py::TestPlugin2_math::test_block_math_003", + "tests/test_plugins.py::TestPlugin2_math::test_block_math_004", + "tests/test_plugins.py::TestPlugin2_math::test_inline_math_001", + "tests/test_plugins.py::TestPlugin1_ruby::test_ruby_splits_001", + "tests/test_plugins.py::TestPlugin1_ruby::test_ruby_splits_002", + "tests/test_plugins.py::TestPlugin1_ruby::test_ruby_with_link_001", + "tests/test_plugins.py::TestPlugin1_ruby::test_ruby_with_link_002", + "tests/test_plugins.py::TestPlugin1_ruby::test_ruby_with_link_003", + "tests/test_plugins.py::TestPlugin1_ruby::test_ruby_without_link_001", + "tests/test_plugins.py::TestPlugin1_ruby::test_ruby_without_link_002", + "tests/test_plugins.py::TestPlugin1_ruby::test_ruby_without_link_003", + "tests/test_plugins.py::TestPlugin1_ruby::test_ruby_without_link_004", + "tests/test_plugins.py::TestPlugin2_ruby::test_ruby_splits_001", + "tests/test_plugins.py::TestPlugin2_ruby::test_ruby_splits_002", + "tests/test_plugins.py::TestPlugin2_ruby::test_ruby_with_link_001", + "tests/test_plugins.py::TestPlugin2_ruby::test_ruby_with_link_002", + "tests/test_plugins.py::TestPlugin2_ruby::test_ruby_with_link_003", + "tests/test_plugins.py::TestPlugin2_ruby::test_ruby_without_link_001", + "tests/test_plugins.py::TestPlugin2_ruby::test_ruby_without_link_002", + "tests/test_plugins.py::TestPlugin2_ruby::test_ruby_without_link_003", + "tests/test_plugins.py::TestPlugin2_ruby::test_ruby_without_link_004", + "tests/test_plugins.py::TestPlugin1_spoiler::test_block_spoiler_001", + "tests/test_plugins.py::TestPlugin1_spoiler::test_block_spoiler_002", + "tests/test_plugins.py::TestPlugin1_spoiler::test_block_spoiler_003", + "tests/test_plugins.py::TestPlugin1_spoiler::test_block_spoiler_004", + "tests/test_plugins.py::TestPlugin1_spoiler::test_block_spoiler_005", + "tests/test_plugins.py::TestPlugin1_spoiler::test_inline_spoiler_001", + "tests/test_plugins.py::TestPlugin1_spoiler::test_inline_spoiler_002", + "tests/test_plugins.py::TestPlugin1_spoiler::test_inline_spoiler_003", + "tests/test_plugins.py::TestPlugin2_spoiler::test_block_spoiler_001", + "tests/test_plugins.py::TestPlugin2_spoiler::test_block_spoiler_002", + "tests/test_plugins.py::TestPlugin2_spoiler::test_block_spoiler_003", + "tests/test_plugins.py::TestPlugin2_spoiler::test_block_spoiler_004", + "tests/test_plugins.py::TestPlugin2_spoiler::test_block_spoiler_005", + "tests/test_plugins.py::TestPlugin2_spoiler::test_inline_spoiler_001", + "tests/test_plugins.py::TestPlugin2_spoiler::test_inline_spoiler_002", + "tests/test_plugins.py::TestPlugin2_spoiler::test_inline_spoiler_003", + "tests/test_plugins.py::TestExtraPlugins::test_math_in_list", + "tests/test_plugins.py::TestExtraPlugins::test_math_in_quote", + "tests/test_plugins.py::TestExtraPlugins::test_table_in_list", + "tests/test_plugins.py::TestExtraPlugins::test_table_in_quote", + "tests/test_renderers.py::TestRendererRst::test_code_001", + "tests/test_renderers.py::TestRendererRst::test_code_002", + "tests/test_renderers.py::TestRendererRst::test_heading_001", + "tests/test_renderers.py::TestRendererRst::test_html_001", + "tests/test_renderers.py::TestRendererRst::test_images_001", + "tests/test_renderers.py::TestRendererRst::test_images_002", + "tests/test_renderers.py::TestRendererRst::test_images_003", + "tests/test_renderers.py::TestRendererRst::test_inline_001", + "tests/test_renderers.py::TestRendererRst::test_inline_002", + "tests/test_renderers.py::TestRendererRst::test_line_break_001", + "tests/test_renderers.py::TestRendererRst::test_links_001", + "tests/test_renderers.py::TestRendererRst::test_list_001", + "tests/test_renderers.py::TestRendererRst::test_list_002", + "tests/test_renderers.py::TestRendererRst::test_list_003", + "tests/test_renderers.py::TestRendererRst::test_list_004", + "tests/test_renderers.py::TestRendererRst::test_list_005", + "tests/test_renderers.py::TestRendererRst::test_quote_001", + "tests/test_renderers.py::TestRendererRst::test_quote_002", + "tests/test_renderers.py::TestRendererRst::test_quote_003", + "tests/test_renderers.py::TestRendererRst::test_thematic_break_001", + "tests/test_syntax.py::TestSyntax::test_emphasis_001", + "tests/test_syntax.py::TestSyntax::test_image_001", + "tests/test_syntax.py::TestSyntax::test_link_001", + "tests/test_syntax.py::TestSyntax::test_link_002", + "tests/test_syntax.py::TestSyntax::test_link_003", + "tests/test_syntax.py::TestSyntax::test_links_001", + "tests/test_syntax.py::TestSyntax::test_links_002", + "tests/test_syntax.py::TestSyntax::test_max_depth_001", + "tests/test_syntax.py::TestSyntax::test_max_depth_002", + "tests/test_syntax.py::TestSyntax::test_non_aggressive_emphasis_001", + "tests/test_syntax.py::TestSyntax::test_non_aggressive_emphasis_002", + "tests/test_syntax.py::TestSyntax::test_non_aggressive_emphasis_003", + "tests/test_syntax.py::TestSyntax::test_setext_headings_001", + "tests/test_syntax.py::TestSyntax::test_setext_headings_002" + ], + "all_git_blobs_modes_verified": true, + "cloud_launch_ready": false, + "commits": { + "bug": "cacf6ca5378e5c94b593438f18c03c27dce261dd", + "healthy": "62750c95db25a8fb93dda09242f64e07508d9231", + "learner": "b518b74b82af6ee0b45f46747be1868faab2eefc" + }, + "existing_squirrel_snapshot_reused": false, + "full_transfer_allowlist": [ + "/testbed/.editorconfig", + "/testbed/.github/FUNDING.yml", + "/testbed/.gitignore", + "/testbed/.readthedocs.yaml", + "/testbed/BACKERS.md", + "/testbed/LICENSE", + "/testbed/MANIFEST.in", + "/testbed/Makefile", + "/testbed/README.md", + "/testbed/README.rst", + "/testbed/benchmark/bench.py", + "/testbed/benchmark/cases/atx.txt", + "/testbed/benchmark/cases/auto_links.txt", + "/testbed/benchmark/cases/blockcode.txt", + "/testbed/benchmark/cases/blockhtml.txt", + "/testbed/benchmark/cases/blockquote.txt", + "/testbed/benchmark/cases/emphasis.txt", + "/testbed/benchmark/cases/fenced.txt", + "/testbed/benchmark/cases/insane_ol.txt", + "/testbed/benchmark/cases/insane_ul.txt", + "/testbed/benchmark/cases/normal_ol.txt", + "/testbed/benchmark/cases/normal_ul.txt", + "/testbed/benchmark/cases/paragraph.txt", + "/testbed/benchmark/cases/ref_links.txt", + "/testbed/benchmark/cases/setext.txt", + "/testbed/benchmark/cases/std_links.txt", + "/testbed/docs/Makefile", + "/testbed/docs/_static/dark-icon.svg", + "/testbed/docs/_static/light-icon.svg", + "/testbed/docs/_static/logo-black.svg", + "/testbed/docs/_static/logo-white.svg", + "/testbed/docs/_templates/partials/globaltoc-above.html", + "/testbed/docs/advanced.rst", + "/testbed/docs/api.rst", + "/testbed/docs/changes.rst", + "/testbed/docs/cli.rst", + "/testbed/docs/community.rst", + "/testbed/docs/conf.py", + "/testbed/docs/directives.rst", + "/testbed/docs/guide.rst", + "/testbed/docs/index.rst", + "/testbed/docs/plugins.rst", + "/testbed/docs/renderers.rst", + "/testbed/docs/requirements.txt", + "/testbed/docs/upgrade.rst", + "/testbed/pyproject.toml", + "/testbed/serve-doc.py", + "/testbed/setup.py", + "/testbed/src/mistune/__init__.py", + "/testbed/src/mistune/__main__.py", + "/testbed/src/mistune/block_parser.py", + "/testbed/src/mistune/core.py", + "/testbed/src/mistune/directives/__init__.py", + "/testbed/src/mistune/directives/_base.py", + "/testbed/src/mistune/directives/_fenced.py", + "/testbed/src/mistune/directives/_rst.py", + "/testbed/src/mistune/directives/admonition.py", + "/testbed/src/mistune/directives/image.py", + "/testbed/src/mistune/directives/include.py", + "/testbed/src/mistune/directives/toc.py", + "/testbed/src/mistune/helpers.py", + "/testbed/src/mistune/inline_parser.py", + "/testbed/src/mistune/list_parser.py", + "/testbed/src/mistune/markdown.py", + "/testbed/src/mistune/plugins/__init__.py", + "/testbed/src/mistune/plugins/abbr.py", + "/testbed/src/mistune/plugins/def_list.py", + "/testbed/src/mistune/plugins/footnotes.py", + "/testbed/src/mistune/plugins/formatting.py", + "/testbed/src/mistune/plugins/math.py", + "/testbed/src/mistune/plugins/ruby.py", + "/testbed/src/mistune/plugins/speedup.py", + "/testbed/src/mistune/plugins/spoiler.py", + "/testbed/src/mistune/plugins/table.py", + "/testbed/src/mistune/plugins/task_lists.py", + "/testbed/src/mistune/plugins/url.py", + "/testbed/src/mistune/py.typed", + "/testbed/src/mistune/renderers/__init__.py", + "/testbed/src/mistune/renderers/_list.py", + "/testbed/src/mistune/renderers/html.py", + "/testbed/src/mistune/renderers/markdown.py", + "/testbed/src/mistune/renderers/rst.py", + "/testbed/src/mistune/toc.py", + "/testbed/src/mistune/util.py", + "/testbed/tests/__init__.py", + "/testbed/tests/fixtures/__init__.py", + "/testbed/tests/fixtures/abbr.txt", + "/testbed/tests/fixtures/commonmark.json", + "/testbed/tests/fixtures/def_list.txt", + "/testbed/tests/fixtures/diff-commonmark.txt", + "/testbed/tests/fixtures/fenced_admonition.txt", + "/testbed/tests/fixtures/fenced_figure.txt", + "/testbed/tests/fixtures/fenced_image.txt", + "/testbed/tests/fixtures/fenced_toc.txt", + "/testbed/tests/fixtures/fix-commonmark.txt", + "/testbed/tests/fixtures/footnotes.txt", + "/testbed/tests/fixtures/hook_toc.txt", + "/testbed/tests/fixtures/include/hello.md", + "/testbed/tests/fixtures/include/hello.txt", + "/testbed/tests/fixtures/include/text.html", + "/testbed/tests/fixtures/include/text.md", + "/testbed/tests/fixtures/insert.txt", + "/testbed/tests/fixtures/mark.txt", + "/testbed/tests/fixtures/math.txt", + "/testbed/tests/fixtures/renderer_markdown.txt", + "/testbed/tests/fixtures/renderer_rst.txt", + "/testbed/tests/fixtures/rst_admonition.txt", + "/testbed/tests/fixtures/rst_toc.txt", + "/testbed/tests/fixtures/ruby.txt", + "/testbed/tests/fixtures/spoiler.txt", + "/testbed/tests/fixtures/strikethrough.txt", + "/testbed/tests/fixtures/subscript.txt", + "/testbed/tests/fixtures/superscript.txt", + "/testbed/tests/fixtures/table.txt", + "/testbed/tests/fixtures/task_lists.txt", + "/testbed/tests/fixtures/url.txt", + "/testbed/tests/test_commonmark.py", + "/testbed/tests/test_directives.py", + "/testbed/tests/test_hooks.py", + "/testbed/tests/test_misc.py", + "/testbed/tests/test_plugins.py", + "/testbed/tests/test_syntax.py" + ], + "healthy_stage_meaning": "Direct parent of the mutation; no source or test execution has been performed", + "mutation_matches_dataset_and_git_blobs": true, + "official_profile": { + "eval_sets": [], + "profile_class": "MistuneBf54ef67", + "profile_lines": [ + 570, + 573 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "bf54ef67390e02a5cdee7495d4386d7770c1902b", + "upstream_repo": "lepture/mistune" + }, + "original_source_commit": "bf54ef67390e02a5cdee7495d4386d7770c1902b", + "private_test_paths": [ + "tests/test_renderers.py" + ], + "private_tests_unchanged": true, + "profile_mapping_basis": "Explicit upstream repo and full commit fields parsed from pinned official Python profile AST, not basename inference", + "qwen_calibrated": false, + "runtime_qualified": false, + "source_paths": [ + "src/mistune/renderers/markdown.py" + ], + "source_repo": "swesmith/lepture__mistune.bf54ef67", + "source_stages_bytes": 1361569, + "task_id": "lepture__mistune.bf54ef67.combine_file__09mnfd6d", + "transfer_limitation": "Existing regular files only; new arbitrary file additions need a qualified patch adapter", + "upstream_repo": "lepture/mistune" + }, + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:lepture__mistune.bf54ef67.combine_file__09mnfd6d", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "62750c95db25a8fb93dda09242f64e07508d9231", + "instruction_sha256": "6616c3d34e23061b20b76f1ceb23c5d0c352eac17b00136bdd4aa5ef31df5f65", + "is_fork": true, + "learner_path": "tasks/49f581aadac1a5e1674af0ea/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "bf54ef67390e02a5cdee7495d4386d7770c1902b", + "actual_upstream_url": "https://raw.githubusercontent.com/lepture/mistune/bf54ef67390e02a5cdee7495d4386d7770c1902b/LICENSE", + "reviewed": true, + "sha256": "539013fd8e19f744f8bf0e27a532bbff54cd689ecef7a800f56ae5dc824be870", + "spdx": "BSD-3-Clause", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/lepture__mistune.bf54ef67/b518b74b82af6ee0b45f46747be1868faab2eefc/LICENSE" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "bf54ef67390e02a5cdee7495d4386d7770c1902b", + "patch_sha256": "62abb66efa04dbcc8bad4cc5aebb0db4533b312c057c330e6ce1e189b02110d9", + "provenance_path": "tasks/49f581aadac1a5e1674af0ea/source-proof.json", + "repository_lineage": [ + "swesmith/lepture__mistune.bf54ef67", + "lepture/mistune" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "b518b74b82af6ee0b45f46747be1868faab2eefc", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "cacf6ca5378e5c94b593438f18c03c27dce261dd", + "source_kind": "mutation", + "source_repo": "swesmith/lepture__mistune.bf54ef67", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "lepture__mistune.bf54ef67.combine_file__09mnfd6d", + "task_sha256": "804eb4fddea6abef0026d4b34aed7d4a41eee4565574056ebb804b63f6148cbb", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "lepture/mistune", + "usage": "quarantine_only" + }, + "task_kind": "original-source-mutation" +} diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/provenance.json b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/provenance.json new file mode 100644 index 0000000000000000000000000000000000000000..1647025b163e185ef8cd95616650d9186c6ebec6 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/provenance.json @@ -0,0 +1,88 @@ +{ + "generated_reference": false, + "healthy_reference_delta_sha256": "2ced3cead2857351deecc8b648a0c91dd94815a2ec6c59093aee133e6e4d013d", + "native_pytest_ids_preserved": true, + "original_source_code_license": { + "actual_upstream_commit": "bf54ef67390e02a5cdee7495d4386d7770c1902b", + "actual_upstream_url": "https://raw.githubusercontent.com/lepture/mistune/bf54ef67390e02a5cdee7495d4386d7770c1902b/LICENSE", + "reviewed": true, + "sha256": "539013fd8e19f744f8bf0e27a532bbff54cd689ecef7a800f56ae5dc824be870", + "spdx": "BSD-3-Clause", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/lepture__mistune.bf54ef67/b518b74b82af6ee0b45f46747be1868faab2eefc/LICENSE" + }, + "provided_reference": true, + "qwen_calibrated": false, + "runtime_qualified": false, + "source_completion_sha256": "09d8ec6381d1f71ae819d0da5512bf9d3aef843516c81a5d18e494977844086e", + "source_index_sha256": "e856874b9410fce9f3bfea52c8c482e84b3e43942d87517f8b55f0034bd40f6f", + "source_proof_sha256": "c808a325fabfed1453c0b9e942b7da0d31ad461ea7a03e0fceadfb73eb757f00", + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:lepture__mistune.bf54ef67.combine_file__09mnfd6d", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "62750c95db25a8fb93dda09242f64e07508d9231", + "instruction_sha256": "6616c3d34e23061b20b76f1ceb23c5d0c352eac17b00136bdd4aa5ef31df5f65", + "is_fork": true, + "learner_path": "tasks/49f581aadac1a5e1674af0ea/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "bf54ef67390e02a5cdee7495d4386d7770c1902b", + "actual_upstream_url": "https://raw.githubusercontent.com/lepture/mistune/bf54ef67390e02a5cdee7495d4386d7770c1902b/LICENSE", + "reviewed": true, + "sha256": "539013fd8e19f744f8bf0e27a532bbff54cd689ecef7a800f56ae5dc824be870", + "spdx": "BSD-3-Clause", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/lepture__mistune.bf54ef67/b518b74b82af6ee0b45f46747be1868faab2eefc/LICENSE" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "bf54ef67390e02a5cdee7495d4386d7770c1902b", + "patch_sha256": "62abb66efa04dbcc8bad4cc5aebb0db4533b312c057c330e6ce1e189b02110d9", + "provenance_path": "tasks/49f581aadac1a5e1674af0ea/source-proof.json", + "repository_lineage": [ + "swesmith/lepture__mistune.bf54ef67", + "lepture/mistune" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "b518b74b82af6ee0b45f46747be1868faab2eefc", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "cacf6ca5378e5c94b593438f18c03c27dce261dd", + "source_kind": "mutation", + "source_repo": "swesmith/lepture__mistune.bf54ef67", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "lepture__mistune.bf54ef67.combine_file__09mnfd6d", + "task_sha256": "804eb4fddea6abef0026d4b34aed7d4a41eee4565574056ebb804b63f6148cbb", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "lepture/mistune", + "usage": "quarantine_only" + }, + "task_bundle_license": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + }, + "training_admissible": false, + "trusted_tests_sha256": "cb345067f46bf3d3e7a60b2963e26cee25fe8aae6cd4a620d05e02f799d96fca" +} diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/provided-gold.diff b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/provided-gold.diff new file mode 100644 index 0000000000000000000000000000000000000000..7c4e03dd587e66fa1b163dd023ebd65040e82af6 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/provided-gold.diff @@ -0,0 +1,27 @@ +diff --git a/src/mistune/renderers/markdown.py b/src/mistune/renderers/markdown.py +index 8641a37a792d460b3471bfb613a0ea491f289585..b49081a77562b601235716b6051537686acf5b77 100644 +--- a/src/mistune/renderers/markdown.py ++++ b/src/mistune/renderers/markdown.py +@@ -14,10 +14,10 @@ + NAME = 'markdown' + + def __call__(self, tokens: Iterable[Dict[str, Any]], state: BlockState) -> str: +- out = self.render_tokens(state, tokens) ++ out = self.render_tokens(tokens, state) + # special handle for line breaks +- out += '\n'.join(self.render_referrences(state)) +- return out.strip() ++ out += '\n\n'.join(self.render_referrences(state)) + '\n' ++ return strip_end(out) + + def render_referrences(self, state: BlockState) -> Iterable[str]: + ref_links = state.env['ref_links'] +@@ -98,7 +98,7 @@ + return '***\n\n' + + def block_text(self, token: Dict[str, Any], state: BlockState) -> str: +- return '\n' + self.render_children(token, state) ++ return self.render_children(token, state) + '\n' + + def block_code(self, token: Dict[str, Any], state: BlockState) -> str: + attrs = token.get("attrs", {}) diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/solution/solve.sh b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..f88b8384b821e6e0f9b7dc8e26b46d3a1af5be3f --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/solution/solve.sh @@ -0,0 +1,33 @@ +#!/bin/bash +set -Eeuo pipefail +cd /testbed/repo +cat > /tmp/openenv-reference.diff <<'OPENENV_REFERENCE' +diff --git a/src/mistune/renderers/markdown.py b/src/mistune/renderers/markdown.py +index 8641a37a792d460b3471bfb613a0ea491f289585..b49081a77562b601235716b6051537686acf5b77 100644 +--- a/src/mistune/renderers/markdown.py ++++ b/src/mistune/renderers/markdown.py +@@ -14,10 +14,10 @@ + NAME = 'markdown' + + def __call__(self, tokens: Iterable[Dict[str, Any]], state: BlockState) -> str: +- out = self.render_tokens(state, tokens) ++ out = self.render_tokens(tokens, state) + # special handle for line breaks +- out += '\n'.join(self.render_referrences(state)) +- return out.strip() ++ out += '\n\n'.join(self.render_referrences(state)) + '\n' ++ return strip_end(out) + + def render_referrences(self, state: BlockState) -> Iterable[str]: + ref_links = state.env['ref_links'] +@@ -98,7 +98,7 @@ + return '***\n\n' + + def block_text(self, token: Dict[str, Any], state: BlockState) -> str: +- return '\n' + self.render_children(token, state) ++ return self.render_children(token, state) + '\n' + + def block_code(self, token: Dict[str, Any], state: BlockState) -> str: + attrs = token.get("attrs", {}) +OPENENV_REFERENCE +/usr/bin/git -c core.hooksPath=/dev/null -c core.fsmonitor=false apply --whitespace=nowarn /tmp/openenv-reference.diff diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/task.toml b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..fa66cb1e6a4999cacf71948dfa4099bc6d67fa63 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/task.toml @@ -0,0 +1,24 @@ +version = "1.0" + +[agent] +timeout_sec = 1800.0 + +[verifier] +timeout_sec = 900.0 + +[environment] +docker_image = "ghcr.io/younesbelkada/scale800@sha256:462fcf35c9650ea1846a7683f96cf6e55a5e8892c262bab964750d07372a6503" +build_timeout_sec = 600.0 +cpus = 2 +memory_mb = 8192 +storage_mb = 16384 + +[metadata] +author_name = "SWE-smith source adapter" +category = "bugfix" +tags = ["swe", "python", "mutation-repair"] + +[environment.env] +# The image's PATH with the testbed env first: the project and pytest are installed there, and the agent's +# non-interactive shells never run `conda activate` +PATH = "/opt/miniconda3/envs/testbed/bin:/opt/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/check_pytest.py b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/check_pytest.py new file mode 100644 index 0000000000000000000000000000000000000000..7abfdc5972f57ca7f0cecbbeeb373414670f780e --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/check_pytest.py @@ -0,0 +1,177 @@ +"""Preserve confirmed requested assertion failures; keep positive checks strict.""" + +import argparse +import hashlib +import json +import re +import xml.etree.ElementTree as ET +from pathlib import Path + +GROUPS = ("pass-to-pass", "fail-to-pass") + + +def split_nodeid(target): + prefix, bracket, parameter = target.partition("[") + parts = prefix.split("::") + if bracket: + parts[-1] += bracket + parameter + return parts + + +def matches(case, target): + parts = split_nodeid(target) + module = parts[0].removesuffix(".py").replace("/", ".") + classname, name = case.get("classname", ""), case.get("name", "") + if not (classname == module or classname.startswith(module + ".")): + return False + selector = parts[-1] if len(parts) > 1 else "" + classes = parts[1:-1] + if classes and classname != module + "." + ".".join(classes): + return False + return ( + not selector + or name == selector + or ("[" not in selector and name.startswith(selector + "[")) + ) + + +def capture_panels(root): + panels, digests = {}, {} + for group in GROUPS: + path = Path(root) / (group + ".xml") + if not path.exists(): + panels[group] = None + continue + with path.open("rb") as stream: + raw = stream.read(4 * 1024**2 + 1) + if not 0 < len(raw) <= 4 * 1024**2 or re.search( + rb" 20000: + raise ValueError("Too many pytest cases") + identities = [(case.get("classname"), case.get("name")) for case in cases] + if len(identities) != len(set(identities)): + raise ValueError("Duplicate pytest case evidence") + panels[group] = cases + digests[group] = hashlib.sha256(raw).hexdigest() + return panels, digests + + +def strict_assess(panels, expected, native_exit): + """The original positive-approval conditions, applied to captured cases.""" + all_cases, actual_failure = [], False + for group in GROUPS: + cases = panels[group] + if cases is None: + if actual_failure: + continue + raise ValueError("Missing preceding pytest panel") + if actual_failure: + raise ValueError( + "Pytest evidence continued after the native stop-on-failure" + ) + targets = expected[group] + if any(not any(matches(case, target) for target in targets) for case in cases): + raise ValueError("Unexpected pytest case") + all_cases.extend(cases) + failures = [case for case in cases if case.find("failure") is not None] + if any( + case.find("error") is not None or case.find("skipped") is not None + for case in cases + ): + raise ValueError("Pytest collection/error/skip is not a completed panel") + actual_failure = actual_failure or bool(failures) + if not failures and any( + not any(matches(case, target) for case in cases) for target in targets + ): + raise ValueError("Declared pytest target never ran") + if actual_failure: + if native_exit == 0: + raise ValueError("Native verifier exit disagrees with pytest failure") + return {"reward": 0, "valid_test_failure": True, "cases": len(all_cases)} + if native_exit != 0: + raise ValueError("Setup or native verifier failed without a real test failure") + if any(panels[group] is None for group in GROUPS): + raise ValueError("Missing completed pytest panel") + return {"reward": 1, "valid_test_failure": False, "cases": len(all_cases)} + + +def assess(root, expected, native_exit): + if type(native_exit) is not int: + raise ValueError("Native verifier exit must be an integer") + if not isinstance(expected, dict) or any( + not isinstance(expected.get(group), list) + or not expected[group] + or any(not isinstance(target, str) or not target for target in expected[group]) + for group in GROUPS + ): + raise ValueError("Complete exact native pytest targets required") + panels, digests = capture_panels(root) + counts = { + "cases": 0, + "matched_failures": 0, + "unexpected_cases": 0, + "unmatched_failures": 0, + "skipped_cases": 0, + "error_cases": 0, + "missing_panels": 0, + "missing_targets": 0, + } + for group in GROUPS: + cases = panels[group] + if cases is None: + counts["missing_panels"] += 1 + counts["missing_targets"] += len(expected[group]) + continue + counts["cases"] += len(cases) + for case in cases: + requested = any(matches(case, target) for target in expected[group]) + failure = case.find("failure") is not None + counts["matched_failures"] += int(requested and failure) + counts["unmatched_failures"] += int(not requested and failure) + counts["unexpected_cases"] += int(not requested) + counts["skipped_cases"] += int(case.find("skipped") is not None) + counts["error_cases"] += int(case.find("error") is not None) + counts["missing_targets"] += sum( + not any(matches(case, target) for case in cases) + for target in expected[group] + ) + if counts["matched_failures"]: + if native_exit == 0: + raise ValueError( + "Native verifier exit disagrees with requested pytest failure" + ) + return { + "reward": 0, + "valid_test_failure": True, + "cases": counts["cases"], + "diagnostic_counts": counts, + "panel_sha256": digests, + "decision": "confirmed_requested_failure_precedence", + } + result = strict_assess(panels, expected, native_exit) + result.update(diagnostic_counts=counts, panel_sha256=digests) + return result + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("--root", required=True) + parser.add_argument("--expected", required=True) + parser.add_argument("--native-exit", type=int, required=True) + args = parser.parse_args() + result = assess( + args.root, json.loads(Path(args.expected).read_bytes()), args.native_exit + ) + reward = Path(args.root) / "reward.txt" + if reward.read_text().strip() != str(result["reward"]): + raise ValueError("Native raw reward disagrees with pytest evidence") + (Path(args.root) / "pytest-evidence.json").write_text( + json.dumps(result, sort_keys=True) + "\n" + ) diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/expected-panels.json b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/expected-panels.json new file mode 100644 index 0000000000000000000000000000000000000000..31de3f8a0c13202c8c0809500505c80dcc386b10 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/expected-panels.json @@ -0,0 +1,951 @@ +{ + "fail-to-pass": [ + "tests/test_renderers.py::TestRendererMarkdown::test_code_001", + "tests/test_renderers.py::TestRendererMarkdown::test_code_002", + "tests/test_renderers.py::TestRendererMarkdown::test_code_003", + "tests/test_renderers.py::TestRendererMarkdown::test_code_004", + "tests/test_renderers.py::TestRendererMarkdown::test_code_005", + "tests/test_renderers.py::TestRendererMarkdown::test_heading_001", + "tests/test_renderers.py::TestRendererMarkdown::test_html_001", + "tests/test_renderers.py::TestRendererMarkdown::test_images_001", + "tests/test_renderers.py::TestRendererMarkdown::test_inline_001", + "tests/test_renderers.py::TestRendererMarkdown::test_linebreak_001", + "tests/test_renderers.py::TestRendererMarkdown::test_links_001", + "tests/test_renderers.py::TestRendererMarkdown::test_links_002", + "tests/test_renderers.py::TestRendererMarkdown::test_links_003", + "tests/test_renderers.py::TestRendererMarkdown::test_list_001", + "tests/test_renderers.py::TestRendererMarkdown::test_list_002", + "tests/test_renderers.py::TestRendererMarkdown::test_list_003", + "tests/test_renderers.py::TestRendererMarkdown::test_list_004", + "tests/test_renderers.py::TestRendererMarkdown::test_list_005", + "tests/test_renderers.py::TestRendererMarkdown::test_list_006", + "tests/test_renderers.py::TestRendererMarkdown::test_quote_001", + "tests/test_renderers.py::TestRendererMarkdown::test_quote_002", + "tests/test_renderers.py::TestRendererMarkdown::test_thematic_break_001" + ], + "pass-to-pass": [ + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_062", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_063", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_064", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_065", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_066", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_067", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_068", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_069", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_070", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_071", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_072", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_073", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_074", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_075", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_076", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_077", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_078", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_079", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_593", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_594", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_595", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_596", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_597", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_598", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_599", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_600", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_601", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_602", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_603", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_604", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_605", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_606", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_607", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_608", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_609", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_610", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_611", + "tests/test_commonmark.py::TestCommonMark::test_backslash_escapes_012", + "tests/test_commonmark.py::TestCommonMark::test_backslash_escapes_013", + "tests/test_commonmark.py::TestCommonMark::test_backslash_escapes_014", + "tests/test_commonmark.py::TestCommonMark::test_backslash_escapes_015", + "tests/test_commonmark.py::TestCommonMark::test_backslash_escapes_016", + "tests/test_commonmark.py::TestCommonMark::test_backslash_escapes_017", + "tests/test_commonmark.py::TestCommonMark::test_backslash_escapes_018", + "tests/test_commonmark.py::TestCommonMark::test_backslash_escapes_019", + "tests/test_commonmark.py::TestCommonMark::test_backslash_escapes_020", + "tests/test_commonmark.py::TestCommonMark::test_backslash_escapes_021", + "tests/test_commonmark.py::TestCommonMark::test_backslash_escapes_022", + "tests/test_commonmark.py::TestCommonMark::test_backslash_escapes_023", + "tests/test_commonmark.py::TestCommonMark::test_backslash_escapes_024", + "tests/test_commonmark.py::TestCommonMark::test_blank_lines_227", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_228", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_229", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_230", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_231", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_232", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_233", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_234", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_235", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_236", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_237", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_238", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_239", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_240", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_241", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_242", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_243", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_244", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_245", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_246", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_247", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_248", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_249", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_250", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_251", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_252", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_328", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_329", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_330", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_331", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_332", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_333", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_334", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_335", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_336", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_337", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_338", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_339", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_340", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_341", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_342", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_343", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_344", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_345", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_346", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_347", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_348", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_349", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_350", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_351", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_353", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_354", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_355", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_356", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_357", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_358", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_359", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_360", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_361", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_362", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_363", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_364", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_365", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_366", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_369", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_370", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_371", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_373", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_374", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_375", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_376", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_377", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_378", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_380", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_381", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_382", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_383", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_384", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_385", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_386", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_387", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_389", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_390", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_392", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_393", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_394", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_395", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_396", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_397", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_398", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_399", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_400", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_401", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_402", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_403", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_404", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_405", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_409", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_410", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_411", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_415", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_419", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_420", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_421", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_422", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_423", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_427", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_428", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_432", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_433", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_434", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_435", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_436", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_437", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_438", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_439", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_440", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_447", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_448", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_449", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_450", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_451", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_452", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_459", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_461", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_466", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_468", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_469", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_472", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_473", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_474", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_475", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_476", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_479", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_480", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_025", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_026", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_027", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_028", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_029", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_030", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_031", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_032", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_033", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_034", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_035", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_036", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_037", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_038", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_039", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_040", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_041", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_119", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_120", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_121", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_122", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_123", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_124", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_125", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_126", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_127", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_128", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_129", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_130", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_131", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_132", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_133", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_134", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_135", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_136", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_137", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_138", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_139", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_140", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_141", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_142", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_143", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_144", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_145", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_146", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_147", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_633", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_634", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_635", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_636", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_637", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_638", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_639", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_640", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_641", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_642", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_643", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_644", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_645", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_646", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_647", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_148", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_149", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_150", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_151", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_152", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_153", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_154", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_155", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_156", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_157", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_158", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_159", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_160", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_161", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_162", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_163", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_164", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_165", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_166", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_167", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_168", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_169", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_170", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_171", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_172", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_173", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_174", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_175", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_176", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_177", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_178", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_179", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_180", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_181", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_182", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_183", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_184", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_185", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_186", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_187", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_188", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_189", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_190", + "tests/test_commonmark.py::TestCommonMark::test_images_571", + "tests/test_commonmark.py::TestCommonMark::test_images_572", + "tests/test_commonmark.py::TestCommonMark::test_images_574", + "tests/test_commonmark.py::TestCommonMark::test_images_575", + "tests/test_commonmark.py::TestCommonMark::test_images_576", + "tests/test_commonmark.py::TestCommonMark::test_images_577", + "tests/test_commonmark.py::TestCommonMark::test_images_578", + "tests/test_commonmark.py::TestCommonMark::test_images_579", + "tests/test_commonmark.py::TestCommonMark::test_images_580", + "tests/test_commonmark.py::TestCommonMark::test_images_581", + "tests/test_commonmark.py::TestCommonMark::test_images_582", + "tests/test_commonmark.py::TestCommonMark::test_images_583", + "tests/test_commonmark.py::TestCommonMark::test_images_584", + "tests/test_commonmark.py::TestCommonMark::test_images_585", + "tests/test_commonmark.py::TestCommonMark::test_images_586", + "tests/test_commonmark.py::TestCommonMark::test_images_587", + "tests/test_commonmark.py::TestCommonMark::test_images_588", + "tests/test_commonmark.py::TestCommonMark::test_images_589", + "tests/test_commonmark.py::TestCommonMark::test_images_590", + "tests/test_commonmark.py::TestCommonMark::test_images_591", + "tests/test_commonmark.py::TestCommonMark::test_images_592", + "tests/test_commonmark.py::TestCommonMark::test_indented_code_blocks_107", + "tests/test_commonmark.py::TestCommonMark::test_indented_code_blocks_108", + "tests/test_commonmark.py::TestCommonMark::test_indented_code_blocks_109", + "tests/test_commonmark.py::TestCommonMark::test_indented_code_blocks_110", + "tests/test_commonmark.py::TestCommonMark::test_indented_code_blocks_111", + "tests/test_commonmark.py::TestCommonMark::test_indented_code_blocks_112", + "tests/test_commonmark.py::TestCommonMark::test_indented_code_blocks_113", + "tests/test_commonmark.py::TestCommonMark::test_indented_code_blocks_114", + "tests/test_commonmark.py::TestCommonMark::test_indented_code_blocks_115", + "tests/test_commonmark.py::TestCommonMark::test_indented_code_blocks_116", + "tests/test_commonmark.py::TestCommonMark::test_indented_code_blocks_117", + "tests/test_commonmark.py::TestCommonMark::test_indented_code_blocks_118", + "tests/test_commonmark.py::TestCommonMark::test_inlines_327", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_192", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_193", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_194", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_195", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_196", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_197", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_198", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_199", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_200", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_201", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_202", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_203", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_204", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_205", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_206", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_207", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_208", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_209", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_210", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_211", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_212", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_213", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_214", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_215", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_216", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_217", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_218", + "tests/test_commonmark.py::TestCommonMark::test_links_481", + "tests/test_commonmark.py::TestCommonMark::test_links_482", + "tests/test_commonmark.py::TestCommonMark::test_links_483", + "tests/test_commonmark.py::TestCommonMark::test_links_484", + "tests/test_commonmark.py::TestCommonMark::test_links_485", + "tests/test_commonmark.py::TestCommonMark::test_links_486", + "tests/test_commonmark.py::TestCommonMark::test_links_487", + "tests/test_commonmark.py::TestCommonMark::test_links_488", + "tests/test_commonmark.py::TestCommonMark::test_links_489", + "tests/test_commonmark.py::TestCommonMark::test_links_490", + "tests/test_commonmark.py::TestCommonMark::test_links_491", + "tests/test_commonmark.py::TestCommonMark::test_links_492", + "tests/test_commonmark.py::TestCommonMark::test_links_493", + "tests/test_commonmark.py::TestCommonMark::test_links_494", + "tests/test_commonmark.py::TestCommonMark::test_links_497", + "tests/test_commonmark.py::TestCommonMark::test_links_498", + "tests/test_commonmark.py::TestCommonMark::test_links_499", + "tests/test_commonmark.py::TestCommonMark::test_links_500", + "tests/test_commonmark.py::TestCommonMark::test_links_501", + "tests/test_commonmark.py::TestCommonMark::test_links_502", + "tests/test_commonmark.py::TestCommonMark::test_links_503", + "tests/test_commonmark.py::TestCommonMark::test_links_505", + "tests/test_commonmark.py::TestCommonMark::test_links_506", + "tests/test_commonmark.py::TestCommonMark::test_links_507", + "tests/test_commonmark.py::TestCommonMark::test_links_508", + "tests/test_commonmark.py::TestCommonMark::test_links_509", + "tests/test_commonmark.py::TestCommonMark::test_links_510", + "tests/test_commonmark.py::TestCommonMark::test_links_511", + "tests/test_commonmark.py::TestCommonMark::test_links_512", + "tests/test_commonmark.py::TestCommonMark::test_links_513", + "tests/test_commonmark.py::TestCommonMark::test_links_514", + "tests/test_commonmark.py::TestCommonMark::test_links_515", + "tests/test_commonmark.py::TestCommonMark::test_links_516", + "tests/test_commonmark.py::TestCommonMark::test_links_520", + "tests/test_commonmark.py::TestCommonMark::test_links_521", + "tests/test_commonmark.py::TestCommonMark::test_links_522", + "tests/test_commonmark.py::TestCommonMark::test_links_523", + "tests/test_commonmark.py::TestCommonMark::test_links_524", + "tests/test_commonmark.py::TestCommonMark::test_links_525", + "tests/test_commonmark.py::TestCommonMark::test_links_526", + "tests/test_commonmark.py::TestCommonMark::test_links_527", + "tests/test_commonmark.py::TestCommonMark::test_links_528", + "tests/test_commonmark.py::TestCommonMark::test_links_529", + "tests/test_commonmark.py::TestCommonMark::test_links_530", + "tests/test_commonmark.py::TestCommonMark::test_links_533", + "tests/test_commonmark.py::TestCommonMark::test_links_534", + "tests/test_commonmark.py::TestCommonMark::test_links_535", + "tests/test_commonmark.py::TestCommonMark::test_links_536", + "tests/test_commonmark.py::TestCommonMark::test_links_537", + "tests/test_commonmark.py::TestCommonMark::test_links_538", + "tests/test_commonmark.py::TestCommonMark::test_links_539", + "tests/test_commonmark.py::TestCommonMark::test_links_540", + "tests/test_commonmark.py::TestCommonMark::test_links_541", + "tests/test_commonmark.py::TestCommonMark::test_links_542", + "tests/test_commonmark.py::TestCommonMark::test_links_543", + "tests/test_commonmark.py::TestCommonMark::test_links_544", + "tests/test_commonmark.py::TestCommonMark::test_links_545", + "tests/test_commonmark.py::TestCommonMark::test_links_546", + "tests/test_commonmark.py::TestCommonMark::test_links_547", + "tests/test_commonmark.py::TestCommonMark::test_links_548", + "tests/test_commonmark.py::TestCommonMark::test_links_549", + "tests/test_commonmark.py::TestCommonMark::test_links_550", + "tests/test_commonmark.py::TestCommonMark::test_links_551", + "tests/test_commonmark.py::TestCommonMark::test_links_552", + "tests/test_commonmark.py::TestCommonMark::test_links_553", + "tests/test_commonmark.py::TestCommonMark::test_links_554", + "tests/test_commonmark.py::TestCommonMark::test_links_555", + "tests/test_commonmark.py::TestCommonMark::test_links_556", + "tests/test_commonmark.py::TestCommonMark::test_links_557", + "tests/test_commonmark.py::TestCommonMark::test_links_558", + "tests/test_commonmark.py::TestCommonMark::test_links_559", + "tests/test_commonmark.py::TestCommonMark::test_links_560", + "tests/test_commonmark.py::TestCommonMark::test_links_561", + "tests/test_commonmark.py::TestCommonMark::test_links_562", + "tests/test_commonmark.py::TestCommonMark::test_links_563", + "tests/test_commonmark.py::TestCommonMark::test_links_564", + "tests/test_commonmark.py::TestCommonMark::test_links_565", + "tests/test_commonmark.py::TestCommonMark::test_links_566", + "tests/test_commonmark.py::TestCommonMark::test_links_567", + "tests/test_commonmark.py::TestCommonMark::test_links_568", + "tests/test_commonmark.py::TestCommonMark::test_links_569", + "tests/test_commonmark.py::TestCommonMark::test_links_570", + "tests/test_commonmark.py::TestCommonMark::test_list_items_253", + "tests/test_commonmark.py::TestCommonMark::test_list_items_254", + "tests/test_commonmark.py::TestCommonMark::test_list_items_255", + "tests/test_commonmark.py::TestCommonMark::test_list_items_256", + "tests/test_commonmark.py::TestCommonMark::test_list_items_257", + "tests/test_commonmark.py::TestCommonMark::test_list_items_258", + "tests/test_commonmark.py::TestCommonMark::test_list_items_259", + "tests/test_commonmark.py::TestCommonMark::test_list_items_260", + "tests/test_commonmark.py::TestCommonMark::test_list_items_261", + "tests/test_commonmark.py::TestCommonMark::test_list_items_262", + "tests/test_commonmark.py::TestCommonMark::test_list_items_263", + "tests/test_commonmark.py::TestCommonMark::test_list_items_264", + "tests/test_commonmark.py::TestCommonMark::test_list_items_265", + "tests/test_commonmark.py::TestCommonMark::test_list_items_266", + "tests/test_commonmark.py::TestCommonMark::test_list_items_267", + "tests/test_commonmark.py::TestCommonMark::test_list_items_268", + "tests/test_commonmark.py::TestCommonMark::test_list_items_269", + "tests/test_commonmark.py::TestCommonMark::test_list_items_270", + "tests/test_commonmark.py::TestCommonMark::test_list_items_271", + "tests/test_commonmark.py::TestCommonMark::test_list_items_272", + "tests/test_commonmark.py::TestCommonMark::test_list_items_273", + "tests/test_commonmark.py::TestCommonMark::test_list_items_274", + "tests/test_commonmark.py::TestCommonMark::test_list_items_275", + "tests/test_commonmark.py::TestCommonMark::test_list_items_276", + "tests/test_commonmark.py::TestCommonMark::test_list_items_277", + "tests/test_commonmark.py::TestCommonMark::test_list_items_278", + "tests/test_commonmark.py::TestCommonMark::test_list_items_279", + "tests/test_commonmark.py::TestCommonMark::test_list_items_280", + "tests/test_commonmark.py::TestCommonMark::test_list_items_281", + "tests/test_commonmark.py::TestCommonMark::test_list_items_282", + "tests/test_commonmark.py::TestCommonMark::test_list_items_283", + "tests/test_commonmark.py::TestCommonMark::test_list_items_284", + "tests/test_commonmark.py::TestCommonMark::test_list_items_285", + "tests/test_commonmark.py::TestCommonMark::test_list_items_286", + "tests/test_commonmark.py::TestCommonMark::test_list_items_287", + "tests/test_commonmark.py::TestCommonMark::test_list_items_288", + "tests/test_commonmark.py::TestCommonMark::test_list_items_289", + "tests/test_commonmark.py::TestCommonMark::test_list_items_290", + "tests/test_commonmark.py::TestCommonMark::test_list_items_291", + "tests/test_commonmark.py::TestCommonMark::test_list_items_292", + "tests/test_commonmark.py::TestCommonMark::test_list_items_293", + "tests/test_commonmark.py::TestCommonMark::test_list_items_294", + "tests/test_commonmark.py::TestCommonMark::test_list_items_295", + "tests/test_commonmark.py::TestCommonMark::test_list_items_296", + "tests/test_commonmark.py::TestCommonMark::test_list_items_297", + "tests/test_commonmark.py::TestCommonMark::test_list_items_298", + "tests/test_commonmark.py::TestCommonMark::test_list_items_299", + "tests/test_commonmark.py::TestCommonMark::test_list_items_300", + "tests/test_commonmark.py::TestCommonMark::test_lists_301", + "tests/test_commonmark.py::TestCommonMark::test_lists_302", + "tests/test_commonmark.py::TestCommonMark::test_lists_303", + "tests/test_commonmark.py::TestCommonMark::test_lists_304", + "tests/test_commonmark.py::TestCommonMark::test_lists_305", + "tests/test_commonmark.py::TestCommonMark::test_lists_306", + "tests/test_commonmark.py::TestCommonMark::test_lists_307", + "tests/test_commonmark.py::TestCommonMark::test_lists_308", + "tests/test_commonmark.py::TestCommonMark::test_lists_309", + "tests/test_commonmark.py::TestCommonMark::test_lists_310", + "tests/test_commonmark.py::TestCommonMark::test_lists_311", + "tests/test_commonmark.py::TestCommonMark::test_lists_312", + "tests/test_commonmark.py::TestCommonMark::test_lists_313", + "tests/test_commonmark.py::TestCommonMark::test_lists_314", + "tests/test_commonmark.py::TestCommonMark::test_lists_315", + "tests/test_commonmark.py::TestCommonMark::test_lists_316", + "tests/test_commonmark.py::TestCommonMark::test_lists_317", + "tests/test_commonmark.py::TestCommonMark::test_lists_318", + "tests/test_commonmark.py::TestCommonMark::test_lists_319", + "tests/test_commonmark.py::TestCommonMark::test_lists_320", + "tests/test_commonmark.py::TestCommonMark::test_lists_321", + "tests/test_commonmark.py::TestCommonMark::test_lists_322", + "tests/test_commonmark.py::TestCommonMark::test_lists_323", + "tests/test_commonmark.py::TestCommonMark::test_lists_324", + "tests/test_commonmark.py::TestCommonMark::test_lists_325", + "tests/test_commonmark.py::TestCommonMark::test_lists_326", + "tests/test_commonmark.py::TestCommonMark::test_paragraphs_219", + "tests/test_commonmark.py::TestCommonMark::test_paragraphs_220", + "tests/test_commonmark.py::TestCommonMark::test_paragraphs_221", + "tests/test_commonmark.py::TestCommonMark::test_paragraphs_222", + "tests/test_commonmark.py::TestCommonMark::test_paragraphs_223", + "tests/test_commonmark.py::TestCommonMark::test_paragraphs_224", + "tests/test_commonmark.py::TestCommonMark::test_paragraphs_225", + "tests/test_commonmark.py::TestCommonMark::test_paragraphs_226", + "tests/test_commonmark.py::TestCommonMark::test_precedence_042", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_612", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_613", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_614", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_615", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_616", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_617", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_618", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_619", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_620", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_621", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_622", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_623", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_624", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_625", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_626", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_627", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_628", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_629", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_630", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_631", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_632", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_080", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_081", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_082", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_083", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_084", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_085", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_086", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_087", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_088", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_089", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_090", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_091", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_092", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_094", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_095", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_096", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_097", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_098", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_099", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_100", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_101", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_102", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_103", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_104", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_105", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_106", + "tests/test_commonmark.py::TestCommonMark::test_soft_line_breaks_648", + "tests/test_commonmark.py::TestCommonMark::test_soft_line_breaks_649", + "tests/test_commonmark.py::TestCommonMark::test_tabs_001", + "tests/test_commonmark.py::TestCommonMark::test_tabs_002", + "tests/test_commonmark.py::TestCommonMark::test_tabs_003", + "tests/test_commonmark.py::TestCommonMark::test_tabs_004", + "tests/test_commonmark.py::TestCommonMark::test_tabs_005", + "tests/test_commonmark.py::TestCommonMark::test_tabs_006", + "tests/test_commonmark.py::TestCommonMark::test_tabs_007", + "tests/test_commonmark.py::TestCommonMark::test_tabs_008", + "tests/test_commonmark.py::TestCommonMark::test_tabs_009", + "tests/test_commonmark.py::TestCommonMark::test_tabs_010", + "tests/test_commonmark.py::TestCommonMark::test_tabs_011", + "tests/test_commonmark.py::TestCommonMark::test_textual_content_650", + "tests/test_commonmark.py::TestCommonMark::test_textual_content_651", + "tests/test_commonmark.py::TestCommonMark::test_textual_content_652", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_043", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_044", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_045", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_046", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_047", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_048", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_049", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_050", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_051", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_052", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_053", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_054", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_055", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_056", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_057", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_058", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_059", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_060", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_061", + "tests/test_directives.py::TestDirective_rst_admonition::test_admonition_001", + "tests/test_directives.py::TestDirective_rst_admonition::test_admonition_002", + "tests/test_directives.py::TestDirective_rst_admonition::test_admonition_003", + "tests/test_directives.py::TestDirective_rst_admonition::test_admonition_004", + "tests/test_directives.py::TestDirective_rst_toc::test_collapse_toc_001", + "tests/test_directives.py::TestDirective_rst_toc::test_complex_001", + "tests/test_directives.py::TestDirective_rst_toc::test_html_in_heading_001", + "tests/test_directives.py::TestDirective_rst_toc::test_insane_001", + "tests/test_directives.py::TestDirective_rst_toc::test_insane_002", + "tests/test_directives.py::TestDirective_rst_toc::test_invalid_option_001", + "tests/test_directives.py::TestDirective_rst_toc::test_invalid_option_002", + "tests/test_directives.py::TestDirective_rst_toc::test_invalid_option_003", + "tests/test_directives.py::TestDirective_rst_toc::test_link_in_heading_001", + "tests/test_directives.py::TestDirective_rst_toc::test_no_toc_001", + "tests/test_directives.py::TestDirective_rst_toc::test_no_toc_002", + "tests/test_directives.py::TestDirective_rst_toc::test_simple_toc_001", + "tests/test_directives.py::TestDirective_fenced_admonition::test_admonition_001", + "tests/test_directives.py::TestDirective_fenced_admonition::test_admonition_002", + "tests/test_directives.py::TestDirective_fenced_admonition::test_admonition_003", + "tests/test_directives.py::TestDirective_fenced_admonition::test_admonition_004", + "tests/test_directives.py::TestDirective_fenced_admonition::test_admonition_005", + "tests/test_directives.py::TestDirective_fenced_admonition::test_admonition_006", + "tests/test_directives.py::TestDirective_fenced_admonition::test_admonition_007", + "tests/test_directives.py::TestDirective_fenced_admonition::test_admonition_008", + "tests/test_directives.py::TestDirective_fenced_toc::test_collapse_toc_001", + "tests/test_directives.py::TestDirective_fenced_toc::test_complex_001", + "tests/test_directives.py::TestDirective_fenced_toc::test_html_in_heading_001", + "tests/test_directives.py::TestDirective_fenced_toc::test_insane_001", + "tests/test_directives.py::TestDirective_fenced_toc::test_insane_002", + "tests/test_directives.py::TestDirective_fenced_toc::test_invalid_option_001", + "tests/test_directives.py::TestDirective_fenced_toc::test_invalid_option_002", + "tests/test_directives.py::TestDirective_fenced_toc::test_invalid_option_003", + "tests/test_directives.py::TestDirective_fenced_toc::test_link_in_heading_001", + "tests/test_directives.py::TestDirective_fenced_toc::test_no_toc_001", + "tests/test_directives.py::TestDirective_fenced_toc::test_no_toc_002", + "tests/test_directives.py::TestDirective_fenced_toc::test_simple_toc_001", + "tests/test_directives.py::TestDirective_fenced_image::test_align_options_001", + "tests/test_directives.py::TestDirective_fenced_image::test_align_options_002", + "tests/test_directives.py::TestDirective_fenced_image::test_all_options_001", + "tests/test_directives.py::TestDirective_fenced_image::test_alt_option_001", + "tests/test_directives.py::TestDirective_fenced_image::test_ampersand_in_source_001", + "tests/test_directives.py::TestDirective_fenced_image::test_ampersand_in_target_001", + "tests/test_directives.py::TestDirective_fenced_image::test_no_options_001", + "tests/test_directives.py::TestDirective_fenced_image::test_target_option_001", + "tests/test_directives.py::TestDirective_fenced_image::test_width_and_height_001", + "tests/test_directives.py::TestDirective_fenced_image::test_width_and_height_002", + "tests/test_directives.py::TestDirective_fenced_figure::test_align_options_001", + "tests/test_directives.py::TestDirective_fenced_figure::test_align_options_002", + "tests/test_directives.py::TestDirective_fenced_figure::test_all_options_001", + "tests/test_directives.py::TestDirective_fenced_figure::test_alt_option_001", + "tests/test_directives.py::TestDirective_fenced_figure::test_caption_001", + "tests/test_directives.py::TestDirective_fenced_figure::test_legend_001", + "tests/test_directives.py::TestDirective_fenced_figure::test_legend_002", + "tests/test_directives.py::TestDirective_fenced_figure::test_no_options_001", + "tests/test_directives.py::TestDirective_fenced_figure::test_target_option_001", + "tests/test_directives.py::TestDirective_fenced_figure::test_width_and_height_001", + "tests/test_directives.py::TestDirective_fenced_figure::test_width_and_height_002", + "tests/test_directives.py::TestDirective_fenced_figure::test_width_and_height_003", + "tests/test_directives.py::TestCustomizeToc::test_colon_fenced_toc", + "tests/test_directives.py::TestCustomizeToc::test_fenced_toc", + "tests/test_directives.py::TestCustomizeToc::test_rst_toc", + "tests/test_directives.py::TestDirectiveInclude::test_html_include", + "tests/test_directives.py::TestDirectiveInclude::test_include_missing_source", + "tests/test_hooks.py::TestTocHook::test_complex_toc_001", + "tests/test_hooks.py::TestTocHook::test_customize_heading_id_func", + "tests/test_hooks.py::TestTocHook::test_html_in_heading_001", + "tests/test_hooks.py::TestTocHook::test_insane_toc_001", + "tests/test_hooks.py::TestTocHook::test_insane_toc_002", + "tests/test_hooks.py::TestTocHook::test_link_in_heading_001", + "tests/test_hooks.py::TestTocHook::test_simple_toc_001", + "tests/test_misc.py::TestMiscCases::test_allow_data_protocols", + "tests/test_misc.py::TestMiscCases::test_allow_harmful_protocols", + "tests/test_misc.py::TestMiscCases::test_ast_output", + "tests/test_misc.py::TestMiscCases::test_ast_url", + "tests/test_misc.py::TestMiscCases::test_before_parse_hooks", + "tests/test_misc.py::TestMiscCases::test_emsp", + "tests/test_misc.py::TestMiscCases::test_escape_html", + "tests/test_misc.py::TestMiscCases::test_hard_wrap", + "tests/test_misc.py::TestMiscCases::test_harmful_links", + "tests/test_misc.py::TestMiscCases::test_html_tag_text_following_list", + "tests/test_misc.py::TestMiscCases::test_markdown_func", + "tests/test_misc.py::TestMiscCases::test_none", + "tests/test_misc.py::TestMiscCases::test_ref_link", + "tests/test_misc.py::TestMiscCases::test_use_plugin", + "tests/test_plugins.py::TestPlugin1_url::test_url_plugin_001", + "tests/test_plugins.py::TestPlugin1_url::test_url_plugin_002", + "tests/test_plugins.py::TestPlugin1_url::test_url_plugin_003", + "tests/test_plugins.py::TestPlugin2_url::test_url_plugin_001", + "tests/test_plugins.py::TestPlugin2_url::test_url_plugin_002", + "tests/test_plugins.py::TestPlugin2_url::test_url_plugin_003", + "tests/test_plugins.py::TestPlugin1_strikethrough::test_strikethrough_001", + "tests/test_plugins.py::TestPlugin1_strikethrough::test_strikethrough_002", + "tests/test_plugins.py::TestPlugin1_strikethrough::test_strikethrough_003", + "tests/test_plugins.py::TestPlugin1_strikethrough::test_strikethrough_004", + "tests/test_plugins.py::TestPlugin1_strikethrough::test_strikethrough_005", + "tests/test_plugins.py::TestPlugin1_strikethrough::test_strikethrough_006", + "tests/test_plugins.py::TestPlugin1_strikethrough::test_strikethrough_007", + "tests/test_plugins.py::TestPlugin2_strikethrough::test_strikethrough_001", + "tests/test_plugins.py::TestPlugin2_strikethrough::test_strikethrough_002", + "tests/test_plugins.py::TestPlugin2_strikethrough::test_strikethrough_003", + "tests/test_plugins.py::TestPlugin2_strikethrough::test_strikethrough_004", + "tests/test_plugins.py::TestPlugin2_strikethrough::test_strikethrough_005", + "tests/test_plugins.py::TestPlugin2_strikethrough::test_strikethrough_006", + "tests/test_plugins.py::TestPlugin2_strikethrough::test_strikethrough_007", + "tests/test_plugins.py::TestPlugin1_mark::test_escape_mark_001", + "tests/test_plugins.py::TestPlugin1_mark::test_escape_mark_002", + "tests/test_plugins.py::TestPlugin1_mark::test_mark_001", + "tests/test_plugins.py::TestPlugin1_mark::test_mark_link_001", + "tests/test_plugins.py::TestPlugin1_mark::test_mark_link_002", + "tests/test_plugins.py::TestPlugin1_mark::test_normal_mark_001", + "tests/test_plugins.py::TestPlugin1_mark::test_normal_mark_002", + "tests/test_plugins.py::TestPlugin1_mark::test_normal_mark_003", + "tests/test_plugins.py::TestPlugin1_mark::test_normal_mark_004", + "tests/test_plugins.py::TestPlugin2_mark::test_escape_mark_001", + "tests/test_plugins.py::TestPlugin2_mark::test_escape_mark_002", + "tests/test_plugins.py::TestPlugin2_mark::test_mark_001", + "tests/test_plugins.py::TestPlugin2_mark::test_mark_link_001", + "tests/test_plugins.py::TestPlugin2_mark::test_mark_link_002", + "tests/test_plugins.py::TestPlugin2_mark::test_normal_mark_001", + "tests/test_plugins.py::TestPlugin2_mark::test_normal_mark_002", + "tests/test_plugins.py::TestPlugin2_mark::test_normal_mark_003", + "tests/test_plugins.py::TestPlugin2_mark::test_normal_mark_004", + "tests/test_plugins.py::TestPlugin1_insert::test_escape_insert_001", + "tests/test_plugins.py::TestPlugin1_insert::test_escape_insert_002", + "tests/test_plugins.py::TestPlugin1_insert::test_insert_001", + "tests/test_plugins.py::TestPlugin1_insert::test_insert_link_001", + "tests/test_plugins.py::TestPlugin1_insert::test_insert_link_002", + "tests/test_plugins.py::TestPlugin1_insert::test_normal_insert_001", + "tests/test_plugins.py::TestPlugin1_insert::test_normal_insert_002", + "tests/test_plugins.py::TestPlugin1_insert::test_normal_insert_003", + "tests/test_plugins.py::TestPlugin1_insert::test_normal_insert_004", + "tests/test_plugins.py::TestPlugin2_insert::test_escape_insert_001", + "tests/test_plugins.py::TestPlugin2_insert::test_escape_insert_002", + "tests/test_plugins.py::TestPlugin2_insert::test_insert_001", + "tests/test_plugins.py::TestPlugin2_insert::test_insert_link_001", + "tests/test_plugins.py::TestPlugin2_insert::test_insert_link_002", + "tests/test_plugins.py::TestPlugin2_insert::test_normal_insert_001", + "tests/test_plugins.py::TestPlugin2_insert::test_normal_insert_002", + "tests/test_plugins.py::TestPlugin2_insert::test_normal_insert_003", + "tests/test_plugins.py::TestPlugin2_insert::test_normal_insert_004", + "tests/test_plugins.py::TestPlugin1_superscript::test_superscript_001", + "tests/test_plugins.py::TestPlugin1_superscript::test_superscript_002", + "tests/test_plugins.py::TestPlugin1_superscript::test_superscript_003", + "tests/test_plugins.py::TestPlugin1_superscript::test_superscript_004", + "tests/test_plugins.py::TestPlugin2_superscript::test_superscript_001", + "tests/test_plugins.py::TestPlugin2_superscript::test_superscript_002", + "tests/test_plugins.py::TestPlugin2_superscript::test_superscript_003", + "tests/test_plugins.py::TestPlugin2_superscript::test_superscript_004", + "tests/test_plugins.py::TestPlugin1_subscript::test_subscript_001", + "tests/test_plugins.py::TestPlugin1_subscript::test_subscript_002", + "tests/test_plugins.py::TestPlugin1_subscript::test_subscript_003", + "tests/test_plugins.py::TestPlugin1_subscript::test_subscript_004", + "tests/test_plugins.py::TestPlugin2_subscript::test_subscript_001", + "tests/test_plugins.py::TestPlugin2_subscript::test_subscript_002", + "tests/test_plugins.py::TestPlugin2_subscript::test_subscript_003", + "tests/test_plugins.py::TestPlugin2_subscript::test_subscript_004", + "tests/test_plugins.py::TestPlugin1_task_lists::test_task_lists_001", + "tests/test_plugins.py::TestPlugin1_task_lists::test_task_lists_002", + "tests/test_plugins.py::TestPlugin1_task_lists::test_task_lists_003", + "tests/test_plugins.py::TestPlugin1_task_lists::test_task_lists_004", + "tests/test_plugins.py::TestPlugin1_task_lists::test_task_lists_005", + "tests/test_plugins.py::TestPlugin1_task_lists::test_task_lists_006", + "tests/test_plugins.py::TestPlugin1_task_lists::test_task_lists_007", + "tests/test_plugins.py::TestPlugin1_task_lists::test_task_lists_008", + "tests/test_plugins.py::TestPlugin2_task_lists::test_task_lists_001", + "tests/test_plugins.py::TestPlugin2_task_lists::test_task_lists_002", + "tests/test_plugins.py::TestPlugin2_task_lists::test_task_lists_003", + "tests/test_plugins.py::TestPlugin2_task_lists::test_task_lists_004", + "tests/test_plugins.py::TestPlugin2_task_lists::test_task_lists_005", + "tests/test_plugins.py::TestPlugin2_task_lists::test_task_lists_006", + "tests/test_plugins.py::TestPlugin2_task_lists::test_task_lists_007", + "tests/test_plugins.py::TestPlugin2_task_lists::test_task_lists_008", + "tests/test_plugins.py::TestPlugin1_table::test_align_table_001", + "tests/test_plugins.py::TestPlugin1_table::test_align_table_002", + "tests/test_plugins.py::TestPlugin1_table::test_misc_table_001", + "tests/test_plugins.py::TestPlugin1_table::test_misc_table_002", + "tests/test_plugins.py::TestPlugin1_table::test_misc_table_003", + "tests/test_plugins.py::TestPlugin1_table::test_mismatch_length_001", + "tests/test_plugins.py::TestPlugin1_table::test_mismatch_length_002", + "tests/test_plugins.py::TestPlugin1_table::test_mismatch_length_003", + "tests/test_plugins.py::TestPlugin1_table::test_mismatch_length_004", + "tests/test_plugins.py::TestPlugin1_table::test_nptable_001", + "tests/test_plugins.py::TestPlugin1_table::test_table_001", + "tests/test_plugins.py::TestPlugin1_table::test_table_002", + "tests/test_plugins.py::TestPlugin2_table::test_align_table_001", + "tests/test_plugins.py::TestPlugin2_table::test_align_table_002", + "tests/test_plugins.py::TestPlugin2_table::test_misc_table_001", + "tests/test_plugins.py::TestPlugin2_table::test_misc_table_002", + "tests/test_plugins.py::TestPlugin2_table::test_misc_table_003", + "tests/test_plugins.py::TestPlugin2_table::test_mismatch_length_001", + "tests/test_plugins.py::TestPlugin2_table::test_mismatch_length_002", + "tests/test_plugins.py::TestPlugin2_table::test_mismatch_length_003", + "tests/test_plugins.py::TestPlugin2_table::test_mismatch_length_004", + "tests/test_plugins.py::TestPlugin2_table::test_nptable_001", + "tests/test_plugins.py::TestPlugin2_table::test_table_001", + "tests/test_plugins.py::TestPlugin2_table::test_table_002", + "tests/test_plugins.py::TestPlugin1_def_list::test_definition_lists_001", + "tests/test_plugins.py::TestPlugin1_def_list::test_definition_lists_002", + "tests/test_plugins.py::TestPlugin1_def_list::test_definition_lists_003", + "tests/test_plugins.py::TestPlugin1_def_list::test_definition_lists_004", + "tests/test_plugins.py::TestPlugin1_def_list::test_definition_lists_005", + "tests/test_plugins.py::TestPlugin1_def_list::test_definition_lists_006", + "tests/test_plugins.py::TestPlugin1_def_list::test_definition_with_multiple_lines_001", + "tests/test_plugins.py::TestPlugin1_def_list::test_definition_with_multiple_lines_002", + "tests/test_plugins.py::TestPlugin1_def_list::test_definition_with_multiple_lines_003", + "tests/test_plugins.py::TestPlugin1_def_list::test_definition_with_multiple_lines_004", + "tests/test_plugins.py::TestPlugin1_def_list::test_definition_with_multiple_lines_005", + "tests/test_plugins.py::TestPlugin2_def_list::test_definition_lists_001", + "tests/test_plugins.py::TestPlugin2_def_list::test_definition_lists_002", + "tests/test_plugins.py::TestPlugin2_def_list::test_definition_lists_003", + "tests/test_plugins.py::TestPlugin2_def_list::test_definition_lists_004", + "tests/test_plugins.py::TestPlugin2_def_list::test_definition_lists_005", + "tests/test_plugins.py::TestPlugin2_def_list::test_definition_lists_006", + "tests/test_plugins.py::TestPlugin2_def_list::test_definition_with_multiple_lines_001", + "tests/test_plugins.py::TestPlugin2_def_list::test_definition_with_multiple_lines_002", + "tests/test_plugins.py::TestPlugin2_def_list::test_definition_with_multiple_lines_003", + "tests/test_plugins.py::TestPlugin2_def_list::test_definition_with_multiple_lines_004", + "tests/test_plugins.py::TestPlugin2_def_list::test_definition_with_multiple_lines_005", + "tests/test_plugins.py::TestPlugin1_footnotes::test_footnotes_001", + "tests/test_plugins.py::TestPlugin1_footnotes::test_footnotes_002", + "tests/test_plugins.py::TestPlugin1_footnotes::test_footnotes_003", + "tests/test_plugins.py::TestPlugin2_footnotes::test_footnotes_001", + "tests/test_plugins.py::TestPlugin2_footnotes::test_footnotes_002", + "tests/test_plugins.py::TestPlugin2_footnotes::test_footnotes_003", + "tests/test_plugins.py::TestPlugin1_abbr::test_abbreviation_001", + "tests/test_plugins.py::TestPlugin1_abbr::test_abbreviation_002", + "tests/test_plugins.py::TestPlugin1_abbr::test_abbreviation_003", + "tests/test_plugins.py::TestPlugin1_abbr::test_abbreviation_004", + "tests/test_plugins.py::TestPlugin1_abbr::test_abbreviation_005", + "tests/test_plugins.py::TestPlugin1_abbr::test_abbreviation_006", + "tests/test_plugins.py::TestPlugin1_abbr::test_abbreviation_007", + "tests/test_plugins.py::TestPlugin1_abbr::test_abbreviation_008", + "tests/test_plugins.py::TestPlugin1_abbr::test_abbreviation_009", + "tests/test_plugins.py::TestPlugin1_abbr::test_abbreviation_010", + "tests/test_plugins.py::TestPlugin2_abbr::test_abbreviation_001", + "tests/test_plugins.py::TestPlugin2_abbr::test_abbreviation_002", + "tests/test_plugins.py::TestPlugin2_abbr::test_abbreviation_003", + "tests/test_plugins.py::TestPlugin2_abbr::test_abbreviation_004", + "tests/test_plugins.py::TestPlugin2_abbr::test_abbreviation_005", + "tests/test_plugins.py::TestPlugin2_abbr::test_abbreviation_006", + "tests/test_plugins.py::TestPlugin2_abbr::test_abbreviation_007", + "tests/test_plugins.py::TestPlugin2_abbr::test_abbreviation_008", + "tests/test_plugins.py::TestPlugin2_abbr::test_abbreviation_009", + "tests/test_plugins.py::TestPlugin2_abbr::test_abbreviation_010", + "tests/test_plugins.py::TestPlugin1_math::test_block_math_001", + "tests/test_plugins.py::TestPlugin1_math::test_block_math_002", + "tests/test_plugins.py::TestPlugin1_math::test_block_math_003", + "tests/test_plugins.py::TestPlugin1_math::test_block_math_004", + "tests/test_plugins.py::TestPlugin1_math::test_inline_math_001", + "tests/test_plugins.py::TestPlugin2_math::test_block_math_001", + "tests/test_plugins.py::TestPlugin2_math::test_block_math_002", + "tests/test_plugins.py::TestPlugin2_math::test_block_math_003", + "tests/test_plugins.py::TestPlugin2_math::test_block_math_004", + "tests/test_plugins.py::TestPlugin2_math::test_inline_math_001", + "tests/test_plugins.py::TestPlugin1_ruby::test_ruby_splits_001", + "tests/test_plugins.py::TestPlugin1_ruby::test_ruby_splits_002", + "tests/test_plugins.py::TestPlugin1_ruby::test_ruby_with_link_001", + "tests/test_plugins.py::TestPlugin1_ruby::test_ruby_with_link_002", + "tests/test_plugins.py::TestPlugin1_ruby::test_ruby_with_link_003", + "tests/test_plugins.py::TestPlugin1_ruby::test_ruby_without_link_001", + "tests/test_plugins.py::TestPlugin1_ruby::test_ruby_without_link_002", + "tests/test_plugins.py::TestPlugin1_ruby::test_ruby_without_link_003", + "tests/test_plugins.py::TestPlugin1_ruby::test_ruby_without_link_004", + "tests/test_plugins.py::TestPlugin2_ruby::test_ruby_splits_001", + "tests/test_plugins.py::TestPlugin2_ruby::test_ruby_splits_002", + "tests/test_plugins.py::TestPlugin2_ruby::test_ruby_with_link_001", + "tests/test_plugins.py::TestPlugin2_ruby::test_ruby_with_link_002", + "tests/test_plugins.py::TestPlugin2_ruby::test_ruby_with_link_003", + "tests/test_plugins.py::TestPlugin2_ruby::test_ruby_without_link_001", + "tests/test_plugins.py::TestPlugin2_ruby::test_ruby_without_link_002", + "tests/test_plugins.py::TestPlugin2_ruby::test_ruby_without_link_003", + "tests/test_plugins.py::TestPlugin2_ruby::test_ruby_without_link_004", + "tests/test_plugins.py::TestPlugin1_spoiler::test_block_spoiler_001", + "tests/test_plugins.py::TestPlugin1_spoiler::test_block_spoiler_002", + "tests/test_plugins.py::TestPlugin1_spoiler::test_block_spoiler_003", + "tests/test_plugins.py::TestPlugin1_spoiler::test_block_spoiler_004", + "tests/test_plugins.py::TestPlugin1_spoiler::test_block_spoiler_005", + "tests/test_plugins.py::TestPlugin1_spoiler::test_inline_spoiler_001", + "tests/test_plugins.py::TestPlugin1_spoiler::test_inline_spoiler_002", + "tests/test_plugins.py::TestPlugin1_spoiler::test_inline_spoiler_003", + "tests/test_plugins.py::TestPlugin2_spoiler::test_block_spoiler_001", + "tests/test_plugins.py::TestPlugin2_spoiler::test_block_spoiler_002", + "tests/test_plugins.py::TestPlugin2_spoiler::test_block_spoiler_003", + "tests/test_plugins.py::TestPlugin2_spoiler::test_block_spoiler_004", + "tests/test_plugins.py::TestPlugin2_spoiler::test_block_spoiler_005", + "tests/test_plugins.py::TestPlugin2_spoiler::test_inline_spoiler_001", + "tests/test_plugins.py::TestPlugin2_spoiler::test_inline_spoiler_002", + "tests/test_plugins.py::TestPlugin2_spoiler::test_inline_spoiler_003", + "tests/test_plugins.py::TestExtraPlugins::test_math_in_list", + "tests/test_plugins.py::TestExtraPlugins::test_math_in_quote", + "tests/test_plugins.py::TestExtraPlugins::test_table_in_list", + "tests/test_plugins.py::TestExtraPlugins::test_table_in_quote", + "tests/test_renderers.py::TestRendererRst::test_code_001", + "tests/test_renderers.py::TestRendererRst::test_code_002", + "tests/test_renderers.py::TestRendererRst::test_heading_001", + "tests/test_renderers.py::TestRendererRst::test_html_001", + "tests/test_renderers.py::TestRendererRst::test_images_001", + "tests/test_renderers.py::TestRendererRst::test_images_002", + "tests/test_renderers.py::TestRendererRst::test_images_003", + "tests/test_renderers.py::TestRendererRst::test_inline_001", + "tests/test_renderers.py::TestRendererRst::test_inline_002", + "tests/test_renderers.py::TestRendererRst::test_line_break_001", + "tests/test_renderers.py::TestRendererRst::test_links_001", + "tests/test_renderers.py::TestRendererRst::test_list_001", + "tests/test_renderers.py::TestRendererRst::test_list_002", + "tests/test_renderers.py::TestRendererRst::test_list_003", + "tests/test_renderers.py::TestRendererRst::test_list_004", + "tests/test_renderers.py::TestRendererRst::test_list_005", + "tests/test_renderers.py::TestRendererRst::test_quote_001", + "tests/test_renderers.py::TestRendererRst::test_quote_002", + "tests/test_renderers.py::TestRendererRst::test_quote_003", + "tests/test_renderers.py::TestRendererRst::test_thematic_break_001", + "tests/test_syntax.py::TestSyntax::test_emphasis_001", + "tests/test_syntax.py::TestSyntax::test_image_001", + "tests/test_syntax.py::TestSyntax::test_link_001", + "tests/test_syntax.py::TestSyntax::test_link_002", + "tests/test_syntax.py::TestSyntax::test_link_003", + "tests/test_syntax.py::TestSyntax::test_links_001", + "tests/test_syntax.py::TestSyntax::test_links_002", + "tests/test_syntax.py::TestSyntax::test_max_depth_001", + "tests/test_syntax.py::TestSyntax::test_max_depth_002", + "tests/test_syntax.py::TestSyntax::test_non_aggressive_emphasis_001", + "tests/test_syntax.py::TestSyntax::test_non_aggressive_emphasis_002", + "tests/test_syntax.py::TestSyntax::test_non_aggressive_emphasis_003", + "tests/test_syntax.py::TestSyntax::test_setext_headings_001", + "tests/test_syntax.py::TestSyntax::test_setext_headings_002" + ] +} diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/grade.py b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/grade.py new file mode 100644 index 0000000000000000000000000000000000000000..e3b37293830e51a5c5833c93c4705e1ed9364257 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/grade.py @@ -0,0 +1,128 @@ +"""Trusted private pytest panel runner. Installed only in a fresh grader Job.""" + +import hashlib +import importlib.util +import json +import os +import shutil +import stat +import subprocess +from pathlib import Path, PurePosixPath + + +def sha(raw): + return hashlib.sha256(raw).hexdigest() + + +def safe(value): + path = PurePosixPath(value) + if ( + path.is_absolute() + or path.as_posix() != value + or not path.parts + or any(part in {".", "..", ".git"} for part in path.parts) + ): + raise ValueError("Unsafe trusted test path") + return path + + +def restore(worktree, private, manifest): + worktree, private = Path(worktree), Path(private) + captured = {} + for name, expected in manifest["files"].items(): + path = private / safe(name) + info = path.lstat() + raw = path.read_bytes() if stat.S_ISREG(info.st_mode) else b"" + if ( + not stat.S_ISREG(info.st_mode) + or len(raw) != expected["bytes"] + or sha(raw) != expected["sha256"] + or stat.S_IMODE(info.st_mode) != expected["mode"] + ): + raise ValueError("Trusted private test bytes or modes drifted") + captured[name] = (raw, expected["mode"]) + # Capture and verify every private byte before changing the submitted tree. + for name in manifest["directory_roots"]: + destination = worktree / safe(name) + if destination.is_symlink(): + raise ValueError("Submitted test directory is a symlink") + for parent in destination.parents: + if parent == worktree: + break + if parent.is_symlink(): + raise ValueError("Submitted test parent is a symlink") + if destination.exists(): + if not destination.is_dir(): + raise ValueError("Submitted test directory is not a directory") + shutil.rmtree(destination) + for name, (raw, mode) in captured.items(): + destination = worktree / safe(name) + for parent in destination.parents: + if parent == worktree: + break + if parent.is_symlink(): + raise ValueError("Submitted test parent is a symlink") + if destination.is_symlink(): + raise ValueError("Submitted trusted file is a symlink") + destination.parent.mkdir(parents=True, exist_ok=True) + destination.write_bytes(raw) + destination.chmod(mode) + + +def run(worktree, private_root, output, invoke=None): + private_root, output, worktree = Path(private_root), Path(output), Path(worktree) + expected = json.loads((private_root / "expected-panels.json").read_bytes()) + config = json.loads((private_root / "panel-config.json").read_bytes()) + manifest = json.loads((private_root / "trusted-inventory.json").read_bytes()) + restore(worktree, private_root / "trusted", manifest) + output.mkdir(parents=True, exist_ok=True) + for name in ( + "reward.txt", + "pass-to-pass.xml", + "fail-to-pass.xml", + "pytest-evidence.json", + ): + (output / name).unlink(missing_ok=True) + environment = dict(os.environ) + for key in ("PYTEST_ADDOPTS", "PYTEST_DISABLE_PLUGIN_AUTOLOAD", "PYTHONPATH"): + environment.pop(key, None) + commands, native_exit = [], 0 + invoke = invoke or subprocess.run + for group in ("pass-to-pass", "fail-to-pass"): + if ( + not isinstance(expected[group], list) + or not expected[group] + or any( + not isinstance(target, str) or not target for target in expected[group] + ) + ): + raise ValueError("Frozen native pytest selectors are incomplete") + command = [ + *config["official_pytest_argv"], + "--override-ini=addopts=", + "--junitxml=" + str(output / (group + ".xml")), + *expected[group], + ] + result = invoke(command, cwd=worktree, env=environment, check=False) + native_exit = result.returncode + commands.append({"group": group, "argv": command, "exit_code": native_exit}) + if native_exit != 0: + break + (output / "pytest-commands.json").write_text( + json.dumps(commands, sort_keys=True) + "\n" + ) + spec = importlib.util.spec_from_file_location( + "trusted_pytest_result", private_root / "check_pytest.py" + ) + checker = importlib.util.module_from_spec(spec) + spec.loader.exec_module(checker) + result = checker.assess(output, expected, native_exit) + (output / "reward.txt").write_text(str(result["reward"]) + "\n") + (output / "pytest-evidence.json").write_text( + json.dumps(result, sort_keys=True) + "\n" + ) + return result + + +if __name__ == "__main__": + run("/testbed/repo", "/tests", "/logs/verifier") diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/panel-config.json b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/panel-config.json new file mode 100644 index 0000000000000000000000000000000000000000..fcf9afd120808ef57ca8e15a2ff5adfbb1b9b425 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/panel-config.json @@ -0,0 +1,24 @@ +{ + "dependency_installation_pinned": false, + "official_install_cmds": [ + "python -m pip install -e ." + ], + "official_pytest_argv": [ + "pytest", + "--disable-warnings", + "--color=no", + "--tb=no", + "--verbose" + ], + "official_test_command": "source /opt/miniconda3/bin/activate; conda activate testbed; pytest --disable-warnings --color=no --tb=no --verbose", + "operator_test_runner_prerequisites": [ + "python -m pip install pytest==8.4.2" + ], + "operator_test_runner_reason": "The official profile invokes pytest, but the common tools runtime does not provide it; pinned separately from source-native project requirements.", + "panel_normalization": "Override project addopts only to execute the exact frozen native panels; add JUnit output, preserve official pytest options and all selectors.", + "python_version": "3.10", + "source_bound_test_dependency_cmds": [], + "test_dependency_source_sha256": { + "pyproject.toml": "b2922e3ef89e2918935d38fb3a777bdbc741619942276a75fd21a8dd9faf6b42" + } +} diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/test.sh b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..81b6d0620f05dbd3b54b4e7ea5de04ce3f8a98e2 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/test.sh @@ -0,0 +1,6 @@ +#!/bin/bash +set -Eeuo pipefail +source /opt/miniconda3/bin/activate +conda activate testbed +cd /testbed/repo +exec python -I /tests/grade.py diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted-inventory.json b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted-inventory.json new file mode 100644 index 0000000000000000000000000000000000000000..aa70e1f5d5d129ced763ef7db40f73f94595e1e2 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted-inventory.json @@ -0,0 +1,212 @@ +{ + "directory_roots": [ + "tests" + ], + "files": { + "pyproject.toml": { + "bytes": 1781, + "mode": 420, + "sha256": "b2922e3ef89e2918935d38fb3a777bdbc741619942276a75fd21a8dd9faf6b42" + }, + "setup.py": { + "bytes": 52, + "mode": 420, + "sha256": "504f5c8cbb3b966b1f3f838da0a0cdc77b312f0c5935951357d17328e5324e21" + }, + "tests/__init__.py": { + "bytes": 1149, + "mode": 420, + "sha256": "229cc35ee9a5f5a9fb37e036683e2276f940b80df2dc6203102c0f36f960e467" + }, + "tests/fixtures/__init__.py": { + "bytes": 1502, + "mode": 420, + "sha256": "960fa58f01c3a473a956cc2d5430314d10f070bff18b35c9707c52c1c42a57e2" + }, + "tests/fixtures/abbr.txt": { + "bytes": 2703, + "mode": 420, + "sha256": "18c7e06359486daeaafa88c7404f4ca8248cd47bf38a7ed475ddd35353e68bea" + }, + "tests/fixtures/commonmark.json": { + "bytes": 140423, + "mode": 420, + "sha256": "ae6129f3ce3caf4f99cf4f9a5ad3558a309652b5b887171013e2bf0797289b98" + }, + "tests/fixtures/def_list.txt": { + "bytes": 2834, + "mode": 420, + "sha256": "909b7156a5ba1f005ea3d8a203946e7ab3576149ec5af73ecad657bb046f386d" + }, + "tests/fixtures/diff-commonmark.txt": { + "bytes": 1176, + "mode": 420, + "sha256": "920df6e3c9c8e3d4627842d5a7aeb172bdd23229acfbbb9a9b728a9f6ce2c1f0" + }, + "tests/fixtures/fenced_admonition.txt": { + "bytes": 2344, + "mode": 420, + "sha256": "0f231afd472bc2c742170798e619d1baa5dd34e9e4a6cb18906dabd1aa37a1d0" + }, + "tests/fixtures/fenced_figure.txt": { + "bytes": 3481, + "mode": 420, + "sha256": "83c3d636e8d4f0dd5a767045cf38877fd3c6c03a20c351f06c50e30ae7f30cda" + }, + "tests/fixtures/fenced_image.txt": { + "bytes": 2343, + "mode": 420, + "sha256": "fa7ede5a90b718aaeb46af7f5a4d98a0e17cec0411355f460a166356020e6780" + }, + "tests/fixtures/fenced_toc.txt": { + "bytes": 3656, + "mode": 420, + "sha256": "019a12ca2e293699d88241460bdea48ee6a65981b36b6bae4c0bbf78f020a296" + }, + "tests/fixtures/fix-commonmark.txt": { + "bytes": 1905, + "mode": 420, + "sha256": "1f2777b457f4da70e02983bbcb2104fa3b442dbb8a5bcac1621499b0b796292f" + }, + "tests/fixtures/footnotes.txt": { + "bytes": 847, + "mode": 420, + "sha256": "55227ab43a3986fd07ecbf0742903a977f04cd9ed403086d7c76f23b1967aab1" + }, + "tests/fixtures/hook_toc.txt": { + "bytes": 1896, + "mode": 420, + "sha256": "bdb1a5c90f08cb29c4eed3c892e9c694f92855507b6cd5809eac3b8eb4fc7dc5" + }, + "tests/fixtures/include/hello.md": { + "bytes": 8, + "mode": 420, + "sha256": "389aaf8f17da55ef35fedf530bc70cd1287042f6410ec94c2b44c1b22c36e60a" + }, + "tests/fixtures/include/hello.txt": { + "bytes": 6, + "mode": 420, + "sha256": "5891b5b522d5df086d0ff0b110fbd9d21bb4fc7163af34d08286a2e846f6be03" + }, + "tests/fixtures/include/text.html": { + "bytes": 24, + "mode": 420, + "sha256": "bac2f8a2e3937f8923da8e560248d2a52867b502fbda531ba73f1d066b35d2ba" + }, + "tests/fixtures/include/text.md": { + "bytes": 163, + "mode": 420, + "sha256": "3ffb497b2829ca6333bc6eb4e7d2959aa7baeaa44180225a4820e0051ae7ef75" + }, + "tests/fixtures/insert.txt": { + "bytes": 1165, + "mode": 420, + "sha256": "de7b89a58c2cbd2d4948c10b8c599fd7500b3ae6734d271a35ff2cf2854b1572" + }, + "tests/fixtures/mark.txt": { + "bytes": 1138, + "mode": 420, + "sha256": "6b5c232cf89f61097ae6d032865a99bdcd9f65e3ef99517d9423b2da0aa983d0" + }, + "tests/fixtures/math.txt": { + "bytes": 1174, + "mode": 420, + "sha256": "eadc29b04cc85928e50003b2908b002a778447ef028c4b773ca1753b907fd898" + }, + "tests/fixtures/renderer_markdown.txt": { + "bytes": 3569, + "mode": 420, + "sha256": "2ba5fc55634d7dbaabd91aedea9e04b34882e67abc3020034bd809a408cac2a7" + }, + "tests/fixtures/renderer_rst.txt": { + "bytes": 2915, + "mode": 420, + "sha256": "47007bc353f230e9b73d8604548539bb16374a4b837bf7ba8d2f478444fff84e" + }, + "tests/fixtures/rst_admonition.txt": { + "bytes": 848, + "mode": 420, + "sha256": "821676f07a4e595c51c84da87edc592e22e8bbed6241e070040d87a4de7c5d7e" + }, + "tests/fixtures/rst_toc.txt": { + "bytes": 3643, + "mode": 420, + "sha256": "f9ae334cef85d776c37d7ad029e1e38d9e1b035423ab624dab8499aff28f7e98" + }, + "tests/fixtures/ruby.txt": { + "bytes": 1773, + "mode": 420, + "sha256": "1302542447ac0befc2618d9c2da1657581fcc1d90c332896e6dc086b698e30ed" + }, + "tests/fixtures/spoiler.txt": { + "bytes": 1154, + "mode": 420, + "sha256": "21446f2e88b70cc3c50e606c36fbcdf567993581ccf8397ace5948973c251985" + }, + "tests/fixtures/strikethrough.txt": { + "bytes": 886, + "mode": 420, + "sha256": "fee85a2207da74bdcf437c2c58804b009b657b4dfd505989fdbee46f78feac07" + }, + "tests/fixtures/subscript.txt": { + "bytes": 521, + "mode": 420, + "sha256": "61fd94b4718edbbfaa782533f659f4f193585fb09e61761a662cd313906932b8" + }, + "tests/fixtures/superscript.txt": { + "bytes": 523, + "mode": 420, + "sha256": "658ac752d95d74e6e97e7daceba6f48ef279dc6f1389a878610bc608e82f34b3" + }, + "tests/fixtures/table.txt": { + "bytes": 4134, + "mode": 420, + "sha256": "f92d66b63d00f95f7a9938cb6e0e42ea4968d6e9f1f62e902b63bc1be69f51b6" + }, + "tests/fixtures/task_lists.txt": { + "bytes": 3104, + "mode": 420, + "sha256": "d17a07a9cb077dd25c3b4c4dd7301bc9f508ab75ec83c2293b0ebaca954be76c" + }, + "tests/fixtures/url.txt": { + "bytes": 530, + "mode": 420, + "sha256": "441ea5e1e27f6edcd52b51f8c20ca1eee8b76d4adcc3b2fcdd419448c528ef21" + }, + "tests/test_commonmark.py": { + "bytes": 2199, + "mode": 420, + "sha256": "77396377672a8419ecab283aebf55a5e206b1aa413626975dc8b2a006c796973" + }, + "tests/test_directives.py": { + "bytes": 2954, + "mode": 420, + "sha256": "3d46db4f9e52d3067954ab7fcaba80ef855008a516a86ee3baf07b2a9c730817" + }, + "tests/test_hooks.py": { + "bytes": 729, + "mode": 420, + "sha256": "9d6f177c6dd52223ac44e31508ed66bbc2b6fc7a4725ed7121fb39842b0a6a61" + }, + "tests/test_misc.py": { + "bytes": 4830, + "mode": 420, + "sha256": "a1bba411b7b74f1b9d43bf88459db1d9fa2c13e7db32dfee707c93cd8ccb5575" + }, + "tests/test_plugins.py": { + "bytes": 2280, + "mode": 420, + "sha256": "56a6731c5e5667870122edfb3d49925a34dc394ae00ce3282dc3e89cbe2fd6b8" + }, + "tests/test_renderers.py": { + "bytes": 500, + "mode": 420, + "sha256": "efc0fa48c74f8ee1b84c961e4ca034eb5f0246b69b4663428c93cc77d471e7b8" + }, + "tests/test_syntax.py": { + "bytes": 342, + "mode": 420, + "sha256": "88f99c6afc5f39f088c0cd1cdf4fab8a69b60b208a1b28924eeb8fbd0d7bef2e" + } + } +} diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/pyproject.toml b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/pyproject.toml new file mode 100644 index 0000000000000000000000000000000000000000..2d95f9b3bd4ee9817157eab051c5277fb0a3846f --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/pyproject.toml @@ -0,0 +1,69 @@ +[project] +name = "mistune" +description = "A sane and fast Markdown parser with useful plugins and renderers" +authors = [{name = "Hsiaoming Yang", email="me@lepture.com"}] +dependencies = [ + "typing-extensions; python_version<'3.11'", +] +license = {text = "BSD-3-Clause"} +dynamic = ["version"] +requires-python = ">=3.8" +readme = "README.rst" +classifiers = [ + "Development Status :: 4 - Beta", + "Environment :: Console", + "Environment :: Web Environment", + "Intended Audience :: Developers", + "License :: OSI Approved :: BSD License", + "Operating System :: OS Independent", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: Implementation :: CPython", + "Programming Language :: Python :: Implementation :: PyPy", + "Topic :: Text Processing :: Markup", +] + +[project.urls] +Documentation = "https://mistune.lepture.com/" +Source = "https://github.com/lepture/mistune" +Donate = "https://github.com/sponsors/lepture" + +[build-system] +requires = ["setuptools"] +build-backend = "setuptools.build_meta" + +[tool.setuptools.dynamic] +version = {attr = "mistune.__version__"} + +[tool.setuptools.packages.find] +where = ["src"] + +[tool.setuptools.package-data] +mistune = ["py.typed"] + +[tool.ruff] +line-length = 120 + +[tool.pytest.ini_options] +pythonpath = ["src", "."] +testpaths = ["tests"] +filterwarnings = ["error"] + +[tool.coverage.run] +branch = true +source = ["mistune"] + +[tool.coverage.paths] +source = ["src"] + +[tool.coverage.report] +exclude_lines = [ + "pragma: no cover", + "def __repr__", + "raise NotImplementedError", + "@(abc\\.)?abstractmethod", +] diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/setup.py b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/setup.py new file mode 100644 index 0000000000000000000000000000000000000000..af8a0fc50e9db1a27585118393965a8c87e19129 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/setup.py @@ -0,0 +1,3 @@ +from setuptools import setup + +setup(name="mistune") diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/__init__.py b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..b715104d1f96221038f7c9060d66b4bc6a5bdda2 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/__init__.py @@ -0,0 +1,40 @@ +import re +from abc import abstractmethod +from unittest import TestCase + +from tests import fixtures + + +class BaseTestCase(TestCase): + @classmethod + def load_fixtures(cls, case_file: str) -> None: + def attach_case(n: str, text: str, html: str) -> None: + def method(self: 'BaseTestCase') -> None: + self.assert_case(n, text, html) + + name = 'test_{}'.format(n) + method.__name__ = name + method.__doc__ = 'Run fixture {} - {}'.format(case_file, n) + setattr(cls, name, method) + + for n, text, html in fixtures.load_examples(case_file): + if cls.ignore_case(n): + continue + attach_case(n, text, html) + + @classmethod + def ignore_case(cls, name: str) -> bool: + return False + + @abstractmethod + def parse(self, text: str) -> str: ... + + def assert_case(self, name: str, text: str, html: str) -> None: + result = self.parse(text) + self.assertEqual(result, html) + + +def normalize_html(html: str) -> str: + html = re.sub(r'>\n+', '>', html) + html = re.sub(r'\n+<', '<', html) + return html.strip() diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/fixtures/__init__.py b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/fixtures/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..9a1abe299918fbbac039621a46f85061a7f0c31e --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/fixtures/__init__.py @@ -0,0 +1,56 @@ +import os +import re +import json +from typing import Any, Iterable, Tuple + +ROOT = os.path.join(os.path.dirname(__file__)) + +EXAMPLE_PATTERN = re.compile( + r'^`{32} example\n([\s\S]*?)' + r'^\.\n([\s\S]*?)' + r'^`{32}$|^#{1,6} *(.*)$', + flags=re.M +) + + +def load_ast(filename: str) -> Any: + with open(os.path.join(ROOT, 'ast', filename)) as f: + return json.load(f) + + +def load_json(filename: str) -> Any: + with open(os.path.join(ROOT, filename)) as f: + return json.load(f) + + +def load_examples(filename: str) -> Iterable[Tuple[str, str, str]]: + if filename.endswith('.json'): + data = load_json(filename) + for item in data: + section = item['section'].lower().replace(' ', '_') + n = '%s_%03d' % (section, item['example']) + yield n, item['markdown'], item['html'] + else: + with open(os.path.join(ROOT, filename), 'rb') as f: + content = f.read() + s = content.decode('utf-8') + yield from parse_examples(s) + + + +def parse_examples(text: str) -> Iterable[Tuple[str, str, str]]: + data = EXAMPLE_PATTERN.findall(text) + + section = None + count = 0 + for md, html, title in data: + if title: + count = 0 + section = title.lower().replace(' ', '_') + + if md and html: + count += 1 + n = '%s_%03d' % (section, count) + md = md.replace(u'\u2192', '\t') + html = html.replace(u'\u2192', '\t') + yield n, md, html diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/fixtures/abbr.txt b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/fixtures/abbr.txt new file mode 100644 index 0000000000000000000000000000000000000000..a87b4f1521511a9071a901311c07372340bb958c --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/fixtures/abbr.txt @@ -0,0 +1,79 @@ +# Abbreviation + +## abbreviation + +```````````````````````````````` example +HTML +. +

HTML

+```````````````````````````````` + +```````````````````````````````` example +HTML +*[HTML]: Hyper Text Markup Language +. +

HTML

+```````````````````````````````` + +```````````````````````````````` example +The HTML specification is maintained by the W3C. +*[HTML]: Hyper Text Markup Language +*[W3C]: World Wide Web Consortium +. +

The HTML specification is maintained by the W3C.

+```````````````````````````````` + +```````````````````````````````` example +The HTML specification is maintained by the W3C. +*[HTML]: + Hyper Text Markup Language +*[W3C]: + World Wide Web Consortium +. +

The HTML specification is maintained by the W3C.

+```````````````````````````````` + +```````````````````````````````` example +The HTML specification is maintained by the W3C. +*[HTML]: Hyper Text Markup Language +*[W3C]: World Wide Web Consortium +There is more text below this one. +. +

The HTML specification is maintained by the W3C.

+

There is more text below this one.

+```````````````````````````````` + +```````````````````````````````` example +The latest spec of HTML is HTML5. +*[HTML]: Hyper Text Markup Language +. +

The latest spec of HTML is HTML5.

+```````````````````````````````` + +```````````````````````````````` example +HTML should always be spelt with capital letters and not spelt html. +*[HTML]: Hyper Text Markup Language +. +

HTML should always be spelt with capital letters and not spelt html.

+```````````````````````````````` + +```````````````````````````````` example +HTML is an abbreviation but nobody knows what it stands for. +*[HTML]: +. +

HTML is an abbreviation but nobody knows what it stands for.

+```````````````````````````````` + +```````````````````````````````` example +Foo.* looks like a regular expression. +*[Foo.*]: Just foo +. +

Foo.* looks like a regular expression.

+```````````````````````````````` + +```````````````````````````````` example +Untrusted HTML should be escaped. +*[HTML]:

This is some HTML

+. +

Untrusted HTML should be escaped.

+```````````````````````````````` diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/fixtures/commonmark.json b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/fixtures/commonmark.json new file mode 100644 index 0000000000000000000000000000000000000000..d742f941312421f89a3491b7e1d5edd0e44d2207 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/fixtures/commonmark.json @@ -0,0 +1,5218 @@ +[ + { + "markdown": "\tfoo\tbaz\t\tbim\n", + "html": "
foo\tbaz\t\tbim\n
\n", + "example": 1, + "start_line": 356, + "end_line": 361, + "section": "Tabs" + }, + { + "markdown": " \tfoo\tbaz\t\tbim\n", + "html": "
foo\tbaz\t\tbim\n
\n", + "example": 2, + "start_line": 363, + "end_line": 368, + "section": "Tabs" + }, + { + "markdown": " a\ta\n ὐ\ta\n", + "html": "
a\ta\nὐ\ta\n
\n", + "example": 3, + "start_line": 370, + "end_line": 377, + "section": "Tabs" + }, + { + "markdown": " - foo\n\n\tbar\n", + "html": "
    \n
  • \n

    foo

    \n

    bar

    \n
  • \n
\n", + "example": 4, + "start_line": 383, + "end_line": 394, + "section": "Tabs" + }, + { + "markdown": "- foo\n\n\t\tbar\n", + "html": "
    \n
  • \n

    foo

    \n
      bar\n
    \n
  • \n
\n", + "example": 5, + "start_line": 396, + "end_line": 408, + "section": "Tabs" + }, + { + "markdown": ">\t\tfoo\n", + "html": "
\n
  foo\n
\n
\n", + "example": 6, + "start_line": 419, + "end_line": 426, + "section": "Tabs" + }, + { + "markdown": "-\t\tfoo\n", + "html": "
    \n
  • \n
      foo\n
    \n
  • \n
\n", + "example": 7, + "start_line": 428, + "end_line": 437, + "section": "Tabs" + }, + { + "markdown": " foo\n\tbar\n", + "html": "
foo\nbar\n
\n", + "example": 8, + "start_line": 440, + "end_line": 447, + "section": "Tabs" + }, + { + "markdown": " - foo\n - bar\n\t - baz\n", + "html": "
    \n
  • foo\n
      \n
    • bar\n
        \n
      • baz
      • \n
      \n
    • \n
    \n
  • \n
\n", + "example": 9, + "start_line": 449, + "end_line": 465, + "section": "Tabs" + }, + { + "markdown": "#\tFoo\n", + "html": "

Foo

\n", + "example": 10, + "start_line": 467, + "end_line": 471, + "section": "Tabs" + }, + { + "markdown": "*\t*\t*\t\n", + "html": "
\n", + "example": 11, + "start_line": 473, + "end_line": 477, + "section": "Tabs" + }, + { + "markdown": "\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\-\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\_\\`\\{\\|\\}\\~\n", + "html": "

!"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~

\n", + "example": 12, + "start_line": 490, + "end_line": 494, + "section": "Backslash escapes" + }, + { + "markdown": "\\\t\\A\\a\\ \\3\\φ\\«\n", + "html": "

\\\t\\A\\a\\ \\3\\φ\\«

\n", + "example": 13, + "start_line": 500, + "end_line": 504, + "section": "Backslash escapes" + }, + { + "markdown": "\\*not emphasized*\n\\
not a tag\n\\[not a link](/foo)\n\\`not code`\n1\\. not a list\n\\* not a list\n\\# not a heading\n\\[foo]: /url \"not a reference\"\n\\ö not a character entity\n", + "html": "

*not emphasized*\n<br/> not a tag\n[not a link](/foo)\n`not code`\n1. not a list\n* not a list\n# not a heading\n[foo]: /url "not a reference"\n&ouml; not a character entity

\n", + "example": 14, + "start_line": 510, + "end_line": 530, + "section": "Backslash escapes" + }, + { + "markdown": "\\\\*emphasis*\n", + "html": "

\\emphasis

\n", + "example": 15, + "start_line": 535, + "end_line": 539, + "section": "Backslash escapes" + }, + { + "markdown": "foo\\\nbar\n", + "html": "

foo
\nbar

\n", + "example": 16, + "start_line": 544, + "end_line": 550, + "section": "Backslash escapes" + }, + { + "markdown": "`` \\[\\` ``\n", + "html": "

\\[\\`

\n", + "example": 17, + "start_line": 556, + "end_line": 560, + "section": "Backslash escapes" + }, + { + "markdown": " \\[\\]\n", + "html": "
\\[\\]\n
\n", + "example": 18, + "start_line": 563, + "end_line": 568, + "section": "Backslash escapes" + }, + { + "markdown": "~~~\n\\[\\]\n~~~\n", + "html": "
\\[\\]\n
\n", + "example": 19, + "start_line": 571, + "end_line": 578, + "section": "Backslash escapes" + }, + { + "markdown": "\n", + "html": "

http://example.com?find=\\*

\n", + "example": 20, + "start_line": 581, + "end_line": 585, + "section": "Backslash escapes" + }, + { + "markdown": "\n", + "html": "\n", + "example": 21, + "start_line": 588, + "end_line": 592, + "section": "Backslash escapes" + }, + { + "markdown": "[foo](/bar\\* \"ti\\*tle\")\n", + "html": "

foo

\n", + "example": 22, + "start_line": 598, + "end_line": 602, + "section": "Backslash escapes" + }, + { + "markdown": "[foo]\n\n[foo]: /bar\\* \"ti\\*tle\"\n", + "html": "

foo

\n", + "example": 23, + "start_line": 605, + "end_line": 611, + "section": "Backslash escapes" + }, + { + "markdown": "``` foo\\+bar\nfoo\n```\n", + "html": "
foo\n
\n", + "example": 24, + "start_line": 614, + "end_line": 621, + "section": "Backslash escapes" + }, + { + "markdown": "  & © Æ Ď\n¾ ℋ ⅆ\n∲ ≧̸\n", + "html": "

  & © Æ Ď\n¾ ℋ ⅆ\n∲ ≧̸

\n", + "example": 25, + "start_line": 650, + "end_line": 658, + "section": "Entity and numeric character references" + }, + { + "markdown": "# Ӓ Ϡ �\n", + "html": "

# Ӓ Ϡ �

\n", + "example": 26, + "start_line": 669, + "end_line": 673, + "section": "Entity and numeric character references" + }, + { + "markdown": "" ആ ಫ\n", + "html": "

" ആ ಫ

\n", + "example": 27, + "start_line": 682, + "end_line": 686, + "section": "Entity and numeric character references" + }, + { + "markdown": "  &x; &#; &#x;\n�\n&#abcdef0;\n&ThisIsNotDefined; &hi?;\n", + "html": "

&nbsp &x; &#; &#x;\n&#87654321;\n&#abcdef0;\n&ThisIsNotDefined; &hi?;

\n", + "example": 28, + "start_line": 691, + "end_line": 701, + "section": "Entity and numeric character references" + }, + { + "markdown": "©\n", + "html": "

&copy

\n", + "example": 29, + "start_line": 708, + "end_line": 712, + "section": "Entity and numeric character references" + }, + { + "markdown": "&MadeUpEntity;\n", + "html": "

&MadeUpEntity;

\n", + "example": 30, + "start_line": 718, + "end_line": 722, + "section": "Entity and numeric character references" + }, + { + "markdown": "\n", + "html": "\n", + "example": 31, + "start_line": 729, + "end_line": 733, + "section": "Entity and numeric character references" + }, + { + "markdown": "[foo](/föö \"föö\")\n", + "html": "

foo

\n", + "example": 32, + "start_line": 736, + "end_line": 740, + "section": "Entity and numeric character references" + }, + { + "markdown": "[foo]\n\n[foo]: /föö \"föö\"\n", + "html": "

foo

\n", + "example": 33, + "start_line": 743, + "end_line": 749, + "section": "Entity and numeric character references" + }, + { + "markdown": "``` föö\nfoo\n```\n", + "html": "
foo\n
\n", + "example": 34, + "start_line": 752, + "end_line": 759, + "section": "Entity and numeric character references" + }, + { + "markdown": "`föö`\n", + "html": "

f&ouml;&ouml;

\n", + "example": 35, + "start_line": 765, + "end_line": 769, + "section": "Entity and numeric character references" + }, + { + "markdown": " föfö\n", + "html": "
f&ouml;f&ouml;\n
\n", + "example": 36, + "start_line": 772, + "end_line": 777, + "section": "Entity and numeric character references" + }, + { + "markdown": "*foo*\n*foo*\n", + "html": "

*foo*\nfoo

\n", + "example": 37, + "start_line": 784, + "end_line": 790, + "section": "Entity and numeric character references" + }, + { + "markdown": "* foo\n\n* foo\n", + "html": "

* foo

\n
    \n
  • foo
  • \n
\n", + "example": 38, + "start_line": 792, + "end_line": 801, + "section": "Entity and numeric character references" + }, + { + "markdown": "foo bar\n", + "html": "

foo\n\nbar

\n", + "example": 39, + "start_line": 803, + "end_line": 809, + "section": "Entity and numeric character references" + }, + { + "markdown": " foo\n", + "html": "

\tfoo

\n", + "example": 40, + "start_line": 811, + "end_line": 815, + "section": "Entity and numeric character references" + }, + { + "markdown": "[a](url "tit")\n", + "html": "

[a](url "tit")

\n", + "example": 41, + "start_line": 818, + "end_line": 822, + "section": "Entity and numeric character references" + }, + { + "markdown": "- `one\n- two`\n", + "html": "
    \n
  • `one
  • \n
  • two`
  • \n
\n", + "example": 42, + "start_line": 841, + "end_line": 849, + "section": "Precedence" + }, + { + "markdown": "***\n---\n___\n", + "html": "
\n
\n
\n", + "example": 43, + "start_line": 880, + "end_line": 888, + "section": "Thematic breaks" + }, + { + "markdown": "+++\n", + "html": "

+++

\n", + "example": 44, + "start_line": 893, + "end_line": 897, + "section": "Thematic breaks" + }, + { + "markdown": "===\n", + "html": "

===

\n", + "example": 45, + "start_line": 900, + "end_line": 904, + "section": "Thematic breaks" + }, + { + "markdown": "--\n**\n__\n", + "html": "

--\n**\n__

\n", + "example": 46, + "start_line": 909, + "end_line": 917, + "section": "Thematic breaks" + }, + { + "markdown": " ***\n ***\n ***\n", + "html": "
\n
\n
\n", + "example": 47, + "start_line": 922, + "end_line": 930, + "section": "Thematic breaks" + }, + { + "markdown": " ***\n", + "html": "
***\n
\n", + "example": 48, + "start_line": 935, + "end_line": 940, + "section": "Thematic breaks" + }, + { + "markdown": "Foo\n ***\n", + "html": "

Foo\n***

\n", + "example": 49, + "start_line": 943, + "end_line": 949, + "section": "Thematic breaks" + }, + { + "markdown": "_____________________________________\n", + "html": "
\n", + "example": 50, + "start_line": 954, + "end_line": 958, + "section": "Thematic breaks" + }, + { + "markdown": " - - -\n", + "html": "
\n", + "example": 51, + "start_line": 963, + "end_line": 967, + "section": "Thematic breaks" + }, + { + "markdown": " ** * ** * ** * **\n", + "html": "
\n", + "example": 52, + "start_line": 970, + "end_line": 974, + "section": "Thematic breaks" + }, + { + "markdown": "- - - -\n", + "html": "
\n", + "example": 53, + "start_line": 977, + "end_line": 981, + "section": "Thematic breaks" + }, + { + "markdown": "- - - - \n", + "html": "
\n", + "example": 54, + "start_line": 986, + "end_line": 990, + "section": "Thematic breaks" + }, + { + "markdown": "_ _ _ _ a\n\na------\n\n---a---\n", + "html": "

_ _ _ _ a

\n

a------

\n

---a---

\n", + "example": 55, + "start_line": 995, + "end_line": 1005, + "section": "Thematic breaks" + }, + { + "markdown": " *-*\n", + "html": "

-

\n", + "example": 56, + "start_line": 1011, + "end_line": 1015, + "section": "Thematic breaks" + }, + { + "markdown": "- foo\n***\n- bar\n", + "html": "
    \n
  • foo
  • \n
\n
\n
    \n
  • bar
  • \n
\n", + "example": 57, + "start_line": 1020, + "end_line": 1032, + "section": "Thematic breaks" + }, + { + "markdown": "Foo\n***\nbar\n", + "html": "

Foo

\n
\n

bar

\n", + "example": 58, + "start_line": 1037, + "end_line": 1045, + "section": "Thematic breaks" + }, + { + "markdown": "Foo\n---\nbar\n", + "html": "

Foo

\n

bar

\n", + "example": 59, + "start_line": 1054, + "end_line": 1061, + "section": "Thematic breaks" + }, + { + "markdown": "* Foo\n* * *\n* Bar\n", + "html": "
    \n
  • Foo
  • \n
\n
\n
    \n
  • Bar
  • \n
\n", + "example": 60, + "start_line": 1067, + "end_line": 1079, + "section": "Thematic breaks" + }, + { + "markdown": "- Foo\n- * * *\n", + "html": "
    \n
  • Foo
  • \n
  • \n
    \n
  • \n
\n", + "example": 61, + "start_line": 1084, + "end_line": 1094, + "section": "Thematic breaks" + }, + { + "markdown": "# foo\n## foo\n### foo\n#### foo\n##### foo\n###### foo\n", + "html": "

foo

\n

foo

\n

foo

\n

foo

\n
foo
\n
foo
\n", + "example": 62, + "start_line": 1113, + "end_line": 1127, + "section": "ATX headings" + }, + { + "markdown": "####### foo\n", + "html": "

####### foo

\n", + "example": 63, + "start_line": 1132, + "end_line": 1136, + "section": "ATX headings" + }, + { + "markdown": "#5 bolt\n\n#hashtag\n", + "html": "

#5 bolt

\n

#hashtag

\n", + "example": 64, + "start_line": 1147, + "end_line": 1154, + "section": "ATX headings" + }, + { + "markdown": "\\## foo\n", + "html": "

## foo

\n", + "example": 65, + "start_line": 1159, + "end_line": 1163, + "section": "ATX headings" + }, + { + "markdown": "# foo *bar* \\*baz\\*\n", + "html": "

foo bar *baz*

\n", + "example": 66, + "start_line": 1168, + "end_line": 1172, + "section": "ATX headings" + }, + { + "markdown": "# foo \n", + "html": "

foo

\n", + "example": 67, + "start_line": 1177, + "end_line": 1181, + "section": "ATX headings" + }, + { + "markdown": " ### foo\n ## foo\n # foo\n", + "html": "

foo

\n

foo

\n

foo

\n", + "example": 68, + "start_line": 1186, + "end_line": 1194, + "section": "ATX headings" + }, + { + "markdown": " # foo\n", + "html": "
# foo\n
\n", + "example": 69, + "start_line": 1199, + "end_line": 1204, + "section": "ATX headings" + }, + { + "markdown": "foo\n # bar\n", + "html": "

foo\n# bar

\n", + "example": 70, + "start_line": 1207, + "end_line": 1213, + "section": "ATX headings" + }, + { + "markdown": "## foo ##\n ### bar ###\n", + "html": "

foo

\n

bar

\n", + "example": 71, + "start_line": 1218, + "end_line": 1224, + "section": "ATX headings" + }, + { + "markdown": "# foo ##################################\n##### foo ##\n", + "html": "

foo

\n
foo
\n", + "example": 72, + "start_line": 1229, + "end_line": 1235, + "section": "ATX headings" + }, + { + "markdown": "### foo ### \n", + "html": "

foo

\n", + "example": 73, + "start_line": 1240, + "end_line": 1244, + "section": "ATX headings" + }, + { + "markdown": "### foo ### b\n", + "html": "

foo ### b

\n", + "example": 74, + "start_line": 1251, + "end_line": 1255, + "section": "ATX headings" + }, + { + "markdown": "# foo#\n", + "html": "

foo#

\n", + "example": 75, + "start_line": 1260, + "end_line": 1264, + "section": "ATX headings" + }, + { + "markdown": "### foo \\###\n## foo #\\##\n# foo \\#\n", + "html": "

foo ###

\n

foo ###

\n

foo #

\n", + "example": 76, + "start_line": 1270, + "end_line": 1278, + "section": "ATX headings" + }, + { + "markdown": "****\n## foo\n****\n", + "html": "
\n

foo

\n
\n", + "example": 77, + "start_line": 1284, + "end_line": 1292, + "section": "ATX headings" + }, + { + "markdown": "Foo bar\n# baz\nBar foo\n", + "html": "

Foo bar

\n

baz

\n

Bar foo

\n", + "example": 78, + "start_line": 1295, + "end_line": 1303, + "section": "ATX headings" + }, + { + "markdown": "## \n#\n### ###\n", + "html": "

\n

\n

\n", + "example": 79, + "start_line": 1308, + "end_line": 1316, + "section": "ATX headings" + }, + { + "markdown": "Foo *bar*\n=========\n\nFoo *bar*\n---------\n", + "html": "

Foo bar

\n

Foo bar

\n", + "example": 80, + "start_line": 1351, + "end_line": 1360, + "section": "Setext headings" + }, + { + "markdown": "Foo *bar\nbaz*\n====\n", + "html": "

Foo bar\nbaz

\n", + "example": 81, + "start_line": 1365, + "end_line": 1372, + "section": "Setext headings" + }, + { + "markdown": " Foo *bar\nbaz*\t\n====\n", + "html": "

Foo bar\nbaz

\n", + "example": 82, + "start_line": 1379, + "end_line": 1386, + "section": "Setext headings" + }, + { + "markdown": "Foo\n-------------------------\n\nFoo\n=\n", + "html": "

Foo

\n

Foo

\n", + "example": 83, + "start_line": 1391, + "end_line": 1400, + "section": "Setext headings" + }, + { + "markdown": " Foo\n---\n\n Foo\n-----\n\n Foo\n ===\n", + "html": "

Foo

\n

Foo

\n

Foo

\n", + "example": 84, + "start_line": 1406, + "end_line": 1419, + "section": "Setext headings" + }, + { + "markdown": " Foo\n ---\n\n Foo\n---\n", + "html": "
Foo\n---\n\nFoo\n
\n
\n", + "example": 85, + "start_line": 1424, + "end_line": 1437, + "section": "Setext headings" + }, + { + "markdown": "Foo\n ---- \n", + "html": "

Foo

\n", + "example": 86, + "start_line": 1443, + "end_line": 1448, + "section": "Setext headings" + }, + { + "markdown": "Foo\n ---\n", + "html": "

Foo\n---

\n", + "example": 87, + "start_line": 1453, + "end_line": 1459, + "section": "Setext headings" + }, + { + "markdown": "Foo\n= =\n\nFoo\n--- -\n", + "html": "

Foo\n= =

\n

Foo

\n
\n", + "example": 88, + "start_line": 1464, + "end_line": 1475, + "section": "Setext headings" + }, + { + "markdown": "Foo \n-----\n", + "html": "

Foo

\n", + "example": 89, + "start_line": 1480, + "end_line": 1485, + "section": "Setext headings" + }, + { + "markdown": "Foo\\\n----\n", + "html": "

Foo\\

\n", + "example": 90, + "start_line": 1490, + "end_line": 1495, + "section": "Setext headings" + }, + { + "markdown": "`Foo\n----\n`\n\n\n", + "html": "

`Foo

\n

`

\n

<a title="a lot

\n

of dashes"/>

\n", + "example": 91, + "start_line": 1501, + "end_line": 1514, + "section": "Setext headings" + }, + { + "markdown": "> Foo\n---\n", + "html": "
\n

Foo

\n
\n
\n", + "example": 92, + "start_line": 1520, + "end_line": 1528, + "section": "Setext headings" + }, + { + "markdown": "> foo\nbar\n===\n", + "html": "
\n

foo\nbar\n===

\n
\n", + "example": 93, + "start_line": 1531, + "end_line": 1541, + "section": "Setext headings" + }, + { + "markdown": "- Foo\n---\n", + "html": "
    \n
  • Foo
  • \n
\n
\n", + "example": 94, + "start_line": 1544, + "end_line": 1552, + "section": "Setext headings" + }, + { + "markdown": "Foo\nBar\n---\n", + "html": "

Foo\nBar

\n", + "example": 95, + "start_line": 1559, + "end_line": 1566, + "section": "Setext headings" + }, + { + "markdown": "---\nFoo\n---\nBar\n---\nBaz\n", + "html": "
\n

Foo

\n

Bar

\n

Baz

\n", + "example": 96, + "start_line": 1572, + "end_line": 1584, + "section": "Setext headings" + }, + { + "markdown": "\n====\n", + "html": "

====

\n", + "example": 97, + "start_line": 1589, + "end_line": 1594, + "section": "Setext headings" + }, + { + "markdown": "---\n---\n", + "html": "
\n
\n", + "example": 98, + "start_line": 1601, + "end_line": 1607, + "section": "Setext headings" + }, + { + "markdown": "- foo\n-----\n", + "html": "
    \n
  • foo
  • \n
\n
\n", + "example": 99, + "start_line": 1610, + "end_line": 1618, + "section": "Setext headings" + }, + { + "markdown": " foo\n---\n", + "html": "
foo\n
\n
\n", + "example": 100, + "start_line": 1621, + "end_line": 1628, + "section": "Setext headings" + }, + { + "markdown": "> foo\n-----\n", + "html": "
\n

foo

\n
\n
\n", + "example": 101, + "start_line": 1631, + "end_line": 1639, + "section": "Setext headings" + }, + { + "markdown": "\\> foo\n------\n", + "html": "

> foo

\n", + "example": 102, + "start_line": 1645, + "end_line": 1650, + "section": "Setext headings" + }, + { + "markdown": "Foo\n\nbar\n---\nbaz\n", + "html": "

Foo

\n

bar

\n

baz

\n", + "example": 103, + "start_line": 1676, + "end_line": 1686, + "section": "Setext headings" + }, + { + "markdown": "Foo\nbar\n\n---\n\nbaz\n", + "html": "

Foo\nbar

\n
\n

baz

\n", + "example": 104, + "start_line": 1692, + "end_line": 1704, + "section": "Setext headings" + }, + { + "markdown": "Foo\nbar\n* * *\nbaz\n", + "html": "

Foo\nbar

\n
\n

baz

\n", + "example": 105, + "start_line": 1710, + "end_line": 1720, + "section": "Setext headings" + }, + { + "markdown": "Foo\nbar\n\\---\nbaz\n", + "html": "

Foo\nbar\n---\nbaz

\n", + "example": 106, + "start_line": 1725, + "end_line": 1735, + "section": "Setext headings" + }, + { + "markdown": " a simple\n indented code block\n", + "html": "
a simple\n  indented code block\n
\n", + "example": 107, + "start_line": 1753, + "end_line": 1760, + "section": "Indented code blocks" + }, + { + "markdown": " - foo\n\n bar\n", + "html": "
    \n
  • \n

    foo

    \n

    bar

    \n
  • \n
\n", + "example": 108, + "start_line": 1767, + "end_line": 1778, + "section": "Indented code blocks" + }, + { + "markdown": "1. foo\n\n - bar\n", + "html": "
    \n
  1. \n

    foo

    \n
      \n
    • bar
    • \n
    \n
  2. \n
\n", + "example": 109, + "start_line": 1781, + "end_line": 1794, + "section": "Indented code blocks" + }, + { + "markdown": "
\n *hi*\n\n - one\n", + "html": "
<a/>\n*hi*\n\n- one\n
\n", + "example": 110, + "start_line": 1801, + "end_line": 1812, + "section": "Indented code blocks" + }, + { + "markdown": " chunk1\n\n chunk2\n \n \n \n chunk3\n", + "html": "
chunk1\n\nchunk2\n\n\n\nchunk3\n
\n", + "example": 111, + "start_line": 1817, + "end_line": 1834, + "section": "Indented code blocks" + }, + { + "markdown": " chunk1\n \n chunk2\n", + "html": "
chunk1\n  \n  chunk2\n
\n", + "example": 112, + "start_line": 1840, + "end_line": 1849, + "section": "Indented code blocks" + }, + { + "markdown": "Foo\n bar\n\n", + "html": "

Foo\nbar

\n", + "example": 113, + "start_line": 1855, + "end_line": 1862, + "section": "Indented code blocks" + }, + { + "markdown": " foo\nbar\n", + "html": "
foo\n
\n

bar

\n", + "example": 114, + "start_line": 1869, + "end_line": 1876, + "section": "Indented code blocks" + }, + { + "markdown": "# Heading\n foo\nHeading\n------\n foo\n----\n", + "html": "

Heading

\n
foo\n
\n

Heading

\n
foo\n
\n
\n", + "example": 115, + "start_line": 1882, + "end_line": 1897, + "section": "Indented code blocks" + }, + { + "markdown": " foo\n bar\n", + "html": "
    foo\nbar\n
\n", + "example": 116, + "start_line": 1902, + "end_line": 1909, + "section": "Indented code blocks" + }, + { + "markdown": "\n \n foo\n \n\n", + "html": "
foo\n
\n", + "example": 117, + "start_line": 1915, + "end_line": 1924, + "section": "Indented code blocks" + }, + { + "markdown": " foo \n", + "html": "
foo  \n
\n", + "example": 118, + "start_line": 1929, + "end_line": 1934, + "section": "Indented code blocks" + }, + { + "markdown": "```\n<\n >\n```\n", + "html": "
<\n >\n
\n", + "example": 119, + "start_line": 1984, + "end_line": 1993, + "section": "Fenced code blocks" + }, + { + "markdown": "~~~\n<\n >\n~~~\n", + "html": "
<\n >\n
\n", + "example": 120, + "start_line": 1998, + "end_line": 2007, + "section": "Fenced code blocks" + }, + { + "markdown": "``\nfoo\n``\n", + "html": "

foo

\n", + "example": 121, + "start_line": 2011, + "end_line": 2017, + "section": "Fenced code blocks" + }, + { + "markdown": "```\naaa\n~~~\n```\n", + "html": "
aaa\n~~~\n
\n", + "example": 122, + "start_line": 2022, + "end_line": 2031, + "section": "Fenced code blocks" + }, + { + "markdown": "~~~\naaa\n```\n~~~\n", + "html": "
aaa\n```\n
\n", + "example": 123, + "start_line": 2034, + "end_line": 2043, + "section": "Fenced code blocks" + }, + { + "markdown": "````\naaa\n```\n``````\n", + "html": "
aaa\n```\n
\n", + "example": 124, + "start_line": 2048, + "end_line": 2057, + "section": "Fenced code blocks" + }, + { + "markdown": "~~~~\naaa\n~~~\n~~~~\n", + "html": "
aaa\n~~~\n
\n", + "example": 125, + "start_line": 2060, + "end_line": 2069, + "section": "Fenced code blocks" + }, + { + "markdown": "```\n", + "html": "
\n", + "example": 126, + "start_line": 2075, + "end_line": 2079, + "section": "Fenced code blocks" + }, + { + "markdown": "`````\n\n```\naaa\n", + "html": "
\n```\naaa\n
\n", + "example": 127, + "start_line": 2082, + "end_line": 2092, + "section": "Fenced code blocks" + }, + { + "markdown": "> ```\n> aaa\n\nbbb\n", + "html": "
\n
aaa\n
\n
\n

bbb

\n", + "example": 128, + "start_line": 2095, + "end_line": 2106, + "section": "Fenced code blocks" + }, + { + "markdown": "```\n\n \n```\n", + "html": "
\n  \n
\n", + "example": 129, + "start_line": 2111, + "end_line": 2120, + "section": "Fenced code blocks" + }, + { + "markdown": "```\n```\n", + "html": "
\n", + "example": 130, + "start_line": 2125, + "end_line": 2130, + "section": "Fenced code blocks" + }, + { + "markdown": " ```\n aaa\naaa\n```\n", + "html": "
aaa\naaa\n
\n", + "example": 131, + "start_line": 2137, + "end_line": 2146, + "section": "Fenced code blocks" + }, + { + "markdown": " ```\naaa\n aaa\naaa\n ```\n", + "html": "
aaa\naaa\naaa\n
\n", + "example": 132, + "start_line": 2149, + "end_line": 2160, + "section": "Fenced code blocks" + }, + { + "markdown": " ```\n aaa\n aaa\n aaa\n ```\n", + "html": "
aaa\n aaa\naaa\n
\n", + "example": 133, + "start_line": 2163, + "end_line": 2174, + "section": "Fenced code blocks" + }, + { + "markdown": " ```\n aaa\n ```\n", + "html": "
```\naaa\n```\n
\n", + "example": 134, + "start_line": 2179, + "end_line": 2188, + "section": "Fenced code blocks" + }, + { + "markdown": "```\naaa\n ```\n", + "html": "
aaa\n
\n", + "example": 135, + "start_line": 2194, + "end_line": 2201, + "section": "Fenced code blocks" + }, + { + "markdown": " ```\naaa\n ```\n", + "html": "
aaa\n
\n", + "example": 136, + "start_line": 2204, + "end_line": 2211, + "section": "Fenced code blocks" + }, + { + "markdown": "```\naaa\n ```\n", + "html": "
aaa\n    ```\n
\n", + "example": 137, + "start_line": 2216, + "end_line": 2224, + "section": "Fenced code blocks" + }, + { + "markdown": "``` ```\naaa\n", + "html": "

\naaa

\n", + "example": 138, + "start_line": 2230, + "end_line": 2236, + "section": "Fenced code blocks" + }, + { + "markdown": "~~~~~~\naaa\n~~~ ~~\n", + "html": "
aaa\n~~~ ~~\n
\n", + "example": 139, + "start_line": 2239, + "end_line": 2247, + "section": "Fenced code blocks" + }, + { + "markdown": "foo\n```\nbar\n```\nbaz\n", + "html": "

foo

\n
bar\n
\n

baz

\n", + "example": 140, + "start_line": 2253, + "end_line": 2264, + "section": "Fenced code blocks" + }, + { + "markdown": "foo\n---\n~~~\nbar\n~~~\n# baz\n", + "html": "

foo

\n
bar\n
\n

baz

\n", + "example": 141, + "start_line": 2270, + "end_line": 2282, + "section": "Fenced code blocks" + }, + { + "markdown": "```ruby\ndef foo(x)\n return 3\nend\n```\n", + "html": "
def foo(x)\n  return 3\nend\n
\n", + "example": 142, + "start_line": 2292, + "end_line": 2303, + "section": "Fenced code blocks" + }, + { + "markdown": "~~~~ ruby startline=3 $%@#$\ndef foo(x)\n return 3\nend\n~~~~~~~\n", + "html": "
def foo(x)\n  return 3\nend\n
\n", + "example": 143, + "start_line": 2306, + "end_line": 2317, + "section": "Fenced code blocks" + }, + { + "markdown": "````;\n````\n", + "html": "
\n", + "example": 144, + "start_line": 2320, + "end_line": 2325, + "section": "Fenced code blocks" + }, + { + "markdown": "``` aa ```\nfoo\n", + "html": "

aa\nfoo

\n", + "example": 145, + "start_line": 2330, + "end_line": 2336, + "section": "Fenced code blocks" + }, + { + "markdown": "~~~ aa ``` ~~~\nfoo\n~~~\n", + "html": "
foo\n
\n", + "example": 146, + "start_line": 2341, + "end_line": 2348, + "section": "Fenced code blocks" + }, + { + "markdown": "```\n``` aaa\n```\n", + "html": "
``` aaa\n
\n", + "example": 147, + "start_line": 2353, + "end_line": 2360, + "section": "Fenced code blocks" + }, + { + "markdown": "
\n
\n**Hello**,\n\n_world_.\n
\n
\n", + "html": "
\n
\n**Hello**,\n

world.\n

\n
\n", + "example": 148, + "start_line": 2432, + "end_line": 2447, + "section": "HTML blocks" + }, + { + "markdown": "\n \n \n \n
\n hi\n
\n\nokay.\n", + "html": "\n \n \n \n
\n hi\n
\n

okay.

\n", + "example": 149, + "start_line": 2461, + "end_line": 2480, + "section": "HTML blocks" + }, + { + "markdown": "
\n*foo*\n", + "example": 151, + "start_line": 2496, + "end_line": 2502, + "section": "HTML blocks" + }, + { + "markdown": "
\n\n*Markdown*\n\n
\n", + "html": "
\n

Markdown

\n
\n", + "example": 152, + "start_line": 2507, + "end_line": 2517, + "section": "HTML blocks" + }, + { + "markdown": "
\n
\n", + "html": "
\n
\n", + "example": 153, + "start_line": 2523, + "end_line": 2531, + "section": "HTML blocks" + }, + { + "markdown": "
\n
\n", + "html": "
\n
\n", + "example": 154, + "start_line": 2534, + "end_line": 2542, + "section": "HTML blocks" + }, + { + "markdown": "
\n*foo*\n\n*bar*\n", + "html": "
\n*foo*\n

bar

\n", + "example": 155, + "start_line": 2546, + "end_line": 2555, + "section": "HTML blocks" + }, + { + "markdown": "
\n", + "html": "\n", + "example": 159, + "start_line": 2595, + "end_line": 2599, + "section": "HTML blocks" + }, + { + "markdown": "
\nfoo\n
\n", + "html": "
\nfoo\n
\n", + "example": 160, + "start_line": 2602, + "end_line": 2610, + "section": "HTML blocks" + }, + { + "markdown": "
\n``` c\nint x = 33;\n```\n", + "html": "
\n``` c\nint x = 33;\n```\n", + "example": 161, + "start_line": 2619, + "end_line": 2629, + "section": "HTML blocks" + }, + { + "markdown": "\n*bar*\n\n", + "html": "\n*bar*\n\n", + "example": 162, + "start_line": 2636, + "end_line": 2644, + "section": "HTML blocks" + }, + { + "markdown": "\n*bar*\n\n", + "html": "\n*bar*\n\n", + "example": 163, + "start_line": 2649, + "end_line": 2657, + "section": "HTML blocks" + }, + { + "markdown": "\n*bar*\n\n", + "html": "\n*bar*\n\n", + "example": 164, + "start_line": 2660, + "end_line": 2668, + "section": "HTML blocks" + }, + { + "markdown": "\n*bar*\n", + "html": "\n*bar*\n", + "example": 165, + "start_line": 2671, + "end_line": 2677, + "section": "HTML blocks" + }, + { + "markdown": "\n*foo*\n\n", + "html": "\n*foo*\n\n", + "example": 166, + "start_line": 2686, + "end_line": 2694, + "section": "HTML blocks" + }, + { + "markdown": "\n\n*foo*\n\n\n", + "html": "\n

foo

\n
\n", + "example": 167, + "start_line": 2701, + "end_line": 2711, + "section": "HTML blocks" + }, + { + "markdown": "*foo*\n", + "html": "

foo

\n", + "example": 168, + "start_line": 2719, + "end_line": 2723, + "section": "HTML blocks" + }, + { + "markdown": "
\nimport Text.HTML.TagSoup\n\nmain :: IO ()\nmain = print $ parseTags tags\n
\nokay\n", + "html": "
\nimport Text.HTML.TagSoup\n\nmain :: IO ()\nmain = print $ parseTags tags\n
\n

okay

\n", + "example": 169, + "start_line": 2735, + "end_line": 2751, + "section": "HTML blocks" + }, + { + "markdown": "\nokay\n", + "html": "\n

okay

\n", + "example": 170, + "start_line": 2756, + "end_line": 2770, + "section": "HTML blocks" + }, + { + "markdown": "\n", + "html": "\n", + "example": 171, + "start_line": 2775, + "end_line": 2791, + "section": "HTML blocks" + }, + { + "markdown": "\nh1 {color:red;}\n\np {color:blue;}\n\nokay\n", + "html": "\nh1 {color:red;}\n\np {color:blue;}\n\n

okay

\n", + "example": 172, + "start_line": 2795, + "end_line": 2811, + "section": "HTML blocks" + }, + { + "markdown": "\n\nfoo\n", + "html": "\n\nfoo\n", + "example": 173, + "start_line": 2818, + "end_line": 2828, + "section": "HTML blocks" + }, + { + "markdown": ">
\n> foo\n\nbar\n", + "html": "
\n
\nfoo\n
\n

bar

\n", + "example": 174, + "start_line": 2831, + "end_line": 2842, + "section": "HTML blocks" + }, + { + "markdown": "-
\n- foo\n", + "html": "
    \n
  • \n
    \n
  • \n
  • foo
  • \n
\n", + "example": 175, + "start_line": 2845, + "end_line": 2855, + "section": "HTML blocks" + }, + { + "markdown": "\n*foo*\n", + "html": "\n

foo

\n", + "example": 176, + "start_line": 2860, + "end_line": 2866, + "section": "HTML blocks" + }, + { + "markdown": "*bar*\n*baz*\n", + "html": "*bar*\n

baz

\n", + "example": 177, + "start_line": 2869, + "end_line": 2875, + "section": "HTML blocks" + }, + { + "markdown": "1. *bar*\n", + "html": "1. *bar*\n", + "example": 178, + "start_line": 2881, + "end_line": 2889, + "section": "HTML blocks" + }, + { + "markdown": "\nokay\n", + "html": "\n

okay

\n", + "example": 179, + "start_line": 2894, + "end_line": 2906, + "section": "HTML blocks" + }, + { + "markdown": "';\n\n?>\nokay\n", + "html": "';\n\n?>\n

okay

\n", + "example": 180, + "start_line": 2912, + "end_line": 2926, + "section": "HTML blocks" + }, + { + "markdown": "\n", + "html": "\n", + "example": 181, + "start_line": 2931, + "end_line": 2935, + "section": "HTML blocks" + }, + { + "markdown": "\nokay\n", + "html": "\n

okay

\n", + "example": 182, + "start_line": 2940, + "end_line": 2968, + "section": "HTML blocks" + }, + { + "markdown": " \n\n \n", + "html": " \n
<!-- foo -->\n
\n", + "example": 183, + "start_line": 2974, + "end_line": 2982, + "section": "HTML blocks" + }, + { + "markdown": "
\n\n
\n", + "html": "
\n
<div>\n
\n", + "example": 184, + "start_line": 2985, + "end_line": 2993, + "section": "HTML blocks" + }, + { + "markdown": "Foo\n
\nbar\n
\n", + "html": "

Foo

\n
\nbar\n
\n", + "example": 185, + "start_line": 2999, + "end_line": 3009, + "section": "HTML blocks" + }, + { + "markdown": "
\nbar\n
\n*foo*\n", + "html": "
\nbar\n
\n*foo*\n", + "example": 186, + "start_line": 3016, + "end_line": 3026, + "section": "HTML blocks" + }, + { + "markdown": "Foo\n\nbaz\n", + "html": "

Foo\n\nbaz

\n", + "example": 187, + "start_line": 3031, + "end_line": 3039, + "section": "HTML blocks" + }, + { + "markdown": "
\n\n*Emphasized* text.\n\n
\n", + "html": "
\n

Emphasized text.

\n
\n", + "example": 188, + "start_line": 3072, + "end_line": 3082, + "section": "HTML blocks" + }, + { + "markdown": "
\n*Emphasized* text.\n
\n", + "html": "
\n*Emphasized* text.\n
\n", + "example": 189, + "start_line": 3085, + "end_line": 3093, + "section": "HTML blocks" + }, + { + "markdown": "\n\n\n\n\n\n\n\n
\nHi\n
\n", + "html": "\n\n\n\n
\nHi\n
\n", + "example": 190, + "start_line": 3107, + "end_line": 3127, + "section": "HTML blocks" + }, + { + "markdown": "\n\n \n\n \n\n \n\n
\n Hi\n
\n", + "html": "\n \n
<td>\n  Hi\n</td>\n
\n \n
\n", + "example": 191, + "start_line": 3134, + "end_line": 3155, + "section": "HTML blocks" + }, + { + "markdown": "[foo]: /url \"title\"\n\n[foo]\n", + "html": "

foo

\n", + "example": 192, + "start_line": 3183, + "end_line": 3189, + "section": "Link reference definitions" + }, + { + "markdown": " [foo]: \n /url \n 'the title' \n\n[foo]\n", + "html": "

foo

\n", + "example": 193, + "start_line": 3192, + "end_line": 3200, + "section": "Link reference definitions" + }, + { + "markdown": "[Foo*bar\\]]:my_(url) 'title (with parens)'\n\n[Foo*bar\\]]\n", + "html": "

Foo*bar]

\n", + "example": 194, + "start_line": 3203, + "end_line": 3209, + "section": "Link reference definitions" + }, + { + "markdown": "[Foo bar]:\n\n'title'\n\n[Foo bar]\n", + "html": "

Foo bar

\n", + "example": 195, + "start_line": 3212, + "end_line": 3220, + "section": "Link reference definitions" + }, + { + "markdown": "[foo]: /url '\ntitle\nline1\nline2\n'\n\n[foo]\n", + "html": "

foo

\n", + "example": 196, + "start_line": 3225, + "end_line": 3239, + "section": "Link reference definitions" + }, + { + "markdown": "[foo]: /url 'title\n\nwith blank line'\n\n[foo]\n", + "html": "

[foo]: /url 'title

\n

with blank line'

\n

[foo]

\n", + "example": 197, + "start_line": 3244, + "end_line": 3254, + "section": "Link reference definitions" + }, + { + "markdown": "[foo]:\n/url\n\n[foo]\n", + "html": "

foo

\n", + "example": 198, + "start_line": 3259, + "end_line": 3266, + "section": "Link reference definitions" + }, + { + "markdown": "[foo]:\n\n[foo]\n", + "html": "

[foo]:

\n

[foo]

\n", + "example": 199, + "start_line": 3271, + "end_line": 3278, + "section": "Link reference definitions" + }, + { + "markdown": "[foo]: <>\n\n[foo]\n", + "html": "

foo

\n", + "example": 200, + "start_line": 3283, + "end_line": 3289, + "section": "Link reference definitions" + }, + { + "markdown": "[foo]: (baz)\n\n[foo]\n", + "html": "

[foo]: (baz)

\n

[foo]

\n", + "example": 201, + "start_line": 3294, + "end_line": 3301, + "section": "Link reference definitions" + }, + { + "markdown": "[foo]: /url\\bar\\*baz \"foo\\\"bar\\baz\"\n\n[foo]\n", + "html": "

foo

\n", + "example": 202, + "start_line": 3307, + "end_line": 3313, + "section": "Link reference definitions" + }, + { + "markdown": "[foo]\n\n[foo]: url\n", + "html": "

foo

\n", + "example": 203, + "start_line": 3318, + "end_line": 3324, + "section": "Link reference definitions" + }, + { + "markdown": "[foo]\n\n[foo]: first\n[foo]: second\n", + "html": "

foo

\n", + "example": 204, + "start_line": 3330, + "end_line": 3337, + "section": "Link reference definitions" + }, + { + "markdown": "[FOO]: /url\n\n[Foo]\n", + "html": "

Foo

\n", + "example": 205, + "start_line": 3343, + "end_line": 3349, + "section": "Link reference definitions" + }, + { + "markdown": "[ΑΓΩ]: /φου\n\n[αγω]\n", + "html": "

αγω

\n", + "example": 206, + "start_line": 3352, + "end_line": 3358, + "section": "Link reference definitions" + }, + { + "markdown": "[foo]: /url\n", + "html": "", + "example": 207, + "start_line": 3367, + "end_line": 3370, + "section": "Link reference definitions" + }, + { + "markdown": "[\nfoo\n]: /url\nbar\n", + "html": "

bar

\n", + "example": 208, + "start_line": 3375, + "end_line": 3382, + "section": "Link reference definitions" + }, + { + "markdown": "[foo]: /url \"title\" ok\n", + "html": "

[foo]: /url "title" ok

\n", + "example": 209, + "start_line": 3388, + "end_line": 3392, + "section": "Link reference definitions" + }, + { + "markdown": "[foo]: /url\n\"title\" ok\n", + "html": "

"title" ok

\n", + "example": 210, + "start_line": 3397, + "end_line": 3402, + "section": "Link reference definitions" + }, + { + "markdown": " [foo]: /url \"title\"\n\n[foo]\n", + "html": "
[foo]: /url "title"\n
\n

[foo]

\n", + "example": 211, + "start_line": 3408, + "end_line": 3416, + "section": "Link reference definitions" + }, + { + "markdown": "```\n[foo]: /url\n```\n\n[foo]\n", + "html": "
[foo]: /url\n
\n

[foo]

\n", + "example": 212, + "start_line": 3422, + "end_line": 3432, + "section": "Link reference definitions" + }, + { + "markdown": "Foo\n[bar]: /baz\n\n[bar]\n", + "html": "

Foo\n[bar]: /baz

\n

[bar]

\n", + "example": 213, + "start_line": 3437, + "end_line": 3446, + "section": "Link reference definitions" + }, + { + "markdown": "# [Foo]\n[foo]: /url\n> bar\n", + "html": "

Foo

\n
\n

bar

\n
\n", + "example": 214, + "start_line": 3452, + "end_line": 3461, + "section": "Link reference definitions" + }, + { + "markdown": "[foo]: /url\nbar\n===\n[foo]\n", + "html": "

bar

\n

foo

\n", + "example": 215, + "start_line": 3463, + "end_line": 3471, + "section": "Link reference definitions" + }, + { + "markdown": "[foo]: /url\n===\n[foo]\n", + "html": "

===\nfoo

\n", + "example": 216, + "start_line": 3473, + "end_line": 3480, + "section": "Link reference definitions" + }, + { + "markdown": "[foo]: /foo-url \"foo\"\n[bar]: /bar-url\n \"bar\"\n[baz]: /baz-url\n\n[foo],\n[bar],\n[baz]\n", + "html": "

foo,\nbar,\nbaz

\n", + "example": 217, + "start_line": 3486, + "end_line": 3499, + "section": "Link reference definitions" + }, + { + "markdown": "[foo]\n\n> [foo]: /url\n", + "html": "

foo

\n
\n
\n", + "example": 218, + "start_line": 3507, + "end_line": 3515, + "section": "Link reference definitions" + }, + { + "markdown": "aaa\n\nbbb\n", + "html": "

aaa

\n

bbb

\n", + "example": 219, + "start_line": 3529, + "end_line": 3536, + "section": "Paragraphs" + }, + { + "markdown": "aaa\nbbb\n\nccc\nddd\n", + "html": "

aaa\nbbb

\n

ccc\nddd

\n", + "example": 220, + "start_line": 3541, + "end_line": 3552, + "section": "Paragraphs" + }, + { + "markdown": "aaa\n\n\nbbb\n", + "html": "

aaa

\n

bbb

\n", + "example": 221, + "start_line": 3557, + "end_line": 3565, + "section": "Paragraphs" + }, + { + "markdown": " aaa\n bbb\n", + "html": "

aaa\nbbb

\n", + "example": 222, + "start_line": 3570, + "end_line": 3576, + "section": "Paragraphs" + }, + { + "markdown": "aaa\n bbb\n ccc\n", + "html": "

aaa\nbbb\nccc

\n", + "example": 223, + "start_line": 3582, + "end_line": 3590, + "section": "Paragraphs" + }, + { + "markdown": " aaa\nbbb\n", + "html": "

aaa\nbbb

\n", + "example": 224, + "start_line": 3596, + "end_line": 3602, + "section": "Paragraphs" + }, + { + "markdown": " aaa\nbbb\n", + "html": "
aaa\n
\n

bbb

\n", + "example": 225, + "start_line": 3605, + "end_line": 3612, + "section": "Paragraphs" + }, + { + "markdown": "aaa \nbbb \n", + "html": "

aaa
\nbbb

\n", + "example": 226, + "start_line": 3619, + "end_line": 3625, + "section": "Paragraphs" + }, + { + "markdown": " \n\naaa\n \n\n# aaa\n\n \n", + "html": "

aaa

\n

aaa

\n", + "example": 227, + "start_line": 3636, + "end_line": 3648, + "section": "Blank lines" + }, + { + "markdown": "> # Foo\n> bar\n> baz\n", + "html": "
\n

Foo

\n

bar\nbaz

\n
\n", + "example": 228, + "start_line": 3704, + "end_line": 3714, + "section": "Block quotes" + }, + { + "markdown": "># Foo\n>bar\n> baz\n", + "html": "
\n

Foo

\n

bar\nbaz

\n
\n", + "example": 229, + "start_line": 3719, + "end_line": 3729, + "section": "Block quotes" + }, + { + "markdown": " > # Foo\n > bar\n > baz\n", + "html": "
\n

Foo

\n

bar\nbaz

\n
\n", + "example": 230, + "start_line": 3734, + "end_line": 3744, + "section": "Block quotes" + }, + { + "markdown": " > # Foo\n > bar\n > baz\n", + "html": "
> # Foo\n> bar\n> baz\n
\n", + "example": 231, + "start_line": 3749, + "end_line": 3758, + "section": "Block quotes" + }, + { + "markdown": "> # Foo\n> bar\nbaz\n", + "html": "
\n

Foo

\n

bar\nbaz

\n
\n", + "example": 232, + "start_line": 3764, + "end_line": 3774, + "section": "Block quotes" + }, + { + "markdown": "> bar\nbaz\n> foo\n", + "html": "
\n

bar\nbaz\nfoo

\n
\n", + "example": 233, + "start_line": 3780, + "end_line": 3790, + "section": "Block quotes" + }, + { + "markdown": "> foo\n---\n", + "html": "
\n

foo

\n
\n
\n", + "example": 234, + "start_line": 3804, + "end_line": 3812, + "section": "Block quotes" + }, + { + "markdown": "> - foo\n- bar\n", + "html": "
\n
    \n
  • foo
  • \n
\n
\n
    \n
  • bar
  • \n
\n", + "example": 235, + "start_line": 3824, + "end_line": 3836, + "section": "Block quotes" + }, + { + "markdown": "> foo\n bar\n", + "html": "
\n
foo\n
\n
\n
bar\n
\n", + "example": 236, + "start_line": 3842, + "end_line": 3852, + "section": "Block quotes" + }, + { + "markdown": "> ```\nfoo\n```\n", + "html": "
\n
\n
\n

foo

\n
\n", + "example": 237, + "start_line": 3855, + "end_line": 3865, + "section": "Block quotes" + }, + { + "markdown": "> foo\n - bar\n", + "html": "
\n

foo\n- bar

\n
\n", + "example": 238, + "start_line": 3871, + "end_line": 3879, + "section": "Block quotes" + }, + { + "markdown": ">\n", + "html": "
\n
\n", + "example": 239, + "start_line": 3895, + "end_line": 3900, + "section": "Block quotes" + }, + { + "markdown": ">\n> \n> \n", + "html": "
\n
\n", + "example": 240, + "start_line": 3903, + "end_line": 3910, + "section": "Block quotes" + }, + { + "markdown": ">\n> foo\n> \n", + "html": "
\n

foo

\n
\n", + "example": 241, + "start_line": 3915, + "end_line": 3923, + "section": "Block quotes" + }, + { + "markdown": "> foo\n\n> bar\n", + "html": "
\n

foo

\n
\n
\n

bar

\n
\n", + "example": 242, + "start_line": 3928, + "end_line": 3939, + "section": "Block quotes" + }, + { + "markdown": "> foo\n> bar\n", + "html": "
\n

foo\nbar

\n
\n", + "example": 243, + "start_line": 3950, + "end_line": 3958, + "section": "Block quotes" + }, + { + "markdown": "> foo\n>\n> bar\n", + "html": "
\n

foo

\n

bar

\n
\n", + "example": 244, + "start_line": 3963, + "end_line": 3972, + "section": "Block quotes" + }, + { + "markdown": "foo\n> bar\n", + "html": "

foo

\n
\n

bar

\n
\n", + "example": 245, + "start_line": 3977, + "end_line": 3985, + "section": "Block quotes" + }, + { + "markdown": "> aaa\n***\n> bbb\n", + "html": "
\n

aaa

\n
\n
\n
\n

bbb

\n
\n", + "example": 246, + "start_line": 3991, + "end_line": 4003, + "section": "Block quotes" + }, + { + "markdown": "> bar\nbaz\n", + "html": "
\n

bar\nbaz

\n
\n", + "example": 247, + "start_line": 4009, + "end_line": 4017, + "section": "Block quotes" + }, + { + "markdown": "> bar\n\nbaz\n", + "html": "
\n

bar

\n
\n

baz

\n", + "example": 248, + "start_line": 4020, + "end_line": 4029, + "section": "Block quotes" + }, + { + "markdown": "> bar\n>\nbaz\n", + "html": "
\n

bar

\n
\n

baz

\n", + "example": 249, + "start_line": 4032, + "end_line": 4041, + "section": "Block quotes" + }, + { + "markdown": "> > > foo\nbar\n", + "html": "
\n
\n
\n

foo\nbar

\n
\n
\n
\n", + "example": 250, + "start_line": 4048, + "end_line": 4060, + "section": "Block quotes" + }, + { + "markdown": ">>> foo\n> bar\n>>baz\n", + "html": "
\n
\n
\n

foo\nbar\nbaz

\n
\n
\n
\n", + "example": 251, + "start_line": 4063, + "end_line": 4077, + "section": "Block quotes" + }, + { + "markdown": "> code\n\n> not code\n", + "html": "
\n
code\n
\n
\n
\n

not code

\n
\n", + "example": 252, + "start_line": 4085, + "end_line": 4097, + "section": "Block quotes" + }, + { + "markdown": "A paragraph\nwith two lines.\n\n indented code\n\n> A block quote.\n", + "html": "

A paragraph\nwith two lines.

\n
indented code\n
\n
\n

A block quote.

\n
\n", + "example": 253, + "start_line": 4139, + "end_line": 4154, + "section": "List items" + }, + { + "markdown": "1. A paragraph\n with two lines.\n\n indented code\n\n > A block quote.\n", + "html": "
    \n
  1. \n

    A paragraph\nwith two lines.

    \n
    indented code\n
    \n
    \n

    A block quote.

    \n
    \n
  2. \n
\n", + "example": 254, + "start_line": 4161, + "end_line": 4180, + "section": "List items" + }, + { + "markdown": "- one\n\n two\n", + "html": "
    \n
  • one
  • \n
\n

two

\n", + "example": 255, + "start_line": 4194, + "end_line": 4203, + "section": "List items" + }, + { + "markdown": "- one\n\n two\n", + "html": "
    \n
  • \n

    one

    \n

    two

    \n
  • \n
\n", + "example": 256, + "start_line": 4206, + "end_line": 4217, + "section": "List items" + }, + { + "markdown": " - one\n\n two\n", + "html": "
    \n
  • one
  • \n
\n
 two\n
\n", + "example": 257, + "start_line": 4220, + "end_line": 4230, + "section": "List items" + }, + { + "markdown": " - one\n\n two\n", + "html": "
    \n
  • \n

    one

    \n

    two

    \n
  • \n
\n", + "example": 258, + "start_line": 4233, + "end_line": 4244, + "section": "List items" + }, + { + "markdown": " > > 1. one\n>>\n>> two\n", + "html": "
\n
\n
    \n
  1. \n

    one

    \n

    two

    \n
  2. \n
\n
\n
\n", + "example": 259, + "start_line": 4255, + "end_line": 4270, + "section": "List items" + }, + { + "markdown": ">>- one\n>>\n > > two\n", + "html": "
\n
\n
    \n
  • one
  • \n
\n

two

\n
\n
\n", + "example": 260, + "start_line": 4282, + "end_line": 4295, + "section": "List items" + }, + { + "markdown": "-one\n\n2.two\n", + "html": "

-one

\n

2.two

\n", + "example": 261, + "start_line": 4301, + "end_line": 4308, + "section": "List items" + }, + { + "markdown": "- foo\n\n\n bar\n", + "html": "
    \n
  • \n

    foo

    \n

    bar

    \n
  • \n
\n", + "example": 262, + "start_line": 4314, + "end_line": 4326, + "section": "List items" + }, + { + "markdown": "1. foo\n\n ```\n bar\n ```\n\n baz\n\n > bam\n", + "html": "
    \n
  1. \n

    foo

    \n
    bar\n
    \n

    baz

    \n
    \n

    bam

    \n
    \n
  2. \n
\n", + "example": 263, + "start_line": 4331, + "end_line": 4353, + "section": "List items" + }, + { + "markdown": "- Foo\n\n bar\n\n\n baz\n", + "html": "
    \n
  • \n

    Foo

    \n
    bar\n\n\nbaz\n
    \n
  • \n
\n", + "example": 264, + "start_line": 4359, + "end_line": 4377, + "section": "List items" + }, + { + "markdown": "123456789. ok\n", + "html": "
    \n
  1. ok
  2. \n
\n", + "example": 265, + "start_line": 4381, + "end_line": 4387, + "section": "List items" + }, + { + "markdown": "1234567890. not ok\n", + "html": "

1234567890. not ok

\n", + "example": 266, + "start_line": 4390, + "end_line": 4394, + "section": "List items" + }, + { + "markdown": "0. ok\n", + "html": "
    \n
  1. ok
  2. \n
\n", + "example": 267, + "start_line": 4399, + "end_line": 4405, + "section": "List items" + }, + { + "markdown": "003. ok\n", + "html": "
    \n
  1. ok
  2. \n
\n", + "example": 268, + "start_line": 4408, + "end_line": 4414, + "section": "List items" + }, + { + "markdown": "-1. not ok\n", + "html": "

-1. not ok

\n", + "example": 269, + "start_line": 4419, + "end_line": 4423, + "section": "List items" + }, + { + "markdown": "- foo\n\n bar\n", + "html": "
    \n
  • \n

    foo

    \n
    bar\n
    \n
  • \n
\n", + "example": 270, + "start_line": 4442, + "end_line": 4454, + "section": "List items" + }, + { + "markdown": " 10. foo\n\n bar\n", + "html": "
    \n
  1. \n

    foo

    \n
    bar\n
    \n
  2. \n
\n", + "example": 271, + "start_line": 4459, + "end_line": 4471, + "section": "List items" + }, + { + "markdown": " indented code\n\nparagraph\n\n more code\n", + "html": "
indented code\n
\n

paragraph

\n
more code\n
\n", + "example": 272, + "start_line": 4478, + "end_line": 4490, + "section": "List items" + }, + { + "markdown": "1. indented code\n\n paragraph\n\n more code\n", + "html": "
    \n
  1. \n
    indented code\n
    \n

    paragraph

    \n
    more code\n
    \n
  2. \n
\n", + "example": 273, + "start_line": 4493, + "end_line": 4509, + "section": "List items" + }, + { + "markdown": "1. indented code\n\n paragraph\n\n more code\n", + "html": "
    \n
  1. \n
     indented code\n
    \n

    paragraph

    \n
    more code\n
    \n
  2. \n
\n", + "example": 274, + "start_line": 4515, + "end_line": 4531, + "section": "List items" + }, + { + "markdown": " foo\n\nbar\n", + "html": "

foo

\n

bar

\n", + "example": 275, + "start_line": 4542, + "end_line": 4549, + "section": "List items" + }, + { + "markdown": "- foo\n\n bar\n", + "html": "
    \n
  • foo
  • \n
\n

bar

\n", + "example": 276, + "start_line": 4552, + "end_line": 4561, + "section": "List items" + }, + { + "markdown": "- foo\n\n bar\n", + "html": "
    \n
  • \n

    foo

    \n

    bar

    \n
  • \n
\n", + "example": 277, + "start_line": 4569, + "end_line": 4580, + "section": "List items" + }, + { + "markdown": "-\n foo\n-\n ```\n bar\n ```\n-\n baz\n", + "html": "
    \n
  • foo
  • \n
  • \n
    bar\n
    \n
  • \n
  • \n
    baz\n
    \n
  • \n
\n", + "example": 278, + "start_line": 4596, + "end_line": 4617, + "section": "List items" + }, + { + "markdown": "- \n foo\n", + "html": "
    \n
  • foo
  • \n
\n", + "example": 279, + "start_line": 4622, + "end_line": 4629, + "section": "List items" + }, + { + "markdown": "-\n\n foo\n", + "html": "
    \n
  • \n
\n

foo

\n", + "example": 280, + "start_line": 4636, + "end_line": 4645, + "section": "List items" + }, + { + "markdown": "- foo\n-\n- bar\n", + "html": "
    \n
  • foo
  • \n
  • \n
  • bar
  • \n
\n", + "example": 281, + "start_line": 4650, + "end_line": 4660, + "section": "List items" + }, + { + "markdown": "- foo\n- \n- bar\n", + "html": "
    \n
  • foo
  • \n
  • \n
  • bar
  • \n
\n", + "example": 282, + "start_line": 4665, + "end_line": 4675, + "section": "List items" + }, + { + "markdown": "1. foo\n2.\n3. bar\n", + "html": "
    \n
  1. foo
  2. \n
  3. \n
  4. bar
  5. \n
\n", + "example": 283, + "start_line": 4680, + "end_line": 4690, + "section": "List items" + }, + { + "markdown": "*\n", + "html": "
    \n
  • \n
\n", + "example": 284, + "start_line": 4695, + "end_line": 4701, + "section": "List items" + }, + { + "markdown": "foo\n*\n\nfoo\n1.\n", + "html": "

foo\n*

\n

foo\n1.

\n", + "example": 285, + "start_line": 4705, + "end_line": 4716, + "section": "List items" + }, + { + "markdown": " 1. A paragraph\n with two lines.\n\n indented code\n\n > A block quote.\n", + "html": "
    \n
  1. \n

    A paragraph\nwith two lines.

    \n
    indented code\n
    \n
    \n

    A block quote.

    \n
    \n
  2. \n
\n", + "example": 286, + "start_line": 4727, + "end_line": 4746, + "section": "List items" + }, + { + "markdown": " 1. A paragraph\n with two lines.\n\n indented code\n\n > A block quote.\n", + "html": "
    \n
  1. \n

    A paragraph\nwith two lines.

    \n
    indented code\n
    \n
    \n

    A block quote.

    \n
    \n
  2. \n
\n", + "example": 287, + "start_line": 4751, + "end_line": 4770, + "section": "List items" + }, + { + "markdown": " 1. A paragraph\n with two lines.\n\n indented code\n\n > A block quote.\n", + "html": "
    \n
  1. \n

    A paragraph\nwith two lines.

    \n
    indented code\n
    \n
    \n

    A block quote.

    \n
    \n
  2. \n
\n", + "example": 288, + "start_line": 4775, + "end_line": 4794, + "section": "List items" + }, + { + "markdown": " 1. A paragraph\n with two lines.\n\n indented code\n\n > A block quote.\n", + "html": "
1.  A paragraph\n    with two lines.\n\n        indented code\n\n    > A block quote.\n
\n", + "example": 289, + "start_line": 4799, + "end_line": 4814, + "section": "List items" + }, + { + "markdown": " 1. A paragraph\nwith two lines.\n\n indented code\n\n > A block quote.\n", + "html": "
    \n
  1. \n

    A paragraph\nwith two lines.

    \n
    indented code\n
    \n
    \n

    A block quote.

    \n
    \n
  2. \n
\n", + "example": 290, + "start_line": 4829, + "end_line": 4848, + "section": "List items" + }, + { + "markdown": " 1. A paragraph\n with two lines.\n", + "html": "
    \n
  1. A paragraph\nwith two lines.
  2. \n
\n", + "example": 291, + "start_line": 4853, + "end_line": 4861, + "section": "List items" + }, + { + "markdown": "> 1. > Blockquote\ncontinued here.\n", + "html": "
\n
    \n
  1. \n
    \n

    Blockquote\ncontinued here.

    \n
    \n
  2. \n
\n
\n", + "example": 292, + "start_line": 4866, + "end_line": 4880, + "section": "List items" + }, + { + "markdown": "> 1. > Blockquote\n> continued here.\n", + "html": "
\n
    \n
  1. \n
    \n

    Blockquote\ncontinued here.

    \n
    \n
  2. \n
\n
\n", + "example": 293, + "start_line": 4883, + "end_line": 4897, + "section": "List items" + }, + { + "markdown": "- foo\n - bar\n - baz\n - boo\n", + "html": "
    \n
  • foo\n
      \n
    • bar\n
        \n
      • baz\n
          \n
        • boo
        • \n
        \n
      • \n
      \n
    • \n
    \n
  • \n
\n", + "example": 294, + "start_line": 4911, + "end_line": 4932, + "section": "List items" + }, + { + "markdown": "- foo\n - bar\n - baz\n - boo\n", + "html": "
    \n
  • foo
  • \n
  • bar
  • \n
  • baz
  • \n
  • boo
  • \n
\n", + "example": 295, + "start_line": 4937, + "end_line": 4949, + "section": "List items" + }, + { + "markdown": "10) foo\n - bar\n", + "html": "
    \n
  1. foo\n
      \n
    • bar
    • \n
    \n
  2. \n
\n", + "example": 296, + "start_line": 4954, + "end_line": 4965, + "section": "List items" + }, + { + "markdown": "10) foo\n - bar\n", + "html": "
    \n
  1. foo
  2. \n
\n
    \n
  • bar
  • \n
\n", + "example": 297, + "start_line": 4970, + "end_line": 4980, + "section": "List items" + }, + { + "markdown": "- - foo\n", + "html": "
    \n
  • \n
      \n
    • foo
    • \n
    \n
  • \n
\n", + "example": 298, + "start_line": 4985, + "end_line": 4995, + "section": "List items" + }, + { + "markdown": "1. - 2. foo\n", + "html": "
    \n
  1. \n
      \n
    • \n
        \n
      1. foo
      2. \n
      \n
    • \n
    \n
  2. \n
\n", + "example": 299, + "start_line": 4998, + "end_line": 5012, + "section": "List items" + }, + { + "markdown": "- # Foo\n- Bar\n ---\n baz\n", + "html": "
    \n
  • \n

    Foo

    \n
  • \n
  • \n

    Bar

    \nbaz
  • \n
\n", + "example": 300, + "start_line": 5017, + "end_line": 5031, + "section": "List items" + }, + { + "markdown": "- foo\n- bar\n+ baz\n", + "html": "
    \n
  • foo
  • \n
  • bar
  • \n
\n
    \n
  • baz
  • \n
\n", + "example": 301, + "start_line": 5253, + "end_line": 5265, + "section": "Lists" + }, + { + "markdown": "1. foo\n2. bar\n3) baz\n", + "html": "
    \n
  1. foo
  2. \n
  3. bar
  4. \n
\n
    \n
  1. baz
  2. \n
\n", + "example": 302, + "start_line": 5268, + "end_line": 5280, + "section": "Lists" + }, + { + "markdown": "Foo\n- bar\n- baz\n", + "html": "

Foo

\n
    \n
  • bar
  • \n
  • baz
  • \n
\n", + "example": 303, + "start_line": 5287, + "end_line": 5297, + "section": "Lists" + }, + { + "markdown": "The number of windows in my house is\n14. The number of doors is 6.\n", + "html": "

The number of windows in my house is\n14. The number of doors is 6.

\n", + "example": 304, + "start_line": 5364, + "end_line": 5370, + "section": "Lists" + }, + { + "markdown": "The number of windows in my house is\n1. The number of doors is 6.\n", + "html": "

The number of windows in my house is

\n
    \n
  1. The number of doors is 6.
  2. \n
\n", + "example": 305, + "start_line": 5374, + "end_line": 5382, + "section": "Lists" + }, + { + "markdown": "- foo\n\n- bar\n\n\n- baz\n", + "html": "
    \n
  • \n

    foo

    \n
  • \n
  • \n

    bar

    \n
  • \n
  • \n

    baz

    \n
  • \n
\n", + "example": 306, + "start_line": 5388, + "end_line": 5407, + "section": "Lists" + }, + { + "markdown": "- foo\n - bar\n - baz\n\n\n bim\n", + "html": "
    \n
  • foo\n
      \n
    • bar\n
        \n
      • \n

        baz

        \n

        bim

        \n
      • \n
      \n
    • \n
    \n
  • \n
\n", + "example": 307, + "start_line": 5409, + "end_line": 5431, + "section": "Lists" + }, + { + "markdown": "- foo\n- bar\n\n\n\n- baz\n- bim\n", + "html": "
    \n
  • foo
  • \n
  • bar
  • \n
\n\n
    \n
  • baz
  • \n
  • bim
  • \n
\n", + "example": 308, + "start_line": 5439, + "end_line": 5457, + "section": "Lists" + }, + { + "markdown": "- foo\n\n notcode\n\n- foo\n\n\n\n code\n", + "html": "
    \n
  • \n

    foo

    \n

    notcode

    \n
  • \n
  • \n

    foo

    \n
  • \n
\n\n
code\n
\n", + "example": 309, + "start_line": 5460, + "end_line": 5483, + "section": "Lists" + }, + { + "markdown": "- a\n - b\n - c\n - d\n - e\n - f\n- g\n", + "html": "
    \n
  • a
  • \n
  • b
  • \n
  • c
  • \n
  • d
  • \n
  • e
  • \n
  • f
  • \n
  • g
  • \n
\n", + "example": 310, + "start_line": 5491, + "end_line": 5509, + "section": "Lists" + }, + { + "markdown": "1. a\n\n 2. b\n\n 3. c\n", + "html": "
    \n
  1. \n

    a

    \n
  2. \n
  3. \n

    b

    \n
  4. \n
  5. \n

    c

    \n
  6. \n
\n", + "example": 311, + "start_line": 5512, + "end_line": 5530, + "section": "Lists" + }, + { + "markdown": "- a\n - b\n - c\n - d\n - e\n", + "html": "
    \n
  • a
  • \n
  • b
  • \n
  • c
  • \n
  • d\n- e
  • \n
\n", + "example": 312, + "start_line": 5536, + "end_line": 5550, + "section": "Lists" + }, + { + "markdown": "1. a\n\n 2. b\n\n 3. c\n", + "html": "
    \n
  1. \n

    a

    \n
  2. \n
  3. \n

    b

    \n
  4. \n
\n
3. c\n
\n", + "example": 313, + "start_line": 5556, + "end_line": 5573, + "section": "Lists" + }, + { + "markdown": "- a\n- b\n\n- c\n", + "html": "
    \n
  • \n

    a

    \n
  • \n
  • \n

    b

    \n
  • \n
  • \n

    c

    \n
  • \n
\n", + "example": 314, + "start_line": 5579, + "end_line": 5596, + "section": "Lists" + }, + { + "markdown": "* a\n*\n\n* c\n", + "html": "
    \n
  • \n

    a

    \n
  • \n
  • \n
  • \n

    c

    \n
  • \n
\n", + "example": 315, + "start_line": 5601, + "end_line": 5616, + "section": "Lists" + }, + { + "markdown": "- a\n- b\n\n c\n- d\n", + "html": "
    \n
  • \n

    a

    \n
  • \n
  • \n

    b

    \n

    c

    \n
  • \n
  • \n

    d

    \n
  • \n
\n", + "example": 316, + "start_line": 5623, + "end_line": 5642, + "section": "Lists" + }, + { + "markdown": "- a\n- b\n\n [ref]: /url\n- d\n", + "html": "
    \n
  • \n

    a

    \n
  • \n
  • \n

    b

    \n
  • \n
  • \n

    d

    \n
  • \n
\n", + "example": 317, + "start_line": 5645, + "end_line": 5663, + "section": "Lists" + }, + { + "markdown": "- a\n- ```\n b\n\n\n ```\n- c\n", + "html": "
    \n
  • a
  • \n
  • \n
    b\n\n\n
    \n
  • \n
  • c
  • \n
\n", + "example": 318, + "start_line": 5668, + "end_line": 5687, + "section": "Lists" + }, + { + "markdown": "- a\n - b\n\n c\n- d\n", + "html": "
    \n
  • a\n
      \n
    • \n

      b

      \n

      c

      \n
    • \n
    \n
  • \n
  • d
  • \n
\n", + "example": 319, + "start_line": 5694, + "end_line": 5712, + "section": "Lists" + }, + { + "markdown": "* a\n > b\n >\n* c\n", + "html": "
    \n
  • a\n
    \n

    b

    \n
    \n
  • \n
  • c
  • \n
\n", + "example": 320, + "start_line": 5718, + "end_line": 5732, + "section": "Lists" + }, + { + "markdown": "- a\n > b\n ```\n c\n ```\n- d\n", + "html": "
    \n
  • a\n
    \n

    b

    \n
    \n
    c\n
    \n
  • \n
  • d
  • \n
\n", + "example": 321, + "start_line": 5738, + "end_line": 5756, + "section": "Lists" + }, + { + "markdown": "- a\n", + "html": "
    \n
  • a
  • \n
\n", + "example": 322, + "start_line": 5761, + "end_line": 5767, + "section": "Lists" + }, + { + "markdown": "- a\n - b\n", + "html": "
    \n
  • a\n
      \n
    • b
    • \n
    \n
  • \n
\n", + "example": 323, + "start_line": 5770, + "end_line": 5781, + "section": "Lists" + }, + { + "markdown": "1. ```\n foo\n ```\n\n bar\n", + "html": "
    \n
  1. \n
    foo\n
    \n

    bar

    \n
  2. \n
\n", + "example": 324, + "start_line": 5787, + "end_line": 5801, + "section": "Lists" + }, + { + "markdown": "* foo\n * bar\n\n baz\n", + "html": "
    \n
  • \n

    foo

    \n
      \n
    • bar
    • \n
    \n

    baz

    \n
  • \n
\n", + "example": 325, + "start_line": 5806, + "end_line": 5821, + "section": "Lists" + }, + { + "markdown": "- a\n - b\n - c\n\n- d\n - e\n - f\n", + "html": "
    \n
  • \n

    a

    \n
      \n
    • b
    • \n
    • c
    • \n
    \n
  • \n
  • \n

    d

    \n
      \n
    • e
    • \n
    • f
    • \n
    \n
  • \n
\n", + "example": 326, + "start_line": 5824, + "end_line": 5849, + "section": "Lists" + }, + { + "markdown": "`hi`lo`\n", + "html": "

hilo`

\n", + "example": 327, + "start_line": 5858, + "end_line": 5862, + "section": "Inlines" + }, + { + "markdown": "`foo`\n", + "html": "

foo

\n", + "example": 328, + "start_line": 5890, + "end_line": 5894, + "section": "Code spans" + }, + { + "markdown": "`` foo ` bar ``\n", + "html": "

foo ` bar

\n", + "example": 329, + "start_line": 5901, + "end_line": 5905, + "section": "Code spans" + }, + { + "markdown": "` `` `\n", + "html": "

``

\n", + "example": 330, + "start_line": 5911, + "end_line": 5915, + "section": "Code spans" + }, + { + "markdown": "` `` `\n", + "html": "

``

\n", + "example": 331, + "start_line": 5919, + "end_line": 5923, + "section": "Code spans" + }, + { + "markdown": "` a`\n", + "html": "

a

\n", + "example": 332, + "start_line": 5928, + "end_line": 5932, + "section": "Code spans" + }, + { + "markdown": "` b `\n", + "html": "

 b 

\n", + "example": 333, + "start_line": 5937, + "end_line": 5941, + "section": "Code spans" + }, + { + "markdown": "` `\n` `\n", + "html": "

 \n

\n", + "example": 334, + "start_line": 5945, + "end_line": 5951, + "section": "Code spans" + }, + { + "markdown": "``\nfoo\nbar \nbaz\n``\n", + "html": "

foo bar baz

\n", + "example": 335, + "start_line": 5956, + "end_line": 5964, + "section": "Code spans" + }, + { + "markdown": "``\nfoo \n``\n", + "html": "

foo

\n", + "example": 336, + "start_line": 5966, + "end_line": 5972, + "section": "Code spans" + }, + { + "markdown": "`foo bar \nbaz`\n", + "html": "

foo bar baz

\n", + "example": 337, + "start_line": 5977, + "end_line": 5982, + "section": "Code spans" + }, + { + "markdown": "`foo\\`bar`\n", + "html": "

foo\\bar`

\n", + "example": 338, + "start_line": 5994, + "end_line": 5998, + "section": "Code spans" + }, + { + "markdown": "``foo`bar``\n", + "html": "

foo`bar

\n", + "example": 339, + "start_line": 6005, + "end_line": 6009, + "section": "Code spans" + }, + { + "markdown": "` foo `` bar `\n", + "html": "

foo `` bar

\n", + "example": 340, + "start_line": 6011, + "end_line": 6015, + "section": "Code spans" + }, + { + "markdown": "*foo`*`\n", + "html": "

*foo*

\n", + "example": 341, + "start_line": 6023, + "end_line": 6027, + "section": "Code spans" + }, + { + "markdown": "[not a `link](/foo`)\n", + "html": "

[not a link](/foo)

\n", + "example": 342, + "start_line": 6032, + "end_line": 6036, + "section": "Code spans" + }, + { + "markdown": "``\n", + "html": "

<a href="">`

\n", + "example": 343, + "start_line": 6042, + "end_line": 6046, + "section": "Code spans" + }, + { + "markdown": "
`\n", + "html": "

`

\n", + "example": 344, + "start_line": 6051, + "end_line": 6055, + "section": "Code spans" + }, + { + "markdown": "``\n", + "html": "

<http://foo.bar.baz>`

\n", + "example": 345, + "start_line": 6060, + "end_line": 6064, + "section": "Code spans" + }, + { + "markdown": "`\n", + "html": "

http://foo.bar.`baz`

\n", + "example": 346, + "start_line": 6069, + "end_line": 6073, + "section": "Code spans" + }, + { + "markdown": "```foo``\n", + "html": "

```foo``

\n", + "example": 347, + "start_line": 6079, + "end_line": 6083, + "section": "Code spans" + }, + { + "markdown": "`foo\n", + "html": "

`foo

\n", + "example": 348, + "start_line": 6086, + "end_line": 6090, + "section": "Code spans" + }, + { + "markdown": "`foo``bar``\n", + "html": "

`foobar

\n", + "example": 349, + "start_line": 6095, + "end_line": 6099, + "section": "Code spans" + }, + { + "markdown": "*foo bar*\n", + "html": "

foo bar

\n", + "example": 350, + "start_line": 6312, + "end_line": 6316, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "a * foo bar*\n", + "html": "

a * foo bar*

\n", + "example": 351, + "start_line": 6322, + "end_line": 6326, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "a*\"foo\"*\n", + "html": "

a*"foo"*

\n", + "example": 352, + "start_line": 6333, + "end_line": 6337, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "* a *\n", + "html": "

* a *

\n", + "example": 353, + "start_line": 6342, + "end_line": 6346, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "foo*bar*\n", + "html": "

foobar

\n", + "example": 354, + "start_line": 6351, + "end_line": 6355, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "5*6*78\n", + "html": "

5678

\n", + "example": 355, + "start_line": 6358, + "end_line": 6362, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "_foo bar_\n", + "html": "

foo bar

\n", + "example": 356, + "start_line": 6367, + "end_line": 6371, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "_ foo bar_\n", + "html": "

_ foo bar_

\n", + "example": 357, + "start_line": 6377, + "end_line": 6381, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "a_\"foo\"_\n", + "html": "

a_"foo"_

\n", + "example": 358, + "start_line": 6387, + "end_line": 6391, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "foo_bar_\n", + "html": "

foo_bar_

\n", + "example": 359, + "start_line": 6396, + "end_line": 6400, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "5_6_78\n", + "html": "

5_6_78

\n", + "example": 360, + "start_line": 6403, + "end_line": 6407, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "пристаням_стремятся_\n", + "html": "

пристаням_стремятся_

\n", + "example": 361, + "start_line": 6410, + "end_line": 6414, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "aa_\"bb\"_cc\n", + "html": "

aa_"bb"_cc

\n", + "example": 362, + "start_line": 6420, + "end_line": 6424, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "foo-_(bar)_\n", + "html": "

foo-(bar)

\n", + "example": 363, + "start_line": 6431, + "end_line": 6435, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "_foo*\n", + "html": "

_foo*

\n", + "example": 364, + "start_line": 6443, + "end_line": 6447, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*foo bar *\n", + "html": "

*foo bar *

\n", + "example": 365, + "start_line": 6453, + "end_line": 6457, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*foo bar\n*\n", + "html": "

*foo bar\n*

\n", + "example": 366, + "start_line": 6462, + "end_line": 6468, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*(*foo)\n", + "html": "

*(*foo)

\n", + "example": 367, + "start_line": 6475, + "end_line": 6479, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*(*foo*)*\n", + "html": "

(foo)

\n", + "example": 368, + "start_line": 6485, + "end_line": 6489, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*foo*bar\n", + "html": "

foobar

\n", + "example": 369, + "start_line": 6494, + "end_line": 6498, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "_foo bar _\n", + "html": "

_foo bar _

\n", + "example": 370, + "start_line": 6507, + "end_line": 6511, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "_(_foo)\n", + "html": "

_(_foo)

\n", + "example": 371, + "start_line": 6517, + "end_line": 6521, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "_(_foo_)_\n", + "html": "

(foo)

\n", + "example": 372, + "start_line": 6526, + "end_line": 6530, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "_foo_bar\n", + "html": "

_foo_bar

\n", + "example": 373, + "start_line": 6535, + "end_line": 6539, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "_пристаням_стремятся\n", + "html": "

_пристаням_стремятся

\n", + "example": 374, + "start_line": 6542, + "end_line": 6546, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "_foo_bar_baz_\n", + "html": "

foo_bar_baz

\n", + "example": 375, + "start_line": 6549, + "end_line": 6553, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "_(bar)_.\n", + "html": "

(bar).

\n", + "example": 376, + "start_line": 6560, + "end_line": 6564, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "**foo bar**\n", + "html": "

foo bar

\n", + "example": 377, + "start_line": 6569, + "end_line": 6573, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "** foo bar**\n", + "html": "

** foo bar**

\n", + "example": 378, + "start_line": 6579, + "end_line": 6583, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "a**\"foo\"**\n", + "html": "

a**"foo"**

\n", + "example": 379, + "start_line": 6590, + "end_line": 6594, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "foo**bar**\n", + "html": "

foobar

\n", + "example": 380, + "start_line": 6599, + "end_line": 6603, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "__foo bar__\n", + "html": "

foo bar

\n", + "example": 381, + "start_line": 6608, + "end_line": 6612, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "__ foo bar__\n", + "html": "

__ foo bar__

\n", + "example": 382, + "start_line": 6618, + "end_line": 6622, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "__\nfoo bar__\n", + "html": "

__\nfoo bar__

\n", + "example": 383, + "start_line": 6626, + "end_line": 6632, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "a__\"foo\"__\n", + "html": "

a__"foo"__

\n", + "example": 384, + "start_line": 6638, + "end_line": 6642, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "foo__bar__\n", + "html": "

foo__bar__

\n", + "example": 385, + "start_line": 6647, + "end_line": 6651, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "5__6__78\n", + "html": "

5__6__78

\n", + "example": 386, + "start_line": 6654, + "end_line": 6658, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "пристаням__стремятся__\n", + "html": "

пристаням__стремятся__

\n", + "example": 387, + "start_line": 6661, + "end_line": 6665, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "__foo, __bar__, baz__\n", + "html": "

foo, bar, baz

\n", + "example": 388, + "start_line": 6668, + "end_line": 6672, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "foo-__(bar)__\n", + "html": "

foo-(bar)

\n", + "example": 389, + "start_line": 6679, + "end_line": 6683, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "**foo bar **\n", + "html": "

**foo bar **

\n", + "example": 390, + "start_line": 6692, + "end_line": 6696, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "**(**foo)\n", + "html": "

**(**foo)

\n", + "example": 391, + "start_line": 6705, + "end_line": 6709, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*(**foo**)*\n", + "html": "

(foo)

\n", + "example": 392, + "start_line": 6715, + "end_line": 6719, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "**Gomphocarpus (*Gomphocarpus physocarpus*, syn.\n*Asclepias physocarpa*)**\n", + "html": "

Gomphocarpus (Gomphocarpus physocarpus, syn.\nAsclepias physocarpa)

\n", + "example": 393, + "start_line": 6722, + "end_line": 6728, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "**foo \"*bar*\" foo**\n", + "html": "

foo "bar" foo

\n", + "example": 394, + "start_line": 6731, + "end_line": 6735, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "**foo**bar\n", + "html": "

foobar

\n", + "example": 395, + "start_line": 6740, + "end_line": 6744, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "__foo bar __\n", + "html": "

__foo bar __

\n", + "example": 396, + "start_line": 6752, + "end_line": 6756, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "__(__foo)\n", + "html": "

__(__foo)

\n", + "example": 397, + "start_line": 6762, + "end_line": 6766, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "_(__foo__)_\n", + "html": "

(foo)

\n", + "example": 398, + "start_line": 6772, + "end_line": 6776, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "__foo__bar\n", + "html": "

__foo__bar

\n", + "example": 399, + "start_line": 6781, + "end_line": 6785, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "__пристаням__стремятся\n", + "html": "

__пристаням__стремятся

\n", + "example": 400, + "start_line": 6788, + "end_line": 6792, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "__foo__bar__baz__\n", + "html": "

foo__bar__baz

\n", + "example": 401, + "start_line": 6795, + "end_line": 6799, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "__(bar)__.\n", + "html": "

(bar).

\n", + "example": 402, + "start_line": 6806, + "end_line": 6810, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*foo [bar](/url)*\n", + "html": "

foo bar

\n", + "example": 403, + "start_line": 6818, + "end_line": 6822, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*foo\nbar*\n", + "html": "

foo\nbar

\n", + "example": 404, + "start_line": 6825, + "end_line": 6831, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "_foo __bar__ baz_\n", + "html": "

foo bar baz

\n", + "example": 405, + "start_line": 6837, + "end_line": 6841, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "_foo _bar_ baz_\n", + "html": "

foo bar baz

\n", + "example": 406, + "start_line": 6844, + "end_line": 6848, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "__foo_ bar_\n", + "html": "

foo bar

\n", + "example": 407, + "start_line": 6851, + "end_line": 6855, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*foo *bar**\n", + "html": "

foo bar

\n", + "example": 408, + "start_line": 6858, + "end_line": 6862, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*foo **bar** baz*\n", + "html": "

foo bar baz

\n", + "example": 409, + "start_line": 6865, + "end_line": 6869, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*foo**bar**baz*\n", + "html": "

foobarbaz

\n", + "example": 410, + "start_line": 6871, + "end_line": 6875, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*foo**bar*\n", + "html": "

foo**bar

\n", + "example": 411, + "start_line": 6895, + "end_line": 6899, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "***foo** bar*\n", + "html": "

foo bar

\n", + "example": 412, + "start_line": 6908, + "end_line": 6912, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*foo **bar***\n", + "html": "

foo bar

\n", + "example": 413, + "start_line": 6915, + "end_line": 6919, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*foo**bar***\n", + "html": "

foobar

\n", + "example": 414, + "start_line": 6922, + "end_line": 6926, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "foo***bar***baz\n", + "html": "

foobarbaz

\n", + "example": 415, + "start_line": 6933, + "end_line": 6937, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "foo******bar*********baz\n", + "html": "

foobar***baz

\n", + "example": 416, + "start_line": 6939, + "end_line": 6943, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*foo **bar *baz* bim** bop*\n", + "html": "

foo bar baz bim bop

\n", + "example": 417, + "start_line": 6948, + "end_line": 6952, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*foo [*bar*](/url)*\n", + "html": "

foo bar

\n", + "example": 418, + "start_line": 6955, + "end_line": 6959, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "** is not an empty emphasis\n", + "html": "

** is not an empty emphasis

\n", + "example": 419, + "start_line": 6964, + "end_line": 6968, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "**** is not an empty strong emphasis\n", + "html": "

**** is not an empty strong emphasis

\n", + "example": 420, + "start_line": 6971, + "end_line": 6975, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "**foo [bar](/url)**\n", + "html": "

foo bar

\n", + "example": 421, + "start_line": 6984, + "end_line": 6988, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "**foo\nbar**\n", + "html": "

foo\nbar

\n", + "example": 422, + "start_line": 6991, + "end_line": 6997, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "__foo _bar_ baz__\n", + "html": "

foo bar baz

\n", + "example": 423, + "start_line": 7003, + "end_line": 7007, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "__foo __bar__ baz__\n", + "html": "

foo bar baz

\n", + "example": 424, + "start_line": 7010, + "end_line": 7014, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "____foo__ bar__\n", + "html": "

foo bar

\n", + "example": 425, + "start_line": 7017, + "end_line": 7021, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "**foo **bar****\n", + "html": "

foo bar

\n", + "example": 426, + "start_line": 7024, + "end_line": 7028, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "**foo *bar* baz**\n", + "html": "

foo bar baz

\n", + "example": 427, + "start_line": 7031, + "end_line": 7035, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "**foo*bar*baz**\n", + "html": "

foobarbaz

\n", + "example": 428, + "start_line": 7038, + "end_line": 7042, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "***foo* bar**\n", + "html": "

foo bar

\n", + "example": 429, + "start_line": 7045, + "end_line": 7049, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "**foo *bar***\n", + "html": "

foo bar

\n", + "example": 430, + "start_line": 7052, + "end_line": 7056, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "**foo *bar **baz**\nbim* bop**\n", + "html": "

foo bar baz\nbim bop

\n", + "example": 431, + "start_line": 7061, + "end_line": 7067, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "**foo [*bar*](/url)**\n", + "html": "

foo bar

\n", + "example": 432, + "start_line": 7070, + "end_line": 7074, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "__ is not an empty emphasis\n", + "html": "

__ is not an empty emphasis

\n", + "example": 433, + "start_line": 7079, + "end_line": 7083, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "____ is not an empty strong emphasis\n", + "html": "

____ is not an empty strong emphasis

\n", + "example": 434, + "start_line": 7086, + "end_line": 7090, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "foo ***\n", + "html": "

foo ***

\n", + "example": 435, + "start_line": 7096, + "end_line": 7100, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "foo *\\**\n", + "html": "

foo *

\n", + "example": 436, + "start_line": 7103, + "end_line": 7107, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "foo *_*\n", + "html": "

foo _

\n", + "example": 437, + "start_line": 7110, + "end_line": 7114, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "foo *****\n", + "html": "

foo *****

\n", + "example": 438, + "start_line": 7117, + "end_line": 7121, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "foo **\\***\n", + "html": "

foo *

\n", + "example": 439, + "start_line": 7124, + "end_line": 7128, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "foo **_**\n", + "html": "

foo _

\n", + "example": 440, + "start_line": 7131, + "end_line": 7135, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "**foo*\n", + "html": "

*foo

\n", + "example": 441, + "start_line": 7142, + "end_line": 7146, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*foo**\n", + "html": "

foo*

\n", + "example": 442, + "start_line": 7149, + "end_line": 7153, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "***foo**\n", + "html": "

*foo

\n", + "example": 443, + "start_line": 7156, + "end_line": 7160, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "****foo*\n", + "html": "

***foo

\n", + "example": 444, + "start_line": 7163, + "end_line": 7167, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "**foo***\n", + "html": "

foo*

\n", + "example": 445, + "start_line": 7170, + "end_line": 7174, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*foo****\n", + "html": "

foo***

\n", + "example": 446, + "start_line": 7177, + "end_line": 7181, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "foo ___\n", + "html": "

foo ___

\n", + "example": 447, + "start_line": 7187, + "end_line": 7191, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "foo _\\__\n", + "html": "

foo _

\n", + "example": 448, + "start_line": 7194, + "end_line": 7198, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "foo _*_\n", + "html": "

foo *

\n", + "example": 449, + "start_line": 7201, + "end_line": 7205, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "foo _____\n", + "html": "

foo _____

\n", + "example": 450, + "start_line": 7208, + "end_line": 7212, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "foo __\\___\n", + "html": "

foo _

\n", + "example": 451, + "start_line": 7215, + "end_line": 7219, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "foo __*__\n", + "html": "

foo *

\n", + "example": 452, + "start_line": 7222, + "end_line": 7226, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "__foo_\n", + "html": "

_foo

\n", + "example": 453, + "start_line": 7229, + "end_line": 7233, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "_foo__\n", + "html": "

foo_

\n", + "example": 454, + "start_line": 7240, + "end_line": 7244, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "___foo__\n", + "html": "

_foo

\n", + "example": 455, + "start_line": 7247, + "end_line": 7251, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "____foo_\n", + "html": "

___foo

\n", + "example": 456, + "start_line": 7254, + "end_line": 7258, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "__foo___\n", + "html": "

foo_

\n", + "example": 457, + "start_line": 7261, + "end_line": 7265, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "_foo____\n", + "html": "

foo___

\n", + "example": 458, + "start_line": 7268, + "end_line": 7272, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "**foo**\n", + "html": "

foo

\n", + "example": 459, + "start_line": 7278, + "end_line": 7282, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*_foo_*\n", + "html": "

foo

\n", + "example": 460, + "start_line": 7285, + "end_line": 7289, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "__foo__\n", + "html": "

foo

\n", + "example": 461, + "start_line": 7292, + "end_line": 7296, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "_*foo*_\n", + "html": "

foo

\n", + "example": 462, + "start_line": 7299, + "end_line": 7303, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "****foo****\n", + "html": "

foo

\n", + "example": 463, + "start_line": 7309, + "end_line": 7313, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "____foo____\n", + "html": "

foo

\n", + "example": 464, + "start_line": 7316, + "end_line": 7320, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "******foo******\n", + "html": "

foo

\n", + "example": 465, + "start_line": 7327, + "end_line": 7331, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "***foo***\n", + "html": "

foo

\n", + "example": 466, + "start_line": 7336, + "end_line": 7340, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "_____foo_____\n", + "html": "

foo

\n", + "example": 467, + "start_line": 7343, + "end_line": 7347, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*foo _bar* baz_\n", + "html": "

foo _bar baz_

\n", + "example": 468, + "start_line": 7352, + "end_line": 7356, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*foo __bar *baz bim__ bam*\n", + "html": "

foo bar *baz bim bam

\n", + "example": 469, + "start_line": 7359, + "end_line": 7363, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "**foo **bar baz**\n", + "html": "

**foo bar baz

\n", + "example": 470, + "start_line": 7368, + "end_line": 7372, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*foo *bar baz*\n", + "html": "

*foo bar baz

\n", + "example": 471, + "start_line": 7375, + "end_line": 7379, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*[bar*](/url)\n", + "html": "

*bar*

\n", + "example": 472, + "start_line": 7384, + "end_line": 7388, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "_foo [bar_](/url)\n", + "html": "

_foo bar_

\n", + "example": 473, + "start_line": 7391, + "end_line": 7395, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*\n", + "html": "

*

\n", + "example": 474, + "start_line": 7398, + "end_line": 7402, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "**\n", + "html": "

**

\n", + "example": 475, + "start_line": 7405, + "end_line": 7409, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "__\n", + "html": "

__

\n", + "example": 476, + "start_line": 7412, + "end_line": 7416, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*a `*`*\n", + "html": "

a *

\n", + "example": 477, + "start_line": 7419, + "end_line": 7423, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "_a `_`_\n", + "html": "

a _

\n", + "example": 478, + "start_line": 7426, + "end_line": 7430, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "**a\n", + "html": "

**ahttp://foo.bar/?q=**

\n", + "example": 479, + "start_line": 7433, + "end_line": 7437, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "__a\n", + "html": "

__ahttp://foo.bar/?q=__

\n", + "example": 480, + "start_line": 7440, + "end_line": 7444, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "[link](/uri \"title\")\n", + "html": "

link

\n", + "example": 481, + "start_line": 7528, + "end_line": 7532, + "section": "Links" + }, + { + "markdown": "[link](/uri)\n", + "html": "

link

\n", + "example": 482, + "start_line": 7538, + "end_line": 7542, + "section": "Links" + }, + { + "markdown": "[](./target.md)\n", + "html": "

\n", + "example": 483, + "start_line": 7544, + "end_line": 7548, + "section": "Links" + }, + { + "markdown": "[link]()\n", + "html": "

link

\n", + "example": 484, + "start_line": 7551, + "end_line": 7555, + "section": "Links" + }, + { + "markdown": "[link](<>)\n", + "html": "

link

\n", + "example": 485, + "start_line": 7558, + "end_line": 7562, + "section": "Links" + }, + { + "markdown": "[]()\n", + "html": "

\n", + "example": 486, + "start_line": 7565, + "end_line": 7569, + "section": "Links" + }, + { + "markdown": "[link](/my uri)\n", + "html": "

[link](/my uri)

\n", + "example": 487, + "start_line": 7574, + "end_line": 7578, + "section": "Links" + }, + { + "markdown": "[link](
)\n", + "html": "

link

\n", + "example": 488, + "start_line": 7580, + "end_line": 7584, + "section": "Links" + }, + { + "markdown": "[link](foo\nbar)\n", + "html": "

[link](foo\nbar)

\n", + "example": 489, + "start_line": 7589, + "end_line": 7595, + "section": "Links" + }, + { + "markdown": "[link]()\n", + "html": "

[link]()

\n", + "example": 490, + "start_line": 7597, + "end_line": 7603, + "section": "Links" + }, + { + "markdown": "[a]()\n", + "html": "

a

\n", + "example": 491, + "start_line": 7608, + "end_line": 7612, + "section": "Links" + }, + { + "markdown": "[link]()\n", + "html": "

[link](<foo>)

\n", + "example": 492, + "start_line": 7616, + "end_line": 7620, + "section": "Links" + }, + { + "markdown": "[a](\n[a](c)\n", + "html": "

[a](<b)c\n[a](<b)c>\n[a](c)

\n", + "example": 493, + "start_line": 7625, + "end_line": 7633, + "section": "Links" + }, + { + "markdown": "[link](\\(foo\\))\n", + "html": "

link

\n", + "example": 494, + "start_line": 7637, + "end_line": 7641, + "section": "Links" + }, + { + "markdown": "[link](foo(and(bar)))\n", + "html": "

link

\n", + "example": 495, + "start_line": 7646, + "end_line": 7650, + "section": "Links" + }, + { + "markdown": "[link](foo(and(bar))\n", + "html": "

[link](foo(and(bar))

\n", + "example": 496, + "start_line": 7655, + "end_line": 7659, + "section": "Links" + }, + { + "markdown": "[link](foo\\(and\\(bar\\))\n", + "html": "

link

\n", + "example": 497, + "start_line": 7662, + "end_line": 7666, + "section": "Links" + }, + { + "markdown": "[link]()\n", + "html": "

link

\n", + "example": 498, + "start_line": 7669, + "end_line": 7673, + "section": "Links" + }, + { + "markdown": "[link](foo\\)\\:)\n", + "html": "

link

\n", + "example": 499, + "start_line": 7679, + "end_line": 7683, + "section": "Links" + }, + { + "markdown": "[link](#fragment)\n\n[link](http://example.com#fragment)\n\n[link](http://example.com?foo=3#frag)\n", + "html": "

link

\n

link

\n

link

\n", + "example": 500, + "start_line": 7688, + "end_line": 7698, + "section": "Links" + }, + { + "markdown": "[link](foo\\bar)\n", + "html": "

link

\n", + "example": 501, + "start_line": 7704, + "end_line": 7708, + "section": "Links" + }, + { + "markdown": "[link](foo%20bä)\n", + "html": "

link

\n", + "example": 502, + "start_line": 7720, + "end_line": 7724, + "section": "Links" + }, + { + "markdown": "[link](\"title\")\n", + "html": "

link

\n", + "example": 503, + "start_line": 7731, + "end_line": 7735, + "section": "Links" + }, + { + "markdown": "[link](/url \"title\")\n[link](/url 'title')\n[link](/url (title))\n", + "html": "

link\nlink\nlink

\n", + "example": 504, + "start_line": 7740, + "end_line": 7748, + "section": "Links" + }, + { + "markdown": "[link](/url \"title \\\""\")\n", + "html": "

link

\n", + "example": 505, + "start_line": 7754, + "end_line": 7758, + "section": "Links" + }, + { + "markdown": "[link](/url \"title\")\n", + "html": "

link

\n", + "example": 506, + "start_line": 7765, + "end_line": 7769, + "section": "Links" + }, + { + "markdown": "[link](/url \"title \"and\" title\")\n", + "html": "

[link](/url "title "and" title")

\n", + "example": 507, + "start_line": 7774, + "end_line": 7778, + "section": "Links" + }, + { + "markdown": "[link](/url 'title \"and\" title')\n", + "html": "

link

\n", + "example": 508, + "start_line": 7783, + "end_line": 7787, + "section": "Links" + }, + { + "markdown": "[link]( /uri\n \"title\" )\n", + "html": "

link

\n", + "example": 509, + "start_line": 7808, + "end_line": 7813, + "section": "Links" + }, + { + "markdown": "[link] (/uri)\n", + "html": "

[link] (/uri)

\n", + "example": 510, + "start_line": 7819, + "end_line": 7823, + "section": "Links" + }, + { + "markdown": "[link [foo [bar]]](/uri)\n", + "html": "

link [foo [bar]]

\n", + "example": 511, + "start_line": 7829, + "end_line": 7833, + "section": "Links" + }, + { + "markdown": "[link] bar](/uri)\n", + "html": "

[link] bar](/uri)

\n", + "example": 512, + "start_line": 7836, + "end_line": 7840, + "section": "Links" + }, + { + "markdown": "[link [bar](/uri)\n", + "html": "

[link bar

\n", + "example": 513, + "start_line": 7843, + "end_line": 7847, + "section": "Links" + }, + { + "markdown": "[link \\[bar](/uri)\n", + "html": "

link [bar

\n", + "example": 514, + "start_line": 7850, + "end_line": 7854, + "section": "Links" + }, + { + "markdown": "[link *foo **bar** `#`*](/uri)\n", + "html": "

link foo bar #

\n", + "example": 515, + "start_line": 7859, + "end_line": 7863, + "section": "Links" + }, + { + "markdown": "[![moon](moon.jpg)](/uri)\n", + "html": "

\"moon\"

\n", + "example": 516, + "start_line": 7866, + "end_line": 7870, + "section": "Links" + }, + { + "markdown": "[foo [bar](/uri)](/uri)\n", + "html": "

[foo bar](/uri)

\n", + "example": 517, + "start_line": 7875, + "end_line": 7879, + "section": "Links" + }, + { + "markdown": "[foo *[bar [baz](/uri)](/uri)*](/uri)\n", + "html": "

[foo [bar baz](/uri)](/uri)

\n", + "example": 518, + "start_line": 7882, + "end_line": 7886, + "section": "Links" + }, + { + "markdown": "![[[foo](uri1)](uri2)](uri3)\n", + "html": "

\"[foo](uri2)\"

\n", + "example": 519, + "start_line": 7889, + "end_line": 7893, + "section": "Links" + }, + { + "markdown": "*[foo*](/uri)\n", + "html": "

*foo*

\n", + "example": 520, + "start_line": 7899, + "end_line": 7903, + "section": "Links" + }, + { + "markdown": "[foo *bar](baz*)\n", + "html": "

foo *bar

\n", + "example": 521, + "start_line": 7906, + "end_line": 7910, + "section": "Links" + }, + { + "markdown": "*foo [bar* baz]\n", + "html": "

foo [bar baz]

\n", + "example": 522, + "start_line": 7916, + "end_line": 7920, + "section": "Links" + }, + { + "markdown": "[foo \n", + "html": "

[foo

\n", + "example": 523, + "start_line": 7926, + "end_line": 7930, + "section": "Links" + }, + { + "markdown": "[foo`](/uri)`\n", + "html": "

[foo](/uri)

\n", + "example": 524, + "start_line": 7933, + "end_line": 7937, + "section": "Links" + }, + { + "markdown": "[foo\n", + "html": "

[foohttp://example.com/?search=](uri)

\n", + "example": 525, + "start_line": 7940, + "end_line": 7944, + "section": "Links" + }, + { + "markdown": "[foo][bar]\n\n[bar]: /url \"title\"\n", + "html": "

foo

\n", + "example": 526, + "start_line": 7978, + "end_line": 7984, + "section": "Links" + }, + { + "markdown": "[link [foo [bar]]][ref]\n\n[ref]: /uri\n", + "html": "

link [foo [bar]]

\n", + "example": 527, + "start_line": 7993, + "end_line": 7999, + "section": "Links" + }, + { + "markdown": "[link \\[bar][ref]\n\n[ref]: /uri\n", + "html": "

link [bar

\n", + "example": 528, + "start_line": 8002, + "end_line": 8008, + "section": "Links" + }, + { + "markdown": "[link *foo **bar** `#`*][ref]\n\n[ref]: /uri\n", + "html": "

link foo bar #

\n", + "example": 529, + "start_line": 8013, + "end_line": 8019, + "section": "Links" + }, + { + "markdown": "[![moon](moon.jpg)][ref]\n\n[ref]: /uri\n", + "html": "

\"moon\"

\n", + "example": 530, + "start_line": 8022, + "end_line": 8028, + "section": "Links" + }, + { + "markdown": "[foo [bar](/uri)][ref]\n\n[ref]: /uri\n", + "html": "

[foo bar]ref

\n", + "example": 531, + "start_line": 8033, + "end_line": 8039, + "section": "Links" + }, + { + "markdown": "[foo *bar [baz][ref]*][ref]\n\n[ref]: /uri\n", + "html": "

[foo bar baz]ref

\n", + "example": 532, + "start_line": 8042, + "end_line": 8048, + "section": "Links" + }, + { + "markdown": "*[foo*][ref]\n\n[ref]: /uri\n", + "html": "

*foo*

\n", + "example": 533, + "start_line": 8057, + "end_line": 8063, + "section": "Links" + }, + { + "markdown": "[foo *bar][ref]*\n\n[ref]: /uri\n", + "html": "

foo *bar*

\n", + "example": 534, + "start_line": 8066, + "end_line": 8072, + "section": "Links" + }, + { + "markdown": "[foo \n\n[ref]: /uri\n", + "html": "

[foo

\n", + "example": 535, + "start_line": 8078, + "end_line": 8084, + "section": "Links" + }, + { + "markdown": "[foo`][ref]`\n\n[ref]: /uri\n", + "html": "

[foo][ref]

\n", + "example": 536, + "start_line": 8087, + "end_line": 8093, + "section": "Links" + }, + { + "markdown": "[foo\n\n[ref]: /uri\n", + "html": "

[foohttp://example.com/?search=][ref]

\n", + "example": 537, + "start_line": 8096, + "end_line": 8102, + "section": "Links" + }, + { + "markdown": "[foo][BaR]\n\n[bar]: /url \"title\"\n", + "html": "

foo

\n", + "example": 538, + "start_line": 8107, + "end_line": 8113, + "section": "Links" + }, + { + "markdown": "[ẞ]\n\n[SS]: /url\n", + "html": "

ẞ

\n", + "example": 539, + "start_line": 8118, + "end_line": 8124, + "section": "Links" + }, + { + "markdown": "[Foo\n bar]: /url\n\n[Baz][Foo bar]\n", + "html": "

Baz

\n", + "example": 540, + "start_line": 8130, + "end_line": 8137, + "section": "Links" + }, + { + "markdown": "[foo] [bar]\n\n[bar]: /url \"title\"\n", + "html": "

[foo] bar

\n", + "example": 541, + "start_line": 8143, + "end_line": 8149, + "section": "Links" + }, + { + "markdown": "[foo]\n[bar]\n\n[bar]: /url \"title\"\n", + "html": "

[foo]\nbar

\n", + "example": 542, + "start_line": 8152, + "end_line": 8160, + "section": "Links" + }, + { + "markdown": "[foo]: /url1\n\n[foo]: /url2\n\n[bar][foo]\n", + "html": "

bar

\n", + "example": 543, + "start_line": 8193, + "end_line": 8201, + "section": "Links" + }, + { + "markdown": "[bar][foo\\!]\n\n[foo!]: /url\n", + "html": "

[bar][foo!]

\n", + "example": 544, + "start_line": 8208, + "end_line": 8214, + "section": "Links" + }, + { + "markdown": "[foo][ref[]\n\n[ref[]: /uri\n", + "html": "

[foo][ref[]

\n

[ref[]: /uri

\n", + "example": 545, + "start_line": 8220, + "end_line": 8227, + "section": "Links" + }, + { + "markdown": "[foo][ref[bar]]\n\n[ref[bar]]: /uri\n", + "html": "

[foo][ref[bar]]

\n

[ref[bar]]: /uri

\n", + "example": 546, + "start_line": 8230, + "end_line": 8237, + "section": "Links" + }, + { + "markdown": "[[[foo]]]\n\n[[[foo]]]: /url\n", + "html": "

[[[foo]]]

\n

[[[foo]]]: /url

\n", + "example": 547, + "start_line": 8240, + "end_line": 8247, + "section": "Links" + }, + { + "markdown": "[foo][ref\\[]\n\n[ref\\[]: /uri\n", + "html": "

foo

\n", + "example": 548, + "start_line": 8250, + "end_line": 8256, + "section": "Links" + }, + { + "markdown": "[bar\\\\]: /uri\n\n[bar\\\\]\n", + "html": "

bar\\

\n", + "example": 549, + "start_line": 8261, + "end_line": 8267, + "section": "Links" + }, + { + "markdown": "[]\n\n[]: /uri\n", + "html": "

[]

\n

[]: /uri

\n", + "example": 550, + "start_line": 8273, + "end_line": 8280, + "section": "Links" + }, + { + "markdown": "[\n ]\n\n[\n ]: /uri\n", + "html": "

[\n]

\n

[\n]: /uri

\n", + "example": 551, + "start_line": 8283, + "end_line": 8294, + "section": "Links" + }, + { + "markdown": "[foo][]\n\n[foo]: /url \"title\"\n", + "html": "

foo

\n", + "example": 552, + "start_line": 8306, + "end_line": 8312, + "section": "Links" + }, + { + "markdown": "[*foo* bar][]\n\n[*foo* bar]: /url \"title\"\n", + "html": "

foo bar

\n", + "example": 553, + "start_line": 8315, + "end_line": 8321, + "section": "Links" + }, + { + "markdown": "[Foo][]\n\n[foo]: /url \"title\"\n", + "html": "

Foo

\n", + "example": 554, + "start_line": 8326, + "end_line": 8332, + "section": "Links" + }, + { + "markdown": "[foo] \n[]\n\n[foo]: /url \"title\"\n", + "html": "

foo\n[]

\n", + "example": 555, + "start_line": 8339, + "end_line": 8347, + "section": "Links" + }, + { + "markdown": "[foo]\n\n[foo]: /url \"title\"\n", + "html": "

foo

\n", + "example": 556, + "start_line": 8359, + "end_line": 8365, + "section": "Links" + }, + { + "markdown": "[*foo* bar]\n\n[*foo* bar]: /url \"title\"\n", + "html": "

foo bar

\n", + "example": 557, + "start_line": 8368, + "end_line": 8374, + "section": "Links" + }, + { + "markdown": "[[*foo* bar]]\n\n[*foo* bar]: /url \"title\"\n", + "html": "

[foo bar]

\n", + "example": 558, + "start_line": 8377, + "end_line": 8383, + "section": "Links" + }, + { + "markdown": "[[bar [foo]\n\n[foo]: /url\n", + "html": "

[[bar foo

\n", + "example": 559, + "start_line": 8386, + "end_line": 8392, + "section": "Links" + }, + { + "markdown": "[Foo]\n\n[foo]: /url \"title\"\n", + "html": "

Foo

\n", + "example": 560, + "start_line": 8397, + "end_line": 8403, + "section": "Links" + }, + { + "markdown": "[foo] bar\n\n[foo]: /url\n", + "html": "

foo bar

\n", + "example": 561, + "start_line": 8408, + "end_line": 8414, + "section": "Links" + }, + { + "markdown": "\\[foo]\n\n[foo]: /url \"title\"\n", + "html": "

[foo]

\n", + "example": 562, + "start_line": 8420, + "end_line": 8426, + "section": "Links" + }, + { + "markdown": "[foo*]: /url\n\n*[foo*]\n", + "html": "

*foo*

\n", + "example": 563, + "start_line": 8432, + "end_line": 8438, + "section": "Links" + }, + { + "markdown": "[foo][bar]\n\n[foo]: /url1\n[bar]: /url2\n", + "html": "

foo

\n", + "example": 564, + "start_line": 8444, + "end_line": 8451, + "section": "Links" + }, + { + "markdown": "[foo][]\n\n[foo]: /url1\n", + "html": "

foo

\n", + "example": 565, + "start_line": 8453, + "end_line": 8459, + "section": "Links" + }, + { + "markdown": "[foo]()\n\n[foo]: /url1\n", + "html": "

foo

\n", + "example": 566, + "start_line": 8463, + "end_line": 8469, + "section": "Links" + }, + { + "markdown": "[foo](not a link)\n\n[foo]: /url1\n", + "html": "

foo(not a link)

\n", + "example": 567, + "start_line": 8471, + "end_line": 8477, + "section": "Links" + }, + { + "markdown": "[foo][bar][baz]\n\n[baz]: /url\n", + "html": "

[foo]bar

\n", + "example": 568, + "start_line": 8482, + "end_line": 8488, + "section": "Links" + }, + { + "markdown": "[foo][bar][baz]\n\n[baz]: /url1\n[bar]: /url2\n", + "html": "

foobaz

\n", + "example": 569, + "start_line": 8494, + "end_line": 8501, + "section": "Links" + }, + { + "markdown": "[foo][bar][baz]\n\n[baz]: /url1\n[foo]: /url2\n", + "html": "

[foo]bar

\n", + "example": 570, + "start_line": 8507, + "end_line": 8514, + "section": "Links" + }, + { + "markdown": "![foo](/url \"title\")\n", + "html": "

\"foo\"

\n", + "example": 571, + "start_line": 8530, + "end_line": 8534, + "section": "Images" + }, + { + "markdown": "![foo *bar*]\n\n[foo *bar*]: train.jpg \"train & tracks\"\n", + "html": "

\"foo

\n", + "example": 572, + "start_line": 8537, + "end_line": 8543, + "section": "Images" + }, + { + "markdown": "![foo ![bar](/url)](/url2)\n", + "html": "

\"foo

\n", + "example": 573, + "start_line": 8546, + "end_line": 8550, + "section": "Images" + }, + { + "markdown": "![foo [bar](/url)](/url2)\n", + "html": "

\"foo

\n", + "example": 574, + "start_line": 8553, + "end_line": 8557, + "section": "Images" + }, + { + "markdown": "![foo *bar*][]\n\n[foo *bar*]: train.jpg \"train & tracks\"\n", + "html": "

\"foo

\n", + "example": 575, + "start_line": 8567, + "end_line": 8573, + "section": "Images" + }, + { + "markdown": "![foo *bar*][foobar]\n\n[FOOBAR]: train.jpg \"train & tracks\"\n", + "html": "

\"foo

\n", + "example": 576, + "start_line": 8576, + "end_line": 8582, + "section": "Images" + }, + { + "markdown": "![foo](train.jpg)\n", + "html": "

\"foo\"

\n", + "example": 577, + "start_line": 8585, + "end_line": 8589, + "section": "Images" + }, + { + "markdown": "My ![foo bar](/path/to/train.jpg \"title\" )\n", + "html": "

My \"foo

\n", + "example": 578, + "start_line": 8592, + "end_line": 8596, + "section": "Images" + }, + { + "markdown": "![foo]()\n", + "html": "

\"foo\"

\n", + "example": 579, + "start_line": 8599, + "end_line": 8603, + "section": "Images" + }, + { + "markdown": "![](/url)\n", + "html": "

\"\"

\n", + "example": 580, + "start_line": 8606, + "end_line": 8610, + "section": "Images" + }, + { + "markdown": "![foo][bar]\n\n[bar]: /url\n", + "html": "

\"foo\"

\n", + "example": 581, + "start_line": 8615, + "end_line": 8621, + "section": "Images" + }, + { + "markdown": "![foo][bar]\n\n[BAR]: /url\n", + "html": "

\"foo\"

\n", + "example": 582, + "start_line": 8624, + "end_line": 8630, + "section": "Images" + }, + { + "markdown": "![foo][]\n\n[foo]: /url \"title\"\n", + "html": "

\"foo\"

\n", + "example": 583, + "start_line": 8635, + "end_line": 8641, + "section": "Images" + }, + { + "markdown": "![*foo* bar][]\n\n[*foo* bar]: /url \"title\"\n", + "html": "

\"foo

\n", + "example": 584, + "start_line": 8644, + "end_line": 8650, + "section": "Images" + }, + { + "markdown": "![Foo][]\n\n[foo]: /url \"title\"\n", + "html": "

\"Foo\"

\n", + "example": 585, + "start_line": 8655, + "end_line": 8661, + "section": "Images" + }, + { + "markdown": "![foo] \n[]\n\n[foo]: /url \"title\"\n", + "html": "

\"foo\"\n[]

\n", + "example": 586, + "start_line": 8667, + "end_line": 8675, + "section": "Images" + }, + { + "markdown": "![foo]\n\n[foo]: /url \"title\"\n", + "html": "

\"foo\"

\n", + "example": 587, + "start_line": 8680, + "end_line": 8686, + "section": "Images" + }, + { + "markdown": "![*foo* bar]\n\n[*foo* bar]: /url \"title\"\n", + "html": "

\"foo

\n", + "example": 588, + "start_line": 8689, + "end_line": 8695, + "section": "Images" + }, + { + "markdown": "![[foo]]\n\n[[foo]]: /url \"title\"\n", + "html": "

![[foo]]

\n

[[foo]]: /url "title"

\n", + "example": 589, + "start_line": 8700, + "end_line": 8707, + "section": "Images" + }, + { + "markdown": "![Foo]\n\n[foo]: /url \"title\"\n", + "html": "

\"Foo\"

\n", + "example": 590, + "start_line": 8712, + "end_line": 8718, + "section": "Images" + }, + { + "markdown": "!\\[foo]\n\n[foo]: /url \"title\"\n", + "html": "

![foo]

\n", + "example": 591, + "start_line": 8724, + "end_line": 8730, + "section": "Images" + }, + { + "markdown": "\\![foo]\n\n[foo]: /url \"title\"\n", + "html": "

!foo

\n", + "example": 592, + "start_line": 8736, + "end_line": 8742, + "section": "Images" + }, + { + "markdown": "\n", + "html": "

http://foo.bar.baz

\n", + "example": 593, + "start_line": 8769, + "end_line": 8773, + "section": "Autolinks" + }, + { + "markdown": "\n", + "html": "

http://foo.bar.baz/test?q=hello&id=22&boolean

\n", + "example": 594, + "start_line": 8776, + "end_line": 8780, + "section": "Autolinks" + }, + { + "markdown": "\n", + "html": "

irc://foo.bar:2233/baz

\n", + "example": 595, + "start_line": 8783, + "end_line": 8787, + "section": "Autolinks" + }, + { + "markdown": "\n", + "html": "

MAILTO:FOO@BAR.BAZ

\n", + "example": 596, + "start_line": 8792, + "end_line": 8796, + "section": "Autolinks" + }, + { + "markdown": "\n", + "html": "

a+b+c:d

\n", + "example": 597, + "start_line": 8804, + "end_line": 8808, + "section": "Autolinks" + }, + { + "markdown": "\n", + "html": "

made-up-scheme://foo,bar

\n", + "example": 598, + "start_line": 8811, + "end_line": 8815, + "section": "Autolinks" + }, + { + "markdown": "\n", + "html": "

http://../

\n", + "example": 599, + "start_line": 8818, + "end_line": 8822, + "section": "Autolinks" + }, + { + "markdown": "\n", + "html": "

localhost:5001/foo

\n", + "example": 600, + "start_line": 8825, + "end_line": 8829, + "section": "Autolinks" + }, + { + "markdown": "\n", + "html": "

<http://foo.bar/baz bim>

\n", + "example": 601, + "start_line": 8834, + "end_line": 8838, + "section": "Autolinks" + }, + { + "markdown": "\n", + "html": "

http://example.com/\\[\\

\n", + "example": 602, + "start_line": 8843, + "end_line": 8847, + "section": "Autolinks" + }, + { + "markdown": "\n", + "html": "

foo@bar.example.com

\n", + "example": 603, + "start_line": 8865, + "end_line": 8869, + "section": "Autolinks" + }, + { + "markdown": "\n", + "html": "

foo+special@Bar.baz-bar0.com

\n", + "example": 604, + "start_line": 8872, + "end_line": 8876, + "section": "Autolinks" + }, + { + "markdown": "\n", + "html": "

<foo+@bar.example.com>

\n", + "example": 605, + "start_line": 8881, + "end_line": 8885, + "section": "Autolinks" + }, + { + "markdown": "<>\n", + "html": "

<>

\n", + "example": 606, + "start_line": 8890, + "end_line": 8894, + "section": "Autolinks" + }, + { + "markdown": "< http://foo.bar >\n", + "html": "

< http://foo.bar >

\n", + "example": 607, + "start_line": 8897, + "end_line": 8901, + "section": "Autolinks" + }, + { + "markdown": "\n", + "html": "

<m:abc>

\n", + "example": 608, + "start_line": 8904, + "end_line": 8908, + "section": "Autolinks" + }, + { + "markdown": "\n", + "html": "

<foo.bar.baz>

\n", + "example": 609, + "start_line": 8911, + "end_line": 8915, + "section": "Autolinks" + }, + { + "markdown": "http://example.com\n", + "html": "

http://example.com

\n", + "example": 610, + "start_line": 8918, + "end_line": 8922, + "section": "Autolinks" + }, + { + "markdown": "foo@bar.example.com\n", + "html": "

foo@bar.example.com

\n", + "example": 611, + "start_line": 8925, + "end_line": 8929, + "section": "Autolinks" + }, + { + "markdown": "\n", + "html": "

\n", + "example": 612, + "start_line": 9006, + "end_line": 9010, + "section": "Raw HTML" + }, + { + "markdown": "\n", + "html": "

\n", + "example": 613, + "start_line": 9015, + "end_line": 9019, + "section": "Raw HTML" + }, + { + "markdown": "\n", + "html": "

\n", + "example": 614, + "start_line": 9024, + "end_line": 9030, + "section": "Raw HTML" + }, + { + "markdown": "\n", + "html": "

\n", + "example": 615, + "start_line": 9035, + "end_line": 9041, + "section": "Raw HTML" + }, + { + "markdown": "Foo \n", + "html": "

Foo

\n", + "example": 616, + "start_line": 9046, + "end_line": 9050, + "section": "Raw HTML" + }, + { + "markdown": "<33> <__>\n", + "html": "

<33> <__>

\n", + "example": 617, + "start_line": 9055, + "end_line": 9059, + "section": "Raw HTML" + }, + { + "markdown": "
\n", + "html": "

<a h*#ref="hi">

\n", + "example": 618, + "start_line": 9064, + "end_line": 9068, + "section": "Raw HTML" + }, + { + "markdown": "
\n", + "html": "

<a href="hi'> <a href=hi'>

\n", + "example": 619, + "start_line": 9073, + "end_line": 9077, + "section": "Raw HTML" + }, + { + "markdown": "< a><\nfoo>\n\n", + "html": "

< a><\nfoo><bar/ >\n<foo bar=baz\nbim!bop />

\n", + "example": 620, + "start_line": 9082, + "end_line": 9092, + "section": "Raw HTML" + }, + { + "markdown": "
\n", + "html": "

<a href='bar'title=title>

\n", + "example": 621, + "start_line": 9097, + "end_line": 9101, + "section": "Raw HTML" + }, + { + "markdown": "
\n", + "html": "

\n", + "example": 622, + "start_line": 9106, + "end_line": 9110, + "section": "Raw HTML" + }, + { + "markdown": "\n", + "html": "

</a href="foo">

\n", + "example": 623, + "start_line": 9115, + "end_line": 9119, + "section": "Raw HTML" + }, + { + "markdown": "foo \n", + "html": "

foo

\n", + "example": 624, + "start_line": 9124, + "end_line": 9130, + "section": "Raw HTML" + }, + { + "markdown": "foo \n", + "html": "

foo <!-- not a comment -- two hyphens -->

\n", + "example": 625, + "start_line": 9133, + "end_line": 9137, + "section": "Raw HTML" + }, + { + "markdown": "foo foo -->\n\nfoo \n", + "html": "

foo <!--> foo -->

\n

foo <!-- foo--->

\n", + "example": 626, + "start_line": 9142, + "end_line": 9149, + "section": "Raw HTML" + }, + { + "markdown": "foo \n", + "html": "

foo

\n", + "example": 627, + "start_line": 9154, + "end_line": 9158, + "section": "Raw HTML" + }, + { + "markdown": "foo \n", + "html": "

foo

\n", + "example": 628, + "start_line": 9163, + "end_line": 9167, + "section": "Raw HTML" + }, + { + "markdown": "foo &<]]>\n", + "html": "

foo &<]]>

\n", + "example": 629, + "start_line": 9172, + "end_line": 9176, + "section": "Raw HTML" + }, + { + "markdown": "foo \n", + "html": "

foo

\n", + "example": 630, + "start_line": 9182, + "end_line": 9186, + "section": "Raw HTML" + }, + { + "markdown": "foo \n", + "html": "

foo

\n", + "example": 631, + "start_line": 9191, + "end_line": 9195, + "section": "Raw HTML" + }, + { + "markdown": "\n", + "html": "

<a href=""">

\n", + "example": 632, + "start_line": 9198, + "end_line": 9202, + "section": "Raw HTML" + }, + { + "markdown": "foo \nbaz\n", + "html": "

foo
\nbaz

\n", + "example": 633, + "start_line": 9212, + "end_line": 9218, + "section": "Hard line breaks" + }, + { + "markdown": "foo\\\nbaz\n", + "html": "

foo
\nbaz

\n", + "example": 634, + "start_line": 9224, + "end_line": 9230, + "section": "Hard line breaks" + }, + { + "markdown": "foo \nbaz\n", + "html": "

foo
\nbaz

\n", + "example": 635, + "start_line": 9235, + "end_line": 9241, + "section": "Hard line breaks" + }, + { + "markdown": "foo \n bar\n", + "html": "

foo
\nbar

\n", + "example": 636, + "start_line": 9246, + "end_line": 9252, + "section": "Hard line breaks" + }, + { + "markdown": "foo\\\n bar\n", + "html": "

foo
\nbar

\n", + "example": 637, + "start_line": 9255, + "end_line": 9261, + "section": "Hard line breaks" + }, + { + "markdown": "*foo \nbar*\n", + "html": "

foo
\nbar

\n", + "example": 638, + "start_line": 9267, + "end_line": 9273, + "section": "Hard line breaks" + }, + { + "markdown": "*foo\\\nbar*\n", + "html": "

foo
\nbar

\n", + "example": 639, + "start_line": 9276, + "end_line": 9282, + "section": "Hard line breaks" + }, + { + "markdown": "`code \nspan`\n", + "html": "

code span

\n", + "example": 640, + "start_line": 9287, + "end_line": 9292, + "section": "Hard line breaks" + }, + { + "markdown": "`code\\\nspan`\n", + "html": "

code\\ span

\n", + "example": 641, + "start_line": 9295, + "end_line": 9300, + "section": "Hard line breaks" + }, + { + "markdown": "
\n", + "html": "

\n", + "example": 642, + "start_line": 9305, + "end_line": 9311, + "section": "Hard line breaks" + }, + { + "markdown": "\n", + "html": "

\n", + "example": 643, + "start_line": 9314, + "end_line": 9320, + "section": "Hard line breaks" + }, + { + "markdown": "foo\\\n", + "html": "

foo\\

\n", + "example": 644, + "start_line": 9327, + "end_line": 9331, + "section": "Hard line breaks" + }, + { + "markdown": "foo \n", + "html": "

foo

\n", + "example": 645, + "start_line": 9334, + "end_line": 9338, + "section": "Hard line breaks" + }, + { + "markdown": "### foo\\\n", + "html": "

foo\\

\n", + "example": 646, + "start_line": 9341, + "end_line": 9345, + "section": "Hard line breaks" + }, + { + "markdown": "### foo \n", + "html": "

foo

\n", + "example": 647, + "start_line": 9348, + "end_line": 9352, + "section": "Hard line breaks" + }, + { + "markdown": "foo\nbaz\n", + "html": "

foo\nbaz

\n", + "example": 648, + "start_line": 9363, + "end_line": 9369, + "section": "Soft line breaks" + }, + { + "markdown": "foo \n baz\n", + "html": "

foo\nbaz

\n", + "example": 649, + "start_line": 9375, + "end_line": 9381, + "section": "Soft line breaks" + }, + { + "markdown": "hello $.;'there\n", + "html": "

hello $.;'there

\n", + "example": 650, + "start_line": 9395, + "end_line": 9399, + "section": "Textual content" + }, + { + "markdown": "Foo χρῆν\n", + "html": "

Foo χρῆν

\n", + "example": 651, + "start_line": 9402, + "end_line": 9406, + "section": "Textual content" + }, + { + "markdown": "Multiple spaces\n", + "html": "

Multiple spaces

\n", + "example": 652, + "start_line": 9411, + "end_line": 9415, + "section": "Textual content" + } +] \ No newline at end of file diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/fixtures/def_list.txt b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/fixtures/def_list.txt new file mode 100644 index 0000000000000000000000000000000000000000..6c5a210232576e53330d55888c2d041ffeccc145 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/fixtures/def_list.txt @@ -0,0 +1,172 @@ +# Definition Lists + +```````````````````````````````` example +Term +: definition +. +
+
Term
+
definition
+
+```````````````````````````````` + +```````````````````````````````` example +Term +: definition1 +: definition2 +. +
+
Term
+
definition1
+
definition2
+
+```````````````````````````````` + +```````````````````````````````` example +Term +: definition1 +: definition2 + +paragraph +. +
+
Term
+
definition1
+
definition2
+
+

paragraph

+```````````````````````````````` + +```````````````````````````````` example +First Term +: This is the definition of the first term. + +Second Term +: This is one definition of the second term. +: This is another definition of the second term. +. +
+
First Term
+
This is the definition of the first term.
+
Second Term
+
This is one definition of the second term.
+
This is another definition of the second term.
+
+```````````````````````````````` + +```````````````````````````````` example +First Term +: This is the definition of the first term. + +Second Term +: This is one definition of the second term. +: This is another definition of the second term. + +paragraph +. +
+
First Term
+
This is the definition of the first term.
+
Second Term
+
This is one definition of the second term.
+
This is another definition of the second term.
+
+

paragraph

+```````````````````````````````` + +```````````````````````````````` example +First Term +: This is the definition of the first term. +Not Second Term +: This is one definition of the second term. +: This is another definition of the second term. + +paragraph +. +
+
First Term
+
This is the definition of the first term. +Not Second Term
+
This is one definition of the second term.
+
This is another definition of the second term.
+
+

paragraph

+```````````````````````````````` + +## Definition with Multiple Lines + +```````````````````````````````` example +Term + +: definition +. +
+
Term
+

definition

+
+
+```````````````````````````````` + + +```````````````````````````````` example +Term +: foo + + bar +. +
+
Term
+

foo

+

bar

+
+
+```````````````````````````````` + +Leading 4 white spaces + +```````````````````````````````` example +Term +: foo + + bar +. +
+
Term
+

foo

+

bar

+
+
+```````````````````````````````` + + +```````````````````````````````` example +Term +: foo + + bar +. +
+
Term
+

foo

+
bar
+
+
+```````````````````````````````` + +```````````````````````````````` example +Term +: foo + + - bar + - baz +. +
+
Term
+

foo

+
    +
  • bar
  • +
  • baz
  • +
+
+
+```````````````````````````````` diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/fixtures/diff-commonmark.txt b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/fixtures/diff-commonmark.txt new file mode 100644 index 0000000000000000000000000000000000000000..9573e2a383b273af5db4a2386d9f9fe35120d9b4 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/fixtures/diff-commonmark.txt @@ -0,0 +1,76 @@ +# Differences + +Results different than commonmark. + + +## Setext headings + + +Example: 93 + + +```````````````````````````````` example +> foo +bar +=== +. +
+

foo +bar

+
+```````````````````````````````` + +If the dash is less than 3, it is not a `
`, in this case, it +can be rendered into `

`. + +```````````````````````````````` example +- # Foo +- Bar + -- + baz +. +
    +
  • +

    Foo

    +
  • +
  • +

    Bar

    +baz
  • +
+```````````````````````````````` + +## Image + +Example 573 + +```````````````````````````````` example +![foo ![bar](/url)](/url2) +. +

foo ![bar](/url)

+```````````````````````````````` + +## Link + +Example 517 + +```````````````````````````````` example +[foo [bar](/uri)](/uri) +. +

foo [bar](/uri)

+```````````````````````````````` + +Example 518 + +```````````````````````````````` example +[foo *[bar [baz](/uri)](/uri)*](/uri) +. +

foo [bar [baz](/uri)](/uri)

+```````````````````````````````` + +Example 519 + +```````````````````````````````` example +![[[foo](uri1)](uri2)](uri3) +. +

[foo](uri1)

+```````````````````````````````` diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/fixtures/fenced_admonition.txt b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/fixtures/fenced_admonition.txt new file mode 100644 index 0000000000000000000000000000000000000000..0f962c5e4d44d9fa81effe866998e1fc6f88565d --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/fixtures/fenced_admonition.txt @@ -0,0 +1,129 @@ +# Admonition + +```````````````````````````````` example +```{unknown} Hi + +this is **strong** world +``` +. +
{unknown} Hi
+
+this is **strong** world
+
+```````````````````````````````` + +```````````````````````````````` example +``` +this is code +``` +. +
this is code
+
+```````````````````````````````` + + +```````````````````````````````` example +~~~{note} Warning + +message +~~~ +. +
+

Warning

+

message

+
+```````````````````````````````` + +```````````````````````````````` example +~~~{note} A **strong** title + +_message_ +~~~ +. +
+

A strong title

+

message

+
+```````````````````````````````` + +Test with code block. + +```````````````````````````````` example +```{note} + + print() +``` +. +
+

Note

+
print()
+
+```````````````````````````````` + +Test with no message. + +```````````````````````````````` example +~~~{note} Warning +~~~ +. +
+

Warning

+
+```````````````````````````````` + +Test with no ending fence + +```````````````````````````````` example +~~~{note} Warning +. +
+

Warning

+
+```````````````````````````````` + +Test with nested admonition + +```````````````````````````````` example +~~~~~~~{note} +~~~~~~{warning} +~~~~~{tip} +~~~~{caution} +~~~{hint} +``````{danger} +`````{attention} +````{important} +```{error} +``` +```` +````` +`````` +~~~ +~~~~ +~~~~~ +~~~~~~ +~~~~~~~ +. +
+

Note

+
+

Warning

+
+

Tip

+
+

Caution

+
+

Hint

+
+

Danger

+
````{important}
+```{error}
+```
+````
+
+
+
+
+
+
+
+```````````````````````````````` diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/fixtures/fenced_figure.txt b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/fixtures/fenced_figure.txt new file mode 100644 index 0000000000000000000000000000000000000000..0fcd23c1f1280e6e9b17a43fbb8942d21b702254 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/fixtures/fenced_figure.txt @@ -0,0 +1,166 @@ +# Figure + +## No options + +```````````````````````````````` example +~~~{figure} picture.png +~~~ +. +
+
+
+```````````````````````````````` + +## Align options + +```````````````````````````````` example +~~~{figure} picture.png +:align: left +~~~ +. +
+
+
+```````````````````````````````` + + +```````````````````````````````` example +~~~{figure} picture.png +:align: invalid +~~~ +. +
+
+
+```````````````````````````````` + +## width and height + +```````````````````````````````` example +~~~{figure} picture.png +:width: 100 +:height: 50 +~~~ +. +
+
+
+```````````````````````````````` + +```````````````````````````````` example +~~~{figure} picture.png +:width: 100px +:height: 50px +~~~ +. +
+
+
+```````````````````````````````` + +```````````````````````````````` example +~~~{figure} picture.png +:figwidth: 400px +~~~ +. +
+
+
+```````````````````````````````` + +## alt option + +```````````````````````````````` example +~~~{figure} picture.png +:alt: description text +~~~ +. +
+
description text
+
+```````````````````````````````` + +## target option + +```````````````````````````````` example +~~~{figure} picture.png +:target: https://lepture.com +~~~ +. +
+ +
+```````````````````````````````` + +## caption + +```````````````````````````````` example +~~~{figure} picture.png +a caption with **emphasis** text +~~~ +. +
+
+
a caption with emphasis text
+
+```````````````````````````````` + +## legend + +```````````````````````````````` example +~~~{figure} picture.png +a caption with **emphasis** text + +> quote +~~~ +. +
+
+
a caption with emphasis text
+
+
+

quote

+
+
+
+```````````````````````````````` + + +```````````````````````````````` example +~~~{figure} picture.png +> quote +~~~ +. +
+
+
+```````````````````````````````` + +## all options + + +```````````````````````````````` example +~~~{figure} picture.png +:figwidth: 400px +:figclass: all-options +:target: https://lepture.com +:alt: description +:align: left +:width: 100 +:height: 50 + +a caption with **emphasis** text + +> quote +~~~ +. +
+description +
a caption with emphasis text
+
+
+

quote

+
+
+
+```````````````````````````````` diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/fixtures/fenced_image.txt b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/fixtures/fenced_image.txt new file mode 100644 index 0000000000000000000000000000000000000000..afec622ce413acb5fcbb287e020c4588e892de8c --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/fixtures/fenced_image.txt @@ -0,0 +1,102 @@ +# Image + +## No options + +```````````````````````````````` example +~~~{image} picture.png +~~~ +. +
+```````````````````````````````` + +## Align options + +```````````````````````````````` example +~~~{image} picture.png +:align: left +~~~ +. +
+```````````````````````````````` + + +```````````````````````````````` example +~~~{image} picture.png +:align: invalid +~~~ +. +
+```````````````````````````````` + +## width and height + +```````````````````````````````` example +~~~{image} picture.png +:width: 100 +:height: 50 +~~~ +. +
+```````````````````````````````` + +```````````````````````````````` example +~~~{image} picture.png +:width: 100px +:height: 50px +~~~ +. +
+```````````````````````````````` + +## alt option + +```````````````````````````````` example +~~~{image} picture.png +:alt: description text +~~~ +. +
description text
+```````````````````````````````` + +## target option + +```````````````````````````````` example +~~~{image} picture.png +:target: https://lepture.com +~~~ +. + +```````````````````````````````` + +## all options + +```````````````````````````````` example +~~~{image} picture.png +:target: https://lepture.com +:alt: description +:align: left +:width: 100 +:height: 50 +~~~ +. +description +```````````````````````````````` + +## ampersand in source + +```````````````````````````````` example +~~~{image} https://example.com/picture.png?foo=qux&test=me +~~~ +. +
+```````````````````````````````` + +## ampersand in target + +```````````````````````````````` example +~~~{image} picture.png +:target: https://example.com/rickroll?a=1&b=2 +~~~ +. + +```````````````````````````````` diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/fixtures/fenced_toc.txt b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/fixtures/fenced_toc.txt new file mode 100644 index 0000000000000000000000000000000000000000..1744000ce6ca473d1d75fb2d9388d46d3463a64c --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/fixtures/fenced_toc.txt @@ -0,0 +1,237 @@ +# Table of Contents + +## No TOC + +```````````````````````````````` example +none +. +

none

+```````````````````````````````` + +```````````````````````````````` example +# H1 +## H2 +. +

H1

+

H2

+```````````````````````````````` + + +## Simple TOC + +```````````````````````````````` example +~~~{toc} +~~~ + +# H1 +## H2 +. +
+Table of Contents + +
+

H1

+

H2

+```````````````````````````````` + +## Invalid Option + +```````````````````````````````` example +# H1 +## H2 + +~~~{toc} +:max-level: s +~~~ +. +

H1

+

H2

+
"max-level" option MUST be integer
+```````````````````````````````` + +```````````````````````````````` example +# H1 +## H2 + +~~~{toc} +:max-level: 9 +~~~ +. +

H1

+

H2

+
"max-level" option MUST be <= 3
+```````````````````````````````` + +```````````````````````````````` example +# H1 +## H2 + +~~~{toc} +:min-level: 2 +:max-level: 1 +~~~ +. +

H1

+

H2

+
"min-level" option MUST be less than "max-level" option
+```````````````````````````````` + +## Complex + +```````````````````````````````` example +# H1 +## H2 +### H3 +#### H4 +# H1 B +# H1 `C` + +```{toc} Contents +``` +. +

H1

+

H2

+

H3

+

H4

+

H1 B

+

H1 C

+
+Contents + +
+```````````````````````````````` + +## Insane + +```````````````````````````````` example +# H1 +### H3 +## H2 +#### H4 +### H3 B +# H1 B + +```{toc} +``` +. +

H1

+

H3

+

H2

+

H4

+

H3 B

+

H1 B

+
+Table of Contents + +
+```````````````````````````````` + +```````````````````````````````` example +### H3 +## H2 +# H1 + +```{toc} +``` +. +

H3

+

H2

+

H1

+
+Table of Contents + +
+```````````````````````````````` + +## Link in Heading + + +```````````````````````````````` example +# [foo](/bar) + +```{toc} +``` +. +

foo

+
+Table of Contents + +
+```````````````````````````````` + +## HTML in Heading + +```````````````````````````````` example +# H1 +```{toc} +``` +. +

H1

+
+Table of Contents + +
+```````````````````````````````` + +## Collapse TOC + +```````````````````````````````` example + +```{toc} +:collapse: +``` + +# H1 +## H2 +. +
+Table of Contents + +
+

H1

+

H2

+```````````````````````````````` diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/fixtures/fix-commonmark.txt b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/fixtures/fix-commonmark.txt new file mode 100644 index 0000000000000000000000000000000000000000..c7870065cc61e07f114050eaaecf60d3db5cbdf9 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/fixtures/fix-commonmark.txt @@ -0,0 +1,123 @@ +Fix problems that commonmark has. + + +## Links + +Links can't contain links. + +```````````````````````````````` example +[](/foo) +. +

<https://example.com>

+```````````````````````````````` + +```````````````````````````````` example +[](/foo) +. +

<name@example.com>

+```````````````````````````````` + +## Emphasis + +`` doesn't contain ``, `` doesn't contain ``. + +```````````````````````````````` example +*_em_* __**strong**__ ______m______ +. +

_em_ **strong** ______m______

+```````````````````````````````` + +### Non aggressive emphasis + +```````````````````````````````` example +*a **b c* d** +. +

a **b c d**

+```````````````````````````````` + +While CommonMark would render it into: + +``` +

a b c d

+``` + +```````````````````````````````` example +*a **b c* d** +. +

a **b c d**

+```````````````````````````````` + +While CommonMark would render it into: + +``` +

a b c d

+``` + +What if the string is: + +```````````````````````````````` example +*a **b c* d +. +

a **b c d

+```````````````````````````````` + +CommonMark would still be a mess: + +``` +

*a *b c d

+``` + + +## Max depth + + +```````````````````````````````` example +> > > > > > > > b +. +
+
+
+
+
+
+

> > b

+
+
+
+
+
+
+```````````````````````````````` + + +```````````````````````````````` example +- a + - b + - c + - d + - e + - f + - g + - h +. +
    +
  • a
      +
    • b
        +
      • c
          +
        • d
            +
          • e
              +
            • f +- g +- h
            • +
            +
          • +
          +
        • +
        +
      • +
      +
    • +
    +
  • +
+```````````````````````````````` diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/fixtures/footnotes.txt b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/fixtures/footnotes.txt new file mode 100644 index 0000000000000000000000000000000000000000..485cfd87c0a18859af15ec52b8baacad5c44fe6c --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/fixtures/footnotes.txt @@ -0,0 +1,45 @@ +# Footnotes + +```````````````````````````````` example +none [^1] +. +

none [^1]

+```````````````````````````````` + +```````````````````````````````` example +oneline [^1] + +[^1]: foo +. +

oneline 1

+
+
    +
  1. foo↩

  2. +
+
+```````````````````````````````` + +```````````````````````````````` example +multiple lines [^1] + +[^1]: foo + + one + + two + + three + + four +. +

multiple lines 1

+
four
+
+
    +
  1. foo

    +

    one

    +

    two

    +

    three↩

  2. +
+
+```````````````````````````````` diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/fixtures/hook_toc.txt b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/fixtures/hook_toc.txt new file mode 100644 index 0000000000000000000000000000000000000000..62a1a1ec79dacaf8854a67e3b48f5a1c1e9d2f4b --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/fixtures/hook_toc.txt @@ -0,0 +1,122 @@ +# Table of Contents + +## Simple TOC + +```````````````````````````````` example +# H1 + +content + +## H2 +. +

H1

+

content

+

H2

+ +```````````````````````````````` + +## Complex TOC + +```````````````````````````````` example +# H1 +## H2 +### H3 +#### H4 +# H1 B +# H1 `C` +. +

H1

+

H2

+

H3

+

H4

+

H1 B

+

H1 C

+ +```````````````````````````````` + +## Insane TOC + +```````````````````````````````` example +# H1 +### H3 +## H2 +#### H4 +### H3 B +# H1 B +. +

H1

+

H3

+

H2

+

H4

+

H3 B

+

H1 B

+ +```````````````````````````````` + +```````````````````````````````` example +### H3 +## H2 +# H1 +. +

H3

+

H2

+

H1

+ +```````````````````````````````` + +## Link in Heading + + +```````````````````````````````` example +# [foo](/bar) +. +

foo

+ +```````````````````````````````` + +## HTML in Heading + +```````````````````````````````` example +# H1 +. +

H1

+ +```````````````````````````````` diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/fixtures/include/hello.md b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/fixtures/include/hello.md new file mode 100644 index 0000000000000000000000000000000000000000..5e3d2769d88dd761efbd358b5dd0cb095d652294 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/fixtures/include/hello.md @@ -0,0 +1 @@ +> hello diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/fixtures/include/hello.txt b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/fixtures/include/hello.txt new file mode 100644 index 0000000000000000000000000000000000000000..ce013625030ba8dba906f756967f9e9ca394464a --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/fixtures/include/hello.txt @@ -0,0 +1 @@ +hello diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/fixtures/include/text.html b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/fixtures/include/text.html new file mode 100644 index 0000000000000000000000000000000000000000..da12a4c59bef8e4cc80b93ee6c98ebf6e9a10372 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/fixtures/include/text.html @@ -0,0 +1 @@ +
include html
diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/fixtures/include/text.md b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/fixtures/include/text.md new file mode 100644 index 0000000000000000000000000000000000000000..e9faa6cc816e06f743ffb9a1ae753a209607840e --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/fixtures/include/text.md @@ -0,0 +1,12 @@ +# Include + +.. include:: ./text.md + +.. include:: ./not-exist.md + +.. include:: ./text.html + :encoding: utf-8 + +.. include:: ./hello.md + +.. include:: ../rst_toc.txt diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/fixtures/insert.txt b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/fixtures/insert.txt new file mode 100644 index 0000000000000000000000000000000000000000..74d02058f0a66e5598e91d8a84429d17b7c4b62a --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/fixtures/insert.txt @@ -0,0 +1,62 @@ +# Insert + +```````````````````````````````` example +^^insert me +. +

^^insert me

+```````````````````````````````` + + +## normal insert + +```````````````````````````````` example +^^insert me^^ +. +

insert me

+```````````````````````````````` + +```````````````````````````````` example +foo ^^insert me^^ +. +

foo insert me

+```````````````````````````````` + +```````````````````````````````` example +^^insert me^^foo +. +

insert mefoo

+```````````````````````````````` + +```````````````````````````````` example +^^insert me^^^ +. +

^^insert me^^^

+```````````````````````````````` + +## escape insert + +```````````````````````````````` example +^^insert me\^^^ +. +

insert me^

+```````````````````````````````` + +```````````````````````````````` example +^^insert \^\^ me^^ +. +

insert ^^ me

+```````````````````````````````` + +## insert link + +```````````````````````````````` example +^^insert [me^^](/) +. +

insert [me](/)

+```````````````````````````````` + +```````````````````````````````` example +^^[hello](/)^^ +. +

hello

+```````````````````````````````` diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/fixtures/mark.txt b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/fixtures/mark.txt new file mode 100644 index 0000000000000000000000000000000000000000..9c8d2fbc1bf286f937a2ed288f5d497bcfca2136 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/fixtures/mark.txt @@ -0,0 +1,61 @@ +# Mark + +```````````````````````````````` example +==mark me +. +

==mark me

+```````````````````````````````` + +## normal mark + +```````````````````````````````` example +==mark me== +. +

mark me

+```````````````````````````````` + +```````````````````````````````` example +foo ==mark me== +. +

foo mark me

+```````````````````````````````` + +```````````````````````````````` example +==mark me==foo +. +

mark mefoo

+```````````````````````````````` + +```````````````````````````````` example +==mark me=== +. +

==mark me===

+```````````````````````````````` + +## escape mark + +```````````````````````````````` example +==mark me\=== +. +

mark me=

+```````````````````````````````` + +```````````````````````````````` example +==mark \=\= me== +. +

mark == me

+```````````````````````````````` + +## mark link + +```````````````````````````````` example +==mark [me==](/) +. +

mark [me](/)

+```````````````````````````````` + +```````````````````````````````` example +==[hello](/)== +. +

hello

+```````````````````````````````` diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/fixtures/math.txt b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/fixtures/math.txt new file mode 100644 index 0000000000000000000000000000000000000000..e7afaf9d1d2757c25e797b47ef4803bdeee503ef --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/fixtures/math.txt @@ -0,0 +1,57 @@ +# Math + +## Block Math + +```````````````````````````````` example +$$ +. +

$$

+```````````````````````````````` + + +```````````````````````````````` example +$$ +\operatorname{ker} f=\{g\in G:f(g)=e_{H}\}{\mbox{.}} +$$ +. +
$$ +\operatorname{ker} f=\{g\in G:f(g)=e_{H}\}{\mbox{.}} +$$
+```````````````````````````````` + +```````````````````````````````` example +$$ +foo +$$ +bar +. +
$$ +foo +$$
+

bar

+```````````````````````````````` + +```````````````````````````````` example +$$ +foo +bar +$$ +. +
$$ +foo +bar +$$
+```````````````````````````````` + + +## Inline Math + +```````````````````````````````` example +The homomorphism $f$ is injective if and only if its kernel is only the +singleton set $e_G$, because otherwise $\exists a,b\in G$ +with $a\neq b$ such that $f(a)=f(b)$. +. +

The homomorphism \(f\) is injective if and only if its kernel is only the +singleton set \(e_G\), because otherwise \(\exists a,b\in G\) +with \(a\neq b\) such that \(f(a)=f(b)\).

+```````````````````````````````` diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/fixtures/renderer_markdown.txt b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/fixtures/renderer_markdown.txt new file mode 100644 index 0000000000000000000000000000000000000000..fd618f9f281f83c0e5f2f51bcb19080e4188011a --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/fixtures/renderer_markdown.txt @@ -0,0 +1,299 @@ +# MarkdownRenderer + + +## inline + +```````````````````````````````` example +this is _em_, **strong**, and `code` +. +this is *em*, **strong**, and `code` +```````````````````````````````` + +## links + +```````````````````````````````` example +[link], [link][], [text][link], [link](/foo), [link](/foo "title") + +[link]: /url +. +[link][link], [link][link], [text][link], [link](/foo), [link](/foo "title") + +[link]: /url +```````````````````````````````` + +```````````````````````````````` example +[link], [link](https://foo(bar "title") + +[link]: /url "title" +. +[link][link], [link]( "title") + +[link]: /url "title" +```````````````````````````````` + +```````````````````````````````` example +[https://lepture.com](https://lepture.com) + + + + [demo@example.com](mailto:demo@example.com) +. + + + + + +```````````````````````````````` + +## images + +```````````````````````````````` example +[link]: /url + +![link], ![link][], ![alt][link] +. +![link][link], ![link][link], ![alt][link] + +[link]: /url +```````````````````````````````` + +## linebreak + +```````````````````````````````` example +foo\ +bar +. +foo +bar +```````````````````````````````` + +## html + +```````````````````````````````` example +inline html text + +and block html + +
hi
+. +inline html text + +and block html + +
hi
+```````````````````````````````` + +## heading + +```````````````````````````````` example +# h1 +## h2 +### h3 +#### h4 +##### h5 +###### h6 + +h1 +== +. +# h1 + +## h2 + +### h3 + +#### h4 + +##### h5 + +###### h6 + +# h1 +```````````````````````````````` + +## thematic break + +```````````````````````````````` example +hi +*** +. +hi + +*** +```````````````````````````````` + +## code + +```````````````````````````````` example +start + + def foo(): + pass + +end +. +start + +``` +def foo(): + pass +``` + +end +```````````````````````````````` + +```````````````````````````````` example +start +```py +def foo(): + pass +``` +end +. +start + +```py +def foo(): + pass +``` + +end +```````````````````````````````` + +```````````````````````````````` example +indent code + + markdown + ``` + fenced +. +indent code + +~~~ +markdown +``` +fenced +~~~ +```````````````````````````````` + +```````````````````````````````` example +indent code + + markdown + ~~~ + fenced +. +indent code + +``` +markdown +~~~ +fenced +``` +```````````````````````````````` + +```````````````````````````````` example +indent code + + markdown + ``` + fenced + ~~~ +. +indent code + +```` +markdown +``` +fenced +~~~ +```` +```````````````````````````````` + + +## quote + +```````````````````````````````` example +> quote +. +> quote +```````````````````````````````` + +```````````````````````````````` example +hello +> quote +. +hello + +> quote +```````````````````````````````` + +> quote + +> quote +> +> continuation +. +> quote + +> quote +> +> continuation + +## list + +```````````````````````````````` example +- list ++ list +. +- list + ++ list +```````````````````````````````` + +```````````````````````````````` example +- item 1 + item 2 +. +- item 1 + item 2 +```````````````````````````````` + +```````````````````````````````` example +- item 1 + + item 2 +- item 3 +. +- item 1 + + item 2 + +- item 3 +```````````````````````````````` + +```````````````````````````````` example +- item 1 + 1. item 2 +. +- item 1 + 1. item 2 +```````````````````````````````` + +```````````````````````````````` example +- item 1 + + 2. item 2 +. +- item 1 + + 2. item 2 +```````````````````````````````` + +```````````````````````````````` example +- list +- +. +- list +- +```````````````````````````````` diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/fixtures/renderer_rst.txt b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/fixtures/renderer_rst.txt new file mode 100644 index 0000000000000000000000000000000000000000..1b2499ddb74fc532191d296612fd19687224ec5b --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/fixtures/renderer_rst.txt @@ -0,0 +1,250 @@ +# RSTRenderer + +## inline + +```````````````````````````````` example +this is _em_, **strong**, and `code` +. +this is *em*, **strong**, and ``code`` +```````````````````````````````` + +```````````````````````````````` example +| escape | +. +\| escape \| +```````````````````````````````` + +## links + +```````````````````````````````` example +this is [link][] and [link](/foo) + +[link]: /url +. +this is `link
`__ and `link `__ +```````````````````````````````` + +## images + +```````````````````````````````` example +this is inline ![alt _text_](/foo) +. +this is inline |img-0| + +.. |img-0| image:: /foo + :alt: alt *text* +```````````````````````````````` + +```````````````````````````````` example +this is figure + +![alt _text_](/foo) +. +this is figure + +.. figure:: /foo + + alt *text* +```````````````````````````````` + +```````````````````````````````` example +this is figure + +![alt _text_](/foo "title") +. +this is figure + +.. figure:: /foo + :alt: title + + alt *text* +```````````````````````````````` + + +## html + +```````````````````````````````` example +ignore inline html text + +but show block html + +
hi
+. +ignore inline html text + +but show block html + +.. raw:: html + +
hi
+```````````````````````````````` + +## line break + +```````````````````````````````` example +hello +world +. +| hello +| world +```````````````````````````````` + +## heading + +```````````````````````````````` example +# h1 +## h2 +### h3 +#### h4 +##### h5 +###### h6 +. +h1 +== + +h2 +-- + +h3 +~~ + +h4 +^^ + +h5 +"" + +h6 +'' +```````````````````````````````` + +## thematic break + +```````````````````````````````` example +hi +*** +. +hi + +-------------- +```````````````````````````````` + +## code + +```````````````````````````````` example +start + + def foo(): + pass + +end +. +start + +:: + + def foo(): + pass + +end +```````````````````````````````` + +```````````````````````````````` example +start + +```py +def foo(): + pass +``` + +end +. +start + +.. code:: py + + def foo(): + pass + +end +```````````````````````````````` + + +## quote + +```````````````````````````````` example +> quote +. + quote +```````````````````````````````` + +```````````````````````````````` example +hello + +> quote +. +hello + + quote +```````````````````````````````` + +```````````````````````````````` example +> hello + +> quote +. + hello + +.. + + quote +```````````````````````````````` + +## list + +```````````````````````````````` example +- list ++ list +. +- list + ++ list +```````````````````````````````` + +```````````````````````````````` example +- item 1 + item 2 +. +- item 1 item 2 +```````````````````````````````` + +```````````````````````````````` example +- item 1 + + item 2 +- item 3 +. +- item 1 + + item 2 + +- item 3 +```````````````````````````````` + +```````````````````````````````` example +- item 1 + 1. item 2 +. +- item 1 + 1. item 2 +```````````````````````````````` + +```````````````````````````````` example +- item 1 + + 1. item 2 +. +- item 1 + + 1. item 2 +```````````````````````````````` diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/fixtures/rst_admonition.txt b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/fixtures/rst_admonition.txt new file mode 100644 index 0000000000000000000000000000000000000000..b29bda3046fdb97802fefc9a7d16a9439d9efeb6 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/fixtures/rst_admonition.txt @@ -0,0 +1,46 @@ +# Admonition + +```````````````````````````````` example +.. hello:: Warning + + message +. +
..  hello:: Warning
+
+    message
+
+```````````````````````````````` + +```````````````````````````````` example +.. note:: Warning + + message +. +
+

Warning

+

message

+
+```````````````````````````````` + +Test with code block. + +```````````````````````````````` example +.. note:: + + print() +. +
+

Note

+
print()
+
+```````````````````````````````` + +Test with no message. + +```````````````````````````````` example +.. note:: Warning +. +
+

Warning

+
+```````````````````````````````` diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/fixtures/rst_toc.txt b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/fixtures/rst_toc.txt new file mode 100644 index 0000000000000000000000000000000000000000..d65e7516398316de9532f5f52cd0ccfe182b86f1 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/fixtures/rst_toc.txt @@ -0,0 +1,223 @@ +# Table of Contents + +## No TOC + +```````````````````````````````` example +none +. +

none

+```````````````````````````````` + +```````````````````````````````` example +# H1 +## H2 +. +

H1

+

H2

+```````````````````````````````` + + +## Simple TOC + +```````````````````````````````` example +.. toc:: + +# H1 +## H2 +. +
+Table of Contents + +
+

H1

+

H2

+```````````````````````````````` + +## Invalid Option + +```````````````````````````````` example +# H1 +## H2 + +.. toc:: + :max-level: s +. +

H1

+

H2

+
"max-level" option MUST be integer
+```````````````````````````````` + +```````````````````````````````` example +# H1 +## H2 +.. toc:: + :max-level: 9 +. +

H1

+

H2

+
"max-level" option MUST be <= 3
+```````````````````````````````` + +```````````````````````````````` example +# H1 +## H2 +.. toc:: + :min-level: 2 + :max-level: 1 +. +

H1

+

H2

+
"min-level" option MUST be less than "max-level" option
+```````````````````````````````` + + +## Complex + +```````````````````````````````` example +# H1 +## H2 +### H3 +#### H4 +# H1 B +# H1 `C` + +.. toc:: Contents + :max-level: 3 +. +

H1

+

H2

+

H3

+

H4

+

H1 B

+

H1 C

+
+Contents + +
+```````````````````````````````` + +## Insane + +```````````````````````````````` example +# H1 +### H3 +## H2 +#### H4 +### H3 B +# H1 B +.. toc:: +. +

H1

+

H3

+

H2

+

H4

+

H3 B

+

H1 B

+
+Table of Contents + +
+```````````````````````````````` + +```````````````````````````````` example +### H3 +## H2 +# H1 +.. toc:: +. +

H3

+

H2

+

H1

+
+Table of Contents + +
+```````````````````````````````` + +## Link in Heading + + +```````````````````````````````` example +# [foo](/bar) +.. toc:: +. +

foo

+
+Table of Contents + +
+```````````````````````````````` + +## HTML in Heading + +```````````````````````````````` example +# H1 +.. toc:: +. +

H1

+
+Table of Contents + +
+```````````````````````````````` + +## Collapse TOC + +```````````````````````````````` example +.. toc:: + :collapse: + +# H1 +## H2 +. +
+Table of Contents + +
+

H1

+

H2

+```````````````````````````````` diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/fixtures/ruby.txt b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/fixtures/ruby.txt new file mode 100644 index 0000000000000000000000000000000000000000..d89ebe28e1161ec3915768d72303feaa168f3c63 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/fixtures/ruby.txt @@ -0,0 +1,64 @@ +# Ruby + + +## ruby without link + +```````````````````````````````` example +[漢字(ㄏㄢˋㄗˋ)] +. +

漢字ㄏㄢˋㄗˋ

+```````````````````````````````` + +```````````````````````````````` example +[漢(ㄏㄢˋ)字(ㄗˋ)] +. +

漢ㄏㄢˋ字ㄗˋ

+```````````````````````````````` + +```````````````````````````````` example +[漢字(ㄏㄢˋㄗˋ)][] +. +

漢字ㄏㄢˋㄗˋ[]

+```````````````````````````````` + +```````````````````````````````` example +[漢字(ㄏㄢˋㄗˋ)][link] +. +

漢字ㄏㄢˋㄗˋ[link]

+```````````````````````````````` + +## ruby with link + +```````````````````````````````` example +[link]: /url + +[漢字(ㄏㄢˋㄗˋ)][link] +. +

漢字ㄏㄢˋㄗˋ

+```````````````````````````````` + +```````````````````````````````` example +[漢字(ㄏㄢˋㄗˋ)]() +. +

漢字ㄏㄢˋㄗˋ

+```````````````````````````````` + +```````````````````````````````` example +[漢字(ㄏㄢˋㄗˋ)](/url) +. +

漢字ㄏㄢˋㄗˋ

+```````````````````````````````` + +## ruby splits + +```````````````````````````````` example +[漢(かん)][字(じ)] +. +

漢かん字じ

+```````````````````````````````` + +```````````````````````````````` example +[[漢(かん)][字(じ)]](https://jisho.org/search/漢字) +. +

漢かん字じ

+```````````````````````````````` diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/fixtures/spoiler.txt b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/fixtures/spoiler.txt new file mode 100644 index 0000000000000000000000000000000000000000..b1394193004aa9a896ac9212dcab200818613506 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/fixtures/spoiler.txt @@ -0,0 +1,74 @@ +# Spoiler + +## Block spoiler + +```````````````````````````````` example +>! hi +. +
+

hi

+
+```````````````````````````````` + + +```````````````````````````````` example +>! not +> spoiler +. +
+

! not +spoiler

+
+```````````````````````````````` + +```````````````````````````````` example +>! multiple +>! lines +. +
+

multiple +lines

+
+```````````````````````````````` + +```````````````````````````````` example +>! foo +>! +>! bar +. +
+

foo

+

bar

+
+```````````````````````````````` + +```````````````````````````````` example +>! foo +> +>! bar +. +
+

! foo

+

! bar

+
+```````````````````````````````` + +## Inline spoiler + +```````````````````````````````` example +hi >! hide !< +. +

hi hide

+```````````````````````````````` + +```````````````````````````````` example +hi >!hide !< +. +

hi hide

+```````````````````````````````` + +```````````````````````````````` example +hi >!hide!< +. +

hi hide

+```````````````````````````````` diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/fixtures/strikethrough.txt b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/fixtures/strikethrough.txt new file mode 100644 index 0000000000000000000000000000000000000000..007a7777aefe1f68e20026c6d87675a12623f1b8 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/fixtures/strikethrough.txt @@ -0,0 +1,46 @@ +# Strikethrough + + +## strikethrough + +```````````````````````````````` example +~~delete me +. +

~~delete me

+```````````````````````````````` + +```````````````````````````````` example +~~delete me~~ +. +

delete me

+```````````````````````````````` + +```````````````````````````````` example +~~delete me~~~ +. +

~~delete me~~~

+```````````````````````````````` + +```````````````````````````````` example +~~delete me\~~~ +. +

delete me~

+```````````````````````````````` + +```````````````````````````````` example +~~delete \~\~ me~~ +. +

delete ~~ me

+```````````````````````````````` + +```````````````````````````````` example +~~delete [me~~](/) +. +

delete [me](/)

+```````````````````````````````` + +```````````````````````````````` example +~~[hello](/)~~ +. +

hello

+```````````````````````````````` diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/fixtures/subscript.txt b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/fixtures/subscript.txt new file mode 100644 index 0000000000000000000000000000000000000000..9e4ef8bad50771b18039cd681d91d51c203128aa --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/fixtures/subscript.txt @@ -0,0 +1,26 @@ +# Subscript + + +```````````````````````````````` example +CH~3~CH~2~OH +. +

CH3CH2OH

+```````````````````````````````` + +```````````````````````````````` example +text~a\ subscript~ +. +

texta subscript

+```````````````````````````````` + +```````````````````````````````` example +text~a subscript~ +. +

text~a subscript~

+```````````````````````````````` + +```````````````````````````````` example +text~a\~subscript~ +. +

texta~subscript

+```````````````````````````````` diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/fixtures/superscript.txt b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/fixtures/superscript.txt new file mode 100644 index 0000000000000000000000000000000000000000..8f114ca8c9566ddfd1d2800341f2065ded0ad560 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/fixtures/superscript.txt @@ -0,0 +1,26 @@ +# Superscript + + +```````````````````````````````` example +CH^3^CH^2^OH +. +

CH3CH2OH

+```````````````````````````````` + +```````````````````````````````` example +text^a\ supscript^ +. +

texta supscript

+```````````````````````````````` + +```````````````````````````````` example +text^a supscript^ +. +

text^a supscript^

+```````````````````````````````` + +```````````````````````````````` example +text^a\^supscript^ +. +

texta^supscript

+```````````````````````````````` diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/fixtures/table.txt b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/fixtures/table.txt new file mode 100644 index 0000000000000000000000000000000000000000..ff4e13ae743b2733f0174cca08c10da2a9b6f1f1 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/fixtures/table.txt @@ -0,0 +1,258 @@ +# Table in Markdown + +https://michelf.ca/projects/php-markdown/extra/#table + + +## nptable + + +```````````````````````````````` example +First Header | Second Header +------------- | ------------- +Content Cell | Content Cell +Content Cell | Content Cell +. + + + + + + + + + + + + + + + + + +
First HeaderSecond Header
Content CellContent Cell
Content CellContent Cell
+```````````````````````````````` + + +## table + +```````````````````````````````` example +| First Header | Second Header | +| ------------- | ------------- | +| Content Cell | | +| Content Cell | Content Cell | +. + + + + + + + + + + + + + + + + + +
First HeaderSecond Header
Content Cell
Content CellContent Cell
+```````````````````````````````` + + +```````````````````````````````` example +| Command | Description | +| --- | --- | +| git status | List all new or modified files | +| git diff | Show file differences that haven't been staged | +. + + + + + + + + + + + + + + + + + +
CommandDescription
git statusList all new or modified files
git diffShow file differences that haven't been staged
+```````````````````````````````` + +## align table + +```````````````````````````````` example + Left | Center | Right +:---- | :--------: | ------: + a | b | c +. + + + + + + + + + + + + + + + +
LeftCenterRight
abc
+```````````````````````````````` + +```````````````````````````````` example +| Left | Center | Right | +| :--- | :----: | ----: | +| a | b | c | +. + + + + + + + + + + + + + + + +
LeftCenterRight
abc
+```````````````````````````````` + +## Misc Table + +```````````````````````````````` example +| A | | +| - | | +| a | b | +. + + + + + + + + + + + + + +
A
ab
+```````````````````````````````` + +```````````````````````````````` example +A | +- | +a | b +. + + + + + + + + + + + + + +
A
ab
+```````````````````````````````` + + +```````````````````````````````` example +| Foo | Bar | +|-----|-----| +| boo | baz | +| faz | | +. + + + + + + + + + + + + + + + + + +
FooBar
boobaz
faz
+```````````````````````````````` + +## Mismatch length + +```````````````````````````````` example +| First Header | +| ------------- | ------------- | +| Content Cell | | +| Content Cell | Content Cell | +. +

| First Header | +| ------------- | ------------- | +| Content Cell | | +| Content Cell | Content Cell |

+```````````````````````````````` + +```````````````````````````````` example +| First Header | Second Header | +| ------------- | ------------- | +| Content Cell | +| Content Cell | Content Cell | +. +

| First Header | Second Header | +| ------------- | ------------- | +| Content Cell | +| Content Cell | Content Cell |

+```````````````````````````````` + +```````````````````````````````` example +A | +- | - | +a | b | c +. +

A |

+
    +
  • | - | +a | b | c
  • +
+```````````````````````````````` + +```````````````````````````````` example +A | B | C +- | - | - +a | b +. +

A | B | C

+
    +
  • | - | - +a | b
  • +
+```````````````````````````````` diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/fixtures/task_lists.txt b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/fixtures/task_lists.txt new file mode 100644 index 0000000000000000000000000000000000000000..c1760acbdd4dd55d815789bc11afad6f2f3a8c3d --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/fixtures/task_lists.txt @@ -0,0 +1,108 @@ +# Task Lists + +```````````````````````````````` example +- [ ] foo +- [x] bar +- [X] baz +. +
    +
  • foo
  • +
  • bar
  • +
  • baz
  • +
+```````````````````````````````` + +```````````````````````````````` example +- foo +- [ ] bar +. +
    +
  • foo
  • +
  • bar
  • +
+```````````````````````````````` + +```````````````````````````````` example +- foo + +- [ ] bar +- [x] baz + + text +. +
    +
  • foo

    +
  • +
  • bar

    +
  • +
  • baz

    +

    text

    +
  • +
+```````````````````````````````` + +```````````````````````````````` example +1. [ ] foo +2. [x] bar +3. [X] baz +. +
    +
  1. foo
  2. +
  3. bar
  4. +
  5. baz
  6. +
+```````````````````````````````` + +```````````````````````````````` example +- [ ] Task list item + over two lines +. +
    +
  • Task list item +over two lines
  • +
+```````````````````````````````` + +```````````````````````````````` example +- [ ] foo + - [x] bar + - [ ] baz +. +
    +
  • foo
      +
    • bar
    • +
    • baz
    • +
    +
  • +
+```````````````````````````````` + +```````````````````````````````` example +1. [ ] foo + 1. [ ] bar + 2. [ ] baz +. +
    +
  1. foo
      +
    1. bar
    2. +
    3. baz
    4. +
    +
  2. +
+```````````````````````````````` + +```````````````````````````````` example +> - [ ] foo +> - [x] bar +> - [ ] baz +. +
+
    +
  • foo
      +
    • bar
    • +
    • baz
    • +
    +
  • +
+
+```````````````````````````````` \ No newline at end of file diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/fixtures/url.txt b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/fixtures/url.txt new file mode 100644 index 0000000000000000000000000000000000000000..669bdd5f34d93942e407aa41569072a6ff6a2f91 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/fixtures/url.txt @@ -0,0 +1,22 @@ +# url plugin + + +```````````````````````````````` example +visit https://lepture.com/ +. +

visit https://lepture.com/

+```````````````````````````````` + + +```````````````````````````````` example +visit [https://lepture.com/](/foo) +. +

visit https://lepture.com/

+```````````````````````````````` + + +```````````````````````````````` example +visit https://lepture.com/ +. +

visit https://lepture.com/

+```````````````````````````````` diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/test_commonmark.py b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/test_commonmark.py new file mode 100644 index 0000000000000000000000000000000000000000..5ece254838b130d5765744897028436efb73b0e6 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/test_commonmark.py @@ -0,0 +1,76 @@ +import mistune +from tests import BaseTestCase, normalize_html + + +DIFF_CASES = { + 'setext_headings_093', + 'html_blocks_191', # mistune keeps \n + + 'images_573', # image can not be in image + + 'links_495', + 'links_517', # aggressive link group + 'links_518', + 'links_519', + 'links_531', + 'links_532', +} + +IGNORE_CASES = { + # we don't support link title in (title) + 'links_496', + 'links_504', + + # we don't support flanking delimiter run + 'emphasis_and_strong_emphasis_352', + 'emphasis_and_strong_emphasis_367', + 'emphasis_and_strong_emphasis_368', + 'emphasis_and_strong_emphasis_372', + 'emphasis_and_strong_emphasis_379', + 'emphasis_and_strong_emphasis_388', + 'emphasis_and_strong_emphasis_391', + + 'emphasis_and_strong_emphasis_406', + 'emphasis_and_strong_emphasis_407', + 'emphasis_and_strong_emphasis_408', + + 'emphasis_and_strong_emphasis_412', + 'emphasis_and_strong_emphasis_413', + 'emphasis_and_strong_emphasis_414', + 'emphasis_and_strong_emphasis_416', + 'emphasis_and_strong_emphasis_417', + 'emphasis_and_strong_emphasis_418', + + 'emphasis_and_strong_emphasis_424', + 'emphasis_and_strong_emphasis_425', + 'emphasis_and_strong_emphasis_426', + 'emphasis_and_strong_emphasis_429', + 'emphasis_and_strong_emphasis_430', + 'emphasis_and_strong_emphasis_431', + 'emphasis_and_strong_emphasis_460', + 'emphasis_and_strong_emphasis_467', + 'emphasis_and_strong_emphasis_470', + 'emphasis_and_strong_emphasis_471', + 'emphasis_and_strong_emphasis_477', + 'emphasis_and_strong_emphasis_478', +} + +for i in range(441, 447): + IGNORE_CASES.add('emphasis_and_strong_emphasis_' + str(i)) +for i in range(453, 459): + IGNORE_CASES.add('emphasis_and_strong_emphasis_' + str(i)) +for i in range(462, 466): + IGNORE_CASES.add('emphasis_and_strong_emphasis_' + str(i)) + + +class TestCommonMark(BaseTestCase): + @classmethod + def ignore_case(cls, n): + return n in IGNORE_CASES or n in DIFF_CASES + + def assert_case(self, n, text, html): + result = mistune.html(text) + self.assertEqual(normalize_html(result), normalize_html(html)) + + +TestCommonMark.load_fixtures('commonmark.json') diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/test_directives.py b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/test_directives.py new file mode 100644 index 0000000000000000000000000000000000000000..388963a4b196c3252368bc842d1bd250d66f3d98 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/test_directives.py @@ -0,0 +1,93 @@ +import os +from mistune import create_markdown +from mistune.directives import ( + RSTDirective, + FencedDirective, + Admonition, + TableOfContents, + Include, + Image, + Figure, +) +from tests import BaseTestCase +from tests.fixtures import ROOT + + +def load_directive_test(filename, directive, cls): + class TestDirective(BaseTestCase): + @staticmethod + def parse(text): + md = create_markdown( + escape=False, + plugins=[cls([directive])], + ) + html = md(text) + return html + + TestDirective.load_fixtures(filename + '.txt') + globals()["TestDirective_" + filename] = TestDirective + + +load_directive_test('rst_admonition', Admonition(), RSTDirective) +load_directive_test('rst_toc', TableOfContents(), RSTDirective) +load_directive_test('fenced_admonition', Admonition(), FencedDirective) +load_directive_test('fenced_toc', TableOfContents(), FencedDirective) +load_directive_test('fenced_image', Image(), FencedDirective) +load_directive_test('fenced_figure', Figure(), FencedDirective) + + +class CustomizeTableOfContents(TableOfContents): + def generate_heading_id(self, token, i): + return 't-' + str(i + 1) + + +class TestCustomizeToc(BaseTestCase): + def test_rst_toc(self): + md = create_markdown( + escape=False, + plugins=[ + RSTDirective([CustomizeTableOfContents()]), + ], + ) + html = md('# h1\n\n.. toc::\n') + self.assertIn('

h1

', html) + self.assertIn('h1', html) + + def test_fenced_toc(self): + md = create_markdown( + escape=False, + plugins=[ + FencedDirective([CustomizeTableOfContents()]), + ], + ) + html = md('# h1\n\n```{toc}\n```\n') + self.assertIn('

h1

', html) + self.assertIn('h1', html) + + def test_colon_fenced_toc(self): + md = create_markdown( + escape=False, + plugins=[ + FencedDirective([CustomizeTableOfContents()], ':'), + ], + ) + html = md('# h1\n\n:::{toc}\n:::\n') + self.assertIn('

h1

', html) + self.assertIn('h1', html) + + +class TestDirectiveInclude(BaseTestCase): + md = create_markdown(escape=False, plugins=[RSTDirective([Include()])]) # type: ignore[list-item] + + def test_html_include(self): + html = self.md.read(os.path.join(ROOT, 'include/text.md'))[0] + self.assertIn('Could not include self', html) + self.assertIn('Could not find file', html) + self.assertIn('
include html
', html) + self.assertIn('
', html) + self.assertIn('# Table of Contents', html) + + def test_include_missing_source(self): + s = '.. include:: foo.txt' + html = self.md(s) + self.assertIn('Missing source file', html) diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/test_hooks.py b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/test_hooks.py new file mode 100644 index 0000000000000000000000000000000000000000..8c0a02e9b600a6034ea367fd014ec7949fb0f5d3 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/test_hooks.py @@ -0,0 +1,26 @@ +import os +from mistune import create_markdown +from mistune.toc import add_toc_hook, render_toc_ul +from tests import BaseTestCase + + +class TestTocHook(BaseTestCase): + @staticmethod + def parse(text): + md = create_markdown(escape=False) + add_toc_hook(md) + html, state = md.parse(text) + result = html + render_toc_ul(state.env['toc_items']) + return result + + def test_customize_heading_id_func(self): + def heading_id(token, i): + return 't-' + str(i + 1) + + md = create_markdown(escape=False) + add_toc_hook(md, heading_id=heading_id) + html = md('# h1') + self.assertEqual(html, '

h1

\n') + + +TestTocHook.load_fixtures('hook_toc.txt') diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/test_misc.py b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/test_misc.py new file mode 100644 index 0000000000000000000000000000000000000000..99bc68d6eca362d235a2dff0ad449ceb8dd5eebc --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/test_misc.py @@ -0,0 +1,137 @@ +import mistune +from unittest import TestCase + + +class TestMiscCases(TestCase): + def test_none(self): + self.assertEqual(mistune.html(None), '') + + def test_before_parse_hooks(self): + def _add_name(md, state): + state.env['name'] = 'test' + + md = mistune.create_markdown() + md.before_parse_hooks.append(_add_name) + state = md.block.state_cls() + md.parse('', state) + self.assertEqual(state.env['name'], 'test') + + def test_hard_wrap(self): + md = mistune.create_markdown(escape=False, hard_wrap=True) + result = md('foo\nbar') + expected = '

foo
\nbar

' + self.assertEqual(result.strip(), expected) + + md = mistune.create_markdown( + escape=False, hard_wrap=True, plugins=['speedup']) + result = md('foo\nbar') + self.assertEqual(result.strip(), expected) + + def test_escape_html(self): + md = mistune.create_markdown(escape=True) + result = md('
1
') + expected = '

<div>1</div>

' + self.assertEqual(result.strip(), expected) + + result = md('1') + expected = '

<em>1</em>

' + self.assertEqual(result.strip(), expected) + + def test_harmful_links(self): + result = mistune.html('[h](javAscript:alert)') + expected = '

h

' + self.assertEqual(result.strip(), expected) + + def test_ref_link(self): + result = mistune.html('[link][h]\n\n[h]: /foo') + expected = '

link

' + self.assertEqual(result.strip(), expected) + + def test_allow_harmful_protocols(self): + renderer = mistune.HTMLRenderer(allow_harmful_protocols=True) + md = mistune.Markdown(renderer) + result = md('[h](javascript:alert)') + expected = '

h

' + self.assertEqual(result.strip(), expected) + + def test_allow_data_protocols(self): + renderer = mistune.HTMLRenderer(allow_harmful_protocols=['data:']) + md = mistune.Markdown(renderer) + result = md('[h](data:alert)') + expected = '

h

' + self.assertEqual(result.strip(), expected) + + def test_use_plugin(self): + from mistune.plugins.url import url + md = mistune.Markdown(mistune.HTMLRenderer()) + md.use(url) + + def test_markdown_func(self): + result = mistune.markdown('**b**') + expected = '

b

\n' + self.assertEqual(result, expected) + + # trigger to use cached parser + result = mistune.markdown('**b**') + self.assertEqual(result, expected) + + def test_ast_output(self): + md = mistune.create_markdown(escape=False, renderer=None) + text = '# h1\n\nfoo **bar**\n\n`&<>"`' + result = md(text) + expected = [ + { + 'type': 'heading', + 'children': [{'type': 'text', 'raw': 'h1'}], + 'attrs': {'level': 1}, + 'style': 'atx', + }, + {'type': 'blank_line'}, + { + 'type': 'paragraph', + 'children': [ + {'type': 'text', 'raw': 'foo '}, + {'type': 'strong', 'children': [{'type': 'text', 'raw': 'bar'}]} + ] + }, + {'type': 'blank_line'}, + { + 'type': 'paragraph', + 'children': [ + {'type': 'codespan', 'raw': '&<>"'}, + ] + }, + ] + self.assertEqual(result, expected) + + def test_ast_url(self): + md = mistune.create_markdown(escape=False, renderer=None) + label = 'hi &<>"' + url = 'https://example.com/foo?a=1&b=2' + text = '[{}]({})'.format(label, url) + result = md(text) + expected = [ + { + 'type': 'paragraph', + 'children': [ + { + 'type': 'link', + 'children': [{'type': 'text', 'raw': label}], + 'attrs': {'url': url}, + }, + ], + }, + ] + self.assertEqual(result, expected) + + def test_emsp(self): + md = mistune.create_markdown(escape=False, hard_wrap=True) + result = md('\u2003\u2003foo\nbar\n\n\u2003\u2003foobar') + expected = '

\u2003\u2003foo
\nbar

\n

\u2003\u2003foobar

' + self.assertEqual(result.strip(), expected) + + def test_html_tag_text_following_list(self): + md = mistune.create_markdown(escape=False, hard_wrap=True) + result = md('foo\n- bar\n\ntable') + expected = '

foo

\n
    \n
  • bar
  • \n
\n

table

' + self.assertEqual(result.strip(), expected) diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/test_plugins.py b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/test_plugins.py new file mode 100644 index 0000000000000000000000000000000000000000..408c5fac6733b3307ee4db14e0996137e1843ebf --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/test_plugins.py @@ -0,0 +1,66 @@ +from mistune import create_markdown +from mistune.plugins.table import table_in_list, table_in_quote +from mistune.plugins.math import math_in_list, math_in_quote +from tests import BaseTestCase + + +def load_plugin(plugin_name): + md1 = create_markdown(escape=False, plugins=[plugin_name]) + md2 = create_markdown(escape=False, plugins=[plugin_name, 'speedup']) + + class TestPlugin1(BaseTestCase): + parse = md1 + + class TestPlugin2(BaseTestCase): + parse = md2 + + TestPlugin1.load_fixtures(plugin_name + ".txt") + TestPlugin2.load_fixtures(plugin_name + ".txt") + globals()["TestPlugin1_" + plugin_name] = TestPlugin1 + globals()["TestPlugin2_" + plugin_name] = TestPlugin2 + + +load_plugin("url") +load_plugin("strikethrough") +load_plugin("mark") +load_plugin("insert") +load_plugin("superscript") +load_plugin("subscript") +load_plugin("task_lists") +load_plugin("table") +load_plugin("def_list") +load_plugin("footnotes") +load_plugin("abbr") +load_plugin("math") +load_plugin("ruby") +load_plugin("spoiler") + + +class TestExtraPlugins(BaseTestCase): + def test_table_in_list(self): + text = '''- Cell | Cell\n ---- | ----\n 1 | 2\n''' + md1 = create_markdown(escape=False) + md2 = create_markdown(escape=False, plugins=['table', table_in_list]) + self.assertNotIn('', md1(text)) + self.assertIn('
', md2(text)) + + def test_table_in_quote(self): + text = '''> Cell | Cell\n> ---- | ----\n> 1 | 2\n''' + md1 = create_markdown(escape=False) + md2 = create_markdown(escape=False, plugins=['table', table_in_quote]) + self.assertNotIn('
', md1(text)) + self.assertIn('
', md2(text)) + + def test_math_in_list(self): + text = '''- $$\n foo\n $$\n''' + md1 = create_markdown(escape=False) + md2 = create_markdown(escape=False, plugins=['math', math_in_list]) + self.assertNotIn('class="math"', md1(text)) + self.assertIn('class="math"', md2(text)) + + def test_math_in_quote(self): + text = '''> $$\n> foo\n> $$\n''' + md1 = create_markdown(escape=False) + md2 = create_markdown(escape=False, plugins=['math', math_in_quote]) + self.assertNotIn('class="math"', md1(text)) + self.assertIn('class="math"', md2(text)) diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/test_renderers.py b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/test_renderers.py new file mode 100644 index 0000000000000000000000000000000000000000..dca515873cd24cf642fab5ff6dbb34d884c9a7ae --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/test_renderers.py @@ -0,0 +1,17 @@ +from mistune import create_markdown +from mistune.renderers.rst import RSTRenderer +from mistune.renderers.markdown import MarkdownRenderer +from tests import BaseTestCase + + +def load_renderer(renderer): + class TestRenderer(BaseTestCase): + parse = create_markdown(renderer=renderer) + + name = renderer.NAME + TestRenderer.load_fixtures('renderer_' + name + '.txt') + globals()["TestRenderer" + name.title()] = TestRenderer + + +load_renderer(RSTRenderer()) +load_renderer(MarkdownRenderer()) diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/test_syntax.py b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/test_syntax.py new file mode 100644 index 0000000000000000000000000000000000000000..06341d595c3cc5ef64f36c729f97901f312317d7 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/tests/trusted/tests/test_syntax.py @@ -0,0 +1,12 @@ +import mistune +from tests import BaseTestCase, normalize_html + + +class TestSyntax(BaseTestCase): + def assert_case(self, n, text, html): + result = mistune.html(text) + self.assertEqual(normalize_html(result), normalize_html(html)) + + +TestSyntax.load_fixtures('fix-commonmark.txt') +TestSyntax.load_fixtures('diff-commonmark.txt') diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/validation/canaries/first-hunk-only.sh b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/validation/canaries/first-hunk-only.sh new file mode 100644 index 0000000000000000000000000000000000000000..78097de704f80a4297a97f4b5cedf21bd4247506 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/validation/canaries/first-hunk-only.sh @@ -0,0 +1,24 @@ +#!/bin/bash +set -Eeuo pipefail +cd /testbed/repo +cat > /tmp/openenv-reference.diff <<'OPENENV_PARTIAL' +diff --git a/src/mistune/renderers/markdown.py b/src/mistune/renderers/markdown.py +index 8641a37a792d460b3471bfb613a0ea491f289585..b49081a77562b601235716b6051537686acf5b77 100644 +--- a/src/mistune/renderers/markdown.py ++++ b/src/mistune/renderers/markdown.py +@@ -14,10 +14,10 @@ + NAME = 'markdown' + + def __call__(self, tokens: Iterable[Dict[str, Any]], state: BlockState) -> str: +- out = self.render_tokens(state, tokens) ++ out = self.render_tokens(tokens, state) + # special handle for line breaks +- out += '\n'.join(self.render_referrences(state)) +- return out.strip() ++ out += '\n\n'.join(self.render_referrences(state)) + '\n' ++ return strip_end(out) + + def render_referrences(self, state: BlockState) -> Iterable[str]: + ref_links = state.env['ref_links'] +OPENENV_PARTIAL +/usr/bin/git -c core.hooksPath=/dev/null -c core.fsmonitor=false apply --whitespace=nowarn /tmp/openenv-reference.diff diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/validation/canaries/original-bug.sh b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/validation/canaries/original-bug.sh new file mode 100644 index 0000000000000000000000000000000000000000..927547df786c86ab3bb5eeb917a31e0fa1895f8b --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/validation/canaries/original-bug.sh @@ -0,0 +1,3 @@ +#!/bin/bash +set -Eeuo pipefail +: diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/validation/openenv.json b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/validation/openenv.json new file mode 100644 index 0000000000000000000000000000000000000000..a13b3c577df494f6c894584d2b608ab051ebc44f --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09mnfd6d/validation/openenv.json @@ -0,0 +1,27 @@ +{ + "canaries": "validation/canaries", + "profile": "harbor-semantic-v1", + "requires_credentials": false, + "resources": { + "cpu": 2, + "disk_mb": 16384, + "episode_timeout_s": 1800, + "memory_mb": 8192 + }, + "reward": { + "floor_margin": 0.1, + "oracle_tolerance": 0, + "range": [ + 0, + 1 + ] + }, + "reward_key": "reward", + "types": { + "tags": [ + "swe", + "python", + "mutation-repair" + ] + } +} diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/LICENSE.source b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/LICENSE.source new file mode 100644 index 0000000000000000000000000000000000000000..b141cdb9f3cb8010b9c3dfb392ff1a00db58a413 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/LICENSE.source @@ -0,0 +1,14 @@ +Copyright (c) 2014, Hsiaoming Yang + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + +* Neither the name of the creator nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/adapter.json b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/adapter.json new file mode 100644 index 0000000000000000000000000000000000000000..6c1854c5acd5467bc0a046c469fbffc70d9209e5 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/adapter.json @@ -0,0 +1,131 @@ +{ + "canary_selection": "Fixed first provided gold hunk only when at least2hunks exist; strict subset, never reward-selected. Single-hunk task original-bug canary is explicitly NOP-equivalent and adds no signal beyond floor_gap.", + "collector_sha256": "352e555112f2de8a1393f939903e4971c9ace0e944843762b707a725c5c72481", + "dependency_installation_pinned": false, + "dependency_setup_sha256": "883d23539d00e744dc83da083548b6dd699be04238df34d5bd5b500a5dc53f28", + "gold_patch_sha256": "f35968a2f373054dfe3b8508cf6b9ea4c8b491340c0b5323261a61b821f7575b", + "hostile_code_isolation_established": false, + "known_wrong_semantic_implementations": 0, + "native_inventory_sha256": "17de35ae0ac47a5aeaefe2d45b024edc58fe81a3811926bf76bace9f7b18e8fb", + "new_files_deletions_and_executable_modes_supported": true, + "official_profile": { + "eval_sets": [], + "profile_class": "MistuneBf54ef67", + "profile_lines": [ + 570, + 573 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "bf54ef67390e02a5cdee7495d4386d7770c1902b", + "upstream_repo": "lepture/mistune" + }, + "original_bug_canary_nop_equivalent": true, + "original_bug_runtime_wrongness_established": false, + "partial_repair_canary": true, + "partial_repair_sha256": "d5b2dd05b861044971bd03e5887f427b37cd12dad0a48db32cd43bd52b44a6f6", + "partial_repair_wrongness_established": false, + "positive_approval_policy": "All original strict presence/identity/no-skip/no-error/exit checks retained", + "private_checker_sha256": "f0a641064b725415e23a0221bb53c90446d7efcb7f9ece5ede93a220d18dd9e7", + "private_checker_version": "matched-failure-precedence-v2", + "provided_original_bug_control": true, + "repo_url": "https://github.com/swesmith/lepture__mistune.bf54ef67.git", + "runtime_image": null, + "runtime_ready": false, + "runtime_recipe": { + "dependency_installation_pinned": false, + "official_install_cmds": [ + "python -m pip install -e ." + ], + "official_pytest_argv": [ + "pytest", + "--disable-warnings", + "--color=no", + "--tb=no", + "--verbose" + ], + "official_test_command": "source /opt/miniconda3/bin/activate; conda activate testbed; pytest --disable-warnings --color=no --tb=no --verbose", + "operator_test_runner_prerequisites": [ + "python -m pip install pytest==8.4.2" + ], + "operator_test_runner_reason": "The official profile invokes pytest, but the common tools runtime does not provide it; pinned separately from source-native project requirements.", + "panel_normalization": "Override project addopts only to execute the exact frozen native panels; add JUnit output, preserve official pytest options and all selectors.", + "python_version": "3.10", + "source_bound_test_dependency_cmds": [], + "test_dependency_source_sha256": { + "pyproject.toml": "b2922e3ef89e2918935d38fb3a777bdbc741619942276a75fd21a8dd9faf6b42" + } + }, + "runtime_resource_review_required": false, + "schema": "python-git-patch-jobs-v1", + "source_base_commit": "d61be76e0804de22f3b3e6662dc15268183e5684", + "source_completion_sha256": "2480e0bda844194ea270c618d3e993156fa6fd476793410e6203b2e3406ea75d", + "source_index_sha256": "e856874b9410fce9f3bfea52c8c482e84b3e43942d87517f8b55f0034bd40f6f", + "source_pr_url": null, + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:lepture__mistune.bf54ef67.combine_file__09sp6cd7", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "62750c95db25a8fb93dda09242f64e07508d9231", + "instruction_sha256": "fec5d4dc1c26e05562d60165b3efd3f8c3feda25d4691e4f3e6fc19152db3408", + "is_fork": true, + "learner_path": "tasks/a5177fad85cc5c3425cb067e/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "bf54ef67390e02a5cdee7495d4386d7770c1902b", + "actual_upstream_url": "https://raw.githubusercontent.com/lepture/mistune/bf54ef67390e02a5cdee7495d4386d7770c1902b/LICENSE", + "reviewed": true, + "sha256": "539013fd8e19f744f8bf0e27a532bbff54cd689ecef7a800f56ae5dc824be870", + "spdx": "BSD-3-Clause", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/lepture__mistune.bf54ef67/d61be76e0804de22f3b3e6662dc15268183e5684/LICENSE" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "bf54ef67390e02a5cdee7495d4386d7770c1902b", + "patch_sha256": "fd90c744db49f0b6e732ced50f6f89901816de129805a230ffa7d157e75051fa", + "provenance_path": "tasks/a5177fad85cc5c3425cb067e/source-proof.json", + "repository_lineage": [ + "swesmith/lepture__mistune.bf54ef67", + "lepture/mistune" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "d61be76e0804de22f3b3e6662dc15268183e5684", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "0d1f317e60a2a36eeee69296c01aeaad02bc4ee9", + "source_kind": "mutation", + "source_repo": "swesmith/lepture__mistune.bf54ef67", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "lepture__mistune.bf54ef67.combine_file__09sp6cd7", + "task_sha256": "13a8eaaff6c6a24671b445d734782202fb4ec1f388956972d2886b26678cfe7c", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "lepture/mistune", + "usage": "quarantine_only" + }, + "source_repo": "swesmith/lepture__mistune.bf54ef67", + "symlink_submodule_changes_supported": false, + "task_id": "lepture__mistune.bf54ef67.combine_file__09sp6cd7", + "transfer": "index-independent-worktree-to-Git-binary-patch", + "transfer_path": "/testbed/submission.patch", + "upstream_repo": "lepture/mistune" +} diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/dependency-setup.sh b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/dependency-setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..551d5bb0d87bd3b22dd7098dddea7e0794a2ab40 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/dependency-setup.sh @@ -0,0 +1,8 @@ +#!/bin/bash +set -Eeuo pipefail +source /opt/miniconda3/bin/activate +conda activate testbed +cd /testbed/repo +python -c 'import sys; assert sys.version_info[:2] == (3, 10)' +python -m pip install pytest==8.4.2 +python -m pip install -e . diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/environment/Dockerfile b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..a59b58c2ea8217c78c1e39b4678f93c8c0023bcd --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/environment/Dockerfile @@ -0,0 +1,3 @@ +# Runtime is selected only by an independently qualified immutable amd64 receipt. +FROM ubuntu:22.04 +RUN false diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/instruction.md b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..5271d617132ff34ffcfd2859148fd69177e813e9 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/instruction.md @@ -0,0 +1,29 @@ +# Footnotes plugin breaks when using case-sensitive keys + +## Description + +When using the footnotes plugin, there's an issue with case-sensitive footnote keys. The plugin is incorrectly handling the case of footnote keys, causing footnotes to not be properly rendered. + +For example, if you have a markdown document with footnotes like: + +```markdown +Here is some text with a footnote[^note1]. + +[^note1]: This is the footnote text. +``` + +It works fine, but if you try to use a key with different case: + +```markdown +Here is some text with a footnote[^Note1]. + +[^Note1]: This is the footnote text. +``` + +The footnote doesn't render correctly. The plugin seems to be converting keys to lowercase, which breaks the expected behavior. + +Additionally, there seems to be an issue with the HTML structure of footnotes, as they're being rendered with `
    ` tags instead of the expected `
      ` tags, which affects the numbering of footnotes. + +## Environment + +The repository is at `/testbed/repo`. Its dependencies, including pytest, are installed in the `testbed` conda environment, which comes first on PATH. If `python -m pytest` reports that pytest is missing, use the full interpreter path: `/opt/miniconda3/envs/testbed/bin/python -m pytest `. Don't install packages: the tests need nothing else, and the sandbox may have no network access. diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/metadata.json b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/metadata.json new file mode 100644 index 0000000000000000000000000000000000000000..f43156b9041b467c7177db6d6e61b1b37a6434ad --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/metadata.json @@ -0,0 +1,1190 @@ +{ + "all_runtime_and_training_flags": false, + "official_profile": { + "eval_sets": [], + "profile_class": "MistuneBf54ef67", + "profile_lines": [ + 570, + 573 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "bf54ef67390e02a5cdee7495d4386d7770c1902b", + "upstream_repo": "lepture/mistune" + }, + "source_healthy_reference_proof": { + "FAIL_TO_PASS": [ + "tests/test_plugins.py::TestPlugin1_footnotes::test_footnotes_002", + "tests/test_plugins.py::TestPlugin1_footnotes::test_footnotes_003", + "tests/test_plugins.py::TestPlugin2_footnotes::test_footnotes_002", + "tests/test_plugins.py::TestPlugin2_footnotes::test_footnotes_003" + ], + "PASS_TO_PASS": [ + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_062", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_063", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_064", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_065", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_066", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_067", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_068", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_069", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_070", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_071", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_072", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_073", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_074", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_075", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_076", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_077", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_078", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_079", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_593", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_594", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_595", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_596", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_597", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_598", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_599", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_600", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_601", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_602", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_603", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_604", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_605", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_606", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_607", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_608", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_609", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_610", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_611", + "tests/test_commonmark.py::TestCommonMark::test_backslash_escapes_012", + "tests/test_commonmark.py::TestCommonMark::test_backslash_escapes_013", + "tests/test_commonmark.py::TestCommonMark::test_backslash_escapes_014", + "tests/test_commonmark.py::TestCommonMark::test_backslash_escapes_015", + "tests/test_commonmark.py::TestCommonMark::test_backslash_escapes_016", + "tests/test_commonmark.py::TestCommonMark::test_backslash_escapes_017", + "tests/test_commonmark.py::TestCommonMark::test_backslash_escapes_018", + "tests/test_commonmark.py::TestCommonMark::test_backslash_escapes_019", + "tests/test_commonmark.py::TestCommonMark::test_backslash_escapes_020", + "tests/test_commonmark.py::TestCommonMark::test_backslash_escapes_021", + "tests/test_commonmark.py::TestCommonMark::test_backslash_escapes_022", + "tests/test_commonmark.py::TestCommonMark::test_backslash_escapes_023", + "tests/test_commonmark.py::TestCommonMark::test_backslash_escapes_024", + "tests/test_commonmark.py::TestCommonMark::test_blank_lines_227", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_228", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_229", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_230", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_231", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_232", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_233", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_234", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_235", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_236", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_237", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_238", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_239", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_240", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_241", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_242", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_243", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_244", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_245", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_246", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_247", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_248", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_249", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_250", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_251", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_252", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_328", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_329", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_330", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_331", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_332", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_333", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_334", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_335", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_336", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_337", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_338", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_339", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_340", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_341", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_342", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_343", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_344", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_345", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_346", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_347", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_348", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_349", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_350", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_351", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_353", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_354", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_355", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_356", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_357", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_358", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_359", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_360", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_361", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_362", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_363", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_364", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_365", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_366", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_369", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_370", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_371", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_373", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_374", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_375", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_376", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_377", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_378", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_380", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_381", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_382", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_383", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_384", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_385", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_386", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_387", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_389", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_390", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_392", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_393", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_394", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_395", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_396", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_397", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_398", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_399", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_400", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_401", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_402", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_403", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_404", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_405", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_409", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_410", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_411", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_415", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_419", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_420", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_421", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_422", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_423", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_427", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_428", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_432", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_433", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_434", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_435", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_436", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_437", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_438", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_439", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_440", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_447", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_448", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_449", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_450", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_451", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_452", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_459", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_461", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_466", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_468", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_469", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_472", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_473", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_474", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_475", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_476", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_479", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_480", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_025", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_026", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_027", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_028", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_029", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_030", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_031", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_032", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_033", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_034", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_035", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_036", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_037", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_038", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_039", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_040", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_041", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_119", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_120", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_121", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_122", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_123", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_124", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_125", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_126", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_127", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_128", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_129", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_130", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_131", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_132", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_133", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_134", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_135", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_136", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_137", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_138", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_139", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_140", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_141", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_142", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_143", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_144", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_145", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_146", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_147", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_633", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_634", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_635", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_636", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_637", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_638", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_639", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_640", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_641", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_642", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_643", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_644", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_645", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_646", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_647", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_148", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_149", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_150", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_151", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_152", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_153", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_154", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_155", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_156", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_157", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_158", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_159", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_160", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_161", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_162", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_163", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_164", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_165", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_166", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_167", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_168", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_169", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_170", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_171", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_172", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_173", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_174", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_175", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_176", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_177", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_178", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_179", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_180", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_181", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_182", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_183", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_184", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_185", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_186", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_187", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_188", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_189", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_190", + "tests/test_commonmark.py::TestCommonMark::test_images_571", + "tests/test_commonmark.py::TestCommonMark::test_images_572", + "tests/test_commonmark.py::TestCommonMark::test_images_574", + "tests/test_commonmark.py::TestCommonMark::test_images_575", + "tests/test_commonmark.py::TestCommonMark::test_images_576", + "tests/test_commonmark.py::TestCommonMark::test_images_577", + "tests/test_commonmark.py::TestCommonMark::test_images_578", + "tests/test_commonmark.py::TestCommonMark::test_images_579", + "tests/test_commonmark.py::TestCommonMark::test_images_580", + "tests/test_commonmark.py::TestCommonMark::test_images_581", + "tests/test_commonmark.py::TestCommonMark::test_images_582", + "tests/test_commonmark.py::TestCommonMark::test_images_583", + "tests/test_commonmark.py::TestCommonMark::test_images_584", + "tests/test_commonmark.py::TestCommonMark::test_images_585", + "tests/test_commonmark.py::TestCommonMark::test_images_586", + "tests/test_commonmark.py::TestCommonMark::test_images_587", + "tests/test_commonmark.py::TestCommonMark::test_images_588", + "tests/test_commonmark.py::TestCommonMark::test_images_589", + "tests/test_commonmark.py::TestCommonMark::test_images_590", + "tests/test_commonmark.py::TestCommonMark::test_images_591", + "tests/test_commonmark.py::TestCommonMark::test_images_592", + "tests/test_commonmark.py::TestCommonMark::test_indented_code_blocks_107", + "tests/test_commonmark.py::TestCommonMark::test_indented_code_blocks_108", + "tests/test_commonmark.py::TestCommonMark::test_indented_code_blocks_109", + "tests/test_commonmark.py::TestCommonMark::test_indented_code_blocks_110", + "tests/test_commonmark.py::TestCommonMark::test_indented_code_blocks_111", + "tests/test_commonmark.py::TestCommonMark::test_indented_code_blocks_112", + "tests/test_commonmark.py::TestCommonMark::test_indented_code_blocks_113", + "tests/test_commonmark.py::TestCommonMark::test_indented_code_blocks_114", + "tests/test_commonmark.py::TestCommonMark::test_indented_code_blocks_115", + "tests/test_commonmark.py::TestCommonMark::test_indented_code_blocks_116", + "tests/test_commonmark.py::TestCommonMark::test_indented_code_blocks_117", + "tests/test_commonmark.py::TestCommonMark::test_indented_code_blocks_118", + "tests/test_commonmark.py::TestCommonMark::test_inlines_327", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_192", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_193", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_194", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_195", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_196", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_197", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_198", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_199", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_200", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_201", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_202", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_203", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_204", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_205", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_206", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_207", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_208", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_209", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_210", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_211", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_212", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_213", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_214", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_215", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_216", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_217", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_218", + "tests/test_commonmark.py::TestCommonMark::test_links_481", + "tests/test_commonmark.py::TestCommonMark::test_links_482", + "tests/test_commonmark.py::TestCommonMark::test_links_483", + "tests/test_commonmark.py::TestCommonMark::test_links_484", + "tests/test_commonmark.py::TestCommonMark::test_links_485", + "tests/test_commonmark.py::TestCommonMark::test_links_486", + "tests/test_commonmark.py::TestCommonMark::test_links_487", + "tests/test_commonmark.py::TestCommonMark::test_links_488", + "tests/test_commonmark.py::TestCommonMark::test_links_489", + "tests/test_commonmark.py::TestCommonMark::test_links_490", + "tests/test_commonmark.py::TestCommonMark::test_links_491", + "tests/test_commonmark.py::TestCommonMark::test_links_492", + "tests/test_commonmark.py::TestCommonMark::test_links_493", + "tests/test_commonmark.py::TestCommonMark::test_links_494", + "tests/test_commonmark.py::TestCommonMark::test_links_497", + "tests/test_commonmark.py::TestCommonMark::test_links_498", + "tests/test_commonmark.py::TestCommonMark::test_links_499", + "tests/test_commonmark.py::TestCommonMark::test_links_500", + "tests/test_commonmark.py::TestCommonMark::test_links_501", + "tests/test_commonmark.py::TestCommonMark::test_links_502", + "tests/test_commonmark.py::TestCommonMark::test_links_503", + "tests/test_commonmark.py::TestCommonMark::test_links_505", + "tests/test_commonmark.py::TestCommonMark::test_links_506", + "tests/test_commonmark.py::TestCommonMark::test_links_507", + "tests/test_commonmark.py::TestCommonMark::test_links_508", + "tests/test_commonmark.py::TestCommonMark::test_links_509", + "tests/test_commonmark.py::TestCommonMark::test_links_510", + "tests/test_commonmark.py::TestCommonMark::test_links_511", + "tests/test_commonmark.py::TestCommonMark::test_links_512", + "tests/test_commonmark.py::TestCommonMark::test_links_513", + "tests/test_commonmark.py::TestCommonMark::test_links_514", + "tests/test_commonmark.py::TestCommonMark::test_links_515", + "tests/test_commonmark.py::TestCommonMark::test_links_516", + "tests/test_commonmark.py::TestCommonMark::test_links_520", + "tests/test_commonmark.py::TestCommonMark::test_links_521", + "tests/test_commonmark.py::TestCommonMark::test_links_522", + "tests/test_commonmark.py::TestCommonMark::test_links_523", + "tests/test_commonmark.py::TestCommonMark::test_links_524", + "tests/test_commonmark.py::TestCommonMark::test_links_525", + "tests/test_commonmark.py::TestCommonMark::test_links_526", + "tests/test_commonmark.py::TestCommonMark::test_links_527", + "tests/test_commonmark.py::TestCommonMark::test_links_528", + "tests/test_commonmark.py::TestCommonMark::test_links_529", + "tests/test_commonmark.py::TestCommonMark::test_links_530", + "tests/test_commonmark.py::TestCommonMark::test_links_533", + "tests/test_commonmark.py::TestCommonMark::test_links_534", + "tests/test_commonmark.py::TestCommonMark::test_links_535", + "tests/test_commonmark.py::TestCommonMark::test_links_536", + "tests/test_commonmark.py::TestCommonMark::test_links_537", + "tests/test_commonmark.py::TestCommonMark::test_links_538", + "tests/test_commonmark.py::TestCommonMark::test_links_539", + "tests/test_commonmark.py::TestCommonMark::test_links_540", + "tests/test_commonmark.py::TestCommonMark::test_links_541", + "tests/test_commonmark.py::TestCommonMark::test_links_542", + "tests/test_commonmark.py::TestCommonMark::test_links_543", + "tests/test_commonmark.py::TestCommonMark::test_links_544", + "tests/test_commonmark.py::TestCommonMark::test_links_545", + "tests/test_commonmark.py::TestCommonMark::test_links_546", + "tests/test_commonmark.py::TestCommonMark::test_links_547", + "tests/test_commonmark.py::TestCommonMark::test_links_548", + "tests/test_commonmark.py::TestCommonMark::test_links_549", + "tests/test_commonmark.py::TestCommonMark::test_links_550", + "tests/test_commonmark.py::TestCommonMark::test_links_551", + "tests/test_commonmark.py::TestCommonMark::test_links_552", + "tests/test_commonmark.py::TestCommonMark::test_links_553", + "tests/test_commonmark.py::TestCommonMark::test_links_554", + "tests/test_commonmark.py::TestCommonMark::test_links_555", + "tests/test_commonmark.py::TestCommonMark::test_links_556", + "tests/test_commonmark.py::TestCommonMark::test_links_557", + "tests/test_commonmark.py::TestCommonMark::test_links_558", + "tests/test_commonmark.py::TestCommonMark::test_links_559", + "tests/test_commonmark.py::TestCommonMark::test_links_560", + "tests/test_commonmark.py::TestCommonMark::test_links_561", + "tests/test_commonmark.py::TestCommonMark::test_links_562", + "tests/test_commonmark.py::TestCommonMark::test_links_563", + "tests/test_commonmark.py::TestCommonMark::test_links_564", + "tests/test_commonmark.py::TestCommonMark::test_links_565", + "tests/test_commonmark.py::TestCommonMark::test_links_566", + "tests/test_commonmark.py::TestCommonMark::test_links_567", + "tests/test_commonmark.py::TestCommonMark::test_links_568", + "tests/test_commonmark.py::TestCommonMark::test_links_569", + "tests/test_commonmark.py::TestCommonMark::test_links_570", + "tests/test_commonmark.py::TestCommonMark::test_list_items_253", + "tests/test_commonmark.py::TestCommonMark::test_list_items_254", + "tests/test_commonmark.py::TestCommonMark::test_list_items_255", + "tests/test_commonmark.py::TestCommonMark::test_list_items_256", + "tests/test_commonmark.py::TestCommonMark::test_list_items_257", + "tests/test_commonmark.py::TestCommonMark::test_list_items_258", + "tests/test_commonmark.py::TestCommonMark::test_list_items_259", + "tests/test_commonmark.py::TestCommonMark::test_list_items_260", + "tests/test_commonmark.py::TestCommonMark::test_list_items_261", + "tests/test_commonmark.py::TestCommonMark::test_list_items_262", + "tests/test_commonmark.py::TestCommonMark::test_list_items_263", + "tests/test_commonmark.py::TestCommonMark::test_list_items_264", + "tests/test_commonmark.py::TestCommonMark::test_list_items_265", + "tests/test_commonmark.py::TestCommonMark::test_list_items_266", + "tests/test_commonmark.py::TestCommonMark::test_list_items_267", + "tests/test_commonmark.py::TestCommonMark::test_list_items_268", + "tests/test_commonmark.py::TestCommonMark::test_list_items_269", + "tests/test_commonmark.py::TestCommonMark::test_list_items_270", + "tests/test_commonmark.py::TestCommonMark::test_list_items_271", + "tests/test_commonmark.py::TestCommonMark::test_list_items_272", + "tests/test_commonmark.py::TestCommonMark::test_list_items_273", + "tests/test_commonmark.py::TestCommonMark::test_list_items_274", + "tests/test_commonmark.py::TestCommonMark::test_list_items_275", + "tests/test_commonmark.py::TestCommonMark::test_list_items_276", + "tests/test_commonmark.py::TestCommonMark::test_list_items_277", + "tests/test_commonmark.py::TestCommonMark::test_list_items_278", + "tests/test_commonmark.py::TestCommonMark::test_list_items_279", + "tests/test_commonmark.py::TestCommonMark::test_list_items_280", + "tests/test_commonmark.py::TestCommonMark::test_list_items_281", + "tests/test_commonmark.py::TestCommonMark::test_list_items_282", + "tests/test_commonmark.py::TestCommonMark::test_list_items_283", + "tests/test_commonmark.py::TestCommonMark::test_list_items_284", + "tests/test_commonmark.py::TestCommonMark::test_list_items_285", + "tests/test_commonmark.py::TestCommonMark::test_list_items_286", + "tests/test_commonmark.py::TestCommonMark::test_list_items_287", + "tests/test_commonmark.py::TestCommonMark::test_list_items_288", + "tests/test_commonmark.py::TestCommonMark::test_list_items_289", + "tests/test_commonmark.py::TestCommonMark::test_list_items_290", + "tests/test_commonmark.py::TestCommonMark::test_list_items_291", + "tests/test_commonmark.py::TestCommonMark::test_list_items_292", + "tests/test_commonmark.py::TestCommonMark::test_list_items_293", + "tests/test_commonmark.py::TestCommonMark::test_list_items_294", + "tests/test_commonmark.py::TestCommonMark::test_list_items_295", + "tests/test_commonmark.py::TestCommonMark::test_list_items_296", + "tests/test_commonmark.py::TestCommonMark::test_list_items_297", + "tests/test_commonmark.py::TestCommonMark::test_list_items_298", + "tests/test_commonmark.py::TestCommonMark::test_list_items_299", + "tests/test_commonmark.py::TestCommonMark::test_list_items_300", + "tests/test_commonmark.py::TestCommonMark::test_lists_301", + "tests/test_commonmark.py::TestCommonMark::test_lists_302", + "tests/test_commonmark.py::TestCommonMark::test_lists_303", + "tests/test_commonmark.py::TestCommonMark::test_lists_304", + "tests/test_commonmark.py::TestCommonMark::test_lists_305", + "tests/test_commonmark.py::TestCommonMark::test_lists_306", + "tests/test_commonmark.py::TestCommonMark::test_lists_307", + "tests/test_commonmark.py::TestCommonMark::test_lists_308", + "tests/test_commonmark.py::TestCommonMark::test_lists_309", + "tests/test_commonmark.py::TestCommonMark::test_lists_310", + "tests/test_commonmark.py::TestCommonMark::test_lists_311", + "tests/test_commonmark.py::TestCommonMark::test_lists_312", + "tests/test_commonmark.py::TestCommonMark::test_lists_313", + "tests/test_commonmark.py::TestCommonMark::test_lists_314", + "tests/test_commonmark.py::TestCommonMark::test_lists_315", + "tests/test_commonmark.py::TestCommonMark::test_lists_316", + "tests/test_commonmark.py::TestCommonMark::test_lists_317", + "tests/test_commonmark.py::TestCommonMark::test_lists_318", + "tests/test_commonmark.py::TestCommonMark::test_lists_319", + "tests/test_commonmark.py::TestCommonMark::test_lists_320", + "tests/test_commonmark.py::TestCommonMark::test_lists_321", + "tests/test_commonmark.py::TestCommonMark::test_lists_322", + "tests/test_commonmark.py::TestCommonMark::test_lists_323", + "tests/test_commonmark.py::TestCommonMark::test_lists_324", + "tests/test_commonmark.py::TestCommonMark::test_lists_325", + "tests/test_commonmark.py::TestCommonMark::test_lists_326", + "tests/test_commonmark.py::TestCommonMark::test_paragraphs_219", + "tests/test_commonmark.py::TestCommonMark::test_paragraphs_220", + "tests/test_commonmark.py::TestCommonMark::test_paragraphs_221", + "tests/test_commonmark.py::TestCommonMark::test_paragraphs_222", + "tests/test_commonmark.py::TestCommonMark::test_paragraphs_223", + "tests/test_commonmark.py::TestCommonMark::test_paragraphs_224", + "tests/test_commonmark.py::TestCommonMark::test_paragraphs_225", + "tests/test_commonmark.py::TestCommonMark::test_paragraphs_226", + "tests/test_commonmark.py::TestCommonMark::test_precedence_042", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_612", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_613", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_614", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_615", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_616", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_617", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_618", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_619", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_620", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_621", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_622", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_623", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_624", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_625", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_626", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_627", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_628", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_629", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_630", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_631", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_632", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_080", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_081", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_082", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_083", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_084", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_085", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_086", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_087", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_088", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_089", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_090", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_091", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_092", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_094", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_095", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_096", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_097", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_098", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_099", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_100", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_101", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_102", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_103", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_104", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_105", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_106", + "tests/test_commonmark.py::TestCommonMark::test_soft_line_breaks_648", + "tests/test_commonmark.py::TestCommonMark::test_soft_line_breaks_649", + "tests/test_commonmark.py::TestCommonMark::test_tabs_001", + "tests/test_commonmark.py::TestCommonMark::test_tabs_002", + "tests/test_commonmark.py::TestCommonMark::test_tabs_003", + "tests/test_commonmark.py::TestCommonMark::test_tabs_004", + "tests/test_commonmark.py::TestCommonMark::test_tabs_005", + "tests/test_commonmark.py::TestCommonMark::test_tabs_006", + "tests/test_commonmark.py::TestCommonMark::test_tabs_007", + "tests/test_commonmark.py::TestCommonMark::test_tabs_008", + "tests/test_commonmark.py::TestCommonMark::test_tabs_009", + "tests/test_commonmark.py::TestCommonMark::test_tabs_010", + "tests/test_commonmark.py::TestCommonMark::test_tabs_011", + "tests/test_commonmark.py::TestCommonMark::test_textual_content_650", + "tests/test_commonmark.py::TestCommonMark::test_textual_content_651", + "tests/test_commonmark.py::TestCommonMark::test_textual_content_652", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_043", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_044", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_045", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_046", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_047", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_048", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_049", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_050", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_051", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_052", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_053", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_054", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_055", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_056", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_057", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_058", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_059", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_060", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_061", + "tests/test_directives.py::TestDirective_rst_admonition::test_admonition_001", + "tests/test_directives.py::TestDirective_rst_admonition::test_admonition_002", + "tests/test_directives.py::TestDirective_rst_admonition::test_admonition_003", + "tests/test_directives.py::TestDirective_rst_admonition::test_admonition_004", + "tests/test_directives.py::TestDirective_rst_toc::test_collapse_toc_001", + "tests/test_directives.py::TestDirective_rst_toc::test_complex_001", + "tests/test_directives.py::TestDirective_rst_toc::test_html_in_heading_001", + "tests/test_directives.py::TestDirective_rst_toc::test_insane_001", + "tests/test_directives.py::TestDirective_rst_toc::test_insane_002", + "tests/test_directives.py::TestDirective_rst_toc::test_invalid_option_001", + "tests/test_directives.py::TestDirective_rst_toc::test_invalid_option_002", + "tests/test_directives.py::TestDirective_rst_toc::test_invalid_option_003", + "tests/test_directives.py::TestDirective_rst_toc::test_link_in_heading_001", + "tests/test_directives.py::TestDirective_rst_toc::test_no_toc_001", + "tests/test_directives.py::TestDirective_rst_toc::test_no_toc_002", + "tests/test_directives.py::TestDirective_rst_toc::test_simple_toc_001", + "tests/test_directives.py::TestDirective_fenced_admonition::test_admonition_001", + "tests/test_directives.py::TestDirective_fenced_admonition::test_admonition_002", + "tests/test_directives.py::TestDirective_fenced_admonition::test_admonition_003", + "tests/test_directives.py::TestDirective_fenced_admonition::test_admonition_004", + "tests/test_directives.py::TestDirective_fenced_admonition::test_admonition_005", + "tests/test_directives.py::TestDirective_fenced_admonition::test_admonition_006", + "tests/test_directives.py::TestDirective_fenced_admonition::test_admonition_007", + "tests/test_directives.py::TestDirective_fenced_admonition::test_admonition_008", + "tests/test_directives.py::TestDirective_fenced_toc::test_collapse_toc_001", + "tests/test_directives.py::TestDirective_fenced_toc::test_complex_001", + "tests/test_directives.py::TestDirective_fenced_toc::test_html_in_heading_001", + "tests/test_directives.py::TestDirective_fenced_toc::test_insane_001", + "tests/test_directives.py::TestDirective_fenced_toc::test_insane_002", + "tests/test_directives.py::TestDirective_fenced_toc::test_invalid_option_001", + "tests/test_directives.py::TestDirective_fenced_toc::test_invalid_option_002", + "tests/test_directives.py::TestDirective_fenced_toc::test_invalid_option_003", + "tests/test_directives.py::TestDirective_fenced_toc::test_link_in_heading_001", + "tests/test_directives.py::TestDirective_fenced_toc::test_no_toc_001", + "tests/test_directives.py::TestDirective_fenced_toc::test_no_toc_002", + "tests/test_directives.py::TestDirective_fenced_toc::test_simple_toc_001", + "tests/test_directives.py::TestDirective_fenced_image::test_align_options_001", + "tests/test_directives.py::TestDirective_fenced_image::test_align_options_002", + "tests/test_directives.py::TestDirective_fenced_image::test_all_options_001", + "tests/test_directives.py::TestDirective_fenced_image::test_alt_option_001", + "tests/test_directives.py::TestDirective_fenced_image::test_ampersand_in_source_001", + "tests/test_directives.py::TestDirective_fenced_image::test_ampersand_in_target_001", + "tests/test_directives.py::TestDirective_fenced_image::test_no_options_001", + "tests/test_directives.py::TestDirective_fenced_image::test_target_option_001", + "tests/test_directives.py::TestDirective_fenced_image::test_width_and_height_001", + "tests/test_directives.py::TestDirective_fenced_image::test_width_and_height_002", + "tests/test_directives.py::TestDirective_fenced_figure::test_align_options_001", + "tests/test_directives.py::TestDirective_fenced_figure::test_align_options_002", + "tests/test_directives.py::TestDirective_fenced_figure::test_all_options_001", + "tests/test_directives.py::TestDirective_fenced_figure::test_alt_option_001", + "tests/test_directives.py::TestDirective_fenced_figure::test_caption_001", + "tests/test_directives.py::TestDirective_fenced_figure::test_legend_001", + "tests/test_directives.py::TestDirective_fenced_figure::test_legend_002", + "tests/test_directives.py::TestDirective_fenced_figure::test_no_options_001", + "tests/test_directives.py::TestDirective_fenced_figure::test_target_option_001", + "tests/test_directives.py::TestDirective_fenced_figure::test_width_and_height_001", + "tests/test_directives.py::TestDirective_fenced_figure::test_width_and_height_002", + "tests/test_directives.py::TestDirective_fenced_figure::test_width_and_height_003", + "tests/test_directives.py::TestCustomizeToc::test_colon_fenced_toc", + "tests/test_directives.py::TestCustomizeToc::test_fenced_toc", + "tests/test_directives.py::TestCustomizeToc::test_rst_toc", + "tests/test_directives.py::TestDirectiveInclude::test_html_include", + "tests/test_directives.py::TestDirectiveInclude::test_include_missing_source", + "tests/test_hooks.py::TestTocHook::test_complex_toc_001", + "tests/test_hooks.py::TestTocHook::test_customize_heading_id_func", + "tests/test_hooks.py::TestTocHook::test_html_in_heading_001", + "tests/test_hooks.py::TestTocHook::test_insane_toc_001", + "tests/test_hooks.py::TestTocHook::test_insane_toc_002", + "tests/test_hooks.py::TestTocHook::test_link_in_heading_001", + "tests/test_hooks.py::TestTocHook::test_simple_toc_001", + "tests/test_misc.py::TestMiscCases::test_allow_data_protocols", + "tests/test_misc.py::TestMiscCases::test_allow_harmful_protocols", + "tests/test_misc.py::TestMiscCases::test_ast_output", + "tests/test_misc.py::TestMiscCases::test_ast_url", + "tests/test_misc.py::TestMiscCases::test_before_parse_hooks", + "tests/test_misc.py::TestMiscCases::test_emsp", + "tests/test_misc.py::TestMiscCases::test_escape_html", + "tests/test_misc.py::TestMiscCases::test_hard_wrap", + "tests/test_misc.py::TestMiscCases::test_harmful_links", + "tests/test_misc.py::TestMiscCases::test_html_tag_text_following_list", + "tests/test_misc.py::TestMiscCases::test_markdown_func", + "tests/test_misc.py::TestMiscCases::test_none", + "tests/test_misc.py::TestMiscCases::test_ref_link", + "tests/test_misc.py::TestMiscCases::test_use_plugin", + "tests/test_plugins.py::TestPlugin1_url::test_url_plugin_001", + "tests/test_plugins.py::TestPlugin1_url::test_url_plugin_002", + "tests/test_plugins.py::TestPlugin1_url::test_url_plugin_003", + "tests/test_plugins.py::TestPlugin2_url::test_url_plugin_001", + "tests/test_plugins.py::TestPlugin2_url::test_url_plugin_002", + "tests/test_plugins.py::TestPlugin2_url::test_url_plugin_003", + "tests/test_plugins.py::TestPlugin1_strikethrough::test_strikethrough_001", + "tests/test_plugins.py::TestPlugin1_strikethrough::test_strikethrough_002", + "tests/test_plugins.py::TestPlugin1_strikethrough::test_strikethrough_003", + "tests/test_plugins.py::TestPlugin1_strikethrough::test_strikethrough_004", + "tests/test_plugins.py::TestPlugin1_strikethrough::test_strikethrough_005", + "tests/test_plugins.py::TestPlugin1_strikethrough::test_strikethrough_006", + "tests/test_plugins.py::TestPlugin1_strikethrough::test_strikethrough_007", + "tests/test_plugins.py::TestPlugin2_strikethrough::test_strikethrough_001", + "tests/test_plugins.py::TestPlugin2_strikethrough::test_strikethrough_002", + "tests/test_plugins.py::TestPlugin2_strikethrough::test_strikethrough_003", + "tests/test_plugins.py::TestPlugin2_strikethrough::test_strikethrough_004", + "tests/test_plugins.py::TestPlugin2_strikethrough::test_strikethrough_005", + "tests/test_plugins.py::TestPlugin2_strikethrough::test_strikethrough_006", + "tests/test_plugins.py::TestPlugin2_strikethrough::test_strikethrough_007", + "tests/test_plugins.py::TestPlugin1_mark::test_escape_mark_001", + "tests/test_plugins.py::TestPlugin1_mark::test_escape_mark_002", + "tests/test_plugins.py::TestPlugin1_mark::test_mark_001", + "tests/test_plugins.py::TestPlugin1_mark::test_mark_link_001", + "tests/test_plugins.py::TestPlugin1_mark::test_mark_link_002", + "tests/test_plugins.py::TestPlugin1_mark::test_normal_mark_001", + "tests/test_plugins.py::TestPlugin1_mark::test_normal_mark_002", + "tests/test_plugins.py::TestPlugin1_mark::test_normal_mark_003", + "tests/test_plugins.py::TestPlugin1_mark::test_normal_mark_004", + "tests/test_plugins.py::TestPlugin2_mark::test_escape_mark_001", + "tests/test_plugins.py::TestPlugin2_mark::test_escape_mark_002", + "tests/test_plugins.py::TestPlugin2_mark::test_mark_001", + "tests/test_plugins.py::TestPlugin2_mark::test_mark_link_001", + "tests/test_plugins.py::TestPlugin2_mark::test_mark_link_002", + "tests/test_plugins.py::TestPlugin2_mark::test_normal_mark_001", + "tests/test_plugins.py::TestPlugin2_mark::test_normal_mark_002", + "tests/test_plugins.py::TestPlugin2_mark::test_normal_mark_003", + "tests/test_plugins.py::TestPlugin2_mark::test_normal_mark_004", + "tests/test_plugins.py::TestPlugin1_insert::test_escape_insert_001", + "tests/test_plugins.py::TestPlugin1_insert::test_escape_insert_002", + "tests/test_plugins.py::TestPlugin1_insert::test_insert_001", + "tests/test_plugins.py::TestPlugin1_insert::test_insert_link_001", + "tests/test_plugins.py::TestPlugin1_insert::test_insert_link_002", + "tests/test_plugins.py::TestPlugin1_insert::test_normal_insert_001", + "tests/test_plugins.py::TestPlugin1_insert::test_normal_insert_002", + "tests/test_plugins.py::TestPlugin1_insert::test_normal_insert_003", + "tests/test_plugins.py::TestPlugin1_insert::test_normal_insert_004", + "tests/test_plugins.py::TestPlugin2_insert::test_escape_insert_001", + "tests/test_plugins.py::TestPlugin2_insert::test_escape_insert_002", + "tests/test_plugins.py::TestPlugin2_insert::test_insert_001", + "tests/test_plugins.py::TestPlugin2_insert::test_insert_link_001", + "tests/test_plugins.py::TestPlugin2_insert::test_insert_link_002", + "tests/test_plugins.py::TestPlugin2_insert::test_normal_insert_001", + "tests/test_plugins.py::TestPlugin2_insert::test_normal_insert_002", + "tests/test_plugins.py::TestPlugin2_insert::test_normal_insert_003", + "tests/test_plugins.py::TestPlugin2_insert::test_normal_insert_004", + "tests/test_plugins.py::TestPlugin1_superscript::test_superscript_001", + "tests/test_plugins.py::TestPlugin1_superscript::test_superscript_002", + "tests/test_plugins.py::TestPlugin1_superscript::test_superscript_003", + "tests/test_plugins.py::TestPlugin1_superscript::test_superscript_004", + "tests/test_plugins.py::TestPlugin2_superscript::test_superscript_001", + "tests/test_plugins.py::TestPlugin2_superscript::test_superscript_002", + "tests/test_plugins.py::TestPlugin2_superscript::test_superscript_003", + "tests/test_plugins.py::TestPlugin2_superscript::test_superscript_004", + "tests/test_plugins.py::TestPlugin1_subscript::test_subscript_001", + "tests/test_plugins.py::TestPlugin1_subscript::test_subscript_002", + "tests/test_plugins.py::TestPlugin1_subscript::test_subscript_003", + "tests/test_plugins.py::TestPlugin1_subscript::test_subscript_004", + "tests/test_plugins.py::TestPlugin2_subscript::test_subscript_001", + "tests/test_plugins.py::TestPlugin2_subscript::test_subscript_002", + "tests/test_plugins.py::TestPlugin2_subscript::test_subscript_003", + "tests/test_plugins.py::TestPlugin2_subscript::test_subscript_004", + "tests/test_plugins.py::TestPlugin1_task_lists::test_task_lists_001", + "tests/test_plugins.py::TestPlugin1_task_lists::test_task_lists_002", + "tests/test_plugins.py::TestPlugin1_task_lists::test_task_lists_003", + "tests/test_plugins.py::TestPlugin1_task_lists::test_task_lists_004", + "tests/test_plugins.py::TestPlugin1_task_lists::test_task_lists_005", + "tests/test_plugins.py::TestPlugin1_task_lists::test_task_lists_006", + "tests/test_plugins.py::TestPlugin1_task_lists::test_task_lists_007", + "tests/test_plugins.py::TestPlugin1_task_lists::test_task_lists_008", + "tests/test_plugins.py::TestPlugin2_task_lists::test_task_lists_001", + "tests/test_plugins.py::TestPlugin2_task_lists::test_task_lists_002", + "tests/test_plugins.py::TestPlugin2_task_lists::test_task_lists_003", + "tests/test_plugins.py::TestPlugin2_task_lists::test_task_lists_004", + "tests/test_plugins.py::TestPlugin2_task_lists::test_task_lists_005", + "tests/test_plugins.py::TestPlugin2_task_lists::test_task_lists_006", + "tests/test_plugins.py::TestPlugin2_task_lists::test_task_lists_007", + "tests/test_plugins.py::TestPlugin2_task_lists::test_task_lists_008", + "tests/test_plugins.py::TestPlugin1_table::test_align_table_001", + "tests/test_plugins.py::TestPlugin1_table::test_align_table_002", + "tests/test_plugins.py::TestPlugin1_table::test_misc_table_001", + "tests/test_plugins.py::TestPlugin1_table::test_misc_table_002", + "tests/test_plugins.py::TestPlugin1_table::test_misc_table_003", + "tests/test_plugins.py::TestPlugin1_table::test_mismatch_length_001", + "tests/test_plugins.py::TestPlugin1_table::test_mismatch_length_002", + "tests/test_plugins.py::TestPlugin1_table::test_mismatch_length_003", + "tests/test_plugins.py::TestPlugin1_table::test_mismatch_length_004", + "tests/test_plugins.py::TestPlugin1_table::test_nptable_001", + "tests/test_plugins.py::TestPlugin1_table::test_table_001", + "tests/test_plugins.py::TestPlugin1_table::test_table_002", + "tests/test_plugins.py::TestPlugin2_table::test_align_table_001", + "tests/test_plugins.py::TestPlugin2_table::test_align_table_002", + "tests/test_plugins.py::TestPlugin2_table::test_misc_table_001", + "tests/test_plugins.py::TestPlugin2_table::test_misc_table_002", + "tests/test_plugins.py::TestPlugin2_table::test_misc_table_003", + "tests/test_plugins.py::TestPlugin2_table::test_mismatch_length_001", + "tests/test_plugins.py::TestPlugin2_table::test_mismatch_length_002", + "tests/test_plugins.py::TestPlugin2_table::test_mismatch_length_003", + "tests/test_plugins.py::TestPlugin2_table::test_mismatch_length_004", + "tests/test_plugins.py::TestPlugin2_table::test_nptable_001", + "tests/test_plugins.py::TestPlugin2_table::test_table_001", + "tests/test_plugins.py::TestPlugin2_table::test_table_002", + "tests/test_plugins.py::TestPlugin1_def_list::test_definition_lists_001", + "tests/test_plugins.py::TestPlugin1_def_list::test_definition_lists_002", + "tests/test_plugins.py::TestPlugin1_def_list::test_definition_lists_003", + "tests/test_plugins.py::TestPlugin1_def_list::test_definition_lists_004", + "tests/test_plugins.py::TestPlugin1_def_list::test_definition_lists_005", + "tests/test_plugins.py::TestPlugin1_def_list::test_definition_lists_006", + "tests/test_plugins.py::TestPlugin1_def_list::test_definition_with_multiple_lines_001", + "tests/test_plugins.py::TestPlugin1_def_list::test_definition_with_multiple_lines_002", + "tests/test_plugins.py::TestPlugin1_def_list::test_definition_with_multiple_lines_003", + "tests/test_plugins.py::TestPlugin1_def_list::test_definition_with_multiple_lines_004", + "tests/test_plugins.py::TestPlugin1_def_list::test_definition_with_multiple_lines_005", + "tests/test_plugins.py::TestPlugin2_def_list::test_definition_lists_001", + "tests/test_plugins.py::TestPlugin2_def_list::test_definition_lists_002", + "tests/test_plugins.py::TestPlugin2_def_list::test_definition_lists_003", + "tests/test_plugins.py::TestPlugin2_def_list::test_definition_lists_004", + "tests/test_plugins.py::TestPlugin2_def_list::test_definition_lists_005", + "tests/test_plugins.py::TestPlugin2_def_list::test_definition_lists_006", + "tests/test_plugins.py::TestPlugin2_def_list::test_definition_with_multiple_lines_001", + "tests/test_plugins.py::TestPlugin2_def_list::test_definition_with_multiple_lines_002", + "tests/test_plugins.py::TestPlugin2_def_list::test_definition_with_multiple_lines_003", + "tests/test_plugins.py::TestPlugin2_def_list::test_definition_with_multiple_lines_004", + "tests/test_plugins.py::TestPlugin2_def_list::test_definition_with_multiple_lines_005", + "tests/test_plugins.py::TestPlugin1_footnotes::test_footnotes_001", + "tests/test_plugins.py::TestPlugin2_footnotes::test_footnotes_001", + "tests/test_plugins.py::TestPlugin1_abbr::test_abbreviation_001", + "tests/test_plugins.py::TestPlugin1_abbr::test_abbreviation_002", + "tests/test_plugins.py::TestPlugin1_abbr::test_abbreviation_003", + "tests/test_plugins.py::TestPlugin1_abbr::test_abbreviation_004", + "tests/test_plugins.py::TestPlugin1_abbr::test_abbreviation_005", + "tests/test_plugins.py::TestPlugin1_abbr::test_abbreviation_006", + "tests/test_plugins.py::TestPlugin1_abbr::test_abbreviation_007", + "tests/test_plugins.py::TestPlugin1_abbr::test_abbreviation_008", + "tests/test_plugins.py::TestPlugin1_abbr::test_abbreviation_009", + "tests/test_plugins.py::TestPlugin1_abbr::test_abbreviation_010", + "tests/test_plugins.py::TestPlugin2_abbr::test_abbreviation_001", + "tests/test_plugins.py::TestPlugin2_abbr::test_abbreviation_002", + "tests/test_plugins.py::TestPlugin2_abbr::test_abbreviation_003", + "tests/test_plugins.py::TestPlugin2_abbr::test_abbreviation_004", + "tests/test_plugins.py::TestPlugin2_abbr::test_abbreviation_005", + "tests/test_plugins.py::TestPlugin2_abbr::test_abbreviation_006", + "tests/test_plugins.py::TestPlugin2_abbr::test_abbreviation_007", + "tests/test_plugins.py::TestPlugin2_abbr::test_abbreviation_008", + "tests/test_plugins.py::TestPlugin2_abbr::test_abbreviation_009", + "tests/test_plugins.py::TestPlugin2_abbr::test_abbreviation_010", + "tests/test_plugins.py::TestPlugin1_math::test_block_math_001", + "tests/test_plugins.py::TestPlugin1_math::test_block_math_002", + "tests/test_plugins.py::TestPlugin1_math::test_block_math_003", + "tests/test_plugins.py::TestPlugin1_math::test_block_math_004", + "tests/test_plugins.py::TestPlugin1_math::test_inline_math_001", + "tests/test_plugins.py::TestPlugin2_math::test_block_math_001", + "tests/test_plugins.py::TestPlugin2_math::test_block_math_002", + "tests/test_plugins.py::TestPlugin2_math::test_block_math_003", + "tests/test_plugins.py::TestPlugin2_math::test_block_math_004", + "tests/test_plugins.py::TestPlugin2_math::test_inline_math_001", + "tests/test_plugins.py::TestPlugin1_ruby::test_ruby_splits_001", + "tests/test_plugins.py::TestPlugin1_ruby::test_ruby_splits_002", + "tests/test_plugins.py::TestPlugin1_ruby::test_ruby_with_link_001", + "tests/test_plugins.py::TestPlugin1_ruby::test_ruby_with_link_002", + "tests/test_plugins.py::TestPlugin1_ruby::test_ruby_with_link_003", + "tests/test_plugins.py::TestPlugin1_ruby::test_ruby_without_link_001", + "tests/test_plugins.py::TestPlugin1_ruby::test_ruby_without_link_002", + "tests/test_plugins.py::TestPlugin1_ruby::test_ruby_without_link_003", + "tests/test_plugins.py::TestPlugin1_ruby::test_ruby_without_link_004", + "tests/test_plugins.py::TestPlugin2_ruby::test_ruby_splits_001", + "tests/test_plugins.py::TestPlugin2_ruby::test_ruby_splits_002", + "tests/test_plugins.py::TestPlugin2_ruby::test_ruby_with_link_001", + "tests/test_plugins.py::TestPlugin2_ruby::test_ruby_with_link_002", + "tests/test_plugins.py::TestPlugin2_ruby::test_ruby_with_link_003", + "tests/test_plugins.py::TestPlugin2_ruby::test_ruby_without_link_001", + "tests/test_plugins.py::TestPlugin2_ruby::test_ruby_without_link_002", + "tests/test_plugins.py::TestPlugin2_ruby::test_ruby_without_link_003", + "tests/test_plugins.py::TestPlugin2_ruby::test_ruby_without_link_004", + "tests/test_plugins.py::TestPlugin1_spoiler::test_block_spoiler_001", + "tests/test_plugins.py::TestPlugin1_spoiler::test_block_spoiler_002", + "tests/test_plugins.py::TestPlugin1_spoiler::test_block_spoiler_003", + "tests/test_plugins.py::TestPlugin1_spoiler::test_block_spoiler_004", + "tests/test_plugins.py::TestPlugin1_spoiler::test_block_spoiler_005", + "tests/test_plugins.py::TestPlugin1_spoiler::test_inline_spoiler_001", + "tests/test_plugins.py::TestPlugin1_spoiler::test_inline_spoiler_002", + "tests/test_plugins.py::TestPlugin1_spoiler::test_inline_spoiler_003", + "tests/test_plugins.py::TestPlugin2_spoiler::test_block_spoiler_001", + "tests/test_plugins.py::TestPlugin2_spoiler::test_block_spoiler_002", + "tests/test_plugins.py::TestPlugin2_spoiler::test_block_spoiler_003", + "tests/test_plugins.py::TestPlugin2_spoiler::test_block_spoiler_004", + "tests/test_plugins.py::TestPlugin2_spoiler::test_block_spoiler_005", + "tests/test_plugins.py::TestPlugin2_spoiler::test_inline_spoiler_001", + "tests/test_plugins.py::TestPlugin2_spoiler::test_inline_spoiler_002", + "tests/test_plugins.py::TestPlugin2_spoiler::test_inline_spoiler_003", + "tests/test_plugins.py::TestExtraPlugins::test_math_in_list", + "tests/test_plugins.py::TestExtraPlugins::test_math_in_quote", + "tests/test_plugins.py::TestExtraPlugins::test_table_in_list", + "tests/test_plugins.py::TestExtraPlugins::test_table_in_quote", + "tests/test_renderers.py::TestRendererRst::test_code_001", + "tests/test_renderers.py::TestRendererRst::test_code_002", + "tests/test_renderers.py::TestRendererRst::test_heading_001", + "tests/test_renderers.py::TestRendererRst::test_html_001", + "tests/test_renderers.py::TestRendererRst::test_images_001", + "tests/test_renderers.py::TestRendererRst::test_images_002", + "tests/test_renderers.py::TestRendererRst::test_images_003", + "tests/test_renderers.py::TestRendererRst::test_inline_001", + "tests/test_renderers.py::TestRendererRst::test_inline_002", + "tests/test_renderers.py::TestRendererRst::test_line_break_001", + "tests/test_renderers.py::TestRendererRst::test_links_001", + "tests/test_renderers.py::TestRendererRst::test_list_001", + "tests/test_renderers.py::TestRendererRst::test_list_002", + "tests/test_renderers.py::TestRendererRst::test_list_003", + "tests/test_renderers.py::TestRendererRst::test_list_004", + "tests/test_renderers.py::TestRendererRst::test_list_005", + "tests/test_renderers.py::TestRendererRst::test_quote_001", + "tests/test_renderers.py::TestRendererRst::test_quote_002", + "tests/test_renderers.py::TestRendererRst::test_quote_003", + "tests/test_renderers.py::TestRendererRst::test_thematic_break_001", + "tests/test_renderers.py::TestRendererMarkdown::test_code_001", + "tests/test_renderers.py::TestRendererMarkdown::test_code_002", + "tests/test_renderers.py::TestRendererMarkdown::test_code_003", + "tests/test_renderers.py::TestRendererMarkdown::test_code_004", + "tests/test_renderers.py::TestRendererMarkdown::test_code_005", + "tests/test_renderers.py::TestRendererMarkdown::test_heading_001", + "tests/test_renderers.py::TestRendererMarkdown::test_html_001", + "tests/test_renderers.py::TestRendererMarkdown::test_images_001", + "tests/test_renderers.py::TestRendererMarkdown::test_inline_001", + "tests/test_renderers.py::TestRendererMarkdown::test_linebreak_001", + "tests/test_renderers.py::TestRendererMarkdown::test_links_001", + "tests/test_renderers.py::TestRendererMarkdown::test_links_002", + "tests/test_renderers.py::TestRendererMarkdown::test_links_003", + "tests/test_renderers.py::TestRendererMarkdown::test_list_001", + "tests/test_renderers.py::TestRendererMarkdown::test_list_002", + "tests/test_renderers.py::TestRendererMarkdown::test_list_003", + "tests/test_renderers.py::TestRendererMarkdown::test_list_004", + "tests/test_renderers.py::TestRendererMarkdown::test_list_005", + "tests/test_renderers.py::TestRendererMarkdown::test_list_006", + "tests/test_renderers.py::TestRendererMarkdown::test_quote_001", + "tests/test_renderers.py::TestRendererMarkdown::test_quote_002", + "tests/test_renderers.py::TestRendererMarkdown::test_thematic_break_001", + "tests/test_syntax.py::TestSyntax::test_emphasis_001", + "tests/test_syntax.py::TestSyntax::test_image_001", + "tests/test_syntax.py::TestSyntax::test_link_001", + "tests/test_syntax.py::TestSyntax::test_link_002", + "tests/test_syntax.py::TestSyntax::test_link_003", + "tests/test_syntax.py::TestSyntax::test_links_001", + "tests/test_syntax.py::TestSyntax::test_links_002", + "tests/test_syntax.py::TestSyntax::test_max_depth_001", + "tests/test_syntax.py::TestSyntax::test_max_depth_002", + "tests/test_syntax.py::TestSyntax::test_non_aggressive_emphasis_001", + "tests/test_syntax.py::TestSyntax::test_non_aggressive_emphasis_002", + "tests/test_syntax.py::TestSyntax::test_non_aggressive_emphasis_003", + "tests/test_syntax.py::TestSyntax::test_setext_headings_001", + "tests/test_syntax.py::TestSyntax::test_setext_headings_002" + ], + "all_git_blobs_modes_verified": true, + "cloud_launch_ready": false, + "commits": { + "bug": "0d1f317e60a2a36eeee69296c01aeaad02bc4ee9", + "healthy": "62750c95db25a8fb93dda09242f64e07508d9231", + "learner": "d61be76e0804de22f3b3e6662dc15268183e5684" + }, + "existing_squirrel_snapshot_reused": false, + "full_transfer_allowlist": [ + "/testbed/.editorconfig", + "/testbed/.github/FUNDING.yml", + "/testbed/.gitignore", + "/testbed/.readthedocs.yaml", + "/testbed/BACKERS.md", + "/testbed/LICENSE", + "/testbed/MANIFEST.in", + "/testbed/Makefile", + "/testbed/README.md", + "/testbed/README.rst", + "/testbed/benchmark/bench.py", + "/testbed/benchmark/cases/atx.txt", + "/testbed/benchmark/cases/auto_links.txt", + "/testbed/benchmark/cases/blockcode.txt", + "/testbed/benchmark/cases/blockhtml.txt", + "/testbed/benchmark/cases/blockquote.txt", + "/testbed/benchmark/cases/emphasis.txt", + "/testbed/benchmark/cases/fenced.txt", + "/testbed/benchmark/cases/insane_ol.txt", + "/testbed/benchmark/cases/insane_ul.txt", + "/testbed/benchmark/cases/normal_ol.txt", + "/testbed/benchmark/cases/normal_ul.txt", + "/testbed/benchmark/cases/paragraph.txt", + "/testbed/benchmark/cases/ref_links.txt", + "/testbed/benchmark/cases/setext.txt", + "/testbed/benchmark/cases/std_links.txt", + "/testbed/docs/Makefile", + "/testbed/docs/_static/dark-icon.svg", + "/testbed/docs/_static/light-icon.svg", + "/testbed/docs/_static/logo-black.svg", + "/testbed/docs/_static/logo-white.svg", + "/testbed/docs/_templates/partials/globaltoc-above.html", + "/testbed/docs/advanced.rst", + "/testbed/docs/api.rst", + "/testbed/docs/changes.rst", + "/testbed/docs/cli.rst", + "/testbed/docs/community.rst", + "/testbed/docs/conf.py", + "/testbed/docs/directives.rst", + "/testbed/docs/guide.rst", + "/testbed/docs/index.rst", + "/testbed/docs/plugins.rst", + "/testbed/docs/renderers.rst", + "/testbed/docs/requirements.txt", + "/testbed/docs/upgrade.rst", + "/testbed/pyproject.toml", + "/testbed/serve-doc.py", + "/testbed/setup.py", + "/testbed/src/mistune/__init__.py", + "/testbed/src/mistune/__main__.py", + "/testbed/src/mistune/block_parser.py", + "/testbed/src/mistune/core.py", + "/testbed/src/mistune/directives/__init__.py", + "/testbed/src/mistune/directives/_base.py", + "/testbed/src/mistune/directives/_fenced.py", + "/testbed/src/mistune/directives/_rst.py", + "/testbed/src/mistune/directives/admonition.py", + "/testbed/src/mistune/directives/image.py", + "/testbed/src/mistune/directives/include.py", + "/testbed/src/mistune/directives/toc.py", + "/testbed/src/mistune/helpers.py", + "/testbed/src/mistune/inline_parser.py", + "/testbed/src/mistune/list_parser.py", + "/testbed/src/mistune/markdown.py", + "/testbed/src/mistune/plugins/__init__.py", + "/testbed/src/mistune/plugins/abbr.py", + "/testbed/src/mistune/plugins/def_list.py", + "/testbed/src/mistune/plugins/footnotes.py", + "/testbed/src/mistune/plugins/formatting.py", + "/testbed/src/mistune/plugins/math.py", + "/testbed/src/mistune/plugins/ruby.py", + "/testbed/src/mistune/plugins/speedup.py", + "/testbed/src/mistune/plugins/spoiler.py", + "/testbed/src/mistune/plugins/table.py", + "/testbed/src/mistune/plugins/task_lists.py", + "/testbed/src/mistune/plugins/url.py", + "/testbed/src/mistune/py.typed", + "/testbed/src/mistune/renderers/__init__.py", + "/testbed/src/mistune/renderers/_list.py", + "/testbed/src/mistune/renderers/html.py", + "/testbed/src/mistune/renderers/markdown.py", + "/testbed/src/mistune/renderers/rst.py", + "/testbed/src/mistune/toc.py", + "/testbed/src/mistune/util.py", + "/testbed/tests/__init__.py", + "/testbed/tests/fixtures/__init__.py", + "/testbed/tests/fixtures/abbr.txt", + "/testbed/tests/fixtures/commonmark.json", + "/testbed/tests/fixtures/def_list.txt", + "/testbed/tests/fixtures/diff-commonmark.txt", + "/testbed/tests/fixtures/fenced_admonition.txt", + "/testbed/tests/fixtures/fenced_figure.txt", + "/testbed/tests/fixtures/fenced_image.txt", + "/testbed/tests/fixtures/fenced_toc.txt", + "/testbed/tests/fixtures/fix-commonmark.txt", + "/testbed/tests/fixtures/footnotes.txt", + "/testbed/tests/fixtures/hook_toc.txt", + "/testbed/tests/fixtures/include/hello.md", + "/testbed/tests/fixtures/include/hello.txt", + "/testbed/tests/fixtures/include/text.html", + "/testbed/tests/fixtures/include/text.md", + "/testbed/tests/fixtures/insert.txt", + "/testbed/tests/fixtures/mark.txt", + "/testbed/tests/fixtures/math.txt", + "/testbed/tests/fixtures/renderer_markdown.txt", + "/testbed/tests/fixtures/renderer_rst.txt", + "/testbed/tests/fixtures/rst_admonition.txt", + "/testbed/tests/fixtures/rst_toc.txt", + "/testbed/tests/fixtures/ruby.txt", + "/testbed/tests/fixtures/spoiler.txt", + "/testbed/tests/fixtures/strikethrough.txt", + "/testbed/tests/fixtures/subscript.txt", + "/testbed/tests/fixtures/superscript.txt", + "/testbed/tests/fixtures/table.txt", + "/testbed/tests/fixtures/task_lists.txt", + "/testbed/tests/fixtures/url.txt", + "/testbed/tests/test_commonmark.py", + "/testbed/tests/test_directives.py", + "/testbed/tests/test_hooks.py", + "/testbed/tests/test_misc.py", + "/testbed/tests/test_renderers.py", + "/testbed/tests/test_syntax.py" + ], + "healthy_stage_meaning": "Direct parent of the mutation; no source or test execution has been performed", + "mutation_matches_dataset_and_git_blobs": true, + "official_profile": { + "eval_sets": [], + "profile_class": "MistuneBf54ef67", + "profile_lines": [ + 570, + 573 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "bf54ef67390e02a5cdee7495d4386d7770c1902b", + "upstream_repo": "lepture/mistune" + }, + "original_source_commit": "bf54ef67390e02a5cdee7495d4386d7770c1902b", + "private_test_paths": [ + "tests/test_plugins.py" + ], + "private_tests_unchanged": true, + "profile_mapping_basis": "Explicit upstream repo and full commit fields parsed from pinned official Python profile AST, not basename inference", + "qwen_calibrated": false, + "runtime_qualified": false, + "source_paths": [ + "src/mistune/plugins/footnotes.py" + ], + "source_repo": "swesmith/lepture__mistune.bf54ef67", + "source_stages_bytes": 1359849, + "task_id": "lepture__mistune.bf54ef67.combine_file__09sp6cd7", + "transfer_limitation": "Existing regular files only; new arbitrary file additions need a qualified patch adapter", + "upstream_repo": "lepture/mistune" + }, + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:lepture__mistune.bf54ef67.combine_file__09sp6cd7", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "62750c95db25a8fb93dda09242f64e07508d9231", + "instruction_sha256": "fec5d4dc1c26e05562d60165b3efd3f8c3feda25d4691e4f3e6fc19152db3408", + "is_fork": true, + "learner_path": "tasks/a5177fad85cc5c3425cb067e/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "bf54ef67390e02a5cdee7495d4386d7770c1902b", + "actual_upstream_url": "https://raw.githubusercontent.com/lepture/mistune/bf54ef67390e02a5cdee7495d4386d7770c1902b/LICENSE", + "reviewed": true, + "sha256": "539013fd8e19f744f8bf0e27a532bbff54cd689ecef7a800f56ae5dc824be870", + "spdx": "BSD-3-Clause", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/lepture__mistune.bf54ef67/d61be76e0804de22f3b3e6662dc15268183e5684/LICENSE" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "bf54ef67390e02a5cdee7495d4386d7770c1902b", + "patch_sha256": "fd90c744db49f0b6e732ced50f6f89901816de129805a230ffa7d157e75051fa", + "provenance_path": "tasks/a5177fad85cc5c3425cb067e/source-proof.json", + "repository_lineage": [ + "swesmith/lepture__mistune.bf54ef67", + "lepture/mistune" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "d61be76e0804de22f3b3e6662dc15268183e5684", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "0d1f317e60a2a36eeee69296c01aeaad02bc4ee9", + "source_kind": "mutation", + "source_repo": "swesmith/lepture__mistune.bf54ef67", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "lepture__mistune.bf54ef67.combine_file__09sp6cd7", + "task_sha256": "13a8eaaff6c6a24671b445d734782202fb4ec1f388956972d2886b26678cfe7c", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "lepture/mistune", + "usage": "quarantine_only" + }, + "task_kind": "original-source-mutation" +} diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/provenance.json b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/provenance.json new file mode 100644 index 0000000000000000000000000000000000000000..ba78312974fafc444b9668fb9b95b01f69c13ce1 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/provenance.json @@ -0,0 +1,88 @@ +{ + "generated_reference": false, + "healthy_reference_delta_sha256": "f35968a2f373054dfe3b8508cf6b9ea4c8b491340c0b5323261a61b821f7575b", + "native_pytest_ids_preserved": true, + "original_source_code_license": { + "actual_upstream_commit": "bf54ef67390e02a5cdee7495d4386d7770c1902b", + "actual_upstream_url": "https://raw.githubusercontent.com/lepture/mistune/bf54ef67390e02a5cdee7495d4386d7770c1902b/LICENSE", + "reviewed": true, + "sha256": "539013fd8e19f744f8bf0e27a532bbff54cd689ecef7a800f56ae5dc824be870", + "spdx": "BSD-3-Clause", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/lepture__mistune.bf54ef67/d61be76e0804de22f3b3e6662dc15268183e5684/LICENSE" + }, + "provided_reference": true, + "qwen_calibrated": false, + "runtime_qualified": false, + "source_completion_sha256": "2480e0bda844194ea270c618d3e993156fa6fd476793410e6203b2e3406ea75d", + "source_index_sha256": "e856874b9410fce9f3bfea52c8c482e84b3e43942d87517f8b55f0034bd40f6f", + "source_proof_sha256": "c3ea9dde6304caf7f45a9e6d6af2b9f46f06b297b01dfe1e1a58f2c6e0881930", + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:lepture__mistune.bf54ef67.combine_file__09sp6cd7", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "62750c95db25a8fb93dda09242f64e07508d9231", + "instruction_sha256": "fec5d4dc1c26e05562d60165b3efd3f8c3feda25d4691e4f3e6fc19152db3408", + "is_fork": true, + "learner_path": "tasks/a5177fad85cc5c3425cb067e/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "bf54ef67390e02a5cdee7495d4386d7770c1902b", + "actual_upstream_url": "https://raw.githubusercontent.com/lepture/mistune/bf54ef67390e02a5cdee7495d4386d7770c1902b/LICENSE", + "reviewed": true, + "sha256": "539013fd8e19f744f8bf0e27a532bbff54cd689ecef7a800f56ae5dc824be870", + "spdx": "BSD-3-Clause", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/lepture__mistune.bf54ef67/d61be76e0804de22f3b3e6662dc15268183e5684/LICENSE" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "bf54ef67390e02a5cdee7495d4386d7770c1902b", + "patch_sha256": "fd90c744db49f0b6e732ced50f6f89901816de129805a230ffa7d157e75051fa", + "provenance_path": "tasks/a5177fad85cc5c3425cb067e/source-proof.json", + "repository_lineage": [ + "swesmith/lepture__mistune.bf54ef67", + "lepture/mistune" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "d61be76e0804de22f3b3e6662dc15268183e5684", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "0d1f317e60a2a36eeee69296c01aeaad02bc4ee9", + "source_kind": "mutation", + "source_repo": "swesmith/lepture__mistune.bf54ef67", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "lepture__mistune.bf54ef67.combine_file__09sp6cd7", + "task_sha256": "13a8eaaff6c6a24671b445d734782202fb4ec1f388956972d2886b26678cfe7c", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "lepture/mistune", + "usage": "quarantine_only" + }, + "task_bundle_license": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + }, + "training_admissible": false, + "trusted_tests_sha256": "cb345067f46bf3d3e7a60b2963e26cee25fe8aae6cd4a620d05e02f799d96fca" +} diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/provided-gold.diff b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/provided-gold.diff new file mode 100644 index 0000000000000000000000000000000000000000..4797ff6e732e6ff0701c15142ff53b17c66846f3 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/provided-gold.diff @@ -0,0 +1,30 @@ +diff --git a/src/mistune/plugins/footnotes.py b/src/mistune/plugins/footnotes.py +index 57aea3dd6ffd30ee0f3301d2221545e82630a54e..96fe8df2b99794a5d86ced246bc20fdb235ee811 100644 +--- a/src/mistune/plugins/footnotes.py ++++ b/src/mistune/plugins/footnotes.py +@@ -53,13 +53,13 @@ + ) -> int: + ref = state.env.get("ref_footnotes") + if not ref: +- ref = [] ++ ref = {} + + key = unikey(m.group('footnote_key')) + if key not in ref: +- ref[key.lower()] = m.group('footnote_text').strip() ++ ref[key] = m.group('footnote_text') + state.env['ref_footnotes'] = ref +- return m.start() ++ return m.end() + + + def parse_footnote_item( +@@ -118,7 +118,7 @@ + + + def render_footnotes(renderer: "BaseRenderer", text: str) -> str: +- return '
      \n
        \n' + text + "
      \n
      \n" ++ return '
      \n
        \n' + text + "
      \n
      \n" + + + def render_footnote_item( diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/solution/solve.sh b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..952745167203df13c7996d971b0ab44f4589fc5f --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/solution/solve.sh @@ -0,0 +1,36 @@ +#!/bin/bash +set -Eeuo pipefail +cd /testbed/repo +cat > /tmp/openenv-reference.diff <<'OPENENV_REFERENCE' +diff --git a/src/mistune/plugins/footnotes.py b/src/mistune/plugins/footnotes.py +index 57aea3dd6ffd30ee0f3301d2221545e82630a54e..96fe8df2b99794a5d86ced246bc20fdb235ee811 100644 +--- a/src/mistune/plugins/footnotes.py ++++ b/src/mistune/plugins/footnotes.py +@@ -53,13 +53,13 @@ + ) -> int: + ref = state.env.get("ref_footnotes") + if not ref: +- ref = [] ++ ref = {} + + key = unikey(m.group('footnote_key')) + if key not in ref: +- ref[key.lower()] = m.group('footnote_text').strip() ++ ref[key] = m.group('footnote_text') + state.env['ref_footnotes'] = ref +- return m.start() ++ return m.end() + + + def parse_footnote_item( +@@ -118,7 +118,7 @@ + + + def render_footnotes(renderer: "BaseRenderer", text: str) -> str: +- return '
      \n
        \n' + text + "
      \n
      \n" ++ return '
      \n
        \n' + text + "
      \n
      \n" + + + def render_footnote_item( +OPENENV_REFERENCE +/usr/bin/git -c core.hooksPath=/dev/null -c core.fsmonitor=false apply --whitespace=nowarn /tmp/openenv-reference.diff diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/task.toml b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..8ca9e44fe02a0c63c03934e81299da03e85eb8b3 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/task.toml @@ -0,0 +1,24 @@ +version = "1.0" + +[agent] +timeout_sec = 1800.0 + +[verifier] +timeout_sec = 900.0 + +[environment] +docker_image = "ghcr.io/younesbelkada/scale800@sha256:fe8b428953891ec55083d7d859e8b17b15223718cb13c91e8d7592cc8b09befe" +build_timeout_sec = 600.0 +cpus = 2 +memory_mb = 8192 +storage_mb = 16384 + +[metadata] +author_name = "SWE-smith source adapter" +category = "bugfix" +tags = ["swe", "python", "mutation-repair"] + +[environment.env] +# The image's PATH with the testbed env first: the project and pytest are installed there, and the agent's +# non-interactive shells never run `conda activate` +PATH = "/opt/miniconda3/envs/testbed/bin:/opt/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/check_pytest.py b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/check_pytest.py new file mode 100644 index 0000000000000000000000000000000000000000..7abfdc5972f57ca7f0cecbbeeb373414670f780e --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/check_pytest.py @@ -0,0 +1,177 @@ +"""Preserve confirmed requested assertion failures; keep positive checks strict.""" + +import argparse +import hashlib +import json +import re +import xml.etree.ElementTree as ET +from pathlib import Path + +GROUPS = ("pass-to-pass", "fail-to-pass") + + +def split_nodeid(target): + prefix, bracket, parameter = target.partition("[") + parts = prefix.split("::") + if bracket: + parts[-1] += bracket + parameter + return parts + + +def matches(case, target): + parts = split_nodeid(target) + module = parts[0].removesuffix(".py").replace("/", ".") + classname, name = case.get("classname", ""), case.get("name", "") + if not (classname == module or classname.startswith(module + ".")): + return False + selector = parts[-1] if len(parts) > 1 else "" + classes = parts[1:-1] + if classes and classname != module + "." + ".".join(classes): + return False + return ( + not selector + or name == selector + or ("[" not in selector and name.startswith(selector + "[")) + ) + + +def capture_panels(root): + panels, digests = {}, {} + for group in GROUPS: + path = Path(root) / (group + ".xml") + if not path.exists(): + panels[group] = None + continue + with path.open("rb") as stream: + raw = stream.read(4 * 1024**2 + 1) + if not 0 < len(raw) <= 4 * 1024**2 or re.search( + rb" 20000: + raise ValueError("Too many pytest cases") + identities = [(case.get("classname"), case.get("name")) for case in cases] + if len(identities) != len(set(identities)): + raise ValueError("Duplicate pytest case evidence") + panels[group] = cases + digests[group] = hashlib.sha256(raw).hexdigest() + return panels, digests + + +def strict_assess(panels, expected, native_exit): + """The original positive-approval conditions, applied to captured cases.""" + all_cases, actual_failure = [], False + for group in GROUPS: + cases = panels[group] + if cases is None: + if actual_failure: + continue + raise ValueError("Missing preceding pytest panel") + if actual_failure: + raise ValueError( + "Pytest evidence continued after the native stop-on-failure" + ) + targets = expected[group] + if any(not any(matches(case, target) for target in targets) for case in cases): + raise ValueError("Unexpected pytest case") + all_cases.extend(cases) + failures = [case for case in cases if case.find("failure") is not None] + if any( + case.find("error") is not None or case.find("skipped") is not None + for case in cases + ): + raise ValueError("Pytest collection/error/skip is not a completed panel") + actual_failure = actual_failure or bool(failures) + if not failures and any( + not any(matches(case, target) for case in cases) for target in targets + ): + raise ValueError("Declared pytest target never ran") + if actual_failure: + if native_exit == 0: + raise ValueError("Native verifier exit disagrees with pytest failure") + return {"reward": 0, "valid_test_failure": True, "cases": len(all_cases)} + if native_exit != 0: + raise ValueError("Setup or native verifier failed without a real test failure") + if any(panels[group] is None for group in GROUPS): + raise ValueError("Missing completed pytest panel") + return {"reward": 1, "valid_test_failure": False, "cases": len(all_cases)} + + +def assess(root, expected, native_exit): + if type(native_exit) is not int: + raise ValueError("Native verifier exit must be an integer") + if not isinstance(expected, dict) or any( + not isinstance(expected.get(group), list) + or not expected[group] + or any(not isinstance(target, str) or not target for target in expected[group]) + for group in GROUPS + ): + raise ValueError("Complete exact native pytest targets required") + panels, digests = capture_panels(root) + counts = { + "cases": 0, + "matched_failures": 0, + "unexpected_cases": 0, + "unmatched_failures": 0, + "skipped_cases": 0, + "error_cases": 0, + "missing_panels": 0, + "missing_targets": 0, + } + for group in GROUPS: + cases = panels[group] + if cases is None: + counts["missing_panels"] += 1 + counts["missing_targets"] += len(expected[group]) + continue + counts["cases"] += len(cases) + for case in cases: + requested = any(matches(case, target) for target in expected[group]) + failure = case.find("failure") is not None + counts["matched_failures"] += int(requested and failure) + counts["unmatched_failures"] += int(not requested and failure) + counts["unexpected_cases"] += int(not requested) + counts["skipped_cases"] += int(case.find("skipped") is not None) + counts["error_cases"] += int(case.find("error") is not None) + counts["missing_targets"] += sum( + not any(matches(case, target) for case in cases) + for target in expected[group] + ) + if counts["matched_failures"]: + if native_exit == 0: + raise ValueError( + "Native verifier exit disagrees with requested pytest failure" + ) + return { + "reward": 0, + "valid_test_failure": True, + "cases": counts["cases"], + "diagnostic_counts": counts, + "panel_sha256": digests, + "decision": "confirmed_requested_failure_precedence", + } + result = strict_assess(panels, expected, native_exit) + result.update(diagnostic_counts=counts, panel_sha256=digests) + return result + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("--root", required=True) + parser.add_argument("--expected", required=True) + parser.add_argument("--native-exit", type=int, required=True) + args = parser.parse_args() + result = assess( + args.root, json.loads(Path(args.expected).read_bytes()), args.native_exit + ) + reward = Path(args.root) / "reward.txt" + if reward.read_text().strip() != str(result["reward"]): + raise ValueError("Native raw reward disagrees with pytest evidence") + (Path(args.root) / "pytest-evidence.json").write_text( + json.dumps(result, sort_keys=True) + "\n" + ) diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/expected-panels.json b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/expected-panels.json new file mode 100644 index 0000000000000000000000000000000000000000..d248bc3b7894a6a7818cf2791698ffa05d13b297 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/expected-panels.json @@ -0,0 +1,951 @@ +{ + "fail-to-pass": [ + "tests/test_plugins.py::TestPlugin1_footnotes::test_footnotes_002", + "tests/test_plugins.py::TestPlugin1_footnotes::test_footnotes_003", + "tests/test_plugins.py::TestPlugin2_footnotes::test_footnotes_002", + "tests/test_plugins.py::TestPlugin2_footnotes::test_footnotes_003" + ], + "pass-to-pass": [ + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_062", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_063", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_064", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_065", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_066", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_067", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_068", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_069", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_070", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_071", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_072", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_073", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_074", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_075", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_076", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_077", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_078", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_079", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_593", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_594", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_595", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_596", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_597", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_598", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_599", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_600", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_601", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_602", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_603", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_604", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_605", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_606", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_607", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_608", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_609", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_610", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_611", + "tests/test_commonmark.py::TestCommonMark::test_backslash_escapes_012", + "tests/test_commonmark.py::TestCommonMark::test_backslash_escapes_013", + "tests/test_commonmark.py::TestCommonMark::test_backslash_escapes_014", + "tests/test_commonmark.py::TestCommonMark::test_backslash_escapes_015", + "tests/test_commonmark.py::TestCommonMark::test_backslash_escapes_016", + "tests/test_commonmark.py::TestCommonMark::test_backslash_escapes_017", + "tests/test_commonmark.py::TestCommonMark::test_backslash_escapes_018", + "tests/test_commonmark.py::TestCommonMark::test_backslash_escapes_019", + "tests/test_commonmark.py::TestCommonMark::test_backslash_escapes_020", + "tests/test_commonmark.py::TestCommonMark::test_backslash_escapes_021", + "tests/test_commonmark.py::TestCommonMark::test_backslash_escapes_022", + "tests/test_commonmark.py::TestCommonMark::test_backslash_escapes_023", + "tests/test_commonmark.py::TestCommonMark::test_backslash_escapes_024", + "tests/test_commonmark.py::TestCommonMark::test_blank_lines_227", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_228", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_229", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_230", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_231", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_232", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_233", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_234", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_235", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_236", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_237", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_238", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_239", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_240", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_241", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_242", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_243", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_244", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_245", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_246", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_247", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_248", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_249", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_250", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_251", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_252", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_328", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_329", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_330", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_331", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_332", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_333", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_334", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_335", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_336", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_337", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_338", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_339", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_340", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_341", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_342", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_343", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_344", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_345", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_346", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_347", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_348", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_349", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_350", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_351", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_353", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_354", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_355", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_356", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_357", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_358", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_359", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_360", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_361", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_362", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_363", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_364", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_365", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_366", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_369", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_370", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_371", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_373", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_374", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_375", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_376", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_377", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_378", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_380", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_381", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_382", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_383", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_384", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_385", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_386", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_387", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_389", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_390", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_392", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_393", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_394", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_395", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_396", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_397", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_398", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_399", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_400", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_401", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_402", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_403", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_404", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_405", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_409", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_410", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_411", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_415", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_419", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_420", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_421", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_422", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_423", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_427", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_428", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_432", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_433", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_434", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_435", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_436", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_437", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_438", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_439", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_440", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_447", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_448", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_449", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_450", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_451", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_452", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_459", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_461", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_466", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_468", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_469", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_472", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_473", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_474", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_475", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_476", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_479", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_480", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_025", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_026", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_027", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_028", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_029", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_030", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_031", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_032", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_033", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_034", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_035", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_036", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_037", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_038", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_039", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_040", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_041", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_119", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_120", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_121", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_122", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_123", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_124", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_125", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_126", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_127", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_128", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_129", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_130", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_131", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_132", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_133", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_134", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_135", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_136", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_137", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_138", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_139", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_140", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_141", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_142", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_143", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_144", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_145", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_146", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_147", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_633", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_634", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_635", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_636", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_637", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_638", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_639", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_640", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_641", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_642", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_643", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_644", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_645", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_646", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_647", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_148", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_149", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_150", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_151", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_152", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_153", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_154", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_155", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_156", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_157", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_158", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_159", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_160", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_161", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_162", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_163", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_164", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_165", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_166", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_167", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_168", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_169", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_170", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_171", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_172", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_173", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_174", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_175", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_176", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_177", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_178", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_179", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_180", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_181", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_182", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_183", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_184", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_185", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_186", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_187", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_188", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_189", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_190", + "tests/test_commonmark.py::TestCommonMark::test_images_571", + "tests/test_commonmark.py::TestCommonMark::test_images_572", + "tests/test_commonmark.py::TestCommonMark::test_images_574", + "tests/test_commonmark.py::TestCommonMark::test_images_575", + "tests/test_commonmark.py::TestCommonMark::test_images_576", + "tests/test_commonmark.py::TestCommonMark::test_images_577", + "tests/test_commonmark.py::TestCommonMark::test_images_578", + "tests/test_commonmark.py::TestCommonMark::test_images_579", + "tests/test_commonmark.py::TestCommonMark::test_images_580", + "tests/test_commonmark.py::TestCommonMark::test_images_581", + "tests/test_commonmark.py::TestCommonMark::test_images_582", + "tests/test_commonmark.py::TestCommonMark::test_images_583", + "tests/test_commonmark.py::TestCommonMark::test_images_584", + "tests/test_commonmark.py::TestCommonMark::test_images_585", + "tests/test_commonmark.py::TestCommonMark::test_images_586", + "tests/test_commonmark.py::TestCommonMark::test_images_587", + "tests/test_commonmark.py::TestCommonMark::test_images_588", + "tests/test_commonmark.py::TestCommonMark::test_images_589", + "tests/test_commonmark.py::TestCommonMark::test_images_590", + "tests/test_commonmark.py::TestCommonMark::test_images_591", + "tests/test_commonmark.py::TestCommonMark::test_images_592", + "tests/test_commonmark.py::TestCommonMark::test_indented_code_blocks_107", + "tests/test_commonmark.py::TestCommonMark::test_indented_code_blocks_108", + "tests/test_commonmark.py::TestCommonMark::test_indented_code_blocks_109", + "tests/test_commonmark.py::TestCommonMark::test_indented_code_blocks_110", + "tests/test_commonmark.py::TestCommonMark::test_indented_code_blocks_111", + "tests/test_commonmark.py::TestCommonMark::test_indented_code_blocks_112", + "tests/test_commonmark.py::TestCommonMark::test_indented_code_blocks_113", + "tests/test_commonmark.py::TestCommonMark::test_indented_code_blocks_114", + "tests/test_commonmark.py::TestCommonMark::test_indented_code_blocks_115", + "tests/test_commonmark.py::TestCommonMark::test_indented_code_blocks_116", + "tests/test_commonmark.py::TestCommonMark::test_indented_code_blocks_117", + "tests/test_commonmark.py::TestCommonMark::test_indented_code_blocks_118", + "tests/test_commonmark.py::TestCommonMark::test_inlines_327", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_192", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_193", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_194", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_195", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_196", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_197", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_198", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_199", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_200", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_201", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_202", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_203", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_204", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_205", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_206", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_207", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_208", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_209", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_210", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_211", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_212", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_213", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_214", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_215", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_216", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_217", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_218", + "tests/test_commonmark.py::TestCommonMark::test_links_481", + "tests/test_commonmark.py::TestCommonMark::test_links_482", + "tests/test_commonmark.py::TestCommonMark::test_links_483", + "tests/test_commonmark.py::TestCommonMark::test_links_484", + "tests/test_commonmark.py::TestCommonMark::test_links_485", + "tests/test_commonmark.py::TestCommonMark::test_links_486", + "tests/test_commonmark.py::TestCommonMark::test_links_487", + "tests/test_commonmark.py::TestCommonMark::test_links_488", + "tests/test_commonmark.py::TestCommonMark::test_links_489", + "tests/test_commonmark.py::TestCommonMark::test_links_490", + "tests/test_commonmark.py::TestCommonMark::test_links_491", + "tests/test_commonmark.py::TestCommonMark::test_links_492", + "tests/test_commonmark.py::TestCommonMark::test_links_493", + "tests/test_commonmark.py::TestCommonMark::test_links_494", + "tests/test_commonmark.py::TestCommonMark::test_links_497", + "tests/test_commonmark.py::TestCommonMark::test_links_498", + "tests/test_commonmark.py::TestCommonMark::test_links_499", + "tests/test_commonmark.py::TestCommonMark::test_links_500", + "tests/test_commonmark.py::TestCommonMark::test_links_501", + "tests/test_commonmark.py::TestCommonMark::test_links_502", + "tests/test_commonmark.py::TestCommonMark::test_links_503", + "tests/test_commonmark.py::TestCommonMark::test_links_505", + "tests/test_commonmark.py::TestCommonMark::test_links_506", + "tests/test_commonmark.py::TestCommonMark::test_links_507", + "tests/test_commonmark.py::TestCommonMark::test_links_508", + "tests/test_commonmark.py::TestCommonMark::test_links_509", + "tests/test_commonmark.py::TestCommonMark::test_links_510", + "tests/test_commonmark.py::TestCommonMark::test_links_511", + "tests/test_commonmark.py::TestCommonMark::test_links_512", + "tests/test_commonmark.py::TestCommonMark::test_links_513", + "tests/test_commonmark.py::TestCommonMark::test_links_514", + "tests/test_commonmark.py::TestCommonMark::test_links_515", + "tests/test_commonmark.py::TestCommonMark::test_links_516", + "tests/test_commonmark.py::TestCommonMark::test_links_520", + "tests/test_commonmark.py::TestCommonMark::test_links_521", + "tests/test_commonmark.py::TestCommonMark::test_links_522", + "tests/test_commonmark.py::TestCommonMark::test_links_523", + "tests/test_commonmark.py::TestCommonMark::test_links_524", + "tests/test_commonmark.py::TestCommonMark::test_links_525", + "tests/test_commonmark.py::TestCommonMark::test_links_526", + "tests/test_commonmark.py::TestCommonMark::test_links_527", + "tests/test_commonmark.py::TestCommonMark::test_links_528", + "tests/test_commonmark.py::TestCommonMark::test_links_529", + "tests/test_commonmark.py::TestCommonMark::test_links_530", + "tests/test_commonmark.py::TestCommonMark::test_links_533", + "tests/test_commonmark.py::TestCommonMark::test_links_534", + "tests/test_commonmark.py::TestCommonMark::test_links_535", + "tests/test_commonmark.py::TestCommonMark::test_links_536", + "tests/test_commonmark.py::TestCommonMark::test_links_537", + "tests/test_commonmark.py::TestCommonMark::test_links_538", + "tests/test_commonmark.py::TestCommonMark::test_links_539", + "tests/test_commonmark.py::TestCommonMark::test_links_540", + "tests/test_commonmark.py::TestCommonMark::test_links_541", + "tests/test_commonmark.py::TestCommonMark::test_links_542", + "tests/test_commonmark.py::TestCommonMark::test_links_543", + "tests/test_commonmark.py::TestCommonMark::test_links_544", + "tests/test_commonmark.py::TestCommonMark::test_links_545", + "tests/test_commonmark.py::TestCommonMark::test_links_546", + "tests/test_commonmark.py::TestCommonMark::test_links_547", + "tests/test_commonmark.py::TestCommonMark::test_links_548", + "tests/test_commonmark.py::TestCommonMark::test_links_549", + "tests/test_commonmark.py::TestCommonMark::test_links_550", + "tests/test_commonmark.py::TestCommonMark::test_links_551", + "tests/test_commonmark.py::TestCommonMark::test_links_552", + "tests/test_commonmark.py::TestCommonMark::test_links_553", + "tests/test_commonmark.py::TestCommonMark::test_links_554", + "tests/test_commonmark.py::TestCommonMark::test_links_555", + "tests/test_commonmark.py::TestCommonMark::test_links_556", + "tests/test_commonmark.py::TestCommonMark::test_links_557", + "tests/test_commonmark.py::TestCommonMark::test_links_558", + "tests/test_commonmark.py::TestCommonMark::test_links_559", + "tests/test_commonmark.py::TestCommonMark::test_links_560", + "tests/test_commonmark.py::TestCommonMark::test_links_561", + "tests/test_commonmark.py::TestCommonMark::test_links_562", + "tests/test_commonmark.py::TestCommonMark::test_links_563", + "tests/test_commonmark.py::TestCommonMark::test_links_564", + "tests/test_commonmark.py::TestCommonMark::test_links_565", + "tests/test_commonmark.py::TestCommonMark::test_links_566", + "tests/test_commonmark.py::TestCommonMark::test_links_567", + "tests/test_commonmark.py::TestCommonMark::test_links_568", + "tests/test_commonmark.py::TestCommonMark::test_links_569", + "tests/test_commonmark.py::TestCommonMark::test_links_570", + "tests/test_commonmark.py::TestCommonMark::test_list_items_253", + "tests/test_commonmark.py::TestCommonMark::test_list_items_254", + "tests/test_commonmark.py::TestCommonMark::test_list_items_255", + "tests/test_commonmark.py::TestCommonMark::test_list_items_256", + "tests/test_commonmark.py::TestCommonMark::test_list_items_257", + "tests/test_commonmark.py::TestCommonMark::test_list_items_258", + "tests/test_commonmark.py::TestCommonMark::test_list_items_259", + "tests/test_commonmark.py::TestCommonMark::test_list_items_260", + "tests/test_commonmark.py::TestCommonMark::test_list_items_261", + "tests/test_commonmark.py::TestCommonMark::test_list_items_262", + "tests/test_commonmark.py::TestCommonMark::test_list_items_263", + "tests/test_commonmark.py::TestCommonMark::test_list_items_264", + "tests/test_commonmark.py::TestCommonMark::test_list_items_265", + "tests/test_commonmark.py::TestCommonMark::test_list_items_266", + "tests/test_commonmark.py::TestCommonMark::test_list_items_267", + "tests/test_commonmark.py::TestCommonMark::test_list_items_268", + "tests/test_commonmark.py::TestCommonMark::test_list_items_269", + "tests/test_commonmark.py::TestCommonMark::test_list_items_270", + "tests/test_commonmark.py::TestCommonMark::test_list_items_271", + "tests/test_commonmark.py::TestCommonMark::test_list_items_272", + "tests/test_commonmark.py::TestCommonMark::test_list_items_273", + "tests/test_commonmark.py::TestCommonMark::test_list_items_274", + "tests/test_commonmark.py::TestCommonMark::test_list_items_275", + "tests/test_commonmark.py::TestCommonMark::test_list_items_276", + "tests/test_commonmark.py::TestCommonMark::test_list_items_277", + "tests/test_commonmark.py::TestCommonMark::test_list_items_278", + "tests/test_commonmark.py::TestCommonMark::test_list_items_279", + "tests/test_commonmark.py::TestCommonMark::test_list_items_280", + "tests/test_commonmark.py::TestCommonMark::test_list_items_281", + "tests/test_commonmark.py::TestCommonMark::test_list_items_282", + "tests/test_commonmark.py::TestCommonMark::test_list_items_283", + "tests/test_commonmark.py::TestCommonMark::test_list_items_284", + "tests/test_commonmark.py::TestCommonMark::test_list_items_285", + "tests/test_commonmark.py::TestCommonMark::test_list_items_286", + "tests/test_commonmark.py::TestCommonMark::test_list_items_287", + "tests/test_commonmark.py::TestCommonMark::test_list_items_288", + "tests/test_commonmark.py::TestCommonMark::test_list_items_289", + "tests/test_commonmark.py::TestCommonMark::test_list_items_290", + "tests/test_commonmark.py::TestCommonMark::test_list_items_291", + "tests/test_commonmark.py::TestCommonMark::test_list_items_292", + "tests/test_commonmark.py::TestCommonMark::test_list_items_293", + "tests/test_commonmark.py::TestCommonMark::test_list_items_294", + "tests/test_commonmark.py::TestCommonMark::test_list_items_295", + "tests/test_commonmark.py::TestCommonMark::test_list_items_296", + "tests/test_commonmark.py::TestCommonMark::test_list_items_297", + "tests/test_commonmark.py::TestCommonMark::test_list_items_298", + "tests/test_commonmark.py::TestCommonMark::test_list_items_299", + "tests/test_commonmark.py::TestCommonMark::test_list_items_300", + "tests/test_commonmark.py::TestCommonMark::test_lists_301", + "tests/test_commonmark.py::TestCommonMark::test_lists_302", + "tests/test_commonmark.py::TestCommonMark::test_lists_303", + "tests/test_commonmark.py::TestCommonMark::test_lists_304", + "tests/test_commonmark.py::TestCommonMark::test_lists_305", + "tests/test_commonmark.py::TestCommonMark::test_lists_306", + "tests/test_commonmark.py::TestCommonMark::test_lists_307", + "tests/test_commonmark.py::TestCommonMark::test_lists_308", + "tests/test_commonmark.py::TestCommonMark::test_lists_309", + "tests/test_commonmark.py::TestCommonMark::test_lists_310", + "tests/test_commonmark.py::TestCommonMark::test_lists_311", + "tests/test_commonmark.py::TestCommonMark::test_lists_312", + "tests/test_commonmark.py::TestCommonMark::test_lists_313", + "tests/test_commonmark.py::TestCommonMark::test_lists_314", + "tests/test_commonmark.py::TestCommonMark::test_lists_315", + "tests/test_commonmark.py::TestCommonMark::test_lists_316", + "tests/test_commonmark.py::TestCommonMark::test_lists_317", + "tests/test_commonmark.py::TestCommonMark::test_lists_318", + "tests/test_commonmark.py::TestCommonMark::test_lists_319", + "tests/test_commonmark.py::TestCommonMark::test_lists_320", + "tests/test_commonmark.py::TestCommonMark::test_lists_321", + "tests/test_commonmark.py::TestCommonMark::test_lists_322", + "tests/test_commonmark.py::TestCommonMark::test_lists_323", + "tests/test_commonmark.py::TestCommonMark::test_lists_324", + "tests/test_commonmark.py::TestCommonMark::test_lists_325", + "tests/test_commonmark.py::TestCommonMark::test_lists_326", + "tests/test_commonmark.py::TestCommonMark::test_paragraphs_219", + "tests/test_commonmark.py::TestCommonMark::test_paragraphs_220", + "tests/test_commonmark.py::TestCommonMark::test_paragraphs_221", + "tests/test_commonmark.py::TestCommonMark::test_paragraphs_222", + "tests/test_commonmark.py::TestCommonMark::test_paragraphs_223", + "tests/test_commonmark.py::TestCommonMark::test_paragraphs_224", + "tests/test_commonmark.py::TestCommonMark::test_paragraphs_225", + "tests/test_commonmark.py::TestCommonMark::test_paragraphs_226", + "tests/test_commonmark.py::TestCommonMark::test_precedence_042", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_612", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_613", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_614", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_615", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_616", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_617", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_618", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_619", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_620", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_621", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_622", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_623", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_624", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_625", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_626", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_627", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_628", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_629", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_630", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_631", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_632", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_080", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_081", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_082", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_083", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_084", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_085", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_086", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_087", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_088", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_089", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_090", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_091", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_092", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_094", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_095", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_096", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_097", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_098", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_099", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_100", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_101", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_102", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_103", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_104", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_105", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_106", + "tests/test_commonmark.py::TestCommonMark::test_soft_line_breaks_648", + "tests/test_commonmark.py::TestCommonMark::test_soft_line_breaks_649", + "tests/test_commonmark.py::TestCommonMark::test_tabs_001", + "tests/test_commonmark.py::TestCommonMark::test_tabs_002", + "tests/test_commonmark.py::TestCommonMark::test_tabs_003", + "tests/test_commonmark.py::TestCommonMark::test_tabs_004", + "tests/test_commonmark.py::TestCommonMark::test_tabs_005", + "tests/test_commonmark.py::TestCommonMark::test_tabs_006", + "tests/test_commonmark.py::TestCommonMark::test_tabs_007", + "tests/test_commonmark.py::TestCommonMark::test_tabs_008", + "tests/test_commonmark.py::TestCommonMark::test_tabs_009", + "tests/test_commonmark.py::TestCommonMark::test_tabs_010", + "tests/test_commonmark.py::TestCommonMark::test_tabs_011", + "tests/test_commonmark.py::TestCommonMark::test_textual_content_650", + "tests/test_commonmark.py::TestCommonMark::test_textual_content_651", + "tests/test_commonmark.py::TestCommonMark::test_textual_content_652", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_043", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_044", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_045", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_046", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_047", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_048", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_049", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_050", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_051", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_052", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_053", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_054", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_055", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_056", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_057", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_058", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_059", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_060", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_061", + "tests/test_directives.py::TestDirective_rst_admonition::test_admonition_001", + "tests/test_directives.py::TestDirective_rst_admonition::test_admonition_002", + "tests/test_directives.py::TestDirective_rst_admonition::test_admonition_003", + "tests/test_directives.py::TestDirective_rst_admonition::test_admonition_004", + "tests/test_directives.py::TestDirective_rst_toc::test_collapse_toc_001", + "tests/test_directives.py::TestDirective_rst_toc::test_complex_001", + "tests/test_directives.py::TestDirective_rst_toc::test_html_in_heading_001", + "tests/test_directives.py::TestDirective_rst_toc::test_insane_001", + "tests/test_directives.py::TestDirective_rst_toc::test_insane_002", + "tests/test_directives.py::TestDirective_rst_toc::test_invalid_option_001", + "tests/test_directives.py::TestDirective_rst_toc::test_invalid_option_002", + "tests/test_directives.py::TestDirective_rst_toc::test_invalid_option_003", + "tests/test_directives.py::TestDirective_rst_toc::test_link_in_heading_001", + "tests/test_directives.py::TestDirective_rst_toc::test_no_toc_001", + "tests/test_directives.py::TestDirective_rst_toc::test_no_toc_002", + "tests/test_directives.py::TestDirective_rst_toc::test_simple_toc_001", + "tests/test_directives.py::TestDirective_fenced_admonition::test_admonition_001", + "tests/test_directives.py::TestDirective_fenced_admonition::test_admonition_002", + "tests/test_directives.py::TestDirective_fenced_admonition::test_admonition_003", + "tests/test_directives.py::TestDirective_fenced_admonition::test_admonition_004", + "tests/test_directives.py::TestDirective_fenced_admonition::test_admonition_005", + "tests/test_directives.py::TestDirective_fenced_admonition::test_admonition_006", + "tests/test_directives.py::TestDirective_fenced_admonition::test_admonition_007", + "tests/test_directives.py::TestDirective_fenced_admonition::test_admonition_008", + "tests/test_directives.py::TestDirective_fenced_toc::test_collapse_toc_001", + "tests/test_directives.py::TestDirective_fenced_toc::test_complex_001", + "tests/test_directives.py::TestDirective_fenced_toc::test_html_in_heading_001", + "tests/test_directives.py::TestDirective_fenced_toc::test_insane_001", + "tests/test_directives.py::TestDirective_fenced_toc::test_insane_002", + "tests/test_directives.py::TestDirective_fenced_toc::test_invalid_option_001", + "tests/test_directives.py::TestDirective_fenced_toc::test_invalid_option_002", + "tests/test_directives.py::TestDirective_fenced_toc::test_invalid_option_003", + "tests/test_directives.py::TestDirective_fenced_toc::test_link_in_heading_001", + "tests/test_directives.py::TestDirective_fenced_toc::test_no_toc_001", + "tests/test_directives.py::TestDirective_fenced_toc::test_no_toc_002", + "tests/test_directives.py::TestDirective_fenced_toc::test_simple_toc_001", + "tests/test_directives.py::TestDirective_fenced_image::test_align_options_001", + "tests/test_directives.py::TestDirective_fenced_image::test_align_options_002", + "tests/test_directives.py::TestDirective_fenced_image::test_all_options_001", + "tests/test_directives.py::TestDirective_fenced_image::test_alt_option_001", + "tests/test_directives.py::TestDirective_fenced_image::test_ampersand_in_source_001", + "tests/test_directives.py::TestDirective_fenced_image::test_ampersand_in_target_001", + "tests/test_directives.py::TestDirective_fenced_image::test_no_options_001", + "tests/test_directives.py::TestDirective_fenced_image::test_target_option_001", + "tests/test_directives.py::TestDirective_fenced_image::test_width_and_height_001", + "tests/test_directives.py::TestDirective_fenced_image::test_width_and_height_002", + "tests/test_directives.py::TestDirective_fenced_figure::test_align_options_001", + "tests/test_directives.py::TestDirective_fenced_figure::test_align_options_002", + "tests/test_directives.py::TestDirective_fenced_figure::test_all_options_001", + "tests/test_directives.py::TestDirective_fenced_figure::test_alt_option_001", + "tests/test_directives.py::TestDirective_fenced_figure::test_caption_001", + "tests/test_directives.py::TestDirective_fenced_figure::test_legend_001", + "tests/test_directives.py::TestDirective_fenced_figure::test_legend_002", + "tests/test_directives.py::TestDirective_fenced_figure::test_no_options_001", + "tests/test_directives.py::TestDirective_fenced_figure::test_target_option_001", + "tests/test_directives.py::TestDirective_fenced_figure::test_width_and_height_001", + "tests/test_directives.py::TestDirective_fenced_figure::test_width_and_height_002", + "tests/test_directives.py::TestDirective_fenced_figure::test_width_and_height_003", + "tests/test_directives.py::TestCustomizeToc::test_colon_fenced_toc", + "tests/test_directives.py::TestCustomizeToc::test_fenced_toc", + "tests/test_directives.py::TestCustomizeToc::test_rst_toc", + "tests/test_directives.py::TestDirectiveInclude::test_html_include", + "tests/test_directives.py::TestDirectiveInclude::test_include_missing_source", + "tests/test_hooks.py::TestTocHook::test_complex_toc_001", + "tests/test_hooks.py::TestTocHook::test_customize_heading_id_func", + "tests/test_hooks.py::TestTocHook::test_html_in_heading_001", + "tests/test_hooks.py::TestTocHook::test_insane_toc_001", + "tests/test_hooks.py::TestTocHook::test_insane_toc_002", + "tests/test_hooks.py::TestTocHook::test_link_in_heading_001", + "tests/test_hooks.py::TestTocHook::test_simple_toc_001", + "tests/test_misc.py::TestMiscCases::test_allow_data_protocols", + "tests/test_misc.py::TestMiscCases::test_allow_harmful_protocols", + "tests/test_misc.py::TestMiscCases::test_ast_output", + "tests/test_misc.py::TestMiscCases::test_ast_url", + "tests/test_misc.py::TestMiscCases::test_before_parse_hooks", + "tests/test_misc.py::TestMiscCases::test_emsp", + "tests/test_misc.py::TestMiscCases::test_escape_html", + "tests/test_misc.py::TestMiscCases::test_hard_wrap", + "tests/test_misc.py::TestMiscCases::test_harmful_links", + "tests/test_misc.py::TestMiscCases::test_html_tag_text_following_list", + "tests/test_misc.py::TestMiscCases::test_markdown_func", + "tests/test_misc.py::TestMiscCases::test_none", + "tests/test_misc.py::TestMiscCases::test_ref_link", + "tests/test_misc.py::TestMiscCases::test_use_plugin", + "tests/test_plugins.py::TestPlugin1_url::test_url_plugin_001", + "tests/test_plugins.py::TestPlugin1_url::test_url_plugin_002", + "tests/test_plugins.py::TestPlugin1_url::test_url_plugin_003", + "tests/test_plugins.py::TestPlugin2_url::test_url_plugin_001", + "tests/test_plugins.py::TestPlugin2_url::test_url_plugin_002", + "tests/test_plugins.py::TestPlugin2_url::test_url_plugin_003", + "tests/test_plugins.py::TestPlugin1_strikethrough::test_strikethrough_001", + "tests/test_plugins.py::TestPlugin1_strikethrough::test_strikethrough_002", + "tests/test_plugins.py::TestPlugin1_strikethrough::test_strikethrough_003", + "tests/test_plugins.py::TestPlugin1_strikethrough::test_strikethrough_004", + "tests/test_plugins.py::TestPlugin1_strikethrough::test_strikethrough_005", + "tests/test_plugins.py::TestPlugin1_strikethrough::test_strikethrough_006", + "tests/test_plugins.py::TestPlugin1_strikethrough::test_strikethrough_007", + "tests/test_plugins.py::TestPlugin2_strikethrough::test_strikethrough_001", + "tests/test_plugins.py::TestPlugin2_strikethrough::test_strikethrough_002", + "tests/test_plugins.py::TestPlugin2_strikethrough::test_strikethrough_003", + "tests/test_plugins.py::TestPlugin2_strikethrough::test_strikethrough_004", + "tests/test_plugins.py::TestPlugin2_strikethrough::test_strikethrough_005", + "tests/test_plugins.py::TestPlugin2_strikethrough::test_strikethrough_006", + "tests/test_plugins.py::TestPlugin2_strikethrough::test_strikethrough_007", + "tests/test_plugins.py::TestPlugin1_mark::test_escape_mark_001", + "tests/test_plugins.py::TestPlugin1_mark::test_escape_mark_002", + "tests/test_plugins.py::TestPlugin1_mark::test_mark_001", + "tests/test_plugins.py::TestPlugin1_mark::test_mark_link_001", + "tests/test_plugins.py::TestPlugin1_mark::test_mark_link_002", + "tests/test_plugins.py::TestPlugin1_mark::test_normal_mark_001", + "tests/test_plugins.py::TestPlugin1_mark::test_normal_mark_002", + "tests/test_plugins.py::TestPlugin1_mark::test_normal_mark_003", + "tests/test_plugins.py::TestPlugin1_mark::test_normal_mark_004", + "tests/test_plugins.py::TestPlugin2_mark::test_escape_mark_001", + "tests/test_plugins.py::TestPlugin2_mark::test_escape_mark_002", + "tests/test_plugins.py::TestPlugin2_mark::test_mark_001", + "tests/test_plugins.py::TestPlugin2_mark::test_mark_link_001", + "tests/test_plugins.py::TestPlugin2_mark::test_mark_link_002", + "tests/test_plugins.py::TestPlugin2_mark::test_normal_mark_001", + "tests/test_plugins.py::TestPlugin2_mark::test_normal_mark_002", + "tests/test_plugins.py::TestPlugin2_mark::test_normal_mark_003", + "tests/test_plugins.py::TestPlugin2_mark::test_normal_mark_004", + "tests/test_plugins.py::TestPlugin1_insert::test_escape_insert_001", + "tests/test_plugins.py::TestPlugin1_insert::test_escape_insert_002", + "tests/test_plugins.py::TestPlugin1_insert::test_insert_001", + "tests/test_plugins.py::TestPlugin1_insert::test_insert_link_001", + "tests/test_plugins.py::TestPlugin1_insert::test_insert_link_002", + "tests/test_plugins.py::TestPlugin1_insert::test_normal_insert_001", + "tests/test_plugins.py::TestPlugin1_insert::test_normal_insert_002", + "tests/test_plugins.py::TestPlugin1_insert::test_normal_insert_003", + "tests/test_plugins.py::TestPlugin1_insert::test_normal_insert_004", + "tests/test_plugins.py::TestPlugin2_insert::test_escape_insert_001", + "tests/test_plugins.py::TestPlugin2_insert::test_escape_insert_002", + "tests/test_plugins.py::TestPlugin2_insert::test_insert_001", + "tests/test_plugins.py::TestPlugin2_insert::test_insert_link_001", + "tests/test_plugins.py::TestPlugin2_insert::test_insert_link_002", + "tests/test_plugins.py::TestPlugin2_insert::test_normal_insert_001", + "tests/test_plugins.py::TestPlugin2_insert::test_normal_insert_002", + "tests/test_plugins.py::TestPlugin2_insert::test_normal_insert_003", + "tests/test_plugins.py::TestPlugin2_insert::test_normal_insert_004", + "tests/test_plugins.py::TestPlugin1_superscript::test_superscript_001", + "tests/test_plugins.py::TestPlugin1_superscript::test_superscript_002", + "tests/test_plugins.py::TestPlugin1_superscript::test_superscript_003", + "tests/test_plugins.py::TestPlugin1_superscript::test_superscript_004", + "tests/test_plugins.py::TestPlugin2_superscript::test_superscript_001", + "tests/test_plugins.py::TestPlugin2_superscript::test_superscript_002", + "tests/test_plugins.py::TestPlugin2_superscript::test_superscript_003", + "tests/test_plugins.py::TestPlugin2_superscript::test_superscript_004", + "tests/test_plugins.py::TestPlugin1_subscript::test_subscript_001", + "tests/test_plugins.py::TestPlugin1_subscript::test_subscript_002", + "tests/test_plugins.py::TestPlugin1_subscript::test_subscript_003", + "tests/test_plugins.py::TestPlugin1_subscript::test_subscript_004", + "tests/test_plugins.py::TestPlugin2_subscript::test_subscript_001", + "tests/test_plugins.py::TestPlugin2_subscript::test_subscript_002", + "tests/test_plugins.py::TestPlugin2_subscript::test_subscript_003", + "tests/test_plugins.py::TestPlugin2_subscript::test_subscript_004", + "tests/test_plugins.py::TestPlugin1_task_lists::test_task_lists_001", + "tests/test_plugins.py::TestPlugin1_task_lists::test_task_lists_002", + "tests/test_plugins.py::TestPlugin1_task_lists::test_task_lists_003", + "tests/test_plugins.py::TestPlugin1_task_lists::test_task_lists_004", + "tests/test_plugins.py::TestPlugin1_task_lists::test_task_lists_005", + "tests/test_plugins.py::TestPlugin1_task_lists::test_task_lists_006", + "tests/test_plugins.py::TestPlugin1_task_lists::test_task_lists_007", + "tests/test_plugins.py::TestPlugin1_task_lists::test_task_lists_008", + "tests/test_plugins.py::TestPlugin2_task_lists::test_task_lists_001", + "tests/test_plugins.py::TestPlugin2_task_lists::test_task_lists_002", + "tests/test_plugins.py::TestPlugin2_task_lists::test_task_lists_003", + "tests/test_plugins.py::TestPlugin2_task_lists::test_task_lists_004", + "tests/test_plugins.py::TestPlugin2_task_lists::test_task_lists_005", + "tests/test_plugins.py::TestPlugin2_task_lists::test_task_lists_006", + "tests/test_plugins.py::TestPlugin2_task_lists::test_task_lists_007", + "tests/test_plugins.py::TestPlugin2_task_lists::test_task_lists_008", + "tests/test_plugins.py::TestPlugin1_table::test_align_table_001", + "tests/test_plugins.py::TestPlugin1_table::test_align_table_002", + "tests/test_plugins.py::TestPlugin1_table::test_misc_table_001", + "tests/test_plugins.py::TestPlugin1_table::test_misc_table_002", + "tests/test_plugins.py::TestPlugin1_table::test_misc_table_003", + "tests/test_plugins.py::TestPlugin1_table::test_mismatch_length_001", + "tests/test_plugins.py::TestPlugin1_table::test_mismatch_length_002", + "tests/test_plugins.py::TestPlugin1_table::test_mismatch_length_003", + "tests/test_plugins.py::TestPlugin1_table::test_mismatch_length_004", + "tests/test_plugins.py::TestPlugin1_table::test_nptable_001", + "tests/test_plugins.py::TestPlugin1_table::test_table_001", + "tests/test_plugins.py::TestPlugin1_table::test_table_002", + "tests/test_plugins.py::TestPlugin2_table::test_align_table_001", + "tests/test_plugins.py::TestPlugin2_table::test_align_table_002", + "tests/test_plugins.py::TestPlugin2_table::test_misc_table_001", + "tests/test_plugins.py::TestPlugin2_table::test_misc_table_002", + "tests/test_plugins.py::TestPlugin2_table::test_misc_table_003", + "tests/test_plugins.py::TestPlugin2_table::test_mismatch_length_001", + "tests/test_plugins.py::TestPlugin2_table::test_mismatch_length_002", + "tests/test_plugins.py::TestPlugin2_table::test_mismatch_length_003", + "tests/test_plugins.py::TestPlugin2_table::test_mismatch_length_004", + "tests/test_plugins.py::TestPlugin2_table::test_nptable_001", + "tests/test_plugins.py::TestPlugin2_table::test_table_001", + "tests/test_plugins.py::TestPlugin2_table::test_table_002", + "tests/test_plugins.py::TestPlugin1_def_list::test_definition_lists_001", + "tests/test_plugins.py::TestPlugin1_def_list::test_definition_lists_002", + "tests/test_plugins.py::TestPlugin1_def_list::test_definition_lists_003", + "tests/test_plugins.py::TestPlugin1_def_list::test_definition_lists_004", + "tests/test_plugins.py::TestPlugin1_def_list::test_definition_lists_005", + "tests/test_plugins.py::TestPlugin1_def_list::test_definition_lists_006", + "tests/test_plugins.py::TestPlugin1_def_list::test_definition_with_multiple_lines_001", + "tests/test_plugins.py::TestPlugin1_def_list::test_definition_with_multiple_lines_002", + "tests/test_plugins.py::TestPlugin1_def_list::test_definition_with_multiple_lines_003", + "tests/test_plugins.py::TestPlugin1_def_list::test_definition_with_multiple_lines_004", + "tests/test_plugins.py::TestPlugin1_def_list::test_definition_with_multiple_lines_005", + "tests/test_plugins.py::TestPlugin2_def_list::test_definition_lists_001", + "tests/test_plugins.py::TestPlugin2_def_list::test_definition_lists_002", + "tests/test_plugins.py::TestPlugin2_def_list::test_definition_lists_003", + "tests/test_plugins.py::TestPlugin2_def_list::test_definition_lists_004", + "tests/test_plugins.py::TestPlugin2_def_list::test_definition_lists_005", + "tests/test_plugins.py::TestPlugin2_def_list::test_definition_lists_006", + "tests/test_plugins.py::TestPlugin2_def_list::test_definition_with_multiple_lines_001", + "tests/test_plugins.py::TestPlugin2_def_list::test_definition_with_multiple_lines_002", + "tests/test_plugins.py::TestPlugin2_def_list::test_definition_with_multiple_lines_003", + "tests/test_plugins.py::TestPlugin2_def_list::test_definition_with_multiple_lines_004", + "tests/test_plugins.py::TestPlugin2_def_list::test_definition_with_multiple_lines_005", + "tests/test_plugins.py::TestPlugin1_footnotes::test_footnotes_001", + "tests/test_plugins.py::TestPlugin2_footnotes::test_footnotes_001", + "tests/test_plugins.py::TestPlugin1_abbr::test_abbreviation_001", + "tests/test_plugins.py::TestPlugin1_abbr::test_abbreviation_002", + "tests/test_plugins.py::TestPlugin1_abbr::test_abbreviation_003", + "tests/test_plugins.py::TestPlugin1_abbr::test_abbreviation_004", + "tests/test_plugins.py::TestPlugin1_abbr::test_abbreviation_005", + "tests/test_plugins.py::TestPlugin1_abbr::test_abbreviation_006", + "tests/test_plugins.py::TestPlugin1_abbr::test_abbreviation_007", + "tests/test_plugins.py::TestPlugin1_abbr::test_abbreviation_008", + "tests/test_plugins.py::TestPlugin1_abbr::test_abbreviation_009", + "tests/test_plugins.py::TestPlugin1_abbr::test_abbreviation_010", + "tests/test_plugins.py::TestPlugin2_abbr::test_abbreviation_001", + "tests/test_plugins.py::TestPlugin2_abbr::test_abbreviation_002", + "tests/test_plugins.py::TestPlugin2_abbr::test_abbreviation_003", + "tests/test_plugins.py::TestPlugin2_abbr::test_abbreviation_004", + "tests/test_plugins.py::TestPlugin2_abbr::test_abbreviation_005", + "tests/test_plugins.py::TestPlugin2_abbr::test_abbreviation_006", + "tests/test_plugins.py::TestPlugin2_abbr::test_abbreviation_007", + "tests/test_plugins.py::TestPlugin2_abbr::test_abbreviation_008", + "tests/test_plugins.py::TestPlugin2_abbr::test_abbreviation_009", + "tests/test_plugins.py::TestPlugin2_abbr::test_abbreviation_010", + "tests/test_plugins.py::TestPlugin1_math::test_block_math_001", + "tests/test_plugins.py::TestPlugin1_math::test_block_math_002", + "tests/test_plugins.py::TestPlugin1_math::test_block_math_003", + "tests/test_plugins.py::TestPlugin1_math::test_block_math_004", + "tests/test_plugins.py::TestPlugin1_math::test_inline_math_001", + "tests/test_plugins.py::TestPlugin2_math::test_block_math_001", + "tests/test_plugins.py::TestPlugin2_math::test_block_math_002", + "tests/test_plugins.py::TestPlugin2_math::test_block_math_003", + "tests/test_plugins.py::TestPlugin2_math::test_block_math_004", + "tests/test_plugins.py::TestPlugin2_math::test_inline_math_001", + "tests/test_plugins.py::TestPlugin1_ruby::test_ruby_splits_001", + "tests/test_plugins.py::TestPlugin1_ruby::test_ruby_splits_002", + "tests/test_plugins.py::TestPlugin1_ruby::test_ruby_with_link_001", + "tests/test_plugins.py::TestPlugin1_ruby::test_ruby_with_link_002", + "tests/test_plugins.py::TestPlugin1_ruby::test_ruby_with_link_003", + "tests/test_plugins.py::TestPlugin1_ruby::test_ruby_without_link_001", + "tests/test_plugins.py::TestPlugin1_ruby::test_ruby_without_link_002", + "tests/test_plugins.py::TestPlugin1_ruby::test_ruby_without_link_003", + "tests/test_plugins.py::TestPlugin1_ruby::test_ruby_without_link_004", + "tests/test_plugins.py::TestPlugin2_ruby::test_ruby_splits_001", + "tests/test_plugins.py::TestPlugin2_ruby::test_ruby_splits_002", + "tests/test_plugins.py::TestPlugin2_ruby::test_ruby_with_link_001", + "tests/test_plugins.py::TestPlugin2_ruby::test_ruby_with_link_002", + "tests/test_plugins.py::TestPlugin2_ruby::test_ruby_with_link_003", + "tests/test_plugins.py::TestPlugin2_ruby::test_ruby_without_link_001", + "tests/test_plugins.py::TestPlugin2_ruby::test_ruby_without_link_002", + "tests/test_plugins.py::TestPlugin2_ruby::test_ruby_without_link_003", + "tests/test_plugins.py::TestPlugin2_ruby::test_ruby_without_link_004", + "tests/test_plugins.py::TestPlugin1_spoiler::test_block_spoiler_001", + "tests/test_plugins.py::TestPlugin1_spoiler::test_block_spoiler_002", + "tests/test_plugins.py::TestPlugin1_spoiler::test_block_spoiler_003", + "tests/test_plugins.py::TestPlugin1_spoiler::test_block_spoiler_004", + "tests/test_plugins.py::TestPlugin1_spoiler::test_block_spoiler_005", + "tests/test_plugins.py::TestPlugin1_spoiler::test_inline_spoiler_001", + "tests/test_plugins.py::TestPlugin1_spoiler::test_inline_spoiler_002", + "tests/test_plugins.py::TestPlugin1_spoiler::test_inline_spoiler_003", + "tests/test_plugins.py::TestPlugin2_spoiler::test_block_spoiler_001", + "tests/test_plugins.py::TestPlugin2_spoiler::test_block_spoiler_002", + "tests/test_plugins.py::TestPlugin2_spoiler::test_block_spoiler_003", + "tests/test_plugins.py::TestPlugin2_spoiler::test_block_spoiler_004", + "tests/test_plugins.py::TestPlugin2_spoiler::test_block_spoiler_005", + "tests/test_plugins.py::TestPlugin2_spoiler::test_inline_spoiler_001", + "tests/test_plugins.py::TestPlugin2_spoiler::test_inline_spoiler_002", + "tests/test_plugins.py::TestPlugin2_spoiler::test_inline_spoiler_003", + "tests/test_plugins.py::TestExtraPlugins::test_math_in_list", + "tests/test_plugins.py::TestExtraPlugins::test_math_in_quote", + "tests/test_plugins.py::TestExtraPlugins::test_table_in_list", + "tests/test_plugins.py::TestExtraPlugins::test_table_in_quote", + "tests/test_renderers.py::TestRendererRst::test_code_001", + "tests/test_renderers.py::TestRendererRst::test_code_002", + "tests/test_renderers.py::TestRendererRst::test_heading_001", + "tests/test_renderers.py::TestRendererRst::test_html_001", + "tests/test_renderers.py::TestRendererRst::test_images_001", + "tests/test_renderers.py::TestRendererRst::test_images_002", + "tests/test_renderers.py::TestRendererRst::test_images_003", + "tests/test_renderers.py::TestRendererRst::test_inline_001", + "tests/test_renderers.py::TestRendererRst::test_inline_002", + "tests/test_renderers.py::TestRendererRst::test_line_break_001", + "tests/test_renderers.py::TestRendererRst::test_links_001", + "tests/test_renderers.py::TestRendererRst::test_list_001", + "tests/test_renderers.py::TestRendererRst::test_list_002", + "tests/test_renderers.py::TestRendererRst::test_list_003", + "tests/test_renderers.py::TestRendererRst::test_list_004", + "tests/test_renderers.py::TestRendererRst::test_list_005", + "tests/test_renderers.py::TestRendererRst::test_quote_001", + "tests/test_renderers.py::TestRendererRst::test_quote_002", + "tests/test_renderers.py::TestRendererRst::test_quote_003", + "tests/test_renderers.py::TestRendererRst::test_thematic_break_001", + "tests/test_renderers.py::TestRendererMarkdown::test_code_001", + "tests/test_renderers.py::TestRendererMarkdown::test_code_002", + "tests/test_renderers.py::TestRendererMarkdown::test_code_003", + "tests/test_renderers.py::TestRendererMarkdown::test_code_004", + "tests/test_renderers.py::TestRendererMarkdown::test_code_005", + "tests/test_renderers.py::TestRendererMarkdown::test_heading_001", + "tests/test_renderers.py::TestRendererMarkdown::test_html_001", + "tests/test_renderers.py::TestRendererMarkdown::test_images_001", + "tests/test_renderers.py::TestRendererMarkdown::test_inline_001", + "tests/test_renderers.py::TestRendererMarkdown::test_linebreak_001", + "tests/test_renderers.py::TestRendererMarkdown::test_links_001", + "tests/test_renderers.py::TestRendererMarkdown::test_links_002", + "tests/test_renderers.py::TestRendererMarkdown::test_links_003", + "tests/test_renderers.py::TestRendererMarkdown::test_list_001", + "tests/test_renderers.py::TestRendererMarkdown::test_list_002", + "tests/test_renderers.py::TestRendererMarkdown::test_list_003", + "tests/test_renderers.py::TestRendererMarkdown::test_list_004", + "tests/test_renderers.py::TestRendererMarkdown::test_list_005", + "tests/test_renderers.py::TestRendererMarkdown::test_list_006", + "tests/test_renderers.py::TestRendererMarkdown::test_quote_001", + "tests/test_renderers.py::TestRendererMarkdown::test_quote_002", + "tests/test_renderers.py::TestRendererMarkdown::test_thematic_break_001", + "tests/test_syntax.py::TestSyntax::test_emphasis_001", + "tests/test_syntax.py::TestSyntax::test_image_001", + "tests/test_syntax.py::TestSyntax::test_link_001", + "tests/test_syntax.py::TestSyntax::test_link_002", + "tests/test_syntax.py::TestSyntax::test_link_003", + "tests/test_syntax.py::TestSyntax::test_links_001", + "tests/test_syntax.py::TestSyntax::test_links_002", + "tests/test_syntax.py::TestSyntax::test_max_depth_001", + "tests/test_syntax.py::TestSyntax::test_max_depth_002", + "tests/test_syntax.py::TestSyntax::test_non_aggressive_emphasis_001", + "tests/test_syntax.py::TestSyntax::test_non_aggressive_emphasis_002", + "tests/test_syntax.py::TestSyntax::test_non_aggressive_emphasis_003", + "tests/test_syntax.py::TestSyntax::test_setext_headings_001", + "tests/test_syntax.py::TestSyntax::test_setext_headings_002" + ] +} diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/grade.py b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/grade.py new file mode 100644 index 0000000000000000000000000000000000000000..e3b37293830e51a5c5833c93c4705e1ed9364257 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/grade.py @@ -0,0 +1,128 @@ +"""Trusted private pytest panel runner. Installed only in a fresh grader Job.""" + +import hashlib +import importlib.util +import json +import os +import shutil +import stat +import subprocess +from pathlib import Path, PurePosixPath + + +def sha(raw): + return hashlib.sha256(raw).hexdigest() + + +def safe(value): + path = PurePosixPath(value) + if ( + path.is_absolute() + or path.as_posix() != value + or not path.parts + or any(part in {".", "..", ".git"} for part in path.parts) + ): + raise ValueError("Unsafe trusted test path") + return path + + +def restore(worktree, private, manifest): + worktree, private = Path(worktree), Path(private) + captured = {} + for name, expected in manifest["files"].items(): + path = private / safe(name) + info = path.lstat() + raw = path.read_bytes() if stat.S_ISREG(info.st_mode) else b"" + if ( + not stat.S_ISREG(info.st_mode) + or len(raw) != expected["bytes"] + or sha(raw) != expected["sha256"] + or stat.S_IMODE(info.st_mode) != expected["mode"] + ): + raise ValueError("Trusted private test bytes or modes drifted") + captured[name] = (raw, expected["mode"]) + # Capture and verify every private byte before changing the submitted tree. + for name in manifest["directory_roots"]: + destination = worktree / safe(name) + if destination.is_symlink(): + raise ValueError("Submitted test directory is a symlink") + for parent in destination.parents: + if parent == worktree: + break + if parent.is_symlink(): + raise ValueError("Submitted test parent is a symlink") + if destination.exists(): + if not destination.is_dir(): + raise ValueError("Submitted test directory is not a directory") + shutil.rmtree(destination) + for name, (raw, mode) in captured.items(): + destination = worktree / safe(name) + for parent in destination.parents: + if parent == worktree: + break + if parent.is_symlink(): + raise ValueError("Submitted test parent is a symlink") + if destination.is_symlink(): + raise ValueError("Submitted trusted file is a symlink") + destination.parent.mkdir(parents=True, exist_ok=True) + destination.write_bytes(raw) + destination.chmod(mode) + + +def run(worktree, private_root, output, invoke=None): + private_root, output, worktree = Path(private_root), Path(output), Path(worktree) + expected = json.loads((private_root / "expected-panels.json").read_bytes()) + config = json.loads((private_root / "panel-config.json").read_bytes()) + manifest = json.loads((private_root / "trusted-inventory.json").read_bytes()) + restore(worktree, private_root / "trusted", manifest) + output.mkdir(parents=True, exist_ok=True) + for name in ( + "reward.txt", + "pass-to-pass.xml", + "fail-to-pass.xml", + "pytest-evidence.json", + ): + (output / name).unlink(missing_ok=True) + environment = dict(os.environ) + for key in ("PYTEST_ADDOPTS", "PYTEST_DISABLE_PLUGIN_AUTOLOAD", "PYTHONPATH"): + environment.pop(key, None) + commands, native_exit = [], 0 + invoke = invoke or subprocess.run + for group in ("pass-to-pass", "fail-to-pass"): + if ( + not isinstance(expected[group], list) + or not expected[group] + or any( + not isinstance(target, str) or not target for target in expected[group] + ) + ): + raise ValueError("Frozen native pytest selectors are incomplete") + command = [ + *config["official_pytest_argv"], + "--override-ini=addopts=", + "--junitxml=" + str(output / (group + ".xml")), + *expected[group], + ] + result = invoke(command, cwd=worktree, env=environment, check=False) + native_exit = result.returncode + commands.append({"group": group, "argv": command, "exit_code": native_exit}) + if native_exit != 0: + break + (output / "pytest-commands.json").write_text( + json.dumps(commands, sort_keys=True) + "\n" + ) + spec = importlib.util.spec_from_file_location( + "trusted_pytest_result", private_root / "check_pytest.py" + ) + checker = importlib.util.module_from_spec(spec) + spec.loader.exec_module(checker) + result = checker.assess(output, expected, native_exit) + (output / "reward.txt").write_text(str(result["reward"]) + "\n") + (output / "pytest-evidence.json").write_text( + json.dumps(result, sort_keys=True) + "\n" + ) + return result + + +if __name__ == "__main__": + run("/testbed/repo", "/tests", "/logs/verifier") diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/panel-config.json b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/panel-config.json new file mode 100644 index 0000000000000000000000000000000000000000..fcf9afd120808ef57ca8e15a2ff5adfbb1b9b425 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/panel-config.json @@ -0,0 +1,24 @@ +{ + "dependency_installation_pinned": false, + "official_install_cmds": [ + "python -m pip install -e ." + ], + "official_pytest_argv": [ + "pytest", + "--disable-warnings", + "--color=no", + "--tb=no", + "--verbose" + ], + "official_test_command": "source /opt/miniconda3/bin/activate; conda activate testbed; pytest --disable-warnings --color=no --tb=no --verbose", + "operator_test_runner_prerequisites": [ + "python -m pip install pytest==8.4.2" + ], + "operator_test_runner_reason": "The official profile invokes pytest, but the common tools runtime does not provide it; pinned separately from source-native project requirements.", + "panel_normalization": "Override project addopts only to execute the exact frozen native panels; add JUnit output, preserve official pytest options and all selectors.", + "python_version": "3.10", + "source_bound_test_dependency_cmds": [], + "test_dependency_source_sha256": { + "pyproject.toml": "b2922e3ef89e2918935d38fb3a777bdbc741619942276a75fd21a8dd9faf6b42" + } +} diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/test.sh b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..81b6d0620f05dbd3b54b4e7ea5de04ce3f8a98e2 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/test.sh @@ -0,0 +1,6 @@ +#!/bin/bash +set -Eeuo pipefail +source /opt/miniconda3/bin/activate +conda activate testbed +cd /testbed/repo +exec python -I /tests/grade.py diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted-inventory.json b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted-inventory.json new file mode 100644 index 0000000000000000000000000000000000000000..aa70e1f5d5d129ced763ef7db40f73f94595e1e2 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted-inventory.json @@ -0,0 +1,212 @@ +{ + "directory_roots": [ + "tests" + ], + "files": { + "pyproject.toml": { + "bytes": 1781, + "mode": 420, + "sha256": "b2922e3ef89e2918935d38fb3a777bdbc741619942276a75fd21a8dd9faf6b42" + }, + "setup.py": { + "bytes": 52, + "mode": 420, + "sha256": "504f5c8cbb3b966b1f3f838da0a0cdc77b312f0c5935951357d17328e5324e21" + }, + "tests/__init__.py": { + "bytes": 1149, + "mode": 420, + "sha256": "229cc35ee9a5f5a9fb37e036683e2276f940b80df2dc6203102c0f36f960e467" + }, + "tests/fixtures/__init__.py": { + "bytes": 1502, + "mode": 420, + "sha256": "960fa58f01c3a473a956cc2d5430314d10f070bff18b35c9707c52c1c42a57e2" + }, + "tests/fixtures/abbr.txt": { + "bytes": 2703, + "mode": 420, + "sha256": "18c7e06359486daeaafa88c7404f4ca8248cd47bf38a7ed475ddd35353e68bea" + }, + "tests/fixtures/commonmark.json": { + "bytes": 140423, + "mode": 420, + "sha256": "ae6129f3ce3caf4f99cf4f9a5ad3558a309652b5b887171013e2bf0797289b98" + }, + "tests/fixtures/def_list.txt": { + "bytes": 2834, + "mode": 420, + "sha256": "909b7156a5ba1f005ea3d8a203946e7ab3576149ec5af73ecad657bb046f386d" + }, + "tests/fixtures/diff-commonmark.txt": { + "bytes": 1176, + "mode": 420, + "sha256": "920df6e3c9c8e3d4627842d5a7aeb172bdd23229acfbbb9a9b728a9f6ce2c1f0" + }, + "tests/fixtures/fenced_admonition.txt": { + "bytes": 2344, + "mode": 420, + "sha256": "0f231afd472bc2c742170798e619d1baa5dd34e9e4a6cb18906dabd1aa37a1d0" + }, + "tests/fixtures/fenced_figure.txt": { + "bytes": 3481, + "mode": 420, + "sha256": "83c3d636e8d4f0dd5a767045cf38877fd3c6c03a20c351f06c50e30ae7f30cda" + }, + "tests/fixtures/fenced_image.txt": { + "bytes": 2343, + "mode": 420, + "sha256": "fa7ede5a90b718aaeb46af7f5a4d98a0e17cec0411355f460a166356020e6780" + }, + "tests/fixtures/fenced_toc.txt": { + "bytes": 3656, + "mode": 420, + "sha256": "019a12ca2e293699d88241460bdea48ee6a65981b36b6bae4c0bbf78f020a296" + }, + "tests/fixtures/fix-commonmark.txt": { + "bytes": 1905, + "mode": 420, + "sha256": "1f2777b457f4da70e02983bbcb2104fa3b442dbb8a5bcac1621499b0b796292f" + }, + "tests/fixtures/footnotes.txt": { + "bytes": 847, + "mode": 420, + "sha256": "55227ab43a3986fd07ecbf0742903a977f04cd9ed403086d7c76f23b1967aab1" + }, + "tests/fixtures/hook_toc.txt": { + "bytes": 1896, + "mode": 420, + "sha256": "bdb1a5c90f08cb29c4eed3c892e9c694f92855507b6cd5809eac3b8eb4fc7dc5" + }, + "tests/fixtures/include/hello.md": { + "bytes": 8, + "mode": 420, + "sha256": "389aaf8f17da55ef35fedf530bc70cd1287042f6410ec94c2b44c1b22c36e60a" + }, + "tests/fixtures/include/hello.txt": { + "bytes": 6, + "mode": 420, + "sha256": "5891b5b522d5df086d0ff0b110fbd9d21bb4fc7163af34d08286a2e846f6be03" + }, + "tests/fixtures/include/text.html": { + "bytes": 24, + "mode": 420, + "sha256": "bac2f8a2e3937f8923da8e560248d2a52867b502fbda531ba73f1d066b35d2ba" + }, + "tests/fixtures/include/text.md": { + "bytes": 163, + "mode": 420, + "sha256": "3ffb497b2829ca6333bc6eb4e7d2959aa7baeaa44180225a4820e0051ae7ef75" + }, + "tests/fixtures/insert.txt": { + "bytes": 1165, + "mode": 420, + "sha256": "de7b89a58c2cbd2d4948c10b8c599fd7500b3ae6734d271a35ff2cf2854b1572" + }, + "tests/fixtures/mark.txt": { + "bytes": 1138, + "mode": 420, + "sha256": "6b5c232cf89f61097ae6d032865a99bdcd9f65e3ef99517d9423b2da0aa983d0" + }, + "tests/fixtures/math.txt": { + "bytes": 1174, + "mode": 420, + "sha256": "eadc29b04cc85928e50003b2908b002a778447ef028c4b773ca1753b907fd898" + }, + "tests/fixtures/renderer_markdown.txt": { + "bytes": 3569, + "mode": 420, + "sha256": "2ba5fc55634d7dbaabd91aedea9e04b34882e67abc3020034bd809a408cac2a7" + }, + "tests/fixtures/renderer_rst.txt": { + "bytes": 2915, + "mode": 420, + "sha256": "47007bc353f230e9b73d8604548539bb16374a4b837bf7ba8d2f478444fff84e" + }, + "tests/fixtures/rst_admonition.txt": { + "bytes": 848, + "mode": 420, + "sha256": "821676f07a4e595c51c84da87edc592e22e8bbed6241e070040d87a4de7c5d7e" + }, + "tests/fixtures/rst_toc.txt": { + "bytes": 3643, + "mode": 420, + "sha256": "f9ae334cef85d776c37d7ad029e1e38d9e1b035423ab624dab8499aff28f7e98" + }, + "tests/fixtures/ruby.txt": { + "bytes": 1773, + "mode": 420, + "sha256": "1302542447ac0befc2618d9c2da1657581fcc1d90c332896e6dc086b698e30ed" + }, + "tests/fixtures/spoiler.txt": { + "bytes": 1154, + "mode": 420, + "sha256": "21446f2e88b70cc3c50e606c36fbcdf567993581ccf8397ace5948973c251985" + }, + "tests/fixtures/strikethrough.txt": { + "bytes": 886, + "mode": 420, + "sha256": "fee85a2207da74bdcf437c2c58804b009b657b4dfd505989fdbee46f78feac07" + }, + "tests/fixtures/subscript.txt": { + "bytes": 521, + "mode": 420, + "sha256": "61fd94b4718edbbfaa782533f659f4f193585fb09e61761a662cd313906932b8" + }, + "tests/fixtures/superscript.txt": { + "bytes": 523, + "mode": 420, + "sha256": "658ac752d95d74e6e97e7daceba6f48ef279dc6f1389a878610bc608e82f34b3" + }, + "tests/fixtures/table.txt": { + "bytes": 4134, + "mode": 420, + "sha256": "f92d66b63d00f95f7a9938cb6e0e42ea4968d6e9f1f62e902b63bc1be69f51b6" + }, + "tests/fixtures/task_lists.txt": { + "bytes": 3104, + "mode": 420, + "sha256": "d17a07a9cb077dd25c3b4c4dd7301bc9f508ab75ec83c2293b0ebaca954be76c" + }, + "tests/fixtures/url.txt": { + "bytes": 530, + "mode": 420, + "sha256": "441ea5e1e27f6edcd52b51f8c20ca1eee8b76d4adcc3b2fcdd419448c528ef21" + }, + "tests/test_commonmark.py": { + "bytes": 2199, + "mode": 420, + "sha256": "77396377672a8419ecab283aebf55a5e206b1aa413626975dc8b2a006c796973" + }, + "tests/test_directives.py": { + "bytes": 2954, + "mode": 420, + "sha256": "3d46db4f9e52d3067954ab7fcaba80ef855008a516a86ee3baf07b2a9c730817" + }, + "tests/test_hooks.py": { + "bytes": 729, + "mode": 420, + "sha256": "9d6f177c6dd52223ac44e31508ed66bbc2b6fc7a4725ed7121fb39842b0a6a61" + }, + "tests/test_misc.py": { + "bytes": 4830, + "mode": 420, + "sha256": "a1bba411b7b74f1b9d43bf88459db1d9fa2c13e7db32dfee707c93cd8ccb5575" + }, + "tests/test_plugins.py": { + "bytes": 2280, + "mode": 420, + "sha256": "56a6731c5e5667870122edfb3d49925a34dc394ae00ce3282dc3e89cbe2fd6b8" + }, + "tests/test_renderers.py": { + "bytes": 500, + "mode": 420, + "sha256": "efc0fa48c74f8ee1b84c961e4ca034eb5f0246b69b4663428c93cc77d471e7b8" + }, + "tests/test_syntax.py": { + "bytes": 342, + "mode": 420, + "sha256": "88f99c6afc5f39f088c0cd1cdf4fab8a69b60b208a1b28924eeb8fbd0d7bef2e" + } + } +} diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/pyproject.toml b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/pyproject.toml new file mode 100644 index 0000000000000000000000000000000000000000..2d95f9b3bd4ee9817157eab051c5277fb0a3846f --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/pyproject.toml @@ -0,0 +1,69 @@ +[project] +name = "mistune" +description = "A sane and fast Markdown parser with useful plugins and renderers" +authors = [{name = "Hsiaoming Yang", email="me@lepture.com"}] +dependencies = [ + "typing-extensions; python_version<'3.11'", +] +license = {text = "BSD-3-Clause"} +dynamic = ["version"] +requires-python = ">=3.8" +readme = "README.rst" +classifiers = [ + "Development Status :: 4 - Beta", + "Environment :: Console", + "Environment :: Web Environment", + "Intended Audience :: Developers", + "License :: OSI Approved :: BSD License", + "Operating System :: OS Independent", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: Implementation :: CPython", + "Programming Language :: Python :: Implementation :: PyPy", + "Topic :: Text Processing :: Markup", +] + +[project.urls] +Documentation = "https://mistune.lepture.com/" +Source = "https://github.com/lepture/mistune" +Donate = "https://github.com/sponsors/lepture" + +[build-system] +requires = ["setuptools"] +build-backend = "setuptools.build_meta" + +[tool.setuptools.dynamic] +version = {attr = "mistune.__version__"} + +[tool.setuptools.packages.find] +where = ["src"] + +[tool.setuptools.package-data] +mistune = ["py.typed"] + +[tool.ruff] +line-length = 120 + +[tool.pytest.ini_options] +pythonpath = ["src", "."] +testpaths = ["tests"] +filterwarnings = ["error"] + +[tool.coverage.run] +branch = true +source = ["mistune"] + +[tool.coverage.paths] +source = ["src"] + +[tool.coverage.report] +exclude_lines = [ + "pragma: no cover", + "def __repr__", + "raise NotImplementedError", + "@(abc\\.)?abstractmethod", +] diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/setup.py b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/setup.py new file mode 100644 index 0000000000000000000000000000000000000000..af8a0fc50e9db1a27585118393965a8c87e19129 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/setup.py @@ -0,0 +1,3 @@ +from setuptools import setup + +setup(name="mistune") diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/__init__.py b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..b715104d1f96221038f7c9060d66b4bc6a5bdda2 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/__init__.py @@ -0,0 +1,40 @@ +import re +from abc import abstractmethod +from unittest import TestCase + +from tests import fixtures + + +class BaseTestCase(TestCase): + @classmethod + def load_fixtures(cls, case_file: str) -> None: + def attach_case(n: str, text: str, html: str) -> None: + def method(self: 'BaseTestCase') -> None: + self.assert_case(n, text, html) + + name = 'test_{}'.format(n) + method.__name__ = name + method.__doc__ = 'Run fixture {} - {}'.format(case_file, n) + setattr(cls, name, method) + + for n, text, html in fixtures.load_examples(case_file): + if cls.ignore_case(n): + continue + attach_case(n, text, html) + + @classmethod + def ignore_case(cls, name: str) -> bool: + return False + + @abstractmethod + def parse(self, text: str) -> str: ... + + def assert_case(self, name: str, text: str, html: str) -> None: + result = self.parse(text) + self.assertEqual(result, html) + + +def normalize_html(html: str) -> str: + html = re.sub(r'>\n+', '>', html) + html = re.sub(r'\n+<', '<', html) + return html.strip() diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/fixtures/__init__.py b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/fixtures/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..9a1abe299918fbbac039621a46f85061a7f0c31e --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/fixtures/__init__.py @@ -0,0 +1,56 @@ +import os +import re +import json +from typing import Any, Iterable, Tuple + +ROOT = os.path.join(os.path.dirname(__file__)) + +EXAMPLE_PATTERN = re.compile( + r'^`{32} example\n([\s\S]*?)' + r'^\.\n([\s\S]*?)' + r'^`{32}$|^#{1,6} *(.*)$', + flags=re.M +) + + +def load_ast(filename: str) -> Any: + with open(os.path.join(ROOT, 'ast', filename)) as f: + return json.load(f) + + +def load_json(filename: str) -> Any: + with open(os.path.join(ROOT, filename)) as f: + return json.load(f) + + +def load_examples(filename: str) -> Iterable[Tuple[str, str, str]]: + if filename.endswith('.json'): + data = load_json(filename) + for item in data: + section = item['section'].lower().replace(' ', '_') + n = '%s_%03d' % (section, item['example']) + yield n, item['markdown'], item['html'] + else: + with open(os.path.join(ROOT, filename), 'rb') as f: + content = f.read() + s = content.decode('utf-8') + yield from parse_examples(s) + + + +def parse_examples(text: str) -> Iterable[Tuple[str, str, str]]: + data = EXAMPLE_PATTERN.findall(text) + + section = None + count = 0 + for md, html, title in data: + if title: + count = 0 + section = title.lower().replace(' ', '_') + + if md and html: + count += 1 + n = '%s_%03d' % (section, count) + md = md.replace(u'\u2192', '\t') + html = html.replace(u'\u2192', '\t') + yield n, md, html diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/fixtures/abbr.txt b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/fixtures/abbr.txt new file mode 100644 index 0000000000000000000000000000000000000000..a87b4f1521511a9071a901311c07372340bb958c --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/fixtures/abbr.txt @@ -0,0 +1,79 @@ +# Abbreviation + +## abbreviation + +```````````````````````````````` example +HTML +. +

      HTML

      +```````````````````````````````` + +```````````````````````````````` example +HTML +*[HTML]: Hyper Text Markup Language +. +

      HTML

      +```````````````````````````````` + +```````````````````````````````` example +The HTML specification is maintained by the W3C. +*[HTML]: Hyper Text Markup Language +*[W3C]: World Wide Web Consortium +. +

      The HTML specification is maintained by the W3C.

      +```````````````````````````````` + +```````````````````````````````` example +The HTML specification is maintained by the W3C. +*[HTML]: + Hyper Text Markup Language +*[W3C]: + World Wide Web Consortium +. +

      The HTML specification is maintained by the W3C.

      +```````````````````````````````` + +```````````````````````````````` example +The HTML specification is maintained by the W3C. +*[HTML]: Hyper Text Markup Language +*[W3C]: World Wide Web Consortium +There is more text below this one. +. +

      The HTML specification is maintained by the W3C.

      +

      There is more text below this one.

      +```````````````````````````````` + +```````````````````````````````` example +The latest spec of HTML is HTML5. +*[HTML]: Hyper Text Markup Language +. +

      The latest spec of HTML is HTML5.

      +```````````````````````````````` + +```````````````````````````````` example +HTML should always be spelt with capital letters and not spelt html. +*[HTML]: Hyper Text Markup Language +. +

      HTML should always be spelt with capital letters and not spelt html.

      +```````````````````````````````` + +```````````````````````````````` example +HTML is an abbreviation but nobody knows what it stands for. +*[HTML]: +. +

      HTML is an abbreviation but nobody knows what it stands for.

      +```````````````````````````````` + +```````````````````````````````` example +Foo.* looks like a regular expression. +*[Foo.*]: Just foo +. +

      Foo.* looks like a regular expression.

      +```````````````````````````````` + +```````````````````````````````` example +Untrusted HTML should be escaped. +*[HTML]:

      This is some HTML

      +. +

      Untrusted HTML should be escaped.

      +```````````````````````````````` diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/fixtures/commonmark.json b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/fixtures/commonmark.json new file mode 100644 index 0000000000000000000000000000000000000000..d742f941312421f89a3491b7e1d5edd0e44d2207 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/fixtures/commonmark.json @@ -0,0 +1,5218 @@ +[ + { + "markdown": "\tfoo\tbaz\t\tbim\n", + "html": "
      foo\tbaz\t\tbim\n
      \n", + "example": 1, + "start_line": 356, + "end_line": 361, + "section": "Tabs" + }, + { + "markdown": " \tfoo\tbaz\t\tbim\n", + "html": "
      foo\tbaz\t\tbim\n
      \n", + "example": 2, + "start_line": 363, + "end_line": 368, + "section": "Tabs" + }, + { + "markdown": " a\ta\n ὐ\ta\n", + "html": "
      a\ta\nὐ\ta\n
      \n", + "example": 3, + "start_line": 370, + "end_line": 377, + "section": "Tabs" + }, + { + "markdown": " - foo\n\n\tbar\n", + "html": "
        \n
      • \n

        foo

        \n

        bar

        \n
      • \n
      \n", + "example": 4, + "start_line": 383, + "end_line": 394, + "section": "Tabs" + }, + { + "markdown": "- foo\n\n\t\tbar\n", + "html": "
        \n
      • \n

        foo

        \n
          bar\n
        \n
      • \n
      \n", + "example": 5, + "start_line": 396, + "end_line": 408, + "section": "Tabs" + }, + { + "markdown": ">\t\tfoo\n", + "html": "
      \n
        foo\n
      \n
      \n", + "example": 6, + "start_line": 419, + "end_line": 426, + "section": "Tabs" + }, + { + "markdown": "-\t\tfoo\n", + "html": "
        \n
      • \n
          foo\n
        \n
      • \n
      \n", + "example": 7, + "start_line": 428, + "end_line": 437, + "section": "Tabs" + }, + { + "markdown": " foo\n\tbar\n", + "html": "
      foo\nbar\n
      \n", + "example": 8, + "start_line": 440, + "end_line": 447, + "section": "Tabs" + }, + { + "markdown": " - foo\n - bar\n\t - baz\n", + "html": "
        \n
      • foo\n
          \n
        • bar\n
            \n
          • baz
          • \n
          \n
        • \n
        \n
      • \n
      \n", + "example": 9, + "start_line": 449, + "end_line": 465, + "section": "Tabs" + }, + { + "markdown": "#\tFoo\n", + "html": "

      Foo

      \n", + "example": 10, + "start_line": 467, + "end_line": 471, + "section": "Tabs" + }, + { + "markdown": "*\t*\t*\t\n", + "html": "
      \n", + "example": 11, + "start_line": 473, + "end_line": 477, + "section": "Tabs" + }, + { + "markdown": "\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\-\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\_\\`\\{\\|\\}\\~\n", + "html": "

      !"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~

      \n", + "example": 12, + "start_line": 490, + "end_line": 494, + "section": "Backslash escapes" + }, + { + "markdown": "\\\t\\A\\a\\ \\3\\φ\\«\n", + "html": "

      \\\t\\A\\a\\ \\3\\φ\\«

      \n", + "example": 13, + "start_line": 500, + "end_line": 504, + "section": "Backslash escapes" + }, + { + "markdown": "\\*not emphasized*\n\\
      not a tag\n\\[not a link](/foo)\n\\`not code`\n1\\. not a list\n\\* not a list\n\\# not a heading\n\\[foo]: /url \"not a reference\"\n\\ö not a character entity\n", + "html": "

      *not emphasized*\n<br/> not a tag\n[not a link](/foo)\n`not code`\n1. not a list\n* not a list\n# not a heading\n[foo]: /url "not a reference"\n&ouml; not a character entity

      \n", + "example": 14, + "start_line": 510, + "end_line": 530, + "section": "Backslash escapes" + }, + { + "markdown": "\\\\*emphasis*\n", + "html": "

      \\emphasis

      \n", + "example": 15, + "start_line": 535, + "end_line": 539, + "section": "Backslash escapes" + }, + { + "markdown": "foo\\\nbar\n", + "html": "

      foo
      \nbar

      \n", + "example": 16, + "start_line": 544, + "end_line": 550, + "section": "Backslash escapes" + }, + { + "markdown": "`` \\[\\` ``\n", + "html": "

      \\[\\`

      \n", + "example": 17, + "start_line": 556, + "end_line": 560, + "section": "Backslash escapes" + }, + { + "markdown": " \\[\\]\n", + "html": "
      \\[\\]\n
      \n", + "example": 18, + "start_line": 563, + "end_line": 568, + "section": "Backslash escapes" + }, + { + "markdown": "~~~\n\\[\\]\n~~~\n", + "html": "
      \\[\\]\n
      \n", + "example": 19, + "start_line": 571, + "end_line": 578, + "section": "Backslash escapes" + }, + { + "markdown": "\n", + "html": "

      http://example.com?find=\\*

      \n", + "example": 20, + "start_line": 581, + "end_line": 585, + "section": "Backslash escapes" + }, + { + "markdown": "\n", + "html": "\n", + "example": 21, + "start_line": 588, + "end_line": 592, + "section": "Backslash escapes" + }, + { + "markdown": "[foo](/bar\\* \"ti\\*tle\")\n", + "html": "

      foo

      \n", + "example": 22, + "start_line": 598, + "end_line": 602, + "section": "Backslash escapes" + }, + { + "markdown": "[foo]\n\n[foo]: /bar\\* \"ti\\*tle\"\n", + "html": "

      foo

      \n", + "example": 23, + "start_line": 605, + "end_line": 611, + "section": "Backslash escapes" + }, + { + "markdown": "``` foo\\+bar\nfoo\n```\n", + "html": "
      foo\n
      \n", + "example": 24, + "start_line": 614, + "end_line": 621, + "section": "Backslash escapes" + }, + { + "markdown": "  & © Æ Ď\n¾ ℋ ⅆ\n∲ ≧̸\n", + "html": "

        & © Æ Ď\n¾ ℋ ⅆ\n∲ ≧̸

      \n", + "example": 25, + "start_line": 650, + "end_line": 658, + "section": "Entity and numeric character references" + }, + { + "markdown": "# Ӓ Ϡ �\n", + "html": "

      # Ӓ Ϡ �

      \n", + "example": 26, + "start_line": 669, + "end_line": 673, + "section": "Entity and numeric character references" + }, + { + "markdown": "" ആ ಫ\n", + "html": "

      " ആ ಫ

      \n", + "example": 27, + "start_line": 682, + "end_line": 686, + "section": "Entity and numeric character references" + }, + { + "markdown": "  &x; &#; &#x;\n�\n&#abcdef0;\n&ThisIsNotDefined; &hi?;\n", + "html": "

      &nbsp &x; &#; &#x;\n&#87654321;\n&#abcdef0;\n&ThisIsNotDefined; &hi?;

      \n", + "example": 28, + "start_line": 691, + "end_line": 701, + "section": "Entity and numeric character references" + }, + { + "markdown": "©\n", + "html": "

      &copy

      \n", + "example": 29, + "start_line": 708, + "end_line": 712, + "section": "Entity and numeric character references" + }, + { + "markdown": "&MadeUpEntity;\n", + "html": "

      &MadeUpEntity;

      \n", + "example": 30, + "start_line": 718, + "end_line": 722, + "section": "Entity and numeric character references" + }, + { + "markdown": "\n", + "html": "\n", + "example": 31, + "start_line": 729, + "end_line": 733, + "section": "Entity and numeric character references" + }, + { + "markdown": "[foo](/föö \"föö\")\n", + "html": "

      foo

      \n", + "example": 32, + "start_line": 736, + "end_line": 740, + "section": "Entity and numeric character references" + }, + { + "markdown": "[foo]\n\n[foo]: /föö \"föö\"\n", + "html": "

      foo

      \n", + "example": 33, + "start_line": 743, + "end_line": 749, + "section": "Entity and numeric character references" + }, + { + "markdown": "``` föö\nfoo\n```\n", + "html": "
      foo\n
      \n", + "example": 34, + "start_line": 752, + "end_line": 759, + "section": "Entity and numeric character references" + }, + { + "markdown": "`föö`\n", + "html": "

      f&ouml;&ouml;

      \n", + "example": 35, + "start_line": 765, + "end_line": 769, + "section": "Entity and numeric character references" + }, + { + "markdown": " föfö\n", + "html": "
      f&ouml;f&ouml;\n
      \n", + "example": 36, + "start_line": 772, + "end_line": 777, + "section": "Entity and numeric character references" + }, + { + "markdown": "*foo*\n*foo*\n", + "html": "

      *foo*\nfoo

      \n", + "example": 37, + "start_line": 784, + "end_line": 790, + "section": "Entity and numeric character references" + }, + { + "markdown": "* foo\n\n* foo\n", + "html": "

      * foo

      \n
        \n
      • foo
      • \n
      \n", + "example": 38, + "start_line": 792, + "end_line": 801, + "section": "Entity and numeric character references" + }, + { + "markdown": "foo bar\n", + "html": "

      foo\n\nbar

      \n", + "example": 39, + "start_line": 803, + "end_line": 809, + "section": "Entity and numeric character references" + }, + { + "markdown": " foo\n", + "html": "

      \tfoo

      \n", + "example": 40, + "start_line": 811, + "end_line": 815, + "section": "Entity and numeric character references" + }, + { + "markdown": "[a](url "tit")\n", + "html": "

      [a](url "tit")

      \n", + "example": 41, + "start_line": 818, + "end_line": 822, + "section": "Entity and numeric character references" + }, + { + "markdown": "- `one\n- two`\n", + "html": "
        \n
      • `one
      • \n
      • two`
      • \n
      \n", + "example": 42, + "start_line": 841, + "end_line": 849, + "section": "Precedence" + }, + { + "markdown": "***\n---\n___\n", + "html": "
      \n
      \n
      \n", + "example": 43, + "start_line": 880, + "end_line": 888, + "section": "Thematic breaks" + }, + { + "markdown": "+++\n", + "html": "

      +++

      \n", + "example": 44, + "start_line": 893, + "end_line": 897, + "section": "Thematic breaks" + }, + { + "markdown": "===\n", + "html": "

      ===

      \n", + "example": 45, + "start_line": 900, + "end_line": 904, + "section": "Thematic breaks" + }, + { + "markdown": "--\n**\n__\n", + "html": "

      --\n**\n__

      \n", + "example": 46, + "start_line": 909, + "end_line": 917, + "section": "Thematic breaks" + }, + { + "markdown": " ***\n ***\n ***\n", + "html": "
      \n
      \n
      \n", + "example": 47, + "start_line": 922, + "end_line": 930, + "section": "Thematic breaks" + }, + { + "markdown": " ***\n", + "html": "
      ***\n
      \n", + "example": 48, + "start_line": 935, + "end_line": 940, + "section": "Thematic breaks" + }, + { + "markdown": "Foo\n ***\n", + "html": "

      Foo\n***

      \n", + "example": 49, + "start_line": 943, + "end_line": 949, + "section": "Thematic breaks" + }, + { + "markdown": "_____________________________________\n", + "html": "
      \n", + "example": 50, + "start_line": 954, + "end_line": 958, + "section": "Thematic breaks" + }, + { + "markdown": " - - -\n", + "html": "
      \n", + "example": 51, + "start_line": 963, + "end_line": 967, + "section": "Thematic breaks" + }, + { + "markdown": " ** * ** * ** * **\n", + "html": "
      \n", + "example": 52, + "start_line": 970, + "end_line": 974, + "section": "Thematic breaks" + }, + { + "markdown": "- - - -\n", + "html": "
      \n", + "example": 53, + "start_line": 977, + "end_line": 981, + "section": "Thematic breaks" + }, + { + "markdown": "- - - - \n", + "html": "
      \n", + "example": 54, + "start_line": 986, + "end_line": 990, + "section": "Thematic breaks" + }, + { + "markdown": "_ _ _ _ a\n\na------\n\n---a---\n", + "html": "

      _ _ _ _ a

      \n

      a------

      \n

      ---a---

      \n", + "example": 55, + "start_line": 995, + "end_line": 1005, + "section": "Thematic breaks" + }, + { + "markdown": " *-*\n", + "html": "

      -

      \n", + "example": 56, + "start_line": 1011, + "end_line": 1015, + "section": "Thematic breaks" + }, + { + "markdown": "- foo\n***\n- bar\n", + "html": "
        \n
      • foo
      • \n
      \n
      \n
        \n
      • bar
      • \n
      \n", + "example": 57, + "start_line": 1020, + "end_line": 1032, + "section": "Thematic breaks" + }, + { + "markdown": "Foo\n***\nbar\n", + "html": "

      Foo

      \n
      \n

      bar

      \n", + "example": 58, + "start_line": 1037, + "end_line": 1045, + "section": "Thematic breaks" + }, + { + "markdown": "Foo\n---\nbar\n", + "html": "

      Foo

      \n

      bar

      \n", + "example": 59, + "start_line": 1054, + "end_line": 1061, + "section": "Thematic breaks" + }, + { + "markdown": "* Foo\n* * *\n* Bar\n", + "html": "
        \n
      • Foo
      • \n
      \n
      \n
        \n
      • Bar
      • \n
      \n", + "example": 60, + "start_line": 1067, + "end_line": 1079, + "section": "Thematic breaks" + }, + { + "markdown": "- Foo\n- * * *\n", + "html": "
        \n
      • Foo
      • \n
      • \n
        \n
      • \n
      \n", + "example": 61, + "start_line": 1084, + "end_line": 1094, + "section": "Thematic breaks" + }, + { + "markdown": "# foo\n## foo\n### foo\n#### foo\n##### foo\n###### foo\n", + "html": "

      foo

      \n

      foo

      \n

      foo

      \n

      foo

      \n
      foo
      \n
      foo
      \n", + "example": 62, + "start_line": 1113, + "end_line": 1127, + "section": "ATX headings" + }, + { + "markdown": "####### foo\n", + "html": "

      ####### foo

      \n", + "example": 63, + "start_line": 1132, + "end_line": 1136, + "section": "ATX headings" + }, + { + "markdown": "#5 bolt\n\n#hashtag\n", + "html": "

      #5 bolt

      \n

      #hashtag

      \n", + "example": 64, + "start_line": 1147, + "end_line": 1154, + "section": "ATX headings" + }, + { + "markdown": "\\## foo\n", + "html": "

      ## foo

      \n", + "example": 65, + "start_line": 1159, + "end_line": 1163, + "section": "ATX headings" + }, + { + "markdown": "# foo *bar* \\*baz\\*\n", + "html": "

      foo bar *baz*

      \n", + "example": 66, + "start_line": 1168, + "end_line": 1172, + "section": "ATX headings" + }, + { + "markdown": "# foo \n", + "html": "

      foo

      \n", + "example": 67, + "start_line": 1177, + "end_line": 1181, + "section": "ATX headings" + }, + { + "markdown": " ### foo\n ## foo\n # foo\n", + "html": "

      foo

      \n

      foo

      \n

      foo

      \n", + "example": 68, + "start_line": 1186, + "end_line": 1194, + "section": "ATX headings" + }, + { + "markdown": " # foo\n", + "html": "
      # foo\n
      \n", + "example": 69, + "start_line": 1199, + "end_line": 1204, + "section": "ATX headings" + }, + { + "markdown": "foo\n # bar\n", + "html": "

      foo\n# bar

      \n", + "example": 70, + "start_line": 1207, + "end_line": 1213, + "section": "ATX headings" + }, + { + "markdown": "## foo ##\n ### bar ###\n", + "html": "

      foo

      \n

      bar

      \n", + "example": 71, + "start_line": 1218, + "end_line": 1224, + "section": "ATX headings" + }, + { + "markdown": "# foo ##################################\n##### foo ##\n", + "html": "

      foo

      \n
      foo
      \n", + "example": 72, + "start_line": 1229, + "end_line": 1235, + "section": "ATX headings" + }, + { + "markdown": "### foo ### \n", + "html": "

      foo

      \n", + "example": 73, + "start_line": 1240, + "end_line": 1244, + "section": "ATX headings" + }, + { + "markdown": "### foo ### b\n", + "html": "

      foo ### b

      \n", + "example": 74, + "start_line": 1251, + "end_line": 1255, + "section": "ATX headings" + }, + { + "markdown": "# foo#\n", + "html": "

      foo#

      \n", + "example": 75, + "start_line": 1260, + "end_line": 1264, + "section": "ATX headings" + }, + { + "markdown": "### foo \\###\n## foo #\\##\n# foo \\#\n", + "html": "

      foo ###

      \n

      foo ###

      \n

      foo #

      \n", + "example": 76, + "start_line": 1270, + "end_line": 1278, + "section": "ATX headings" + }, + { + "markdown": "****\n## foo\n****\n", + "html": "
      \n

      foo

      \n
      \n", + "example": 77, + "start_line": 1284, + "end_line": 1292, + "section": "ATX headings" + }, + { + "markdown": "Foo bar\n# baz\nBar foo\n", + "html": "

      Foo bar

      \n

      baz

      \n

      Bar foo

      \n", + "example": 78, + "start_line": 1295, + "end_line": 1303, + "section": "ATX headings" + }, + { + "markdown": "## \n#\n### ###\n", + "html": "

      \n

      \n

      \n", + "example": 79, + "start_line": 1308, + "end_line": 1316, + "section": "ATX headings" + }, + { + "markdown": "Foo *bar*\n=========\n\nFoo *bar*\n---------\n", + "html": "

      Foo bar

      \n

      Foo bar

      \n", + "example": 80, + "start_line": 1351, + "end_line": 1360, + "section": "Setext headings" + }, + { + "markdown": "Foo *bar\nbaz*\n====\n", + "html": "

      Foo bar\nbaz

      \n", + "example": 81, + "start_line": 1365, + "end_line": 1372, + "section": "Setext headings" + }, + { + "markdown": " Foo *bar\nbaz*\t\n====\n", + "html": "

      Foo bar\nbaz

      \n", + "example": 82, + "start_line": 1379, + "end_line": 1386, + "section": "Setext headings" + }, + { + "markdown": "Foo\n-------------------------\n\nFoo\n=\n", + "html": "

      Foo

      \n

      Foo

      \n", + "example": 83, + "start_line": 1391, + "end_line": 1400, + "section": "Setext headings" + }, + { + "markdown": " Foo\n---\n\n Foo\n-----\n\n Foo\n ===\n", + "html": "

      Foo

      \n

      Foo

      \n

      Foo

      \n", + "example": 84, + "start_line": 1406, + "end_line": 1419, + "section": "Setext headings" + }, + { + "markdown": " Foo\n ---\n\n Foo\n---\n", + "html": "
      Foo\n---\n\nFoo\n
      \n
      \n", + "example": 85, + "start_line": 1424, + "end_line": 1437, + "section": "Setext headings" + }, + { + "markdown": "Foo\n ---- \n", + "html": "

      Foo

      \n", + "example": 86, + "start_line": 1443, + "end_line": 1448, + "section": "Setext headings" + }, + { + "markdown": "Foo\n ---\n", + "html": "

      Foo\n---

      \n", + "example": 87, + "start_line": 1453, + "end_line": 1459, + "section": "Setext headings" + }, + { + "markdown": "Foo\n= =\n\nFoo\n--- -\n", + "html": "

      Foo\n= =

      \n

      Foo

      \n
      \n", + "example": 88, + "start_line": 1464, + "end_line": 1475, + "section": "Setext headings" + }, + { + "markdown": "Foo \n-----\n", + "html": "

      Foo

      \n", + "example": 89, + "start_line": 1480, + "end_line": 1485, + "section": "Setext headings" + }, + { + "markdown": "Foo\\\n----\n", + "html": "

      Foo\\

      \n", + "example": 90, + "start_line": 1490, + "end_line": 1495, + "section": "Setext headings" + }, + { + "markdown": "`Foo\n----\n`\n\n\n", + "html": "

      `Foo

      \n

      `

      \n

      <a title="a lot

      \n

      of dashes"/>

      \n", + "example": 91, + "start_line": 1501, + "end_line": 1514, + "section": "Setext headings" + }, + { + "markdown": "> Foo\n---\n", + "html": "
      \n

      Foo

      \n
      \n
      \n", + "example": 92, + "start_line": 1520, + "end_line": 1528, + "section": "Setext headings" + }, + { + "markdown": "> foo\nbar\n===\n", + "html": "
      \n

      foo\nbar\n===

      \n
      \n", + "example": 93, + "start_line": 1531, + "end_line": 1541, + "section": "Setext headings" + }, + { + "markdown": "- Foo\n---\n", + "html": "
        \n
      • Foo
      • \n
      \n
      \n", + "example": 94, + "start_line": 1544, + "end_line": 1552, + "section": "Setext headings" + }, + { + "markdown": "Foo\nBar\n---\n", + "html": "

      Foo\nBar

      \n", + "example": 95, + "start_line": 1559, + "end_line": 1566, + "section": "Setext headings" + }, + { + "markdown": "---\nFoo\n---\nBar\n---\nBaz\n", + "html": "
      \n

      Foo

      \n

      Bar

      \n

      Baz

      \n", + "example": 96, + "start_line": 1572, + "end_line": 1584, + "section": "Setext headings" + }, + { + "markdown": "\n====\n", + "html": "

      ====

      \n", + "example": 97, + "start_line": 1589, + "end_line": 1594, + "section": "Setext headings" + }, + { + "markdown": "---\n---\n", + "html": "
      \n
      \n", + "example": 98, + "start_line": 1601, + "end_line": 1607, + "section": "Setext headings" + }, + { + "markdown": "- foo\n-----\n", + "html": "
        \n
      • foo
      • \n
      \n
      \n", + "example": 99, + "start_line": 1610, + "end_line": 1618, + "section": "Setext headings" + }, + { + "markdown": " foo\n---\n", + "html": "
      foo\n
      \n
      \n", + "example": 100, + "start_line": 1621, + "end_line": 1628, + "section": "Setext headings" + }, + { + "markdown": "> foo\n-----\n", + "html": "
      \n

      foo

      \n
      \n
      \n", + "example": 101, + "start_line": 1631, + "end_line": 1639, + "section": "Setext headings" + }, + { + "markdown": "\\> foo\n------\n", + "html": "

      > foo

      \n", + "example": 102, + "start_line": 1645, + "end_line": 1650, + "section": "Setext headings" + }, + { + "markdown": "Foo\n\nbar\n---\nbaz\n", + "html": "

      Foo

      \n

      bar

      \n

      baz

      \n", + "example": 103, + "start_line": 1676, + "end_line": 1686, + "section": "Setext headings" + }, + { + "markdown": "Foo\nbar\n\n---\n\nbaz\n", + "html": "

      Foo\nbar

      \n
      \n

      baz

      \n", + "example": 104, + "start_line": 1692, + "end_line": 1704, + "section": "Setext headings" + }, + { + "markdown": "Foo\nbar\n* * *\nbaz\n", + "html": "

      Foo\nbar

      \n
      \n

      baz

      \n", + "example": 105, + "start_line": 1710, + "end_line": 1720, + "section": "Setext headings" + }, + { + "markdown": "Foo\nbar\n\\---\nbaz\n", + "html": "

      Foo\nbar\n---\nbaz

      \n", + "example": 106, + "start_line": 1725, + "end_line": 1735, + "section": "Setext headings" + }, + { + "markdown": " a simple\n indented code block\n", + "html": "
      a simple\n  indented code block\n
      \n", + "example": 107, + "start_line": 1753, + "end_line": 1760, + "section": "Indented code blocks" + }, + { + "markdown": " - foo\n\n bar\n", + "html": "
        \n
      • \n

        foo

        \n

        bar

        \n
      • \n
      \n", + "example": 108, + "start_line": 1767, + "end_line": 1778, + "section": "Indented code blocks" + }, + { + "markdown": "1. foo\n\n - bar\n", + "html": "
        \n
      1. \n

        foo

        \n
          \n
        • bar
        • \n
        \n
      2. \n
      \n", + "example": 109, + "start_line": 1781, + "end_line": 1794, + "section": "Indented code blocks" + }, + { + "markdown": "
      \n *hi*\n\n - one\n", + "html": "
      <a/>\n*hi*\n\n- one\n
      \n", + "example": 110, + "start_line": 1801, + "end_line": 1812, + "section": "Indented code blocks" + }, + { + "markdown": " chunk1\n\n chunk2\n \n \n \n chunk3\n", + "html": "
      chunk1\n\nchunk2\n\n\n\nchunk3\n
      \n", + "example": 111, + "start_line": 1817, + "end_line": 1834, + "section": "Indented code blocks" + }, + { + "markdown": " chunk1\n \n chunk2\n", + "html": "
      chunk1\n  \n  chunk2\n
      \n", + "example": 112, + "start_line": 1840, + "end_line": 1849, + "section": "Indented code blocks" + }, + { + "markdown": "Foo\n bar\n\n", + "html": "

      Foo\nbar

      \n", + "example": 113, + "start_line": 1855, + "end_line": 1862, + "section": "Indented code blocks" + }, + { + "markdown": " foo\nbar\n", + "html": "
      foo\n
      \n

      bar

      \n", + "example": 114, + "start_line": 1869, + "end_line": 1876, + "section": "Indented code blocks" + }, + { + "markdown": "# Heading\n foo\nHeading\n------\n foo\n----\n", + "html": "

      Heading

      \n
      foo\n
      \n

      Heading

      \n
      foo\n
      \n
      \n", + "example": 115, + "start_line": 1882, + "end_line": 1897, + "section": "Indented code blocks" + }, + { + "markdown": " foo\n bar\n", + "html": "
          foo\nbar\n
      \n", + "example": 116, + "start_line": 1902, + "end_line": 1909, + "section": "Indented code blocks" + }, + { + "markdown": "\n \n foo\n \n\n", + "html": "
      foo\n
      \n", + "example": 117, + "start_line": 1915, + "end_line": 1924, + "section": "Indented code blocks" + }, + { + "markdown": " foo \n", + "html": "
      foo  \n
      \n", + "example": 118, + "start_line": 1929, + "end_line": 1934, + "section": "Indented code blocks" + }, + { + "markdown": "```\n<\n >\n```\n", + "html": "
      <\n >\n
      \n", + "example": 119, + "start_line": 1984, + "end_line": 1993, + "section": "Fenced code blocks" + }, + { + "markdown": "~~~\n<\n >\n~~~\n", + "html": "
      <\n >\n
      \n", + "example": 120, + "start_line": 1998, + "end_line": 2007, + "section": "Fenced code blocks" + }, + { + "markdown": "``\nfoo\n``\n", + "html": "

      foo

      \n", + "example": 121, + "start_line": 2011, + "end_line": 2017, + "section": "Fenced code blocks" + }, + { + "markdown": "```\naaa\n~~~\n```\n", + "html": "
      aaa\n~~~\n
      \n", + "example": 122, + "start_line": 2022, + "end_line": 2031, + "section": "Fenced code blocks" + }, + { + "markdown": "~~~\naaa\n```\n~~~\n", + "html": "
      aaa\n```\n
      \n", + "example": 123, + "start_line": 2034, + "end_line": 2043, + "section": "Fenced code blocks" + }, + { + "markdown": "````\naaa\n```\n``````\n", + "html": "
      aaa\n```\n
      \n", + "example": 124, + "start_line": 2048, + "end_line": 2057, + "section": "Fenced code blocks" + }, + { + "markdown": "~~~~\naaa\n~~~\n~~~~\n", + "html": "
      aaa\n~~~\n
      \n", + "example": 125, + "start_line": 2060, + "end_line": 2069, + "section": "Fenced code blocks" + }, + { + "markdown": "```\n", + "html": "
      \n", + "example": 126, + "start_line": 2075, + "end_line": 2079, + "section": "Fenced code blocks" + }, + { + "markdown": "`````\n\n```\naaa\n", + "html": "
      \n```\naaa\n
      \n", + "example": 127, + "start_line": 2082, + "end_line": 2092, + "section": "Fenced code blocks" + }, + { + "markdown": "> ```\n> aaa\n\nbbb\n", + "html": "
      \n
      aaa\n
      \n
      \n

      bbb

      \n", + "example": 128, + "start_line": 2095, + "end_line": 2106, + "section": "Fenced code blocks" + }, + { + "markdown": "```\n\n \n```\n", + "html": "
      \n  \n
      \n", + "example": 129, + "start_line": 2111, + "end_line": 2120, + "section": "Fenced code blocks" + }, + { + "markdown": "```\n```\n", + "html": "
      \n", + "example": 130, + "start_line": 2125, + "end_line": 2130, + "section": "Fenced code blocks" + }, + { + "markdown": " ```\n aaa\naaa\n```\n", + "html": "
      aaa\naaa\n
      \n", + "example": 131, + "start_line": 2137, + "end_line": 2146, + "section": "Fenced code blocks" + }, + { + "markdown": " ```\naaa\n aaa\naaa\n ```\n", + "html": "
      aaa\naaa\naaa\n
      \n", + "example": 132, + "start_line": 2149, + "end_line": 2160, + "section": "Fenced code blocks" + }, + { + "markdown": " ```\n aaa\n aaa\n aaa\n ```\n", + "html": "
      aaa\n aaa\naaa\n
      \n", + "example": 133, + "start_line": 2163, + "end_line": 2174, + "section": "Fenced code blocks" + }, + { + "markdown": " ```\n aaa\n ```\n", + "html": "
      ```\naaa\n```\n
      \n", + "example": 134, + "start_line": 2179, + "end_line": 2188, + "section": "Fenced code blocks" + }, + { + "markdown": "```\naaa\n ```\n", + "html": "
      aaa\n
      \n", + "example": 135, + "start_line": 2194, + "end_line": 2201, + "section": "Fenced code blocks" + }, + { + "markdown": " ```\naaa\n ```\n", + "html": "
      aaa\n
      \n", + "example": 136, + "start_line": 2204, + "end_line": 2211, + "section": "Fenced code blocks" + }, + { + "markdown": "```\naaa\n ```\n", + "html": "
      aaa\n    ```\n
      \n", + "example": 137, + "start_line": 2216, + "end_line": 2224, + "section": "Fenced code blocks" + }, + { + "markdown": "``` ```\naaa\n", + "html": "

      \naaa

      \n", + "example": 138, + "start_line": 2230, + "end_line": 2236, + "section": "Fenced code blocks" + }, + { + "markdown": "~~~~~~\naaa\n~~~ ~~\n", + "html": "
      aaa\n~~~ ~~\n
      \n", + "example": 139, + "start_line": 2239, + "end_line": 2247, + "section": "Fenced code blocks" + }, + { + "markdown": "foo\n```\nbar\n```\nbaz\n", + "html": "

      foo

      \n
      bar\n
      \n

      baz

      \n", + "example": 140, + "start_line": 2253, + "end_line": 2264, + "section": "Fenced code blocks" + }, + { + "markdown": "foo\n---\n~~~\nbar\n~~~\n# baz\n", + "html": "

      foo

      \n
      bar\n
      \n

      baz

      \n", + "example": 141, + "start_line": 2270, + "end_line": 2282, + "section": "Fenced code blocks" + }, + { + "markdown": "```ruby\ndef foo(x)\n return 3\nend\n```\n", + "html": "
      def foo(x)\n  return 3\nend\n
      \n", + "example": 142, + "start_line": 2292, + "end_line": 2303, + "section": "Fenced code blocks" + }, + { + "markdown": "~~~~ ruby startline=3 $%@#$\ndef foo(x)\n return 3\nend\n~~~~~~~\n", + "html": "
      def foo(x)\n  return 3\nend\n
      \n", + "example": 143, + "start_line": 2306, + "end_line": 2317, + "section": "Fenced code blocks" + }, + { + "markdown": "````;\n````\n", + "html": "
      \n", + "example": 144, + "start_line": 2320, + "end_line": 2325, + "section": "Fenced code blocks" + }, + { + "markdown": "``` aa ```\nfoo\n", + "html": "

      aa\nfoo

      \n", + "example": 145, + "start_line": 2330, + "end_line": 2336, + "section": "Fenced code blocks" + }, + { + "markdown": "~~~ aa ``` ~~~\nfoo\n~~~\n", + "html": "
      foo\n
      \n", + "example": 146, + "start_line": 2341, + "end_line": 2348, + "section": "Fenced code blocks" + }, + { + "markdown": "```\n``` aaa\n```\n", + "html": "
      ``` aaa\n
      \n", + "example": 147, + "start_line": 2353, + "end_line": 2360, + "section": "Fenced code blocks" + }, + { + "markdown": "
\n
\n**Hello**,\n\n_world_.\n
\n
\n", + "html": "
\n
\n**Hello**,\n

world.\n

\n
\n", + "example": 148, + "start_line": 2432, + "end_line": 2447, + "section": "HTML blocks" + }, + { + "markdown": "\n \n \n \n
\n hi\n
\n\nokay.\n", + "html": "\n \n \n \n
\n hi\n
\n

okay.

\n", + "example": 149, + "start_line": 2461, + "end_line": 2480, + "section": "HTML blocks" + }, + { + "markdown": "
\n*foo*\n", + "example": 151, + "start_line": 2496, + "end_line": 2502, + "section": "HTML blocks" + }, + { + "markdown": "
\n\n*Markdown*\n\n
\n", + "html": "
\n

Markdown

\n
\n", + "example": 152, + "start_line": 2507, + "end_line": 2517, + "section": "HTML blocks" + }, + { + "markdown": "
\n
\n", + "html": "
\n
\n", + "example": 153, + "start_line": 2523, + "end_line": 2531, + "section": "HTML blocks" + }, + { + "markdown": "
\n
\n", + "html": "
\n
\n", + "example": 154, + "start_line": 2534, + "end_line": 2542, + "section": "HTML blocks" + }, + { + "markdown": "
\n*foo*\n\n*bar*\n", + "html": "
\n*foo*\n

bar

\n", + "example": 155, + "start_line": 2546, + "end_line": 2555, + "section": "HTML blocks" + }, + { + "markdown": "
\n", + "html": "\n", + "example": 159, + "start_line": 2595, + "end_line": 2599, + "section": "HTML blocks" + }, + { + "markdown": "
\nfoo\n
\n", + "html": "
\nfoo\n
\n", + "example": 160, + "start_line": 2602, + "end_line": 2610, + "section": "HTML blocks" + }, + { + "markdown": "
\n``` c\nint x = 33;\n```\n", + "html": "
\n``` c\nint x = 33;\n```\n", + "example": 161, + "start_line": 2619, + "end_line": 2629, + "section": "HTML blocks" + }, + { + "markdown": "\n*bar*\n\n", + "html": "\n*bar*\n\n", + "example": 162, + "start_line": 2636, + "end_line": 2644, + "section": "HTML blocks" + }, + { + "markdown": "\n*bar*\n\n", + "html": "\n*bar*\n\n", + "example": 163, + "start_line": 2649, + "end_line": 2657, + "section": "HTML blocks" + }, + { + "markdown": "\n*bar*\n\n", + "html": "\n*bar*\n\n", + "example": 164, + "start_line": 2660, + "end_line": 2668, + "section": "HTML blocks" + }, + { + "markdown": "\n*bar*\n", + "html": "\n*bar*\n", + "example": 165, + "start_line": 2671, + "end_line": 2677, + "section": "HTML blocks" + }, + { + "markdown": "\n*foo*\n\n", + "html": "\n*foo*\n\n", + "example": 166, + "start_line": 2686, + "end_line": 2694, + "section": "HTML blocks" + }, + { + "markdown": "\n\n*foo*\n\n\n", + "html": "\n

foo

\n
\n", + "example": 167, + "start_line": 2701, + "end_line": 2711, + "section": "HTML blocks" + }, + { + "markdown": "*foo*\n", + "html": "

foo

\n", + "example": 168, + "start_line": 2719, + "end_line": 2723, + "section": "HTML blocks" + }, + { + "markdown": "
\nimport Text.HTML.TagSoup\n\nmain :: IO ()\nmain = print $ parseTags tags\n
\nokay\n", + "html": "
\nimport Text.HTML.TagSoup\n\nmain :: IO ()\nmain = print $ parseTags tags\n
\n

okay

\n", + "example": 169, + "start_line": 2735, + "end_line": 2751, + "section": "HTML blocks" + }, + { + "markdown": "\nokay\n", + "html": "\n

okay

\n", + "example": 170, + "start_line": 2756, + "end_line": 2770, + "section": "HTML blocks" + }, + { + "markdown": "\n", + "html": "\n", + "example": 171, + "start_line": 2775, + "end_line": 2791, + "section": "HTML blocks" + }, + { + "markdown": "\nh1 {color:red;}\n\np {color:blue;}\n\nokay\n", + "html": "\nh1 {color:red;}\n\np {color:blue;}\n\n

okay

\n", + "example": 172, + "start_line": 2795, + "end_line": 2811, + "section": "HTML blocks" + }, + { + "markdown": "\n\nfoo\n", + "html": "\n\nfoo\n", + "example": 173, + "start_line": 2818, + "end_line": 2828, + "section": "HTML blocks" + }, + { + "markdown": ">
\n> foo\n\nbar\n", + "html": "
\n
\nfoo\n
\n

bar

\n", + "example": 174, + "start_line": 2831, + "end_line": 2842, + "section": "HTML blocks" + }, + { + "markdown": "-
\n- foo\n", + "html": "
    \n
  • \n
    \n
  • \n
  • foo
  • \n
\n", + "example": 175, + "start_line": 2845, + "end_line": 2855, + "section": "HTML blocks" + }, + { + "markdown": "\n*foo*\n", + "html": "\n

foo

\n", + "example": 176, + "start_line": 2860, + "end_line": 2866, + "section": "HTML blocks" + }, + { + "markdown": "*bar*\n*baz*\n", + "html": "*bar*\n

baz

\n", + "example": 177, + "start_line": 2869, + "end_line": 2875, + "section": "HTML blocks" + }, + { + "markdown": "1. *bar*\n", + "html": "1. *bar*\n", + "example": 178, + "start_line": 2881, + "end_line": 2889, + "section": "HTML blocks" + }, + { + "markdown": "\nokay\n", + "html": "\n

okay

\n", + "example": 179, + "start_line": 2894, + "end_line": 2906, + "section": "HTML blocks" + }, + { + "markdown": "';\n\n?>\nokay\n", + "html": "';\n\n?>\n

okay

\n", + "example": 180, + "start_line": 2912, + "end_line": 2926, + "section": "HTML blocks" + }, + { + "markdown": "\n", + "html": "\n", + "example": 181, + "start_line": 2931, + "end_line": 2935, + "section": "HTML blocks" + }, + { + "markdown": "\nokay\n", + "html": "\n

okay

\n", + "example": 182, + "start_line": 2940, + "end_line": 2968, + "section": "HTML blocks" + }, + { + "markdown": " \n\n \n", + "html": " \n
<!-- foo -->\n
\n", + "example": 183, + "start_line": 2974, + "end_line": 2982, + "section": "HTML blocks" + }, + { + "markdown": "
\n\n
\n", + "html": "
\n
<div>\n
\n", + "example": 184, + "start_line": 2985, + "end_line": 2993, + "section": "HTML blocks" + }, + { + "markdown": "Foo\n
\nbar\n
\n", + "html": "

Foo

\n
\nbar\n
\n", + "example": 185, + "start_line": 2999, + "end_line": 3009, + "section": "HTML blocks" + }, + { + "markdown": "
\nbar\n
\n*foo*\n", + "html": "
\nbar\n
\n*foo*\n", + "example": 186, + "start_line": 3016, + "end_line": 3026, + "section": "HTML blocks" + }, + { + "markdown": "Foo\n\nbaz\n", + "html": "

Foo\n\nbaz

\n", + "example": 187, + "start_line": 3031, + "end_line": 3039, + "section": "HTML blocks" + }, + { + "markdown": "
\n\n*Emphasized* text.\n\n
\n", + "html": "
\n

Emphasized text.

\n
\n", + "example": 188, + "start_line": 3072, + "end_line": 3082, + "section": "HTML blocks" + }, + { + "markdown": "
\n*Emphasized* text.\n
\n", + "html": "
\n*Emphasized* text.\n
\n", + "example": 189, + "start_line": 3085, + "end_line": 3093, + "section": "HTML blocks" + }, + { + "markdown": "\n\n\n\n\n\n\n\n
\nHi\n
\n", + "html": "\n\n\n\n
\nHi\n
\n", + "example": 190, + "start_line": 3107, + "end_line": 3127, + "section": "HTML blocks" + }, + { + "markdown": "\n\n \n\n \n\n \n\n
\n Hi\n
\n", + "html": "\n \n
<td>\n  Hi\n</td>\n
\n \n
\n", + "example": 191, + "start_line": 3134, + "end_line": 3155, + "section": "HTML blocks" + }, + { + "markdown": "[foo]: /url \"title\"\n\n[foo]\n", + "html": "

foo

\n", + "example": 192, + "start_line": 3183, + "end_line": 3189, + "section": "Link reference definitions" + }, + { + "markdown": " [foo]: \n /url \n 'the title' \n\n[foo]\n", + "html": "

foo

\n", + "example": 193, + "start_line": 3192, + "end_line": 3200, + "section": "Link reference definitions" + }, + { + "markdown": "[Foo*bar\\]]:my_(url) 'title (with parens)'\n\n[Foo*bar\\]]\n", + "html": "

Foo*bar]

\n", + "example": 194, + "start_line": 3203, + "end_line": 3209, + "section": "Link reference definitions" + }, + { + "markdown": "[Foo bar]:\n\n'title'\n\n[Foo bar]\n", + "html": "

Foo bar

\n", + "example": 195, + "start_line": 3212, + "end_line": 3220, + "section": "Link reference definitions" + }, + { + "markdown": "[foo]: /url '\ntitle\nline1\nline2\n'\n\n[foo]\n", + "html": "

foo

\n", + "example": 196, + "start_line": 3225, + "end_line": 3239, + "section": "Link reference definitions" + }, + { + "markdown": "[foo]: /url 'title\n\nwith blank line'\n\n[foo]\n", + "html": "

[foo]: /url 'title

\n

with blank line'

\n

[foo]

\n", + "example": 197, + "start_line": 3244, + "end_line": 3254, + "section": "Link reference definitions" + }, + { + "markdown": "[foo]:\n/url\n\n[foo]\n", + "html": "

foo

\n", + "example": 198, + "start_line": 3259, + "end_line": 3266, + "section": "Link reference definitions" + }, + { + "markdown": "[foo]:\n\n[foo]\n", + "html": "

[foo]:

\n

[foo]

\n", + "example": 199, + "start_line": 3271, + "end_line": 3278, + "section": "Link reference definitions" + }, + { + "markdown": "[foo]: <>\n\n[foo]\n", + "html": "

foo

\n", + "example": 200, + "start_line": 3283, + "end_line": 3289, + "section": "Link reference definitions" + }, + { + "markdown": "[foo]: (baz)\n\n[foo]\n", + "html": "

[foo]: (baz)

\n

[foo]

\n", + "example": 201, + "start_line": 3294, + "end_line": 3301, + "section": "Link reference definitions" + }, + { + "markdown": "[foo]: /url\\bar\\*baz \"foo\\\"bar\\baz\"\n\n[foo]\n", + "html": "

foo

\n", + "example": 202, + "start_line": 3307, + "end_line": 3313, + "section": "Link reference definitions" + }, + { + "markdown": "[foo]\n\n[foo]: url\n", + "html": "

foo

\n", + "example": 203, + "start_line": 3318, + "end_line": 3324, + "section": "Link reference definitions" + }, + { + "markdown": "[foo]\n\n[foo]: first\n[foo]: second\n", + "html": "

foo

\n", + "example": 204, + "start_line": 3330, + "end_line": 3337, + "section": "Link reference definitions" + }, + { + "markdown": "[FOO]: /url\n\n[Foo]\n", + "html": "

Foo

\n", + "example": 205, + "start_line": 3343, + "end_line": 3349, + "section": "Link reference definitions" + }, + { + "markdown": "[ΑΓΩ]: /φου\n\n[αγω]\n", + "html": "

αγω

\n", + "example": 206, + "start_line": 3352, + "end_line": 3358, + "section": "Link reference definitions" + }, + { + "markdown": "[foo]: /url\n", + "html": "", + "example": 207, + "start_line": 3367, + "end_line": 3370, + "section": "Link reference definitions" + }, + { + "markdown": "[\nfoo\n]: /url\nbar\n", + "html": "

bar

\n", + "example": 208, + "start_line": 3375, + "end_line": 3382, + "section": "Link reference definitions" + }, + { + "markdown": "[foo]: /url \"title\" ok\n", + "html": "

[foo]: /url "title" ok

\n", + "example": 209, + "start_line": 3388, + "end_line": 3392, + "section": "Link reference definitions" + }, + { + "markdown": "[foo]: /url\n\"title\" ok\n", + "html": "

"title" ok

\n", + "example": 210, + "start_line": 3397, + "end_line": 3402, + "section": "Link reference definitions" + }, + { + "markdown": " [foo]: /url \"title\"\n\n[foo]\n", + "html": "
[foo]: /url "title"\n
\n

[foo]

\n", + "example": 211, + "start_line": 3408, + "end_line": 3416, + "section": "Link reference definitions" + }, + { + "markdown": "```\n[foo]: /url\n```\n\n[foo]\n", + "html": "
[foo]: /url\n
\n

[foo]

\n", + "example": 212, + "start_line": 3422, + "end_line": 3432, + "section": "Link reference definitions" + }, + { + "markdown": "Foo\n[bar]: /baz\n\n[bar]\n", + "html": "

Foo\n[bar]: /baz

\n

[bar]

\n", + "example": 213, + "start_line": 3437, + "end_line": 3446, + "section": "Link reference definitions" + }, + { + "markdown": "# [Foo]\n[foo]: /url\n> bar\n", + "html": "

Foo

\n
\n

bar

\n
\n", + "example": 214, + "start_line": 3452, + "end_line": 3461, + "section": "Link reference definitions" + }, + { + "markdown": "[foo]: /url\nbar\n===\n[foo]\n", + "html": "

bar

\n

foo

\n", + "example": 215, + "start_line": 3463, + "end_line": 3471, + "section": "Link reference definitions" + }, + { + "markdown": "[foo]: /url\n===\n[foo]\n", + "html": "

===\nfoo

\n", + "example": 216, + "start_line": 3473, + "end_line": 3480, + "section": "Link reference definitions" + }, + { + "markdown": "[foo]: /foo-url \"foo\"\n[bar]: /bar-url\n \"bar\"\n[baz]: /baz-url\n\n[foo],\n[bar],\n[baz]\n", + "html": "

foo,\nbar,\nbaz

\n", + "example": 217, + "start_line": 3486, + "end_line": 3499, + "section": "Link reference definitions" + }, + { + "markdown": "[foo]\n\n> [foo]: /url\n", + "html": "

foo

\n
\n
\n", + "example": 218, + "start_line": 3507, + "end_line": 3515, + "section": "Link reference definitions" + }, + { + "markdown": "aaa\n\nbbb\n", + "html": "

aaa

\n

bbb

\n", + "example": 219, + "start_line": 3529, + "end_line": 3536, + "section": "Paragraphs" + }, + { + "markdown": "aaa\nbbb\n\nccc\nddd\n", + "html": "

aaa\nbbb

\n

ccc\nddd

\n", + "example": 220, + "start_line": 3541, + "end_line": 3552, + "section": "Paragraphs" + }, + { + "markdown": "aaa\n\n\nbbb\n", + "html": "

aaa

\n

bbb

\n", + "example": 221, + "start_line": 3557, + "end_line": 3565, + "section": "Paragraphs" + }, + { + "markdown": " aaa\n bbb\n", + "html": "

aaa\nbbb

\n", + "example": 222, + "start_line": 3570, + "end_line": 3576, + "section": "Paragraphs" + }, + { + "markdown": "aaa\n bbb\n ccc\n", + "html": "

aaa\nbbb\nccc

\n", + "example": 223, + "start_line": 3582, + "end_line": 3590, + "section": "Paragraphs" + }, + { + "markdown": " aaa\nbbb\n", + "html": "

aaa\nbbb

\n", + "example": 224, + "start_line": 3596, + "end_line": 3602, + "section": "Paragraphs" + }, + { + "markdown": " aaa\nbbb\n", + "html": "
aaa\n
\n

bbb

\n", + "example": 225, + "start_line": 3605, + "end_line": 3612, + "section": "Paragraphs" + }, + { + "markdown": "aaa \nbbb \n", + "html": "

aaa
\nbbb

\n", + "example": 226, + "start_line": 3619, + "end_line": 3625, + "section": "Paragraphs" + }, + { + "markdown": " \n\naaa\n \n\n# aaa\n\n \n", + "html": "

aaa

\n

aaa

\n", + "example": 227, + "start_line": 3636, + "end_line": 3648, + "section": "Blank lines" + }, + { + "markdown": "> # Foo\n> bar\n> baz\n", + "html": "
\n

Foo

\n

bar\nbaz

\n
\n", + "example": 228, + "start_line": 3704, + "end_line": 3714, + "section": "Block quotes" + }, + { + "markdown": "># Foo\n>bar\n> baz\n", + "html": "
\n

Foo

\n

bar\nbaz

\n
\n", + "example": 229, + "start_line": 3719, + "end_line": 3729, + "section": "Block quotes" + }, + { + "markdown": " > # Foo\n > bar\n > baz\n", + "html": "
\n

Foo

\n

bar\nbaz

\n
\n", + "example": 230, + "start_line": 3734, + "end_line": 3744, + "section": "Block quotes" + }, + { + "markdown": " > # Foo\n > bar\n > baz\n", + "html": "
> # Foo\n> bar\n> baz\n
\n", + "example": 231, + "start_line": 3749, + "end_line": 3758, + "section": "Block quotes" + }, + { + "markdown": "> # Foo\n> bar\nbaz\n", + "html": "
\n

Foo

\n

bar\nbaz

\n
\n", + "example": 232, + "start_line": 3764, + "end_line": 3774, + "section": "Block quotes" + }, + { + "markdown": "> bar\nbaz\n> foo\n", + "html": "
\n

bar\nbaz\nfoo

\n
\n", + "example": 233, + "start_line": 3780, + "end_line": 3790, + "section": "Block quotes" + }, + { + "markdown": "> foo\n---\n", + "html": "
\n

foo

\n
\n
\n", + "example": 234, + "start_line": 3804, + "end_line": 3812, + "section": "Block quotes" + }, + { + "markdown": "> - foo\n- bar\n", + "html": "
\n
    \n
  • foo
  • \n
\n
\n
    \n
  • bar
  • \n
\n", + "example": 235, + "start_line": 3824, + "end_line": 3836, + "section": "Block quotes" + }, + { + "markdown": "> foo\n bar\n", + "html": "
\n
foo\n
\n
\n
bar\n
\n", + "example": 236, + "start_line": 3842, + "end_line": 3852, + "section": "Block quotes" + }, + { + "markdown": "> ```\nfoo\n```\n", + "html": "
\n
\n
\n

foo

\n
\n", + "example": 237, + "start_line": 3855, + "end_line": 3865, + "section": "Block quotes" + }, + { + "markdown": "> foo\n - bar\n", + "html": "
\n

foo\n- bar

\n
\n", + "example": 238, + "start_line": 3871, + "end_line": 3879, + "section": "Block quotes" + }, + { + "markdown": ">\n", + "html": "
\n
\n", + "example": 239, + "start_line": 3895, + "end_line": 3900, + "section": "Block quotes" + }, + { + "markdown": ">\n> \n> \n", + "html": "
\n
\n", + "example": 240, + "start_line": 3903, + "end_line": 3910, + "section": "Block quotes" + }, + { + "markdown": ">\n> foo\n> \n", + "html": "
\n

foo

\n
\n", + "example": 241, + "start_line": 3915, + "end_line": 3923, + "section": "Block quotes" + }, + { + "markdown": "> foo\n\n> bar\n", + "html": "
\n

foo

\n
\n
\n

bar

\n
\n", + "example": 242, + "start_line": 3928, + "end_line": 3939, + "section": "Block quotes" + }, + { + "markdown": "> foo\n> bar\n", + "html": "
\n

foo\nbar

\n
\n", + "example": 243, + "start_line": 3950, + "end_line": 3958, + "section": "Block quotes" + }, + { + "markdown": "> foo\n>\n> bar\n", + "html": "
\n

foo

\n

bar

\n
\n", + "example": 244, + "start_line": 3963, + "end_line": 3972, + "section": "Block quotes" + }, + { + "markdown": "foo\n> bar\n", + "html": "

foo

\n
\n

bar

\n
\n", + "example": 245, + "start_line": 3977, + "end_line": 3985, + "section": "Block quotes" + }, + { + "markdown": "> aaa\n***\n> bbb\n", + "html": "
\n

aaa

\n
\n
\n
\n

bbb

\n
\n", + "example": 246, + "start_line": 3991, + "end_line": 4003, + "section": "Block quotes" + }, + { + "markdown": "> bar\nbaz\n", + "html": "
\n

bar\nbaz

\n
\n", + "example": 247, + "start_line": 4009, + "end_line": 4017, + "section": "Block quotes" + }, + { + "markdown": "> bar\n\nbaz\n", + "html": "
\n

bar

\n
\n

baz

\n", + "example": 248, + "start_line": 4020, + "end_line": 4029, + "section": "Block quotes" + }, + { + "markdown": "> bar\n>\nbaz\n", + "html": "
\n

bar

\n
\n

baz

\n", + "example": 249, + "start_line": 4032, + "end_line": 4041, + "section": "Block quotes" + }, + { + "markdown": "> > > foo\nbar\n", + "html": "
\n
\n
\n

foo\nbar

\n
\n
\n
\n", + "example": 250, + "start_line": 4048, + "end_line": 4060, + "section": "Block quotes" + }, + { + "markdown": ">>> foo\n> bar\n>>baz\n", + "html": "
\n
\n
\n

foo\nbar\nbaz

\n
\n
\n
\n", + "example": 251, + "start_line": 4063, + "end_line": 4077, + "section": "Block quotes" + }, + { + "markdown": "> code\n\n> not code\n", + "html": "
\n
code\n
\n
\n
\n

not code

\n
\n", + "example": 252, + "start_line": 4085, + "end_line": 4097, + "section": "Block quotes" + }, + { + "markdown": "A paragraph\nwith two lines.\n\n indented code\n\n> A block quote.\n", + "html": "

A paragraph\nwith two lines.

\n
indented code\n
\n
\n

A block quote.

\n
\n", + "example": 253, + "start_line": 4139, + "end_line": 4154, + "section": "List items" + }, + { + "markdown": "1. A paragraph\n with two lines.\n\n indented code\n\n > A block quote.\n", + "html": "
    \n
  1. \n

    A paragraph\nwith two lines.

    \n
    indented code\n
    \n
    \n

    A block quote.

    \n
    \n
  2. \n
\n", + "example": 254, + "start_line": 4161, + "end_line": 4180, + "section": "List items" + }, + { + "markdown": "- one\n\n two\n", + "html": "
    \n
  • one
  • \n
\n

two

\n", + "example": 255, + "start_line": 4194, + "end_line": 4203, + "section": "List items" + }, + { + "markdown": "- one\n\n two\n", + "html": "
    \n
  • \n

    one

    \n

    two

    \n
  • \n
\n", + "example": 256, + "start_line": 4206, + "end_line": 4217, + "section": "List items" + }, + { + "markdown": " - one\n\n two\n", + "html": "
    \n
  • one
  • \n
\n
 two\n
\n", + "example": 257, + "start_line": 4220, + "end_line": 4230, + "section": "List items" + }, + { + "markdown": " - one\n\n two\n", + "html": "
    \n
  • \n

    one

    \n

    two

    \n
  • \n
\n", + "example": 258, + "start_line": 4233, + "end_line": 4244, + "section": "List items" + }, + { + "markdown": " > > 1. one\n>>\n>> two\n", + "html": "
\n
\n
    \n
  1. \n

    one

    \n

    two

    \n
  2. \n
\n
\n
\n", + "example": 259, + "start_line": 4255, + "end_line": 4270, + "section": "List items" + }, + { + "markdown": ">>- one\n>>\n > > two\n", + "html": "
\n
\n
    \n
  • one
  • \n
\n

two

\n
\n
\n", + "example": 260, + "start_line": 4282, + "end_line": 4295, + "section": "List items" + }, + { + "markdown": "-one\n\n2.two\n", + "html": "

-one

\n

2.two

\n", + "example": 261, + "start_line": 4301, + "end_line": 4308, + "section": "List items" + }, + { + "markdown": "- foo\n\n\n bar\n", + "html": "
    \n
  • \n

    foo

    \n

    bar

    \n
  • \n
\n", + "example": 262, + "start_line": 4314, + "end_line": 4326, + "section": "List items" + }, + { + "markdown": "1. foo\n\n ```\n bar\n ```\n\n baz\n\n > bam\n", + "html": "
    \n
  1. \n

    foo

    \n
    bar\n
    \n

    baz

    \n
    \n

    bam

    \n
    \n
  2. \n
\n", + "example": 263, + "start_line": 4331, + "end_line": 4353, + "section": "List items" + }, + { + "markdown": "- Foo\n\n bar\n\n\n baz\n", + "html": "
    \n
  • \n

    Foo

    \n
    bar\n\n\nbaz\n
    \n
  • \n
\n", + "example": 264, + "start_line": 4359, + "end_line": 4377, + "section": "List items" + }, + { + "markdown": "123456789. ok\n", + "html": "
    \n
  1. ok
  2. \n
\n", + "example": 265, + "start_line": 4381, + "end_line": 4387, + "section": "List items" + }, + { + "markdown": "1234567890. not ok\n", + "html": "

1234567890. not ok

\n", + "example": 266, + "start_line": 4390, + "end_line": 4394, + "section": "List items" + }, + { + "markdown": "0. ok\n", + "html": "
    \n
  1. ok
  2. \n
\n", + "example": 267, + "start_line": 4399, + "end_line": 4405, + "section": "List items" + }, + { + "markdown": "003. ok\n", + "html": "
    \n
  1. ok
  2. \n
\n", + "example": 268, + "start_line": 4408, + "end_line": 4414, + "section": "List items" + }, + { + "markdown": "-1. not ok\n", + "html": "

-1. not ok

\n", + "example": 269, + "start_line": 4419, + "end_line": 4423, + "section": "List items" + }, + { + "markdown": "- foo\n\n bar\n", + "html": "
    \n
  • \n

    foo

    \n
    bar\n
    \n
  • \n
\n", + "example": 270, + "start_line": 4442, + "end_line": 4454, + "section": "List items" + }, + { + "markdown": " 10. foo\n\n bar\n", + "html": "
    \n
  1. \n

    foo

    \n
    bar\n
    \n
  2. \n
\n", + "example": 271, + "start_line": 4459, + "end_line": 4471, + "section": "List items" + }, + { + "markdown": " indented code\n\nparagraph\n\n more code\n", + "html": "
indented code\n
\n

paragraph

\n
more code\n
\n", + "example": 272, + "start_line": 4478, + "end_line": 4490, + "section": "List items" + }, + { + "markdown": "1. indented code\n\n paragraph\n\n more code\n", + "html": "
    \n
  1. \n
    indented code\n
    \n

    paragraph

    \n
    more code\n
    \n
  2. \n
\n", + "example": 273, + "start_line": 4493, + "end_line": 4509, + "section": "List items" + }, + { + "markdown": "1. indented code\n\n paragraph\n\n more code\n", + "html": "
    \n
  1. \n
     indented code\n
    \n

    paragraph

    \n
    more code\n
    \n
  2. \n
\n", + "example": 274, + "start_line": 4515, + "end_line": 4531, + "section": "List items" + }, + { + "markdown": " foo\n\nbar\n", + "html": "

foo

\n

bar

\n", + "example": 275, + "start_line": 4542, + "end_line": 4549, + "section": "List items" + }, + { + "markdown": "- foo\n\n bar\n", + "html": "
    \n
  • foo
  • \n
\n

bar

\n", + "example": 276, + "start_line": 4552, + "end_line": 4561, + "section": "List items" + }, + { + "markdown": "- foo\n\n bar\n", + "html": "
    \n
  • \n

    foo

    \n

    bar

    \n
  • \n
\n", + "example": 277, + "start_line": 4569, + "end_line": 4580, + "section": "List items" + }, + { + "markdown": "-\n foo\n-\n ```\n bar\n ```\n-\n baz\n", + "html": "
    \n
  • foo
  • \n
  • \n
    bar\n
    \n
  • \n
  • \n
    baz\n
    \n
  • \n
\n", + "example": 278, + "start_line": 4596, + "end_line": 4617, + "section": "List items" + }, + { + "markdown": "- \n foo\n", + "html": "
    \n
  • foo
  • \n
\n", + "example": 279, + "start_line": 4622, + "end_line": 4629, + "section": "List items" + }, + { + "markdown": "-\n\n foo\n", + "html": "
    \n
  • \n
\n

foo

\n", + "example": 280, + "start_line": 4636, + "end_line": 4645, + "section": "List items" + }, + { + "markdown": "- foo\n-\n- bar\n", + "html": "
    \n
  • foo
  • \n
  • \n
  • bar
  • \n
\n", + "example": 281, + "start_line": 4650, + "end_line": 4660, + "section": "List items" + }, + { + "markdown": "- foo\n- \n- bar\n", + "html": "
    \n
  • foo
  • \n
  • \n
  • bar
  • \n
\n", + "example": 282, + "start_line": 4665, + "end_line": 4675, + "section": "List items" + }, + { + "markdown": "1. foo\n2.\n3. bar\n", + "html": "
    \n
  1. foo
  2. \n
  3. \n
  4. bar
  5. \n
\n", + "example": 283, + "start_line": 4680, + "end_line": 4690, + "section": "List items" + }, + { + "markdown": "*\n", + "html": "
    \n
  • \n
\n", + "example": 284, + "start_line": 4695, + "end_line": 4701, + "section": "List items" + }, + { + "markdown": "foo\n*\n\nfoo\n1.\n", + "html": "

foo\n*

\n

foo\n1.

\n", + "example": 285, + "start_line": 4705, + "end_line": 4716, + "section": "List items" + }, + { + "markdown": " 1. A paragraph\n with two lines.\n\n indented code\n\n > A block quote.\n", + "html": "
    \n
  1. \n

    A paragraph\nwith two lines.

    \n
    indented code\n
    \n
    \n

    A block quote.

    \n
    \n
  2. \n
\n", + "example": 286, + "start_line": 4727, + "end_line": 4746, + "section": "List items" + }, + { + "markdown": " 1. A paragraph\n with two lines.\n\n indented code\n\n > A block quote.\n", + "html": "
    \n
  1. \n

    A paragraph\nwith two lines.

    \n
    indented code\n
    \n
    \n

    A block quote.

    \n
    \n
  2. \n
\n", + "example": 287, + "start_line": 4751, + "end_line": 4770, + "section": "List items" + }, + { + "markdown": " 1. A paragraph\n with two lines.\n\n indented code\n\n > A block quote.\n", + "html": "
    \n
  1. \n

    A paragraph\nwith two lines.

    \n
    indented code\n
    \n
    \n

    A block quote.

    \n
    \n
  2. \n
\n", + "example": 288, + "start_line": 4775, + "end_line": 4794, + "section": "List items" + }, + { + "markdown": " 1. A paragraph\n with two lines.\n\n indented code\n\n > A block quote.\n", + "html": "
1.  A paragraph\n    with two lines.\n\n        indented code\n\n    > A block quote.\n
\n", + "example": 289, + "start_line": 4799, + "end_line": 4814, + "section": "List items" + }, + { + "markdown": " 1. A paragraph\nwith two lines.\n\n indented code\n\n > A block quote.\n", + "html": "
    \n
  1. \n

    A paragraph\nwith two lines.

    \n
    indented code\n
    \n
    \n

    A block quote.

    \n
    \n
  2. \n
\n", + "example": 290, + "start_line": 4829, + "end_line": 4848, + "section": "List items" + }, + { + "markdown": " 1. A paragraph\n with two lines.\n", + "html": "
    \n
  1. A paragraph\nwith two lines.
  2. \n
\n", + "example": 291, + "start_line": 4853, + "end_line": 4861, + "section": "List items" + }, + { + "markdown": "> 1. > Blockquote\ncontinued here.\n", + "html": "
\n
    \n
  1. \n
    \n

    Blockquote\ncontinued here.

    \n
    \n
  2. \n
\n
\n", + "example": 292, + "start_line": 4866, + "end_line": 4880, + "section": "List items" + }, + { + "markdown": "> 1. > Blockquote\n> continued here.\n", + "html": "
\n
    \n
  1. \n
    \n

    Blockquote\ncontinued here.

    \n
    \n
  2. \n
\n
\n", + "example": 293, + "start_line": 4883, + "end_line": 4897, + "section": "List items" + }, + { + "markdown": "- foo\n - bar\n - baz\n - boo\n", + "html": "
    \n
  • foo\n
      \n
    • bar\n
        \n
      • baz\n
          \n
        • boo
        • \n
        \n
      • \n
      \n
    • \n
    \n
  • \n
\n", + "example": 294, + "start_line": 4911, + "end_line": 4932, + "section": "List items" + }, + { + "markdown": "- foo\n - bar\n - baz\n - boo\n", + "html": "
    \n
  • foo
  • \n
  • bar
  • \n
  • baz
  • \n
  • boo
  • \n
\n", + "example": 295, + "start_line": 4937, + "end_line": 4949, + "section": "List items" + }, + { + "markdown": "10) foo\n - bar\n", + "html": "
    \n
  1. foo\n
      \n
    • bar
    • \n
    \n
  2. \n
\n", + "example": 296, + "start_line": 4954, + "end_line": 4965, + "section": "List items" + }, + { + "markdown": "10) foo\n - bar\n", + "html": "
    \n
  1. foo
  2. \n
\n
    \n
  • bar
  • \n
\n", + "example": 297, + "start_line": 4970, + "end_line": 4980, + "section": "List items" + }, + { + "markdown": "- - foo\n", + "html": "
    \n
  • \n
      \n
    • foo
    • \n
    \n
  • \n
\n", + "example": 298, + "start_line": 4985, + "end_line": 4995, + "section": "List items" + }, + { + "markdown": "1. - 2. foo\n", + "html": "
    \n
  1. \n
      \n
    • \n
        \n
      1. foo
      2. \n
      \n
    • \n
    \n
  2. \n
\n", + "example": 299, + "start_line": 4998, + "end_line": 5012, + "section": "List items" + }, + { + "markdown": "- # Foo\n- Bar\n ---\n baz\n", + "html": "
    \n
  • \n

    Foo

    \n
  • \n
  • \n

    Bar

    \nbaz
  • \n
\n", + "example": 300, + "start_line": 5017, + "end_line": 5031, + "section": "List items" + }, + { + "markdown": "- foo\n- bar\n+ baz\n", + "html": "
    \n
  • foo
  • \n
  • bar
  • \n
\n
    \n
  • baz
  • \n
\n", + "example": 301, + "start_line": 5253, + "end_line": 5265, + "section": "Lists" + }, + { + "markdown": "1. foo\n2. bar\n3) baz\n", + "html": "
    \n
  1. foo
  2. \n
  3. bar
  4. \n
\n
    \n
  1. baz
  2. \n
\n", + "example": 302, + "start_line": 5268, + "end_line": 5280, + "section": "Lists" + }, + { + "markdown": "Foo\n- bar\n- baz\n", + "html": "

Foo

\n
    \n
  • bar
  • \n
  • baz
  • \n
\n", + "example": 303, + "start_line": 5287, + "end_line": 5297, + "section": "Lists" + }, + { + "markdown": "The number of windows in my house is\n14. The number of doors is 6.\n", + "html": "

The number of windows in my house is\n14. The number of doors is 6.

\n", + "example": 304, + "start_line": 5364, + "end_line": 5370, + "section": "Lists" + }, + { + "markdown": "The number of windows in my house is\n1. The number of doors is 6.\n", + "html": "

The number of windows in my house is

\n
    \n
  1. The number of doors is 6.
  2. \n
\n", + "example": 305, + "start_line": 5374, + "end_line": 5382, + "section": "Lists" + }, + { + "markdown": "- foo\n\n- bar\n\n\n- baz\n", + "html": "
    \n
  • \n

    foo

    \n
  • \n
  • \n

    bar

    \n
  • \n
  • \n

    baz

    \n
  • \n
\n", + "example": 306, + "start_line": 5388, + "end_line": 5407, + "section": "Lists" + }, + { + "markdown": "- foo\n - bar\n - baz\n\n\n bim\n", + "html": "
    \n
  • foo\n
      \n
    • bar\n
        \n
      • \n

        baz

        \n

        bim

        \n
      • \n
      \n
    • \n
    \n
  • \n
\n", + "example": 307, + "start_line": 5409, + "end_line": 5431, + "section": "Lists" + }, + { + "markdown": "- foo\n- bar\n\n\n\n- baz\n- bim\n", + "html": "
    \n
  • foo
  • \n
  • bar
  • \n
\n\n
    \n
  • baz
  • \n
  • bim
  • \n
\n", + "example": 308, + "start_line": 5439, + "end_line": 5457, + "section": "Lists" + }, + { + "markdown": "- foo\n\n notcode\n\n- foo\n\n\n\n code\n", + "html": "
    \n
  • \n

    foo

    \n

    notcode

    \n
  • \n
  • \n

    foo

    \n
  • \n
\n\n
code\n
\n", + "example": 309, + "start_line": 5460, + "end_line": 5483, + "section": "Lists" + }, + { + "markdown": "- a\n - b\n - c\n - d\n - e\n - f\n- g\n", + "html": "
    \n
  • a
  • \n
  • b
  • \n
  • c
  • \n
  • d
  • \n
  • e
  • \n
  • f
  • \n
  • g
  • \n
\n", + "example": 310, + "start_line": 5491, + "end_line": 5509, + "section": "Lists" + }, + { + "markdown": "1. a\n\n 2. b\n\n 3. c\n", + "html": "
    \n
  1. \n

    a

    \n
  2. \n
  3. \n

    b

    \n
  4. \n
  5. \n

    c

    \n
  6. \n
\n", + "example": 311, + "start_line": 5512, + "end_line": 5530, + "section": "Lists" + }, + { + "markdown": "- a\n - b\n - c\n - d\n - e\n", + "html": "
    \n
  • a
  • \n
  • b
  • \n
  • c
  • \n
  • d\n- e
  • \n
\n", + "example": 312, + "start_line": 5536, + "end_line": 5550, + "section": "Lists" + }, + { + "markdown": "1. a\n\n 2. b\n\n 3. c\n", + "html": "
    \n
  1. \n

    a

    \n
  2. \n
  3. \n

    b

    \n
  4. \n
\n
3. c\n
\n", + "example": 313, + "start_line": 5556, + "end_line": 5573, + "section": "Lists" + }, + { + "markdown": "- a\n- b\n\n- c\n", + "html": "
    \n
  • \n

    a

    \n
  • \n
  • \n

    b

    \n
  • \n
  • \n

    c

    \n
  • \n
\n", + "example": 314, + "start_line": 5579, + "end_line": 5596, + "section": "Lists" + }, + { + "markdown": "* a\n*\n\n* c\n", + "html": "
    \n
  • \n

    a

    \n
  • \n
  • \n
  • \n

    c

    \n
  • \n
\n", + "example": 315, + "start_line": 5601, + "end_line": 5616, + "section": "Lists" + }, + { + "markdown": "- a\n- b\n\n c\n- d\n", + "html": "
    \n
  • \n

    a

    \n
  • \n
  • \n

    b

    \n

    c

    \n
  • \n
  • \n

    d

    \n
  • \n
\n", + "example": 316, + "start_line": 5623, + "end_line": 5642, + "section": "Lists" + }, + { + "markdown": "- a\n- b\n\n [ref]: /url\n- d\n", + "html": "
    \n
  • \n

    a

    \n
  • \n
  • \n

    b

    \n
  • \n
  • \n

    d

    \n
  • \n
\n", + "example": 317, + "start_line": 5645, + "end_line": 5663, + "section": "Lists" + }, + { + "markdown": "- a\n- ```\n b\n\n\n ```\n- c\n", + "html": "
    \n
  • a
  • \n
  • \n
    b\n\n\n
    \n
  • \n
  • c
  • \n
\n", + "example": 318, + "start_line": 5668, + "end_line": 5687, + "section": "Lists" + }, + { + "markdown": "- a\n - b\n\n c\n- d\n", + "html": "
    \n
  • a\n
      \n
    • \n

      b

      \n

      c

      \n
    • \n
    \n
  • \n
  • d
  • \n
\n", + "example": 319, + "start_line": 5694, + "end_line": 5712, + "section": "Lists" + }, + { + "markdown": "* a\n > b\n >\n* c\n", + "html": "
    \n
  • a\n
    \n

    b

    \n
    \n
  • \n
  • c
  • \n
\n", + "example": 320, + "start_line": 5718, + "end_line": 5732, + "section": "Lists" + }, + { + "markdown": "- a\n > b\n ```\n c\n ```\n- d\n", + "html": "
    \n
  • a\n
    \n

    b

    \n
    \n
    c\n
    \n
  • \n
  • d
  • \n
\n", + "example": 321, + "start_line": 5738, + "end_line": 5756, + "section": "Lists" + }, + { + "markdown": "- a\n", + "html": "
    \n
  • a
  • \n
\n", + "example": 322, + "start_line": 5761, + "end_line": 5767, + "section": "Lists" + }, + { + "markdown": "- a\n - b\n", + "html": "
    \n
  • a\n
      \n
    • b
    • \n
    \n
  • \n
\n", + "example": 323, + "start_line": 5770, + "end_line": 5781, + "section": "Lists" + }, + { + "markdown": "1. ```\n foo\n ```\n\n bar\n", + "html": "
    \n
  1. \n
    foo\n
    \n

    bar

    \n
  2. \n
\n", + "example": 324, + "start_line": 5787, + "end_line": 5801, + "section": "Lists" + }, + { + "markdown": "* foo\n * bar\n\n baz\n", + "html": "
    \n
  • \n

    foo

    \n
      \n
    • bar
    • \n
    \n

    baz

    \n
  • \n
\n", + "example": 325, + "start_line": 5806, + "end_line": 5821, + "section": "Lists" + }, + { + "markdown": "- a\n - b\n - c\n\n- d\n - e\n - f\n", + "html": "
    \n
  • \n

    a

    \n
      \n
    • b
    • \n
    • c
    • \n
    \n
  • \n
  • \n

    d

    \n
      \n
    • e
    • \n
    • f
    • \n
    \n
  • \n
\n", + "example": 326, + "start_line": 5824, + "end_line": 5849, + "section": "Lists" + }, + { + "markdown": "`hi`lo`\n", + "html": "

hilo`

\n", + "example": 327, + "start_line": 5858, + "end_line": 5862, + "section": "Inlines" + }, + { + "markdown": "`foo`\n", + "html": "

foo

\n", + "example": 328, + "start_line": 5890, + "end_line": 5894, + "section": "Code spans" + }, + { + "markdown": "`` foo ` bar ``\n", + "html": "

foo ` bar

\n", + "example": 329, + "start_line": 5901, + "end_line": 5905, + "section": "Code spans" + }, + { + "markdown": "` `` `\n", + "html": "

``

\n", + "example": 330, + "start_line": 5911, + "end_line": 5915, + "section": "Code spans" + }, + { + "markdown": "` `` `\n", + "html": "

``

\n", + "example": 331, + "start_line": 5919, + "end_line": 5923, + "section": "Code spans" + }, + { + "markdown": "` a`\n", + "html": "

a

\n", + "example": 332, + "start_line": 5928, + "end_line": 5932, + "section": "Code spans" + }, + { + "markdown": "` b `\n", + "html": "

 b 

\n", + "example": 333, + "start_line": 5937, + "end_line": 5941, + "section": "Code spans" + }, + { + "markdown": "` `\n` `\n", + "html": "

 \n

\n", + "example": 334, + "start_line": 5945, + "end_line": 5951, + "section": "Code spans" + }, + { + "markdown": "``\nfoo\nbar \nbaz\n``\n", + "html": "

foo bar baz

\n", + "example": 335, + "start_line": 5956, + "end_line": 5964, + "section": "Code spans" + }, + { + "markdown": "``\nfoo \n``\n", + "html": "

foo

\n", + "example": 336, + "start_line": 5966, + "end_line": 5972, + "section": "Code spans" + }, + { + "markdown": "`foo bar \nbaz`\n", + "html": "

foo bar baz

\n", + "example": 337, + "start_line": 5977, + "end_line": 5982, + "section": "Code spans" + }, + { + "markdown": "`foo\\`bar`\n", + "html": "

foo\\bar`

\n", + "example": 338, + "start_line": 5994, + "end_line": 5998, + "section": "Code spans" + }, + { + "markdown": "``foo`bar``\n", + "html": "

foo`bar

\n", + "example": 339, + "start_line": 6005, + "end_line": 6009, + "section": "Code spans" + }, + { + "markdown": "` foo `` bar `\n", + "html": "

foo `` bar

\n", + "example": 340, + "start_line": 6011, + "end_line": 6015, + "section": "Code spans" + }, + { + "markdown": "*foo`*`\n", + "html": "

*foo*

\n", + "example": 341, + "start_line": 6023, + "end_line": 6027, + "section": "Code spans" + }, + { + "markdown": "[not a `link](/foo`)\n", + "html": "

[not a link](/foo)

\n", + "example": 342, + "start_line": 6032, + "end_line": 6036, + "section": "Code spans" + }, + { + "markdown": "``\n", + "html": "

<a href="">`

\n", + "example": 343, + "start_line": 6042, + "end_line": 6046, + "section": "Code spans" + }, + { + "markdown": "
`\n", + "html": "

`

\n", + "example": 344, + "start_line": 6051, + "end_line": 6055, + "section": "Code spans" + }, + { + "markdown": "``\n", + "html": "

<http://foo.bar.baz>`

\n", + "example": 345, + "start_line": 6060, + "end_line": 6064, + "section": "Code spans" + }, + { + "markdown": "`\n", + "html": "

http://foo.bar.`baz`

\n", + "example": 346, + "start_line": 6069, + "end_line": 6073, + "section": "Code spans" + }, + { + "markdown": "```foo``\n", + "html": "

```foo``

\n", + "example": 347, + "start_line": 6079, + "end_line": 6083, + "section": "Code spans" + }, + { + "markdown": "`foo\n", + "html": "

`foo

\n", + "example": 348, + "start_line": 6086, + "end_line": 6090, + "section": "Code spans" + }, + { + "markdown": "`foo``bar``\n", + "html": "

`foobar

\n", + "example": 349, + "start_line": 6095, + "end_line": 6099, + "section": "Code spans" + }, + { + "markdown": "*foo bar*\n", + "html": "

foo bar

\n", + "example": 350, + "start_line": 6312, + "end_line": 6316, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "a * foo bar*\n", + "html": "

a * foo bar*

\n", + "example": 351, + "start_line": 6322, + "end_line": 6326, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "a*\"foo\"*\n", + "html": "

a*"foo"*

\n", + "example": 352, + "start_line": 6333, + "end_line": 6337, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "* a *\n", + "html": "

* a *

\n", + "example": 353, + "start_line": 6342, + "end_line": 6346, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "foo*bar*\n", + "html": "

foobar

\n", + "example": 354, + "start_line": 6351, + "end_line": 6355, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "5*6*78\n", + "html": "

5678

\n", + "example": 355, + "start_line": 6358, + "end_line": 6362, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "_foo bar_\n", + "html": "

foo bar

\n", + "example": 356, + "start_line": 6367, + "end_line": 6371, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "_ foo bar_\n", + "html": "

_ foo bar_

\n", + "example": 357, + "start_line": 6377, + "end_line": 6381, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "a_\"foo\"_\n", + "html": "

a_"foo"_

\n", + "example": 358, + "start_line": 6387, + "end_line": 6391, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "foo_bar_\n", + "html": "

foo_bar_

\n", + "example": 359, + "start_line": 6396, + "end_line": 6400, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "5_6_78\n", + "html": "

5_6_78

\n", + "example": 360, + "start_line": 6403, + "end_line": 6407, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "пристаням_стремятся_\n", + "html": "

пристаням_стремятся_

\n", + "example": 361, + "start_line": 6410, + "end_line": 6414, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "aa_\"bb\"_cc\n", + "html": "

aa_"bb"_cc

\n", + "example": 362, + "start_line": 6420, + "end_line": 6424, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "foo-_(bar)_\n", + "html": "

foo-(bar)

\n", + "example": 363, + "start_line": 6431, + "end_line": 6435, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "_foo*\n", + "html": "

_foo*

\n", + "example": 364, + "start_line": 6443, + "end_line": 6447, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*foo bar *\n", + "html": "

*foo bar *

\n", + "example": 365, + "start_line": 6453, + "end_line": 6457, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*foo bar\n*\n", + "html": "

*foo bar\n*

\n", + "example": 366, + "start_line": 6462, + "end_line": 6468, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*(*foo)\n", + "html": "

*(*foo)

\n", + "example": 367, + "start_line": 6475, + "end_line": 6479, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*(*foo*)*\n", + "html": "

(foo)

\n", + "example": 368, + "start_line": 6485, + "end_line": 6489, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*foo*bar\n", + "html": "

foobar

\n", + "example": 369, + "start_line": 6494, + "end_line": 6498, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "_foo bar _\n", + "html": "

_foo bar _

\n", + "example": 370, + "start_line": 6507, + "end_line": 6511, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "_(_foo)\n", + "html": "

_(_foo)

\n", + "example": 371, + "start_line": 6517, + "end_line": 6521, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "_(_foo_)_\n", + "html": "

(foo)

\n", + "example": 372, + "start_line": 6526, + "end_line": 6530, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "_foo_bar\n", + "html": "

_foo_bar

\n", + "example": 373, + "start_line": 6535, + "end_line": 6539, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "_пристаням_стремятся\n", + "html": "

_пристаням_стремятся

\n", + "example": 374, + "start_line": 6542, + "end_line": 6546, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "_foo_bar_baz_\n", + "html": "

foo_bar_baz

\n", + "example": 375, + "start_line": 6549, + "end_line": 6553, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "_(bar)_.\n", + "html": "

(bar).

\n", + "example": 376, + "start_line": 6560, + "end_line": 6564, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "**foo bar**\n", + "html": "

foo bar

\n", + "example": 377, + "start_line": 6569, + "end_line": 6573, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "** foo bar**\n", + "html": "

** foo bar**

\n", + "example": 378, + "start_line": 6579, + "end_line": 6583, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "a**\"foo\"**\n", + "html": "

a**"foo"**

\n", + "example": 379, + "start_line": 6590, + "end_line": 6594, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "foo**bar**\n", + "html": "

foobar

\n", + "example": 380, + "start_line": 6599, + "end_line": 6603, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "__foo bar__\n", + "html": "

foo bar

\n", + "example": 381, + "start_line": 6608, + "end_line": 6612, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "__ foo bar__\n", + "html": "

__ foo bar__

\n", + "example": 382, + "start_line": 6618, + "end_line": 6622, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "__\nfoo bar__\n", + "html": "

__\nfoo bar__

\n", + "example": 383, + "start_line": 6626, + "end_line": 6632, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "a__\"foo\"__\n", + "html": "

a__"foo"__

\n", + "example": 384, + "start_line": 6638, + "end_line": 6642, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "foo__bar__\n", + "html": "

foo__bar__

\n", + "example": 385, + "start_line": 6647, + "end_line": 6651, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "5__6__78\n", + "html": "

5__6__78

\n", + "example": 386, + "start_line": 6654, + "end_line": 6658, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "пристаням__стремятся__\n", + "html": "

пристаням__стремятся__

\n", + "example": 387, + "start_line": 6661, + "end_line": 6665, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "__foo, __bar__, baz__\n", + "html": "

foo, bar, baz

\n", + "example": 388, + "start_line": 6668, + "end_line": 6672, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "foo-__(bar)__\n", + "html": "

foo-(bar)

\n", + "example": 389, + "start_line": 6679, + "end_line": 6683, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "**foo bar **\n", + "html": "

**foo bar **

\n", + "example": 390, + "start_line": 6692, + "end_line": 6696, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "**(**foo)\n", + "html": "

**(**foo)

\n", + "example": 391, + "start_line": 6705, + "end_line": 6709, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*(**foo**)*\n", + "html": "

(foo)

\n", + "example": 392, + "start_line": 6715, + "end_line": 6719, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "**Gomphocarpus (*Gomphocarpus physocarpus*, syn.\n*Asclepias physocarpa*)**\n", + "html": "

Gomphocarpus (Gomphocarpus physocarpus, syn.\nAsclepias physocarpa)

\n", + "example": 393, + "start_line": 6722, + "end_line": 6728, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "**foo \"*bar*\" foo**\n", + "html": "

foo "bar" foo

\n", + "example": 394, + "start_line": 6731, + "end_line": 6735, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "**foo**bar\n", + "html": "

foobar

\n", + "example": 395, + "start_line": 6740, + "end_line": 6744, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "__foo bar __\n", + "html": "

__foo bar __

\n", + "example": 396, + "start_line": 6752, + "end_line": 6756, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "__(__foo)\n", + "html": "

__(__foo)

\n", + "example": 397, + "start_line": 6762, + "end_line": 6766, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "_(__foo__)_\n", + "html": "

(foo)

\n", + "example": 398, + "start_line": 6772, + "end_line": 6776, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "__foo__bar\n", + "html": "

__foo__bar

\n", + "example": 399, + "start_line": 6781, + "end_line": 6785, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "__пристаням__стремятся\n", + "html": "

__пристаням__стремятся

\n", + "example": 400, + "start_line": 6788, + "end_line": 6792, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "__foo__bar__baz__\n", + "html": "

foo__bar__baz

\n", + "example": 401, + "start_line": 6795, + "end_line": 6799, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "__(bar)__.\n", + "html": "

(bar).

\n", + "example": 402, + "start_line": 6806, + "end_line": 6810, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*foo [bar](/url)*\n", + "html": "

foo bar

\n", + "example": 403, + "start_line": 6818, + "end_line": 6822, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*foo\nbar*\n", + "html": "

foo\nbar

\n", + "example": 404, + "start_line": 6825, + "end_line": 6831, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "_foo __bar__ baz_\n", + "html": "

foo bar baz

\n", + "example": 405, + "start_line": 6837, + "end_line": 6841, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "_foo _bar_ baz_\n", + "html": "

foo bar baz

\n", + "example": 406, + "start_line": 6844, + "end_line": 6848, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "__foo_ bar_\n", + "html": "

foo bar

\n", + "example": 407, + "start_line": 6851, + "end_line": 6855, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*foo *bar**\n", + "html": "

foo bar

\n", + "example": 408, + "start_line": 6858, + "end_line": 6862, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*foo **bar** baz*\n", + "html": "

foo bar baz

\n", + "example": 409, + "start_line": 6865, + "end_line": 6869, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*foo**bar**baz*\n", + "html": "

foobarbaz

\n", + "example": 410, + "start_line": 6871, + "end_line": 6875, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*foo**bar*\n", + "html": "

foo**bar

\n", + "example": 411, + "start_line": 6895, + "end_line": 6899, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "***foo** bar*\n", + "html": "

foo bar

\n", + "example": 412, + "start_line": 6908, + "end_line": 6912, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*foo **bar***\n", + "html": "

foo bar

\n", + "example": 413, + "start_line": 6915, + "end_line": 6919, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*foo**bar***\n", + "html": "

foobar

\n", + "example": 414, + "start_line": 6922, + "end_line": 6926, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "foo***bar***baz\n", + "html": "

foobarbaz

\n", + "example": 415, + "start_line": 6933, + "end_line": 6937, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "foo******bar*********baz\n", + "html": "

foobar***baz

\n", + "example": 416, + "start_line": 6939, + "end_line": 6943, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*foo **bar *baz* bim** bop*\n", + "html": "

foo bar baz bim bop

\n", + "example": 417, + "start_line": 6948, + "end_line": 6952, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*foo [*bar*](/url)*\n", + "html": "

foo bar

\n", + "example": 418, + "start_line": 6955, + "end_line": 6959, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "** is not an empty emphasis\n", + "html": "

** is not an empty emphasis

\n", + "example": 419, + "start_line": 6964, + "end_line": 6968, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "**** is not an empty strong emphasis\n", + "html": "

**** is not an empty strong emphasis

\n", + "example": 420, + "start_line": 6971, + "end_line": 6975, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "**foo [bar](/url)**\n", + "html": "

foo bar

\n", + "example": 421, + "start_line": 6984, + "end_line": 6988, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "**foo\nbar**\n", + "html": "

foo\nbar

\n", + "example": 422, + "start_line": 6991, + "end_line": 6997, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "__foo _bar_ baz__\n", + "html": "

foo bar baz

\n", + "example": 423, + "start_line": 7003, + "end_line": 7007, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "__foo __bar__ baz__\n", + "html": "

foo bar baz

\n", + "example": 424, + "start_line": 7010, + "end_line": 7014, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "____foo__ bar__\n", + "html": "

foo bar

\n", + "example": 425, + "start_line": 7017, + "end_line": 7021, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "**foo **bar****\n", + "html": "

foo bar

\n", + "example": 426, + "start_line": 7024, + "end_line": 7028, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "**foo *bar* baz**\n", + "html": "

foo bar baz

\n", + "example": 427, + "start_line": 7031, + "end_line": 7035, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "**foo*bar*baz**\n", + "html": "

foobarbaz

\n", + "example": 428, + "start_line": 7038, + "end_line": 7042, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "***foo* bar**\n", + "html": "

foo bar

\n", + "example": 429, + "start_line": 7045, + "end_line": 7049, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "**foo *bar***\n", + "html": "

foo bar

\n", + "example": 430, + "start_line": 7052, + "end_line": 7056, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "**foo *bar **baz**\nbim* bop**\n", + "html": "

foo bar baz\nbim bop

\n", + "example": 431, + "start_line": 7061, + "end_line": 7067, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "**foo [*bar*](/url)**\n", + "html": "

foo bar

\n", + "example": 432, + "start_line": 7070, + "end_line": 7074, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "__ is not an empty emphasis\n", + "html": "

__ is not an empty emphasis

\n", + "example": 433, + "start_line": 7079, + "end_line": 7083, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "____ is not an empty strong emphasis\n", + "html": "

____ is not an empty strong emphasis

\n", + "example": 434, + "start_line": 7086, + "end_line": 7090, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "foo ***\n", + "html": "

foo ***

\n", + "example": 435, + "start_line": 7096, + "end_line": 7100, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "foo *\\**\n", + "html": "

foo *

\n", + "example": 436, + "start_line": 7103, + "end_line": 7107, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "foo *_*\n", + "html": "

foo _

\n", + "example": 437, + "start_line": 7110, + "end_line": 7114, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "foo *****\n", + "html": "

foo *****

\n", + "example": 438, + "start_line": 7117, + "end_line": 7121, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "foo **\\***\n", + "html": "

foo *

\n", + "example": 439, + "start_line": 7124, + "end_line": 7128, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "foo **_**\n", + "html": "

foo _

\n", + "example": 440, + "start_line": 7131, + "end_line": 7135, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "**foo*\n", + "html": "

*foo

\n", + "example": 441, + "start_line": 7142, + "end_line": 7146, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*foo**\n", + "html": "

foo*

\n", + "example": 442, + "start_line": 7149, + "end_line": 7153, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "***foo**\n", + "html": "

*foo

\n", + "example": 443, + "start_line": 7156, + "end_line": 7160, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "****foo*\n", + "html": "

***foo

\n", + "example": 444, + "start_line": 7163, + "end_line": 7167, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "**foo***\n", + "html": "

foo*

\n", + "example": 445, + "start_line": 7170, + "end_line": 7174, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*foo****\n", + "html": "

foo***

\n", + "example": 446, + "start_line": 7177, + "end_line": 7181, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "foo ___\n", + "html": "

foo ___

\n", + "example": 447, + "start_line": 7187, + "end_line": 7191, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "foo _\\__\n", + "html": "

foo _

\n", + "example": 448, + "start_line": 7194, + "end_line": 7198, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "foo _*_\n", + "html": "

foo *

\n", + "example": 449, + "start_line": 7201, + "end_line": 7205, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "foo _____\n", + "html": "

foo _____

\n", + "example": 450, + "start_line": 7208, + "end_line": 7212, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "foo __\\___\n", + "html": "

foo _

\n", + "example": 451, + "start_line": 7215, + "end_line": 7219, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "foo __*__\n", + "html": "

foo *

\n", + "example": 452, + "start_line": 7222, + "end_line": 7226, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "__foo_\n", + "html": "

_foo

\n", + "example": 453, + "start_line": 7229, + "end_line": 7233, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "_foo__\n", + "html": "

foo_

\n", + "example": 454, + "start_line": 7240, + "end_line": 7244, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "___foo__\n", + "html": "

_foo

\n", + "example": 455, + "start_line": 7247, + "end_line": 7251, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "____foo_\n", + "html": "

___foo

\n", + "example": 456, + "start_line": 7254, + "end_line": 7258, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "__foo___\n", + "html": "

foo_

\n", + "example": 457, + "start_line": 7261, + "end_line": 7265, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "_foo____\n", + "html": "

foo___

\n", + "example": 458, + "start_line": 7268, + "end_line": 7272, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "**foo**\n", + "html": "

foo

\n", + "example": 459, + "start_line": 7278, + "end_line": 7282, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*_foo_*\n", + "html": "

foo

\n", + "example": 460, + "start_line": 7285, + "end_line": 7289, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "__foo__\n", + "html": "

foo

\n", + "example": 461, + "start_line": 7292, + "end_line": 7296, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "_*foo*_\n", + "html": "

foo

\n", + "example": 462, + "start_line": 7299, + "end_line": 7303, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "****foo****\n", + "html": "

foo

\n", + "example": 463, + "start_line": 7309, + "end_line": 7313, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "____foo____\n", + "html": "

foo

\n", + "example": 464, + "start_line": 7316, + "end_line": 7320, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "******foo******\n", + "html": "

foo

\n", + "example": 465, + "start_line": 7327, + "end_line": 7331, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "***foo***\n", + "html": "

foo

\n", + "example": 466, + "start_line": 7336, + "end_line": 7340, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "_____foo_____\n", + "html": "

foo

\n", + "example": 467, + "start_line": 7343, + "end_line": 7347, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*foo _bar* baz_\n", + "html": "

foo _bar baz_

\n", + "example": 468, + "start_line": 7352, + "end_line": 7356, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*foo __bar *baz bim__ bam*\n", + "html": "

foo bar *baz bim bam

\n", + "example": 469, + "start_line": 7359, + "end_line": 7363, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "**foo **bar baz**\n", + "html": "

**foo bar baz

\n", + "example": 470, + "start_line": 7368, + "end_line": 7372, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*foo *bar baz*\n", + "html": "

*foo bar baz

\n", + "example": 471, + "start_line": 7375, + "end_line": 7379, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*[bar*](/url)\n", + "html": "

*bar*

\n", + "example": 472, + "start_line": 7384, + "end_line": 7388, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "_foo [bar_](/url)\n", + "html": "

_foo bar_

\n", + "example": 473, + "start_line": 7391, + "end_line": 7395, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*\n", + "html": "

*

\n", + "example": 474, + "start_line": 7398, + "end_line": 7402, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "**\n", + "html": "

**

\n", + "example": 475, + "start_line": 7405, + "end_line": 7409, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "__\n", + "html": "

__

\n", + "example": 476, + "start_line": 7412, + "end_line": 7416, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*a `*`*\n", + "html": "

a *

\n", + "example": 477, + "start_line": 7419, + "end_line": 7423, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "_a `_`_\n", + "html": "

a _

\n", + "example": 478, + "start_line": 7426, + "end_line": 7430, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "**a\n", + "html": "

**ahttp://foo.bar/?q=**

\n", + "example": 479, + "start_line": 7433, + "end_line": 7437, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "__a\n", + "html": "

__ahttp://foo.bar/?q=__

\n", + "example": 480, + "start_line": 7440, + "end_line": 7444, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "[link](/uri \"title\")\n", + "html": "

link

\n", + "example": 481, + "start_line": 7528, + "end_line": 7532, + "section": "Links" + }, + { + "markdown": "[link](/uri)\n", + "html": "

link

\n", + "example": 482, + "start_line": 7538, + "end_line": 7542, + "section": "Links" + }, + { + "markdown": "[](./target.md)\n", + "html": "

\n", + "example": 483, + "start_line": 7544, + "end_line": 7548, + "section": "Links" + }, + { + "markdown": "[link]()\n", + "html": "

link

\n", + "example": 484, + "start_line": 7551, + "end_line": 7555, + "section": "Links" + }, + { + "markdown": "[link](<>)\n", + "html": "

link

\n", + "example": 485, + "start_line": 7558, + "end_line": 7562, + "section": "Links" + }, + { + "markdown": "[]()\n", + "html": "

\n", + "example": 486, + "start_line": 7565, + "end_line": 7569, + "section": "Links" + }, + { + "markdown": "[link](/my uri)\n", + "html": "

[link](/my uri)

\n", + "example": 487, + "start_line": 7574, + "end_line": 7578, + "section": "Links" + }, + { + "markdown": "[link](
)\n", + "html": "

link

\n", + "example": 488, + "start_line": 7580, + "end_line": 7584, + "section": "Links" + }, + { + "markdown": "[link](foo\nbar)\n", + "html": "

[link](foo\nbar)

\n", + "example": 489, + "start_line": 7589, + "end_line": 7595, + "section": "Links" + }, + { + "markdown": "[link]()\n", + "html": "

[link]()

\n", + "example": 490, + "start_line": 7597, + "end_line": 7603, + "section": "Links" + }, + { + "markdown": "[a]()\n", + "html": "

a

\n", + "example": 491, + "start_line": 7608, + "end_line": 7612, + "section": "Links" + }, + { + "markdown": "[link]()\n", + "html": "

[link](<foo>)

\n", + "example": 492, + "start_line": 7616, + "end_line": 7620, + "section": "Links" + }, + { + "markdown": "[a](\n[a](c)\n", + "html": "

[a](<b)c\n[a](<b)c>\n[a](c)

\n", + "example": 493, + "start_line": 7625, + "end_line": 7633, + "section": "Links" + }, + { + "markdown": "[link](\\(foo\\))\n", + "html": "

link

\n", + "example": 494, + "start_line": 7637, + "end_line": 7641, + "section": "Links" + }, + { + "markdown": "[link](foo(and(bar)))\n", + "html": "

link

\n", + "example": 495, + "start_line": 7646, + "end_line": 7650, + "section": "Links" + }, + { + "markdown": "[link](foo(and(bar))\n", + "html": "

[link](foo(and(bar))

\n", + "example": 496, + "start_line": 7655, + "end_line": 7659, + "section": "Links" + }, + { + "markdown": "[link](foo\\(and\\(bar\\))\n", + "html": "

link

\n", + "example": 497, + "start_line": 7662, + "end_line": 7666, + "section": "Links" + }, + { + "markdown": "[link]()\n", + "html": "

link

\n", + "example": 498, + "start_line": 7669, + "end_line": 7673, + "section": "Links" + }, + { + "markdown": "[link](foo\\)\\:)\n", + "html": "

link

\n", + "example": 499, + "start_line": 7679, + "end_line": 7683, + "section": "Links" + }, + { + "markdown": "[link](#fragment)\n\n[link](http://example.com#fragment)\n\n[link](http://example.com?foo=3#frag)\n", + "html": "

link

\n

link

\n

link

\n", + "example": 500, + "start_line": 7688, + "end_line": 7698, + "section": "Links" + }, + { + "markdown": "[link](foo\\bar)\n", + "html": "

link

\n", + "example": 501, + "start_line": 7704, + "end_line": 7708, + "section": "Links" + }, + { + "markdown": "[link](foo%20bä)\n", + "html": "

link

\n", + "example": 502, + "start_line": 7720, + "end_line": 7724, + "section": "Links" + }, + { + "markdown": "[link](\"title\")\n", + "html": "

link

\n", + "example": 503, + "start_line": 7731, + "end_line": 7735, + "section": "Links" + }, + { + "markdown": "[link](/url \"title\")\n[link](/url 'title')\n[link](/url (title))\n", + "html": "

link\nlink\nlink

\n", + "example": 504, + "start_line": 7740, + "end_line": 7748, + "section": "Links" + }, + { + "markdown": "[link](/url \"title \\\""\")\n", + "html": "

link

\n", + "example": 505, + "start_line": 7754, + "end_line": 7758, + "section": "Links" + }, + { + "markdown": "[link](/url \"title\")\n", + "html": "

link

\n", + "example": 506, + "start_line": 7765, + "end_line": 7769, + "section": "Links" + }, + { + "markdown": "[link](/url \"title \"and\" title\")\n", + "html": "

[link](/url "title "and" title")

\n", + "example": 507, + "start_line": 7774, + "end_line": 7778, + "section": "Links" + }, + { + "markdown": "[link](/url 'title \"and\" title')\n", + "html": "

link

\n", + "example": 508, + "start_line": 7783, + "end_line": 7787, + "section": "Links" + }, + { + "markdown": "[link]( /uri\n \"title\" )\n", + "html": "

link

\n", + "example": 509, + "start_line": 7808, + "end_line": 7813, + "section": "Links" + }, + { + "markdown": "[link] (/uri)\n", + "html": "

[link] (/uri)

\n", + "example": 510, + "start_line": 7819, + "end_line": 7823, + "section": "Links" + }, + { + "markdown": "[link [foo [bar]]](/uri)\n", + "html": "

link [foo [bar]]

\n", + "example": 511, + "start_line": 7829, + "end_line": 7833, + "section": "Links" + }, + { + "markdown": "[link] bar](/uri)\n", + "html": "

[link] bar](/uri)

\n", + "example": 512, + "start_line": 7836, + "end_line": 7840, + "section": "Links" + }, + { + "markdown": "[link [bar](/uri)\n", + "html": "

[link bar

\n", + "example": 513, + "start_line": 7843, + "end_line": 7847, + "section": "Links" + }, + { + "markdown": "[link \\[bar](/uri)\n", + "html": "

link [bar

\n", + "example": 514, + "start_line": 7850, + "end_line": 7854, + "section": "Links" + }, + { + "markdown": "[link *foo **bar** `#`*](/uri)\n", + "html": "

link foo bar #

\n", + "example": 515, + "start_line": 7859, + "end_line": 7863, + "section": "Links" + }, + { + "markdown": "[![moon](moon.jpg)](/uri)\n", + "html": "

\"moon\"

\n", + "example": 516, + "start_line": 7866, + "end_line": 7870, + "section": "Links" + }, + { + "markdown": "[foo [bar](/uri)](/uri)\n", + "html": "

[foo bar](/uri)

\n", + "example": 517, + "start_line": 7875, + "end_line": 7879, + "section": "Links" + }, + { + "markdown": "[foo *[bar [baz](/uri)](/uri)*](/uri)\n", + "html": "

[foo [bar baz](/uri)](/uri)

\n", + "example": 518, + "start_line": 7882, + "end_line": 7886, + "section": "Links" + }, + { + "markdown": "![[[foo](uri1)](uri2)](uri3)\n", + "html": "

\"[foo](uri2)\"

\n", + "example": 519, + "start_line": 7889, + "end_line": 7893, + "section": "Links" + }, + { + "markdown": "*[foo*](/uri)\n", + "html": "

*foo*

\n", + "example": 520, + "start_line": 7899, + "end_line": 7903, + "section": "Links" + }, + { + "markdown": "[foo *bar](baz*)\n", + "html": "

foo *bar

\n", + "example": 521, + "start_line": 7906, + "end_line": 7910, + "section": "Links" + }, + { + "markdown": "*foo [bar* baz]\n", + "html": "

foo [bar baz]

\n", + "example": 522, + "start_line": 7916, + "end_line": 7920, + "section": "Links" + }, + { + "markdown": "[foo \n", + "html": "

[foo

\n", + "example": 523, + "start_line": 7926, + "end_line": 7930, + "section": "Links" + }, + { + "markdown": "[foo`](/uri)`\n", + "html": "

[foo](/uri)

\n", + "example": 524, + "start_line": 7933, + "end_line": 7937, + "section": "Links" + }, + { + "markdown": "[foo\n", + "html": "

[foohttp://example.com/?search=](uri)

\n", + "example": 525, + "start_line": 7940, + "end_line": 7944, + "section": "Links" + }, + { + "markdown": "[foo][bar]\n\n[bar]: /url \"title\"\n", + "html": "

foo

\n", + "example": 526, + "start_line": 7978, + "end_line": 7984, + "section": "Links" + }, + { + "markdown": "[link [foo [bar]]][ref]\n\n[ref]: /uri\n", + "html": "

link [foo [bar]]

\n", + "example": 527, + "start_line": 7993, + "end_line": 7999, + "section": "Links" + }, + { + "markdown": "[link \\[bar][ref]\n\n[ref]: /uri\n", + "html": "

link [bar

\n", + "example": 528, + "start_line": 8002, + "end_line": 8008, + "section": "Links" + }, + { + "markdown": "[link *foo **bar** `#`*][ref]\n\n[ref]: /uri\n", + "html": "

link foo bar #

\n", + "example": 529, + "start_line": 8013, + "end_line": 8019, + "section": "Links" + }, + { + "markdown": "[![moon](moon.jpg)][ref]\n\n[ref]: /uri\n", + "html": "

\"moon\"

\n", + "example": 530, + "start_line": 8022, + "end_line": 8028, + "section": "Links" + }, + { + "markdown": "[foo [bar](/uri)][ref]\n\n[ref]: /uri\n", + "html": "

[foo bar]ref

\n", + "example": 531, + "start_line": 8033, + "end_line": 8039, + "section": "Links" + }, + { + "markdown": "[foo *bar [baz][ref]*][ref]\n\n[ref]: /uri\n", + "html": "

[foo bar baz]ref

\n", + "example": 532, + "start_line": 8042, + "end_line": 8048, + "section": "Links" + }, + { + "markdown": "*[foo*][ref]\n\n[ref]: /uri\n", + "html": "

*foo*

\n", + "example": 533, + "start_line": 8057, + "end_line": 8063, + "section": "Links" + }, + { + "markdown": "[foo *bar][ref]*\n\n[ref]: /uri\n", + "html": "

foo *bar*

\n", + "example": 534, + "start_line": 8066, + "end_line": 8072, + "section": "Links" + }, + { + "markdown": "[foo \n\n[ref]: /uri\n", + "html": "

[foo

\n", + "example": 535, + "start_line": 8078, + "end_line": 8084, + "section": "Links" + }, + { + "markdown": "[foo`][ref]`\n\n[ref]: /uri\n", + "html": "

[foo][ref]

\n", + "example": 536, + "start_line": 8087, + "end_line": 8093, + "section": "Links" + }, + { + "markdown": "[foo\n\n[ref]: /uri\n", + "html": "

[foohttp://example.com/?search=][ref]

\n", + "example": 537, + "start_line": 8096, + "end_line": 8102, + "section": "Links" + }, + { + "markdown": "[foo][BaR]\n\n[bar]: /url \"title\"\n", + "html": "

foo

\n", + "example": 538, + "start_line": 8107, + "end_line": 8113, + "section": "Links" + }, + { + "markdown": "[ẞ]\n\n[SS]: /url\n", + "html": "

ẞ

\n", + "example": 539, + "start_line": 8118, + "end_line": 8124, + "section": "Links" + }, + { + "markdown": "[Foo\n bar]: /url\n\n[Baz][Foo bar]\n", + "html": "

Baz

\n", + "example": 540, + "start_line": 8130, + "end_line": 8137, + "section": "Links" + }, + { + "markdown": "[foo] [bar]\n\n[bar]: /url \"title\"\n", + "html": "

[foo] bar

\n", + "example": 541, + "start_line": 8143, + "end_line": 8149, + "section": "Links" + }, + { + "markdown": "[foo]\n[bar]\n\n[bar]: /url \"title\"\n", + "html": "

[foo]\nbar

\n", + "example": 542, + "start_line": 8152, + "end_line": 8160, + "section": "Links" + }, + { + "markdown": "[foo]: /url1\n\n[foo]: /url2\n\n[bar][foo]\n", + "html": "

bar

\n", + "example": 543, + "start_line": 8193, + "end_line": 8201, + "section": "Links" + }, + { + "markdown": "[bar][foo\\!]\n\n[foo!]: /url\n", + "html": "

[bar][foo!]

\n", + "example": 544, + "start_line": 8208, + "end_line": 8214, + "section": "Links" + }, + { + "markdown": "[foo][ref[]\n\n[ref[]: /uri\n", + "html": "

[foo][ref[]

\n

[ref[]: /uri

\n", + "example": 545, + "start_line": 8220, + "end_line": 8227, + "section": "Links" + }, + { + "markdown": "[foo][ref[bar]]\n\n[ref[bar]]: /uri\n", + "html": "

[foo][ref[bar]]

\n

[ref[bar]]: /uri

\n", + "example": 546, + "start_line": 8230, + "end_line": 8237, + "section": "Links" + }, + { + "markdown": "[[[foo]]]\n\n[[[foo]]]: /url\n", + "html": "

[[[foo]]]

\n

[[[foo]]]: /url

\n", + "example": 547, + "start_line": 8240, + "end_line": 8247, + "section": "Links" + }, + { + "markdown": "[foo][ref\\[]\n\n[ref\\[]: /uri\n", + "html": "

foo

\n", + "example": 548, + "start_line": 8250, + "end_line": 8256, + "section": "Links" + }, + { + "markdown": "[bar\\\\]: /uri\n\n[bar\\\\]\n", + "html": "

bar\\

\n", + "example": 549, + "start_line": 8261, + "end_line": 8267, + "section": "Links" + }, + { + "markdown": "[]\n\n[]: /uri\n", + "html": "

[]

\n

[]: /uri

\n", + "example": 550, + "start_line": 8273, + "end_line": 8280, + "section": "Links" + }, + { + "markdown": "[\n ]\n\n[\n ]: /uri\n", + "html": "

[\n]

\n

[\n]: /uri

\n", + "example": 551, + "start_line": 8283, + "end_line": 8294, + "section": "Links" + }, + { + "markdown": "[foo][]\n\n[foo]: /url \"title\"\n", + "html": "

foo

\n", + "example": 552, + "start_line": 8306, + "end_line": 8312, + "section": "Links" + }, + { + "markdown": "[*foo* bar][]\n\n[*foo* bar]: /url \"title\"\n", + "html": "

foo bar

\n", + "example": 553, + "start_line": 8315, + "end_line": 8321, + "section": "Links" + }, + { + "markdown": "[Foo][]\n\n[foo]: /url \"title\"\n", + "html": "

Foo

\n", + "example": 554, + "start_line": 8326, + "end_line": 8332, + "section": "Links" + }, + { + "markdown": "[foo] \n[]\n\n[foo]: /url \"title\"\n", + "html": "

foo\n[]

\n", + "example": 555, + "start_line": 8339, + "end_line": 8347, + "section": "Links" + }, + { + "markdown": "[foo]\n\n[foo]: /url \"title\"\n", + "html": "

foo

\n", + "example": 556, + "start_line": 8359, + "end_line": 8365, + "section": "Links" + }, + { + "markdown": "[*foo* bar]\n\n[*foo* bar]: /url \"title\"\n", + "html": "

foo bar

\n", + "example": 557, + "start_line": 8368, + "end_line": 8374, + "section": "Links" + }, + { + "markdown": "[[*foo* bar]]\n\n[*foo* bar]: /url \"title\"\n", + "html": "

[foo bar]

\n", + "example": 558, + "start_line": 8377, + "end_line": 8383, + "section": "Links" + }, + { + "markdown": "[[bar [foo]\n\n[foo]: /url\n", + "html": "

[[bar foo

\n", + "example": 559, + "start_line": 8386, + "end_line": 8392, + "section": "Links" + }, + { + "markdown": "[Foo]\n\n[foo]: /url \"title\"\n", + "html": "

Foo

\n", + "example": 560, + "start_line": 8397, + "end_line": 8403, + "section": "Links" + }, + { + "markdown": "[foo] bar\n\n[foo]: /url\n", + "html": "

foo bar

\n", + "example": 561, + "start_line": 8408, + "end_line": 8414, + "section": "Links" + }, + { + "markdown": "\\[foo]\n\n[foo]: /url \"title\"\n", + "html": "

[foo]

\n", + "example": 562, + "start_line": 8420, + "end_line": 8426, + "section": "Links" + }, + { + "markdown": "[foo*]: /url\n\n*[foo*]\n", + "html": "

*foo*

\n", + "example": 563, + "start_line": 8432, + "end_line": 8438, + "section": "Links" + }, + { + "markdown": "[foo][bar]\n\n[foo]: /url1\n[bar]: /url2\n", + "html": "

foo

\n", + "example": 564, + "start_line": 8444, + "end_line": 8451, + "section": "Links" + }, + { + "markdown": "[foo][]\n\n[foo]: /url1\n", + "html": "

foo

\n", + "example": 565, + "start_line": 8453, + "end_line": 8459, + "section": "Links" + }, + { + "markdown": "[foo]()\n\n[foo]: /url1\n", + "html": "

foo

\n", + "example": 566, + "start_line": 8463, + "end_line": 8469, + "section": "Links" + }, + { + "markdown": "[foo](not a link)\n\n[foo]: /url1\n", + "html": "

foo(not a link)

\n", + "example": 567, + "start_line": 8471, + "end_line": 8477, + "section": "Links" + }, + { + "markdown": "[foo][bar][baz]\n\n[baz]: /url\n", + "html": "

[foo]bar

\n", + "example": 568, + "start_line": 8482, + "end_line": 8488, + "section": "Links" + }, + { + "markdown": "[foo][bar][baz]\n\n[baz]: /url1\n[bar]: /url2\n", + "html": "

foobaz

\n", + "example": 569, + "start_line": 8494, + "end_line": 8501, + "section": "Links" + }, + { + "markdown": "[foo][bar][baz]\n\n[baz]: /url1\n[foo]: /url2\n", + "html": "

[foo]bar

\n", + "example": 570, + "start_line": 8507, + "end_line": 8514, + "section": "Links" + }, + { + "markdown": "![foo](/url \"title\")\n", + "html": "

\"foo\"

\n", + "example": 571, + "start_line": 8530, + "end_line": 8534, + "section": "Images" + }, + { + "markdown": "![foo *bar*]\n\n[foo *bar*]: train.jpg \"train & tracks\"\n", + "html": "

\"foo

\n", + "example": 572, + "start_line": 8537, + "end_line": 8543, + "section": "Images" + }, + { + "markdown": "![foo ![bar](/url)](/url2)\n", + "html": "

\"foo

\n", + "example": 573, + "start_line": 8546, + "end_line": 8550, + "section": "Images" + }, + { + "markdown": "![foo [bar](/url)](/url2)\n", + "html": "

\"foo

\n", + "example": 574, + "start_line": 8553, + "end_line": 8557, + "section": "Images" + }, + { + "markdown": "![foo *bar*][]\n\n[foo *bar*]: train.jpg \"train & tracks\"\n", + "html": "

\"foo

\n", + "example": 575, + "start_line": 8567, + "end_line": 8573, + "section": "Images" + }, + { + "markdown": "![foo *bar*][foobar]\n\n[FOOBAR]: train.jpg \"train & tracks\"\n", + "html": "

\"foo

\n", + "example": 576, + "start_line": 8576, + "end_line": 8582, + "section": "Images" + }, + { + "markdown": "![foo](train.jpg)\n", + "html": "

\"foo\"

\n", + "example": 577, + "start_line": 8585, + "end_line": 8589, + "section": "Images" + }, + { + "markdown": "My ![foo bar](/path/to/train.jpg \"title\" )\n", + "html": "

My \"foo

\n", + "example": 578, + "start_line": 8592, + "end_line": 8596, + "section": "Images" + }, + { + "markdown": "![foo]()\n", + "html": "

\"foo\"

\n", + "example": 579, + "start_line": 8599, + "end_line": 8603, + "section": "Images" + }, + { + "markdown": "![](/url)\n", + "html": "

\"\"

\n", + "example": 580, + "start_line": 8606, + "end_line": 8610, + "section": "Images" + }, + { + "markdown": "![foo][bar]\n\n[bar]: /url\n", + "html": "

\"foo\"

\n", + "example": 581, + "start_line": 8615, + "end_line": 8621, + "section": "Images" + }, + { + "markdown": "![foo][bar]\n\n[BAR]: /url\n", + "html": "

\"foo\"

\n", + "example": 582, + "start_line": 8624, + "end_line": 8630, + "section": "Images" + }, + { + "markdown": "![foo][]\n\n[foo]: /url \"title\"\n", + "html": "

\"foo\"

\n", + "example": 583, + "start_line": 8635, + "end_line": 8641, + "section": "Images" + }, + { + "markdown": "![*foo* bar][]\n\n[*foo* bar]: /url \"title\"\n", + "html": "

\"foo

\n", + "example": 584, + "start_line": 8644, + "end_line": 8650, + "section": "Images" + }, + { + "markdown": "![Foo][]\n\n[foo]: /url \"title\"\n", + "html": "

\"Foo\"

\n", + "example": 585, + "start_line": 8655, + "end_line": 8661, + "section": "Images" + }, + { + "markdown": "![foo] \n[]\n\n[foo]: /url \"title\"\n", + "html": "

\"foo\"\n[]

\n", + "example": 586, + "start_line": 8667, + "end_line": 8675, + "section": "Images" + }, + { + "markdown": "![foo]\n\n[foo]: /url \"title\"\n", + "html": "

\"foo\"

\n", + "example": 587, + "start_line": 8680, + "end_line": 8686, + "section": "Images" + }, + { + "markdown": "![*foo* bar]\n\n[*foo* bar]: /url \"title\"\n", + "html": "

\"foo

\n", + "example": 588, + "start_line": 8689, + "end_line": 8695, + "section": "Images" + }, + { + "markdown": "![[foo]]\n\n[[foo]]: /url \"title\"\n", + "html": "

![[foo]]

\n

[[foo]]: /url "title"

\n", + "example": 589, + "start_line": 8700, + "end_line": 8707, + "section": "Images" + }, + { + "markdown": "![Foo]\n\n[foo]: /url \"title\"\n", + "html": "

\"Foo\"

\n", + "example": 590, + "start_line": 8712, + "end_line": 8718, + "section": "Images" + }, + { + "markdown": "!\\[foo]\n\n[foo]: /url \"title\"\n", + "html": "

![foo]

\n", + "example": 591, + "start_line": 8724, + "end_line": 8730, + "section": "Images" + }, + { + "markdown": "\\![foo]\n\n[foo]: /url \"title\"\n", + "html": "

!foo

\n", + "example": 592, + "start_line": 8736, + "end_line": 8742, + "section": "Images" + }, + { + "markdown": "\n", + "html": "

http://foo.bar.baz

\n", + "example": 593, + "start_line": 8769, + "end_line": 8773, + "section": "Autolinks" + }, + { + "markdown": "\n", + "html": "

http://foo.bar.baz/test?q=hello&id=22&boolean

\n", + "example": 594, + "start_line": 8776, + "end_line": 8780, + "section": "Autolinks" + }, + { + "markdown": "\n", + "html": "

irc://foo.bar:2233/baz

\n", + "example": 595, + "start_line": 8783, + "end_line": 8787, + "section": "Autolinks" + }, + { + "markdown": "\n", + "html": "

MAILTO:FOO@BAR.BAZ

\n", + "example": 596, + "start_line": 8792, + "end_line": 8796, + "section": "Autolinks" + }, + { + "markdown": "\n", + "html": "

a+b+c:d

\n", + "example": 597, + "start_line": 8804, + "end_line": 8808, + "section": "Autolinks" + }, + { + "markdown": "\n", + "html": "

made-up-scheme://foo,bar

\n", + "example": 598, + "start_line": 8811, + "end_line": 8815, + "section": "Autolinks" + }, + { + "markdown": "\n", + "html": "

http://../

\n", + "example": 599, + "start_line": 8818, + "end_line": 8822, + "section": "Autolinks" + }, + { + "markdown": "\n", + "html": "

localhost:5001/foo

\n", + "example": 600, + "start_line": 8825, + "end_line": 8829, + "section": "Autolinks" + }, + { + "markdown": "\n", + "html": "

<http://foo.bar/baz bim>

\n", + "example": 601, + "start_line": 8834, + "end_line": 8838, + "section": "Autolinks" + }, + { + "markdown": "\n", + "html": "

http://example.com/\\[\\

\n", + "example": 602, + "start_line": 8843, + "end_line": 8847, + "section": "Autolinks" + }, + { + "markdown": "\n", + "html": "

foo@bar.example.com

\n", + "example": 603, + "start_line": 8865, + "end_line": 8869, + "section": "Autolinks" + }, + { + "markdown": "\n", + "html": "

foo+special@Bar.baz-bar0.com

\n", + "example": 604, + "start_line": 8872, + "end_line": 8876, + "section": "Autolinks" + }, + { + "markdown": "\n", + "html": "

<foo+@bar.example.com>

\n", + "example": 605, + "start_line": 8881, + "end_line": 8885, + "section": "Autolinks" + }, + { + "markdown": "<>\n", + "html": "

<>

\n", + "example": 606, + "start_line": 8890, + "end_line": 8894, + "section": "Autolinks" + }, + { + "markdown": "< http://foo.bar >\n", + "html": "

< http://foo.bar >

\n", + "example": 607, + "start_line": 8897, + "end_line": 8901, + "section": "Autolinks" + }, + { + "markdown": "\n", + "html": "

<m:abc>

\n", + "example": 608, + "start_line": 8904, + "end_line": 8908, + "section": "Autolinks" + }, + { + "markdown": "\n", + "html": "

<foo.bar.baz>

\n", + "example": 609, + "start_line": 8911, + "end_line": 8915, + "section": "Autolinks" + }, + { + "markdown": "http://example.com\n", + "html": "

http://example.com

\n", + "example": 610, + "start_line": 8918, + "end_line": 8922, + "section": "Autolinks" + }, + { + "markdown": "foo@bar.example.com\n", + "html": "

foo@bar.example.com

\n", + "example": 611, + "start_line": 8925, + "end_line": 8929, + "section": "Autolinks" + }, + { + "markdown": "\n", + "html": "

\n", + "example": 612, + "start_line": 9006, + "end_line": 9010, + "section": "Raw HTML" + }, + { + "markdown": "\n", + "html": "

\n", + "example": 613, + "start_line": 9015, + "end_line": 9019, + "section": "Raw HTML" + }, + { + "markdown": "\n", + "html": "

\n", + "example": 614, + "start_line": 9024, + "end_line": 9030, + "section": "Raw HTML" + }, + { + "markdown": "\n", + "html": "

\n", + "example": 615, + "start_line": 9035, + "end_line": 9041, + "section": "Raw HTML" + }, + { + "markdown": "Foo \n", + "html": "

Foo

\n", + "example": 616, + "start_line": 9046, + "end_line": 9050, + "section": "Raw HTML" + }, + { + "markdown": "<33> <__>\n", + "html": "

<33> <__>

\n", + "example": 617, + "start_line": 9055, + "end_line": 9059, + "section": "Raw HTML" + }, + { + "markdown": "
\n", + "html": "

<a h*#ref="hi">

\n", + "example": 618, + "start_line": 9064, + "end_line": 9068, + "section": "Raw HTML" + }, + { + "markdown": "
\n", + "html": "

<a href="hi'> <a href=hi'>

\n", + "example": 619, + "start_line": 9073, + "end_line": 9077, + "section": "Raw HTML" + }, + { + "markdown": "< a><\nfoo>\n\n", + "html": "

< a><\nfoo><bar/ >\n<foo bar=baz\nbim!bop />

\n", + "example": 620, + "start_line": 9082, + "end_line": 9092, + "section": "Raw HTML" + }, + { + "markdown": "
\n", + "html": "

<a href='bar'title=title>

\n", + "example": 621, + "start_line": 9097, + "end_line": 9101, + "section": "Raw HTML" + }, + { + "markdown": "
\n", + "html": "

\n", + "example": 622, + "start_line": 9106, + "end_line": 9110, + "section": "Raw HTML" + }, + { + "markdown": "\n", + "html": "

</a href="foo">

\n", + "example": 623, + "start_line": 9115, + "end_line": 9119, + "section": "Raw HTML" + }, + { + "markdown": "foo \n", + "html": "

foo

\n", + "example": 624, + "start_line": 9124, + "end_line": 9130, + "section": "Raw HTML" + }, + { + "markdown": "foo \n", + "html": "

foo <!-- not a comment -- two hyphens -->

\n", + "example": 625, + "start_line": 9133, + "end_line": 9137, + "section": "Raw HTML" + }, + { + "markdown": "foo foo -->\n\nfoo \n", + "html": "

foo <!--> foo -->

\n

foo <!-- foo--->

\n", + "example": 626, + "start_line": 9142, + "end_line": 9149, + "section": "Raw HTML" + }, + { + "markdown": "foo \n", + "html": "

foo

\n", + "example": 627, + "start_line": 9154, + "end_line": 9158, + "section": "Raw HTML" + }, + { + "markdown": "foo \n", + "html": "

foo

\n", + "example": 628, + "start_line": 9163, + "end_line": 9167, + "section": "Raw HTML" + }, + { + "markdown": "foo &<]]>\n", + "html": "

foo &<]]>

\n", + "example": 629, + "start_line": 9172, + "end_line": 9176, + "section": "Raw HTML" + }, + { + "markdown": "foo \n", + "html": "

foo

\n", + "example": 630, + "start_line": 9182, + "end_line": 9186, + "section": "Raw HTML" + }, + { + "markdown": "foo \n", + "html": "

foo

\n", + "example": 631, + "start_line": 9191, + "end_line": 9195, + "section": "Raw HTML" + }, + { + "markdown": "\n", + "html": "

<a href=""">

\n", + "example": 632, + "start_line": 9198, + "end_line": 9202, + "section": "Raw HTML" + }, + { + "markdown": "foo \nbaz\n", + "html": "

foo
\nbaz

\n", + "example": 633, + "start_line": 9212, + "end_line": 9218, + "section": "Hard line breaks" + }, + { + "markdown": "foo\\\nbaz\n", + "html": "

foo
\nbaz

\n", + "example": 634, + "start_line": 9224, + "end_line": 9230, + "section": "Hard line breaks" + }, + { + "markdown": "foo \nbaz\n", + "html": "

foo
\nbaz

\n", + "example": 635, + "start_line": 9235, + "end_line": 9241, + "section": "Hard line breaks" + }, + { + "markdown": "foo \n bar\n", + "html": "

foo
\nbar

\n", + "example": 636, + "start_line": 9246, + "end_line": 9252, + "section": "Hard line breaks" + }, + { + "markdown": "foo\\\n bar\n", + "html": "

foo
\nbar

\n", + "example": 637, + "start_line": 9255, + "end_line": 9261, + "section": "Hard line breaks" + }, + { + "markdown": "*foo \nbar*\n", + "html": "

foo
\nbar

\n", + "example": 638, + "start_line": 9267, + "end_line": 9273, + "section": "Hard line breaks" + }, + { + "markdown": "*foo\\\nbar*\n", + "html": "

foo
\nbar

\n", + "example": 639, + "start_line": 9276, + "end_line": 9282, + "section": "Hard line breaks" + }, + { + "markdown": "`code \nspan`\n", + "html": "

code span

\n", + "example": 640, + "start_line": 9287, + "end_line": 9292, + "section": "Hard line breaks" + }, + { + "markdown": "`code\\\nspan`\n", + "html": "

code\\ span

\n", + "example": 641, + "start_line": 9295, + "end_line": 9300, + "section": "Hard line breaks" + }, + { + "markdown": "
\n", + "html": "

\n", + "example": 642, + "start_line": 9305, + "end_line": 9311, + "section": "Hard line breaks" + }, + { + "markdown": "\n", + "html": "

\n", + "example": 643, + "start_line": 9314, + "end_line": 9320, + "section": "Hard line breaks" + }, + { + "markdown": "foo\\\n", + "html": "

foo\\

\n", + "example": 644, + "start_line": 9327, + "end_line": 9331, + "section": "Hard line breaks" + }, + { + "markdown": "foo \n", + "html": "

foo

\n", + "example": 645, + "start_line": 9334, + "end_line": 9338, + "section": "Hard line breaks" + }, + { + "markdown": "### foo\\\n", + "html": "

foo\\

\n", + "example": 646, + "start_line": 9341, + "end_line": 9345, + "section": "Hard line breaks" + }, + { + "markdown": "### foo \n", + "html": "

foo

\n", + "example": 647, + "start_line": 9348, + "end_line": 9352, + "section": "Hard line breaks" + }, + { + "markdown": "foo\nbaz\n", + "html": "

foo\nbaz

\n", + "example": 648, + "start_line": 9363, + "end_line": 9369, + "section": "Soft line breaks" + }, + { + "markdown": "foo \n baz\n", + "html": "

foo\nbaz

\n", + "example": 649, + "start_line": 9375, + "end_line": 9381, + "section": "Soft line breaks" + }, + { + "markdown": "hello $.;'there\n", + "html": "

hello $.;'there

\n", + "example": 650, + "start_line": 9395, + "end_line": 9399, + "section": "Textual content" + }, + { + "markdown": "Foo χρῆν\n", + "html": "

Foo χρῆν

\n", + "example": 651, + "start_line": 9402, + "end_line": 9406, + "section": "Textual content" + }, + { + "markdown": "Multiple spaces\n", + "html": "

Multiple spaces

\n", + "example": 652, + "start_line": 9411, + "end_line": 9415, + "section": "Textual content" + } +] \ No newline at end of file diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/fixtures/def_list.txt b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/fixtures/def_list.txt new file mode 100644 index 0000000000000000000000000000000000000000..6c5a210232576e53330d55888c2d041ffeccc145 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/fixtures/def_list.txt @@ -0,0 +1,172 @@ +# Definition Lists + +```````````````````````````````` example +Term +: definition +. +
+
Term
+
definition
+
+```````````````````````````````` + +```````````````````````````````` example +Term +: definition1 +: definition2 +. +
+
Term
+
definition1
+
definition2
+
+```````````````````````````````` + +```````````````````````````````` example +Term +: definition1 +: definition2 + +paragraph +. +
+
Term
+
definition1
+
definition2
+
+

paragraph

+```````````````````````````````` + +```````````````````````````````` example +First Term +: This is the definition of the first term. + +Second Term +: This is one definition of the second term. +: This is another definition of the second term. +. +
+
First Term
+
This is the definition of the first term.
+
Second Term
+
This is one definition of the second term.
+
This is another definition of the second term.
+
+```````````````````````````````` + +```````````````````````````````` example +First Term +: This is the definition of the first term. + +Second Term +: This is one definition of the second term. +: This is another definition of the second term. + +paragraph +. +
+
First Term
+
This is the definition of the first term.
+
Second Term
+
This is one definition of the second term.
+
This is another definition of the second term.
+
+

paragraph

+```````````````````````````````` + +```````````````````````````````` example +First Term +: This is the definition of the first term. +Not Second Term +: This is one definition of the second term. +: This is another definition of the second term. + +paragraph +. +
+
First Term
+
This is the definition of the first term. +Not Second Term
+
This is one definition of the second term.
+
This is another definition of the second term.
+
+

paragraph

+```````````````````````````````` + +## Definition with Multiple Lines + +```````````````````````````````` example +Term + +: definition +. +
+
Term
+

definition

+
+
+```````````````````````````````` + + +```````````````````````````````` example +Term +: foo + + bar +. +
+
Term
+

foo

+

bar

+
+
+```````````````````````````````` + +Leading 4 white spaces + +```````````````````````````````` example +Term +: foo + + bar +. +
+
Term
+

foo

+

bar

+
+
+```````````````````````````````` + + +```````````````````````````````` example +Term +: foo + + bar +. +
+
Term
+

foo

+
bar
+
+
+```````````````````````````````` + +```````````````````````````````` example +Term +: foo + + - bar + - baz +. +
+
Term
+

foo

+
    +
  • bar
  • +
  • baz
  • +
+
+
+```````````````````````````````` diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/fixtures/diff-commonmark.txt b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/fixtures/diff-commonmark.txt new file mode 100644 index 0000000000000000000000000000000000000000..9573e2a383b273af5db4a2386d9f9fe35120d9b4 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/fixtures/diff-commonmark.txt @@ -0,0 +1,76 @@ +# Differences + +Results different than commonmark. + + +## Setext headings + + +Example: 93 + + +```````````````````````````````` example +> foo +bar +=== +. +
+

foo +bar

+
+```````````````````````````````` + +If the dash is less than 3, it is not a `
`, in this case, it +can be rendered into `

`. + +```````````````````````````````` example +- # Foo +- Bar + -- + baz +. +
    +
  • +

    Foo

    +
  • +
  • +

    Bar

    +baz
  • +
+```````````````````````````````` + +## Image + +Example 573 + +```````````````````````````````` example +![foo ![bar](/url)](/url2) +. +

foo ![bar](/url)

+```````````````````````````````` + +## Link + +Example 517 + +```````````````````````````````` example +[foo [bar](/uri)](/uri) +. +

foo [bar](/uri)

+```````````````````````````````` + +Example 518 + +```````````````````````````````` example +[foo *[bar [baz](/uri)](/uri)*](/uri) +. +

foo [bar [baz](/uri)](/uri)

+```````````````````````````````` + +Example 519 + +```````````````````````````````` example +![[[foo](uri1)](uri2)](uri3) +. +

[foo](uri1)

+```````````````````````````````` diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/fixtures/fenced_admonition.txt b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/fixtures/fenced_admonition.txt new file mode 100644 index 0000000000000000000000000000000000000000..0f962c5e4d44d9fa81effe866998e1fc6f88565d --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/fixtures/fenced_admonition.txt @@ -0,0 +1,129 @@ +# Admonition + +```````````````````````````````` example +```{unknown} Hi + +this is **strong** world +``` +. +
{unknown} Hi
+
+this is **strong** world
+
+```````````````````````````````` + +```````````````````````````````` example +``` +this is code +``` +. +
this is code
+
+```````````````````````````````` + + +```````````````````````````````` example +~~~{note} Warning + +message +~~~ +. +
+

Warning

+

message

+
+```````````````````````````````` + +```````````````````````````````` example +~~~{note} A **strong** title + +_message_ +~~~ +. +
+

A strong title

+

message

+
+```````````````````````````````` + +Test with code block. + +```````````````````````````````` example +```{note} + + print() +``` +. +
+

Note

+
print()
+
+```````````````````````````````` + +Test with no message. + +```````````````````````````````` example +~~~{note} Warning +~~~ +. +
+

Warning

+
+```````````````````````````````` + +Test with no ending fence + +```````````````````````````````` example +~~~{note} Warning +. +
+

Warning

+
+```````````````````````````````` + +Test with nested admonition + +```````````````````````````````` example +~~~~~~~{note} +~~~~~~{warning} +~~~~~{tip} +~~~~{caution} +~~~{hint} +``````{danger} +`````{attention} +````{important} +```{error} +``` +```` +````` +`````` +~~~ +~~~~ +~~~~~ +~~~~~~ +~~~~~~~ +. +
+

Note

+
+

Warning

+
+

Tip

+
+

Caution

+
+

Hint

+
+

Danger

+
````{important}
+```{error}
+```
+````
+
+
+
+
+
+
+
+```````````````````````````````` diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/fixtures/fenced_figure.txt b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/fixtures/fenced_figure.txt new file mode 100644 index 0000000000000000000000000000000000000000..0fcd23c1f1280e6e9b17a43fbb8942d21b702254 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/fixtures/fenced_figure.txt @@ -0,0 +1,166 @@ +# Figure + +## No options + +```````````````````````````````` example +~~~{figure} picture.png +~~~ +. +
+
+
+```````````````````````````````` + +## Align options + +```````````````````````````````` example +~~~{figure} picture.png +:align: left +~~~ +. +
+
+
+```````````````````````````````` + + +```````````````````````````````` example +~~~{figure} picture.png +:align: invalid +~~~ +. +
+
+
+```````````````````````````````` + +## width and height + +```````````````````````````````` example +~~~{figure} picture.png +:width: 100 +:height: 50 +~~~ +. +
+
+
+```````````````````````````````` + +```````````````````````````````` example +~~~{figure} picture.png +:width: 100px +:height: 50px +~~~ +. +
+
+
+```````````````````````````````` + +```````````````````````````````` example +~~~{figure} picture.png +:figwidth: 400px +~~~ +. +
+
+
+```````````````````````````````` + +## alt option + +```````````````````````````````` example +~~~{figure} picture.png +:alt: description text +~~~ +. +
+
description text
+
+```````````````````````````````` + +## target option + +```````````````````````````````` example +~~~{figure} picture.png +:target: https://lepture.com +~~~ +. +
+ +
+```````````````````````````````` + +## caption + +```````````````````````````````` example +~~~{figure} picture.png +a caption with **emphasis** text +~~~ +. +
+
+
a caption with emphasis text
+
+```````````````````````````````` + +## legend + +```````````````````````````````` example +~~~{figure} picture.png +a caption with **emphasis** text + +> quote +~~~ +. +
+
+
a caption with emphasis text
+
+
+

quote

+
+
+
+```````````````````````````````` + + +```````````````````````````````` example +~~~{figure} picture.png +> quote +~~~ +. +
+
+
+```````````````````````````````` + +## all options + + +```````````````````````````````` example +~~~{figure} picture.png +:figwidth: 400px +:figclass: all-options +:target: https://lepture.com +:alt: description +:align: left +:width: 100 +:height: 50 + +a caption with **emphasis** text + +> quote +~~~ +. +
+description +
a caption with emphasis text
+
+
+

quote

+
+
+
+```````````````````````````````` diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/fixtures/fenced_image.txt b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/fixtures/fenced_image.txt new file mode 100644 index 0000000000000000000000000000000000000000..afec622ce413acb5fcbb287e020c4588e892de8c --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/fixtures/fenced_image.txt @@ -0,0 +1,102 @@ +# Image + +## No options + +```````````````````````````````` example +~~~{image} picture.png +~~~ +. +
+```````````````````````````````` + +## Align options + +```````````````````````````````` example +~~~{image} picture.png +:align: left +~~~ +. +
+```````````````````````````````` + + +```````````````````````````````` example +~~~{image} picture.png +:align: invalid +~~~ +. +
+```````````````````````````````` + +## width and height + +```````````````````````````````` example +~~~{image} picture.png +:width: 100 +:height: 50 +~~~ +. +
+```````````````````````````````` + +```````````````````````````````` example +~~~{image} picture.png +:width: 100px +:height: 50px +~~~ +. +
+```````````````````````````````` + +## alt option + +```````````````````````````````` example +~~~{image} picture.png +:alt: description text +~~~ +. +
description text
+```````````````````````````````` + +## target option + +```````````````````````````````` example +~~~{image} picture.png +:target: https://lepture.com +~~~ +. + +```````````````````````````````` + +## all options + +```````````````````````````````` example +~~~{image} picture.png +:target: https://lepture.com +:alt: description +:align: left +:width: 100 +:height: 50 +~~~ +. +description +```````````````````````````````` + +## ampersand in source + +```````````````````````````````` example +~~~{image} https://example.com/picture.png?foo=qux&test=me +~~~ +. +
+```````````````````````````````` + +## ampersand in target + +```````````````````````````````` example +~~~{image} picture.png +:target: https://example.com/rickroll?a=1&b=2 +~~~ +. + +```````````````````````````````` diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/fixtures/fenced_toc.txt b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/fixtures/fenced_toc.txt new file mode 100644 index 0000000000000000000000000000000000000000..1744000ce6ca473d1d75fb2d9388d46d3463a64c --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/fixtures/fenced_toc.txt @@ -0,0 +1,237 @@ +# Table of Contents + +## No TOC + +```````````````````````````````` example +none +. +

none

+```````````````````````````````` + +```````````````````````````````` example +# H1 +## H2 +. +

H1

+

H2

+```````````````````````````````` + + +## Simple TOC + +```````````````````````````````` example +~~~{toc} +~~~ + +# H1 +## H2 +. +
+Table of Contents + +
+

H1

+

H2

+```````````````````````````````` + +## Invalid Option + +```````````````````````````````` example +# H1 +## H2 + +~~~{toc} +:max-level: s +~~~ +. +

H1

+

H2

+
"max-level" option MUST be integer
+```````````````````````````````` + +```````````````````````````````` example +# H1 +## H2 + +~~~{toc} +:max-level: 9 +~~~ +. +

H1

+

H2

+
"max-level" option MUST be <= 3
+```````````````````````````````` + +```````````````````````````````` example +# H1 +## H2 + +~~~{toc} +:min-level: 2 +:max-level: 1 +~~~ +. +

H1

+

H2

+
"min-level" option MUST be less than "max-level" option
+```````````````````````````````` + +## Complex + +```````````````````````````````` example +# H1 +## H2 +### H3 +#### H4 +# H1 B +# H1 `C` + +```{toc} Contents +``` +. +

H1

+

H2

+

H3

+

H4

+

H1 B

+

H1 C

+
+Contents + +
+```````````````````````````````` + +## Insane + +```````````````````````````````` example +# H1 +### H3 +## H2 +#### H4 +### H3 B +# H1 B + +```{toc} +``` +. +

H1

+

H3

+

H2

+

H4

+

H3 B

+

H1 B

+
+Table of Contents + +
+```````````````````````````````` + +```````````````````````````````` example +### H3 +## H2 +# H1 + +```{toc} +``` +. +

H3

+

H2

+

H1

+
+Table of Contents + +
+```````````````````````````````` + +## Link in Heading + + +```````````````````````````````` example +# [foo](/bar) + +```{toc} +``` +. +

foo

+
+Table of Contents + +
+```````````````````````````````` + +## HTML in Heading + +```````````````````````````````` example +# H1 +```{toc} +``` +. +

H1

+
+Table of Contents + +
+```````````````````````````````` + +## Collapse TOC + +```````````````````````````````` example + +```{toc} +:collapse: +``` + +# H1 +## H2 +. +
+Table of Contents + +
+

H1

+

H2

+```````````````````````````````` diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/fixtures/fix-commonmark.txt b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/fixtures/fix-commonmark.txt new file mode 100644 index 0000000000000000000000000000000000000000..c7870065cc61e07f114050eaaecf60d3db5cbdf9 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/fixtures/fix-commonmark.txt @@ -0,0 +1,123 @@ +Fix problems that commonmark has. + + +## Links + +Links can't contain links. + +```````````````````````````````` example +[](/foo) +. +

<https://example.com>

+```````````````````````````````` + +```````````````````````````````` example +[](/foo) +. +

<name@example.com>

+```````````````````````````````` + +## Emphasis + +`` doesn't contain ``, `` doesn't contain ``. + +```````````````````````````````` example +*_em_* __**strong**__ ______m______ +. +

_em_ **strong** ______m______

+```````````````````````````````` + +### Non aggressive emphasis + +```````````````````````````````` example +*a **b c* d** +. +

a **b c d**

+```````````````````````````````` + +While CommonMark would render it into: + +``` +

a b c d

+``` + +```````````````````````````````` example +*a **b c* d** +. +

a **b c d**

+```````````````````````````````` + +While CommonMark would render it into: + +``` +

a b c d

+``` + +What if the string is: + +```````````````````````````````` example +*a **b c* d +. +

a **b c d

+```````````````````````````````` + +CommonMark would still be a mess: + +``` +

*a *b c d

+``` + + +## Max depth + + +```````````````````````````````` example +> > > > > > > > b +. +
+
+
+
+
+
+

> > b

+
+
+
+
+
+
+```````````````````````````````` + + +```````````````````````````````` example +- a + - b + - c + - d + - e + - f + - g + - h +. +
    +
  • a
      +
    • b
        +
      • c
          +
        • d
            +
          • e
              +
            • f +- g +- h
            • +
            +
          • +
          +
        • +
        +
      • +
      +
    • +
    +
  • +
+```````````````````````````````` diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/fixtures/footnotes.txt b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/fixtures/footnotes.txt new file mode 100644 index 0000000000000000000000000000000000000000..485cfd87c0a18859af15ec52b8baacad5c44fe6c --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/fixtures/footnotes.txt @@ -0,0 +1,45 @@ +# Footnotes + +```````````````````````````````` example +none [^1] +. +

none [^1]

+```````````````````````````````` + +```````````````````````````````` example +oneline [^1] + +[^1]: foo +. +

oneline 1

+
+
    +
  1. foo↩

  2. +
+
+```````````````````````````````` + +```````````````````````````````` example +multiple lines [^1] + +[^1]: foo + + one + + two + + three + + four +. +

multiple lines 1

+
four
+
+
    +
  1. foo

    +

    one

    +

    two

    +

    three↩

  2. +
+
+```````````````````````````````` diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/fixtures/hook_toc.txt b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/fixtures/hook_toc.txt new file mode 100644 index 0000000000000000000000000000000000000000..62a1a1ec79dacaf8854a67e3b48f5a1c1e9d2f4b --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/fixtures/hook_toc.txt @@ -0,0 +1,122 @@ +# Table of Contents + +## Simple TOC + +```````````````````````````````` example +# H1 + +content + +## H2 +. +

H1

+

content

+

H2

+ +```````````````````````````````` + +## Complex TOC + +```````````````````````````````` example +# H1 +## H2 +### H3 +#### H4 +# H1 B +# H1 `C` +. +

H1

+

H2

+

H3

+

H4

+

H1 B

+

H1 C

+ +```````````````````````````````` + +## Insane TOC + +```````````````````````````````` example +# H1 +### H3 +## H2 +#### H4 +### H3 B +# H1 B +. +

H1

+

H3

+

H2

+

H4

+

H3 B

+

H1 B

+ +```````````````````````````````` + +```````````````````````````````` example +### H3 +## H2 +# H1 +. +

H3

+

H2

+

H1

+ +```````````````````````````````` + +## Link in Heading + + +```````````````````````````````` example +# [foo](/bar) +. +

foo

+ +```````````````````````````````` + +## HTML in Heading + +```````````````````````````````` example +# H1 +. +

H1

+ +```````````````````````````````` diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/fixtures/include/hello.md b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/fixtures/include/hello.md new file mode 100644 index 0000000000000000000000000000000000000000..5e3d2769d88dd761efbd358b5dd0cb095d652294 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/fixtures/include/hello.md @@ -0,0 +1 @@ +> hello diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/fixtures/include/hello.txt b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/fixtures/include/hello.txt new file mode 100644 index 0000000000000000000000000000000000000000..ce013625030ba8dba906f756967f9e9ca394464a --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/fixtures/include/hello.txt @@ -0,0 +1 @@ +hello diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/fixtures/include/text.html b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/fixtures/include/text.html new file mode 100644 index 0000000000000000000000000000000000000000..da12a4c59bef8e4cc80b93ee6c98ebf6e9a10372 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/fixtures/include/text.html @@ -0,0 +1 @@ +
include html
diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/fixtures/include/text.md b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/fixtures/include/text.md new file mode 100644 index 0000000000000000000000000000000000000000..e9faa6cc816e06f743ffb9a1ae753a209607840e --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/fixtures/include/text.md @@ -0,0 +1,12 @@ +# Include + +.. include:: ./text.md + +.. include:: ./not-exist.md + +.. include:: ./text.html + :encoding: utf-8 + +.. include:: ./hello.md + +.. include:: ../rst_toc.txt diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/fixtures/insert.txt b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/fixtures/insert.txt new file mode 100644 index 0000000000000000000000000000000000000000..74d02058f0a66e5598e91d8a84429d17b7c4b62a --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/fixtures/insert.txt @@ -0,0 +1,62 @@ +# Insert + +```````````````````````````````` example +^^insert me +. +

^^insert me

+```````````````````````````````` + + +## normal insert + +```````````````````````````````` example +^^insert me^^ +. +

insert me

+```````````````````````````````` + +```````````````````````````````` example +foo ^^insert me^^ +. +

foo insert me

+```````````````````````````````` + +```````````````````````````````` example +^^insert me^^foo +. +

insert mefoo

+```````````````````````````````` + +```````````````````````````````` example +^^insert me^^^ +. +

^^insert me^^^

+```````````````````````````````` + +## escape insert + +```````````````````````````````` example +^^insert me\^^^ +. +

insert me^

+```````````````````````````````` + +```````````````````````````````` example +^^insert \^\^ me^^ +. +

insert ^^ me

+```````````````````````````````` + +## insert link + +```````````````````````````````` example +^^insert [me^^](/) +. +

insert [me](/)

+```````````````````````````````` + +```````````````````````````````` example +^^[hello](/)^^ +. +

hello

+```````````````````````````````` diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/fixtures/mark.txt b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/fixtures/mark.txt new file mode 100644 index 0000000000000000000000000000000000000000..9c8d2fbc1bf286f937a2ed288f5d497bcfca2136 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/fixtures/mark.txt @@ -0,0 +1,61 @@ +# Mark + +```````````````````````````````` example +==mark me +. +

==mark me

+```````````````````````````````` + +## normal mark + +```````````````````````````````` example +==mark me== +. +

mark me

+```````````````````````````````` + +```````````````````````````````` example +foo ==mark me== +. +

foo mark me

+```````````````````````````````` + +```````````````````````````````` example +==mark me==foo +. +

mark mefoo

+```````````````````````````````` + +```````````````````````````````` example +==mark me=== +. +

==mark me===

+```````````````````````````````` + +## escape mark + +```````````````````````````````` example +==mark me\=== +. +

mark me=

+```````````````````````````````` + +```````````````````````````````` example +==mark \=\= me== +. +

mark == me

+```````````````````````````````` + +## mark link + +```````````````````````````````` example +==mark [me==](/) +. +

mark [me](/)

+```````````````````````````````` + +```````````````````````````````` example +==[hello](/)== +. +

hello

+```````````````````````````````` diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/fixtures/math.txt b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/fixtures/math.txt new file mode 100644 index 0000000000000000000000000000000000000000..e7afaf9d1d2757c25e797b47ef4803bdeee503ef --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/fixtures/math.txt @@ -0,0 +1,57 @@ +# Math + +## Block Math + +```````````````````````````````` example +$$ +. +

$$

+```````````````````````````````` + + +```````````````````````````````` example +$$ +\operatorname{ker} f=\{g\in G:f(g)=e_{H}\}{\mbox{.}} +$$ +. +
$$ +\operatorname{ker} f=\{g\in G:f(g)=e_{H}\}{\mbox{.}} +$$
+```````````````````````````````` + +```````````````````````````````` example +$$ +foo +$$ +bar +. +
$$ +foo +$$
+

bar

+```````````````````````````````` + +```````````````````````````````` example +$$ +foo +bar +$$ +. +
$$ +foo +bar +$$
+```````````````````````````````` + + +## Inline Math + +```````````````````````````````` example +The homomorphism $f$ is injective if and only if its kernel is only the +singleton set $e_G$, because otherwise $\exists a,b\in G$ +with $a\neq b$ such that $f(a)=f(b)$. +. +

The homomorphism \(f\) is injective if and only if its kernel is only the +singleton set \(e_G\), because otherwise \(\exists a,b\in G\) +with \(a\neq b\) such that \(f(a)=f(b)\).

+```````````````````````````````` diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/fixtures/renderer_markdown.txt b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/fixtures/renderer_markdown.txt new file mode 100644 index 0000000000000000000000000000000000000000..fd618f9f281f83c0e5f2f51bcb19080e4188011a --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/fixtures/renderer_markdown.txt @@ -0,0 +1,299 @@ +# MarkdownRenderer + + +## inline + +```````````````````````````````` example +this is _em_, **strong**, and `code` +. +this is *em*, **strong**, and `code` +```````````````````````````````` + +## links + +```````````````````````````````` example +[link], [link][], [text][link], [link](/foo), [link](/foo "title") + +[link]: /url +. +[link][link], [link][link], [text][link], [link](/foo), [link](/foo "title") + +[link]: /url +```````````````````````````````` + +```````````````````````````````` example +[link], [link](https://foo(bar "title") + +[link]: /url "title" +. +[link][link], [link]( "title") + +[link]: /url "title" +```````````````````````````````` + +```````````````````````````````` example +[https://lepture.com](https://lepture.com) + + + + [demo@example.com](mailto:demo@example.com) +. + + + + + +```````````````````````````````` + +## images + +```````````````````````````````` example +[link]: /url + +![link], ![link][], ![alt][link] +. +![link][link], ![link][link], ![alt][link] + +[link]: /url +```````````````````````````````` + +## linebreak + +```````````````````````````````` example +foo\ +bar +. +foo +bar +```````````````````````````````` + +## html + +```````````````````````````````` example +inline html text + +and block html + +
hi
+. +inline html text + +and block html + +
hi
+```````````````````````````````` + +## heading + +```````````````````````````````` example +# h1 +## h2 +### h3 +#### h4 +##### h5 +###### h6 + +h1 +== +. +# h1 + +## h2 + +### h3 + +#### h4 + +##### h5 + +###### h6 + +# h1 +```````````````````````````````` + +## thematic break + +```````````````````````````````` example +hi +*** +. +hi + +*** +```````````````````````````````` + +## code + +```````````````````````````````` example +start + + def foo(): + pass + +end +. +start + +``` +def foo(): + pass +``` + +end +```````````````````````````````` + +```````````````````````````````` example +start +```py +def foo(): + pass +``` +end +. +start + +```py +def foo(): + pass +``` + +end +```````````````````````````````` + +```````````````````````````````` example +indent code + + markdown + ``` + fenced +. +indent code + +~~~ +markdown +``` +fenced +~~~ +```````````````````````````````` + +```````````````````````````````` example +indent code + + markdown + ~~~ + fenced +. +indent code + +``` +markdown +~~~ +fenced +``` +```````````````````````````````` + +```````````````````````````````` example +indent code + + markdown + ``` + fenced + ~~~ +. +indent code + +```` +markdown +``` +fenced +~~~ +```` +```````````````````````````````` + + +## quote + +```````````````````````````````` example +> quote +. +> quote +```````````````````````````````` + +```````````````````````````````` example +hello +> quote +. +hello + +> quote +```````````````````````````````` + +> quote + +> quote +> +> continuation +. +> quote + +> quote +> +> continuation + +## list + +```````````````````````````````` example +- list ++ list +. +- list + ++ list +```````````````````````````````` + +```````````````````````````````` example +- item 1 + item 2 +. +- item 1 + item 2 +```````````````````````````````` + +```````````````````````````````` example +- item 1 + + item 2 +- item 3 +. +- item 1 + + item 2 + +- item 3 +```````````````````````````````` + +```````````````````````````````` example +- item 1 + 1. item 2 +. +- item 1 + 1. item 2 +```````````````````````````````` + +```````````````````````````````` example +- item 1 + + 2. item 2 +. +- item 1 + + 2. item 2 +```````````````````````````````` + +```````````````````````````````` example +- list +- +. +- list +- +```````````````````````````````` diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/fixtures/renderer_rst.txt b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/fixtures/renderer_rst.txt new file mode 100644 index 0000000000000000000000000000000000000000..1b2499ddb74fc532191d296612fd19687224ec5b --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/fixtures/renderer_rst.txt @@ -0,0 +1,250 @@ +# RSTRenderer + +## inline + +```````````````````````````````` example +this is _em_, **strong**, and `code` +. +this is *em*, **strong**, and ``code`` +```````````````````````````````` + +```````````````````````````````` example +| escape | +. +\| escape \| +```````````````````````````````` + +## links + +```````````````````````````````` example +this is [link][] and [link](/foo) + +[link]: /url +. +this is `link
`__ and `link `__ +```````````````````````````````` + +## images + +```````````````````````````````` example +this is inline ![alt _text_](/foo) +. +this is inline |img-0| + +.. |img-0| image:: /foo + :alt: alt *text* +```````````````````````````````` + +```````````````````````````````` example +this is figure + +![alt _text_](/foo) +. +this is figure + +.. figure:: /foo + + alt *text* +```````````````````````````````` + +```````````````````````````````` example +this is figure + +![alt _text_](/foo "title") +. +this is figure + +.. figure:: /foo + :alt: title + + alt *text* +```````````````````````````````` + + +## html + +```````````````````````````````` example +ignore inline html text + +but show block html + +
hi
+. +ignore inline html text + +but show block html + +.. raw:: html + +
hi
+```````````````````````````````` + +## line break + +```````````````````````````````` example +hello +world +. +| hello +| world +```````````````````````````````` + +## heading + +```````````````````````````````` example +# h1 +## h2 +### h3 +#### h4 +##### h5 +###### h6 +. +h1 +== + +h2 +-- + +h3 +~~ + +h4 +^^ + +h5 +"" + +h6 +'' +```````````````````````````````` + +## thematic break + +```````````````````````````````` example +hi +*** +. +hi + +-------------- +```````````````````````````````` + +## code + +```````````````````````````````` example +start + + def foo(): + pass + +end +. +start + +:: + + def foo(): + pass + +end +```````````````````````````````` + +```````````````````````````````` example +start + +```py +def foo(): + pass +``` + +end +. +start + +.. code:: py + + def foo(): + pass + +end +```````````````````````````````` + + +## quote + +```````````````````````````````` example +> quote +. + quote +```````````````````````````````` + +```````````````````````````````` example +hello + +> quote +. +hello + + quote +```````````````````````````````` + +```````````````````````````````` example +> hello + +> quote +. + hello + +.. + + quote +```````````````````````````````` + +## list + +```````````````````````````````` example +- list ++ list +. +- list + ++ list +```````````````````````````````` + +```````````````````````````````` example +- item 1 + item 2 +. +- item 1 item 2 +```````````````````````````````` + +```````````````````````````````` example +- item 1 + + item 2 +- item 3 +. +- item 1 + + item 2 + +- item 3 +```````````````````````````````` + +```````````````````````````````` example +- item 1 + 1. item 2 +. +- item 1 + 1. item 2 +```````````````````````````````` + +```````````````````````````````` example +- item 1 + + 1. item 2 +. +- item 1 + + 1. item 2 +```````````````````````````````` diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/fixtures/rst_admonition.txt b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/fixtures/rst_admonition.txt new file mode 100644 index 0000000000000000000000000000000000000000..b29bda3046fdb97802fefc9a7d16a9439d9efeb6 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/fixtures/rst_admonition.txt @@ -0,0 +1,46 @@ +# Admonition + +```````````````````````````````` example +.. hello:: Warning + + message +. +
..  hello:: Warning
+
+    message
+
+```````````````````````````````` + +```````````````````````````````` example +.. note:: Warning + + message +. +
+

Warning

+

message

+
+```````````````````````````````` + +Test with code block. + +```````````````````````````````` example +.. note:: + + print() +. +
+

Note

+
print()
+
+```````````````````````````````` + +Test with no message. + +```````````````````````````````` example +.. note:: Warning +. +
+

Warning

+
+```````````````````````````````` diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/fixtures/rst_toc.txt b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/fixtures/rst_toc.txt new file mode 100644 index 0000000000000000000000000000000000000000..d65e7516398316de9532f5f52cd0ccfe182b86f1 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/fixtures/rst_toc.txt @@ -0,0 +1,223 @@ +# Table of Contents + +## No TOC + +```````````````````````````````` example +none +. +

none

+```````````````````````````````` + +```````````````````````````````` example +# H1 +## H2 +. +

H1

+

H2

+```````````````````````````````` + + +## Simple TOC + +```````````````````````````````` example +.. toc:: + +# H1 +## H2 +. +
+Table of Contents + +
+

H1

+

H2

+```````````````````````````````` + +## Invalid Option + +```````````````````````````````` example +# H1 +## H2 + +.. toc:: + :max-level: s +. +

H1

+

H2

+
"max-level" option MUST be integer
+```````````````````````````````` + +```````````````````````````````` example +# H1 +## H2 +.. toc:: + :max-level: 9 +. +

H1

+

H2

+
"max-level" option MUST be <= 3
+```````````````````````````````` + +```````````````````````````````` example +# H1 +## H2 +.. toc:: + :min-level: 2 + :max-level: 1 +. +

H1

+

H2

+
"min-level" option MUST be less than "max-level" option
+```````````````````````````````` + + +## Complex + +```````````````````````````````` example +# H1 +## H2 +### H3 +#### H4 +# H1 B +# H1 `C` + +.. toc:: Contents + :max-level: 3 +. +

H1

+

H2

+

H3

+

H4

+

H1 B

+

H1 C

+
+Contents + +
+```````````````````````````````` + +## Insane + +```````````````````````````````` example +# H1 +### H3 +## H2 +#### H4 +### H3 B +# H1 B +.. toc:: +. +

H1

+

H3

+

H2

+

H4

+

H3 B

+

H1 B

+
+Table of Contents + +
+```````````````````````````````` + +```````````````````````````````` example +### H3 +## H2 +# H1 +.. toc:: +. +

H3

+

H2

+

H1

+
+Table of Contents + +
+```````````````````````````````` + +## Link in Heading + + +```````````````````````````````` example +# [foo](/bar) +.. toc:: +. +

foo

+
+Table of Contents + +
+```````````````````````````````` + +## HTML in Heading + +```````````````````````````````` example +# H1 +.. toc:: +. +

H1

+
+Table of Contents + +
+```````````````````````````````` + +## Collapse TOC + +```````````````````````````````` example +.. toc:: + :collapse: + +# H1 +## H2 +. +
+Table of Contents + +
+

H1

+

H2

+```````````````````````````````` diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/fixtures/ruby.txt b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/fixtures/ruby.txt new file mode 100644 index 0000000000000000000000000000000000000000..d89ebe28e1161ec3915768d72303feaa168f3c63 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/fixtures/ruby.txt @@ -0,0 +1,64 @@ +# Ruby + + +## ruby without link + +```````````````````````````````` example +[漢字(ㄏㄢˋㄗˋ)] +. +

漢字ㄏㄢˋㄗˋ

+```````````````````````````````` + +```````````````````````````````` example +[漢(ㄏㄢˋ)字(ㄗˋ)] +. +

漢ㄏㄢˋ字ㄗˋ

+```````````````````````````````` + +```````````````````````````````` example +[漢字(ㄏㄢˋㄗˋ)][] +. +

漢字ㄏㄢˋㄗˋ[]

+```````````````````````````````` + +```````````````````````````````` example +[漢字(ㄏㄢˋㄗˋ)][link] +. +

漢字ㄏㄢˋㄗˋ[link]

+```````````````````````````````` + +## ruby with link + +```````````````````````````````` example +[link]: /url + +[漢字(ㄏㄢˋㄗˋ)][link] +. +

漢字ㄏㄢˋㄗˋ

+```````````````````````````````` + +```````````````````````````````` example +[漢字(ㄏㄢˋㄗˋ)]() +. +

漢字ㄏㄢˋㄗˋ

+```````````````````````````````` + +```````````````````````````````` example +[漢字(ㄏㄢˋㄗˋ)](/url) +. +

漢字ㄏㄢˋㄗˋ

+```````````````````````````````` + +## ruby splits + +```````````````````````````````` example +[漢(かん)][字(じ)] +. +

漢かん字じ

+```````````````````````````````` + +```````````````````````````````` example +[[漢(かん)][字(じ)]](https://jisho.org/search/漢字) +. +

漢かん字じ

+```````````````````````````````` diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/fixtures/spoiler.txt b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/fixtures/spoiler.txt new file mode 100644 index 0000000000000000000000000000000000000000..b1394193004aa9a896ac9212dcab200818613506 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/fixtures/spoiler.txt @@ -0,0 +1,74 @@ +# Spoiler + +## Block spoiler + +```````````````````````````````` example +>! hi +. +
+

hi

+
+```````````````````````````````` + + +```````````````````````````````` example +>! not +> spoiler +. +
+

! not +spoiler

+
+```````````````````````````````` + +```````````````````````````````` example +>! multiple +>! lines +. +
+

multiple +lines

+
+```````````````````````````````` + +```````````````````````````````` example +>! foo +>! +>! bar +. +
+

foo

+

bar

+
+```````````````````````````````` + +```````````````````````````````` example +>! foo +> +>! bar +. +
+

! foo

+

! bar

+
+```````````````````````````````` + +## Inline spoiler + +```````````````````````````````` example +hi >! hide !< +. +

hi hide

+```````````````````````````````` + +```````````````````````````````` example +hi >!hide !< +. +

hi hide

+```````````````````````````````` + +```````````````````````````````` example +hi >!hide!< +. +

hi hide

+```````````````````````````````` diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/fixtures/strikethrough.txt b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/fixtures/strikethrough.txt new file mode 100644 index 0000000000000000000000000000000000000000..007a7777aefe1f68e20026c6d87675a12623f1b8 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/fixtures/strikethrough.txt @@ -0,0 +1,46 @@ +# Strikethrough + + +## strikethrough + +```````````````````````````````` example +~~delete me +. +

~~delete me

+```````````````````````````````` + +```````````````````````````````` example +~~delete me~~ +. +

delete me

+```````````````````````````````` + +```````````````````````````````` example +~~delete me~~~ +. +

~~delete me~~~

+```````````````````````````````` + +```````````````````````````````` example +~~delete me\~~~ +. +

delete me~

+```````````````````````````````` + +```````````````````````````````` example +~~delete \~\~ me~~ +. +

delete ~~ me

+```````````````````````````````` + +```````````````````````````````` example +~~delete [me~~](/) +. +

delete [me](/)

+```````````````````````````````` + +```````````````````````````````` example +~~[hello](/)~~ +. +

hello

+```````````````````````````````` diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/fixtures/subscript.txt b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/fixtures/subscript.txt new file mode 100644 index 0000000000000000000000000000000000000000..9e4ef8bad50771b18039cd681d91d51c203128aa --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/fixtures/subscript.txt @@ -0,0 +1,26 @@ +# Subscript + + +```````````````````````````````` example +CH~3~CH~2~OH +. +

CH3CH2OH

+```````````````````````````````` + +```````````````````````````````` example +text~a\ subscript~ +. +

texta subscript

+```````````````````````````````` + +```````````````````````````````` example +text~a subscript~ +. +

text~a subscript~

+```````````````````````````````` + +```````````````````````````````` example +text~a\~subscript~ +. +

texta~subscript

+```````````````````````````````` diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/fixtures/superscript.txt b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/fixtures/superscript.txt new file mode 100644 index 0000000000000000000000000000000000000000..8f114ca8c9566ddfd1d2800341f2065ded0ad560 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/fixtures/superscript.txt @@ -0,0 +1,26 @@ +# Superscript + + +```````````````````````````````` example +CH^3^CH^2^OH +. +

CH3CH2OH

+```````````````````````````````` + +```````````````````````````````` example +text^a\ supscript^ +. +

texta supscript

+```````````````````````````````` + +```````````````````````````````` example +text^a supscript^ +. +

text^a supscript^

+```````````````````````````````` + +```````````````````````````````` example +text^a\^supscript^ +. +

texta^supscript

+```````````````````````````````` diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/fixtures/table.txt b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/fixtures/table.txt new file mode 100644 index 0000000000000000000000000000000000000000..ff4e13ae743b2733f0174cca08c10da2a9b6f1f1 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/fixtures/table.txt @@ -0,0 +1,258 @@ +# Table in Markdown + +https://michelf.ca/projects/php-markdown/extra/#table + + +## nptable + + +```````````````````````````````` example +First Header | Second Header +------------- | ------------- +Content Cell | Content Cell +Content Cell | Content Cell +. + + + + + + + + + + + + + + + + + +
First HeaderSecond Header
Content CellContent Cell
Content CellContent Cell
+```````````````````````````````` + + +## table + +```````````````````````````````` example +| First Header | Second Header | +| ------------- | ------------- | +| Content Cell | | +| Content Cell | Content Cell | +. + + + + + + + + + + + + + + + + + +
First HeaderSecond Header
Content Cell
Content CellContent Cell
+```````````````````````````````` + + +```````````````````````````````` example +| Command | Description | +| --- | --- | +| git status | List all new or modified files | +| git diff | Show file differences that haven't been staged | +. + + + + + + + + + + + + + + + + + +
CommandDescription
git statusList all new or modified files
git diffShow file differences that haven't been staged
+```````````````````````````````` + +## align table + +```````````````````````````````` example + Left | Center | Right +:---- | :--------: | ------: + a | b | c +. + + + + + + + + + + + + + + + +
LeftCenterRight
abc
+```````````````````````````````` + +```````````````````````````````` example +| Left | Center | Right | +| :--- | :----: | ----: | +| a | b | c | +. + + + + + + + + + + + + + + + +
LeftCenterRight
abc
+```````````````````````````````` + +## Misc Table + +```````````````````````````````` example +| A | | +| - | | +| a | b | +. + + + + + + + + + + + + + +
A
ab
+```````````````````````````````` + +```````````````````````````````` example +A | +- | +a | b +. + + + + + + + + + + + + + +
A
ab
+```````````````````````````````` + + +```````````````````````````````` example +| Foo | Bar | +|-----|-----| +| boo | baz | +| faz | | +. + + + + + + + + + + + + + + + + + +
FooBar
boobaz
faz
+```````````````````````````````` + +## Mismatch length + +```````````````````````````````` example +| First Header | +| ------------- | ------------- | +| Content Cell | | +| Content Cell | Content Cell | +. +

| First Header | +| ------------- | ------------- | +| Content Cell | | +| Content Cell | Content Cell |

+```````````````````````````````` + +```````````````````````````````` example +| First Header | Second Header | +| ------------- | ------------- | +| Content Cell | +| Content Cell | Content Cell | +. +

| First Header | Second Header | +| ------------- | ------------- | +| Content Cell | +| Content Cell | Content Cell |

+```````````````````````````````` + +```````````````````````````````` example +A | +- | - | +a | b | c +. +

A |

+
    +
  • | - | +a | b | c
  • +
+```````````````````````````````` + +```````````````````````````````` example +A | B | C +- | - | - +a | b +. +

A | B | C

+
    +
  • | - | - +a | b
  • +
+```````````````````````````````` diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/fixtures/task_lists.txt b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/fixtures/task_lists.txt new file mode 100644 index 0000000000000000000000000000000000000000..c1760acbdd4dd55d815789bc11afad6f2f3a8c3d --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/fixtures/task_lists.txt @@ -0,0 +1,108 @@ +# Task Lists + +```````````````````````````````` example +- [ ] foo +- [x] bar +- [X] baz +. +
    +
  • foo
  • +
  • bar
  • +
  • baz
  • +
+```````````````````````````````` + +```````````````````````````````` example +- foo +- [ ] bar +. +
    +
  • foo
  • +
  • bar
  • +
+```````````````````````````````` + +```````````````````````````````` example +- foo + +- [ ] bar +- [x] baz + + text +. +
    +
  • foo

    +
  • +
  • bar

    +
  • +
  • baz

    +

    text

    +
  • +
+```````````````````````````````` + +```````````````````````````````` example +1. [ ] foo +2. [x] bar +3. [X] baz +. +
    +
  1. foo
  2. +
  3. bar
  4. +
  5. baz
  6. +
+```````````````````````````````` + +```````````````````````````````` example +- [ ] Task list item + over two lines +. +
    +
  • Task list item +over two lines
  • +
+```````````````````````````````` + +```````````````````````````````` example +- [ ] foo + - [x] bar + - [ ] baz +. +
    +
  • foo
      +
    • bar
    • +
    • baz
    • +
    +
  • +
+```````````````````````````````` + +```````````````````````````````` example +1. [ ] foo + 1. [ ] bar + 2. [ ] baz +. +
    +
  1. foo
      +
    1. bar
    2. +
    3. baz
    4. +
    +
  2. +
+```````````````````````````````` + +```````````````````````````````` example +> - [ ] foo +> - [x] bar +> - [ ] baz +. +
+
    +
  • foo
      +
    • bar
    • +
    • baz
    • +
    +
  • +
+
+```````````````````````````````` \ No newline at end of file diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/fixtures/url.txt b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/fixtures/url.txt new file mode 100644 index 0000000000000000000000000000000000000000..669bdd5f34d93942e407aa41569072a6ff6a2f91 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/fixtures/url.txt @@ -0,0 +1,22 @@ +# url plugin + + +```````````````````````````````` example +visit https://lepture.com/ +. +

visit https://lepture.com/

+```````````````````````````````` + + +```````````````````````````````` example +visit [https://lepture.com/](/foo) +. +

visit https://lepture.com/

+```````````````````````````````` + + +```````````````````````````````` example +visit https://lepture.com/ +. +

visit https://lepture.com/

+```````````````````````````````` diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/test_commonmark.py b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/test_commonmark.py new file mode 100644 index 0000000000000000000000000000000000000000..5ece254838b130d5765744897028436efb73b0e6 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/test_commonmark.py @@ -0,0 +1,76 @@ +import mistune +from tests import BaseTestCase, normalize_html + + +DIFF_CASES = { + 'setext_headings_093', + 'html_blocks_191', # mistune keeps \n + + 'images_573', # image can not be in image + + 'links_495', + 'links_517', # aggressive link group + 'links_518', + 'links_519', + 'links_531', + 'links_532', +} + +IGNORE_CASES = { + # we don't support link title in (title) + 'links_496', + 'links_504', + + # we don't support flanking delimiter run + 'emphasis_and_strong_emphasis_352', + 'emphasis_and_strong_emphasis_367', + 'emphasis_and_strong_emphasis_368', + 'emphasis_and_strong_emphasis_372', + 'emphasis_and_strong_emphasis_379', + 'emphasis_and_strong_emphasis_388', + 'emphasis_and_strong_emphasis_391', + + 'emphasis_and_strong_emphasis_406', + 'emphasis_and_strong_emphasis_407', + 'emphasis_and_strong_emphasis_408', + + 'emphasis_and_strong_emphasis_412', + 'emphasis_and_strong_emphasis_413', + 'emphasis_and_strong_emphasis_414', + 'emphasis_and_strong_emphasis_416', + 'emphasis_and_strong_emphasis_417', + 'emphasis_and_strong_emphasis_418', + + 'emphasis_and_strong_emphasis_424', + 'emphasis_and_strong_emphasis_425', + 'emphasis_and_strong_emphasis_426', + 'emphasis_and_strong_emphasis_429', + 'emphasis_and_strong_emphasis_430', + 'emphasis_and_strong_emphasis_431', + 'emphasis_and_strong_emphasis_460', + 'emphasis_and_strong_emphasis_467', + 'emphasis_and_strong_emphasis_470', + 'emphasis_and_strong_emphasis_471', + 'emphasis_and_strong_emphasis_477', + 'emphasis_and_strong_emphasis_478', +} + +for i in range(441, 447): + IGNORE_CASES.add('emphasis_and_strong_emphasis_' + str(i)) +for i in range(453, 459): + IGNORE_CASES.add('emphasis_and_strong_emphasis_' + str(i)) +for i in range(462, 466): + IGNORE_CASES.add('emphasis_and_strong_emphasis_' + str(i)) + + +class TestCommonMark(BaseTestCase): + @classmethod + def ignore_case(cls, n): + return n in IGNORE_CASES or n in DIFF_CASES + + def assert_case(self, n, text, html): + result = mistune.html(text) + self.assertEqual(normalize_html(result), normalize_html(html)) + + +TestCommonMark.load_fixtures('commonmark.json') diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/test_directives.py b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/test_directives.py new file mode 100644 index 0000000000000000000000000000000000000000..388963a4b196c3252368bc842d1bd250d66f3d98 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/test_directives.py @@ -0,0 +1,93 @@ +import os +from mistune import create_markdown +from mistune.directives import ( + RSTDirective, + FencedDirective, + Admonition, + TableOfContents, + Include, + Image, + Figure, +) +from tests import BaseTestCase +from tests.fixtures import ROOT + + +def load_directive_test(filename, directive, cls): + class TestDirective(BaseTestCase): + @staticmethod + def parse(text): + md = create_markdown( + escape=False, + plugins=[cls([directive])], + ) + html = md(text) + return html + + TestDirective.load_fixtures(filename + '.txt') + globals()["TestDirective_" + filename] = TestDirective + + +load_directive_test('rst_admonition', Admonition(), RSTDirective) +load_directive_test('rst_toc', TableOfContents(), RSTDirective) +load_directive_test('fenced_admonition', Admonition(), FencedDirective) +load_directive_test('fenced_toc', TableOfContents(), FencedDirective) +load_directive_test('fenced_image', Image(), FencedDirective) +load_directive_test('fenced_figure', Figure(), FencedDirective) + + +class CustomizeTableOfContents(TableOfContents): + def generate_heading_id(self, token, i): + return 't-' + str(i + 1) + + +class TestCustomizeToc(BaseTestCase): + def test_rst_toc(self): + md = create_markdown( + escape=False, + plugins=[ + RSTDirective([CustomizeTableOfContents()]), + ], + ) + html = md('# h1\n\n.. toc::\n') + self.assertIn('

h1

', html) + self.assertIn('h1', html) + + def test_fenced_toc(self): + md = create_markdown( + escape=False, + plugins=[ + FencedDirective([CustomizeTableOfContents()]), + ], + ) + html = md('# h1\n\n```{toc}\n```\n') + self.assertIn('

h1

', html) + self.assertIn('h1', html) + + def test_colon_fenced_toc(self): + md = create_markdown( + escape=False, + plugins=[ + FencedDirective([CustomizeTableOfContents()], ':'), + ], + ) + html = md('# h1\n\n:::{toc}\n:::\n') + self.assertIn('

h1

', html) + self.assertIn('h1', html) + + +class TestDirectiveInclude(BaseTestCase): + md = create_markdown(escape=False, plugins=[RSTDirective([Include()])]) # type: ignore[list-item] + + def test_html_include(self): + html = self.md.read(os.path.join(ROOT, 'include/text.md'))[0] + self.assertIn('Could not include self', html) + self.assertIn('Could not find file', html) + self.assertIn('
include html
', html) + self.assertIn('
', html) + self.assertIn('# Table of Contents', html) + + def test_include_missing_source(self): + s = '.. include:: foo.txt' + html = self.md(s) + self.assertIn('Missing source file', html) diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/test_hooks.py b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/test_hooks.py new file mode 100644 index 0000000000000000000000000000000000000000..8c0a02e9b600a6034ea367fd014ec7949fb0f5d3 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/test_hooks.py @@ -0,0 +1,26 @@ +import os +from mistune import create_markdown +from mistune.toc import add_toc_hook, render_toc_ul +from tests import BaseTestCase + + +class TestTocHook(BaseTestCase): + @staticmethod + def parse(text): + md = create_markdown(escape=False) + add_toc_hook(md) + html, state = md.parse(text) + result = html + render_toc_ul(state.env['toc_items']) + return result + + def test_customize_heading_id_func(self): + def heading_id(token, i): + return 't-' + str(i + 1) + + md = create_markdown(escape=False) + add_toc_hook(md, heading_id=heading_id) + html = md('# h1') + self.assertEqual(html, '

h1

\n') + + +TestTocHook.load_fixtures('hook_toc.txt') diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/test_misc.py b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/test_misc.py new file mode 100644 index 0000000000000000000000000000000000000000..99bc68d6eca362d235a2dff0ad449ceb8dd5eebc --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/test_misc.py @@ -0,0 +1,137 @@ +import mistune +from unittest import TestCase + + +class TestMiscCases(TestCase): + def test_none(self): + self.assertEqual(mistune.html(None), '') + + def test_before_parse_hooks(self): + def _add_name(md, state): + state.env['name'] = 'test' + + md = mistune.create_markdown() + md.before_parse_hooks.append(_add_name) + state = md.block.state_cls() + md.parse('', state) + self.assertEqual(state.env['name'], 'test') + + def test_hard_wrap(self): + md = mistune.create_markdown(escape=False, hard_wrap=True) + result = md('foo\nbar') + expected = '

foo
\nbar

' + self.assertEqual(result.strip(), expected) + + md = mistune.create_markdown( + escape=False, hard_wrap=True, plugins=['speedup']) + result = md('foo\nbar') + self.assertEqual(result.strip(), expected) + + def test_escape_html(self): + md = mistune.create_markdown(escape=True) + result = md('
1
') + expected = '

<div>1</div>

' + self.assertEqual(result.strip(), expected) + + result = md('1') + expected = '

<em>1</em>

' + self.assertEqual(result.strip(), expected) + + def test_harmful_links(self): + result = mistune.html('[h](javAscript:alert)') + expected = '

h

' + self.assertEqual(result.strip(), expected) + + def test_ref_link(self): + result = mistune.html('[link][h]\n\n[h]: /foo') + expected = '

link

' + self.assertEqual(result.strip(), expected) + + def test_allow_harmful_protocols(self): + renderer = mistune.HTMLRenderer(allow_harmful_protocols=True) + md = mistune.Markdown(renderer) + result = md('[h](javascript:alert)') + expected = '

h

' + self.assertEqual(result.strip(), expected) + + def test_allow_data_protocols(self): + renderer = mistune.HTMLRenderer(allow_harmful_protocols=['data:']) + md = mistune.Markdown(renderer) + result = md('[h](data:alert)') + expected = '

h

' + self.assertEqual(result.strip(), expected) + + def test_use_plugin(self): + from mistune.plugins.url import url + md = mistune.Markdown(mistune.HTMLRenderer()) + md.use(url) + + def test_markdown_func(self): + result = mistune.markdown('**b**') + expected = '

b

\n' + self.assertEqual(result, expected) + + # trigger to use cached parser + result = mistune.markdown('**b**') + self.assertEqual(result, expected) + + def test_ast_output(self): + md = mistune.create_markdown(escape=False, renderer=None) + text = '# h1\n\nfoo **bar**\n\n`&<>"`' + result = md(text) + expected = [ + { + 'type': 'heading', + 'children': [{'type': 'text', 'raw': 'h1'}], + 'attrs': {'level': 1}, + 'style': 'atx', + }, + {'type': 'blank_line'}, + { + 'type': 'paragraph', + 'children': [ + {'type': 'text', 'raw': 'foo '}, + {'type': 'strong', 'children': [{'type': 'text', 'raw': 'bar'}]} + ] + }, + {'type': 'blank_line'}, + { + 'type': 'paragraph', + 'children': [ + {'type': 'codespan', 'raw': '&<>"'}, + ] + }, + ] + self.assertEqual(result, expected) + + def test_ast_url(self): + md = mistune.create_markdown(escape=False, renderer=None) + label = 'hi &<>"' + url = 'https://example.com/foo?a=1&b=2' + text = '[{}]({})'.format(label, url) + result = md(text) + expected = [ + { + 'type': 'paragraph', + 'children': [ + { + 'type': 'link', + 'children': [{'type': 'text', 'raw': label}], + 'attrs': {'url': url}, + }, + ], + }, + ] + self.assertEqual(result, expected) + + def test_emsp(self): + md = mistune.create_markdown(escape=False, hard_wrap=True) + result = md('\u2003\u2003foo\nbar\n\n\u2003\u2003foobar') + expected = '

\u2003\u2003foo
\nbar

\n

\u2003\u2003foobar

' + self.assertEqual(result.strip(), expected) + + def test_html_tag_text_following_list(self): + md = mistune.create_markdown(escape=False, hard_wrap=True) + result = md('foo\n- bar\n\ntable') + expected = '

foo

\n
    \n
  • bar
  • \n
\n

table

' + self.assertEqual(result.strip(), expected) diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/test_plugins.py b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/test_plugins.py new file mode 100644 index 0000000000000000000000000000000000000000..408c5fac6733b3307ee4db14e0996137e1843ebf --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/test_plugins.py @@ -0,0 +1,66 @@ +from mistune import create_markdown +from mistune.plugins.table import table_in_list, table_in_quote +from mistune.plugins.math import math_in_list, math_in_quote +from tests import BaseTestCase + + +def load_plugin(plugin_name): + md1 = create_markdown(escape=False, plugins=[plugin_name]) + md2 = create_markdown(escape=False, plugins=[plugin_name, 'speedup']) + + class TestPlugin1(BaseTestCase): + parse = md1 + + class TestPlugin2(BaseTestCase): + parse = md2 + + TestPlugin1.load_fixtures(plugin_name + ".txt") + TestPlugin2.load_fixtures(plugin_name + ".txt") + globals()["TestPlugin1_" + plugin_name] = TestPlugin1 + globals()["TestPlugin2_" + plugin_name] = TestPlugin2 + + +load_plugin("url") +load_plugin("strikethrough") +load_plugin("mark") +load_plugin("insert") +load_plugin("superscript") +load_plugin("subscript") +load_plugin("task_lists") +load_plugin("table") +load_plugin("def_list") +load_plugin("footnotes") +load_plugin("abbr") +load_plugin("math") +load_plugin("ruby") +load_plugin("spoiler") + + +class TestExtraPlugins(BaseTestCase): + def test_table_in_list(self): + text = '''- Cell | Cell\n ---- | ----\n 1 | 2\n''' + md1 = create_markdown(escape=False) + md2 = create_markdown(escape=False, plugins=['table', table_in_list]) + self.assertNotIn('', md1(text)) + self.assertIn('
', md2(text)) + + def test_table_in_quote(self): + text = '''> Cell | Cell\n> ---- | ----\n> 1 | 2\n''' + md1 = create_markdown(escape=False) + md2 = create_markdown(escape=False, plugins=['table', table_in_quote]) + self.assertNotIn('
', md1(text)) + self.assertIn('
', md2(text)) + + def test_math_in_list(self): + text = '''- $$\n foo\n $$\n''' + md1 = create_markdown(escape=False) + md2 = create_markdown(escape=False, plugins=['math', math_in_list]) + self.assertNotIn('class="math"', md1(text)) + self.assertIn('class="math"', md2(text)) + + def test_math_in_quote(self): + text = '''> $$\n> foo\n> $$\n''' + md1 = create_markdown(escape=False) + md2 = create_markdown(escape=False, plugins=['math', math_in_quote]) + self.assertNotIn('class="math"', md1(text)) + self.assertIn('class="math"', md2(text)) diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/test_renderers.py b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/test_renderers.py new file mode 100644 index 0000000000000000000000000000000000000000..dca515873cd24cf642fab5ff6dbb34d884c9a7ae --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/test_renderers.py @@ -0,0 +1,17 @@ +from mistune import create_markdown +from mistune.renderers.rst import RSTRenderer +from mistune.renderers.markdown import MarkdownRenderer +from tests import BaseTestCase + + +def load_renderer(renderer): + class TestRenderer(BaseTestCase): + parse = create_markdown(renderer=renderer) + + name = renderer.NAME + TestRenderer.load_fixtures('renderer_' + name + '.txt') + globals()["TestRenderer" + name.title()] = TestRenderer + + +load_renderer(RSTRenderer()) +load_renderer(MarkdownRenderer()) diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/test_syntax.py b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/test_syntax.py new file mode 100644 index 0000000000000000000000000000000000000000..06341d595c3cc5ef64f36c729f97901f312317d7 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/tests/trusted/tests/test_syntax.py @@ -0,0 +1,12 @@ +import mistune +from tests import BaseTestCase, normalize_html + + +class TestSyntax(BaseTestCase): + def assert_case(self, n, text, html): + result = mistune.html(text) + self.assertEqual(normalize_html(result), normalize_html(html)) + + +TestSyntax.load_fixtures('fix-commonmark.txt') +TestSyntax.load_fixtures('diff-commonmark.txt') diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/validation/canaries/first-hunk-only.sh b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/validation/canaries/first-hunk-only.sh new file mode 100644 index 0000000000000000000000000000000000000000..b85c7dd293917d9b72805032d5a405f5b1525167 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/validation/canaries/first-hunk-only.sh @@ -0,0 +1,27 @@ +#!/bin/bash +set -Eeuo pipefail +cd /testbed/repo +cat > /tmp/openenv-reference.diff <<'OPENENV_PARTIAL' +diff --git a/src/mistune/plugins/footnotes.py b/src/mistune/plugins/footnotes.py +index 57aea3dd6ffd30ee0f3301d2221545e82630a54e..96fe8df2b99794a5d86ced246bc20fdb235ee811 100644 +--- a/src/mistune/plugins/footnotes.py ++++ b/src/mistune/plugins/footnotes.py +@@ -53,13 +53,13 @@ + ) -> int: + ref = state.env.get("ref_footnotes") + if not ref: +- ref = [] ++ ref = {} + + key = unikey(m.group('footnote_key')) + if key not in ref: +- ref[key.lower()] = m.group('footnote_text').strip() ++ ref[key] = m.group('footnote_text') + state.env['ref_footnotes'] = ref +- return m.start() ++ return m.end() + + + def parse_footnote_item( +OPENENV_PARTIAL +/usr/bin/git -c core.hooksPath=/dev/null -c core.fsmonitor=false apply --whitespace=nowarn /tmp/openenv-reference.diff diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/validation/canaries/original-bug.sh b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/validation/canaries/original-bug.sh new file mode 100644 index 0000000000000000000000000000000000000000..927547df786c86ab3bb5eeb917a31e0fa1895f8b --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/validation/canaries/original-bug.sh @@ -0,0 +1,3 @@ +#!/bin/bash +set -Eeuo pipefail +: diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/validation/openenv.json b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/validation/openenv.json new file mode 100644 index 0000000000000000000000000000000000000000..a13b3c577df494f6c894584d2b608ab051ebc44f --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__09sp6cd7/validation/openenv.json @@ -0,0 +1,27 @@ +{ + "canaries": "validation/canaries", + "profile": "harbor-semantic-v1", + "requires_credentials": false, + "resources": { + "cpu": 2, + "disk_mb": 16384, + "episode_timeout_s": 1800, + "memory_mb": 8192 + }, + "reward": { + "floor_margin": 0.1, + "oracle_tolerance": 0, + "range": [ + 0, + 1 + ] + }, + "reward_key": "reward", + "types": { + "tags": [ + "swe", + "python", + "mutation-repair" + ] + } +} diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/LICENSE.source b/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/LICENSE.source new file mode 100644 index 0000000000000000000000000000000000000000..b141cdb9f3cb8010b9c3dfb392ff1a00db58a413 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/LICENSE.source @@ -0,0 +1,14 @@ +Copyright (c) 2014, Hsiaoming Yang + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + +* Neither the name of the creator nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/adapter.json b/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/adapter.json new file mode 100644 index 0000000000000000000000000000000000000000..3bf6e875b04e80540dd1f13087d3e7a8ce360aae --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/adapter.json @@ -0,0 +1,131 @@ +{ + "canary_selection": "Fixed first provided gold hunk only when at least2hunks exist; strict subset, never reward-selected. Single-hunk task original-bug canary is explicitly NOP-equivalent and adds no signal beyond floor_gap.", + "collector_sha256": "352e555112f2de8a1393f939903e4971c9ace0e944843762b707a725c5c72481", + "dependency_installation_pinned": false, + "dependency_setup_sha256": "883d23539d00e744dc83da083548b6dd699be04238df34d5bd5b500a5dc53f28", + "gold_patch_sha256": "68e79dd3fb65fa601d02627bfa3c8d02ef87d4db3ef5a6aae7791c97f31ed85f", + "hostile_code_isolation_established": false, + "known_wrong_semantic_implementations": 0, + "native_inventory_sha256": "149112ad6bec78d562f63b6a044d5116835182ad3432788f247778cb338af4d4", + "new_files_deletions_and_executable_modes_supported": true, + "official_profile": { + "eval_sets": [], + "profile_class": "MistuneBf54ef67", + "profile_lines": [ + 570, + 573 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "bf54ef67390e02a5cdee7495d4386d7770c1902b", + "upstream_repo": "lepture/mistune" + }, + "original_bug_canary_nop_equivalent": true, + "original_bug_runtime_wrongness_established": false, + "partial_repair_canary": true, + "partial_repair_sha256": "ae2d53eeff0db31dada4376d129a1cd22e5fd5766a23cb3834f261228b3ca5fc", + "partial_repair_wrongness_established": false, + "positive_approval_policy": "All original strict presence/identity/no-skip/no-error/exit checks retained", + "private_checker_sha256": "f0a641064b725415e23a0221bb53c90446d7efcb7f9ece5ede93a220d18dd9e7", + "private_checker_version": "matched-failure-precedence-v2", + "provided_original_bug_control": true, + "repo_url": "https://github.com/swesmith/lepture__mistune.bf54ef67.git", + "runtime_image": null, + "runtime_ready": false, + "runtime_recipe": { + "dependency_installation_pinned": false, + "official_install_cmds": [ + "python -m pip install -e ." + ], + "official_pytest_argv": [ + "pytest", + "--disable-warnings", + "--color=no", + "--tb=no", + "--verbose" + ], + "official_test_command": "source /opt/miniconda3/bin/activate; conda activate testbed; pytest --disable-warnings --color=no --tb=no --verbose", + "operator_test_runner_prerequisites": [ + "python -m pip install pytest==8.4.2" + ], + "operator_test_runner_reason": "The official profile invokes pytest, but the common tools runtime does not provide it; pinned separately from source-native project requirements.", + "panel_normalization": "Override project addopts only to execute the exact frozen native panels; add JUnit output, preserve official pytest options and all selectors.", + "python_version": "3.10", + "source_bound_test_dependency_cmds": [], + "test_dependency_source_sha256": { + "pyproject.toml": "b2922e3ef89e2918935d38fb3a777bdbc741619942276a75fd21a8dd9faf6b42" + } + }, + "runtime_resource_review_required": false, + "schema": "python-git-patch-jobs-v1", + "source_base_commit": "69def72ff04a96ecf6a3fff3f0d0d6d9493d0016", + "source_completion_sha256": "78acb37f4cf2a52d738613b6cbfbf87584021fc4a5458b9ba85f38402fabe22a", + "source_index_sha256": "e856874b9410fce9f3bfea52c8c482e84b3e43942d87517f8b55f0034bd40f6f", + "source_pr_url": null, + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:lepture__mistune.bf54ef67.combine_file__0adn7wof", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "62750c95db25a8fb93dda09242f64e07508d9231", + "instruction_sha256": "5d7dd0d57c4f836f666ecd266d4cd92c4acbe268f44dc0ea042007c11b8930ad", + "is_fork": true, + "learner_path": "tasks/87038867c5ba8248e9db56d2/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "bf54ef67390e02a5cdee7495d4386d7770c1902b", + "actual_upstream_url": "https://raw.githubusercontent.com/lepture/mistune/bf54ef67390e02a5cdee7495d4386d7770c1902b/LICENSE", + "reviewed": true, + "sha256": "539013fd8e19f744f8bf0e27a532bbff54cd689ecef7a800f56ae5dc824be870", + "spdx": "BSD-3-Clause", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/lepture__mistune.bf54ef67/69def72ff04a96ecf6a3fff3f0d0d6d9493d0016/LICENSE" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "bf54ef67390e02a5cdee7495d4386d7770c1902b", + "patch_sha256": "c3bd306acfc12ff1dc8ba54b47bff7d8ada4d516fa24a2e96810cb3390dd14c0", + "provenance_path": "tasks/87038867c5ba8248e9db56d2/source-proof.json", + "repository_lineage": [ + "swesmith/lepture__mistune.bf54ef67", + "lepture/mistune" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "69def72ff04a96ecf6a3fff3f0d0d6d9493d0016", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "8b73fda73cce7bd6e10265ebedcd3d33241bc84b", + "source_kind": "mutation", + "source_repo": "swesmith/lepture__mistune.bf54ef67", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "lepture__mistune.bf54ef67.combine_file__0adn7wof", + "task_sha256": "3bc63ae763a6e5515a18f6e6abaa5bb4d622b9db8591e114736fee6851e221d5", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "lepture/mistune", + "usage": "quarantine_only" + }, + "source_repo": "swesmith/lepture__mistune.bf54ef67", + "symlink_submodule_changes_supported": false, + "task_id": "lepture__mistune.bf54ef67.combine_file__0adn7wof", + "transfer": "index-independent-worktree-to-Git-binary-patch", + "transfer_path": "/testbed/submission.patch", + "upstream_repo": "lepture/mistune" +} diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/dependency-setup.sh b/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/dependency-setup.sh new file mode 100644 index 0000000000000000000000000000000000000000..551d5bb0d87bd3b22dd7098dddea7e0794a2ab40 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/dependency-setup.sh @@ -0,0 +1,8 @@ +#!/bin/bash +set -Eeuo pipefail +source /opt/miniconda3/bin/activate +conda activate testbed +cd /testbed/repo +python -c 'import sys; assert sys.version_info[:2] == (3, 10)' +python -m pip install pytest==8.4.2 +python -m pip install -e . diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/environment/Dockerfile b/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/environment/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..a59b58c2ea8217c78c1e39b4678f93c8c0023bcd --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/environment/Dockerfile @@ -0,0 +1,3 @@ +# Runtime is selected only by an independently qualified immutable amd64 receipt. +FROM ubuntu:22.04 +RUN false diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/instruction.md b/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/instruction.md new file mode 100644 index 0000000000000000000000000000000000000000..7617f7031e1f9e7da78744e53311ddb43e547dd7 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/instruction.md @@ -0,0 +1,53 @@ +Setext headings not parsing correctly after recent changes + +#### Description + +Setext headings (underlined with `=` or `-`) are not being parsed properly. The parser seems to be having issues with the setext heading detection logic. + +#### Steps/Code to Reproduce + +```python +import mistune + +markdown_text = """This is a heading +================== + +This is another heading +----------------------- + +Regular paragraph text. +""" + +md = mistune.create_markdown() +result = md(markdown_text) +print(result) +``` + +Expected output should show proper HTML headings (`

` and `

`), but the current behavior is not working as expected. + +Also affects more complex cases: + +```python +import mistune + +markdown_text = """Heading 1 +========= + +Some content here. + +Heading 2 +--------- + +More content. +""" + +md = mistune.create_markdown() +result = md(markdown_text) +print(result) +``` + +The setext heading syntax should work where a line of text is followed by a line of `=` characters (for h1) or `-` characters (for h2), but this appears to be broken. + +## Environment + +The repository is at `/testbed/repo`. Its dependencies, including pytest, are installed in the `testbed` conda environment, which comes first on PATH. If `python -m pytest` reports that pytest is missing, use the full interpreter path: `/opt/miniconda3/envs/testbed/bin/python -m pytest `. Don't install packages: the tests need nothing else, and the sandbox may have no network access. diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/metadata.json b/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/metadata.json new file mode 100644 index 0000000000000000000000000000000000000000..ac19b407d19f07cc3ce2a1e4d9428d375590a5d0 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/metadata.json @@ -0,0 +1,1190 @@ +{ + "all_runtime_and_training_flags": false, + "official_profile": { + "eval_sets": [], + "profile_class": "MistuneBf54ef67", + "profile_lines": [ + 570, + 573 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "bf54ef67390e02a5cdee7495d4386d7770c1902b", + "upstream_repo": "lepture/mistune" + }, + "source_healthy_reference_proof": { + "FAIL_TO_PASS": [ + "tests/test_commonmark.py::TestCommonMark::test_backslash_escapes_019", + "tests/test_commonmark.py::TestCommonMark::test_backslash_escapes_024", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_228", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_229", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_230", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_232", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_233", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_234", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_235", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_236", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_237", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_238", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_241", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_242", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_243", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_244", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_245", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_246", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_247", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_248", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_249", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_250", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_251", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_252", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_034", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_119", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_120", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_122", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_123", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_124", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_125", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_126", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_127", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_128", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_129", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_130", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_131", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_132", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_133", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_135", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_136", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_137", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_139", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_140", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_141", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_142", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_143", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_144", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_146", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_147", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_174", + "tests/test_commonmark.py::TestCommonMark::test_indented_code_blocks_115", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_212", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_214", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_218", + "tests/test_commonmark.py::TestCommonMark::test_list_items_253", + "tests/test_commonmark.py::TestCommonMark::test_list_items_254", + "tests/test_commonmark.py::TestCommonMark::test_list_items_259", + "tests/test_commonmark.py::TestCommonMark::test_list_items_260", + "tests/test_commonmark.py::TestCommonMark::test_list_items_263", + "tests/test_commonmark.py::TestCommonMark::test_list_items_278", + "tests/test_commonmark.py::TestCommonMark::test_list_items_279", + "tests/test_commonmark.py::TestCommonMark::test_list_items_280", + "tests/test_commonmark.py::TestCommonMark::test_list_items_286", + "tests/test_commonmark.py::TestCommonMark::test_list_items_287", + "tests/test_commonmark.py::TestCommonMark::test_list_items_288", + "tests/test_commonmark.py::TestCommonMark::test_list_items_290", + "tests/test_commonmark.py::TestCommonMark::test_list_items_292", + "tests/test_commonmark.py::TestCommonMark::test_list_items_293", + "tests/test_commonmark.py::TestCommonMark::test_lists_318", + "tests/test_commonmark.py::TestCommonMark::test_lists_320", + "tests/test_commonmark.py::TestCommonMark::test_lists_321", + "tests/test_commonmark.py::TestCommonMark::test_lists_324", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_085", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_092", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_096", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_098", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_100", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_101", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_104", + "tests/test_commonmark.py::TestCommonMark::test_tabs_006", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_043", + "tests/test_directives.py::TestDirective_fenced_admonition::test_admonition_002", + "tests/test_directives.py::TestDirective_fenced_admonition::test_admonition_008", + "tests/test_directives.py::TestDirective_fenced_figure::test_all_options_001", + "tests/test_directives.py::TestDirective_fenced_figure::test_legend_001", + "tests/test_directives.py::TestDirective_fenced_figure::test_legend_002", + "tests/test_directives.py::TestDirectiveInclude::test_html_include", + "tests/test_plugins.py::TestPlugin1_task_lists::test_task_lists_008", + "tests/test_plugins.py::TestPlugin2_task_lists::test_task_lists_008", + "tests/test_plugins.py::TestExtraPlugins::test_math_in_quote", + "tests/test_plugins.py::TestExtraPlugins::test_table_in_quote", + "tests/test_renderers.py::TestRendererRst::test_code_002", + "tests/test_renderers.py::TestRendererRst::test_quote_001", + "tests/test_renderers.py::TestRendererRst::test_quote_002", + "tests/test_renderers.py::TestRendererRst::test_quote_003", + "tests/test_renderers.py::TestRendererMarkdown::test_code_002", + "tests/test_renderers.py::TestRendererMarkdown::test_quote_001", + "tests/test_renderers.py::TestRendererMarkdown::test_quote_002", + "tests/test_syntax.py::TestSyntax::test_max_depth_001", + "tests/test_syntax.py::TestSyntax::test_setext_headings_001" + ], + "PASS_TO_PASS": [ + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_062", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_063", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_064", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_065", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_066", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_067", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_068", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_069", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_070", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_071", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_072", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_073", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_074", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_075", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_076", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_077", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_078", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_079", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_593", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_594", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_595", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_596", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_597", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_598", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_599", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_600", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_601", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_602", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_603", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_604", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_605", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_606", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_607", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_608", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_609", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_610", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_611", + "tests/test_commonmark.py::TestCommonMark::test_backslash_escapes_012", + "tests/test_commonmark.py::TestCommonMark::test_backslash_escapes_013", + "tests/test_commonmark.py::TestCommonMark::test_backslash_escapes_014", + "tests/test_commonmark.py::TestCommonMark::test_backslash_escapes_015", + "tests/test_commonmark.py::TestCommonMark::test_backslash_escapes_016", + "tests/test_commonmark.py::TestCommonMark::test_backslash_escapes_017", + "tests/test_commonmark.py::TestCommonMark::test_backslash_escapes_018", + "tests/test_commonmark.py::TestCommonMark::test_backslash_escapes_020", + "tests/test_commonmark.py::TestCommonMark::test_backslash_escapes_021", + "tests/test_commonmark.py::TestCommonMark::test_backslash_escapes_022", + "tests/test_commonmark.py::TestCommonMark::test_backslash_escapes_023", + "tests/test_commonmark.py::TestCommonMark::test_blank_lines_227", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_231", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_239", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_240", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_328", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_329", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_330", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_331", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_332", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_333", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_334", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_335", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_336", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_337", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_338", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_339", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_340", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_341", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_342", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_343", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_344", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_345", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_346", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_347", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_348", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_349", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_350", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_351", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_353", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_354", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_355", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_356", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_357", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_358", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_359", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_360", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_361", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_362", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_363", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_364", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_365", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_366", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_369", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_370", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_371", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_373", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_374", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_375", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_376", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_377", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_378", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_380", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_381", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_382", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_383", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_384", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_385", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_386", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_387", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_389", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_390", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_392", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_393", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_394", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_395", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_396", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_397", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_398", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_399", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_400", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_401", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_402", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_403", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_404", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_405", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_409", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_410", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_411", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_415", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_419", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_420", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_421", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_422", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_423", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_427", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_428", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_432", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_433", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_434", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_435", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_436", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_437", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_438", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_439", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_440", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_447", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_448", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_449", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_450", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_451", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_452", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_459", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_461", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_466", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_468", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_469", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_472", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_473", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_474", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_475", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_476", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_479", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_480", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_025", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_026", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_027", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_028", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_029", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_030", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_031", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_032", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_033", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_035", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_036", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_037", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_038", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_039", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_040", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_041", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_121", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_134", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_138", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_145", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_633", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_634", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_635", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_636", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_637", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_638", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_639", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_640", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_641", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_642", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_643", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_644", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_645", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_646", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_647", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_148", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_149", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_150", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_151", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_152", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_153", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_154", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_155", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_156", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_157", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_158", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_159", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_160", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_161", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_162", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_163", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_164", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_165", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_166", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_167", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_168", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_169", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_170", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_171", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_172", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_173", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_175", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_176", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_177", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_178", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_179", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_180", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_181", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_182", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_183", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_184", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_185", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_186", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_187", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_188", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_189", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_190", + "tests/test_commonmark.py::TestCommonMark::test_images_571", + "tests/test_commonmark.py::TestCommonMark::test_images_572", + "tests/test_commonmark.py::TestCommonMark::test_images_574", + "tests/test_commonmark.py::TestCommonMark::test_images_575", + "tests/test_commonmark.py::TestCommonMark::test_images_576", + "tests/test_commonmark.py::TestCommonMark::test_images_577", + "tests/test_commonmark.py::TestCommonMark::test_images_578", + "tests/test_commonmark.py::TestCommonMark::test_images_579", + "tests/test_commonmark.py::TestCommonMark::test_images_580", + "tests/test_commonmark.py::TestCommonMark::test_images_581", + "tests/test_commonmark.py::TestCommonMark::test_images_582", + "tests/test_commonmark.py::TestCommonMark::test_images_583", + "tests/test_commonmark.py::TestCommonMark::test_images_584", + "tests/test_commonmark.py::TestCommonMark::test_images_585", + "tests/test_commonmark.py::TestCommonMark::test_images_586", + "tests/test_commonmark.py::TestCommonMark::test_images_587", + "tests/test_commonmark.py::TestCommonMark::test_images_588", + "tests/test_commonmark.py::TestCommonMark::test_images_589", + "tests/test_commonmark.py::TestCommonMark::test_images_590", + "tests/test_commonmark.py::TestCommonMark::test_images_591", + "tests/test_commonmark.py::TestCommonMark::test_images_592", + "tests/test_commonmark.py::TestCommonMark::test_indented_code_blocks_107", + "tests/test_commonmark.py::TestCommonMark::test_indented_code_blocks_108", + "tests/test_commonmark.py::TestCommonMark::test_indented_code_blocks_109", + "tests/test_commonmark.py::TestCommonMark::test_indented_code_blocks_110", + "tests/test_commonmark.py::TestCommonMark::test_indented_code_blocks_111", + "tests/test_commonmark.py::TestCommonMark::test_indented_code_blocks_112", + "tests/test_commonmark.py::TestCommonMark::test_indented_code_blocks_113", + "tests/test_commonmark.py::TestCommonMark::test_indented_code_blocks_114", + "tests/test_commonmark.py::TestCommonMark::test_indented_code_blocks_116", + "tests/test_commonmark.py::TestCommonMark::test_indented_code_blocks_117", + "tests/test_commonmark.py::TestCommonMark::test_indented_code_blocks_118", + "tests/test_commonmark.py::TestCommonMark::test_inlines_327", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_192", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_193", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_194", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_195", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_196", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_197", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_198", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_199", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_200", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_201", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_202", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_203", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_204", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_205", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_206", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_207", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_208", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_209", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_210", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_211", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_213", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_215", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_216", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_217", + "tests/test_commonmark.py::TestCommonMark::test_links_481", + "tests/test_commonmark.py::TestCommonMark::test_links_482", + "tests/test_commonmark.py::TestCommonMark::test_links_483", + "tests/test_commonmark.py::TestCommonMark::test_links_484", + "tests/test_commonmark.py::TestCommonMark::test_links_485", + "tests/test_commonmark.py::TestCommonMark::test_links_486", + "tests/test_commonmark.py::TestCommonMark::test_links_487", + "tests/test_commonmark.py::TestCommonMark::test_links_488", + "tests/test_commonmark.py::TestCommonMark::test_links_489", + "tests/test_commonmark.py::TestCommonMark::test_links_490", + "tests/test_commonmark.py::TestCommonMark::test_links_491", + "tests/test_commonmark.py::TestCommonMark::test_links_492", + "tests/test_commonmark.py::TestCommonMark::test_links_493", + "tests/test_commonmark.py::TestCommonMark::test_links_494", + "tests/test_commonmark.py::TestCommonMark::test_links_497", + "tests/test_commonmark.py::TestCommonMark::test_links_498", + "tests/test_commonmark.py::TestCommonMark::test_links_499", + "tests/test_commonmark.py::TestCommonMark::test_links_500", + "tests/test_commonmark.py::TestCommonMark::test_links_501", + "tests/test_commonmark.py::TestCommonMark::test_links_502", + "tests/test_commonmark.py::TestCommonMark::test_links_503", + "tests/test_commonmark.py::TestCommonMark::test_links_505", + "tests/test_commonmark.py::TestCommonMark::test_links_506", + "tests/test_commonmark.py::TestCommonMark::test_links_507", + "tests/test_commonmark.py::TestCommonMark::test_links_508", + "tests/test_commonmark.py::TestCommonMark::test_links_509", + "tests/test_commonmark.py::TestCommonMark::test_links_510", + "tests/test_commonmark.py::TestCommonMark::test_links_511", + "tests/test_commonmark.py::TestCommonMark::test_links_512", + "tests/test_commonmark.py::TestCommonMark::test_links_513", + "tests/test_commonmark.py::TestCommonMark::test_links_514", + "tests/test_commonmark.py::TestCommonMark::test_links_515", + "tests/test_commonmark.py::TestCommonMark::test_links_516", + "tests/test_commonmark.py::TestCommonMark::test_links_520", + "tests/test_commonmark.py::TestCommonMark::test_links_521", + "tests/test_commonmark.py::TestCommonMark::test_links_522", + "tests/test_commonmark.py::TestCommonMark::test_links_523", + "tests/test_commonmark.py::TestCommonMark::test_links_524", + "tests/test_commonmark.py::TestCommonMark::test_links_525", + "tests/test_commonmark.py::TestCommonMark::test_links_526", + "tests/test_commonmark.py::TestCommonMark::test_links_527", + "tests/test_commonmark.py::TestCommonMark::test_links_528", + "tests/test_commonmark.py::TestCommonMark::test_links_529", + "tests/test_commonmark.py::TestCommonMark::test_links_530", + "tests/test_commonmark.py::TestCommonMark::test_links_533", + "tests/test_commonmark.py::TestCommonMark::test_links_534", + "tests/test_commonmark.py::TestCommonMark::test_links_535", + "tests/test_commonmark.py::TestCommonMark::test_links_536", + "tests/test_commonmark.py::TestCommonMark::test_links_537", + "tests/test_commonmark.py::TestCommonMark::test_links_538", + "tests/test_commonmark.py::TestCommonMark::test_links_539", + "tests/test_commonmark.py::TestCommonMark::test_links_540", + "tests/test_commonmark.py::TestCommonMark::test_links_541", + "tests/test_commonmark.py::TestCommonMark::test_links_542", + "tests/test_commonmark.py::TestCommonMark::test_links_543", + "tests/test_commonmark.py::TestCommonMark::test_links_544", + "tests/test_commonmark.py::TestCommonMark::test_links_545", + "tests/test_commonmark.py::TestCommonMark::test_links_546", + "tests/test_commonmark.py::TestCommonMark::test_links_547", + "tests/test_commonmark.py::TestCommonMark::test_links_548", + "tests/test_commonmark.py::TestCommonMark::test_links_549", + "tests/test_commonmark.py::TestCommonMark::test_links_550", + "tests/test_commonmark.py::TestCommonMark::test_links_551", + "tests/test_commonmark.py::TestCommonMark::test_links_552", + "tests/test_commonmark.py::TestCommonMark::test_links_553", + "tests/test_commonmark.py::TestCommonMark::test_links_554", + "tests/test_commonmark.py::TestCommonMark::test_links_555", + "tests/test_commonmark.py::TestCommonMark::test_links_556", + "tests/test_commonmark.py::TestCommonMark::test_links_557", + "tests/test_commonmark.py::TestCommonMark::test_links_558", + "tests/test_commonmark.py::TestCommonMark::test_links_559", + "tests/test_commonmark.py::TestCommonMark::test_links_560", + "tests/test_commonmark.py::TestCommonMark::test_links_561", + "tests/test_commonmark.py::TestCommonMark::test_links_562", + "tests/test_commonmark.py::TestCommonMark::test_links_563", + "tests/test_commonmark.py::TestCommonMark::test_links_564", + "tests/test_commonmark.py::TestCommonMark::test_links_565", + "tests/test_commonmark.py::TestCommonMark::test_links_566", + "tests/test_commonmark.py::TestCommonMark::test_links_567", + "tests/test_commonmark.py::TestCommonMark::test_links_568", + "tests/test_commonmark.py::TestCommonMark::test_links_569", + "tests/test_commonmark.py::TestCommonMark::test_links_570", + "tests/test_commonmark.py::TestCommonMark::test_list_items_255", + "tests/test_commonmark.py::TestCommonMark::test_list_items_256", + "tests/test_commonmark.py::TestCommonMark::test_list_items_257", + "tests/test_commonmark.py::TestCommonMark::test_list_items_258", + "tests/test_commonmark.py::TestCommonMark::test_list_items_261", + "tests/test_commonmark.py::TestCommonMark::test_list_items_262", + "tests/test_commonmark.py::TestCommonMark::test_list_items_264", + "tests/test_commonmark.py::TestCommonMark::test_list_items_265", + "tests/test_commonmark.py::TestCommonMark::test_list_items_266", + "tests/test_commonmark.py::TestCommonMark::test_list_items_267", + "tests/test_commonmark.py::TestCommonMark::test_list_items_268", + "tests/test_commonmark.py::TestCommonMark::test_list_items_269", + "tests/test_commonmark.py::TestCommonMark::test_list_items_270", + "tests/test_commonmark.py::TestCommonMark::test_list_items_271", + "tests/test_commonmark.py::TestCommonMark::test_list_items_272", + "tests/test_commonmark.py::TestCommonMark::test_list_items_273", + "tests/test_commonmark.py::TestCommonMark::test_list_items_274", + "tests/test_commonmark.py::TestCommonMark::test_list_items_275", + "tests/test_commonmark.py::TestCommonMark::test_list_items_276", + "tests/test_commonmark.py::TestCommonMark::test_list_items_277", + "tests/test_commonmark.py::TestCommonMark::test_list_items_281", + "tests/test_commonmark.py::TestCommonMark::test_list_items_282", + "tests/test_commonmark.py::TestCommonMark::test_list_items_283", + "tests/test_commonmark.py::TestCommonMark::test_list_items_284", + "tests/test_commonmark.py::TestCommonMark::test_list_items_285", + "tests/test_commonmark.py::TestCommonMark::test_list_items_289", + "tests/test_commonmark.py::TestCommonMark::test_list_items_291", + "tests/test_commonmark.py::TestCommonMark::test_list_items_294", + "tests/test_commonmark.py::TestCommonMark::test_list_items_295", + "tests/test_commonmark.py::TestCommonMark::test_list_items_296", + "tests/test_commonmark.py::TestCommonMark::test_list_items_297", + "tests/test_commonmark.py::TestCommonMark::test_list_items_298", + "tests/test_commonmark.py::TestCommonMark::test_list_items_299", + "tests/test_commonmark.py::TestCommonMark::test_list_items_300", + "tests/test_commonmark.py::TestCommonMark::test_lists_301", + "tests/test_commonmark.py::TestCommonMark::test_lists_302", + "tests/test_commonmark.py::TestCommonMark::test_lists_303", + "tests/test_commonmark.py::TestCommonMark::test_lists_304", + "tests/test_commonmark.py::TestCommonMark::test_lists_305", + "tests/test_commonmark.py::TestCommonMark::test_lists_306", + "tests/test_commonmark.py::TestCommonMark::test_lists_307", + "tests/test_commonmark.py::TestCommonMark::test_lists_308", + "tests/test_commonmark.py::TestCommonMark::test_lists_309", + "tests/test_commonmark.py::TestCommonMark::test_lists_310", + "tests/test_commonmark.py::TestCommonMark::test_lists_311", + "tests/test_commonmark.py::TestCommonMark::test_lists_312", + "tests/test_commonmark.py::TestCommonMark::test_lists_313", + "tests/test_commonmark.py::TestCommonMark::test_lists_314", + "tests/test_commonmark.py::TestCommonMark::test_lists_315", + "tests/test_commonmark.py::TestCommonMark::test_lists_316", + "tests/test_commonmark.py::TestCommonMark::test_lists_317", + "tests/test_commonmark.py::TestCommonMark::test_lists_319", + "tests/test_commonmark.py::TestCommonMark::test_lists_322", + "tests/test_commonmark.py::TestCommonMark::test_lists_323", + "tests/test_commonmark.py::TestCommonMark::test_lists_325", + "tests/test_commonmark.py::TestCommonMark::test_lists_326", + "tests/test_commonmark.py::TestCommonMark::test_paragraphs_219", + "tests/test_commonmark.py::TestCommonMark::test_paragraphs_220", + "tests/test_commonmark.py::TestCommonMark::test_paragraphs_221", + "tests/test_commonmark.py::TestCommonMark::test_paragraphs_222", + "tests/test_commonmark.py::TestCommonMark::test_paragraphs_223", + "tests/test_commonmark.py::TestCommonMark::test_paragraphs_224", + "tests/test_commonmark.py::TestCommonMark::test_paragraphs_225", + "tests/test_commonmark.py::TestCommonMark::test_paragraphs_226", + "tests/test_commonmark.py::TestCommonMark::test_precedence_042", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_612", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_613", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_614", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_615", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_616", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_617", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_618", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_619", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_620", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_621", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_622", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_623", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_624", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_625", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_626", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_627", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_628", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_629", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_630", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_631", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_632", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_080", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_081", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_082", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_083", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_084", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_086", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_087", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_088", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_089", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_090", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_091", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_094", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_095", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_097", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_099", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_102", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_103", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_105", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_106", + "tests/test_commonmark.py::TestCommonMark::test_soft_line_breaks_648", + "tests/test_commonmark.py::TestCommonMark::test_soft_line_breaks_649", + "tests/test_commonmark.py::TestCommonMark::test_tabs_001", + "tests/test_commonmark.py::TestCommonMark::test_tabs_002", + "tests/test_commonmark.py::TestCommonMark::test_tabs_003", + "tests/test_commonmark.py::TestCommonMark::test_tabs_004", + "tests/test_commonmark.py::TestCommonMark::test_tabs_005", + "tests/test_commonmark.py::TestCommonMark::test_tabs_007", + "tests/test_commonmark.py::TestCommonMark::test_tabs_008", + "tests/test_commonmark.py::TestCommonMark::test_tabs_009", + "tests/test_commonmark.py::TestCommonMark::test_tabs_010", + "tests/test_commonmark.py::TestCommonMark::test_tabs_011", + "tests/test_commonmark.py::TestCommonMark::test_textual_content_650", + "tests/test_commonmark.py::TestCommonMark::test_textual_content_651", + "tests/test_commonmark.py::TestCommonMark::test_textual_content_652", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_044", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_045", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_046", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_047", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_048", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_049", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_050", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_051", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_052", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_053", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_054", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_055", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_056", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_057", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_058", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_059", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_060", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_061", + "tests/test_directives.py::TestDirective_rst_admonition::test_admonition_001", + "tests/test_directives.py::TestDirective_rst_admonition::test_admonition_002", + "tests/test_directives.py::TestDirective_rst_admonition::test_admonition_003", + "tests/test_directives.py::TestDirective_rst_admonition::test_admonition_004", + "tests/test_directives.py::TestDirective_rst_toc::test_collapse_toc_001", + "tests/test_directives.py::TestDirective_rst_toc::test_complex_001", + "tests/test_directives.py::TestDirective_rst_toc::test_html_in_heading_001", + "tests/test_directives.py::TestDirective_rst_toc::test_insane_001", + "tests/test_directives.py::TestDirective_rst_toc::test_insane_002", + "tests/test_directives.py::TestDirective_rst_toc::test_invalid_option_001", + "tests/test_directives.py::TestDirective_rst_toc::test_invalid_option_002", + "tests/test_directives.py::TestDirective_rst_toc::test_invalid_option_003", + "tests/test_directives.py::TestDirective_rst_toc::test_link_in_heading_001", + "tests/test_directives.py::TestDirective_rst_toc::test_no_toc_001", + "tests/test_directives.py::TestDirective_rst_toc::test_no_toc_002", + "tests/test_directives.py::TestDirective_rst_toc::test_simple_toc_001", + "tests/test_directives.py::TestDirective_fenced_admonition::test_admonition_001", + "tests/test_directives.py::TestDirective_fenced_admonition::test_admonition_003", + "tests/test_directives.py::TestDirective_fenced_admonition::test_admonition_004", + "tests/test_directives.py::TestDirective_fenced_admonition::test_admonition_005", + "tests/test_directives.py::TestDirective_fenced_admonition::test_admonition_006", + "tests/test_directives.py::TestDirective_fenced_admonition::test_admonition_007", + "tests/test_directives.py::TestDirective_fenced_toc::test_collapse_toc_001", + "tests/test_directives.py::TestDirective_fenced_toc::test_complex_001", + "tests/test_directives.py::TestDirective_fenced_toc::test_html_in_heading_001", + "tests/test_directives.py::TestDirective_fenced_toc::test_insane_001", + "tests/test_directives.py::TestDirective_fenced_toc::test_insane_002", + "tests/test_directives.py::TestDirective_fenced_toc::test_invalid_option_001", + "tests/test_directives.py::TestDirective_fenced_toc::test_invalid_option_002", + "tests/test_directives.py::TestDirective_fenced_toc::test_invalid_option_003", + "tests/test_directives.py::TestDirective_fenced_toc::test_link_in_heading_001", + "tests/test_directives.py::TestDirective_fenced_toc::test_no_toc_001", + "tests/test_directives.py::TestDirective_fenced_toc::test_no_toc_002", + "tests/test_directives.py::TestDirective_fenced_toc::test_simple_toc_001", + "tests/test_directives.py::TestDirective_fenced_image::test_align_options_001", + "tests/test_directives.py::TestDirective_fenced_image::test_align_options_002", + "tests/test_directives.py::TestDirective_fenced_image::test_all_options_001", + "tests/test_directives.py::TestDirective_fenced_image::test_alt_option_001", + "tests/test_directives.py::TestDirective_fenced_image::test_ampersand_in_source_001", + "tests/test_directives.py::TestDirective_fenced_image::test_ampersand_in_target_001", + "tests/test_directives.py::TestDirective_fenced_image::test_no_options_001", + "tests/test_directives.py::TestDirective_fenced_image::test_target_option_001", + "tests/test_directives.py::TestDirective_fenced_image::test_width_and_height_001", + "tests/test_directives.py::TestDirective_fenced_image::test_width_and_height_002", + "tests/test_directives.py::TestDirective_fenced_figure::test_align_options_001", + "tests/test_directives.py::TestDirective_fenced_figure::test_align_options_002", + "tests/test_directives.py::TestDirective_fenced_figure::test_alt_option_001", + "tests/test_directives.py::TestDirective_fenced_figure::test_caption_001", + "tests/test_directives.py::TestDirective_fenced_figure::test_no_options_001", + "tests/test_directives.py::TestDirective_fenced_figure::test_target_option_001", + "tests/test_directives.py::TestDirective_fenced_figure::test_width_and_height_001", + "tests/test_directives.py::TestDirective_fenced_figure::test_width_and_height_002", + "tests/test_directives.py::TestDirective_fenced_figure::test_width_and_height_003", + "tests/test_directives.py::TestCustomizeToc::test_colon_fenced_toc", + "tests/test_directives.py::TestCustomizeToc::test_fenced_toc", + "tests/test_directives.py::TestCustomizeToc::test_rst_toc", + "tests/test_directives.py::TestDirectiveInclude::test_include_missing_source", + "tests/test_hooks.py::TestTocHook::test_complex_toc_001", + "tests/test_hooks.py::TestTocHook::test_customize_heading_id_func", + "tests/test_hooks.py::TestTocHook::test_html_in_heading_001", + "tests/test_hooks.py::TestTocHook::test_insane_toc_001", + "tests/test_hooks.py::TestTocHook::test_insane_toc_002", + "tests/test_hooks.py::TestTocHook::test_link_in_heading_001", + "tests/test_hooks.py::TestTocHook::test_simple_toc_001", + "tests/test_misc.py::TestMiscCases::test_allow_data_protocols", + "tests/test_misc.py::TestMiscCases::test_allow_harmful_protocols", + "tests/test_misc.py::TestMiscCases::test_ast_output", + "tests/test_misc.py::TestMiscCases::test_ast_url", + "tests/test_misc.py::TestMiscCases::test_before_parse_hooks", + "tests/test_misc.py::TestMiscCases::test_emsp", + "tests/test_misc.py::TestMiscCases::test_escape_html", + "tests/test_misc.py::TestMiscCases::test_hard_wrap", + "tests/test_misc.py::TestMiscCases::test_harmful_links", + "tests/test_misc.py::TestMiscCases::test_html_tag_text_following_list", + "tests/test_misc.py::TestMiscCases::test_markdown_func", + "tests/test_misc.py::TestMiscCases::test_none", + "tests/test_misc.py::TestMiscCases::test_ref_link", + "tests/test_misc.py::TestMiscCases::test_use_plugin", + "tests/test_plugins.py::TestPlugin1_url::test_url_plugin_001", + "tests/test_plugins.py::TestPlugin1_url::test_url_plugin_002", + "tests/test_plugins.py::TestPlugin1_url::test_url_plugin_003", + "tests/test_plugins.py::TestPlugin2_url::test_url_plugin_001", + "tests/test_plugins.py::TestPlugin2_url::test_url_plugin_002", + "tests/test_plugins.py::TestPlugin2_url::test_url_plugin_003", + "tests/test_plugins.py::TestPlugin1_strikethrough::test_strikethrough_001", + "tests/test_plugins.py::TestPlugin1_strikethrough::test_strikethrough_002", + "tests/test_plugins.py::TestPlugin1_strikethrough::test_strikethrough_003", + "tests/test_plugins.py::TestPlugin1_strikethrough::test_strikethrough_004", + "tests/test_plugins.py::TestPlugin1_strikethrough::test_strikethrough_005", + "tests/test_plugins.py::TestPlugin1_strikethrough::test_strikethrough_006", + "tests/test_plugins.py::TestPlugin1_strikethrough::test_strikethrough_007", + "tests/test_plugins.py::TestPlugin2_strikethrough::test_strikethrough_001", + "tests/test_plugins.py::TestPlugin2_strikethrough::test_strikethrough_002", + "tests/test_plugins.py::TestPlugin2_strikethrough::test_strikethrough_003", + "tests/test_plugins.py::TestPlugin2_strikethrough::test_strikethrough_004", + "tests/test_plugins.py::TestPlugin2_strikethrough::test_strikethrough_005", + "tests/test_plugins.py::TestPlugin2_strikethrough::test_strikethrough_006", + "tests/test_plugins.py::TestPlugin2_strikethrough::test_strikethrough_007", + "tests/test_plugins.py::TestPlugin1_mark::test_escape_mark_001", + "tests/test_plugins.py::TestPlugin1_mark::test_escape_mark_002", + "tests/test_plugins.py::TestPlugin1_mark::test_mark_001", + "tests/test_plugins.py::TestPlugin1_mark::test_mark_link_001", + "tests/test_plugins.py::TestPlugin1_mark::test_mark_link_002", + "tests/test_plugins.py::TestPlugin1_mark::test_normal_mark_001", + "tests/test_plugins.py::TestPlugin1_mark::test_normal_mark_002", + "tests/test_plugins.py::TestPlugin1_mark::test_normal_mark_003", + "tests/test_plugins.py::TestPlugin1_mark::test_normal_mark_004", + "tests/test_plugins.py::TestPlugin2_mark::test_escape_mark_001", + "tests/test_plugins.py::TestPlugin2_mark::test_escape_mark_002", + "tests/test_plugins.py::TestPlugin2_mark::test_mark_001", + "tests/test_plugins.py::TestPlugin2_mark::test_mark_link_001", + "tests/test_plugins.py::TestPlugin2_mark::test_mark_link_002", + "tests/test_plugins.py::TestPlugin2_mark::test_normal_mark_001", + "tests/test_plugins.py::TestPlugin2_mark::test_normal_mark_002", + "tests/test_plugins.py::TestPlugin2_mark::test_normal_mark_003", + "tests/test_plugins.py::TestPlugin2_mark::test_normal_mark_004", + "tests/test_plugins.py::TestPlugin1_insert::test_escape_insert_001", + "tests/test_plugins.py::TestPlugin1_insert::test_escape_insert_002", + "tests/test_plugins.py::TestPlugin1_insert::test_insert_001", + "tests/test_plugins.py::TestPlugin1_insert::test_insert_link_001", + "tests/test_plugins.py::TestPlugin1_insert::test_insert_link_002", + "tests/test_plugins.py::TestPlugin1_insert::test_normal_insert_001", + "tests/test_plugins.py::TestPlugin1_insert::test_normal_insert_002", + "tests/test_plugins.py::TestPlugin1_insert::test_normal_insert_003", + "tests/test_plugins.py::TestPlugin1_insert::test_normal_insert_004", + "tests/test_plugins.py::TestPlugin2_insert::test_escape_insert_001", + "tests/test_plugins.py::TestPlugin2_insert::test_escape_insert_002", + "tests/test_plugins.py::TestPlugin2_insert::test_insert_001", + "tests/test_plugins.py::TestPlugin2_insert::test_insert_link_001", + "tests/test_plugins.py::TestPlugin2_insert::test_insert_link_002", + "tests/test_plugins.py::TestPlugin2_insert::test_normal_insert_001", + "tests/test_plugins.py::TestPlugin2_insert::test_normal_insert_002", + "tests/test_plugins.py::TestPlugin2_insert::test_normal_insert_003", + "tests/test_plugins.py::TestPlugin2_insert::test_normal_insert_004", + "tests/test_plugins.py::TestPlugin1_superscript::test_superscript_001", + "tests/test_plugins.py::TestPlugin1_superscript::test_superscript_002", + "tests/test_plugins.py::TestPlugin1_superscript::test_superscript_003", + "tests/test_plugins.py::TestPlugin1_superscript::test_superscript_004", + "tests/test_plugins.py::TestPlugin2_superscript::test_superscript_001", + "tests/test_plugins.py::TestPlugin2_superscript::test_superscript_002", + "tests/test_plugins.py::TestPlugin2_superscript::test_superscript_003", + "tests/test_plugins.py::TestPlugin2_superscript::test_superscript_004", + "tests/test_plugins.py::TestPlugin1_subscript::test_subscript_001", + "tests/test_plugins.py::TestPlugin1_subscript::test_subscript_002", + "tests/test_plugins.py::TestPlugin1_subscript::test_subscript_003", + "tests/test_plugins.py::TestPlugin1_subscript::test_subscript_004", + "tests/test_plugins.py::TestPlugin2_subscript::test_subscript_001", + "tests/test_plugins.py::TestPlugin2_subscript::test_subscript_002", + "tests/test_plugins.py::TestPlugin2_subscript::test_subscript_003", + "tests/test_plugins.py::TestPlugin2_subscript::test_subscript_004", + "tests/test_plugins.py::TestPlugin1_task_lists::test_task_lists_001", + "tests/test_plugins.py::TestPlugin1_task_lists::test_task_lists_002", + "tests/test_plugins.py::TestPlugin1_task_lists::test_task_lists_003", + "tests/test_plugins.py::TestPlugin1_task_lists::test_task_lists_004", + "tests/test_plugins.py::TestPlugin1_task_lists::test_task_lists_005", + "tests/test_plugins.py::TestPlugin1_task_lists::test_task_lists_006", + "tests/test_plugins.py::TestPlugin1_task_lists::test_task_lists_007", + "tests/test_plugins.py::TestPlugin2_task_lists::test_task_lists_001", + "tests/test_plugins.py::TestPlugin2_task_lists::test_task_lists_002", + "tests/test_plugins.py::TestPlugin2_task_lists::test_task_lists_003", + "tests/test_plugins.py::TestPlugin2_task_lists::test_task_lists_004", + "tests/test_plugins.py::TestPlugin2_task_lists::test_task_lists_005", + "tests/test_plugins.py::TestPlugin2_task_lists::test_task_lists_006", + "tests/test_plugins.py::TestPlugin2_task_lists::test_task_lists_007", + "tests/test_plugins.py::TestPlugin1_table::test_align_table_001", + "tests/test_plugins.py::TestPlugin1_table::test_align_table_002", + "tests/test_plugins.py::TestPlugin1_table::test_misc_table_001", + "tests/test_plugins.py::TestPlugin1_table::test_misc_table_002", + "tests/test_plugins.py::TestPlugin1_table::test_misc_table_003", + "tests/test_plugins.py::TestPlugin1_table::test_mismatch_length_001", + "tests/test_plugins.py::TestPlugin1_table::test_mismatch_length_002", + "tests/test_plugins.py::TestPlugin1_table::test_mismatch_length_003", + "tests/test_plugins.py::TestPlugin1_table::test_mismatch_length_004", + "tests/test_plugins.py::TestPlugin1_table::test_nptable_001", + "tests/test_plugins.py::TestPlugin1_table::test_table_001", + "tests/test_plugins.py::TestPlugin1_table::test_table_002", + "tests/test_plugins.py::TestPlugin2_table::test_align_table_001", + "tests/test_plugins.py::TestPlugin2_table::test_align_table_002", + "tests/test_plugins.py::TestPlugin2_table::test_misc_table_001", + "tests/test_plugins.py::TestPlugin2_table::test_misc_table_002", + "tests/test_plugins.py::TestPlugin2_table::test_misc_table_003", + "tests/test_plugins.py::TestPlugin2_table::test_mismatch_length_001", + "tests/test_plugins.py::TestPlugin2_table::test_mismatch_length_002", + "tests/test_plugins.py::TestPlugin2_table::test_mismatch_length_003", + "tests/test_plugins.py::TestPlugin2_table::test_mismatch_length_004", + "tests/test_plugins.py::TestPlugin2_table::test_nptable_001", + "tests/test_plugins.py::TestPlugin2_table::test_table_001", + "tests/test_plugins.py::TestPlugin2_table::test_table_002", + "tests/test_plugins.py::TestPlugin1_def_list::test_definition_lists_001", + "tests/test_plugins.py::TestPlugin1_def_list::test_definition_lists_002", + "tests/test_plugins.py::TestPlugin1_def_list::test_definition_lists_003", + "tests/test_plugins.py::TestPlugin1_def_list::test_definition_lists_004", + "tests/test_plugins.py::TestPlugin1_def_list::test_definition_lists_005", + "tests/test_plugins.py::TestPlugin1_def_list::test_definition_lists_006", + "tests/test_plugins.py::TestPlugin1_def_list::test_definition_with_multiple_lines_001", + "tests/test_plugins.py::TestPlugin1_def_list::test_definition_with_multiple_lines_002", + "tests/test_plugins.py::TestPlugin1_def_list::test_definition_with_multiple_lines_003", + "tests/test_plugins.py::TestPlugin1_def_list::test_definition_with_multiple_lines_004", + "tests/test_plugins.py::TestPlugin1_def_list::test_definition_with_multiple_lines_005", + "tests/test_plugins.py::TestPlugin2_def_list::test_definition_lists_001", + "tests/test_plugins.py::TestPlugin2_def_list::test_definition_lists_002", + "tests/test_plugins.py::TestPlugin2_def_list::test_definition_lists_003", + "tests/test_plugins.py::TestPlugin2_def_list::test_definition_lists_004", + "tests/test_plugins.py::TestPlugin2_def_list::test_definition_lists_005", + "tests/test_plugins.py::TestPlugin2_def_list::test_definition_lists_006", + "tests/test_plugins.py::TestPlugin2_def_list::test_definition_with_multiple_lines_001", + "tests/test_plugins.py::TestPlugin2_def_list::test_definition_with_multiple_lines_002", + "tests/test_plugins.py::TestPlugin2_def_list::test_definition_with_multiple_lines_003", + "tests/test_plugins.py::TestPlugin2_def_list::test_definition_with_multiple_lines_004", + "tests/test_plugins.py::TestPlugin2_def_list::test_definition_with_multiple_lines_005", + "tests/test_plugins.py::TestPlugin1_footnotes::test_footnotes_001", + "tests/test_plugins.py::TestPlugin1_footnotes::test_footnotes_002", + "tests/test_plugins.py::TestPlugin1_footnotes::test_footnotes_003", + "tests/test_plugins.py::TestPlugin2_footnotes::test_footnotes_001", + "tests/test_plugins.py::TestPlugin2_footnotes::test_footnotes_002", + "tests/test_plugins.py::TestPlugin2_footnotes::test_footnotes_003", + "tests/test_plugins.py::TestPlugin1_abbr::test_abbreviation_001", + "tests/test_plugins.py::TestPlugin1_abbr::test_abbreviation_002", + "tests/test_plugins.py::TestPlugin1_abbr::test_abbreviation_003", + "tests/test_plugins.py::TestPlugin1_abbr::test_abbreviation_004", + "tests/test_plugins.py::TestPlugin1_abbr::test_abbreviation_005", + "tests/test_plugins.py::TestPlugin1_abbr::test_abbreviation_006", + "tests/test_plugins.py::TestPlugin1_abbr::test_abbreviation_007", + "tests/test_plugins.py::TestPlugin1_abbr::test_abbreviation_008", + "tests/test_plugins.py::TestPlugin1_abbr::test_abbreviation_009", + "tests/test_plugins.py::TestPlugin1_abbr::test_abbreviation_010", + "tests/test_plugins.py::TestPlugin2_abbr::test_abbreviation_001", + "tests/test_plugins.py::TestPlugin2_abbr::test_abbreviation_002", + "tests/test_plugins.py::TestPlugin2_abbr::test_abbreviation_003", + "tests/test_plugins.py::TestPlugin2_abbr::test_abbreviation_004", + "tests/test_plugins.py::TestPlugin2_abbr::test_abbreviation_005", + "tests/test_plugins.py::TestPlugin2_abbr::test_abbreviation_006", + "tests/test_plugins.py::TestPlugin2_abbr::test_abbreviation_007", + "tests/test_plugins.py::TestPlugin2_abbr::test_abbreviation_008", + "tests/test_plugins.py::TestPlugin2_abbr::test_abbreviation_009", + "tests/test_plugins.py::TestPlugin2_abbr::test_abbreviation_010", + "tests/test_plugins.py::TestPlugin1_math::test_block_math_001", + "tests/test_plugins.py::TestPlugin1_math::test_block_math_002", + "tests/test_plugins.py::TestPlugin1_math::test_block_math_003", + "tests/test_plugins.py::TestPlugin1_math::test_block_math_004", + "tests/test_plugins.py::TestPlugin1_math::test_inline_math_001", + "tests/test_plugins.py::TestPlugin2_math::test_block_math_001", + "tests/test_plugins.py::TestPlugin2_math::test_block_math_002", + "tests/test_plugins.py::TestPlugin2_math::test_block_math_003", + "tests/test_plugins.py::TestPlugin2_math::test_block_math_004", + "tests/test_plugins.py::TestPlugin2_math::test_inline_math_001", + "tests/test_plugins.py::TestPlugin1_ruby::test_ruby_splits_001", + "tests/test_plugins.py::TestPlugin1_ruby::test_ruby_splits_002", + "tests/test_plugins.py::TestPlugin1_ruby::test_ruby_with_link_001", + "tests/test_plugins.py::TestPlugin1_ruby::test_ruby_with_link_002", + "tests/test_plugins.py::TestPlugin1_ruby::test_ruby_with_link_003", + "tests/test_plugins.py::TestPlugin1_ruby::test_ruby_without_link_001", + "tests/test_plugins.py::TestPlugin1_ruby::test_ruby_without_link_002", + "tests/test_plugins.py::TestPlugin1_ruby::test_ruby_without_link_003", + "tests/test_plugins.py::TestPlugin1_ruby::test_ruby_without_link_004", + "tests/test_plugins.py::TestPlugin2_ruby::test_ruby_splits_001", + "tests/test_plugins.py::TestPlugin2_ruby::test_ruby_splits_002", + "tests/test_plugins.py::TestPlugin2_ruby::test_ruby_with_link_001", + "tests/test_plugins.py::TestPlugin2_ruby::test_ruby_with_link_002", + "tests/test_plugins.py::TestPlugin2_ruby::test_ruby_with_link_003", + "tests/test_plugins.py::TestPlugin2_ruby::test_ruby_without_link_001", + "tests/test_plugins.py::TestPlugin2_ruby::test_ruby_without_link_002", + "tests/test_plugins.py::TestPlugin2_ruby::test_ruby_without_link_003", + "tests/test_plugins.py::TestPlugin2_ruby::test_ruby_without_link_004", + "tests/test_plugins.py::TestPlugin1_spoiler::test_block_spoiler_001", + "tests/test_plugins.py::TestPlugin1_spoiler::test_block_spoiler_002", + "tests/test_plugins.py::TestPlugin1_spoiler::test_block_spoiler_003", + "tests/test_plugins.py::TestPlugin1_spoiler::test_block_spoiler_004", + "tests/test_plugins.py::TestPlugin1_spoiler::test_block_spoiler_005", + "tests/test_plugins.py::TestPlugin1_spoiler::test_inline_spoiler_001", + "tests/test_plugins.py::TestPlugin1_spoiler::test_inline_spoiler_002", + "tests/test_plugins.py::TestPlugin1_spoiler::test_inline_spoiler_003", + "tests/test_plugins.py::TestPlugin2_spoiler::test_block_spoiler_001", + "tests/test_plugins.py::TestPlugin2_spoiler::test_block_spoiler_002", + "tests/test_plugins.py::TestPlugin2_spoiler::test_block_spoiler_003", + "tests/test_plugins.py::TestPlugin2_spoiler::test_block_spoiler_004", + "tests/test_plugins.py::TestPlugin2_spoiler::test_block_spoiler_005", + "tests/test_plugins.py::TestPlugin2_spoiler::test_inline_spoiler_001", + "tests/test_plugins.py::TestPlugin2_spoiler::test_inline_spoiler_002", + "tests/test_plugins.py::TestPlugin2_spoiler::test_inline_spoiler_003", + "tests/test_plugins.py::TestExtraPlugins::test_math_in_list", + "tests/test_plugins.py::TestExtraPlugins::test_table_in_list", + "tests/test_renderers.py::TestRendererRst::test_code_001", + "tests/test_renderers.py::TestRendererRst::test_heading_001", + "tests/test_renderers.py::TestRendererRst::test_html_001", + "tests/test_renderers.py::TestRendererRst::test_images_001", + "tests/test_renderers.py::TestRendererRst::test_images_002", + "tests/test_renderers.py::TestRendererRst::test_images_003", + "tests/test_renderers.py::TestRendererRst::test_inline_001", + "tests/test_renderers.py::TestRendererRst::test_inline_002", + "tests/test_renderers.py::TestRendererRst::test_line_break_001", + "tests/test_renderers.py::TestRendererRst::test_links_001", + "tests/test_renderers.py::TestRendererRst::test_list_001", + "tests/test_renderers.py::TestRendererRst::test_list_002", + "tests/test_renderers.py::TestRendererRst::test_list_003", + "tests/test_renderers.py::TestRendererRst::test_list_004", + "tests/test_renderers.py::TestRendererRst::test_list_005", + "tests/test_renderers.py::TestRendererRst::test_thematic_break_001", + "tests/test_renderers.py::TestRendererMarkdown::test_code_001", + "tests/test_renderers.py::TestRendererMarkdown::test_code_003", + "tests/test_renderers.py::TestRendererMarkdown::test_code_004", + "tests/test_renderers.py::TestRendererMarkdown::test_code_005", + "tests/test_renderers.py::TestRendererMarkdown::test_heading_001", + "tests/test_renderers.py::TestRendererMarkdown::test_html_001", + "tests/test_renderers.py::TestRendererMarkdown::test_images_001", + "tests/test_renderers.py::TestRendererMarkdown::test_inline_001", + "tests/test_renderers.py::TestRendererMarkdown::test_linebreak_001", + "tests/test_renderers.py::TestRendererMarkdown::test_links_001", + "tests/test_renderers.py::TestRendererMarkdown::test_links_002", + "tests/test_renderers.py::TestRendererMarkdown::test_links_003", + "tests/test_renderers.py::TestRendererMarkdown::test_list_001", + "tests/test_renderers.py::TestRendererMarkdown::test_list_002", + "tests/test_renderers.py::TestRendererMarkdown::test_list_003", + "tests/test_renderers.py::TestRendererMarkdown::test_list_004", + "tests/test_renderers.py::TestRendererMarkdown::test_list_005", + "tests/test_renderers.py::TestRendererMarkdown::test_list_006", + "tests/test_renderers.py::TestRendererMarkdown::test_thematic_break_001", + "tests/test_syntax.py::TestSyntax::test_emphasis_001", + "tests/test_syntax.py::TestSyntax::test_image_001", + "tests/test_syntax.py::TestSyntax::test_link_001", + "tests/test_syntax.py::TestSyntax::test_link_002", + "tests/test_syntax.py::TestSyntax::test_link_003", + "tests/test_syntax.py::TestSyntax::test_links_001", + "tests/test_syntax.py::TestSyntax::test_links_002", + "tests/test_syntax.py::TestSyntax::test_max_depth_002", + "tests/test_syntax.py::TestSyntax::test_non_aggressive_emphasis_001", + "tests/test_syntax.py::TestSyntax::test_non_aggressive_emphasis_002", + "tests/test_syntax.py::TestSyntax::test_non_aggressive_emphasis_003", + "tests/test_syntax.py::TestSyntax::test_setext_headings_002" + ], + "all_git_blobs_modes_verified": true, + "cloud_launch_ready": false, + "commits": { + "bug": "8b73fda73cce7bd6e10265ebedcd3d33241bc84b", + "healthy": "62750c95db25a8fb93dda09242f64e07508d9231", + "learner": "69def72ff04a96ecf6a3fff3f0d0d6d9493d0016" + }, + "existing_squirrel_snapshot_reused": false, + "full_transfer_allowlist": [ + "/testbed/.editorconfig", + "/testbed/.github/FUNDING.yml", + "/testbed/.gitignore", + "/testbed/.readthedocs.yaml", + "/testbed/BACKERS.md", + "/testbed/LICENSE", + "/testbed/MANIFEST.in", + "/testbed/Makefile", + "/testbed/README.md", + "/testbed/README.rst", + "/testbed/benchmark/bench.py", + "/testbed/benchmark/cases/atx.txt", + "/testbed/benchmark/cases/auto_links.txt", + "/testbed/benchmark/cases/blockcode.txt", + "/testbed/benchmark/cases/blockhtml.txt", + "/testbed/benchmark/cases/blockquote.txt", + "/testbed/benchmark/cases/emphasis.txt", + "/testbed/benchmark/cases/fenced.txt", + "/testbed/benchmark/cases/insane_ol.txt", + "/testbed/benchmark/cases/insane_ul.txt", + "/testbed/benchmark/cases/normal_ol.txt", + "/testbed/benchmark/cases/normal_ul.txt", + "/testbed/benchmark/cases/paragraph.txt", + "/testbed/benchmark/cases/ref_links.txt", + "/testbed/benchmark/cases/setext.txt", + "/testbed/benchmark/cases/std_links.txt", + "/testbed/docs/Makefile", + "/testbed/docs/_static/dark-icon.svg", + "/testbed/docs/_static/light-icon.svg", + "/testbed/docs/_static/logo-black.svg", + "/testbed/docs/_static/logo-white.svg", + "/testbed/docs/_templates/partials/globaltoc-above.html", + "/testbed/docs/advanced.rst", + "/testbed/docs/api.rst", + "/testbed/docs/changes.rst", + "/testbed/docs/cli.rst", + "/testbed/docs/community.rst", + "/testbed/docs/conf.py", + "/testbed/docs/directives.rst", + "/testbed/docs/guide.rst", + "/testbed/docs/index.rst", + "/testbed/docs/plugins.rst", + "/testbed/docs/renderers.rst", + "/testbed/docs/requirements.txt", + "/testbed/docs/upgrade.rst", + "/testbed/pyproject.toml", + "/testbed/serve-doc.py", + "/testbed/setup.py", + "/testbed/src/mistune/__init__.py", + "/testbed/src/mistune/__main__.py", + "/testbed/src/mistune/block_parser.py", + "/testbed/src/mistune/core.py", + "/testbed/src/mistune/directives/__init__.py", + "/testbed/src/mistune/directives/_base.py", + "/testbed/src/mistune/directives/_fenced.py", + "/testbed/src/mistune/directives/_rst.py", + "/testbed/src/mistune/directives/admonition.py", + "/testbed/src/mistune/directives/image.py", + "/testbed/src/mistune/directives/include.py", + "/testbed/src/mistune/directives/toc.py", + "/testbed/src/mistune/helpers.py", + "/testbed/src/mistune/inline_parser.py", + "/testbed/src/mistune/list_parser.py", + "/testbed/src/mistune/markdown.py", + "/testbed/src/mistune/plugins/__init__.py", + "/testbed/src/mistune/plugins/abbr.py", + "/testbed/src/mistune/plugins/def_list.py", + "/testbed/src/mistune/plugins/footnotes.py", + "/testbed/src/mistune/plugins/formatting.py", + "/testbed/src/mistune/plugins/math.py", + "/testbed/src/mistune/plugins/ruby.py", + "/testbed/src/mistune/plugins/speedup.py", + "/testbed/src/mistune/plugins/spoiler.py", + "/testbed/src/mistune/plugins/table.py", + "/testbed/src/mistune/plugins/task_lists.py", + "/testbed/src/mistune/plugins/url.py", + "/testbed/src/mistune/py.typed", + "/testbed/src/mistune/renderers/__init__.py", + "/testbed/src/mistune/renderers/_list.py", + "/testbed/src/mistune/renderers/html.py", + "/testbed/src/mistune/renderers/markdown.py", + "/testbed/src/mistune/renderers/rst.py", + "/testbed/src/mistune/toc.py", + "/testbed/src/mistune/util.py", + "/testbed/tests/__init__.py", + "/testbed/tests/fixtures/__init__.py", + "/testbed/tests/fixtures/abbr.txt", + "/testbed/tests/fixtures/commonmark.json", + "/testbed/tests/fixtures/def_list.txt", + "/testbed/tests/fixtures/diff-commonmark.txt", + "/testbed/tests/fixtures/fenced_admonition.txt", + "/testbed/tests/fixtures/fenced_figure.txt", + "/testbed/tests/fixtures/fenced_image.txt", + "/testbed/tests/fixtures/fenced_toc.txt", + "/testbed/tests/fixtures/fix-commonmark.txt", + "/testbed/tests/fixtures/footnotes.txt", + "/testbed/tests/fixtures/hook_toc.txt", + "/testbed/tests/fixtures/include/hello.md", + "/testbed/tests/fixtures/include/hello.txt", + "/testbed/tests/fixtures/include/text.html", + "/testbed/tests/fixtures/include/text.md", + "/testbed/tests/fixtures/insert.txt", + "/testbed/tests/fixtures/mark.txt", + "/testbed/tests/fixtures/math.txt", + "/testbed/tests/fixtures/renderer_markdown.txt", + "/testbed/tests/fixtures/renderer_rst.txt", + "/testbed/tests/fixtures/rst_admonition.txt", + "/testbed/tests/fixtures/rst_toc.txt", + "/testbed/tests/fixtures/ruby.txt", + "/testbed/tests/fixtures/spoiler.txt", + "/testbed/tests/fixtures/strikethrough.txt", + "/testbed/tests/fixtures/subscript.txt", + "/testbed/tests/fixtures/superscript.txt", + "/testbed/tests/fixtures/table.txt", + "/testbed/tests/fixtures/task_lists.txt", + "/testbed/tests/fixtures/url.txt", + "/testbed/tests/test_hooks.py", + "/testbed/tests/test_misc.py" + ], + "healthy_stage_meaning": "Direct parent of the mutation; no source or test execution has been performed", + "mutation_matches_dataset_and_git_blobs": true, + "official_profile": { + "eval_sets": [], + "profile_class": "MistuneBf54ef67", + "profile_lines": [ + 570, + 573 + ], + "profile_source_commit": "9b74ac08118a85c39c356802f7961893af73e07f", + "profile_source_path": "swesmith/profiles/python.py", + "profile_source_sha256": "eadf29551ca2e706950d3f2311b47a3d08c2ccee3c8dd217fa299014a08e4286", + "upstream_commit": "bf54ef67390e02a5cdee7495d4386d7770c1902b", + "upstream_repo": "lepture/mistune" + }, + "original_source_commit": "bf54ef67390e02a5cdee7495d4386d7770c1902b", + "private_test_paths": [ + "tests/test_commonmark.py", + "tests/test_directives.py", + "tests/test_plugins.py", + "tests/test_renderers.py", + "tests/test_syntax.py" + ], + "private_tests_unchanged": true, + "profile_mapping_basis": "Explicit upstream repo and full commit fields parsed from pinned official Python profile AST, not basename inference", + "qwen_calibrated": false, + "runtime_qualified": false, + "source_paths": [ + "src/mistune/block_parser.py" + ], + "source_repo": "swesmith/lepture__mistune.bf54ef67", + "source_stages_bytes": 1354780, + "task_id": "lepture__mistune.bf54ef67.combine_file__0adn7wof", + "transfer_limitation": "Existing regular files only; new arbitrary file additions need a qualified patch adapter", + "upstream_repo": "lepture/mistune" + }, + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:lepture__mistune.bf54ef67.combine_file__0adn7wof", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "62750c95db25a8fb93dda09242f64e07508d9231", + "instruction_sha256": "5d7dd0d57c4f836f666ecd266d4cd92c4acbe268f44dc0ea042007c11b8930ad", + "is_fork": true, + "learner_path": "tasks/87038867c5ba8248e9db56d2/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "bf54ef67390e02a5cdee7495d4386d7770c1902b", + "actual_upstream_url": "https://raw.githubusercontent.com/lepture/mistune/bf54ef67390e02a5cdee7495d4386d7770c1902b/LICENSE", + "reviewed": true, + "sha256": "539013fd8e19f744f8bf0e27a532bbff54cd689ecef7a800f56ae5dc824be870", + "spdx": "BSD-3-Clause", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/lepture__mistune.bf54ef67/69def72ff04a96ecf6a3fff3f0d0d6d9493d0016/LICENSE" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "bf54ef67390e02a5cdee7495d4386d7770c1902b", + "patch_sha256": "c3bd306acfc12ff1dc8ba54b47bff7d8ada4d516fa24a2e96810cb3390dd14c0", + "provenance_path": "tasks/87038867c5ba8248e9db56d2/source-proof.json", + "repository_lineage": [ + "swesmith/lepture__mistune.bf54ef67", + "lepture/mistune" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "69def72ff04a96ecf6a3fff3f0d0d6d9493d0016", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "8b73fda73cce7bd6e10265ebedcd3d33241bc84b", + "source_kind": "mutation", + "source_repo": "swesmith/lepture__mistune.bf54ef67", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "lepture__mistune.bf54ef67.combine_file__0adn7wof", + "task_sha256": "3bc63ae763a6e5515a18f6e6abaa5bb4d622b9db8591e114736fee6851e221d5", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "lepture/mistune", + "usage": "quarantine_only" + }, + "task_kind": "original-source-mutation" +} diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/provenance.json b/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/provenance.json new file mode 100644 index 0000000000000000000000000000000000000000..a6e1c80533862642cecc2fb72c11dd7c0572e6a7 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/provenance.json @@ -0,0 +1,88 @@ +{ + "generated_reference": false, + "healthy_reference_delta_sha256": "68e79dd3fb65fa601d02627bfa3c8d02ef87d4db3ef5a6aae7791c97f31ed85f", + "native_pytest_ids_preserved": true, + "original_source_code_license": { + "actual_upstream_commit": "bf54ef67390e02a5cdee7495d4386d7770c1902b", + "actual_upstream_url": "https://raw.githubusercontent.com/lepture/mistune/bf54ef67390e02a5cdee7495d4386d7770c1902b/LICENSE", + "reviewed": true, + "sha256": "539013fd8e19f744f8bf0e27a532bbff54cd689ecef7a800f56ae5dc824be870", + "spdx": "BSD-3-Clause", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/lepture__mistune.bf54ef67/69def72ff04a96ecf6a3fff3f0d0d6d9493d0016/LICENSE" + }, + "provided_reference": true, + "qwen_calibrated": false, + "runtime_qualified": false, + "source_completion_sha256": "78acb37f4cf2a52d738613b6cbfbf87584021fc4a5458b9ba85f38402fabe22a", + "source_index_sha256": "e856874b9410fce9f3bfea52c8c482e84b3e43942d87517f8b55f0034bd40f6f", + "source_proof_sha256": "3e19d4d5b9451b17cfeb5014c68f77204a67f86ccd0fade610a7d38a3b64ab35", + "source_record": { + "anti_training_canary": false, + "anti_training_reviewed": true, + "candidate_id": "swesmith-py:lepture__mistune.bf54ef67.combine_file__0adn7wof", + "cloud_launch_ready": false, + "eligibility": { + "reasons": [], + "semantic_nonoverlap_established": false, + "status": "eligible_for_controls", + "training_admissible": false, + "warnings": [] + }, + "healthy_mirror_commit": "62750c95db25a8fb93dda09242f64e07508d9231", + "instruction_sha256": "5d7dd0d57c4f836f666ecd266d4cd92c4acbe268f44dc0ea042007c11b8930ad", + "is_fork": true, + "learner_path": "tasks/87038867c5ba8248e9db56d2/learner", + "license_evidence": { + "source_code": { + "actual_upstream_commit": "bf54ef67390e02a5cdee7495d4386d7770c1902b", + "actual_upstream_url": "https://raw.githubusercontent.com/lepture/mistune/bf54ef67390e02a5cdee7495d4386d7770c1902b/LICENSE", + "reviewed": true, + "sha256": "539013fd8e19f744f8bf0e27a532bbff54cd689ecef7a800f56ae5dc824be870", + "spdx": "BSD-3-Clause", + "training_allowed": true, + "url": "https://raw.githubusercontent.com/swesmith/lepture__mistune.bf54ef67/69def72ff04a96ecf6a3fff3f0d0d6d9493d0016/LICENSE" + }, + "task_bundle": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + } + }, + "original_source_commit": "bf54ef67390e02a5cdee7495d4386d7770c1902b", + "patch_sha256": "c3bd306acfc12ff1dc8ba54b47bff7d8ada4d516fa24a2e96810cb3390dd14c0", + "provenance_path": "tasks/87038867c5ba8248e9db56d2/source-proof.json", + "repository_lineage": [ + "swesmith/lepture__mistune.bf54ef67", + "lepture/mistune" + ], + "rfc008_complete": false, + "runtime_qualified": false, + "semantic_nonoverlap_established": false, + "source_commit": "69def72ff04a96ecf6a3fff3f0d0d6d9493d0016", + "source_dataset": "SWE-bench/SWE-smith-py", + "source_head_commit": "8b73fda73cce7bd6e10265ebedcd3d33241bc84b", + "source_kind": "mutation", + "source_repo": "swesmith/lepture__mistune.bf54ef67", + "source_revision": "77cab9055d42ab4a5c25c89a8f937096db13558e", + "source_split": "train", + "target_model_calibrated": false, + "task_id": "lepture__mistune.bf54ef67.combine_file__0adn7wof", + "task_sha256": "3bc63ae763a6e5515a18f6e6abaa5bb4d622b9db8591e114736fee6851e221d5", + "training_admissible": false, + "upstream_identity_reviewed": true, + "upstream_repo": "lepture/mistune", + "usage": "quarantine_only" + }, + "task_bundle_license": { + "reviewed": true, + "sha256": "18afda407941c9d3c65ff530bedd3bc93f3a13d9504ee5728e959fb43ffce808", + "spdx": "MIT", + "training_allowed": true, + "url": "https://huggingface.co/datasets/SWE-bench/SWE-smith-py/raw/77cab9055d42ab4a5c25c89a8f937096db13558e/README.md" + }, + "training_admissible": false, + "trusted_tests_sha256": "cb345067f46bf3d3e7a60b2963e26cee25fe8aae6cd4a620d05e02f799d96fca" +} diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/provided-gold.diff b/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/provided-gold.diff new file mode 100644 index 0000000000000000000000000000000000000000..8ace96ed93652845937b917d8cc165848dee35bb --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/provided-gold.diff @@ -0,0 +1,120 @@ +diff --git a/src/mistune/block_parser.py b/src/mistune/block_parser.py +index 2e32bff62309b67456810f83b8d817ccffea1f4b..8e43bb6960bb01a018fb5474c0b8fc737f477f2e 100644 +--- a/src/mistune/block_parser.py ++++ b/src/mistune/block_parser.py +@@ -166,11 +166,11 @@ + + m2 = _end.search(state.src, cursor_start) + if m2: ++ code = state.src[cursor_start:m2.start()] ++ end_pos = m2.end() ++ else: + code = state.src[cursor_start:] + end_pos = state.cursor_max +- else: +- code = state.src[cursor_start:m2.start()] +- end_pos = m2.end() + + if spaces and code: + _trim_pattern = re.compile('^ {0,' + str(len(spaces)) + '}', re.M) +@@ -183,6 +183,7 @@ + + state.append_token(token) + return end_pos ++ + def parse_atx_heading(self, m: Match[str], state: BlockState) -> int: + """Parse token for ATX heading. An ATX heading is started with 1 to 6 + symbol of ``#``.""" +@@ -204,28 +205,20 @@ + H1 title + ======== + """ +- # Check if there's a paragraph before the underline +- if not state.tokens or state.tokens[-1]['type'] != 'paragraph': +- return None +- +- # Get the last paragraph as the heading text +- last_token = state.tokens.pop() +- text = last_token['text'] +- +- # Determine heading level based on the underline character +- marker = m.group('setext_1') +- level = 1 if marker == '=' else 2 +- +- # Create heading token +- token = { +- 'type': 'heading', +- 'text': text, +- 'attrs': {'level': level}, +- 'style': 'setext' +- } +- state.append_token(token) +- +- return m.end() + 1 ++ last_token = state.last_token() ++ if last_token and last_token['type'] == 'paragraph': ++ level = 1 if m.group('setext_1') == '=' else 2 ++ last_token['type'] = 'heading' ++ last_token['style'] = 'setext' ++ last_token['attrs'] = {'level': level} ++ return m.end() + 1 ++ ++ sc = self.compile_sc(['thematic_break', 'list']) ++ m2 = sc.match(state.src, state.cursor) ++ if m2: ++ return self.parse_method(m2, state) ++ return None ++ + def parse_ref_link(self, m: Match[str], state: BlockState) -> Optional[int]: + """Parse link references and save the link information into ``state.env``. + +@@ -364,7 +357,7 @@ + # treated as 4 spaces + return expand_tab(text), end_pos + +- def parse_block_quote(self, m: Match[str], state: BlockState) ->int: ++ def parse_block_quote(self, m: Match[str], state: BlockState) -> int: + """Parse token for block quote. Here is an example of the syntax: + + .. code-block:: markdown +@@ -373,27 +366,22 @@ + > with right arrows + """ + text, end_pos = self.extract_block_quote(m, state) +- if not text.strip(): +- token = {'type': 'block_quote', 'children': []} +- state.append_token(token) +- return state.cursor +- +- # create a new parser instance to parse the block quote content +- if state.nested_level < self.max_nested_level: +- new_state = state.child_state(text) +- new_state.nested_level = state.nested_level + 1 +- self.parse(new_state, self.block_quote_rules) +- children = new_state.tokens ++ # scan children state ++ child = state.child_state(text) ++ if state.depth() >= self.max_nested_level - 1: ++ rules = list(self.block_quote_rules) ++ rules.remove('block_quote') + else: +- # if we've reached the maximum nesting level, treat as text +- children = [{'type': 'paragraph', 'text': text.strip()}] +- +- token = {'type': 'block_quote', 'children': children} ++ rules = self.block_quote_rules ++ ++ self.parse(child, rules) ++ token = {'type': 'block_quote', 'children': child.tokens} ++ if end_pos: ++ state.prepend_token(token) ++ return end_pos + state.append_token(token) +- +- if end_pos: +- return end_pos + return state.cursor ++ + def parse_list(self, m: Match[str], state: BlockState) -> int: + """Parse tokens for ordered and unordered list.""" + return parse_list(self, m, state) diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/solution/solve.sh b/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/solution/solve.sh new file mode 100644 index 0000000000000000000000000000000000000000..b97fa312681d6b8bf14b49a686476d4081a42a61 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/solution/solve.sh @@ -0,0 +1,126 @@ +#!/bin/bash +set -Eeuo pipefail +cd /testbed/repo +cat > /tmp/openenv-reference.diff <<'OPENENV_REFERENCE' +diff --git a/src/mistune/block_parser.py b/src/mistune/block_parser.py +index 2e32bff62309b67456810f83b8d817ccffea1f4b..8e43bb6960bb01a018fb5474c0b8fc737f477f2e 100644 +--- a/src/mistune/block_parser.py ++++ b/src/mistune/block_parser.py +@@ -166,11 +166,11 @@ + + m2 = _end.search(state.src, cursor_start) + if m2: ++ code = state.src[cursor_start:m2.start()] ++ end_pos = m2.end() ++ else: + code = state.src[cursor_start:] + end_pos = state.cursor_max +- else: +- code = state.src[cursor_start:m2.start()] +- end_pos = m2.end() + + if spaces and code: + _trim_pattern = re.compile('^ {0,' + str(len(spaces)) + '}', re.M) +@@ -183,6 +183,7 @@ + + state.append_token(token) + return end_pos ++ + def parse_atx_heading(self, m: Match[str], state: BlockState) -> int: + """Parse token for ATX heading. An ATX heading is started with 1 to 6 + symbol of ``#``.""" +@@ -204,28 +205,20 @@ + H1 title + ======== + """ +- # Check if there's a paragraph before the underline +- if not state.tokens or state.tokens[-1]['type'] != 'paragraph': +- return None +- +- # Get the last paragraph as the heading text +- last_token = state.tokens.pop() +- text = last_token['text'] +- +- # Determine heading level based on the underline character +- marker = m.group('setext_1') +- level = 1 if marker == '=' else 2 +- +- # Create heading token +- token = { +- 'type': 'heading', +- 'text': text, +- 'attrs': {'level': level}, +- 'style': 'setext' +- } +- state.append_token(token) +- +- return m.end() + 1 ++ last_token = state.last_token() ++ if last_token and last_token['type'] == 'paragraph': ++ level = 1 if m.group('setext_1') == '=' else 2 ++ last_token['type'] = 'heading' ++ last_token['style'] = 'setext' ++ last_token['attrs'] = {'level': level} ++ return m.end() + 1 ++ ++ sc = self.compile_sc(['thematic_break', 'list']) ++ m2 = sc.match(state.src, state.cursor) ++ if m2: ++ return self.parse_method(m2, state) ++ return None ++ + def parse_ref_link(self, m: Match[str], state: BlockState) -> Optional[int]: + """Parse link references and save the link information into ``state.env``. + +@@ -364,7 +357,7 @@ + # treated as 4 spaces + return expand_tab(text), end_pos + +- def parse_block_quote(self, m: Match[str], state: BlockState) ->int: ++ def parse_block_quote(self, m: Match[str], state: BlockState) -> int: + """Parse token for block quote. Here is an example of the syntax: + + .. code-block:: markdown +@@ -373,27 +366,22 @@ + > with right arrows + """ + text, end_pos = self.extract_block_quote(m, state) +- if not text.strip(): +- token = {'type': 'block_quote', 'children': []} +- state.append_token(token) +- return state.cursor +- +- # create a new parser instance to parse the block quote content +- if state.nested_level < self.max_nested_level: +- new_state = state.child_state(text) +- new_state.nested_level = state.nested_level + 1 +- self.parse(new_state, self.block_quote_rules) +- children = new_state.tokens ++ # scan children state ++ child = state.child_state(text) ++ if state.depth() >= self.max_nested_level - 1: ++ rules = list(self.block_quote_rules) ++ rules.remove('block_quote') + else: +- # if we've reached the maximum nesting level, treat as text +- children = [{'type': 'paragraph', 'text': text.strip()}] +- +- token = {'type': 'block_quote', 'children': children} ++ rules = self.block_quote_rules ++ ++ self.parse(child, rules) ++ token = {'type': 'block_quote', 'children': child.tokens} ++ if end_pos: ++ state.prepend_token(token) ++ return end_pos + state.append_token(token) +- +- if end_pos: +- return end_pos + return state.cursor ++ + def parse_list(self, m: Match[str], state: BlockState) -> int: + """Parse tokens for ordered and unordered list.""" + return parse_list(self, m, state) +OPENENV_REFERENCE +/usr/bin/git -c core.hooksPath=/dev/null -c core.fsmonitor=false apply --whitespace=nowarn /tmp/openenv-reference.diff diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/task.toml b/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/task.toml new file mode 100644 index 0000000000000000000000000000000000000000..b67b6fe18fdc08c3b4d7ac24ba7e240302625439 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/task.toml @@ -0,0 +1,24 @@ +version = "1.0" + +[agent] +timeout_sec = 1800.0 + +[verifier] +timeout_sec = 900.0 + +[environment] +docker_image = "ghcr.io/younesbelkada/scale800@sha256:db8fad2533bc8754d8d66825fce83b36fb80e2b9ca4c6dd27ccc9a0c1872e2c1" +build_timeout_sec = 600.0 +cpus = 2 +memory_mb = 8192 +storage_mb = 16384 + +[metadata] +author_name = "SWE-smith source adapter" +category = "bugfix" +tags = ["swe", "python", "mutation-repair"] + +[environment.env] +# The image's PATH with the testbed env first: the project and pytest are installed there, and the agent's +# non-interactive shells never run `conda activate` +PATH = "/opt/miniconda3/envs/testbed/bin:/opt/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/tests/check_pytest.py b/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/tests/check_pytest.py new file mode 100644 index 0000000000000000000000000000000000000000..7abfdc5972f57ca7f0cecbbeeb373414670f780e --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/tests/check_pytest.py @@ -0,0 +1,177 @@ +"""Preserve confirmed requested assertion failures; keep positive checks strict.""" + +import argparse +import hashlib +import json +import re +import xml.etree.ElementTree as ET +from pathlib import Path + +GROUPS = ("pass-to-pass", "fail-to-pass") + + +def split_nodeid(target): + prefix, bracket, parameter = target.partition("[") + parts = prefix.split("::") + if bracket: + parts[-1] += bracket + parameter + return parts + + +def matches(case, target): + parts = split_nodeid(target) + module = parts[0].removesuffix(".py").replace("/", ".") + classname, name = case.get("classname", ""), case.get("name", "") + if not (classname == module or classname.startswith(module + ".")): + return False + selector = parts[-1] if len(parts) > 1 else "" + classes = parts[1:-1] + if classes and classname != module + "." + ".".join(classes): + return False + return ( + not selector + or name == selector + or ("[" not in selector and name.startswith(selector + "[")) + ) + + +def capture_panels(root): + panels, digests = {}, {} + for group in GROUPS: + path = Path(root) / (group + ".xml") + if not path.exists(): + panels[group] = None + continue + with path.open("rb") as stream: + raw = stream.read(4 * 1024**2 + 1) + if not 0 < len(raw) <= 4 * 1024**2 or re.search( + rb" 20000: + raise ValueError("Too many pytest cases") + identities = [(case.get("classname"), case.get("name")) for case in cases] + if len(identities) != len(set(identities)): + raise ValueError("Duplicate pytest case evidence") + panels[group] = cases + digests[group] = hashlib.sha256(raw).hexdigest() + return panels, digests + + +def strict_assess(panels, expected, native_exit): + """The original positive-approval conditions, applied to captured cases.""" + all_cases, actual_failure = [], False + for group in GROUPS: + cases = panels[group] + if cases is None: + if actual_failure: + continue + raise ValueError("Missing preceding pytest panel") + if actual_failure: + raise ValueError( + "Pytest evidence continued after the native stop-on-failure" + ) + targets = expected[group] + if any(not any(matches(case, target) for target in targets) for case in cases): + raise ValueError("Unexpected pytest case") + all_cases.extend(cases) + failures = [case for case in cases if case.find("failure") is not None] + if any( + case.find("error") is not None or case.find("skipped") is not None + for case in cases + ): + raise ValueError("Pytest collection/error/skip is not a completed panel") + actual_failure = actual_failure or bool(failures) + if not failures and any( + not any(matches(case, target) for case in cases) for target in targets + ): + raise ValueError("Declared pytest target never ran") + if actual_failure: + if native_exit == 0: + raise ValueError("Native verifier exit disagrees with pytest failure") + return {"reward": 0, "valid_test_failure": True, "cases": len(all_cases)} + if native_exit != 0: + raise ValueError("Setup or native verifier failed without a real test failure") + if any(panels[group] is None for group in GROUPS): + raise ValueError("Missing completed pytest panel") + return {"reward": 1, "valid_test_failure": False, "cases": len(all_cases)} + + +def assess(root, expected, native_exit): + if type(native_exit) is not int: + raise ValueError("Native verifier exit must be an integer") + if not isinstance(expected, dict) or any( + not isinstance(expected.get(group), list) + or not expected[group] + or any(not isinstance(target, str) or not target for target in expected[group]) + for group in GROUPS + ): + raise ValueError("Complete exact native pytest targets required") + panels, digests = capture_panels(root) + counts = { + "cases": 0, + "matched_failures": 0, + "unexpected_cases": 0, + "unmatched_failures": 0, + "skipped_cases": 0, + "error_cases": 0, + "missing_panels": 0, + "missing_targets": 0, + } + for group in GROUPS: + cases = panels[group] + if cases is None: + counts["missing_panels"] += 1 + counts["missing_targets"] += len(expected[group]) + continue + counts["cases"] += len(cases) + for case in cases: + requested = any(matches(case, target) for target in expected[group]) + failure = case.find("failure") is not None + counts["matched_failures"] += int(requested and failure) + counts["unmatched_failures"] += int(not requested and failure) + counts["unexpected_cases"] += int(not requested) + counts["skipped_cases"] += int(case.find("skipped") is not None) + counts["error_cases"] += int(case.find("error") is not None) + counts["missing_targets"] += sum( + not any(matches(case, target) for case in cases) + for target in expected[group] + ) + if counts["matched_failures"]: + if native_exit == 0: + raise ValueError( + "Native verifier exit disagrees with requested pytest failure" + ) + return { + "reward": 0, + "valid_test_failure": True, + "cases": counts["cases"], + "diagnostic_counts": counts, + "panel_sha256": digests, + "decision": "confirmed_requested_failure_precedence", + } + result = strict_assess(panels, expected, native_exit) + result.update(diagnostic_counts=counts, panel_sha256=digests) + return result + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("--root", required=True) + parser.add_argument("--expected", required=True) + parser.add_argument("--native-exit", type=int, required=True) + args = parser.parse_args() + result = assess( + args.root, json.loads(Path(args.expected).read_bytes()), args.native_exit + ) + reward = Path(args.root) / "reward.txt" + if reward.read_text().strip() != str(result["reward"]): + raise ValueError("Native raw reward disagrees with pytest evidence") + (Path(args.root) / "pytest-evidence.json").write_text( + json.dumps(result, sort_keys=True) + "\n" + ) diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/tests/expected-panels.json b/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/tests/expected-panels.json new file mode 100644 index 0000000000000000000000000000000000000000..7dc726ad49e5013668d8da63284df67cf2f4649c --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/tests/expected-panels.json @@ -0,0 +1,951 @@ +{ + "fail-to-pass": [ + "tests/test_commonmark.py::TestCommonMark::test_backslash_escapes_019", + "tests/test_commonmark.py::TestCommonMark::test_backslash_escapes_024", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_228", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_229", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_230", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_232", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_233", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_234", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_235", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_236", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_237", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_238", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_241", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_242", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_243", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_244", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_245", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_246", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_247", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_248", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_249", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_250", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_251", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_252", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_034", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_119", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_120", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_122", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_123", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_124", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_125", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_126", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_127", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_128", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_129", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_130", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_131", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_132", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_133", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_135", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_136", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_137", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_139", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_140", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_141", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_142", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_143", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_144", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_146", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_147", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_174", + "tests/test_commonmark.py::TestCommonMark::test_indented_code_blocks_115", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_212", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_214", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_218", + "tests/test_commonmark.py::TestCommonMark::test_list_items_253", + "tests/test_commonmark.py::TestCommonMark::test_list_items_254", + "tests/test_commonmark.py::TestCommonMark::test_list_items_259", + "tests/test_commonmark.py::TestCommonMark::test_list_items_260", + "tests/test_commonmark.py::TestCommonMark::test_list_items_263", + "tests/test_commonmark.py::TestCommonMark::test_list_items_278", + "tests/test_commonmark.py::TestCommonMark::test_list_items_279", + "tests/test_commonmark.py::TestCommonMark::test_list_items_280", + "tests/test_commonmark.py::TestCommonMark::test_list_items_286", + "tests/test_commonmark.py::TestCommonMark::test_list_items_287", + "tests/test_commonmark.py::TestCommonMark::test_list_items_288", + "tests/test_commonmark.py::TestCommonMark::test_list_items_290", + "tests/test_commonmark.py::TestCommonMark::test_list_items_292", + "tests/test_commonmark.py::TestCommonMark::test_list_items_293", + "tests/test_commonmark.py::TestCommonMark::test_lists_318", + "tests/test_commonmark.py::TestCommonMark::test_lists_320", + "tests/test_commonmark.py::TestCommonMark::test_lists_321", + "tests/test_commonmark.py::TestCommonMark::test_lists_324", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_085", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_092", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_096", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_098", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_100", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_101", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_104", + "tests/test_commonmark.py::TestCommonMark::test_tabs_006", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_043", + "tests/test_directives.py::TestDirective_fenced_admonition::test_admonition_002", + "tests/test_directives.py::TestDirective_fenced_admonition::test_admonition_008", + "tests/test_directives.py::TestDirective_fenced_figure::test_all_options_001", + "tests/test_directives.py::TestDirective_fenced_figure::test_legend_001", + "tests/test_directives.py::TestDirective_fenced_figure::test_legend_002", + "tests/test_directives.py::TestDirectiveInclude::test_html_include", + "tests/test_plugins.py::TestPlugin1_task_lists::test_task_lists_008", + "tests/test_plugins.py::TestPlugin2_task_lists::test_task_lists_008", + "tests/test_plugins.py::TestExtraPlugins::test_math_in_quote", + "tests/test_plugins.py::TestExtraPlugins::test_table_in_quote", + "tests/test_renderers.py::TestRendererRst::test_code_002", + "tests/test_renderers.py::TestRendererRst::test_quote_001", + "tests/test_renderers.py::TestRendererRst::test_quote_002", + "tests/test_renderers.py::TestRendererRst::test_quote_003", + "tests/test_renderers.py::TestRendererMarkdown::test_code_002", + "tests/test_renderers.py::TestRendererMarkdown::test_quote_001", + "tests/test_renderers.py::TestRendererMarkdown::test_quote_002", + "tests/test_syntax.py::TestSyntax::test_max_depth_001", + "tests/test_syntax.py::TestSyntax::test_setext_headings_001" + ], + "pass-to-pass": [ + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_062", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_063", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_064", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_065", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_066", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_067", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_068", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_069", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_070", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_071", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_072", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_073", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_074", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_075", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_076", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_077", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_078", + "tests/test_commonmark.py::TestCommonMark::test_atx_headings_079", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_593", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_594", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_595", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_596", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_597", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_598", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_599", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_600", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_601", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_602", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_603", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_604", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_605", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_606", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_607", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_608", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_609", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_610", + "tests/test_commonmark.py::TestCommonMark::test_autolinks_611", + "tests/test_commonmark.py::TestCommonMark::test_backslash_escapes_012", + "tests/test_commonmark.py::TestCommonMark::test_backslash_escapes_013", + "tests/test_commonmark.py::TestCommonMark::test_backslash_escapes_014", + "tests/test_commonmark.py::TestCommonMark::test_backslash_escapes_015", + "tests/test_commonmark.py::TestCommonMark::test_backslash_escapes_016", + "tests/test_commonmark.py::TestCommonMark::test_backslash_escapes_017", + "tests/test_commonmark.py::TestCommonMark::test_backslash_escapes_018", + "tests/test_commonmark.py::TestCommonMark::test_backslash_escapes_020", + "tests/test_commonmark.py::TestCommonMark::test_backslash_escapes_021", + "tests/test_commonmark.py::TestCommonMark::test_backslash_escapes_022", + "tests/test_commonmark.py::TestCommonMark::test_backslash_escapes_023", + "tests/test_commonmark.py::TestCommonMark::test_blank_lines_227", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_231", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_239", + "tests/test_commonmark.py::TestCommonMark::test_block_quotes_240", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_328", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_329", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_330", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_331", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_332", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_333", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_334", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_335", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_336", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_337", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_338", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_339", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_340", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_341", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_342", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_343", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_344", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_345", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_346", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_347", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_348", + "tests/test_commonmark.py::TestCommonMark::test_code_spans_349", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_350", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_351", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_353", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_354", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_355", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_356", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_357", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_358", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_359", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_360", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_361", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_362", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_363", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_364", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_365", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_366", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_369", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_370", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_371", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_373", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_374", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_375", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_376", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_377", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_378", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_380", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_381", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_382", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_383", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_384", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_385", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_386", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_387", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_389", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_390", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_392", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_393", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_394", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_395", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_396", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_397", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_398", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_399", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_400", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_401", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_402", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_403", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_404", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_405", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_409", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_410", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_411", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_415", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_419", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_420", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_421", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_422", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_423", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_427", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_428", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_432", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_433", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_434", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_435", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_436", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_437", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_438", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_439", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_440", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_447", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_448", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_449", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_450", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_451", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_452", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_459", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_461", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_466", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_468", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_469", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_472", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_473", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_474", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_475", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_476", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_479", + "tests/test_commonmark.py::TestCommonMark::test_emphasis_and_strong_emphasis_480", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_025", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_026", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_027", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_028", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_029", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_030", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_031", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_032", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_033", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_035", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_036", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_037", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_038", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_039", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_040", + "tests/test_commonmark.py::TestCommonMark::test_entity_and_numeric_character_references_041", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_121", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_134", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_138", + "tests/test_commonmark.py::TestCommonMark::test_fenced_code_blocks_145", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_633", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_634", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_635", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_636", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_637", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_638", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_639", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_640", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_641", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_642", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_643", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_644", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_645", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_646", + "tests/test_commonmark.py::TestCommonMark::test_hard_line_breaks_647", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_148", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_149", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_150", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_151", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_152", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_153", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_154", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_155", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_156", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_157", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_158", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_159", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_160", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_161", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_162", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_163", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_164", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_165", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_166", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_167", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_168", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_169", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_170", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_171", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_172", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_173", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_175", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_176", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_177", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_178", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_179", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_180", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_181", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_182", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_183", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_184", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_185", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_186", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_187", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_188", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_189", + "tests/test_commonmark.py::TestCommonMark::test_html_blocks_190", + "tests/test_commonmark.py::TestCommonMark::test_images_571", + "tests/test_commonmark.py::TestCommonMark::test_images_572", + "tests/test_commonmark.py::TestCommonMark::test_images_574", + "tests/test_commonmark.py::TestCommonMark::test_images_575", + "tests/test_commonmark.py::TestCommonMark::test_images_576", + "tests/test_commonmark.py::TestCommonMark::test_images_577", + "tests/test_commonmark.py::TestCommonMark::test_images_578", + "tests/test_commonmark.py::TestCommonMark::test_images_579", + "tests/test_commonmark.py::TestCommonMark::test_images_580", + "tests/test_commonmark.py::TestCommonMark::test_images_581", + "tests/test_commonmark.py::TestCommonMark::test_images_582", + "tests/test_commonmark.py::TestCommonMark::test_images_583", + "tests/test_commonmark.py::TestCommonMark::test_images_584", + "tests/test_commonmark.py::TestCommonMark::test_images_585", + "tests/test_commonmark.py::TestCommonMark::test_images_586", + "tests/test_commonmark.py::TestCommonMark::test_images_587", + "tests/test_commonmark.py::TestCommonMark::test_images_588", + "tests/test_commonmark.py::TestCommonMark::test_images_589", + "tests/test_commonmark.py::TestCommonMark::test_images_590", + "tests/test_commonmark.py::TestCommonMark::test_images_591", + "tests/test_commonmark.py::TestCommonMark::test_images_592", + "tests/test_commonmark.py::TestCommonMark::test_indented_code_blocks_107", + "tests/test_commonmark.py::TestCommonMark::test_indented_code_blocks_108", + "tests/test_commonmark.py::TestCommonMark::test_indented_code_blocks_109", + "tests/test_commonmark.py::TestCommonMark::test_indented_code_blocks_110", + "tests/test_commonmark.py::TestCommonMark::test_indented_code_blocks_111", + "tests/test_commonmark.py::TestCommonMark::test_indented_code_blocks_112", + "tests/test_commonmark.py::TestCommonMark::test_indented_code_blocks_113", + "tests/test_commonmark.py::TestCommonMark::test_indented_code_blocks_114", + "tests/test_commonmark.py::TestCommonMark::test_indented_code_blocks_116", + "tests/test_commonmark.py::TestCommonMark::test_indented_code_blocks_117", + "tests/test_commonmark.py::TestCommonMark::test_indented_code_blocks_118", + "tests/test_commonmark.py::TestCommonMark::test_inlines_327", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_192", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_193", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_194", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_195", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_196", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_197", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_198", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_199", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_200", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_201", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_202", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_203", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_204", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_205", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_206", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_207", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_208", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_209", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_210", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_211", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_213", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_215", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_216", + "tests/test_commonmark.py::TestCommonMark::test_link_reference_definitions_217", + "tests/test_commonmark.py::TestCommonMark::test_links_481", + "tests/test_commonmark.py::TestCommonMark::test_links_482", + "tests/test_commonmark.py::TestCommonMark::test_links_483", + "tests/test_commonmark.py::TestCommonMark::test_links_484", + "tests/test_commonmark.py::TestCommonMark::test_links_485", + "tests/test_commonmark.py::TestCommonMark::test_links_486", + "tests/test_commonmark.py::TestCommonMark::test_links_487", + "tests/test_commonmark.py::TestCommonMark::test_links_488", + "tests/test_commonmark.py::TestCommonMark::test_links_489", + "tests/test_commonmark.py::TestCommonMark::test_links_490", + "tests/test_commonmark.py::TestCommonMark::test_links_491", + "tests/test_commonmark.py::TestCommonMark::test_links_492", + "tests/test_commonmark.py::TestCommonMark::test_links_493", + "tests/test_commonmark.py::TestCommonMark::test_links_494", + "tests/test_commonmark.py::TestCommonMark::test_links_497", + "tests/test_commonmark.py::TestCommonMark::test_links_498", + "tests/test_commonmark.py::TestCommonMark::test_links_499", + "tests/test_commonmark.py::TestCommonMark::test_links_500", + "tests/test_commonmark.py::TestCommonMark::test_links_501", + "tests/test_commonmark.py::TestCommonMark::test_links_502", + "tests/test_commonmark.py::TestCommonMark::test_links_503", + "tests/test_commonmark.py::TestCommonMark::test_links_505", + "tests/test_commonmark.py::TestCommonMark::test_links_506", + "tests/test_commonmark.py::TestCommonMark::test_links_507", + "tests/test_commonmark.py::TestCommonMark::test_links_508", + "tests/test_commonmark.py::TestCommonMark::test_links_509", + "tests/test_commonmark.py::TestCommonMark::test_links_510", + "tests/test_commonmark.py::TestCommonMark::test_links_511", + "tests/test_commonmark.py::TestCommonMark::test_links_512", + "tests/test_commonmark.py::TestCommonMark::test_links_513", + "tests/test_commonmark.py::TestCommonMark::test_links_514", + "tests/test_commonmark.py::TestCommonMark::test_links_515", + "tests/test_commonmark.py::TestCommonMark::test_links_516", + "tests/test_commonmark.py::TestCommonMark::test_links_520", + "tests/test_commonmark.py::TestCommonMark::test_links_521", + "tests/test_commonmark.py::TestCommonMark::test_links_522", + "tests/test_commonmark.py::TestCommonMark::test_links_523", + "tests/test_commonmark.py::TestCommonMark::test_links_524", + "tests/test_commonmark.py::TestCommonMark::test_links_525", + "tests/test_commonmark.py::TestCommonMark::test_links_526", + "tests/test_commonmark.py::TestCommonMark::test_links_527", + "tests/test_commonmark.py::TestCommonMark::test_links_528", + "tests/test_commonmark.py::TestCommonMark::test_links_529", + "tests/test_commonmark.py::TestCommonMark::test_links_530", + "tests/test_commonmark.py::TestCommonMark::test_links_533", + "tests/test_commonmark.py::TestCommonMark::test_links_534", + "tests/test_commonmark.py::TestCommonMark::test_links_535", + "tests/test_commonmark.py::TestCommonMark::test_links_536", + "tests/test_commonmark.py::TestCommonMark::test_links_537", + "tests/test_commonmark.py::TestCommonMark::test_links_538", + "tests/test_commonmark.py::TestCommonMark::test_links_539", + "tests/test_commonmark.py::TestCommonMark::test_links_540", + "tests/test_commonmark.py::TestCommonMark::test_links_541", + "tests/test_commonmark.py::TestCommonMark::test_links_542", + "tests/test_commonmark.py::TestCommonMark::test_links_543", + "tests/test_commonmark.py::TestCommonMark::test_links_544", + "tests/test_commonmark.py::TestCommonMark::test_links_545", + "tests/test_commonmark.py::TestCommonMark::test_links_546", + "tests/test_commonmark.py::TestCommonMark::test_links_547", + "tests/test_commonmark.py::TestCommonMark::test_links_548", + "tests/test_commonmark.py::TestCommonMark::test_links_549", + "tests/test_commonmark.py::TestCommonMark::test_links_550", + "tests/test_commonmark.py::TestCommonMark::test_links_551", + "tests/test_commonmark.py::TestCommonMark::test_links_552", + "tests/test_commonmark.py::TestCommonMark::test_links_553", + "tests/test_commonmark.py::TestCommonMark::test_links_554", + "tests/test_commonmark.py::TestCommonMark::test_links_555", + "tests/test_commonmark.py::TestCommonMark::test_links_556", + "tests/test_commonmark.py::TestCommonMark::test_links_557", + "tests/test_commonmark.py::TestCommonMark::test_links_558", + "tests/test_commonmark.py::TestCommonMark::test_links_559", + "tests/test_commonmark.py::TestCommonMark::test_links_560", + "tests/test_commonmark.py::TestCommonMark::test_links_561", + "tests/test_commonmark.py::TestCommonMark::test_links_562", + "tests/test_commonmark.py::TestCommonMark::test_links_563", + "tests/test_commonmark.py::TestCommonMark::test_links_564", + "tests/test_commonmark.py::TestCommonMark::test_links_565", + "tests/test_commonmark.py::TestCommonMark::test_links_566", + "tests/test_commonmark.py::TestCommonMark::test_links_567", + "tests/test_commonmark.py::TestCommonMark::test_links_568", + "tests/test_commonmark.py::TestCommonMark::test_links_569", + "tests/test_commonmark.py::TestCommonMark::test_links_570", + "tests/test_commonmark.py::TestCommonMark::test_list_items_255", + "tests/test_commonmark.py::TestCommonMark::test_list_items_256", + "tests/test_commonmark.py::TestCommonMark::test_list_items_257", + "tests/test_commonmark.py::TestCommonMark::test_list_items_258", + "tests/test_commonmark.py::TestCommonMark::test_list_items_261", + "tests/test_commonmark.py::TestCommonMark::test_list_items_262", + "tests/test_commonmark.py::TestCommonMark::test_list_items_264", + "tests/test_commonmark.py::TestCommonMark::test_list_items_265", + "tests/test_commonmark.py::TestCommonMark::test_list_items_266", + "tests/test_commonmark.py::TestCommonMark::test_list_items_267", + "tests/test_commonmark.py::TestCommonMark::test_list_items_268", + "tests/test_commonmark.py::TestCommonMark::test_list_items_269", + "tests/test_commonmark.py::TestCommonMark::test_list_items_270", + "tests/test_commonmark.py::TestCommonMark::test_list_items_271", + "tests/test_commonmark.py::TestCommonMark::test_list_items_272", + "tests/test_commonmark.py::TestCommonMark::test_list_items_273", + "tests/test_commonmark.py::TestCommonMark::test_list_items_274", + "tests/test_commonmark.py::TestCommonMark::test_list_items_275", + "tests/test_commonmark.py::TestCommonMark::test_list_items_276", + "tests/test_commonmark.py::TestCommonMark::test_list_items_277", + "tests/test_commonmark.py::TestCommonMark::test_list_items_281", + "tests/test_commonmark.py::TestCommonMark::test_list_items_282", + "tests/test_commonmark.py::TestCommonMark::test_list_items_283", + "tests/test_commonmark.py::TestCommonMark::test_list_items_284", + "tests/test_commonmark.py::TestCommonMark::test_list_items_285", + "tests/test_commonmark.py::TestCommonMark::test_list_items_289", + "tests/test_commonmark.py::TestCommonMark::test_list_items_291", + "tests/test_commonmark.py::TestCommonMark::test_list_items_294", + "tests/test_commonmark.py::TestCommonMark::test_list_items_295", + "tests/test_commonmark.py::TestCommonMark::test_list_items_296", + "tests/test_commonmark.py::TestCommonMark::test_list_items_297", + "tests/test_commonmark.py::TestCommonMark::test_list_items_298", + "tests/test_commonmark.py::TestCommonMark::test_list_items_299", + "tests/test_commonmark.py::TestCommonMark::test_list_items_300", + "tests/test_commonmark.py::TestCommonMark::test_lists_301", + "tests/test_commonmark.py::TestCommonMark::test_lists_302", + "tests/test_commonmark.py::TestCommonMark::test_lists_303", + "tests/test_commonmark.py::TestCommonMark::test_lists_304", + "tests/test_commonmark.py::TestCommonMark::test_lists_305", + "tests/test_commonmark.py::TestCommonMark::test_lists_306", + "tests/test_commonmark.py::TestCommonMark::test_lists_307", + "tests/test_commonmark.py::TestCommonMark::test_lists_308", + "tests/test_commonmark.py::TestCommonMark::test_lists_309", + "tests/test_commonmark.py::TestCommonMark::test_lists_310", + "tests/test_commonmark.py::TestCommonMark::test_lists_311", + "tests/test_commonmark.py::TestCommonMark::test_lists_312", + "tests/test_commonmark.py::TestCommonMark::test_lists_313", + "tests/test_commonmark.py::TestCommonMark::test_lists_314", + "tests/test_commonmark.py::TestCommonMark::test_lists_315", + "tests/test_commonmark.py::TestCommonMark::test_lists_316", + "tests/test_commonmark.py::TestCommonMark::test_lists_317", + "tests/test_commonmark.py::TestCommonMark::test_lists_319", + "tests/test_commonmark.py::TestCommonMark::test_lists_322", + "tests/test_commonmark.py::TestCommonMark::test_lists_323", + "tests/test_commonmark.py::TestCommonMark::test_lists_325", + "tests/test_commonmark.py::TestCommonMark::test_lists_326", + "tests/test_commonmark.py::TestCommonMark::test_paragraphs_219", + "tests/test_commonmark.py::TestCommonMark::test_paragraphs_220", + "tests/test_commonmark.py::TestCommonMark::test_paragraphs_221", + "tests/test_commonmark.py::TestCommonMark::test_paragraphs_222", + "tests/test_commonmark.py::TestCommonMark::test_paragraphs_223", + "tests/test_commonmark.py::TestCommonMark::test_paragraphs_224", + "tests/test_commonmark.py::TestCommonMark::test_paragraphs_225", + "tests/test_commonmark.py::TestCommonMark::test_paragraphs_226", + "tests/test_commonmark.py::TestCommonMark::test_precedence_042", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_612", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_613", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_614", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_615", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_616", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_617", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_618", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_619", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_620", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_621", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_622", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_623", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_624", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_625", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_626", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_627", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_628", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_629", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_630", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_631", + "tests/test_commonmark.py::TestCommonMark::test_raw_html_632", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_080", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_081", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_082", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_083", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_084", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_086", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_087", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_088", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_089", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_090", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_091", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_094", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_095", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_097", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_099", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_102", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_103", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_105", + "tests/test_commonmark.py::TestCommonMark::test_setext_headings_106", + "tests/test_commonmark.py::TestCommonMark::test_soft_line_breaks_648", + "tests/test_commonmark.py::TestCommonMark::test_soft_line_breaks_649", + "tests/test_commonmark.py::TestCommonMark::test_tabs_001", + "tests/test_commonmark.py::TestCommonMark::test_tabs_002", + "tests/test_commonmark.py::TestCommonMark::test_tabs_003", + "tests/test_commonmark.py::TestCommonMark::test_tabs_004", + "tests/test_commonmark.py::TestCommonMark::test_tabs_005", + "tests/test_commonmark.py::TestCommonMark::test_tabs_007", + "tests/test_commonmark.py::TestCommonMark::test_tabs_008", + "tests/test_commonmark.py::TestCommonMark::test_tabs_009", + "tests/test_commonmark.py::TestCommonMark::test_tabs_010", + "tests/test_commonmark.py::TestCommonMark::test_tabs_011", + "tests/test_commonmark.py::TestCommonMark::test_textual_content_650", + "tests/test_commonmark.py::TestCommonMark::test_textual_content_651", + "tests/test_commonmark.py::TestCommonMark::test_textual_content_652", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_044", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_045", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_046", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_047", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_048", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_049", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_050", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_051", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_052", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_053", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_054", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_055", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_056", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_057", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_058", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_059", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_060", + "tests/test_commonmark.py::TestCommonMark::test_thematic_breaks_061", + "tests/test_directives.py::TestDirective_rst_admonition::test_admonition_001", + "tests/test_directives.py::TestDirective_rst_admonition::test_admonition_002", + "tests/test_directives.py::TestDirective_rst_admonition::test_admonition_003", + "tests/test_directives.py::TestDirective_rst_admonition::test_admonition_004", + "tests/test_directives.py::TestDirective_rst_toc::test_collapse_toc_001", + "tests/test_directives.py::TestDirective_rst_toc::test_complex_001", + "tests/test_directives.py::TestDirective_rst_toc::test_html_in_heading_001", + "tests/test_directives.py::TestDirective_rst_toc::test_insane_001", + "tests/test_directives.py::TestDirective_rst_toc::test_insane_002", + "tests/test_directives.py::TestDirective_rst_toc::test_invalid_option_001", + "tests/test_directives.py::TestDirective_rst_toc::test_invalid_option_002", + "tests/test_directives.py::TestDirective_rst_toc::test_invalid_option_003", + "tests/test_directives.py::TestDirective_rst_toc::test_link_in_heading_001", + "tests/test_directives.py::TestDirective_rst_toc::test_no_toc_001", + "tests/test_directives.py::TestDirective_rst_toc::test_no_toc_002", + "tests/test_directives.py::TestDirective_rst_toc::test_simple_toc_001", + "tests/test_directives.py::TestDirective_fenced_admonition::test_admonition_001", + "tests/test_directives.py::TestDirective_fenced_admonition::test_admonition_003", + "tests/test_directives.py::TestDirective_fenced_admonition::test_admonition_004", + "tests/test_directives.py::TestDirective_fenced_admonition::test_admonition_005", + "tests/test_directives.py::TestDirective_fenced_admonition::test_admonition_006", + "tests/test_directives.py::TestDirective_fenced_admonition::test_admonition_007", + "tests/test_directives.py::TestDirective_fenced_toc::test_collapse_toc_001", + "tests/test_directives.py::TestDirective_fenced_toc::test_complex_001", + "tests/test_directives.py::TestDirective_fenced_toc::test_html_in_heading_001", + "tests/test_directives.py::TestDirective_fenced_toc::test_insane_001", + "tests/test_directives.py::TestDirective_fenced_toc::test_insane_002", + "tests/test_directives.py::TestDirective_fenced_toc::test_invalid_option_001", + "tests/test_directives.py::TestDirective_fenced_toc::test_invalid_option_002", + "tests/test_directives.py::TestDirective_fenced_toc::test_invalid_option_003", + "tests/test_directives.py::TestDirective_fenced_toc::test_link_in_heading_001", + "tests/test_directives.py::TestDirective_fenced_toc::test_no_toc_001", + "tests/test_directives.py::TestDirective_fenced_toc::test_no_toc_002", + "tests/test_directives.py::TestDirective_fenced_toc::test_simple_toc_001", + "tests/test_directives.py::TestDirective_fenced_image::test_align_options_001", + "tests/test_directives.py::TestDirective_fenced_image::test_align_options_002", + "tests/test_directives.py::TestDirective_fenced_image::test_all_options_001", + "tests/test_directives.py::TestDirective_fenced_image::test_alt_option_001", + "tests/test_directives.py::TestDirective_fenced_image::test_ampersand_in_source_001", + "tests/test_directives.py::TestDirective_fenced_image::test_ampersand_in_target_001", + "tests/test_directives.py::TestDirective_fenced_image::test_no_options_001", + "tests/test_directives.py::TestDirective_fenced_image::test_target_option_001", + "tests/test_directives.py::TestDirective_fenced_image::test_width_and_height_001", + "tests/test_directives.py::TestDirective_fenced_image::test_width_and_height_002", + "tests/test_directives.py::TestDirective_fenced_figure::test_align_options_001", + "tests/test_directives.py::TestDirective_fenced_figure::test_align_options_002", + "tests/test_directives.py::TestDirective_fenced_figure::test_alt_option_001", + "tests/test_directives.py::TestDirective_fenced_figure::test_caption_001", + "tests/test_directives.py::TestDirective_fenced_figure::test_no_options_001", + "tests/test_directives.py::TestDirective_fenced_figure::test_target_option_001", + "tests/test_directives.py::TestDirective_fenced_figure::test_width_and_height_001", + "tests/test_directives.py::TestDirective_fenced_figure::test_width_and_height_002", + "tests/test_directives.py::TestDirective_fenced_figure::test_width_and_height_003", + "tests/test_directives.py::TestCustomizeToc::test_colon_fenced_toc", + "tests/test_directives.py::TestCustomizeToc::test_fenced_toc", + "tests/test_directives.py::TestCustomizeToc::test_rst_toc", + "tests/test_directives.py::TestDirectiveInclude::test_include_missing_source", + "tests/test_hooks.py::TestTocHook::test_complex_toc_001", + "tests/test_hooks.py::TestTocHook::test_customize_heading_id_func", + "tests/test_hooks.py::TestTocHook::test_html_in_heading_001", + "tests/test_hooks.py::TestTocHook::test_insane_toc_001", + "tests/test_hooks.py::TestTocHook::test_insane_toc_002", + "tests/test_hooks.py::TestTocHook::test_link_in_heading_001", + "tests/test_hooks.py::TestTocHook::test_simple_toc_001", + "tests/test_misc.py::TestMiscCases::test_allow_data_protocols", + "tests/test_misc.py::TestMiscCases::test_allow_harmful_protocols", + "tests/test_misc.py::TestMiscCases::test_ast_output", + "tests/test_misc.py::TestMiscCases::test_ast_url", + "tests/test_misc.py::TestMiscCases::test_before_parse_hooks", + "tests/test_misc.py::TestMiscCases::test_emsp", + "tests/test_misc.py::TestMiscCases::test_escape_html", + "tests/test_misc.py::TestMiscCases::test_hard_wrap", + "tests/test_misc.py::TestMiscCases::test_harmful_links", + "tests/test_misc.py::TestMiscCases::test_html_tag_text_following_list", + "tests/test_misc.py::TestMiscCases::test_markdown_func", + "tests/test_misc.py::TestMiscCases::test_none", + "tests/test_misc.py::TestMiscCases::test_ref_link", + "tests/test_misc.py::TestMiscCases::test_use_plugin", + "tests/test_plugins.py::TestPlugin1_url::test_url_plugin_001", + "tests/test_plugins.py::TestPlugin1_url::test_url_plugin_002", + "tests/test_plugins.py::TestPlugin1_url::test_url_plugin_003", + "tests/test_plugins.py::TestPlugin2_url::test_url_plugin_001", + "tests/test_plugins.py::TestPlugin2_url::test_url_plugin_002", + "tests/test_plugins.py::TestPlugin2_url::test_url_plugin_003", + "tests/test_plugins.py::TestPlugin1_strikethrough::test_strikethrough_001", + "tests/test_plugins.py::TestPlugin1_strikethrough::test_strikethrough_002", + "tests/test_plugins.py::TestPlugin1_strikethrough::test_strikethrough_003", + "tests/test_plugins.py::TestPlugin1_strikethrough::test_strikethrough_004", + "tests/test_plugins.py::TestPlugin1_strikethrough::test_strikethrough_005", + "tests/test_plugins.py::TestPlugin1_strikethrough::test_strikethrough_006", + "tests/test_plugins.py::TestPlugin1_strikethrough::test_strikethrough_007", + "tests/test_plugins.py::TestPlugin2_strikethrough::test_strikethrough_001", + "tests/test_plugins.py::TestPlugin2_strikethrough::test_strikethrough_002", + "tests/test_plugins.py::TestPlugin2_strikethrough::test_strikethrough_003", + "tests/test_plugins.py::TestPlugin2_strikethrough::test_strikethrough_004", + "tests/test_plugins.py::TestPlugin2_strikethrough::test_strikethrough_005", + "tests/test_plugins.py::TestPlugin2_strikethrough::test_strikethrough_006", + "tests/test_plugins.py::TestPlugin2_strikethrough::test_strikethrough_007", + "tests/test_plugins.py::TestPlugin1_mark::test_escape_mark_001", + "tests/test_plugins.py::TestPlugin1_mark::test_escape_mark_002", + "tests/test_plugins.py::TestPlugin1_mark::test_mark_001", + "tests/test_plugins.py::TestPlugin1_mark::test_mark_link_001", + "tests/test_plugins.py::TestPlugin1_mark::test_mark_link_002", + "tests/test_plugins.py::TestPlugin1_mark::test_normal_mark_001", + "tests/test_plugins.py::TestPlugin1_mark::test_normal_mark_002", + "tests/test_plugins.py::TestPlugin1_mark::test_normal_mark_003", + "tests/test_plugins.py::TestPlugin1_mark::test_normal_mark_004", + "tests/test_plugins.py::TestPlugin2_mark::test_escape_mark_001", + "tests/test_plugins.py::TestPlugin2_mark::test_escape_mark_002", + "tests/test_plugins.py::TestPlugin2_mark::test_mark_001", + "tests/test_plugins.py::TestPlugin2_mark::test_mark_link_001", + "tests/test_plugins.py::TestPlugin2_mark::test_mark_link_002", + "tests/test_plugins.py::TestPlugin2_mark::test_normal_mark_001", + "tests/test_plugins.py::TestPlugin2_mark::test_normal_mark_002", + "tests/test_plugins.py::TestPlugin2_mark::test_normal_mark_003", + "tests/test_plugins.py::TestPlugin2_mark::test_normal_mark_004", + "tests/test_plugins.py::TestPlugin1_insert::test_escape_insert_001", + "tests/test_plugins.py::TestPlugin1_insert::test_escape_insert_002", + "tests/test_plugins.py::TestPlugin1_insert::test_insert_001", + "tests/test_plugins.py::TestPlugin1_insert::test_insert_link_001", + "tests/test_plugins.py::TestPlugin1_insert::test_insert_link_002", + "tests/test_plugins.py::TestPlugin1_insert::test_normal_insert_001", + "tests/test_plugins.py::TestPlugin1_insert::test_normal_insert_002", + "tests/test_plugins.py::TestPlugin1_insert::test_normal_insert_003", + "tests/test_plugins.py::TestPlugin1_insert::test_normal_insert_004", + "tests/test_plugins.py::TestPlugin2_insert::test_escape_insert_001", + "tests/test_plugins.py::TestPlugin2_insert::test_escape_insert_002", + "tests/test_plugins.py::TestPlugin2_insert::test_insert_001", + "tests/test_plugins.py::TestPlugin2_insert::test_insert_link_001", + "tests/test_plugins.py::TestPlugin2_insert::test_insert_link_002", + "tests/test_plugins.py::TestPlugin2_insert::test_normal_insert_001", + "tests/test_plugins.py::TestPlugin2_insert::test_normal_insert_002", + "tests/test_plugins.py::TestPlugin2_insert::test_normal_insert_003", + "tests/test_plugins.py::TestPlugin2_insert::test_normal_insert_004", + "tests/test_plugins.py::TestPlugin1_superscript::test_superscript_001", + "tests/test_plugins.py::TestPlugin1_superscript::test_superscript_002", + "tests/test_plugins.py::TestPlugin1_superscript::test_superscript_003", + "tests/test_plugins.py::TestPlugin1_superscript::test_superscript_004", + "tests/test_plugins.py::TestPlugin2_superscript::test_superscript_001", + "tests/test_plugins.py::TestPlugin2_superscript::test_superscript_002", + "tests/test_plugins.py::TestPlugin2_superscript::test_superscript_003", + "tests/test_plugins.py::TestPlugin2_superscript::test_superscript_004", + "tests/test_plugins.py::TestPlugin1_subscript::test_subscript_001", + "tests/test_plugins.py::TestPlugin1_subscript::test_subscript_002", + "tests/test_plugins.py::TestPlugin1_subscript::test_subscript_003", + "tests/test_plugins.py::TestPlugin1_subscript::test_subscript_004", + "tests/test_plugins.py::TestPlugin2_subscript::test_subscript_001", + "tests/test_plugins.py::TestPlugin2_subscript::test_subscript_002", + "tests/test_plugins.py::TestPlugin2_subscript::test_subscript_003", + "tests/test_plugins.py::TestPlugin2_subscript::test_subscript_004", + "tests/test_plugins.py::TestPlugin1_task_lists::test_task_lists_001", + "tests/test_plugins.py::TestPlugin1_task_lists::test_task_lists_002", + "tests/test_plugins.py::TestPlugin1_task_lists::test_task_lists_003", + "tests/test_plugins.py::TestPlugin1_task_lists::test_task_lists_004", + "tests/test_plugins.py::TestPlugin1_task_lists::test_task_lists_005", + "tests/test_plugins.py::TestPlugin1_task_lists::test_task_lists_006", + "tests/test_plugins.py::TestPlugin1_task_lists::test_task_lists_007", + "tests/test_plugins.py::TestPlugin2_task_lists::test_task_lists_001", + "tests/test_plugins.py::TestPlugin2_task_lists::test_task_lists_002", + "tests/test_plugins.py::TestPlugin2_task_lists::test_task_lists_003", + "tests/test_plugins.py::TestPlugin2_task_lists::test_task_lists_004", + "tests/test_plugins.py::TestPlugin2_task_lists::test_task_lists_005", + "tests/test_plugins.py::TestPlugin2_task_lists::test_task_lists_006", + "tests/test_plugins.py::TestPlugin2_task_lists::test_task_lists_007", + "tests/test_plugins.py::TestPlugin1_table::test_align_table_001", + "tests/test_plugins.py::TestPlugin1_table::test_align_table_002", + "tests/test_plugins.py::TestPlugin1_table::test_misc_table_001", + "tests/test_plugins.py::TestPlugin1_table::test_misc_table_002", + "tests/test_plugins.py::TestPlugin1_table::test_misc_table_003", + "tests/test_plugins.py::TestPlugin1_table::test_mismatch_length_001", + "tests/test_plugins.py::TestPlugin1_table::test_mismatch_length_002", + "tests/test_plugins.py::TestPlugin1_table::test_mismatch_length_003", + "tests/test_plugins.py::TestPlugin1_table::test_mismatch_length_004", + "tests/test_plugins.py::TestPlugin1_table::test_nptable_001", + "tests/test_plugins.py::TestPlugin1_table::test_table_001", + "tests/test_plugins.py::TestPlugin1_table::test_table_002", + "tests/test_plugins.py::TestPlugin2_table::test_align_table_001", + "tests/test_plugins.py::TestPlugin2_table::test_align_table_002", + "tests/test_plugins.py::TestPlugin2_table::test_misc_table_001", + "tests/test_plugins.py::TestPlugin2_table::test_misc_table_002", + "tests/test_plugins.py::TestPlugin2_table::test_misc_table_003", + "tests/test_plugins.py::TestPlugin2_table::test_mismatch_length_001", + "tests/test_plugins.py::TestPlugin2_table::test_mismatch_length_002", + "tests/test_plugins.py::TestPlugin2_table::test_mismatch_length_003", + "tests/test_plugins.py::TestPlugin2_table::test_mismatch_length_004", + "tests/test_plugins.py::TestPlugin2_table::test_nptable_001", + "tests/test_plugins.py::TestPlugin2_table::test_table_001", + "tests/test_plugins.py::TestPlugin2_table::test_table_002", + "tests/test_plugins.py::TestPlugin1_def_list::test_definition_lists_001", + "tests/test_plugins.py::TestPlugin1_def_list::test_definition_lists_002", + "tests/test_plugins.py::TestPlugin1_def_list::test_definition_lists_003", + "tests/test_plugins.py::TestPlugin1_def_list::test_definition_lists_004", + "tests/test_plugins.py::TestPlugin1_def_list::test_definition_lists_005", + "tests/test_plugins.py::TestPlugin1_def_list::test_definition_lists_006", + "tests/test_plugins.py::TestPlugin1_def_list::test_definition_with_multiple_lines_001", + "tests/test_plugins.py::TestPlugin1_def_list::test_definition_with_multiple_lines_002", + "tests/test_plugins.py::TestPlugin1_def_list::test_definition_with_multiple_lines_003", + "tests/test_plugins.py::TestPlugin1_def_list::test_definition_with_multiple_lines_004", + "tests/test_plugins.py::TestPlugin1_def_list::test_definition_with_multiple_lines_005", + "tests/test_plugins.py::TestPlugin2_def_list::test_definition_lists_001", + "tests/test_plugins.py::TestPlugin2_def_list::test_definition_lists_002", + "tests/test_plugins.py::TestPlugin2_def_list::test_definition_lists_003", + "tests/test_plugins.py::TestPlugin2_def_list::test_definition_lists_004", + "tests/test_plugins.py::TestPlugin2_def_list::test_definition_lists_005", + "tests/test_plugins.py::TestPlugin2_def_list::test_definition_lists_006", + "tests/test_plugins.py::TestPlugin2_def_list::test_definition_with_multiple_lines_001", + "tests/test_plugins.py::TestPlugin2_def_list::test_definition_with_multiple_lines_002", + "tests/test_plugins.py::TestPlugin2_def_list::test_definition_with_multiple_lines_003", + "tests/test_plugins.py::TestPlugin2_def_list::test_definition_with_multiple_lines_004", + "tests/test_plugins.py::TestPlugin2_def_list::test_definition_with_multiple_lines_005", + "tests/test_plugins.py::TestPlugin1_footnotes::test_footnotes_001", + "tests/test_plugins.py::TestPlugin1_footnotes::test_footnotes_002", + "tests/test_plugins.py::TestPlugin1_footnotes::test_footnotes_003", + "tests/test_plugins.py::TestPlugin2_footnotes::test_footnotes_001", + "tests/test_plugins.py::TestPlugin2_footnotes::test_footnotes_002", + "tests/test_plugins.py::TestPlugin2_footnotes::test_footnotes_003", + "tests/test_plugins.py::TestPlugin1_abbr::test_abbreviation_001", + "tests/test_plugins.py::TestPlugin1_abbr::test_abbreviation_002", + "tests/test_plugins.py::TestPlugin1_abbr::test_abbreviation_003", + "tests/test_plugins.py::TestPlugin1_abbr::test_abbreviation_004", + "tests/test_plugins.py::TestPlugin1_abbr::test_abbreviation_005", + "tests/test_plugins.py::TestPlugin1_abbr::test_abbreviation_006", + "tests/test_plugins.py::TestPlugin1_abbr::test_abbreviation_007", + "tests/test_plugins.py::TestPlugin1_abbr::test_abbreviation_008", + "tests/test_plugins.py::TestPlugin1_abbr::test_abbreviation_009", + "tests/test_plugins.py::TestPlugin1_abbr::test_abbreviation_010", + "tests/test_plugins.py::TestPlugin2_abbr::test_abbreviation_001", + "tests/test_plugins.py::TestPlugin2_abbr::test_abbreviation_002", + "tests/test_plugins.py::TestPlugin2_abbr::test_abbreviation_003", + "tests/test_plugins.py::TestPlugin2_abbr::test_abbreviation_004", + "tests/test_plugins.py::TestPlugin2_abbr::test_abbreviation_005", + "tests/test_plugins.py::TestPlugin2_abbr::test_abbreviation_006", + "tests/test_plugins.py::TestPlugin2_abbr::test_abbreviation_007", + "tests/test_plugins.py::TestPlugin2_abbr::test_abbreviation_008", + "tests/test_plugins.py::TestPlugin2_abbr::test_abbreviation_009", + "tests/test_plugins.py::TestPlugin2_abbr::test_abbreviation_010", + "tests/test_plugins.py::TestPlugin1_math::test_block_math_001", + "tests/test_plugins.py::TestPlugin1_math::test_block_math_002", + "tests/test_plugins.py::TestPlugin1_math::test_block_math_003", + "tests/test_plugins.py::TestPlugin1_math::test_block_math_004", + "tests/test_plugins.py::TestPlugin1_math::test_inline_math_001", + "tests/test_plugins.py::TestPlugin2_math::test_block_math_001", + "tests/test_plugins.py::TestPlugin2_math::test_block_math_002", + "tests/test_plugins.py::TestPlugin2_math::test_block_math_003", + "tests/test_plugins.py::TestPlugin2_math::test_block_math_004", + "tests/test_plugins.py::TestPlugin2_math::test_inline_math_001", + "tests/test_plugins.py::TestPlugin1_ruby::test_ruby_splits_001", + "tests/test_plugins.py::TestPlugin1_ruby::test_ruby_splits_002", + "tests/test_plugins.py::TestPlugin1_ruby::test_ruby_with_link_001", + "tests/test_plugins.py::TestPlugin1_ruby::test_ruby_with_link_002", + "tests/test_plugins.py::TestPlugin1_ruby::test_ruby_with_link_003", + "tests/test_plugins.py::TestPlugin1_ruby::test_ruby_without_link_001", + "tests/test_plugins.py::TestPlugin1_ruby::test_ruby_without_link_002", + "tests/test_plugins.py::TestPlugin1_ruby::test_ruby_without_link_003", + "tests/test_plugins.py::TestPlugin1_ruby::test_ruby_without_link_004", + "tests/test_plugins.py::TestPlugin2_ruby::test_ruby_splits_001", + "tests/test_plugins.py::TestPlugin2_ruby::test_ruby_splits_002", + "tests/test_plugins.py::TestPlugin2_ruby::test_ruby_with_link_001", + "tests/test_plugins.py::TestPlugin2_ruby::test_ruby_with_link_002", + "tests/test_plugins.py::TestPlugin2_ruby::test_ruby_with_link_003", + "tests/test_plugins.py::TestPlugin2_ruby::test_ruby_without_link_001", + "tests/test_plugins.py::TestPlugin2_ruby::test_ruby_without_link_002", + "tests/test_plugins.py::TestPlugin2_ruby::test_ruby_without_link_003", + "tests/test_plugins.py::TestPlugin2_ruby::test_ruby_without_link_004", + "tests/test_plugins.py::TestPlugin1_spoiler::test_block_spoiler_001", + "tests/test_plugins.py::TestPlugin1_spoiler::test_block_spoiler_002", + "tests/test_plugins.py::TestPlugin1_spoiler::test_block_spoiler_003", + "tests/test_plugins.py::TestPlugin1_spoiler::test_block_spoiler_004", + "tests/test_plugins.py::TestPlugin1_spoiler::test_block_spoiler_005", + "tests/test_plugins.py::TestPlugin1_spoiler::test_inline_spoiler_001", + "tests/test_plugins.py::TestPlugin1_spoiler::test_inline_spoiler_002", + "tests/test_plugins.py::TestPlugin1_spoiler::test_inline_spoiler_003", + "tests/test_plugins.py::TestPlugin2_spoiler::test_block_spoiler_001", + "tests/test_plugins.py::TestPlugin2_spoiler::test_block_spoiler_002", + "tests/test_plugins.py::TestPlugin2_spoiler::test_block_spoiler_003", + "tests/test_plugins.py::TestPlugin2_spoiler::test_block_spoiler_004", + "tests/test_plugins.py::TestPlugin2_spoiler::test_block_spoiler_005", + "tests/test_plugins.py::TestPlugin2_spoiler::test_inline_spoiler_001", + "tests/test_plugins.py::TestPlugin2_spoiler::test_inline_spoiler_002", + "tests/test_plugins.py::TestPlugin2_spoiler::test_inline_spoiler_003", + "tests/test_plugins.py::TestExtraPlugins::test_math_in_list", + "tests/test_plugins.py::TestExtraPlugins::test_table_in_list", + "tests/test_renderers.py::TestRendererRst::test_code_001", + "tests/test_renderers.py::TestRendererRst::test_heading_001", + "tests/test_renderers.py::TestRendererRst::test_html_001", + "tests/test_renderers.py::TestRendererRst::test_images_001", + "tests/test_renderers.py::TestRendererRst::test_images_002", + "tests/test_renderers.py::TestRendererRst::test_images_003", + "tests/test_renderers.py::TestRendererRst::test_inline_001", + "tests/test_renderers.py::TestRendererRst::test_inline_002", + "tests/test_renderers.py::TestRendererRst::test_line_break_001", + "tests/test_renderers.py::TestRendererRst::test_links_001", + "tests/test_renderers.py::TestRendererRst::test_list_001", + "tests/test_renderers.py::TestRendererRst::test_list_002", + "tests/test_renderers.py::TestRendererRst::test_list_003", + "tests/test_renderers.py::TestRendererRst::test_list_004", + "tests/test_renderers.py::TestRendererRst::test_list_005", + "tests/test_renderers.py::TestRendererRst::test_thematic_break_001", + "tests/test_renderers.py::TestRendererMarkdown::test_code_001", + "tests/test_renderers.py::TestRendererMarkdown::test_code_003", + "tests/test_renderers.py::TestRendererMarkdown::test_code_004", + "tests/test_renderers.py::TestRendererMarkdown::test_code_005", + "tests/test_renderers.py::TestRendererMarkdown::test_heading_001", + "tests/test_renderers.py::TestRendererMarkdown::test_html_001", + "tests/test_renderers.py::TestRendererMarkdown::test_images_001", + "tests/test_renderers.py::TestRendererMarkdown::test_inline_001", + "tests/test_renderers.py::TestRendererMarkdown::test_linebreak_001", + "tests/test_renderers.py::TestRendererMarkdown::test_links_001", + "tests/test_renderers.py::TestRendererMarkdown::test_links_002", + "tests/test_renderers.py::TestRendererMarkdown::test_links_003", + "tests/test_renderers.py::TestRendererMarkdown::test_list_001", + "tests/test_renderers.py::TestRendererMarkdown::test_list_002", + "tests/test_renderers.py::TestRendererMarkdown::test_list_003", + "tests/test_renderers.py::TestRendererMarkdown::test_list_004", + "tests/test_renderers.py::TestRendererMarkdown::test_list_005", + "tests/test_renderers.py::TestRendererMarkdown::test_list_006", + "tests/test_renderers.py::TestRendererMarkdown::test_thematic_break_001", + "tests/test_syntax.py::TestSyntax::test_emphasis_001", + "tests/test_syntax.py::TestSyntax::test_image_001", + "tests/test_syntax.py::TestSyntax::test_link_001", + "tests/test_syntax.py::TestSyntax::test_link_002", + "tests/test_syntax.py::TestSyntax::test_link_003", + "tests/test_syntax.py::TestSyntax::test_links_001", + "tests/test_syntax.py::TestSyntax::test_links_002", + "tests/test_syntax.py::TestSyntax::test_max_depth_002", + "tests/test_syntax.py::TestSyntax::test_non_aggressive_emphasis_001", + "tests/test_syntax.py::TestSyntax::test_non_aggressive_emphasis_002", + "tests/test_syntax.py::TestSyntax::test_non_aggressive_emphasis_003", + "tests/test_syntax.py::TestSyntax::test_setext_headings_002" + ] +} diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/tests/grade.py b/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/tests/grade.py new file mode 100644 index 0000000000000000000000000000000000000000..e3b37293830e51a5c5833c93c4705e1ed9364257 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/tests/grade.py @@ -0,0 +1,128 @@ +"""Trusted private pytest panel runner. Installed only in a fresh grader Job.""" + +import hashlib +import importlib.util +import json +import os +import shutil +import stat +import subprocess +from pathlib import Path, PurePosixPath + + +def sha(raw): + return hashlib.sha256(raw).hexdigest() + + +def safe(value): + path = PurePosixPath(value) + if ( + path.is_absolute() + or path.as_posix() != value + or not path.parts + or any(part in {".", "..", ".git"} for part in path.parts) + ): + raise ValueError("Unsafe trusted test path") + return path + + +def restore(worktree, private, manifest): + worktree, private = Path(worktree), Path(private) + captured = {} + for name, expected in manifest["files"].items(): + path = private / safe(name) + info = path.lstat() + raw = path.read_bytes() if stat.S_ISREG(info.st_mode) else b"" + if ( + not stat.S_ISREG(info.st_mode) + or len(raw) != expected["bytes"] + or sha(raw) != expected["sha256"] + or stat.S_IMODE(info.st_mode) != expected["mode"] + ): + raise ValueError("Trusted private test bytes or modes drifted") + captured[name] = (raw, expected["mode"]) + # Capture and verify every private byte before changing the submitted tree. + for name in manifest["directory_roots"]: + destination = worktree / safe(name) + if destination.is_symlink(): + raise ValueError("Submitted test directory is a symlink") + for parent in destination.parents: + if parent == worktree: + break + if parent.is_symlink(): + raise ValueError("Submitted test parent is a symlink") + if destination.exists(): + if not destination.is_dir(): + raise ValueError("Submitted test directory is not a directory") + shutil.rmtree(destination) + for name, (raw, mode) in captured.items(): + destination = worktree / safe(name) + for parent in destination.parents: + if parent == worktree: + break + if parent.is_symlink(): + raise ValueError("Submitted test parent is a symlink") + if destination.is_symlink(): + raise ValueError("Submitted trusted file is a symlink") + destination.parent.mkdir(parents=True, exist_ok=True) + destination.write_bytes(raw) + destination.chmod(mode) + + +def run(worktree, private_root, output, invoke=None): + private_root, output, worktree = Path(private_root), Path(output), Path(worktree) + expected = json.loads((private_root / "expected-panels.json").read_bytes()) + config = json.loads((private_root / "panel-config.json").read_bytes()) + manifest = json.loads((private_root / "trusted-inventory.json").read_bytes()) + restore(worktree, private_root / "trusted", manifest) + output.mkdir(parents=True, exist_ok=True) + for name in ( + "reward.txt", + "pass-to-pass.xml", + "fail-to-pass.xml", + "pytest-evidence.json", + ): + (output / name).unlink(missing_ok=True) + environment = dict(os.environ) + for key in ("PYTEST_ADDOPTS", "PYTEST_DISABLE_PLUGIN_AUTOLOAD", "PYTHONPATH"): + environment.pop(key, None) + commands, native_exit = [], 0 + invoke = invoke or subprocess.run + for group in ("pass-to-pass", "fail-to-pass"): + if ( + not isinstance(expected[group], list) + or not expected[group] + or any( + not isinstance(target, str) or not target for target in expected[group] + ) + ): + raise ValueError("Frozen native pytest selectors are incomplete") + command = [ + *config["official_pytest_argv"], + "--override-ini=addopts=", + "--junitxml=" + str(output / (group + ".xml")), + *expected[group], + ] + result = invoke(command, cwd=worktree, env=environment, check=False) + native_exit = result.returncode + commands.append({"group": group, "argv": command, "exit_code": native_exit}) + if native_exit != 0: + break + (output / "pytest-commands.json").write_text( + json.dumps(commands, sort_keys=True) + "\n" + ) + spec = importlib.util.spec_from_file_location( + "trusted_pytest_result", private_root / "check_pytest.py" + ) + checker = importlib.util.module_from_spec(spec) + spec.loader.exec_module(checker) + result = checker.assess(output, expected, native_exit) + (output / "reward.txt").write_text(str(result["reward"]) + "\n") + (output / "pytest-evidence.json").write_text( + json.dumps(result, sort_keys=True) + "\n" + ) + return result + + +if __name__ == "__main__": + run("/testbed/repo", "/tests", "/logs/verifier") diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/tests/panel-config.json b/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/tests/panel-config.json new file mode 100644 index 0000000000000000000000000000000000000000..fcf9afd120808ef57ca8e15a2ff5adfbb1b9b425 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/tests/panel-config.json @@ -0,0 +1,24 @@ +{ + "dependency_installation_pinned": false, + "official_install_cmds": [ + "python -m pip install -e ." + ], + "official_pytest_argv": [ + "pytest", + "--disable-warnings", + "--color=no", + "--tb=no", + "--verbose" + ], + "official_test_command": "source /opt/miniconda3/bin/activate; conda activate testbed; pytest --disable-warnings --color=no --tb=no --verbose", + "operator_test_runner_prerequisites": [ + "python -m pip install pytest==8.4.2" + ], + "operator_test_runner_reason": "The official profile invokes pytest, but the common tools runtime does not provide it; pinned separately from source-native project requirements.", + "panel_normalization": "Override project addopts only to execute the exact frozen native panels; add JUnit output, preserve official pytest options and all selectors.", + "python_version": "3.10", + "source_bound_test_dependency_cmds": [], + "test_dependency_source_sha256": { + "pyproject.toml": "b2922e3ef89e2918935d38fb3a777bdbc741619942276a75fd21a8dd9faf6b42" + } +} diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/tests/test.sh b/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/tests/test.sh new file mode 100644 index 0000000000000000000000000000000000000000..81b6d0620f05dbd3b54b4e7ea5de04ce3f8a98e2 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/tests/test.sh @@ -0,0 +1,6 @@ +#!/bin/bash +set -Eeuo pipefail +source /opt/miniconda3/bin/activate +conda activate testbed +cd /testbed/repo +exec python -I /tests/grade.py diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/tests/trusted/pyproject.toml b/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/tests/trusted/pyproject.toml new file mode 100644 index 0000000000000000000000000000000000000000..2d95f9b3bd4ee9817157eab051c5277fb0a3846f --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/tests/trusted/pyproject.toml @@ -0,0 +1,69 @@ +[project] +name = "mistune" +description = "A sane and fast Markdown parser with useful plugins and renderers" +authors = [{name = "Hsiaoming Yang", email="me@lepture.com"}] +dependencies = [ + "typing-extensions; python_version<'3.11'", +] +license = {text = "BSD-3-Clause"} +dynamic = ["version"] +requires-python = ">=3.8" +readme = "README.rst" +classifiers = [ + "Development Status :: 4 - Beta", + "Environment :: Console", + "Environment :: Web Environment", + "Intended Audience :: Developers", + "License :: OSI Approved :: BSD License", + "Operating System :: OS Independent", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: Implementation :: CPython", + "Programming Language :: Python :: Implementation :: PyPy", + "Topic :: Text Processing :: Markup", +] + +[project.urls] +Documentation = "https://mistune.lepture.com/" +Source = "https://github.com/lepture/mistune" +Donate = "https://github.com/sponsors/lepture" + +[build-system] +requires = ["setuptools"] +build-backend = "setuptools.build_meta" + +[tool.setuptools.dynamic] +version = {attr = "mistune.__version__"} + +[tool.setuptools.packages.find] +where = ["src"] + +[tool.setuptools.package-data] +mistune = ["py.typed"] + +[tool.ruff] +line-length = 120 + +[tool.pytest.ini_options] +pythonpath = ["src", "."] +testpaths = ["tests"] +filterwarnings = ["error"] + +[tool.coverage.run] +branch = true +source = ["mistune"] + +[tool.coverage.paths] +source = ["src"] + +[tool.coverage.report] +exclude_lines = [ + "pragma: no cover", + "def __repr__", + "raise NotImplementedError", + "@(abc\\.)?abstractmethod", +] diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/tests/trusted/setup.py b/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/tests/trusted/setup.py new file mode 100644 index 0000000000000000000000000000000000000000..af8a0fc50e9db1a27585118393965a8c87e19129 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/tests/trusted/setup.py @@ -0,0 +1,3 @@ +from setuptools import setup + +setup(name="mistune") diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/tests/trusted/tests/__init__.py b/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/tests/trusted/tests/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..b715104d1f96221038f7c9060d66b4bc6a5bdda2 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/tests/trusted/tests/__init__.py @@ -0,0 +1,40 @@ +import re +from abc import abstractmethod +from unittest import TestCase + +from tests import fixtures + + +class BaseTestCase(TestCase): + @classmethod + def load_fixtures(cls, case_file: str) -> None: + def attach_case(n: str, text: str, html: str) -> None: + def method(self: 'BaseTestCase') -> None: + self.assert_case(n, text, html) + + name = 'test_{}'.format(n) + method.__name__ = name + method.__doc__ = 'Run fixture {} - {}'.format(case_file, n) + setattr(cls, name, method) + + for n, text, html in fixtures.load_examples(case_file): + if cls.ignore_case(n): + continue + attach_case(n, text, html) + + @classmethod + def ignore_case(cls, name: str) -> bool: + return False + + @abstractmethod + def parse(self, text: str) -> str: ... + + def assert_case(self, name: str, text: str, html: str) -> None: + result = self.parse(text) + self.assertEqual(result, html) + + +def normalize_html(html: str) -> str: + html = re.sub(r'>\n+', '>', html) + html = re.sub(r'\n+<', '<', html) + return html.strip() diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/tests/trusted/tests/fixtures/__init__.py b/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/tests/trusted/tests/fixtures/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..9a1abe299918fbbac039621a46f85061a7f0c31e --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/tests/trusted/tests/fixtures/__init__.py @@ -0,0 +1,56 @@ +import os +import re +import json +from typing import Any, Iterable, Tuple + +ROOT = os.path.join(os.path.dirname(__file__)) + +EXAMPLE_PATTERN = re.compile( + r'^`{32} example\n([\s\S]*?)' + r'^\.\n([\s\S]*?)' + r'^`{32}$|^#{1,6} *(.*)$', + flags=re.M +) + + +def load_ast(filename: str) -> Any: + with open(os.path.join(ROOT, 'ast', filename)) as f: + return json.load(f) + + +def load_json(filename: str) -> Any: + with open(os.path.join(ROOT, filename)) as f: + return json.load(f) + + +def load_examples(filename: str) -> Iterable[Tuple[str, str, str]]: + if filename.endswith('.json'): + data = load_json(filename) + for item in data: + section = item['section'].lower().replace(' ', '_') + n = '%s_%03d' % (section, item['example']) + yield n, item['markdown'], item['html'] + else: + with open(os.path.join(ROOT, filename), 'rb') as f: + content = f.read() + s = content.decode('utf-8') + yield from parse_examples(s) + + + +def parse_examples(text: str) -> Iterable[Tuple[str, str, str]]: + data = EXAMPLE_PATTERN.findall(text) + + section = None + count = 0 + for md, html, title in data: + if title: + count = 0 + section = title.lower().replace(' ', '_') + + if md and html: + count += 1 + n = '%s_%03d' % (section, count) + md = md.replace(u'\u2192', '\t') + html = html.replace(u'\u2192', '\t') + yield n, md, html diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/tests/trusted/tests/fixtures/abbr.txt b/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/tests/trusted/tests/fixtures/abbr.txt new file mode 100644 index 0000000000000000000000000000000000000000..a87b4f1521511a9071a901311c07372340bb958c --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/tests/trusted/tests/fixtures/abbr.txt @@ -0,0 +1,79 @@ +# Abbreviation + +## abbreviation + +```````````````````````````````` example +HTML +. +

HTML

+```````````````````````````````` + +```````````````````````````````` example +HTML +*[HTML]: Hyper Text Markup Language +. +

HTML

+```````````````````````````````` + +```````````````````````````````` example +The HTML specification is maintained by the W3C. +*[HTML]: Hyper Text Markup Language +*[W3C]: World Wide Web Consortium +. +

The HTML specification is maintained by the W3C.

+```````````````````````````````` + +```````````````````````````````` example +The HTML specification is maintained by the W3C. +*[HTML]: + Hyper Text Markup Language +*[W3C]: + World Wide Web Consortium +. +

The HTML specification is maintained by the W3C.

+```````````````````````````````` + +```````````````````````````````` example +The HTML specification is maintained by the W3C. +*[HTML]: Hyper Text Markup Language +*[W3C]: World Wide Web Consortium +There is more text below this one. +. +

The HTML specification is maintained by the W3C.

+

There is more text below this one.

+```````````````````````````````` + +```````````````````````````````` example +The latest spec of HTML is HTML5. +*[HTML]: Hyper Text Markup Language +. +

The latest spec of HTML is HTML5.

+```````````````````````````````` + +```````````````````````````````` example +HTML should always be spelt with capital letters and not spelt html. +*[HTML]: Hyper Text Markup Language +. +

HTML should always be spelt with capital letters and not spelt html.

+```````````````````````````````` + +```````````````````````````````` example +HTML is an abbreviation but nobody knows what it stands for. +*[HTML]: +. +

HTML is an abbreviation but nobody knows what it stands for.

+```````````````````````````````` + +```````````````````````````````` example +Foo.* looks like a regular expression. +*[Foo.*]: Just foo +. +

Foo.* looks like a regular expression.

+```````````````````````````````` + +```````````````````````````````` example +Untrusted HTML should be escaped. +*[HTML]:

This is some HTML

+. +

Untrusted HTML should be escaped.

+```````````````````````````````` diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/tests/trusted/tests/fixtures/commonmark.json b/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/tests/trusted/tests/fixtures/commonmark.json new file mode 100644 index 0000000000000000000000000000000000000000..d742f941312421f89a3491b7e1d5edd0e44d2207 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/tests/trusted/tests/fixtures/commonmark.json @@ -0,0 +1,5218 @@ +[ + { + "markdown": "\tfoo\tbaz\t\tbim\n", + "html": "
foo\tbaz\t\tbim\n
\n", + "example": 1, + "start_line": 356, + "end_line": 361, + "section": "Tabs" + }, + { + "markdown": " \tfoo\tbaz\t\tbim\n", + "html": "
foo\tbaz\t\tbim\n
\n", + "example": 2, + "start_line": 363, + "end_line": 368, + "section": "Tabs" + }, + { + "markdown": " a\ta\n ὐ\ta\n", + "html": "
a\ta\nὐ\ta\n
\n", + "example": 3, + "start_line": 370, + "end_line": 377, + "section": "Tabs" + }, + { + "markdown": " - foo\n\n\tbar\n", + "html": "
    \n
  • \n

    foo

    \n

    bar

    \n
  • \n
\n", + "example": 4, + "start_line": 383, + "end_line": 394, + "section": "Tabs" + }, + { + "markdown": "- foo\n\n\t\tbar\n", + "html": "
    \n
  • \n

    foo

    \n
      bar\n
    \n
  • \n
\n", + "example": 5, + "start_line": 396, + "end_line": 408, + "section": "Tabs" + }, + { + "markdown": ">\t\tfoo\n", + "html": "
\n
  foo\n
\n
\n", + "example": 6, + "start_line": 419, + "end_line": 426, + "section": "Tabs" + }, + { + "markdown": "-\t\tfoo\n", + "html": "
    \n
  • \n
      foo\n
    \n
  • \n
\n", + "example": 7, + "start_line": 428, + "end_line": 437, + "section": "Tabs" + }, + { + "markdown": " foo\n\tbar\n", + "html": "
foo\nbar\n
\n", + "example": 8, + "start_line": 440, + "end_line": 447, + "section": "Tabs" + }, + { + "markdown": " - foo\n - bar\n\t - baz\n", + "html": "
    \n
  • foo\n
      \n
    • bar\n
        \n
      • baz
      • \n
      \n
    • \n
    \n
  • \n
\n", + "example": 9, + "start_line": 449, + "end_line": 465, + "section": "Tabs" + }, + { + "markdown": "#\tFoo\n", + "html": "

Foo

\n", + "example": 10, + "start_line": 467, + "end_line": 471, + "section": "Tabs" + }, + { + "markdown": "*\t*\t*\t\n", + "html": "
\n", + "example": 11, + "start_line": 473, + "end_line": 477, + "section": "Tabs" + }, + { + "markdown": "\\!\\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\-\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\_\\`\\{\\|\\}\\~\n", + "html": "

!"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~

\n", + "example": 12, + "start_line": 490, + "end_line": 494, + "section": "Backslash escapes" + }, + { + "markdown": "\\\t\\A\\a\\ \\3\\φ\\«\n", + "html": "

\\\t\\A\\a\\ \\3\\φ\\«

\n", + "example": 13, + "start_line": 500, + "end_line": 504, + "section": "Backslash escapes" + }, + { + "markdown": "\\*not emphasized*\n\\
not a tag\n\\[not a link](/foo)\n\\`not code`\n1\\. not a list\n\\* not a list\n\\# not a heading\n\\[foo]: /url \"not a reference\"\n\\ö not a character entity\n", + "html": "

*not emphasized*\n<br/> not a tag\n[not a link](/foo)\n`not code`\n1. not a list\n* not a list\n# not a heading\n[foo]: /url "not a reference"\n&ouml; not a character entity

\n", + "example": 14, + "start_line": 510, + "end_line": 530, + "section": "Backslash escapes" + }, + { + "markdown": "\\\\*emphasis*\n", + "html": "

\\emphasis

\n", + "example": 15, + "start_line": 535, + "end_line": 539, + "section": "Backslash escapes" + }, + { + "markdown": "foo\\\nbar\n", + "html": "

foo
\nbar

\n", + "example": 16, + "start_line": 544, + "end_line": 550, + "section": "Backslash escapes" + }, + { + "markdown": "`` \\[\\` ``\n", + "html": "

\\[\\`

\n", + "example": 17, + "start_line": 556, + "end_line": 560, + "section": "Backslash escapes" + }, + { + "markdown": " \\[\\]\n", + "html": "
\\[\\]\n
\n", + "example": 18, + "start_line": 563, + "end_line": 568, + "section": "Backslash escapes" + }, + { + "markdown": "~~~\n\\[\\]\n~~~\n", + "html": "
\\[\\]\n
\n", + "example": 19, + "start_line": 571, + "end_line": 578, + "section": "Backslash escapes" + }, + { + "markdown": "\n", + "html": "

http://example.com?find=\\*

\n", + "example": 20, + "start_line": 581, + "end_line": 585, + "section": "Backslash escapes" + }, + { + "markdown": "\n", + "html": "\n", + "example": 21, + "start_line": 588, + "end_line": 592, + "section": "Backslash escapes" + }, + { + "markdown": "[foo](/bar\\* \"ti\\*tle\")\n", + "html": "

foo

\n", + "example": 22, + "start_line": 598, + "end_line": 602, + "section": "Backslash escapes" + }, + { + "markdown": "[foo]\n\n[foo]: /bar\\* \"ti\\*tle\"\n", + "html": "

foo

\n", + "example": 23, + "start_line": 605, + "end_line": 611, + "section": "Backslash escapes" + }, + { + "markdown": "``` foo\\+bar\nfoo\n```\n", + "html": "
foo\n
\n", + "example": 24, + "start_line": 614, + "end_line": 621, + "section": "Backslash escapes" + }, + { + "markdown": "  & © Æ Ď\n¾ ℋ ⅆ\n∲ ≧̸\n", + "html": "

  & © Æ Ď\n¾ ℋ ⅆ\n∲ ≧̸

\n", + "example": 25, + "start_line": 650, + "end_line": 658, + "section": "Entity and numeric character references" + }, + { + "markdown": "# Ӓ Ϡ �\n", + "html": "

# Ӓ Ϡ �

\n", + "example": 26, + "start_line": 669, + "end_line": 673, + "section": "Entity and numeric character references" + }, + { + "markdown": "" ആ ಫ\n", + "html": "

" ആ ಫ

\n", + "example": 27, + "start_line": 682, + "end_line": 686, + "section": "Entity and numeric character references" + }, + { + "markdown": "  &x; &#; &#x;\n�\n&#abcdef0;\n&ThisIsNotDefined; &hi?;\n", + "html": "

&nbsp &x; &#; &#x;\n&#87654321;\n&#abcdef0;\n&ThisIsNotDefined; &hi?;

\n", + "example": 28, + "start_line": 691, + "end_line": 701, + "section": "Entity and numeric character references" + }, + { + "markdown": "©\n", + "html": "

&copy

\n", + "example": 29, + "start_line": 708, + "end_line": 712, + "section": "Entity and numeric character references" + }, + { + "markdown": "&MadeUpEntity;\n", + "html": "

&MadeUpEntity;

\n", + "example": 30, + "start_line": 718, + "end_line": 722, + "section": "Entity and numeric character references" + }, + { + "markdown": "\n", + "html": "\n", + "example": 31, + "start_line": 729, + "end_line": 733, + "section": "Entity and numeric character references" + }, + { + "markdown": "[foo](/föö \"föö\")\n", + "html": "

foo

\n", + "example": 32, + "start_line": 736, + "end_line": 740, + "section": "Entity and numeric character references" + }, + { + "markdown": "[foo]\n\n[foo]: /föö \"föö\"\n", + "html": "

foo

\n", + "example": 33, + "start_line": 743, + "end_line": 749, + "section": "Entity and numeric character references" + }, + { + "markdown": "``` föö\nfoo\n```\n", + "html": "
foo\n
\n", + "example": 34, + "start_line": 752, + "end_line": 759, + "section": "Entity and numeric character references" + }, + { + "markdown": "`föö`\n", + "html": "

f&ouml;&ouml;

\n", + "example": 35, + "start_line": 765, + "end_line": 769, + "section": "Entity and numeric character references" + }, + { + "markdown": " föfö\n", + "html": "
f&ouml;f&ouml;\n
\n", + "example": 36, + "start_line": 772, + "end_line": 777, + "section": "Entity and numeric character references" + }, + { + "markdown": "*foo*\n*foo*\n", + "html": "

*foo*\nfoo

\n", + "example": 37, + "start_line": 784, + "end_line": 790, + "section": "Entity and numeric character references" + }, + { + "markdown": "* foo\n\n* foo\n", + "html": "

* foo

\n
    \n
  • foo
  • \n
\n", + "example": 38, + "start_line": 792, + "end_line": 801, + "section": "Entity and numeric character references" + }, + { + "markdown": "foo bar\n", + "html": "

foo\n\nbar

\n", + "example": 39, + "start_line": 803, + "end_line": 809, + "section": "Entity and numeric character references" + }, + { + "markdown": " foo\n", + "html": "

\tfoo

\n", + "example": 40, + "start_line": 811, + "end_line": 815, + "section": "Entity and numeric character references" + }, + { + "markdown": "[a](url "tit")\n", + "html": "

[a](url "tit")

\n", + "example": 41, + "start_line": 818, + "end_line": 822, + "section": "Entity and numeric character references" + }, + { + "markdown": "- `one\n- two`\n", + "html": "
    \n
  • `one
  • \n
  • two`
  • \n
\n", + "example": 42, + "start_line": 841, + "end_line": 849, + "section": "Precedence" + }, + { + "markdown": "***\n---\n___\n", + "html": "
\n
\n
\n", + "example": 43, + "start_line": 880, + "end_line": 888, + "section": "Thematic breaks" + }, + { + "markdown": "+++\n", + "html": "

+++

\n", + "example": 44, + "start_line": 893, + "end_line": 897, + "section": "Thematic breaks" + }, + { + "markdown": "===\n", + "html": "

===

\n", + "example": 45, + "start_line": 900, + "end_line": 904, + "section": "Thematic breaks" + }, + { + "markdown": "--\n**\n__\n", + "html": "

--\n**\n__

\n", + "example": 46, + "start_line": 909, + "end_line": 917, + "section": "Thematic breaks" + }, + { + "markdown": " ***\n ***\n ***\n", + "html": "
\n
\n
\n", + "example": 47, + "start_line": 922, + "end_line": 930, + "section": "Thematic breaks" + }, + { + "markdown": " ***\n", + "html": "
***\n
\n", + "example": 48, + "start_line": 935, + "end_line": 940, + "section": "Thematic breaks" + }, + { + "markdown": "Foo\n ***\n", + "html": "

Foo\n***

\n", + "example": 49, + "start_line": 943, + "end_line": 949, + "section": "Thematic breaks" + }, + { + "markdown": "_____________________________________\n", + "html": "
\n", + "example": 50, + "start_line": 954, + "end_line": 958, + "section": "Thematic breaks" + }, + { + "markdown": " - - -\n", + "html": "
\n", + "example": 51, + "start_line": 963, + "end_line": 967, + "section": "Thematic breaks" + }, + { + "markdown": " ** * ** * ** * **\n", + "html": "
\n", + "example": 52, + "start_line": 970, + "end_line": 974, + "section": "Thematic breaks" + }, + { + "markdown": "- - - -\n", + "html": "
\n", + "example": 53, + "start_line": 977, + "end_line": 981, + "section": "Thematic breaks" + }, + { + "markdown": "- - - - \n", + "html": "
\n", + "example": 54, + "start_line": 986, + "end_line": 990, + "section": "Thematic breaks" + }, + { + "markdown": "_ _ _ _ a\n\na------\n\n---a---\n", + "html": "

_ _ _ _ a

\n

a------

\n

---a---

\n", + "example": 55, + "start_line": 995, + "end_line": 1005, + "section": "Thematic breaks" + }, + { + "markdown": " *-*\n", + "html": "

-

\n", + "example": 56, + "start_line": 1011, + "end_line": 1015, + "section": "Thematic breaks" + }, + { + "markdown": "- foo\n***\n- bar\n", + "html": "
    \n
  • foo
  • \n
\n
\n
    \n
  • bar
  • \n
\n", + "example": 57, + "start_line": 1020, + "end_line": 1032, + "section": "Thematic breaks" + }, + { + "markdown": "Foo\n***\nbar\n", + "html": "

Foo

\n
\n

bar

\n", + "example": 58, + "start_line": 1037, + "end_line": 1045, + "section": "Thematic breaks" + }, + { + "markdown": "Foo\n---\nbar\n", + "html": "

Foo

\n

bar

\n", + "example": 59, + "start_line": 1054, + "end_line": 1061, + "section": "Thematic breaks" + }, + { + "markdown": "* Foo\n* * *\n* Bar\n", + "html": "
    \n
  • Foo
  • \n
\n
\n
    \n
  • Bar
  • \n
\n", + "example": 60, + "start_line": 1067, + "end_line": 1079, + "section": "Thematic breaks" + }, + { + "markdown": "- Foo\n- * * *\n", + "html": "
    \n
  • Foo
  • \n
  • \n
    \n
  • \n
\n", + "example": 61, + "start_line": 1084, + "end_line": 1094, + "section": "Thematic breaks" + }, + { + "markdown": "# foo\n## foo\n### foo\n#### foo\n##### foo\n###### foo\n", + "html": "

foo

\n

foo

\n

foo

\n

foo

\n
foo
\n
foo
\n", + "example": 62, + "start_line": 1113, + "end_line": 1127, + "section": "ATX headings" + }, + { + "markdown": "####### foo\n", + "html": "

####### foo

\n", + "example": 63, + "start_line": 1132, + "end_line": 1136, + "section": "ATX headings" + }, + { + "markdown": "#5 bolt\n\n#hashtag\n", + "html": "

#5 bolt

\n

#hashtag

\n", + "example": 64, + "start_line": 1147, + "end_line": 1154, + "section": "ATX headings" + }, + { + "markdown": "\\## foo\n", + "html": "

## foo

\n", + "example": 65, + "start_line": 1159, + "end_line": 1163, + "section": "ATX headings" + }, + { + "markdown": "# foo *bar* \\*baz\\*\n", + "html": "

foo bar *baz*

\n", + "example": 66, + "start_line": 1168, + "end_line": 1172, + "section": "ATX headings" + }, + { + "markdown": "# foo \n", + "html": "

foo

\n", + "example": 67, + "start_line": 1177, + "end_line": 1181, + "section": "ATX headings" + }, + { + "markdown": " ### foo\n ## foo\n # foo\n", + "html": "

foo

\n

foo

\n

foo

\n", + "example": 68, + "start_line": 1186, + "end_line": 1194, + "section": "ATX headings" + }, + { + "markdown": " # foo\n", + "html": "
# foo\n
\n", + "example": 69, + "start_line": 1199, + "end_line": 1204, + "section": "ATX headings" + }, + { + "markdown": "foo\n # bar\n", + "html": "

foo\n# bar

\n", + "example": 70, + "start_line": 1207, + "end_line": 1213, + "section": "ATX headings" + }, + { + "markdown": "## foo ##\n ### bar ###\n", + "html": "

foo

\n

bar

\n", + "example": 71, + "start_line": 1218, + "end_line": 1224, + "section": "ATX headings" + }, + { + "markdown": "# foo ##################################\n##### foo ##\n", + "html": "

foo

\n
foo
\n", + "example": 72, + "start_line": 1229, + "end_line": 1235, + "section": "ATX headings" + }, + { + "markdown": "### foo ### \n", + "html": "

foo

\n", + "example": 73, + "start_line": 1240, + "end_line": 1244, + "section": "ATX headings" + }, + { + "markdown": "### foo ### b\n", + "html": "

foo ### b

\n", + "example": 74, + "start_line": 1251, + "end_line": 1255, + "section": "ATX headings" + }, + { + "markdown": "# foo#\n", + "html": "

foo#

\n", + "example": 75, + "start_line": 1260, + "end_line": 1264, + "section": "ATX headings" + }, + { + "markdown": "### foo \\###\n## foo #\\##\n# foo \\#\n", + "html": "

foo ###

\n

foo ###

\n

foo #

\n", + "example": 76, + "start_line": 1270, + "end_line": 1278, + "section": "ATX headings" + }, + { + "markdown": "****\n## foo\n****\n", + "html": "
\n

foo

\n
\n", + "example": 77, + "start_line": 1284, + "end_line": 1292, + "section": "ATX headings" + }, + { + "markdown": "Foo bar\n# baz\nBar foo\n", + "html": "

Foo bar

\n

baz

\n

Bar foo

\n", + "example": 78, + "start_line": 1295, + "end_line": 1303, + "section": "ATX headings" + }, + { + "markdown": "## \n#\n### ###\n", + "html": "

\n

\n

\n", + "example": 79, + "start_line": 1308, + "end_line": 1316, + "section": "ATX headings" + }, + { + "markdown": "Foo *bar*\n=========\n\nFoo *bar*\n---------\n", + "html": "

Foo bar

\n

Foo bar

\n", + "example": 80, + "start_line": 1351, + "end_line": 1360, + "section": "Setext headings" + }, + { + "markdown": "Foo *bar\nbaz*\n====\n", + "html": "

Foo bar\nbaz

\n", + "example": 81, + "start_line": 1365, + "end_line": 1372, + "section": "Setext headings" + }, + { + "markdown": " Foo *bar\nbaz*\t\n====\n", + "html": "

Foo bar\nbaz

\n", + "example": 82, + "start_line": 1379, + "end_line": 1386, + "section": "Setext headings" + }, + { + "markdown": "Foo\n-------------------------\n\nFoo\n=\n", + "html": "

Foo

\n

Foo

\n", + "example": 83, + "start_line": 1391, + "end_line": 1400, + "section": "Setext headings" + }, + { + "markdown": " Foo\n---\n\n Foo\n-----\n\n Foo\n ===\n", + "html": "

Foo

\n

Foo

\n

Foo

\n", + "example": 84, + "start_line": 1406, + "end_line": 1419, + "section": "Setext headings" + }, + { + "markdown": " Foo\n ---\n\n Foo\n---\n", + "html": "
Foo\n---\n\nFoo\n
\n
\n", + "example": 85, + "start_line": 1424, + "end_line": 1437, + "section": "Setext headings" + }, + { + "markdown": "Foo\n ---- \n", + "html": "

Foo

\n", + "example": 86, + "start_line": 1443, + "end_line": 1448, + "section": "Setext headings" + }, + { + "markdown": "Foo\n ---\n", + "html": "

Foo\n---

\n", + "example": 87, + "start_line": 1453, + "end_line": 1459, + "section": "Setext headings" + }, + { + "markdown": "Foo\n= =\n\nFoo\n--- -\n", + "html": "

Foo\n= =

\n

Foo

\n
\n", + "example": 88, + "start_line": 1464, + "end_line": 1475, + "section": "Setext headings" + }, + { + "markdown": "Foo \n-----\n", + "html": "

Foo

\n", + "example": 89, + "start_line": 1480, + "end_line": 1485, + "section": "Setext headings" + }, + { + "markdown": "Foo\\\n----\n", + "html": "

Foo\\

\n", + "example": 90, + "start_line": 1490, + "end_line": 1495, + "section": "Setext headings" + }, + { + "markdown": "`Foo\n----\n`\n\n\n", + "html": "

`Foo

\n

`

\n

<a title="a lot

\n

of dashes"/>

\n", + "example": 91, + "start_line": 1501, + "end_line": 1514, + "section": "Setext headings" + }, + { + "markdown": "> Foo\n---\n", + "html": "
\n

Foo

\n
\n
\n", + "example": 92, + "start_line": 1520, + "end_line": 1528, + "section": "Setext headings" + }, + { + "markdown": "> foo\nbar\n===\n", + "html": "
\n

foo\nbar\n===

\n
\n", + "example": 93, + "start_line": 1531, + "end_line": 1541, + "section": "Setext headings" + }, + { + "markdown": "- Foo\n---\n", + "html": "
    \n
  • Foo
  • \n
\n
\n", + "example": 94, + "start_line": 1544, + "end_line": 1552, + "section": "Setext headings" + }, + { + "markdown": "Foo\nBar\n---\n", + "html": "

Foo\nBar

\n", + "example": 95, + "start_line": 1559, + "end_line": 1566, + "section": "Setext headings" + }, + { + "markdown": "---\nFoo\n---\nBar\n---\nBaz\n", + "html": "
\n

Foo

\n

Bar

\n

Baz

\n", + "example": 96, + "start_line": 1572, + "end_line": 1584, + "section": "Setext headings" + }, + { + "markdown": "\n====\n", + "html": "

====

\n", + "example": 97, + "start_line": 1589, + "end_line": 1594, + "section": "Setext headings" + }, + { + "markdown": "---\n---\n", + "html": "
\n
\n", + "example": 98, + "start_line": 1601, + "end_line": 1607, + "section": "Setext headings" + }, + { + "markdown": "- foo\n-----\n", + "html": "
    \n
  • foo
  • \n
\n
\n", + "example": 99, + "start_line": 1610, + "end_line": 1618, + "section": "Setext headings" + }, + { + "markdown": " foo\n---\n", + "html": "
foo\n
\n
\n", + "example": 100, + "start_line": 1621, + "end_line": 1628, + "section": "Setext headings" + }, + { + "markdown": "> foo\n-----\n", + "html": "
\n

foo

\n
\n
\n", + "example": 101, + "start_line": 1631, + "end_line": 1639, + "section": "Setext headings" + }, + { + "markdown": "\\> foo\n------\n", + "html": "

> foo

\n", + "example": 102, + "start_line": 1645, + "end_line": 1650, + "section": "Setext headings" + }, + { + "markdown": "Foo\n\nbar\n---\nbaz\n", + "html": "

Foo

\n

bar

\n

baz

\n", + "example": 103, + "start_line": 1676, + "end_line": 1686, + "section": "Setext headings" + }, + { + "markdown": "Foo\nbar\n\n---\n\nbaz\n", + "html": "

Foo\nbar

\n
\n

baz

\n", + "example": 104, + "start_line": 1692, + "end_line": 1704, + "section": "Setext headings" + }, + { + "markdown": "Foo\nbar\n* * *\nbaz\n", + "html": "

Foo\nbar

\n
\n

baz

\n", + "example": 105, + "start_line": 1710, + "end_line": 1720, + "section": "Setext headings" + }, + { + "markdown": "Foo\nbar\n\\---\nbaz\n", + "html": "

Foo\nbar\n---\nbaz

\n", + "example": 106, + "start_line": 1725, + "end_line": 1735, + "section": "Setext headings" + }, + { + "markdown": " a simple\n indented code block\n", + "html": "
a simple\n  indented code block\n
\n", + "example": 107, + "start_line": 1753, + "end_line": 1760, + "section": "Indented code blocks" + }, + { + "markdown": " - foo\n\n bar\n", + "html": "
    \n
  • \n

    foo

    \n

    bar

    \n
  • \n
\n", + "example": 108, + "start_line": 1767, + "end_line": 1778, + "section": "Indented code blocks" + }, + { + "markdown": "1. foo\n\n - bar\n", + "html": "
    \n
  1. \n

    foo

    \n
      \n
    • bar
    • \n
    \n
  2. \n
\n", + "example": 109, + "start_line": 1781, + "end_line": 1794, + "section": "Indented code blocks" + }, + { + "markdown": "
\n *hi*\n\n - one\n", + "html": "
<a/>\n*hi*\n\n- one\n
\n", + "example": 110, + "start_line": 1801, + "end_line": 1812, + "section": "Indented code blocks" + }, + { + "markdown": " chunk1\n\n chunk2\n \n \n \n chunk3\n", + "html": "
chunk1\n\nchunk2\n\n\n\nchunk3\n
\n", + "example": 111, + "start_line": 1817, + "end_line": 1834, + "section": "Indented code blocks" + }, + { + "markdown": " chunk1\n \n chunk2\n", + "html": "
chunk1\n  \n  chunk2\n
\n", + "example": 112, + "start_line": 1840, + "end_line": 1849, + "section": "Indented code blocks" + }, + { + "markdown": "Foo\n bar\n\n", + "html": "

Foo\nbar

\n", + "example": 113, + "start_line": 1855, + "end_line": 1862, + "section": "Indented code blocks" + }, + { + "markdown": " foo\nbar\n", + "html": "
foo\n
\n

bar

\n", + "example": 114, + "start_line": 1869, + "end_line": 1876, + "section": "Indented code blocks" + }, + { + "markdown": "# Heading\n foo\nHeading\n------\n foo\n----\n", + "html": "

Heading

\n
foo\n
\n

Heading

\n
foo\n
\n
\n", + "example": 115, + "start_line": 1882, + "end_line": 1897, + "section": "Indented code blocks" + }, + { + "markdown": " foo\n bar\n", + "html": "
    foo\nbar\n
\n", + "example": 116, + "start_line": 1902, + "end_line": 1909, + "section": "Indented code blocks" + }, + { + "markdown": "\n \n foo\n \n\n", + "html": "
foo\n
\n", + "example": 117, + "start_line": 1915, + "end_line": 1924, + "section": "Indented code blocks" + }, + { + "markdown": " foo \n", + "html": "
foo  \n
\n", + "example": 118, + "start_line": 1929, + "end_line": 1934, + "section": "Indented code blocks" + }, + { + "markdown": "```\n<\n >\n```\n", + "html": "
<\n >\n
\n", + "example": 119, + "start_line": 1984, + "end_line": 1993, + "section": "Fenced code blocks" + }, + { + "markdown": "~~~\n<\n >\n~~~\n", + "html": "
<\n >\n
\n", + "example": 120, + "start_line": 1998, + "end_line": 2007, + "section": "Fenced code blocks" + }, + { + "markdown": "``\nfoo\n``\n", + "html": "

foo

\n", + "example": 121, + "start_line": 2011, + "end_line": 2017, + "section": "Fenced code blocks" + }, + { + "markdown": "```\naaa\n~~~\n```\n", + "html": "
aaa\n~~~\n
\n", + "example": 122, + "start_line": 2022, + "end_line": 2031, + "section": "Fenced code blocks" + }, + { + "markdown": "~~~\naaa\n```\n~~~\n", + "html": "
aaa\n```\n
\n", + "example": 123, + "start_line": 2034, + "end_line": 2043, + "section": "Fenced code blocks" + }, + { + "markdown": "````\naaa\n```\n``````\n", + "html": "
aaa\n```\n
\n", + "example": 124, + "start_line": 2048, + "end_line": 2057, + "section": "Fenced code blocks" + }, + { + "markdown": "~~~~\naaa\n~~~\n~~~~\n", + "html": "
aaa\n~~~\n
\n", + "example": 125, + "start_line": 2060, + "end_line": 2069, + "section": "Fenced code blocks" + }, + { + "markdown": "```\n", + "html": "
\n", + "example": 126, + "start_line": 2075, + "end_line": 2079, + "section": "Fenced code blocks" + }, + { + "markdown": "`````\n\n```\naaa\n", + "html": "
\n```\naaa\n
\n", + "example": 127, + "start_line": 2082, + "end_line": 2092, + "section": "Fenced code blocks" + }, + { + "markdown": "> ```\n> aaa\n\nbbb\n", + "html": "
\n
aaa\n
\n
\n

bbb

\n", + "example": 128, + "start_line": 2095, + "end_line": 2106, + "section": "Fenced code blocks" + }, + { + "markdown": "```\n\n \n```\n", + "html": "
\n  \n
\n", + "example": 129, + "start_line": 2111, + "end_line": 2120, + "section": "Fenced code blocks" + }, + { + "markdown": "```\n```\n", + "html": "
\n", + "example": 130, + "start_line": 2125, + "end_line": 2130, + "section": "Fenced code blocks" + }, + { + "markdown": " ```\n aaa\naaa\n```\n", + "html": "
aaa\naaa\n
\n", + "example": 131, + "start_line": 2137, + "end_line": 2146, + "section": "Fenced code blocks" + }, + { + "markdown": " ```\naaa\n aaa\naaa\n ```\n", + "html": "
aaa\naaa\naaa\n
\n", + "example": 132, + "start_line": 2149, + "end_line": 2160, + "section": "Fenced code blocks" + }, + { + "markdown": " ```\n aaa\n aaa\n aaa\n ```\n", + "html": "
aaa\n aaa\naaa\n
\n", + "example": 133, + "start_line": 2163, + "end_line": 2174, + "section": "Fenced code blocks" + }, + { + "markdown": " ```\n aaa\n ```\n", + "html": "
```\naaa\n```\n
\n", + "example": 134, + "start_line": 2179, + "end_line": 2188, + "section": "Fenced code blocks" + }, + { + "markdown": "```\naaa\n ```\n", + "html": "
aaa\n
\n", + "example": 135, + "start_line": 2194, + "end_line": 2201, + "section": "Fenced code blocks" + }, + { + "markdown": " ```\naaa\n ```\n", + "html": "
aaa\n
\n", + "example": 136, + "start_line": 2204, + "end_line": 2211, + "section": "Fenced code blocks" + }, + { + "markdown": "```\naaa\n ```\n", + "html": "
aaa\n    ```\n
\n", + "example": 137, + "start_line": 2216, + "end_line": 2224, + "section": "Fenced code blocks" + }, + { + "markdown": "``` ```\naaa\n", + "html": "

\naaa

\n", + "example": 138, + "start_line": 2230, + "end_line": 2236, + "section": "Fenced code blocks" + }, + { + "markdown": "~~~~~~\naaa\n~~~ ~~\n", + "html": "
aaa\n~~~ ~~\n
\n", + "example": 139, + "start_line": 2239, + "end_line": 2247, + "section": "Fenced code blocks" + }, + { + "markdown": "foo\n```\nbar\n```\nbaz\n", + "html": "

foo

\n
bar\n
\n

baz

\n", + "example": 140, + "start_line": 2253, + "end_line": 2264, + "section": "Fenced code blocks" + }, + { + "markdown": "foo\n---\n~~~\nbar\n~~~\n# baz\n", + "html": "

foo

\n
bar\n
\n

baz

\n", + "example": 141, + "start_line": 2270, + "end_line": 2282, + "section": "Fenced code blocks" + }, + { + "markdown": "```ruby\ndef foo(x)\n return 3\nend\n```\n", + "html": "
def foo(x)\n  return 3\nend\n
\n", + "example": 142, + "start_line": 2292, + "end_line": 2303, + "section": "Fenced code blocks" + }, + { + "markdown": "~~~~ ruby startline=3 $%@#$\ndef foo(x)\n return 3\nend\n~~~~~~~\n", + "html": "
def foo(x)\n  return 3\nend\n
\n", + "example": 143, + "start_line": 2306, + "end_line": 2317, + "section": "Fenced code blocks" + }, + { + "markdown": "````;\n````\n", + "html": "
\n", + "example": 144, + "start_line": 2320, + "end_line": 2325, + "section": "Fenced code blocks" + }, + { + "markdown": "``` aa ```\nfoo\n", + "html": "

aa\nfoo

\n", + "example": 145, + "start_line": 2330, + "end_line": 2336, + "section": "Fenced code blocks" + }, + { + "markdown": "~~~ aa ``` ~~~\nfoo\n~~~\n", + "html": "
foo\n
\n", + "example": 146, + "start_line": 2341, + "end_line": 2348, + "section": "Fenced code blocks" + }, + { + "markdown": "```\n``` aaa\n```\n", + "html": "
``` aaa\n
\n", + "example": 147, + "start_line": 2353, + "end_line": 2360, + "section": "Fenced code blocks" + }, + { + "markdown": "

\n
\n**Hello**,\n\n_world_.\n
\n
\n", + "html": "
\n
\n**Hello**,\n

world.\n

\n
\n", + "example": 148, + "start_line": 2432, + "end_line": 2447, + "section": "HTML blocks" + }, + { + "markdown": "\n \n \n \n
\n hi\n
\n\nokay.\n", + "html": "\n \n \n \n
\n hi\n
\n

okay.

\n", + "example": 149, + "start_line": 2461, + "end_line": 2480, + "section": "HTML blocks" + }, + { + "markdown": "
\n*foo*\n", + "example": 151, + "start_line": 2496, + "end_line": 2502, + "section": "HTML blocks" + }, + { + "markdown": "
\n\n*Markdown*\n\n
\n", + "html": "
\n

Markdown

\n
\n", + "example": 152, + "start_line": 2507, + "end_line": 2517, + "section": "HTML blocks" + }, + { + "markdown": "
\n
\n", + "html": "
\n
\n", + "example": 153, + "start_line": 2523, + "end_line": 2531, + "section": "HTML blocks" + }, + { + "markdown": "
\n
\n", + "html": "
\n
\n", + "example": 154, + "start_line": 2534, + "end_line": 2542, + "section": "HTML blocks" + }, + { + "markdown": "
\n*foo*\n\n*bar*\n", + "html": "
\n*foo*\n

bar

\n", + "example": 155, + "start_line": 2546, + "end_line": 2555, + "section": "HTML blocks" + }, + { + "markdown": "
\n", + "html": "\n", + "example": 159, + "start_line": 2595, + "end_line": 2599, + "section": "HTML blocks" + }, + { + "markdown": "
\nfoo\n
\n", + "html": "
\nfoo\n
\n", + "example": 160, + "start_line": 2602, + "end_line": 2610, + "section": "HTML blocks" + }, + { + "markdown": "
\n``` c\nint x = 33;\n```\n", + "html": "
\n``` c\nint x = 33;\n```\n", + "example": 161, + "start_line": 2619, + "end_line": 2629, + "section": "HTML blocks" + }, + { + "markdown": "\n*bar*\n\n", + "html": "\n*bar*\n\n", + "example": 162, + "start_line": 2636, + "end_line": 2644, + "section": "HTML blocks" + }, + { + "markdown": "\n*bar*\n\n", + "html": "\n*bar*\n\n", + "example": 163, + "start_line": 2649, + "end_line": 2657, + "section": "HTML blocks" + }, + { + "markdown": "\n*bar*\n\n", + "html": "\n*bar*\n\n", + "example": 164, + "start_line": 2660, + "end_line": 2668, + "section": "HTML blocks" + }, + { + "markdown": "\n*bar*\n", + "html": "\n*bar*\n", + "example": 165, + "start_line": 2671, + "end_line": 2677, + "section": "HTML blocks" + }, + { + "markdown": "\n*foo*\n\n", + "html": "\n*foo*\n\n", + "example": 166, + "start_line": 2686, + "end_line": 2694, + "section": "HTML blocks" + }, + { + "markdown": "\n\n*foo*\n\n\n", + "html": "\n

foo

\n
\n", + "example": 167, + "start_line": 2701, + "end_line": 2711, + "section": "HTML blocks" + }, + { + "markdown": "*foo*\n", + "html": "

foo

\n", + "example": 168, + "start_line": 2719, + "end_line": 2723, + "section": "HTML blocks" + }, + { + "markdown": "
\nimport Text.HTML.TagSoup\n\nmain :: IO ()\nmain = print $ parseTags tags\n
\nokay\n", + "html": "
\nimport Text.HTML.TagSoup\n\nmain :: IO ()\nmain = print $ parseTags tags\n
\n

okay

\n", + "example": 169, + "start_line": 2735, + "end_line": 2751, + "section": "HTML blocks" + }, + { + "markdown": "\nokay\n", + "html": "\n

okay

\n", + "example": 170, + "start_line": 2756, + "end_line": 2770, + "section": "HTML blocks" + }, + { + "markdown": "\n", + "html": "\n", + "example": 171, + "start_line": 2775, + "end_line": 2791, + "section": "HTML blocks" + }, + { + "markdown": "\nh1 {color:red;}\n\np {color:blue;}\n\nokay\n", + "html": "\nh1 {color:red;}\n\np {color:blue;}\n\n

okay

\n", + "example": 172, + "start_line": 2795, + "end_line": 2811, + "section": "HTML blocks" + }, + { + "markdown": "\n\nfoo\n", + "html": "\n\nfoo\n", + "example": 173, + "start_line": 2818, + "end_line": 2828, + "section": "HTML blocks" + }, + { + "markdown": ">
\n> foo\n\nbar\n", + "html": "
\n
\nfoo\n
\n

bar

\n", + "example": 174, + "start_line": 2831, + "end_line": 2842, + "section": "HTML blocks" + }, + { + "markdown": "-
\n- foo\n", + "html": "
    \n
  • \n
    \n
  • \n
  • foo
  • \n
\n", + "example": 175, + "start_line": 2845, + "end_line": 2855, + "section": "HTML blocks" + }, + { + "markdown": "\n*foo*\n", + "html": "\n

foo

\n", + "example": 176, + "start_line": 2860, + "end_line": 2866, + "section": "HTML blocks" + }, + { + "markdown": "*bar*\n*baz*\n", + "html": "*bar*\n

baz

\n", + "example": 177, + "start_line": 2869, + "end_line": 2875, + "section": "HTML blocks" + }, + { + "markdown": "1. *bar*\n", + "html": "1. *bar*\n", + "example": 178, + "start_line": 2881, + "end_line": 2889, + "section": "HTML blocks" + }, + { + "markdown": "\nokay\n", + "html": "\n

okay

\n", + "example": 179, + "start_line": 2894, + "end_line": 2906, + "section": "HTML blocks" + }, + { + "markdown": "';\n\n?>\nokay\n", + "html": "';\n\n?>\n

okay

\n", + "example": 180, + "start_line": 2912, + "end_line": 2926, + "section": "HTML blocks" + }, + { + "markdown": "\n", + "html": "\n", + "example": 181, + "start_line": 2931, + "end_line": 2935, + "section": "HTML blocks" + }, + { + "markdown": "\nokay\n", + "html": "\n

okay

\n", + "example": 182, + "start_line": 2940, + "end_line": 2968, + "section": "HTML blocks" + }, + { + "markdown": " \n\n \n", + "html": " \n
<!-- foo -->\n
\n", + "example": 183, + "start_line": 2974, + "end_line": 2982, + "section": "HTML blocks" + }, + { + "markdown": "
\n\n
\n", + "html": "
\n
<div>\n
\n", + "example": 184, + "start_line": 2985, + "end_line": 2993, + "section": "HTML blocks" + }, + { + "markdown": "Foo\n
\nbar\n
\n", + "html": "

Foo

\n
\nbar\n
\n", + "example": 185, + "start_line": 2999, + "end_line": 3009, + "section": "HTML blocks" + }, + { + "markdown": "
\nbar\n
\n*foo*\n", + "html": "
\nbar\n
\n*foo*\n", + "example": 186, + "start_line": 3016, + "end_line": 3026, + "section": "HTML blocks" + }, + { + "markdown": "Foo\n\nbaz\n", + "html": "

Foo\n\nbaz

\n", + "example": 187, + "start_line": 3031, + "end_line": 3039, + "section": "HTML blocks" + }, + { + "markdown": "
\n\n*Emphasized* text.\n\n
\n", + "html": "
\n

Emphasized text.

\n
\n", + "example": 188, + "start_line": 3072, + "end_line": 3082, + "section": "HTML blocks" + }, + { + "markdown": "
\n*Emphasized* text.\n
\n", + "html": "
\n*Emphasized* text.\n
\n", + "example": 189, + "start_line": 3085, + "end_line": 3093, + "section": "HTML blocks" + }, + { + "markdown": "\n\n\n\n\n\n\n\n
\nHi\n
\n", + "html": "\n\n\n\n
\nHi\n
\n", + "example": 190, + "start_line": 3107, + "end_line": 3127, + "section": "HTML blocks" + }, + { + "markdown": "\n\n \n\n \n\n \n\n
\n Hi\n
\n", + "html": "\n \n
<td>\n  Hi\n</td>\n
\n \n
\n", + "example": 191, + "start_line": 3134, + "end_line": 3155, + "section": "HTML blocks" + }, + { + "markdown": "[foo]: /url \"title\"\n\n[foo]\n", + "html": "

foo

\n", + "example": 192, + "start_line": 3183, + "end_line": 3189, + "section": "Link reference definitions" + }, + { + "markdown": " [foo]: \n /url \n 'the title' \n\n[foo]\n", + "html": "

foo

\n", + "example": 193, + "start_line": 3192, + "end_line": 3200, + "section": "Link reference definitions" + }, + { + "markdown": "[Foo*bar\\]]:my_(url) 'title (with parens)'\n\n[Foo*bar\\]]\n", + "html": "

Foo*bar]

\n", + "example": 194, + "start_line": 3203, + "end_line": 3209, + "section": "Link reference definitions" + }, + { + "markdown": "[Foo bar]:\n\n'title'\n\n[Foo bar]\n", + "html": "

Foo bar

\n", + "example": 195, + "start_line": 3212, + "end_line": 3220, + "section": "Link reference definitions" + }, + { + "markdown": "[foo]: /url '\ntitle\nline1\nline2\n'\n\n[foo]\n", + "html": "

foo

\n", + "example": 196, + "start_line": 3225, + "end_line": 3239, + "section": "Link reference definitions" + }, + { + "markdown": "[foo]: /url 'title\n\nwith blank line'\n\n[foo]\n", + "html": "

[foo]: /url 'title

\n

with blank line'

\n

[foo]

\n", + "example": 197, + "start_line": 3244, + "end_line": 3254, + "section": "Link reference definitions" + }, + { + "markdown": "[foo]:\n/url\n\n[foo]\n", + "html": "

foo

\n", + "example": 198, + "start_line": 3259, + "end_line": 3266, + "section": "Link reference definitions" + }, + { + "markdown": "[foo]:\n\n[foo]\n", + "html": "

[foo]:

\n

[foo]

\n", + "example": 199, + "start_line": 3271, + "end_line": 3278, + "section": "Link reference definitions" + }, + { + "markdown": "[foo]: <>\n\n[foo]\n", + "html": "

foo

\n", + "example": 200, + "start_line": 3283, + "end_line": 3289, + "section": "Link reference definitions" + }, + { + "markdown": "[foo]: (baz)\n\n[foo]\n", + "html": "

[foo]: (baz)

\n

[foo]

\n", + "example": 201, + "start_line": 3294, + "end_line": 3301, + "section": "Link reference definitions" + }, + { + "markdown": "[foo]: /url\\bar\\*baz \"foo\\\"bar\\baz\"\n\n[foo]\n", + "html": "

foo

\n", + "example": 202, + "start_line": 3307, + "end_line": 3313, + "section": "Link reference definitions" + }, + { + "markdown": "[foo]\n\n[foo]: url\n", + "html": "

foo

\n", + "example": 203, + "start_line": 3318, + "end_line": 3324, + "section": "Link reference definitions" + }, + { + "markdown": "[foo]\n\n[foo]: first\n[foo]: second\n", + "html": "

foo

\n", + "example": 204, + "start_line": 3330, + "end_line": 3337, + "section": "Link reference definitions" + }, + { + "markdown": "[FOO]: /url\n\n[Foo]\n", + "html": "

Foo

\n", + "example": 205, + "start_line": 3343, + "end_line": 3349, + "section": "Link reference definitions" + }, + { + "markdown": "[ΑΓΩ]: /φου\n\n[αγω]\n", + "html": "

αγω

\n", + "example": 206, + "start_line": 3352, + "end_line": 3358, + "section": "Link reference definitions" + }, + { + "markdown": "[foo]: /url\n", + "html": "", + "example": 207, + "start_line": 3367, + "end_line": 3370, + "section": "Link reference definitions" + }, + { + "markdown": "[\nfoo\n]: /url\nbar\n", + "html": "

bar

\n", + "example": 208, + "start_line": 3375, + "end_line": 3382, + "section": "Link reference definitions" + }, + { + "markdown": "[foo]: /url \"title\" ok\n", + "html": "

[foo]: /url "title" ok

\n", + "example": 209, + "start_line": 3388, + "end_line": 3392, + "section": "Link reference definitions" + }, + { + "markdown": "[foo]: /url\n\"title\" ok\n", + "html": "

"title" ok

\n", + "example": 210, + "start_line": 3397, + "end_line": 3402, + "section": "Link reference definitions" + }, + { + "markdown": " [foo]: /url \"title\"\n\n[foo]\n", + "html": "
[foo]: /url "title"\n
\n

[foo]

\n", + "example": 211, + "start_line": 3408, + "end_line": 3416, + "section": "Link reference definitions" + }, + { + "markdown": "```\n[foo]: /url\n```\n\n[foo]\n", + "html": "
[foo]: /url\n
\n

[foo]

\n", + "example": 212, + "start_line": 3422, + "end_line": 3432, + "section": "Link reference definitions" + }, + { + "markdown": "Foo\n[bar]: /baz\n\n[bar]\n", + "html": "

Foo\n[bar]: /baz

\n

[bar]

\n", + "example": 213, + "start_line": 3437, + "end_line": 3446, + "section": "Link reference definitions" + }, + { + "markdown": "# [Foo]\n[foo]: /url\n> bar\n", + "html": "

Foo

\n
\n

bar

\n
\n", + "example": 214, + "start_line": 3452, + "end_line": 3461, + "section": "Link reference definitions" + }, + { + "markdown": "[foo]: /url\nbar\n===\n[foo]\n", + "html": "

bar

\n

foo

\n", + "example": 215, + "start_line": 3463, + "end_line": 3471, + "section": "Link reference definitions" + }, + { + "markdown": "[foo]: /url\n===\n[foo]\n", + "html": "

===\nfoo

\n", + "example": 216, + "start_line": 3473, + "end_line": 3480, + "section": "Link reference definitions" + }, + { + "markdown": "[foo]: /foo-url \"foo\"\n[bar]: /bar-url\n \"bar\"\n[baz]: /baz-url\n\n[foo],\n[bar],\n[baz]\n", + "html": "

foo,\nbar,\nbaz

\n", + "example": 217, + "start_line": 3486, + "end_line": 3499, + "section": "Link reference definitions" + }, + { + "markdown": "[foo]\n\n> [foo]: /url\n", + "html": "

foo

\n
\n
\n", + "example": 218, + "start_line": 3507, + "end_line": 3515, + "section": "Link reference definitions" + }, + { + "markdown": "aaa\n\nbbb\n", + "html": "

aaa

\n

bbb

\n", + "example": 219, + "start_line": 3529, + "end_line": 3536, + "section": "Paragraphs" + }, + { + "markdown": "aaa\nbbb\n\nccc\nddd\n", + "html": "

aaa\nbbb

\n

ccc\nddd

\n", + "example": 220, + "start_line": 3541, + "end_line": 3552, + "section": "Paragraphs" + }, + { + "markdown": "aaa\n\n\nbbb\n", + "html": "

aaa

\n

bbb

\n", + "example": 221, + "start_line": 3557, + "end_line": 3565, + "section": "Paragraphs" + }, + { + "markdown": " aaa\n bbb\n", + "html": "

aaa\nbbb

\n", + "example": 222, + "start_line": 3570, + "end_line": 3576, + "section": "Paragraphs" + }, + { + "markdown": "aaa\n bbb\n ccc\n", + "html": "

aaa\nbbb\nccc

\n", + "example": 223, + "start_line": 3582, + "end_line": 3590, + "section": "Paragraphs" + }, + { + "markdown": " aaa\nbbb\n", + "html": "

aaa\nbbb

\n", + "example": 224, + "start_line": 3596, + "end_line": 3602, + "section": "Paragraphs" + }, + { + "markdown": " aaa\nbbb\n", + "html": "
aaa\n
\n

bbb

\n", + "example": 225, + "start_line": 3605, + "end_line": 3612, + "section": "Paragraphs" + }, + { + "markdown": "aaa \nbbb \n", + "html": "

aaa
\nbbb

\n", + "example": 226, + "start_line": 3619, + "end_line": 3625, + "section": "Paragraphs" + }, + { + "markdown": " \n\naaa\n \n\n# aaa\n\n \n", + "html": "

aaa

\n

aaa

\n", + "example": 227, + "start_line": 3636, + "end_line": 3648, + "section": "Blank lines" + }, + { + "markdown": "> # Foo\n> bar\n> baz\n", + "html": "
\n

Foo

\n

bar\nbaz

\n
\n", + "example": 228, + "start_line": 3704, + "end_line": 3714, + "section": "Block quotes" + }, + { + "markdown": "># Foo\n>bar\n> baz\n", + "html": "
\n

Foo

\n

bar\nbaz

\n
\n", + "example": 229, + "start_line": 3719, + "end_line": 3729, + "section": "Block quotes" + }, + { + "markdown": " > # Foo\n > bar\n > baz\n", + "html": "
\n

Foo

\n

bar\nbaz

\n
\n", + "example": 230, + "start_line": 3734, + "end_line": 3744, + "section": "Block quotes" + }, + { + "markdown": " > # Foo\n > bar\n > baz\n", + "html": "
> # Foo\n> bar\n> baz\n
\n", + "example": 231, + "start_line": 3749, + "end_line": 3758, + "section": "Block quotes" + }, + { + "markdown": "> # Foo\n> bar\nbaz\n", + "html": "
\n

Foo

\n

bar\nbaz

\n
\n", + "example": 232, + "start_line": 3764, + "end_line": 3774, + "section": "Block quotes" + }, + { + "markdown": "> bar\nbaz\n> foo\n", + "html": "
\n

bar\nbaz\nfoo

\n
\n", + "example": 233, + "start_line": 3780, + "end_line": 3790, + "section": "Block quotes" + }, + { + "markdown": "> foo\n---\n", + "html": "
\n

foo

\n
\n
\n", + "example": 234, + "start_line": 3804, + "end_line": 3812, + "section": "Block quotes" + }, + { + "markdown": "> - foo\n- bar\n", + "html": "
\n
    \n
  • foo
  • \n
\n
\n
    \n
  • bar
  • \n
\n", + "example": 235, + "start_line": 3824, + "end_line": 3836, + "section": "Block quotes" + }, + { + "markdown": "> foo\n bar\n", + "html": "
\n
foo\n
\n
\n
bar\n
\n", + "example": 236, + "start_line": 3842, + "end_line": 3852, + "section": "Block quotes" + }, + { + "markdown": "> ```\nfoo\n```\n", + "html": "
\n
\n
\n

foo

\n
\n", + "example": 237, + "start_line": 3855, + "end_line": 3865, + "section": "Block quotes" + }, + { + "markdown": "> foo\n - bar\n", + "html": "
\n

foo\n- bar

\n
\n", + "example": 238, + "start_line": 3871, + "end_line": 3879, + "section": "Block quotes" + }, + { + "markdown": ">\n", + "html": "
\n
\n", + "example": 239, + "start_line": 3895, + "end_line": 3900, + "section": "Block quotes" + }, + { + "markdown": ">\n> \n> \n", + "html": "
\n
\n", + "example": 240, + "start_line": 3903, + "end_line": 3910, + "section": "Block quotes" + }, + { + "markdown": ">\n> foo\n> \n", + "html": "
\n

foo

\n
\n", + "example": 241, + "start_line": 3915, + "end_line": 3923, + "section": "Block quotes" + }, + { + "markdown": "> foo\n\n> bar\n", + "html": "
\n

foo

\n
\n
\n

bar

\n
\n", + "example": 242, + "start_line": 3928, + "end_line": 3939, + "section": "Block quotes" + }, + { + "markdown": "> foo\n> bar\n", + "html": "
\n

foo\nbar

\n
\n", + "example": 243, + "start_line": 3950, + "end_line": 3958, + "section": "Block quotes" + }, + { + "markdown": "> foo\n>\n> bar\n", + "html": "
\n

foo

\n

bar

\n
\n", + "example": 244, + "start_line": 3963, + "end_line": 3972, + "section": "Block quotes" + }, + { + "markdown": "foo\n> bar\n", + "html": "

foo

\n
\n

bar

\n
\n", + "example": 245, + "start_line": 3977, + "end_line": 3985, + "section": "Block quotes" + }, + { + "markdown": "> aaa\n***\n> bbb\n", + "html": "
\n

aaa

\n
\n
\n
\n

bbb

\n
\n", + "example": 246, + "start_line": 3991, + "end_line": 4003, + "section": "Block quotes" + }, + { + "markdown": "> bar\nbaz\n", + "html": "
\n

bar\nbaz

\n
\n", + "example": 247, + "start_line": 4009, + "end_line": 4017, + "section": "Block quotes" + }, + { + "markdown": "> bar\n\nbaz\n", + "html": "
\n

bar

\n
\n

baz

\n", + "example": 248, + "start_line": 4020, + "end_line": 4029, + "section": "Block quotes" + }, + { + "markdown": "> bar\n>\nbaz\n", + "html": "
\n

bar

\n
\n

baz

\n", + "example": 249, + "start_line": 4032, + "end_line": 4041, + "section": "Block quotes" + }, + { + "markdown": "> > > foo\nbar\n", + "html": "
\n
\n
\n

foo\nbar

\n
\n
\n
\n", + "example": 250, + "start_line": 4048, + "end_line": 4060, + "section": "Block quotes" + }, + { + "markdown": ">>> foo\n> bar\n>>baz\n", + "html": "
\n
\n
\n

foo\nbar\nbaz

\n
\n
\n
\n", + "example": 251, + "start_line": 4063, + "end_line": 4077, + "section": "Block quotes" + }, + { + "markdown": "> code\n\n> not code\n", + "html": "
\n
code\n
\n
\n
\n

not code

\n
\n", + "example": 252, + "start_line": 4085, + "end_line": 4097, + "section": "Block quotes" + }, + { + "markdown": "A paragraph\nwith two lines.\n\n indented code\n\n> A block quote.\n", + "html": "

A paragraph\nwith two lines.

\n
indented code\n
\n
\n

A block quote.

\n
\n", + "example": 253, + "start_line": 4139, + "end_line": 4154, + "section": "List items" + }, + { + "markdown": "1. A paragraph\n with two lines.\n\n indented code\n\n > A block quote.\n", + "html": "
    \n
  1. \n

    A paragraph\nwith two lines.

    \n
    indented code\n
    \n
    \n

    A block quote.

    \n
    \n
  2. \n
\n", + "example": 254, + "start_line": 4161, + "end_line": 4180, + "section": "List items" + }, + { + "markdown": "- one\n\n two\n", + "html": "
    \n
  • one
  • \n
\n

two

\n", + "example": 255, + "start_line": 4194, + "end_line": 4203, + "section": "List items" + }, + { + "markdown": "- one\n\n two\n", + "html": "
    \n
  • \n

    one

    \n

    two

    \n
  • \n
\n", + "example": 256, + "start_line": 4206, + "end_line": 4217, + "section": "List items" + }, + { + "markdown": " - one\n\n two\n", + "html": "
    \n
  • one
  • \n
\n
 two\n
\n", + "example": 257, + "start_line": 4220, + "end_line": 4230, + "section": "List items" + }, + { + "markdown": " - one\n\n two\n", + "html": "
    \n
  • \n

    one

    \n

    two

    \n
  • \n
\n", + "example": 258, + "start_line": 4233, + "end_line": 4244, + "section": "List items" + }, + { + "markdown": " > > 1. one\n>>\n>> two\n", + "html": "
\n
\n
    \n
  1. \n

    one

    \n

    two

    \n
  2. \n
\n
\n
\n", + "example": 259, + "start_line": 4255, + "end_line": 4270, + "section": "List items" + }, + { + "markdown": ">>- one\n>>\n > > two\n", + "html": "
\n
\n
    \n
  • one
  • \n
\n

two

\n
\n
\n", + "example": 260, + "start_line": 4282, + "end_line": 4295, + "section": "List items" + }, + { + "markdown": "-one\n\n2.two\n", + "html": "

-one

\n

2.two

\n", + "example": 261, + "start_line": 4301, + "end_line": 4308, + "section": "List items" + }, + { + "markdown": "- foo\n\n\n bar\n", + "html": "
    \n
  • \n

    foo

    \n

    bar

    \n
  • \n
\n", + "example": 262, + "start_line": 4314, + "end_line": 4326, + "section": "List items" + }, + { + "markdown": "1. foo\n\n ```\n bar\n ```\n\n baz\n\n > bam\n", + "html": "
    \n
  1. \n

    foo

    \n
    bar\n
    \n

    baz

    \n
    \n

    bam

    \n
    \n
  2. \n
\n", + "example": 263, + "start_line": 4331, + "end_line": 4353, + "section": "List items" + }, + { + "markdown": "- Foo\n\n bar\n\n\n baz\n", + "html": "
    \n
  • \n

    Foo

    \n
    bar\n\n\nbaz\n
    \n
  • \n
\n", + "example": 264, + "start_line": 4359, + "end_line": 4377, + "section": "List items" + }, + { + "markdown": "123456789. ok\n", + "html": "
    \n
  1. ok
  2. \n
\n", + "example": 265, + "start_line": 4381, + "end_line": 4387, + "section": "List items" + }, + { + "markdown": "1234567890. not ok\n", + "html": "

1234567890. not ok

\n", + "example": 266, + "start_line": 4390, + "end_line": 4394, + "section": "List items" + }, + { + "markdown": "0. ok\n", + "html": "
    \n
  1. ok
  2. \n
\n", + "example": 267, + "start_line": 4399, + "end_line": 4405, + "section": "List items" + }, + { + "markdown": "003. ok\n", + "html": "
    \n
  1. ok
  2. \n
\n", + "example": 268, + "start_line": 4408, + "end_line": 4414, + "section": "List items" + }, + { + "markdown": "-1. not ok\n", + "html": "

-1. not ok

\n", + "example": 269, + "start_line": 4419, + "end_line": 4423, + "section": "List items" + }, + { + "markdown": "- foo\n\n bar\n", + "html": "
    \n
  • \n

    foo

    \n
    bar\n
    \n
  • \n
\n", + "example": 270, + "start_line": 4442, + "end_line": 4454, + "section": "List items" + }, + { + "markdown": " 10. foo\n\n bar\n", + "html": "
    \n
  1. \n

    foo

    \n
    bar\n
    \n
  2. \n
\n", + "example": 271, + "start_line": 4459, + "end_line": 4471, + "section": "List items" + }, + { + "markdown": " indented code\n\nparagraph\n\n more code\n", + "html": "
indented code\n
\n

paragraph

\n
more code\n
\n", + "example": 272, + "start_line": 4478, + "end_line": 4490, + "section": "List items" + }, + { + "markdown": "1. indented code\n\n paragraph\n\n more code\n", + "html": "
    \n
  1. \n
    indented code\n
    \n

    paragraph

    \n
    more code\n
    \n
  2. \n
\n", + "example": 273, + "start_line": 4493, + "end_line": 4509, + "section": "List items" + }, + { + "markdown": "1. indented code\n\n paragraph\n\n more code\n", + "html": "
    \n
  1. \n
     indented code\n
    \n

    paragraph

    \n
    more code\n
    \n
  2. \n
\n", + "example": 274, + "start_line": 4515, + "end_line": 4531, + "section": "List items" + }, + { + "markdown": " foo\n\nbar\n", + "html": "

foo

\n

bar

\n", + "example": 275, + "start_line": 4542, + "end_line": 4549, + "section": "List items" + }, + { + "markdown": "- foo\n\n bar\n", + "html": "
    \n
  • foo
  • \n
\n

bar

\n", + "example": 276, + "start_line": 4552, + "end_line": 4561, + "section": "List items" + }, + { + "markdown": "- foo\n\n bar\n", + "html": "
    \n
  • \n

    foo

    \n

    bar

    \n
  • \n
\n", + "example": 277, + "start_line": 4569, + "end_line": 4580, + "section": "List items" + }, + { + "markdown": "-\n foo\n-\n ```\n bar\n ```\n-\n baz\n", + "html": "
    \n
  • foo
  • \n
  • \n
    bar\n
    \n
  • \n
  • \n
    baz\n
    \n
  • \n
\n", + "example": 278, + "start_line": 4596, + "end_line": 4617, + "section": "List items" + }, + { + "markdown": "- \n foo\n", + "html": "
    \n
  • foo
  • \n
\n", + "example": 279, + "start_line": 4622, + "end_line": 4629, + "section": "List items" + }, + { + "markdown": "-\n\n foo\n", + "html": "
    \n
  • \n
\n

foo

\n", + "example": 280, + "start_line": 4636, + "end_line": 4645, + "section": "List items" + }, + { + "markdown": "- foo\n-\n- bar\n", + "html": "
    \n
  • foo
  • \n
  • \n
  • bar
  • \n
\n", + "example": 281, + "start_line": 4650, + "end_line": 4660, + "section": "List items" + }, + { + "markdown": "- foo\n- \n- bar\n", + "html": "
    \n
  • foo
  • \n
  • \n
  • bar
  • \n
\n", + "example": 282, + "start_line": 4665, + "end_line": 4675, + "section": "List items" + }, + { + "markdown": "1. foo\n2.\n3. bar\n", + "html": "
    \n
  1. foo
  2. \n
  3. \n
  4. bar
  5. \n
\n", + "example": 283, + "start_line": 4680, + "end_line": 4690, + "section": "List items" + }, + { + "markdown": "*\n", + "html": "
    \n
  • \n
\n", + "example": 284, + "start_line": 4695, + "end_line": 4701, + "section": "List items" + }, + { + "markdown": "foo\n*\n\nfoo\n1.\n", + "html": "

foo\n*

\n

foo\n1.

\n", + "example": 285, + "start_line": 4705, + "end_line": 4716, + "section": "List items" + }, + { + "markdown": " 1. A paragraph\n with two lines.\n\n indented code\n\n > A block quote.\n", + "html": "
    \n
  1. \n

    A paragraph\nwith two lines.

    \n
    indented code\n
    \n
    \n

    A block quote.

    \n
    \n
  2. \n
\n", + "example": 286, + "start_line": 4727, + "end_line": 4746, + "section": "List items" + }, + { + "markdown": " 1. A paragraph\n with two lines.\n\n indented code\n\n > A block quote.\n", + "html": "
    \n
  1. \n

    A paragraph\nwith two lines.

    \n
    indented code\n
    \n
    \n

    A block quote.

    \n
    \n
  2. \n
\n", + "example": 287, + "start_line": 4751, + "end_line": 4770, + "section": "List items" + }, + { + "markdown": " 1. A paragraph\n with two lines.\n\n indented code\n\n > A block quote.\n", + "html": "
    \n
  1. \n

    A paragraph\nwith two lines.

    \n
    indented code\n
    \n
    \n

    A block quote.

    \n
    \n
  2. \n
\n", + "example": 288, + "start_line": 4775, + "end_line": 4794, + "section": "List items" + }, + { + "markdown": " 1. A paragraph\n with two lines.\n\n indented code\n\n > A block quote.\n", + "html": "
1.  A paragraph\n    with two lines.\n\n        indented code\n\n    > A block quote.\n
\n", + "example": 289, + "start_line": 4799, + "end_line": 4814, + "section": "List items" + }, + { + "markdown": " 1. A paragraph\nwith two lines.\n\n indented code\n\n > A block quote.\n", + "html": "
    \n
  1. \n

    A paragraph\nwith two lines.

    \n
    indented code\n
    \n
    \n

    A block quote.

    \n
    \n
  2. \n
\n", + "example": 290, + "start_line": 4829, + "end_line": 4848, + "section": "List items" + }, + { + "markdown": " 1. A paragraph\n with two lines.\n", + "html": "
    \n
  1. A paragraph\nwith two lines.
  2. \n
\n", + "example": 291, + "start_line": 4853, + "end_line": 4861, + "section": "List items" + }, + { + "markdown": "> 1. > Blockquote\ncontinued here.\n", + "html": "
\n
    \n
  1. \n
    \n

    Blockquote\ncontinued here.

    \n
    \n
  2. \n
\n
\n", + "example": 292, + "start_line": 4866, + "end_line": 4880, + "section": "List items" + }, + { + "markdown": "> 1. > Blockquote\n> continued here.\n", + "html": "
\n
    \n
  1. \n
    \n

    Blockquote\ncontinued here.

    \n
    \n
  2. \n
\n
\n", + "example": 293, + "start_line": 4883, + "end_line": 4897, + "section": "List items" + }, + { + "markdown": "- foo\n - bar\n - baz\n - boo\n", + "html": "
    \n
  • foo\n
      \n
    • bar\n
        \n
      • baz\n
          \n
        • boo
        • \n
        \n
      • \n
      \n
    • \n
    \n
  • \n
\n", + "example": 294, + "start_line": 4911, + "end_line": 4932, + "section": "List items" + }, + { + "markdown": "- foo\n - bar\n - baz\n - boo\n", + "html": "
    \n
  • foo
  • \n
  • bar
  • \n
  • baz
  • \n
  • boo
  • \n
\n", + "example": 295, + "start_line": 4937, + "end_line": 4949, + "section": "List items" + }, + { + "markdown": "10) foo\n - bar\n", + "html": "
    \n
  1. foo\n
      \n
    • bar
    • \n
    \n
  2. \n
\n", + "example": 296, + "start_line": 4954, + "end_line": 4965, + "section": "List items" + }, + { + "markdown": "10) foo\n - bar\n", + "html": "
    \n
  1. foo
  2. \n
\n
    \n
  • bar
  • \n
\n", + "example": 297, + "start_line": 4970, + "end_line": 4980, + "section": "List items" + }, + { + "markdown": "- - foo\n", + "html": "
    \n
  • \n
      \n
    • foo
    • \n
    \n
  • \n
\n", + "example": 298, + "start_line": 4985, + "end_line": 4995, + "section": "List items" + }, + { + "markdown": "1. - 2. foo\n", + "html": "
    \n
  1. \n
      \n
    • \n
        \n
      1. foo
      2. \n
      \n
    • \n
    \n
  2. \n
\n", + "example": 299, + "start_line": 4998, + "end_line": 5012, + "section": "List items" + }, + { + "markdown": "- # Foo\n- Bar\n ---\n baz\n", + "html": "
    \n
  • \n

    Foo

    \n
  • \n
  • \n

    Bar

    \nbaz
  • \n
\n", + "example": 300, + "start_line": 5017, + "end_line": 5031, + "section": "List items" + }, + { + "markdown": "- foo\n- bar\n+ baz\n", + "html": "
    \n
  • foo
  • \n
  • bar
  • \n
\n
    \n
  • baz
  • \n
\n", + "example": 301, + "start_line": 5253, + "end_line": 5265, + "section": "Lists" + }, + { + "markdown": "1. foo\n2. bar\n3) baz\n", + "html": "
    \n
  1. foo
  2. \n
  3. bar
  4. \n
\n
    \n
  1. baz
  2. \n
\n", + "example": 302, + "start_line": 5268, + "end_line": 5280, + "section": "Lists" + }, + { + "markdown": "Foo\n- bar\n- baz\n", + "html": "

Foo

\n
    \n
  • bar
  • \n
  • baz
  • \n
\n", + "example": 303, + "start_line": 5287, + "end_line": 5297, + "section": "Lists" + }, + { + "markdown": "The number of windows in my house is\n14. The number of doors is 6.\n", + "html": "

The number of windows in my house is\n14. The number of doors is 6.

\n", + "example": 304, + "start_line": 5364, + "end_line": 5370, + "section": "Lists" + }, + { + "markdown": "The number of windows in my house is\n1. The number of doors is 6.\n", + "html": "

The number of windows in my house is

\n
    \n
  1. The number of doors is 6.
  2. \n
\n", + "example": 305, + "start_line": 5374, + "end_line": 5382, + "section": "Lists" + }, + { + "markdown": "- foo\n\n- bar\n\n\n- baz\n", + "html": "
    \n
  • \n

    foo

    \n
  • \n
  • \n

    bar

    \n
  • \n
  • \n

    baz

    \n
  • \n
\n", + "example": 306, + "start_line": 5388, + "end_line": 5407, + "section": "Lists" + }, + { + "markdown": "- foo\n - bar\n - baz\n\n\n bim\n", + "html": "
    \n
  • foo\n
      \n
    • bar\n
        \n
      • \n

        baz

        \n

        bim

        \n
      • \n
      \n
    • \n
    \n
  • \n
\n", + "example": 307, + "start_line": 5409, + "end_line": 5431, + "section": "Lists" + }, + { + "markdown": "- foo\n- bar\n\n\n\n- baz\n- bim\n", + "html": "
    \n
  • foo
  • \n
  • bar
  • \n
\n\n
    \n
  • baz
  • \n
  • bim
  • \n
\n", + "example": 308, + "start_line": 5439, + "end_line": 5457, + "section": "Lists" + }, + { + "markdown": "- foo\n\n notcode\n\n- foo\n\n\n\n code\n", + "html": "
    \n
  • \n

    foo

    \n

    notcode

    \n
  • \n
  • \n

    foo

    \n
  • \n
\n\n
code\n
\n", + "example": 309, + "start_line": 5460, + "end_line": 5483, + "section": "Lists" + }, + { + "markdown": "- a\n - b\n - c\n - d\n - e\n - f\n- g\n", + "html": "
    \n
  • a
  • \n
  • b
  • \n
  • c
  • \n
  • d
  • \n
  • e
  • \n
  • f
  • \n
  • g
  • \n
\n", + "example": 310, + "start_line": 5491, + "end_line": 5509, + "section": "Lists" + }, + { + "markdown": "1. a\n\n 2. b\n\n 3. c\n", + "html": "
    \n
  1. \n

    a

    \n
  2. \n
  3. \n

    b

    \n
  4. \n
  5. \n

    c

    \n
  6. \n
\n", + "example": 311, + "start_line": 5512, + "end_line": 5530, + "section": "Lists" + }, + { + "markdown": "- a\n - b\n - c\n - d\n - e\n", + "html": "
    \n
  • a
  • \n
  • b
  • \n
  • c
  • \n
  • d\n- e
  • \n
\n", + "example": 312, + "start_line": 5536, + "end_line": 5550, + "section": "Lists" + }, + { + "markdown": "1. a\n\n 2. b\n\n 3. c\n", + "html": "
    \n
  1. \n

    a

    \n
  2. \n
  3. \n

    b

    \n
  4. \n
\n
3. c\n
\n", + "example": 313, + "start_line": 5556, + "end_line": 5573, + "section": "Lists" + }, + { + "markdown": "- a\n- b\n\n- c\n", + "html": "
    \n
  • \n

    a

    \n
  • \n
  • \n

    b

    \n
  • \n
  • \n

    c

    \n
  • \n
\n", + "example": 314, + "start_line": 5579, + "end_line": 5596, + "section": "Lists" + }, + { + "markdown": "* a\n*\n\n* c\n", + "html": "
    \n
  • \n

    a

    \n
  • \n
  • \n
  • \n

    c

    \n
  • \n
\n", + "example": 315, + "start_line": 5601, + "end_line": 5616, + "section": "Lists" + }, + { + "markdown": "- a\n- b\n\n c\n- d\n", + "html": "
    \n
  • \n

    a

    \n
  • \n
  • \n

    b

    \n

    c

    \n
  • \n
  • \n

    d

    \n
  • \n
\n", + "example": 316, + "start_line": 5623, + "end_line": 5642, + "section": "Lists" + }, + { + "markdown": "- a\n- b\n\n [ref]: /url\n- d\n", + "html": "
    \n
  • \n

    a

    \n
  • \n
  • \n

    b

    \n
  • \n
  • \n

    d

    \n
  • \n
\n", + "example": 317, + "start_line": 5645, + "end_line": 5663, + "section": "Lists" + }, + { + "markdown": "- a\n- ```\n b\n\n\n ```\n- c\n", + "html": "
    \n
  • a
  • \n
  • \n
    b\n\n\n
    \n
  • \n
  • c
  • \n
\n", + "example": 318, + "start_line": 5668, + "end_line": 5687, + "section": "Lists" + }, + { + "markdown": "- a\n - b\n\n c\n- d\n", + "html": "
    \n
  • a\n
      \n
    • \n

      b

      \n

      c

      \n
    • \n
    \n
  • \n
  • d
  • \n
\n", + "example": 319, + "start_line": 5694, + "end_line": 5712, + "section": "Lists" + }, + { + "markdown": "* a\n > b\n >\n* c\n", + "html": "
    \n
  • a\n
    \n

    b

    \n
    \n
  • \n
  • c
  • \n
\n", + "example": 320, + "start_line": 5718, + "end_line": 5732, + "section": "Lists" + }, + { + "markdown": "- a\n > b\n ```\n c\n ```\n- d\n", + "html": "
    \n
  • a\n
    \n

    b

    \n
    \n
    c\n
    \n
  • \n
  • d
  • \n
\n", + "example": 321, + "start_line": 5738, + "end_line": 5756, + "section": "Lists" + }, + { + "markdown": "- a\n", + "html": "
    \n
  • a
  • \n
\n", + "example": 322, + "start_line": 5761, + "end_line": 5767, + "section": "Lists" + }, + { + "markdown": "- a\n - b\n", + "html": "
    \n
  • a\n
      \n
    • b
    • \n
    \n
  • \n
\n", + "example": 323, + "start_line": 5770, + "end_line": 5781, + "section": "Lists" + }, + { + "markdown": "1. ```\n foo\n ```\n\n bar\n", + "html": "
    \n
  1. \n
    foo\n
    \n

    bar

    \n
  2. \n
\n", + "example": 324, + "start_line": 5787, + "end_line": 5801, + "section": "Lists" + }, + { + "markdown": "* foo\n * bar\n\n baz\n", + "html": "
    \n
  • \n

    foo

    \n
      \n
    • bar
    • \n
    \n

    baz

    \n
  • \n
\n", + "example": 325, + "start_line": 5806, + "end_line": 5821, + "section": "Lists" + }, + { + "markdown": "- a\n - b\n - c\n\n- d\n - e\n - f\n", + "html": "
    \n
  • \n

    a

    \n
      \n
    • b
    • \n
    • c
    • \n
    \n
  • \n
  • \n

    d

    \n
      \n
    • e
    • \n
    • f
    • \n
    \n
  • \n
\n", + "example": 326, + "start_line": 5824, + "end_line": 5849, + "section": "Lists" + }, + { + "markdown": "`hi`lo`\n", + "html": "

hilo`

\n", + "example": 327, + "start_line": 5858, + "end_line": 5862, + "section": "Inlines" + }, + { + "markdown": "`foo`\n", + "html": "

foo

\n", + "example": 328, + "start_line": 5890, + "end_line": 5894, + "section": "Code spans" + }, + { + "markdown": "`` foo ` bar ``\n", + "html": "

foo ` bar

\n", + "example": 329, + "start_line": 5901, + "end_line": 5905, + "section": "Code spans" + }, + { + "markdown": "` `` `\n", + "html": "

``

\n", + "example": 330, + "start_line": 5911, + "end_line": 5915, + "section": "Code spans" + }, + { + "markdown": "` `` `\n", + "html": "

``

\n", + "example": 331, + "start_line": 5919, + "end_line": 5923, + "section": "Code spans" + }, + { + "markdown": "` a`\n", + "html": "

a

\n", + "example": 332, + "start_line": 5928, + "end_line": 5932, + "section": "Code spans" + }, + { + "markdown": "` b `\n", + "html": "

 b 

\n", + "example": 333, + "start_line": 5937, + "end_line": 5941, + "section": "Code spans" + }, + { + "markdown": "` `\n` `\n", + "html": "

 \n

\n", + "example": 334, + "start_line": 5945, + "end_line": 5951, + "section": "Code spans" + }, + { + "markdown": "``\nfoo\nbar \nbaz\n``\n", + "html": "

foo bar baz

\n", + "example": 335, + "start_line": 5956, + "end_line": 5964, + "section": "Code spans" + }, + { + "markdown": "``\nfoo \n``\n", + "html": "

foo

\n", + "example": 336, + "start_line": 5966, + "end_line": 5972, + "section": "Code spans" + }, + { + "markdown": "`foo bar \nbaz`\n", + "html": "

foo bar baz

\n", + "example": 337, + "start_line": 5977, + "end_line": 5982, + "section": "Code spans" + }, + { + "markdown": "`foo\\`bar`\n", + "html": "

foo\\bar`

\n", + "example": 338, + "start_line": 5994, + "end_line": 5998, + "section": "Code spans" + }, + { + "markdown": "``foo`bar``\n", + "html": "

foo`bar

\n", + "example": 339, + "start_line": 6005, + "end_line": 6009, + "section": "Code spans" + }, + { + "markdown": "` foo `` bar `\n", + "html": "

foo `` bar

\n", + "example": 340, + "start_line": 6011, + "end_line": 6015, + "section": "Code spans" + }, + { + "markdown": "*foo`*`\n", + "html": "

*foo*

\n", + "example": 341, + "start_line": 6023, + "end_line": 6027, + "section": "Code spans" + }, + { + "markdown": "[not a `link](/foo`)\n", + "html": "

[not a link](/foo)

\n", + "example": 342, + "start_line": 6032, + "end_line": 6036, + "section": "Code spans" + }, + { + "markdown": "``\n", + "html": "

<a href="">`

\n", + "example": 343, + "start_line": 6042, + "end_line": 6046, + "section": "Code spans" + }, + { + "markdown": "
`\n", + "html": "

`

\n", + "example": 344, + "start_line": 6051, + "end_line": 6055, + "section": "Code spans" + }, + { + "markdown": "``\n", + "html": "

<http://foo.bar.baz>`

\n", + "example": 345, + "start_line": 6060, + "end_line": 6064, + "section": "Code spans" + }, + { + "markdown": "`\n", + "html": "

http://foo.bar.`baz`

\n", + "example": 346, + "start_line": 6069, + "end_line": 6073, + "section": "Code spans" + }, + { + "markdown": "```foo``\n", + "html": "

```foo``

\n", + "example": 347, + "start_line": 6079, + "end_line": 6083, + "section": "Code spans" + }, + { + "markdown": "`foo\n", + "html": "

`foo

\n", + "example": 348, + "start_line": 6086, + "end_line": 6090, + "section": "Code spans" + }, + { + "markdown": "`foo``bar``\n", + "html": "

`foobar

\n", + "example": 349, + "start_line": 6095, + "end_line": 6099, + "section": "Code spans" + }, + { + "markdown": "*foo bar*\n", + "html": "

foo bar

\n", + "example": 350, + "start_line": 6312, + "end_line": 6316, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "a * foo bar*\n", + "html": "

a * foo bar*

\n", + "example": 351, + "start_line": 6322, + "end_line": 6326, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "a*\"foo\"*\n", + "html": "

a*"foo"*

\n", + "example": 352, + "start_line": 6333, + "end_line": 6337, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "* a *\n", + "html": "

* a *

\n", + "example": 353, + "start_line": 6342, + "end_line": 6346, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "foo*bar*\n", + "html": "

foobar

\n", + "example": 354, + "start_line": 6351, + "end_line": 6355, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "5*6*78\n", + "html": "

5678

\n", + "example": 355, + "start_line": 6358, + "end_line": 6362, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "_foo bar_\n", + "html": "

foo bar

\n", + "example": 356, + "start_line": 6367, + "end_line": 6371, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "_ foo bar_\n", + "html": "

_ foo bar_

\n", + "example": 357, + "start_line": 6377, + "end_line": 6381, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "a_\"foo\"_\n", + "html": "

a_"foo"_

\n", + "example": 358, + "start_line": 6387, + "end_line": 6391, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "foo_bar_\n", + "html": "

foo_bar_

\n", + "example": 359, + "start_line": 6396, + "end_line": 6400, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "5_6_78\n", + "html": "

5_6_78

\n", + "example": 360, + "start_line": 6403, + "end_line": 6407, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "пристаням_стремятся_\n", + "html": "

пристаням_стремятся_

\n", + "example": 361, + "start_line": 6410, + "end_line": 6414, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "aa_\"bb\"_cc\n", + "html": "

aa_"bb"_cc

\n", + "example": 362, + "start_line": 6420, + "end_line": 6424, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "foo-_(bar)_\n", + "html": "

foo-(bar)

\n", + "example": 363, + "start_line": 6431, + "end_line": 6435, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "_foo*\n", + "html": "

_foo*

\n", + "example": 364, + "start_line": 6443, + "end_line": 6447, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*foo bar *\n", + "html": "

*foo bar *

\n", + "example": 365, + "start_line": 6453, + "end_line": 6457, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*foo bar\n*\n", + "html": "

*foo bar\n*

\n", + "example": 366, + "start_line": 6462, + "end_line": 6468, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*(*foo)\n", + "html": "

*(*foo)

\n", + "example": 367, + "start_line": 6475, + "end_line": 6479, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*(*foo*)*\n", + "html": "

(foo)

\n", + "example": 368, + "start_line": 6485, + "end_line": 6489, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*foo*bar\n", + "html": "

foobar

\n", + "example": 369, + "start_line": 6494, + "end_line": 6498, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "_foo bar _\n", + "html": "

_foo bar _

\n", + "example": 370, + "start_line": 6507, + "end_line": 6511, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "_(_foo)\n", + "html": "

_(_foo)

\n", + "example": 371, + "start_line": 6517, + "end_line": 6521, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "_(_foo_)_\n", + "html": "

(foo)

\n", + "example": 372, + "start_line": 6526, + "end_line": 6530, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "_foo_bar\n", + "html": "

_foo_bar

\n", + "example": 373, + "start_line": 6535, + "end_line": 6539, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "_пристаням_стремятся\n", + "html": "

_пристаням_стремятся

\n", + "example": 374, + "start_line": 6542, + "end_line": 6546, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "_foo_bar_baz_\n", + "html": "

foo_bar_baz

\n", + "example": 375, + "start_line": 6549, + "end_line": 6553, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "_(bar)_.\n", + "html": "

(bar).

\n", + "example": 376, + "start_line": 6560, + "end_line": 6564, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "**foo bar**\n", + "html": "

foo bar

\n", + "example": 377, + "start_line": 6569, + "end_line": 6573, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "** foo bar**\n", + "html": "

** foo bar**

\n", + "example": 378, + "start_line": 6579, + "end_line": 6583, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "a**\"foo\"**\n", + "html": "

a**"foo"**

\n", + "example": 379, + "start_line": 6590, + "end_line": 6594, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "foo**bar**\n", + "html": "

foobar

\n", + "example": 380, + "start_line": 6599, + "end_line": 6603, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "__foo bar__\n", + "html": "

foo bar

\n", + "example": 381, + "start_line": 6608, + "end_line": 6612, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "__ foo bar__\n", + "html": "

__ foo bar__

\n", + "example": 382, + "start_line": 6618, + "end_line": 6622, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "__\nfoo bar__\n", + "html": "

__\nfoo bar__

\n", + "example": 383, + "start_line": 6626, + "end_line": 6632, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "a__\"foo\"__\n", + "html": "

a__"foo"__

\n", + "example": 384, + "start_line": 6638, + "end_line": 6642, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "foo__bar__\n", + "html": "

foo__bar__

\n", + "example": 385, + "start_line": 6647, + "end_line": 6651, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "5__6__78\n", + "html": "

5__6__78

\n", + "example": 386, + "start_line": 6654, + "end_line": 6658, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "пристаням__стремятся__\n", + "html": "

пристаням__стремятся__

\n", + "example": 387, + "start_line": 6661, + "end_line": 6665, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "__foo, __bar__, baz__\n", + "html": "

foo, bar, baz

\n", + "example": 388, + "start_line": 6668, + "end_line": 6672, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "foo-__(bar)__\n", + "html": "

foo-(bar)

\n", + "example": 389, + "start_line": 6679, + "end_line": 6683, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "**foo bar **\n", + "html": "

**foo bar **

\n", + "example": 390, + "start_line": 6692, + "end_line": 6696, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "**(**foo)\n", + "html": "

**(**foo)

\n", + "example": 391, + "start_line": 6705, + "end_line": 6709, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*(**foo**)*\n", + "html": "

(foo)

\n", + "example": 392, + "start_line": 6715, + "end_line": 6719, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "**Gomphocarpus (*Gomphocarpus physocarpus*, syn.\n*Asclepias physocarpa*)**\n", + "html": "

Gomphocarpus (Gomphocarpus physocarpus, syn.\nAsclepias physocarpa)

\n", + "example": 393, + "start_line": 6722, + "end_line": 6728, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "**foo \"*bar*\" foo**\n", + "html": "

foo "bar" foo

\n", + "example": 394, + "start_line": 6731, + "end_line": 6735, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "**foo**bar\n", + "html": "

foobar

\n", + "example": 395, + "start_line": 6740, + "end_line": 6744, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "__foo bar __\n", + "html": "

__foo bar __

\n", + "example": 396, + "start_line": 6752, + "end_line": 6756, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "__(__foo)\n", + "html": "

__(__foo)

\n", + "example": 397, + "start_line": 6762, + "end_line": 6766, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "_(__foo__)_\n", + "html": "

(foo)

\n", + "example": 398, + "start_line": 6772, + "end_line": 6776, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "__foo__bar\n", + "html": "

__foo__bar

\n", + "example": 399, + "start_line": 6781, + "end_line": 6785, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "__пристаням__стремятся\n", + "html": "

__пристаням__стремятся

\n", + "example": 400, + "start_line": 6788, + "end_line": 6792, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "__foo__bar__baz__\n", + "html": "

foo__bar__baz

\n", + "example": 401, + "start_line": 6795, + "end_line": 6799, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "__(bar)__.\n", + "html": "

(bar).

\n", + "example": 402, + "start_line": 6806, + "end_line": 6810, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*foo [bar](/url)*\n", + "html": "

foo bar

\n", + "example": 403, + "start_line": 6818, + "end_line": 6822, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*foo\nbar*\n", + "html": "

foo\nbar

\n", + "example": 404, + "start_line": 6825, + "end_line": 6831, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "_foo __bar__ baz_\n", + "html": "

foo bar baz

\n", + "example": 405, + "start_line": 6837, + "end_line": 6841, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "_foo _bar_ baz_\n", + "html": "

foo bar baz

\n", + "example": 406, + "start_line": 6844, + "end_line": 6848, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "__foo_ bar_\n", + "html": "

foo bar

\n", + "example": 407, + "start_line": 6851, + "end_line": 6855, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*foo *bar**\n", + "html": "

foo bar

\n", + "example": 408, + "start_line": 6858, + "end_line": 6862, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*foo **bar** baz*\n", + "html": "

foo bar baz

\n", + "example": 409, + "start_line": 6865, + "end_line": 6869, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*foo**bar**baz*\n", + "html": "

foobarbaz

\n", + "example": 410, + "start_line": 6871, + "end_line": 6875, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*foo**bar*\n", + "html": "

foo**bar

\n", + "example": 411, + "start_line": 6895, + "end_line": 6899, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "***foo** bar*\n", + "html": "

foo bar

\n", + "example": 412, + "start_line": 6908, + "end_line": 6912, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*foo **bar***\n", + "html": "

foo bar

\n", + "example": 413, + "start_line": 6915, + "end_line": 6919, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*foo**bar***\n", + "html": "

foobar

\n", + "example": 414, + "start_line": 6922, + "end_line": 6926, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "foo***bar***baz\n", + "html": "

foobarbaz

\n", + "example": 415, + "start_line": 6933, + "end_line": 6937, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "foo******bar*********baz\n", + "html": "

foobar***baz

\n", + "example": 416, + "start_line": 6939, + "end_line": 6943, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*foo **bar *baz* bim** bop*\n", + "html": "

foo bar baz bim bop

\n", + "example": 417, + "start_line": 6948, + "end_line": 6952, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*foo [*bar*](/url)*\n", + "html": "

foo bar

\n", + "example": 418, + "start_line": 6955, + "end_line": 6959, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "** is not an empty emphasis\n", + "html": "

** is not an empty emphasis

\n", + "example": 419, + "start_line": 6964, + "end_line": 6968, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "**** is not an empty strong emphasis\n", + "html": "

**** is not an empty strong emphasis

\n", + "example": 420, + "start_line": 6971, + "end_line": 6975, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "**foo [bar](/url)**\n", + "html": "

foo bar

\n", + "example": 421, + "start_line": 6984, + "end_line": 6988, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "**foo\nbar**\n", + "html": "

foo\nbar

\n", + "example": 422, + "start_line": 6991, + "end_line": 6997, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "__foo _bar_ baz__\n", + "html": "

foo bar baz

\n", + "example": 423, + "start_line": 7003, + "end_line": 7007, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "__foo __bar__ baz__\n", + "html": "

foo bar baz

\n", + "example": 424, + "start_line": 7010, + "end_line": 7014, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "____foo__ bar__\n", + "html": "

foo bar

\n", + "example": 425, + "start_line": 7017, + "end_line": 7021, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "**foo **bar****\n", + "html": "

foo bar

\n", + "example": 426, + "start_line": 7024, + "end_line": 7028, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "**foo *bar* baz**\n", + "html": "

foo bar baz

\n", + "example": 427, + "start_line": 7031, + "end_line": 7035, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "**foo*bar*baz**\n", + "html": "

foobarbaz

\n", + "example": 428, + "start_line": 7038, + "end_line": 7042, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "***foo* bar**\n", + "html": "

foo bar

\n", + "example": 429, + "start_line": 7045, + "end_line": 7049, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "**foo *bar***\n", + "html": "

foo bar

\n", + "example": 430, + "start_line": 7052, + "end_line": 7056, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "**foo *bar **baz**\nbim* bop**\n", + "html": "

foo bar baz\nbim bop

\n", + "example": 431, + "start_line": 7061, + "end_line": 7067, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "**foo [*bar*](/url)**\n", + "html": "

foo bar

\n", + "example": 432, + "start_line": 7070, + "end_line": 7074, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "__ is not an empty emphasis\n", + "html": "

__ is not an empty emphasis

\n", + "example": 433, + "start_line": 7079, + "end_line": 7083, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "____ is not an empty strong emphasis\n", + "html": "

____ is not an empty strong emphasis

\n", + "example": 434, + "start_line": 7086, + "end_line": 7090, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "foo ***\n", + "html": "

foo ***

\n", + "example": 435, + "start_line": 7096, + "end_line": 7100, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "foo *\\**\n", + "html": "

foo *

\n", + "example": 436, + "start_line": 7103, + "end_line": 7107, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "foo *_*\n", + "html": "

foo _

\n", + "example": 437, + "start_line": 7110, + "end_line": 7114, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "foo *****\n", + "html": "

foo *****

\n", + "example": 438, + "start_line": 7117, + "end_line": 7121, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "foo **\\***\n", + "html": "

foo *

\n", + "example": 439, + "start_line": 7124, + "end_line": 7128, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "foo **_**\n", + "html": "

foo _

\n", + "example": 440, + "start_line": 7131, + "end_line": 7135, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "**foo*\n", + "html": "

*foo

\n", + "example": 441, + "start_line": 7142, + "end_line": 7146, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*foo**\n", + "html": "

foo*

\n", + "example": 442, + "start_line": 7149, + "end_line": 7153, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "***foo**\n", + "html": "

*foo

\n", + "example": 443, + "start_line": 7156, + "end_line": 7160, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "****foo*\n", + "html": "

***foo

\n", + "example": 444, + "start_line": 7163, + "end_line": 7167, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "**foo***\n", + "html": "

foo*

\n", + "example": 445, + "start_line": 7170, + "end_line": 7174, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*foo****\n", + "html": "

foo***

\n", + "example": 446, + "start_line": 7177, + "end_line": 7181, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "foo ___\n", + "html": "

foo ___

\n", + "example": 447, + "start_line": 7187, + "end_line": 7191, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "foo _\\__\n", + "html": "

foo _

\n", + "example": 448, + "start_line": 7194, + "end_line": 7198, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "foo _*_\n", + "html": "

foo *

\n", + "example": 449, + "start_line": 7201, + "end_line": 7205, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "foo _____\n", + "html": "

foo _____

\n", + "example": 450, + "start_line": 7208, + "end_line": 7212, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "foo __\\___\n", + "html": "

foo _

\n", + "example": 451, + "start_line": 7215, + "end_line": 7219, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "foo __*__\n", + "html": "

foo *

\n", + "example": 452, + "start_line": 7222, + "end_line": 7226, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "__foo_\n", + "html": "

_foo

\n", + "example": 453, + "start_line": 7229, + "end_line": 7233, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "_foo__\n", + "html": "

foo_

\n", + "example": 454, + "start_line": 7240, + "end_line": 7244, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "___foo__\n", + "html": "

_foo

\n", + "example": 455, + "start_line": 7247, + "end_line": 7251, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "____foo_\n", + "html": "

___foo

\n", + "example": 456, + "start_line": 7254, + "end_line": 7258, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "__foo___\n", + "html": "

foo_

\n", + "example": 457, + "start_line": 7261, + "end_line": 7265, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "_foo____\n", + "html": "

foo___

\n", + "example": 458, + "start_line": 7268, + "end_line": 7272, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "**foo**\n", + "html": "

foo

\n", + "example": 459, + "start_line": 7278, + "end_line": 7282, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*_foo_*\n", + "html": "

foo

\n", + "example": 460, + "start_line": 7285, + "end_line": 7289, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "__foo__\n", + "html": "

foo

\n", + "example": 461, + "start_line": 7292, + "end_line": 7296, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "_*foo*_\n", + "html": "

foo

\n", + "example": 462, + "start_line": 7299, + "end_line": 7303, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "****foo****\n", + "html": "

foo

\n", + "example": 463, + "start_line": 7309, + "end_line": 7313, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "____foo____\n", + "html": "

foo

\n", + "example": 464, + "start_line": 7316, + "end_line": 7320, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "******foo******\n", + "html": "

foo

\n", + "example": 465, + "start_line": 7327, + "end_line": 7331, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "***foo***\n", + "html": "

foo

\n", + "example": 466, + "start_line": 7336, + "end_line": 7340, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "_____foo_____\n", + "html": "

foo

\n", + "example": 467, + "start_line": 7343, + "end_line": 7347, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*foo _bar* baz_\n", + "html": "

foo _bar baz_

\n", + "example": 468, + "start_line": 7352, + "end_line": 7356, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*foo __bar *baz bim__ bam*\n", + "html": "

foo bar *baz bim bam

\n", + "example": 469, + "start_line": 7359, + "end_line": 7363, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "**foo **bar baz**\n", + "html": "

**foo bar baz

\n", + "example": 470, + "start_line": 7368, + "end_line": 7372, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*foo *bar baz*\n", + "html": "

*foo bar baz

\n", + "example": 471, + "start_line": 7375, + "end_line": 7379, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*[bar*](/url)\n", + "html": "

*bar*

\n", + "example": 472, + "start_line": 7384, + "end_line": 7388, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "_foo [bar_](/url)\n", + "html": "

_foo bar_

\n", + "example": 473, + "start_line": 7391, + "end_line": 7395, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*\n", + "html": "

*

\n", + "example": 474, + "start_line": 7398, + "end_line": 7402, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "**\n", + "html": "

**

\n", + "example": 475, + "start_line": 7405, + "end_line": 7409, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "__\n", + "html": "

__

\n", + "example": 476, + "start_line": 7412, + "end_line": 7416, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "*a `*`*\n", + "html": "

a *

\n", + "example": 477, + "start_line": 7419, + "end_line": 7423, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "_a `_`_\n", + "html": "

a _

\n", + "example": 478, + "start_line": 7426, + "end_line": 7430, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "**a\n", + "html": "

**ahttp://foo.bar/?q=**

\n", + "example": 479, + "start_line": 7433, + "end_line": 7437, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "__a\n", + "html": "

__ahttp://foo.bar/?q=__

\n", + "example": 480, + "start_line": 7440, + "end_line": 7444, + "section": "Emphasis and strong emphasis" + }, + { + "markdown": "[link](/uri \"title\")\n", + "html": "

link

\n", + "example": 481, + "start_line": 7528, + "end_line": 7532, + "section": "Links" + }, + { + "markdown": "[link](/uri)\n", + "html": "

link

\n", + "example": 482, + "start_line": 7538, + "end_line": 7542, + "section": "Links" + }, + { + "markdown": "[](./target.md)\n", + "html": "

\n", + "example": 483, + "start_line": 7544, + "end_line": 7548, + "section": "Links" + }, + { + "markdown": "[link]()\n", + "html": "

link

\n", + "example": 484, + "start_line": 7551, + "end_line": 7555, + "section": "Links" + }, + { + "markdown": "[link](<>)\n", + "html": "

link

\n", + "example": 485, + "start_line": 7558, + "end_line": 7562, + "section": "Links" + }, + { + "markdown": "[]()\n", + "html": "

\n", + "example": 486, + "start_line": 7565, + "end_line": 7569, + "section": "Links" + }, + { + "markdown": "[link](/my uri)\n", + "html": "

[link](/my uri)

\n", + "example": 487, + "start_line": 7574, + "end_line": 7578, + "section": "Links" + }, + { + "markdown": "[link](
)\n", + "html": "

link

\n", + "example": 488, + "start_line": 7580, + "end_line": 7584, + "section": "Links" + }, + { + "markdown": "[link](foo\nbar)\n", + "html": "

[link](foo\nbar)

\n", + "example": 489, + "start_line": 7589, + "end_line": 7595, + "section": "Links" + }, + { + "markdown": "[link]()\n", + "html": "

[link]()

\n", + "example": 490, + "start_line": 7597, + "end_line": 7603, + "section": "Links" + }, + { + "markdown": "[a]()\n", + "html": "

a

\n", + "example": 491, + "start_line": 7608, + "end_line": 7612, + "section": "Links" + }, + { + "markdown": "[link]()\n", + "html": "

[link](<foo>)

\n", + "example": 492, + "start_line": 7616, + "end_line": 7620, + "section": "Links" + }, + { + "markdown": "[a](\n[a](c)\n", + "html": "

[a](<b)c\n[a](<b)c>\n[a](c)

\n", + "example": 493, + "start_line": 7625, + "end_line": 7633, + "section": "Links" + }, + { + "markdown": "[link](\\(foo\\))\n", + "html": "

link

\n", + "example": 494, + "start_line": 7637, + "end_line": 7641, + "section": "Links" + }, + { + "markdown": "[link](foo(and(bar)))\n", + "html": "

link

\n", + "example": 495, + "start_line": 7646, + "end_line": 7650, + "section": "Links" + }, + { + "markdown": "[link](foo(and(bar))\n", + "html": "

[link](foo(and(bar))

\n", + "example": 496, + "start_line": 7655, + "end_line": 7659, + "section": "Links" + }, + { + "markdown": "[link](foo\\(and\\(bar\\))\n", + "html": "

link

\n", + "example": 497, + "start_line": 7662, + "end_line": 7666, + "section": "Links" + }, + { + "markdown": "[link]()\n", + "html": "

link

\n", + "example": 498, + "start_line": 7669, + "end_line": 7673, + "section": "Links" + }, + { + "markdown": "[link](foo\\)\\:)\n", + "html": "

link

\n", + "example": 499, + "start_line": 7679, + "end_line": 7683, + "section": "Links" + }, + { + "markdown": "[link](#fragment)\n\n[link](http://example.com#fragment)\n\n[link](http://example.com?foo=3#frag)\n", + "html": "

link

\n

link

\n

link

\n", + "example": 500, + "start_line": 7688, + "end_line": 7698, + "section": "Links" + }, + { + "markdown": "[link](foo\\bar)\n", + "html": "

link

\n", + "example": 501, + "start_line": 7704, + "end_line": 7708, + "section": "Links" + }, + { + "markdown": "[link](foo%20bä)\n", + "html": "

link

\n", + "example": 502, + "start_line": 7720, + "end_line": 7724, + "section": "Links" + }, + { + "markdown": "[link](\"title\")\n", + "html": "

link

\n", + "example": 503, + "start_line": 7731, + "end_line": 7735, + "section": "Links" + }, + { + "markdown": "[link](/url \"title\")\n[link](/url 'title')\n[link](/url (title))\n", + "html": "

link\nlink\nlink

\n", + "example": 504, + "start_line": 7740, + "end_line": 7748, + "section": "Links" + }, + { + "markdown": "[link](/url \"title \\\""\")\n", + "html": "

link

\n", + "example": 505, + "start_line": 7754, + "end_line": 7758, + "section": "Links" + }, + { + "markdown": "[link](/url \"title\")\n", + "html": "

link

\n", + "example": 506, + "start_line": 7765, + "end_line": 7769, + "section": "Links" + }, + { + "markdown": "[link](/url \"title \"and\" title\")\n", + "html": "

[link](/url "title "and" title")

\n", + "example": 507, + "start_line": 7774, + "end_line": 7778, + "section": "Links" + }, + { + "markdown": "[link](/url 'title \"and\" title')\n", + "html": "

link

\n", + "example": 508, + "start_line": 7783, + "end_line": 7787, + "section": "Links" + }, + { + "markdown": "[link]( /uri\n \"title\" )\n", + "html": "

link

\n", + "example": 509, + "start_line": 7808, + "end_line": 7813, + "section": "Links" + }, + { + "markdown": "[link] (/uri)\n", + "html": "

[link] (/uri)

\n", + "example": 510, + "start_line": 7819, + "end_line": 7823, + "section": "Links" + }, + { + "markdown": "[link [foo [bar]]](/uri)\n", + "html": "

link [foo [bar]]

\n", + "example": 511, + "start_line": 7829, + "end_line": 7833, + "section": "Links" + }, + { + "markdown": "[link] bar](/uri)\n", + "html": "

[link] bar](/uri)

\n", + "example": 512, + "start_line": 7836, + "end_line": 7840, + "section": "Links" + }, + { + "markdown": "[link [bar](/uri)\n", + "html": "

[link bar

\n", + "example": 513, + "start_line": 7843, + "end_line": 7847, + "section": "Links" + }, + { + "markdown": "[link \\[bar](/uri)\n", + "html": "

link [bar

\n", + "example": 514, + "start_line": 7850, + "end_line": 7854, + "section": "Links" + }, + { + "markdown": "[link *foo **bar** `#`*](/uri)\n", + "html": "

link foo bar #

\n", + "example": 515, + "start_line": 7859, + "end_line": 7863, + "section": "Links" + }, + { + "markdown": "[![moon](moon.jpg)](/uri)\n", + "html": "

\"moon\"

\n", + "example": 516, + "start_line": 7866, + "end_line": 7870, + "section": "Links" + }, + { + "markdown": "[foo [bar](/uri)](/uri)\n", + "html": "

[foo bar](/uri)

\n", + "example": 517, + "start_line": 7875, + "end_line": 7879, + "section": "Links" + }, + { + "markdown": "[foo *[bar [baz](/uri)](/uri)*](/uri)\n", + "html": "

[foo [bar baz](/uri)](/uri)

\n", + "example": 518, + "start_line": 7882, + "end_line": 7886, + "section": "Links" + }, + { + "markdown": "![[[foo](uri1)](uri2)](uri3)\n", + "html": "

\"[foo](uri2)\"

\n", + "example": 519, + "start_line": 7889, + "end_line": 7893, + "section": "Links" + }, + { + "markdown": "*[foo*](/uri)\n", + "html": "

*foo*

\n", + "example": 520, + "start_line": 7899, + "end_line": 7903, + "section": "Links" + }, + { + "markdown": "[foo *bar](baz*)\n", + "html": "

foo *bar

\n", + "example": 521, + "start_line": 7906, + "end_line": 7910, + "section": "Links" + }, + { + "markdown": "*foo [bar* baz]\n", + "html": "

foo [bar baz]

\n", + "example": 522, + "start_line": 7916, + "end_line": 7920, + "section": "Links" + }, + { + "markdown": "[foo \n", + "html": "

[foo

\n", + "example": 523, + "start_line": 7926, + "end_line": 7930, + "section": "Links" + }, + { + "markdown": "[foo`](/uri)`\n", + "html": "

[foo](/uri)

\n", + "example": 524, + "start_line": 7933, + "end_line": 7937, + "section": "Links" + }, + { + "markdown": "[foo\n", + "html": "

[foohttp://example.com/?search=](uri)

\n", + "example": 525, + "start_line": 7940, + "end_line": 7944, + "section": "Links" + }, + { + "markdown": "[foo][bar]\n\n[bar]: /url \"title\"\n", + "html": "

foo

\n", + "example": 526, + "start_line": 7978, + "end_line": 7984, + "section": "Links" + }, + { + "markdown": "[link [foo [bar]]][ref]\n\n[ref]: /uri\n", + "html": "

link [foo [bar]]

\n", + "example": 527, + "start_line": 7993, + "end_line": 7999, + "section": "Links" + }, + { + "markdown": "[link \\[bar][ref]\n\n[ref]: /uri\n", + "html": "

link [bar

\n", + "example": 528, + "start_line": 8002, + "end_line": 8008, + "section": "Links" + }, + { + "markdown": "[link *foo **bar** `#`*][ref]\n\n[ref]: /uri\n", + "html": "

link foo bar #

\n", + "example": 529, + "start_line": 8013, + "end_line": 8019, + "section": "Links" + }, + { + "markdown": "[![moon](moon.jpg)][ref]\n\n[ref]: /uri\n", + "html": "

\"moon\"

\n", + "example": 530, + "start_line": 8022, + "end_line": 8028, + "section": "Links" + }, + { + "markdown": "[foo [bar](/uri)][ref]\n\n[ref]: /uri\n", + "html": "

[foo bar]ref

\n", + "example": 531, + "start_line": 8033, + "end_line": 8039, + "section": "Links" + }, + { + "markdown": "[foo *bar [baz][ref]*][ref]\n\n[ref]: /uri\n", + "html": "

[foo bar baz]ref

\n", + "example": 532, + "start_line": 8042, + "end_line": 8048, + "section": "Links" + }, + { + "markdown": "*[foo*][ref]\n\n[ref]: /uri\n", + "html": "

*foo*

\n", + "example": 533, + "start_line": 8057, + "end_line": 8063, + "section": "Links" + }, + { + "markdown": "[foo *bar][ref]*\n\n[ref]: /uri\n", + "html": "

foo *bar*

\n", + "example": 534, + "start_line": 8066, + "end_line": 8072, + "section": "Links" + }, + { + "markdown": "[foo \n\n[ref]: /uri\n", + "html": "

[foo

\n", + "example": 535, + "start_line": 8078, + "end_line": 8084, + "section": "Links" + }, + { + "markdown": "[foo`][ref]`\n\n[ref]: /uri\n", + "html": "

[foo][ref]

\n", + "example": 536, + "start_line": 8087, + "end_line": 8093, + "section": "Links" + }, + { + "markdown": "[foo\n\n[ref]: /uri\n", + "html": "

[foohttp://example.com/?search=][ref]

\n", + "example": 537, + "start_line": 8096, + "end_line": 8102, + "section": "Links" + }, + { + "markdown": "[foo][BaR]\n\n[bar]: /url \"title\"\n", + "html": "

foo

\n", + "example": 538, + "start_line": 8107, + "end_line": 8113, + "section": "Links" + }, + { + "markdown": "[ẞ]\n\n[SS]: /url\n", + "html": "

ẞ

\n", + "example": 539, + "start_line": 8118, + "end_line": 8124, + "section": "Links" + }, + { + "markdown": "[Foo\n bar]: /url\n\n[Baz][Foo bar]\n", + "html": "

Baz

\n", + "example": 540, + "start_line": 8130, + "end_line": 8137, + "section": "Links" + }, + { + "markdown": "[foo] [bar]\n\n[bar]: /url \"title\"\n", + "html": "

[foo] bar

\n", + "example": 541, + "start_line": 8143, + "end_line": 8149, + "section": "Links" + }, + { + "markdown": "[foo]\n[bar]\n\n[bar]: /url \"title\"\n", + "html": "

[foo]\nbar

\n", + "example": 542, + "start_line": 8152, + "end_line": 8160, + "section": "Links" + }, + { + "markdown": "[foo]: /url1\n\n[foo]: /url2\n\n[bar][foo]\n", + "html": "

bar

\n", + "example": 543, + "start_line": 8193, + "end_line": 8201, + "section": "Links" + }, + { + "markdown": "[bar][foo\\!]\n\n[foo!]: /url\n", + "html": "

[bar][foo!]

\n", + "example": 544, + "start_line": 8208, + "end_line": 8214, + "section": "Links" + }, + { + "markdown": "[foo][ref[]\n\n[ref[]: /uri\n", + "html": "

[foo][ref[]

\n

[ref[]: /uri

\n", + "example": 545, + "start_line": 8220, + "end_line": 8227, + "section": "Links" + }, + { + "markdown": "[foo][ref[bar]]\n\n[ref[bar]]: /uri\n", + "html": "

[foo][ref[bar]]

\n

[ref[bar]]: /uri

\n", + "example": 546, + "start_line": 8230, + "end_line": 8237, + "section": "Links" + }, + { + "markdown": "[[[foo]]]\n\n[[[foo]]]: /url\n", + "html": "

[[[foo]]]

\n

[[[foo]]]: /url

\n", + "example": 547, + "start_line": 8240, + "end_line": 8247, + "section": "Links" + }, + { + "markdown": "[foo][ref\\[]\n\n[ref\\[]: /uri\n", + "html": "

foo

\n", + "example": 548, + "start_line": 8250, + "end_line": 8256, + "section": "Links" + }, + { + "markdown": "[bar\\\\]: /uri\n\n[bar\\\\]\n", + "html": "

bar\\

\n", + "example": 549, + "start_line": 8261, + "end_line": 8267, + "section": "Links" + }, + { + "markdown": "[]\n\n[]: /uri\n", + "html": "

[]

\n

[]: /uri

\n", + "example": 550, + "start_line": 8273, + "end_line": 8280, + "section": "Links" + }, + { + "markdown": "[\n ]\n\n[\n ]: /uri\n", + "html": "

[\n]

\n

[\n]: /uri

\n", + "example": 551, + "start_line": 8283, + "end_line": 8294, + "section": "Links" + }, + { + "markdown": "[foo][]\n\n[foo]: /url \"title\"\n", + "html": "

foo

\n", + "example": 552, + "start_line": 8306, + "end_line": 8312, + "section": "Links" + }, + { + "markdown": "[*foo* bar][]\n\n[*foo* bar]: /url \"title\"\n", + "html": "

foo bar

\n", + "example": 553, + "start_line": 8315, + "end_line": 8321, + "section": "Links" + }, + { + "markdown": "[Foo][]\n\n[foo]: /url \"title\"\n", + "html": "

Foo

\n", + "example": 554, + "start_line": 8326, + "end_line": 8332, + "section": "Links" + }, + { + "markdown": "[foo] \n[]\n\n[foo]: /url \"title\"\n", + "html": "

foo\n[]

\n", + "example": 555, + "start_line": 8339, + "end_line": 8347, + "section": "Links" + }, + { + "markdown": "[foo]\n\n[foo]: /url \"title\"\n", + "html": "

foo

\n", + "example": 556, + "start_line": 8359, + "end_line": 8365, + "section": "Links" + }, + { + "markdown": "[*foo* bar]\n\n[*foo* bar]: /url \"title\"\n", + "html": "

foo bar

\n", + "example": 557, + "start_line": 8368, + "end_line": 8374, + "section": "Links" + }, + { + "markdown": "[[*foo* bar]]\n\n[*foo* bar]: /url \"title\"\n", + "html": "

[foo bar]

\n", + "example": 558, + "start_line": 8377, + "end_line": 8383, + "section": "Links" + }, + { + "markdown": "[[bar [foo]\n\n[foo]: /url\n", + "html": "

[[bar foo

\n", + "example": 559, + "start_line": 8386, + "end_line": 8392, + "section": "Links" + }, + { + "markdown": "[Foo]\n\n[foo]: /url \"title\"\n", + "html": "

Foo

\n", + "example": 560, + "start_line": 8397, + "end_line": 8403, + "section": "Links" + }, + { + "markdown": "[foo] bar\n\n[foo]: /url\n", + "html": "

foo bar

\n", + "example": 561, + "start_line": 8408, + "end_line": 8414, + "section": "Links" + }, + { + "markdown": "\\[foo]\n\n[foo]: /url \"title\"\n", + "html": "

[foo]

\n", + "example": 562, + "start_line": 8420, + "end_line": 8426, + "section": "Links" + }, + { + "markdown": "[foo*]: /url\n\n*[foo*]\n", + "html": "

*foo*

\n", + "example": 563, + "start_line": 8432, + "end_line": 8438, + "section": "Links" + }, + { + "markdown": "[foo][bar]\n\n[foo]: /url1\n[bar]: /url2\n", + "html": "

foo

\n", + "example": 564, + "start_line": 8444, + "end_line": 8451, + "section": "Links" + }, + { + "markdown": "[foo][]\n\n[foo]: /url1\n", + "html": "

foo

\n", + "example": 565, + "start_line": 8453, + "end_line": 8459, + "section": "Links" + }, + { + "markdown": "[foo]()\n\n[foo]: /url1\n", + "html": "

foo

\n", + "example": 566, + "start_line": 8463, + "end_line": 8469, + "section": "Links" + }, + { + "markdown": "[foo](not a link)\n\n[foo]: /url1\n", + "html": "

foo(not a link)

\n", + "example": 567, + "start_line": 8471, + "end_line": 8477, + "section": "Links" + }, + { + "markdown": "[foo][bar][baz]\n\n[baz]: /url\n", + "html": "

[foo]bar

\n", + "example": 568, + "start_line": 8482, + "end_line": 8488, + "section": "Links" + }, + { + "markdown": "[foo][bar][baz]\n\n[baz]: /url1\n[bar]: /url2\n", + "html": "

foobaz

\n", + "example": 569, + "start_line": 8494, + "end_line": 8501, + "section": "Links" + }, + { + "markdown": "[foo][bar][baz]\n\n[baz]: /url1\n[foo]: /url2\n", + "html": "

[foo]bar

\n", + "example": 570, + "start_line": 8507, + "end_line": 8514, + "section": "Links" + }, + { + "markdown": "![foo](/url \"title\")\n", + "html": "

\"foo\"

\n", + "example": 571, + "start_line": 8530, + "end_line": 8534, + "section": "Images" + }, + { + "markdown": "![foo *bar*]\n\n[foo *bar*]: train.jpg \"train & tracks\"\n", + "html": "

\"foo

\n", + "example": 572, + "start_line": 8537, + "end_line": 8543, + "section": "Images" + }, + { + "markdown": "![foo ![bar](/url)](/url2)\n", + "html": "

\"foo

\n", + "example": 573, + "start_line": 8546, + "end_line": 8550, + "section": "Images" + }, + { + "markdown": "![foo [bar](/url)](/url2)\n", + "html": "

\"foo

\n", + "example": 574, + "start_line": 8553, + "end_line": 8557, + "section": "Images" + }, + { + "markdown": "![foo *bar*][]\n\n[foo *bar*]: train.jpg \"train & tracks\"\n", + "html": "

\"foo

\n", + "example": 575, + "start_line": 8567, + "end_line": 8573, + "section": "Images" + }, + { + "markdown": "![foo *bar*][foobar]\n\n[FOOBAR]: train.jpg \"train & tracks\"\n", + "html": "

\"foo

\n", + "example": 576, + "start_line": 8576, + "end_line": 8582, + "section": "Images" + }, + { + "markdown": "![foo](train.jpg)\n", + "html": "

\"foo\"

\n", + "example": 577, + "start_line": 8585, + "end_line": 8589, + "section": "Images" + }, + { + "markdown": "My ![foo bar](/path/to/train.jpg \"title\" )\n", + "html": "

My \"foo

\n", + "example": 578, + "start_line": 8592, + "end_line": 8596, + "section": "Images" + }, + { + "markdown": "![foo]()\n", + "html": "

\"foo\"

\n", + "example": 579, + "start_line": 8599, + "end_line": 8603, + "section": "Images" + }, + { + "markdown": "![](/url)\n", + "html": "

\"\"

\n", + "example": 580, + "start_line": 8606, + "end_line": 8610, + "section": "Images" + }, + { + "markdown": "![foo][bar]\n\n[bar]: /url\n", + "html": "

\"foo\"

\n", + "example": 581, + "start_line": 8615, + "end_line": 8621, + "section": "Images" + }, + { + "markdown": "![foo][bar]\n\n[BAR]: /url\n", + "html": "

\"foo\"

\n", + "example": 582, + "start_line": 8624, + "end_line": 8630, + "section": "Images" + }, + { + "markdown": "![foo][]\n\n[foo]: /url \"title\"\n", + "html": "

\"foo\"

\n", + "example": 583, + "start_line": 8635, + "end_line": 8641, + "section": "Images" + }, + { + "markdown": "![*foo* bar][]\n\n[*foo* bar]: /url \"title\"\n", + "html": "

\"foo

\n", + "example": 584, + "start_line": 8644, + "end_line": 8650, + "section": "Images" + }, + { + "markdown": "![Foo][]\n\n[foo]: /url \"title\"\n", + "html": "

\"Foo\"

\n", + "example": 585, + "start_line": 8655, + "end_line": 8661, + "section": "Images" + }, + { + "markdown": "![foo] \n[]\n\n[foo]: /url \"title\"\n", + "html": "

\"foo\"\n[]

\n", + "example": 586, + "start_line": 8667, + "end_line": 8675, + "section": "Images" + }, + { + "markdown": "![foo]\n\n[foo]: /url \"title\"\n", + "html": "

\"foo\"

\n", + "example": 587, + "start_line": 8680, + "end_line": 8686, + "section": "Images" + }, + { + "markdown": "![*foo* bar]\n\n[*foo* bar]: /url \"title\"\n", + "html": "

\"foo

\n", + "example": 588, + "start_line": 8689, + "end_line": 8695, + "section": "Images" + }, + { + "markdown": "![[foo]]\n\n[[foo]]: /url \"title\"\n", + "html": "

![[foo]]

\n

[[foo]]: /url "title"

\n", + "example": 589, + "start_line": 8700, + "end_line": 8707, + "section": "Images" + }, + { + "markdown": "![Foo]\n\n[foo]: /url \"title\"\n", + "html": "

\"Foo\"

\n", + "example": 590, + "start_line": 8712, + "end_line": 8718, + "section": "Images" + }, + { + "markdown": "!\\[foo]\n\n[foo]: /url \"title\"\n", + "html": "

![foo]

\n", + "example": 591, + "start_line": 8724, + "end_line": 8730, + "section": "Images" + }, + { + "markdown": "\\![foo]\n\n[foo]: /url \"title\"\n", + "html": "

!foo

\n", + "example": 592, + "start_line": 8736, + "end_line": 8742, + "section": "Images" + }, + { + "markdown": "\n", + "html": "

http://foo.bar.baz

\n", + "example": 593, + "start_line": 8769, + "end_line": 8773, + "section": "Autolinks" + }, + { + "markdown": "\n", + "html": "

http://foo.bar.baz/test?q=hello&id=22&boolean

\n", + "example": 594, + "start_line": 8776, + "end_line": 8780, + "section": "Autolinks" + }, + { + "markdown": "\n", + "html": "

irc://foo.bar:2233/baz

\n", + "example": 595, + "start_line": 8783, + "end_line": 8787, + "section": "Autolinks" + }, + { + "markdown": "\n", + "html": "

MAILTO:FOO@BAR.BAZ

\n", + "example": 596, + "start_line": 8792, + "end_line": 8796, + "section": "Autolinks" + }, + { + "markdown": "\n", + "html": "

a+b+c:d

\n", + "example": 597, + "start_line": 8804, + "end_line": 8808, + "section": "Autolinks" + }, + { + "markdown": "\n", + "html": "

made-up-scheme://foo,bar

\n", + "example": 598, + "start_line": 8811, + "end_line": 8815, + "section": "Autolinks" + }, + { + "markdown": "\n", + "html": "

http://../

\n", + "example": 599, + "start_line": 8818, + "end_line": 8822, + "section": "Autolinks" + }, + { + "markdown": "\n", + "html": "

localhost:5001/foo

\n", + "example": 600, + "start_line": 8825, + "end_line": 8829, + "section": "Autolinks" + }, + { + "markdown": "\n", + "html": "

<http://foo.bar/baz bim>

\n", + "example": 601, + "start_line": 8834, + "end_line": 8838, + "section": "Autolinks" + }, + { + "markdown": "\n", + "html": "

http://example.com/\\[\\

\n", + "example": 602, + "start_line": 8843, + "end_line": 8847, + "section": "Autolinks" + }, + { + "markdown": "\n", + "html": "

foo@bar.example.com

\n", + "example": 603, + "start_line": 8865, + "end_line": 8869, + "section": "Autolinks" + }, + { + "markdown": "\n", + "html": "

foo+special@Bar.baz-bar0.com

\n", + "example": 604, + "start_line": 8872, + "end_line": 8876, + "section": "Autolinks" + }, + { + "markdown": "\n", + "html": "

<foo+@bar.example.com>

\n", + "example": 605, + "start_line": 8881, + "end_line": 8885, + "section": "Autolinks" + }, + { + "markdown": "<>\n", + "html": "

<>

\n", + "example": 606, + "start_line": 8890, + "end_line": 8894, + "section": "Autolinks" + }, + { + "markdown": "< http://foo.bar >\n", + "html": "

< http://foo.bar >

\n", + "example": 607, + "start_line": 8897, + "end_line": 8901, + "section": "Autolinks" + }, + { + "markdown": "\n", + "html": "

<m:abc>

\n", + "example": 608, + "start_line": 8904, + "end_line": 8908, + "section": "Autolinks" + }, + { + "markdown": "\n", + "html": "

<foo.bar.baz>

\n", + "example": 609, + "start_line": 8911, + "end_line": 8915, + "section": "Autolinks" + }, + { + "markdown": "http://example.com\n", + "html": "

http://example.com

\n", + "example": 610, + "start_line": 8918, + "end_line": 8922, + "section": "Autolinks" + }, + { + "markdown": "foo@bar.example.com\n", + "html": "

foo@bar.example.com

\n", + "example": 611, + "start_line": 8925, + "end_line": 8929, + "section": "Autolinks" + }, + { + "markdown": "\n", + "html": "

\n", + "example": 612, + "start_line": 9006, + "end_line": 9010, + "section": "Raw HTML" + }, + { + "markdown": "\n", + "html": "

\n", + "example": 613, + "start_line": 9015, + "end_line": 9019, + "section": "Raw HTML" + }, + { + "markdown": "\n", + "html": "

\n", + "example": 614, + "start_line": 9024, + "end_line": 9030, + "section": "Raw HTML" + }, + { + "markdown": "\n", + "html": "

\n", + "example": 615, + "start_line": 9035, + "end_line": 9041, + "section": "Raw HTML" + }, + { + "markdown": "Foo \n", + "html": "

Foo

\n", + "example": 616, + "start_line": 9046, + "end_line": 9050, + "section": "Raw HTML" + }, + { + "markdown": "<33> <__>\n", + "html": "

<33> <__>

\n", + "example": 617, + "start_line": 9055, + "end_line": 9059, + "section": "Raw HTML" + }, + { + "markdown": "
\n", + "html": "

<a h*#ref="hi">

\n", + "example": 618, + "start_line": 9064, + "end_line": 9068, + "section": "Raw HTML" + }, + { + "markdown": "
\n", + "html": "

<a href="hi'> <a href=hi'>

\n", + "example": 619, + "start_line": 9073, + "end_line": 9077, + "section": "Raw HTML" + }, + { + "markdown": "< a><\nfoo>\n\n", + "html": "

< a><\nfoo><bar/ >\n<foo bar=baz\nbim!bop />

\n", + "example": 620, + "start_line": 9082, + "end_line": 9092, + "section": "Raw HTML" + }, + { + "markdown": "
\n", + "html": "

<a href='bar'title=title>

\n", + "example": 621, + "start_line": 9097, + "end_line": 9101, + "section": "Raw HTML" + }, + { + "markdown": "
\n", + "html": "

\n", + "example": 622, + "start_line": 9106, + "end_line": 9110, + "section": "Raw HTML" + }, + { + "markdown": "\n", + "html": "

</a href="foo">

\n", + "example": 623, + "start_line": 9115, + "end_line": 9119, + "section": "Raw HTML" + }, + { + "markdown": "foo \n", + "html": "

foo

\n", + "example": 624, + "start_line": 9124, + "end_line": 9130, + "section": "Raw HTML" + }, + { + "markdown": "foo \n", + "html": "

foo <!-- not a comment -- two hyphens -->

\n", + "example": 625, + "start_line": 9133, + "end_line": 9137, + "section": "Raw HTML" + }, + { + "markdown": "foo foo -->\n\nfoo \n", + "html": "

foo <!--> foo -->

\n

foo <!-- foo--->

\n", + "example": 626, + "start_line": 9142, + "end_line": 9149, + "section": "Raw HTML" + }, + { + "markdown": "foo \n", + "html": "

foo

\n", + "example": 627, + "start_line": 9154, + "end_line": 9158, + "section": "Raw HTML" + }, + { + "markdown": "foo \n", + "html": "

foo

\n", + "example": 628, + "start_line": 9163, + "end_line": 9167, + "section": "Raw HTML" + }, + { + "markdown": "foo &<]]>\n", + "html": "

foo &<]]>

\n", + "example": 629, + "start_line": 9172, + "end_line": 9176, + "section": "Raw HTML" + }, + { + "markdown": "foo \n", + "html": "

foo

\n", + "example": 630, + "start_line": 9182, + "end_line": 9186, + "section": "Raw HTML" + }, + { + "markdown": "foo \n", + "html": "

foo

\n", + "example": 631, + "start_line": 9191, + "end_line": 9195, + "section": "Raw HTML" + }, + { + "markdown": "\n", + "html": "

<a href=""">

\n", + "example": 632, + "start_line": 9198, + "end_line": 9202, + "section": "Raw HTML" + }, + { + "markdown": "foo \nbaz\n", + "html": "

foo
\nbaz

\n", + "example": 633, + "start_line": 9212, + "end_line": 9218, + "section": "Hard line breaks" + }, + { + "markdown": "foo\\\nbaz\n", + "html": "

foo
\nbaz

\n", + "example": 634, + "start_line": 9224, + "end_line": 9230, + "section": "Hard line breaks" + }, + { + "markdown": "foo \nbaz\n", + "html": "

foo
\nbaz

\n", + "example": 635, + "start_line": 9235, + "end_line": 9241, + "section": "Hard line breaks" + }, + { + "markdown": "foo \n bar\n", + "html": "

foo
\nbar

\n", + "example": 636, + "start_line": 9246, + "end_line": 9252, + "section": "Hard line breaks" + }, + { + "markdown": "foo\\\n bar\n", + "html": "

foo
\nbar

\n", + "example": 637, + "start_line": 9255, + "end_line": 9261, + "section": "Hard line breaks" + }, + { + "markdown": "*foo \nbar*\n", + "html": "

foo
\nbar

\n", + "example": 638, + "start_line": 9267, + "end_line": 9273, + "section": "Hard line breaks" + }, + { + "markdown": "*foo\\\nbar*\n", + "html": "

foo
\nbar

\n", + "example": 639, + "start_line": 9276, + "end_line": 9282, + "section": "Hard line breaks" + }, + { + "markdown": "`code \nspan`\n", + "html": "

code span

\n", + "example": 640, + "start_line": 9287, + "end_line": 9292, + "section": "Hard line breaks" + }, + { + "markdown": "`code\\\nspan`\n", + "html": "

code\\ span

\n", + "example": 641, + "start_line": 9295, + "end_line": 9300, + "section": "Hard line breaks" + }, + { + "markdown": "
\n", + "html": "

\n", + "example": 642, + "start_line": 9305, + "end_line": 9311, + "section": "Hard line breaks" + }, + { + "markdown": "\n", + "html": "

\n", + "example": 643, + "start_line": 9314, + "end_line": 9320, + "section": "Hard line breaks" + }, + { + "markdown": "foo\\\n", + "html": "

foo\\

\n", + "example": 644, + "start_line": 9327, + "end_line": 9331, + "section": "Hard line breaks" + }, + { + "markdown": "foo \n", + "html": "

foo

\n", + "example": 645, + "start_line": 9334, + "end_line": 9338, + "section": "Hard line breaks" + }, + { + "markdown": "### foo\\\n", + "html": "

foo\\

\n", + "example": 646, + "start_line": 9341, + "end_line": 9345, + "section": "Hard line breaks" + }, + { + "markdown": "### foo \n", + "html": "

foo

\n", + "example": 647, + "start_line": 9348, + "end_line": 9352, + "section": "Hard line breaks" + }, + { + "markdown": "foo\nbaz\n", + "html": "

foo\nbaz

\n", + "example": 648, + "start_line": 9363, + "end_line": 9369, + "section": "Soft line breaks" + }, + { + "markdown": "foo \n baz\n", + "html": "

foo\nbaz

\n", + "example": 649, + "start_line": 9375, + "end_line": 9381, + "section": "Soft line breaks" + }, + { + "markdown": "hello $.;'there\n", + "html": "

hello $.;'there

\n", + "example": 650, + "start_line": 9395, + "end_line": 9399, + "section": "Textual content" + }, + { + "markdown": "Foo χρῆν\n", + "html": "

Foo χρῆν

\n", + "example": 651, + "start_line": 9402, + "end_line": 9406, + "section": "Textual content" + }, + { + "markdown": "Multiple spaces\n", + "html": "

Multiple spaces

\n", + "example": 652, + "start_line": 9411, + "end_line": 9415, + "section": "Textual content" + } +] \ No newline at end of file diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/tests/trusted/tests/fixtures/def_list.txt b/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/tests/trusted/tests/fixtures/def_list.txt new file mode 100644 index 0000000000000000000000000000000000000000..6c5a210232576e53330d55888c2d041ffeccc145 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/tests/trusted/tests/fixtures/def_list.txt @@ -0,0 +1,172 @@ +# Definition Lists + +```````````````````````````````` example +Term +: definition +. +
+
Term
+
definition
+
+```````````````````````````````` + +```````````````````````````````` example +Term +: definition1 +: definition2 +. +
+
Term
+
definition1
+
definition2
+
+```````````````````````````````` + +```````````````````````````````` example +Term +: definition1 +: definition2 + +paragraph +. +
+
Term
+
definition1
+
definition2
+
+

paragraph

+```````````````````````````````` + +```````````````````````````````` example +First Term +: This is the definition of the first term. + +Second Term +: This is one definition of the second term. +: This is another definition of the second term. +. +
+
First Term
+
This is the definition of the first term.
+
Second Term
+
This is one definition of the second term.
+
This is another definition of the second term.
+
+```````````````````````````````` + +```````````````````````````````` example +First Term +: This is the definition of the first term. + +Second Term +: This is one definition of the second term. +: This is another definition of the second term. + +paragraph +. +
+
First Term
+
This is the definition of the first term.
+
Second Term
+
This is one definition of the second term.
+
This is another definition of the second term.
+
+

paragraph

+```````````````````````````````` + +```````````````````````````````` example +First Term +: This is the definition of the first term. +Not Second Term +: This is one definition of the second term. +: This is another definition of the second term. + +paragraph +. +
+
First Term
+
This is the definition of the first term. +Not Second Term
+
This is one definition of the second term.
+
This is another definition of the second term.
+
+

paragraph

+```````````````````````````````` + +## Definition with Multiple Lines + +```````````````````````````````` example +Term + +: definition +. +
+
Term
+

definition

+
+
+```````````````````````````````` + + +```````````````````````````````` example +Term +: foo + + bar +. +
+
Term
+

foo

+

bar

+
+
+```````````````````````````````` + +Leading 4 white spaces + +```````````````````````````````` example +Term +: foo + + bar +. +
+
Term
+

foo

+

bar

+
+
+```````````````````````````````` + + +```````````````````````````````` example +Term +: foo + + bar +. +
+
Term
+

foo

+
bar
+
+
+```````````````````````````````` + +```````````````````````````````` example +Term +: foo + + - bar + - baz +. +
+
Term
+

foo

+
    +
  • bar
  • +
  • baz
  • +
+
+
+```````````````````````````````` diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/tests/trusted/tests/fixtures/diff-commonmark.txt b/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/tests/trusted/tests/fixtures/diff-commonmark.txt new file mode 100644 index 0000000000000000000000000000000000000000..9573e2a383b273af5db4a2386d9f9fe35120d9b4 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/tests/trusted/tests/fixtures/diff-commonmark.txt @@ -0,0 +1,76 @@ +# Differences + +Results different than commonmark. + + +## Setext headings + + +Example: 93 + + +```````````````````````````````` example +> foo +bar +=== +. +
+

foo +bar

+
+```````````````````````````````` + +If the dash is less than 3, it is not a `
`, in this case, it +can be rendered into `

`. + +```````````````````````````````` example +- # Foo +- Bar + -- + baz +. +
    +
  • +

    Foo

    +
  • +
  • +

    Bar

    +baz
  • +
+```````````````````````````````` + +## Image + +Example 573 + +```````````````````````````````` example +![foo ![bar](/url)](/url2) +. +

foo ![bar](/url)

+```````````````````````````````` + +## Link + +Example 517 + +```````````````````````````````` example +[foo [bar](/uri)](/uri) +. +

foo [bar](/uri)

+```````````````````````````````` + +Example 518 + +```````````````````````````````` example +[foo *[bar [baz](/uri)](/uri)*](/uri) +. +

foo [bar [baz](/uri)](/uri)

+```````````````````````````````` + +Example 519 + +```````````````````````````````` example +![[[foo](uri1)](uri2)](uri3) +. +

[foo](uri1)

+```````````````````````````````` diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/tests/trusted/tests/fixtures/fenced_admonition.txt b/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/tests/trusted/tests/fixtures/fenced_admonition.txt new file mode 100644 index 0000000000000000000000000000000000000000..0f962c5e4d44d9fa81effe866998e1fc6f88565d --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/tests/trusted/tests/fixtures/fenced_admonition.txt @@ -0,0 +1,129 @@ +# Admonition + +```````````````````````````````` example +```{unknown} Hi + +this is **strong** world +``` +. +
{unknown} Hi
+
+this is **strong** world
+
+```````````````````````````````` + +```````````````````````````````` example +``` +this is code +``` +. +
this is code
+
+```````````````````````````````` + + +```````````````````````````````` example +~~~{note} Warning + +message +~~~ +. +
+

Warning

+

message

+
+```````````````````````````````` + +```````````````````````````````` example +~~~{note} A **strong** title + +_message_ +~~~ +. +
+

A strong title

+

message

+
+```````````````````````````````` + +Test with code block. + +```````````````````````````````` example +```{note} + + print() +``` +. +
+

Note

+
print()
+
+```````````````````````````````` + +Test with no message. + +```````````````````````````````` example +~~~{note} Warning +~~~ +. +
+

Warning

+
+```````````````````````````````` + +Test with no ending fence + +```````````````````````````````` example +~~~{note} Warning +. +
+

Warning

+
+```````````````````````````````` + +Test with nested admonition + +```````````````````````````````` example +~~~~~~~{note} +~~~~~~{warning} +~~~~~{tip} +~~~~{caution} +~~~{hint} +``````{danger} +`````{attention} +````{important} +```{error} +``` +```` +````` +`````` +~~~ +~~~~ +~~~~~ +~~~~~~ +~~~~~~~ +. +
+

Note

+
+

Warning

+
+

Tip

+
+

Caution

+
+

Hint

+
+

Danger

+
````{important}
+```{error}
+```
+````
+
+
+
+
+
+
+
+```````````````````````````````` diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/tests/trusted/tests/fixtures/fenced_figure.txt b/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/tests/trusted/tests/fixtures/fenced_figure.txt new file mode 100644 index 0000000000000000000000000000000000000000..0fcd23c1f1280e6e9b17a43fbb8942d21b702254 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/tests/trusted/tests/fixtures/fenced_figure.txt @@ -0,0 +1,166 @@ +# Figure + +## No options + +```````````````````````````````` example +~~~{figure} picture.png +~~~ +. +
+
+
+```````````````````````````````` + +## Align options + +```````````````````````````````` example +~~~{figure} picture.png +:align: left +~~~ +. +
+
+
+```````````````````````````````` + + +```````````````````````````````` example +~~~{figure} picture.png +:align: invalid +~~~ +. +
+
+
+```````````````````````````````` + +## width and height + +```````````````````````````````` example +~~~{figure} picture.png +:width: 100 +:height: 50 +~~~ +. +
+
+
+```````````````````````````````` + +```````````````````````````````` example +~~~{figure} picture.png +:width: 100px +:height: 50px +~~~ +. +
+
+
+```````````````````````````````` + +```````````````````````````````` example +~~~{figure} picture.png +:figwidth: 400px +~~~ +. +
+
+
+```````````````````````````````` + +## alt option + +```````````````````````````````` example +~~~{figure} picture.png +:alt: description text +~~~ +. +
+
description text
+
+```````````````````````````````` + +## target option + +```````````````````````````````` example +~~~{figure} picture.png +:target: https://lepture.com +~~~ +. +
+ +
+```````````````````````````````` + +## caption + +```````````````````````````````` example +~~~{figure} picture.png +a caption with **emphasis** text +~~~ +. +
+
+
a caption with emphasis text
+
+```````````````````````````````` + +## legend + +```````````````````````````````` example +~~~{figure} picture.png +a caption with **emphasis** text + +> quote +~~~ +. +
+
+
a caption with emphasis text
+
+
+

quote

+
+
+
+```````````````````````````````` + + +```````````````````````````````` example +~~~{figure} picture.png +> quote +~~~ +. +
+
+
+```````````````````````````````` + +## all options + + +```````````````````````````````` example +~~~{figure} picture.png +:figwidth: 400px +:figclass: all-options +:target: https://lepture.com +:alt: description +:align: left +:width: 100 +:height: 50 + +a caption with **emphasis** text + +> quote +~~~ +. +
+description +
a caption with emphasis text
+
+
+

quote

+
+
+
+```````````````````````````````` diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/tests/trusted/tests/fixtures/fenced_image.txt b/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/tests/trusted/tests/fixtures/fenced_image.txt new file mode 100644 index 0000000000000000000000000000000000000000..afec622ce413acb5fcbb287e020c4588e892de8c --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/tests/trusted/tests/fixtures/fenced_image.txt @@ -0,0 +1,102 @@ +# Image + +## No options + +```````````````````````````````` example +~~~{image} picture.png +~~~ +. +
+```````````````````````````````` + +## Align options + +```````````````````````````````` example +~~~{image} picture.png +:align: left +~~~ +. +
+```````````````````````````````` + + +```````````````````````````````` example +~~~{image} picture.png +:align: invalid +~~~ +. +
+```````````````````````````````` + +## width and height + +```````````````````````````````` example +~~~{image} picture.png +:width: 100 +:height: 50 +~~~ +. +
+```````````````````````````````` + +```````````````````````````````` example +~~~{image} picture.png +:width: 100px +:height: 50px +~~~ +. +
+```````````````````````````````` + +## alt option + +```````````````````````````````` example +~~~{image} picture.png +:alt: description text +~~~ +. +
description text
+```````````````````````````````` + +## target option + +```````````````````````````````` example +~~~{image} picture.png +:target: https://lepture.com +~~~ +. + +```````````````````````````````` + +## all options + +```````````````````````````````` example +~~~{image} picture.png +:target: https://lepture.com +:alt: description +:align: left +:width: 100 +:height: 50 +~~~ +. +description +```````````````````````````````` + +## ampersand in source + +```````````````````````````````` example +~~~{image} https://example.com/picture.png?foo=qux&test=me +~~~ +. +
+```````````````````````````````` + +## ampersand in target + +```````````````````````````````` example +~~~{image} picture.png +:target: https://example.com/rickroll?a=1&b=2 +~~~ +. + +```````````````````````````````` diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/tests/trusted/tests/fixtures/fenced_toc.txt b/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/tests/trusted/tests/fixtures/fenced_toc.txt new file mode 100644 index 0000000000000000000000000000000000000000..1744000ce6ca473d1d75fb2d9388d46d3463a64c --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/tests/trusted/tests/fixtures/fenced_toc.txt @@ -0,0 +1,237 @@ +# Table of Contents + +## No TOC + +```````````````````````````````` example +none +. +

none

+```````````````````````````````` + +```````````````````````````````` example +# H1 +## H2 +. +

H1

+

H2

+```````````````````````````````` + + +## Simple TOC + +```````````````````````````````` example +~~~{toc} +~~~ + +# H1 +## H2 +. +
+Table of Contents + +
+

H1

+

H2

+```````````````````````````````` + +## Invalid Option + +```````````````````````````````` example +# H1 +## H2 + +~~~{toc} +:max-level: s +~~~ +. +

H1

+

H2

+
"max-level" option MUST be integer
+```````````````````````````````` + +```````````````````````````````` example +# H1 +## H2 + +~~~{toc} +:max-level: 9 +~~~ +. +

H1

+

H2

+
"max-level" option MUST be <= 3
+```````````````````````````````` + +```````````````````````````````` example +# H1 +## H2 + +~~~{toc} +:min-level: 2 +:max-level: 1 +~~~ +. +

H1

+

H2

+
"min-level" option MUST be less than "max-level" option
+```````````````````````````````` + +## Complex + +```````````````````````````````` example +# H1 +## H2 +### H3 +#### H4 +# H1 B +# H1 `C` + +```{toc} Contents +``` +. +

H1

+

H2

+

H3

+

H4

+

H1 B

+

H1 C

+
+Contents + +
+```````````````````````````````` + +## Insane + +```````````````````````````````` example +# H1 +### H3 +## H2 +#### H4 +### H3 B +# H1 B + +```{toc} +``` +. +

H1

+

H3

+

H2

+

H4

+

H3 B

+

H1 B

+
+Table of Contents + +
+```````````````````````````````` + +```````````````````````````````` example +### H3 +## H2 +# H1 + +```{toc} +``` +. +

H3

+

H2

+

H1

+
+Table of Contents + +
+```````````````````````````````` + +## Link in Heading + + +```````````````````````````````` example +# [foo](/bar) + +```{toc} +``` +. +

foo

+
+Table of Contents + +
+```````````````````````````````` + +## HTML in Heading + +```````````````````````````````` example +# H1 +```{toc} +``` +. +

H1

+
+Table of Contents + +
+```````````````````````````````` + +## Collapse TOC + +```````````````````````````````` example + +```{toc} +:collapse: +``` + +# H1 +## H2 +. +
+Table of Contents + +
+

H1

+

H2

+```````````````````````````````` diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/tests/trusted/tests/fixtures/fix-commonmark.txt b/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/tests/trusted/tests/fixtures/fix-commonmark.txt new file mode 100644 index 0000000000000000000000000000000000000000..c7870065cc61e07f114050eaaecf60d3db5cbdf9 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/tests/trusted/tests/fixtures/fix-commonmark.txt @@ -0,0 +1,123 @@ +Fix problems that commonmark has. + + +## Links + +Links can't contain links. + +```````````````````````````````` example +[](/foo) +. +

<https://example.com>

+```````````````````````````````` + +```````````````````````````````` example +[](/foo) +. +

<name@example.com>

+```````````````````````````````` + +## Emphasis + +`` doesn't contain ``, `` doesn't contain ``. + +```````````````````````````````` example +*_em_* __**strong**__ ______m______ +. +

_em_ **strong** ______m______

+```````````````````````````````` + +### Non aggressive emphasis + +```````````````````````````````` example +*a **b c* d** +. +

a **b c d**

+```````````````````````````````` + +While CommonMark would render it into: + +``` +

a b c d

+``` + +```````````````````````````````` example +*a **b c* d** +. +

a **b c d**

+```````````````````````````````` + +While CommonMark would render it into: + +``` +

a b c d

+``` + +What if the string is: + +```````````````````````````````` example +*a **b c* d +. +

a **b c d

+```````````````````````````````` + +CommonMark would still be a mess: + +``` +

*a *b c d

+``` + + +## Max depth + + +```````````````````````````````` example +> > > > > > > > b +. +
+
+
+
+
+
+

> > b

+
+
+
+
+
+
+```````````````````````````````` + + +```````````````````````````````` example +- a + - b + - c + - d + - e + - f + - g + - h +. +
    +
  • a
      +
    • b
        +
      • c
          +
        • d
            +
          • e
              +
            • f +- g +- h
            • +
            +
          • +
          +
        • +
        +
      • +
      +
    • +
    +
  • +
+```````````````````````````````` diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/tests/trusted/tests/fixtures/footnotes.txt b/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/tests/trusted/tests/fixtures/footnotes.txt new file mode 100644 index 0000000000000000000000000000000000000000..485cfd87c0a18859af15ec52b8baacad5c44fe6c --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/tests/trusted/tests/fixtures/footnotes.txt @@ -0,0 +1,45 @@ +# Footnotes + +```````````````````````````````` example +none [^1] +. +

none [^1]

+```````````````````````````````` + +```````````````````````````````` example +oneline [^1] + +[^1]: foo +. +

oneline 1

+
+
    +
  1. foo↩

  2. +
+
+```````````````````````````````` + +```````````````````````````````` example +multiple lines [^1] + +[^1]: foo + + one + + two + + three + + four +. +

multiple lines 1

+
four
+
+
    +
  1. foo

    +

    one

    +

    two

    +

    three↩

  2. +
+
+```````````````````````````````` diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/tests/trusted/tests/fixtures/hook_toc.txt b/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/tests/trusted/tests/fixtures/hook_toc.txt new file mode 100644 index 0000000000000000000000000000000000000000..62a1a1ec79dacaf8854a67e3b48f5a1c1e9d2f4b --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/tests/trusted/tests/fixtures/hook_toc.txt @@ -0,0 +1,122 @@ +# Table of Contents + +## Simple TOC + +```````````````````````````````` example +# H1 + +content + +## H2 +. +

H1

+

content

+

H2

+ +```````````````````````````````` + +## Complex TOC + +```````````````````````````````` example +# H1 +## H2 +### H3 +#### H4 +# H1 B +# H1 `C` +. +

H1

+

H2

+

H3

+

H4

+

H1 B

+

H1 C

+ +```````````````````````````````` + +## Insane TOC + +```````````````````````````````` example +# H1 +### H3 +## H2 +#### H4 +### H3 B +# H1 B +. +

H1

+

H3

+

H2

+

H4

+

H3 B

+

H1 B

+ +```````````````````````````````` + +```````````````````````````````` example +### H3 +## H2 +# H1 +. +

H3

+

H2

+

H1

+ +```````````````````````````````` + +## Link in Heading + + +```````````````````````````````` example +# [foo](/bar) +. +

foo

+ +```````````````````````````````` + +## HTML in Heading + +```````````````````````````````` example +# H1 +. +

H1

+ +```````````````````````````````` diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/tests/trusted/tests/fixtures/include/hello.md b/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/tests/trusted/tests/fixtures/include/hello.md new file mode 100644 index 0000000000000000000000000000000000000000..5e3d2769d88dd761efbd358b5dd0cb095d652294 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/tests/trusted/tests/fixtures/include/hello.md @@ -0,0 +1 @@ +> hello diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/tests/trusted/tests/fixtures/include/hello.txt b/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/tests/trusted/tests/fixtures/include/hello.txt new file mode 100644 index 0000000000000000000000000000000000000000..ce013625030ba8dba906f756967f9e9ca394464a --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/tests/trusted/tests/fixtures/include/hello.txt @@ -0,0 +1 @@ +hello diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/tests/trusted/tests/fixtures/include/text.html b/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/tests/trusted/tests/fixtures/include/text.html new file mode 100644 index 0000000000000000000000000000000000000000..da12a4c59bef8e4cc80b93ee6c98ebf6e9a10372 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/tests/trusted/tests/fixtures/include/text.html @@ -0,0 +1 @@ +
include html
diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/tests/trusted/tests/fixtures/include/text.md b/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/tests/trusted/tests/fixtures/include/text.md new file mode 100644 index 0000000000000000000000000000000000000000..e9faa6cc816e06f743ffb9a1ae753a209607840e --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/tests/trusted/tests/fixtures/include/text.md @@ -0,0 +1,12 @@ +# Include + +.. include:: ./text.md + +.. include:: ./not-exist.md + +.. include:: ./text.html + :encoding: utf-8 + +.. include:: ./hello.md + +.. include:: ../rst_toc.txt diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/tests/trusted/tests/fixtures/insert.txt b/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/tests/trusted/tests/fixtures/insert.txt new file mode 100644 index 0000000000000000000000000000000000000000..74d02058f0a66e5598e91d8a84429d17b7c4b62a --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/tests/trusted/tests/fixtures/insert.txt @@ -0,0 +1,62 @@ +# Insert + +```````````````````````````````` example +^^insert me +. +

^^insert me

+```````````````````````````````` + + +## normal insert + +```````````````````````````````` example +^^insert me^^ +. +

insert me

+```````````````````````````````` + +```````````````````````````````` example +foo ^^insert me^^ +. +

foo insert me

+```````````````````````````````` + +```````````````````````````````` example +^^insert me^^foo +. +

insert mefoo

+```````````````````````````````` + +```````````````````````````````` example +^^insert me^^^ +. +

^^insert me^^^

+```````````````````````````````` + +## escape insert + +```````````````````````````````` example +^^insert me\^^^ +. +

insert me^

+```````````````````````````````` + +```````````````````````````````` example +^^insert \^\^ me^^ +. +

insert ^^ me

+```````````````````````````````` + +## insert link + +```````````````````````````````` example +^^insert [me^^](/) +. +

insert [me](/)

+```````````````````````````````` + +```````````````````````````````` example +^^[hello](/)^^ +. +

hello

+```````````````````````````````` diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/tests/trusted/tests/fixtures/mark.txt b/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/tests/trusted/tests/fixtures/mark.txt new file mode 100644 index 0000000000000000000000000000000000000000..9c8d2fbc1bf286f937a2ed288f5d497bcfca2136 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/tests/trusted/tests/fixtures/mark.txt @@ -0,0 +1,61 @@ +# Mark + +```````````````````````````````` example +==mark me +. +

==mark me

+```````````````````````````````` + +## normal mark + +```````````````````````````````` example +==mark me== +. +

mark me

+```````````````````````````````` + +```````````````````````````````` example +foo ==mark me== +. +

foo mark me

+```````````````````````````````` + +```````````````````````````````` example +==mark me==foo +. +

mark mefoo

+```````````````````````````````` + +```````````````````````````````` example +==mark me=== +. +

==mark me===

+```````````````````````````````` + +## escape mark + +```````````````````````````````` example +==mark me\=== +. +

mark me=

+```````````````````````````````` + +```````````````````````````````` example +==mark \=\= me== +. +

mark == me

+```````````````````````````````` + +## mark link + +```````````````````````````````` example +==mark [me==](/) +. +

mark [me](/)

+```````````````````````````````` + +```````````````````````````````` example +==[hello](/)== +. +

hello

+```````````````````````````````` diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/tests/trusted/tests/fixtures/math.txt b/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/tests/trusted/tests/fixtures/math.txt new file mode 100644 index 0000000000000000000000000000000000000000..e7afaf9d1d2757c25e797b47ef4803bdeee503ef --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/tests/trusted/tests/fixtures/math.txt @@ -0,0 +1,57 @@ +# Math + +## Block Math + +```````````````````````````````` example +$$ +. +

$$

+```````````````````````````````` + + +```````````````````````````````` example +$$ +\operatorname{ker} f=\{g\in G:f(g)=e_{H}\}{\mbox{.}} +$$ +. +
$$ +\operatorname{ker} f=\{g\in G:f(g)=e_{H}\}{\mbox{.}} +$$
+```````````````````````````````` + +```````````````````````````````` example +$$ +foo +$$ +bar +. +
$$ +foo +$$
+

bar

+```````````````````````````````` + +```````````````````````````````` example +$$ +foo +bar +$$ +. +
$$ +foo +bar +$$
+```````````````````````````````` + + +## Inline Math + +```````````````````````````````` example +The homomorphism $f$ is injective if and only if its kernel is only the +singleton set $e_G$, because otherwise $\exists a,b\in G$ +with $a\neq b$ such that $f(a)=f(b)$. +. +

The homomorphism \(f\) is injective if and only if its kernel is only the +singleton set \(e_G\), because otherwise \(\exists a,b\in G\) +with \(a\neq b\) such that \(f(a)=f(b)\).

+```````````````````````````````` diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/tests/trusted/tests/fixtures/renderer_markdown.txt b/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/tests/trusted/tests/fixtures/renderer_markdown.txt new file mode 100644 index 0000000000000000000000000000000000000000..fd618f9f281f83c0e5f2f51bcb19080e4188011a --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/tests/trusted/tests/fixtures/renderer_markdown.txt @@ -0,0 +1,299 @@ +# MarkdownRenderer + + +## inline + +```````````````````````````````` example +this is _em_, **strong**, and `code` +. +this is *em*, **strong**, and `code` +```````````````````````````````` + +## links + +```````````````````````````````` example +[link], [link][], [text][link], [link](/foo), [link](/foo "title") + +[link]: /url +. +[link][link], [link][link], [text][link], [link](/foo), [link](/foo "title") + +[link]: /url +```````````````````````````````` + +```````````````````````````````` example +[link], [link](https://foo(bar "title") + +[link]: /url "title" +. +[link][link], [link]( "title") + +[link]: /url "title" +```````````````````````````````` + +```````````````````````````````` example +[https://lepture.com](https://lepture.com) + + + + [demo@example.com](mailto:demo@example.com) +. + + + + + +```````````````````````````````` + +## images + +```````````````````````````````` example +[link]: /url + +![link], ![link][], ![alt][link] +. +![link][link], ![link][link], ![alt][link] + +[link]: /url +```````````````````````````````` + +## linebreak + +```````````````````````````````` example +foo\ +bar +. +foo +bar +```````````````````````````````` + +## html + +```````````````````````````````` example +inline html text + +and block html + +
hi
+. +inline html text + +and block html + +
hi
+```````````````````````````````` + +## heading + +```````````````````````````````` example +# h1 +## h2 +### h3 +#### h4 +##### h5 +###### h6 + +h1 +== +. +# h1 + +## h2 + +### h3 + +#### h4 + +##### h5 + +###### h6 + +# h1 +```````````````````````````````` + +## thematic break + +```````````````````````````````` example +hi +*** +. +hi + +*** +```````````````````````````````` + +## code + +```````````````````````````````` example +start + + def foo(): + pass + +end +. +start + +``` +def foo(): + pass +``` + +end +```````````````````````````````` + +```````````````````````````````` example +start +```py +def foo(): + pass +``` +end +. +start + +```py +def foo(): + pass +``` + +end +```````````````````````````````` + +```````````````````````````````` example +indent code + + markdown + ``` + fenced +. +indent code + +~~~ +markdown +``` +fenced +~~~ +```````````````````````````````` + +```````````````````````````````` example +indent code + + markdown + ~~~ + fenced +. +indent code + +``` +markdown +~~~ +fenced +``` +```````````````````````````````` + +```````````````````````````````` example +indent code + + markdown + ``` + fenced + ~~~ +. +indent code + +```` +markdown +``` +fenced +~~~ +```` +```````````````````````````````` + + +## quote + +```````````````````````````````` example +> quote +. +> quote +```````````````````````````````` + +```````````````````````````````` example +hello +> quote +. +hello + +> quote +```````````````````````````````` + +> quote + +> quote +> +> continuation +. +> quote + +> quote +> +> continuation + +## list + +```````````````````````````````` example +- list ++ list +. +- list + ++ list +```````````````````````````````` + +```````````````````````````````` example +- item 1 + item 2 +. +- item 1 + item 2 +```````````````````````````````` + +```````````````````````````````` example +- item 1 + + item 2 +- item 3 +. +- item 1 + + item 2 + +- item 3 +```````````````````````````````` + +```````````````````````````````` example +- item 1 + 1. item 2 +. +- item 1 + 1. item 2 +```````````````````````````````` + +```````````````````````````````` example +- item 1 + + 2. item 2 +. +- item 1 + + 2. item 2 +```````````````````````````````` + +```````````````````````````````` example +- list +- +. +- list +- +```````````````````````````````` diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/tests/trusted/tests/fixtures/renderer_rst.txt b/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/tests/trusted/tests/fixtures/renderer_rst.txt new file mode 100644 index 0000000000000000000000000000000000000000..1b2499ddb74fc532191d296612fd19687224ec5b --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/tests/trusted/tests/fixtures/renderer_rst.txt @@ -0,0 +1,250 @@ +# RSTRenderer + +## inline + +```````````````````````````````` example +this is _em_, **strong**, and `code` +. +this is *em*, **strong**, and ``code`` +```````````````````````````````` + +```````````````````````````````` example +| escape | +. +\| escape \| +```````````````````````````````` + +## links + +```````````````````````````````` example +this is [link][] and [link](/foo) + +[link]: /url +. +this is `link
`__ and `link `__ +```````````````````````````````` + +## images + +```````````````````````````````` example +this is inline ![alt _text_](/foo) +. +this is inline |img-0| + +.. |img-0| image:: /foo + :alt: alt *text* +```````````````````````````````` + +```````````````````````````````` example +this is figure + +![alt _text_](/foo) +. +this is figure + +.. figure:: /foo + + alt *text* +```````````````````````````````` + +```````````````````````````````` example +this is figure + +![alt _text_](/foo "title") +. +this is figure + +.. figure:: /foo + :alt: title + + alt *text* +```````````````````````````````` + + +## html + +```````````````````````````````` example +ignore inline html text + +but show block html + +
hi
+. +ignore inline html text + +but show block html + +.. raw:: html + +
hi
+```````````````````````````````` + +## line break + +```````````````````````````````` example +hello +world +. +| hello +| world +```````````````````````````````` + +## heading + +```````````````````````````````` example +# h1 +## h2 +### h3 +#### h4 +##### h5 +###### h6 +. +h1 +== + +h2 +-- + +h3 +~~ + +h4 +^^ + +h5 +"" + +h6 +'' +```````````````````````````````` + +## thematic break + +```````````````````````````````` example +hi +*** +. +hi + +-------------- +```````````````````````````````` + +## code + +```````````````````````````````` example +start + + def foo(): + pass + +end +. +start + +:: + + def foo(): + pass + +end +```````````````````````````````` + +```````````````````````````````` example +start + +```py +def foo(): + pass +``` + +end +. +start + +.. code:: py + + def foo(): + pass + +end +```````````````````````````````` + + +## quote + +```````````````````````````````` example +> quote +. + quote +```````````````````````````````` + +```````````````````````````````` example +hello + +> quote +. +hello + + quote +```````````````````````````````` + +```````````````````````````````` example +> hello + +> quote +. + hello + +.. + + quote +```````````````````````````````` + +## list + +```````````````````````````````` example +- list ++ list +. +- list + ++ list +```````````````````````````````` + +```````````````````````````````` example +- item 1 + item 2 +. +- item 1 item 2 +```````````````````````````````` + +```````````````````````````````` example +- item 1 + + item 2 +- item 3 +. +- item 1 + + item 2 + +- item 3 +```````````````````````````````` + +```````````````````````````````` example +- item 1 + 1. item 2 +. +- item 1 + 1. item 2 +```````````````````````````````` + +```````````````````````````````` example +- item 1 + + 1. item 2 +. +- item 1 + + 1. item 2 +```````````````````````````````` diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/tests/trusted/tests/fixtures/rst_admonition.txt b/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/tests/trusted/tests/fixtures/rst_admonition.txt new file mode 100644 index 0000000000000000000000000000000000000000..b29bda3046fdb97802fefc9a7d16a9439d9efeb6 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/tests/trusted/tests/fixtures/rst_admonition.txt @@ -0,0 +1,46 @@ +# Admonition + +```````````````````````````````` example +.. hello:: Warning + + message +. +
..  hello:: Warning
+
+    message
+
+```````````````````````````````` + +```````````````````````````````` example +.. note:: Warning + + message +. +
+

Warning

+

message

+
+```````````````````````````````` + +Test with code block. + +```````````````````````````````` example +.. note:: + + print() +. +
+

Note

+
print()
+
+```````````````````````````````` + +Test with no message. + +```````````````````````````````` example +.. note:: Warning +. +
+

Warning

+
+```````````````````````````````` diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/tests/trusted/tests/fixtures/rst_toc.txt b/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/tests/trusted/tests/fixtures/rst_toc.txt new file mode 100644 index 0000000000000000000000000000000000000000..d65e7516398316de9532f5f52cd0ccfe182b86f1 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/tests/trusted/tests/fixtures/rst_toc.txt @@ -0,0 +1,223 @@ +# Table of Contents + +## No TOC + +```````````````````````````````` example +none +. +

none

+```````````````````````````````` + +```````````````````````````````` example +# H1 +## H2 +. +

H1

+

H2

+```````````````````````````````` + + +## Simple TOC + +```````````````````````````````` example +.. toc:: + +# H1 +## H2 +. +
+Table of Contents + +
+

H1

+

H2

+```````````````````````````````` + +## Invalid Option + +```````````````````````````````` example +# H1 +## H2 + +.. toc:: + :max-level: s +. +

H1

+

H2

+
"max-level" option MUST be integer
+```````````````````````````````` + +```````````````````````````````` example +# H1 +## H2 +.. toc:: + :max-level: 9 +. +

H1

+

H2

+
"max-level" option MUST be <= 3
+```````````````````````````````` + +```````````````````````````````` example +# H1 +## H2 +.. toc:: + :min-level: 2 + :max-level: 1 +. +

H1

+

H2

+
"min-level" option MUST be less than "max-level" option
+```````````````````````````````` + + +## Complex + +```````````````````````````````` example +# H1 +## H2 +### H3 +#### H4 +# H1 B +# H1 `C` + +.. toc:: Contents + :max-level: 3 +. +

H1

+

H2

+

H3

+

H4

+

H1 B

+

H1 C

+
+Contents + +
+```````````````````````````````` + +## Insane + +```````````````````````````````` example +# H1 +### H3 +## H2 +#### H4 +### H3 B +# H1 B +.. toc:: +. +

H1

+

H3

+

H2

+

H4

+

H3 B

+

H1 B

+
+Table of Contents + +
+```````````````````````````````` + +```````````````````````````````` example +### H3 +## H2 +# H1 +.. toc:: +. +

H3

+

H2

+

H1

+
+Table of Contents + +
+```````````````````````````````` + +## Link in Heading + + +```````````````````````````````` example +# [foo](/bar) +.. toc:: +. +

foo

+
+Table of Contents + +
+```````````````````````````````` + +## HTML in Heading + +```````````````````````````````` example +# H1 +.. toc:: +. +

H1

+
+Table of Contents + +
+```````````````````````````````` + +## Collapse TOC + +```````````````````````````````` example +.. toc:: + :collapse: + +# H1 +## H2 +. +
+Table of Contents + +
+

H1

+

H2

+```````````````````````````````` diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/tests/trusted/tests/fixtures/ruby.txt b/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/tests/trusted/tests/fixtures/ruby.txt new file mode 100644 index 0000000000000000000000000000000000000000..d89ebe28e1161ec3915768d72303feaa168f3c63 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/tests/trusted/tests/fixtures/ruby.txt @@ -0,0 +1,64 @@ +# Ruby + + +## ruby without link + +```````````````````````````````` example +[漢字(ㄏㄢˋㄗˋ)] +. +

漢字ㄏㄢˋㄗˋ

+```````````````````````````````` + +```````````````````````````````` example +[漢(ㄏㄢˋ)字(ㄗˋ)] +. +

漢ㄏㄢˋ字ㄗˋ

+```````````````````````````````` + +```````````````````````````````` example +[漢字(ㄏㄢˋㄗˋ)][] +. +

漢字ㄏㄢˋㄗˋ[]

+```````````````````````````````` + +```````````````````````````````` example +[漢字(ㄏㄢˋㄗˋ)][link] +. +

漢字ㄏㄢˋㄗˋ[link]

+```````````````````````````````` + +## ruby with link + +```````````````````````````````` example +[link]: /url + +[漢字(ㄏㄢˋㄗˋ)][link] +. +

漢字ㄏㄢˋㄗˋ

+```````````````````````````````` + +```````````````````````````````` example +[漢字(ㄏㄢˋㄗˋ)]() +. +

漢字ㄏㄢˋㄗˋ

+```````````````````````````````` + +```````````````````````````````` example +[漢字(ㄏㄢˋㄗˋ)](/url) +. +

漢字ㄏㄢˋㄗˋ

+```````````````````````````````` + +## ruby splits + +```````````````````````````````` example +[漢(かん)][字(じ)] +. +

漢かん字じ

+```````````````````````````````` + +```````````````````````````````` example +[[漢(かん)][字(じ)]](https://jisho.org/search/漢字) +. +

漢かん字じ

+```````````````````````````````` diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/tests/trusted/tests/fixtures/spoiler.txt b/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/tests/trusted/tests/fixtures/spoiler.txt new file mode 100644 index 0000000000000000000000000000000000000000..b1394193004aa9a896ac9212dcab200818613506 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/tests/trusted/tests/fixtures/spoiler.txt @@ -0,0 +1,74 @@ +# Spoiler + +## Block spoiler + +```````````````````````````````` example +>! hi +. +
+

hi

+
+```````````````````````````````` + + +```````````````````````````````` example +>! not +> spoiler +. +
+

! not +spoiler

+
+```````````````````````````````` + +```````````````````````````````` example +>! multiple +>! lines +. +
+

multiple +lines

+
+```````````````````````````````` + +```````````````````````````````` example +>! foo +>! +>! bar +. +
+

foo

+

bar

+
+```````````````````````````````` + +```````````````````````````````` example +>! foo +> +>! bar +. +
+

! foo

+

! bar

+
+```````````````````````````````` + +## Inline spoiler + +```````````````````````````````` example +hi >! hide !< +. +

hi hide

+```````````````````````````````` + +```````````````````````````````` example +hi >!hide !< +. +

hi hide

+```````````````````````````````` + +```````````````````````````````` example +hi >!hide!< +. +

hi hide

+```````````````````````````````` diff --git a/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/tests/trusted/tests/fixtures/strikethrough.txt b/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/tests/trusted/tests/fixtures/strikethrough.txt new file mode 100644 index 0000000000000000000000000000000000000000..007a7777aefe1f68e20026c6d87675a12623f1b8 --- /dev/null +++ b/tasks/lepture__mistune.bf54ef67.combine_file__0adn7wof/tests/trusted/tests/fixtures/strikethrough.txt @@ -0,0 +1,46 @@ +# Strikethrough + + +## strikethrough + +```````````````````````````````` example +~~delete me +. +

~~delete me

+```````````````````````````````` + +```````````````````````````````` example +~~delete me~~ +. +

delete me

+```````````````````````````````` + +```````````````````````````````` example +~~delete me~~~ +. +

~~delete me~~~

+```````````````````````````````` + +```````````````````````````````` example +~~delete me\~~~ +. +

delete me~

+```````````````````````````````` + +```````````````````````````````` example +~~delete \~\~ me~~ +. +

delete ~~ me

+```````````````````````````````` + +```````````````````````````````` example +~~delete [me~~](/) +. +

delete [me](/)

+```````````````````````````````` + +```````````````````````````````` example +~~[hello](/)~~ +. +

hello

+````````````````````````````````