Beakerboy / Beakerboy/VBA-SQL-Library
SQLSelect — UNION storage/rendering broken
- 主要语言
- VBA
- 星标
- 90
- 派生
- 18
- PR 合并指标
- 30 天内没有已合并 PR
描述
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 `sUnion` and `aUnion`; union array not initialized.
- `UnionString` builds only one union; ORDER BY placed before UNION in final SQL.
### Snippet (actual)
```vb
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)
```vb
' 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
1) Create two selects; call `First.Union Second` and then `OrderBy`.
### Actual
- UNION omitted/malformed; `ORDER BY` rendered without merging unions.
### Proposed Fix
- Store `(oSelect, sType)`; iterate unions; emit before `OrderByString`; initialize `aUnion`.
---
贡献指南
这个仓库没有索引到贡献指南
调研方向
从 src/ClassModules/SQLSelect.cls 开始,检查 Union、UnionString、aUnion 以及最终的 SQL 渲染顺序。使用两个 SELECT 后跟 OrderBy 重现该问题,然后验证 unions 已初始化、所有 unions 都已渲染,并且 UNION 子句出现在 ORDER BY 之前。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- sql
- 领域
- database
- Issue 类型
- 缺陷
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 活跃度
- 停滞
- 描述清晰度
- 描述清楚
- 新手友好度
- 55/100