• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

stephenafamo / bob / 14351235503

09 Apr 2025 07:14AM UTC coverage: 47.87% (-1.5%) from 49.32%
14351235503

Pull #388

github

stephenafamo
Implement parsing of SQLite SELECT queries
Pull Request #388: Implement parsing of SQLite SELECT queries

1093 of 2670 new or added lines in 29 files covered. (40.94%)

4 existing lines in 4 files now uncovered.

7471 of 15607 relevant lines covered (47.87%)

240.65 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

28.57
/dialect/sqlite/dialect/mods.go
1
package dialect
2

3
import (
4
        "github.com/stephenafamo/bob"
5
        "github.com/stephenafamo/bob/clause"
6
        "github.com/stephenafamo/bob/expr"
7
        "github.com/stephenafamo/bob/mods"
8
)
9

NEW
10
func With[Q interface{ AppendCTE(bob.Expression) }](name string, columns ...string) CTEChain[Q] {
×
11
        return CTEChain[Q](func() clause.CTE {
×
12
                return clause.CTE{
×
13
                        Name:    name,
×
14
                        Columns: columns,
×
15
                }
×
16
        })
×
17
}
18

19
type CTEChain[Q interface{ AppendCTE(bob.Expression) }] func() clause.CTE
20

21
func (c CTEChain[Q]) Apply(q Q) {
×
NEW
22
        q.AppendCTE(c())
×
23
}
×
24

25
func (c CTEChain[Q]) As(q bob.Query) CTEChain[Q] {
×
26
        cte := c()
×
27
        cte.Query = q
×
28
        return CTEChain[Q](func() clause.CTE {
×
29
                return cte
×
30
        })
×
31
}
32

33
func (c CTEChain[Q]) NotMaterialized() CTEChain[Q] {
×
34
        b := false
×
35
        cte := c()
×
36
        cte.Materialized = &b
×
37
        return CTEChain[Q](func() clause.CTE {
×
38
                return cte
×
39
        })
×
40
}
41

42
func (c CTEChain[Q]) Materialized() CTEChain[Q] {
×
43
        b := true
×
44
        cte := c()
×
45
        cte.Materialized = &b
×
46
        return CTEChain[Q](func() clause.CTE {
×
47
                return cte
×
48
        })
×
49
}
50

51
func OrAbort[Q interface{ SetOr(string) }]() bob.Mod[Q] {
×
52
        return bob.ModFunc[Q](func(i Q) {
×
53
                i.SetOr("ABORT")
×
54
        })
×
55
}
56

57
func OrFail[Q interface{ SetOr(string) }]() bob.Mod[Q] {
×
58
        return bob.ModFunc[Q](func(i Q) {
×
59
                i.SetOr("FAIL")
×
60
        })
×
61
}
62

63
func OrIgnore[Q interface{ SetOr(string) }]() bob.Mod[Q] {
×
64
        return bob.ModFunc[Q](func(i Q) {
×
65
                i.SetOr("IGNORE")
×
66
        })
×
67
}
68

69
func OrReplace[Q interface{ SetOr(string) }]() bob.Mod[Q] {
2✔
70
        return bob.ModFunc[Q](func(i Q) {
4✔
71
                i.SetOr("REPLACE")
2✔
72
        })
2✔
73
}
74

75
func OrRollback[Q interface{ SetOr(string) }]() bob.Mod[Q] {
×
76
        return bob.ModFunc[Q](func(i Q) {
×
77
                i.SetOr("ROLLBACK")
×
78
        })
×
79
}
80

81
type fromable interface {
82
        SetTable(any)
83
        SetTableAlias(alias string, columns ...string)
84
        SetIndexedBy(*string)
85
}
86

87
func From[Q fromable](table any) FromChain[Q] {
30✔
88
        return FromChain[Q](func() clause.From {
60✔
89
                return clause.From{
30✔
90
                        Table: table,
30✔
91
                }
30✔
92
        })
30✔
93
}
94

95
type FromChain[Q fromable] func() clause.From
96

97
func (f FromChain[Q]) Apply(q Q) {
30✔
98
        from := f()
30✔
99

30✔
100
        q.SetTable(from.Table)
30✔
101
        if from.Alias != "" {
36✔
102
                q.SetTableAlias(from.Alias, from.Columns...)
6✔
103
        }
6✔
104

105
        q.SetIndexedBy(from.IndexedBy)
30✔
106
}
107

108
func (f FromChain[Q]) As(alias string) FromChain[Q] {
6✔
109
        fr := f()
6✔
110
        fr.Alias = alias
6✔
111

6✔
112
        return FromChain[Q](func() clause.From {
12✔
113
                return fr
6✔
114
        })
6✔
115
}
116

117
func (f FromChain[Q]) NotIndexed() bob.Mod[Q] {
×
118
        i := ""
×
119
        fr := f()
×
120
        fr.SetIndexedBy(&i)
×
121

×
122
        return FromChain[Q](func() clause.From {
×
123
                return fr
×
124
        })
×
125
}
126

127
func (f FromChain[Q]) IndexedBy(indexName string) bob.Mod[Q] {
×
128
        fr := f()
×
129
        fr.SetIndexedBy(&indexName)
×
130

×
131
        return FromChain[Q](func() clause.From {
×
132
                return fr
×
133
        })
×
134
}
135

136
type JoinChain[Q interface{ AppendJoin(clause.Join) }] func() clause.Join
137

138
func (j JoinChain[Q]) Apply(q Q) {
×
139
        q.AppendJoin(j())
×
140
}
×
141

142
func (f JoinChain[Q]) NotIndexed() bob.Mod[Q] {
×
143
        i := ""
×
144
        jo := f()
×
145
        jo.To.SetIndexedBy(&i)
×
146

×
147
        return JoinChain[Q](func() clause.Join {
×
148
                return jo
×
149
        })
×
150
}
151

152
func (f JoinChain[Q]) IndexedBy(indexName string) bob.Mod[Q] {
×
153
        jo := f()
×
154
        jo.To.SetIndexedBy(&indexName)
×
155

×
156
        return JoinChain[Q](func() clause.Join {
×
157
                return jo
×
158
        })
×
159
}
160

161
func (j JoinChain[Q]) As(alias string) JoinChain[Q] {
×
162
        jo := j()
×
163
        jo.To.Alias = alias
×
164

×
165
        return JoinChain[Q](func() clause.Join {
×
166
                return jo
×
167
        })
×
168
}
169

170
func (j JoinChain[Q]) Natural() bob.Mod[Q] {
×
171
        jo := j()
×
172
        jo.Natural = true
×
173

×
174
        return mods.Join[Q](jo)
×
175
}
×
176

177
func (j JoinChain[Q]) On(on ...bob.Expression) bob.Mod[Q] {
×
178
        jo := j()
×
179
        jo.On = append(jo.On, on...)
×
180

×
181
        return mods.Join[Q](jo)
×
182
}
×
183

184
func (j JoinChain[Q]) OnEQ(a, b bob.Expression) bob.Mod[Q] {
×
185
        jo := j()
×
186
        jo.On = append(jo.On, expr.X[Expression, Expression](a).EQ(b))
×
187

×
188
        return mods.Join[Q](jo)
×
189
}
×
190

191
func (j JoinChain[Q]) Using(using ...string) bob.Mod[Q] {
×
192
        jo := j()
×
193
        jo.Using = using
×
194

×
195
        return mods.Join[Q](jo)
×
196
}
×
197

198
type CrossJoinChain[Q Joinable] func() clause.Join
199

200
func (j CrossJoinChain[Q]) Apply(q Q) {
2✔
201
        q.AppendJoin(j())
2✔
202
}
2✔
203

204
func (j CrossJoinChain[Q]) As(alias string, columns ...string) bob.Mod[Q] {
2✔
205
        jo := j()
2✔
206
        jo.To.Alias = alias
2✔
207
        jo.To.Columns = columns
2✔
208

2✔
209
        return CrossJoinChain[Q](func() clause.Join {
4✔
210
                return jo
2✔
211
        })
2✔
212
}
213

214
type Joinable interface{ AppendJoin(clause.Join) }
215

216
func Join[Q Joinable](typ string, e any) JoinChain[Q] {
×
217
        return JoinChain[Q](func() clause.Join {
×
218
                return clause.Join{
×
219
                        Type: typ,
×
220
                        To:   clause.From{Table: e},
×
221
                }
×
222
        })
×
223
}
224

225
func InnerJoin[Q Joinable](e any) JoinChain[Q] {
×
226
        return Join[Q](clause.InnerJoin, e)
×
227
}
×
228

229
func LeftJoin[Q Joinable](e any) JoinChain[Q] {
×
230
        return Join[Q](clause.LeftJoin, e)
×
231
}
×
232

233
func RightJoin[Q Joinable](e any) JoinChain[Q] {
×
234
        return Join[Q](clause.RightJoin, e)
×
235
}
×
236

237
func FullJoin[Q Joinable](e any) JoinChain[Q] {
×
238
        return Join[Q](clause.FullJoin, e)
×
239
}
×
240

241
func CrossJoin[Q Joinable](e any) CrossJoinChain[Q] {
2✔
242
        return CrossJoinChain[Q](func() clause.Join {
4✔
243
                return clause.Join{
2✔
244
                        Type: clause.CrossJoin,
2✔
245
                        To:   clause.From{Table: e},
2✔
246
                }
2✔
247
        })
2✔
248
}
249

250
type OrderBy[Q interface{ AppendOrder(bob.Expression) }] func() clause.OrderDef
251

252
func (s OrderBy[Q]) Apply(q Q) {
4✔
253
        q.AppendOrder(s())
4✔
254
}
4✔
255

256
func (o OrderBy[Q]) Collate(collationName string) OrderBy[Q] {
2✔
257
        order := o()
2✔
258
        order.Collation = collationName
2✔
259

2✔
260
        return OrderBy[Q](func() clause.OrderDef {
4✔
261
                return order
2✔
262
        })
2✔
263
}
264

265
func (o OrderBy[Q]) Asc() OrderBy[Q] {
2✔
266
        order := o()
2✔
267
        order.Direction = "ASC"
2✔
268

2✔
269
        return OrderBy[Q](func() clause.OrderDef {
4✔
270
                return order
2✔
271
        })
2✔
272
}
273

274
func (o OrderBy[Q]) Desc() OrderBy[Q] {
×
275
        order := o()
×
276
        order.Direction = "DESC"
×
277

×
278
        return OrderBy[Q](func() clause.OrderDef {
×
279
                return order
×
280
        })
×
281
}
282

283
func (o OrderBy[Q]) NullsFirst() OrderBy[Q] {
×
284
        order := o()
×
285
        order.Nulls = "FIRST"
×
286

×
287
        return OrderBy[Q](func() clause.OrderDef {
×
288
                return order
×
289
        })
×
290
}
291

292
func (o OrderBy[Q]) NullsLast() OrderBy[Q] {
×
293
        order := o()
×
294
        order.Nulls = "LAST"
×
295

×
296
        return OrderBy[Q](func() clause.OrderDef {
×
297
                return order
×
298
        })
×
299
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc