Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: publish to PyPI

on:
release:
types: [published]
types: ["published", "created", "released"]

jobs:
deploy:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "sqlquerypp"
version = "0.1.0a5"
version = "0.1.0a6"
description = "SQL query preprocessor for generating optimized queries"
readme = "README.md"
repository = "https://github.com/puzzleYOU/sqlquerypp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
b.col_b2
FROM
table_a AS a
LEFT JOIN table_b AS b ON b.col_a1 = a.col_a1 AND b.cond1 = %s AND b.cond2 = %s
LEFT JOIN table_b AS b ON b.col_a1 = a.col_a1 AND b.cond1 = %s AND b.cond2 = %s AND b.rangecond IN ('a', 'b')
WHERE
a.col_a1 = (SELECT * FROM loop_values LIMIT 1)
UNION ALL
Expand All @@ -28,7 +28,7 @@
FROM
all_entries
LEFT JOIN table_a AS a ON a.col_a1 = (SELECT col_a1 FROM loop_values WHERE col_a1 > all_entries.col_a1 LIMIT 1)
LEFT JOIN table_b AS b ON b.col_a1 = a.col_a1 AND b.cond1 = %s AND b.cond2 = %s
LEFT JOIN table_b AS b ON b.col_a1 = a.col_a1 AND b.cond1 = %s AND b.cond2 = %s AND b.rangecond IN ('a', 'b')
WHERE
n + 1 < (SELECT COUNT(*) FROM loop_values)
)
Expand Down Expand Up @@ -59,7 +59,7 @@ UNION ALL
b.col_b2
FROM
table_a AS a
LEFT JOIN table_b AS b ON b.col_a1 = a.col_a1 AND b.cond3 = %s AND b.cond4 = %s
LEFT JOIN table_b AS b ON b.col_a1 = a.col_a1 AND b.cond3 = %s AND b.cond4 = %s AND b.rangecond IN ('a', 'b')
WHERE
a.col_a1 = (SELECT * FROM loop_values LIMIT 1)
UNION ALL
Expand All @@ -72,7 +72,7 @@ UNION ALL
FROM
all_entries
LEFT JOIN table_a AS a ON a.col_a1 = (SELECT col_a1 FROM loop_values WHERE col_a1 > all_entries.col_a1 LIMIT 1)
LEFT JOIN table_b AS b ON b.col_a1 = a.col_a1 AND b.cond3 = %s AND b.cond4 = %s
LEFT JOIN table_b AS b ON b.col_a1 = a.col_a1 AND b.cond3 = %s AND b.cond4 = %s AND b.rangecond IN ('a', 'b')
WHERE
n + 1 < (SELECT COUNT(*) FROM loop_values)
)
Expand Down
2 changes: 2 additions & 0 deletions python/tests/mysql84/test_combined_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ def test_with_multiple_parameters_and_union_fragments(self) -> None:
ON b.col_a1 = a.col_a1
AND b.cond1 = %s
AND b.cond2 = %s
AND b.rangecond IN ('a', 'b')
WHERE a.col_a1 = $id
}
UNION ALL
Expand All @@ -29,6 +30,7 @@ def test_with_multiple_parameters_and_union_fragments(self) -> None:
ON b.col_a1 = a.col_a1
AND b.cond3 = %s
AND b.cond4 = %s
AND b.rangecond IN ('a', 'b')
WHERE a.col_a1 = $id
}
""",
Expand Down
7 changes: 6 additions & 1 deletion src/parser/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ pub struct ParserState<'t> {
statement: &'t String,
seen_token_state: Option<TokenState>,
combined_result_nodes_state: NodesState<CombinedResultNode>,
visiting_inner_query: bool,
offset: usize,
}

Expand All @@ -34,6 +35,7 @@ impl<'t> ParserState<'t> {
Self { statement,
seen_token_state: None,
combined_result_nodes_state: NodesState::new(),
visiting_inner_query: false,
offset: 0 }
}

Expand Down Expand Up @@ -180,7 +182,8 @@ impl<'t> ParserState<'t> {
},

(_, TokenState::OpeningParenthese(offset))
if handles_combined_result_node =>
if handles_combined_result_node
&& !self.visiting_inner_query =>
{
self.attach_iteration_query(*offset + 1)?
},
Expand All @@ -194,12 +197,14 @@ impl<'t> ParserState<'t> {
(_, TokenState::OpeningBrace(offset))
if handles_combined_result_node =>
{
self.visiting_inner_query = true;
self.mark_inner_query_begin(*offset)?
},

(_, TokenState::ClosingBrace(offset))
if handles_combined_result_node =>
{
self.visiting_inner_query = false;
self.finalize_combined_result_node(offset)
},

Expand Down
Loading