Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
B
beego
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
beego
Commits
658a671b
Commit
658a671b
authored
Oct 09, 2013
by
slene
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
all panic use Error
parent
aaf1490f
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
38 additions
and
37 deletions
+38
-37
db.go
orm/db.go
+16
-16
db_tables.go
orm/db_tables.go
+1
-1
models_boot.go
orm/models_boot.go
+2
-2
orm.go
orm/orm.go
+5
-5
orm_conds.go
orm/orm_conds.go
+7
-6
orm_object.go
orm/orm_object.go
+2
-2
orm_queryset.go
orm/orm_queryset.go
+1
-1
orm_raw.go
orm/orm_raw.go
+4
-4
No files found.
orm/db.go
View file @
658a671b
...
@@ -58,7 +58,7 @@ func (d *dbBase) collectValues(mi *modelInfo, ind reflect.Value, cols []string,
...
@@ -58,7 +58,7 @@ func (d *dbBase) collectValues(mi *modelInfo, ind reflect.Value, cols []string,
if
fi
,
_
=
mi
.
fields
.
GetByAny
(
column
);
fi
!=
nil
{
if
fi
,
_
=
mi
.
fields
.
GetByAny
(
column
);
fi
!=
nil
{
column
=
fi
.
column
column
=
fi
.
column
}
else
{
}
else
{
panic
(
fmt
.
Sprint
f
(
"wrong db field/column name `%s` for model `%s`"
,
column
,
mi
.
fullName
))
panic
(
fmt
.
Error
f
(
"wrong db field/column name `%s` for model `%s`"
,
column
,
mi
.
fullName
))
}
}
if
fi
.
dbcol
==
false
||
fi
.
auto
&&
skipAuto
{
if
fi
.
dbcol
==
false
||
fi
.
auto
&&
skipAuto
{
continue
continue
...
@@ -360,7 +360,7 @@ func (d *dbBase) UpdateBatch(q dbQuerier, qs *querySet, mi *modelInfo, cond *Con
...
@@ -360,7 +360,7 @@ func (d *dbBase) UpdateBatch(q dbQuerier, qs *querySet, mi *modelInfo, cond *Con
values
:=
make
([]
interface
{},
0
,
len
(
params
))
values
:=
make
([]
interface
{},
0
,
len
(
params
))
for
col
,
val
:=
range
params
{
for
col
,
val
:=
range
params
{
if
fi
,
ok
:=
mi
.
fields
.
GetByAny
(
col
);
ok
==
false
||
fi
.
dbcol
==
false
{
if
fi
,
ok
:=
mi
.
fields
.
GetByAny
(
col
);
ok
==
false
||
fi
.
dbcol
==
false
{
panic
(
fmt
.
Sprint
f
(
"wrong field/column name `%s`"
,
col
))
panic
(
fmt
.
Error
f
(
"wrong field/column name `%s`"
,
col
))
}
else
{
}
else
{
columns
=
append
(
columns
,
fi
.
column
)
columns
=
append
(
columns
,
fi
.
column
)
values
=
append
(
values
,
val
)
values
=
append
(
values
,
val
)
...
@@ -368,7 +368,7 @@ func (d *dbBase) UpdateBatch(q dbQuerier, qs *querySet, mi *modelInfo, cond *Con
...
@@ -368,7 +368,7 @@ func (d *dbBase) UpdateBatch(q dbQuerier, qs *querySet, mi *modelInfo, cond *Con
}
}
if
len
(
columns
)
==
0
{
if
len
(
columns
)
==
0
{
panic
(
"update params cannot empty"
)
panic
(
fmt
.
Errorf
(
"update params cannot empty"
)
)
}
}
tables
:=
newDbTables
(
mi
,
d
.
ins
)
tables
:=
newDbTables
(
mi
,
d
.
ins
)
...
@@ -438,7 +438,7 @@ func (d *dbBase) DeleteBatch(q dbQuerier, qs *querySet, mi *modelInfo, cond *Con
...
@@ -438,7 +438,7 @@ func (d *dbBase) DeleteBatch(q dbQuerier, qs *querySet, mi *modelInfo, cond *Con
}
}
if
cond
==
nil
||
cond
.
IsEmpty
()
{
if
cond
==
nil
||
cond
.
IsEmpty
()
{
panic
(
"delete operation cannot execute without condition"
)
panic
(
fmt
.
Errorf
(
"delete operation cannot execute without condition"
)
)
}
}
Q
:=
d
.
ins
.
TableQuote
()
Q
:=
d
.
ins
.
TableQuote
()
...
@@ -533,9 +533,9 @@ func (d *dbBase) ReadBatch(q dbQuerier, qs *querySet, mi *modelInfo, cond *Condi
...
@@ -533,9 +533,9 @@ func (d *dbBase) ReadBatch(q dbQuerier, qs *querySet, mi *modelInfo, cond *Condi
if
errTyp
{
if
errTyp
{
if
one
{
if
one
{
panic
(
fmt
.
Sprint
f
(
"wrong object type `%s` for rows scan, need *%s"
,
val
.
Type
(),
mi
.
fullName
))
panic
(
fmt
.
Error
f
(
"wrong object type `%s` for rows scan, need *%s"
,
val
.
Type
(),
mi
.
fullName
))
}
else
{
}
else
{
panic
(
fmt
.
Sprint
f
(
"wrong object type `%s` for rows scan, need *[]*%s or *[]%s"
,
val
.
Type
(),
mi
.
fullName
,
mi
.
fullName
))
panic
(
fmt
.
Error
f
(
"wrong object type `%s` for rows scan, need *[]*%s or *[]%s"
,
val
.
Type
(),
mi
.
fullName
,
mi
.
fullName
))
}
}
}
}
...
@@ -559,7 +559,7 @@ func (d *dbBase) ReadBatch(q dbQuerier, qs *querySet, mi *modelInfo, cond *Condi
...
@@ -559,7 +559,7 @@ func (d *dbBase) ReadBatch(q dbQuerier, qs *querySet, mi *modelInfo, cond *Condi
maps
[
fi
.
column
]
=
true
maps
[
fi
.
column
]
=
true
}
}
}
else
{
}
else
{
panic
(
fmt
.
Sprint
f
(
"wrong field/column name `%s`"
,
col
))
panic
(
fmt
.
Error
f
(
"wrong field/column name `%s`"
,
col
))
}
}
}
}
if
hasRel
{
if
hasRel
{
...
@@ -717,7 +717,7 @@ func (d *dbBase) GenerateOperatorSql(mi *modelInfo, fi *fieldInfo, operator stri
...
@@ -717,7 +717,7 @@ func (d *dbBase) GenerateOperatorSql(mi *modelInfo, fi *fieldInfo, operator stri
params
:=
getFlatParams
(
fi
,
args
,
tz
)
params
:=
getFlatParams
(
fi
,
args
,
tz
)
if
len
(
params
)
==
0
{
if
len
(
params
)
==
0
{
panic
(
fmt
.
Sprint
f
(
"operator `%s` need at least one args"
,
operator
))
panic
(
fmt
.
Error
f
(
"operator `%s` need at least one args"
,
operator
))
}
}
arg
:=
params
[
0
]
arg
:=
params
[
0
]
...
@@ -729,7 +729,7 @@ func (d *dbBase) GenerateOperatorSql(mi *modelInfo, fi *fieldInfo, operator stri
...
@@ -729,7 +729,7 @@ func (d *dbBase) GenerateOperatorSql(mi *modelInfo, fi *fieldInfo, operator stri
sql
=
fmt
.
Sprintf
(
"IN (%s)"
,
strings
.
Join
(
marks
,
", "
))
sql
=
fmt
.
Sprintf
(
"IN (%s)"
,
strings
.
Join
(
marks
,
", "
))
}
else
{
}
else
{
if
len
(
params
)
>
1
{
if
len
(
params
)
>
1
{
panic
(
fmt
.
Sprint
f
(
"operator `%s` need 1 args not %d"
,
operator
,
len
(
params
)))
panic
(
fmt
.
Error
f
(
"operator `%s` need 1 args not %d"
,
operator
,
len
(
params
)))
}
}
sql
=
d
.
ins
.
OperatorSql
(
operator
)
sql
=
d
.
ins
.
OperatorSql
(
operator
)
switch
operator
{
switch
operator
{
...
@@ -758,7 +758,7 @@ func (d *dbBase) GenerateOperatorSql(mi *modelInfo, fi *fieldInfo, operator stri
...
@@ -758,7 +758,7 @@ func (d *dbBase) GenerateOperatorSql(mi *modelInfo, fi *fieldInfo, operator stri
}
}
params
=
nil
params
=
nil
}
else
{
}
else
{
panic
(
fmt
.
Sprint
f
(
"operator `%s` need a bool value not `%T`"
,
operator
,
arg
))
panic
(
fmt
.
Error
f
(
"operator `%s` need a bool value not `%T`"
,
operator
,
arg
))
}
}
}
}
}
}
...
@@ -779,13 +779,13 @@ func (d *dbBase) setColsValues(mi *modelInfo, ind *reflect.Value, cols []string,
...
@@ -779,13 +779,13 @@ func (d *dbBase) setColsValues(mi *modelInfo, ind *reflect.Value, cols []string,
value
,
err
:=
d
.
convertValueFromDB
(
fi
,
val
,
tz
)
value
,
err
:=
d
.
convertValueFromDB
(
fi
,
val
,
tz
)
if
err
!=
nil
{
if
err
!=
nil
{
panic
(
fmt
.
Sprint
f
(
"Raw value: `%v` %s"
,
val
,
err
.
Error
()))
panic
(
fmt
.
Error
f
(
"Raw value: `%v` %s"
,
val
,
err
.
Error
()))
}
}
_
,
err
=
d
.
setFieldValue
(
fi
,
value
,
field
)
_
,
err
=
d
.
setFieldValue
(
fi
,
value
,
field
)
if
err
!=
nil
{
if
err
!=
nil
{
panic
(
fmt
.
Sprint
f
(
"Raw value: `%v` %s"
,
val
,
err
.
Error
()))
panic
(
fmt
.
Error
f
(
"Raw value: `%v` %s"
,
val
,
err
.
Error
()))
}
}
}
}
}
}
...
@@ -1034,7 +1034,7 @@ func (d *dbBase) ReadValues(q dbQuerier, qs *querySet, mi *modelInfo, cond *Cond
...
@@ -1034,7 +1034,7 @@ func (d *dbBase) ReadValues(q dbQuerier, qs *querySet, mi *modelInfo, cond *Cond
case
*
ParamsList
:
case
*
ParamsList
:
typ
=
3
typ
=
3
default
:
default
:
panic
(
fmt
.
Sprint
f
(
"unsupport read values type `%T`"
,
container
))
panic
(
fmt
.
Error
f
(
"unsupport read values type `%T`"
,
container
))
}
}
tables
:=
newDbTables
(
mi
,
d
.
ins
)
tables
:=
newDbTables
(
mi
,
d
.
ins
)
...
@@ -1117,7 +1117,7 @@ func (d *dbBase) ReadValues(q dbQuerier, qs *querySet, mi *modelInfo, cond *Cond
...
@@ -1117,7 +1117,7 @@ func (d *dbBase) ReadValues(q dbQuerier, qs *querySet, mi *modelInfo, cond *Cond
value
,
err
:=
d
.
convertValueFromDB
(
fi
,
val
,
tz
)
value
,
err
:=
d
.
convertValueFromDB
(
fi
,
val
,
tz
)
if
err
!=
nil
{
if
err
!=
nil
{
panic
(
fmt
.
Sprint
f
(
"db value convert failed `%v` %s"
,
val
,
err
.
Error
()))
panic
(
fmt
.
Error
f
(
"db value convert failed `%v` %s"
,
val
,
err
.
Error
()))
}
}
params
[
columns
[
i
]]
=
value
params
[
columns
[
i
]]
=
value
...
@@ -1132,7 +1132,7 @@ func (d *dbBase) ReadValues(q dbQuerier, qs *querySet, mi *modelInfo, cond *Cond
...
@@ -1132,7 +1132,7 @@ func (d *dbBase) ReadValues(q dbQuerier, qs *querySet, mi *modelInfo, cond *Cond
value
,
err
:=
d
.
convertValueFromDB
(
fi
,
val
,
tz
)
value
,
err
:=
d
.
convertValueFromDB
(
fi
,
val
,
tz
)
if
err
!=
nil
{
if
err
!=
nil
{
panic
(
fmt
.
Sprint
f
(
"db value convert failed `%v` %s"
,
val
,
err
.
Error
()))
panic
(
fmt
.
Error
f
(
"db value convert failed `%v` %s"
,
val
,
err
.
Error
()))
}
}
params
=
append
(
params
,
value
)
params
=
append
(
params
,
value
)
...
@@ -1146,7 +1146,7 @@ func (d *dbBase) ReadValues(q dbQuerier, qs *querySet, mi *modelInfo, cond *Cond
...
@@ -1146,7 +1146,7 @@ func (d *dbBase) ReadValues(q dbQuerier, qs *querySet, mi *modelInfo, cond *Cond
value
,
err
:=
d
.
convertValueFromDB
(
fi
,
val
,
tz
)
value
,
err
:=
d
.
convertValueFromDB
(
fi
,
val
,
tz
)
if
err
!=
nil
{
if
err
!=
nil
{
panic
(
fmt
.
Sprint
f
(
"db value convert failed `%v` %s"
,
val
,
err
.
Error
()))
panic
(
fmt
.
Error
f
(
"db value convert failed `%v` %s"
,
val
,
err
.
Error
()))
}
}
list
=
append
(
list
,
value
)
list
=
append
(
list
,
value
)
...
...
orm/db_tables.go
View file @
658a671b
...
@@ -126,7 +126,7 @@ func (t *dbTables) parseRelated(rels []string, depth int) {
...
@@ -126,7 +126,7 @@ func (t *dbTables) parseRelated(rels []string, depth int) {
jtl
=
jt
jtl
=
jt
}
else
{
}
else
{
panic
(
fmt
.
Sprint
f
(
"unknown model/table name `%s`"
,
ex
))
panic
(
fmt
.
Error
f
(
"unknown model/table name `%s`"
,
ex
))
}
}
}
}
}
}
...
...
orm/models_boot.go
View file @
658a671b
...
@@ -14,7 +14,7 @@ func registerModel(model interface{}, prefix string) {
...
@@ -14,7 +14,7 @@ func registerModel(model interface{}, prefix string) {
typ
:=
ind
.
Type
()
typ
:=
ind
.
Type
()
if
val
.
Kind
()
!=
reflect
.
Ptr
{
if
val
.
Kind
()
!=
reflect
.
Ptr
{
panic
(
fmt
.
Sprint
f
(
"<orm.RegisterModel> cannot use non-ptr model struct `%s`"
,
getFullName
(
typ
)))
panic
(
fmt
.
Error
f
(
"<orm.RegisterModel> cannot use non-ptr model struct `%s`"
,
getFullName
(
typ
)))
}
}
table
:=
getTableName
(
val
)
table
:=
getTableName
(
val
)
...
@@ -177,7 +177,7 @@ func bootStrap() {
...
@@ -177,7 +177,7 @@ func bootStrap() {
}
}
}
}
if
added
==
false
{
if
added
==
false
{
panic
(
fmt
.
Sprint
f
(
"cannot generate auto reverse field info `%s` to `%s`"
,
fi
.
fullName
,
ffi
.
fullName
))
panic
(
fmt
.
Error
f
(
"cannot generate auto reverse field info `%s` to `%s`"
,
fi
.
fullName
,
ffi
.
fullName
))
}
}
}
}
}
}
...
...
orm/orm.go
View file @
658a671b
...
@@ -44,13 +44,13 @@ func (o *orm) getMiInd(md interface{}) (mi *modelInfo, ind reflect.Value) {
...
@@ -44,13 +44,13 @@ func (o *orm) getMiInd(md interface{}) (mi *modelInfo, ind reflect.Value) {
ind
=
reflect
.
Indirect
(
val
)
ind
=
reflect
.
Indirect
(
val
)
typ
:=
ind
.
Type
()
typ
:=
ind
.
Type
()
if
val
.
Kind
()
!=
reflect
.
Ptr
{
if
val
.
Kind
()
!=
reflect
.
Ptr
{
panic
(
fmt
.
Sprint
f
(
"<Ormer> cannot use non-ptr model struct `%s`"
,
getFullName
(
typ
)))
panic
(
fmt
.
Error
f
(
"<Ormer> cannot use non-ptr model struct `%s`"
,
getFullName
(
typ
)))
}
}
name
:=
getFullName
(
typ
)
name
:=
getFullName
(
typ
)
if
mi
,
ok
:=
modelCache
.
getByFN
(
name
);
ok
{
if
mi
,
ok
:=
modelCache
.
getByFN
(
name
);
ok
{
return
mi
,
ind
return
mi
,
ind
}
}
panic
(
fmt
.
Sprint
f
(
"<Ormer> table: `%s` not found, maybe not RegisterModel"
,
name
))
panic
(
fmt
.
Error
f
(
"<Ormer> table: `%s` not found, maybe not RegisterModel"
,
name
))
}
}
func
(
o
*
orm
)
Read
(
md
interface
{},
cols
...
string
)
error
{
func
(
o
*
orm
)
Read
(
md
interface
{},
cols
...
string
)
error
{
...
@@ -141,14 +141,14 @@ func (o *orm) QueryTable(ptrStructOrTableName interface{}) (qs QuerySeter) {
...
@@ -141,14 +141,14 @@ func (o *orm) QueryTable(ptrStructOrTableName interface{}) (qs QuerySeter) {
}
}
}
}
if
qs
==
nil
{
if
qs
==
nil
{
panic
(
fmt
.
Sprint
f
(
"<Ormer.QueryTable> table name: `%s` not exists"
,
name
))
panic
(
fmt
.
Error
f
(
"<Ormer.QueryTable> table name: `%s` not exists"
,
name
))
}
}
return
return
}
}
func
(
o
*
orm
)
Using
(
name
string
)
error
{
func
(
o
*
orm
)
Using
(
name
string
)
error
{
if
o
.
isTx
{
if
o
.
isTx
{
panic
(
"<Ormer.Using> transaction has been start, cannot change db"
)
panic
(
fmt
.
Errorf
(
"<Ormer.Using> transaction has been start, cannot change db"
)
)
}
}
if
al
,
ok
:=
dataBaseCache
.
get
(
name
);
ok
{
if
al
,
ok
:=
dataBaseCache
.
get
(
name
);
ok
{
o
.
alias
=
al
o
.
alias
=
al
...
@@ -158,7 +158,7 @@ func (o *orm) Using(name string) error {
...
@@ -158,7 +158,7 @@ func (o *orm) Using(name string) error {
o
.
db
=
al
.
DB
o
.
db
=
al
.
DB
}
}
}
else
{
}
else
{
return
errors
.
New
(
fmt
.
Sprintf
(
"<Ormer.Using> unknown db alias name `%s`"
,
name
)
)
return
fmt
.
Errorf
(
"<Ormer.Using> unknown db alias name `%s`"
,
name
)
}
}
return
nil
return
nil
}
}
...
...
orm/orm_conds.go
View file @
658a671b
package
orm
package
orm
import
(
import
(
"fmt"
"strings"
"strings"
)
)
...
@@ -28,7 +29,7 @@ func NewCondition() *Condition {
...
@@ -28,7 +29,7 @@ func NewCondition() *Condition {
func
(
c
Condition
)
And
(
expr
string
,
args
...
interface
{})
*
Condition
{
func
(
c
Condition
)
And
(
expr
string
,
args
...
interface
{})
*
Condition
{
if
expr
==
""
||
len
(
args
)
==
0
{
if
expr
==
""
||
len
(
args
)
==
0
{
panic
(
"<Condition.And> args cannot empty"
)
panic
(
fmt
.
Errorf
(
"<Condition.And> args cannot empty"
)
)
}
}
c
.
params
=
append
(
c
.
params
,
condValue
{
exprs
:
strings
.
Split
(
expr
,
ExprSep
),
args
:
args
})
c
.
params
=
append
(
c
.
params
,
condValue
{
exprs
:
strings
.
Split
(
expr
,
ExprSep
),
args
:
args
})
return
&
c
return
&
c
...
@@ -36,7 +37,7 @@ func (c Condition) And(expr string, args ...interface{}) *Condition {
...
@@ -36,7 +37,7 @@ func (c Condition) And(expr string, args ...interface{}) *Condition {
func
(
c
Condition
)
AndNot
(
expr
string
,
args
...
interface
{})
*
Condition
{
func
(
c
Condition
)
AndNot
(
expr
string
,
args
...
interface
{})
*
Condition
{
if
expr
==
""
||
len
(
args
)
==
0
{
if
expr
==
""
||
len
(
args
)
==
0
{
panic
(
"<Condition.AndNot> args cannot empty"
)
panic
(
fmt
.
Errorf
(
"<Condition.AndNot> args cannot empty"
)
)
}
}
c
.
params
=
append
(
c
.
params
,
condValue
{
exprs
:
strings
.
Split
(
expr
,
ExprSep
),
args
:
args
,
isNot
:
true
})
c
.
params
=
append
(
c
.
params
,
condValue
{
exprs
:
strings
.
Split
(
expr
,
ExprSep
),
args
:
args
,
isNot
:
true
})
return
&
c
return
&
c
...
@@ -45,7 +46,7 @@ func (c Condition) AndNot(expr string, args ...interface{}) *Condition {
...
@@ -45,7 +46,7 @@ func (c Condition) AndNot(expr string, args ...interface{}) *Condition {
func
(
c
*
Condition
)
AndCond
(
cond
*
Condition
)
*
Condition
{
func
(
c
*
Condition
)
AndCond
(
cond
*
Condition
)
*
Condition
{
c
=
c
.
clone
()
c
=
c
.
clone
()
if
c
==
cond
{
if
c
==
cond
{
panic
(
"cannot use self as sub cond"
)
panic
(
fmt
.
Errorf
(
"<Condition.AndCond> cannot use self as sub cond"
)
)
}
}
if
cond
!=
nil
{
if
cond
!=
nil
{
c
.
params
=
append
(
c
.
params
,
condValue
{
cond
:
cond
,
isCond
:
true
})
c
.
params
=
append
(
c
.
params
,
condValue
{
cond
:
cond
,
isCond
:
true
})
...
@@ -55,7 +56,7 @@ func (c *Condition) AndCond(cond *Condition) *Condition {
...
@@ -55,7 +56,7 @@ func (c *Condition) AndCond(cond *Condition) *Condition {
func
(
c
Condition
)
Or
(
expr
string
,
args
...
interface
{})
*
Condition
{
func
(
c
Condition
)
Or
(
expr
string
,
args
...
interface
{})
*
Condition
{
if
expr
==
""
||
len
(
args
)
==
0
{
if
expr
==
""
||
len
(
args
)
==
0
{
panic
(
"<Condition.Or> args cannot empty"
)
panic
(
fmt
.
Errorf
(
"<Condition.Or> args cannot empty"
)
)
}
}
c
.
params
=
append
(
c
.
params
,
condValue
{
exprs
:
strings
.
Split
(
expr
,
ExprSep
),
args
:
args
,
isOr
:
true
})
c
.
params
=
append
(
c
.
params
,
condValue
{
exprs
:
strings
.
Split
(
expr
,
ExprSep
),
args
:
args
,
isOr
:
true
})
return
&
c
return
&
c
...
@@ -63,7 +64,7 @@ func (c Condition) Or(expr string, args ...interface{}) *Condition {
...
@@ -63,7 +64,7 @@ func (c Condition) Or(expr string, args ...interface{}) *Condition {
func
(
c
Condition
)
OrNot
(
expr
string
,
args
...
interface
{})
*
Condition
{
func
(
c
Condition
)
OrNot
(
expr
string
,
args
...
interface
{})
*
Condition
{
if
expr
==
""
||
len
(
args
)
==
0
{
if
expr
==
""
||
len
(
args
)
==
0
{
panic
(
"<Condition.OrNot> args cannot empty"
)
panic
(
fmt
.
Errorf
(
"<Condition.OrNot> args cannot empty"
)
)
}
}
c
.
params
=
append
(
c
.
params
,
condValue
{
exprs
:
strings
.
Split
(
expr
,
ExprSep
),
args
:
args
,
isNot
:
true
,
isOr
:
true
})
c
.
params
=
append
(
c
.
params
,
condValue
{
exprs
:
strings
.
Split
(
expr
,
ExprSep
),
args
:
args
,
isNot
:
true
,
isOr
:
true
})
return
&
c
return
&
c
...
@@ -72,7 +73,7 @@ func (c Condition) OrNot(expr string, args ...interface{}) *Condition {
...
@@ -72,7 +73,7 @@ func (c Condition) OrNot(expr string, args ...interface{}) *Condition {
func
(
c
*
Condition
)
OrCond
(
cond
*
Condition
)
*
Condition
{
func
(
c
*
Condition
)
OrCond
(
cond
*
Condition
)
*
Condition
{
c
=
c
.
clone
()
c
=
c
.
clone
()
if
c
==
cond
{
if
c
==
cond
{
panic
(
"cannot use self as sub cond"
)
panic
(
fmt
.
Errorf
(
"<Condition.OrCond> cannot use self as sub cond"
)
)
}
}
if
cond
!=
nil
{
if
cond
!=
nil
{
c
.
params
=
append
(
c
.
params
,
condValue
{
cond
:
cond
,
isCond
:
true
,
isOr
:
true
})
c
.
params
=
append
(
c
.
params
,
condValue
{
cond
:
cond
,
isCond
:
true
,
isOr
:
true
})
...
...
orm/orm_object.go
View file @
658a671b
...
@@ -23,10 +23,10 @@ func (o *insertSet) Insert(md interface{}) (int64, error) {
...
@@ -23,10 +23,10 @@ func (o *insertSet) Insert(md interface{}) (int64, error) {
typ
:=
ind
.
Type
()
typ
:=
ind
.
Type
()
name
:=
getFullName
(
typ
)
name
:=
getFullName
(
typ
)
if
val
.
Kind
()
!=
reflect
.
Ptr
{
if
val
.
Kind
()
!=
reflect
.
Ptr
{
panic
(
fmt
.
Sprint
f
(
"<Inserter.Insert> cannot use non-ptr model struct `%s`"
,
name
))
panic
(
fmt
.
Error
f
(
"<Inserter.Insert> cannot use non-ptr model struct `%s`"
,
name
))
}
}
if
name
!=
o
.
mi
.
fullName
{
if
name
!=
o
.
mi
.
fullName
{
panic
(
fmt
.
Sprint
f
(
"<Inserter.Insert> need model `%s` but found `%s`"
,
o
.
mi
.
fullName
,
name
))
panic
(
fmt
.
Error
f
(
"<Inserter.Insert> need model `%s` but found `%s`"
,
o
.
mi
.
fullName
,
name
))
}
}
id
,
err
:=
o
.
orm
.
alias
.
DbBaser
.
InsertStmt
(
o
.
stmt
,
o
.
mi
,
ind
,
o
.
orm
.
alias
.
TZ
)
id
,
err
:=
o
.
orm
.
alias
.
DbBaser
.
InsertStmt
(
o
.
stmt
,
o
.
mi
,
ind
,
o
.
orm
.
alias
.
TZ
)
if
err
!=
nil
{
if
err
!=
nil
{
...
...
orm/orm_queryset.go
View file @
658a671b
...
@@ -67,7 +67,7 @@ func (o querySet) RelatedSel(params ...interface{}) QuerySeter {
...
@@ -67,7 +67,7 @@ func (o querySet) RelatedSel(params ...interface{}) QuerySeter {
case
int
:
case
int
:
o
.
relDepth
=
val
o
.
relDepth
=
val
default
:
default
:
panic
(
fmt
.
Sprint
f
(
"<QuerySeter.RelatedSel> wrong param kind: %v"
,
val
))
panic
(
fmt
.
Error
f
(
"<QuerySeter.RelatedSel> wrong param kind: %v"
,
val
))
}
}
}
}
}
}
...
...
orm/orm_raw.go
View file @
658a671b
...
@@ -314,7 +314,7 @@ func (o *rawSet) loopSetRefs(refs []interface{}, sIdxes [][]int, sInds []reflect
...
@@ -314,7 +314,7 @@ func (o *rawSet) loopSetRefs(refs []interface{}, sIdxes [][]int, sInds []reflect
func
(
o
*
rawSet
)
QueryRow
(
containers
...
interface
{})
error
{
func
(
o
*
rawSet
)
QueryRow
(
containers
...
interface
{})
error
{
if
len
(
containers
)
==
0
{
if
len
(
containers
)
==
0
{
panic
(
"<RawSeter.QueryRow> need at least one arg"
)
panic
(
fmt
.
Errorf
(
"<RawSeter.QueryRow> need at least one arg"
)
)
}
}
refs
:=
make
([]
interface
{},
0
,
len
(
containers
))
refs
:=
make
([]
interface
{},
0
,
len
(
containers
))
...
@@ -327,7 +327,7 @@ func (o *rawSet) QueryRow(containers ...interface{}) error {
...
@@ -327,7 +327,7 @@ func (o *rawSet) QueryRow(containers ...interface{}) error {
ind
:=
reflect
.
Indirect
(
val
)
ind
:=
reflect
.
Indirect
(
val
)
if
val
.
Kind
()
!=
reflect
.
Ptr
{
if
val
.
Kind
()
!=
reflect
.
Ptr
{
panic
(
"<RawSeter.QueryRow> all args must be use ptr"
)
panic
(
fmt
.
Errorf
(
"<RawSeter.QueryRow> all args must be use ptr"
)
)
}
}
etyp
:=
ind
.
Type
()
etyp
:=
ind
.
Type
()
...
@@ -377,7 +377,7 @@ func (o *rawSet) QueryRows(containers ...interface{}) (int64, error) {
...
@@ -377,7 +377,7 @@ func (o *rawSet) QueryRows(containers ...interface{}) (int64, error) {
val
:=
reflect
.
ValueOf
(
container
)
val
:=
reflect
.
ValueOf
(
container
)
sInd
:=
reflect
.
Indirect
(
val
)
sInd
:=
reflect
.
Indirect
(
val
)
if
val
.
Kind
()
!=
reflect
.
Ptr
||
sInd
.
Kind
()
!=
reflect
.
Slice
{
if
val
.
Kind
()
!=
reflect
.
Ptr
||
sInd
.
Kind
()
!=
reflect
.
Slice
{
panic
(
"<RawSeter.QueryRows> all args must be use ptr slice"
)
panic
(
fmt
.
Errorf
(
"<RawSeter.QueryRows> all args must be use ptr slice"
)
)
}
}
etyp
:=
sInd
.
Type
()
.
Elem
()
etyp
:=
sInd
.
Type
()
.
Elem
()
...
@@ -440,7 +440,7 @@ func (o *rawSet) readValues(container interface{}) (int64, error) {
...
@@ -440,7 +440,7 @@ func (o *rawSet) readValues(container interface{}) (int64, error) {
case
*
ParamsList
:
case
*
ParamsList
:
typ
=
3
typ
=
3
default
:
default
:
panic
(
fmt
.
Sprint
f
(
"<RawSeter> unsupport read values type `%T`"
,
container
))
panic
(
fmt
.
Error
f
(
"<RawSeter> unsupport read values type `%T`"
,
container
))
}
}
query
:=
o
.
query
query
:=
o
.
query
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment