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

stephenafamo / bob / 28859493523

07 Jul 2026 10:24AM UTC coverage: 47.546% (+0.5%) from 47.059%
28859493523

Pull #726

github

sandonemaki
perf(orm): drop reflection from AfterPreloader collect/load path

AfterPreloader stored the element/slice reflect.Type and rebuilt the
result slice with reflect.MakeSlice + per-element reflect.ValueOf().Set(),
and compared reflect.TypeOf(v) on every Collect.

Capture the [T, Ts] type parameters in closures in NewAfterPreloader so
collecting and assembling the loaded objects needs no reflection: Collect
type-asserts v.(T), and the result is returned as T (one) or Ts (many),
matching the previous behaviour.

Change the generated code to resolve column name -> index once up front
and scan by index, reducing column resolution from per-row to once per
query.
Pull Request #726: perf(orm): drop reflection from AfterPreloader collect/load path

43 of 75 new or added lines in 10 files covered. (57.33%)

3 existing lines in 3 files now uncovered.

11809 of 24837 relevant lines covered (47.55%)

721.82 hits per line

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

0.0
/dialect/sqlite/load.go
1
package sqlite
2

3
import (
4
        "github.com/stephenafamo/bob"
5
        "github.com/stephenafamo/bob/dialect/sqlite/dialect"
6
        "github.com/stephenafamo/bob/orm"
7
)
8

9
type (
10
        // Preloader builds a query mod that modifies the original query to retrieve related fields
11
        // while it can be used as a queryMod, it does not have any direct effect.
12
        // if using manually, the ApplyPreload method should be called
13
        // with the query's context AFTER other mods have been applied
14
        Preloader   = orm.Preloader[*dialect.SelectQuery]
15
        PreloadRel  = orm.PreloadRel[Expression]
16
        PreloadSide = orm.PreloadSide[Expression]
17
        // Settings for preloading relationships
18
        PreloadSettings = orm.PreloadSettings[*dialect.SelectQuery]
19
        // Modifies preloading relationships
20
        PreloadOption = orm.PreloadOption[*dialect.SelectQuery]
21
)
22

23
func PreloadOnly(cols ...string) PreloadOption {
×
24
        return orm.PreloadOnly[*dialect.SelectQuery](cols)
×
25
}
×
26

27
func PreloadExcept(cols ...string) PreloadOption {
×
28
        return orm.PreloadExcept[*dialect.SelectQuery](cols)
×
29
}
×
30

31
func PreloadWhere(f ...func(from, to string) []bob.Expression) PreloadOption {
×
32
        return orm.PreloadWhere[*dialect.SelectQuery](f)
×
33
}
×
34

35
func PreloadAs(alias string) PreloadOption {
×
36
        return orm.PreloadAs[*dialect.SelectQuery](alias)
×
37
}
×
38

NEW
39
func Preload[T orm.Preloadable, Ts ~[]T](rel orm.PreloadRel[Expression], cols []string, mapper orm.PreloadMapper[T], opts ...PreloadOption) Preloader {
×
NEW
40
        return orm.Preload[T, Ts](rel, cols, mapper, opts...)
×
UNCOV
41
}
×
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