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

stephenafamo / bob / 14841476257

05 May 2025 04:38PM UTC coverage: 41.442% (-0.3%) from 41.696%
14841476257

Pull #406

github

stephenafamo
Support query gen for `DELETE` queries in sqlite
Pull Request #406: Support query gen for `DELETE` queries in sqlite

21 of 161 new or added lines in 6 files covered. (13.04%)

7394 of 17842 relevant lines covered (41.44%)

210.18 hits per line

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

72.55
/dialect/sqlite/dialect/delete.go
1
package dialect
2

3
import (
4
        "context"
5
        "io"
6

7
        "github.com/stephenafamo/bob"
8
        "github.com/stephenafamo/bob/clause"
9
)
10

11
// Trying to represent the select query structure as documented in
12
// https://www.sqlite.org/lang_delete.html
13
type DeleteQuery struct {
14
        clause.With
15
        clause.From
16
        clause.Where
17
        clause.Returning
18
        clause.Limit
19
        clause.Offset
20
        bob.Load
21
        bob.EmbeddedHook
22
        bob.ContextualModdable[*DeleteQuery]
23
}
24

25
func (d DeleteQuery) WriteSQL(ctx context.Context, w io.Writer, dl bob.Dialect, start int) ([]any, error) {
2✔
26
        var err error
2✔
27
        var args []any
2✔
28

2✔
29
        if ctx, err = d.RunContextualMods(ctx, &d); err != nil {
2✔
30
                return nil, err
×
31
        }
×
32

33
        withArgs, err := bob.ExpressIf(ctx, w, dl, start+len(args), d.With,
2✔
34
                len(d.With.CTEs) > 0, "\n", "")
2✔
35
        if err != nil {
2✔
36
                return nil, err
×
37
        }
×
38
        args = append(args, withArgs...)
2✔
39

2✔
40
        w.Write([]byte("DELETE FROM"))
2✔
41

2✔
42
        tableArgs, err := bob.ExpressIf(ctx, w, dl, start+len(args), d.From, true, " ", "")
2✔
43
        if err != nil {
2✔
44
                return nil, err
×
45
        }
×
46
        args = append(args, tableArgs...)
2✔
47

2✔
48
        whereArgs, err := bob.ExpressIf(ctx, w, dl, start+len(args), d.Where,
2✔
49
                len(d.Where.Conditions) > 0, "\n", "")
2✔
50
        if err != nil {
2✔
51
                return nil, err
×
52
        }
×
53
        args = append(args, whereArgs...)
2✔
54

2✔
55
        retArgs, err := bob.ExpressIf(ctx, w, dl, start+len(args), d.Returning,
2✔
56
                len(d.Returning.Expressions) > 0, "\n", "")
2✔
57
        if err != nil {
2✔
58
                return nil, err
×
59
        }
×
60
        args = append(args, retArgs...)
2✔
61

2✔
62
        limitArgs, err := bob.ExpressIf(ctx, w, dl, start+len(args), d.Limit,
2✔
63
                d.Limit.Count != nil, "\n", "")
2✔
64
        if err != nil {
2✔
NEW
65
                return nil, err
×
NEW
66
        }
×
67
        args = append(args, limitArgs...)
2✔
68

2✔
69
        offsetArgs, err := bob.ExpressIf(ctx, w, dl, start+len(args), d.Offset,
2✔
70
                d.Offset.Count != nil, "\n", "")
2✔
71
        if err != nil {
2✔
NEW
72
                return nil, err
×
NEW
73
        }
×
74
        args = append(args, offsetArgs...)
2✔
75

2✔
76
        return args, nil
2✔
77
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc