Beakerboy / Beakerboy/VBA-SQL-Library
SQLSelect — UNION storage/rendering broken
- Langage dominant
- VBA
- Étoiles
- 90
- Forks
- 18
- Métriques de merge des PR
- Aucune PR mergée en 30 j
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 `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`.
---
Guide de contribution
Aucun guide de contribution indexé pour ce dépôt
Piste de recherche
Commencez dans src/ClassModules/SQLSelect.cls et examinez Union, UnionString, aUnion ainsi que l’ordre final de génération du SQL. Reproduisez le problème avec deux SELECTs suivis de OrderBy, puis vérifiez que les unions sont initialisées, que toutes les unions sont générées et que les clauses UNION apparaissent avant ORDER BY.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- sql
- Domaine
- database
- Type d'issue
- Bug
- Difficulté
- 2/5
- Temps estimé
- 1-3 heures
- Activité
- À l'abandon
- Clarté
- Clairement spécifiée
- Accessibilité débutants
- 55/100