mirror of
https://github.com/gogf/gf.git
synced 2025-04-05 11:18:50 +08:00
comment updates for gdb.Builder (#2513)
This commit is contained in:
parent
12e9febe9e
commit
67e6772d88
@ -125,3 +125,17 @@ func Test_Model_Builder(t *testing.T) {
|
||||
t.Assert(args, []interface{}{1})
|
||||
})
|
||||
}
|
||||
|
||||
func Test_Safe_Builder(t *testing.T) {
|
||||
// test whether m.Builder() is chain safe
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
b := db.Model().Builder()
|
||||
b.Where("id", 1)
|
||||
_, args := b.Build()
|
||||
t.AssertNil(args)
|
||||
|
||||
b = b.Where("id", 1)
|
||||
_, args = b.Build()
|
||||
t.Assert(args, g.Slice{1})
|
||||
})
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ type WhereHolder struct {
|
||||
Prefix string // Field prefix, eg: "user.", "order.".
|
||||
}
|
||||
|
||||
// Builder creates and returns a WhereBuilder.
|
||||
// Builder creates and returns a WhereBuilder. Please note that the builder is chain-safe.
|
||||
func (m *Model) Builder() *WhereBuilder {
|
||||
b := &WhereBuilder{
|
||||
model: m,
|
||||
@ -34,8 +34,7 @@ func (m *Model) Builder() *WhereBuilder {
|
||||
return b
|
||||
}
|
||||
|
||||
// getBuilder creates and returns a cloned WhereBuilder of current WhereBuilder if `safe` is true,
|
||||
// or else it returns the current WhereBuilder.
|
||||
// getBuilder creates and returns a cloned WhereBuilder of current WhereBuilder
|
||||
func (b *WhereBuilder) getBuilder() *WhereBuilder {
|
||||
return b.Clone()
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user