SQLSelect — UNION storage/rendering broken
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 55/100
Research direction
Start in src/ClassModules/SQLSelect.cls and inspect Union, UnionString, aUnion, and the final SQL rendering order. Reproduce the issue with two selects followed by OrderBy, then verify that unions are initialized, all unions are rendered, and UNION clauses appear before ORDER BY.
Written by the indexing model from the issue text.
Description
SQLSelect: fix UNION storage/rendering and clause order
- Component:
src/ClassModules/SQLSelect.cls
Problems
- Stores the class identifier instead of the instance in
Union. - Name mismatch between
sUnionandaUnion; union array not initialized. UnionStringbuilds only one union; ORDER BY placed before UNION in final SQL.
Snippet (actual)
Public Sub Union(oSelect As SQLSelect, Optional sType = "")
Dim UnionArray() As Variant
UnionArray = Array(SQLSelect, sType) ' uses class name, not instance
' ...
End Sub
Private Function UnionString()
Dim NewSelect As iSQLQuery
aUnion = UnionArray(0)
Set NewSelect = aUnion(0)
UnionString = " UNION " & NewSelect.toString()
End Function
Expected (conceptual)
' Store (oSelect, sType)
aUnion = ArrayPush(aUnion, Array(oSelect, sType))
' Build all unions and place before ORDER BY
Function UnionString() As String
Dim i As Long, s As String
For i = 0 To UBound(aUnion)
Dim it As Variant: it = aUnion(i)
Dim q As iSQLQuery: Set q = it(0)
Dim t As String: t = it(1)
s = s & " UNION " & IIf(t <> "", t & " ", "") & q.toString()
Next i
UnionString = s
End Function
Steps to Reproduce
- Create two selects; call
First.Union Secondand thenOrderBy.
Actual
- UNION omitted/malformed;
ORDER BYrendered without merging unions.
Proposed Fix
- Store
(oSelect, sType); iterate unions; emit beforeOrderByString; initializeaUnion.
- Dominant language
- VBA
- Stars
- 90
- Forks
- 18
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Beakerboy/VBA-SQL-Library
-
Difficulty 1/5 Under an hour Newbie friendliness 55/100
Beakerboy/VBA-SQL-Library#68 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 55/100
Beakerboy/VBA-SQL-Library#67 ·
-
Difficulty 1/5 1-3 hours Newbie friendliness 52/100
Beakerboy/VBA-SQL-Library#66 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 55/100
Beakerboy/VBA-SQL-Library#65 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 55/100
Beakerboy/VBA-SQL-Library#64 ·
All issues in Beakerboy/VBA-SQL-Library
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
OpenLiberty/open-liberty#35839 ·
-
affects-9.0 found-by-ai may-affects-25.10 may-affects-26.3 may-affects-26.9 may-affects-7.5 may-affects-8.1 may-affects-8.5 severity/major sig/execution type/bug
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
-
Difficulty 1/5 Under an hour Newbie friendliness 92/100
antlr/grammars-v4#5014 · 1 comment ·
-
comp-query-execution fuzz
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
ClickHouse/ClickHouse#121303 · 3 comments ·