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
56aa224a
Commit
56aa224a
authored
Aug 31, 2016
by
astaxie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
simplfy the code
parent
8c37a07a
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
18 deletions
+9
-18
models_info_f.go
orm/models_info_f.go
+3
-3
models_utils.go
orm/models_utils.go
+6
-15
No files found.
orm/models_info_f.go
View file @
56aa224a
...
...
@@ -143,7 +143,7 @@ func newFieldInfo(mi *modelInfo, field reflect.Value, sf reflect.StructField, mN
var
(
tag
string
tagValue
string
initial
StrTo
initial
StrTo
// store the default value
fieldType
int
attrs
map
[
string
]
bool
tags
map
[
string
]
string
...
...
@@ -215,7 +215,7 @@ checkType:
}
break
checkType
default
:
err
=
fmt
.
Errorf
(
"
error
"
)
err
=
fmt
.
Errorf
(
"
rel only allow these value: fk, one, m2m
"
)
goto
wrongTag
}
}
...
...
@@ -235,7 +235,7 @@ checkType:
}
break
checkType
default
:
err
=
fmt
.
Errorf
(
"
error
"
)
err
=
fmt
.
Errorf
(
"
reverse only allow these value: one, many
"
)
goto
wrongTag
}
}
...
...
orm/models_utils.go
View file @
56aa224a
...
...
@@ -70,11 +70,8 @@ func getTableEngine(val reflect.Value) string {
fun
:=
val
.
MethodByName
(
"TableEngine"
)
if
fun
.
IsValid
()
{
vals
:=
fun
.
Call
([]
reflect
.
Value
{})
if
len
(
vals
)
>
0
{
val
:=
vals
[
0
]
if
val
.
Kind
()
==
reflect
.
String
{
return
val
.
String
()
}
if
len
(
vals
)
>
0
&&
vals
[
0
]
.
Kind
()
==
reflect
.
String
{
return
vals
[
0
]
.
String
()
}
}
return
""
...
...
@@ -85,15 +82,12 @@ func getTableIndex(val reflect.Value) [][]string {
fun
:=
val
.
MethodByName
(
"TableIndex"
)
if
fun
.
IsValid
()
{
vals
:=
fun
.
Call
([]
reflect
.
Value
{})
if
len
(
vals
)
>
0
{
val
:=
vals
[
0
]
if
val
.
CanInterface
()
{
if
d
,
ok
:=
val
.
Interface
()
.
([][]
string
);
ok
{
if
len
(
vals
)
>
0
&&
vals
[
0
]
.
CanInterface
()
{
if
d
,
ok
:=
vals
[
0
]
.
Interface
()
.
([][]
string
);
ok
{
return
d
}
}
}
}
return
nil
}
...
...
@@ -102,15 +96,12 @@ func getTableUnique(val reflect.Value) [][]string {
fun
:=
val
.
MethodByName
(
"TableUnique"
)
if
fun
.
IsValid
()
{
vals
:=
fun
.
Call
([]
reflect
.
Value
{})
if
len
(
vals
)
>
0
{
val
:=
vals
[
0
]
if
val
.
CanInterface
()
{
if
d
,
ok
:=
val
.
Interface
()
.
([][]
string
);
ok
{
if
len
(
vals
)
>
0
&&
vals
[
0
]
.
CanInterface
()
{
if
d
,
ok
:=
vals
[
0
]
.
Interface
()
.
([][]
string
);
ok
{
return
d
}
}
}
}
return
nil
}
...
...
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