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
94f7ba8b
Commit
94f7ba8b
authored
Aug 22, 2013
by
slene
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
orm add uint uint32 uint64 auto increment support
parent
7d7c9825
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
13 additions
and
12 deletions
+13
-12
cmd_utils.go
orm/cmd_utils.go
+3
-2
db_sqlite.go
orm/db_sqlite.go
+1
-1
models.go
orm/models.go
+0
-1
models_boot.go
orm/models_boot.go
+1
-1
models_info_f.go
orm/models_info_f.go
+2
-7
models_test.go
orm/models_test.go
+5
-0
orm_test.go
orm/orm_test.go
+1
-0
No files found.
orm/cmd_utils.go
View file @
94f7ba8b
...
...
@@ -102,9 +102,10 @@ func getDbCreateSql(al *alias) (sqls []string) {
}
if
fi
.
auto
{
if
al
.
Driver
==
DR_Postgres
{
switch
al
.
Driver
{
case
DR_Sqlite
,
DR_Postgres
:
column
+=
T
[
"auto"
]
}
else
{
default
:
column
+=
col
+
" "
+
T
[
"auto"
]
}
}
else
if
fi
.
pk
{
...
...
orm/db_sqlite.go
View file @
94f7ba8b
...
...
@@ -20,7 +20,7 @@ var sqliteOperators = map[string]string{
}
var
sqliteTypes
=
map
[
string
]
string
{
"auto"
:
"NOT NULL PRIMARY KEY AUTOINCREMENT"
,
"auto"
:
"
integer
NOT NULL PRIMARY KEY AUTOINCREMENT"
,
"pk"
:
"NOT NULL PRIMARY KEY"
,
"bool"
:
"bool"
,
"string"
:
"varchar(%d)"
,
...
...
orm/models.go
View file @
94f7ba8b
...
...
@@ -20,7 +20,6 @@ var (
supportTag
=
map
[
string
]
int
{
"-"
:
1
,
"null"
:
1
,
"blank"
:
1
,
"index"
:
1
,
"unique"
:
1
,
"pk"
:
1
,
...
...
orm/models_boot.go
View file @
94f7ba8b
...
...
@@ -42,7 +42,7 @@ func registerModel(model interface{}, prefix string) {
if
fi
.
name
==
"Id"
{
if
fi
.
sf
.
Tag
.
Get
(
defaultStructTagName
)
==
""
{
switch
fi
.
addrValue
.
Elem
()
.
Kind
()
{
case
reflect
.
Int
,
reflect
.
Int
64
,
reflect
.
Int32
:
case
reflect
.
Int
,
reflect
.
Int
32
,
reflect
.
Int64
,
reflect
.
Uint
,
reflect
.
Uint32
,
reflect
.
Uint64
:
fi
.
auto
=
true
fi
.
pk
=
true
info
.
fields
.
pk
=
fi
...
...
orm/models_info_f.go
View file @
94f7ba8b
...
...
@@ -93,7 +93,6 @@ type fieldInfo struct {
auto
bool
pk
bool
null
bool
blank
bool
index
bool
unique
bool
initial
StrTo
...
...
@@ -248,7 +247,6 @@ checkType:
fi
.
fullName
=
mi
.
fullName
+
"."
+
sf
.
Name
fi
.
null
=
attrs
[
"null"
]
fi
.
blank
=
attrs
[
"blank"
]
fi
.
index
=
attrs
[
"index"
]
fi
.
auto
=
attrs
[
"auto"
]
fi
.
pk
=
attrs
[
"pk"
]
...
...
@@ -257,7 +255,6 @@ checkType:
switch
fieldType
{
case
RelManyToMany
,
RelReverseMany
,
RelReverseOne
:
fi
.
null
=
false
fi
.
blank
=
false
fi
.
index
=
false
fi
.
auto
=
false
fi
.
pk
=
false
...
...
@@ -360,22 +357,20 @@ checkType:
if
fi
.
auto
{
switch
addrField
.
Elem
()
.
Kind
()
{
case
reflect
.
Int
,
reflect
.
Int32
,
reflect
.
Int64
:
case
reflect
.
Int
,
reflect
.
Int32
,
reflect
.
Int64
,
reflect
.
Uint
,
reflect
.
Uint32
,
reflect
.
Uint64
:
default
:
err
=
fmt
.
Errorf
(
"auto primary key only support int, int32, int64, but found `%s`"
,
addrField
.
Elem
()
.
Kind
())
err
=
fmt
.
Errorf
(
"auto primary key only support int, int32, int64,
uint, uint32, uint64
but found `%s`"
,
addrField
.
Elem
()
.
Kind
())
goto
end
}
fi
.
pk
=
true
}
fi
.
null
=
false
fi
.
blank
=
false
fi
.
index
=
false
fi
.
unique
=
false
}
if
fi
.
unique
{
fi
.
blank
=
false
fi
.
index
=
false
}
...
...
orm/models_test.go
View file @
94f7ba8b
...
...
@@ -58,6 +58,11 @@ type DataNull struct {
Decimal
float64
`orm:"digits(8);decimals(4);null"`
}
// only for mysql
type
UserBig
struct
{
Id
uint64
}
type
User
struct
{
Id
int
UserName
string
`orm:"size(30);unique"`
...
...
orm/orm_test.go
View file @
94f7ba8b
...
...
@@ -196,6 +196,7 @@ func TestSyncDb(t *testing.T) {
RegisterModel
(
new
(
Post
))
RegisterModel
(
new
(
Tag
))
RegisterModel
(
new
(
Comment
))
RegisterModel
(
new
(
UserBig
))
BootStrap
()
...
...
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