From 944bee86f2250e9e46e2f66952c2ed43a8db9ec9 Mon Sep 17 00:00:00 2001 From: Justin Joyce Date: Fri, 26 Aug 2022 22:28:52 +0100 Subject: [PATCH] FIX/#399 --- docs/Release Notes/Change Log.md | 1 + opteryx/engine/planner/planner.py | 5 +++-- tests/sql_battery/test_battery_shape.py | 2 ++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/docs/Release Notes/Change Log.md b/docs/Release Notes/Change Log.md index 3977370cd..7e54b9912 100644 --- a/docs/Release Notes/Change Log.md +++ b/docs/Release Notes/Change Log.md @@ -27,6 +27,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - [[#334](https://github.com/mabel-dev/opteryx/issues/334)] All lists should be cast to lists of strings. ([@joocer](https://github.com/joocer)) - [[#382](https://github.com/mabel-dev/opteryx/issues/382)] `INNER JOIN` on `UNNEST` relation. ([@joocer](https://github.com/joocer)) - [[#320](https://github.com/mabel-dev/opteryx/issues/320)] Can't execute functions on results of `GROUP BY`. ([@joocer](https://github.com/joocer)) +- [[#399](https://github.com/mabel-dev/opteryx/issues/399)] Strings in double quotes aren't parsed. ([@joocer](https://github.com/joocer)) ## [0.2.0] - 2022-07-31 diff --git a/opteryx/engine/planner/planner.py b/opteryx/engine/planner/planner.py index 5476923c4..3d7f86db7 100644 --- a/opteryx/engine/planner/planner.py +++ b/opteryx/engine/planner/planner.py @@ -127,9 +127,10 @@ def _build_literal_node(self, value, alias: list = []): """ if value is None or value == "Null": return ExpressionTreeNode(NodeType.LITERAL_NONE) - if "SingleQuotedString" in value: + string_quoting = list(value.keys())[0] + if string_quoting in ("SingleQuotedString", "DoubleQuotedString"): # quoted strings are either VARCHAR or TIMESTAMP - str_value = value["SingleQuotedString"] + str_value = value[string_quoting] dte_value = dates.parse_iso(str_value) if dte_value: return ExpressionTreeNode( diff --git a/tests/sql_battery/test_battery_shape.py b/tests/sql_battery/test_battery_shape.py index 40dea7873..88df4f983 100644 --- a/tests/sql_battery/test_battery_shape.py +++ b/tests/sql_battery/test_battery_shape.py @@ -528,6 +528,8 @@ ("EXPLAIN SELECT * FROM $planets AS a INNER JOIN (SELECT id FROM $planets) AS b USING (id)", 3, 3), # ALIAS issues #408 ("SELECT $planets.* FROM $planets INNER JOIN (SELECT id FROM $planets) AS b USING (id)", 9, 21), + # DOUBLE QUOTED STRING #399 + ("SELECT birth_place['town'] FROM $astronauts WHERE birth_place['town'] = \"Rome\"", 1, 1), ] # fmt:on