Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
public
/
sequelize
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
不要怂,就是干,撸起袖子干!
Commit 16e13f6c
authored
May 21, 2013
by
sevastos
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Enable the override of the default attributes
1 parent
b14ecc52
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
39 additions
and
3 deletions
lib/dao-factory.js
lib/dialects/postgres/query-generator.js
lib/dialects/sqlite/query-generator.js
spec/sequelize.spec.js
lib/dao-factory.js
View file @
16e13f6
...
...
@@ -481,7 +481,9 @@ module.exports = (function() {
}
Utils
.
_
.
each
(
defaultAttributes
,
function
(
value
,
attr
)
{
self
.
rawAttributes
[
attr
]
=
value
if
(
Utils
.
_
.
isUndefined
(
self
.
rawAttributes
[
attr
]))
{
self
.
rawAttributes
[
attr
]
=
value
}
})
}
...
...
lib/dialects/postgres/query-generator.js
View file @
16e13f6
...
...
@@ -726,9 +726,15 @@ module.exports = (function() {
}
if
(
Utils
.
_
.
includes
(
dataType
,
'SERIAL'
))
{
dataType
=
dataType
.
replace
(
/INTEGER/
,
''
)
if
(
Utils
.
_
.
includes
(
dataType
,
'BIGINT'
))
{
dataType
=
dataType
.
replace
(
/SERIAL/
,
'BIGSERIAL'
)
dataType
=
dataType
.
replace
(
/BIGINT/
,
''
)
tables
[
tableName
][
attr
]
=
'bigserial'
}
else
{
dataType
=
dataType
.
replace
(
/INTEGER/
,
''
)
tables
[
tableName
][
attr
]
=
'serial'
}
dataType
=
dataType
.
replace
(
/NOT NULL/
,
''
)
tables
[
tableName
][
attr
]
=
'serial'
}
if
(
dataType
.
match
(
/^ENUM
\(
/
))
{
...
...
lib/dialects/sqlite/query-generator.js
View file @
16e13f6
...
...
@@ -76,6 +76,10 @@ module.exports = (function() {
if
(
attributes
.
hasOwnProperty
(
attr
))
{
var
dataType
=
attributes
[
attr
]
if
(
Utils
.
_
.
includes
(
dataType
,
'AUTOINCREMENT'
))
{
dataType
=
dataType
.
replace
(
/BIGINT/
,
'INTEGER'
)
}
if
(
Utils
.
_
.
includes
(
dataType
,
'PRIMARY KEY'
)
&&
needsMultiplePrimaryKeys
)
{
primaryKeys
.
push
(
attr
)
attrStr
.
push
(
Utils
.
addTicks
(
attr
)
+
" "
+
dataType
.
replace
(
/PRIMARY KEY/
,
'NOT NULL'
))
...
...
spec/sequelize.spec.js
View file @
16e13f6
...
...
@@ -194,5 +194,29 @@ describe(Helpers.getTestDialectTeaser("Sequelize"), function() {
})
})
})
describe
(
'table'
,
function
()
{
[
{
id
:
{
type
:
Helpers
.
Sequelize
.
BIGINT
}
},
{
id
:
{
type
:
Helpers
.
Sequelize
.
STRING
,
allowNull
:
true
}
},
{
id
:
{
type
:
Helpers
.
Sequelize
.
BIGINT
,
allowNull
:
false
,
primaryKey
:
true
,
autoIncrement
:
true
}
}
].
forEach
(
function
(
customAttributes
)
{
it
(
'should be able to override options on the default attributes'
,
function
(
done
)
{
var
Picture
=
this
.
sequelize
.
define
(
'picture'
,
Helpers
.
Sequelize
.
Utils
.
_
.
cloneDeep
(
customAttributes
))
Picture
.
sync
({
force
:
true
}).
success
(
function
()
{
Object
.
keys
(
customAttributes
).
forEach
(
function
(
attribute
)
{
Object
.
keys
(
customAttributes
[
attribute
]).
forEach
(
function
(
option
)
{
var
optionValue
=
customAttributes
[
attribute
][
option
];
expect
(
Picture
.
rawAttributes
[
attribute
][
option
]).
toBe
(
optionValue
)
});
})
done
()
})
})
})
})
})
})
Write
Preview
Markdown
is supported
Attach a file
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 post a comment