Beakerboy / Beakerboy/VBA-SQL-Library

SQLSelect — UNION storage/rendering broken

オープン
#63 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
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`.

---

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

評価

技術スタック
sql
領域
database
issue の種類
バグ
難易度
2/5
見積もり時間
1〜3時間
活発さ
停滞
明瞭さ
明確に書かれている
初心者へのやさしさ
55/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。